aiffparse: Add support for 32 bit and 64 bit floating point formats
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 24 Mar 2011 09:08:59 +0000 (10:08 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 24 Mar 2011 09:13:47 +0000 (10:13 +0100)
gst/aiff/aiffparse.c
gst/aiff/aiffparse.h

index 3107c57..8a127be 100644 (file)
@@ -655,19 +655,37 @@ gst_aiff_parse_parse_comm (GstAiffParse * aiff, GstBuffer * buf)
   aiff->width = GST_ROUND_UP_8 (aiff->depth);
   aiff->rate = (int) gst_aiff_parse_read_IEEE80 (data + 8);
 
+  aiff->floating_point = FALSE;
+
   if (aiff->is_aifc) {
+    guint32 fourcc = GST_READ_UINT32_LE (data + 18);
+
     /* We only support the 'trivial' uncompressed AIFC, but it can be
      * either big or little endian */
-    if (GST_READ_UINT32_LE (data + 18) == GST_MAKE_FOURCC ('N', 'O', 'N', 'E'))
-      aiff->endianness = G_BIG_ENDIAN;
-    else if (GST_READ_UINT32_LE (data + 18) ==
-        GST_MAKE_FOURCC ('s', 'o', 'w', 't'))
-      aiff->endianness = G_LITTLE_ENDIAN;
-    else {
-      GST_WARNING_OBJECT (aiff, "Unsupported compression in AIFC "
-          "file: %" GST_FOURCC_FORMAT,
-          GST_FOURCC_ARGS (GST_READ_UINT32_LE (data + 18)));
-      return FALSE;
+    switch (fourcc) {
+      case GST_MAKE_FOURCC ('N', 'O', 'N', 'E'):
+        aiff->endianness = G_BIG_ENDIAN;
+        break;
+      case GST_MAKE_FOURCC ('s', 'o', 'w', 't'):
+        aiff->endianness = G_LITTLE_ENDIAN;
+        break;
+      case GST_MAKE_FOURCC ('F', 'L', '3', '2'):
+      case GST_MAKE_FOURCC ('f', 'l', '3', '2'):
+        aiff->floating_point = TRUE;
+        aiff->width = aiff->depth = 32;
+        aiff->endianness = G_BIG_ENDIAN;
+        break;
+      case GST_MAKE_FOURCC ('f', 'l', '6', '4'):
+        aiff->floating_point = TRUE;
+        aiff->width = aiff->depth = 64;
+        aiff->endianness = G_BIG_ENDIAN;
+        break;
+      default:
+        GST_WARNING_OBJECT (aiff, "Unsupported compression in AIFC "
+            "file: %" GST_FOURCC_FORMAT,
+            GST_FOURCC_ARGS (GST_READ_UINT32_LE (data + 18)));
+        return FALSE;
+
     }
   } else
     aiff->endianness = G_BIG_ENDIAN;
@@ -719,12 +737,20 @@ gst_aiff_parse_create_caps (GstAiffParse * aiff)
 {
   GstCaps *caps;
 
-  caps = gst_caps_new_simple ("audio/x-raw-int",
-      "width", G_TYPE_INT, aiff->width,
-      "depth", G_TYPE_INT, aiff->depth,
-      "channels", G_TYPE_INT, aiff->channels,
-      "endianness", G_TYPE_INT, aiff->endianness,
-      "rate", G_TYPE_INT, aiff->rate, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+  if (aiff->floating_point) {
+    caps = gst_caps_new_simple ("audio/x-raw-float",
+        "width", G_TYPE_INT, aiff->width,
+        "channels", G_TYPE_INT, aiff->channels,
+        "endianness", G_TYPE_INT, aiff->endianness,
+        "rate", G_TYPE_INT, aiff->rate, NULL);
+  } else {
+    caps = gst_caps_new_simple ("audio/x-raw-int",
+        "width", G_TYPE_INT, aiff->width,
+        "depth", G_TYPE_INT, aiff->depth,
+        "channels", G_TYPE_INT, aiff->channels,
+        "endianness", G_TYPE_INT, aiff->endianness,
+        "rate", G_TYPE_INT, aiff->rate, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+  }
 
   GST_DEBUG_OBJECT (aiff, "Created caps: %" GST_PTR_FORMAT, caps);
   return caps;
index 1ffe212..b773a15 100644 (file)
@@ -77,6 +77,7 @@ struct _GstAiffParse {
   guint16 width;
   guint16 depth;
   guint32 endianness;
+  gboolean floating_point;
 
   /* real bytes per second used or 0 when no bitrate is known */
   guint32 bps;