]> git.sesse.net Git - ffmpeg/commitdiff
s->target_i and global are in dB but s->target_tp and true_peak are
authorSebastian Dröge <sebastian at centricular.com>
Sat, 2 May 2020 03:52:00 +0000 (20:52 -0700)
committerKyle Swanson <k@ylo.ph>
Sat, 2 May 2020 04:36:07 +0000 (21:36 -0700)
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>
libavfilter/af_loudnorm.c

index 314b25fa39f5fd3b1b92a5132eee0aedf3d0c651..8e3cdc36db5eec3e762d87a64d4c7dccdcbbdcae 100644 (file)
@@ -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;
     }