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 <gwenole.beauchesne@intel.com>
This commit is contained in:
Víctor Manuel Jáquez Leal 2015-02-23 16:55:36 +01:00 committed by Gwenole Beauchesne
parent 6a465ae793
commit 71d3ce4de2

View file

@ -681,7 +681,8 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
#if GST_CHECK_VERSION(1,1,0) && (USE_GLX || USE_EGL) #if GST_CHECK_VERSION(1,1,0) && (USE_GLX || USE_EGL)
has_texture_upload_meta = gst_query_find_allocation_meta (query, 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 USE_GST_GL_HELPERS
if (has_texture_upload_meta) { if (has_texture_upload_meta) {
@ -751,11 +752,6 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_add_option (config, gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META); 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); gst_buffer_pool_set_config (pool, config);
} else if (has_video_alignment) { } else if (has_video_alignment) {
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
@ -766,8 +762,7 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
/* GstVideoGLTextureUploadMeta (OpenGL) */ /* GstVideoGLTextureUploadMeta (OpenGL) */
#if GST_CHECK_VERSION(1,1,0) && (USE_GLX || USE_EGL) #if GST_CHECK_VERSION(1,1,0) && (USE_GLX || USE_EGL)
if (feature == GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META if (has_texture_upload_meta) {
&& !has_texture_upload_meta) {
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_add_option (config, gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META); GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);