]> git.sesse.net Git - ffmpeg/commitdiff
lavu: add av_ctz() for trailing zero bit count
authorJustin Ruggles <justin.ruggles@gmail.com>
Fri, 26 Oct 2012 18:48:40 +0000 (14:48 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Mon, 5 Nov 2012 20:32:29 +0000 (15:32 -0500)
doc/APIchanges
libavutil/Makefile
libavutil/intmath.c [moved from libavutil/log2.c with 95% similarity]
libavutil/intmath.h
libavutil/version.h

index 24defe406b29a08dba34bf35b1c6dcd38964872b..c8b8fbf32adaa54fa8854d1c2f80029c0a6fb1fd 100644 (file)
@@ -13,6 +13,9 @@ libavutil:     2012-10-22
 
 API changes, most recent first:
 
+2012-xx-xx - xxxxxxx - lavu 52.1.0 - intmath.h
+  Add av_ctz() for trailing zero bit count
+
 2012-10-18 - xxxxxxx - lavu 51.45.0 - error.h
   Add AVERROR_EXPERIMENTAL
 
index 45f8e9076c1bdb2a0301b495bf6e9a13a5f16c9b..d4ffd5e7d6afa9618f25c4738d15171a075e55db 100644 (file)
@@ -67,10 +67,10 @@ OBJS = adler32.o                                                        \
        float_dsp.o                                                      \
        imgutils.o                                                       \
        intfloat_readwrite.o                                             \
+       intmath.o                                                        \
        lfg.o                                                            \
        lls.o                                                            \
        log.o                                                            \
-       log2.o                                                           \
        log2_tab.o                                                       \
        mathematics.o                                                    \
        md5.o                                                            \
similarity index 95%
rename from libavutil/log2.c
rename to libavutil/intmath.c
index 18c1b40aaab1e3ba65e3225726be94485990d7fe..8db425c6e9e9475d29c868acbf4c947b19c619c6 100644 (file)
@@ -32,3 +32,8 @@ int av_log2_16bit(unsigned v)
 {
     return ff_log2_16bit(v);
 }
+
+int av_ctz(int v)
+{
+    return ff_ctz(v);
+}
index 2cb313240b76028a49fd4dabdbf21d997c858ce1..a5ee6525ee31436586970b924191795a7630ae18 100644 (file)
@@ -85,6 +85,61 @@ static av_always_inline av_const int ff_log2_16bit_c(unsigned int v)
 #define av_log2       ff_log2
 #define av_log2_16bit ff_log2_16bit
 
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup lavu_math
+ * @{
+ */
+
+#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
+#ifndef ff_ctz
+#define ff_ctz(v) __builtin_ctz(v)
+#endif
+#endif
+
+#ifndef ff_ctz
+#define ff_ctz ff_ctz_c
+static av_always_inline av_const int ff_ctz_c(int v)
+{
+    int c;
+
+    if (v & 0x1)
+        return 0;
+
+    c = 1;
+    if (!(v & 0xffff)) {
+        v >>= 16;
+        c += 16;
+    }
+    if (!(v & 0xff)) {
+        v >>= 8;
+        c += 8;
+    }
+    if (!(v & 0xf)) {
+        v >>= 4;
+        c += 4;
+    }
+    if (!(v & 0x3)) {
+        v >>= 2;
+        c += 2;
+    }
+    c -= v & 0x1;
+
+    return c;
+}
+#endif
+
+/**
+ * Trailing zero bit count.
+ *
+ * @param v  input value. If v is 0, the result is undefined.
+ * @return   the number of trailing 0-bits
+ */
+int av_ctz(int v);
+
 /**
  * @}
  */
index ae7fa7abebf65409d34ad25820981a135d4dfc8b..1659dbd537cce78b6ffc791297e094b39ae1ec48 100644 (file)
@@ -37,7 +37,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 52
-#define LIBAVUTIL_VERSION_MINOR  0
+#define LIBAVUTIL_VERSION_MINOR  1
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \