vaapivideobufferpool: share options flag with pluginbase

Originally, vaapivideobufferpool has a set of boolean variables for the
buffer configuration options.

This pach changes these boolean variables for a single bitwise, just as
it is used in pluginbase. Hence, the internal enum was moved to
vaapivideobufferpool header.

https://bugzilla.gnome.org/show_bug.cgi?id=765435
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-05-25 10:58:01 +02:00
parent d0c72182a4
commit 6c5b6232da
3 changed files with 37 additions and 29 deletions

View file

@ -37,13 +37,6 @@
/* Environment variable for disable driver white-list */
#define GST_VAAPI_ALL_DRIVERS_ENV "GST_VAAPI_ALL_DRIVERS"
enum
{
GST_VAAPI_OPTION_VIDEO_META = (1u << 0),
GST_VAAPI_OPTION_VIDEO_ALIGNMENT = (1u << 1),
GST_VAAPI_OPTION_GL_TEXTURE_UPLOAD = (1u << 2),
};
/* GstVideoContext interface */
static void
plugin_set_display (GstVaapiPluginBase * plugin, GstVaapiDisplay * display)
@ -520,7 +513,7 @@ gst_vaapi_buffer_pool_caps_is_equal (GstBufferPool * pool, GstCaps * newcaps)
* @plugin: a #GstVaapiPluginBase
* @caps: the initial #GstCaps for the resulting buffer pool
* @size: the size of each buffer, not including prefix and padding
* @options: #GstBufferPool options encoded as bit-wise flags
* @options: a set of #GstVaapiVideoBufferPoolOption encoded as bit-wise
* @allocator: (allow-none): the #GstAllocator to use or %NULL
*
* Create an instance of #GstVaapiVideoBufferPool
@ -543,16 +536,16 @@ gst_vaapi_plugin_base_create_pool (GstVaapiPluginBase * plugin, GstCaps * caps,
max_buffers);
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META);
if (options & GST_VAAPI_OPTION_VIDEO_META) {
if (options & GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_META) {
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
}
if (options & GST_VAAPI_OPTION_VIDEO_ALIGNMENT) {
if (options & GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT) {
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
}
#if (USE_GLX || USE_EGL)
if (options & GST_VAAPI_OPTION_GL_TEXTURE_UPLOAD) {
if (options & GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_GL_TEXTURE_UPLOAD) {
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
}
@ -620,7 +613,8 @@ ensure_sinkpad_buffer_pool (GstVaapiPluginBase * plugin, GstCaps * caps)
goto error_create_allocator;
pool = gst_vaapi_plugin_base_create_pool (plugin, caps,
GST_VIDEO_INFO_SIZE (&vi), 0, 0, GST_VAAPI_OPTION_VIDEO_META, allocator);
GST_VIDEO_INFO_SIZE (&vi), 0, 0,
GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_META, allocator);
gst_object_unref (allocator);
if (!pool)
goto error_create_pool;
@ -766,17 +760,17 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
pool_options = 0;
if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL))
pool_options |= GST_VAAPI_OPTION_VIDEO_META;
pool_options |= GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_META;
#if (USE_GLX || USE_EGL)
if (gst_query_find_allocation_meta (query,
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, &idx) &&
gst_vaapi_caps_feature_contains (caps,
GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META))
pool_options |= GST_VAAPI_OPTION_GL_TEXTURE_UPLOAD;
pool_options |= GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_GL_TEXTURE_UPLOAD;
#if USE_GST_GL_HELPERS
if (pool_options & GST_VAAPI_OPTION_GL_TEXTURE_UPLOAD) {
if (pool_options & GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_GL_TEXTURE_UPLOAD) {
const GstStructure *params;
GstObject *gl_context;
@ -811,7 +805,7 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
not provide a correct propose_allocation() implementation */
if (gst_buffer_pool_has_option (pool,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT))
pool_options |= GST_VAAPI_OPTION_VIDEO_ALIGNMENT;
pool_options |= GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT;
/* GstVaapiVideoMeta is mandatory, and this implies VA surface memory */
if (!gst_buffer_pool_has_option (pool,

View file

@ -48,9 +48,7 @@ struct _GstVaapiVideoBufferPoolPrivate
GstAllocator *allocator;
GstVideoInfo alloc_info;
GstVaapiDisplay *display;
guint has_video_meta:1;
guint has_video_alignment:1;
guint has_texture_upload_meta:1;
guint options;
guint use_dmabuf_memory:1;
};
@ -182,19 +180,20 @@ gst_vaapi_video_buffer_pool_set_config (GstBufferPool * pool,
if (!priv->allocator)
goto error_no_allocator;
priv->has_video_meta = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
priv->options = 0;
if (gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META))
priv->options |= GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_META;
priv->has_video_alignment = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
if (priv->has_video_alignment) {
if (gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT)) {
fill_video_alignment (GST_VAAPI_VIDEO_BUFFER_POOL (pool), &align);
gst_buffer_pool_config_set_video_alignment (config, &align);
}
priv->has_texture_upload_meta = !priv->use_dmabuf_memory
&& gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
if (!priv->use_dmabuf_memory && gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META))
priv->options |= GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_GL_TEXTURE_UPLOAD;
return
GST_BUFFER_POOL_CLASS
@ -277,7 +276,7 @@ gst_vaapi_video_buffer_pool_alloc_buffer (GstBufferPool * pool,
gst_vaapi_video_meta_replace (&meta, NULL);
gst_buffer_append_memory (buffer, mem);
if (priv->has_video_meta) {
if (priv->options & GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_META) {
GstVideoInfo *const vip = &priv->alloc_info;
GstVideoMeta *vmeta;
@ -293,7 +292,7 @@ gst_vaapi_video_buffer_pool_alloc_buffer (GstBufferPool * pool,
}
}
#if (USE_GLX || USE_EGL)
if (priv->has_texture_upload_meta)
if (priv->options & GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_GL_TEXTURE_UPLOAD)
gst_buffer_add_texture_upload_meta (buffer);
#endif

View file

@ -68,6 +68,21 @@ typedef enum {
GST_BUFFER_POOL_ACQUIRE_FLAG_LAST << 0,
} GstVaapiVideoBufferPoolAcquireFlags;
/**
* GstVaapiVideoBufferPoolOption:
* @GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_META:
* @GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT:
* @GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_GL_TEXTURE_UPLOAD:
*
* Helper enum to handle the buffer pool options using bit operation.
**/
typedef enum
{
GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_META = (1u << 0),
GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT = (1u << 1),
GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_GL_TEXTURE_UPLOAD = (1u << 2),
} GstVaapiVideoBufferPoolOption;
/**
* GstVaapiVideoBufferPool:
*