Commit 23d461fe authored by John Stebbins's avatar John Stebbins Committed by Tim Walker

ac3dec: Allow asymmetric application of DRC when drc_scale > 1

Amplification of quiet sounds is enhanced.
Inspired by gbooker's A52Decoder.
parent d67cfdeb
...@@ -778,8 +778,13 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) ...@@ -778,8 +778,13 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
i = !s->channel_mode; i = !s->channel_mode;
do { do {
if (get_bits1(gbc)) { if (get_bits1(gbc)) {
s->dynamic_range[i] = powf(dynamic_range_tab[get_bits(gbc, 8)], /* Allow asymmetric application of DRC when drc_scale > 1.
s->drc_scale); Amplification of quiet sounds is enhanced */
float range = dynamic_range_tab[get_bits(gbc, 8)];
if (range > 1.0 || s->drc_scale <= 1.0)
s->dynamic_range[i] = powf(range, s->drc_scale);
else
s->dynamic_range[i] = range;
} else if (blk == 0) { } else if (blk == 0) {
s->dynamic_range[i] = 1.0f; s->dynamic_range[i] = 1.0f;
} }
...@@ -1493,7 +1498,7 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx) ...@@ -1493,7 +1498,7 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)
#define OFFSET(x) offsetof(AC3DecodeContext, x) #define OFFSET(x) offsetof(AC3DecodeContext, x)
#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM) #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)
static const AVOption options[] = { static const AVOption options[] = {
{ "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 1.0, PAR }, { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0, PAR },
{ NULL}, { NULL},
}; };
......
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