From 71d3ce4de2f32b7d454345b6ec3741dce6c33fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Mon, 23 Feb 2015 16:55:36 +0100 Subject: [PATCH] plugins: upload meta only if feature and allocation Working on bug #743687, I realized that vaapidecode always adds to its buffer pool the config option GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META if the decide_allocation()'s query has GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE. Nevertheless, there are occasions where the query has the API type, but the last negotiated caps don't have the feature meta:GstVideoGLTextureUploadMeta. Under this contradiction, vaapidecode adds the GLTextureUploadMeta API to its buffer pool configuration, and adds its buffer's meta to each output buffer, even if the negotiated caps feature is memory:SystemMemory with I420 color format. This kind of output buffers chokes ClutterAutoVideosSink, since it uses a map that relates caps <-> GL upload method. If it receives a buffer with color format I420, it assumes that it doesn't have a texture upload meta, because only those with RGB color format has it. Our buffers, with I420 format, say that they have the upload meta too. In that case the mapped method is a dummy one which does nothing. I reported this issue in bug #744039 (the patch, obviously, was rejected). This patch workarounds the problem: the buffer pool's configuration option GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META is set if and only if the query has the GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE *and* the negotiated caps feature is meta:GstVideoGLTextureUploadMeta. I have tested these patches with gst-master (1.5), gst-1.4 and gst-1.2 and in all they seem to work correctly. https://bugzilla.gnome.org/show_bug.cgi?id=744618 [adapted to fit current EGL changes] Signed-off-by: Gwenole Beauchesne --- gst/vaapi/gstvaapipluginbase.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index 718e5f3ae6..29fa096ec3 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -681,7 +681,8 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin, #if GST_CHECK_VERSION(1,1,0) && (USE_GLX || USE_EGL) has_texture_upload_meta = gst_query_find_allocation_meta (query, - GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, &idx); + GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, &idx) && + (feature == GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META); #if USE_GST_GL_HELPERS if (has_texture_upload_meta) { @@ -751,11 +752,6 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin, config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); -#if GST_CHECK_VERSION(1,1,0) && (USE_GLX || USE_EGL) - if (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); } else if (has_video_alignment) { config = gst_buffer_pool_get_config (pool); @@ -766,8 +762,7 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin, /* GstVideoGLTextureUploadMeta (OpenGL) */ #if GST_CHECK_VERSION(1,1,0) && (USE_GLX || USE_EGL) - if (feature == GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META - && !has_texture_upload_meta) { + if (has_texture_upload_meta) { config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);