From e6a4b71b906ca0f79d5066384c408c01986b11ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 24 Mar 2011 10:08:59 +0100 Subject: [PATCH] aiffparse: Add support for 32 bit and 64 bit floating point formats --- gst/aiff/aiffparse.c | 58 ++++++++++++++++++++++++++++++++------------ gst/aiff/aiffparse.h | 1 + 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/gst/aiff/aiffparse.c b/gst/aiff/aiffparse.c index 3107c57dd0..8a127be369 100644 --- a/gst/aiff/aiffparse.c +++ b/gst/aiff/aiffparse.c @@ -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; diff --git a/gst/aiff/aiffparse.h b/gst/aiff/aiffparse.h index 1ffe212b74..b773a15052 100644 --- a/gst/aiff/aiffparse.h +++ b/gst/aiff/aiffparse.h @@ -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;