[FFmpeg-cvslog] libm: provide fallback definition for cbrtf() using powf()

Mans Rullgard git at videolan.org
Wed Jun 27 02:07:40 CEST 2012


ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Fri Jun 22 15:37:46 2012 +0100| [153335625c429d2e4ab6a4d2d704d7eb91293290] | committer: Mans Rullgard

libm: provide fallback definition for cbrtf() using powf()

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 at mansr.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=153335625c429d2e4ab6a4d2d704d7eb91293290
---

 configure        |    2 ++
 libavutil/libm.h |    7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/configure b/configure
index 52c25b4..473393a 100755
--- 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
diff --git a/libavutil/libm.h b/libavutil/libm.h
index 783f3cd..b6d8a94 100644
--- a/libavutil/libm.h
+++ b/libavutil/libm.h
@@ -28,6 +28,13 @@
 #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)



More information about the ffmpeg-cvslog mailing list