summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f56c6e1)
raw | patch | inline | side by side (parent: f56c6e1)
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | |
Thu, 5 May 2011 09:28:38 +0000 (11:28 +0200) | ||
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | |
Sat, 14 May 2011 09:39:34 +0000 (11:39 +0200) |
This prevents adding duplicates over and over again to the resulting
caps if they already describe the new intersection result.
While this changes intersection from O(n*m) to O(n^2*m), it results in
smaller caps, which in the end will decrease further processing times.
For example in an audioconvert ! audioconvert ! audioconvert pipeline,
when forwarding the downstream caps preference in basetransform
(see e26da72de25a91c3eaad9f7c8b2f53ba888a0394) this results in
16 instead of 191 caps structures.
caps if they already describe the new intersection result.
While this changes intersection from O(n*m) to O(n^2*m), it results in
smaller caps, which in the end will decrease further processing times.
For example in an audioconvert ! audioconvert ! audioconvert pipeline,
when forwarding the downstream caps preference in basetransform
(see e26da72de25a91c3eaad9f7c8b2f53ba888a0394) this results in
16 instead of 191 caps structures.
gst/gstcaps.c | patch | blob | history | |
tests/check/gst/gstcaps.c | patch | blob | history |
diff --git a/gst/gstcaps.c b/gst/gstcaps.c
index 5d8912c4d365ebdcb487692de5d6c8a51a1e578c..84fce69a180df05ca5d9a5ded392404ab771595d 100644 (file)
--- a/gst/gstcaps.c
+++ b/gst/gstcaps.c
istruct = gst_caps_structure_intersect (struct1, struct2);
- gst_caps_append_structure (dest, istruct);
+ gst_caps_merge_structure (dest, istruct);
/* move down left */
k++;
if (G_UNLIKELY (j == 0))
struct2 = gst_caps_get_structure_unchecked (caps2, j);
istruct = gst_caps_structure_intersect (struct1, struct2);
if (istruct)
- gst_caps_append_structure (dest, istruct);
+ gst_caps_merge_structure (dest, istruct);
}
}
index fa160d91dd3320d8611fbb0bae7a5d55d466175c..a22c15f0d2ce095741d5ac17f6383ea281379ccb 100644 (file)
GST_END_TEST;
+GST_START_TEST (test_intersect_duplication)
+{
+ GstCaps *c1, *c2, *test;
+
+ c1 = gst_caps_from_string
+ ("audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2 ]");
+ c2 = gst_caps_from_string
+ ("audio/x-raw-int, width=(int)16, depth=(int)16, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2 ], endianness=(int){ 1234, 4321 }, signed=(boolean){ true, false }; audio/x-raw-int, width=(int)16, depth=(int)16, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 11 ], endianness=(int){ 1234, 4321 }, signed=(boolean){ true, false }; audio/x-raw-int, width=(int)16, depth=(int)[ 1, 16 ], rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 11 ], endianness=(int){ 1234, 4321 }, signed=(boolean){ true, false }");
+
+ test = gst_caps_intersect_full (c1, c2, GST_CAPS_INTERSECT_FIRST);
+ fail_unless_equals_int (gst_caps_get_size (test), 1);
+ fail_unless (gst_caps_is_equal (c1, test));
+ gst_caps_unref (c1);
+ gst_caps_unref (c2);
+ gst_caps_unref (test);
+}
+
+GST_END_TEST;
static gboolean
_caps_is_fixed_foreach (GQuark field_id, const GValue * value, gpointer unused)
tcase_add_test (tc_chain, test_intersect_zigzag);
tcase_add_test (tc_chain, test_intersect_first);
tcase_add_test (tc_chain, test_intersect_first2);
+ tcase_add_test (tc_chain, test_intersect_duplication);
tcase_add_test (tc_chain, test_normalize);
tcase_add_test (tc_chain, test_broken);