]> git.sesse.net Git - ffmpeg/commitdiff
libm: provide fallback definition for cbrtf() using powf()
authorMans Rullgard <mans@mansr.com>
Fri, 22 Jun 2012 14:37:46 +0000 (15:37 +0100)
committerMans Rullgard <mans@mansr.com>
Tue, 26 Jun 2012 14:56:38 +0000 (15:56 +0100)
This adds a fallback for cbrtf() using powf(x, 1/3).  Since
powf() with a non-integer exponent requires a non-negative
base, special handling of negative inputs is needed.

Signed-off-by: Mans Rullgard <mans@mansr.com>
configure
libavutil/libm.h

index 52c25b484c43d5f8b1d2024372b6fa42a7229ffa..473393a4e868e6162253ae93ef4c8e7aaa076dfd 100755 (executable)
--- a/configure
+++ b/configure
@@ -1059,6 +1059,7 @@ HAVE_LIST="
     asm_mod_y
     attribute_may_alias
     attribute_packed
+    cbrtf
     closesocket
     cmov
     dcbzl
@@ -2918,6 +2919,7 @@ done
 check_lib math.h sin -lm && LIBM="-lm"
 enabled vaapi && require vaapi va/va.h vaInitialize -lva
 
+check_mathfunc cbrtf
 check_mathfunc exp2
 check_mathfunc exp2f
 check_mathfunc llrint
index 783f3cdfab68cb4021e799ce8cabb960599a16c8..b6d8a94fce260a9ace0a4759c04b309e327e8109 100644 (file)
 #include "config.h"
 #include "attributes.h"
 
+#if !HAVE_CBRTF
+static av_always_inline float cbrtf(float x)
+{
+    return x < 0 ? -powf(-x, 1.0 / 3.0) : powf(x, 1.0 / 3.0);
+}
+#endif
+
 #if !HAVE_EXP2
 #undef exp2
 #define exp2(x) exp((x) * 0.693147180559945)