[x265] [PATCH 6 of 8] simplify compute on get codeNumber length

Min Chen chenm003 at 163.com
Thu Apr 30 12:49:38 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1430390945 -28800
# Node ID 1b0d268d13c62cb48939a041b1952329973d2882
# Parent  124349f8cedf5ad62b60d732acb669b2adccb15d
simplify compute on get codeNumber length
---
 source/encoder/entropy.cpp |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff -r 124349f8cedf -r 1b0d268d13c6 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Thu Apr 30 18:49:01 2015 +0800
+++ b/source/encoder/entropy.cpp	Thu Apr 30 18:49:05 2015 +0800
@@ -1144,13 +1144,13 @@
     {
         length = 0;
         codeNumber = (codeNumber >> absGoRice) - COEF_REMAIN_BIN_REDUCTION;
-        if (codeNumber != 0)
         {
             unsigned long idx;
             CLZ(idx, codeNumber + 1);
             length = idx;
             codeNumber -= (1 << idx) - 1;
         }
+        X265_CHECK((codeNumber != 0) || (length == 0), "length check failure\n");
         codeNumber = (codeNumber << absGoRice) + codeRemain;
 
         encodeBinsEP((1 << (COEF_REMAIN_BIN_REDUCTION + length + 1)) - 2, COEF_REMAIN_BIN_REDUCTION + length + 1);
@@ -1795,12 +1795,13 @@
                             else
                             {
                                 codeNumber = ((uint32_t)codeNumber >> goRiceParam) - COEF_REMAIN_BIN_REDUCTION;
-                                if (codeNumber != 0)
                                 {
                                     unsigned long idx;
                                     CLZ(idx, codeNumber + 1);
                                     length = idx;
                                 }
+                                X265_CHECK((codeNumber != 0) || (length == 0), "length check failure\n");
+
                                 m_fracBits += (COEF_REMAIN_BIN_REDUCTION + length + 1 + goRiceParam + length) << 15;
                             }
 



More information about the x265-devel mailing list