mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 17:18:15 +00:00
plugins: handle vaapi allocator in allocation query
In propose_allocation() if the numer of allocation params is zero, the system's allocator is added first, and lastly the native VA-API allocator. In decide_allocation(), the allocations params in query are travered, looking for a native VA-API allocator. If it is found, it is reused as src pad allocator. Otherwise, a new allocator is instantiated and appended in the query. https://bugzilla.gnome.org/show_bug.cgi?id=789476
This commit is contained in:
parent
8855a926be
commit
448105578b
1 changed files with 49 additions and 12 deletions
|
@ -806,7 +806,7 @@ gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
GstBufferPool *pool = NULL;
|
GstBufferPool *pool = NULL;
|
||||||
gboolean need_pool;
|
gboolean need_pool;
|
||||||
guint size = 0;
|
guint size = 0, n_allocators;
|
||||||
|
|
||||||
gst_query_parse_allocation (query, &caps, &need_pool);
|
gst_query_parse_allocation (query, &caps, &need_pool);
|
||||||
if (!caps)
|
if (!caps)
|
||||||
|
@ -822,10 +822,23 @@ gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
|
||||||
plugin->sinkpad_allocator);
|
plugin->sinkpad_allocator);
|
||||||
if (!pool)
|
if (!pool)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gst_query_add_allocation_param (query, plugin->sinkpad_allocator, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set sinkpad allocator as the last allocation param.
|
||||||
|
*
|
||||||
|
* If there's none, set system's allocator first and VAAPI allocator
|
||||||
|
* second
|
||||||
|
*/
|
||||||
|
n_allocators = gst_query_get_n_allocation_params (query);
|
||||||
|
if (n_allocators == 0) {
|
||||||
|
GstAllocator *allocator;
|
||||||
|
|
||||||
|
allocator = gst_allocator_find (GST_ALLOCATOR_SYSMEM);
|
||||||
|
gst_query_add_allocation_param (query, allocator, NULL);
|
||||||
|
gst_object_unref (allocator);
|
||||||
|
}
|
||||||
|
gst_query_add_allocation_param (query, plugin->sinkpad_allocator, NULL);
|
||||||
|
|
||||||
gst_query_add_allocation_pool (query, pool, size,
|
gst_query_add_allocation_pool (query, pool, size,
|
||||||
BUFFER_POOL_SINK_MIN_BUFFERS, 0);
|
BUFFER_POOL_SINK_MIN_BUFFERS, 0);
|
||||||
if (pool)
|
if (pool)
|
||||||
|
@ -861,8 +874,9 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
GstBufferPool *pool;
|
GstBufferPool *pool;
|
||||||
GstVideoInfo vi;
|
GstVideoInfo vi;
|
||||||
guint size, min, max, pool_options;
|
guint i, size, min, max, pool_options, num_allocators;
|
||||||
gboolean update_pool = FALSE, update_allocator = FALSE;
|
gint index_allocator;
|
||||||
|
gboolean update_pool = FALSE;
|
||||||
#if (USE_GLX || USE_EGL)
|
#if (USE_GLX || USE_EGL)
|
||||||
guint idx;
|
guint idx;
|
||||||
#endif
|
#endif
|
||||||
|
@ -911,8 +925,25 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
|
||||||
goto error_invalid_caps;
|
goto error_invalid_caps;
|
||||||
gst_video_info_force_nv12_if_encoded (&vi);
|
gst_video_info_force_nv12_if_encoded (&vi);
|
||||||
|
|
||||||
if (gst_query_get_n_allocation_params (query) > 0)
|
index_allocator = -1;
|
||||||
update_allocator = TRUE;
|
num_allocators = gst_query_get_n_allocation_params (query);
|
||||||
|
for (i = 0; i < num_allocators; i++) {
|
||||||
|
GstAllocator *allocator = NULL;
|
||||||
|
|
||||||
|
gst_query_parse_nth_allocation_param (query, i, &allocator, NULL);
|
||||||
|
if (!allocator)
|
||||||
|
continue;
|
||||||
|
if (g_strcmp0 (allocator->mem_type, GST_VAAPI_VIDEO_MEMORY_NAME) == 0) {
|
||||||
|
GST_DEBUG_OBJECT (plugin, "found vaapi allocator in query %"
|
||||||
|
GST_PTR_FORMAT, allocator);
|
||||||
|
index_allocator = i;
|
||||||
|
if (plugin->srcpad_allocator)
|
||||||
|
gst_object_unref (plugin->srcpad_allocator);
|
||||||
|
plugin->srcpad_allocator = allocator;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
gst_object_unref (allocator);
|
||||||
|
}
|
||||||
|
|
||||||
if (gst_query_get_n_allocation_pools (query) > 0) {
|
if (gst_query_get_n_allocation_pools (query) > 0) {
|
||||||
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
|
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
|
||||||
|
@ -955,11 +986,17 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
|
||||||
else
|
else
|
||||||
gst_query_add_allocation_pool (query, pool, size, min, max);
|
gst_query_add_allocation_pool (query, pool, size, min, max);
|
||||||
|
|
||||||
if (update_allocator)
|
/* allocator might be updated by ensure_srcpad_allocator() */
|
||||||
gst_query_set_nth_allocation_param (query, 0, plugin->srcpad_allocator,
|
if (plugin->srcpad_allocator) {
|
||||||
NULL);
|
if (index_allocator > 0) {
|
||||||
else
|
gst_query_set_nth_allocation_param (query, index_allocator,
|
||||||
|
plugin->srcpad_allocator, NULL);
|
||||||
|
} else {
|
||||||
|
GST_DEBUG_OBJECT (plugin, "adding allocator in query %" GST_PTR_FORMAT,
|
||||||
|
plugin->srcpad_allocator);
|
||||||
gst_query_add_allocation_param (query, plugin->srcpad_allocator, NULL);
|
gst_query_add_allocation_param (query, plugin->srcpad_allocator, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_clear_object (&plugin->srcpad_buffer_pool);
|
g_clear_object (&plugin->srcpad_buffer_pool);
|
||||||
plugin->srcpad_buffer_pool = pool;
|
plugin->srcpad_buffer_pool = pool;
|
||||||
|
|
Loading…
Reference in a new issue