[x265] [PATCH RFC] psyrdoq: implementation of psyrdoq
sumalatha at multicorewareinc.com
sumalatha at multicorewareinc.com
Fri Jul 18 14:18:15 CEST 2014
# HG changeset patch
# User Sumalatha Polureddy<sumalatha at multicorewareinc.com>
# Date 1405685461 -19800
# Node ID 2e9fd3bd970e2dd286bade400580dcd9102da304
# Parent eef6867b9c53b4b9dad639ba9b68c81666abe37a
psyrdoq: implementation of psyrdoq
diff -r eef6867b9c53 -r 2e9fd3bd970e source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp Fri Jul 18 02:19:55 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp Fri Jul 18 17:41:01 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
// ====================================================================================================================
@@ -74,7 +76,9 @@
// allocate temporary buffers
// OPT_ME: I may reduce this to short and output matched, but I am not sure it is right.
- m_tmpCoeff = X265_MALLOC(int32_t, MAX_CU_SIZE * MAX_CU_SIZE);
+ m_tmpCoeff = X265_MALLOC(int32_t, MAX_CU_SIZE * MAX_CU_SIZE);
+ m_tmpfencCoeff = X265_MALLOC(int32_t, MAX_CU_SIZE * MAX_CU_SIZE);
+ m_tmpfencBuf = X265_MALLOC(int16_t, MAX_CU_SIZE * MAX_CU_SIZE);
// allocate bit estimation class (for RDOQ)
m_estBitsSbac = new EstBitsSbac;
@@ -88,6 +92,14 @@
{
X265_FREE(m_tmpCoeff);
}
+ if (m_tmpfencCoeff)
+ {
+ X265_FREE(m_tmpfencCoeff);
+ }
+ if (m_tmpfencBuf)
+ {
+ X265_FREE(m_tmpfencBuf);
+ }
// delete bit estimation class
delete m_estBitsSbac;
@@ -302,6 +314,8 @@
}
uint32_t TComTrQuant::transformNxN(TComDataCU* cu,
+ pixel* fenc,
+ uint32_t fencStride,
int16_t* residual,
uint32_t stride,
coeff_t* coeff,
@@ -311,10 +325,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++)
@@ -334,6 +348,18 @@
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
+ for (int y = 0; y < trSize; y++)
+ {
+ for (int x = 0; x < trSize; x++)
+ {
+ m_tmpfencBuf[(y*fencStride) + x] = (int16_t)fenc[(y*fencStride) + x];
+ }
+ }
+ primitives.dct[index](m_tmpfencBuf, m_tmpfencCoeff, stride);
+ }
primitives.dct[index](residual, m_tmpCoeff, stride);
if (m_nr->bNoiseReduction)
{
@@ -351,7 +377,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);
}
@@ -500,7 +526,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;
@@ -607,7 +633,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
@@ -624,7 +650,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
{
@@ -1119,7 +1145,9 @@
uint32_t c1c2Idx,
int qbits,
double scaleFactor,
- bool last) const
+ bool last,
+ int signCoef,
+ int origCoef) const
{
uint32_t bestAbsLevel = 0;
@@ -1148,7 +1176,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));
+ 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 eef6867b9c53 -r 2e9fd3bd970e source/Lib/TLibCommon/TComTrQuant.h
--- a/source/Lib/TLibCommon/TComTrQuant.h Fri Jul 18 02:19:55 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.h Fri Jul 18 17:41:01 2014 +0530
@@ -127,8 +127,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);
@@ -212,7 +222,10 @@
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; // tmp buffer which stores the dct of orig pix buffer
+ int16_t* m_tmpfencBuf; // 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
@@ -226,11 +239,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 eef6867b9c53 -r 2e9fd3bd970e source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Fri Jul 18 02:19:55 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Fri Jul 18 17:41:01 2014 +0530
@@ -440,7 +440,7 @@
//--- transform and quantization ---
int chFmt = cu->getChromaFormat();
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);
- 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;
@@ -513,7 +513,7 @@
int curChromaQpOffset = (ttype == TEXT_CHROMA_U) ? cu->m_slice->m_pps->chromaCbQpOffset : cu->m_slice->m_pps->chromaCrQpOffset;
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_CHROMA, QP_BD_OFFSET, curChromaQpOffset, chFmt);
- 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;
@@ -873,7 +873,7 @@
//===== transform and quantization =====
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);
- 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);
@@ -1346,7 +1346,7 @@
//--- transform and quantization ---
int curChromaQpOffset = (ttype == TEXT_CHROMA_U) ? cu->m_slice->m_pps->chromaCbQpOffset : cu->m_slice->m_pps->chromaCrQpOffset;
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_CHROMA, QP_BD_OFFSET, curChromaQpOffset, chFmt);
- 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);
@@ -2471,7 +2471,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);
@@ -2491,7 +2491,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);
@@ -2542,7 +2542,7 @@
const uint32_t strideResiC = resiYuv->m_cwidth;
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);
- 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);
@@ -2572,12 +2572,12 @@
int curChromaQpOffset = cu->m_slice->m_pps->chromaCbQpOffset;
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_CHROMA, QP_BD_OFFSET, curChromaQpOffset, chFmt);
- 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);
curChromaQpOffset = cu->m_slice->m_pps->chromaCrQpOffset;
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_CHROMA, QP_BD_OFFSET, curChromaQpOffset, chFmt);
- 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);
@@ -2617,7 +2617,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;
@@ -2723,7 +2723,7 @@
m_sbacCoder->estBit(m_trQuant.m_estBitsSbac, log2TrSize, TEXT_LUMA);
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);
- 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);
@@ -2754,12 +2754,12 @@
//Cb transform
int curChromaQpOffset = cu->m_slice->m_pps->chromaCbQpOffset;
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_CHROMA, QP_BD_OFFSET, curChromaQpOffset, chFmt);
- 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);
//Cr transform
curChromaQpOffset = cu->m_slice->m_pps->chromaCrQpOffset;
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_CHROMA, QP_BD_OFFSET, curChromaQpOffset, chFmt);
- 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);
@@ -3095,7 +3095,7 @@
m_sbacCoder->estBit(m_trQuant.m_estBitsSbac, log2TrSize, TEXT_LUMA);
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);
- 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);
@@ -3179,11 +3179,11 @@
int curChromaQpOffset = cu->m_slice->m_pps->chromaCbQpOffset;
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_CHROMA, QP_BD_OFFSET, curChromaQpOffset, chFmt);
- 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);
curChromaQpOffset = cu->m_slice->m_pps->chromaCrQpOffset;
m_trQuant.setQPforQuant(cu->getQP(0), TEXT_CHROMA, QP_BD_OFFSET, curChromaQpOffset, chFmt);
- 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 eef6867b9c53 -r 2e9fd3bd970e source/Lib/TLibEncoder/TEncSearch.h
--- a/source/Lib/TLibEncoder/TEncSearch.h Fri Jul 18 02:19:55 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.h Fri Jul 18 17:41:01 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 eef6867b9c53 -r 2e9fd3bd970e source/common/param.cpp
--- a/source/common/param.cpp Fri Jul 18 02:19:55 2014 -0500
+++ b/source/common/param.cpp Fri Jul 18 17:41:01 2014 +0530
@@ -162,7 +162,8 @@
param->cbQpOffset = 0;
param->crQpOffset = 0;
param->rdPenalty = 0;
- param->psyRd = 0.0;
+ param->psyRd = 0.5;
+ param->psyRdoq = 0.5;
param->bIntraInBFrames = 1;
param->bLossless = 0;
param->bCULossless = 0;
@@ -394,11 +395,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 eef6867b9c53 -r 2e9fd3bd970e source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp Fri Jul 18 02:19:55 2014 -0500
+++ b/source/encoder/analysis.cpp Fri Jul 18 17:41:01 2014 +0530
@@ -52,6 +52,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)
{
@@ -1869,7 +1870,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 eef6867b9c53 -r 2e9fd3bd970e source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Fri Jul 18 02:19:55 2014 -0500
+++ b/source/encoder/encoder.cpp Fri Jul 18 17:41:01 2014 +0530
@@ -1313,8 +1313,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 eef6867b9c53 -r 2e9fd3bd970e source/x265.h
--- a/source/x265.h Fri Jul 18 02:19:55 2014 -0500
+++ b/source/x265.h Fri Jul 18 17:41:01 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