From 8d42c95b0f706a1bf1649bfafef607fc951e5027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 29 Mar 2016 14:17:54 +0200 Subject: [PATCH] plugin: use allowed caps filter from element Instead of using the srcpad template caps for filtering the peer caps, the function gst_vaapi_find_preferred_caps_feature(), now receives a new parameter for the element's allowed caps. With this modification, the vaapipostproc element simplifies a bit its code. https://bugzilla.gnome.org/show_bug.cgi?id=765223 --- gst/vaapi/gstvaapidecode.c | 8 +++++--- gst/vaapi/gstvaapipluginbase.c | 3 ++- gst/vaapi/gstvaapipluginutil.c | 12 ++++++------ gst/vaapi/gstvaapipluginutil.h | 2 +- gst/vaapi/gstvaapipostproc.c | 25 ++++++++----------------- 5 files changed, 22 insertions(+), 28 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index 6bf21268e4..7857a0a09a 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -236,6 +236,8 @@ static gboolean gst_vaapidecode_update_src_caps (GstVaapiDecode * decode) { GstVideoDecoder *const vdec = GST_VIDEO_DECODER (decode); + GstPad *const srcpad = GST_VIDEO_DECODER_SRC_PAD (vdec); + GstCaps *templ; GstVideoCodecState *state, *ref_state; GstVaapiCapsFeature feature; GstCapsFeatures *features = NULL; @@ -253,9 +255,9 @@ gst_vaapidecode_update_src_caps (GstVaapiDecode * decode) ref_state = decode->input_state; format = GST_VIDEO_INFO_FORMAT (&decode->decoded_info); - feature = - gst_vaapi_find_preferred_caps_feature (GST_VIDEO_DECODER_SRC_PAD (vdec), - &format); + templ = gst_pad_get_pad_template_caps (srcpad); + feature = gst_vaapi_find_preferred_caps_feature (srcpad, templ, &format); + gst_caps_unref (templ); if (feature == GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED) return FALSE; diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index 5b80a9c51c..34138b293b 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -621,7 +621,8 @@ gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin, goto error_no_caps; if (!feature) - feature = gst_vaapi_find_preferred_caps_feature (plugin->srcpad, NULL); + feature = gst_vaapi_find_preferred_caps_feature (plugin->srcpad, caps, + NULL); has_video_meta = gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); diff --git a/gst/vaapi/gstvaapipluginutil.c b/gst/vaapi/gstvaapipluginutil.c index 50240cb5d8..f774916d5d 100644 --- a/gst/vaapi/gstvaapipluginutil.c +++ b/gst/vaapi/gstvaapipluginutil.c @@ -479,24 +479,24 @@ gst_vaapi_find_preferred_format (const GValue * format_list, } GstVaapiCapsFeature -gst_vaapi_find_preferred_caps_feature (GstPad * pad, +gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps, GstVideoFormat * out_format_ptr) { GstVaapiCapsFeature feature = GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED; guint i, j, num_structures; - GstCaps *caps = NULL; - GstCaps *out_caps, *templ; + GstCaps *out_caps, *caps = NULL; static const guint feature_list[] = { GST_VAAPI_CAPS_FEATURE_VAAPI_SURFACE, GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META, GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY, }; - templ = gst_pad_get_pad_template_caps (pad); - out_caps = gst_pad_peer_query_caps (pad, templ); - gst_caps_unref (templ); + out_caps = gst_pad_peer_query_caps (pad, allowed_caps); if (!out_caps) goto cleanup; + if (gst_caps_is_any (out_caps) || gst_caps_is_empty (out_caps)) + goto cleanup; + feature = GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY; num_structures = gst_caps_get_size (out_caps); for (i = 0; i < num_structures; i++) { diff --git a/gst/vaapi/gstvaapipluginutil.h b/gst/vaapi/gstvaapipluginutil.h index f1244033c2..1589638d76 100644 --- a/gst/vaapi/gstvaapipluginutil.h +++ b/gst/vaapi/gstvaapipluginutil.h @@ -84,7 +84,7 @@ gst_vaapi_video_format_new_template_caps_with_features (GstVideoFormat format, G_GNUC_INTERNAL GstVaapiCapsFeature -gst_vaapi_find_preferred_caps_feature (GstPad * pad, +gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps, GstVideoFormat * out_format_ptr); G_GNUC_INTERNAL diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c index 9f066e46cc..53b2b70a79 100644 --- a/gst/vaapi/gstvaapipostproc.c +++ b/gst/vaapi/gstvaapipostproc.c @@ -1105,29 +1105,20 @@ gst_vaapipostproc_transform_caps_impl (GstBaseTransform * trans, * if the user didn't explicitly ask for colorspace conversion. * Use a filter caps which contain all raw video formats, (excluding * GST_VIDEO_FORMAT_ENCODED) */ + out_format = GST_VIDEO_FORMAT_UNKNOWN; if (postproc->format != DEFAULT_FORMAT) out_format = postproc->format; - else { - GstCaps *peer_caps; - GstVideoInfo peer_vi; - peer_caps = - gst_pad_peer_query_caps (GST_BASE_TRANSFORM_SRC_PAD (trans), - postproc->allowed_srcpad_caps); - if (gst_caps_is_any (peer_caps) || gst_caps_is_empty (peer_caps)) - return peer_caps; - if (!gst_caps_is_fixed (peer_caps)) - peer_caps = gst_caps_fixate (peer_caps); - gst_video_info_from_caps (&peer_vi, peer_caps); - out_format = GST_VIDEO_INFO_FORMAT (&peer_vi); - if (peer_caps) - gst_caps_unref (peer_caps); - } feature = gst_vaapi_find_preferred_caps_feature (GST_BASE_TRANSFORM_SRC_PAD (trans), - &out_format); - gst_video_info_change_format (&vi, out_format, width, height); + postproc->allowed_srcpad_caps, + (out_format == GST_VIDEO_FORMAT_UNKNOWN) ? &out_format : NULL); + if (feature == GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED) + return gst_pad_peer_query_caps (GST_BASE_TRANSFORM_SRC_PAD (trans), + postproc->allowed_srcpad_caps); + + gst_video_info_change_format (&vi, out_format, width, height); out_caps = gst_video_info_to_caps (&vi); if (!out_caps) return NULL;