From 8c0a3d5fe035f2d19b5815f142e145cfbedf28b3 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 18 Oct 2012 18:15:38 +0100 Subject: avutil: remove inline av_log2 from public API This removes inline av_log2 and av_log2_16bit from the public API, instead exporting them as regular functions. In-tree code still gets the inline and otherwise optimised variants. Signed-off-by: Mans Rullgard --- libavutil/intmath.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'libavutil/intmath.h') diff --git a/libavutil/intmath.h b/libavutil/intmath.h index 0ad30123e8..b4b87e6059 100644 --- a/libavutil/intmath.h +++ b/libavutil/intmath.h @@ -21,6 +21,8 @@ #ifndef AVUTIL_INTMATH_H #define AVUTIL_INTMATH_H +#include + #include "config.h" #include "attributes.h" @@ -31,15 +33,54 @@ #if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4) -#ifndef av_log2 -# define av_log2(x) (31 - __builtin_clz((x)|1)) -# ifndef av_log2_16bit -# define av_log2_16bit av_log2 +#ifndef ff_log2 +# define ff_log2(x) (31 - __builtin_clz((x)|1)) +# ifndef ff_log2_16bit +# define ff_log2_16bit av_log2 # endif -#endif /* av_log2 */ +#endif /* ff_log2 */ #endif /* AV_GCC_VERSION_AT_LEAST(3,4) */ +extern const uint8_t ff_log2_tab[256]; + +#ifndef ff_log2 +#define ff_log2 ff_log2_c +static av_always_inline av_const int ff_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; +} +#endif + +#ifndef ff_log2_16bit +#define ff_log2_16bit ff_log2_16bit_c +static av_always_inline av_const int ff_log2_16bit_c(unsigned int v) +{ + int n = 0; + if (v & 0xff00) { + v >>= 8; + n += 8; + } + n += ff_log2_tab[v]; + + return n; +} +#endif + +#define av_log2 ff_log2 +#define av_log2_16bit ff_log2_16bit + /** * @} */ -- cgit v1.2.3