From 892b6d3822f675fdb84be90c4c5bf086cc2af331 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Fri, 29 Jul 2016 15:13:29 +0200 Subject: [PATCH] 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. --- gst/vaapi/gstvaapipluginbase.c | 4 +--- gst/vaapi/gstvaapivideomemory.c | 26 ++++++++++++++++++++++++++ gst/vaapi/gstvaapivideomemory.h | 4 ++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index c5b8b85..54fc403 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -832,10 +832,8 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin, if (!pool) { if (!ensure_srcpad_allocator (plugin, &vi)) goto error_create_allocator; - /* Update video size with allocator's image size */ - size = GST_VIDEO_INFO_SIZE (&GST_VAAPI_VIDEO_ALLOCATOR_CAST - (plugin->srcpad_allocator)->image_info); + 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) diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c index ea09177..3b2b4d8 100644 --- a/gst/vaapi/gstvaapivideomemory.c +++ b/gst/vaapi/gstvaapivideomemory.c @@ -1036,6 +1036,32 @@ 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) { diff --git a/gst/vaapi/gstvaapivideomemory.h b/gst/vaapi/gstvaapivideomemory.h index c096a03..88a3814 100644 --- a/gst/vaapi/gstvaapivideomemory.h +++ b/gst/vaapi/gstvaapivideomemory.h @@ -218,6 +218,10 @@ gst_allocator_set_vaapi_video_info (GstAllocator * allocator, 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); G_END_DECLS -- 2.7.4