From ed58a212ff290799abcea23ee090e3dc560f434d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 20 Apr 2006 09:11:22 +0000 Subject: [PATCH] gst/matroska/matroska-demux.c: Make mpeg2 aac audio work: create artificial private codec data chunk which faad2 seem... Original commit message from CVS: * gst/matroska/matroska-demux.c: (gst_matroska_demux_audio_caps), (gst_matroska_demux_plugin_init): Make mpeg2 aac audio work: create artificial private codec data chunk which faad2 seems to require, just as we do for mpeg4 aac. Also call gst_riff_init(). Partially fixes #338767. --- ChangeLog | 8 ++++++++ gst/matroska/matroska-demux.c | 36 +++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5d413d..751e4b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-04-20 Tim-Philipp Müller + + * gst/matroska/matroska-demux.c: (gst_matroska_demux_audio_caps), + (gst_matroska_demux_plugin_init): + Make mpeg2 aac audio work: create artificial private codec data + chunk which faad2 seems to require, just as we do for mpeg4 aac. + Also call gst_riff_init(). Partially fixes #338767. + 2006-04-19 Tim-Philipp Müller * gst/wavenc/gstwavenc.c: (gst_wavenc_base_init), diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 179ea9a..d3878ee 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -29,6 +29,7 @@ /* For AVI compatibility mode... Who did that? */ /* and for fourcc stuff */ +#include #include #include @@ -3252,28 +3253,28 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext * strlen (GST_MATROSKA_CODEC_ID_AUDIO_MPEG2)) || !strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_MPEG4, strlen (GST_MATROSKA_CODEC_ID_AUDIO_MPEG4))) { - gint mpegversion = -1; GstBuffer *priv = NULL; + gint mpegversion = -1; + gint rate_idx, profile; + guint8 *data; + + /* make up decoderspecificdata */ + priv = gst_buffer_new_and_alloc (5); + data = GST_BUFFER_DATA (priv); + rate_idx = aac_rate_idx (audiocontext->samplerate); + profile = aac_profile_idx (codec_id); + + data[0] = ((profile + 1) << 3) | ((rate_idx & 0xE) >> 1); + data[1] = ((rate_idx & 0x1) << 7) | (audiocontext->channels << 3); + GST_BUFFER_SIZE (priv) = 2; if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_MPEG2, - strlen (GST_MATROSKA_CODEC_ID_AUDIO_MPEG2))) + strlen (GST_MATROSKA_CODEC_ID_AUDIO_MPEG2))) { mpegversion = 2; - else if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_MPEG4, + } else if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_MPEG4, strlen (GST_MATROSKA_CODEC_ID_AUDIO_MPEG4))) { - gint rate_idx, profile; - guint8 *data; - mpegversion = 4; - /* make up decoderspecificdata */ - priv = gst_buffer_new_and_alloc (5); - data = GST_BUFFER_DATA (priv); - rate_idx = aac_rate_idx (audiocontext->samplerate); - profile = aac_profile_idx (codec_id); - - data[0] = ((profile + 1) << 3) | ((rate_idx & 0xE) >> 1); - data[1] = ((rate_idx & 0x1) << 7) | (audiocontext->channels << 3); - if (g_strrstr (codec_id, "SBR")) { /* HE-AAC (aka SBR AAC) */ audiocontext->samplerate *= 2; @@ -3281,8 +3282,7 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext * data[2] = AAC_SYNC_EXTENSION_TYPE >> 3; data[3] = ((AAC_SYNC_EXTENSION_TYPE & 0x07) << 5) | 5; data[4] = (1 << 7) | (rate_idx << 3); - } else { - GST_BUFFER_SIZE (priv) = 2; + GST_BUFFER_SIZE (priv) = 5; } } else { g_assert_not_reached (); @@ -3431,6 +3431,8 @@ gst_matroska_demux_change_state (GstElement * element, gboolean gst_matroska_demux_plugin_init (GstPlugin * plugin) { + gst_riff_init (); + /* create an elementfactory for the matroska_demux element */ if (!gst_element_register (plugin, "matroskademux", GST_RANK_PRIMARY, GST_TYPE_MATROSKA_DEMUX)) -- 2.7.4