diff --git a/configure b/configure index 5de470c5835a9171f26b21da4d981c6a705ee6fd..ba7722186e80ca447d594879b3f210f8a634a88c 100755 --- a/configure +++ b/configure @@ -1815,6 +1815,8 @@ MATH_FUNCS=" copysign cosf erf + exp10 + exp10f exp2 exp2f expf diff --git a/libavutil/libm.h b/libavutil/libm.h index 146768aac69c931de58a84aac69489e0de8aea92..6f9ac1b3492eaeb19e005e76ee1754c171d473e4 100644 --- a/libavutil/libm.h +++ b/libavutil/libm.h @@ -29,6 +29,7 @@ #include "config.h" #include "attributes.h" #include "intfloat.h" +#include "mathematics.h" #if HAVE_MIPSFPU && HAVE_INLINE_ASM #include "libavutil/mips/libm_mips.h" @@ -292,6 +293,24 @@ static inline double erf(double z) #define exp2f(x) ((float)exp2(x)) #endif /* HAVE_EXP2F */ +/* Somewhat inaccurate fallbacks, relative error ~ 1e-13 concentrated on very +small and very large values. For perfection accuracy-wise, should use pow. +Speed benefits (>2x average, with no super slow paths) deemed to be worth the +accuracy tradeoff */ +#if !HAVE_EXP10 +static av_always_inline double exp10(double x) +{ + return exp2(M_LOG2_10 * x); +} +#endif /* HAVE_EXP10 */ + +#if !HAVE_EXP10F +static av_always_inline float exp10f(float x) +{ + return exp2f(M_LOG2_10 * x); +} +#endif /* HAVE_EXP10F */ + #if !HAVE_ISINF #undef isinf /* Note: these do not follow the BSD/Apple/GNU convention of returning -1 for