Commit 3a5a039a authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'c229f571'

* commit 'c229f571':
  (e)ac3: parse and store the Lt/Rt and LFE mix levels.
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents c3d12156 c229f571
......@@ -106,6 +106,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;
......
......@@ -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;
......
......@@ -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)
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment