comparison common.h @ 1018:61cb1c0a6eb6 libavutil

Add av_popcount() to libavutil/common.h and bump minor version
author thardin
date Tue, 14 Sep 2010 14:45:43 +0000
parents f197db9ab43a
children
comparison
equal deleted inserted replaced
1017:fd2dd26fab8a 1018:61cb1c0a6eb6
188 * @return computed ceiling of log2(x) 188 * @return computed ceiling of log2(x)
189 */ 189 */
190 static inline av_const int av_ceil_log2_c(int x) 190 static inline av_const int av_ceil_log2_c(int x)
191 { 191 {
192 return av_log2((x - 1) << 1); 192 return av_log2((x - 1) << 1);
193 }
194
195 /**
196 * Count number of bits set to one in x
197 * @param x value to count bits of
198 * @return the number of bits set to one in x
199 */
200 static inline av_const int av_popcount_c(uint32_t x)
201 {
202 x -= (x >> 1) & 0x55555555;
203 x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
204 x = (x + (x >> 4)) & 0x0F0F0F0F;
205 x += x >> 8;
206 return (x + (x >> 16)) & 0x3F;
193 } 207 }
194 208
195 #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) 209 #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
196 #define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24)) 210 #define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24))
197 211
349 # define av_clipl_int32 av_clipl_int32_c 363 # define av_clipl_int32 av_clipl_int32_c
350 #endif 364 #endif
351 #ifndef av_clipf 365 #ifndef av_clipf
352 # define av_clipf av_clipf_c 366 # define av_clipf av_clipf_c
353 #endif 367 #endif
368 #ifndef av_popcount
369 # define av_popcount av_popcount_c
370 #endif