Re: [libav-devel] [PATCH 1/2] intmath: add faster clz support

2017-02-08 Thread Luca Barbato
On 03/02/2017 18:00, Vittorio Giovara wrote:
> From: Ganesh Ajjanagadde 
> 
> ---
> One of the api requirements for pixlet.
> Vittorio
> 
>  libavutil/intmath.h | 19 +++
>  1 file changed, 19 insertions(+)
> 

Possibly OK.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 1/2] intmath: add faster clz support

2017-02-03 Thread Vittorio Giovara
From: Ganesh Ajjanagadde 

---
One of the api requirements for pixlet.
Vittorio

 libavutil/intmath.h | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/libavutil/intmath.h b/libavutil/intmath.h
index a5ee652..780bbab 100644
--- a/libavutil/intmath.h
+++ b/libavutil/intmath.h
@@ -44,6 +44,10 @@
 #   endif
 #endif /* ff_log2 */
 
+#ifndef ff_clz
+#   define ff_clz(v) __builtin_clz(v)
+#endif /* ff_clz */
+
 #endif /* AV_GCC_VERSION_AT_LEAST(3,4) */
 
 extern const uint8_t ff_log2_tab[256];
@@ -132,6 +136,21 @@ static av_always_inline av_const int ff_ctz_c(int v)
 }
 #endif
 
+#ifndef ff_clz
+#define ff_clz ff_clz_c
+static av_always_inline av_const unsigned ff_clz_c(unsigned x)
+{
+unsigned i = sizeof(x) * 8;
+
+while (x) {
+x >>= 1;
+i--;
+}
+
+return i;
+}
+#endif
+
 /**
  * Trailing zero bit count.
  *
-- 
2.10.0

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel