va: allocator: Add hack for no fourcc when surface creation.
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Fri, 24 Jun 2022 17:42:36 +0000 (19:42 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 27 Jun 2022 13:43:14 +0000 (13:43 +0000)
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>

subprojects/gst-plugins-bad/gst-libs/gst/va/gstva.h
subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c
subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.h
subprojects/gst-plugins-bad/sys/va/gstvabasedec.c
subprojects/gst-plugins-bad/sys/va/gstvabasedec.h

index b3c4f5c..0736fc9 100644 (file)
@@ -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 <gst/va/va-prelude.h>
 #include <gst/va/va-enumtypes.h>
 #include <gst/va/gstvadisplay.h>
index fb26ef7..29e106a 100644 (file)
@@ -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
index 79f84c0..f6d883c 100644 (file)
@@ -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);
index 957bf07..fdd469f 100644 (file)
@@ -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;
index 048d7ac..cfe5a3a 100644 (file)
@@ -83,6 +83,8 @@ struct _GstVaBaseDec
   GstVideoConverter *convert;
 
   gboolean need_negotiation;
+
+  guint32 hacks;
 };
 
 struct _GstVaBaseDecClass