From: Gwenole Beauchesne Date: Mon, 28 Jul 2014 16:00:19 +0000 (+0200) Subject: vaapidecode: simplify bufferpool configuration. X-Git-Tag: 0.5.9~5 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fgstreamer-vaapi.git;a=commitdiff_plain;h=0607898019b95b28a5edda2273831ec0d60ede6c vaapidecode: simplify bufferpool configuration. Rework the logics behind the configuration of an adequate bufferpool, especially when OpenGL meta or additional capsfeatures are needed. Besides, for GStreamer >= 1.4, the first capsfeatures that gets matched, and that is not system memory, is now selected by default. --- diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index cc934e4..49dd455 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -517,11 +517,10 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query) gboolean need_pool, update_pool; gboolean has_video_meta = FALSE; gboolean has_video_alignment = FALSE; - GstVideoCodecState *state; #if GST_CHECK_VERSION(1,1,0) && USE_GLX gboolean has_texture_upload_meta = FALSE; - GstCapsFeatures *features, *features2; #endif + GstVideoCodecState *state; gst_query_parse_allocation(query, &caps, &need_pool); @@ -531,34 +530,27 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query) state = gst_video_decoder_get_output_state(vdec); decode->has_texture_upload_meta = FALSE; - has_video_meta = gst_query_find_allocation_meta(query, GST_VIDEO_META_API_TYPE, NULL); -#if GST_CHECK_VERSION(1,1,0) && USE_GLX - if (has_video_meta) - decode->has_texture_upload_meta = gst_query_find_allocation_meta(query, - GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, NULL); + has_video_meta = gst_query_find_allocation_meta(query, + GST_VIDEO_META_API_TYPE, NULL); - features = gst_caps_get_features(state->caps, 0); - features2 = gst_caps_features_new(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, NULL); +#if GST_CHECK_VERSION(1,1,0) && USE_GLX + has_texture_upload_meta = gst_query_find_allocation_meta(query, + GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, NULL); - has_texture_upload_meta = + decode->has_texture_upload_meta = gst_vaapi_find_preferred_caps_feature(GST_VIDEO_DECODER_SRC_PAD(vdec), GST_VIDEO_FORMAT_ENCODED) == GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META; +#endif /* Update src caps if feature is not handled downstream */ - if (!decode->has_texture_upload_meta && - gst_caps_features_is_equal(features, features2)) - gst_vaapidecode_update_src_caps (decode, state); - else if (has_texture_upload_meta && - !gst_caps_features_is_equal(features, features2)) { - gst_video_info_set_format(&state->info, GST_VIDEO_FORMAT_RGBA, - state->info.width, - state->info.height); + if (!gst_caps_is_always_compatible(caps, state->caps)) { + if (decode->has_texture_upload_meta) + gst_video_info_set_format(&state->info, GST_VIDEO_FORMAT_RGBA, + GST_VIDEO_INFO_WIDTH(&state->info), + GST_VIDEO_INFO_HEIGHT(&state->info)); gst_vaapidecode_update_src_caps(decode, state); } - gst_caps_features_free(features2); -#endif - gst_video_codec_state_unref(state); gst_video_info_init(&vi); @@ -609,7 +601,7 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query) gst_buffer_pool_config_add_option(config, GST_BUFFER_POOL_OPTION_VIDEO_META); #if GST_CHECK_VERSION(1,1,0) && USE_GLX - if (decode->has_texture_upload_meta) + if (has_texture_upload_meta) gst_buffer_pool_config_add_option(config, GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META); #endif @@ -622,6 +614,15 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query) gst_buffer_pool_set_config(pool, config); } +#if GST_CHECK_VERSION(1,1,0) && USE_GLX + if (decode->has_texture_upload_meta && !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); + gst_buffer_pool_set_config(pool, config); + } +#endif + if (update_pool) gst_query_set_nth_allocation_pool(query, 0, pool, size, min, max); else diff --git a/gst/vaapi/gstvaapipluginutil.c b/gst/vaapi/gstvaapipluginutil.c index 8d0b186..7c3e354 100644 --- a/gst/vaapi/gstvaapipluginutil.c +++ b/gst/vaapi/gstvaapipluginutil.c @@ -541,6 +541,12 @@ gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstVideoFormat format) GstCapsFeatures *const features = gst_caps_get_features (out_caps, i); GstStructure *const structure = gst_caps_get_structure (out_caps, i); +#if GST_CHECK_VERSION(1,3,0) + /* Skip ANY features, we need an exact match for correct evaluation */ + if (gst_caps_features_is_any (features)) + continue; +#endif + caps = gst_caps_new_full (gst_structure_copy (structure), NULL); if (!caps) continue; @@ -556,6 +562,13 @@ gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstVideoFormat format) feature < GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY) feature = GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY; gst_caps_replace (&caps, NULL); + +#if GST_CHECK_VERSION(1,3,0) + /* Stop at the first match, the caps should already be sorted out + by preference order from downstream elements */ + if (feature != GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY) + break; +#endif } cleanup: