va: postproc: Get info from caps in decide_allocation()
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 20 Apr 2021 10:52:26 +0000 (12:52 +0200)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 28 Apr 2021 09:39:24 +0000 (11:39 +0200)
decide_allocation() occurs before set_caps(), where out_info is set,
thus setting srcpad_info with zeros or old values. Instead of it, the
caps, from the allocation query, are converted and used.

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

sys/va/gstvavpp.c

index c1c9bca..6ba0b5c 100644 (file)
@@ -643,7 +643,7 @@ gst_va_vpp_decide_allocation (GstBaseTransform * trans, GstQuery * query)
   GstBufferPool *pool = NULL, *other_pool = NULL;
   GstCaps *outcaps = NULL;
   GstStructure *config;
-  GstVideoInfo alloc_info;
+  GstVideoInfo vinfo;
   guint min, max, size = 0, usage_hint = VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE;
   gboolean update_pool, update_allocator, has_videometa, copy_frames;
 
@@ -652,6 +652,11 @@ gst_va_vpp_decide_allocation (GstBaseTransform * trans, GstQuery * query)
   gst_allocation_params_init (&other_params);
   gst_allocation_params_init (&params);
 
+  if (!gst_video_info_from_caps (&vinfo, outcaps)) {
+    GST_ERROR_OBJECT (self, "Cannot parse caps %" GST_PTR_FORMAT, outcaps);
+    return FALSE;
+  }
+
   if (gst_query_get_n_allocation_params (query) > 0) {
     gst_query_parse_nth_allocation_param (query, 0, &allocator, &other_params);
     if (allocator && !(GST_IS_VA_DMABUF_ALLOCATOR (allocator)
@@ -679,10 +684,6 @@ gst_va_vpp_decide_allocation (GstBaseTransform * trans, GstQuery * query)
 
     update_pool = TRUE;
   } else {
-    GstVideoInfo vinfo;
-
-    gst_video_info_init (&vinfo);
-    gst_video_info_from_caps (&vinfo, outcaps);
     size = GST_VIDEO_INFO_SIZE (&vinfo);
     min = 1;
     max = 0;
@@ -709,13 +710,12 @@ gst_va_vpp_decide_allocation (GstBaseTransform * trans, GstQuery * query)
   else
     gst_query_add_allocation_param (query, allocator, &params);
 
-  alloc_info = self->out_info;
   if (GST_IS_VA_DMABUF_ALLOCATOR (allocator)) {
-    gst_va_dmabuf_allocator_get_format (allocator, &alloc_info, NULL);
+    gst_va_dmabuf_allocator_get_format (allocator, &vinfo, NULL);
   } else if (GST_IS_VA_ALLOCATOR (allocator)) {
-    gst_va_allocator_get_format (allocator, &alloc_info, NULL);
+    gst_va_allocator_get_format (allocator, &vinfo, NULL);
   }
-  self->srcpad_info = alloc_info;
+  self->srcpad_info = vinfo;
 
   if (update_pool)
     gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);