From ec55017a83d99d40cad63068ac63a51a24bc6e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Fri, 24 Jun 2022 19:42:36 +0200 Subject: [PATCH] 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: --- .../gst-plugins-bad/gst-libs/gst/va/gstva.h | 6 ++++++ .../gst-libs/gst/va/gstvaallocator.c | 16 +++++++++++++++- .../gst-libs/gst/va/gstvaallocator.h | 3 +++ .../gst-plugins-bad/sys/va/gstvabasedec.c | 1 + .../gst-plugins-bad/sys/va/gstvabasedec.h | 2 ++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstva.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstva.h index b3c4f5cee9..0736fc9934 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstva.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstva.h @@ -32,6 +32,12 @@ typedef enum GST_VA_FEATURE_AUTO, } GstVaFeature; +enum +{ + /* jpeg decoder in i965 driver cannot create surfaces with fourcc */ + GST_VA_HACK_SURFACE_NO_FOURCC = 1 << 0, +}; + #include #include #include diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c index fb26ef7052..29e106a661 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c @@ -951,6 +951,8 @@ struct _GstVaAllocator GstVideoInfo info; guint usage_hint; + guint32 hacks; + GstVaSurfaceCopy *copy; GstVaMemoryPool pool; @@ -1556,7 +1558,8 @@ gst_va_allocator_try (GstAllocator * allocator) self->fourcc = 0; self->rt_format = gst_va_chroma_from_video_format (self->img_format); } 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); } @@ -1641,6 +1644,17 @@ gst_va_allocator_get_format (GstAllocator * allocator, GstVideoInfo * info, 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 =====================================================*/ VASurfaceID diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h index 79f84c0e2a..f6d883c680 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h @@ -101,6 +101,9 @@ gboolean gst_va_allocator_get_format (GstAllocator * alloca GstVideoInfo * info, guint * usage_hint, GstVaFeature * use_derived); +GST_VA_API +void gst_va_allocator_set_hacks (GstAllocator * allocator, + guint32 hack); GST_VA_API VASurfaceID gst_va_memory_get_surface (GstMemory * mem); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c index 957bf07fec..fdd469f4c8 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c @@ -228,6 +228,7 @@ _create_allocator (GstVaBaseDec * base, GstCaps * caps) GArray *surface_formats = gst_va_decoder_get_surface_formats (base->decoder); allocator = gst_va_allocator_new (base->display, surface_formats); + gst_va_allocator_set_hacks (allocator, base->hacks); } return allocator; diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h index 048d7ac5b2..cfe5a3a759 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.h @@ -83,6 +83,8 @@ struct _GstVaBaseDec GstVideoConverter *convert; gboolean need_negotiation; + + guint32 hacks; }; struct _GstVaBaseDecClass