baseparse: Try harder to fixate caps based on upstream in default negotiation

Upstream might provide a width/height while downstream has the field but accepts
a range. gst_caps_fixate() would select the minimum value of that range later
but it would be more accurate to take the upstream value, at least if it's a
subset of what downstream accepts.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4608

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9593>
This commit is contained in:
Sebastian Dröge 2025-08-21 09:02:45 +03:00 committed by GStreamer Marge Bot
parent c24dc93944
commit e8ab8eccae

View File

@ -1166,9 +1166,16 @@ update_upstream_provided (const GstIdStr * field, const GValue * value,
GstStructure *structure = gst_caps_get_structure (default_caps, i);
if (!gst_structure_has_field (structure, gst_id_str_as_str (field))) {
gst_structure_id_str_set_value (structure, field, value);
} else {
const GValue *v = gst_structure_id_str_get_value (structure, field);
// If a downstream caps field is not fixed and the upstream value is a
// subset, take over the value from the upstream caps.
// Otherwise let gst_caps_fixate() take care of it later.
if (!gst_value_is_fixed (v) && gst_value_is_subset (value, v)) {
gst_structure_id_str_set_value (structure, field, value);
}
}
/* XXX: maybe try to fixate better than gst_caps_fixate() the
* downstream caps based on upstream values if possible */
}
return TRUE;