gl: context_egl: Add a helper to list all supported fourcc/modifiers
This helper creates a GST_TYPE_LIST of all possible DRM formats that the context can support. This will be needed to fix support for formats that aren't emulated using GStreamer shaders. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9306>
This commit is contained in:
parent
ef98722709
commit
c475088501
@ -1892,6 +1892,58 @@ gst_gl_context_egl_format_supports_modifier (GstGLContext * context,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_gl_context_egl_format_list_all_drm_formats:
|
||||
* @context: an EGL #GstGLContext
|
||||
* @drm_fmt_list: a #GValue initialized to hold %GST_TYPE_LIST
|
||||
*
|
||||
* Append all fourcc/modifier pair supported for this egl context. This is
|
||||
* useful when implementating direct dmabuf upload as all the formats can be
|
||||
* processed as RGBA in this case.
|
||||
*
|
||||
* Since 1.28
|
||||
*/
|
||||
void
|
||||
gst_gl_context_egl_format_list_all_drm_formats (GstGLContext * context,
|
||||
GValue * drm_fmt_list)
|
||||
{
|
||||
#if GST_GL_HAVE_DMABUF
|
||||
GstGLContextEGL *egl;
|
||||
|
||||
g_return_if_fail (GST_IS_GL_CONTEXT_EGL (context));
|
||||
g_return_if_fail (GST_VALUE_HOLDS_LIST (drm_fmt_list));
|
||||
|
||||
if (!gst_gl_context_egl_fetch_dma_formats (context))
|
||||
return;
|
||||
|
||||
egl = GST_GL_CONTEXT_EGL (context);
|
||||
|
||||
GST_OBJECT_LOCK (context);
|
||||
if (!egl->dma_formats)
|
||||
goto beach;
|
||||
|
||||
for (gint i = 0; i < egl->dma_formats->len; i++) {
|
||||
GstGLDmaFormat *format;
|
||||
format = &g_array_index (egl->dma_formats, GstGLDmaFormat, i);
|
||||
|
||||
for (gint j = 0; j < format->modifiers->len; j++) {
|
||||
GstGLDmaModifier *modifier;
|
||||
GValue value = G_VALUE_INIT;
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
|
||||
modifier = &g_array_index (format->modifiers, GstGLDmaModifier, j);
|
||||
gchar *drm_fmt_str = gst_video_dma_drm_fourcc_to_string (format->fourcc,
|
||||
modifier->modifier);
|
||||
g_value_take_string (&value, drm_fmt_str);
|
||||
gst_value_list_append_and_take_value (drm_fmt_list, &value);
|
||||
}
|
||||
}
|
||||
|
||||
beach:
|
||||
GST_OBJECT_UNLOCK (context);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_gl_context_egl_supports_modifier: (skip)
|
||||
* @context: an EGL #GStGLContext
|
||||
|
@ -120,6 +120,10 @@ gboolean gst_gl_context_egl_format_supports_modifier (GstGLContext *
|
||||
guint64 modifier,
|
||||
gboolean include_external);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void gst_gl_context_egl_format_list_all_drm_formats (GstGLContext * context,
|
||||
GValue *drm_fmt_list);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
gboolean gst_gl_context_egl_supports_modifier (GstGLContext * context);
|
||||
G_END_DECLS
|
||||
|
Loading…
x
Reference in New Issue
Block a user