* [FFmpeg-devel] [PATCH 1/2] avutil/mathematics: add missing constants @ 2023-05-11 23:12 James Almer 2023-05-11 23:12 ` [FFmpeg-devel] [PATCH 2/2] avfilter/af_surround: replace double constants with float variants James Almer 2023-05-19 18:34 ` [FFmpeg-devel] [PATCH 1/2] avutil/mathematics: add missing constants James Almer 0 siblings, 2 replies; 3+ messages in thread From: James Almer @ 2023-05-11 23:12 UTC (permalink / raw) To: ffmpeg-devel Including float variants for all of them. Signed-off-by: James Almer <jamrial@gmail.com> --- libavutil/mathematics.h | 51 +++++++++++++++++++++++++++++++++++++++++ libavutil/version.h | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/libavutil/mathematics.h b/libavutil/mathematics.h index e4aff1e973..3e7b52eed6 100644 --- a/libavutil/mathematics.h +++ b/libavutil/mathematics.h @@ -36,30 +36,81 @@ #ifndef M_E #define M_E 2.7182818284590452354 /* e */ #endif +#ifndef M_Ef +#define M_Ef 2.7182818284590452354f /* e */ +#endif #ifndef M_LN2 #define M_LN2 0.69314718055994530942 /* log_e 2 */ #endif +#ifndef M_LN2f +#define M_LN2f 0.69314718055994530942f /* log_e 2 */ +#endif #ifndef M_LN10 #define M_LN10 2.30258509299404568402 /* log_e 10 */ #endif +#ifndef M_LN10f +#define M_LN10f 2.30258509299404568402f /* log_e 10 */ +#endif #ifndef M_LOG2_10 #define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ #endif +#ifndef M_LOG2_10f +#define M_LOG2_10f 3.32192809488736234787f /* log_2 10 */ +#endif #ifndef M_PHI #define M_PHI 1.61803398874989484820 /* phi / golden ratio */ #endif +#ifndef M_PHIf +#define M_PHIf 1.61803398874989484820f /* phi / golden ratio */ +#endif #ifndef M_PI #define M_PI 3.14159265358979323846 /* pi */ #endif +#ifndef M_PIf +#define M_PIf 3.14159265358979323846f /* pi */ +#endif #ifndef M_PI_2 #define M_PI_2 1.57079632679489661923 /* pi/2 */ #endif +#ifndef M_PI_2f +#define M_PI_2f 1.57079632679489661923f /* pi/2 */ +#endif +#ifndef M_PI_4 +#define M_PI_4 0.78539816339744830962 /* pi/4 */ +#endif +#ifndef M_PI_4f +#define M_PI_4f 0.78539816339744830962f /* pi/4 */ +#endif +#ifndef M_1_PI +#define M_1_PI 0.31830988618379067154 /* 1/pi */ +#endif +#ifndef M_1_PIf +#define M_1_PIf 0.31830988618379067154f /* 1/pi */ +#endif +#ifndef M_2_PI +#define M_2_PI 0.63661977236758134308 /* 2/pi */ +#endif +#ifndef M_2_PIf +#define M_2_PIf 0.63661977236758134308f /* 2/pi */ +#endif +#ifndef M_2_SQRTPI +#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +#endif +#ifndef M_2_SQRTPIf +#define M_2_SQRTPIf 1.12837916709551257390f /* 2/sqrt(pi) */ +#endif #ifndef M_SQRT1_2 #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #endif +#ifndef M_SQRT1_2f +#define M_SQRT1_2f 0.70710678118654752440f /* 1/sqrt(2) */ +#endif #ifndef M_SQRT2 #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ #endif +#ifndef M_SQRT2f +#define M_SQRT2f 1.41421356237309504880f /* sqrt(2) */ +#endif #ifndef NAN #define NAN av_int2float(0x7fc00000) #endif diff --git a/libavutil/version.h b/libavutil/version.h index 341bcbf188..a4177aa137 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 58 -#define LIBAVUTIL_VERSION_MINOR 7 +#define LIBAVUTIL_VERSION_MINOR 8 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 3+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avfilter/af_surround: replace double constants with float variants 2023-05-11 23:12 [FFmpeg-devel] [PATCH 1/2] avutil/mathematics: add missing constants James Almer @ 2023-05-11 23:12 ` James Almer 2023-05-19 18:34 ` [FFmpeg-devel] [PATCH 1/2] avutil/mathematics: add missing constants James Almer 1 sibling, 0 replies; 3+ messages in thread From: James Almer @ 2023-05-11 23:12 UTC (permalink / raw) To: ffmpeg-devel This is cleaner than the approach in d1ded7310a. Signed-off-by: James Almer <jamrial@gmail.com> --- libavfilter/af_surround.c | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/libavfilter/af_surround.c b/libavfilter/af_surround.c index bcc89053a4..4edd838101 100644 --- a/libavfilter/af_surround.c +++ b/libavfilter/af_surround.c @@ -330,16 +330,16 @@ static void angle_transform(float *x, float *y, float angle) if (angle == 90.f) return; - reference = angle * (float)M_PI / 180.f; + reference = angle * M_PIf / 180.f; r = hypotf(*x, *y); a = atan2f(*x, *y); r /= r_distance(a); - if (fabsf(a) <= (float)M_PI_4) - a *= reference / (float)M_PI_2; + if (fabsf(a) <= M_PI_4f) + a *= reference / M_PI_2f; else - 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); + a = M_PIf + (-2.f * M_PIf + reference) * (M_PIf - fabsf(a)) * FFDIFFSIGN(a, 0.f) / (3.f * M_PI_2f); r *= r_distance(a); @@ -366,16 +366,16 @@ static void focus_transform(float *x, float *y, float focus) 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 <= (float)M_PI); - *x = av_clipf(a+a*fmaxf(0.f, p*p-(float)M_PI_2), -1.f, 1.f); - *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); + av_assert2(p >= 0.f && p <= M_PIf); + *x = av_clipf(a+a*fmaxf(0.f, p*p-M_PI_2f), -1.f, 1.f); + *y = av_clipf(cosf(a*M_PI_2f+M_PIf)*cosf(M_PI_2f-p/M_PIf)*M_LN10f+1.f, -1.f, 1.f); } static inline void get_lfe(int output_lfe, int n, float lowcut, float highcut, float *lfe_mag, float c_mag, float *mag_total, int lfe_mode) { if (output_lfe && n < highcut) { - *lfe_mag = n < lowcut ? 1.f : .5f*(1.f+cosf((float)M_PI*(lowcut-n)/(lowcut-highcut))); + *lfe_mag = n < lowcut ? 1.f : .5f*(1.f+cosf(M_PIf*(lowcut-n)/(lowcut-highcut))); *lfe_mag *= c_mag; if (lfe_mode) *mag_total -= *lfe_mag; @@ -777,8 +777,8 @@ static void filter_stereo(AVFilterContext *ctx) mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum; mag_dif = (l_mag - r_mag) / mag_sum; - if (phase_dif > (float)M_PI) - phase_dif = 2.f * (float)M_PI - phase_dif; + if (phase_dif > M_PIf) + phase_dif = 2.f * M_PIf - phase_dif; stereo_position(mag_dif, phase_dif, &x, &y); angle_transform(&x, &y, angle); @@ -832,8 +832,8 @@ static void filter_2_1(AVFilterContext *ctx) mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum; mag_dif = (l_mag - r_mag) / mag_sum; - if (phase_dif > (float)M_PI) - phase_dif = 2.f * (float)M_PI - phase_dif; + if (phase_dif > M_PIf) + phase_dif = 2.f * M_PIf - phase_dif; stereo_position(mag_dif, phase_dif, &x, &y); angle_transform(&x, &y, angle); @@ -889,8 +889,8 @@ static void filter_surround(AVFilterContext *ctx) mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum; mag_dif = (l_mag - r_mag) / mag_sum; - if (phase_dif > (float)M_PI) - phase_dif = 2.f * (float)M_PI - phase_dif; + if (phase_dif > M_PIf) + phase_dif = 2.f * M_PIf - phase_dif; stereo_position(mag_dif, phase_dif, &x, &y); angle_transform(&x, &y, angle); @@ -946,11 +946,11 @@ static void filter_5_0_side(AVFilterContext *ctx) float xl, yl; float xr, yr; - if (phase_difl > (float)M_PI) - phase_difl = 2.f * (float)M_PI - phase_difl; + if (phase_difl > M_PIf) + phase_difl = 2.f * M_PIf - phase_difl; - if (phase_difr > (float)M_PI) - phase_difr = 2.f * (float)M_PI - phase_difr; + if (phase_difr > M_PIf) + phase_difr = 2.f * M_PIf - phase_difr; stereo_position(mag_difl, phase_difl, &xl, &yl); stereo_position(mag_difr, phase_difr, &xr, &yr); @@ -1005,11 +1005,11 @@ static void filter_5_1_side(AVFilterContext *ctx) float xl, yl; float xr, yr; - if (phase_difl > (float)M_PI) - phase_difl = 2.f * (float)M_PI - phase_difl; + if (phase_difl > M_PIf) + phase_difl = 2.f * M_PIf - phase_difl; - if (phase_difr > (float)M_PI) - phase_difr = 2.f * (float)M_PI - phase_difr; + if (phase_difr > M_PIf) + phase_difr = 2.f * M_PIf - phase_difr; stereo_position(mag_difl, phase_difl, &xl, &yl); stereo_position(mag_difr, phase_difr, &xr, &yr); @@ -1064,11 +1064,11 @@ static void filter_5_1_back(AVFilterContext *ctx) float xl, yl; float xr, yr; - if (phase_difl > (float)M_PI) - phase_difl = 2.f * (float)M_PI - phase_difl; + if (phase_difl > M_PIf) + phase_difl = 2.f * M_PIf - phase_difl; - if (phase_difr > (float)M_PI) - phase_difr = 2.f * (float)M_PI - phase_difr; + if (phase_difr > M_PIf) + phase_difr = 2.f * M_PIf - phase_difr; stereo_position(mag_difl, phase_difl, &xl, &yl); stereo_position(mag_difr, phase_difr, &xr, &yr); -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avutil/mathematics: add missing constants 2023-05-11 23:12 [FFmpeg-devel] [PATCH 1/2] avutil/mathematics: add missing constants James Almer 2023-05-11 23:12 ` [FFmpeg-devel] [PATCH 2/2] avfilter/af_surround: replace double constants with float variants James Almer @ 2023-05-19 18:34 ` James Almer 1 sibling, 0 replies; 3+ messages in thread From: James Almer @ 2023-05-19 18:34 UTC (permalink / raw) To: ffmpeg-devel On 5/11/2023 8:12 PM, James Almer wrote: > Including float variants for all of them. > > Signed-off-by: James Almer <jamrial@gmail.com> > --- > libavutil/mathematics.h | 51 +++++++++++++++++++++++++++++++++++++++++ > libavutil/version.h | 2 +- > 2 files changed, 52 insertions(+), 1 deletion(-) Will apply set. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-19 18:34 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-05-11 23:12 [FFmpeg-devel] [PATCH 1/2] avutil/mathematics: add missing constants James Almer 2023-05-11 23:12 ` [FFmpeg-devel] [PATCH 2/2] avfilter/af_surround: replace double constants with float variants James Almer 2023-05-19 18:34 ` [FFmpeg-devel] [PATCH 1/2] avutil/mathematics: add missing constants James Almer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git