X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavutil%2Fcommon.h;h=03a2354db4a30974fa08ef5a55e95250a6dd759c;hb=db9f426caba574719c58de12e68742063c8e7979;hp=3e3baab3a13d4bdd03aabf071a41c5b3cd47c327;hpb=27ccc82e1bb1b97a85e5fb33b92082267078b4d1;p=ffmpeg diff --git a/libavutil/common.h b/libavutil/common.h index 3e3baab3a13..03a2354db4a 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -34,7 +34,9 @@ #include #include #include + #include "attributes.h" +#include "version.h" #include "libavutil/avconfig.h" #if AV_HAVE_BIGENDIAN @@ -62,40 +64,13 @@ #define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) /* misc math functions */ -extern const uint8_t ff_log2_tab[256]; /** * Reverse the order of the bits of an 8-bits unsigned integer. */ -extern const uint8_t av_reverse[256]; - -static av_always_inline av_const int av_log2_c(unsigned int v) -{ - int n = 0; - if (v & 0xffff0000) { - v >>= 16; - n += 16; - } - if (v & 0xff00) { - v >>= 8; - n += 8; - } - n += ff_log2_tab[v]; - - return n; -} - -static av_always_inline av_const int av_log2_16bit_c(unsigned int v) -{ - int n = 0; - if (v & 0xff00) { - v >>= 8; - n += 8; - } - n += ff_log2_tab[v]; - - return n; -} +#if FF_API_AV_REVERSE +extern attribute_deprecated const uint8_t av_reverse[256]; +#endif #ifdef HAVE_AV_CONFIG_H # include "config.h" @@ -105,6 +80,14 @@ static av_always_inline av_const int av_log2_16bit_c(unsigned int v) /* Pull in unguarded fallback defines at the end of this file. */ #include "common.h" +#ifndef av_log2 +av_const int av_log2(unsigned v); +#endif + +#ifndef av_log2_16bit +av_const int av_log2_16bit(unsigned v); +#endif + /** * Clip a signed integer value into the amin-amax range. * @param a value to clip @@ -119,6 +102,20 @@ static av_always_inline av_const int av_clip_c(int a, int amin, int amax) else return a; } +/** + * Clip a signed 64bit integer value into the amin-amax range. + * @param a value to clip + * @param amin minimum value of the clip range + * @param amax maximum value of the clip range + * @return clipped value + */ +static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, int64_t amax) +{ + if (a < amin) return amin; + else if (a > amax) return amax; + else return a; +} + /** * Clip a signed integer value into the 0-255 range. * @param a value to clip @@ -386,18 +383,15 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x) * to ensure they are immediately available in intmath.h. */ -#ifndef av_log2 -# define av_log2 av_log2_c -#endif -#ifndef av_log2_16bit -# define av_log2_16bit av_log2_16bit_c -#endif #ifndef av_ceil_log2 # define av_ceil_log2 av_ceil_log2_c #endif #ifndef av_clip # define av_clip av_clip_c #endif +#ifndef av_clip64 +# define av_clip64 av_clip64_c +#endif #ifndef av_clip_uint8 # define av_clip_uint8 av_clip_uint8_c #endif