[x265-commits] [x265] cleanup m_sharedPredTransformSkip[]

Satoshi Nakagawa nakagawa424 at oki.com
Mon Mar 10 04:02:03 CET 2014


details:   http://hg.videolan.org/x265/rev/d3bfe4152e67
branches:  
changeset: 6422:d3bfe4152e67
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Sat Mar 08 13:08:50 2014 +0900
description:
cleanup m_sharedPredTransformSkip[]

NEW_CALCRECON macro is TODO mark for asm experts, to optimize register assignment.
Subject: [x265] Removed Encoder* as member of DPB and replaced it with field m_bOpenGOP

details:   http://hg.videolan.org/x265/rev/13e2c2fe091d
branches:  
changeset: 6423:13e2c2fe091d
user:      David T Yuen <dtyx265 at gmail.com>
date:      Fri Mar 07 14:49:07 2014 -0800
description:
Removed Encoder* as member of DPB and replaced it with field m_bOpenGOP

Also added int bframes to Lowres since only param->bframes is passed to its
methods thus eliminating one of DPB's uses of Encoder*
Subject: [x265] Replaced Encoder* with x265_param* as member of several classes

details:   http://hg.videolan.org/x265/rev/0bd2465e3d4a
branches:  
changeset: 6424:0bd2465e3d4a
user:      David T Yuen <dtyx265 at gmail.com>
date:      Fri Mar 07 16:46:58 2014 -0800
description:
Replaced Encoder* with x265_param* as member of several classes

Replaced Encoder* with x265_param* as member of TEncCu, framefilter,
ratecontrol, CostEstimate and Lookahead Added m_CUTransquantBypassFlagValue to
TEncCu since it's part of Encoder and not x265_param framefilter's processRow
and processRowPost needed Encoder* to run Encoder::signalReconRowCompleted
Subject: [x265] TEncCu: nits, no logic change

details:   http://hg.videolan.org/x265/rev/1ff43004128f
branches:  
changeset: 6425:1ff43004128f
user:      Steve Borho <steve at borho.org>
date:      Sun Mar 09 21:36:14 2014 -0500
description:
TEncCu: nits, no logic change
Subject: [x265] me: skip TMVP merge candidates that are beyond vertical search range

details:   http://hg.videolan.org/x265/rev/f29f0ba91dfa
branches:  
changeset: 6426:f29f0ba91dfa
user:      Steve Borho <steve at borho.org>
date:      Sat Mar 08 20:42:48 2014 -0600
description:
me: skip TMVP merge candidates that are beyond vertical search range

Because of frame parallelism, pixels more than search range below coincident
may not be available in references.  Sometimes these merge candidates happened
to be the best cost, resulting in hash mismatches.

Because xMergeEstimation() can now return with no valid merge modes, the caller
must deal with the potential of no merge mode. predInterSearch() is sometimes
called to only measure merge modes (skipping ME for AMP partitions for some
presets), so now predInterSearch() can also possibly exit without generating
a valid prediction.
Subject: [x265] TEncSearch: remove confusing default arguments from predInterSearch()

details:   http://hg.videolan.org/x265/rev/f8926fb14c42
branches:  
changeset: 6427:f8926fb14c42
user:      Steve Borho <steve at borho.org>
date:      Sun Mar 09 20:59:24 2014 -0500
description:
TEncSearch: remove confusing default arguments from predInterSearch()

And completely remove bLuma which was always true
Subject: [x265] TEncSearch: remove default argument from encodeResAndCalcRdInterCU()

details:   http://hg.videolan.org/x265/rev/74d4709422f6
branches:  
changeset: 6428:74d4709422f6
user:      Steve Borho <steve at borho.org>
date:      Sun Mar 09 21:03:12 2014 -0500
description:
TEncSearch: remove default argument from encodeResAndCalcRdInterCU()
Subject: [x265] TEncCu: disable TMVP range check if frame threading disabled, code style nits

details:   http://hg.videolan.org/x265/rev/82a66870fc8b
branches:  
changeset: 6429:82a66870fc8b
user:      Steve Borho <steve at borho.org>
date:      Sun Mar 09 21:49:30 2014 -0500
description:
TEncCu: disable TMVP range check if frame threading disabled, code style nits

diffstat:

 source/Lib/TLibCommon/TComPic.cpp     |    4 +-
 source/Lib/TLibCommon/TComPic.h       |    2 +-
 source/Lib/TLibEncoder/TEncCu.cpp     |   99 +++++++--------
 source/Lib/TLibEncoder/TEncCu.h       |    3 +-
 source/Lib/TLibEncoder/TEncSearch.cpp |  150 ++++++++++-------------
 source/Lib/TLibEncoder/TEncSearch.h   |    9 +-
 source/common/lowres.cpp              |    7 +-
 source/common/lowres.h                |    7 +-
 source/common/pixel.cpp               |   15 ++-
 source/common/primitives.h            |    2 +
 source/common/x86/pixel-util8.asm     |   45 +++++++
 source/encoder/compress.cpp           |  101 ++++++++-------
 source/encoder/dpb.cpp                |    4 +-
 source/encoder/dpb.h                  |    4 +-
 source/encoder/encoder.cpp            |    4 +-
 source/encoder/frameencoder.cpp       |    2 +-
 source/encoder/frameencoder.h         |    2 +-
 source/encoder/framefilter.cpp        |   66 +++++-----
 source/encoder/framefilter.h          |    7 +-
 source/encoder/ratecontrol.cpp        |  206 +++++++++++++++++-----------------
 source/encoder/ratecontrol.h          |    2 +-
 source/encoder/slicetype.cpp          |  180 ++++++++++++++--------------
 source/encoder/slicetype.h            |    6 +-
 source/test/pixelharness.cpp          |    2 +
 24 files changed, 488 insertions(+), 441 deletions(-)

diffs (truncated from 2852 to 300 lines):

diff -r 93861c42b879 -r 82a66870fc8b source/Lib/TLibCommon/TComPic.cpp
--- a/source/Lib/TLibCommon/TComPic.cpp	Fri Mar 07 22:54:00 2014 -0600
+++ b/source/Lib/TLibCommon/TComPic.cpp	Sun Mar 09 21:49:30 2014 -0500
@@ -154,7 +154,7 @@ void TComPic::reInit(Encoder* cfg)
         memset(m_qpaAq, 0,  m_picSym->getFrameHeightInCU() * sizeof(double));
 }
 
-void TComPic::destroy(int bframes)
+void TComPic::destroy()
 {
     if (m_picSym)
     {
@@ -176,7 +176,7 @@ void TComPic::destroy(int bframes)
         delete m_reconPicYuv;
         m_reconPicYuv = NULL;
     }
-    m_lowres.destroy(bframes);
+    m_lowres.destroy();
 
     X265_FREE(m_rowDiagQp);
     X265_FREE(m_rowDiagQScale);
diff -r 93861c42b879 -r 82a66870fc8b source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h	Fri Mar 07 22:54:00 2014 -0600
+++ b/source/Lib/TLibCommon/TComPic.h	Sun Mar 09 21:49:30 2014 -0500
@@ -119,7 +119,7 @@ public:
     virtual ~TComPic();
 
     bool          create(Encoder* cfg);
-    virtual void  destroy(int bframes);
+    virtual void  destroy();
     void          reInit(Encoder* cfg);
 
     bool          getUsedByCurr()           { return m_bUsedByCurr; }
diff -r 93861c42b879 -r 82a66870fc8b source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Fri Mar 07 22:54:00 2014 -0600
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Sun Mar 09 21:49:30 2014 -0500
@@ -64,9 +64,9 @@ TEncCu::TEncCu()
 }
 
 /**
- \param    uiTotalDepth  total number of allowable depth
- \param    uiMaxWidth    largest CU width
- \param    uiMaxHeight   largest CU height
+ \param    totalDepth  total number of allowable depth
+ \param    maxWidth    largest CU width
+ \param    maxHeight   largest CU height
  */
 bool TEncCu::create(UChar totalDepth, uint32_t maxWidth)
 {
@@ -100,7 +100,7 @@ bool TEncCu::create(UChar totalDepth, ui
 
     m_origYuv = new TComYuv*[m_totalDepth - 1];
 
-    int csp = m_cfg->param->internalCsp;
+    int csp = m_param->internalCsp;
 
     bool ok = true;
     for (int i = 0; i < m_totalDepth - 1; i++)
@@ -330,7 +330,8 @@ void TEncCu::destroy()
  */
 void TEncCu::init(Encoder* top)
 {
-    m_cfg = top;
+    m_param = top->param;
+    m_CUTransquantBypassFlagValue = top->m_CUTransquantBypassFlagValue;
 }
 
 // ====================================================================================================================
@@ -380,7 +381,7 @@ void TEncCu::compressCU(TComDataCU* cu)
     }
     else
     {
-        if (m_cfg->param->rdLevel < 5)
+        if (m_param->rdLevel < 5)
         {
             TComDataCU* outBestCU = NULL;
 
@@ -678,10 +679,10 @@ void TEncCu::xCompressIntraCU(TComDataCU
     if (bBoundary || (bSliceEnd && bInsidePicture)) return;
 
     // Assert if Best prediction mode is NONE
-    // Selected mode's RD-cost must be not MAX_DOUBLE.
+    // Selected mode's RD-cost must be not MAX_INT64.
     assert(outBestCU->getPartitionSize(0) != SIZE_NONE);
     assert(outBestCU->getPredictionMode(0) != MODE_NONE);
-    assert(outBestCU->m_totalCost != MAX_DOUBLE);
+    assert(outBestCU->m_totalCost != MAX_INT64);
 }
 
 void TEncCu::xCompressCU(TComDataCU*& outBestCU, TComDataCU*& outTempCU, uint32_t depth, PartSize parentSize)
@@ -731,7 +732,7 @@ void TEncCu::xCompressCU(TComDataCU*& ou
         if (outBestCU->getSlice()->getSliceType() != I_SLICE)
         {
             // 2Nx2N
-            if (m_cfg->param->bEnableEarlySkip)
+            if (m_param->bEnableEarlySkip)
             {
                 xCheckRDCostInter(outBestCU, outTempCU, SIZE_2Nx2N);
                 outTempCU->initEstData(depth, qp); // by competition for inter_2Nx2N
@@ -741,12 +742,12 @@ void TEncCu::xCompressCU(TComDataCU*& ou
 
             outTempCU->initEstData(depth, qp);
 
-            if (!m_cfg->param->bEnableEarlySkip)
+            if (!m_param->bEnableEarlySkip)
             {
                 // 2Nx2N, NxN
                 xCheckRDCostInter(outBestCU, outTempCU, SIZE_2Nx2N);
                 outTempCU->initEstData(depth, qp);
-                if (m_cfg->param->bEnableCbfFastMode)
+                if (m_param->bEnableCbfFastMode)
                 {
                     doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
                 }
@@ -770,14 +771,14 @@ void TEncCu::xCompressCU(TComDataCU*& ou
                     }
                 }
 
-                if (m_cfg->param->bEnableRectInter)
+                if (m_param->bEnableRectInter)
                 {
                     // 2NxN, Nx2N
                     if (doNotBlockPu)
                     {
                         xCheckRDCostInter(outBestCU, outTempCU, SIZE_Nx2N);
                         outTempCU->initEstData(depth, qp);
-                        if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_Nx2N)
+                        if (m_param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_Nx2N)
                         {
                             doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
                         }
@@ -786,7 +787,7 @@ void TEncCu::xCompressCU(TComDataCU*& ou
                     {
                         xCheckRDCostInter(outBestCU, outTempCU, SIZE_2NxN);
                         outTempCU->initEstData(depth, qp);
-                        if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxN)
+                        if (m_param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxN)
                         {
                             doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
                         }
@@ -808,7 +809,7 @@ void TEncCu::xCompressCU(TComDataCU*& ou
                         {
                             xCheckRDCostInter(outBestCU, outTempCU, SIZE_2NxnU);
                             outTempCU->initEstData(depth, qp);
-                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnU)
+                            if (m_param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnU)
                             {
                                 doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
                             }
@@ -817,7 +818,7 @@ void TEncCu::xCompressCU(TComDataCU*& ou
                         {
                             xCheckRDCostInter(outBestCU, outTempCU, SIZE_2NxnD);
                             outTempCU->initEstData(depth, qp);
-                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnD)
+                            if (m_param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnD)
                             {
                                 doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
                             }
@@ -829,7 +830,7 @@ void TEncCu::xCompressCU(TComDataCU*& ou
                         {
                             xCheckRDCostInter(outBestCU, outTempCU, SIZE_2NxnU, true);
                             outTempCU->initEstData(depth, qp);
-                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnU)
+                            if (m_param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnU)
                             {
                                 doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
                             }
@@ -838,7 +839,7 @@ void TEncCu::xCompressCU(TComDataCU*& ou
                         {
                             xCheckRDCostInter(outBestCU, outTempCU, SIZE_2NxnD, true);
                             outTempCU->initEstData(depth, qp);
-                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnD)
+                            if (m_param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnD)
                             {
                                 doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
                             }
@@ -852,7 +853,7 @@ void TEncCu::xCompressCU(TComDataCU*& ou
                         {
                             xCheckRDCostInter(outBestCU, outTempCU, SIZE_nLx2N);
                             outTempCU->initEstData(depth, qp);
-                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_nLx2N)
+                            if (m_param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_nLx2N)
                             {
                                 doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
                             }
@@ -869,7 +870,7 @@ void TEncCu::xCompressCU(TComDataCU*& ou
                         {
                             xCheckRDCostInter(outBestCU, outTempCU, SIZE_nLx2N, true);
                             outTempCU->initEstData(depth, qp);
-                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_nLx2N)
+                            if (m_param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_nLx2N)
                             {
                                 doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
                             }
@@ -1022,10 +1023,10 @@ void TEncCu::xCompressCU(TComDataCU*& ou
     if (bBoundary || (bSliceEnd && bInsidePicture)) return;
 
     // Assert if Best prediction mode is NONE
-    // Selected mode's RD-cost must be not MAX_DOUBLE.
+    // Selected mode's RD-cost must be not MAX_INT64.
     assert(outBestCU->getPartitionSize(0) != SIZE_NONE);
     assert(outBestCU->getPredictionMode(0) != MODE_NONE);
-    assert(outBestCU->m_totalCost != MAX_DOUBLE);
+    assert(outBestCU->m_totalCost != MAX_INT64);
 }
 
 /** finish encoding a cu and handle end-of-slice conditions
@@ -1228,7 +1229,7 @@ void TEncCu::xCheckRDCostMerge2Nx2N(TCom
 
     UChar depth = outTempCU->getDepth(0);
     outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
-    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
+    outTempCU->setCUTransquantBypassSubParts(m_CUTransquantBypassFlagValue, 0, depth);
     outTempCU->getInterMergeCandidates(0, 0, mvFieldNeighbours, interDirNeighbours, numValidMergeCand);
 
     int mergeCandBuffer[MRG_MAX_NUM_CANDS];
@@ -1253,19 +1254,19 @@ void TEncCu::xCheckRDCostMerge2Nx2N(TCom
     {
         for (uint32_t mergeCand = 0; mergeCand < numValidMergeCand; ++mergeCand)
         {
-            /* TODO: check only necessary when -F>1, and ref pixels available is in units of LCU rows */
-            if (mvFieldNeighbours[0 + 2 * mergeCand].mv.y >= (m_cfg->param->searchRange + 1) * 4
-                || mvFieldNeighbours[1 + 2 * mergeCand].mv.y >= (m_cfg->param->searchRange + 1) * 4)
+            if (m_param->frameNumThreads > 1 &&
+                (mvFieldNeighbours[0 + 2 * mergeCand].mv.y >= (m_param->searchRange + 1) * 4 ||
+                 mvFieldNeighbours[1 + 2 * mergeCand].mv.y >= (m_param->searchRange + 1) * 4))
             {
                 continue;
             }
-            if (!(noResidual == 1 && mergeCandBuffer[mergeCand] == 1))
+            if (!(noResidual && mergeCandBuffer[mergeCand] == 1))
             {
-                if (!(bestIsSkip && noResidual == 0))
+                if (!(bestIsSkip && !noResidual))
                 {
                     // set MC parameters
                     outTempCU->setPredModeSubParts(MODE_INTER, 0, depth); // interprets depth relative to LCU level
-                    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue,     0, depth);
+                    outTempCU->setCUTransquantBypassSubParts(m_CUTransquantBypassFlagValue, 0, depth);
                     outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
                     outTempCU->setMergeFlag(0, true);
                     outTempCU->setMergeIndex(0, mergeCand);
@@ -1282,18 +1283,14 @@ void TEncCu::xCheckRDCostMerge2Nx2N(TCom
                                                         m_tmpResiYuv[depth],
                                                         m_bestResiYuv[depth],
                                                         m_tmpRecoYuv[depth],
-                                                        (noResidual ? true : false));
+                                                        !!noResidual,
+                                                        true);
 
                     /* Todo: Fix the satd cost estimates. Why is merge being chosen in high motion areas: estimated distortion is too low? */
-                    if (noResidual == 0)
-                    {
-                        if (outTempCU->getQtRootCbf(0) == 0)
-                        {
-                            mergeCandBuffer[mergeCand] = 1;
-                        }
-                    }
+                    if (!noResidual && !outTempCU->getQtRootCbf(0))
+                        mergeCandBuffer[mergeCand] = 1;
 
-                    outTempCU->setSkipFlagSubParts(outTempCU->getQtRootCbf(0) == 0, 0, depth);
+                    outTempCU->setSkipFlagSubParts(!outTempCU->getQtRootCbf(0), 0, depth);
                     int origQP = outTempCU->getQP(0);
                     xCheckDQP(outTempCU);
                     if (outTempCU->m_totalCost < outBestCU->m_totalCost)
@@ -1315,13 +1312,13 @@ void TEncCu::xCheckRDCostMerge2Nx2N(TCom
                     outTempCU->initEstData(depth, origQP);
                     if (!bestIsSkip)
                     {
-                        bestIsSkip = outBestCU->getQtRootCbf(0) == 0;
+                        bestIsSkip = !outBestCU->getQtRootCbf(0);
                     }
                 }
             }
         }
 
-        if (noResidual == 0 && m_cfg->param->bEnableEarlySkip)
+        if (noResidual == 0 && m_param->bEnableEarlySkip)
         {
             if (outBestCU->getQtRootCbf(0) == 0)
             {
@@ -1361,16 +1358,16 @@ void TEncCu::xCheckRDCostInter(TComDataC
     outTempCU->setSkipFlagSubParts(false, 0, depth);
     outTempCU->setPartSizeSubParts(partSize, 0, depth);
     outTempCU->setPredModeSubParts(MODE_INTER, 0, depth);
-    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
+    outTempCU->setCUTransquantBypassSubParts(m_CUTransquantBypassFlagValue, 0, depth);
 
-    m_tmpRecoYuv[depth]->clear();
+    m_tmpRecoYuv[depth]->clear(); // TODO: Are either of these clears necessary?
     m_tmpResiYuv[depth]->clear();
-    m_search->predInterSearch(outTempCU, m_tmpPredYuv[depth], bUseMRG);
-    m_search->encodeResAndCalcRdInterCU(outTempCU, m_origYuv[depth], m_tmpPredYuv[depth], m_tmpResiYuv[depth], m_bestResiYuv[depth], m_tmpRecoYuv[depth], false);
-
-    xCheckDQP(outTempCU);
-
-    xCheckBestMode(outBestCU, outTempCU, depth);
+    if (m_search->predInterSearch(outTempCU, m_tmpPredYuv[depth], bUseMRG, true))
+    {


More information about the x265-commits mailing list