[x265] [PATCH 2 of 4] rdlevel: Add code for rdlevel 2
deepthidevaki at multicorewareinc.com
deepthidevaki at multicorewareinc.com
Wed Dec 4 08:37:47 CET 2013
# HG changeset patch
# User Deepthi Devaki <deepthidevaki at multicorewareinc.com>
# Date 1386142554 -19800
# Node ID 71d40e349b4062df2ac12b54cd6eded9cdfa70a2
# Parent 57a4555507b0a15d388b8c0cf26f752918fd3f74
rdlevel: Add code for rdlevel 2
Use signalling bits + sa8d cost to choose best among inter/merge/intra. Encode only best mode at each depth.
diff -r 57a4555507b0 -r 71d40e349b40 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp Wed Dec 04 13:04:39 2013 +0530
+++ b/source/encoder/compress.cpp Wed Dec 04 13:05:54 2013 +0530
@@ -286,39 +286,27 @@
}
}
- //calculate the motion compensation for chroma for the best mode selected
- int numPart = outBestCU->getNumPartInter();
- for (int partIdx = 0; partIdx < numPart; partIdx++)
+ if (m_cfg->param.rdLevel > 2)
{
- m_search->motionCompensation(outBestCU, bestPredYuv, REF_PIC_LIST_X, partIdx, false, true);
- }
+ //calculate the motion compensation for chroma for the best mode selected
+ int numPart = outBestCU->getNumPartInter();
+ for (int partIdx = 0; partIdx < numPart; partIdx++)
+ {
+ m_search->motionCompensation(outBestCU, bestPredYuv, REF_PIC_LIST_X, partIdx, false, true);
+ }
- TComDataCU* tmp;
- TComYuv *yuv;
+ TComDataCU* tmp;
+ TComYuv *yuv;
- outTempCU->setMergeIndexSubParts(bestMergeCand, 0, 0, depth);
- outTempCU->setInterDirSubParts(interDirNeighbours[bestMergeCand], 0, 0, depth);
- outTempCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField(mvFieldNeighbours[0 + 2 * bestMergeCand], SIZE_2Nx2N, 0, 0);
- outTempCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField(mvFieldNeighbours[1 + 2 * bestMergeCand], SIZE_2Nx2N, 0, 0);
+ outTempCU->setMergeIndexSubParts(bestMergeCand, 0, 0, depth);
+ outTempCU->setInterDirSubParts(interDirNeighbours[bestMergeCand], 0, 0, depth);
+ outTempCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField(mvFieldNeighbours[0 + 2 * bestMergeCand], SIZE_2Nx2N, 0, 0);
+ outTempCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField(mvFieldNeighbours[1 + 2 * bestMergeCand], SIZE_2Nx2N, 0, 0);
- //No-residue mode
- m_search->encodeResAndCalcRdInterCU(outTempCU, m_origYuv[depth], bestPredYuv, m_tmpResiYuv[depth], m_bestResiYuv[depth], m_tmpRecoYuv[depth], true);
- xCheckDQP(outTempCU);
+ //No-residue mode
+ m_search->encodeResAndCalcRdInterCU(outTempCU, m_origYuv[depth], bestPredYuv, m_tmpResiYuv[depth], m_bestResiYuv[depth], m_tmpRecoYuv[depth], true);
+ xCheckDQP(outTempCU);
- tmp = outTempCU;
- outTempCU = outBestCU;
- outBestCU = tmp;
-
- yuv = yuvReconBest;
- yuvReconBest = m_tmpRecoYuv[depth];
- m_tmpRecoYuv[depth] = yuv;
-
- //Encode with residue
- m_search->encodeResAndCalcRdInterCU(outTempCU, m_origYuv[depth], bestPredYuv, m_tmpResiYuv[depth], m_bestResiYuv[depth], m_tmpRecoYuv[depth], false);
- xCheckDQP(outTempCU);
-
- if (outTempCU->m_totalCost < outBestCU->m_totalCost) //Choose best from no-residue mode and residue mode
- {
tmp = outTempCU;
outTempCU = outBestCU;
outBestCU = tmp;
@@ -326,8 +314,22 @@
yuv = yuvReconBest;
yuvReconBest = m_tmpRecoYuv[depth];
m_tmpRecoYuv[depth] = yuv;
+
+ //Encode with residue
+ m_search->encodeResAndCalcRdInterCU(outTempCU, m_origYuv[depth], bestPredYuv, m_tmpResiYuv[depth], m_bestResiYuv[depth], m_tmpRecoYuv[depth], false);
+ xCheckDQP(outTempCU);
+
+ if (outTempCU->m_totalCost < outBestCU->m_totalCost) //Choose best from no-residue mode and residue mode
+ {
+ tmp = outTempCU;
+ outTempCU = outBestCU;
+ outBestCU = tmp;
+
+ yuv = yuvReconBest;
+ yuvReconBest = m_tmpRecoYuv[depth];
+ m_tmpRecoYuv[depth] = yuv;
+ }
}
- m_tmpResiYuv[depth]->clear();
x265_emms();
}
@@ -479,17 +481,19 @@
m_modePredYuv[2][depth] = m_bestPredYuv[depth];
m_bestPredYuv[depth] = tempYuv;
}
- //calculate the motion compensation for chroma for the best mode selected
- int numPart = outBestCU->getNumPartInter();
- for (int partIdx = 0; partIdx < numPart; partIdx++)
+ if (m_cfg->param.rdLevel > 2)
{
- m_search->motionCompensation(outBestCU, m_bestPredYuv[depth], REF_PIC_LIST_X, partIdx, false, true);
+ //calculate the motion compensation for chroma for the best mode selected
+ int numPart = outBestCU->getNumPartInter();
+ for (int partIdx = 0; partIdx < numPart; partIdx++)
+ {
+ m_search->motionCompensation(outBestCU, m_bestPredYuv[depth], REF_PIC_LIST_X, partIdx, false, true);
+ }
+
+ m_search->encodeResAndCalcRdInterCU(outBestCU, m_origYuv[depth], m_bestPredYuv[depth], m_tmpResiYuv[depth],
+ m_bestResiYuv[depth], m_bestRecoYuv[depth], false);
+ xCheckDQP(outBestCU);
}
-
- m_search->encodeResAndCalcRdInterCU(outBestCU, m_origYuv[depth], m_bestPredYuv[depth], m_tmpResiYuv[depth],
- m_bestResiYuv[depth], m_bestRecoYuv[depth], false);
- xCheckDQP(outBestCU);
-
if (m_bestMergeCU[depth]->m_totalCost < outBestCU->m_totalCost)
{
outBestCU = m_bestMergeCU[depth];
@@ -506,13 +510,20 @@
if (outBestCU->getSlice()->getSliceType() == P_SLICE)
{
/*compute intra cost */
- if (outBestCU->getCbf(0, TEXT_LUMA) != 0 ||
- outBestCU->getCbf(0, TEXT_CHROMA_U) != 0 ||
- outBestCU->getCbf(0, TEXT_CHROMA_V) != 0)
+ bool bdoIntra = true;
+ if (m_cfg->param.rdLevel > 2)
+ {
+ bdoIntra = (outBestCU->getCbf(0, TEXT_LUMA) || outBestCU->getCbf(0, TEXT_CHROMA_U) ||
+ outBestCU->getCbf(0, TEXT_CHROMA_V));
+ }
+ if (bdoIntra)
{
xComputeCostIntraInInter(m_intraInInterCU[depth], SIZE_2Nx2N);
- xEncodeIntraInInter(m_intraInInterCU[depth], m_origYuv[depth], m_modePredYuv[5][depth], m_tmpResiYuv[depth], m_tmpRecoYuv[depth]);
-
+ if (m_cfg->param.rdLevel > 2)
+ {
+ xEncodeIntraInInter(m_intraInInterCU[depth], m_origYuv[depth], m_modePredYuv[5][depth],
+ m_tmpResiYuv[depth], m_tmpRecoYuv[depth]);
+ }
if (m_intraInInterCU[depth]->m_totalCost < outBestCU->m_totalCost)
{
outBestCU = m_intraInInterCU[depth];
@@ -538,7 +549,25 @@
m_bestRecoYuv[depth] = m_bestMergeRecoYuv[depth];
m_bestMergeRecoYuv[depth] = tempYuv;
}
+ if (m_cfg->param.rdLevel <= 2)
+ {
+ if (outBestCU->getPredictionMode(0) == MODE_INTER)
+ {
+ int numPart = outBestCU->getNumPartInter();
+ for (int partIdx = 0; partIdx < numPart; partIdx++)
+ {
+ m_search->motionCompensation(outBestCU, m_bestPredYuv[depth], REF_PIC_LIST_X, partIdx, false, true);
+ }
+ m_search->encodeResAndCalcRdInterCU(outBestCU, m_origYuv[depth], m_bestPredYuv[depth], m_tmpResiYuv[depth],
+ m_bestResiYuv[depth], m_bestRecoYuv[depth], false);
+ xCheckDQP(outBestCU);
+ }
+ else
+ {
+ xEncodeIntraInInter(outBestCU, m_origYuv[depth], m_bestPredYuv[depth], m_tmpResiYuv[depth], m_bestRecoYuv[depth]);
+ }
+ }
/* Disable recursive analysis for whole CUs temporarily */
if ((outBestCU != 0) && (outBestCU->isSkipped(0)))
{
More information about the x265-devel
mailing list