History

avfilter/af_surround: avoid using doubles

Paul B Mahol committed 4 years ago

Commit 11d74431 parent eb1e3591 file · +20 −20Browse files

Unified · Split

libavfilter/af_surround.c+20−20
@@ -363,8 +363,8 @@ static void stereo_position(float a, float p, float *x, float *y) · 362 unmodified lines
363363 {
364364 av_assert2(a >= -1.f && a <= 1.f);
365365 av_assert2(p >= 0.f && p <= M_PI);
366− *x = av_clipf(a+a*FFMAX(0, p*p-M_PI_2), -1.f, 1.f);
367− *y = av_clipf(cosf(a*M_PI_2+M_PI)*cosf(M_PI_2-p/M_PI)*M_LN10+1, -1.f, 1.f);
366+ *x = av_clipf(a+a*fmaxf(0.f, p*p-M_PI_2), -1.f, 1.f);
367+ *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);
368368 }
369369
370370 static inline void get_lfe(int output_lfe, int n, float lowcut, float highcut,
@@ -1423,12 +1423,12 @@ static void filter_stereo(AVFilterContext *ctx) · 1052 unmodified lines
14231423 float r_phase = atan2f(r_im, r_re);
14241424 float phase_dif = fabsf(l_phase - r_phase);
14251425 float mag_sum = l_mag + r_mag;
1426− float mag_dif = mag_sum < 0.000001 ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
1426+ float mag_dif = mag_sum < 0.000001f ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
14271427 float mag_total = hypotf(l_mag, r_mag);
14281428 float x, y;
14291429
14301430 if (phase_dif > M_PI)
1431− phase_dif = 2 * M_PI - phase_dif;
1431+ phase_dif = 2.f * M_PI - phase_dif;
14321432
14331433 stereo_position(mag_dif, phase_dif, &x, &y);
14341434 stereo_transform(&x, &y, angle);
@@ -1465,12 +1465,12 @@ static void filter_surround(AVFilterContext *ctx) · 30 unmodified lines
14651465 float r_phase = atan2f(r_im, r_re);
14661466 float phase_dif = fabsf(l_phase - r_phase);
14671467 float mag_sum = l_mag + r_mag;
1468− float mag_dif = mag_sum < 0.000001 ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
1468+ float mag_dif = mag_sum < 0.000001f ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
14691469 float mag_total = hypotf(l_mag, r_mag);
14701470 float x, y;
14711471
14721472 if (phase_dif > M_PI)
1473− phase_dif = 2 * M_PI - phase_dif;
1473+ phase_dif = 2.f * M_PI - phase_dif;
14741474
14751475 stereo_position(mag_dif, phase_dif, &x, &y);
14761476 stereo_transform(&x, &y, s->angle);
@@ -1500,12 +1500,12 @@ static void filter_2_1(AVFilterContext *ctx) · 23 unmodified lines
15001500 float r_phase = atan2f(r_im, r_re);
15011501 float phase_dif = fabsf(l_phase - r_phase);
15021502 float mag_sum = l_mag + r_mag;
1503− float mag_dif = mag_sum < 0.000001 ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
1503+ float mag_dif = mag_sum < 0.000001f ? FFDIFFSIGN(l_mag, r_mag) : (l_mag - r_mag) / mag_sum;
15041504 float mag_total = hypotf(l_mag, r_mag);
15051505 float x, y;
15061506
15071507 if (phase_dif > M_PI)
1508− phase_dif = 2 * M_PI - phase_dif;
1508+ phase_dif = 2.f * M_PI - phase_dif;
15091509
15101510 stereo_position(mag_dif, phase_dif, &x, &y);
15111511 stereo_transform(&x, &y, s->angle);
@@ -1544,8 +1544,8 @@ static void filter_5_0_side(AVFilterContext *ctx) · 32 unmodified lines
15441544 float phase_difr = fabsf(fr_phase - sr_phase);
15451545 float magl_sum = fl_mag + sl_mag;
15461546 float magr_sum = fr_mag + sr_mag;
1547− float mag_difl = magl_sum < 0.000001 ? FFDIFFSIGN(fl_mag, sl_mag) : (fl_mag - sl_mag) / magl_sum;
1548− float mag_difr = magr_sum < 0.000001 ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
1547+ float mag_difl = magl_sum < 0.000001f ? FFDIFFSIGN(fl_mag, sl_mag) : (fl_mag - sl_mag) / magl_sum;
1548+ float mag_difr = magr_sum < 0.000001f ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
15491549 float mag_totall = hypotf(fl_mag, sl_mag);
15501550 float mag_totalr = hypotf(fr_mag, sr_mag);
15511551 float bl_phase = atan2f(fl_im + sl_im, fl_re + sl_re);
@@ -1554,10 +1554,10 @@ static void filter_5_0_side(AVFilterContext *ctx) · 2 unmodified lines
15541554 float xr, yr;
15551555
15561556 if (phase_difl > M_PI)
1557− phase_difl = 2 * M_PI - phase_difl;
1557+ phase_difl = 2.f * M_PI - phase_difl;
15581558
15591559 if (phase_difr > M_PI)
1560− phase_difr = 2 * M_PI - phase_difr;
1560+ phase_difr = 2.f * M_PI - phase_difr;
15611561
15621562 stereo_position(mag_difl, phase_difl, &xl, &yl);
15631563 stereo_position(mag_difr, phase_difr, &xr, &yr);
@@ -1603,8 +1603,8 @@ static void filter_5_1_side(AVFilterContext *ctx) · 39 unmodified lines
16031603 float phase_difr = fabsf(fr_phase - sr_phase);
16041604 float magl_sum = fl_mag + sl_mag;
16051605 float magr_sum = fr_mag + sr_mag;
1606− float mag_difl = magl_sum < 0.000001 ? FFDIFFSIGN(fl_mag, sl_mag) : (fl_mag - sl_mag) / magl_sum;
1607− float mag_difr = magr_sum < 0.000001 ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
1606+ float mag_difl = magl_sum < 0.000001f ? FFDIFFSIGN(fl_mag, sl_mag) : (fl_mag - sl_mag) / magl_sum;
1607+ float mag_difr = magr_sum < 0.000001f ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
16081608 float mag_totall = hypotf(fl_mag, sl_mag);
16091609 float mag_totalr = hypotf(fr_mag, sr_mag);
16101610 float bl_phase = atan2f(fl_im + sl_im, fl_re + sl_re);
@@ -1613,10 +1613,10 @@ static void filter_5_1_side(AVFilterContext *ctx) · 2 unmodified lines
16131613 float xr, yr;
16141614
16151615 if (phase_difl > M_PI)
1616− phase_difl = 2 * M_PI - phase_difl;
1616+ phase_difl = 2.f * M_PI - phase_difl;
16171617
16181618 if (phase_difr > M_PI)
1619− phase_difr = 2 * M_PI - phase_difr;
1619+ phase_difr = 2.f * M_PI - phase_difr;
16201620
16211621 stereo_position(mag_difl, phase_difl, &xl, &yl);
16221622 stereo_position(mag_difr, phase_difr, &xr, &yr);
@@ -1662,8 +1662,8 @@ static void filter_5_1_back(AVFilterContext *ctx) · 39 unmodified lines
16621662 float phase_difr = fabsf(fr_phase - br_phase);
16631663 float magl_sum = fl_mag + bl_mag;
16641664 float magr_sum = fr_mag + br_mag;
1665− float mag_difl = magl_sum < 0.000001 ? FFDIFFSIGN(fl_mag, bl_mag) : (fl_mag - bl_mag) / magl_sum;
1666− float mag_difr = magr_sum < 0.000001 ? FFDIFFSIGN(fr_mag, br_mag) : (fr_mag - br_mag) / magr_sum;
1665+ float mag_difl = magl_sum < 0.000001f ? FFDIFFSIGN(fl_mag, bl_mag) : (fl_mag - bl_mag) / magl_sum;
1666+ float mag_difr = magr_sum < 0.000001f ? FFDIFFSIGN(fr_mag, br_mag) : (fr_mag - br_mag) / magr_sum;
16671667 float mag_totall = hypotf(fl_mag, bl_mag);
16681668 float mag_totalr = hypotf(fr_mag, br_mag);
16691669 float sl_phase = atan2f(fl_im + bl_im, fl_re + bl_re);
@@ -1672,10 +1672,10 @@ static void filter_5_1_back(AVFilterContext *ctx) · 2 unmodified lines
16721672 float xr, yr;
16731673
16741674 if (phase_difl > M_PI)
1675− phase_difl = 2 * M_PI - phase_difl;
1675+ phase_difl = 2.f * M_PI - phase_difl;
16761676
16771677 if (phase_difr > M_PI)
1678− phase_difr = 2 * M_PI - phase_difr;
1678+ phase_difr = 2.f * M_PI - phase_difr;
16791679
16801680 stereo_position(mag_difl, phase_difl, &xl, &yl);
16811681 stereo_position(mag_difr, phase_difr, &xr, &yr);

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