History

avfilter/f_ebur128: multiply is usually faster than divide

Also guard against overflow when subtracting from unsigned.

Paul B Mahol committed 4 years ago

Commit 15a11041 parent d5ad1d71 file · +3 −3Browse files

Unified · Split

libavfilter/f_ebur128.c+3−3
@@ -762,7 +762,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 761 unmodified lines
762762
763763 /* get lower loudness to consider */
764764 n = 0;
765− nb_pow = LRA_LOWER_PRC * nb_powers / 100. + 0.5;
765+ nb_pow = LRA_LOWER_PRC * 0.01 * nb_powers + 0.5;
766766 for (i = gate_hist_pos; i < HIST_SIZE; i++) {
767767 n += ebur128->i3000.histogram[i].count;
768768 if (n >= nb_pow) {
@@ -773,9 +773,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 4 unmodified lines
773773
774774 /* get higher loudness to consider */
775775 n = nb_powers;
776− nb_pow = LRA_HIGHER_PRC * nb_powers / 100. + 0.5;
776+ nb_pow = LRA_HIGHER_PRC * 0.01 * nb_powers + 0.5;
777777 for (i = HIST_SIZE - 1; i >= 0; i--) {
778− n -= ebur128->i3000.histogram[i].count;
778+ n -= FFMIN(n, ebur128->i3000.histogram[i].count);
779779 if (n < nb_pow) {
780780 ebur128->lra_high = ebur128->i3000.histogram[i].loudness;
781781 break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t