summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2009-12-03 23:43:08 +0000
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2009-12-03 23:43:09 +0000
commit295b6c032628dc5e9e912d0a5f74910e22b4ef08 (patch)
treef2bbc4dbd1d4dfa3f7d740e9a93b76a571fadf28
parente6e9e3c5897c962a7591c311afa6141a867f29dd (diff)
ogg: extract number of channels from FLAC, speex and vorbis headers
Because we can.
-rw-r--r--ext/ogg/gstoggstream.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/ext/ogg/gstoggstream.c b/ext/ogg/gstoggstream.c
index 07908a1a4..c2d73d75c 100644
--- a/ext/ogg/gstoggstream.c
+++ b/ext/ogg/gstoggstream.c
@@ -441,8 +441,11 @@ static gboolean
setup_vorbis_mapper (GstOggStream * pad, ogg_packet * packet)
{
guint8 *data = packet->packet;
+ guint chans;
- data += 1 + 6 + 4 + 1;
+ data += 1 + 6 + 4;
+ chans = GST_READ_UINT8 (data);
+ data += 1;
pad->granulerate_n = GST_READ_UINT32_LE (data);
pad->granulerate_d = 1;
pad->granuleshift = 0;
@@ -457,7 +460,8 @@ setup_vorbis_mapper (GstOggStream * pad, ogg_packet * packet)
parse_vorbis_header_packet (pad, packet);
pad->caps = gst_caps_new_simple ("audio/x-vorbis",
- "rate", G_TYPE_INT, pad->granulerate_n, NULL);
+ "rate", G_TYPE_INT, pad->granulerate_n, "channels", G_TYPE_INT, chans,
+ NULL);
return TRUE;
}
@@ -507,12 +511,17 @@ static gboolean
setup_speex_mapper (GstOggStream * pad, ogg_packet * packet)
{
guint8 *data = packet->packet;
+ guint chans;
data += 8 + 20 + 4 + 4;
pad->granulerate_n = GST_READ_UINT32_LE (data);
pad->granulerate_d = 1;
pad->granuleshift = 0;
- GST_LOG ("sample rate: %d", pad->granulerate_n);
+
+ data += 4 + 4 + 4;
+ chans = GST_READ_UINT32_LE (data);
+
+ GST_LOG ("sample rate: %d, channels: %u", pad->granulerate_n, chans);
pad->n_header_packets = GST_READ_UINT32_LE (packet->packet + 68) + 2;
pad->frame_size = GST_READ_UINT32_LE (packet->packet + 64) *
@@ -521,8 +530,8 @@ setup_speex_mapper (GstOggStream * pad, ogg_packet * packet)
if (pad->granulerate_n == 0)
return FALSE;
- pad->caps = gst_caps_new_simple ("audio/x-speex",
- "rate", G_TYPE_INT, pad->granulerate_n, NULL);
+ pad->caps = gst_caps_new_simple ("audio/x-speex", "rate", G_TYPE_INT,
+ pad->granulerate_n, "channels", G_TYPE_INT, chans, NULL);
return TRUE;
}
@@ -541,21 +550,24 @@ static gboolean
setup_flac_mapper (GstOggStream * pad, ogg_packet * packet)
{
guint8 *data = packet->packet;
+ guint chans;
/* see http://flac.sourceforge.net/ogg_mapping.html */
pad->granulerate_n = (GST_READ_UINT32_BE (data + 27) & 0xFFFFF000) >> 12;
pad->granulerate_d = 1;
pad->granuleshift = 0;
- GST_DEBUG ("sample rate: %d", pad->granulerate_n);
+ chans = ((GST_READ_UINT32_BE (data + 27) & 0x00000E00) >> 9) + 1;
+
+ GST_DEBUG ("sample rate: %d, channels: %u", pad->granulerate_n, chans);
pad->n_header_packets = GST_READ_UINT16_BE (packet->packet + 7);
if (pad->granulerate_n == 0)
return FALSE;
- pad->caps = gst_caps_new_simple ("audio/x-flac",
- "rate", G_TYPE_INT, pad->granulerate_n, NULL);
+ pad->caps = gst_caps_new_simple ("audio/x-flac", "rate", G_TYPE_INT,
+ pad->granulerate_n, "channels", G_TYPE_INT, chans, NULL);
return TRUE;
}