diff --git a/source/Lib/CommonLib/CodingStructure.h b/source/Lib/CommonLib/CodingStructure.h index ae9642fd1b425f8a2f39f706257aba4eb5b52af2..31b7576d7cd8c42d943fd2e6310f83f2ca6b0df6 100644 --- a/source/Lib/CommonLib/CodingStructure.h +++ b/source/Lib/CommonLib/CodingStructure.h @@ -85,8 +85,10 @@ public: int prevQP[MAX_NUM_CHANNEL_TYPE]; int currQP[MAX_NUM_CHANNEL_TYPE]; int chromaQpAdj; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST Position sharedBndPos; Size sharedBndSize; +#endif bool isLossless; const SPS *sps; const PPS *pps; diff --git a/source/Lib/CommonLib/InterPrediction.h b/source/Lib/CommonLib/InterPrediction.h index 350f30d1336826374f1b247c046a3dfcdbeb3bef..b28b49dd3c93969837a8ef870ff9575f4ba593e8 100644 --- a/source/Lib/CommonLib/InterPrediction.h +++ b/source/Lib/CommonLib/InterPrediction.h @@ -63,7 +63,9 @@ class Mv; class InterPrediction : public WeightPrediction { private: +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST int m_shareState; +#endif @@ -189,9 +191,11 @@ public: #if JVET_J0090_MEMORY_BANDWITH_MEASURE void cacheAssign( CacheModel *cache ); #endif +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST void setShareState(int shareStateIn) {m_shareState = shareStateIn;} #if ENABLE_SPLIT_PARALLELISM int getShareState() const { return m_shareState; } +#endif #endif static bool isSubblockVectorSpreadOverLimit( int a, int b, int c, int d, int predType ); void xFillIBCBuffer(CodingUnit &cu); diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 24ddb4ccdf9e75ced54ca5ce84d9f8b8cf3883b5..2789b0c211025aba7b3e75319e79475f31bc913e 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #include <assert.h> #include <cassert> +#define JVET_P0400_REMOVE_SHARED_MERGE_LIST 1 // JVET-P0400: removeal of shared merge list + #define JVET_P0436_CQP_OFFSET_SIGNALLING 1 // JVET_P0436: CU chroma QP offset signalling consistent with VPDU and bugfix #define JVET_P0154_PROF_SAMPLE_OFFSET_CLIPPING 1 // JVET-P0154/P0094/P0172/P0413/P0518/P0281: Clip the PROF sample offset to 14-bit @@ -78,7 +80,9 @@ #define JVET_O0625_ALF_PADDING 1 // JVET-O0625/O0654/O0662: Unified padding method in ALF +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST #define MRG_SHARELIST_SHARSIZE 32 +#endif #define JVET_M0497_MATRIX_MULT 0 // 0: Fast method; 1: Matrix multiplication @@ -865,12 +869,14 @@ enum TriangleSplit TRIANGLE_DIR_NUM }; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST enum SharedMrgState { NO_SHARE = 0, GEN_ON_SHARED_BOUND = 1, SHARING = 2 }; +#endif ////////////////////////////////////////////////////////////////////////// // Encoder modes to try out ////////////////////////////////////////////////////////////////////////// diff --git a/source/Lib/CommonLib/Unit.cpp b/source/Lib/CommonLib/Unit.cpp index 332628ec5acd68d77aba84b5a1cdbb0461d64ba8..a3742c476d786d9555f649a0c569aabbe20a08cb 100644 --- a/source/Lib/CommonLib/Unit.cpp +++ b/source/Lib/CommonLib/Unit.cpp @@ -281,8 +281,10 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other ) for (int i = 0; i<2; i++) refIdxBi[i] = other.refIdxBi[i]; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST shareParentPos = other.shareParentPos; shareParentSize = other.shareParentSize; +#endif smvdMode = other.smvdMode; ispMode = other.ispMode; mipFlag = other.mipFlag; @@ -329,9 +331,11 @@ void CodingUnit::initData() GBiIdx = GBI_DEFAULT; for (int i = 0; i < 2; i++) refIdxBi[i] = -1; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST shareParentPos = Position(-1, -1); shareParentSize.width = -1; shareParentSize.height = -1; +#endif smvdMode = 0; ispMode = 0; mipFlag = false; @@ -543,9 +547,11 @@ void PredictionUnit::initData() } } mhIntraFlag = false; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST shareParentPos = Position(-1, -1); shareParentSize.width = -1; shareParentSize.height = -1; +#endif mmvdEncOptMode = 0; } @@ -596,8 +602,10 @@ PredictionUnit& PredictionUnit::operator=(const InterPredictionData& predData) } } mhIntraFlag = predData.mhIntraFlag; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST shareParentPos = predData.shareParentPos; shareParentSize = predData.shareParentSize; +#endif return *this; } @@ -643,8 +651,10 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other ) } } mhIntraFlag = other.mhIntraFlag; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST shareParentPos = other.shareParentPos; shareParentSize = other.shareParentSize; +#endif return *this; } diff --git a/source/Lib/CommonLib/Unit.h b/source/Lib/CommonLib/Unit.h index 739b51f44c6a69e14fba1cdcdc4d3dccb1d8fee2..305aa0ac860c465bb0774dee06546cffc3818a2f 100644 --- a/source/Lib/CommonLib/Unit.h +++ b/source/Lib/CommonLib/Unit.h @@ -323,8 +323,10 @@ struct CodingUnit : public UnitArea // needed for fast imv mode decisions int8_t imvNumCand; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST Position shareParentPos; Size shareParentSize; +#endif uint8_t smvdMode; uint8_t ispMode; bool useEscape[MAX_NUM_COMPONENT]; @@ -401,8 +403,10 @@ struct InterPredictionData Mv mvAffi[NUM_REF_PIC_LIST_01][3]; bool mhIntraFlag; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST Position shareParentPos; Size shareParentSize; +#endif Mv bv; // block vector for IBC Mv bvd; // block vector difference for IBC uint8_t mmvdEncOptMode; // 0: no action 1: skip chroma MC for MMVD candidate pre-selection 2: skip chroma MC and BIO for MMVD candidate pre-selection @@ -427,8 +431,10 @@ struct PredictionUnit : public UnitArea, public IntraPredictionData, public Inte PredictionUnit& operator=(const MotionInfo& mi); unsigned idx; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST Position shareParentPos; Size shareParentSize; +#endif PredictionUnit *next; diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 5bb5e56dbccfa653f527c66a25c74403fdd316c1..5c0e1c37fcb93ea5206d6e9b01604923f2d779b4 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -665,7 +665,12 @@ bool PU::xCheckSimilarMotion(const int mergeCandIndex, const int prevCnt, const bool PU::addMergeHMVPCand(const CodingStructure &cs, MergeCtx& mrgCtx, bool canFastExit, const int& mrgCandIdx, const uint32_t maxNumMergeCandMin1, int &cnt, const int prevCnt, bool isAvailableSubPu, unsigned subPuMvpPos , bool ibcFlag +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST , bool isShared +#endif +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + , bool isGt4x4 +#endif ) { const Slice& slice = *cs.slice; @@ -689,7 +694,11 @@ bool PU::addMergeHMVPCand(const CodingStructure &cs, MergeCtx& mrgCtx, bool canF { mrgCtx.mvFieldNeighbours[(cnt << 1) + 1].setMvField(miNeighbor.mv[1], miNeighbor.refIdx[1]); } +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + if (mrgIdx > 2 || ((mrgIdx > 1 || !isGt4x4) && ibcFlag) || !xCheckSimilarMotion(cnt, prevCnt, mrgCtx, hasPruned)) +#else if (mrgIdx > 2 || (mrgIdx > 1 && ibcFlag) || !xCheckSimilarMotion(cnt, prevCnt, mrgCtx, hasPruned)) +#endif { mrgCtx.GBiIdx[cnt] = (mrgCtx.interDirNeighbours[cnt] == 3) ? miNeighbor.GBiIdx : GBI_DEFAULT; if (mrgCandIdx == cnt && canFastExit) @@ -732,15 +741,27 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const int cnt = 0; +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + const Position posRT = pu.Y().topRight(); + const Position posLB = pu.Y().bottomLeft(); +#else const Position posRT = pu.shareParentPos.offset(pu.shareParentSize.width - 1, 0); const Position posLB = pu.shareParentPos.offset(0, pu.shareParentSize.height - 1); +#endif MotionInfo miAbove, miLeft, miAboveLeft, miAboveRight, miBelowLeft; //left const PredictionUnit* puLeft = cs.getPURestricted(posLB.offset(-1, 0), pu, pu.chType); +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + bool isGt4x4 = pu.lwidth() * pu.lheight() > 16; +#endif const bool isAvailableA1 = puLeft && isDiffMER(pu, *puLeft) && pu.cu != puLeft->cu && CU::isIBC(*puLeft->cu); +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + if (isGt4x4 && isAvailableA1) +#else if (isAvailableA1) +#endif { miLeft = puLeft->getMotionInfo(posLB.offset(-1, 0)); @@ -765,7 +786,11 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const // above const PredictionUnit *puAbove = cs.getPURestricted(posRT.offset(0, -1), pu, pu.chType); bool isAvailableB1 = puAbove && isDiffMER(pu, *puAbove) && pu.cu != puAbove->cu && CU::isIBC(*puAbove->cu); +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + if (isGt4x4 && isAvailableB1) +#else if (isAvailableB1) +#endif { miAbove = puAbove->getMotionInfo(posRT.offset(0, -1)); @@ -799,7 +824,9 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const bool isAvailableSubPu = false; unsigned subPuMvpPos = 0; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST bool isShared = ((pu.Y().lumaSize().width != pu.shareParentSize.width) || (pu.Y().lumaSize().height != pu.shareParentSize.height)); +#endif bool bFound = addMergeHMVPCand(cs, mrgCtx, canFastExit , mrgCandIdx @@ -807,7 +834,12 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const , spatialCandPos , isAvailableSubPu, subPuMvpPos , true +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST , isShared +#endif +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + , isGt4x4 +#endif ); if (bFound) { @@ -1127,14 +1159,24 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, { bool isAvailableSubPu = false; unsigned subPuMvpPos = 0; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST bool isShared = false; +#endif +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + bool isGt4x4 = true; +#endif bool bFound = addMergeHMVPCand(cs, mrgCtx, canFastExit , mrgCandIdx , maxNumMergeCandMin1, cnt , spatialCandPos , isAvailableSubPu, subPuMvpPos , CU::isIBC(*pu.cu) +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST , isShared +#endif +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + , isGt4x4 +#endif ); if (bFound) { diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h index f6c6214f4aecc76baa33c6541e8e339cafe9d046..d9445e937802f71f9d4276a673d7d4d17376dff3 100644 --- a/source/Lib/CommonLib/UnitTools.h +++ b/source/Lib/CommonLib/UnitTools.h @@ -148,7 +148,12 @@ namespace PU bool xCheckSimilarMotion(const int mergeCandIndex, const int prevCnt, const MergeCtx mergeCandList, bool hasPruned[MRG_MAX_NUM_CANDS]); bool addMergeHMVPCand(const CodingStructure &cs, MergeCtx& mrgCtx, bool canFastExit, const int& mrgCandIdx, const uint32_t maxNumMergeCandMin1, int &cnt, const int prevCnt, bool isAvailableSubPu, unsigned subPuMvpPos , bool ibcFlag +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST , bool isShared +#endif +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + , bool isGt4x4 +#endif ); void addAMVPHMVPCand(const PredictionUnit &pu, const RefPicList eRefPicList, const RefPicList eRefPicList2nd, const int currRefPOC, AMVPInfo &info, uint8_t imv); bool addAffineMVPCandUnscaled( const PredictionUnit &pu, const RefPicList &refPicList, const int &refIdx, const Position &pos, const MvpDir &dir, AffineAMVPInfo &affiAmvpInfo ); diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 02f70ab25fa47ce6bf96d13ac7344aac25eb76ff..f5987d816c179b65725e1805689f4f762524208a 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -472,7 +472,9 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU pCuCtxChroma->isChromaQpAdjCoded = false; } } +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST int startShareThisLevel = 0; +#endif const PartSplit splitMode = split_cu_mode( cs, partitioner ); @@ -480,6 +482,7 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU if( splitMode != CU_DONT_SPLIT ) { +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST const PartSplit split = splitMode; int splitRatio = 1; CHECK(!(split == CU_QUAD_SPLIT || split == CU_HORZ_SPLIT || split == CU_VERT_SPLIT @@ -505,6 +508,7 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU shareParentSize.height = partitioner.currArea().lheight(); } } +#endif if (CS::isDualITree(cs) && pPartitionerChroma != nullptr && (partitioner.currArea().lwidth() >= 64 || partitioner.currArea().lheight() >= 64)) { partitioner.splitCurrArea(CU_QUAD_SPLIT, cs); @@ -622,8 +626,10 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU //recover ModeType cs.modeType = partitioner.modeType = modeTypeParent; } +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST if (startShareThisLevel == 1) shareStateDec = NO_SHARE; +#endif return lastSegment; } @@ -659,8 +665,10 @@ 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_P0400_REMOVE_SHARED_MERGE_LIST cu.shareParentPos = (shareStateDec == SHARING) ? shareParentPos : partitioner.currArea().lumaPos(); cu.shareParentSize = (shareStateDec == SHARING) ? shareParentSize : partitioner.currArea().lumaSize(); +#endif bool isLastCtu = coding_unit( cu, partitioner, cuCtx ); //recover cuCtx.qp to luma qp after decoding the chroma CU @@ -703,8 +711,10 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU { 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_P0400_REMOVE_SHARED_MERGE_LIST if (startShareThisLevel == 1) shareStateDec = NO_SHARE; +#endif return isLastCtu; } @@ -836,8 +846,10 @@ bool CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& if( cu.skip ) { cs.addTU ( cu, partitioner.chType ); +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST pu.shareParentPos = cu.shareParentPos; pu.shareParentSize = cu.shareParentSize; +#endif MergeCtx mrgCtx; prediction_unit ( pu, mrgCtx ); return end_of_ctu( cu, cuCtx ); @@ -1177,8 +1189,10 @@ void CABACReader::cu_pred_data( CodingUnit &cu ) for( auto &pu : CU::traversePUs( cu ) ) { +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST pu.shareParentPos = cu.shareParentPos; pu.shareParentSize = cu.shareParentSize; +#endif prediction_unit( pu, mrgCtx ); } diff --git a/source/Lib/DecoderLib/CABACReader.h b/source/Lib/DecoderLib/CABACReader.h index 2fc6a6e336948365296257a3460777c6243cf899..e6e1d6018b9a99d1ef72c474e4c9d76239ad557e 100644 --- a/source/Lib/DecoderLib/CABACReader.h +++ b/source/Lib/DecoderLib/CABACReader.h @@ -48,7 +48,11 @@ class CABACReader { public: +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + CABACReader(BinDecoderBase& binDecoder) : m_BinDecoder(binDecoder), m_Bitstream(0) {} +#else CABACReader(BinDecoderBase& binDecoder) : shareStateDec(0), m_BinDecoder(binDecoder), m_Bitstream(0) {} +#endif virtual ~CABACReader() {} public: @@ -156,9 +160,11 @@ private: uint32_t xReadTruncUnarySymbol ( PLTRunMode runtype, uint32_t maxVal, uint32_t ctxT ); uint32_t xReadTruncMsbP1RefinementBits( PLTRunMode runtype, uint32_t maxVal, uint32_t ctxT ); public: +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST int shareStateDec; Position shareParentPos; Size shareParentSize; +#endif private: BinDecoderBase& m_BinDecoder; InputBitstream* m_Bitstream; diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index 1718b640d96f010fbc146342cb59a5a01c08aa64..8c7ddb113f1a2ae90d8361931b03545cf6a7fc5b 100644 --- a/source/Lib/DecoderLib/DecCu.cpp +++ b/source/Lib/DecoderLib/DecCu.cpp @@ -103,11 +103,13 @@ void DecCu::decompressCtu( CodingStructure& cs, const UnitArea& ctuArea ) { const int maxNumChannelType = cs.pcv->chrFormat != CHROMA_400 && CS::isDualITree( cs ) ? 2 : 1; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST if (!cs.pcv->isEncoder) { m_shareStateDec = NO_SHARE; } bool sharePrepareCondition = ((!cs.pcv->isEncoder) && (!(cs.slice->isIntra()) || cs.slice->getSPS()->getIBCFlag())); +#endif if (cs.resetIBCBuffer) { @@ -130,6 +132,7 @@ void DecCu::decompressCtu( CodingStructure& cs, const UnitArea& ctuArea ) m_pcInterPred->resetVPDUforIBC(cs.pcv->chrFormat, cs.slice->getSPS()->getMaxCUHeight(), vSize, currCU.Y().x, currCU.Y().y); } } +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST if(sharePrepareCondition) { if ((currCU.shareParentPos.x >= 0) && (!(currCU.shareParentPos.x == prevTmpPos.x && currCU.shareParentPos.y == prevTmpPos.y))) @@ -143,6 +146,7 @@ void DecCu::decompressCtu( CodingStructure& cs, const UnitArea& ctuArea ) } prevTmpPos = currCU.shareParentPos; } +#endif if (currCU.predMode != MODE_INTRA && currCU.predMode != MODE_PLT && currCU.Y().valid()) { xDeriveCUMV(currCU); @@ -546,8 +550,13 @@ void DecCu::xReconInter(CodingUnit &cu) if (cu.Y().valid()) { const PredictionUnit &pu = *cu.firstPU; +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + bool isIbcSmallBlk = CU::isIBC(cu) && (cu.lwidth() * cu.lheight() <= 16); + if (!cu.affine && !cu.triangle && !isIbcSmallBlk) +#else bool isShare = ((CU::isIBC(cu) && (cu.shareParentSize.width != cu.Y().lumaSize().width || cu.shareParentSize.height != cu.Y().lumaSize().height)) ? true : false); if (!cu.affine && !cu.triangle && !isShare) +#endif { MotionInfo mi = pu.getMotionInfo(); mi.GBiIdx = (mi.interDir == 3) ? cu.GBiIdx : GBI_DEFAULT; @@ -732,8 +741,10 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) } int fPosBaseIdx = pu.mmvdMergeIdx / MMVD_MAX_REFINE_NUM; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST pu.shareParentPos = cu.shareParentPos; pu.shareParentSize = cu.shareParentSize; +#endif PU::getInterMergeCandidates(pu, mrgCtx, 1, fPosBaseIdx + 1); PU::getInterMMVDMergeCandidates(pu, mrgCtx, pu.mmvdMergeIdx @@ -788,8 +799,10 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) } else { +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST pu.shareParentPos = cu.shareParentPos; pu.shareParentSize = cu.shareParentSize; +#endif if (CU::isIBC(*pu.cu)) PU::getIBCMergeCandidates(pu, mrgCtx, pu.mergeIdx); else @@ -804,8 +817,10 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) } else { +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST pu.shareParentPos = cu.shareParentPos; pu.shareParentSize = cu.shareParentSize; +#endif #if REUSE_CU_RESULTS if ( cu.imv && !pu.cu->affine && !cu.cs->pcv->isEncoder ) #else diff --git a/source/Lib/DecoderLib/DecCu.h b/source/Lib/DecoderLib/DecCu.h index 0fb25d76565075abf41d0e5eda3f45279ec33b2d..4ef4076c087fdbc9a351563c09a61ec0e525a8da 100644 --- a/source/Lib/DecoderLib/DecCu.h +++ b/source/Lib/DecoderLib/DecCu.h @@ -73,9 +73,11 @@ public: void initDecCuReshaper ( Reshape* pcReshape, ChromaFormat chromaFormatIDC) ; void destoryDecCuReshaprBuf(); +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST void setShareStateDec (int shareStateDecIn) { m_shareStateDec = shareStateDecIn; } #if ENABLE_SPLIT_PARALLELISM int getShareStateDec () const { return m_shareStateDec; } +#endif #endif /// reconstruct Ctu information protected: @@ -97,7 +99,9 @@ private: IntraPrediction* m_pcIntraPred; InterPrediction* m_pcInterPred; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST int m_shareStateDec; +#endif MotionInfo m_SubPuMiBuf[(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)]; diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index d315172bb131403f6d6c149d50ccb9a9583ac545..10d54df714e00d0fe6efb503aaa74413b5297f2c 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -274,6 +274,7 @@ void EncCu::init( EncLib* pcEncLib, const SPS& sps PARL_PARAM( const int tId ) ) m_dataId = tId; #endif m_pcLoopFilter = pcEncLib->getLoopFilter(); +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST m_shareState = NO_SHARE; m_pcInterSearch->setShareState(0); setShareStateDec(0); @@ -282,6 +283,7 @@ void EncCu::init( EncLib* pcEncLib, const SPS& sps PARL_PARAM( const int tId ) ) m_shareBndPosY = -1; m_shareBndSizeW = 0; m_shareBndSizeH = 0; +#endif DecCu::init( m_pcTrQuant, m_pcIntraSearch, m_pcInterSearch ); @@ -588,6 +590,7 @@ bool EncCu::xCheckBestMode( CodingStructure *&tempCS, CodingStructure *&bestCS, void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Partitioner& partitioner, double maxCostAllowed ) { CHECK(maxCostAllowed < 0, "Wrong value of maxCostAllowed!"); +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST if (m_shareState == NO_SHARE) { tempCS->sharedBndPos = tempCS->area.Y().lumaPos(); @@ -597,6 +600,7 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par bestCS->sharedBndSize.width = bestCS->area.lwidth(); bestCS->sharedBndSize.height = bestCS->area.lheight(); } +#endif #if ENABLE_SPLIT_PARALLELISM CHECK( m_dataId != tempCS->picture->scheduler.getDataId(), "Working in the wrong dataId!" ); @@ -702,7 +706,9 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par DTRACE( g_trace_ctx, D_COMMON, "@(%4d,%4d) [%2dx%2d]\n", tempCS->area.lx(), tempCS->area.ly(), tempCS->area.lwidth(), tempCS->area.lheight() ); +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST int startShareThisLevel = 0; +#endif m_pcInterSearch->resetSavedAffineMotion(); double bestIntPelCost = MAX_DOUBLE; @@ -898,12 +904,14 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par } } while( m_modeCtrl->nextMode( *tempCS, partitioner ) ); +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST if(startShareThisLevel == 1) { m_shareState = NO_SHARE; m_pcInterSearch->setShareState(m_shareState); setShareStateDec(m_shareState); } +#endif ////////////////////////////////////////////////////////////////////////// // Finishing CU @@ -950,8 +958,13 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par const CodingUnit& cu = *bestCS->cus.front(); const PredictionUnit& pu = *cu.firstPU; +#if JVET_P0400_REMOVE_SHARED_MERGE_LIST + bool isIbcSmallBlk = CU::isIBC(cu) && (cu.lwidth() * cu.lheight() <= 16); + if (!cu.affine && !cu.triangle && !isIbcSmallBlk) +#else bool isShare = ((CU::isIBC(cu) && m_shareState == 2) ? true : false); if (!cu.affine && !cu.triangle && !isShare) +#endif { MotionInfo mi = pu.getMotionInfo(); mi.GBiIdx = (mi.interDir == 3) ? cu.GBiIdx : GBI_DEFAULT; @@ -1216,6 +1229,7 @@ void EncCu::copyState( EncCu* other, Partitioner& partitioner, const UnitArea& c EncReshape *encReshapeOther = dynamic_cast<EncReshape*>(other->m_pcReshape); encReshapeThis->copyState( *encReshapeOther ); } +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST m_shareState = other->m_shareState; m_shareBndPosX = other->m_shareBndPosX; m_shareBndPosY = other->m_shareBndPosY; @@ -1223,6 +1237,7 @@ void EncCu::copyState( EncCu* other, Partitioner& partitioner, const UnitArea& c m_shareBndSizeH = other->m_shareBndSizeH; setShareStateDec( other->getShareStateDec() ); m_pcInterSearch->setShareState( other->m_pcInterSearch->getShareState() ); +#endif m_CABACEstimator->getCtx() = other->m_CABACEstimator->getCtx(); } @@ -1300,6 +1315,7 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, } } +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST int startShareThisLevel = 0; const uint32_t uiLPelX = tempCS->area.Y().lumaPos().x; const uint32_t uiTPelY = tempCS->area.Y().lumaPos().y; @@ -1336,6 +1352,7 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, m_pcInterSearch->setShareState(m_shareState); setShareStateDec(m_shareState); +#endif partitioner.splitCurrArea( split, *tempCS ); bool qgEnableChildren = partitioner.currQgEnable(); // QG possible at children level @@ -1369,6 +1386,7 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, tempCS->initSubStructure( *tempSubCS, partitioner.chType, subCUArea, false ); tempCS->initSubStructure( *bestSubCS, partitioner.chType, subCUArea, false ); +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST tempSubCS->sharedBndPos.x = (m_shareState == SHARING) ? m_shareBndPosX : tempSubCS->area.Y().lumaPos().x; tempSubCS->sharedBndPos.y = (m_shareState == SHARING) ? m_shareBndPosY : tempSubCS->area.Y().lumaPos().y; tempSubCS->sharedBndSize.width = (m_shareState == SHARING) ? m_shareBndSizeW : tempSubCS->area.lwidth(); @@ -1377,6 +1395,7 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, bestSubCS->sharedBndPos.y = (m_shareState == SHARING) ? m_shareBndPosY : tempSubCS->area.Y().lumaPos().y; bestSubCS->sharedBndSize.width = (m_shareState == SHARING) ? m_shareBndSizeW : tempSubCS->area.lwidth(); bestSubCS->sharedBndSize.height = (m_shareState == SHARING) ? m_shareBndSizeH : tempSubCS->area.lheight(); +#endif tempSubCS->bestParent = bestSubCS->bestParent = bestCS; double newMaxCostAllowed = isLuma(partitioner.chType) ? std::min(encTestMode.maxCostAllowed, bestCS->cost - m_pcRdCost->calcRdCost(tempCS->fracBits, tempCS->dist)) : MAX_DOUBLE; newMaxCostAllowed = std::max(0.0, newMaxCostAllowed); @@ -1396,12 +1415,14 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, { tempCS->motionLut = oldMotionLut; } +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST if( startShareThisLevel == 1 ) { m_shareState = NO_SHARE; m_pcInterSearch->setShareState( m_shareState ); setShareStateDec( m_shareState ); } +#endif return; } @@ -1443,12 +1464,14 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, { tempCS->motionLut = oldMotionLut; } +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST if( startShareThisLevel == 1 ) { m_shareState = NO_SHARE; m_pcInterSearch->setShareState( m_shareState ); setShareStateDec( m_shareState ); } +#endif return; } } @@ -1457,12 +1480,14 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, partitioner.exitCurrSplit(); +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST if (startShareThisLevel == 1) { m_shareState = NO_SHARE; m_pcInterSearch->setShareState(m_shareState); setShareStateDec(m_shareState); } +#endif m_CurrCtx--; @@ -2222,8 +2247,10 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& PredictionUnit pu( tempCS->area ); pu.cu = &cu; pu.cs = tempCS; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST pu.shareParentPos = tempCS->sharedBndPos; pu.shareParentSize = tempCS->sharedBndSize; +#endif PU::getInterMergeCandidates(pu, mergeCtx , 0 ); @@ -3308,8 +3335,10 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct pu.mmvdMergeFlag = false; pu.regularMergeFlag = false; cu.triangle = false; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST pu.shareParentPos = tempCS->sharedBndPos; pu.shareParentSize = tempCS->sharedBndSize; +#endif PU::getIBCMergeCandidates(pu, mergeCtx); } @@ -3542,8 +3571,10 @@ void EncCu::xCheckRDCostIBCMode(CodingStructure *&tempCS, CodingStructure *&best cu.mmvdSkip = false; pu.mmvdMergeFlag = false; pu.regularMergeFlag = false; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST pu.shareParentPos = tempCS->sharedBndPos; pu.shareParentSize = tempCS->sharedBndSize; +#endif pu.intraDir[0] = DC_IDX; // set intra pred for ibc block pu.intraDir[1] = PLANAR_IDX; // set intra pred for ibc block @@ -4516,8 +4547,10 @@ void EncCu::xReuseCachedResult( CodingStructure *&tempCS, CodingStructure *&best if( bestEncCache->setCsFrom( *tempCS, cachedMode, partitioner ) ) { CodingUnit& cu = *tempCS->cus.front(); +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST cu.shareParentPos = tempCS->sharedBndPos; cu.shareParentSize = tempCS->sharedBndSize; +#endif partitioner.setCUData( cu ); if( CU::isIntra( cu ) diff --git a/source/Lib/EncoderLib/EncCu.h b/source/Lib/EncoderLib/EncCu.h index c812dad0cc5d4606838762d3e3317f658546c6bf..42adec40484de60fc601de09c8326fc4a1f27172 100644 --- a/source/Lib/EncoderLib/EncCu.h +++ b/source/Lib/EncoderLib/EncCu.h @@ -117,11 +117,13 @@ private: RateCtrl* m_pcRateCtrl; IbcHashMap m_ibcHashMap; EncModeCtrl *m_modeCtrl; +#if !JVET_P0400_REMOVE_SHARED_MERGE_LIST int m_shareState; uint32_t m_shareBndPosX; uint32_t m_shareBndPosY; SizeType m_shareBndSizeW; SizeType m_shareBndSizeH; +#endif PelStorage m_acMergeBuffer[MMVD_MRG_MAX_RD_BUF_NUM]; PelStorage m_acRealMergeBuffer[MRG_MAX_NUM_CANDS];