mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
vabasetransform: clean up decide_allocation() vmethod
When creating a new VA pool set config size to zero because it's not used. Also, given the potential different sizes from software buffer pools and VA buffer pools, this patch handle that potential different values. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5805>
This commit is contained in:
parent
33e49023ff
commit
4fab6bb45a
1 changed files with 21 additions and 37 deletions
|
@ -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 the allocation query that was answered downstream, we can
|
||||||
* configure some properties on it. Only it's called when not in
|
* configure some properties on it. Only it's called when not in
|
||||||
* passthrough mode. */
|
* passthrough mode. */
|
||||||
|
@ -349,20 +330,13 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans,
|
||||||
GstBufferPool *pool = NULL, *other_pool = NULL;
|
GstBufferPool *pool = NULL, *other_pool = NULL;
|
||||||
GstCaps *outcaps = NULL;
|
GstCaps *outcaps = NULL;
|
||||||
GstStructure *config;
|
GstStructure *config;
|
||||||
GstVideoInfo vinfo;
|
guint min, max, other_size = 0, size = 0, usage_hint;
|
||||||
guint min, max, size = 0, usage_hint;
|
|
||||||
gboolean update_pool, update_allocator, has_videometa, copy_frames;
|
gboolean update_pool, update_allocator, has_videometa, copy_frames;
|
||||||
gboolean dont_use_other_pool = FALSE;
|
gboolean dont_use_other_pool = FALSE;
|
||||||
|
|
||||||
gst_query_parse_allocation (query, &outcaps, NULL);
|
gst_query_parse_allocation (query, &outcaps, NULL);
|
||||||
|
if (!outcaps)
|
||||||
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);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (gst_query_get_n_allocation_params (query) > 0) {
|
if (gst_query_get_n_allocation_params (query) > 0) {
|
||||||
GstVaDisplay *display;
|
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);
|
"may need other pool for copy frames %" GST_PTR_FORMAT, pool);
|
||||||
other_pool = pool;
|
other_pool = pool;
|
||||||
pool = NULL;
|
pool = NULL;
|
||||||
|
other_size = size;
|
||||||
} else if (dont_use_other_pool) {
|
} else if (dont_use_other_pool) {
|
||||||
gst_clear_object (&pool);
|
gst_clear_object (&pool);
|
||||||
}
|
}
|
||||||
|
@ -400,7 +375,6 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans,
|
||||||
|
|
||||||
update_pool = TRUE;
|
update_pool = TRUE;
|
||||||
} else {
|
} else {
|
||||||
size = GST_VIDEO_INFO_SIZE (&vinfo);
|
|
||||||
min = 1;
|
min = 1;
|
||||||
max = 0;
|
max = 0;
|
||||||
update_pool = FALSE;
|
update_pool = FALSE;
|
||||||
|
@ -409,7 +383,7 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans,
|
||||||
if (!allocator) {
|
if (!allocator) {
|
||||||
if (!(allocator =
|
if (!(allocator =
|
||||||
gst_va_base_transform_allocator_from_caps (self, outcaps)))
|
gst_va_base_transform_allocator_from_caps (self, outcaps)))
|
||||||
return FALSE;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pool)
|
if (!pool)
|
||||||
|
@ -421,14 +395,13 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans,
|
||||||
config = gst_buffer_pool_get_config (pool);
|
config = gst_buffer_pool_get_config (pool);
|
||||||
gst_buffer_pool_config_set_allocator (config, allocator, ¶ms);
|
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_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_buffer_pool_config_set_va_allocation_params (config, usage_hint,
|
||||||
GST_VA_FEATURE_AUTO);
|
GST_VA_FEATURE_AUTO);
|
||||||
if (!gst_buffer_pool_set_config (pool, config)) {
|
if (!gst_buffer_pool_set_config (pool, config))
|
||||||
gst_object_unref (allocator);
|
goto bail;
|
||||||
gst_object_unref (pool);
|
if (!gst_va_pool_get_buffer_size (pool, &size))
|
||||||
return FALSE;
|
goto bail;
|
||||||
}
|
|
||||||
|
|
||||||
if (GST_IS_VA_DMABUF_ALLOCATOR (allocator)) {
|
if (GST_IS_VA_DMABUF_ALLOCATOR (allocator)) {
|
||||||
GstVideoInfoDmaDrm dma_info;
|
GstVideoInfoDmaDrm dma_info;
|
||||||
|
@ -460,9 +433,13 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans,
|
||||||
gst_object_replace ((GstObject **) & self->priv->other_pool,
|
gst_object_replace ((GstObject **) & self->priv->other_pool,
|
||||||
(GstObject *) other_pool);
|
(GstObject *) other_pool);
|
||||||
} else {
|
} else {
|
||||||
|
gst_clear_object (&self->priv->other_pool);
|
||||||
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,
|
GST_DEBUG_OBJECT (self, "Use the other pool for copy %" GST_PTR_FORMAT,
|
||||||
self->priv->other_pool);
|
self->priv->other_pool);
|
||||||
} else {
|
} else {
|
||||||
|
@ -482,6 +459,13 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans,
|
||||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans,
|
return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans,
|
||||||
query);
|
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
|
/* output buffers must be from our VA-based pool, they cannot be
|
||||||
|
|
Loading…
Reference in a new issue