X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavutil%2Finternal.h;h=c4bcf37ab8ac67f1aded554c0ccbf0c6b366f3d9;hb=6711aa21e263a270ecd2d6a6ee1b673e665ce98a;hp=f86b7fb7413a65bf0ccb95b5ceb520279e9d5589;hpb=14a28298cb8815de1138181ac7f8992f927cb12a;p=ffmpeg diff --git a/libavutil/internal.h b/libavutil/internal.h index f86b7fb7413..c4bcf37ab8a 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -39,6 +39,7 @@ #include "timer.h" #include "cpu.h" #include "dict.h" +#include "macros.h" #include "pixfmt.h" #include "version.h" @@ -292,6 +293,25 @@ static av_always_inline av_const int64_t ff_rint64_clip(double a, int64_t amin, return res; } +/** + * Compute 10^x for floating point values. Note: this function is by no means + * "correctly rounded", and is meant as a fast, reasonably accurate approximation. + * For instance, maximum relative error for the double precision variant is + * ~ 1e-13 for very small and very large values. + * This is ~2x faster than GNU libm's approach, which is still off by 2ulp on + * some inputs. + * @param x exponent + * @return 10^x + */ +static av_always_inline double ff_exp10(double x) +{ + return exp2(M_LOG2_10 * x); +} + +static av_always_inline float ff_exp10f(float x) +{ + return exp2f(M_LOG2_10 * x); +} /** * A wrapper for open() setting O_CLOEXEC.