From 80b1e53cccfe91e96c17d2015918b565b4315eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Wed, 29 Jul 2020 13:39:44 +0200 Subject: vaapipluginutil: simplify gst_vaapi_find_preferred_caps_feature() Generalize the way how the preferred color format is chosen. Also use new GStreamre API as syntatic sugar. Part-of: --- gst/vaapi/gstvaapipluginutil.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'gst') diff --git a/gst/vaapi/gstvaapipluginutil.c b/gst/vaapi/gstvaapipluginutil.c index aa485314..f5eb6d56 100644 --- a/gst/vaapi/gstvaapipluginutil.c +++ b/gst/vaapi/gstvaapipluginutil.c @@ -683,7 +683,7 @@ gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps, caps = gst_caps_new_full (gst_structure_copy (structure), NULL); if (!caps) continue; - gst_caps_set_features (caps, 0, gst_caps_features_copy (features)); + gst_caps_set_features_simple (caps, gst_caps_features_copy (features)); for (j = 0; j < G_N_ELEMENTS (feature_list); j++) { if (gst_vaapi_caps_feature_contains (caps, feature_list[j]) @@ -699,33 +699,23 @@ gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps, break; } +find_format: if (!caps) - goto cleanup; + caps = gst_caps_ref (out_caps); -find_format: if (out_format_ptr) { GstVideoFormat out_format; GstStructure *structure = NULL; const GValue *format_list; - GstCapsFeatures *features; - - /* if the best feature is SystemMemory, we should choose the - * vidoe/x-raw caps in the filtered peer caps set. If not, use - * the first caps, which is the preferred by downstream. */ - if (feature == GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY) { - gst_caps_replace (&caps, out_caps); - num_structures = gst_caps_get_size (caps); - for (i = 0; i < num_structures; i++) { + + num_structures = gst_caps_get_size (caps); + for (i = 0; i < num_structures; i++) { + GstCapsFeatures *const features = gst_caps_get_features (caps, i); + if (gst_caps_features_contains (features, + gst_vaapi_caps_feature_to_string (feature))) { structure = gst_caps_get_structure (caps, i); - features = gst_caps_get_features (caps, i); - if (!gst_caps_features_is_any (features) - && gst_caps_features_contains (features, - gst_vaapi_caps_feature_to_string - (GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY))) - break; + break; } - } else { - structure = gst_caps_get_structure (caps, 0); } if (!structure) goto cleanup; -- cgit v1.2.1