From eb90ae6523a32380aabc1cd9ee0daef16584393b Mon Sep 17 00:00:00 2001
From: John Cox <jc@kynesim.co.uk>
Date: Wed, 20 Jan 2016 17:56:30 +0000
Subject: [PATCH 2/6] cabac_functions: Cound zeros with ctz if it is fast

When refilling the low bit buffer after get_cabac count the bits with ctz
if the processor has a fast version.
---
 libavcodec/cabac_functions.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/cabac_functions.h b/libavcodec/cabac_functions.h
index 31c919b..156e8bd 100644
--- a/libavcodec/cabac_functions.h
+++ b/libavcodec/cabac_functions.h
@@ -71,14 +71,18 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
     if(!(c->low & CABAC_MASK))
         refill(c);
 }
+#endif
 
 #ifndef get_cabac_inline
 static void refill2(CABACContext *c){
     int i;
     unsigned x;
-
+#if !HAVE_FAST_CLZ
     x= c->low ^ (c->low-1);
     i= 7 - ff_h264_norm_shift[x>>(CABAC_BITS-1)];
+#else
+    i = ff_ctz(c->low) - CABAC_BITS;
+#endif
 
     x= -CABAC_MASK;
 
-- 
1.9.1

