[x265-commits] [x265] weight: match x264 weight analysis and logging [OUTPUT CH...
Steve Borho
steve at borho.org
Tue Mar 11 07:57:56 CET 2014
details: http://hg.videolan.org/x265/rev/f3988b70f4aa
branches:
changeset: 6442:f3988b70f4aa
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 18:09:43 2014 -0500
description:
weight: match x264 weight analysis and logging [OUTPUT CHANGE]
This only weights the first reference, and will only weight chroma if luma
was weighted. Further work remains, we must add an unweighted dup of the
weighted reference into the P slice's L0 reference list.
Subject: [x265] TEncSearch: cleanups in predInterSearch(), no logic change
details: http://hg.videolan.org/x265/rev/275edc95de11
branches:
changeset: 6443:275edc95de11
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 18:30:28 2014 -0500
description:
TEncSearch: cleanups in predInterSearch(), no logic change
Subject: [x265] TEncSearch: remove useless distBiP argument from xEstimateMvPredAMVP
details: http://hg.videolan.org/x265/rev/621f9c82eb14
branches:
changeset: 6444:621f9c82eb14
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 21:33:28 2014 -0500
description:
TEncSearch: remove useless distBiP argument from xEstimateMvPredAMVP
Subject: [x265] TEncSearch: replace costbi with listCost[2]
details: http://hg.videolan.org/x265/rev/12841ab3ce3f
branches:
changeset: 6445:12841ab3ce3f
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 21:40:59 2014 -0500
description:
TEncSearch: replace costbi with listCost[2]
Subject: [x265] TEncSearch: rename bits to listbits[] for clarity
details: http://hg.videolan.org/x265/rev/7495c029daf6
branches:
changeset: 6446:7495c029daf6
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 21:42:10 2014 -0500
description:
TEncSearch: rename bits to listbits[] for clarity
Subject: [x265] TEncSearch: simplify and localize scope of bitstemp
details: http://hg.videolan.org/x265/rev/c095646a2ef0
branches:
changeset: 6447:c095646a2ef0
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 21:43:39 2014 -0500
description:
TEncSearch: simplify and localize scope of bitstemp
Subject: [x265] TEncSearch: localize scope of costTemp
details: http://hg.videolan.org/x265/rev/132393836a2e
branches:
changeset: 6448:132393836a2e
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 21:44:26 2014 -0500
description:
TEncSearch: localize scope of costTemp
Subject: [x265] TEncSearch: localize scope and rename listRefIdx
details: http://hg.videolan.org/x265/rev/dc977fbf3ed1
branches:
changeset: 6449:dc977fbf3ed1
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 21:45:59 2014 -0500
description:
TEncSearch: localize scope and rename listRefIdx
Subject: [x265] TEncSearch: localize scope of mvzero
details: http://hg.videolan.org/x265/rev/de73109c06d5
branches:
changeset: 6450:de73109c06d5
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 21:46:57 2014 -0500
description:
TEncSearch: localize scope of mvzero
Subject: [x265] TEncSearch: localize scope and rename listMv
details: http://hg.videolan.org/x265/rev/f91dc85070fe
branches:
changeset: 6451:f91dc85070fe
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 21:48:23 2014 -0500
description:
TEncSearch: localize scope and rename listMv
Subject: [x265] TEncSearch: remove mvTemp[][] array, just use outmv stack var
details: http://hg.videolan.org/x265/rev/d546b400d156
branches:
changeset: 6452:d546b400d156
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 21:49:35 2014 -0500
description:
TEncSearch: remove mvTemp[][] array, just use outmv stack var
Subject: [x265] TEncSearch: localize scope, rename, and remove defaults for listSelBits array
details: http://hg.videolan.org/x265/rev/85e8a21a261b
branches:
changeset: 6453:85e8a21a261b
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 21:55:02 2014 -0500
description:
TEncSearch: localize scope, rename, and remove defaults for listSelBits array
Subject: [x265] TEncSearch: remove list1 hacks
details: http://hg.videolan.org/x265/rev/0d4182301313
branches:
changeset: 6454:0d4182301313
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 22:00:17 2014 -0500
description:
TEncSearch: remove list1 hacks
Subject: [x265] TEncSearch: hoist bMergeOnly check to only be performed once
details: http://hg.videolan.org/x265/rev/0574550353e6
branches:
changeset: 6455:0574550353e6
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 22:11:14 2014 -0500
description:
TEncSearch: hoist bMergeOnly check to only be performed once
Subject: [x265] TEncSearch: localize scope of bidir MV and ref idx arrays
details: http://hg.videolan.org/x265/rev/1f1aa83d20ed
branches:
changeset: 6456:1f1aa83d20ed
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 22:20:55 2014 -0500
description:
TEncSearch: localize scope of bidir MV and ref idx arrays
Subject: [x265] TEncSearch: host bMergeOnly logic to the top of predInterSearch
details: http://hg.videolan.org/x265/rev/c3156f2b7c97
branches:
changeset: 6457:c3156f2b7c97
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 22:50:41 2014 -0500
description:
TEncSearch: host bMergeOnly logic to the top of predInterSearch
This makes merge-only easier to follow and more efficient, and makes the full
search code easier to read and easier to maintain. This should have no change
in outputs
Subject: [x265] TEncSearch: reorder code for more clarity
details: http://hg.videolan.org/x265/rev/504c81462e30
branches:
changeset: 6458:504c81462e30
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 22:59:18 2014 -0500
description:
TEncSearch: reorder code for more clarity
Subject: [x265] TEncSearch: fix some comments
details: http://hg.videolan.org/x265/rev/e40524d079b4
branches:
changeset: 6459:e40524d079b4
user: Steve Borho <steve at borho.org>
date: Mon Mar 10 23:03:05 2014 -0500
description:
TEncSearch: fix some comments
diffstat:
source/Lib/TLibCommon/TComSlice.cpp | 1 -
source/Lib/TLibCommon/TComSlice.h | 1 -
source/Lib/TLibEncoder/TEncSearch.cpp | 545 +++++++++++++++----------------
source/Lib/TLibEncoder/TEncSearch.h | 2 +-
source/encoder/encoder.cpp | 20 +-
source/encoder/encoder.h | 3 +-
source/encoder/frameencoder.cpp | 9 +-
source/encoder/weightPrediction.cpp | 576 ++++++++++++++-------------------
8 files changed, 528 insertions(+), 629 deletions(-)
diffs (truncated from 1415 to 300 lines):
diff -r 1417ba917211 -r e40524d079b4 source/Lib/TLibCommon/TComSlice.cpp
--- a/source/Lib/TLibCommon/TComSlice.cpp Mon Mar 10 16:59:22 2014 +0530
+++ b/source/Lib/TLibCommon/TComSlice.cpp Mon Mar 10 23:03:05 2014 -0500
@@ -118,7 +118,6 @@ void TComSlice::initSlice()
m_cabacInitFlag = false;
m_numEntryPointOffsets = 0;
m_enableTMVPFlag = true;
- m_numWPRefs = 0;
}
bool TComSlice::getRapPicFlag()
diff -r 1417ba917211 -r e40524d079b4 source/Lib/TLibCommon/TComSlice.h
--- a/source/Lib/TLibCommon/TComSlice.h Mon Mar 10 16:59:22 2014 +0530
+++ b/source/Lib/TLibCommon/TComSlice.h Mon Mar 10 23:03:05 2014 -0500
@@ -1347,7 +1347,6 @@ private:
public:
wpScalingParam m_weightPredTable[2][MAX_NUM_REF][3]; // [REF_PIC_LIST_0 or REF_PIC_LIST_1][refIdx][0:Y, 1:U, 2:V]
- int m_numWPRefs; // number of references for which unidirectional weighted prediction is used
TComSlice();
virtual ~TComSlice();
diff -r 1417ba917211 -r e40524d079b4 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Mon Mar 10 16:59:22 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Mon Mar 10 23:03:05 2014 -0500
@@ -2115,14 +2115,13 @@ uint32_t TEncSearch::xGetInterPrediction
/** estimation of best merge coding
* \param cu
* \param fencYuv
- * \param iPUIdx
- * \param uiInterDir
+ * \param puIdx
+ * \param interDir
* \param pacMvField
- * \param uiMergeIndex
+ * \param mergeIndex
* \param outCost
* \param outBits
- * \param puhNeighCands
- * \param bValid
+ * \param neighCands
* \returns void
*/
void TEncSearch::xMergeEstimation(TComDataCU* cu, int puIdx, uint32_t& interDir, TComMvField* mvField, uint32_t& mergeIndex, uint32_t& outCost, uint32_t& outbits, TComMvField* mvFieldNeighbours, UChar* interDirNeighbours, int& numValidMergeCand)
@@ -2216,318 +2215,295 @@ void TEncSearch::xRestrictBipredMergeCan
*/
bool TEncSearch::predInterSearch(TComDataCU* cu, TComYuv* predYuv, bool bMergeOnly, bool bChroma)
{
- MV mvzero(0, 0);
- MV mv[2];
- MV mvBidir[2];
- MV mvTemp[2][MAX_NUM_REF];
- MV mvPred[2][MAX_NUM_REF];
- MV mvPredBi[2][MAX_NUM_REF];
-
- int mvpIdxBi[2][MAX_NUM_REF];
- int mvpIdx[2][MAX_NUM_REF];
- AMVPInfo amvpInfo[2][MAX_NUM_REF];
-
- uint32_t mbBits[3] = { 1, 1, 0 };
- int refIdx[2] = { 0, 0 }; // If un-initialized, may cause SEGV in bi-directional prediction iterative stage.
- int refIdxBidir[2] = { 0, 0 };
-
+ int numPart = cu->getNumPartInter();
PartSize partSize = cu->getPartitionSize(0);
- uint32_t lastMode = 0;
- int numPart = cu->getNumPartInter();
- int numPredDir = cu->getSlice()->isInterP() ? 1 : 2;
- uint32_t biPDistTemp = MAX_INT;
TComPicYuv *fenc = cu->getSlice()->getPic()->getPicYuvOrg();
TComMvField mvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
UChar interDirNeighbours[MRG_MAX_NUM_CANDS];
int numValidMergeCand = 0;
-
int totalmebits = 0;
- for (int partIdx = 0; partIdx < numPart; partIdx++)
+ if (bMergeOnly && cu->getCUSize(0) > 8 && numPart == 2)
{
- uint32_t listCost[2] = { MAX_UINT, MAX_UINT };
- uint32_t bits[3];
- uint32_t costbi = MAX_UINT;
- uint32_t costTemp = 0;
- uint32_t bitsTemp;
- MV mvValidList1;
- int refIdxValidList1 = 0;
- uint32_t bitsValidList1 = MAX_UINT;
- uint32_t costValidList1 = MAX_UINT;
-
- uint32_t partAddr;
- int roiWidth, roiHeight;
- xGetBlkBits(partSize, cu->getSlice()->isInterP(), partIdx, lastMode, mbBits);
- cu->getPartIndexAndSize(partIdx, partAddr, roiWidth, roiHeight);
-
- Pel* pu = fenc->getLumaAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr);
- m_me.setSourcePU(pu - fenc->getLumaAddr(), roiWidth, roiHeight);
-
- cu->getMvPredLeft(m_mvPredictors[0]);
- cu->getMvPredAbove(m_mvPredictors[1]);
- cu->getMvPredAboveRight(m_mvPredictors[2]);
-
- // force ME for the smallest rect/AMP sizes (Why? the HM did this)
- if (cu->getCUSize(0) <= 8 || numPart != 2)
- bMergeOnly = false;
-
- if (!bMergeOnly)
+ for (int partIdx = 0; partIdx < numPart; partIdx++)
{
- // Uni-directional prediction
- for (int list = 0; list < numPredDir; list++)
- {
- for (int idx = 0; idx < cu->getSlice()->getNumRefIdx(list); idx++)
- {
- bitsTemp = mbBits[list];
- if (cu->getSlice()->getNumRefIdx(list) > 1)
- {
- bitsTemp += idx + 1;
- if (idx == cu->getSlice()->getNumRefIdx(list) - 1) bitsTemp--;
- }
- xEstimateMvPredAMVP(cu, partIdx, list, idx, mvPred[list][idx], &amvpInfo[list][idx], &biPDistTemp);
- mvpIdx[list][idx] = cu->getMVPIdx(list, partAddr);
-
- bitsTemp += MVP_IDX_BITS;
- int merange = m_adaptiveRange[list][idx];
- MV& mvp = mvPred[list][idx];
- MV& outmv = mvTemp[list][idx];
-
- MV mvmin, mvmax;
- xSetSearchRange(cu, mvp, merange, mvmin, mvmax);
- int satdCost = m_me.motionEstimate(m_mref[list][idx],
- mvmin, mvmax, mvp, 3, m_mvPredictors, merange, outmv);
-
- /* Get total cost of partition, but only include MV bit cost once */
- bitsTemp += m_me.bitcost(outmv);
- costTemp = (satdCost - m_me.mvcost(outmv)) + m_rdCost->getCost(bitsTemp);
-
- xCheckBestMVP(&amvpInfo[list][idx], mvTemp[list][idx], mvPred[list][idx], mvpIdx[list][idx], bitsTemp, costTemp);
-
- if (costTemp < listCost[list])
- {
- listCost[list] = costTemp;
- bits[list] = bitsTemp; // storing for bi-prediction
-
- // set motion
- mv[list] = mvTemp[list][idx];
- refIdx[list] = idx;
- }
-
- if (list == 1 && costTemp < costValidList1)
- {
- costValidList1 = costTemp;
- bitsValidList1 = bitsTemp;
-
- // set motion
- mvValidList1 = mvTemp[list][idx];
- refIdxValidList1 = idx;
- }
- }
- }
-
- // Bi-directional prediction
- if ((cu->getSlice()->isInterB()) && (cu->isBipredRestriction() == false))
- {
- mvBidir[0] = mv[0];
- mvBidir[1] = mv[1];
- refIdxBidir[0] = refIdx[0];
- refIdxBidir[1] = refIdx[1];
-
- ::memcpy(mvPredBi, mvPred, sizeof(mvPred));
- ::memcpy(mvpIdxBi, mvpIdx, sizeof(mvpIdx));
-
- // Generate reference subpels
- xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(REF_PIC_LIST_0, refIdx[0])->getPicYuvRec(), partAddr, &mv[0], roiWidth, roiHeight, &m_predYuv[0]);
- xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(REF_PIC_LIST_1, refIdx[1])->getPicYuvRec(), partAddr, &mv[1], roiWidth, roiHeight, &m_predYuv[1]);
-
- pixel *ref0 = m_predYuv[0].getLumaAddr(partAddr);
- pixel *ref1 = m_predYuv[1].getLumaAddr(partAddr);
-
- ALIGN_VAR_32(pixel, avg[MAX_CU_SIZE * MAX_CU_SIZE]);
-
- int partEnum = partitionFromSizes(roiWidth, roiHeight);
- primitives.pixelavg_pp[partEnum](avg, roiWidth, ref0, m_predYuv[0].getStride(), ref1, m_predYuv[1].getStride(), 32);
- int satdCost = primitives.satd[partEnum](pu, fenc->getStride(), avg, roiWidth);
- x265_emms();
- bits[2] = bits[0] + bits[1] - mbBits[0] - mbBits[1] + mbBits[2];
- costbi = satdCost + m_rdCost->getCost(bits[2]);
-
- if (mv[0].notZero() || mv[1].notZero())
- {
- ref0 = m_mref[0][refIdx[0]]->fpelPlane + (pu - fenc->getLumaAddr()); //MV(0,0) of ref0
- ref1 = m_mref[1][refIdx[1]]->fpelPlane + (pu - fenc->getLumaAddr()); //MV(0,0) of ref1
- intptr_t refStride = m_mref[0][refIdx[0]]->lumaStride;
-
- primitives.pixelavg_pp[partEnum](avg, roiWidth, ref0, refStride, ref1, refStride, 32);
- satdCost = primitives.satd[partEnum](pu, fenc->getStride(), avg, roiWidth);
- x265_emms();
-
- unsigned int bitsZero0, bitsZero1;
- m_me.setMVP(mvPredBi[0][refIdxBidir[0]]);
- bitsZero0 = bits[0] - m_me.bitcost(mv[0]) + m_me.bitcost(mvzero);
-
- m_me.setMVP(mvPredBi[1][refIdxBidir[1]]);
- bitsZero1 = bits[1] - m_me.bitcost(mv[1]) + m_me.bitcost(mvzero);
-
- uint32_t costZero = satdCost + m_rdCost->getCost(bitsZero0) + m_rdCost->getCost(bitsZero1);
-
- MV mvpZero[2];
- int mvpidxZero[2];
- mvpZero[0] = mvPredBi[0][refIdxBidir[0]];
- mvpidxZero[0] = mvpIdxBi[0][refIdxBidir[0]];
- xCheckBestMVP(&amvpInfo[0][refIdxBidir[0]], mvzero, mvpZero[0], mvpidxZero[0], bitsZero0, costZero);
- mvpZero[1] = mvPredBi[1][refIdxBidir[1]];
- mvpidxZero[1] = mvpIdxBi[1][refIdxBidir[1]];
- xCheckBestMVP(&amvpInfo[1][refIdxBidir[1]], mvzero, mvpZero[1], mvpidxZero[1], bitsZero1, costZero);
-
- if (costZero < costbi)
- {
- costbi = costZero;
- mvBidir[0].x = mvBidir[0].y = 0;
- mvBidir[1].x = mvBidir[1].y = 0;
- mvPredBi[0][refIdxBidir[0]] = mvpZero[0];
- mvPredBi[1][refIdxBidir[1]] = mvpZero[1];
- mvpIdxBi[0][refIdxBidir[0]] = mvpidxZero[0];
- mvpIdxBi[1][refIdxBidir[1]] = mvpidxZero[1];
- bits[2] = bitsZero0 + bitsZero1 - mbBits[0] - mbBits[1] + mbBits[2];
- }
- }
- } // if (B_SLICE)
- }
-
- // Clear Motion Field
- cu->getCUMvField(REF_PIC_LIST_0)->setAllMvField(TComMvField(), partSize, partAddr, 0, partIdx);
- cu->getCUMvField(REF_PIC_LIST_1)->setAllMvField(TComMvField(), partSize, partAddr, 0, partIdx);
-
- uint32_t mebits = 0;
- // Set Motion Field_
- mv[1] = mvValidList1;
- refIdx[1] = refIdxValidList1;
- bits[1] = bitsValidList1;
- listCost[1] = costValidList1;
-
- if (!bMergeOnly)
- {
- if (costbi <= listCost[0] && costbi <= listCost[1])
- {
- lastMode = 2;
- {
- cu->getCUMvField(REF_PIC_LIST_0)->setAllMv(mvBidir[0], partSize, partAddr, 0, partIdx);
- cu->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx(refIdxBidir[0], partSize, partAddr, 0, partIdx);
- cu->getCUMvField(REF_PIC_LIST_1)->setAllMv(mvBidir[1], partSize, partAddr, 0, partIdx);
- cu->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx(refIdxBidir[1], partSize, partAddr, 0, partIdx);
- }
- {
- MV mvtmp = mvBidir[0] - mvPredBi[0][refIdxBidir[0]];
- cu->getCUMvField(REF_PIC_LIST_0)->setMvd(partAddr, mvtmp);
- }
- {
- MV mvtmp = mvBidir[1] - mvPredBi[1][refIdxBidir[1]];
- cu->getCUMvField(REF_PIC_LIST_1)->setMvd(partAddr, mvtmp);
- }
-
- cu->setInterDirSubParts(3, partAddr, partIdx, cu->getDepth(0));
-
- cu->setMVPIdx(REF_PIC_LIST_0, partAddr, mvpIdxBi[0][refIdxBidir[0]]);
- cu->setMVPIdx(REF_PIC_LIST_1, partAddr, mvpIdxBi[1][refIdxBidir[1]]);
-
- mebits = bits[2];
- }
- else if (listCost[0] <= listCost[1])
- {
- lastMode = 0;
- cu->getCUMvField(REF_PIC_LIST_0)->setAllMv(mv[0], partSize, partAddr, 0, partIdx);
- cu->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx(refIdx[0], partSize, partAddr, 0, partIdx);
- {
- MV mvtmp = mv[0] - mvPred[0][refIdx[0]];
- cu->getCUMvField(REF_PIC_LIST_0)->setMvd(partAddr, mvtmp);
- }
- cu->setInterDirSubParts(1, partAddr, partIdx, cu->getDepth(0));
-
- cu->setMVPIdx(REF_PIC_LIST_0, partAddr, mvpIdx[0][refIdx[0]]);
-
- mebits = bits[0];
- }
- else
- {
- lastMode = 1;
- cu->getCUMvField(REF_PIC_LIST_1)->setAllMv(mv[1], partSize, partAddr, 0, partIdx);
- cu->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx(refIdx[1], partSize, partAddr, 0, partIdx);
- {
- MV mvtmp = mv[1] - mvPred[1][refIdx[1]];
- cu->getCUMvField(REF_PIC_LIST_1)->setMvd(partAddr, mvtmp);
- }
- cu->setInterDirSubParts(2, partAddr, partIdx, cu->getDepth(0));
-
- cu->setMVPIdx(REF_PIC_LIST_1, partAddr, mvpIdx[1][refIdx[1]]);
-
- mebits = bits[1];
- }
- }
More information about the x265-commits
mailing list