mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
plugins: allow bufferpool to not allocate vaapi video meta.
Add GST_VAAPI_VIDEO_BUFFER_POOL_ACQUIRE_FLAG_NO_ALLOC params flag that can be used to disable early allocations of vaapi video metas on buffers, thus delagating that to the bufferpool user.
This commit is contained in:
parent
038d56bdca
commit
1ef5a3a200
3 changed files with 37 additions and 8 deletions
|
@ -216,21 +216,29 @@ gst_vaapi_video_buffer_pool_alloc_buffer (GstBufferPool * pool,
|
|||
GstMemory *mem;
|
||||
GstBuffer *buffer;
|
||||
|
||||
const gboolean alloc_vaapi_video_meta = !params ||
|
||||
!(params->flags & GST_VAAPI_VIDEO_BUFFER_POOL_ACQUIRE_FLAG_NO_ALLOC);
|
||||
|
||||
if (!priv->allocator)
|
||||
goto error_no_allocator;
|
||||
|
||||
meta = gst_vaapi_video_meta_new (priv->display);
|
||||
if (!meta)
|
||||
goto error_create_meta;
|
||||
if (alloc_vaapi_video_meta) {
|
||||
meta = gst_vaapi_video_meta_new (priv->display);
|
||||
if (!meta)
|
||||
goto error_create_meta;
|
||||
|
||||
buffer = gst_vaapi_video_buffer_new (meta);
|
||||
buffer = gst_vaapi_video_buffer_new (meta);
|
||||
} else {
|
||||
meta = NULL;
|
||||
buffer = gst_vaapi_video_buffer_new_empty ();
|
||||
}
|
||||
if (!buffer)
|
||||
goto error_create_buffer;
|
||||
|
||||
mem = gst_vaapi_video_memory_new (priv->allocator, meta);
|
||||
if (!mem)
|
||||
goto error_create_memory;
|
||||
gst_vaapi_video_meta_unref (meta);
|
||||
gst_vaapi_video_meta_replace (&meta, NULL);
|
||||
gst_buffer_append_memory (buffer, mem);
|
||||
|
||||
if (priv->has_video_meta) {
|
||||
|
|
|
@ -69,6 +69,20 @@ typedef struct _GstVaapiVideoBufferPoolPrivate GstVaapiVideoBufferPoolPrivate;
|
|||
"GstBufferPoolOptionVideoGLTextureUploadMeta"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GstVaapiVideoBufferPoolAcquireFlags:
|
||||
* @GST_VAAPI_VIDEO_BUFFER_POOL_ACQUIRE_FLAG_NO_ALLOC: option to
|
||||
* request that vaapi video metadata are not initially allocated,
|
||||
* but are subsequently provided by the user.
|
||||
*
|
||||
* The set of #GstVaapiVideoBufferPool specific flags for
|
||||
* gst_buffer_pool_acquire_buffer().
|
||||
*/
|
||||
typedef enum {
|
||||
GST_VAAPI_VIDEO_BUFFER_POOL_ACQUIRE_FLAG_NO_ALLOC =
|
||||
GST_BUFFER_POOL_ACQUIRE_FLAG_LAST << 0,
|
||||
} GstVaapiVideoBufferPoolAcquireFlags;
|
||||
|
||||
/**
|
||||
* GstVaapiVideoBufferPool:
|
||||
*
|
||||
|
|
|
@ -281,7 +281,7 @@ gst_vaapi_video_memory_new (GstAllocator * base_allocator,
|
|||
mem->surface = NULL;
|
||||
mem->image_info = &allocator->image_info;
|
||||
mem->image = NULL;
|
||||
mem->meta = gst_vaapi_video_meta_ref (meta);
|
||||
mem->meta = meta ? gst_vaapi_video_meta_ref (meta) : NULL;
|
||||
mem->map_type = 0;
|
||||
mem->map_count = 0;
|
||||
mem->use_direct_rendering = allocator->has_direct_rendering;
|
||||
|
@ -294,7 +294,7 @@ gst_vaapi_video_memory_free (GstVaapiVideoMemory * mem)
|
|||
mem->surface = NULL;
|
||||
gst_vaapi_video_memory_reset_image (mem);
|
||||
gst_vaapi_surface_proxy_replace (&mem->proxy, NULL);
|
||||
gst_vaapi_video_meta_unref (mem->meta);
|
||||
gst_vaapi_video_meta_replace (&mem->meta, NULL);
|
||||
gst_object_unref (GST_MEMORY_CAST (mem)->allocator);
|
||||
g_slice_free (GstVaapiVideoMemory, mem);
|
||||
}
|
||||
|
@ -319,7 +319,8 @@ gst_vaapi_video_memory_reset_surface (GstVaapiVideoMemory * mem)
|
|||
mem->surface = NULL;
|
||||
gst_vaapi_video_memory_reset_image (mem);
|
||||
gst_vaapi_surface_proxy_replace (&mem->proxy, NULL);
|
||||
gst_vaapi_video_meta_set_surface_proxy (mem->meta, NULL);
|
||||
if (mem->meta)
|
||||
gst_vaapi_video_meta_set_surface_proxy (mem->meta, NULL);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
|
@ -328,6 +329,9 @@ gst_vaapi_video_memory_map (GstVaapiVideoMemory * mem, gsize maxsize,
|
|||
{
|
||||
gpointer data;
|
||||
|
||||
g_return_val_if_fail (mem, NULL);
|
||||
g_return_val_if_fail (mem->meta, NULL);
|
||||
|
||||
if (mem->map_count == 0) {
|
||||
switch (flags & GST_MAP_READWRITE) {
|
||||
case 0:
|
||||
|
@ -426,6 +430,9 @@ gst_vaapi_video_memory_copy (GstVaapiVideoMemory * mem,
|
|||
GstMemory *out_mem;
|
||||
gsize maxsize;
|
||||
|
||||
g_return_val_if_fail (mem, NULL);
|
||||
g_return_val_if_fail (mem->meta, NULL);
|
||||
|
||||
/* XXX: this implements a soft-copy, i.e. underlying VA surfaces
|
||||
are not copied */
|
||||
(void) gst_memory_get_sizes (GST_MEMORY_CAST (mem), NULL, &maxsize);
|
||||
|
|
Loading…
Reference in a new issue