[x265] [PATCH] psyrdoq: implementation of psyrdoq

sumalatha at multicorewareinc.com sumalatha at multicorewareinc.com
Tue Jul 22 14:29:23 CEST 2014


# HG changeset patch
# User Sumalatha Polureddy<sumalatha at multicorewareinc.com>
# Date 1406032149 -19800
# Node ID 37e03dcd2e4f0b5894880ff8c097bd6e11590459
# Parent  d303b4d860e9f06396a156726dd518d0f41fe796
psyrdoq: implementation of psyrdoq

diff -r d303b4d860e9 -r 37e03dcd2e4f source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Mon Jul 21 22:43:38 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Tue Jul 22 17:59:09 2014 +0530
@@ -64,6 +64,8 @@
     return y + ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))); // min(x, y)
 }
 
+#define SIGN(x,y) ((x^(y >> 31))-(y >> 31))
+
 // ====================================================================================================================
 // TComTrQuant class member functions
 // ====================================================================================================================
@@ -307,6 +309,8 @@
 }
 
 uint32_t TComTrQuant::transformNxN(TComDataCU* cu,
+                                   pixel*      fenc,
+                                   uint32_t    fencStride,
                                    int16_t*    residual,
                                    uint32_t    stride,
                                    coeff_t*    coeff,
@@ -316,10 +320,10 @@
                                    bool        useTransformSkip,
                                    bool        curUseRDOQ)
 {
+    int trSize = 1 << log2TrSize;
     if (cu->getCUTransquantBypass(absPartIdx))
     {
         uint32_t numSig = 0;
-        int trSize = 1 << log2TrSize;
         for (int k = 0; k < trSize; k++)
         {
             for (int j = 0; j < trSize; j++)
@@ -339,6 +343,12 @@
         const uint32_t sizeIdx = log2TrSize - 2;
         int useDST = (sizeIdx == 0 && ttype == TEXT_LUMA && cu->getPredictionMode(absPartIdx) == MODE_INTRA);
         int index = DCT_4x4 + sizeIdx - useDST;
+        if (psyRdoqEnabled())
+        {
+            // converting pixel to int and putting in separate buffer to take dct
+            primitives.square_copy_ps[sizeIdx](m_tmpfencBuf, MAX_CU_SIZE, fenc, fencStride);
+            primitives.dct[index](m_tmpfencBuf, m_tmpfencCoeff, stride);
+        }
         primitives.dct[index](residual, m_tmpCoeff, stride);
         if (m_nr->bNoiseReduction)
         {
@@ -356,7 +366,7 @@
 
     if (m_useRDOQ && curUseRDOQ)
     {
-        return xRateDistOptQuant(cu, m_tmpCoeff, coeff, log2TrSize, ttype, absPartIdx);
+        return xRateDistOptQuant(cu, m_tmpfencCoeff, m_tmpCoeff, coeff, log2TrSize, ttype, absPartIdx);
     }
     return xQuant(cu, m_tmpCoeff, coeff, log2TrSize, ttype, absPartIdx);
 }
@@ -505,7 +515,7 @@
  * Rate distortion optimized quantization for entropy
  * coding engines using probability models like CABAC
  */
-uint32_t TComTrQuant::xRateDistOptQuant(TComDataCU* cu, int32_t* srcCoeff, coeff_t* dstCoeff, uint32_t log2TrSize,
+uint32_t TComTrQuant::xRateDistOptQuant(TComDataCU* cu, int32_t* fencCoeff, int32_t* srcCoeff, coeff_t* dstCoeff, uint32_t log2TrSize,
                                         TextType ttype, uint32_t absPartIdx)
 {
     uint32_t trSize = 1 << log2TrSize;
@@ -614,7 +624,7 @@
                 {
                     level = xGetCodedLevel(costCoeff[scanPos], curCostSig, costSig[scanPos],
                                            levelDouble, maxAbsLevel, baseLevel, greaterOneBits, levelAbsBits, goRiceParam,
-                                           c1c2Idx, qbits, scaleFactor, 1);
+                                           c1c2Idx, qbits, scaleFactor, 1, srcCoeff[blkPos], fencCoeff[blkPos]);
                     sigRateDelta[blkPos] = 0;
                 }
                 else
@@ -631,7 +641,7 @@
                         curCostSig = xGetRateSigCoef(1, ctxSig);
                         level = xGetCodedLevel(costCoeff[scanPos], curCostSig, costSig[scanPos],
                                                levelDouble, maxAbsLevel, baseLevel, greaterOneBits, levelAbsBits, goRiceParam,
-                                               c1c2Idx, qbits, scaleFactor, 0);
+                                               c1c2Idx, qbits, scaleFactor, 0, srcCoeff[blkPos], fencCoeff[blkPos]);
                     }
                     else
                     {
@@ -1126,7 +1136,9 @@
                                             uint32_t     c1c2Idx,
                                             int          qbits,
                                             double       scaleFactor,
-                                            bool         last) const
+                                            bool         last,
+                                            int          signCoef,
+                                            int          origCoef) const
 {
     uint32_t   bestAbsLevel = 0;
 
@@ -1155,7 +1167,18 @@
     for (int absLevel = maxAbsLevel; absLevel >= minAbsLevel; absLevel--)
     {
         X265_CHECK(fabs((double)err2 - double(levelDouble  - (absLevel << qbits)) * double(levelDouble  - (absLevel << qbits)) * scaleFactor) < 1e-5, "err2 check failure\n");
-        double curCost = err2 + xGetICRateCost(absLevel, diffLevel, greaterOneBits, levelAbsBits, absGoRice, c1c2Idx);
+        double curCost = 0;
+        if (psyRdoqEnabled())
+        {
+            int unquantAbsLevel = (maxAbsLevel << qbits);
+            int predictedCoef = origCoef - signCoef;
+            int psyValue = abs(unquantAbsLevel + SIGN(predictedCoef, signCoef)); // test with differnt cases to check whether SIGN is required
+            curCost = err2 + xGetICRateCost(absLevel, diffLevel, greaterOneBits, levelAbsBits, absGoRice, c1c2Idx) - (m_psyRdoqScale * psyValue * m_lambda);
+        }
+        else
+        {
+            curCost = err2 + xGetICRateCost(absLevel, diffLevel, greaterOneBits, levelAbsBits, absGoRice, c1c2Idx);
+        }
         curCost       += curCostSig;
 
         if (curCost < bestCodedCost)
diff -r d303b4d860e9 -r 37e03dcd2e4f source/Lib/TLibCommon/TComTrQuant.h
--- a/source/Lib/TLibCommon/TComTrQuant.h	Mon Jul 21 22:43:38 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.h	Tue Jul 22 17:59:09 2014 +0530
@@ -120,8 +120,18 @@
     // initialize class
     void init(bool useRDOQ);
 
+    void setPsyRdoqScale(double scale)
+    {
+        m_psyRdoqScale = scale;
+    }
+
+    inline bool psyRdoqEnabled() const
+    {
+        return m_psyRdoqScale != 0;
+    }
+
     // transform & inverse transform functions
-    uint32_t transformNxN(TComDataCU* cu, int16_t* residual, uint32_t stride, coeff_t* coeff, uint32_t log2TrSize,
+    uint32_t transformNxN(TComDataCU* cu, pixel* fenc, uint32_t fencStride, int16_t* residual, uint32_t stride, coeff_t* coeff, uint32_t log2TrSize,
                           TextType ttype, uint32_t absPartIdx, bool useTransformSkip = false, bool curUseRDOQ = true);
 
     void invtransformNxN(bool transQuantBypass, int16_t* residual, uint32_t stride, coeff_t* coeff, uint32_t log2TrSize, TextType ttype, bool bIntra, bool useTransformSkip, uint32_t numSig);
@@ -207,7 +217,11 @@
     bool     m_useRDOQ;
     bool     m_scalingListEnabledFlag;
 
-    int32_t* m_tmpCoeff;
+    double   m_psyRdoqScale;
+    int32_t* m_tmpCoeff; // tmp buffer which stores the dct of residual
+    int32_t  m_tmpfencCoeff[MAX_CU_SIZE * MAX_CU_SIZE]; // tmp buffer which stores the dct of orig pix buffer
+    int16_t m_tmpfencBuf[MAX_CU_SIZE * MAX_CU_SIZE]; // tmp buffer which stores short of orig pixel
+
     int32_t* m_quantCoef[ScalingList::NUM_SIZES][ScalingList::NUM_LISTS][ScalingList::NUM_REM];     ///< array of quantization matrix coefficient 4x4
     int32_t* m_dequantCoef[ScalingList::NUM_SIZES][ScalingList::NUM_LISTS][ScalingList::NUM_REM];   ///< array of dequantization matrix coefficient 4x4
 
@@ -221,11 +235,11 @@
     uint32_t xQuant(TComDataCU* cu, int32_t* src, coeff_t* dst, uint32_t log2TrSize, TextType ttype, uint32_t absPartIdx);
 
     // RDOQ functions
-    uint32_t xRateDistOptQuant(TComDataCU* cu, int32_t* srcCoeff, coeff_t* dstCoeff, uint32_t log2TrSize, TextType ttype, uint32_t absPartIdx);
+    uint32_t xRateDistOptQuant(TComDataCU* cu, int32_t* fencCoeff, int32_t* srcCoeff, coeff_t* dstCoeff, uint32_t log2TrSize, TextType ttype, uint32_t absPartIdx);
 
     inline uint32_t xGetCodedLevel(double& codedCost, const double curCostSig, double& codedCostSig, int levelDouble,
                                    uint32_t maxAbsLevel, uint32_t baseLevel, const int *greaterOneBits, const int *levelAbsBits, uint32_t absGoRice,
-                                   uint32_t c1c2Idx, int qbits, double scale, bool bLast) const;
+                                   uint32_t c1c2Idx, int qbits, double scale, bool bLast, int sign_coef, int orig_coef) const;
 
     inline double xGetICRateCost(uint32_t absLevel, int32_t  diffLevel, const int *greaterOneBits, const int *levelAbsBits, uint32_t absGoRice, uint32_t c1c2Idx) const;
 
diff -r d303b4d860e9 -r 37e03dcd2e4f source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Jul 21 22:43:38 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Tue Jul 22 17:59:09 2014 +0530
@@ -438,7 +438,7 @@
         m_entropyCoder->estBit(m_trQuant.m_estBitsSbac, log2TrSize, TEXT_LUMA);
 
     //--- transform and quantization ---
-    uint32_t numSig = m_trQuant.transformNxN(cu, residual, stride, coeff, log2TrSize, TEXT_LUMA, absPartIdx, useTransformSkip);
+    uint32_t numSig = m_trQuant.transformNxN(cu, fenc, stride, residual, stride, coeff, log2TrSize, TEXT_LUMA, absPartIdx, useTransformSkip);
 
     //--- set coded block flag ---
     cbf = numSig ? 1 : 0;
@@ -507,7 +507,7 @@
         m_entropyCoder->estBit(m_trQuant.m_estBitsSbac, log2TrSizeC, TEXT_CHROMA);
 
     //--- transform and quantization ---
-    uint32_t numSig = m_trQuant.transformNxN(cu, residual, stride, coeff, log2TrSizeC, ttype, absPartIdx, useTransformSkipC);
+    uint32_t numSig = m_trQuant.transformNxN(cu, fenc, stride, residual, stride, coeff, log2TrSizeC, ttype, absPartIdx, useTransformSkipC);
 
     //--- set coded block flag ---
     cbf = numSig ? 1 : 0;
@@ -865,7 +865,7 @@
         primitives.calcresidual[sizeIdx](fenc, pred, residual, stride);
 
         //===== transform and quantization =====
-        uint32_t numSig = m_trQuant.transformNxN(cu, residual, stride, coeff, log2TrSize, TEXT_LUMA, absPartIdx, useTransformSkip);
+        uint32_t numSig = m_trQuant.transformNxN(cu, fenc, stride, residual, stride, coeff, log2TrSize, TEXT_LUMA, absPartIdx, useTransformSkip);
 
         //--- set coded block flag ---
         cu->setCbfSubParts((numSig ? 1 : 0) << trDepth, TEXT_LUMA, absPartIdx, fullDepth);
@@ -1336,7 +1336,7 @@
                 primitives.calcresidual[sizeIdxC](fenc, pred, residual, stride);
 
                 //--- transform and quantization ---
-                uint32_t numSig = m_trQuant.transformNxN(cu, residual, stride, coeff, log2TrSizeC, ttype, absPartIdxC, useTransformSkipC);
+                uint32_t numSig = m_trQuant.transformNxN(cu, fenc, stride, residual, stride, coeff, log2TrSizeC, ttype, absPartIdxC, useTransformSkipC);
 
                 //--- set coded block flag ---
                 cu->setCbfPartRange((((numSig > 0) ? 1 : 0) << trDepth), ttype, absPartIdxC, tuIterator.absPartIdxStep);
@@ -2466,7 +2466,7 @@
 
     if (cu->getPredictionMode(0) == MODE_INTER)
     {
-        residualTransformQuantInter(cu, 0, resiYuv, cu->getDepth(0), true);
+        residualTransformQuantInter(cu, 0, fencYuv, resiYuv, cu->getDepth(0), true);
         uint32_t cuSize = 1 << cu->getLog2CUSize(0);
         if (cu->getQtRootCbf(0))
             reconYuv->addClip(predYuv, resiYuv, cuSize);
@@ -2486,7 +2486,7 @@
     }
 }
 
-void TEncSearch::residualTransformQuantInter(TComDataCU* cu, uint32_t absPartIdx, ShortYuv* resiYuv, const uint32_t depth, bool curuseRDOQ)
+void TEncSearch::residualTransformQuantInter(TComDataCU* cu, uint32_t absPartIdx, TComYuv* fencYuv, ShortYuv* resiYuv, const uint32_t depth, bool curuseRDOQ)
 {
     X265_CHECK(cu->getDepth(0) == cu->getDepth(absPartIdx), "invalid depth\n");
     const uint32_t trMode = depth - cu->getDepth(0);
@@ -2536,7 +2536,7 @@
         const uint32_t strideResiY = resiYuv->m_width;
         const uint32_t strideResiC = resiYuv->m_cwidth;
 
-        uint32_t numSigY = m_trQuant.transformNxN(cu, curResiY, strideResiY, coeffCurY,
+        uint32_t numSigY = m_trQuant.transformNxN(cu, fencYuv->getLumaAddr(absPartIdx), fencYuv->getStride(), curResiY, strideResiY, coeffCurY,
                                                   log2TrSize, TEXT_LUMA, absPartIdx, false, curuseRDOQ);
 
         cu->setCbfSubParts(numSigY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);
@@ -2561,9 +2561,9 @@
                 cu->setTransformSkipPartRange(0, TEXT_CHROMA_U, absPartIdxC, tuIterator.absPartIdxStep);
                 cu->setTransformSkipPartRange(0, TEXT_CHROMA_V, absPartIdxC, tuIterator.absPartIdxStep);
 
-                uint32_t numSigU = m_trQuant.transformNxN(cu, curResiU, strideResiC, coeffCurU + subTUOffset,
+                uint32_t numSigU = m_trQuant.transformNxN(cu, fencYuv->getCbAddr(absPartIdxC), fencYuv->getCStride(), curResiU, strideResiC, coeffCurU + subTUOffset,
                                                           log2TrSizeC, TEXT_CHROMA_U, absPartIdxC, false, curuseRDOQ);
-                uint32_t numSigV = m_trQuant.transformNxN(cu, curResiV, strideResiC, coeffCurV + subTUOffset,
+                uint32_t numSigV = m_trQuant.transformNxN(cu, fencYuv->getCrAddr(absPartIdxC), fencYuv->getCStride(), curResiV, strideResiC, coeffCurV + subTUOffset,
                                                           log2TrSizeC, TEXT_CHROMA_V, absPartIdxC, false, curuseRDOQ);
 
                 cu->setCbfPartRange(numSigU ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.absPartIdxStep);
@@ -2595,7 +2595,7 @@
     {
         const uint32_t qPartNumSubdiv = cu->m_pic->getNumPartInCU() >> ((depth + 1) << 1);
         for (uint32_t i = 0; i < 4; ++i)
-            residualTransformQuantInter(cu, absPartIdx + i * qPartNumSubdiv, resiYuv, depth + 1, curuseRDOQ);
+            residualTransformQuantInter(cu, absPartIdx + i * qPartNumSubdiv, fencYuv, resiYuv, depth + 1, curuseRDOQ);
 
         uint32_t ycbf = 0;
         uint32_t ucbf = 0;
@@ -2700,7 +2700,7 @@
         if (m_bEnableRDOQ && curuseRDOQ)
             m_entropyCoder->estBit(m_trQuant.m_estBitsSbac, log2TrSize, TEXT_LUMA);
 
-        numSigY = m_trQuant.transformNxN(cu, resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, coeffCurY,
+        numSigY = m_trQuant.transformNxN(cu, fencYuv->getLumaAddr(absPartIdx), fencYuv->getStride(), resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, coeffCurY,
                                          log2TrSize, TEXT_LUMA, absPartIdx, false, curuseRDOQ);
 
         cu->setCbfSubParts(numSigY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);
@@ -2728,9 +2728,9 @@
                 if (m_bEnableRDOQ && curuseRDOQ)
                     m_entropyCoder->estBit(m_trQuant.m_estBitsSbac, log2TrSizeC, TEXT_CHROMA);
 
-                numSigU[tuIterator.section] = m_trQuant.transformNxN(cu, resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurU + subTUOffset,
+                numSigU[tuIterator.section] = m_trQuant.transformNxN(cu, fencYuv->getCbAddr(absPartIdxC), fencYuv->getCStride(), resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurU + subTUOffset,
                                                                      log2TrSizeC, TEXT_CHROMA_U, absPartIdxC, false, curuseRDOQ);
-                numSigV[tuIterator.section] = m_trQuant.transformNxN(cu, resiYuv->getCrAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurV + subTUOffset,
+                numSigV[tuIterator.section] = m_trQuant.transformNxN(cu, fencYuv->getCrAddr(absPartIdxC), fencYuv->getCStride(), resiYuv->getCrAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurV + subTUOffset,
                                                                      log2TrSizeC, TEXT_CHROMA_V, absPartIdxC, false, curuseRDOQ);
 
                 cu->setCbfPartRange(numSigU[tuIterator.section] ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.absPartIdxStep);
@@ -3059,7 +3059,7 @@
             if (m_bEnableRDOQ)
                 m_entropyCoder->estBit(m_trQuant.m_estBitsSbac, log2TrSize, TEXT_LUMA);
 
-            uint32_t numSigTSkipY = m_trQuant.transformNxN(cu, resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, tsCoeffY,
+            uint32_t numSigTSkipY = m_trQuant.transformNxN(cu, fencYuv->getLumaAddr(absPartIdx), fencYuv->getStride(), resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, tsCoeffY,
                                                            log2TrSize, TEXT_LUMA, absPartIdx, true, curuseRDOQ);
             cu->setCbfSubParts(numSigTSkipY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);
 
@@ -3140,9 +3140,9 @@
                 if (m_bEnableRDOQ)
                     m_entropyCoder->estBit(m_trQuant.m_estBitsSbac, log2TrSizeC, TEXT_CHROMA);
 
-                uint32_t numSigTSkipU = m_trQuant.transformNxN(cu, resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, tsCoeffU,
+                uint32_t numSigTSkipU = m_trQuant.transformNxN(cu, fencYuv->getCbAddr(absPartIdxC), fencYuv->getCStride(), resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, tsCoeffU,
                                                                log2TrSizeC, TEXT_CHROMA_U, absPartIdxC, true, curuseRDOQ);
-                uint32_t numSigTSkipV = m_trQuant.transformNxN(cu, resiYuv->getCrAddr(absPartIdxC), resiYuv->m_cwidth, tsCoeffV,
+                uint32_t numSigTSkipV = m_trQuant.transformNxN(cu, fencYuv->getCrAddr(absPartIdxC), fencYuv->getCStride(), resiYuv->getCrAddr(absPartIdxC), resiYuv->m_cwidth, tsCoeffV,
                                                                log2TrSizeC, TEXT_CHROMA_V, absPartIdxC, true, curuseRDOQ);
 
                 cu->setCbfPartRange(numSigTSkipU ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.absPartIdxStep);
diff -r d303b4d860e9 -r 37e03dcd2e4f source/Lib/TLibEncoder/TEncSearch.h
--- a/source/Lib/TLibEncoder/TEncSearch.h	Mon Jul 21 22:43:38 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.h	Tue Jul 22 17:59:09 2014 +0530
@@ -164,7 +164,7 @@
                              uint64_t &rdCost, uint32_t &outBits, uint32_t &outDist, uint32_t *puiZeroDist, bool curUseRDOQ = true);
     void xSetResidualQTData(TComDataCU* cu, uint32_t absPartIdx, ShortYuv* resiYuv, uint32_t depth, bool bSpatial);
 
-    void residualTransformQuantInter(TComDataCU* cu, uint32_t absPartIdx, ShortYuv* resiYuv, uint32_t depth, bool curUseRDOQ = true);
+    void residualTransformQuantInter(TComDataCU* cu, uint32_t absPartIdx, TComYuv* fencYuv, ShortYuv* resiYuv, uint32_t depth, bool curUseRDOQ = true);
 
     // -------------------------------------------------------------------------------------------------------------------
     // compute symbol bits
diff -r d303b4d860e9 -r 37e03dcd2e4f source/common/param.cpp
--- a/source/common/param.cpp	Mon Jul 21 22:43:38 2014 -0500
+++ b/source/common/param.cpp	Tue Jul 22 17:59:09 2014 +0530
@@ -163,6 +163,7 @@
     param->crQpOffset = 0;
     param->rdPenalty = 0;
     param->psyRd = 0.0;
+    param->psyRdoq = 0.5;
     param->bIntraInBFrames = 1;
     param->bLossless = 0;
     param->bCULossless = 0;
@@ -413,11 +414,13 @@
         {
             param->rc.aqStrength = 0.0;
             param->psyRd = 0.0;
+            param->psyRdoq = 0.0;
         }
         else if (!strcmp(tune, "ssim"))
         {
             param->rc.aqMode = X265_AQ_AUTO_VARIANCE;
             param->psyRd = 0.0;
+            param->psyRdoq = 0.0;
         }
         else if (!strcmp(tune, "fastdecode") ||
                  !strcmp(tune, "fast-decode"))
diff -r d303b4d860e9 -r 37e03dcd2e4f source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Mon Jul 21 22:43:38 2014 -0500
+++ b/source/encoder/analysis.cpp	Tue Jul 22 17:59:09 2014 +0530
@@ -49,6 +49,7 @@
 {
     m_param = top->m_param;
     m_trQuant.init(top->m_bEnableRDOQ);
+    m_trQuant.setPsyRdoqScale(top->m_param->psyRdoq);
 
     if (!top->m_scalingList.m_bEnabled)
     {
@@ -1874,7 +1875,7 @@
             primitives.chroma[m_param->internalCsp].sub_ps[part](dst, dststride, src1, src2, src1stride, src2stride);
 
             // Residual encoding
-            residualTransformQuantInter(cu, 0, m_tmpResiYuv[depth], cu->getDepth(0), true);
+            residualTransformQuantInter(cu, 0, m_origYuv[0], m_tmpResiYuv[depth], cu->getDepth(0), true);
             checkDQP(cu);
 
             if (lcu->getMergeFlag(absPartIdx) && cu->getPartitionSize(0) == SIZE_2Nx2N && !cu->getQtRootCbf(0))
diff -r d303b4d860e9 -r 37e03dcd2e4f source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Mon Jul 21 22:43:38 2014 -0500
+++ b/source/encoder/encoder.cpp	Tue Jul 22 17:59:09 2014 +0530
@@ -1296,8 +1296,17 @@
         p->crQpOffset += 6;
     }
 
-    // disable RDOQ if psy-rd is enabled; until we make it psy-aware
-    m_bEnableRDOQ = p->psyRd == 0.0 && p->rdLevel >= 4;
+    // disable RDOQ when rdlevel < 4
+    // disable RDOQ when psyrd is enabled and psyrdoq is disabled
+    if (p->rdLevel >= 4)
+    {
+        if (p->psyRd && !p->psyRdoq)
+            m_bEnableRDOQ = 0;
+        else
+            m_bEnableRDOQ = 1;
+    }
+    else
+        m_bEnableRDOQ = 0;
 
     if (p->bLossless)
     {
diff -r d303b4d860e9 -r 37e03dcd2e4f source/x265.h
--- a/source/x265.h	Mon Jul 21 22:43:38 2014 -0500
+++ b/source/x265.h	Tue Jul 22 17:59:09 2014 +0530
@@ -613,6 +613,10 @@
      * energy of the source, at the cost of lost compression. Default 0.0 */
     double    psyRd;
 
+    /* Psycho-visual rate-distortion opt quantize strength. Only has an effect in presets
+    * which use RDOQ. Default 0.0 */
+    double    psyRdoq;
+
     /*== Coding tools ==*/
 
     /* Enable the implicit signaling of the sign bit of the last coefficient of


More information about the x265-devel mailing list