va: allocator: try to create surface without fourcc but chroma only
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Sat, 12 Sep 2020 11:10:18 +0000 (13:10 +0200)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 23 Sep 2020 16:19:22 +0000 (18:19 +0200)
There are, in VPP, surfaces that doesn't support 4:2:2 fourccs but it
supports the chroma. So this patch gives that opportunity to the
driver.

This patch also simplifiies
gst_va_video_surface_format_from_image_format() to just an iterator
for surfaces available formats.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1529>

sys/va/gstvaallocator.c
sys/va/gstvavideoformat.c

index f6d90e5..8747347 100644 (file)
@@ -885,7 +885,7 @@ gst_va_allocator_alloc (GstAllocator * allocator,
 {
   GstVaAllocator *self;
   GstVaMemory *mem;
-  GstVideoFormat format;
+  GstVideoFormat format, img_format;
   VAImage image = { 0, };
   VASurfaceID surface;
   guint32 fourcc, rt_format;
@@ -894,20 +894,22 @@ gst_va_allocator_alloc (GstAllocator * allocator,
 
   self = GST_VA_ALLOCATOR (allocator);
 
-  format =
-      gst_va_video_surface_format_from_image_format (GST_VIDEO_INFO_FORMAT
-      (&params->info), self->surface_formats);
+  img_format = GST_VIDEO_INFO_FORMAT (&params->info);
+
+  format = gst_va_video_surface_format_from_image_format (img_format,
+      self->surface_formats);
   if (format == GST_VIDEO_FORMAT_UNKNOWN) {
-    GST_ERROR_OBJECT (allocator, "Unsupported format: %s",
-        gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&params->info)));
-    return NULL;
+    /* try a surface without fourcc but rt_format only */
+    fourcc = 0;
+    rt_format = gst_va_chroma_from_video_format (img_format);
+  } else {
+    fourcc = gst_va_fourcc_from_video_format (format);
+    rt_format = gst_va_chroma_from_video_format (format);
   }
 
-  fourcc = gst_va_fourcc_from_video_format (format);
-  rt_format = gst_va_chroma_from_video_format (format);
-  if (fourcc == 0 || rt_format == 0) {
-    GST_ERROR_OBJECT (allocator, "Unsupported format: %s",
-        gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&params->info)));
+  if (rt_format == 0) {
+    GST_ERROR_OBJECT (allocator, "Unsupported image format: %s",
+        gst_video_format_to_string (img_format));
     return NULL;
   }
 
index 7e42bca..6acb001 100644 (file)
@@ -210,7 +210,7 @@ gst_va_video_surface_format_from_image_format (GstVideoFormat image_format,
     GArray * surface_formats)
 {
   GstVideoFormat surface_format;
-  guint i, image_chroma, surface_chroma;
+  guint i, image_chroma;
 
   if (image_format == GST_VIDEO_FORMAT_UNKNOWN)
     return GST_VIDEO_FORMAT_UNKNOWN;
@@ -227,11 +227,6 @@ gst_va_video_surface_format_from_image_format (GstVideoFormat image_format,
 
     if (surface_format == image_format)
       return surface_format;
-
-    surface_chroma = gst_va_chroma_from_video_format (surface_format);
-
-    if (surface_chroma == image_chroma)
-      return surface_format;
   }
 
   return GST_VIDEO_FORMAT_UNKNOWN;