Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-02-24 12:30:37 +0300
committerPaul B Mahol <onemda@gmail.com>2022-02-24 13:15:28 +0300
commit15a1104d73cbd47a67fc14ce2ddc97a92145695e (patch)
tree863f0f263dbcf11924c9bd2276bf0eacaf631ce0 /libavfilter/f_ebur128.c
parentd5ad1d7847ebfa4da1f1476c4af18fa2701e4d24 (diff)
avfilter/f_ebur128: multiply is usually faster than divide
Also guard against overflow when subtracting from unsigned.
Diffstat (limited to 'libavfilter/f_ebur128.c')
-rw-r--r--libavfilter/f_ebur128.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index d5ffab7ca1..f63cf77983 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -762,7 +762,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
/* get lower loudness to consider */
n = 0;
- nb_pow = LRA_LOWER_PRC * nb_powers / 100. + 0.5;
+ nb_pow = LRA_LOWER_PRC * 0.01 * nb_powers + 0.5;
for (i = gate_hist_pos; i < HIST_SIZE; i++) {
n += ebur128->i3000.histogram[i].count;
if (n >= nb_pow) {
@@ -773,9 +773,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
/* get higher loudness to consider */
n = nb_powers;
- nb_pow = LRA_HIGHER_PRC * nb_powers / 100. + 0.5;
+ nb_pow = LRA_HIGHER_PRC * 0.01 * nb_powers + 0.5;
for (i = HIST_SIZE - 1; i >= 0; i--) {
- n -= ebur128->i3000.histogram[i].count;
+ n -= FFMIN(n, ebur128->i3000.histogram[i].count);
if (n < nb_pow) {
ebur128->lra_high = ebur128->i3000.histogram[i].loudness;
break;