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
363{363{
364 av_assert2(a >= -1.f && a <= 1.f);364 av_assert2(a >= -1.f && a <= 1.f);
365 av_assert2(p >= 0.f && p <= M_PI);365 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);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, -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);
368}368}
369 369
370static inline void get_lfe(int output_lfe, int n, float lowcut, float highcut,370static 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
1423 float r_phase = atan2f(r_im, r_re);1423 float r_phase = atan2f(r_im, r_re);
1424 float phase_dif = fabsf(l_phase - r_phase);1424 float phase_dif = fabsf(l_phase - r_phase);
1425 float mag_sum = l_mag + r_mag;1425 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;
1427 float mag_total = hypotf(l_mag, r_mag);1427 float mag_total = hypotf(l_mag, r_mag);
1428 float x, y;1428 float x, y;
1429 1429
1430 if (phase_dif > M_PI)1430 if (phase_dif > M_PI)
1431 phase_dif = 2 * M_PI - phase_dif;1431 phase_dif = 2.f * M_PI - phase_dif;
1432 1432
1433 stereo_position(mag_dif, phase_dif, &x, &y);1433 stereo_position(mag_dif, phase_dif, &x, &y);
1434 stereo_transform(&x, &y, angle);1434 stereo_transform(&x, &y, angle);
@@ -1465,12 +1465,12 @@ static void filter_surround(AVFilterContext *ctx) · 30 unmodified lines
1465 float r_phase = atan2f(r_im, r_re);1465 float r_phase = atan2f(r_im, r_re);
1466 float phase_dif = fabsf(l_phase - r_phase);1466 float phase_dif = fabsf(l_phase - r_phase);
1467 float mag_sum = l_mag + r_mag;1467 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;
1469 float mag_total = hypotf(l_mag, r_mag);1469 float mag_total = hypotf(l_mag, r_mag);
1470 float x, y;1470 float x, y;
1471 1471
1472 if (phase_dif > M_PI)1472 if (phase_dif > M_PI)
1473 phase_dif = 2 * M_PI - phase_dif;1473 phase_dif = 2.f * M_PI - phase_dif;
1474 1474
1475 stereo_position(mag_dif, phase_dif, &x, &y);1475 stereo_position(mag_dif, phase_dif, &x, &y);
1476 stereo_transform(&x, &y, s->angle);1476 stereo_transform(&x, &y, s->angle);
@@ -1500,12 +1500,12 @@ static void filter_2_1(AVFilterContext *ctx) · 23 unmodified lines
1500 float r_phase = atan2f(r_im, r_re);1500 float r_phase = atan2f(r_im, r_re);
1501 float phase_dif = fabsf(l_phase - r_phase);1501 float phase_dif = fabsf(l_phase - r_phase);
1502 float mag_sum = l_mag + r_mag;1502 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;
1504 float mag_total = hypotf(l_mag, r_mag);1504 float mag_total = hypotf(l_mag, r_mag);
1505 float x, y;1505 float x, y;
1506 1506
1507 if (phase_dif > M_PI)1507 if (phase_dif > M_PI)
1508 phase_dif = 2 * M_PI - phase_dif;1508 phase_dif = 2.f * M_PI - phase_dif;
1509 1509
1510 stereo_position(mag_dif, phase_dif, &x, &y);1510 stereo_position(mag_dif, phase_dif, &x, &y);
1511 stereo_transform(&x, &y, s->angle);1511 stereo_transform(&x, &y, s->angle);
@@ -1544,8 +1544,8 @@ static void filter_5_0_side(AVFilterContext *ctx) · 32 unmodified lines
1544 float phase_difr = fabsf(fr_phase - sr_phase);1544 float phase_difr = fabsf(fr_phase - sr_phase);
1545 float magl_sum = fl_mag + sl_mag;1545 float magl_sum = fl_mag + sl_mag;
1546 float magr_sum = fr_mag + sr_mag;1546 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;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.000001 ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;1548 float mag_difr = magr_sum < 0.000001f ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
1549 float mag_totall = hypotf(fl_mag, sl_mag);1549 float mag_totall = hypotf(fl_mag, sl_mag);
1550 float mag_totalr = hypotf(fr_mag, sr_mag);1550 float mag_totalr = hypotf(fr_mag, sr_mag);
1551 float bl_phase = atan2f(fl_im + sl_im, fl_re + sl_re);1551 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
1554 float xr, yr;1554 float xr, yr;
1555 1555
1556 if (phase_difl > M_PI)1556 if (phase_difl > M_PI)
1557 phase_difl = 2 * M_PI - phase_difl;1557 phase_difl = 2.f * M_PI - phase_difl;
1558 1558
1559 if (phase_difr > M_PI)1559 if (phase_difr > M_PI)
1560 phase_difr = 2 * M_PI - phase_difr;1560 phase_difr = 2.f * M_PI - phase_difr;
1561 1561
1562 stereo_position(mag_difl, phase_difl, &xl, &yl);1562 stereo_position(mag_difl, phase_difl, &xl, &yl);
1563 stereo_position(mag_difr, phase_difr, &xr, &yr);1563 stereo_position(mag_difr, phase_difr, &xr, &yr);
@@ -1603,8 +1603,8 @@ static void filter_5_1_side(AVFilterContext *ctx) · 39 unmodified lines
1603 float phase_difr = fabsf(fr_phase - sr_phase);1603 float phase_difr = fabsf(fr_phase - sr_phase);
1604 float magl_sum = fl_mag + sl_mag;1604 float magl_sum = fl_mag + sl_mag;
1605 float magr_sum = fr_mag + sr_mag;1605 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;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.000001 ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;1607 float mag_difr = magr_sum < 0.000001f ? FFDIFFSIGN(fr_mag, sr_mag) : (fr_mag - sr_mag) / magr_sum;
1608 float mag_totall = hypotf(fl_mag, sl_mag);1608 float mag_totall = hypotf(fl_mag, sl_mag);
1609 float mag_totalr = hypotf(fr_mag, sr_mag);1609 float mag_totalr = hypotf(fr_mag, sr_mag);
1610 float bl_phase = atan2f(fl_im + sl_im, fl_re + sl_re);1610 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
1613 float xr, yr;1613 float xr, yr;
1614 1614
1615 if (phase_difl > M_PI)1615 if (phase_difl > M_PI)
1616 phase_difl = 2 * M_PI - phase_difl;1616 phase_difl = 2.f * M_PI - phase_difl;
1617 1617
1618 if (phase_difr > M_PI)1618 if (phase_difr > M_PI)
1619 phase_difr = 2 * M_PI - phase_difr;1619 phase_difr = 2.f * M_PI - phase_difr;
1620 1620
1621 stereo_position(mag_difl, phase_difl, &xl, &yl);1621 stereo_position(mag_difl, phase_difl, &xl, &yl);
1622 stereo_position(mag_difr, phase_difr, &xr, &yr);1622 stereo_position(mag_difr, phase_difr, &xr, &yr);
@@ -1662,8 +1662,8 @@ static void filter_5_1_back(AVFilterContext *ctx) · 39 unmodified lines
1662 float phase_difr = fabsf(fr_phase - br_phase);1662 float phase_difr = fabsf(fr_phase - br_phase);
1663 float magl_sum = fl_mag + bl_mag;1663 float magl_sum = fl_mag + bl_mag;
1664 float magr_sum = fr_mag + br_mag;1664 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;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.000001 ? FFDIFFSIGN(fr_mag, br_mag) : (fr_mag - br_mag) / magr_sum;1666 float mag_difr = magr_sum < 0.000001f ? FFDIFFSIGN(fr_mag, br_mag) : (fr_mag - br_mag) / magr_sum;
1667 float mag_totall = hypotf(fl_mag, bl_mag);1667 float mag_totall = hypotf(fl_mag, bl_mag);
1668 float mag_totalr = hypotf(fr_mag, br_mag);1668 float mag_totalr = hypotf(fr_mag, br_mag);
1669 float sl_phase = atan2f(fl_im + bl_im, fl_re + bl_re);1669 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
1672 float xr, yr;1672 float xr, yr;
1673 1673
1674 if (phase_difl > M_PI)1674 if (phase_difl > M_PI)
1675 phase_difl = 2 * M_PI - phase_difl;1675 phase_difl = 2.f * M_PI - phase_difl;
1676 1676
1677 if (phase_difr > M_PI)1677 if (phase_difr > M_PI)
1678 phase_difr = 2 * M_PI - phase_difr;1678 phase_difr = 2.f * M_PI - phase_difr;
1679 1679
1680 stereo_position(mag_difl, phase_difl, &xl, &yl);1680 stereo_position(mag_difl, phase_difl, &xl, &yl);
1681 stereo_position(mag_difr, phase_difr, &xr, &yr);1681 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