videoconvert: Fix prepare output buffer error 94/292494/4
authorJeongmo Yang <jm80.yang@samsung.com>
Tue, 9 May 2023 05:04:58 +0000 (14:04 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Tue, 9 May 2023 09:38:17 +0000 (18:38 +0900)
- It's not considered that tizen buffer pool is not created.

[Version] 1.20.0-47
[Issue Type] Bug fix

Change-Id: I9bc6435ba35829cf52d4a96111caf7551172ccab
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/gstreamer.spec
subprojects/gst-plugins-base/gst/videoconvert/gstvideoconvert.c

index da7faf01def558908635e396512ce151bb91b02a..47cb643748e71ef88a2575c5b7dcd761eb2eaed8 100644 (file)
@@ -62,7 +62,7 @@
 
 Name:           %{_name}
 Version:        1.20.0
-Release:        46
+Release:        47
 Summary:        Streaming-Media Framework Runtime
 License:        LGPL-2.0+
 Group:          Multimedia/Framework
index 4eb8a4e08c15358617ba89d389a5914410c3954d..d7c3e838f380393927cc24812228c4988875a294 100644 (file)
@@ -886,7 +886,8 @@ gst_video_convert_decide_allocation (GstBaseTransform * trans,
   GstVideoFilter *filter = GST_VIDEO_FILTER_CAST (trans);
   vc = GST_VIDEO_CONVERT_CAST(trans);
 
-  if (filter->out_info.finfo->format == GST_VIDEO_FORMAT_SN12 ) {
+  if (filter->in_info.finfo->format != filter->out_info.finfo->format &&
+    filter->out_info.finfo->format == GST_VIDEO_FORMAT_SN12) {
     guint size;
     GstStructure *config;
     GstCaps *caps = NULL;
@@ -897,25 +898,26 @@ gst_video_convert_decide_allocation (GstBaseTransform * trans,
 
     size = vinfo.size;
 
-    if (caps) {
-      vc->pool = gst_tizen_buffer_pool_new ();
-      config = gst_buffer_pool_get_config (vc->pool);
+    if (!caps) {
+      GST_WARNING_OBJECT (vc, "Not using our internal pool and copying buffers for downstream");
+      return FALSE;
+    }
 
-      gst_buffer_pool_config_set_params (config, caps, size, 4, 10);
-      gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
-      gst_buffer_pool_set_config (vc->pool, config);
+    GST_INFO_OBJECT (vc, "Creating Tizen buffer pool");
 
-      if (!gst_buffer_pool_set_active (vc->pool, TRUE)) {
-        gst_object_unref (vc->pool);
-        vc->pool = NULL;
-        GST_INFO ("Failed to activate internal pool");
-      }
-    } else {
-      GST_ERROR("Not using our internal pool and copying buffers for downstream");
-      return FALSE;
+    vc->pool = gst_tizen_buffer_pool_new ();
+    config = gst_buffer_pool_get_config (vc->pool);
+
+    gst_buffer_pool_config_set_params (config, caps, size, 4, 10);
+    gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
+    gst_buffer_pool_set_config (vc->pool, config);
+
+    if (!gst_buffer_pool_set_active (vc->pool, TRUE)) {
+      gst_object_unref (vc->pool);
+      vc->pool = NULL;
+      GST_WARNING_OBJECT (vc, "Failed to activate Tizen buffer pool");
     }
   }
-  GST_DEBUG("[%s]Creating Tizen Buffer Pool", __FUNCTION__);
 
   return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans, query);
 }
@@ -930,19 +932,22 @@ gst_video_convert_prepare_output_buffer (GstBaseTransform * trans,
 
   vc = GST_VIDEO_CONVERT_CAST (trans);
 
-  if (filter->out_info.finfo->format == GST_VIDEO_FORMAT_SN12 ) {
-    if (gst_buffer_pool_acquire_buffer (vc->pool, &buf, 0) != GST_FLOW_OK) {
-      GST_ERROR("[%s] memory prepare failed.",__FUNCTION__);
-      return GST_FLOW_ERROR;
-    }
-
-    if (input != buf)
-      GST_BASE_TRANSFORM_CLASS (parent_class)->copy_metadata (trans, input, buf);
-    *outbuf = buf;
+  if (!vc->pool)
+    return GST_BASE_TRANSFORM_CLASS (parent_class)->prepare_output_buffer(trans, input, outbuf);
 
-    return GST_FLOW_OK;
+  if (gst_buffer_pool_acquire_buffer (vc->pool, &buf, 0) != GST_FLOW_OK) {
+    GST_ERROR_OBJECT (vc, "acquire buffer failed");
+    return GST_FLOW_ERROR;
   }
-  return GST_BASE_TRANSFORM_CLASS (parent_class)->prepare_output_buffer(trans, input, outbuf);
+
+  GST_DEBUG_OBJECT (vc, "acquired buffer %p", buf);
+
+  if (input != buf)
+    GST_BASE_TRANSFORM_CLASS (parent_class)->copy_metadata (trans, input, buf);
+
+  *outbuf = buf;
+
+  return GST_FLOW_OK;
 }
 #endif