21 #ifndef AVUTIL_INTMATH_H
22 #define AVUTIL_INTMATH_H
37 #if AV_GCC_VERSION_AT_LEAST(3,4)
39 # define ff_log2(x) (31 - __builtin_clz((x)|1))
40 # ifndef ff_log2_16bit
41 # define ff_log2_16bit av_log2
50 #define ff_log2 ff_log2_c
69 #define ff_log2_16bit ff_log2_16bit_c
83 #define av_log2 ff_log2
84 #define av_log2_16bit ff_log2_16bit
92 #if AV_GCC_VERSION_AT_LEAST(3,4)
94 #define ff_ctz(v) __builtin_ctz(v)
97 #define ff_ctzll(v) __builtin_ctzll(v)
100 #define ff_clz(v) __builtin_clz(v)
106 #define ff_ctz ff_ctz_c
117 static const uint8_t debruijn_ctz32[32] = {
118 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
119 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
121 return debruijn_ctz32[(uint32_t)((v & -v) * 0x077CB531
U) >> 27];
126 #define ff_ctzll ff_ctzll_c
131 static const uint8_t debruijn_ctz64[64] = {
132 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
133 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
134 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
135 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
137 return debruijn_ctz64[(uint64_t)((v & -v) * 0x022FDD63CC95386D
U) >> 58];
142 #define ff_clz ff_clz_c
145 unsigned i =
sizeof(x) * 8;
156 #if AV_GCC_VERSION_AT_LEAST(3,4)
158 #define av_parity __builtin_parity