[FFmpeg-cvslog] (e)ac3: parse and store the Lt/Rt and LFE mix levels.

Tim Walker git at videolan.org
Sun Jan 19 21:46:22 CET 2014


ffmpeg | branch: master | Tim Walker <tdskywalker at gmail.com> | Fri Jan 17 15:57:40 2014 +0100| [c229f571fd3c7d7b567c27c87b2bbcdaee1b0e9f] | committer: Tim Walker

(e)ac3: parse and store the Lt/Rt and LFE mix levels.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c229f571fd3c7d7b567c27c87b2bbcdaee1b0e9f
---

 libavcodec/ac3.h     |    8 ++++++++
 libavcodec/ac3dec.c  |   16 ++++++++++++----
 libavcodec/ac3dec.h  |    5 +++++
 libavcodec/eac3dec.c |   10 +++++-----
 4 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index f01da07..fa290d3 100644
--- a/libavcodec/ac3.h
+++ b/libavcodec/ac3.h
@@ -104,6 +104,14 @@ typedef enum AC3DolbyHeadphoneMode {
     AC3_DHEADPHONMOD_RESERVED
 } AC3DolbyHeadphoneMode;
 
+/** Preferred Stereo Downmix mode */
+typedef enum AC3PreferredStereoDownmixMode {
+    AC3_DMIXMOD_NOTINDICATED = 0,
+    AC3_DMIXMOD_LTRT,
+    AC3_DMIXMOD_LORO,
+    AC3_DMIXMOD_RESERVED
+} AC3PreferredStereoDownmixMode;
+
 typedef struct AC3BitAllocParameters {
     int sr_code;
     int sr_shift;
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 584ce1a..b6ee401 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -227,16 +227,20 @@ static int ac3_parse_header(AC3DecodeContext *s)
 
     skip_bits(gbc, 2); //skip copyright bit and original bitstream bit
 
-    /* skip the timecodes or parse the Alternate Bit Stream Syntax
-       TODO: read & use the xbsi1 downmix levels */
+    /* skip the timecodes or parse the Alternate Bit Stream Syntax */
     if (s->bitstream_id != 6) {
         if (get_bits1(gbc))
             skip_bits(gbc, 14); //skip timecode1
         if (get_bits1(gbc))
             skip_bits(gbc, 14); //skip timecode2
     } else {
-        if (get_bits1(gbc))
-            skip_bits(gbc, 14); //skip xbsi1
+        if (get_bits1(gbc)) {
+            s->preferred_downmix       = get_bits(gbc, 2);
+            s->center_mix_level_ltrt   = get_bits(gbc, 3);
+            s->surround_mix_level_ltrt = get_bits(gbc, 3);
+            s->center_mix_level        = get_bits(gbc, 3);
+            s->surround_mix_level      = get_bits(gbc, 3);
+        }
         if (get_bits1(gbc)) {
             s->dolby_surround_ex_mode = get_bits(gbc, 2);
             s->dolby_headphone_mode   = get_bits(gbc, 2);
@@ -280,8 +284,12 @@ static int parse_frame_header(AC3DecodeContext *s)
     s->fbw_channels                 = s->channels - s->lfe_on;
     s->lfe_ch                       = s->fbw_channels + 1;
     s->frame_size                   = hdr.frame_size;
+    s->preferred_downmix            = AC3_DMIXMOD_NOTINDICATED;
     s->center_mix_level             = hdr.center_mix_level;
+    s->center_mix_level_ltrt        = 4; // -3.0dB
     s->surround_mix_level           = hdr.surround_mix_level;
+    s->surround_mix_level_ltrt      = 4; // -3.0dB
+    s->lfe_mix_level_exists         = 0;
     s->num_blocks                   = hdr.num_blocks;
     s->frame_type                   = hdr.frame_type;
     s->substreamid                  = hdr.substreamid;
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 73ca1c3..8fcd142 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -84,8 +84,13 @@ typedef struct AC3DecodeContext {
     int channel_mode;                       ///< channel mode                           (acmod)
     int lfe_on;                             ///< lfe channel in use
     int channel_map;                        ///< custom channel map
+    int preferred_downmix;                  ///< Preferred 2-channel downmix mode       (dmixmod)
     int center_mix_level;                   ///< Center mix level index
+    int center_mix_level_ltrt;              ///< Center mix level index for Lt/Rt       (ltrtcmixlev)
     int surround_mix_level;                 ///< Surround mix level index
+    int surround_mix_level_ltrt;            ///< Surround mix level index for Lt/Rt     (ltrtsurmixlev)
+    int lfe_mix_level_exists;               ///< indicates if lfemixlevcod is specified (lfemixlevcode)
+    int lfe_mix_level;                      ///< LFE mix level index                    (lfemixlevcod)
     int eac3;                               ///< indicates if current frame is E-AC-3
     int dolby_surround_mode;                ///< dolby surround mode                    (dsurmod)
     int dolby_surround_ex_mode;             ///< dolby surround ex mode                 (dsurexmod)
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index 731735f..dfd78c6 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -345,23 +345,23 @@ int ff_eac3_parse_header(AC3DecodeContext *s)
     if (get_bits1(gbc)) {
         /* center and surround mix levels */
         if (s->channel_mode > AC3_CHMODE_STEREO) {
-            skip_bits(gbc, 2);  // skip preferred stereo downmix mode
+            s->preferred_downmix = get_bits(gbc, 2);
             if (s->channel_mode & 1) {
                 /* if three front channels exist */
-                skip_bits(gbc, 3); //skip Lt/Rt center mix level
+                s->center_mix_level_ltrt = get_bits(gbc, 3);
                 s->center_mix_level = get_bits(gbc, 3);
             }
             if (s->channel_mode & 4) {
                 /* if a surround channel exists */
-                skip_bits(gbc, 3); //skip Lt/Rt surround mix level
+                s->surround_mix_level_ltrt = get_bits(gbc, 3);
                 s->surround_mix_level = get_bits(gbc, 3);
             }
         }
 
         /* lfe mix level */
-        if (s->lfe_on && get_bits1(gbc)) {
+        if (s->lfe_on && (s->lfe_mix_level_exists = get_bits1(gbc))) {
             // TODO: use LFE mix level
-            skip_bits(gbc, 5); // skip LFE mix level code
+            s->lfe_mix_level = get_bits(gbc, 5);
         }
 
         /* info for mixing with other streams and substreams */



More information about the ffmpeg-cvslog mailing list