va: allocator: Add hack for no fourcc when surface creation.

This patch adds general mechanism for handling specific hacks. In this
case for jpeg decoder in i965 driver, which cannot create surfaces
with fourcc specified.

From jpeg decoder to the allocator, which creates the surfaces,
there's a non-simple path: basedec pseudo-class adds a hacks guint32
which will be set by actual elements (vajpegdec, in this case) and
basedec will always set the hack to the allocator when the allocator
is instantiated.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1575>
This commit is contained in:
Víctor Manuel Jáquez Leal 2022-06-24 19:42:36 +02:00 committed by GStreamer Marge Bot
parent ffd94a98be
commit ec55017a83
5 changed files with 27 additions and 1 deletions

View file

@ -32,6 +32,12 @@ typedef enum
GST_VA_FEATURE_AUTO, GST_VA_FEATURE_AUTO,
} GstVaFeature; } GstVaFeature;
enum
{
/* jpeg decoder in i965 driver cannot create surfaces with fourcc */
GST_VA_HACK_SURFACE_NO_FOURCC = 1 << 0,
};
#include <gst/va/va-prelude.h> #include <gst/va/va-prelude.h>
#include <gst/va/va-enumtypes.h> #include <gst/va/va-enumtypes.h>
#include <gst/va/gstvadisplay.h> #include <gst/va/gstvadisplay.h>

View file

@ -951,6 +951,8 @@ struct _GstVaAllocator
GstVideoInfo info; GstVideoInfo info;
guint usage_hint; guint usage_hint;
guint32 hacks;
GstVaSurfaceCopy *copy; GstVaSurfaceCopy *copy;
GstVaMemoryPool pool; GstVaMemoryPool pool;
@ -1556,7 +1558,8 @@ gst_va_allocator_try (GstAllocator * allocator)
self->fourcc = 0; self->fourcc = 0;
self->rt_format = gst_va_chroma_from_video_format (self->img_format); self->rt_format = gst_va_chroma_from_video_format (self->img_format);
} else { } else {
self->fourcc = gst_va_fourcc_from_video_format (self->surface_format); if (G_LIKELY (!(self->hacks & GST_VA_HACK_SURFACE_NO_FOURCC)))
self->fourcc = gst_va_fourcc_from_video_format (self->surface_format);
self->rt_format = gst_va_chroma_from_video_format (self->surface_format); self->rt_format = gst_va_chroma_from_video_format (self->surface_format);
} }
@ -1641,6 +1644,17 @@ gst_va_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info,
return TRUE; return TRUE;
} }
void
gst_va_allocator_set_hacks (GstAllocator * allocator, guint32 hacks)
{
GstVaAllocator *self;
g_return_if_fail (GST_IS_VA_ALLOCATOR (allocator));
self = GST_VA_ALLOCATOR (allocator);
self->hacks = hacks;
}
/*============ Utilities =====================================================*/ /*============ Utilities =====================================================*/
VASurfaceID VASurfaceID

View file

@ -101,6 +101,9 @@ gboolean gst_va_allocator_get_format (GstAllocator * alloca
GstVideoInfo * info, GstVideoInfo * info,
guint * usage_hint, guint * usage_hint,
GstVaFeature * use_derived); GstVaFeature * use_derived);
GST_VA_API
void gst_va_allocator_set_hacks (GstAllocator * allocator,
guint32 hack);
GST_VA_API GST_VA_API
VASurfaceID gst_va_memory_get_surface (GstMemory * mem); VASurfaceID gst_va_memory_get_surface (GstMemory * mem);

View file

@ -228,6 +228,7 @@ _create_allocator (GstVaBaseDec * base, GstCaps * caps)
GArray *surface_formats = GArray *surface_formats =
gst_va_decoder_get_surface_formats (base->decoder); gst_va_decoder_get_surface_formats (base->decoder);
allocator = gst_va_allocator_new (base->display, surface_formats); allocator = gst_va_allocator_new (base->display, surface_formats);
gst_va_allocator_set_hacks (allocator, base->hacks);
} }
return allocator; return allocator;

View file

@ -83,6 +83,8 @@ struct _GstVaBaseDec
GstVideoConverter *convert; GstVideoConverter *convert;
gboolean need_negotiation; gboolean need_negotiation;
guint32 hacks;
}; };
struct _GstVaBaseDecClass struct _GstVaBaseDecClass