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
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-03-29 14:17:54 +02:00
parent 2d7d38cb9c
commit 8d42c95b0f
5 changed files with 22 additions and 28 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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++) {

View file

@ -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

View file

@ -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;