X-Git-Url: https://git.libav.org/?p=libav.git;a=blobdiff_plain;f=libavutil%2Flibm.h;h=b5821e82679d397ea133b3a66b4aed5b73c1df11;hp=704bcf95541e08aa3fc20171d7276214e297343f;hb=46df708b45b34191973ef5181b052ce8e583bb4e;hpb=2912e87a6c9264d556734e2bf94a99c64cf9b102 diff --git a/libavutil/libm.h b/libavutil/libm.h index 704bcf9554..b5821e8267 100644 --- a/libavutil/libm.h +++ b/libavutil/libm.h @@ -27,6 +27,14 @@ #include #include "config.h" #include "attributes.h" +#include "intfloat.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 @@ -38,6 +46,26 @@ #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)) @@ -86,6 +114,13 @@ static av_always_inline av_const float roundf(float x) } #endif /* HAVE_ROUNDF */ +#if !HAVE_TRUNC +static av_always_inline av_const double trunc(double x) +{ + return (x > 0) ? floor(x) : ceil(x); +} +#endif /* HAVE_TRUNC */ + #if !HAVE_TRUNCF static av_always_inline av_const float truncf(float x) {