avfilter/af_surround: avoid using doubles

This commit is contained in:
Paul B Mahol 2022-11-15 09:52:39 +01:00
parent eb1e359a14
commit 11d744343f
1 changed files with 20 additions and 20 deletions

View File

@ -363,8 +363,8 @@ static void stereo_position(float a, float p, float *x, float *y)
{
av_assert2(a >= -1.f && a <= 1.f);
av_assert2(p >= 0.f && p <= M_PI);
*x = av_clipf(a+a*FFMAX(0, p*p-M_PI_2), -1.f, 1.f);
*y = av_clipf(cosf(a*M_PI_2+M_PI)*cosf(M_PI_2-p/M_PI)*M_LN10+1, -1.f, 1.f);
*x = av_clipf(a+a*fmaxf(0.f, p*p-M_PI_2), -1.f, 1.f);
*y = av_clipf(cosf(a*M_PI_2+M_PI)*cosf(M_PI_2-p/M_PI)*M_LN10+1.f, -1.f, 1.f);
}
static inline void get_lfe(int output_lfe, int n, float lowcut, float highcut,
@ -1423,12 +1423,12 @@ static void filter_stereo(AVFilterContext *ctx)
float r_phase = atan2f(r_im, r_re);
float phase_dif = fabsf(l_phase - r_phase);
float mag_sum = l_mag + r_mag;
float mag_dif = mag_sum < 0.000001 ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
float mag_dif = mag_sum < 0.000001f ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
float mag_total = hypotf(l_mag, r_mag);
float x, y;
if (phase_dif > M_PI)
phase_dif = 2 * M_PI - phase_dif;
phase_dif = 2.f * M_PI - phase_dif;
stereo_position(mag_dif, phase_dif, &x, &y);
stereo_transform(&x, &y, angle);
@ -1465,12 +1465,12 @@ static void filter_surround(AVFilterContext *ctx)
float r_phase = atan2f(r_im, r_re);
float phase_dif = fabsf(l_phase - r_phase);
float mag_sum = l_mag + r_mag;
float mag_dif = mag_sum < 0.000001 ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
float mag_dif = mag_sum < 0.000001f ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
float mag_total = hypotf(l_mag, r_mag);
float x, y;
if (phase_dif > M_PI)
phase_dif = 2 * M_PI - phase_dif;
phase_dif = 2.f * M_PI - phase_dif;
stereo_position(mag_dif, phase_dif, &x, &y);
stereo_transform(&x, &y, s->angle);
@ -1500,12 +1500,12 @@ static void filter_2_1(AVFilterContext *ctx)
float r_phase = atan2f(r_im, r_re);
float phase_dif = fabsf(l_phase - r_phase);
float mag_sum = l_mag + r_mag;
float mag_dif = mag_sum < 0.000001 ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
float mag_dif = mag_sum < 0.000001f ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
float mag_total = hypotf(l_mag, r_mag);
float x, y;
if (phase_dif > M_PI)
phase_dif = 2 * M_PI - phase_dif;
phase_dif = 2.f * M_PI - phase_dif;
stereo_position(mag_dif, phase_dif, &x, &y);
stereo_transform(&x, &y, s->angle);
@ -1544,8 +1544,8 @@ static void filter_5_0_side(AVFilterContext *ctx)
float phase_difr = fabsf(fr_phase - sr_phase);
float magl_sum = fl_mag + sl_mag;
float magr_sum = fr_mag + sr_mag;
float mag_difl = magl_sum < 0.000001 ? FFDIFFSIGN(fl_mag, sl_mag) : (fl_mag - sl_mag) / magl_sum;
float mag_difr = magr_sum < 0.000001 ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
float mag_difl = magl_sum < 0.000001f ? FFDIFFSIGN(fl_mag, sl_mag) : (fl_mag - sl_mag) / magl_sum;
float mag_difr = magr_sum < 0.000001f ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
float mag_totall = hypotf(fl_mag, sl_mag);
float mag_totalr = hypotf(fr_mag, sr_mag);
float bl_phase = atan2f(fl_im + sl_im, fl_re + sl_re);
@ -1554,10 +1554,10 @@ static void filter_5_0_side(AVFilterContext *ctx)
float xr, yr;
if (phase_difl > M_PI)
phase_difl = 2 * M_PI - phase_difl;
phase_difl = 2.f * M_PI - phase_difl;
if (phase_difr > M_PI)
phase_difr = 2 * M_PI - phase_difr;
phase_difr = 2.f * M_PI - phase_difr;
stereo_position(mag_difl, phase_difl, &xl, &yl);
stereo_position(mag_difr, phase_difr, &xr, &yr);
@ -1603,8 +1603,8 @@ static void filter_5_1_side(AVFilterContext *ctx)
float phase_difr = fabsf(fr_phase - sr_phase);
float magl_sum = fl_mag + sl_mag;
float magr_sum = fr_mag + sr_mag;
float mag_difl = magl_sum < 0.000001 ? FFDIFFSIGN(fl_mag, sl_mag) : (fl_mag - sl_mag) / magl_sum;
float mag_difr = magr_sum < 0.000001 ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
float mag_difl = magl_sum < 0.000001f ? FFDIFFSIGN(fl_mag, sl_mag) : (fl_mag - sl_mag) / magl_sum;
float mag_difr = magr_sum < 0.000001f ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
float mag_totall = hypotf(fl_mag, sl_mag);
float mag_totalr = hypotf(fr_mag, sr_mag);
float bl_phase = atan2f(fl_im + sl_im, fl_re + sl_re);
@ -1613,10 +1613,10 @@ static void filter_5_1_side(AVFilterContext *ctx)
float xr, yr;
if (phase_difl > M_PI)
phase_difl = 2 * M_PI - phase_difl;
phase_difl = 2.f * M_PI - phase_difl;
if (phase_difr > M_PI)
phase_difr = 2 * M_PI - phase_difr;
phase_difr = 2.f * M_PI - phase_difr;
stereo_position(mag_difl, phase_difl, &xl, &yl);
stereo_position(mag_difr, phase_difr, &xr, &yr);
@ -1662,8 +1662,8 @@ static void filter_5_1_back(AVFilterContext *ctx)
float phase_difr = fabsf(fr_phase - br_phase);
float magl_sum = fl_mag + bl_mag;
float magr_sum = fr_mag + br_mag;
float mag_difl = magl_sum < 0.000001 ? FFDIFFSIGN(fl_mag, bl_mag) : (fl_mag - bl_mag) / magl_sum;
float mag_difr = magr_sum < 0.000001 ? FFDIFFSIGN(fr_mag, br_mag) : (fr_mag - br_mag) / magr_sum;
float mag_difl = magl_sum < 0.000001f ? FFDIFFSIGN(fl_mag, bl_mag) : (fl_mag - bl_mag) / magl_sum;
float mag_difr = magr_sum < 0.000001f ? FFDIFFSIGN(fr_mag, br_mag) : (fr_mag - br_mag) / magr_sum;
float mag_totall = hypotf(fl_mag, bl_mag);
float mag_totalr = hypotf(fr_mag, br_mag);
float sl_phase = atan2f(fl_im + bl_im, fl_re + bl_re);
@ -1672,10 +1672,10 @@ static void filter_5_1_back(AVFilterContext *ctx)
float xr, yr;
if (phase_difl > M_PI)
phase_difl = 2 * M_PI - phase_difl;
phase_difl = 2.f * M_PI - phase_difl;
if (phase_difr > M_PI)
phase_difr = 2 * M_PI - phase_difr;
phase_difr = 2.f * M_PI - phase_difr;
stereo_position(mag_difl, phase_difl, &xl, &yl);
stereo_position(mag_difr, phase_difr, &xr, &yr);