mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-03 02:11:21 +00:00
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/370>
This commit is contained in:
parent
cf3b0120cb
commit
80b1e53ccc
1 changed files with 10 additions and 20 deletions
|
@ -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);
|
caps = gst_caps_new_full (gst_structure_copy (structure), NULL);
|
||||||
if (!caps)
|
if (!caps)
|
||||||
continue;
|
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++) {
|
for (j = 0; j < G_N_ELEMENTS (feature_list); j++) {
|
||||||
if (gst_vaapi_caps_feature_contains (caps, 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!caps)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
find_format:
|
find_format:
|
||||||
|
if (!caps)
|
||||||
|
caps = gst_caps_ref (out_caps);
|
||||||
|
|
||||||
if (out_format_ptr) {
|
if (out_format_ptr) {
|
||||||
GstVideoFormat out_format;
|
GstVideoFormat out_format;
|
||||||
GstStructure *structure = NULL;
|
GstStructure *structure = NULL;
|
||||||
const GValue *format_list;
|
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);
|
num_structures = gst_caps_get_size (caps);
|
||||||
for (i = 0; i < num_structures; i++) {
|
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);
|
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)
|
if (!structure)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
Loading…
Reference in a new issue