diff --git a/ChangeLog b/ChangeLog index 34d9955d0d..a88c9d5dcc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-07-20 Ronald Bultje + + * docs/random/ds/0.9-suggested-changes: + Make note about renaming fixed-list to array. + * gst/gstvalue.c: (gst_value_intersect_fixed_list), + (_gst_value_initialize): + Add array intersections. + * testsuite/caps/intersect2.c: (main): + Add test for array intersections. + 2004-07-20 Thomas Vander Stichele * configure.ac: back to cvs diff --git a/docs/random/ds/0.9-suggested-changes b/docs/random/ds/0.9-suggested-changes index e5dae51536..e12ee7889a 100644 --- a/docs/random/ds/0.9-suggested-changes +++ b/docs/random/ds/0.9-suggested-changes @@ -69,6 +69,8 @@ API: so that you can search a GstPlay for an element implementing the interface (right now gstplay has added a gst_play_get_by_interface) + - rename GST_TYPE_FIXED_LIST to GST_TYPE_ARRAY + caps: (Company:) diff --git a/gst/gstvalue.c b/gst/gstvalue.c index ad053100af..59a04b874a 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -1525,6 +1525,32 @@ gst_value_intersect_list (GValue * dest, const GValue * value1, return ret; } +static gboolean +gst_value_intersect_fixed_list (GValue * dest, const GValue * src1, + const GValue * src2) +{ + gint size, n; + GValue val = { 0 }; + + /* only works on similar-sized arrays */ + size = gst_value_list_get_size (src1); + if (size != gst_value_list_get_size (src2)) + return FALSE; + g_value_init (dest, GST_TYPE_FIXED_LIST); + + for (n = 0; n < size; n++) { + if (!gst_value_intersect (&val, gst_value_list_get_value (src1, n), + gst_value_list_get_value (src2, n))) { + g_value_unset (dest); + return FALSE; + } + gst_value_list_append_value (dest, &val); + g_value_unset (&val); + } + + return TRUE; +} + /*************** * subtraction * ***************/ @@ -2800,6 +2826,8 @@ _gst_value_initialize (void) gst_value_intersect_double_double_range); gst_value_register_intersect_func (GST_TYPE_DOUBLE_RANGE, GST_TYPE_DOUBLE_RANGE, gst_value_intersect_double_range_double_range); + gst_value_register_intersect_func (GST_TYPE_FIXED_LIST, + GST_TYPE_FIXED_LIST, gst_value_intersect_fixed_list); gst_value_register_subtract_func (G_TYPE_INT, GST_TYPE_INT_RANGE, gst_value_subtract_int_int_range); diff --git a/tests/old/testsuite/caps/intersect2.c b/tests/old/testsuite/caps/intersect2.c index 7eef6dd52c..e43bc63970 100644 --- a/tests/old/testsuite/caps/intersect2.c +++ b/tests/old/testsuite/caps/intersect2.c @@ -34,6 +34,20 @@ GstStaticCaps rawcaps8 = GST_STATIC_CAPS ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"); +GstStaticCaps rawcaps9 = + GST_STATIC_CAPS + ("audio/x-raw-float, " + "channel-positions=(int)< " + "{ 1, 2, 3, 4, 5, 6 }, " + "{ 1, 2 }, " + "{ 1, 2, 3, 4, 5, 6 }, " "{ 1, 2, 3, 4, 5, 6 }, " "{ 4, 5, 6 }, " "6 >"); + +GstStaticCaps rawcaps10 = + GST_STATIC_CAPS + ("audio/x-raw-float, " + "channel-positions=(int)< 1, { 2, 3, 4, 5, 6 }, 3, 4, {4, 5, 6 }, " + "{ 4, 5, 6 } >"); + int main (int argc, char *argv[]) @@ -94,5 +108,14 @@ main (int argc, char *argv[]) gst_caps_free (caps1); gst_caps_free (caps2); + caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps9)); + caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps10)); + caps = gst_caps_intersect (caps1, caps2); + g_print ("caps %s\n", gst_caps_to_string (caps)); + if (gst_caps_is_empty (caps)) + return 1; + gst_caps_free (caps1); + gst_caps_free (caps2); + return 0; } diff --git a/testsuite/caps/intersect2.c b/testsuite/caps/intersect2.c index 7eef6dd52c..e43bc63970 100644 --- a/testsuite/caps/intersect2.c +++ b/testsuite/caps/intersect2.c @@ -34,6 +34,20 @@ GstStaticCaps rawcaps8 = GST_STATIC_CAPS ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"); +GstStaticCaps rawcaps9 = + GST_STATIC_CAPS + ("audio/x-raw-float, " + "channel-positions=(int)< " + "{ 1, 2, 3, 4, 5, 6 }, " + "{ 1, 2 }, " + "{ 1, 2, 3, 4, 5, 6 }, " "{ 1, 2, 3, 4, 5, 6 }, " "{ 4, 5, 6 }, " "6 >"); + +GstStaticCaps rawcaps10 = + GST_STATIC_CAPS + ("audio/x-raw-float, " + "channel-positions=(int)< 1, { 2, 3, 4, 5, 6 }, 3, 4, {4, 5, 6 }, " + "{ 4, 5, 6 } >"); + int main (int argc, char *argv[]) @@ -94,5 +108,14 @@ main (int argc, char *argv[]) gst_caps_free (caps1); gst_caps_free (caps2); + caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps9)); + caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps10)); + caps = gst_caps_intersect (caps1, caps2); + g_print ("caps %s\n", gst_caps_to_string (caps)); + if (gst_caps_is_empty (caps)) + return 1; + gst_caps_free (caps1); + gst_caps_free (caps2); + return 0; }