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

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/f_ebur128.c+3−3
@@ -762,7 +762,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 761 unmodified lines
762 762
763 /* get lower loudness to consider */763 /* get lower loudness to consider */
764 n = 0;764 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;
766 for (i = gate_hist_pos; i < HIST_SIZE; i++) {766 for (i = gate_hist_pos; i < HIST_SIZE; i++) {
767 n += ebur128->i3000.histogram[i].count;767 n += ebur128->i3000.histogram[i].count;
768 if (n >= nb_pow) {768 if (n >= nb_pow) {
@@ -773,9 +773,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 4 unmodified lines
773 773
774 /* get higher loudness to consider */774 /* get higher loudness to consider */
775 n = nb_powers;775 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;
777 for (i = HIST_SIZE - 1; i >= 0; i--) {777 for (i = HIST_SIZE - 1; i >= 0; i--) {
778 n -= ebur128->i3000.histogram[i].count;778 n -= FFMIN(n, ebur128->i3000.histogram[i].count);
779 if (n < nb_pow) {779 if (n < nb_pow) {
780 ebur128->lra_high = ebur128->i3000.histogram[i].loudness;780 ebur128->lra_high = ebur128->i3000.histogram[i].loudness;
781 break;781 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