mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
value: Consider "1" and "{1}" as equal in gst_value_compare()
Previously this was only done in the is_subset() check but having it only there brings us into definition-hell where "1" and "{1}" are subset of each other but not equal.
This commit is contained in:
parent
f304196148
commit
0a80b57d74
2 changed files with 18 additions and 37 deletions
|
@ -3107,48 +3107,11 @@ gst_caps_structure_is_subset_field (GQuark field_id, const GValue * value,
|
|||
GstStructure *superset = user_data;
|
||||
GValue subtraction = { 0, };
|
||||
const GValue *other;
|
||||
GType ltype;
|
||||
|
||||
if (!(other = gst_structure_id_get_value (superset, field_id)))
|
||||
/* field is missing in the superset => is subset */
|
||||
return TRUE;
|
||||
|
||||
/* Special case: lists and scalar values
|
||||
* "{ 1 }" and "1" subsets of each other
|
||||
* but not strictly equal */
|
||||
ltype = gst_value_list_get_type ();
|
||||
if (G_VALUE_HOLDS (other, ltype) && !G_VALUE_HOLDS (value, ltype)) {
|
||||
const GValue *elt;
|
||||
gint i, n;
|
||||
gboolean all_equal = TRUE;
|
||||
|
||||
n = gst_value_list_get_size (other);
|
||||
for (i = 0; i < n; i++) {
|
||||
elt = gst_value_list_get_value (other, 0);
|
||||
if (gst_value_compare (elt, value) != GST_VALUE_EQUAL) {
|
||||
all_equal = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (all_equal)
|
||||
return TRUE;
|
||||
} else if (G_VALUE_HOLDS (value, ltype) && !G_VALUE_HOLDS (other, ltype)) {
|
||||
const GValue *elt;
|
||||
gint i, n;
|
||||
gboolean all_equal = TRUE;
|
||||
|
||||
n = gst_value_list_get_size (value);
|
||||
for (i = 0; i < n; i++) {
|
||||
elt = gst_value_list_get_value (value, 0);
|
||||
if (gst_value_compare (elt, other) != GST_VALUE_EQUAL) {
|
||||
all_equal = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (all_equal)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* equal values are subset */
|
||||
if (gst_value_compare (other, value) == GST_VALUE_EQUAL)
|
||||
return TRUE;
|
||||
|
|
|
@ -3394,10 +3394,28 @@ gint
|
|||
gst_value_compare (const GValue * value1, const GValue * value2)
|
||||
{
|
||||
GstValueCompareFunc compare;
|
||||
GType ltype;
|
||||
|
||||
g_return_val_if_fail (G_IS_VALUE (value1), GST_VALUE_LESS_THAN);
|
||||
g_return_val_if_fail (G_IS_VALUE (value2), GST_VALUE_GREATER_THAN);
|
||||
|
||||
/* Special case: lists and scalar values
|
||||
* "{ 1 }" and "1" are equal */
|
||||
ltype = gst_value_list_get_type ();
|
||||
if (G_VALUE_HOLDS (value1, ltype) && !G_VALUE_HOLDS (value2, ltype)
|
||||
&& gst_value_list_get_size (value1) == 1) {
|
||||
const GValue *elt;
|
||||
|
||||
elt = gst_value_list_get_value (value1, 0);
|
||||
return gst_value_compare (elt, value2);
|
||||
} else if (G_VALUE_HOLDS (value2, ltype) && !G_VALUE_HOLDS (value1, ltype)
|
||||
&& gst_value_list_get_size (value2) == 1) {
|
||||
const GValue *elt;
|
||||
|
||||
elt = gst_value_list_get_value (value2, 0);
|
||||
return gst_value_compare (elt, value1);
|
||||
}
|
||||
|
||||
if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2))
|
||||
return GST_VALUE_UNORDERED;
|
||||
|
||||
|
|
Loading…
Reference in a new issue