[FFmpeg-devel] [PATCH] avfilter/window_func: use a constant instead of acosh()

James Almer jamrial at gmail.com
Sat Aug 20 07:32:02 EEST 2016


Should fix compilation with non C99 compilers like msvc 2012, where
acosh() is not available.

Signed-off-by: James Almer <jamrial at gmail.com>
---
A fallback function like

static av_always_inline double acosh(double x)
{
    return log(x + sqrt((x * x) - 1.0));
}

could be added to libm.h if acosh() is needed sometime in the
future for values that can't be computed at compile time.
The above example doesn't take into account things like x == NaN
and x < 1.0, though.

 libavfilter/window_func.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/window_func.c b/libavfilter/window_func.c
index fcdf6ea..acf1b20 100644
--- a/libavfilter/window_func.c
+++ b/libavfilter/window_func.c
@@ -117,7 +117,7 @@ void ff_generate_window_func(float *lut, int N, int win_func, float *overlap)
         *overlap = 0.33;
         break;
     case WFUNC_DOLPH: {
-        double b = cosh(acosh(pow(10., 3)) / (N-1)), sum, t, c, norm = 0;
+        double b = cosh(7.6009022095419887 / (N-1)), sum, t, c, norm = 0;
         int j;
         for (c = 1 - 1 / (b*b), n = (N-1) / 2; n >= 0; --n) {
             for (sum = !n, b = t = j = 1; j <= n && sum != t; b *= (n-j) * (1./j), ++j)
-- 
2.9.1



More information about the ffmpeg-devel mailing list