gst/audioconvert/gstaudioconvert.c: Previous fix was too simplistic, and broke the...
authorMichael Smith <msmith@xiph.org>
Fri, 16 Mar 2007 17:29:09 +0000 (17:29 +0000)
committerMichael Smith <msmith@xiph.org>
Fri, 16 Mar 2007 17:29:09 +0000 (17:29 +0000)
Original commit message from CVS:
* gst/audioconvert/gstaudioconvert.c: (make_lossless_changes),
(strip_width_64), (append_with_other_format):
Previous fix was too simplistic, and broke the tests. Use a better
approach; only strip 64 from widths for integer audio.

ChangeLog
gst/audioconvert/gstaudioconvert.c

index 7df33b4..46ae701 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,13 @@
 2007-03-16  Michael Smith  <msmith@fluendo.com>
 
        * gst/audioconvert/gstaudioconvert.c: (make_lossless_changes),
+       (strip_width_64), (append_with_other_format):
+         Previous fix was too simplistic, and broke the tests. Use a better
+         approach; only strip 64 from widths for integer audio.
+
+2007-03-16  Michael Smith  <msmith@fluendo.com>
+
+       * gst/audioconvert/gstaudioconvert.c: (make_lossless_changes),
        (gst_audio_convert_transform_caps):
          We don't support 64 bit integer audio, so don't try to claim we can.
          Stops us producing caps don't match our template caps.
index 59ecfef..9070a6e 100644 (file)
@@ -380,7 +380,7 @@ static GstStructure *
 make_lossless_changes (GstStructure * s, gboolean isfloat)
 {
   if (isfloat) {
-    /* float doesn't have a depth or signedness field and only supports a
+    /* float doesn't have a depth or signedness field and only supports
      * widths of 32/64 and native endianness */
     gst_structure_remove_field (s, "depth");
     gst_structure_remove_field (s, "signed");
@@ -413,13 +413,34 @@ make_lossless_changes (GstStructure * s, gboolean isfloat)
     gst_structure_set_value (s, "signed", &list);
     g_value_unset (&val);
     g_value_unset (&list);
-    /* We don't handle 64 bit integer audio, so we set the width here as well */
-    gst_structure_set (s, "width", G_TYPE_INT, 32, NULL);
   }
 
   return s;
 }
 
+static void
+strip_width_64 (GstStructure * s)
+{
+  const GValue *v = gst_structure_get_value (s, "width");
+  GValue widths = { 0 };
+
+  if (GST_VALUE_HOLDS_LIST (v)) {
+    int i;
+    int len = gst_value_list_get_size (v);
+
+    g_value_init (&widths, GST_TYPE_LIST);
+
+    for (i = 0; i < len; i++) {
+      const GValue *width = gst_value_list_get_value (v, i);
+
+      if (g_value_get_int (width) != 64)
+        gst_value_list_append_value (&widths, width);
+    }
+    gst_structure_set_value (s, "width", &widths);
+    g_value_unset (&widths);
+  }
+}
+
 /* Little utility function to create a related structure for float/int */
 static void
 append_with_other_format (GstCaps * caps, GstStructure * s, gboolean isfloat)
@@ -430,6 +451,9 @@ append_with_other_format (GstCaps * caps, GstStructure * s, gboolean isfloat)
     s2 = gst_structure_copy (s);
     gst_structure_set_name (s2, "audio/x-raw-int");
     s = make_lossless_changes (s2, FALSE);
+    /* If 64 bit float was allowed; remove width 64: we don't support it for 
+     * integer*/
+    strip_width_64 (s);
     gst_caps_append_structure (caps, s2);
   } else {
     s2 = gst_structure_copy (s);