X-Git-Url: https://git.libav.org/?p=libav.git;a=blobdiff_plain;f=libavutil%2Flibm.h;h=b5821e82679d397ea133b3a66b4aed5b73c1df11;hp=c9d188b4d9c6431b54310523a7c4d5a08d73ede9;hb=46df708b45b34191973ef5181b052ce8e583bb4e;hpb=335ee1aaddd4de450d95352205f68373ec51bae5 diff --git a/libavutil/libm.h b/libavutil/libm.h index c9d188b4d9..b5821e8267 100644 --- a/libavutil/libm.h +++ b/libavutil/libm.h @@ -1,23 +1,23 @@ /* - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * FFmpeg is distributed in the hope that it will be useful, + * Libav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** - * @file libavutil/libm.h + * @file * Replacements for frequently missing libm functions */ @@ -26,6 +26,15 @@ #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 @@ -37,11 +46,36 @@ #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)) #endif /* HAVE_LLRINT */ +#if !HAVE_LLRINTF +#undef llrintf +#define llrintf(x) ((long long)rint(x)) +#endif /* HAVE_LLRINT */ + #if !HAVE_LOG2 #undef log2 #define log2(x) (log(x) * 1.44269504088896340736) @@ -80,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) {