After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 636599 - matroskademux: wrongly set caps rate with AAC audio
matroskademux: wrongly set caps rate with AAC audio
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other All
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-12-06 14:50 UTC by Fabien Lebaillif - Delamare
Modified: 2018-11-03 14:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A sample file audio is AAC 48Khz caps is created with rate=96Khz (512.00 KB, video/x-matroska)
2010-12-06 14:50 UTC, Fabien Lebaillif - Delamare
  Details
matroskademux: improve the AAC codec data parsing logic (4.21 KB, patch)
2011-06-13 21:08 UTC, Debarshi Ray
none Details | Review
matroskademux: use GstBitReader instead of masks to read AAC codec data (1.87 KB, patch)
2011-06-14 04:28 UTC, Debarshi Ray
none Details | Review
matroskademux: improve the AAC codec data parsing logic (3.79 KB, patch)
2011-06-14 04:30 UTC, Debarshi Ray
none Details | Review
matroskademux: use GstBitReader instead of masks to read AAC codec data (1.70 KB, patch)
2011-06-14 10:10 UTC, Debarshi Ray
needs-work Details | Review
matroskademux: improve the AAC codec data parsing logic (3.76 KB, patch)
2011-06-14 10:12 UTC, Debarshi Ray
needs-work Details | Review

Description Fabien Lebaillif - Delamare 2010-12-06 14:50:23 UTC
Created attachment 175923 [details]
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 ?
Comment 1 Mark Nauwelaerts 2010-12-07 11:19:02 UTC
I would say the above lines are not really an error (though maybe not optimal); 5 bytes of codec-data probably indicates HE-AAC (e.g. SBR), which is why the samplerate is doubled.

Problem is that it is hard to know whether some other field (e.g. matroska samplerate field) has already taken this into account or not.  Definitive solution may require codec-utils in -base to also support parsing of HE-AAC codec-data (which may need some more specs in that area).
Comment 2 Debarshi Ray 2011-06-13 21:08:45 UTC
Created attachment 189851 [details] [review]
matroskademux: improve the AAC codec data parsing logic
Comment 3 Debarshi Ray 2011-06-14 04:28:27 UTC
Created attachment 189869 [details] [review]
matroskademux: use GstBitReader instead of masks to read AAC codec data
Comment 4 Debarshi Ray 2011-06-14 04:30:40 UTC
Created attachment 189870 [details] [review]
matroskademux: improve the AAC codec data parsing logic
Comment 5 Debarshi Ray 2011-06-14 04:31:32 UTC
Split the initial patch in two parts: first one replaces the masks by GstBitReader, the second one changes the logic.
Comment 6 Debarshi Ray 2011-06-14 10:10:55 UTC
Created attachment 189884 [details] [review]
matroskademux: use GstBitReader instead of masks to read AAC codec data

Create the GstBitReader on the stack.
Comment 7 Debarshi Ray 2011-06-14 10:12:53 UTC
Created attachment 189885 [details] [review]
matroskademux: improve the AAC codec data parsing logic

Create the GstBitReader on the stack.
Comment 8 Sebastian Dröge (slomo) 2013-06-10 12:06:05 UTC
This should be integrated into gst-plugins-base/gst-libs/gst/pbutils/codec-utils. And then used in matroskademux, but also aacparse.
Comment 9 Tim-Philipp Müller 2014-11-26 15:01:54 UTC
Still applies to git master (note: sample file is only the header, parser/demuxer errors are expected)
Comment 10 GStreamer system administrator 2018-11-03 14:43:02 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/37.