Browse code

Add av_popcount() to libavutil/common.h and bump minor version

Originally committed as revision 25120 to svn://svn.ffmpeg.org/ffmpeg/trunk

Tomas Härdin authored on 2010/09/14 23:45:43
Showing 2 changed files
... ...
@@ -40,7 +40,7 @@
40 40
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
41 41
 
42 42
 #define LIBAVUTIL_VERSION_MAJOR 50
43
-#define LIBAVUTIL_VERSION_MINOR 26
43
+#define LIBAVUTIL_VERSION_MINOR 27
44 44
 #define LIBAVUTIL_VERSION_MICRO  0
45 45
 
46 46
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
... ...
@@ -192,6 +192,20 @@ static inline av_const int av_ceil_log2_c(int x)
192 192
     return av_log2((x - 1) << 1);
193 193
 }
194 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;
207
+}
208
+
195 209
 #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
196 210
 #define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24))
197 211
 
... ...
@@ -351,3 +365,6 @@ static inline av_const int av_ceil_log2_c(int x)
351 351
 #ifndef av_clipf
352 352
 #   define av_clipf         av_clipf_c
353 353
 #endif
354
+#ifndef av_popcount
355
+#   define av_popcount      av_popcount_c
356
+#endif