plugins: request GLTextureUpload meta on buffers in the buffer pool.

Requesting the GLTextureUpload meta on buffers in the bufferpool
prevents such metas from being de-allocated when buffers are released
in the sink.

This is particulary useful in terms of performance when using the
GLTextureUploadMeta API since the GstVaapiTexture associated with
the target texture is stored in the meta.

https://bugzilla.gnome.org/show_bug.cgi?id=712558

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
Matthieu Bouron 2013-11-20 17:20:07 +00:00 committed by Gwenole Beauchesne
parent c7673f1cd6
commit 6b6c10d94d
5 changed files with 45 additions and 3 deletions

View file

@ -343,7 +343,7 @@ gst_vaapidecode_push_decoded_frame(GstVideoDecoder *vdec,
#if GST_CHECK_VERSION(1,1,0)
if (decode->has_texture_upload_meta)
gst_buffer_add_texture_upload_meta(out_frame->output_buffer);
gst_buffer_ensure_texture_upload_meta(out_frame->output_buffer);
#endif
#else
out_frame->output_buffer =
@ -552,11 +552,14 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
config = gst_buffer_pool_get_config(pool);
gst_buffer_pool_config_add_option(config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
gst_buffer_pool_set_config(pool, config);
#if GST_CHECK_VERSION(1,1,0)
decode->has_texture_upload_meta = gst_query_find_allocation_meta(query,
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, NULL);
if (decode->has_texture_upload_meta)
gst_buffer_pool_config_add_option(config,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
#endif
gst_buffer_pool_set_config(pool, config);
}
if (update_pool)

View file

@ -24,6 +24,9 @@
#include "gstvaapivideobufferpool.h"
#include "gstvaapivideobuffer.h"
#include "gstvaapivideomemory.h"
#if GST_CHECK_VERSION(1,1,0)
#include "gstvaapivideometa_texture.h"
#endif
GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapivideopool);
#define GST_CAT_DEFAULT gst_debug_vaapivideopool
@ -43,7 +46,8 @@ struct _GstVaapiVideoBufferPoolPrivate {
guint video_info_index;
GstAllocator *allocator;
GstVaapiDisplay *display;
guint has_video_meta : 1;
guint has_video_meta : 1;
guint has_texture_upload_meta : 1;
};
#define GST_VAAPI_VIDEO_BUFFER_POOL_GET_PRIVATE(obj) \
@ -103,6 +107,7 @@ gst_vaapi_video_buffer_pool_get_options(GstBufferPool *pool)
static const gchar *g_options[] = {
GST_BUFFER_POOL_OPTION_VIDEO_META,
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META,
NULL,
};
return g_options;
@ -147,6 +152,9 @@ gst_vaapi_video_buffer_pool_set_config(GstBufferPool *pool,
priv->has_video_meta = gst_buffer_pool_config_has_option(config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
priv->has_texture_upload_meta = gst_buffer_pool_config_has_option(config,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
return GST_BUFFER_POOL_CLASS(gst_vaapi_video_buffer_pool_parent_class)->
set_config(pool, config);
@ -214,6 +222,11 @@ gst_vaapi_video_buffer_pool_alloc_buffer(GstBufferPool *pool,
vmeta->unmap = gst_video_meta_unmap_vaapi_memory;
}
#if GST_CHECK_VERSION(1,1,0)
if (priv->has_texture_upload_meta)
gst_buffer_add_texture_upload_meta(buffer);
#endif
*out_buffer_ptr = buffer;
return GST_FLOW_OK;

View file

@ -59,6 +59,21 @@ typedef struct _GstVaapiVideoBufferPoolPrivate GstVaapiVideoBufferPoolPrivate;
*/
#define GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META "GstBufferPoolOptionVaapiVideoMeta"
/**
*
* GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META:
*
* An option that can be activated on bufferpool to request gl texture
* upload on buffers from the pool.
*
* When this option is enabled on the bufferpool,
* #GST_BUFFER_POOL_OPTION_VIDEO_META should also be enabled.
*/
#ifndef GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META
#define GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META \
"GstBufferPoolOptionVideoGLTextureUploadMeta"
#endif
/**
* GstVaapiVideoBufferPool:
*

View file

@ -96,4 +96,11 @@ gst_buffer_add_texture_upload_meta(GstBuffer *buffer)
#endif
return meta != NULL;
}
gboolean
gst_buffer_ensure_texture_upload_meta(GstBuffer *buffer)
{
return gst_buffer_get_video_gl_texture_upload_meta(buffer) ||
gst_buffer_add_texture_upload_meta(buffer);
}
#endif

View file

@ -35,6 +35,10 @@ G_GNUC_INTERNAL
gboolean
gst_buffer_add_texture_upload_meta(GstBuffer *buffer);
G_GNUC_INTERNAL
gboolean
gst_buffer_ensure_texture_upload_meta(GstBuffer *buffer);
G_END_DECLS
#endif /* GST_VAAPI_VIDEO_META_TEXTURE_H */