gstvaapivideomemory: allocator's image size getter

Add the method gst_allocator_get_vaapi_image_size() for the
GstVaapiVideoAllocator, which gets the size of the allocated images with the
current video info.

This method replaces the direct call to the allocator's image info when the
pool is configured.
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-07-29 15:13:29 +02:00
parent d0ee0b4e72
commit 892b6d3822
3 changed files with 31 additions and 3 deletions

View file

@ -832,10 +832,8 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
if (!pool) { if (!pool) {
if (!ensure_srcpad_allocator (plugin, &vi)) if (!ensure_srcpad_allocator (plugin, &vi))
goto error_create_allocator; goto error_create_allocator;
/* Update video size with allocator's image size */ /* Update video size with allocator's image size */
size = GST_VIDEO_INFO_SIZE (&GST_VAAPI_VIDEO_ALLOCATOR_CAST gst_allocator_get_vaapi_image_size (plugin->srcpad_allocator, &size);
(plugin->srcpad_allocator)->image_info);
pool = gst_vaapi_plugin_base_create_pool (plugin, caps, size, min, max, pool = gst_vaapi_plugin_base_create_pool (plugin, caps, size, min, max,
pool_options, plugin->srcpad_allocator); pool_options, plugin->srcpad_allocator);
if (!pool) if (!pool)

View file

@ -1036,6 +1036,32 @@ gst_allocator_set_vaapi_video_info (GstAllocator * allocator,
return TRUE; 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 gboolean
gst_vaapi_is_dmabuf_allocator (GstAllocator * allocator) gst_vaapi_is_dmabuf_allocator (GstAllocator * allocator)
{ {

View file

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