From 0a80b57d74fd2146afcc1f7fc0c2e46ffd01ec50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 30 May 2011 11:33:57 +0200 Subject: [PATCH] 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. --- gst/gststructure.c | 37 ------------------------------------- gst/gstvalue.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 37 deletions(-) diff --git a/gst/gststructure.c b/gst/gststructure.c index 1f3a462f35..3b2c2e4121 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -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; diff --git a/gst/gstvalue.c b/gst/gstvalue.c index 8baf1e6150..3817160941 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -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;