aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/common.h
diff options
context:
space:
mode:
authorTomas Härdin <tomas.hardin@codemill.se>2010-09-14 14:45:43 +0000
committerTomas Härdin <tomas.hardin@codemill.se>2010-09-14 14:45:43 +0000
commitbc6f0af289b4e43ff745db6f4ea4bc508d19453e (patch)
tree07bbe7fb0a71f57116e14bdbc843935f8083a54f /libavutil/common.h
parent1d16a1cf99488f16492b1bb48e023f4da8377e07 (diff)
downloadffmpeg-bc6f0af289b4e43ff745db6f4ea4bc508d19453e.tar.gz
Add av_popcount() to libavutil/common.h and bump minor version
Originally committed as revision 25120 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/common.h')
-rw-r--r--libavutil/common.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavutil/common.h b/libavutil/common.h
index d054f87c5b..6404076a13 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -192,6 +192,20 @@ static inline av_const int av_ceil_log2_c(int x)
return av_log2((x - 1) << 1);
}
+/**
+ * Count number of bits set to one in x
+ * @param x value to count bits of
+ * @return the number of bits set to one in x
+ */
+static inline av_const int av_popcount_c(uint32_t x)
+{
+ x -= (x >> 1) & 0x55555555;
+ x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
+ x = (x + (x >> 4)) & 0x0F0F0F0F;
+ x += x >> 8;
+ return (x + (x >> 16)) & 0x3F;
+}
+
#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24))
@@ -351,3 +365,6 @@ static inline av_const int av_ceil_log2_c(int x)
#ifndef av_clipf
# define av_clipf av_clipf_c
#endif
+#ifndef av_popcount
+# define av_popcount av_popcount_c
+#endif