summaryrefslogtreecommitdiff
path: root/libavfilter/af_loudnorm.c
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian at centricular.com>2020-05-01 20:52:00 -0700
committerKyle Swanson <k@ylo.ph>2020-05-01 21:36:07 -0700
commited3da72583298ed04a488e363bd3fa6d69ade165 (patch)
treebddfc37694f83f2898ab051622f7ef316aa25fbe /libavfilter/af_loudnorm.c
parent9ce7de903882793749abc68eeb29813a19f50de5 (diff)
s->target_i and global are in dB but s->target_tp and true_peak are
linear. Instead of mixing these in the calculations, convert the former first to have all following calculations in the same unit. Signed-off-by: Kyle Swanson <k@ylo.ph>
Diffstat (limited to 'libavfilter/af_loudnorm.c')
-rw-r--r--libavfilter/af_loudnorm.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c
index 314b25fa39..8e3cdc36db 100644
--- a/libavfilter/af_loudnorm.c
+++ b/libavfilter/af_loudnorm.c
@@ -453,10 +453,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
true_peak = tmp;
}
- offset = s->target_i - global;
- offset_tp = true_peak + offset;
+ offset = pow(10., (s->target_i - global) / 20.);
+ offset_tp = true_peak * offset;
s->offset = offset_tp < s->target_tp ? offset : s->target_tp - true_peak;
- s->offset = pow(10., s->offset / 20.);
s->frame_type = LINEAR_MODE;
}