Commit 2eeba2b7 authored by Lin Yu Cheng's avatar Lin Yu Cheng Committed by Xiang Li

M0170 shared merging list candidate

parent 6543133f
......@@ -89,6 +89,10 @@ public:
int prevQP[MAX_NUM_CHANNEL_TYPE];
int currQP[MAX_NUM_CHANNEL_TYPE];
int chromaQpAdj;
#if JVET_M0170_MRG_SHARELIST
Position sharedBndPos;
Size sharedBndSize;
#endif
bool isLossless;
const SPS *sps;
const PPS *pps;
......
......@@ -63,6 +63,9 @@ class Mv;
class InterPrediction : public WeightPrediction
{
private:
#if JVET_M0170_MRG_SHARELIST
int m_shareState;
#endif
Distortion m_bioDistThres;
Distortion m_bioSubBlkDistThres;
......@@ -157,7 +160,9 @@ public:
#if JVET_J0090_MEMORY_BANDWITH_MEASURE
void cacheAssign( CacheModel *cache );
#endif
#if JVET_M0170_MRG_SHARELIST
void setShareState(int shareStateIn) {m_shareState = shareStateIn;}
#endif
};
//! \}
......
......@@ -137,6 +137,9 @@ Slice::Slice()
, m_uiMaxTTSizeIChroma ( 0 )
, m_uiMaxBTSize ( 0 )
, m_MotionCandLut (NULL)
#if JVET_M0170_MRG_SHARELIST
, m_MotionCandLuTsBkup (NULL)
#endif
{
for(uint32_t i=0; i<NUM_REF_PIC_LIST_01; i++)
{
......@@ -1611,6 +1614,12 @@ void Slice::initMotionLUTs()
m_MotionCandLut->currCnt = 0;
m_MotionCandLut->motionCand = nullptr;
m_MotionCandLut->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS];
#if JVET_M0170_MRG_SHARELIST
m_MotionCandLuTsBkup = new LutMotionCand;
m_MotionCandLuTsBkup->currCnt = 0;
m_MotionCandLuTsBkup->motionCand = nullptr;
m_MotionCandLuTsBkup->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS];
#endif
}
void Slice::destroyMotionLUTs()
{
......@@ -1618,18 +1627,31 @@ void Slice::destroyMotionLUTs()
m_MotionCandLut->motionCand = nullptr;
delete m_MotionCandLut;
m_MotionCandLut = NULL;
#if JVET_M0170_MRG_SHARELIST
delete[] m_MotionCandLuTsBkup->motionCand;
m_MotionCandLuTsBkup->motionCand = nullptr;
delete m_MotionCandLuTsBkup;
m_MotionCandLuTsBkup = NULL;
#endif
}
void Slice::resetMotionLUTs()
{
m_MotionCandLut->currCnt = 0;
#if JVET_M0170_MRG_SHARELIST
m_MotionCandLuTsBkup->currCnt = 0;
#endif
}
MotionInfo Slice::getMotionInfoFromLUTs(int MotCandIdx) const
{
return m_MotionCandLut->motionCand[MotCandIdx];
}
#if JVET_M0170_MRG_SHARELIST
MotionInfo Slice::getMotionInfoFromLUTBkup(int MotCandIdx) const
{
return m_MotionCandLuTsBkup->motionCand[MotCandIdx];
}
#endif
void Slice::addMotionInfoToLUTs(LutMotionCand* lutMC, MotionInfo newMi)
{
......
......@@ -1665,7 +1665,10 @@ private:
AlfSliceParam m_alfSliceParam;
LutMotionCand* m_MotionCandLut;
#if JVET_M0170_MRG_SHARELIST
public:
LutMotionCand* m_MotionCandLuTsBkup;
#endif
public:
Slice();
virtual ~Slice();
......@@ -1947,6 +1950,10 @@ public:
void destroyMotionLUTs ();
void resetMotionLUTs();
int getAvailableLUTMrgNum() const { return m_MotionCandLut->currCnt; }
#if JVET_M0170_MRG_SHARELIST
int getAvailableLUTBkupMrgNum() const { return m_MotionCandLuTsBkup->currCnt; }
MotionInfo getMotionInfoFromLUTBkup(int MotCandIdx) const;
#endif
MotionInfo getMotionInfoFromLUTs(int MotCandIdx) const;
LutMotionCand* getMotionLUTs() { return m_MotionCandLut; }
......
......@@ -54,10 +54,16 @@
#define JVET_M0444_SMVD 1 // SMVD mode
#define JVET_M0170_MRG_SHARELIST 1
#if JVET_M0170_MRG_SHARELIST
#define MRG_SHARELIST_SHARSIZE 32
#endif
#define JVET_M0064_CCLM_SIMPLIFICATION 1
#define JVET_M0142_CCLM_COLLOCATED_CHROMA 1 // Adding support for chroma sample location type 2 in CCLM
#define JVET_M0479_18BITS_MV_CLIP 1
#define JVET_M0497_FAST_DST7 1
......@@ -884,6 +890,14 @@ enum TriangleSplit
TRIANGLE_DIR_NUM
};
#if JVET_M0170_MRG_SHARELIST
enum SharedMrgState
{
NO_SHARE = 0,
GEN_ON_SHARED_BOUND = 1,
SHARING = 2
};
#endif
//////////////////////////////////////////////////////////////////////////
// Encoder modes to try out
//////////////////////////////////////////////////////////////////////////
......
......@@ -272,6 +272,11 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other )
GBiIdx = other.GBiIdx;
for (int i = 0; i<2; i++)
refIdxBi[i] = other.refIdxBi[i];
#if JVET_M0170_MRG_SHARELIST
shareParentPos = other.shareParentPos;
shareParentSize = other.shareParentSize;
#endif
ibc = other.ibc;
#if JVET_M0444_SMVD
smvdMode = other.smvdMode;
......@@ -309,6 +314,11 @@ void CodingUnit::initData()
GBiIdx = GBI_DEFAULT;
for (int i = 0; i < 2; i++)
refIdxBi[i] = -1;
#if JVET_M0170_MRG_SHARELIST
shareParentPos = Position(-1, -1);
shareParentSize.width = -1;
shareParentSize.height = -1;
#endif
ibc = false;
#if JVET_M0444_SMVD
smvdMode = 0;
......@@ -356,6 +366,11 @@ void PredictionUnit::initData()
}
}
mhIntraFlag = false;
#if JVET_M0170_MRG_SHARELIST
shareParentPos = Position(-1, -1);
shareParentSize.width = -1;
shareParentSize.height = -1;
#endif
}
PredictionUnit& PredictionUnit::operator=(const IntraPredictionData& predData)
......@@ -396,7 +411,10 @@ PredictionUnit& PredictionUnit::operator=(const InterPredictionData& predData)
}
}
mhIntraFlag = predData.mhIntraFlag;
#if JVET_M0170_MRG_SHARELIST
shareParentPos = predData.shareParentPos;
shareParentSize = predData.shareParentSize;
#endif
return *this;
}
......@@ -433,7 +451,10 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other )
}
}
mhIntraFlag = other.mhIntraFlag;
#if JVET_M0170_MRG_SHARELIST
shareParentPos = other.shareParentPos;
shareParentSize = other.shareParentSize;
#endif
return *this;
}
......
......@@ -312,6 +312,10 @@ struct CodingUnit : public UnitArea
int refIdxBi[2];
// needed for fast imv mode decisions
int8_t imvNumCand;
#if JVET_M0170_MRG_SHARELIST
Position shareParentPos;
Size shareParentSize;
#endif
bool ibc;
#if JVET_M0444_SMVD
uint8_t smvdMode;
......@@ -366,6 +370,11 @@ struct InterPredictionData
Mv mvdAffi [NUM_REF_PIC_LIST_01][3];
Mv mvAffi[NUM_REF_PIC_LIST_01][3];
bool mhIntraFlag;
#if JVET_M0170_MRG_SHARELIST
Position shareParentPos;
Size shareParentSize;
#endif
Mv bv; // block vector for IBC
Mv bvd; // block vector difference for IBC
};
......@@ -389,6 +398,11 @@ struct PredictionUnit : public UnitArea, public IntraPredictionData, public Inte
PredictionUnit& operator=(const MotionInfo& mi);
unsigned idx;
#if JVET_M0170_MRG_SHARELIST
Position shareParentPos;
Size shareParentSize;
#endif
PredictionUnit *next;
// for accessing motion information, which can have higher resolution than PUs (should always be used, when accessing neighboring motion information)
......
......@@ -712,6 +712,9 @@ bool PU::xCheckSimilarMotion(const int mergeCandIndex, const int prevCnt, const
bool PU::addMergeHMVPCand(const Slice &slice, MergeCtx& mrgCtx, bool canFastExit, const int& mrgCandIdx, const uint32_t maxNumMergeCandMin1, int &cnt, const int prevCnt, bool isAvailableSubPu, unsigned subPuMvpPos
, int mmvdList
#if JVET_M0170_MRG_SHARELIST
, bool isShared
#endif
)
#else
......@@ -728,10 +731,19 @@ bool PU::addMergeHMVPCand(const Slice &slice, MergeCtx& mrgCtx, bool isCandInter
{
hasPruned[subPuMvpPos] = true;
}
#if JVET_M0170_MRG_SHARELIST
int num_avai_candInLUT = (isShared ? slice.getAvailableLUTBkupMrgNum() : slice.getAvailableLUTMrgNum());
#else
int num_avai_candInLUT = slice.getAvailableLUTMrgNum();
#endif
for (int mrgIdx = 1; mrgIdx <= num_avai_candInLUT; mrgIdx++)
{
#if JVET_M0170_MRG_SHARELIST
miNeighbor = isShared ? slice.getMotionInfoFromLUTBkup(num_avai_candInLUT - mrgIdx) : slice.getMotionInfoFromLUTs(num_avai_candInLUT - mrgIdx);
#else
miNeighbor = slice.getMotionInfoFromLUTs(num_avai_candInLUT - mrgIdx);
#endif
mrgCtx.interDirNeighbours[cnt] = miNeighbor.interDir;
mrgCtx.mvFieldNeighbours[cnt << 1].setMvField(miNeighbor.mv[0], miNeighbor.refIdx[0]);
if (slice.isInterB())
......@@ -797,10 +809,15 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
int mrgCandIdxIBC = mrgCandIdx;
#if JVET_M0170_MRG_SHARELIST
const Position posLT = pu.shareParentPos;
const Position posRT = pu.shareParentPos.offset(pu.shareParentSize.width - 1, 0);
const Position posLB = pu.shareParentPos.offset(0, pu.shareParentSize.height - 1);
#else
const Position posLT = pu.Y().topLeft();
const Position posRT = pu.Y().topRight();
const Position posLB = pu.Y().bottomLeft();
#endif
MotionInfo miAbove, miLeft, miAboveLeft, miAboveRight, miBelowLeft;
//left
......@@ -1051,13 +1068,24 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
{
//>> MTK colocated-RightBottom
// offset the pos to be sure to "point" to the same position the uiAbsPartIdx would've pointed to
#if JVET_M0170_MRG_SHARELIST
Position posRB = pu.shareParentPos.offset(pu.shareParentSize.width-3, pu.shareParentSize.height - 3);
#else
Position posRB = pu.Y().bottomRight().offset(-3, -3);
#endif
const PreCalcValues& pcv = *cs.pcv;
Position posC0;
#if JVET_M0170_MRG_SHARELIST
Position posC1 = pu.shareParentPos.offset((pu.shareParentSize.width/2), (pu.shareParentSize.height/2));
#else
Position posC1 = pu.Y().center();
#endif
bool C0Avail = false;
#if JVET_M0170_MRG_SHARELIST
bool C1Avail = (posC1.x < pcv.lumaWidth) && (posC1.y < pcv.lumaHeight);
#endif
if (((posRB.x + pcv.minCUWidth) < pcv.lumaWidth) && ((posRB.y + pcv.minCUHeight) < pcv.lumaHeight))
{
......@@ -1093,7 +1121,11 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
int dir = 0;
unsigned uiArrayAddr = cnt;
bool bExistMV = ( C0Avail && getColocatedMVP(pu, REF_PIC_LIST_0, posC0, cColMv, iRefIdx ) )
#if JVET_M0170_MRG_SHARELIST
|| ( C1Avail && getColocatedMVP(pu, REF_PIC_LIST_0, posC1, cColMv, iRefIdx ));
#else
|| getColocatedMVP(pu, REF_PIC_LIST_0, posC1, cColMv, iRefIdx );
#endif
if (bExistMV)
{
......@@ -1104,7 +1136,11 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
if (slice.isInterB())
{
bExistMV = ( C0Avail && getColocatedMVP(pu, REF_PIC_LIST_1, posC0, cColMv, iRefIdx ) )
#if JVET_M0170_MRG_SHARELIST
|| (C1Avail && getColocatedMVP(pu, REF_PIC_LIST_1, posC1, cColMv, iRefIdx ) );
#else
|| getColocatedMVP(pu, REF_PIC_LIST_1, posC1, cColMv, iRefIdx );
#endif
if (bExistMV)
{
dir |= 2;
......@@ -1156,10 +1192,16 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
bool isAvailableSubPu = false;
unsigned subPuMvpPos = 0;
#if JVET_L0090_PAIR_AVG
#if JVET_M0170_MRG_SHARELIST
bool isShared = ((pu.Y().lumaSize().width != pu.shareParentSize.width) || (pu.Y().lumaSize().height != pu.shareParentSize.height));
#endif
bool bFound = addMergeHMVPCand(slice, mrgCtx, canFastExit
, (mmvdList != 0 && mrgCandIdx != -1) ? (const int) mrgCandIdxIBC : mrgCandIdx
, maxNumMergeCandMin1, cnt, cnt, isAvailableSubPu, subPuMvpPos
, mmvdList
#if JVET_M0170_MRG_SHARELIST
, isShared
#endif
);
#else
bool bFound = addMergeHMVPCand(slice, mrgCtx, isCandInter, canFastExit
......@@ -1848,6 +1890,9 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, const in
Position posC0;
bool C0Avail = false;
Position posC1 = pu.Y().center();
#if JVET_M0170_MRG_SHARELIST
bool C1Avail = ( posC1.x < pcv.lumaWidth ) && ( posC1.y < pcv.lumaHeight ) ;
#endif
Mv cColMv;
......@@ -1878,7 +1923,11 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, const in
}
}
#if JVET_M0170_MRG_SHARELIST
if ((C0Avail && getColocatedMVP(pu, eRefPicList, posC0, cColMv, refIdx_Col)) || (C1Avail && getColocatedMVP(pu, eRefPicList, posC1, cColMv, refIdx_Col)))
#else
if ((C0Avail && getColocatedMVP(pu, eRefPicList, posC0, cColMv, refIdx_Col)) || getColocatedMVP(pu, eRefPicList, posC1, cColMv, refIdx_Col))
#endif
{
if (pu.cu->imv != 0)
{
......@@ -2195,6 +2244,9 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, co
Position posC0;
bool C0Avail = false;
Position posC1 = pu.Y().center();
#if JVET_M0170_MRG_SHARELIST
bool C1Avail = ( posC1.x < pcv.lumaWidth ) && ( posC1.y < pcv.lumaHeight ) ;
#endif
Mv cColMv;
if ( ((posRB.x + pcv.minCUWidth) < pcv.lumaWidth) && ((posRB.y + pcv.minCUHeight) < pcv.lumaHeight) )
......@@ -2224,7 +2276,11 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, co
}
}
#if JVET_M0170_MRG_SHARELIST
if ( (C0Avail && getColocatedMVP( pu, eRefPicList, posC0, cColMv, refIdxCol )) || (C1Avail && getColocatedMVP( pu, eRefPicList, posC1, cColMv, refIdxCol ) ) )
#else
if ( (C0Avail && getColocatedMVP( pu, eRefPicList, posC0, cColMv, refIdxCol )) || getColocatedMVP( pu, eRefPicList, posC1, cColMv, refIdxCol ) )
#endif
{
cColMv.roundToPrecision(MV_PRECISION_INTERNAL, MV_PRECISION_QUARTER);
affiAMVPInfo.mvCandLT[affiAMVPInfo.numCand] = cColMv;
......@@ -3699,6 +3755,9 @@ void PU::getTriangleMergeCandidates( const PredictionUnit &pu, MergeCtx& triangl
Position posC0;
Position posC1 = pu.Y().center();
bool isAvailableC0 = false;
#if JVET_M0170_MRG_SHARELIST
bool isAvailableC1 = (posC1.x < pcv.lumaWidth) && (posC1.y < pcv.lumaHeight);
#endif
if (((posRB.x + pcv.minCUWidth) < pcv.lumaWidth) && ((posRB.y + pcv.minCUHeight) < pcv.lumaHeight))
{
......@@ -3761,7 +3820,11 @@ void PU::getTriangleMergeCandidates( const PredictionUnit &pu, MergeCtx& triangl
// C1
temporalMv.interDir = 0;
#if JVET_M0170_MRG_SHARELIST
existMV = isAvailableC1 && getColocatedMVP(pu, REF_PIC_LIST_0, posC1, cColMv, refIdx );
#else
existMV = getColocatedMVP(pu, REF_PIC_LIST_0, posC1, cColMv, refIdx );
#endif
if( existMV )
{
temporalMv.isInter = true;
......@@ -3769,7 +3832,11 @@ void PU::getTriangleMergeCandidates( const PredictionUnit &pu, MergeCtx& triangl
temporalMv.mv[0] = cColMv;
temporalMv.refIdx[0] = refIdx;
}
#if JVET_M0170_MRG_SHARELIST
existMV = isAvailableC1 && getColocatedMVP(pu, REF_PIC_LIST_1, posC1, cColMv, refIdx );
#else
existMV = getColocatedMVP(pu, REF_PIC_LIST_1, posC1, cColMv, refIdx );
#endif
if( existMV )
{
temporalMv.interDir |= 2;
......
......@@ -120,6 +120,9 @@ namespace PU
#if JVET_L0090_PAIR_AVG
bool addMergeHMVPCand(const Slice &slice, MergeCtx& mrgCtx, bool canFastExit, const int& mrgCandIdx, const uint32_t maxNumMergeCandMin1, int &cnt, const int prevCnt, bool isAvailableSubPu, unsigned subPuMvpPos
, int mmvdList
#if JVET_M0170_MRG_SHARELIST
, bool isShared
#endif
);
#else
bool addMergeHMVPCand(const Slice &slice, MergeCtx& mrgCtx, bool isCandInter[MRG_MAX_NUM_CANDS], bool canFastExit, const int& mrgCandIdx, const uint32_t maxNumMergeCandMin1, int &cnt, const int prevCnt, bool isAvailableSubPu, unsigned subPuMvpPos
......
......@@ -420,6 +420,9 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU
pCuCtxChroma->isChromaQpAdjCoded = false;
}
}
#if JVET_M0170_MRG_SHARELIST
int startShareThisLevel = 0;
#endif
#if JVET_M0421_SPLIT_SIG
const PartSplit splitMode = split_cu_mode( cs, partitioner );
......@@ -448,6 +451,33 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU
// quad-tree split
if( qtSplit )
{
#endif
#if JVET_M0170_MRG_SHARELIST
const PartSplit split = splitMode;
int splitRatio = 1;
CHECK(!(split == CU_QUAD_SPLIT || split == CU_HORZ_SPLIT || split == CU_VERT_SPLIT
|| split == CU_TRIH_SPLIT || split == CU_TRIV_SPLIT), "invalid split type");
splitRatio = (split == CU_HORZ_SPLIT || split == CU_VERT_SPLIT) ? 1 : 2;
bool isOneChildSmall = (((partitioner.currArea().lwidth())*(partitioner.currArea().lheight())) >> splitRatio) < MRG_SHARELIST_SHARSIZE;
if ((((partitioner.currArea().lwidth())*(partitioner.currArea().lheight())) > (MRG_SHARELIST_SHARSIZE * 1)))
{
shareStateDec = NO_SHARE;
}
if (shareStateDec == NO_SHARE)//init state
{
if (isOneChildSmall)
{
shareStateDec = SHARING;//share start state
startShareThisLevel = 1;
shareParentPos = partitioner.currArea().lumaPos();
shareParentSize.width = partitioner.currArea().lwidth();
shareParentSize.height = partitioner.currArea().lheight();
}
}
#endif
if (CS::isDualITree(cs) && pPartitionerChroma != nullptr && (partitioner.currArea().lwidth() >= 64 || partitioner.currArea().lheight() >= 64))
{
......@@ -543,6 +573,10 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU
partitioner.exitCurrSplit();
}
#if JVET_M0170_MRG_SHARELIST
if (startShareThisLevel == 1)
shareStateDec = NO_SHARE;
#endif
return lastSegment;
#if !JVET_M0421_SPLIT_SIG
}
......@@ -560,6 +594,33 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU
if( splitMode != CU_DONT_SPLIT )
{
#if JVET_M0170_MRG_SHARELIST
const PartSplit split = splitMode;
int splitRatio = 1;
CHECK(!(split == CU_QUAD_SPLIT || split == CU_HORZ_SPLIT || split == CU_VERT_SPLIT
|| split == CU_TRIH_SPLIT || split == CU_TRIV_SPLIT), "invalid split type");
splitRatio = (split == CU_HORZ_SPLIT || split == CU_VERT_SPLIT) ? 1 : 2;
bool isOneChildSmall = (((partitioner.currArea().lwidth())*(partitioner.currArea().lheight())) >> splitRatio) < MRG_SHARELIST_SHARSIZE;
if ((((partitioner.currArea().lwidth())*(partitioner.currArea().lheight())) > (MRG_SHARELIST_SHARSIZE * 1)))
{
shareStateDec = NO_SHARE;
}
if (shareStateDec == NO_SHARE)//init state
{
if (isOneChildSmall)
{
shareStateDec = SHARING;//share start state
startShareThisLevel = 1;
shareParentPos = partitioner.currArea().lumaPos();
shareParentSize.width = partitioner.currArea().lwidth();
shareParentSize.height = partitioner.currArea().lheight();
}
}
#endif
partitioner.splitCurrArea( splitMode, cs );
do
......@@ -571,6 +632,10 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU
} while( partitioner.nextPart( cs ) );
partitioner.exitCurrSplit();
#if JVET_M0170_MRG_SHARELIST
if (startShareThisLevel == 1)
shareStateDec = NO_SHARE;
#endif
return lastSegment;
}
}
......@@ -604,10 +669,18 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU
cu.chromaQpAdj = cs.chromaQpAdj; //NOTE: CU chroma QP adjustment can be changed by adjustment signaling at TU level
// coding unit
#if JVET_M0170_MRG_SHARELIST
cu.shareParentPos = (shareStateDec == SHARING) ? shareParentPos : partitioner.currArea().lumaPos();
cu.shareParentSize = (shareStateDec == SHARING) ? shareParentSize : partitioner.currArea().lumaSize();
#endif
bool isLastCtu = coding_unit( cu, partitioner, cuCtx );
DTRACE( g_trace_ctx, D_QP, "x=%d, y=%d, w=%d, h=%d, qp=%d\n", cu.Y().x, cu.Y().y, cu.Y().width, cu.Y().height, cu.qp );
#if JVET_M0170_MRG_SHARELIST
if (startShareThisLevel == 1)
shareStateDec = NO_SHARE;
#endif
return isLastCtu;
}
......@@ -822,6 +895,10 @@ bool CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx&
{
cs.addTU ( cu, partitioner.chType );
PredictionUnit& pu = cs.addPU( cu, partitioner.chType );
#if JVET_M0170_MRG_SHARELIST
pu.shareParentPos = cu.shareParentPos;
pu.shareParentSize = cu.shareParentSize;
#endif
MergeCtx mrgCtx;
prediction_unit ( pu, mrgCtx );
return end_of_ctu( cu, cuCtx );
......@@ -972,6 +1049,10 @@ void CABACReader::cu_pred_data( CodingUnit &cu )
for( auto &pu : CU::traversePUs( cu ) )
{
#if JVET_M0170_MRG_SHARELIST
pu.shareParentPos = cu.shareParentPos;
pu.shareParentSize = cu.shareParentSize;
#endif
prediction_unit( pu, mrgCtx );
}
......
......@@ -48,7 +48,11 @@
class CABACReader
{
public:
#if JVET_M0170_MRG_SHARELIST
CABACReader(BinDecoderBase& binDecoder) : shareStateDec(0), m_BinDecoder(binDecoder), m_Bitstream(0) {}
#else
CABACReader( BinDecoderBase& binDecoder ) : m_BinDecoder( binDecoder ), m_Bitstream( 0 ) {}
#endif
virtual ~CABACReader() {}
public:
......@@ -154,7 +158,12 @@ private:
unsigned get_num_bits_read () { return m_BinDecoder.getNumBitsRead(); }
void xReadTruncBinCode(uint32_t& symbol, uint32_t maxSymbol);
#if JVET_M0170_MRG_SHARELIST
public:
int shareStateDec;
Position shareParentPos;
Size shareParentSize;
#endif
private:
BinDecoderBase& m_BinDecoder;
InputBitstream* m_Bitstream;
......
......@@ -81,14 +81,42 @@ void DecCu::init( TrQuant* pcTrQuant, IntraPrediction* pcIntra, InterPrediction*
void DecCu::decompressCtu( CodingStructure& cs, const UnitArea& ctuArea )
{
const int maxNumChannelType = cs.pcv->chrFormat != CHROMA_400 && CS::isDualITree( cs ) ? 2 : 1;
#if JVET_M0170_MRG_SHARELIST
if (!cs.pcv->isEncoder)
{
m_shareStateDec = NO_SHARE;
}
bool sharePrepareCondition = ((!cs.pcv->isEncoder) && (!(cs.slice->isIntra())));
#endif
for( int ch = 0; ch < maxNumChannelType; ch++ )
{
const ChannelType chType = ChannelType( ch );
#if JVET_M0170_MRG_SHARELIST
Position prevTmpPos;
prevTmpPos.x = -1; prevTmpPos.y = -1;
#endif
for( auto &currCU : cs.traverseCUs( CS::getArea( cs, ctuArea, chType ), chType ) )
{
#if JVET_M0170_MRG_SHARELIST
if(sharePrepareCondition)
{
if ((currCU.shareParentPos.x >= 0) && (!(currCU.shareParentPos.x == prevTmpPos.x && currCU.shareParentPos.y == prevTmpPos.y)))
{
m_shareStateDec = GEN_ON_SHARED_BOUND;
cs.slice->copyMotionLUTs(cs.slice->getMotionLUTs(), cs.slice->m_MotionCandLuTsBkup);
}
if (currCU.shareParentPos.x < 0)
{
m_shareStateDec = 0;
}