]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/libm.h
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavutil / libm.h
index 57eb0c0d6e19ebee579cecec13ad707adf2d015d..d36420bc9be0b11c1e2ed49b546f398872775ded 100644 (file)
 #include <math.h>
 #include "config.h"
 #include "attributes.h"
+#include "intfloat.h"
 
 #if HAVE_MIPSFPU && HAVE_INLINE_ASM
 #include "libavutil/mips/libm_mips.h"
 #endif /* HAVE_MIPSFPU && HAVE_INLINE_ASM*/
 
 #if !HAVE_CBRTF
-#undef cbrtf
-#define cbrtf(x) powf(x, 1.0/3.0)
-#endif /* 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 exp2f(x) ((float)exp2(x))
 #endif /* HAVE_EXP2F */
 
+#if !HAVE_ISINF
+static av_always_inline av_const int isinf(float x)
+{
+    uint32_t v = av_float2int(x);
+    if ((v & 0x7f800000) != 0x7f800000)
+        return 0;
+    return !(v & 0x007fffff);
+}
+#endif /* HAVE_ISINF */
+
+#if !HAVE_ISNAN
+static av_always_inline av_const int isnan(float x)
+{
+    uint32_t v = av_float2int(x);
+    if ((v & 0x7f800000) != 0x7f800000)
+        return 0;
+    return v & 0x007fffff;
+}
+#endif /* HAVE_ISNAN */
+
 #if !HAVE_LLRINT
 #undef llrint
 #define llrint(x) ((long long)rint(x))
 #define log2f(x) ((float)log2(x))
 #endif /* HAVE_LOG2F */
 
+#if !HAVE_RINT
+static inline double rint(double x)
+{
+    return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
+}
+#endif /* HAVE_RINT */
+
 #if !HAVE_LRINT
 static av_always_inline av_const long int lrint(double x)
 {