[x265] [PATCH] merge2nx2n: move initializations out of the loop
deepthidevaki at multicorewareinc.com
deepthidevaki at multicorewareinc.com
Wed Nov 27 13:23:30 CET 2013
# HG changeset patch
# User Deepthi Devaki <deepthidevaki at multicorewareinc.com>
# Date 1385554910 -19800
# Branch stable
# Node ID 2123b8a0d5954d1bb0ca4b3c6fdb80e505218786
# Parent 417f794274e5692851b558eaa609e6fbdac1d50f
merge2nx2n: move initializations out of the loop
Only mergeIndex and MVs will be changed in each loop.
diff -r 417f794274e5 -r 2123b8a0d595 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp Wed Nov 27 01:49:09 2013 -0600
+++ b/source/encoder/compress.cpp Wed Nov 27 17:51:50 2013 +0530
@@ -138,7 +138,7 @@
// Filtered and Unfiltered refAbove and refLeft pointing to above and left.
above = aboveScale;
left = leftScale;
- aboveFiltered = aboveScale;
+ aboveFiltered = aboveScale;
leftFiltered = leftScale;
}
@@ -235,15 +235,22 @@
outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
outTempCU->getInterMergeCandidates(0, 0, mvFieldNeighbours, interDirNeighbours, numValidMergeCand);
+ outTempCU->setPredModeSubParts(MODE_INTER, 0, depth);
+ outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
+ outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth);
+ outTempCU->setMergeFlagSubParts(true, 0, 0, depth);
+
+ outBestCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
+ outBestCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
+ outBestCU->setPredModeSubParts(MODE_INTER, 0, depth);
+ outBestCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
+ outBestCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth);
+ outBestCU->setMergeFlagSubParts(true, 0, 0, depth);
int bestMergeCand = 0;
for (int mergeCand = 0; mergeCand < numValidMergeCand; ++mergeCand)
{
// set MC parameters, interprets depth relative to LCU level
- outTempCU->setPredModeSubParts(MODE_INTER, 0, depth);
- outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
- outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth);
- outTempCU->setMergeFlagSubParts(true, 0, 0, depth);
outTempCU->setMergeIndexSubParts(mergeCand, 0, 0, depth);
outTempCU->setInterDirSubParts(interDirNeighbours[mergeCand], 0, 0, depth);
outTempCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField(mvFieldNeighbours[0 + 2 * mergeCand], SIZE_2Nx2N, 0, 0); // interprets depth relative to rpcTempCU level
@@ -255,9 +262,6 @@
outTempCU->m_totalCost = primitives.sse_pp[part](m_origYuv[depth]->getLumaAddr(), m_origYuv[depth]->getStride(),
m_tmpPredYuv[depth]->getLumaAddr(), m_tmpPredYuv[depth]->getStride());
-
- int orgQP = outTempCU->getQP(0);
-
if (outTempCU->m_totalCost < outBestCU->m_totalCost)
{
bestMergeCand = mergeCand;
@@ -269,8 +273,6 @@
bestPredYuv = m_tmpPredYuv[depth];
m_tmpPredYuv[depth] = yuv;
}
-
- outTempCU->initEstData(depth, orgQP);
}
//calculate the motion compensation for chroma for the best mode selected
@@ -384,14 +386,14 @@
char currentQP = outTempCU->getQP(0);
char previousQP = colocated0->getQP(0);
UChar delta = 0, minDepth0 = 4, minDepth1 = 4;
- if(depth == 0)
- {
+ if (depth == 0)
+ {
double sum0 = 0;
double sum1 = 0;
double avgDepth0 = 0;
double avgDepth1 = 0;
double avgDepth = 0;
- for (uint32_t i = 0; i < outTempCU->getTotalNumPart(); i = i+4)
+ for (uint32_t i = 0; i < outTempCU->getTotalNumPart(); i = i + 4)
{
if (colocated0 && colocated0->getDepth(i) < minDepth0)
minDepth0 = colocated0->getDepth(i);
@@ -402,6 +404,7 @@
if (colocated1)
sum1 += (colocated1->getDepth(i) * 4);
}
+
avgDepth0 = sum0 / outTempCU->getTotalNumPart();
avgDepth1 = sum1 / outTempCU->getTotalNumPart();
avgDepth = (avgDepth0 + avgDepth1) / 2;
@@ -418,7 +421,7 @@
if (minDepth > 0)
minDepth = minDepth - delta;
}
-#endif
+#endif // if TOPSKIP
#if TOPSKIP
if (!(depth < minDepth)) //topskip
#endif
@@ -506,7 +509,6 @@
m_search->estimateRDInterCU(outBestCU, m_origYuv[depth], m_bestPredYuv[depth], m_tmpResiYuv[depth],
m_bestResiYuv[depth], m_bestRecoYuv[depth], false);
-
if (m_bestMergeCU[depth]->m_totalCost < outBestCU->m_totalCost)
{
outBestCU = m_bestMergeCU[depth];
@@ -591,10 +593,10 @@
if (bSubBranch && bTrySplitDQP && depth < g_maxCUDepth - g_addCUDepth)
{
#if EARLY_EXIT // turn ON this to enable early exit
- // early exit when the RD cost of best mode at depth n is less than the sum of avgerage of RD cost of the neighbour
+ // early exit when the RD cost of best mode at depth n is less than the sum of avgerage of RD cost of the neighbour
// CU's(above, aboveleft, aboveright, left, colocated) and avg cost of that CU at depth "n" with weightage for each quantity
#if TOPSKIP
- if (outBestCU != 0 && !(depth < minDepth))//topskip
+ if (outBestCU != 0 && !(depth < minDepth)) //topskip
#else
if (outBestCU != 0)
#endif
More information about the x265-devel
mailing list