gst/gstcaps.c: fix simplifying and subtracting not working correctly with optional...
authorBenjamin Otte <otte@gnome.org>
Thu, 22 Apr 2004 23:50:46 +0000 (23:50 +0000)
committerBenjamin Otte <otte@gnome.org>
Thu, 22 Apr 2004 23:50:46 +0000 (23:50 +0000)
Original commit message from CVS:
* gst/gstcaps.c: (gst_caps_structure_subtract_field),
(gst_caps_structure_subtract), (gst_caps_subtract),
(gst_caps_structure_figure_out_union),
(gst_caps_structure_simplify), (gst_caps_do_simplify):
fix simplifying and subtracting not working correctly with optional
properties
solve assorted problems that make it now simplify ebven more
* docs/gst/tmpl/gstcaps.sgml:
* gst/gstcaps.h:
make gst_caps_do_simplify return a bool to indicate if it simplified
* testsuite/caps/simplify.c: (main):
add more checks. The tests is quite a bit useless right now because
the core is heavily simplifying itself.
* testsuite/caps/caps.h:
fix caps to contain all optional properties

ChangeLog
docs/gst/tmpl/gstcaps.sgml
gst/gstcaps.c
gst/gstcaps.h
tests/old/testsuite/caps/caps.h
tests/old/testsuite/caps/simplify.c
testsuite/caps/caps.h
testsuite/caps/simplify.c

index 6ce766b7dde2e80f0b26f6b1222751268675056c..49cccf9216bb25ea2dbc2f3865107f01e3fe8acd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2004-04-23  Benjamin Otte  <otte@gnome.org>
+         
+       * gst/gstcaps.c: (gst_caps_structure_subtract_field),
+       (gst_caps_structure_subtract), (gst_caps_subtract),
+       (gst_caps_structure_figure_out_union),
+       (gst_caps_structure_simplify), (gst_caps_do_simplify):
+         fix simplifying and subtracting not working correctly with optional
+         properties
+         solve assorted problems that make it now simplify ebven more
+       * docs/gst/tmpl/gstcaps.sgml:
+       * gst/gstcaps.h:
+         make gst_caps_do_simplify return a bool to indicate if it simplified
+       * testsuite/caps/simplify.c: (main):
+         add more checks. The tests is quite a bit useless right now because
+         the core is heavily simplifying itself.
+       * testsuite/caps/caps.h:
+         fix caps to contain all optional properties
+
 2004-04-22  Benjamin Otte  <otte@gnome.org>
 
        * docs/gst/tmpl/gstcaps.sgml:
index 353904bffe9324e33a60cfee1491fb6b3b193331..4c43a70b200001ff1c60c2a63420ef7247818a53 100644 (file)
@@ -373,6 +373,7 @@ Structure describing sets of media formats
 </para>
 
 @caps: 
+@Returns: 
 
 
 <!-- ##### FUNCTION gst_caps_save_thyself ##### -->
index b7da8906f031e03e57b6041cd0cd408f5c34b9f3..cb1a940e600cdfede9122eee01b7212cd19bc0fb 100644 (file)
@@ -900,7 +900,7 @@ gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2)
 typedef struct
 {
   const GstStructure *subtract_from;
-  GstCaps *put_into;
+  GSList *put_into;
 }
 SubtractionEntry;
 
@@ -915,33 +915,46 @@ gst_caps_structure_subtract_field (GQuark field_id, GValue * value,
   GstStructure *structure;
 
   other = gst_structure_id_get_value (e->subtract_from, field_id);
-  if (!other)
-    return TRUE;
+  if (!other) {
+    return FALSE;
+  }
   if (!gst_value_subtract (&subtraction, other, value))
     return TRUE;
-  structure = gst_structure_copy (e->subtract_from);
   if (gst_value_compare (&subtraction, other) == GST_VALUE_EQUAL) {
-    gst_caps_append_structure (e->put_into, structure);
+    g_value_unset (&subtraction);
     return FALSE;
   } else {
+    structure = gst_structure_copy (e->subtract_from);
     gst_structure_id_set_value (structure, field_id, &subtraction);
     g_value_unset (&subtraction);
-    gst_caps_append_structure (e->put_into, structure);
+    e->put_into = g_slist_prepend (e->put_into, structure);
     return TRUE;
   }
 }
 
-static void
-gst_caps_structure_subtract (GstCaps * into, const GstStructure * minuend,
+static gboolean
+gst_caps_structure_subtract (GSList ** into, const GstStructure * minuend,
     const GstStructure * subtrahend)
 {
   SubtractionEntry e;
+  gboolean ret;
 
   e.subtract_from = minuend;
-  e.put_into = into;
+  e.put_into = NULL;
 
-  gst_structure_foreach ((GstStructure *) subtrahend,
+  ret = gst_structure_foreach ((GstStructure *) subtrahend,
       gst_caps_structure_subtract_field, &e);
+  if (ret) {
+    *into = e.put_into;
+  } else {
+    GSList *walk;
+
+    for (walk = e.put_into; walk; walk = g_slist_next (walk)) {
+      gst_structure_free (walk->data);
+    }
+    g_slist_free (e.put_into);
+  }
+  return ret;
 }
 
 GstCaps *
@@ -979,7 +992,18 @@ gst_caps_subtract (const GstCaps * minuend, const GstCaps * subtrahend)
     for (j = 0; j < src->structs->len; j++) {
       min = gst_caps_get_structure (src, j);
       if (gst_structure_get_name_id (min) == gst_structure_get_name_id (sub)) {
-        gst_caps_structure_subtract (dest, min, sub);
+        GSList *list;
+
+        if (gst_caps_structure_subtract (&list, min, sub)) {
+          GSList *walk;
+
+          for (walk = list; walk; walk = g_slist_next (walk)) {
+            gst_caps_append_structure (dest, (GstStructure *) walk->data);
+          }
+          g_slist_free (list);
+        } else {
+          gst_caps_append_structure (dest, gst_structure_copy (min));
+        }
       } else {
         gst_caps_append_structure (dest, gst_structure_copy (min));
       }
@@ -988,6 +1012,7 @@ gst_caps_subtract (const GstCaps * minuend, const GstCaps * subtrahend)
       return dest;
   }
 
+  gst_caps_do_simplify (dest);
   return dest;
 }
 
@@ -1123,7 +1148,6 @@ gst_caps_simplify (const GstCaps * caps)
   return ret;
 }
 
-/* need this here */
 typedef struct
 {
   GQuark name;
@@ -1132,15 +1156,18 @@ typedef struct
 }
 UnionField;
 
-static G_GNUC_UNUSED gboolean
+static gboolean
 gst_caps_structure_figure_out_union (GQuark field_id, GValue * value,
     gpointer user_data)
 {
   UnionField *u = user_data;
   const GValue *val = gst_structure_id_get_value (u->compare, field_id);
 
-  if (!val)
-    return TRUE;
+  if (!val) {
+    if (u->name)
+      g_value_unset (&u->value);
+    return FALSE;
+  }
   if (gst_value_compare (val, value) == GST_VALUE_EQUAL)
     return TRUE;
   if (u->name) {
@@ -1152,40 +1179,52 @@ gst_caps_structure_figure_out_union (GQuark field_id, GValue * value,
   return TRUE;
 }
 
-static GstStructure *
-gst_caps_structure_simplify (const GstStructure * simplify,
-    GstStructure * compare)
+static gboolean
+gst_caps_structure_simplify (GstStructure ** result,
+    const GstStructure * simplify, GstStructure * compare)
 {
-  GstCaps *caps = gst_caps_new_empty ();
-  GstStructure *ret;
+  GSList *list;
   UnionField field = { 0, {0,}, NULL };
 
   /* try to subtract to get a real subset */
-  gst_caps_structure_subtract (caps, simplify, compare);
-  switch (gst_caps_get_size (caps)) {
-    case 0:
-      gst_caps_free (caps);
-      return NULL;
-    case 1:
-      ret = gst_structure_copy (gst_caps_get_structure (caps, 0));
-      break;
-    default:
-      ret = gst_structure_copy (simplify);
-      break;
+  if (gst_caps_structure_subtract (&list, simplify, compare)) {
+    switch (g_slist_length (list)) {
+      case 0:
+        *result = NULL;
+        return TRUE;
+      case 1:
+        *result = list->data;
+        g_slist_free (list);
+        return TRUE;
+      default:
+      {
+        GSList *walk;
+
+        for (walk = list; walk; walk = g_slist_next (walk)) {
+          gst_structure_free (walk->data);
+        }
+        g_slist_free (list);
+        break;
+      }
+    }
   }
-  gst_caps_free (caps);
 
   /* try to union both structs */
   field.compare = compare;
-  if (gst_structure_foreach (ret, gst_caps_structure_figure_out_union, &field)) {
-    g_assert (field.name != 0);
-    gst_structure_id_set_value (compare, field.name, &field.value);
-    gst_structure_free (ret);
+  if (gst_structure_foreach ((GstStructure *) simplify,
+          gst_caps_structure_figure_out_union, &field)) {
+    gboolean ret = FALSE;
+
+    if (gst_structure_n_fields (simplify) == gst_structure_n_fields (compare)) {
+      gst_structure_id_set_value (compare, field.name, &field.value);
+      *result = NULL;
+      ret = TRUE;
+    }
     g_value_unset (&field.value);
-    return NULL;
+    return ret;
   }
 
-  return ret;
+  return FALSE;
 }
 
 /**
@@ -1196,50 +1235,63 @@ gst_caps_structure_simplify (const GstStructure * simplify,
  * same set of formats, but in a simpler form.  Component structures that are 
  * identical are merged.  Component structures that have values that can be 
  * merged are also merged.
+ *
+ * Returns: TRUE, if the caps could be simplified
  */
-void
+gboolean
 gst_caps_do_simplify (GstCaps * caps)
 {
   GstStructure *simplify, *compare, *result;
   gint i, j, start;
+  gboolean changed = FALSE;
 
-  g_return_if_fail (caps != NULL);
+  g_return_val_if_fail (caps != NULL, FALSE);
 
   if (gst_caps_get_size (caps) < 2)
-    return;
+    return FALSE;
 
   g_ptr_array_sort (caps->structs, gst_caps_compare_structures);
 
   start = caps->structs->len - 1;
   for (i = caps->structs->len - 1; i >= 0; i--) {
     simplify = gst_caps_get_structure (caps, i);
+    if (gst_structure_get_name_id (simplify) !=
+        gst_structure_get_name_id (gst_caps_get_structure (caps, start)))
+      start = i;
     for (j = start; j >= 0; j--) {
-      compare = gst_caps_get_structure (caps, j);
       if (j == i)
         continue;
+      compare = gst_caps_get_structure (caps, j);
       if (gst_structure_get_name_id (simplify) !=
           gst_structure_get_name_id (compare)) {
-        start = j;
         break;
       }
-      result = gst_caps_structure_simplify (simplify, compare);
+      if (gst_caps_structure_simplify (&result, simplify, compare)) {
 #if 0
-      g_print ("%s  -  %s  =  %s\n",
-          gst_structure_to_string (simplify),
-          gst_structure_to_string (compare),
-          result ? gst_structure_to_string (result) : "---");
+        g_print ("%s  -  %s  =  %s\n",
+            gst_structure_to_string (simplify),
+            gst_structure_to_string (compare),
+            result ? gst_structure_to_string (result) : "---");
 #endif
-      if (result) {
-        gst_structure_free (simplify);
-        g_ptr_array_index (caps->structs, i) = result;
-        simplify = result;
-      } else {
-        gst_caps_remove_structure (caps, i);
-        start--;
-        break;
+        if (result) {
+          gst_structure_free (simplify);
+          g_ptr_array_index (caps->structs, i) = result;
+          simplify = result;
+        } else {
+          gst_caps_remove_structure (caps, i);
+          start--;
+          break;
+        }
+        changed = TRUE;
       }
     }
   }
+
+  if (!changed)
+    return FALSE;
+
+  /* gst_caps_do_simplify (caps); */
+  return TRUE;
 }
 
 #ifndef GST_DISABLE_LOADSAVE
index 525ce8d771893b0414504f57d13830ff2c09d102..91162543e773cef0ea30314d7a45b767c166b082 100644 (file)
@@ -128,7 +128,7 @@ GstCaps *                gst_caps_normalize                             (const G
 #ifndef GST_DISABLE_DEPRECATED
 GstCaps *                gst_caps_simplify                              (const GstCaps *caps);
 #endif
-void                    gst_caps_do_simplify                           (GstCaps *caps);
+gboolean                 gst_caps_do_simplify                           (GstCaps *caps);
 
 #ifndef GST_DISABLE_LOADSAVE
 xmlNodePtr               gst_caps_save_thyself                          (const GstCaps *caps,
index e198dbe307da3b8ee87a9ee74c9b6421efea8d32..3024eeca9f3244e175b61a92b081a9ecb2382900 100644 (file)
@@ -7,11 +7,11 @@
 static const gchar *caps_list[] = {
   "audio/x-adpcm, layout=(string)quicktime; audio/x-adpcm, layout=(string)quicktime; audio/x-adpcm, layout=(string)wav; audio/x-adpcm, layout=(string)wav; audio/x-adpcm, layout=(string)dk3; audio/x-adpcm, layout=(string)dk3; audio/x-adpcm, layout=(string)dk4; audio/x-adpcm, layout=(string)dk4; audio/x-adpcm, layout=(string)westwood; audio/x-adpcm, layout=(string)westwood; audio/x-adpcm, layout=(string)smjpeg; audio/x-adpcm, layout=(string)smjpeg; audio/x-adpcm, layout=(string)microsoft; audio/x-adpcm, layout=(string)microsoft; audio/x-adpcm, layout=(string)4xm; audio/x-adpcm, layout=(string)4xm; audio/x-adpcm, layout=(string)xa; audio/x-adpcm, layout=(string)xa; audio/x-adpcm, layout=(string)adx; audio/x-adpcm, layout=(string)adx; audio/x-adpcm, layout=(string)ea; audio/x-adpcm, layout=(string)ea; audio/x-adpcm, layout=(string)g726; audio/x-adpcm, layout=(string)g726",
   "video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)I420; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)YUY2; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)24, depth=(int)24, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, endianness=(int)4321; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)24, depth=(int)24, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, endianness=(int)4321; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)Y42B; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)32, depth=(int)24, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, endianness=(int)4321; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)YUV9; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)Y41B; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)16, depth=(int)16, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31, endianness=(int)1234; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)16, depth=(int)15, red_mask=(int)31744, green_mask=(int)992, blue_mask=(int)31, endianness=(int)1234",
-  "video/x-raw-yuv, format=(fourcc){ YUY2, I420 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-jpeg, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)[ 3, 5 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-xvid, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-3ivx, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)[ 41, 43 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)1, systemstream=(boolean)false, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dv, systemstream=(boolean)false, width=(int)720, height=(int){ 576, 480 }; video/x-huffyuv, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]",
-  "video/x-raw-yuv, format=(fourcc){ YUY2, I420 }, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; image/jpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-divx, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], divxversion=(int)[ 3, 5 ]; video/x-xvid, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-3ivx, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-msmpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], msmpegversion=(int)[ 41, 43 ]; video/mpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], mpegversion=(int)1, systemstream=(boolean)false; video/x-h263, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-dv, width=(int)720, height=(int){ 576, 480 }, systemstream=(boolean)false; video/x-huffyuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]",
+  "video/x-raw-yuv, format=(fourcc){ YUY2, I420 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]; video/x-jpeg, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)[ 3, 5 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-xvid, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-3ivx, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)[ 41, 43 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)1, systemstream=(boolean)false, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dv, systemstream=(boolean)false, width=(int)720, height=(int){ 576, 480 }; video/x-huffyuv, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]",
+  "video/x-raw-yuv, format=(fourcc){ YUY2, I420 }, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]; image/jpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-divx, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], divxversion=(int)[ 3, 5 ]; video/x-xvid, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-3ivx, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-msmpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], msmpegversion=(int)[ 41, 43 ]; video/mpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], mpegversion=(int)1, systemstream=(boolean)false; video/x-h263, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-dv, width=(int)720, height=(int){ 576, 480 }, systemstream=(boolean)false; video/x-huffyuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]",
   "video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
   "video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
-  "video/x-raw-yuv, format=(fourcc){ I420 }, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]",
+  "video/x-raw-yuv, format=(fourcc){ I420 }, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
   "ANY",
   "EMPTY"
 };
index ca70ca5869eb678d4c23f4226edc2d1b356bbb67..99d5173d3861a73d7b47b233aebd6a7c855999b6 100644 (file)
@@ -78,10 +78,11 @@ main (gint argc, gchar ** argv)
     check_caps (caps);
     if (!gst_caps_is_any (caps)) {
       for (j = 0; j < G_N_ELEMENTS (caps_list); j++) {
+        GstCaps *temp, *temp2;
         GstCaps *caps2 = gst_caps_from_string (caps_list[j]);
 
         /* subtraction */
-        GstCaps *temp = gst_caps_subtract (caps, caps2);
+        temp = gst_caps_subtract (caps, caps2);
 
         g_print ("%2u - %2u ", i, j);
         check_caps (temp);
@@ -92,8 +93,14 @@ main (gint argc, gchar ** argv)
         check_caps (temp);
         if (i == j)
           g_assert (gst_caps_get_size (caps) == gst_caps_get_size (temp));
+        g_assert (gst_caps_is_subset (caps, temp));
+        g_assert (gst_caps_is_subset (caps2, temp));
+        /* appending (union without simplifying) */
+        temp2 = gst_caps_copy (caps);
+        gst_caps_append (temp2, caps2);
+        g_assert (gst_caps_is_equal (temp, temp2));
+        gst_caps_free (temp2);
         gst_caps_free (temp);
-        gst_caps_free (caps2);
       }
     }
     gst_caps_free (caps);
index e198dbe307da3b8ee87a9ee74c9b6421efea8d32..3024eeca9f3244e175b61a92b081a9ecb2382900 100644 (file)
@@ -7,11 +7,11 @@
 static const gchar *caps_list[] = {
   "audio/x-adpcm, layout=(string)quicktime; audio/x-adpcm, layout=(string)quicktime; audio/x-adpcm, layout=(string)wav; audio/x-adpcm, layout=(string)wav; audio/x-adpcm, layout=(string)dk3; audio/x-adpcm, layout=(string)dk3; audio/x-adpcm, layout=(string)dk4; audio/x-adpcm, layout=(string)dk4; audio/x-adpcm, layout=(string)westwood; audio/x-adpcm, layout=(string)westwood; audio/x-adpcm, layout=(string)smjpeg; audio/x-adpcm, layout=(string)smjpeg; audio/x-adpcm, layout=(string)microsoft; audio/x-adpcm, layout=(string)microsoft; audio/x-adpcm, layout=(string)4xm; audio/x-adpcm, layout=(string)4xm; audio/x-adpcm, layout=(string)xa; audio/x-adpcm, layout=(string)xa; audio/x-adpcm, layout=(string)adx; audio/x-adpcm, layout=(string)adx; audio/x-adpcm, layout=(string)ea; audio/x-adpcm, layout=(string)ea; audio/x-adpcm, layout=(string)g726; audio/x-adpcm, layout=(string)g726",
   "video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)I420; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)YUY2; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)24, depth=(int)24, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, endianness=(int)4321; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)24, depth=(int)24, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, endianness=(int)4321; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)Y42B; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)32, depth=(int)24, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, endianness=(int)4321; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)YUV9; video/x-raw-yuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], format=(fourcc)Y41B; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)16, depth=(int)16, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31, endianness=(int)1234; video/x-raw-rgb, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ], bpp=(int)16, depth=(int)15, red_mask=(int)31744, green_mask=(int)992, blue_mask=(int)31, endianness=(int)1234",
-  "video/x-raw-yuv, format=(fourcc){ YUY2, I420 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-jpeg, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)[ 3, 5 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-xvid, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-3ivx, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)[ 41, 43 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)1, systemstream=(boolean)false, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dv, systemstream=(boolean)false, width=(int)720, height=(int){ 576, 480 }; video/x-huffyuv, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]",
-  "video/x-raw-yuv, format=(fourcc){ YUY2, I420 }, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; image/jpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-divx, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], divxversion=(int)[ 3, 5 ]; video/x-xvid, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-3ivx, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-msmpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], msmpegversion=(int)[ 41, 43 ]; video/mpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], mpegversion=(int)1, systemstream=(boolean)false; video/x-h263, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-dv, width=(int)720, height=(int){ 576, 480 }, systemstream=(boolean)false; video/x-huffyuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]",
+  "video/x-raw-yuv, format=(fourcc){ YUY2, I420 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]; video/x-jpeg, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-divx, divxversion=(int)[ 3, 5 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-xvid, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-3ivx, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-msmpeg, msmpegversion=(int)[ 41, 43 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/mpeg, mpegversion=(int)1, systemstream=(boolean)false, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-h263, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]; video/x-dv, systemstream=(boolean)false, width=(int)720, height=(int){ 576, 480 }; video/x-huffyuv, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]",
+  "video/x-raw-yuv, format=(fourcc){ YUY2, I420 }, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]; image/jpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-divx, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], divxversion=(int)[ 3, 5 ]; video/x-xvid, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-3ivx, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-msmpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], msmpegversion=(int)[ 41, 43 ]; video/mpeg, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], mpegversion=(int)1, systemstream=(boolean)false; video/x-h263, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]; video/x-dv, width=(int)720, height=(int){ 576, 480 }, systemstream=(boolean)false; video/x-huffyuv, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]",
   "video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
   "video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
-  "video/x-raw-yuv, format=(fourcc){ I420 }, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ]",
+  "video/x-raw-yuv, format=(fourcc){ I420 }, width=(int)[ 16, 4096 ], height=(int)[ 16, 4096 ], framerate=(double)[ 0, 1.7976931348623157e+308 ]",
   "ANY",
   "EMPTY"
 };
index ca70ca5869eb678d4c23f4226edc2d1b356bbb67..99d5173d3861a73d7b47b233aebd6a7c855999b6 100644 (file)
@@ -78,10 +78,11 @@ main (gint argc, gchar ** argv)
     check_caps (caps);
     if (!gst_caps_is_any (caps)) {
       for (j = 0; j < G_N_ELEMENTS (caps_list); j++) {
+        GstCaps *temp, *temp2;
         GstCaps *caps2 = gst_caps_from_string (caps_list[j]);
 
         /* subtraction */
-        GstCaps *temp = gst_caps_subtract (caps, caps2);
+        temp = gst_caps_subtract (caps, caps2);
 
         g_print ("%2u - %2u ", i, j);
         check_caps (temp);
@@ -92,8 +93,14 @@ main (gint argc, gchar ** argv)
         check_caps (temp);
         if (i == j)
           g_assert (gst_caps_get_size (caps) == gst_caps_get_size (temp));
+        g_assert (gst_caps_is_subset (caps, temp));
+        g_assert (gst_caps_is_subset (caps2, temp));
+        /* appending (union without simplifying) */
+        temp2 = gst_caps_copy (caps);
+        gst_caps_append (temp2, caps2);
+        g_assert (gst_caps_is_equal (temp, temp2));
+        gst_caps_free (temp2);
         gst_caps_free (temp);
-        gst_caps_free (caps2);
       }
     }
     gst_caps_free (caps);