[x265] [PATCH 7 of 8] faster clip operator on goRiceParam

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


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1430390949 -28800
# Node ID 4c32ff8072c70fef009aeee10ac2d6c7fe2bec21
# Parent  1b0d268d13c62cb48939a041b1952329973d2882
faster clip operator on goRiceParam
---
 source/encoder/entropy.cpp |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff -r 1b0d268d13c6 -r 4c32ff8072c7 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Thu Apr 30 18:49:05 2015 +0800
+++ b/source/encoder/entropy.cpp	Thu Apr 30 18:49:09 2015 +0800
@@ -1805,8 +1805,9 @@
                                 m_fracBits += (COEF_REMAIN_BIN_REDUCTION + length + 1 + goRiceParam + length) << 15;
                             }
 
-                            if (absCoeff[idx] > 3 * (1 << goRiceParam))
-                                goRiceParam = std::min<uint32_t>(goRiceParam + 1, 4);
+                            if (absCoeff[idx] > (COEF_REMAIN_BIN_REDUCTION << goRiceParam))
+                                goRiceParam = (goRiceParam + 1) - (goRiceParam >> 2);
+                            X265_CHECK(goRiceParam <= 4, "goRiceParam check failure\n");
                         }
                         if (absCoeff[idx] >= 2)
                             firstCoeff2 = 0;
@@ -1824,8 +1825,9 @@
                         if (absCoeff[idx] >= baseLevel)
                         {
                             writeCoefRemainExGolomb(absCoeff[idx] - baseLevel, goRiceParam);
-                            if (absCoeff[idx] > 3 * (1 << goRiceParam))
-                                goRiceParam = std::min<uint32_t>(goRiceParam + 1, 4);
+                            if (absCoeff[idx] > (COEF_REMAIN_BIN_REDUCTION << goRiceParam))
+                                goRiceParam = (goRiceParam + 1) - (goRiceParam >> 2);
+                            X265_CHECK(goRiceParam <= 4, "goRiceParam check failure\n");
                         }
                         if (absCoeff[idx] >= 2)
                             firstCoeff2 = 0;



More information about the x265-devel mailing list