diff mbox series

[FFmpeg-devel] avfilter/f_ebur128: multiply in integer first, before dividing in float

Message ID 20220405204128.1606-1-h.leppkes@gmail.com
State Accepted
Commit cd96211ace22224e27d00ed8bf92955e48ebff73
Headers show
Series [FFmpeg-devel] avfilter/f_ebur128: multiply in integer first, before dividing in float | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Hendrik Leppkes April 5, 2022, 8:41 p.m. UTC
Restores the order of operations from before 15a1104, which reduces
errors from floating point calculations, and fixes FATE on mingw64.
---
 libavfilter/f_ebur128.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paul B Mahol April 6, 2022, 2:38 p.m. UTC | #1
ok, if other fates are not regressed.
diff mbox series

Patch

diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 1b1bcf1bff..a036aa0c86 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -768,7 +768,7 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
 
                     /* get lower loudness to consider */
                     n = 0;
-                    nb_pow = LRA_LOWER_PRC * 0.01 * nb_powers + 0.5;
+                    nb_pow = LRA_LOWER_PRC * nb_powers * 0.01 + 0.5;
                     for (i = gate_hist_pos; i < HIST_SIZE; i++) {
                         n += ebur128->i3000.histogram[i].count;
                         if (n >= nb_pow) {
@@ -779,7 +779,7 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
 
                     /* get higher loudness to consider */
                     n = nb_powers;
-                    nb_pow = LRA_HIGHER_PRC * 0.01 * nb_powers + 0.5;
+                    nb_pow = LRA_HIGHER_PRC * nb_powers * 0.01 + 0.5;
                     for (i = HIST_SIZE - 1; i >= 0; i--) {
                         n -= FFMIN(n, ebur128->i3000.histogram[i].count);
                         if (n < nb_pow) {