History

avfilter/af_surround: improve LFE loudness

Paul B Mahol committed 3 years ago

Commit fced45f1 parent 52291d21 file · +7 −7Browse files

Unified · Split

libavfilter/af_surround.c+7−7
@@ -387,11 +387,11 @@ static void stereo_position(float a, float p, float *x, float *y) · 386 unmodified lines
387}387}
388 388
389static inline void get_lfe(int output_lfe, int n, float lowcut, float highcut,389static inline void get_lfe(int output_lfe, int n, float lowcut, float highcut,
390 float *lfe_mag, float *mag_total, int lfe_mode)390 float *lfe_mag, float c_mag, float *mag_total, int lfe_mode)
391{391{
392 if (output_lfe && n < highcut) {392 if (output_lfe && n < highcut) {
393 *lfe_mag = n < lowcut ? 1.f : .5f*(1.f+cosf(M_PI*(lowcut-n)/(lowcut-highcut)));393 *lfe_mag = n < lowcut ? 1.f : .5f*(1.f+cosf(M_PI*(lowcut-n)/(lowcut-highcut)));
394 *lfe_mag *= *mag_total;394 *lfe_mag *= c_mag;
395 if (lfe_mode)395 if (lfe_mode)
396 *mag_total -= *lfe_mag;396 *mag_total -= *lfe_mag;
397 } else {397 } else {
@@ -440,7 +440,7 @@ static int stereo_upmix(AVFilterContext *ctx, int ch) · 42 unmodified lines
440 break;440 break;
441 case AV_CHAN_LOW_FREQUENCY:441 case AV_CHAN_LOW_FREQUENCY:
442 for (int n = 0; n < rdft_size; n++)442 for (int n = 0; n < rdft_size; n++)
443 factor[n] = lfe_mag[n];443 factor[n] = powf(1.f - fabsf(x[n]), f_x) * powf((1.f - fabs(y[n])), f_y);
444 break;444 break;
445 case AV_CHAN_BACK_CENTER:445 case AV_CHAN_BACK_CENTER:
446 for (int n = 0; n < rdft_size; n++)446 for (int n = 0; n < rdft_size; n++)
@@ -543,7 +543,7 @@ static void upmix_3_1_surround(AVFilterContext *ctx, · 96 unmodified lines
543 dstc = (float *)s->output->extended_data[2];543 dstc = (float *)s->output->extended_data[2];
544 dstlfe = (float *)s->output->extended_data[3];544 dstlfe = (float *)s->output->extended_data[3];
545 545
546 get_lfe(s->output_lfe, n, s->lowcut, s->highcut, &lfe_mag, &c_mag, s->lfe_mode);546 get_lfe(s->output_lfe, n, s->lowcut, s->highcut, &lfe_mag, c_mag, &mag_total, s->lfe_mode);
547 547
548 l_mag = powf(.5f * ( x + 1.f), s->f_x[SC_FL]) * powf((y + 1.f) * .5f, s->f_y[SC_FL]) * mag_total;548 l_mag = powf(.5f * ( x + 1.f), s->f_x[SC_FL]) * powf((y + 1.f) * .5f, s->f_y[SC_FL]) * mag_total;
549 r_mag = powf(.5f * (-x + 1.f), s->f_x[SC_FR]) * powf((y + 1.f) * .5f, s->f_y[SC_FR]) * mag_total;549 r_mag = powf(.5f * (-x + 1.f), s->f_x[SC_FR]) * powf((y + 1.f) * .5f, s->f_y[SC_FR]) * mag_total;
@@ -581,7 +581,7 @@ static void upmix_5_1_back_surround(AVFilterContext *ctx, · 31 unmodified lines
581 dstls = (float *)s->output->extended_data[4];581 dstls = (float *)s->output->extended_data[4];
582 dstrs = (float *)s->output->extended_data[5];582 dstrs = (float *)s->output->extended_data[5];
583 583
584 get_lfe(s->output_lfe, n, s->lowcut, s->highcut, &lfe_mag, &c_mag, s->lfe_mode);584 get_lfe(s->output_lfe, n, s->lowcut, s->highcut, &lfe_mag, c_mag, &mag_total, s->lfe_mode);
585 585
586 l_mag = powf(.5f * ( x + 1.f), s->f_x[SC_FL]) * powf((y + 1.f) * .5f, s->f_y[SC_FL]) * mag_total;586 l_mag = powf(.5f * ( x + 1.f), s->f_x[SC_FL]) * powf((y + 1.f) * .5f, s->f_y[SC_FL]) * mag_total;
587 r_mag = powf(.5f * (-x + 1.f), s->f_x[SC_FR]) * powf((y + 1.f) * .5f, s->f_y[SC_FR]) * mag_total;587 r_mag = powf(.5f * (-x + 1.f), s->f_x[SC_FR]) * powf((y + 1.f) * .5f, s->f_y[SC_FR]) * mag_total;
@@ -679,7 +679,7 @@ static void upmix_7_1_5_0_side(AVFilterContext *ctx, · 91 unmodified lines
679 679
680 c_phase = atan2f(c_im, c_re);680 c_phase = atan2f(c_im, c_re);
681 681
682 get_lfe(s->output_lfe, n, s->lowcut, s->highcut, &lfe_mag, &mag_total, s->lfe_mode);682 get_lfe(s->output_lfe, n, s->lowcut, s->highcut, &lfe_mag, hypotf(c_re, c_im), &mag_total, s->lfe_mode);
683 683
684 fl_mag = powf(.5f * (xl + 1.f), s->f_x[SC_FL]) * powf((yl + 1.f) * .5f, s->f_y[SC_FL]) * mag_totall;684 fl_mag = powf(.5f * (xl + 1.f), s->f_x[SC_FL]) * powf((yl + 1.f) * .5f, s->f_y[SC_FL]) * mag_totall;
685 fr_mag = powf(.5f * (xr + 1.f), s->f_x[SC_FR]) * powf((yr + 1.f) * .5f, s->f_y[SC_FR]) * mag_totalr;685 fr_mag = powf(.5f * (xr + 1.f), s->f_x[SC_FR]) * powf((yr + 1.f) * .5f, s->f_y[SC_FR]) * mag_totalr;
@@ -811,7 +811,7 @@ static void filter_stereo(AVFilterContext *ctx) · 125 unmodified lines
811 stereo_position(mag_dif, phase_dif, &x, &y);811 stereo_position(mag_dif, phase_dif, &x, &y);
812 angle_transform(&x, &y, angle);812 angle_transform(&x, &y, angle);
813 focus_transform(&x, &y, focus);813 focus_transform(&x, &y, focus);
814 get_lfe(output_lfe, n, lowcut, highcut, &lfemag[n], &mag_total, lfe_mode);814 get_lfe(output_lfe, n, lowcut, highcut, &lfemag[n], c_mag, &mag_total, lfe_mode);
815 815
816 xpos[n] = x;816 xpos[n] = x;
817 ypos[n] = y;817 ypos[n] = y;

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