diff options
author | Nikolas Bowe <nbowe-at-google.com@ffmpeg.org> | 2016-09-09 12:48:52 -0700 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-09-15 12:18:55 +0200 |
commit | 96cd6f672e5d8c5d49b06de4f24376f36880fea8 (patch) | |
tree | a21fbbd26b2c12c0c932b8f9b8af9e3a7568d836 /libavcodec/eac3dec.c | |
parent | 6f062eb8d0e17398f225c537d5fd78f5ae880906 (diff) | |
download | ffmpeg-96cd6f672e5d8c5d49b06de4f24376f36880fea8.tar.gz |
avcodec/(e)ac3: Fix target_level for EAC3.
Currently when using target_level with EAC3 it produces silence. This small patch fixes target_level for decoding EAC3.
Example:
ffmpeg -y -i /tmp/test.wav -acodec eac3 -dialnorm -14 -ac 6 -b:a 384000 /tmp/test.m2ts
ffmpeg -y -target_level -24 -i /tmp/test.m2ts -acodec pcm_s16le -f matroska /tmp/out.mkv
ffplay /tmp/out.mkv
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/eac3dec.c')
-rw-r--r-- | libavcodec/eac3dec.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c index 47e5aa6587..83a54bcfab 100644 --- a/libavcodec/eac3dec.c +++ b/libavcodec/eac3dec.c @@ -339,9 +339,17 @@ static int ff_eac3_parse_header(AC3DecodeContext *s) /* volume control params */ for (i = 0; i < (s->channel_mode ? 1 : 2); i++) { - skip_bits(gbc, 5); // skip dialog normalization - if (get_bits1(gbc)) { - skip_bits(gbc, 8); // skip compression gain word + s->dialog_normalization[i] = -get_bits(gbc, 5); + if (s->dialog_normalization[i] == 0) { + s->dialog_normalization[i] = -31; + } + if (s->target_level != 0) { + s->level_gain[i] = powf(2.0f, + (float)(s->target_level - s->dialog_normalization[i])/6.0f); + } + s->compression_exists[i] = get_bits1(gbc); + if (s->compression_exists[i]) { + s->heavy_dynamic_range[i] = AC3_HEAVY_RANGE(get_bits(gbc, 8)); } } |