plugin: if any caps in downstream, negotiate raw video

When downstream has any caps, vaapi should not shovel vaapi featured
buffers, but rather plain raw video, assuming always the worst case
scenario (downstream cannot handle featured video memory but raw
system memory buffers).

This patch query the peer caps without any filter, to know if
donwstream just ask for any caps, if so jump to the color space
checking, otherwise do the caps intersection and continue with the
feature selection algorithm.

Fixes: #139
parent 3fa74d78
Pipeline #21595 passed with stages
in 20 minutes and 53 seconds
......@@ -638,21 +638,31 @@ gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps,
guint i, j, num_structures;
GstCaps *out_caps, *caps = NULL;
GstCaps *peer_caps, *out_caps = NULL, *caps = NULL;
static const guint feature_list[] = { GST_VAAPI_CAPS_FEATURE_VAAPI_SURFACE,
out_caps = gst_pad_peer_query_caps (pad, allowed_caps);
if (!out_caps)
/* query with no filter */
peer_caps = gst_pad_peer_query_caps (pad, NULL);
if (!peer_caps)
goto cleanup;
if (gst_caps_is_any (out_caps) || gst_caps_is_empty (out_caps))
if (gst_caps_is_empty (peer_caps))
goto cleanup;
/* filter against our allowed caps */
out_caps = gst_caps_intersect_full (allowed_caps, peer_caps,
/* default feature */
/* if downstream requests caps ANY, system memory is preferred */
if (gst_caps_is_any (peer_caps))
goto find_format;
num_structures = gst_caps_get_size (out_caps);
for (i = 0; i < num_structures; i++) {
GstCapsFeatures *const features = gst_caps_get_features (out_caps, i);
......@@ -685,13 +695,14 @@ gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps,
if (!caps)
goto cleanup;
if (out_format_ptr) {
GstVideoFormat out_format;
GstStructure *structure;
const GValue *format_list;
/* if the best feature is SystemMemory, we should use the first
* caps in the peer caps set, which is the preferred by
* caps in the filtered peer caps set, which is the preferred by
* downstream. */
gst_caps_replace (&caps, out_caps);
......@@ -713,6 +724,7 @@ gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps,
gst_caps_replace (&caps, NULL);
gst_caps_replace (&out_caps, NULL);
gst_caps_replace (&peer_caps, NULL);
return feature;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment