Commit 15a1104d authored by Paul B Mahol's avatar Paul B Mahol

avfilter/f_ebur128: multiply is usually faster than divide

Also guard against overflow when subtracting from unsigned.
parent d5ad1d78
......@@ -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;
......
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