plugins: add allocator to allocation query

This patch adds the created allocator to the allocation query either
in decide_allocation() and propose_allocation() vmehtods.

With it, there's no need to set the modified allocator's size in the
pool configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=774782
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-11-21 11:25:21 +01:00
parent aca43dab47
commit acefc7e384
3 changed files with 11 additions and 34 deletions

View file

@ -701,7 +701,6 @@ ensure_sinkpad_buffer_pool (GstVaapiPluginBase * plugin, GstCaps * caps)
if (!ensure_sinkpad_allocator (plugin, caps, &size))
goto error;
gst_allocator_get_vaapi_image_size (plugin->sinkpad_allocator, &size);
pool = gst_vaapi_plugin_base_create_pool (plugin, caps, size, 0, 0,
GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_META, plugin->sinkpad_allocator);
if (!pool)
@ -779,6 +778,7 @@ gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
return FALSE;
gst_query_add_allocation_pool (query, plugin->sinkpad_buffer_pool,
plugin->sinkpad_buffer_size, 0, 0);
gst_query_add_allocation_param (query, plugin->sinkpad_allocator, NULL);
}
gst_query_add_allocation_meta (query, GST_VAAPI_VIDEO_META_API_TYPE, NULL);
@ -812,7 +812,7 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
GstBufferPool *pool;
GstVideoInfo vi;
guint size, min, max, pool_options;
gboolean update_pool = FALSE;
gboolean update_pool = FALSE, update_allocator = FALSE;
#if (USE_GLX || USE_EGL)
guint idx;
#endif
@ -860,6 +860,9 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
goto error_invalid_caps;
gst_video_info_force_nv12_if_encoded (&vi);
if (gst_query_get_n_allocation_params (query) > 0)
update_allocator = TRUE;
if (gst_query_get_n_allocation_pools (query) > 0) {
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
update_pool = TRUE;
@ -888,8 +891,6 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
if (!pool) {
if (!ensure_srcpad_allocator (plugin, &vi, caps))
goto error;
/* Update video size with allocator's image size */
gst_allocator_get_vaapi_image_size (plugin->srcpad_allocator, &size);
pool = gst_vaapi_plugin_base_create_pool (plugin, caps, size, min, max,
pool_options, plugin->srcpad_allocator);
if (!pool)
@ -901,6 +902,12 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
else
gst_query_add_allocation_pool (query, pool, size, min, max);
if (update_allocator)
gst_query_set_nth_allocation_param (query, 0, plugin->srcpad_allocator,
NULL);
else
gst_query_add_allocation_param (query, plugin->srcpad_allocator, NULL);
g_clear_object (&plugin->srcpad_buffer_pool);
plugin->srcpad_buffer_pool = pool;
return TRUE;

View file

@ -1127,32 +1127,6 @@ gst_allocator_set_vaapi_video_info (GstAllocator * allocator,
return TRUE;
}
/**
* gst_allocator_get_vaapi_image_size:
* @allocator: a #GstAllocator instance.
* @size: (out) (optional): the VA image size created by @allocator.
*
* This function gets the size of the VA images instantiated by the
* @allocator.
*
* Returns: %TRUE if @allocator is VA valid
**/
gboolean
gst_allocator_get_vaapi_image_size (GstAllocator * allocator, guint * size)
{
GstVaapiVideoAllocator *alloc;
g_return_val_if_fail (GST_IS_ALLOCATOR (allocator), FALSE);
if (g_strcmp0 (allocator->mem_type, GST_VAAPI_VIDEO_MEMORY_NAME))
return FALSE;
alloc = GST_VAAPI_VIDEO_ALLOCATOR_CAST (allocator);
if (alloc && size)
*size = GST_VIDEO_INFO_SIZE (&alloc->image_info);
return TRUE;
}
gboolean
gst_vaapi_is_dmabuf_allocator (GstAllocator * allocator)
{

View file

@ -235,10 +235,6 @@ gboolean
gst_allocator_set_vaapi_video_info (GstAllocator * allocator,
const GstVideoInfo * vip, guint flags);
G_GNUC_INTERNAL
gboolean
gst_allocator_get_vaapi_image_size (GstAllocator * allocator, guint * size);
G_GNUC_INTERNAL
gboolean
gst_vaapi_is_dmabuf_allocator (GstAllocator * allocator);