History

avfilter/af_surround: reduce double usage

Paul B Mahol committed 3 years ago

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

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
330330 if (angle == 90.f)
331331 return;
332332
333− reference = angle * M_PI / 180.f;
333+ reference = angle * (float)M_PI / 180.f;
334334 r = hypotf(*x, *y);
335335 a = atan2f(*x, *y);
336336
337337 r /= r_distance(a);
338338
339− if (fabsf(a) <= M_PI_4)
340− a *= reference / M_PI_2;
339+ if (fabsf(a) <= (float)M_PI_4)
340+ a *= reference / (float)M_PI_2;
341341 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);
343343
344344 r *= r_distance(a);
345345
@@ -366,16 +366,16 @@ static void focus_transform(float *x, float *y, float focus) · 20 unmodified lines
366366 static void stereo_position(float a, float p, float *x, float *y)
367367 {
368368 av_assert2(a >= -1.f && a <= 1.f);
369− av_assert2(p >= 0.f && p <= M_PI);
370− *x = av_clipf(a+a*fmaxf(0.f, p*p-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);
369+ av_assert2(p >= 0.f && p <= (float)M_PI);
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*(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);
372372 }
373373
374374 static inline void get_lfe(int output_lfe, int n, float lowcut, float highcut,
375375 float *lfe_mag, float c_mag, float *mag_total, int lfe_mode)
376376 {
377377 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)));
379379 *lfe_mag *= c_mag;
380380 if (lfe_mode)
381381 *mag_total -= *lfe_mag;
@@ -413,7 +413,7 @@ static void calculate_factors(AVFilterContext *ctx, int ch, int chan) · 31 unmodified lines
413413 break;
414414 case AV_CHAN_LOW_FREQUENCY:
415415 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);
417417 break;
418418 case AV_CHAN_BACK_CENTER:
419419 for (int n = 0; n < rdft_size; n++)
@@ -777,8 +777,8 @@ static void filter_stereo(AVFilterContext *ctx) · 357 unmodified lines
777777
778778 mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum;
779779 mag_dif = (l_mag - r_mag) / mag_sum;
780− if (phase_dif > M_PI)
781− phase_dif = 2.f * M_PI - phase_dif;
780+ if (phase_dif > (float)M_PI)
781+ phase_dif = 2.f * (float)M_PI - phase_dif;
782782
783783 stereo_position(mag_dif, phase_dif, &x, &y);
784784 angle_transform(&x, &y, angle);
@@ -832,8 +832,8 @@ static void filter_2_1(AVFilterContext *ctx) · 47 unmodified lines
832832
833833 mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum;
834834 mag_dif = (l_mag - r_mag) / mag_sum;
835− if (phase_dif > M_PI)
836− phase_dif = 2.f * M_PI - phase_dif;
835+ if (phase_dif > (float)M_PI)
836+ phase_dif = 2.f * (float)M_PI - phase_dif;
837837
838838 stereo_position(mag_dif, phase_dif, &x, &y);
839839 angle_transform(&x, &y, angle);
@@ -889,8 +889,8 @@ static void filter_surround(AVFilterContext *ctx) · 49 unmodified lines
889889
890890 mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum;
891891 mag_dif = (l_mag - r_mag) / mag_sum;
892− if (phase_dif > M_PI)
893− phase_dif = 2.f * M_PI - phase_dif;
892+ if (phase_dif > (float)M_PI)
893+ phase_dif = 2.f * (float)M_PI - phase_dif;
894894
895895 stereo_position(mag_dif, phase_dif, &x, &y);
896896 angle_transform(&x, &y, angle);
@@ -946,11 +946,11 @@ static void filter_5_0_side(AVFilterContext *ctx) · 49 unmodified lines
946946 float xl, yl;
947947 float xr, yr;
948948
949− if (phase_difl > M_PI)
950− phase_difl = 2.f * M_PI - phase_difl;
949+ if (phase_difl > (float)M_PI)
950+ phase_difl = 2.f * (float)M_PI - phase_difl;
951951
952− if (phase_difr > M_PI)
953− phase_difr = 2.f * M_PI - phase_difr;
952+ if (phase_difr > (float)M_PI)
953+ phase_difr = 2.f * (float)M_PI - phase_difr;
954954
955955 stereo_position(mag_difl, phase_difl, &xl, &yl);
956956 stereo_position(mag_difr, phase_difr, &xr, &yr);
@@ -1005,11 +1005,11 @@ static void filter_5_1_side(AVFilterContext *ctx) · 48 unmodified lines
10051005 float xl, yl;
10061006 float xr, yr;
10071007
1008− if (phase_difl > M_PI)
1009− phase_difl = 2.f * M_PI - phase_difl;
1008+ if (phase_difl > (float)M_PI)
1009+ phase_difl = 2.f * (float)M_PI - phase_difl;
10101010
1011− if (phase_difr > M_PI)
1012− phase_difr = 2.f * M_PI - phase_difr;
1011+ if (phase_difr > (float)M_PI)
1012+ phase_difr = 2.f * (float)M_PI - phase_difr;
10131013
10141014 stereo_position(mag_difl, phase_difl, &xl, &yl);
10151015 stereo_position(mag_difr, phase_difr, &xr, &yr);
@@ -1064,11 +1064,11 @@ static void filter_5_1_back(AVFilterContext *ctx) · 48 unmodified lines
10641064 float xl, yl;
10651065 float xr, yr;
10661066
1067− if (phase_difl > M_PI)
1068− phase_difl = 2.f * M_PI - phase_difl;
1067+ if (phase_difl > (float)M_PI)
1068+ phase_difl = 2.f * (float)M_PI - phase_difl;
10691069
1070− if (phase_difr > M_PI)
1071− phase_difr = 2.f * M_PI - phase_difr;
1070+ if (phase_difr > (float)M_PI)
1071+ phase_difr = 2.f * (float)M_PI - phase_difr;
10721072
10731073 stereo_position(mag_difl, phase_difl, &xl, &yl);
10741074 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