21 #ifndef AVUTIL_INTMATH_H
22 #define AVUTIL_INTMATH_H
38 #if AV_GCC_VERSION_AT_LEAST(3,4)
40 # define ff_log2(x) (31 - __builtin_clz((x)|1))
41 # ifndef ff_log2_16bit
42 # define ff_log2_16bit av_log2
51 #define ff_log2 ff_log2_c
70 #define ff_log2_16bit ff_log2_16bit_c
84 #define av_log2 ff_log2
85 #define av_log2_16bit ff_log2_16bit
93 #if AV_GCC_VERSION_AT_LEAST(3,4)
95 #define ff_ctz(v) __builtin_ctz(v)
98 #define ff_ctzll(v) __builtin_ctzll(v)
101 #define ff_clz(v) __builtin_clz(v)
107 #define ff_ctz ff_ctz_c
118 static const uint8_t debruijn_ctz32[32] = {
119 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
120 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
122 return debruijn_ctz32[(uint32_t)((v & -v) * 0x077CB531
U) >> 27];
127 #define ff_ctzll ff_ctzll_c
132 static const uint8_t debruijn_ctz64[64] = {
133 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
134 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
135 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
136 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
138 return debruijn_ctz64[(uint64_t)((v & -v) * 0x022FDD63CC95386D
U) >> 58];
143 #define ff_clz ff_clz_c
146 unsigned i =
sizeof(x) * 8;
157 #if AV_GCC_VERSION_AT_LEAST(3,4)
159 #define av_parity __builtin_parity