[x265-commits] [x265] TEncEntropy: hoist trivial functions to header for possib...

Steve Borho steve at borho.org
Wed Jul 2 22:47:40 CEST 2014


details:   http://hg.videolan.org/x265/rev/a15e58e38501
branches:  
changeset: 7209:a15e58e38501
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 01 23:53:04 2014 -0500
description:
TEncEntropy: hoist trivial functions to header for possible inlining

And remove useless comments
Subject: [x265] TEncEntropy: nit

details:   http://hg.videolan.org/x265/rev/166b7ddace37
branches:  
changeset: 7210:166b7ddace37
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 01 23:53:12 2014 -0500
description:
TEncEntropy: nit
Subject: [x265] TEncEntropy: hoist encodeSliceHeader() to header after simplifying

details:   http://hg.videolan.org/x265/rev/719ec54347ab
branches:  
changeset: 7211:719ec54347ab
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 01 23:56:13 2014 -0500
description:
TEncEntropy: hoist encodeSliceHeader() to header after simplifying
Subject: [x265] TEncEntropy: hoist encodeSkipFlag() after moving I-slice check to callers

details:   http://hg.videolan.org/x265/rev/8208c49e9aa4
branches:  
changeset: 7212:8208c49e9aa4
user:      Steve Borho <steve at borho.org>
date:      Wed Jul 02 00:08:51 2014 -0500
description:
TEncEntropy: hoist encodeSkipFlag() after moving I-slice check to callers
Subject: [x265] TEncEntropy: reorder nit

details:   http://hg.videolan.org/x265/rev/a4cf2c474fb8
branches:  
changeset: 7213:a4cf2c474fb8
user:      Steve Borho <steve at borho.org>
date:      Wed Jul 02 00:09:03 2014 -0500
description:
TEncEntropy: reorder nit
Subject: [x265] TEncEntropy: hoist encodePredMode() after moving I-slice check to callers

details:   http://hg.videolan.org/x265/rev/ca17915c0176
branches:  
changeset: 7214:ca17915c0176
user:      Steve Borho <steve at borho.org>
date:      Wed Jul 02 00:13:10 2014 -0500
description:
TEncEntropy: hoist encodePredMode() after moving I-slice check to callers
Subject: [x265] TEncEntropy: inline the only one caller of encodeInterDirPU

details:   http://hg.videolan.org/x265/rev/f483344d276f
branches:  
changeset: 7215:f483344d276f
user:      Steve Borho <steve at borho.org>
date:      Wed Jul 02 00:15:40 2014 -0500
description:
TEncEntropy: inline the only one caller of encodeInterDirPU
Subject: [x265] input: streamline control logic of threaded file readers

details:   http://hg.videolan.org/x265/rev/99b8e4d69e0f
branches:  
changeset: 7216:99b8e4d69e0f
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 01 17:47:28 2014 -0500
description:
input: streamline control logic of threaded file readers

These files were written before ThreadSafeInteger and this caused the control
logic to be over-complicated.  Now they can be greatly simplified and their
control flows can be re-unified to be more like each other.

Also, drop PPA events. File reading is pretty uninteresting when profiling.
Subject: [x265] encoder: fix --no-wpp behavior, keep TLD selection logic in one place

details:   http://hg.videolan.org/x265/rev/0743791a8245
branches:  
changeset: 7217:0743791a8245
user:      Steve Borho <steve at borho.org>
date:      Wed Jul 02 01:19:10 2014 -0500
description:
encoder: fix --no-wpp behavior, keep TLD selection logic in one place

do not use static m_threadLocalData, this would break if multiple encoders were
allocated in a single process

pass the selected TLD to row processes, so they do not need to be aware of the
WPP/NO-WPP details.

Cleanup frameencoder.h, move non-trivial processRow() to the cpp file
Subject: [x265] frame: initialize recon to avoid SAO read of uninitialized pixels beyond picture end

details:   http://hg.videolan.org/x265/rev/cbe0999934b7
branches:  
changeset: 7218:cbe0999934b7
user:      Kavitha Sampath <kavitha at multicorewareinc.com>
date:      Wed Jul 02 16:06:23 2014 +0530
description:
frame: initialize recon to avoid SAO read of uninitialized pixels beyond picture end
Subject: [x265] add primitives.nquant for RDOQ

details:   http://hg.videolan.org/x265/rev/5bfd621a58b9
branches:  
changeset: 7219:5bfd621a58b9
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Wed Jul 02 16:37:41 2014 +0900
description:
add primitives.nquant for RDOQ
Subject: [x265] rc: move structure FrameStats to FrameEncoder class

details:   http://hg.videolan.org/x265/rev/8f76f88c7dbf
branches:  
changeset: 7220:8f76f88c7dbf
user:      Aarthi Thirumalai
date:      Tue Jul 01 14:28:25 2014 +0530
description:
rc: move structure FrameStats to FrameEncoder class

Stats are not needed post encode, moving it to FrameEncoder.
Subject: [x265] rc: compute inter, intra and skip cus per frame for the first pass

details:   http://hg.videolan.org/x265/rev/5bee122bc183
branches:  
changeset: 7221:5bee122bc183
user:      Aarthi Thirumalai
date:      Thu Jun 26 17:49:26 2014 +0530
description:
rc: compute inter, intra and skip cus per frame for the first pass
Subject: [x265] rc: write frame stats and cu stats to file in first pass

details:   http://hg.videolan.org/x265/rev/887081b5f694
branches:  
changeset: 7222:887081b5f694
user:      Aarthi Thirumalai<aarthi at multicorewareinc.com>
date:      Mon Jun 30 22:05:50 2014 +0530
description:
rc: write frame stats and cu stats to file in first pass
Subject: [x265] rc: fix gcc warnings

details:   http://hg.videolan.org/x265/rev/b90fdc3ffb96
branches:  
changeset: 7223:b90fdc3ffb96
user:      Steve Borho <steve at borho.org>
date:      Wed Jul 02 14:31:51 2014 -0500
description:
rc: fix gcc warnings

diffstat:

 source/Lib/TLibCommon/TComTrQuant.cpp  |   32 ++-
 source/Lib/TLibEncoder/TEncCu.cpp      |   24 ++-
 source/Lib/TLibEncoder/TEncCu.h        |    4 +
 source/Lib/TLibEncoder/TEncEntropy.cpp |  244 +--------------------------------
 source/Lib/TLibEncoder/TEncEntropy.h   |   78 ++++++----
 source/Lib/TLibEncoder/TEncSearch.cpp  |   10 +-
 source/common/dct.cpp                  |   28 +++-
 source/common/frame.cpp                |   15 +-
 source/common/frame.h                  |   15 --
 source/common/primitives.h             |    2 +
 source/common/x86/asm-primitives.cpp   |    2 +
 source/common/x86/pixel-util.h         |    1 +
 source/common/x86/pixel-util8.asm      |   77 ++++++++++-
 source/encoder/compress.cpp            |    7 +-
 source/encoder/cturow.h                |    6 +
 source/encoder/encoder.cpp             |   11 +-
 source/encoder/encoder.h               |    2 +-
 source/encoder/frameencoder.cpp        |   69 ++++++++-
 source/encoder/frameencoder.h          |   75 +++------
 source/encoder/framefilter.cpp         |   18 +-
 source/encoder/framefilter.h           |    6 +-
 source/encoder/ratecontrol.cpp         |   40 +++++-
 source/encoder/ratecontrol.h           |    5 +-
 source/input/y4m.cpp                   |  208 ++++++++++++---------------
 source/input/y4m.h                     |   14 +-
 source/input/yuv.cpp                   |  110 +++++++-------
 source/input/yuv.h                     |    8 +-
 source/test/mbdstharness.cpp           |   59 +++++++
 source/test/mbdstharness.h             |    1 +
 29 files changed, 584 insertions(+), 587 deletions(-)

diffs (truncated from 2102 to 300 lines):

diff -r a18972fd05b1 -r b90fdc3ffb96 source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Tue Jul 01 14:58:35 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Wed Jul 02 14:31:51 2014 -0500
@@ -508,23 +508,30 @@ void TComTrQuant::xITransformSkip(int32_
 uint32_t TComTrQuant::xRateDistOptQuant(TComDataCU* cu, int32_t* srcCoeff, coeff_t* dstCoeff, uint32_t trSize,
                                         TextType ttype, uint32_t absPartIdx, int32_t *lastPos)
 {
-    x265_emms();
-    selectLambda(ttype);
-
     const uint32_t log2TrSize = g_convertToBit[trSize] + 2;
-    uint32_t absSum = 0;
     int transformShift = MAX_TR_DYNAMIC_RANGE - X265_DEPTH - log2TrSize; // Represents scaling through forward transform
-    uint32_t goRiceParam = 0;
-    double blockUncodedCost = 0;
     int scalingListType = (cu->isIntra(absPartIdx) ? 0 : 3) + ttype;
 
     X265_CHECK(scalingListType < 6, "scaling list type out of range\n");
 
     int qbits = QUANT_SHIFT + m_qpParam.m_per + transformShift; // Right shift of non-RDOQ quantizer;  level = (coeff*Q + offset)>>q_bits
     int add = (1 << (qbits - 1));
-    double *errScale = getErrScaleCoeff(scalingListType, log2TrSize - 2, m_qpParam.m_rem);
     int32_t *qCoef = getQuantCoeff(scalingListType, m_qpParam.m_rem, log2TrSize - 2);
 
+    int numCoeff = 1 << log2TrSize * 2;
+    int scaledCoeff[32 * 32];
+    uint32_t numSig = primitives.nquant(srcCoeff, qCoef, scaledCoeff, dstCoeff, qbits, add, numCoeff);
+
+    X265_CHECK(numSig == primitives.count_nonzero(dstCoeff, numCoeff), "numSig differ\n");
+    if (numSig == 0)
+        return 0;
+
+    x265_emms();
+    selectLambda(ttype);
+
+    double *errScale = getErrScaleCoeff(scalingListType, log2TrSize - 2, m_qpParam.m_rem);
+
+    double blockUncodedCost = 0;
     double costCoeff[32 * 32];
     double costSig[32 * 32];
     double costCoeff0[32 * 32];
@@ -544,6 +551,7 @@ uint32_t TComTrQuant::xRateDistOptQuant(
     int    c2            = 0;
     double baseCost      = 0;
     int    lastScanPos   = -1;
+    uint32_t goRiceParam = 0;
     uint32_t c1Idx       = 0;
     uint32_t c2Idx       = 0;
     int cgLastScanPos    = -1;
@@ -567,16 +575,13 @@ uint32_t TComTrQuant::xRateDistOptQuant(
             //===== quantization =====
             uint32_t blkPos = codingParameters.scan[scanPos];
             // set coeff
-            int Q = qCoef[blkPos];
             double scaleFactor = errScale[blkPos];
-            int levelDouble    = srcCoeff[blkPos];
-            levelDouble        = (int)std::min<int64_t>((int64_t)abs((int)levelDouble) * Q, MAX_INT - add);
 
-            uint32_t maxAbsLevel = (levelDouble + add) >> qbits;
+            int levelDouble      = scaledCoeff[blkPos];
+            uint32_t maxAbsLevel = abs(dstCoeff[blkPos]);
 
             costCoeff0[scanPos] = ((uint64_t)levelDouble * levelDouble) * scaleFactor;
             blockUncodedCost   += costCoeff0[scanPos];
-            dstCoeff[blkPos]    = maxAbsLevel;
 
             if (maxAbsLevel > 0 && lastScanPos < 0)
             {
@@ -776,7 +781,7 @@ uint32_t TComTrQuant::xRateDistOptQuant(
     //===== estimate last position =====
     if (lastScanPos < 0)
     {
-        return absSum;
+        return 0;
     }
 
     double bestCost = 0;
@@ -840,6 +845,7 @@ uint32_t TComTrQuant::xRateDistOptQuant(
         } // end if (sigCoeffGroupFlag[ cgBlkPos ])
     } // end for
 
+    uint32_t absSum = 0;
     for (int pos = 0; pos < bestLastIdxp1; pos++)
     {
         int blkPos = codingParameters.scan[pos];
diff -r a18972fd05b1 -r b90fdc3ffb96 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Tue Jul 01 14:58:35 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Wed Jul 02 14:31:51 2014 -0500
@@ -343,6 +343,7 @@ void TEncCu::compressCU(TComDataCU* cu)
                 m_log->totalCu++;
                 part = cu->getDepth(i);
                 int next = numPartition >> (part * 2);
+                m_log->qTreeIntraCnt[part]++;
                 if (part == g_maxCUDepth - 1 && cu->getPartitionSize(i) != SIZE_2Nx2N)
                 {
                     m_log->cntIntraNxN++;
@@ -383,6 +384,7 @@ void TEncCu::compressCU(TComDataCU* cu)
                 if (cu->isSkipped(i))
                 {
                     m_log->cntSkipCu[part]++;
+                    m_log->qTreeSkipCnt[part]++;
                 }
                 else
                 {
@@ -390,6 +392,7 @@ void TEncCu::compressCU(TComDataCU* cu)
                     if (cu->getPredictionMode(0) == MODE_INTER)
                     {
                         m_log->cntInter[part]++;
+                        m_log->qTreeInterCnt[part]++;
                         if (cu->getPartitionSize(0) < AMP_ID)
                             m_log->cuInterDistribution[part][cu->getPartitionSize(0)]++;
                         else
@@ -397,6 +400,7 @@ void TEncCu::compressCU(TComDataCU* cu)
                     }
                     else if (cu->getPredictionMode(0) == MODE_INTRA)
                     {
+                        m_log->qTreeIntraCnt[part]++;
                         if (part == g_maxCUDepth - 1 && cu->getPartitionSize(0) == SIZE_NxN)
                         {
                             m_log->cntIntraNxN++;
@@ -1154,9 +1158,7 @@ void TEncCu::xEncodeCU(TComDataCU* cu, u
         m_entropyCoder->encodeCUTransquantBypassFlag(cu, absPartIdx);
     }
     if (!slice->isIntra())
-    {
         m_entropyCoder->encodeSkipFlag(cu, absPartIdx);
-    }
 
     if (cu->isSkipped(absPartIdx))
     {
@@ -1164,7 +1166,9 @@ void TEncCu::xEncodeCU(TComDataCU* cu, u
         finishCU(cu, absPartIdx, depth);
         return;
     }
-    m_entropyCoder->encodePredMode(cu, absPartIdx);
+
+    if (!slice->isIntra())
+        m_entropyCoder->encodePredMode(cu, absPartIdx);
 
     m_entropyCoder->encodePartSize(cu, absPartIdx, depth);
 
@@ -1346,8 +1350,11 @@ void TEncCu::xCheckRDCostIntra(TComDataC
     {
         m_entropyCoder->encodeCUTransquantBypassFlag(outTempCU, 0);
     }
-    m_entropyCoder->encodeSkipFlag(outTempCU, 0);
-    m_entropyCoder->encodePredMode(outTempCU, 0);
+    if (!outTempCU->getSlice()->isIntra())
+    {
+        m_entropyCoder->encodeSkipFlag(outTempCU, 0);
+        m_entropyCoder->encodePredMode(outTempCU, 0);
+    }
     m_entropyCoder->encodePartSize(outTempCU, 0, depth);
     m_entropyCoder->encodePredInfo(outTempCU, 0);
     outTempCU->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
@@ -1394,8 +1401,11 @@ void TEncCu::xCheckRDCostIntraInInter(TC
     {
         m_entropyCoder->encodeCUTransquantBypassFlag(outTempCU, 0);
     }
-    m_entropyCoder->encodeSkipFlag(outTempCU, 0);
-    m_entropyCoder->encodePredMode(outTempCU, 0);
+    if (!outTempCU->getSlice()->isIntra())
+    {
+        m_entropyCoder->encodeSkipFlag(outTempCU, 0);
+        m_entropyCoder->encodePredMode(outTempCU, 0);
+    }
     m_entropyCoder->encodePartSize(outTempCU, 0, depth);
     m_entropyCoder->encodePredInfo(outTempCU, 0);
     outTempCU->m_mvBits = m_entropyCoder->getNumberOfWrittenBits();
diff -r a18972fd05b1 -r b90fdc3ffb96 source/Lib/TLibEncoder/TEncCu.h
--- a/source/Lib/TLibEncoder/TEncCu.h	Tue Jul 01 14:58:35 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.h	Wed Jul 02 14:31:51 2014 -0500
@@ -66,6 +66,10 @@ struct StatisticLog
     uint64_t cntTotalCu[4];
     uint64_t totalCu;
 
+    /* These states store the count of inter,intra and skip ctus within quad tree structure of each CU */
+    uint32_t qTreeInterCnt[4];
+    uint32_t qTreeIntraCnt[4];
+    uint32_t qTreeSkipCnt[4];
     StatisticLog()
     {
         memset(this, 0, sizeof(StatisticLog));
diff -r a18972fd05b1 -r b90fdc3ffb96 source/Lib/TLibEncoder/TEncEntropy.cpp
--- a/source/Lib/TLibEncoder/TEncEntropy.cpp	Tue Jul 01 14:58:35 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncEntropy.cpp	Wed Jul 02 14:31:51 2014 -0500
@@ -44,127 +44,6 @@ using namespace x265;
 //! \ingroup TLibEncoder
 //! \{
 
-void TEncEntropy::setEntropyCoder(TEncSbac* e, TComSlice* slice)
-{
-    m_entropyCoder = e;
-    m_entropyCoder->setSlice(slice);
-}
-
-void TEncEntropy::encodeSliceHeader(TComSlice* slice)
-{
-    if (slice->getSPS()->getUseSAO())
-    {
-        SAOParam *saoParam = slice->getPic()->getPicSym()->getSaoParam();
-        slice->setSaoEnabledFlag(saoParam->bSaoFlag[0]);
-        slice->setSaoEnabledFlagChroma(saoParam->bSaoFlag[1]);
-    }
-
-    m_entropyCoder->codeSliceHeader(slice);
-}
-
-void  TEncEntropy::encodeTilesWPPEntryPoint(TComSlice* pSlice)
-{
-    m_entropyCoder->codeTilesWPPEntryPoint(pSlice);
-}
-
-void TEncEntropy::encodeTerminatingBit(uint32_t isLast)
-{
-    m_entropyCoder->codeTerminatingBit(isLast);
-}
-
-void TEncEntropy::encodeSliceFinish()
-{
-    m_entropyCoder->codeSliceFinish();
-}
-
-void TEncEntropy::encodePPS(TComPPS* pps)
-{
-    m_entropyCoder->codePPS(pps);
-}
-
-void TEncEntropy::encodeSPS(TComSPS* sps)
-{
-    m_entropyCoder->codeSPS(sps);
-}
-
-void TEncEntropy::encodeAUD(TComSlice* slice)
-{
-    m_entropyCoder->codeAUD(slice);
-}
-
-void TEncEntropy::encodeCUTransquantBypassFlag(TComDataCU* cu, uint32_t absPartIdx)
-{
-    m_entropyCoder->codeCUTransquantBypassFlag(cu, absPartIdx);
-}
-
-void TEncEntropy::encodeVPS(TComVPS* vps)
-{
-    m_entropyCoder->codeVPS(vps);
-}
-
-void TEncEntropy::encodeSkipFlag(TComDataCU* cu, uint32_t absPartIdx)
-{
-    if (cu->getSlice()->isIntra())
-    {
-        return;
-    }
-    m_entropyCoder->codeSkipFlag(cu, absPartIdx);
-}
-
-/** encode merge flag
- * \param cu
- * \param absPartIdx
- * \returns void
- */
-void TEncEntropy::encodeMergeFlag(TComDataCU* cu, uint32_t absPartIdx)
-{
-    // at least one merge candidate exists
-    m_entropyCoder->codeMergeFlag(cu, absPartIdx);
-}
-
-/** encode merge index
- * \param cu
- * \param absPartIdx
- * \param uiPUIdx
- * \returns void
- */
-void TEncEntropy::encodeMergeIndex(TComDataCU* cu, uint32_t absPartIdx)
-{
-    m_entropyCoder->codeMergeIndex(cu, absPartIdx);
-}
-
-/** encode prediction mode
- * \param cu
- * \param absPartIdx
- * \returns void
- */
-void TEncEntropy::encodePredMode(TComDataCU* cu, uint32_t absPartIdx)
-{
-    if (cu->getSlice()->isIntra())
-    {
-        return;
-    }
-
-    m_entropyCoder->codePredMode(cu, absPartIdx);
-}
-
-// Split mode
-void TEncEntropy::encodeSplitFlag(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth)
-{
-    m_entropyCoder->codeSplitFlag(cu, absPartIdx, depth);
-}
-


More information about the x265-commits mailing list