va: basedec: refactor the other video pool instantiation

Just a code clean up

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1673>
This commit is contained in:
Víctor Manuel Jáquez Leal 2020-10-09 15:47:43 +02:00 committed by GStreamer Merge Bot
parent a6398eca17
commit 5658c4182a

View file

@ -174,6 +174,31 @@ _create_allocator (GstVaBaseDec * base, GstCaps * caps)
return allocator; return allocator;
} }
static void
_create_other_pool (GstVaBaseDec * base, GstAllocator * allocator,
GstAllocationParams * params, GstCaps * caps, guint size)
{
GstBufferPool *pool;
GstStructure *config;
if (base->other_pool)
return;
GST_DEBUG_OBJECT (base, "making new other pool for copy");
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_ERROR_OBJECT (base, "Couldn't configure other pool for copy.");
gst_clear_object (&pool);
}
base->other_pool = pool;
}
/* 1. get allocator in query /* 1. get allocator in query
* 1.1 if allocator is not ours and downstream doesn't handle * 1.1 if allocator is not ours and downstream doesn't handle
* videometa, keep it for other_pool * videometa, keep it for other_pool
@ -195,7 +220,6 @@ gst_va_base_dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
GstAllocationParams other_params, params; GstAllocationParams other_params, params;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
GstCaps *caps = NULL; GstCaps *caps = NULL;
GstStructure *config;
GstVideoInfo info; GstVideoInfo info;
GstVaBaseDec *base = GST_VA_BASE_DEC (decoder); GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
guint size = 0, min, max; guint size = 0, min, max;
@ -251,16 +275,7 @@ gst_va_base_dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
size = GST_VIDEO_INFO_SIZE (&info); size = GST_VIDEO_INFO_SIZE (&info);
if (!base->has_videometa && !gst_caps_is_vamemory (caps)) { if (!base->has_videometa && !gst_caps_is_vamemory (caps)) {
GST_DEBUG_OBJECT (base, "making new other pool for copy"); _create_other_pool (base, other_allocator, &other_params, caps, size);
base->other_pool = gst_video_buffer_pool_new ();
config = gst_buffer_pool_get_config (base->other_pool);
gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
gst_buffer_pool_config_set_allocator (config, other_allocator,
&other_params);
if (!gst_buffer_pool_set_config (base->other_pool, config)) {
GST_ERROR_OBJECT (base, "couldn't configure other pool for copy");
gst_clear_object (&base->other_pool);
}
} else { } else {
gst_clear_object (&other_allocator); gst_clear_object (&other_allocator);
} }