matroskademux: wrongly set caps rate with AAC audio
Submitted by Fabien Lebaillif - Delamare
Link to original bug (#636599)
Description
Created attachment 175923
A sample file audio is AAC 48Khz caps is created with rate=96Khz
Using the attached file, or any other for that matter, the audio caps is build with the wrong sample rate value.
GST_DEBUG="matr*:5" gst-launch-0.10 playbin2 uri="file:///samplerate_48_reported_96.mkv"
0:00:00.066778665 3153 0x27f10a0 DEBUG matroskademux matroska-demux.c:1555:gst_matroska_demux_add_stream:<matroskademux0>
TrackAudioSamplingFrequency: 48000.000000
0:00:00.066796811 3153 0x27f10a0 DEBUG matroskademux matroska-demux.c:1591:gst_matroska_demux_add_stream:<matroskademux0>
TrackAudioChannels: 2
0:00:00.066810746 3153 0x27f10a0 DEBUG matroskademux matroska-demux.c:1607:gst_matroska_demux_add_stream:<matroskademux0>
Parsing TrackAudio element finished with 'ok'
0:00:00.066824620 3153 0x27f10a0 DEBUG matroskademux matroska-demux.c:1815:gst_matroska_demux_add_stream:<matroskademux0>
Parsing TrackEntry element finished with 'ok'
0:00:00.066845196 3153 0x27f10a0 DEBUG matroskademux matroska-demux.c:6740:gst_matroska_demux_audio_caps: obj_type = 2, freq_index = 3
0:00:00.066906340 3153 0x27f10a0 INFO matroskademux matroska-demux.c:1954:gst_matroska_demux_add_stream:<matroskademux0>
Adding pad 'audio_00' with caps audio/mpeg, mpegversion=(int)4, framed=(boolean)true, codec_data=( buffer)119056e500, channels=(int)2, rate=(int)96000
As we can see audio is detected as 48000 (TrackAudioSamplingFrequency) but the caps has rate=(int)96000
The error is in matroska-demux.c::gst_matroska_demux_audio_caps (line 6776) where context->codec_priv_size == (5 + explicit_freq_bytes)is evaluated to true
if (obj_type == 5 || (freq_index >= 6 && freq_index != 15) ||
(context->codec_priv_size == (5 + explicit_freq_bytes))) {
audiocontext->samplerate *= 2;
audiocontext->samplerate gets doubled up because of explicit_freq_bytes. I would have provided a path but I am not sure what explicit_freq_bytes should be ?
Attachment 175923, "A sample file audio is AAC 48Khz caps is created with rate=96Khz":
samplerate_48_reported_96.mkv