[x265] [PATCH 2 of 4] reduce shift operator on coeff remain code

Min Chen chenm003 at 163.com
Tue Jun 23 02:54:55 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1435019988 25200
# Node ID 64167d1ad6d81c6c2d2ab762592d131860825fe9
# Parent  b3915bc1febdeb620ecbb0fdef5583fa6c73c44e
reduce shift operator on coeff remain code
---
 source/encoder/entropy.cpp |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff -r b3915bc1febd -r 64167d1ad6d8 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Mon Jun 22 17:39:45 2015 -0700
+++ b/source/encoder/entropy.cpp	Mon Jun 22 17:39:48 2015 -0700
@@ -1809,6 +1809,7 @@
                     // Standard path
                     uint32_t goRiceParam = 0;
                     int baseLevel = 3;
+                    uint32_t threshold = COEF_REMAIN_BIN_REDUCTION;
 #if CHECKED_BUILD || _DEBUG
                     int firstCoeff2 = 1;
 #endif
@@ -1823,8 +1824,10 @@
                         if (absCoeff[idx] >= baseLevel)
                         {
                             writeCoefRemainExGolomb(absCoeff[idx] - baseLevel, goRiceParam);
-                            if (absCoeff[idx] > (COEF_REMAIN_BIN_REDUCTION << goRiceParam))
-                                goRiceParam = (goRiceParam + 1) - (goRiceParam >> 2);
+                            X265_CHECK(threshold == (uint32_t)(COEF_REMAIN_BIN_REDUCTION << goRiceParam), "COEF_REMAIN_BIN_REDUCTION check failure\n");
+                            const int adjust = (absCoeff[idx] > threshold) & (goRiceParam <= 3);
+                            goRiceParam += adjust;
+                            threshold += (adjust) ? threshold : 0;
                             X265_CHECK(goRiceParam <= 4, "goRiceParam check failure\n");
                         }
 #if CHECKED_BUILD || _DEBUG



More information about the x265-devel mailing list