[x265] [PATCH 3 of 6] improve rdoQuant 10%+ by C++ template <log2TrSize>

Min Chen chenm003 at 163.com
Thu Sep 10 00:33:42 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1441837039 18000
# Node ID 7411ad14770ba8830c09789361fb48a6d4e5b44c
# Parent  c72ca72fe00acfb81ed43e8d9af826f9cb77b4fe
improve rdoQuant 10%+ by C++ template <log2TrSize>
---
 source/common/quant.cpp |    7 +++++--
 source/common/quant.h   |    9 ++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff -r c72ca72fe00a -r 7411ad14770b source/common/quant.cpp
--- a/source/common/quant.cpp	Wed Sep 09 17:17:17 2015 -0500
+++ b/source/common/quant.cpp	Wed Sep 09 17:17:19 2015 -0500
@@ -185,6 +185,8 @@
 
 }
 
+Quant::rdoQuant_t Quant::rdoQuant_func[NUM_CU_DEPTH] = {&Quant::rdoQuant<2>, &Quant::rdoQuant<3>, &Quant::rdoQuant<4>, &Quant::rdoQuant<5>};
+
 Quant::Quant()
 {
     m_resiDctCoeff = NULL;
@@ -455,7 +457,7 @@
     }
 
     if (m_rdoqLevel)
-        return rdoQuant(cu, coeff, log2TrSize, ttype, absPartIdx, usePsy);
+        return (this->*rdoQuant_func[log2TrSize - 2])(cu, coeff, ttype, absPartIdx, usePsy);
     else
     {
         int deltaU[32 * 32];
@@ -550,7 +552,8 @@
 
 /* Rate distortion optimized quantization for entropy coding engines using
  * probability models like CABAC */
-uint32_t Quant::rdoQuant(const CUData& cu, int16_t* dstCoeff, uint32_t log2TrSize, TextType ttype, uint32_t absPartIdx, bool usePsy)
+template<uint32_t log2TrSize>
+uint32_t Quant::rdoQuant(const CUData& cu, int16_t* dstCoeff, TextType ttype, uint32_t absPartIdx, bool usePsy)
 {
     int transformShift = MAX_TR_DYNAMIC_RANGE - X265_DEPTH - log2TrSize; /* Represents scaling through forward transform */
     int scalingListType = (cu.isIntra(absPartIdx) ? 0 : 3) + ttype;
diff -r c72ca72fe00a -r 7411ad14770b source/common/quant.h
--- a/source/common/quant.h	Wed Sep 09 17:17:17 2015 -0500
+++ b/source/common/quant.h	Wed Sep 09 17:17:19 2015 -0500
@@ -151,7 +151,14 @@
 
     uint32_t signBitHidingHDQ(int16_t* qcoeff, int32_t* deltaU, uint32_t numSig, const TUEntropyCodingParameters &codingParameters, uint32_t log2TrSize);
 
-    uint32_t rdoQuant(const CUData& cu, int16_t* dstCoeff, uint32_t log2TrSize, TextType ttype, uint32_t absPartIdx, bool usePsy);
+    template<uint32_t log2TrSize>
+    uint32_t rdoQuant(const CUData& cu, int16_t* dstCoeff, TextType ttype, uint32_t absPartIdx, bool usePsy);
+
+public:
+    typedef uint32_t (Quant::*rdoQuant_t)(const CUData& cu, int16_t* dstCoeff, TextType ttype, uint32_t absPartIdx, bool usePsy);
+
+private:
+    static rdoQuant_t rdoQuant_func[NUM_CU_DEPTH];
 };
 }
 



More information about the x265-devel mailing list