From 13345fc1f86fc3615789e196d5a339c1c27c9068 Mon Sep 17 00:00:00 2001 From: Tim Walker Date: Wed, 11 Dec 2013 02:03:34 +0000 Subject: (e)ac3: parse and store the Dolby Surround, Surround EX and Headphone mode flags. --- libavcodec/ac3dec.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'libavcodec/ac3dec.c') diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index e1c696269e..2b71c8384c 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -227,12 +227,26 @@ static int ac3_parse_header(AC3DecodeContext *s) skip_bits(gbc, 2); //skip copyright bit and original bitstream bit - /* skip the timecodes (or extra bitstream information for Alternate Syntax) + /* default dolby matrix encoding modes */ + s->dolby_surround_ex_mode = AC3_DSUREXMOD_NOTINDICATED; + s->dolby_headphone_mode = AC3_DHEADPHONMOD_NOTINDICATED; + + /* skip the timecodes or parse the Alternate Bit Stream Syntax TODO: read & use the xbsi1 downmix levels */ - if (get_bits1(gbc)) - skip_bits(gbc, 14); //skip timecode1 / xbsi1 - if (get_bits1(gbc)) - skip_bits(gbc, 14); //skip timecode2 / xbsi2 + 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->dolby_surround_ex_mode = get_bits(gbc, 2); + s->dolby_headphone_mode = get_bits(gbc, 2); + skip_bits(gbc, 10); // skip adconvtyp (1), xbsi2 (8), encinfo (1) + } + } /* skip additional bitstream info */ if (get_bits1(gbc)) { @@ -259,6 +273,7 @@ static int parse_frame_header(AC3DecodeContext *s) /* get decoding parameters from header info */ s->bit_alloc_params.sr_code = hdr.sr_code; + s->bitstream_id = hdr.bitstream_id; s->bitstream_mode = hdr.bitstream_mode; s->channel_mode = hdr.channel_mode; s->lfe_on = hdr.lfe_on; @@ -274,6 +289,7 @@ static int parse_frame_header(AC3DecodeContext *s) s->num_blocks = hdr.num_blocks; s->frame_type = hdr.frame_type; s->substreamid = hdr.substreamid; + s->dolby_surround_mode = hdr.dolby_surround_mode; if (s->lfe_on) { s->start_freq[s->lfe_ch] = 0; @@ -282,7 +298,7 @@ static int parse_frame_header(AC3DecodeContext *s) s->channel_in_cpl[s->lfe_ch] = 0; } - if (hdr.bitstream_id <= 10) { + if (s->bitstream_id <= 10) { s->eac3 = 0; s->snr_offset_strategy = 2; s->block_switch_syntax = 1; -- cgit v1.2.3