aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorTim Walker <tdskywalker@gmail.com>2014-01-17 15:57:40 +0100
committerTim Walker <tdskywalker@gmail.com>2014-01-19 19:12:42 +0100
commitc229f571fd3c7d7b567c27c87b2bbcdaee1b0e9f (patch)
treeb6b72196768c8731b4d4dbf1651fdda6634f7375 /libavcodec
parent1f604f96ea70503caa642f68a85be6074a5b3f46 (diff)
downloadffmpeg-c229f571fd3c7d7b567c27c87b2bbcdaee1b0e9f.tar.gz
(e)ac3: parse and store the Lt/Rt and LFE mix levels.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3.h8
-rw-r--r--libavcodec/ac3dec.c16
-rw-r--r--libavcodec/ac3dec.h5
-rw-r--r--libavcodec/eac3dec.c10
4 files changed, 30 insertions, 9 deletions
diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index f01da07213..fa290d35e9 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 584ce1a35a..b6ee401485 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 73ca1c3305..8fcd1421dc 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 731735f2c9..dfd78c6ad7 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 */