[FFmpeg-devel] [PATCH 1/2] libavutil: add av_zhb
James Almer
jamrial at gmail.com
Tue Mar 17 05:08:05 CET 2015
Signed-off-by: James Almer <jamrial at gmail.com>
---
Better name (av_zero_high_bits?) and doxygen welcome.
libavutil/common.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/libavutil/common.h b/libavutil/common.h
index 852c1de..2ee5a98 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -301,6 +301,17 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
return av_popcount((uint32_t)x) + av_popcount((uint32_t)(x >> 32));
}
+/**
+ * Zero high bits from a starting from bit position p
+ * @param a value to clip
+ * @param p bit position to clip at
+ * @return clipped value
+ */
+static av_always_inline av_const unsigned av_zhb_c(unsigned a, unsigned p)
+{
+ return a & ((1 << p) - 1);
+}
+
#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
@@ -484,3 +495,6 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
#ifndef av_popcount64
# define av_popcount64 av_popcount64_c
#endif
+#ifndef av_zhb
+# define av_zhb av_zhb_c
+#endif
--
2.3.2
More information about the ffmpeg-devel
mailing list