[x265] [PATCH] EARLY EXIT NO RDO OPTIMIZATION - replaced SATD predictions with RDO predictions
Steve Borho
steve at borho.org
Wed Jul 31 22:31:00 CEST 2013
On Wed, Jul 31, 2013 at 7:23 AM, <aarthi at multicorewareinc.com> wrote:
> # HG changeset patch
> # User sumalatha
> # Date 1375273324 -19800
> # Node ID 1510dd1fda4dada5d940cd1552f4b5b31585ff98
> # Parent 66eab44e4c56d7f7841a417aa05b9b49a6192a5a
> EARLY EXIT NO RDO OPTIMIZATION - replaced SATD predictions with RDO
> predictions
>
This looks reasonable, but please re-post these as three separate patches:
1 - change LAMBDA_PARTITION_SELECT
2 - uncrustify existing compress.cpp
3 - logic changes to cleaned up compress.cpp
Also see comments below
> diff -r 66eab44e4c56 -r 1510dd1fda4d source/Lib/TLibCommon/CommonDef.h
> --- a/source/Lib/TLibCommon/CommonDef.h Wed Jul 31 01:18:43 2013 -0500
> +++ b/source/Lib/TLibCommon/CommonDef.h Wed Jul 31 17:52:04 2013 +0530
> @@ -126,7 +126,7 @@
> #define REG_DCT 65535
>
> #define CABAC_INIT_PRESENT_FLAG 1
> -#define LAMBDA_PARTITION_SELECT 0.6
> +#define LAMBDA_PARTITION_SELECT 0.9
>
> #define _SUMMARY_OUT_ 0 ///< print-out PSNR
> results of all slices to summary.txt
> #define _SUMMARY_PIC_ 0 ///< print-out PSNR
> results for each slice type to summary.txt
> diff -r 66eab44e4c56 -r 1510dd1fda4d source/encoder/compress.cpp
> --- a/source/encoder/compress.cpp Wed Jul 31 01:18:43 2013 -0500
> +++ b/source/encoder/compress.cpp Wed Jul 31 17:52:04 2013 +0530
> @@ -286,15 +286,12 @@
> Bool bTrySplitDQP = true;
> Bool bBoundary = false;
> UInt64 nxnCost = 0;
> -#if EARLY_EXIT_NO_RDO
> - UInt64 inter2Nx2NCost = 0;
> -#endif
> UInt lpelx = outTempCU->getCUPelX();
> UInt rpelx = lpelx + outTempCU->getWidth(0) - 1;
> UInt tpely = outTempCU->getCUPelY();
> UInt bpely = tpely + outTempCU->getHeight(0) - 1;
> TComDataCU* subTempPartCU, * subBestPartCU;
> - Int qp = outTempCU->getQP(0);
> + Int qp = m_cfg->getUseRateCtrl() ? m_rateControl->getRCQP() :
> outTempCU->getQP(0);
>
this is resurrecting getUseRateCtrl(), which was removed on the tip
>
> // If slice start or slice end is within this cu...
> TComSlice * slice = outTempCU->getPic()->getSlice();
> @@ -332,6 +329,7 @@
>
> /* Compute Merge Cost */
> Bool earlyDetectionSkip = false;
> +
> xCheckRDCostMerge2Nx2N(m_bestMergeCU[depth], m_mergeCU[depth],
> &earlyDetectionSkip, m_modePredYuv[3][depth], m_bestMergeRecoYuv[depth]);
>
> if (!earlyDetectionSkip)
> @@ -354,9 +352,7 @@
> m_bestPredYuvNxN[PartitionIndex][depth] =
> m_bestPredYuv[depth];
> m_bestPredYuv[depth] = tempYuv;
> }*/
> -#if EARLY_EXIT_NO_RDO
> - inter2Nx2NCost = outBestCU->m_totalCost;
> -#endif
> +
> bTrySplitDQP = bTrySplit;
>
> if ((Int)depth <= m_addSADDepth)
> @@ -365,37 +361,9 @@
> m_addSADDepth = depth;
> }
>
> -#if EARLY_EXIT_NO_RDO
> - if (depth < g_maxCUDepth - g_addCUDepth)
> - {
> - outTempCU->initEstData(depth, qp);
> - UChar nextDepth = (UChar)(depth + 1);
> - /*Best CU initialised to NULL; */
> - subBestPartCU = NULL;
> - /*The temp structure is used for boundary analysis, and
> to copy Best SubCU mode data on return*/
> - subTempPartCU;
> - nxnCost = 0;
> - for (UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++)
> - {
> - subTempPartCU = m_interCU_NxN[partUnitIdx][nextDepth];
> - subTempPartCU->initSubCU(outTempCU, partUnitIdx,
> nextDepth, qp); // clear sub partition datas or init.
> - TComPic* subPic = subTempPartCU->getPic();
> -
> m_origYuv[nextDepth]->copyFromPicYuv(subPic->getPicYuvOrg(),
> subTempPartCU->getAddr(), subTempPartCU->getZorderIdxInCU());
>
> - Bool bInSlice = subTempPartCU->getSCUAddr() <
> slice->getSliceCurEndCUAddr() ;
> - if (bInSlice && (subTempPartCU->getCUPelX() <
> slice->getSPS()->getPicWidthInLumaSamples()) &&
> - (subTempPartCU->getCUPelY() <
> slice->getSPS()->getPicHeightInLumaSamples()))
> - {
> - xComputeCostInter(subTempPartCU,
> m_bestPredYuvNxN[partUnitIdx][nextDepth], SIZE_2Nx2N, 0);
> - nxnCost += subTempPartCU->m_totalCost;
> - }
> -
> - }
> - }
> -#endif // if EARLY_EXIT_NO_RDO
>
> - if (outBestCU->m_totalCost > nxnCost)
> - {
> +
> /*Compute Rect costs*/
> if (m_cfg->getUseRectInter())
> {
> @@ -419,7 +387,7 @@
> m_modePredYuv[2][depth] = m_bestPredYuv[depth];
> m_bestPredYuv[depth] = tempYuv;
> }
> - }
> +
>
> m_search->encodeResAndCalcRdInterCU(outBestCU,
> m_origYuv[depth], m_bestPredYuv[depth], m_tmpResiYuv[depth],
> m_bestResiYuv[depth],
> m_bestRecoYuv[depth], false);
> @@ -444,7 +412,7 @@
> outBestCU->getCbf(0, TEXT_CHROMA_U) != 0 ||
> outBestCU->getCbf(0, TEXT_CHROMA_V) != 0)
> {
> - xComputeCostIntraInInter(m_intraInInterCU[depth],
> SIZE_2Nx2N);
> + 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_intraInInterCU[depth]->m_totalCost <
> outBestCU->m_totalCost)
> @@ -457,26 +425,12 @@
> TComYuv* tmpPic = m_bestRecoYuv[depth];
> m_bestRecoYuv[depth] = m_tmpRecoYuv[depth];
> m_tmpRecoYuv[depth] = tmpPic;
> +
> }
> }
>
> // further split
> -#if EARLY_EXIT_NO_RDO
> - if (inter2Nx2NCost < nxnCost && depth < g_maxCUDepth -
> g_addCUDepth)
> - {
> - m_entropyCoder->resetBits();
> - m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth,
> true);
> - outBestCU->m_totalBits +=
> m_entropyCoder->getNumberOfWrittenBits(); // split bits
> - outBestCU->m_totalBins +=
> ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
> - outBestCU->m_totalCost =
> m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);
> - /* Copy Best data to Picture for next partition
> prediction. */
> - outBestCU->copyToPic((UChar)depth);
>
> - /* Copy Yuv data to picture Yuv */
> - xCopyYuv2Pic(outBestCU->getPic(), outBestCU->getAddr(),
> outBestCU->getZorderIdxInCU(), depth, depth, outBestCU, lpelx, tpely);
> - return;
> - }
> -#endif // if EARLY_EXIT_NO_RDO
> }
> else
> {
> @@ -525,7 +479,70 @@
>
> // further split
> if (bSubBranch && bTrySplitDQP && depth < g_maxCUDepth - g_addCUDepth)
> - {
> + {
> +#if EARLY_EXIT_NO_RDO
> + if(outBestCU!=0 && depth >0)
> + {
> +
> + outTempCU->initEstData(depth, qp);
> + UChar nextDepth = (UChar)(depth + 1);
> + /*Best CU initialised to NULL; */
> + subBestPartCU = NULL;
> + /*The temp structure is used for boundary analysis, and
> to copy Best SubCU mode data on return*/
> + subTempPartCU;
> + nxnCost = 0;
> + for (UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++)
> + {
> + subTempPartCU = m_interCU_NxN[partUnitIdx][nextDepth];
> + subTempPartCU->initSubCU(outTempCU, partUnitIdx,
> nextDepth, qp); // clear sub partition datas or init.
> + TComPic* subPic = subTempPartCU->getPic();
> +
> m_origYuv[nextDepth]->copyFromPicYuv(subPic->getPicYuvOrg(),
> subTempPartCU->getAddr(), subTempPartCU->getZorderIdxInCU());
> + TComSlice * pcSubSlice =
> subTempPartCU->getPic()->getSlice();
> + Bool subSliceEnd = subTempPartCU->getSCUAddr() <
> slice->getSliceCurEndCUAddr()
> + && pcSubSlice->getSliceCurEndCUAddr() <
> subTempPartCU->getSCUAddr() + subTempPartCU->getTotalNumPart();
> + if (!subSliceEnd && (subTempPartCU->getCUPelX() <
> slice->getSPS()->getPicWidthInLumaSamples()) &&
> + (subTempPartCU->getCUPelY() <
> slice->getSPS()->getPicHeightInLumaSamples()))
> + {
> + if(outBestCU->getPredictionMode(0)==0)
> + {
> +
> + xComputeCostInter(subTempPartCU,
> m_bestPredYuvNxN[partUnitIdx][nextDepth],outBestCU->getPartitionSize(0), 0);
> +
> m_search->encodeResAndCalcRdInterCU(subTempPartCU, m_origYuv[nextDepth],
> m_bestPredYuvNxN[partUnitIdx][nextDepth], m_tmpResiYuv[nextDepth],
> + m_bestResiYuv[nextDepth],
> m_tmpRecoYuv[nextDepth], false);
> + nxnCost += subTempPartCU->m_totalCost;
> +
> + }
> + else if(outBestCU->getPredictionMode(0)==1)
> + {
> +
> + xComputeCostIntraInInter(subTempPartCU,
> SIZE_2Nx2N);
> + xEncodeIntraInInter(subTempPartCU,
> m_origYuv[nextDepth], m_modePredYuv[5][nextDepth], m_tmpResiYuv[nextDepth],
> m_tmpRecoYuv[nextDepth]);
> + nxnCost += subTempPartCU->m_totalCost;
> +
> +
> + }
>
This looks like it's adding tabs and spurious blank lines that need to be
tidied up
> +
> + }
> + }
> +
> +
> + if ( outBestCU->m_totalCost < LAMBDA_PARTITION_SELECT*
> nxnCost)
> + {
> + m_entropyCoder->resetBits();
> + m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth,
> true);
> + outBestCU->m_totalBits +=
> m_entropyCoder->getNumberOfWrittenBits(); // split bits
> + outBestCU->m_totalBins +=
> ((TEncBinCABAC*)((TEncSbac*)m_entropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
> + outBestCU->m_totalCost =
> m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);
> + /* Copy Best data to Picture for next partition
> prediction. */
> + outBestCU->copyToPic((UChar)depth);
> +
> + /* Copy Yuv data to picture Yuv */
> + xCopyYuv2Pic(outBestCU->getPic(), outBestCU->getAddr(),
> outBestCU->getZorderIdxInCU(), depth, depth, outBestCU, lpelx, tpely);
> + return;
> + }
> +
> + }
> + #endif // if EARLY_EXIT_NO_RDO
> outTempCU->initEstData(depth, qp);
> UChar nextDepth = (UChar)(depth + 1);
> subTempPartCU = m_tempCU[nextDepth];
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> http://mailman.videolan.org/listinfo/x265-devel
>
--
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/private/x265-devel/attachments/20130731/81e5b270/attachment-0001.html>
More information about the x265-devel
mailing list