diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c index 9b262b5fef..458955b923 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c @@ -317,25 +317,6 @@ config_failed: } } -static GstBufferPool * -_create_other_pool (GstAllocator * allocator, - GstAllocationParams * params, GstCaps * caps, guint size) -{ - GstBufferPool *pool = NULL; - GstStructure *config; - - pool = gst_video_buffer_pool_new (); - config = gst_buffer_pool_get_config (pool); - - gst_buffer_pool_config_set_params (config, caps, size, 0, 0); - gst_buffer_pool_config_set_allocator (config, allocator, params); - if (!gst_buffer_pool_set_config (pool, config)) { - gst_clear_object (&pool); - } - - return pool; -} - /* configure the allocation query that was answered downstream, we can * configure some properties on it. Only it's called when not in * passthrough mode. */ @@ -349,20 +330,13 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, GstBufferPool *pool = NULL, *other_pool = NULL; GstCaps *outcaps = NULL; GstStructure *config; - GstVideoInfo vinfo; - guint min, max, size = 0, usage_hint; + guint min, max, other_size = 0, size = 0, usage_hint; gboolean update_pool, update_allocator, has_videometa, copy_frames; gboolean dont_use_other_pool = FALSE; gst_query_parse_allocation (query, &outcaps, NULL); - - gst_allocation_params_init (&other_params); - gst_allocation_params_init (¶ms); - - if (!gst_va_video_info_from_caps (&vinfo, NULL, outcaps)) { - GST_ERROR_OBJECT (self, "Cannot parse caps %" GST_PTR_FORMAT, outcaps); + if (!outcaps) return FALSE; - } if (gst_query_get_n_allocation_params (query) > 0) { GstVaDisplay *display; @@ -393,6 +367,7 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, "may need other pool for copy frames %" GST_PTR_FORMAT, pool); other_pool = pool; pool = NULL; + other_size = size; } else if (dont_use_other_pool) { gst_clear_object (&pool); } @@ -400,7 +375,6 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, update_pool = TRUE; } else { - size = GST_VIDEO_INFO_SIZE (&vinfo); min = 1; max = 0; update_pool = FALSE; @@ -409,7 +383,7 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, if (!allocator) { if (!(allocator = gst_va_base_transform_allocator_from_caps (self, outcaps))) - return FALSE; + goto bail; } if (!pool) @@ -421,14 +395,13 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_set_allocator (config, allocator, ¶ms); gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); - gst_buffer_pool_config_set_params (config, outcaps, size, min, max); + gst_buffer_pool_config_set_params (config, outcaps, 0, min, max); gst_buffer_pool_config_set_va_allocation_params (config, usage_hint, GST_VA_FEATURE_AUTO); - if (!gst_buffer_pool_set_config (pool, config)) { - gst_object_unref (allocator); - gst_object_unref (pool); - return FALSE; - } + if (!gst_buffer_pool_set_config (pool, config)) + goto bail; + if (!gst_va_pool_get_buffer_size (pool, &size)) + goto bail; if (GST_IS_VA_DMABUF_ALLOCATOR (allocator)) { GstVideoInfoDmaDrm dma_info; @@ -460,9 +433,13 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, gst_object_replace ((GstObject **) & self->priv->other_pool, (GstObject *) other_pool); } else { + gst_clear_object (&self->priv->other_pool); self->priv->other_pool = - _create_other_pool (other_allocator, &other_params, outcaps, size); + gst_va_create_other_pool (other_allocator, &other_params, outcaps, + other_size); } + if (!self->priv->other_pool) + goto bail; GST_DEBUG_OBJECT (self, "Use the other pool for copy %" GST_PTR_FORMAT, self->priv->other_pool); } else { @@ -482,6 +459,13 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans, query); +bail: + gst_object_unref (allocator); + gst_object_unref (pool); + gst_clear_object (&other_allocator); + gst_clear_object (&other_pool); + + return FALSE; } /* output buffers must be from our VA-based pool, they cannot be