[x265] [PATCH] search: dump the best motion statistics for P&B slices into analysisdata file
Gopu Govindaswamy
gopu at multicorewareinc.com
Wed Oct 15 06:40:29 CEST 2014
On Wed, Oct 15, 2014 at 12:44 AM, Steve Borho <steve at borho.org> wrote:
> On 10/14, gopu at multicorewareinc.com wrote:
> > # HG changeset patch
> > # User Gopu Govindaswamy <gopu at multicorewareinc.com>
> > # Date 1413280221 -19800
> > # Tue Oct 14 15:20:21 2014 +0530
> > # Node ID 188757dfe944c7e70429ffe1316775d135d87d13
> > # Parent f26e81eb555aa586380b34314c302ea9b148f357
> > search: dump the best motion statistics for P&B slices into analysisdata
> file
> >
> > diff -r f26e81eb555a -r 188757dfe944 source/Lib/TLibCommon/TComRom.h
> > --- a/source/Lib/TLibCommon/TComRom.h Mon Oct 13 14:36:40 2014 +0530
> > +++ b/source/Lib/TLibCommon/TComRom.h Tue Oct 14 15:20:21 2014 +0530
> > @@ -68,6 +68,8 @@
> >
> > #define SLFASE_CONSTANT 0x5f4e4a53
> >
> > +#define MAX_RECURSIVE 85 //maximum recursive call for each cu
> > +
> > void initROM();
> > void destroyROM();
> >
> > diff -r f26e81eb555a -r 188757dfe944 source/encoder/analysis.cpp
> > --- a/source/encoder/analysis.cpp Mon Oct 13 14:36:40 2014 +0530
> > +++ b/source/encoder/analysis.cpp Tue Oct 14 15:20:21 2014 +0530
> > @@ -477,6 +477,9 @@
> > }
> > else
> > {
> > + if (m_param->analysisMode)
> > + m_interAnalysisData = ctu->m_pic->m_interData +
> (ctu->m_cuAddr * MAX_RECURSIVE);
> > +
> > if (m_param->rdLevel < 5)
> > {
> > TComDataCU* outBestCU = NULL;
> > @@ -712,10 +715,10 @@
> > for (uint32_t partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++)
> > {
> > CU *child_cu =
> pic->getCU(outTempCU->m_cuAddr)->m_cuLocalData + cu->childIdx + partUnitIdx;
> > - int qp = outTempCU->getQP(0);
> > - subBestPartCU->initSubCU(outTempCU, child_cu, partUnitIdx,
> nextDepth, qp); // clear sub partition datas or init.
> > if (child_cu->flags & CU::PRESENT)
> > {
> > + int qp = outTempCU->getQP(0);
> > + subBestPartCU->initSubCU(outTempCU, child_cu,
> partUnitIdx, nextDepth, qp); // clear sub partition datas or init.
> > subTempPartCU->initSubCU(outTempCU, child_cu,
> partUnitIdx, nextDepth, qp); // clear sub partition datas or init.
> >
> > if (partUnitIdx) // initialize RD with previous depth
> buffer
> > @@ -1386,6 +1389,10 @@
> > m_bestRecoYuv[depth]->copyToPicYuv(pic->getPicYuvRec(),
> cuAddr, absPartIdx);
> > }
> >
> > + /* increment the analysisData buffer for each recursive call */
> > + if (m_interAnalysisData)
> > + m_interAnalysisData++;
> > +
> > #if CHECKED_BUILD || _DEBUG
> > /* Assert if Best prediction mode is NONE
> > * Selected mode's RD-cost must be not MAX_INT64 */
> > @@ -1450,6 +1457,10 @@
> > outTempCU->initEstData();
> > if (m_param->bEnableCbfFastMode)
> > doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
> > +
> > + /* increment the analysisData buffer for each recursive
> call */
> > + if (m_interAnalysisData)
> > + m_interAnalysisData++;
> > }
> > }
> >
> > @@ -2093,7 +2104,7 @@
> > cu->m_totalDistortion =
> primitives.sa8d[sizeIdx](m_origYuv[depth]->getLumaAddr(),
> m_origYuv[depth]->getStride(), predYuv->getLumaAddr(),
> predYuv->getStride());
> > cu->m_sa8dCost = m_rdCost.calcRdSADCost(cu->m_totalDistortion,
> cu->m_totalBits);
> > }
> > - else if (predInterSearch(cu, cuData, predYuv, false, false))
> > + else if (predInterSearch(cu, cuData, predYuv, false, false,
> m_interAnalysisData))
> > {
> > int sizeIdx = cu->getLog2CUSize(0) - 2;
> > uint32_t distortion =
> primitives.sa8d[sizeIdx](m_origYuv[depth]->getLumaAddr(),
> m_origYuv[depth]->getStride(), predYuv->getLumaAddr(),
> predYuv->getStride());
> > @@ -2124,7 +2135,7 @@
> > checkDQP(tempCU);
> > checkBestMode(bestCU, tempCU, depth);
> > }
> > - else if (predInterSearch(tempCU, cuData, m_tmpPredYuv[depth],
> bMergeOnly, true))
> > + else if (predInterSearch(tempCU, cuData, m_tmpPredYuv[depth],
> bMergeOnly, true, m_interAnalysisData))
> > {
> > encodeResAndCalcRdInterCU(tempCU, cuData, m_origYuv[depth],
> m_tmpPredYuv[depth], m_tmpResiYuv[depth], m_bestResiYuv[depth],
> m_tmpRecoYuv[depth]);
> > checkDQP(tempCU);
> > diff -r f26e81eb555a -r 188757dfe944 source/encoder/analysis.h
> > --- a/source/encoder/analysis.h Mon Oct 13 14:36:40 2014 +0530
> > +++ b/source/encoder/analysis.h Tue Oct 14 15:20:21 2014 +0530
> > @@ -109,6 +109,7 @@
> >
> > StatisticLog m_sliceTypeLog[3];
> > StatisticLog* m_log;
> > + x265_inter_data* m_interAnalysisData; // To store the inter
> analysis data per CU
> >
> > Analysis();
> > bool create(uint32_t totalDepth, uint32_t maxWidth,
> ThreadLocalData* tld);
> > diff -r f26e81eb555a -r 188757dfe944 source/encoder/search.cpp
> > --- a/source/encoder/search.cpp Mon Oct 13 14:36:40 2014 +0530
> > +++ b/source/encoder/search.cpp Tue Oct 14 15:20:21 2014 +0530
> > @@ -1684,7 +1684,7 @@
> >
> > /* search of the best candidate for inter prediction
> > * returns true if predYuv was filled with a motion compensated
> prediction */
> > -bool Search::predInterSearch(TComDataCU* cu, CU* cuData, TComYuv*
> predYuv, bool bMergeOnly, bool bChroma)
> > +bool Search::predInterSearch(TComDataCU* cu, CU* cuData, TComYuv*
> predYuv, bool bMergeOnly, bool bChroma, x265_inter_data* interAnalysisData)
> > {
> > MV amvpCand[2][MAX_NUM_REF][AMVP_NUM_CANDS];
> > MV mvc[(MD_ABOVE_LEFT + 1) * 2 + 1];
> > @@ -1755,6 +1755,11 @@
> > list[0].cost = MAX_UINT;
> > list[1].cost = MAX_UINT;
> >
> > + /* require for sharing mode, if cost is zero no need to call
> subpelCompare
> > + * extract the best cost from mvcost and this is only for
> actual me, not required for
> > + * lowres me and isCostZero is NULL when the me is called from
> slicetype */
> > + bool costZero[2];
>
> it would be cleaner to add costZero to MotionData
>
> > +
> > getBlkBits(partSize, slice->isInterP(), partIdx, lastMode,
> listSelBits);
> >
> > // Uni-directional prediction
> > @@ -1812,10 +1817,24 @@
> > list[l].ref = ref;
> > list[l].cost = cost;
> > list[l].bits = bits;
> > + costZero[l] = !!satdCost;
> > }
>
> since satdCost includes MV cost, it doesn't seem possible for it to ever
> be completely zero
>
Yes right, For analysis load mode if the satdCost is zero for any MV,
we are just take the MV cost, not necessary to call subpelCompare, i have
given the snapshot of the logic below
if (isCostZero)
satdCost = m_me.mvcost(bmv);
else
satdCost = m_me.subpelCompare(&slice->m_mref[l][ref],
bmv, m_me.satd) + m_me.mvcost(bmv);
bmv - is the shared MVs, this will be an separate patch for sharing MVs
> > }
> > }
> >
> > + if (m_param->analysisMode == X265_ANALYSIS_SAVE &&
> interAnalysisData)
> > + {
> > + for (int32_t i = 0; i < 2; i++)
> > + {
> > + interAnalysisData->costZero[i] = costZero[i];
> > + interAnalysisData->mvx[i] = list[i].mv.x;
> > + interAnalysisData->mvy[i] = list[i].mv.y;
> > + interAnalysisData->ref[i] = list[i].ref;
> > + }
> > + interAnalysisData->zOrder = cu->m_absIdxInCTU;
> > + interAnalysisData->depth = cu->getDepth(0);
> > + }
> > +
> > // Bi-directional prediction
> > if (slice->isInterB() && !cu->isBipredRestriction() &&
> list[0].cost != MAX_UINT && list[1].cost != MAX_UINT)
> > {
> > diff -r f26e81eb555a -r 188757dfe944 source/encoder/search.h
> > --- a/source/encoder/search.h Mon Oct 13 14:36:40 2014 +0530
> > +++ b/source/encoder/search.h Tue Oct 14 15:20:21 2014 +0530
> > @@ -101,7 +101,7 @@
> > void estIntraPredChromaQT(TComDataCU* cu, CU* cuData, TComYuv*
> fencYuv, TComYuv* predYuv, ShortYuv* resiYuv, TComYuv* reconYuv);
> >
> > // estimation inter prediction (non-skip)
> > - bool predInterSearch(TComDataCU* cu, CU* cuData, TComYuv*
> predYuv, bool bMergeOnly, bool bChroma);
> > + bool predInterSearch(TComDataCU* cu, CU* cuData, TComYuv*
> predYuv, bool bMergeOnly, bool bChroma, x265_inter_data*
> m_interAnalysisData);
> >
> > // encode residual and compute rd-cost for inter mode
> > void encodeResAndCalcRdInterCU(TComDataCU* cu, CU* cuData,
> TComYuv* fencYuv, TComYuv* predYuv, ShortYuv* resiYuv, ShortYuv*
> bestResiYuv, TComYuv* reconYuv);
> > _______________________________________________
> > x265-devel mailing list
> > x265-devel at videolan.org
> > https://mailman.videolan.org/listinfo/x265-devel
>
> --
> Steve Borho
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
--
Thanks & Regards
Gopu G
Multicoreware Inc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20141015/4e800414/attachment.html>
More information about the x265-devel
mailing list