mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-05 23:18:47 +00:00
glcontext_egl: add method to check if format supports a modifier
Makes _check_modifier from glupload reusable. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6792>
This commit is contained in:
parent
d80477d769
commit
270e186311
3 changed files with 57 additions and 35 deletions
|
@ -57,6 +57,14 @@
|
||||||
#include "../viv-fb/gstglwindow_viv_fb_egl.h"
|
#include "../viv-fb/gstglwindow_viv_fb_egl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GST_GL_HAVE_DMABUF
|
||||||
|
#ifdef HAVE_LIBDRM
|
||||||
|
#include <drm_fourcc.h>
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define DRM_FORMAT_MOD_LINEAR 0ULL
|
||||||
|
#endif
|
||||||
|
|
||||||
#define GST_CAT_DEFAULT gst_gl_context_debug
|
#define GST_CAT_DEFAULT gst_gl_context_debug
|
||||||
|
|
||||||
typedef struct _GstGLDmaFormat GstGLDmaFormat;
|
typedef struct _GstGLDmaFormat GstGLDmaFormat;
|
||||||
|
@ -1830,6 +1838,48 @@ beach:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_gl_context_egl_format_supports_modifier: (skip)
|
||||||
|
* @context: an EGL #GstGLContext
|
||||||
|
* @fourcc: the FourCC format to look up
|
||||||
|
* @modifier: the format modifier to check
|
||||||
|
* @include_externam: whether to take external-only modifiers into account
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if @fourcc supports @modifier.
|
||||||
|
*
|
||||||
|
* Since: 1.26
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_gl_context_egl_format_supports_modifier (GstGLContext * context,
|
||||||
|
guint32 fourcc, guint64 modifier, gboolean include_external)
|
||||||
|
{
|
||||||
|
#if GST_GL_HAVE_DMABUF
|
||||||
|
const GArray *dma_modifiers;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_GL_CONTEXT_EGL (context), FALSE);
|
||||||
|
|
||||||
|
if (!gst_gl_context_egl_get_format_modifiers (context, fourcc,
|
||||||
|
&dma_modifiers))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!dma_modifiers) {
|
||||||
|
/* fourcc found, but no modifier info; consider only linear is supported */
|
||||||
|
return (modifier == DRM_FORMAT_MOD_LINEAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < dma_modifiers->len; i++) {
|
||||||
|
GstGLDmaModifier *mod = &g_array_index (dma_modifiers, GstGLDmaModifier, i);
|
||||||
|
|
||||||
|
if (!mod->external_only || include_external) {
|
||||||
|
if (mod->modifier == modifier)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_gl_context_egl_supports_modifier: (skip)
|
* gst_gl_context_egl_supports_modifier: (skip)
|
||||||
* @context: an EGL #GStGLContext
|
* @context: an EGL #GStGLContext
|
||||||
|
|
|
@ -113,6 +113,13 @@ G_GNUC_INTERNAL
|
||||||
gboolean gst_gl_context_egl_get_format_modifiers (GstGLContext * context,
|
gboolean gst_gl_context_egl_get_format_modifiers (GstGLContext * context,
|
||||||
gint fourcc,
|
gint fourcc,
|
||||||
const GArray ** modifiers);
|
const GArray ** modifiers);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
gboolean gst_gl_context_egl_format_supports_modifier (GstGLContext * context,
|
||||||
|
guint32 fourcc,
|
||||||
|
guint64 modifier,
|
||||||
|
gboolean include_external);
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
gboolean gst_gl_context_egl_supports_modifier (GstGLContext * context);
|
gboolean gst_gl_context_egl_supports_modifier (GstGLContext * context);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -867,41 +867,6 @@ _dma_buf_upload_new (GstGLUpload * upload)
|
||||||
return dmabuf;
|
return dmabuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_check_modifier (GstGLContext * context, guint32 fourcc,
|
|
||||||
guint64 modifier, gboolean include_external)
|
|
||||||
{
|
|
||||||
const GArray *dma_modifiers;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
/* If no context provide, no further check. */
|
|
||||||
if (!context)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
if (!gst_gl_context_egl_get_format_modifiers (context, fourcc,
|
|
||||||
&dma_modifiers))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (!dma_modifiers) {
|
|
||||||
/* recognize the fourcc but no modifier info, consider it as linear */
|
|
||||||
if (modifier == DRM_FORMAT_MOD_LINEAR)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < dma_modifiers->len; i++) {
|
|
||||||
GstGLDmaModifier *mod = &g_array_index (dma_modifiers, GstGLDmaModifier, i);
|
|
||||||
|
|
||||||
if (!mod->external_only || include_external) {
|
|
||||||
if (mod->modifier == modifier)
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_default_formats_list (GstStructure * structure)
|
_set_default_formats_list (GstStructure * structure)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue