[x265-commits] [x265] quant: move enums for scan order to TComRom together with...

Steve Borho steve at borho.org
Wed Jul 30 05:46:30 CEST 2014


details:   http://hg.videolan.org/x265/rev/fecc01d4c27f
branches:  
changeset: 7618:fecc01d4c27f
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 02:46:25 2014 -0500
description:
quant: move enums for scan order to TComRom together with the tables
Subject: [x265] quant: use ScanType enum as type for scanType, other cleanups

details:   http://hg.videolan.org/x265/rev/8d1b7dc5b832
branches:  
changeset: 7619:8d1b7dc5b832
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 14:09:01 2014 -0500
description:
quant: use ScanType enum as type for scanType, other cleanups
Subject: [x265] scaling: replace pow(2.0, -2.0 * transformShift) with shift adjustment

details:   http://hg.videolan.org/x265/rev/e51017789090
branches:  
changeset: 7620:e51017789090
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 14:34:42 2014 -0500
description:
scaling: replace pow(2.0, -2.0 * transformShift) with shift adjustment

Result is the same
Subject: [x265] defs: remove FULL_NBIT, no change to logic

details:   http://hg.videolan.org/x265/rev/2e22ea6ec4bc
branches:  
changeset: 7621:2e22ea6ec4bc
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 14:36:36 2014 -0500
description:
defs: remove FULL_NBIT, no change to logic
Subject: [x265] scaling: further simplify scaling list calculation

details:   http://hg.videolan.org/x265/rev/7c8fc08dfbd6
branches:  
changeset: 7622:7c8fc08dfbd6
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 14:44:30 2014 -0500
description:
scaling: further simplify scaling list calculation

It does more operations with ints, but mainly I just find this more readable
Subject: [x265] defs: cleanup CommonDef.h and TypeDef.h again

details:   http://hg.videolan.org/x265/rev/b5339cbf1764
branches:  
changeset: 7623:b5339cbf1764
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 15:07:56 2014 -0500
description:
defs: cleanup CommonDef.h and TypeDef.h again

TypeDef.h only defines enums, CommonDef.h only defines constants (grouped
together logically).  Remove doxygenness
Subject: [x265] typedef: remove redundant ChromaFormat enums

details:   http://hg.videolan.org/x265/rev/57a8320024ed
branches:  
changeset: 7624:57a8320024ed
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 15:14:06 2014 -0500
description:
typedef: remove redundant ChromaFormat enums
Subject: [x265] move quant defines from TComRom.h to CommonDef.h; they are not table sizes

details:   http://hg.videolan.org/x265/rev/eeeb96ecf0c7
branches:  
changeset: 7625:eeeb96ecf0c7
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 15:21:45 2014 -0500
description:
move quant defines from TComRom.h to CommonDef.h; they are not table sizes
Subject: [x265] scaling: cleanup

details:   http://hg.videolan.org/x265/rev/71bce9ae1072
branches:  
changeset: 7626:71bce9ae1072
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 15:33:09 2014 -0500
description:
scaling: cleanup
Subject: [x265] scaling: factor prec into scalingBits

details:   http://hg.videolan.org/x265/rev/664eff34ef25
branches:  
changeset: 7627:664eff34ef25
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 16:22:37 2014 -0500
description:
scaling: factor prec into scalingBits

This makes errScale clearly function to remove quantCoeff^2, and add this
cost scale factor (which is just a bit shift).  By factoring it this way, we
can probably remove the need for doubles in the near future by not using the
scaled coefficients in the stupid first place.
Subject: [x265] quant: improve documentation and code clarity, no logic change

details:   http://hg.videolan.org/x265/rev/4012d5a6ff93
branches:  
changeset: 7628:4012d5a6ff93
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 18:20:36 2014 -0500
description:
quant: improve documentation and code clarity, no logic change
Subject: [x265] quant: inline getRateSigCoef(), getRateSigCoeffGroup() and getICost()

details:   http://hg.videolan.org/x265/rev/f174808a7df4
branches:  
changeset: 7629:f174808a7df4
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 20:19:34 2014 -0500
description:
quant: inline getRateSigCoef(), getRateSigCoeffGroup() and getICost()
Subject: [x265] quant: hoist lambda multiplication out of getICRateCost()

details:   http://hg.videolan.org/x265/rev/e9e5f177a698
branches:  
changeset: 7630:e9e5f177a698
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 20:37:22 2014 -0500
description:
quant: hoist lambda multiplication out of getICRateCost()
Subject: [x265] quant: getICRate() and getICRateCost() do not need to be class methods

details:   http://hg.videolan.org/x265/rev/bb9b2fcf75ef
branches:  
changeset: 7631:bb9b2fcf75ef
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 20:42:25 2014 -0500
description:
quant: getICRate() and getICRateCost() do not need to be class methods
Subject: [x265] TEncSearch: fix output non-determination bug

details:   http://hg.videolan.org/x265/rev/05132ebe8413
branches:  
changeset: 7632:05132ebe8413
user:      Min Chen <chenm003 at 163.com>
date:      Tue Jul 29 18:56:48 2014 -0700
description:
TEncSearch: fix output non-determination bug

When temporal candidates end up as MVP candidates, they can reach beyond the
available region of valid pixels in the reference picture. In that case, we
should not try to measure distortion there, it only introduces non-determinism.
Just take the other MVP without contest. If both MVP were out of range, we
default to mvpIdx = 0.

Note that there was never any risk of a decode error since when ME runs it
clamps all motion vectors to the range of available pixels.  The setting of
this mvmin/mvmax range is assigned just after picking the best of the two MVP
candidates.

diffstat:

 source/Lib/TLibCommon/CommonDef.h        |   79 ++---
 source/Lib/TLibCommon/TComDataCU.cpp     |   26 +-
 source/Lib/TLibCommon/TComDataCU.h       |    2 +-
 source/Lib/TLibCommon/TComPrediction.cpp |    2 +-
 source/Lib/TLibCommon/TComRom.h          |   48 +--
 source/Lib/TLibCommon/TComTrQuant.cpp    |  392 +++++++++++++++---------------
 source/Lib/TLibCommon/TComTrQuant.h      |  117 +++++----
 source/Lib/TLibCommon/TypeDef.h          |  113 ++------
 source/Lib/TLibEncoder/TEncSearch.cpp    |   63 ++--
 source/common/deblock.cpp                |    4 +-
 source/common/scalinglist.cpp            |   15 +-
 source/encoder/entropy.cpp               |   24 +-
 12 files changed, 415 insertions(+), 470 deletions(-)

diffs (truncated from 1653 to 300 lines):

diff -r a9678988dda2 -r 05132ebe8413 source/Lib/TLibCommon/CommonDef.h
--- a/source/Lib/TLibCommon/CommonDef.h	Tue Jul 29 23:14:42 2014 +0530
+++ b/source/Lib/TLibCommon/CommonDef.h	Tue Jul 29 18:56:48 2014 -0700
@@ -31,73 +31,74 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/** \file     CommonDef.h
-    \brief    Defines constants, macros and tool parameters
-*/
-
 #ifndef X265_COMMONDEF_H
 #define X265_COMMONDEF_H
 
 #include "TypeDef.h"
 
-//! \ingroup TLibCommon
-//! \{
-
 #ifndef NULL
 #define NULL 0
 #endif
 
-// ====================================================================================================================
-// Common constants
-// ====================================================================================================================
+#define MAX_UINT                    0xFFFFFFFFU // max. value of unsigned 32-bit integer
+#define MAX_INT                     2147483647  // max. value of signed 32-bit integer
+#define MAX_INT64                   0x7FFFFFFFFFFFFFFFLL  // max. value of signed 64-bit integer
+#define MAX_DOUBLE                  1.7e+308    // max. value of double-type value
 
-#define COEF_REMAIN_BIN_REDUCTION   3 ///< indicates the level at which the VLC
-                                      ///< transitions from Golomb-Rice to TU+EG(k)
+#define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which the VLC
+                                      // transitions from Golomb-Rice to TU+EG(k)
 
-#define CU_DQP_TU_CMAX              5 ///< max number bins for truncated unary
-#define CU_DQP_EG_k                 0 ///< exp-golomb order
+#define SBH_THRESHOLD               4 // fixed sign bit hiding controlling threshold
 
-#define SBH_THRESHOLD               4 ///< I0156: value of the fixed SBH controlling threshold
-
-#define C1FLAG_NUMBER               8 // maximum number of largerThan1 flag coded in one chunk :  16 in HM5
+#define C1FLAG_NUMBER               8 // maximum number of largerThan1 flag coded in one chunk:  16 in HM5
 #define C2FLAG_NUMBER               1 // maximum number of largerThan2 flag coded in one chunk:  16 in HM5
 
 #define SAO_ENCODING_RATE           0.75
 #define SAO_ENCODING_RATE_CHROMA    0.5
 
-#define MLS_GRP_NUM                 64 ///< G644 : Max number of coefficient groups, max(16, 64)
-#define MLS_CG_SIZE                 4 ///< G644 : Coefficient group size of 4x4
+#define MLS_GRP_NUM                 64 // Max number of coefficient groups, max(16, 64)
+#define MLS_CG_SIZE                 4  // Coefficient group size of 4x4
 #define MLS_CG_LOG2_SIZE            2
 
+#define QUANT_IQUANT_SHIFT          20 // Q(QP%6) * IQ(QP%6) = 2^20
+#define QUANT_SHIFT                 14 // Q(4) = 2^14
+#define SCALE_BITS                  15 // Inherited from TMuC, presumably for fractional bit estimates in RDOQ
+#define MAX_TR_DYNAMIC_RANGE        15 // Maximum transform dynamic range (excluding sign bit)
+
+#define SHIFT_INV_1ST               7  // Shift after first inverse transform stage
+#define SHIFT_INV_2ND               12 // Shift after second inverse transform stage
+
 #define AMVP_DECIMATION_FACTOR      4
 
 #define SCAN_SET_SIZE               16
 #define LOG2_SCAN_SET_SIZE          4
 
-#define FAST_UDI_MAX_RDMODE_NUM     35 ///< maximum number of RD comparison in fast-UDI estimation loop
+#define FAST_UDI_MAX_RDMODE_NUM     35 // maximum number of RD comparison in fast-UDI estimation loop
 
 #define ALL_IDX                     -1
 #define PLANAR_IDX                  0
 #define VER_IDX                     26 // index for intra VERTICAL   mode
 #define HOR_IDX                     10 // index for intra HORIZONTAL mode
-#define DC_IDX                      1 // index for intra DC mode
-#define NUM_CHROMA_MODE             5 // total number of chroma modes
+#define DC_IDX                      1  // index for intra DC mode
+#define NUM_CHROMA_MODE             5  // total number of chroma modes
 #define DM_CHROMA_IDX               36 // chroma mode index for derived from luma intra mode
 
-#define FULL_NBIT 1 ///< When enabled, compute costs using full sample bitdepth.  When disabled, compute costs as if it is 8-bit source video.
-#if FULL_NBIT || !HIGH_BIT_DEPTH
+#define MDCS_ANGLE_LIMIT            4 // distance from true angle that horiz or vertical scan is allowed
+#define MDCS_LOG2_MAX_SIZE          3 // TUs with log2 of size greater than this can only use diagonal scan
+
+#if HIGH_BIT_DEPTH
+# define DISTORTION_PRECISION_ADJUSTMENT(x) (x)
+#else
 # define DISTORTION_PRECISION_ADJUSTMENT(x) 0
-#else
-# define DISTORTION_PRECISION_ADJUSTMENT(x) (x)
 #endif
 
-#define MAX_NUM_REF_PICS            16          ///< max. number of pictures used for reference
-#define MAX_NUM_REF                 16          ///< max. number of entries in picture reference list
+#define MAX_NUM_REF_PICS            16 // max. number of pictures used for reference
+#define MAX_NUM_REF                 16 // max. number of entries in picture reference list
 
-#define MAX_UINT                    0xFFFFFFFFU ///< max. value of unsigned 32-bit integer
-#define MAX_INT                     2147483647  ///< max. value of signed 32-bit integer
-#define MAX_INT64                   0x7FFFFFFFFFFFFFFFLL  ///< max. value of signed 64-bit integer
-#define MAX_DOUBLE                  1.7e+308    ///< max. value of double-type value
+#define REF_PIC_LIST_0              0
+#define REF_PIC_LIST_1              1
+#define REF_PIC_LIST_X              100
+#define NOT_VALID                   -1
 
 #define MIN_QP                      0
 #define MAX_QP                      51
@@ -106,18 +107,12 @@
 #define MIN_QPSCALE                 0.21249999999999999
 #define MAX_MAX_QPSCALE             615.46574234477100
 
-#define NOT_VALID                  -1
-
-// ====================================================================================================================
-// Coding tool configuration
-// ====================================================================================================================
-
-// AMVP: advanced motion vector prediction
-#define AMVP_MAX_NUM_CANDS          2 ///< max number of final candidates
-#define MRG_MAX_NUM_CANDS           5
+#define AMVP_MAX_NUM_CANDS          2 // max number of final AMVP candidates
+#define MRG_MAX_NUM_CANDS           5 // max number of final merge candidates
 
 #define MAX_CHROMA_FORMAT_IDC       3 //  TODO: Remove me
 
-//! \}
+#define CHROMA_H_SHIFT(x) (x == X265_CSP_I420 || x == X265_CSP_I422)
+#define CHROMA_V_SHIFT(x) (x == X265_CSP_I420)
 
 #endif // ifndef X265_COMMONDEF_H
diff -r a9678988dda2 -r 05132ebe8413 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Tue Jul 29 23:14:42 2014 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Tue Jul 29 18:56:48 2014 -0700
@@ -2428,44 +2428,42 @@ void TComDataCU::xDeriveCenterIdx(uint32
                                        + (partWidth  >> (m_pic->getLog2UnitSize() + 1))];
 }
 
-uint32_t TComDataCU::getCoefScanIdx(uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma, bool bIsIntra)
+ScanType TComDataCU::getCoefScanIdx(uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma, bool bIsIntra)
 {
-    uint32_t scanIdx;
     uint32_t dirMode;
 
     if (!bIsIntra)
-    {
         return SCAN_DIAG;
-    }
+
     //check that MDCS can be used for this TU
 
     if (bIsLuma)
     {
-        if (log2TrSize > MDCS_LOG2_MAX_SIZE) return SCAN_DIAG;
+        if (log2TrSize > MDCS_LOG2_MAX_SIZE)
+            return SCAN_DIAG;
 
         dirMode = getLumaIntraDir(absPartIdx);
     }
     else
     {
-        if (log2TrSize > (MDCS_LOG2_MAX_SIZE - m_hChromaShift)) return SCAN_DIAG;
+        if (log2TrSize > (MDCS_LOG2_MAX_SIZE - m_hChromaShift))
+            return SCAN_DIAG;
 
-        dirMode  = getChromaIntraDir(absPartIdx);
+        dirMode = getChromaIntraDir(absPartIdx);
         if (dirMode == DM_CHROMA_IDX)
         {
-            uint32_t lumaLCUIdx = (m_chromaFormat == CHROMA_444) ? absPartIdx : absPartIdx & (~((1 << (2 * g_addCUDepth)) - 1));
+            uint32_t lumaLCUIdx = (m_chromaFormat == X265_CSP_I444) ? absPartIdx : absPartIdx & (~((1 << (2 * g_addCUDepth)) - 1));
             dirMode = getLumaIntraDir(lumaLCUIdx);
-            dirMode = (m_chromaFormat == CHROMA_422) ? g_chroma422IntraAngleMappingTable[dirMode] : dirMode;
+            dirMode = (m_chromaFormat == X265_CSP_I422) ? g_chroma422IntraAngleMappingTable[dirMode] : dirMode;
         }
     }
 
     if (abs((int)dirMode - VER_IDX) <= MDCS_ANGLE_LIMIT)
-        scanIdx = SCAN_HOR;
+        return SCAN_HOR;
     else if (abs((int)dirMode - HOR_IDX) <= MDCS_ANGLE_LIMIT)
-        scanIdx = SCAN_VER;
+        return SCAN_VER;
     else
-        scanIdx = SCAN_DIAG;
-
-    return scanIdx;
+        return SCAN_DIAG;
 }
 
 uint32_t TComDataCU::getSCUAddr()
diff -r a9678988dda2 -r 05132ebe8413 source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h	Tue Jul 29 23:14:42 2014 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.h	Tue Jul 29 18:56:48 2014 -0700
@@ -488,7 +488,7 @@ public:
 
     uint32_t&     getTotalNumPart()     { return m_numPartitions; }
 
-    uint32_t      getCoefScanIdx(uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma, bool bIsIntra);
+    ScanType      getCoefScanIdx(uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma, bool bIsIntra);
 
     // -------------------------------------------------------------------------------------------------------------------
     // member functions to support multiple color space formats
diff -r a9678988dda2 -r 05132ebe8413 source/Lib/TLibCommon/TComPrediction.cpp
--- a/source/Lib/TLibCommon/TComPrediction.cpp	Tue Jul 29 23:14:42 2014 +0530
+++ b/source/Lib/TLibCommon/TComPrediction.cpp	Tue Jul 29 18:56:48 2014 -0700
@@ -145,7 +145,7 @@ void TComPrediction::predIntraChromaAng(
     pixel refAbv[3 * MAX_CU_SIZE];
     pixel refLft[3 * MAX_CU_SIZE];
 
-    bool bUseFilteredPredictions = (chFmt == CHROMA_444 && filteringIntraReferenceSamples(dirMode, log2TrSizeC));
+    bool bUseFilteredPredictions = (chFmt == X265_CSP_I444 && filteringIntraReferenceSamples(dirMode, log2TrSizeC));
 
     if (bUseFilteredPredictions)
     {
diff -r a9678988dda2 -r 05132ebe8413 source/Lib/TLibCommon/TComRom.h
--- a/source/Lib/TLibCommon/TComRom.h	Tue Jul 29 23:14:42 2014 +0530
+++ b/source/Lib/TLibCommon/TComRom.h	Tue Jul 29 18:56:48 2014 -0700
@@ -100,14 +100,6 @@ extern uint32_t g_log2UnitSize;
 
 extern const uint32_t g_puOffset[8];
 
-#define QUANT_IQUANT_SHIFT    20 // Q(QP%6) * IQ(QP%6) = 2^20
-#define QUANT_SHIFT           14 // Q(4) = 2^14
-#define SCALE_BITS            15 // Inherited from TMuC, presumably for fractional bit estimates in RDOQ
-#define MAX_TR_DYNAMIC_RANGE  15 // Maximum transform dynamic range (excluding sign bit)
-
-#define SHIFT_INV_1ST          7 // Shift after first inverse transform stage
-#define SHIFT_INV_2ND         12 // Shift after second inverse transform stage
-
 extern const int16_t g_t4[4][4];
 extern const int16_t g_t8[8][8];
 extern const int16_t g_t16[16][16];
@@ -130,36 +122,33 @@ extern const int16_t g_chromaFilter[8][N
 // Scanning order & context mapping table
 // ====================================================================================================================
 
+// coefficient scanning type used in ACS
+enum ScanType
+{
+    SCAN_DIAG = 0,     // up-right diagonal scan
+    SCAN_HOR = 1,      // horizontal first scan
+    SCAN_VER = 2,      // vertical first scan
+    NUM_SCAN_TYPE = 3
+};
+
+enum SignificanceMapContextType
+{
+    CONTEXT_TYPE_4x4 = 0,
+    CONTEXT_TYPE_8x8 = 1,
+    CONTEXT_TYPE_NxN = 2,
+    CONTEXT_NUMBER_OF_TYPES = 3
+};
+
 #define NUM_SCAN_SIZE 4
 
 extern const uint16_t* const g_scanOrder[NUM_SCAN_TYPE][NUM_SCAN_SIZE];
 extern const uint16_t* const g_scanOrderCG[NUM_SCAN_TYPE][NUM_SCAN_SIZE];
 extern const uint16_t g_scan8x8diag[8 * 8];
 extern const uint16_t g_scan4x4[NUM_SCAN_TYPE][4 * 4];
-
-//extern const uint8_t g_groupIdx[32];
-static inline uint32_t getGroupIdx(const uint32_t idx)
-{
-    uint32_t group = (idx >> 3);
-
-    if (idx >= 24)
-        group = 2;
-    uint32_t groupIdx = ((idx >> (group + 1)) - 2) + 4 + (group << 1);
-    if (idx <= 3)
-        groupIdx = idx;
-
-#ifdef _DEBUG
-    static const uint8_t g_groupIdx[32]   = { 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9 };
-    assert(groupIdx == g_groupIdx[idx]);
-#endif
-
-    return groupIdx;
-}
+#define NUM_SCAN_SIZE 4
 
 extern const uint8_t g_minInGroup[10];
-
 extern const uint8_t g_goRiceRange[5];      //!< maximum value coded with Rice codes
-//extern const uint8_t g_goRicePrefixLen[5];  //!< prefix length for each maximum value
 
 // ====================================================================================================================
 // Misc.
@@ -167,7 +156,6 @@ extern const uint8_t g_goRiceRange[5];  
 
 extern uint8_t g_convertToBit[MAX_CU_SIZE + 1]; // from width to log2(width)-2
 
-
 // Map Luma samples to chroma samples
 extern const int g_winUnitX[MAX_CHROMA_FORMAT_IDC + 1];
 extern const int g_winUnitY[MAX_CHROMA_FORMAT_IDC + 1];
diff -r a9678988dda2 -r 05132ebe8413 source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Tue Jul 29 23:14:42 2014 +0530


More information about the x265-commits mailing list