From 57074fc0259def8928d4701df2fbb4367b818ce0 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 3 Nov 2011 15:35:32 +0000 Subject: [PATCH 1/2] caps: Add gst_caps_is_strictly_equal --- gst/gstcaps.c | 41 +++++++++++++++++++++++++++++++++++++++++ gst/gstcaps.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 3652a44562..f9ce800583 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -1180,6 +1180,47 @@ gst_caps_is_equal (const GstCaps * caps1, const GstCaps * caps2) return gst_caps_is_subset (caps1, caps2) && gst_caps_is_subset (caps2, caps1); } +/** + * gst_caps_is_strictly_equal: + * @caps1: a #GstCaps + * @caps2: another #GstCaps + * + * Checks if the given caps are exactly the same set of caps. + * + * This function deals correctly with passing NULL for any of the caps. + * + * Returns: TRUE if both caps are strictly equal. + * + * Since: 0.10.36 + */ +gboolean +gst_caps_is_strictly_equal (const GstCaps * caps1, const GstCaps * caps2) +{ + int i; + /* FIXME 0.11: NULL pointers are no valid Caps but indicate an error + * So there should be an assertion that caps1 and caps2 != NULL */ + + /* NULL <-> NULL is allowed here */ + if (G_UNLIKELY (caps1 == caps2)) + return TRUE; + + /* one of them NULL => they are different (can't be both NULL because + * we checked that above) */ + if (G_UNLIKELY (caps1 == NULL || caps2 == NULL)) + return FALSE; + + if (caps1->structs->len != caps2->structs->len) + return FALSE; + + for (i = 0; i < caps1->structs->len; i++) { + if (!gst_structure_is_equal (gst_caps_get_structure_unchecked (caps1, i), + gst_caps_get_structure_unchecked (caps2, i))) + return FALSE; + } + + return TRUE; +} + /* intersect operation */ /** diff --git a/gst/gstcaps.h b/gst/gstcaps.h index 47c0d33fda..56a8441b40 100644 --- a/gst/gstcaps.h +++ b/gst/gstcaps.h @@ -268,6 +268,8 @@ gboolean gst_caps_is_equal_fixed (const GstCaps *caps1, const GstCaps *caps2); gboolean gst_caps_can_intersect (const GstCaps * caps1, const GstCaps * caps2); +gboolean gst_caps_is_strictly_equal (const GstCaps *caps1, + const GstCaps *caps2); /* operations */ From e97eeb5cd48ac7428230a43602bd79a33f3dcb7d Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 3 Nov 2011 15:36:59 +0000 Subject: [PATCH 2/2] basetransform: Only use the cached transform on strictly equal caps https://bugzilla.gnome.org/show_bug.cgi?id=663333 --- libs/gst/base/gstbasetransform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index 0174ac8c8b..d3889324ef 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -709,7 +709,7 @@ gst_base_transform_getcaps (GstPad * pad) peercaps = gst_pad_peer_get_caps_reffed (otherpad); GST_OBJECT_LOCK (trans); samecaps = (peercaps && trans->priv->cached_peer_caps[cache_index] - && gst_caps_is_equal (peercaps, + && gst_caps_is_strictly_equal (peercaps, trans->priv->cached_peer_caps[cache_index])); if (!samecaps) { if (trans->priv->cached_peer_caps[cache_index]) {