History

avfilter/af_surround: reduce double usage

Paul B Mahol committed 3 years ago

Commit d1ded731 parent f0136501 file · +27 −27Browse files

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

Unified · Split

libavfilter/af_surround.c+27−27
@@ -330,16 +330,16 @@ static void angle_transform(float *x, float *y, float angle) · 329 unmodified lines
330 if (angle == 90.f)330 if (angle == 90.f)
331 return;331 return;
332 332
333 reference = angle * M_PI / 180.f;333 reference = angle * (float)M_PI / 180.f;
334 r = hypotf(*x, *y);334 r = hypotf(*x, *y);
335 a = atan2f(*x, *y);335 a = atan2f(*x, *y);
336 336
337 r /= r_distance(a);337 r /= r_distance(a);
338 338
339 if (fabsf(a) <= M_PI_4)339 if (fabsf(a) <= (float)M_PI_4)
340 a *= reference / M_PI_2;340 a *= reference / (float)M_PI_2;
341 else341 else
342 a = M_PI + (-2.f * M_PI + reference) * (M_PI - fabsf(a)) * FFDIFFSIGN(a, 0.f) / (3.f * M_PI_2);342 a = (float)M_PI + (-2.f * (float)M_PI + reference) * ((float)M_PI - fabsf(a)) * FFDIFFSIGN(a, 0.f) / (3.f * (float)M_PI_2);
343 343
344 r *= r_distance(a);344 r *= r_distance(a);
345 345
@@ -366,16 +366,16 @@ static void focus_transform(float *x, float *y, float focus) · 20 unmodified lines
366static void stereo_position(float a, float p, float *x, float *y)366static void stereo_position(float a, float p, float *x, float *y)
367{367{
368 av_assert2(a >= -1.f && a <= 1.f);368 av_assert2(a >= -1.f && a <= 1.f);
369 av_assert2(p >= 0.f && p <= M_PI);369 av_assert2(p >= 0.f && p <= (float)M_PI);
370 *x = av_clipf(a+a*fmaxf(0.f, p*p-M_PI_2), -1.f, 1.f);370 *x = av_clipf(a+a*fmaxf(0.f, p*p-(float)M_PI_2), -1.f, 1.f);
371 *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);371 *y = av_clipf(cosf(a*(float)M_PI_2+(float)M_PI)*cosf((float)M_PI_2-p/(float)M_PI)*(float)M_LN10+1.f, -1.f, 1.f);
372}372}
373 373
374static inline void get_lfe(int output_lfe, int n, float lowcut, float highcut,374static inline void get_lfe(int output_lfe, int n, float lowcut, float highcut,
375 float *lfe_mag, float c_mag, float *mag_total, int lfe_mode)375 float *lfe_mag, float c_mag, float *mag_total, int lfe_mode)
376{376{
377 if (output_lfe && n < highcut) {377 if (output_lfe && n < highcut) {
378 *lfe_mag = n < lowcut ? 1.f : .5f*(1.f+cosf(M_PI*(lowcut-n)/(lowcut-highcut)));378 *lfe_mag = n < lowcut ? 1.f : .5f*(1.f+cosf((float)M_PI*(lowcut-n)/(lowcut-highcut)));
379 *lfe_mag *= c_mag;379 *lfe_mag *= c_mag;
380 if (lfe_mode)380 if (lfe_mode)
381 *mag_total -= *lfe_mag;381 *mag_total -= *lfe_mag;
@@ -413,7 +413,7 @@ static void calculate_factors(AVFilterContext *ctx, int ch, int chan) · 31 unmodified lines
413 break;413 break;
414 case AV_CHAN_LOW_FREQUENCY:414 case AV_CHAN_LOW_FREQUENCY:
415 for (int n = 0; n < rdft_size; n++)415 for (int n = 0; n < rdft_size; n++)
416 factor[n] = powf(1.f - fabsf(x[n]), f_x) * powf((1.f - fabs(y[n])), f_y);416 factor[n] = powf(1.f - fabsf(x[n]), f_x) * powf((1.f - fabsf(y[n])), f_y);
417 break;417 break;
418 case AV_CHAN_BACK_CENTER:418 case AV_CHAN_BACK_CENTER:
419 for (int n = 0; n < rdft_size; n++)419 for (int n = 0; n < rdft_size; n++)
@@ -777,8 +777,8 @@ static void filter_stereo(AVFilterContext *ctx) · 357 unmodified lines
777 777
778 mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum;778 mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum;
779 mag_dif = (l_mag - r_mag) / mag_sum;779 mag_dif = (l_mag - r_mag) / mag_sum;
780 if (phase_dif > M_PI)780 if (phase_dif > (float)M_PI)
781 phase_dif = 2.f * M_PI - phase_dif;781 phase_dif = 2.f * (float)M_PI - phase_dif;
782 782
783 stereo_position(mag_dif, phase_dif, &x, &y);783 stereo_position(mag_dif, phase_dif, &x, &y);
784 angle_transform(&x, &y, angle);784 angle_transform(&x, &y, angle);
@@ -832,8 +832,8 @@ static void filter_2_1(AVFilterContext *ctx) · 47 unmodified lines
832 832
833 mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum;833 mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum;
834 mag_dif = (l_mag - r_mag) / mag_sum;834 mag_dif = (l_mag - r_mag) / mag_sum;
835 if (phase_dif > M_PI)835 if (phase_dif > (float)M_PI)
836 phase_dif = 2.f * M_PI - phase_dif;836 phase_dif = 2.f * (float)M_PI - phase_dif;
837 837
838 stereo_position(mag_dif, phase_dif, &x, &y);838 stereo_position(mag_dif, phase_dif, &x, &y);
839 angle_transform(&x, &y, angle);839 angle_transform(&x, &y, angle);
@@ -889,8 +889,8 @@ static void filter_surround(AVFilterContext *ctx) · 49 unmodified lines
889 889
890 mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum;890 mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum;
891 mag_dif = (l_mag - r_mag) / mag_sum;891 mag_dif = (l_mag - r_mag) / mag_sum;
892 if (phase_dif > M_PI)892 if (phase_dif > (float)M_PI)
893 phase_dif = 2.f * M_PI - phase_dif;893 phase_dif = 2.f * (float)M_PI - phase_dif;
894 894
895 stereo_position(mag_dif, phase_dif, &x, &y);895 stereo_position(mag_dif, phase_dif, &x, &y);
896 angle_transform(&x, &y, angle);896 angle_transform(&x, &y, angle);
@@ -946,11 +946,11 @@ static void filter_5_0_side(AVFilterContext *ctx) · 49 unmodified lines
946 float xl, yl;946 float xl, yl;
947 float xr, yr;947 float xr, yr;
948 948
949 if (phase_difl > M_PI)949 if (phase_difl > (float)M_PI)
950 phase_difl = 2.f * M_PI - phase_difl;950 phase_difl = 2.f * (float)M_PI - phase_difl;
951 951
952 if (phase_difr > M_PI)952 if (phase_difr > (float)M_PI)
953 phase_difr = 2.f * M_PI - phase_difr;953 phase_difr = 2.f * (float)M_PI - phase_difr;
954 954
955 stereo_position(mag_difl, phase_difl, &xl, &yl);955 stereo_position(mag_difl, phase_difl, &xl, &yl);
956 stereo_position(mag_difr, phase_difr, &xr, &yr);956 stereo_position(mag_difr, phase_difr, &xr, &yr);
@@ -1005,11 +1005,11 @@ static void filter_5_1_side(AVFilterContext *ctx) · 48 unmodified lines
1005 float xl, yl;1005 float xl, yl;
1006 float xr, yr;1006 float xr, yr;
1007 1007
1008 if (phase_difl > M_PI)1008 if (phase_difl > (float)M_PI)
1009 phase_difl = 2.f * M_PI - phase_difl;1009 phase_difl = 2.f * (float)M_PI - phase_difl;
1010 1010
1011 if (phase_difr > M_PI)1011 if (phase_difr > (float)M_PI)
1012 phase_difr = 2.f * M_PI - phase_difr;1012 phase_difr = 2.f * (float)M_PI - phase_difr;
1013 1013
1014 stereo_position(mag_difl, phase_difl, &xl, &yl);1014 stereo_position(mag_difl, phase_difl, &xl, &yl);
1015 stereo_position(mag_difr, phase_difr, &xr, &yr);1015 stereo_position(mag_difr, phase_difr, &xr, &yr);
@@ -1064,11 +1064,11 @@ static void filter_5_1_back(AVFilterContext *ctx) · 48 unmodified lines
1064 float xl, yl;1064 float xl, yl;
1065 float xr, yr;1065 float xr, yr;
1066 1066
1067 if (phase_difl > M_PI)1067 if (phase_difl > (float)M_PI)
1068 phase_difl = 2.f * M_PI - phase_difl;1068 phase_difl = 2.f * (float)M_PI - phase_difl;
1069 1069
1070 if (phase_difr > M_PI)1070 if (phase_difr > (float)M_PI)
1071 phase_difr = 2.f * M_PI - phase_difr;1071 phase_difr = 2.f * (float)M_PI - phase_difr;
1072 1072
1073 stereo_position(mag_difl, phase_difl, &xl, &yl);1073 stereo_position(mag_difl, phase_difl, &xl, &yl);
1074 stereo_position(mag_difr, phase_difr, &xr, &yr);1074 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