[x265] [PATCH] weightsAnalyse: use CLZ to get a smaller denominator

Ximing Cheng chengximing1989 at foxmail.com
Sat May 7 08:47:44 CEST 2016


# HG changeset patch
# User Ximing Cheng <ximingcheng at tencent.com>
# Date 1462603048 -28800
#      Sat May 07 14:37:28 2016 +0800
# Node ID f8e9b285e6fda9ef5d25dd54cb246c32def3967a
# Parent  00ea3784bd36c164c5f799c998d7a09f2cb244bf
weightsAnalyse: use CLZ to get a smaller denominator

diff -r 00ea3784bd36 -r f8e9b285e6fd source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Thu Apr 28 09:59:30 2016 +0200
+++ b/source/encoder/slicetype.cpp	Sat May 07 14:37:28 2016 +0800
@@ -456,10 +456,13 @@
     COPY4_IF_LT(minscore, s, minscale, curScale, minoff, curOffset, found, 1);
 
     /* Use a smaller denominator if possible */
-    while (mindenom > 0 && !(minscale & 1))
+    if (mindenom > 0 && !(minscale & 1))
     {
-        mindenom--;
-        minscale >>= 1;
+        unsigned long idx;
+        CLZ(idx, minscale);
+        int shift = X265_MIN((int)idx, mindenom);
+        mindenom -= shift;
+        minscale >>= shift;
     }
 
     if (!found || (minscale == 1 << mindenom && minoff == 0) || (float)minscore / origscore > 0.998f)


More information about the x265-devel mailing list