changeset 4825:91d96a6038e2

RDOQ : pass a parameter to temporarily disable RDOQ. default value of parameter is true, that means RDOQ is not disabled. Outputs mustnot change in any rd levels.
author Deepthi Devaki <deepthidevaki@multicorewareinc.com>
date Mon, 04 Nov 2013 15:23:10 +0530
parents 37903c6fd1f9
children 6e211f980d98
files source/Lib/TLibCommon/TComTrQuant.cpp source/Lib/TLibCommon/TComTrQuant.h source/Lib/TLibEncoder/TEncSearch.cpp source/Lib/TLibEncoder/TEncSearch.h
diffstat 4 files changed, 37 insertions(+-), 35 deletions(-) [+]
line wrap: on
line diff
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Mon Nov 04 12:09:06 2013 +0530
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Mon Nov 04 15:23:10 2013 +0530
@@ -253,11 +253,11 @@ void TComTrQuant::signBitHidingHDQ(TCoef
 }
 
 uint32_t TComTrQuant::xQuant(TComDataCU* cu, int32_t* coef, TCoeff* qCoef, int width, int height,
-                         TextType ttype, uint32_t absPartIdx, int32_t *lastPos)
+                             TextType ttype, uint32_t absPartIdx, int32_t *lastPos, bool curUseRDOQ)
 {
     uint32_t acSum = 0;
     int add = 0;
-    bool useRDOQ = cu->getTransformSkip(absPartIdx, ttype) ? m_useRDOQTS : m_useRDOQ;
+    bool useRDOQ = (cu->getTransformSkip(absPartIdx, ttype) ? m_useRDOQTS : m_useRDOQ) && curUseRDOQ;
 
     assert(width == height);
 
@@ -339,15 +339,16 @@ void TComTrQuant::init(uint32_t maxTrSiz
 }
 
 uint32_t TComTrQuant::transformNxN(TComDataCU* cu,
-                               int16_t*      residual,
-                               uint32_t        stride,
-                               TCoeff*     coeff,
-                               uint32_t        width,
-                               uint32_t        height,
-                               TextType    ttype,
-                               uint32_t        absPartIdx,
-                               int32_t*        lastPos,
-                               bool        useTransformSkip)
+                                   int16_t*    residual,
+                                   uint32_t    stride,
+                                   TCoeff*     coeff,
+                                   uint32_t    width,
+                                   uint32_t    height,
+                                   TextType    ttype,
+                                   uint32_t    absPartIdx,
+                                   int32_t*    lastPos,
+                                   bool        useTransformSkip,
+                                   bool        curUseRDOQ)
 {
     if (cu->getCUTransquantBypass(absPartIdx))
     {
@@ -385,7 +386,7 @@ uint32_t TComTrQuant::transformNxN(TComD
         const uint32_t log2BlockSize = g_convertToBit[width];
         primitives.dct[DCT_4x4 + log2BlockSize - ((width == 4) && (mode != REG_DCT))](residual, m_tmpCoeff, stride);
     }
-    return xQuant(cu, m_tmpCoeff, coeff, width, height, ttype, absPartIdx, lastPos);
+    return xQuant(cu, m_tmpCoeff, coeff, width, height, ttype, absPartIdx, lastPos, curUseRDOQ);
 }
 
 void TComTrQuant::invtransformNxN(bool transQuantBypass, uint32_t mode, int16_t* residual, uint32_t stride, TCoeff* coeff, uint32_t width, uint32_t height, int scalingListType, bool useTransformSkip, int lastPos)
--- a/source/Lib/TLibCommon/TComTrQuant.h	Mon Nov 04 12:09:06 2013 +0530
+++ b/source/Lib/TLibCommon/TComTrQuant.h	Mon Nov 04 15:23:10 2013 +0530
@@ -128,7 +128,7 @@ public:
 
     // transform & inverse transform functions
     uint32_t transformNxN(TComDataCU* cu, int16_t* residual, uint32_t stride, TCoeff* coeff, uint32_t width, uint32_t height,
-                      TextType ttype, uint32_t absPartIdx, int32_t* lastPos, bool useTransformSkip = false);
+                          TextType ttype, uint32_t absPartIdx, int32_t* lastPos, bool useTransformSkip = false, bool curUseRDOQ = true);
 
     void invtransformNxN(bool transQuantBypass, uint32_t mode, int16_t* residual, uint32_t stride, TCoeff* coeff, uint32_t width, uint32_t height, int scalingListType, bool useTransformSkip = false, int lastPos = MAX_INT);
 
@@ -194,7 +194,7 @@ private:
 
     void signBitHidingHDQ(TCoeff* qcoeff, TCoeff* coeff, const uint32_t* scan, int32_t* deltaU, int width, int height);
 
-    uint32_t xQuant(TComDataCU* cu, int32_t* src, TCoeff* dst, int width, int height, TextType ttype, uint32_t absPartIdx, int32_t *lastPos);
+    uint32_t xQuant(TComDataCU* cu, int32_t* src, TCoeff* dst, int width, int height, TextType ttype, uint32_t absPartIdx, int32_t *lastPos, bool curUseRDOQ = true);
 
     // RDOQ functions
     uint32_t xRateDistOptQuant(TComDataCU* cu, int32_t* srcCoeff, TCoeff* dstCoeff, uint32_t width, uint32_t height, TextType ttype, uint32_t absPartIdx, int32_t *lastPos);
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Nov 04 12:09:06 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Nov 04 15:23:10 2013 +0530
@@ -2773,7 +2773,7 @@ void TEncSearch::xSetSearchRange(TComDat
  * \returns void
  */
 void TEncSearch::encodeResAndCalcRdInterCU(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv, TShortYUV* outResiYuv,
-                                           TShortYUV* outBestResiYuv, TComYuv* outReconYuv, bool bSkipRes)
+                                           TShortYUV* outBestResiYuv, TComYuv* outReconYuv, bool bSkipRes, bool curUseRDOQ)
 {
     if (cu->isIntra(0))
     {
@@ -2854,7 +2854,7 @@ void TEncSearch::encodeResAndCalcRdInter
     m_rdGoOnSbacCoder->load(m_rdSbacCoders[cu->getDepth(0)][CI_CURR_BEST]);
 
     uint32_t zeroDistortion = 0;
-    xEstimateResidualQT(cu, 0, 0, outResiYuv, cu->getDepth(0), cost, bits, distortion, &zeroDistortion);
+    xEstimateResidualQT(cu, 0, 0, outResiYuv, cu->getDepth(0), cost, bits, distortion, &zeroDistortion, curUseRDOQ);
 
     m_entropyCoder->resetBits();
     m_entropyCoder->encodeQtRootCbfZero(cu);
@@ -2939,15 +2939,16 @@ void TEncSearch::encodeResAndCalcRdInter
 #pragma warning(disable: 4701) // potentially uninitialized local variable
 #endif
 
-void TEncSearch::xEstimateResidualQT(TComDataCU* cu,
-                                     uint32_t        absPartIdx,
-                                     uint32_t        absTUPartIdx,
-                                     TShortYUV*  resiYuv,
-                                     const uint32_t  depth,
-                                     UInt64 &    rdCost,
-                                     uint32_t &      outBits,
-                                     uint32_t &      outDist,
-                                     uint32_t *      outZeroDist)
+void TEncSearch::xEstimateResidualQT(TComDataCU*    cu,
+                                     uint32_t       absPartIdx,
+                                     uint32_t       absTUPartIdx,
+                                     TShortYUV*     resiYuv,
+                                     const uint32_t depth,
+                                     UInt64 &       rdCost,
+                                     uint32_t &     outBits,
+                                     uint32_t &     outDist,
+                                     uint32_t *     outZeroDist,
+                                     bool           curuseRDOQ)
 {
     assert(cu->getDepth(0) == cu->getDepth(absPartIdx));
     const uint32_t trMode = depth - cu->getDepth(0);
@@ -3014,7 +3015,7 @@ void TEncSearch::xEstimateResidualQT(TCo
             cu->setTransformSkipSubParts(0, TEXT_CHROMA_V, absPartIdx, cu->getDepth(0) + trModeC);
         }
 
-        if (m_cfg->param.bEnableRDOQ)
+        if (m_cfg->param.bEnableRDOQ && curuseRDOQ)
         {
             m_entropyCoder->estimateBit(m_trQuant->m_estBitsSbac, trWidth, trHeight, TEXT_LUMA);
         }
@@ -3023,13 +3024,13 @@ void TEncSearch::xEstimateResidualQT(TCo
         m_trQuant->selectLambda(TEXT_LUMA);
 
         absSumY = m_trQuant->transformNxN(cu, resiYuv->getLumaAddr(absTUPartIdx), resiYuv->m_width, coeffCurY,
-                                          trWidth, trHeight, TEXT_LUMA, absPartIdx, &lastPosY);
+                                          trWidth, trHeight, TEXT_LUMA, absPartIdx, &lastPosY, false, curuseRDOQ);
 
         cu->setCbfSubParts(absSumY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);
 
         if (bCodeChroma)
         {
-            if (m_cfg->param.bEnableRDOQ)
+            if (m_cfg->param.bEnableRDOQ && curuseRDOQ)
             {
                 m_entropyCoder->estimateBit(m_trQuant->m_estBitsSbac, trWidthC, trHeightC, TEXT_CHROMA);
             }
@@ -3040,12 +3041,12 @@ void TEncSearch::xEstimateResidualQT(TCo
             m_trQuant->selectLambda(TEXT_CHROMA);
 
             absSumU = m_trQuant->transformNxN(cu, resiYuv->getCbAddr(absTUPartIdxC), resiYuv->m_cwidth, coeffCurU,
-                                              trWidthC, trHeightC, TEXT_CHROMA_U, absPartIdx, &lastPosU);
+                                              trWidthC, trHeightC, TEXT_CHROMA_U, absPartIdx, &lastPosU, false, curuseRDOQ);
 
             curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();
             m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset);
             absSumV = m_trQuant->transformNxN(cu, resiYuv->getCrAddr(absTUPartIdxC), resiYuv->m_cwidth, coeffCurV,
-                                              trWidthC, trHeightC, TEXT_CHROMA_V, absPartIdx, &lastPosV);
+                                              trWidthC, trHeightC, TEXT_CHROMA_V, absPartIdx, &lastPosV, false, curuseRDOQ);
 
             cu->setCbfSubParts(absSumU ? setCbf : 0, TEXT_CHROMA_U, absPartIdx, cu->getDepth(0) + trModeC);
             cu->setCbfSubParts(absSumV ? setCbf : 0, TEXT_CHROMA_V, absPartIdx, cu->getDepth(0) + trModeC);
@@ -3318,7 +3319,7 @@ void TEncSearch::xEstimateResidualQT(TCo
 
             m_trQuant->selectLambda(TEXT_LUMA);
             absSumTransformSkipY = m_trQuant->transformNxN(cu, resiYuv->getLumaAddr(absTUPartIdx), resiYuv->m_width, coeffCurY,
-                                                           trWidth, trHeight, TEXT_LUMA, absPartIdx, &lastPosTransformSkipY, true);
+                                                           trWidth, trHeight, TEXT_LUMA, absPartIdx, &lastPosTransformSkipY, true, curuseRDOQ);
             cu->setCbfSubParts(absSumTransformSkipY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);
 
             if (absSumTransformSkipY != 0)
@@ -3398,11 +3399,11 @@ void TEncSearch::xEstimateResidualQT(TCo
             m_trQuant->selectLambda(TEXT_CHROMA);
 
             absSumTransformSkipU = m_trQuant->transformNxN(cu, resiYuv->getCbAddr(absTUPartIdxC), resiYuv->m_cwidth, coeffCurU,
-                                                           trWidthC, trHeightC, TEXT_CHROMA_U, absPartIdx, &lastPosTransformSkipU, true);
+                                                           trWidthC, trHeightC, TEXT_CHROMA_U, absPartIdx, &lastPosTransformSkipU, true, curuseRDOQ);
             curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();
             m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset);
             absSumTransformSkipV = m_trQuant->transformNxN(cu, resiYuv->getCrAddr(absTUPartIdxC), resiYuv->m_cwidth, coeffCurV,
-                                                           trWidthC, trHeightC, TEXT_CHROMA_V, absPartIdx, &lastPosTransformSkipV, true);
+                                                           trWidthC, trHeightC, TEXT_CHROMA_V, absPartIdx, &lastPosTransformSkipV, true, curuseRDOQ);
 
             cu->setCbfSubParts(absSumTransformSkipU ? setCbf : 0, TEXT_CHROMA_U, absPartIdx, cu->getDepth(0) + trModeC);
             cu->setCbfSubParts(absSumTransformSkipV ? setCbf : 0, TEXT_CHROMA_V, absPartIdx, cu->getDepth(0) + trModeC);
--- a/source/Lib/TLibEncoder/TEncSearch.h	Mon Nov 04 12:09:06 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.h	Mon Nov 04 15:23:10 2013 +0530
@@ -147,7 +147,7 @@ public:
 
     /// encode residual and compute rd-cost for inter mode
     void encodeResAndCalcRdInterCU(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv, TShortYUV* resiYuv, TShortYUV* bestResiYuv,
-                                   TComYuv* reconYuv, bool bSkipRes);
+                                   TComYuv* reconYuv, bool bSkipRes, bool curUseRDOQ = true);
 
     /// set ME search range
     void setAdaptiveSearchRange(int dir, int refIdx, int merange) { m_adaptiveRange[dir][refIdx] = merange; }
@@ -235,7 +235,7 @@ protected:
 
     void xEncodeResidualQT(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool bSubdivAndCbf, TextType ttype);
     void xEstimateResidualQT(TComDataCU* cu, uint32_t absPartIdx, uint32_t absTUPartIdx, TShortYUV* resiYuv, uint32_t depth,
-                             UInt64 &rdCost, uint32_t &outBits, uint32_t &outDist, uint32_t *puiZeroDist);
+                             UInt64 &rdCost, uint32_t &outBits, uint32_t &outDist, uint32_t *puiZeroDist, bool curUseRDOQ = true);
     void xSetResidualQTData(TComDataCU* cu, uint32_t absPartIdx, uint32_t absTUPartIdx, TShortYUV* resiYuv, uint32_t depth, bool bSpatial);
 
     void setWpScalingDistParam(TComDataCU* cu, int refIdx, int picList);