[x265] [PATCH 8 of 8] simplify logic on get coeff remain cost in codeCoeffNxN()

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


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1430390954 -28800
# Node ID e14e721da50dd94007a8f41f2c5b24f4704f0136
# Parent  4c32ff8072c70fef009aeee10ac2d6c7fe2bec21
simplify logic on get coeff remain cost in codeCoeffNxN()
---
 source/encoder/entropy.cpp |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff -r 4c32ff8072c7 -r e14e721da50d source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Thu Apr 30 18:49:09 2015 +0800
+++ b/source/encoder/entropy.cpp	Thu Apr 30 18:49:14 2015 +0800
@@ -1787,14 +1787,9 @@
                             //writeCoefRemainExGolomb(absCoeff[idx] - baseLevel, goRiceParam);
                             uint32_t length = 0;
 
-                            if (((uint32_t)codeNumber >> goRiceParam) < COEF_REMAIN_BIN_REDUCTION)
+                            codeNumber = ((uint32_t)codeNumber >> goRiceParam) - COEF_REMAIN_BIN_REDUCTION;
+                            if (codeNumber >= 0)
                             {
-                                length = (uint32_t)codeNumber >> goRiceParam;
-                                m_fracBits += (length + 1 + goRiceParam) << 15;
-                            }
-                            else
-                            {
-                                codeNumber = ((uint32_t)codeNumber >> goRiceParam) - COEF_REMAIN_BIN_REDUCTION;
                                 {
                                     unsigned long idx;
                                     CLZ(idx, codeNumber + 1);
@@ -1802,8 +1797,9 @@
                                 }
                                 X265_CHECK((codeNumber != 0) || (length == 0), "length check failure\n");
 
-                                m_fracBits += (COEF_REMAIN_BIN_REDUCTION + length + 1 + goRiceParam + length) << 15;
+                                codeNumber = (length + length);
                             }
+                            m_fracBits += (COEF_REMAIN_BIN_REDUCTION + 1 + goRiceParam + codeNumber) << 15;
 
                             if (absCoeff[idx] > (COEF_REMAIN_BIN_REDUCTION << goRiceParam))
                                 goRiceParam = (goRiceParam + 1) - (goRiceParam >> 2);



More information about the x265-devel mailing list