From 32eab075c38785cf1d9ed8972683a50f2a84b4b5 Mon Sep 17 00:00:00 2001 From: Vadim Seregin <vseregin@qti.qualcomm.com> Date: Wed, 15 Feb 2023 18:35:40 +0000 Subject: [PATCH] Fix TM macro off --- source/Lib/CommonLib/CommonDef.h | 4 +- source/Lib/CommonLib/ContextModelling.cpp | 12 +- source/Lib/CommonLib/ContextModelling.h | 14 +- source/Lib/CommonLib/Contexts.cpp | 4 +- source/Lib/CommonLib/Contexts.h | 4 +- source/Lib/CommonLib/InterPrediction.cpp | 256 ++++++++++-------- source/Lib/CommonLib/InterPrediction.h | 25 +- source/Lib/CommonLib/InterpolationFilter.cpp | 14 +- source/Lib/CommonLib/InterpolationFilter.h | 6 +- source/Lib/CommonLib/Mv.cpp | 2 +- source/Lib/CommonLib/Mv.h | 6 +- source/Lib/CommonLib/RdCost.h | 14 +- source/Lib/CommonLib/TypeDef.h | 46 ++-- source/Lib/CommonLib/Unit.cpp | 18 +- source/Lib/CommonLib/Unit.h | 8 +- source/Lib/CommonLib/UnitTools.cpp | 128 +++------ source/Lib/CommonLib/UnitTools.h | 12 +- .../CommonLib/x86/InterpolationFilterX86.h | 6 +- source/Lib/DecoderLib/CABACReader.cpp | 94 ++++--- source/Lib/DecoderLib/CABACReader.h | 84 +++--- source/Lib/DecoderLib/DecCu.cpp | 32 ++- source/Lib/DecoderLib/DecCu.h | 2 +- source/Lib/EncoderLib/CABACWriter.cpp | 74 ++--- source/Lib/EncoderLib/CABACWriter.h | 66 ++--- source/Lib/EncoderLib/EncCu.cpp | 68 ++--- source/Lib/EncoderLib/EncCu.h | 2 +- source/Lib/EncoderLib/InterSearch.cpp | 34 ++- source/Lib/EncoderLib/InterSearch.h | 2 +- 28 files changed, 524 insertions(+), 513 deletions(-) diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index c6cce04c3..bc4157537 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -113,7 +113,7 @@ #define NULL 0 #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION static const int SUB_TMVP_CANDIDATE_NUM = 10; static const int SUB_TMVP_INDEX = 3; // 1: 2 subtmvp; 2: 4 subtmvp static const int SUB_TMVP_NUM = 2 * SUB_TMVP_INDEX; @@ -1338,7 +1338,7 @@ static const int EXT_PICTURE_SIZE = 16; #if JVET_AC0104_IBC_BVD_PREDICTION static const int IBC_BVD_PREDICTION_MAX_BIN_NUM = 4; -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif // ==================================================================================================================== diff --git a/source/Lib/CommonLib/ContextModelling.cpp b/source/Lib/CommonLib/ContextModelling.cpp index 9adf0be9e..cb1da4d1b 100644 --- a/source/Lib/CommonLib/ContextModelling.cpp +++ b/source/Lib/CommonLib/ContextModelling.cpp @@ -342,16 +342,16 @@ unsigned DeriveCtx::CtxRribcFlipType(const CodingUnit& cu) #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV -unsigned DeriveCtx::CtxBvOneNullComp(const CodingUnit &cu) +unsigned DeriveCtx::CtxbvOneZeroComp(const CodingUnit &cu) { const CodingStructure *cs = cu.cs; unsigned ctxId = 0; const CodingUnit *cuLeft = cs->getCURestricted(cu.lumaPos().offset(-1, 0), cu, CH_L); - ctxId = (cuLeft && cuLeft->predMode == MODE_IBC && !cuLeft->firstPU->mergeFlag && cuLeft->bvOneNullComp) ? 1 : 0; + ctxId = (cuLeft && cuLeft->predMode == MODE_IBC && !cuLeft->firstPU->mergeFlag && cuLeft->bvOneZeroComp) ? 1 : 0; const CodingUnit *cuAbove = cs->getCURestricted(cu.lumaPos().offset(0, -1), cu, CH_L); - ctxId += (cuAbove && cuAbove->predMode == MODE_IBC && !cuAbove->firstPU->mergeFlag && cuAbove->bvOneNullComp) ? 1 : 0; + ctxId += (cuAbove && cuAbove->predMode == MODE_IBC && !cuAbove->firstPU->mergeFlag && cuAbove->bvOneZeroComp) ? 1 : 0; return ctxId; } @@ -458,7 +458,7 @@ int DeriveCtx::CtxSmBvdBin(const int iPreviousBinIsCorrect2, const int iPrevious } return ctxNumInGroup + (0 == isHor ? 0 : ctxNumInGroup) + iCtxIdx; } -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif unsigned DeriveCtx::CtxPredModeFlag( const CodingUnit& cu ) { @@ -534,7 +534,7 @@ void MergeCtx::convertRegularMergeCandToBi(int candIdx) } } #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void MergeCtx::saveMergeInfo(PredictionUnit& puTmp, PredictionUnit pu) { puTmp.mergeIdx = pu.mergeIdx; @@ -657,7 +657,7 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) } #endif } -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION bool MergeCtx::xCheckSimilarMotionSubTMVP(int mergeCandIndex, uint32_t mvdSimilarityThresh) const { if (interDirNeighbours[mergeCandIndex] == 0) diff --git a/source/Lib/CommonLib/ContextModelling.h b/source/Lib/CommonLib/ContextModelling.h index 1124ac4d6..6fddd6eac 100644 --- a/source/Lib/CommonLib/ContextModelling.h +++ b/source/Lib/CommonLib/ContextModelling.h @@ -601,7 +601,7 @@ public: int numAMVPMergeCand; #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION MotionBuf subPuMvpMiBuf[SUB_TMVP_NUM]; #else MotionBuf subPuMvpMiBuf; @@ -623,7 +623,7 @@ public: #else bool useAltHpelIf [ MRG_MAX_NUM_CANDS ]; #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void saveMergeInfo(PredictionUnit& puTmp, PredictionUnit pu); #endif void setMergeInfo( PredictionUnit& pu, int candIdx ); @@ -644,7 +644,7 @@ public: bool xCheckSimilarIBCMotion(int mergeCandIndex, uint32_t mvdSimilarityThresh = 1) const; #endif #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION bool xCheckSimilarMotionSubTMVP(int mergeCandIndex, uint32_t mvdSimilarityThresh = 1) const; #endif #if TM_MRG @@ -678,7 +678,7 @@ public: MergeCtx *mrgCtx; MergeType mergeType[RMVF_AFFINE_MRG_MAX_CAND_LIST_SIZE]; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION int colIdx[RMVF_AFFINE_MRG_MAX_CAND_LIST_SIZE]; #endif #if JVET_AB0112_AFFINE_DMVR @@ -704,7 +704,7 @@ public: MergeCtx *mrgCtx; MergeType mergeType[AFFINE_MRG_MAX_NUM_CANDS]; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION int colIdx[AFFINE_MRG_MAX_NUM_CANDS]; #endif #if JVET_AB0112_AFFINE_DMVR @@ -730,7 +730,7 @@ unsigned CtxBMMrgFlag(const CodingUnit& cu); unsigned CtxRribcFlipType(const CodingUnit& cu); #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV -unsigned CtxBvOneNullComp(const CodingUnit &cu); +unsigned CtxbvOneZeroComp(const CodingUnit &cu); #endif unsigned CtxPredModeFlag( const CodingUnit& cu ); unsigned CtxIBCFlag(const CodingUnit& cu); @@ -751,7 +751,7 @@ unsigned CtxSgpmFlag(const CodingUnit &cu); #if JVET_AC0104_IBC_BVD_PREDICTION int CtxSmBvdBin(const int iPreviousBinIsCorrect2, const int iPreviousBinIsCorrect, const int isHor, const int significance); -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif } diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index c5c838bce..b43436a3f 100644 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -1702,7 +1702,7 @@ const CtxSet ContextSetCfg::rribcFlipType = ContextSetCfg::addCtxSet #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV -const CtxSet ContextSetCfg::bvOneNullComp = ContextSetCfg::addCtxSet +const CtxSet ContextSetCfg::bvOneZeroComp = ContextSetCfg::addCtxSet ({ { 48, 50, 50, 50, }, { 56, 50, 43, 28, }, @@ -1859,7 +1859,7 @@ const CtxSet ContextSetCfg::MvsdIdxBVDMSB = ContextSetCfg::addCtxSet { 222, 83, 181, 94, 222, 83, 181, 94, 222, 83, 181, 94, 222, 83, 181, 94, }, { 100, 116, 100, 101, 100, 116, 100, 101, 100, 116, 100, 101, 100, 116, 100, 101, }, }); -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif #if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED diff --git a/source/Lib/CommonLib/Contexts.h b/source/Lib/CommonLib/Contexts.h index 0b69f6e71..aabe1d104 100644 --- a/source/Lib/CommonLib/Contexts.h +++ b/source/Lib/CommonLib/Contexts.h @@ -346,7 +346,7 @@ public: static const CtxSet rribcFlipType; #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - static const CtxSet bvOneNullComp; + static const CtxSet bvOneZeroComp; #endif #if JVET_Y0065_GPM_INTRA static const CtxSet GPMIntraFlag; @@ -455,7 +455,7 @@ public: #if JVET_AC0104_IBC_BVD_PREDICTION static const CtxSet MvsdIdxBVDMSB; -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif #if MULTI_HYP_PRED static const CtxSet MultiHypothesisFlag; diff --git a/source/Lib/CommonLib/InterPrediction.cpp b/source/Lib/CommonLib/InterPrediction.cpp index a8cf1e637..43f9df0e3 100644 --- a/source/Lib/CommonLib/InterPrediction.cpp +++ b/source/Lib/CommonLib/InterPrediction.cpp @@ -678,7 +678,7 @@ void InterPrediction::init( RdCost* pcRdCost, ChromaFormat chromaFormatIDC, cons // ==================================================================================================================== // Public member functions // ==================================================================================================================== -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION bool InterPrediction::xCheckIdenticalMotionSubTMVP(const PredictionUnit &pu) { const Slice &slice = *pu.cs->slice; @@ -8045,7 +8045,7 @@ void InterPrediction::sortAffineMergeCandidates(PredictionUnit pu, AffineMergeC } #endif #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void InterPrediction::adjustMergeCandidatesInOneCandidateGroupSubTMVP(PredictionUnit &pu, MergeCtx& mvpMergeCandCtx, int numRetrievedMergeCand, int mrgCandIdx) { if (mvpMergeCandCtx.numValidMergeCand <= 1) @@ -9192,13 +9192,13 @@ bool InterPrediction::xAMLIsLeftTempAvailable(PredictionUnit& pu) } #endif -#if JVET_W0090_ARMC_TM -void InterPrediction::updateCandList(uint32_t uiCand, Distortion uiCost, uint32_t uiMrgCandNum, uint32_t* RdCandList, Distortion* CandCostList) +#if JVET_W0090_ARMC_TM || JVET_AA0070_RRIBC +void InterPrediction::updateCandList(uint32_t uiCand, Distortion uiCost, uint32_t uiMrgCandNum, uint32_t* rdCandList, Distortion* candCostList) { uint32_t i; uint32_t shift = 0; - while (shift < uiMrgCandNum && uiCost < CandCostList[uiMrgCandNum - 1 - shift]) + while (shift < uiMrgCandNum && uiCost < candCostList[uiMrgCandNum - 1 - shift]) { shift++; } @@ -9207,13 +9207,16 @@ void InterPrediction::updateCandList(uint32_t uiCand, Distortion uiCost, uint32_ { for (i = 1; i < shift; i++) { - RdCandList[uiMrgCandNum - i] = RdCandList[uiMrgCandNum - 1 - i]; - CandCostList[uiMrgCandNum - i] = CandCostList[uiMrgCandNum - 1 - i]; + rdCandList[uiMrgCandNum - i] = rdCandList[uiMrgCandNum - 1 - i]; + candCostList[uiMrgCandNum - i] = candCostList[uiMrgCandNum - 1 - i]; } - RdCandList[uiMrgCandNum - shift] = uiCand; - CandCostList[uiMrgCandNum - shift] = uiCost; + rdCandList[uiMrgCandNum - shift] = uiCand; + candCostList[uiMrgCandNum - shift] = uiCost; } } +#endif + +#if JVET_W0090_ARMC_TM void InterPrediction::updateCandInfo(MergeCtx& mrgCtx, uint32_t(*RdCandList)[MRG_MAX_NUM_CANDS], int mrgCandIdx) { MergeCtx mrgCtxTmp; @@ -9275,7 +9278,7 @@ void InterPrediction::updateCandInfo(MergeCtx& mrgCtx, uint32_t(*RdCandList)[MR } } #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void InterPrediction::getBlkAMLRefTemplateSubTMVP(PredictionUnit &pu, PelUnitBuf &pcBufPredRefTop, PelUnitBuf &pcBufPredRefLeft) { Mv mvCurr; @@ -10636,72 +10639,6 @@ void InterPrediction::adjustIBCMergeCandidates(PredictionUnit &pu, MergeCtx& mr updateIBCCandInfo(pu, mrgCtx, rdCandList, startPos, endPos); } -void InterPrediction::updateIBCCandInfo(PredictionUnit &pu, MergeCtx& mrgCtx, uint32_t* RdCandList,uint32_t startPos,uint32_t endPos) -{ - MergeCtx mrgCtxTmp; - for (uint32_t ui = 0; ui < IBC_MRG_MAX_NUM_CANDS_MEM; ++ui) - { - mrgCtxTmp.bcwIdx[ui] = BCW_DEFAULT; - mrgCtxTmp.interDirNeighbours[ui] = 0; - mrgCtxTmp.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; - mrgCtxTmp.mvFieldNeighbours[(ui << 1) + 1].refIdx = NOT_VALID; - mrgCtxTmp.useAltHpelIf[ui] = false; -#if INTER_LIC - mrgCtxTmp.licFlags[ui] = false; -#endif -#if JVET_AC0112_IBC_LIC - mrgCtxTmp.ibcLicFlags[ui] = false; -#endif -#if JVET_AA0070_RRIBC - mrgCtxTmp.rribcFlipTypes[ui] = 0; -#endif - } - for (uint32_t uiMergeCand = startPos; uiMergeCand < endPos; ++uiMergeCand) - { - mrgCtx.setMergeInfo(pu, uiMergeCand); - if (pu.bv == Mv(0, 0)) - { - break; - } - mrgCtxTmp.bcwIdx[uiMergeCand] = mrgCtx.bcwIdx[uiMergeCand]; - mrgCtxTmp.interDirNeighbours[uiMergeCand] = mrgCtx.interDirNeighbours[uiMergeCand]; - mrgCtxTmp.mvFieldNeighbours[(uiMergeCand << 1)] = mrgCtx.mvFieldNeighbours[(uiMergeCand << 1)]; - mrgCtxTmp.mvFieldNeighbours[(uiMergeCand << 1) + 1] = mrgCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1]; - mrgCtxTmp.useAltHpelIf[uiMergeCand] = mrgCtx.useAltHpelIf[uiMergeCand]; -#if INTER_LIC - mrgCtxTmp.licFlags[uiMergeCand] = mrgCtx.licFlags[uiMergeCand]; -#endif -#if JVET_AC0112_IBC_LIC - mrgCtxTmp.ibcLicFlags[uiMergeCand] = mrgCtx.ibcLicFlags[uiMergeCand]; -#endif -#if JVET_AA0070_RRIBC - mrgCtxTmp.rribcFlipTypes[uiMergeCand] = mrgCtx.rribcFlipTypes[uiMergeCand]; -#endif - } - //update - for (uint32_t uiMergeCand = startPos; uiMergeCand < endPos; ++uiMergeCand) - { - mrgCtx.setMergeInfo(pu, uiMergeCand); - if (pu.bv == Mv(0, 0)) - { - break; - } - mrgCtx.bcwIdx[uiMergeCand] = mrgCtxTmp.bcwIdx[RdCandList[uiMergeCand -startPos]]; - mrgCtx.interDirNeighbours[uiMergeCand] = mrgCtxTmp.interDirNeighbours[RdCandList[uiMergeCand -startPos]]; - mrgCtx.mvFieldNeighbours[(uiMergeCand << 1)] = mrgCtxTmp.mvFieldNeighbours[RdCandList[uiMergeCand -startPos] << 1]; - mrgCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1] = mrgCtxTmp.mvFieldNeighbours[(RdCandList[uiMergeCand -startPos] << 1) + 1]; - mrgCtx.useAltHpelIf[uiMergeCand] = mrgCtxTmp.useAltHpelIf[RdCandList[uiMergeCand -startPos]]; -#if INTER_LIC - mrgCtx.licFlags[uiMergeCand] = mrgCtxTmp.licFlags[RdCandList[uiMergeCand -startPos]]; -#endif -#if JVET_AC0112_IBC_LIC - mrgCtx.ibcLicFlags[uiMergeCand] = mrgCtxTmp.ibcLicFlags[RdCandList[uiMergeCand -startPos]]; -#endif -#if JVET_AA0070_RRIBC - mrgCtx.rribcFlipTypes[uiMergeCand] = mrgCtxTmp.rribcFlipTypes[RdCandList[uiMergeCand -startPos]]; -#endif - } -} #endif #if JVET_AA0107_RMVF_AFFINE_MERGE_DERIVATION void InterPrediction::adjustAffineMergeCandidatesOneGroup(PredictionUnit &pu, AffineMergeCtx& affMrgCtx, int listsize, int mrgCandIdx) @@ -10863,6 +10800,76 @@ void InterPrediction::updateAffineCandInfo2(PredictionUnit &pu, AffineMergeCtx& } #endif #endif + +#if JVET_Z0075_IBC_HMVP_ENLARGE || JVET_AA0070_RRIBC +void InterPrediction::updateIBCCandInfo( PredictionUnit &pu, MergeCtx& mrgCtx, uint32_t* RdCandList, uint32_t startPos, uint32_t endPos ) +{ + MergeCtx mrgCtxTmp; + for( uint32_t ui = 0; ui < IBC_MRG_MAX_NUM_CANDS_MEM; ++ui ) + { + mrgCtxTmp.bcwIdx[ui] = BCW_DEFAULT; + mrgCtxTmp.interDirNeighbours[ui] = 0; + mrgCtxTmp.mvFieldNeighbours[( ui << 1 )].refIdx = NOT_VALID; + mrgCtxTmp.mvFieldNeighbours[( ui << 1 ) + 1].refIdx = NOT_VALID; + mrgCtxTmp.useAltHpelIf[ui] = false; +#if INTER_LIC + mrgCtxTmp.licFlags[ui] = false; +#endif +#if JVET_AC0112_IBC_LIC + mrgCtxTmp.ibcLicFlags[ui] = false; +#endif +#if JVET_AA0070_RRIBC + mrgCtxTmp.rribcFlipTypes[ui] = 0; +#endif + } + for( uint32_t uiMergeCand = startPos; uiMergeCand < endPos; ++uiMergeCand ) + { + mrgCtx.setMergeInfo( pu, uiMergeCand ); + if( pu.bv == Mv( 0, 0 ) ) + { + break; + } + mrgCtxTmp.bcwIdx[uiMergeCand] = mrgCtx.bcwIdx[uiMergeCand]; + mrgCtxTmp.interDirNeighbours[uiMergeCand] = mrgCtx.interDirNeighbours[uiMergeCand]; + mrgCtxTmp.mvFieldNeighbours[( uiMergeCand << 1 )] = mrgCtx.mvFieldNeighbours[( uiMergeCand << 1 )]; + mrgCtxTmp.mvFieldNeighbours[( uiMergeCand << 1 ) + 1] = mrgCtx.mvFieldNeighbours[( uiMergeCand << 1 ) + 1]; + mrgCtxTmp.useAltHpelIf[uiMergeCand] = mrgCtx.useAltHpelIf[uiMergeCand]; +#if INTER_LIC + mrgCtxTmp.licFlags[uiMergeCand] = mrgCtx.licFlags[uiMergeCand]; +#endif +#if JVET_AC0112_IBC_LIC + mrgCtxTmp.ibcLicFlags[uiMergeCand] = mrgCtx.ibcLicFlags[uiMergeCand]; +#endif +#if JVET_AA0070_RRIBC + mrgCtxTmp.rribcFlipTypes[uiMergeCand] = mrgCtx.rribcFlipTypes[uiMergeCand]; +#endif + } + //update + for( uint32_t uiMergeCand = startPos; uiMergeCand < endPos; ++uiMergeCand ) + { + mrgCtx.setMergeInfo( pu, uiMergeCand ); + if( pu.bv == Mv( 0, 0 ) ) + { + break; + } + mrgCtx.bcwIdx[uiMergeCand] = mrgCtxTmp.bcwIdx[RdCandList[uiMergeCand - startPos]]; + mrgCtx.interDirNeighbours[uiMergeCand] = mrgCtxTmp.interDirNeighbours[RdCandList[uiMergeCand - startPos]]; + mrgCtx.mvFieldNeighbours[( uiMergeCand << 1 )] = mrgCtxTmp.mvFieldNeighbours[RdCandList[uiMergeCand - startPos] << 1]; + mrgCtx.mvFieldNeighbours[( uiMergeCand << 1 ) + 1] = mrgCtxTmp.mvFieldNeighbours[( RdCandList[uiMergeCand - startPos] << 1 ) + 1]; + mrgCtx.useAltHpelIf[uiMergeCand] = mrgCtxTmp.useAltHpelIf[RdCandList[uiMergeCand - startPos]]; +#if INTER_LIC + mrgCtx.licFlags[uiMergeCand] = mrgCtxTmp.licFlags[RdCandList[uiMergeCand - startPos]]; +#endif +#if JVET_AC0112_IBC_LIC + mrgCtx.ibcLicFlags[uiMergeCand] = mrgCtxTmp.ibcLicFlags[RdCandList[uiMergeCand - startPos]]; +#endif +#if JVET_AA0070_RRIBC + mrgCtx.rribcFlipTypes[uiMergeCand] = mrgCtxTmp.rribcFlipTypes[RdCandList[uiMergeCand - startPos]]; +#endif + } +} +#endif + #if JVET_Z0061_TM_OBMC void InterPrediction::xOBMCWeightedAverageY(const PredictionUnit &pu, const CPelUnitBuf &pcYuvSrc0, const CPelUnitBuf &pcYuvSrc1, PelUnitBuf &pcYuvDst, @@ -12706,7 +12713,7 @@ TplMatchingCtrl::TplMatchingCtrl( const PredictionUnit& pu, #if JVET_AC0104_IBC_BVD_PREDICTION , const int tplSize , const bool isForBmvdFlag -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif ) : m_cu (*pu.cu) , m_pu (pu) @@ -12851,21 +12858,24 @@ TplMatchingCtrl::TplMatchingCtrl( const PredictionUnit& pu, const bool tplAvalableAbove = xFillCurTemplate<TM_TPL_SIZE, true >((fillCurTpl ? curTplAbove : nullptr)); const bool tplAvalableLeft = xFillCurTemplate<TM_TPL_SIZE, false>((fillCurTpl ? curTplLeft : nullptr)); #endif + #if JVET_AC0104_IBC_BVD_PREDICTION m_curTplAbove = tplAvalableAbove ? PelBuf(curTplAbove, pu.lwidth(), tplSize) : PelBuf(); m_curTplLeft = tplAvalableLeft ? PelBuf(curTplLeft , tplSize, pu.lheight()) : PelBuf(); -#else // !JVET_AC0104_IBC_BVD_PREDICTION +#else m_curTplAbove = tplAvalableAbove ? PelBuf(curTplAbove, pu.lwidth(), TM_TPL_SIZE) : PelBuf(); m_curTplLeft = tplAvalableLeft ? PelBuf(curTplLeft , TM_TPL_SIZE, pu.lheight()) : PelBuf(); -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif + m_refTplAbove = tplAvalableAbove ? PelBuf(refTplAbove, m_curTplAbove ) : PelBuf(); m_refTplLeft = tplAvalableLeft ? PelBuf(refTplLeft , m_curTplLeft ) : PelBuf(); + #if JVET_X0056_DMVD_EARLY_TERMINATION #if JVET_AC0104_IBC_BVD_PREDICTION m_earlyTerminateTh = tplSize * ((tplAvalableAbove ? m_pu.lwidth() : 0) + (tplAvalableLeft ? m_pu.lheight() : 0)); -#else // !JVET_AC0104_IBC_BVD_PREDICTION +#else m_earlyTerminateTh = TM_TPL_SIZE * ((tplAvalableAbove ? m_pu.lwidth() : 0) + (tplAvalableLeft ? m_pu.lheight() : 0)); -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif #endif @@ -13077,7 +13087,7 @@ bool TplMatchingCtrl::xGetCurTemplateAvailable() return true; } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif template <int tplSize, bool trueAfalseL, int sr> PelBuf TplMatchingCtrl::xGetRefTemplate(const PredictionUnit& curPu, const Picture& refPic, const Mv& _mv, PelBuf& dstBuf) @@ -13097,22 +13107,28 @@ PelBuf TplMatchingCtrl::xGetRefTemplate(const PredictionUnit& curPu, const Pictu Mv tempBv = _mv; tempBv.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_INT); #if JVET_AC0104_IBC_BVD_PREDICTION +#if JVET_AA0070_RRIBC if (1 == curPu.cu->rribcFlipType && 0 == trueAfalseL) { tempBv += Mv(m_pu.lwidth() + tplSize - 1, 0); //at least, template size should be available } else - if (2 == curPu.cu->rribcFlipType && 1 == trueAfalseL) + { + if( 2 == curPu.cu->rribcFlipType && 1 == trueAfalseL ) { - tempBv += Mv(0, m_pu.lheight() + tplSize - 1); + tempBv += Mv( 0, m_pu.lheight() + tplSize - 1 ); } else { - tempBv += trueAfalseL ? Mv(0, -tplSize) : Mv(-tplSize, 0); + tempBv += trueAfalseL ? Mv( 0, -tplSize ) : Mv( -tplSize, 0 ); } -#else // !JVET_AC0104_IBC_BVD_PREDICTION + } +#else + tempBv += trueAfalseL ? Mv( 0, -tplSize ) : Mv( -tplSize, 0 ); +#endif +#else tempBv += trueAfalseL ? Mv(0, -tplSize) : Mv(-tplSize, 0); -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif if (!PU::searchBv(m_pu, cuPelX, cuPelY, roiWidth, roiHeight, picWidth, picHeight, tempBv.getHor(), tempBv.getVer(), ctuSize)) { @@ -13236,7 +13252,7 @@ PelBuf TplMatchingCtrl::xGetCurTemplateBvd(const PredictionUnit& curPu, const Pi #endif #if JVET_AC0104_IBC_BVD_PREDICTION const Pel* ref = refBuf.bufAt(blkPos); -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif Pel* dst = dstBuf.buf; const int refStride = refBuf.stride; @@ -13248,6 +13264,7 @@ PelBuf TplMatchingCtrl::xGetCurTemplateBvd(const PredictionUnit& curPu, const Pi const bool useAltHpelIf = false; const bool biMCForDMVR = false; +#if JVET_AA0070_RRIBC if (0 != m_cu.rribcFlipType) { if (2 == m_cu.rribcFlipType) @@ -13263,6 +13280,9 @@ PelBuf TplMatchingCtrl::xGetCurTemplateBvd(const PredictionUnit& curPu, const Pi { m_interRes.m_if.filterHor(m_compID, (Pel*)ref, refStride, dst, dstStride, bw, bh, xFrac, true, m_cu.chromaFormat, m_cu.slice->clpRng(m_compID), nFilterIdx, biMCForDMVR, useAltHpelIf); } +#else + m_interRes.m_if.filterHor( m_compID, (Pel*)ref, refStride, dst, dstStride, bw, bh, xFrac, true, m_cu.chromaFormat, m_cu.slice->clpRng( m_compID ), nFilterIdx, biMCForDMVR, useAltHpelIf ); +#endif return dstBuf; } @@ -13281,6 +13301,7 @@ PelBuf TplMatchingCtrl::xGetRefTemplateBvd(const PredictionUnit& curPu, const P // Do interpolation on the fly Position blkPos = Position(curPu.lx(), curPu.ly()); +#if JVET_AA0070_RRIBC if (0 == curPu.cu->rribcFlipType) { blkPos = blkPos.offset(trueAfalseL ? Position(0, 0 - tplSize) : Position(0 - tplSize, 0)); // default template offset @@ -13297,6 +13318,9 @@ PelBuf TplMatchingCtrl::xGetRefTemplateBvd(const PredictionUnit& curPu, const P { blkPos = blkPos.offset(trueAfalseL ? Position(0, 0 - tplSize) : Position(0 - tplSize, 0)); // default template offset } +#else + blkPos = blkPos.offset( trueAfalseL ? Position( 0, 0 - tplSize ) : Position( 0 - tplSize, 0 ) ); // default template offset +#endif const Size blkSize = Size(dstBuf.width, dstBuf.height); @@ -13334,7 +13358,7 @@ PelBuf TplMatchingCtrl::xGetRefTemplateBvd(const PredictionUnit& curPu, const P return dstBuf; } -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif template <int tplSize, bool trueAfalseL> void TplMatchingCtrl::xRemoveHighFreq(const Picture& otherRefPic, const Mv& otherRefMv, const uint8_t curRefBcwWeight) @@ -13651,7 +13675,7 @@ Distortion TplMatchingCtrl::xGetTempMatchErrorBvd(const Mv& mv) return sum; } -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif template <int tplSize> Distortion TplMatchingCtrl::xGetTempMatchError(const Mv& mv) @@ -13674,7 +13698,7 @@ Distortion TplMatchingCtrl::xGetTempMatchError(const Mv& mv) template <int tplSize, bool trueAfalseL, bool useForBvd> #else template <int tplSize, bool trueAfalseL> -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif Distortion TplMatchingCtrl::xGetTempMatchError(const Mv& mv) { PelBuf& curTplBuf = trueAfalseL ? m_curTplAbove : m_curTplLeft; @@ -13692,9 +13716,9 @@ Distortion TplMatchingCtrl::xGetTempMatchError(const Mv& mv) #if JVET_AC0104_IBC_BVD_PREDICTION refTplBuf = useForBvd ? xGetRefTemplateBvd<tplSize, trueAfalseL>(m_pu, m_refPic, mv, refTplBuf) : xGetRefTemplate<tplSize, trueAfalseL, 0>(m_pu, m_refPic, mv, refTplBuf); -#else //!JVET_AC0104_IBC_BVD_PREDICTION +#else refTplBuf = xGetRefTemplate<tplSize, trueAfalseL, 0>(m_pu, m_refPic, mv, refTplBuf); -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif #if JVET_Z0084_IBC_TM if (refTplBuf.buf == nullptr) { @@ -13829,7 +13853,7 @@ bool InterPrediction::readTplAmvpBuffer(AMVPInfo& dst, const CodingUnit& cu, Ref } #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void InterPrediction::writeMergeBuffer(const MergeCtx& srcList0, const MergeCtx& srcList1, const CodingUnit& cu) { m_pcMergeCtxList0 = srcList0; @@ -17146,6 +17170,7 @@ struct CandCheckEnv if (res && doBoundaryCheck) { +#if JVET_AA0070_RRIBC if (1 == pu.cu->rribcFlipType) { useTop = PU::searchBv(pu, pu.lumaPos().x, pu.lumaPos().y, pu.lwidth(), 1, picWidth, picHeight, xPred, yPred, lcuWidth); @@ -17153,17 +17178,23 @@ struct CandCheckEnv useLeft = PU::searchBv(pu, pu.lumaPos().x, pu.lumaPos().y, 1, pu.lheight(), picWidth, picHeight, xPred, yPred, lcuWidth); } else - if (2 == pu.cu->rribcFlipType) + { + if( 2 == pu.cu->rribcFlipType ) { - useLeft = PU::searchBv(pu, pu.lumaPos().x, pu.lumaPos().y, 1, pu.lheight(), picWidth, picHeight, xPred, yPred, lcuWidth); + useLeft = PU::searchBv( pu, pu.lumaPos().x, pu.lumaPos().y, 1, pu.lheight(), picWidth, picHeight, xPred, yPred, lcuWidth ); yPred += pu.lheight(); //at least, template size of 1 should be available - useTop = PU::searchBv(pu, pu.lumaPos().x, pu.lumaPos().y, pu.lwidth(), 1, picWidth, picHeight, xPred, yPred, lcuWidth); + useTop = PU::searchBv( pu, pu.lumaPos().x, pu.lumaPos().y, pu.lwidth(), 1, picWidth, picHeight, xPred, yPred, lcuWidth ); } else { - useLeft = PU::searchBv(pu, pu.lumaPos().x, pu.lumaPos().y, 1, pu.lheight(), picWidth, picHeight, xPred - 1, yPred, lcuWidth); - useTop = PU::searchBv(pu, pu.lumaPos().x, pu.lumaPos().y, pu.lwidth(), 1, picWidth, picHeight, xPred, yPred - 1, lcuWidth); + useLeft = PU::searchBv( pu, pu.lumaPos().x, pu.lumaPos().y, 1, pu.lheight(), picWidth, picHeight, xPred - 1, yPred, lcuWidth ); + useTop = PU::searchBv( pu, pu.lumaPos().x, pu.lumaPos().y, pu.lwidth(), 1, picWidth, picHeight, xPred, yPred - 1, lcuWidth ); } + } +#else + useLeft = PU::searchBv( pu, pu.lumaPos().x, pu.lumaPos().y, 1, pu.lheight(), picWidth, picHeight, xPred - 1, yPred, lcuWidth ); + useTop = PU::searchBv( pu, pu.lumaPos().x, pu.lumaPos().y, pu.lwidth(), 1, picWidth, picHeight, xPred, yPred - 1, lcuWidth ); +#endif } else if (!doBoundaryCheck) { @@ -17257,11 +17288,11 @@ void InterPrediction::deriveBvdSignIBC(const Mv& cMvPred, const Mv& cMvdKnownAtD verAbs = tmp.getAbsVer(); const int iTotalNumberOfBins = iHorMSBins + iVerMSBins; -#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV +#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV && JVET_AA0070_RRIBC const int numSignBits = (pu.cu->rribcFlipType != 0) ? 0 : #else const int numSignBits = -#endif // JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV +#endif ((0 != horAbs && !pu.bvdSuffixInfo.horEncodeSignInEP) ? 1 : 0) + ((0 != verAbs && !pu.bvdSuffixInfo.verEncodeSignInEP) ? 1 : 0); @@ -17302,7 +17333,11 @@ void InterPrediction::deriveBvdSignIBC(const Mv& cMvPred, const Mv& cMvdKnownAtD CHECK(iHorRange < 0, "iHorRange < 0"); CHECK(iVerRange < 0, "iVerRange < 0"); +#if JVET_AA0070_RRIBC const bool rrIBCmode = pu.cu->rribcFlipType != 0; +#else + const bool rrIBCmode = false; +#endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV const bool horPositiveAllowedRRIBC = pu.mvpIdx[REF_PIC_LIST_0] == 1 && rrIBCmode; @@ -17317,12 +17352,12 @@ void InterPrediction::deriveBvdSignIBC(const Mv& cMvPred, const Mv& cMvdKnownAtD const bool horNegativeAllowed = horNegativeAllowedRRIBC || (!rrIBCmode && !si.horEncodeSignInEP) || (!rrIBCmode && si.horEncodeSignInEP && cMvdKnownAtDecoder.getHor() < 0); const bool verPositiveAllowed = verPositiveAllowedRRIBC || (!rrIBCmode && !si.verEncodeSignInEP) || (!rrIBCmode && si.verEncodeSignInEP && cMvdKnownAtDecoder.getVer() > 0); const bool verNegativeAllowed = verNegativeAllowedRRIBC || (!rrIBCmode && !si.verEncodeSignInEP) || (!rrIBCmode && si.verEncodeSignInEP && cMvdKnownAtDecoder.getVer() < 0); -#else // !JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV +#else const bool horPositiveAllowed = !si.horEncodeSignInEP || (si.horEncodeSignInEP && cMvdKnownAtDecoder.getHor() > 0); const bool horNegativeAllowed = !si.horEncodeSignInEP || (si.horEncodeSignInEP && cMvdKnownAtDecoder.getHor() < 0); const bool verPositiveAllowed = !si.verEncodeSignInEP || (si.verEncodeSignInEP && cMvdKnownAtDecoder.getVer() > 0); const bool verNegativeAllowed = !si.verEncodeSignInEP || (si.verEncodeSignInEP && cMvdKnownAtDecoder.getVer() < 0); -#endif // JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV +#endif if (rrIBCmode) { @@ -17364,7 +17399,9 @@ void InterPrediction::deriveBvdSignIBC(const Mv& cMvPred, const Mv& cMvdKnownAtD } else { - CHECK(pu.cu->rribcFlipType != 0, "pu.cu->rribcFlipType !=0"); +#if JVET_AA0070_RRIBC + CHECK(pu.cu->rribcFlipType != 0, "pu.cu->rribcFlipType != 0"); +#endif for (unsigned int iHorCnt = 0; iHorCnt < iHorRange; ++iHorCnt) { @@ -17416,7 +17453,7 @@ void InterPrediction::deriveBvdSignIBC(const Mv& cMvPred, const Mv& cMvdKnownAtD #if JVET_AC0104_IBC_BVD_PREDICTION TplMatchingCtrl tplCtrl(pu, interRes, recPic, true, COMPONENT_Y, false, 0, m_pcCurTplAbove, m_pcCurTplLeft, m_pcRefTplAbove, m_pcRefTplLeft, Mv(0, 0), nullptr, 0, 1, true); -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif std::vector<std::pair<Mv, Distortion>> aMvCostVec(patternsNum); @@ -17477,7 +17514,9 @@ void InterPrediction::deriveBvdSignIBC(const Mv& cMvPred, const Mv& cMvdKnownAtD } else { - CHECK(pu.cu->rribcFlipType != 0, "pu.cu->rribcFlipType !=0"); +#if JVET_AA0070_RRIBC + CHECK(pu.cu->rribcFlipType != 0, "pu.cu->rribcFlipType != 0"); +#endif step = (horNegativeAllowed ? 1 : 0) * ((verNegativeAllowed ? 1 : 0) + (verPositiveAllowed ? 1 : 0)) + (horPositiveAllowed ? 1 : 0) * ((verNegativeAllowed ? 1 : 0) + (verPositiveAllowed ? 1 : 0)); @@ -17928,7 +17967,7 @@ void InterPrediction::initOffsets(Mv& cMvdInput, std::vector<Mv>& cMvdDerived, M CHECK(numMSBver != verBitCount, "numMSBver != verBitCount"); } } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif void InterPrediction::setBiRefPairIdx(PredictionUnit &pu) { @@ -20045,7 +20084,8 @@ void InterPrediction::deriveMVDcandAffine(const PredictionUnit& pu, RefPicList e } return cMvd; } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif + Mv InterPrediction::deriveMVDFromMVSDIdxTrans(int mvsdIdx, std::vector<Mv>& cMvdDerived) { int bin = 0; diff --git a/source/Lib/CommonLib/InterPrediction.h b/source/Lib/CommonLib/InterPrediction.h index 42925e79b..0e44fa598 100644 --- a/source/Lib/CommonLib/InterPrediction.h +++ b/source/Lib/CommonLib/InterPrediction.h @@ -373,7 +373,7 @@ protected: void xSubPuBio(PredictionUnit& pu, PelUnitBuf& predBuf, const RefPicList &eRefPicList = REF_PIC_LIST_X, PelUnitBuf* yuvDstTmp = NULL); #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION MotionInfo m_subPuMiBuf[SUB_TMVP_NUM][(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)]; #else MotionInfo m_subPuMiBuf[(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)]; @@ -582,7 +582,7 @@ public: void initOffsets(Mv& cMvdInput, std::vector<Mv>& cMvdDerived, MvdSuffixInfo& si, int imv); void applyOffsets(Mv& cMvdInput, std::vector<Mv>& cMvdDerived, const MvdSuffixInfo& si, int imv); -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif #if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED #if JVET_Z0054_BLK_REF_PIC_REORDER @@ -594,7 +594,7 @@ public: #if JVET_AC0104_IBC_BVD_PREDICTION int deriveMVSDIdxFromMVDTransIBC(const Mv& cMvd, const std::vector<Mv>& cMvdDerived, const MvdSuffixInfo& si) const ; Mv deriveMVDFromMVSDIdxTransIBC(int mvsdIdx, const std::vector<Mv>& cMvdDerived, const MvdSuffixInfo& si) const; -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif Mv deriveMVDFromMVSDIdxTrans(int mvsdIdx, std::vector<Mv>& cMvdDerived); void deriveMvdSignSMVD(const Mv& cMvPred, const Mv& cMvPred2, const Mv& cMvdKnownAtDecoder, PredictionUnit& pu, std::vector<Mv>& cMvdDerived); @@ -636,7 +636,7 @@ public: void sortAffineMergeCandidates(PredictionUnit pu, AffineMergeCtx& affMrgCtx, uint32_t * affMmvdLUT, uint32_t afMMVDIdx = -1); #endif #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void getBlkAMLRefTemplateSubTMVP(PredictionUnit &pu, PelUnitBuf &pcBufPredRefTop, PelUnitBuf &pcBufPredRefLeft); static bool xCheckIdenticalMotionSubTMVP(const PredictionUnit& pu); void adjustMergeCandidatesInOneCandidateGroupSubTMVP(PredictionUnit &pu, MergeCtx& smvpMergeCandCtx, int numRetrievedMergeCand, int mrgCandIdx = -1); @@ -662,8 +662,10 @@ public: void xSubblockTMOBMC(const ComponentID eComp, PredictionUnit &pu, PelUnitBuf &pcYuvPredDst, PelUnitBuf &pcYuvPredSrc, int iDir, int iOBMCmode = 0); #endif +#if JVET_W0090_ARMC_TM || JVET_AA0070_RRIBC + void updateCandList(uint32_t uiCand, Distortion uiCost, uint32_t uiMrgCandNum, uint32_t* rdCandList, Distortion* candCostList); +#endif #if JVET_W0090_ARMC_TM - void updateCandList(uint32_t uiCand, Distortion uiCost, uint32_t uiMrgCandNum, uint32_t* RdCandList, Distortion* CandCostList); void updateCandInfo(MergeCtx& mrgCtx, uint32_t(*RdCandList)[MRG_MAX_NUM_CANDS], int mrgCandIdx = -1); #endif #if JVET_W0090_ARMC_TM || JVET_Z0056_GPM_SPLIT_MODE_REORDERING @@ -733,7 +735,6 @@ public: #endif #if JVET_Z0075_IBC_HMVP_ENLARGE void adjustIBCMergeCandidates(PredictionUnit &pu, MergeCtx& mrgCtx, uint32_t startPos,uint32_t endPos); - void updateIBCCandInfo(PredictionUnit &pu, MergeCtx& mrgCtx, uint32_t* RdCandList, uint32_t startPos,uint32_t endPos); #endif #endif #if JVET_AC0112_IBC_GPM @@ -743,6 +744,10 @@ public: #endif #endif +#if JVET_Z0075_IBC_HMVP_ENLARGE || JVET_AA0070_RRIBC + void updateIBCCandInfo(PredictionUnit &pu, MergeCtx& mrgCtx, uint32_t* RdCandList, uint32_t startPos,uint32_t endPos); +#endif + #if JVET_Z0056_GPM_SPLIT_MODE_REORDERING template <uint8_t partIdx, bool useDefaultPelBuffer = true> void fillPartGPMRefTemplate(PredictionUnit &pu, Pel* bufTop = nullptr, Pel* bufLeft = nullptr) @@ -1023,7 +1028,7 @@ class TplMatchingCtrl #if JVET_AC0104_IBC_BVD_PREDICTION bool m_useTop; bool m_useLeft; -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif public: TplMatchingCtrl(const PredictionUnit& pu, @@ -1043,7 +1048,7 @@ public: #if JVET_AC0104_IBC_BVD_PREDICTION , const int tplSize = TM_TPL_SIZE , const bool isForBmvdFlag = false -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif ); bool getTemplatePresentFlag() { return m_curTplAbove.buf != nullptr || m_curTplLeft.buf != nullptr; } @@ -1061,7 +1066,7 @@ private: template <int tplSize, bool trueAfalseL> bool xGetCurTemplateAvailable(); template <int tplSize, bool trueAfalseL> PelBuf xGetCurTemplateBvd(const PredictionUnit& curPu, const Picture& refPic, PelBuf& dstBuf); template <int tplSize, bool trueAfalseL> PelBuf xGetRefTemplateBvd (const PredictionUnit& curPu, const Picture& refPic, const Mv& _mv, PelBuf& dstBuf); -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif template <int tplSize, bool trueAfalseL> void xRemoveHighFreq (const Picture& otherRefPic, const Mv& otherRefMv, const uint8_t curRefBcwWeight); template <int tplSize, int searchPattern> void xRefineMvSearch (int maxSearchRounds, int searchStepShift); #if MULTI_PASS_DMVR @@ -1082,7 +1087,7 @@ public: bool& getCurLeftRefAvailFlag() { return m_useLeft; } #else template <int tplSize, bool trueAfalseL> Distortion xGetTempMatchError(const Mv& mv); -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif }; #endif // TM_AMVP || TM_MRG diff --git a/source/Lib/CommonLib/InterpolationFilter.cpp b/source/Lib/CommonLib/InterpolationFilter.cpp index 407dffad0..23fa41b54 100644 --- a/source/Lib/CommonLib/InterpolationFilter.cpp +++ b/source/Lib/CommonLib/InterpolationFilter.cpp @@ -1166,7 +1166,6 @@ const TFilterCoeff InterpolationFilter::m_bilinearFilterPrec4[LUMA_INTERPOLATION InterpolationFilter::InterpolationFilter() { #if IF_12TAP -#if !QC_SIF_SIMD m_filterHor[0][0][0] = filter<12, false, false, false>; m_filterHor[0][0][1] = filter<12, false, false, true>; m_filterHor[0][1][0] = filter<12, false, true, false>; @@ -1240,9 +1239,7 @@ InterpolationFilter::InterpolationFilter() m_filterVer[3][1][0] = filter<2, true, true, false>; m_filterVer[3][1][1] = filter<2, true, true, true>; #endif -#endif #else -#if !QC_SIF_SIMD m_filterHor[0][0][0] = filter<8, false, false, false>; m_filterHor[0][0][1] = filter<8, false, false, true>; m_filterHor[0][1][0] = filter<8, false, true, false>; @@ -1272,7 +1269,6 @@ InterpolationFilter::InterpolationFilter() m_filterVer[2][0][1] = filter<2, true, false, true>; m_filterVer[2][1][0] = filter<2, true, true, false>; m_filterVer[2][1][1] = filter<2, true, true, true>; -#endif #endif m_filterCopy[0][0] = filterCopy<false, false>; m_filterCopy[0][1] = filterCopy<false, true>; @@ -1282,8 +1278,7 @@ InterpolationFilter::InterpolationFilter() m_filterCopyWithNoClipping = filterCopyWithNoClipping; m_filterReverseCopy[0] = filterReverseCopy <true>; m_filterReverseCopy[1] = filterReverseCopy <false>; -#endif //JVET_AC0104_IBC_BVD_PREDICTION -#if !QC_SIF_SIMD +#endif m_weightedGeoBlk = xWeightedGeoBlk; #if JVET_Y0065_GPM_INTRA m_weightedGeoBlkRounded = xWeightedGeoBlkRounded; @@ -1293,7 +1288,6 @@ InterpolationFilter::InterpolationFilter() m_sadTM = xSadTM; m_sgpmSadTM = xSgpmSadTM; #endif -#endif #if JVET_Z0056_GPM_SPLIT_MODE_REORDERING m_weightedGeoTplA = xWeightedGeoTpl<true>; m_weightedGeoTplL = xWeightedGeoTpl<false>; @@ -1493,7 +1487,7 @@ void InterpolationFilter::filterReverseCopy(const ClpRng& clpRng, const Pel* src } } } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif #if SIMD_4x4_12 && defined(TARGET_SIMD_X86) void InterpolationFilter::filter4x4( const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int xFrac, int yFrac, bool isLast) @@ -1888,7 +1882,7 @@ void InterpolationFilter::filterVer(const ClpRng& clpRng, Pel const *src, int sr void InterpolationFilter::filterHor(const ComponentID compID, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, int frac, bool isLast, const ChromaFormat fmt, const ClpRng& clpRng, int nFilterIdx, bool biMCForDMVR, bool useAltHpelIf #if JVET_AC0104_IBC_BVD_PREDICTION , const bool useCopyWithNoClipping -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif ) { #if JVET_AC0104_IBC_BVD_PREDICTION @@ -1897,7 +1891,7 @@ void InterpolationFilter::filterHor(const ComponentID compID, Pel const *src, in m_filterCopyWithNoClipping(clpRng, src, srcStride, dst, dstStride, width, height); } else -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif if( frac == 0 && nFilterIdx < 2 ) { diff --git a/source/Lib/CommonLib/InterpolationFilter.h b/source/Lib/CommonLib/InterpolationFilter.h index 4ab99c178..81bfc0bea 100644 --- a/source/Lib/CommonLib/InterpolationFilter.h +++ b/source/Lib/CommonLib/InterpolationFilter.h @@ -136,7 +136,7 @@ public: static void filterCopyWithNoClipping( const ClpRng& clpRng, const Pel* src, int srcStride, Pel* dst, int dstStride, int width, int height ); template<bool isVer> static void filterReverseCopy( const ClpRng& clpRng, const Pel* src, int srcStride, Pel* dst, int dstStride, int width, int height ); -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif template<int N, bool isVertical, bool isFirst, bool isLast> static void filter(const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, TFilterCoeff const *coeff, bool biMCForDMVR); @@ -206,7 +206,7 @@ public: #if JVET_AC0104_IBC_BVD_PREDICTION void( *m_filterCopyWithNoClipping )(const ClpRng& clpRng, const Pel* src, int srcStride, Pel* dst, int dstStride, int width, int height); void( *m_filterReverseCopy[2] )(const ClpRng& clpRng, const Pel* src, int srcStride, Pel* dst, int dstStride, int width, int height); -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif #if JVET_AA0058_GPM_ADAPTIVE_BLENDING void( *m_weightedGeoBlk )(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, const uint8_t bldIdx, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); #else @@ -252,7 +252,7 @@ public: void filterHor(const ComponentID compID, Pel const* src, int srcStride, Pel *dst, int dstStride, int width, int height, int frac, bool isLast, const ChromaFormat fmt, const ClpRng& clpRng, int nFilterIdx = 0, bool biMCForDMVR = false, bool useAltHpelIf = false #if JVET_AC0104_IBC_BVD_PREDICTION , const bool useCopyWithNoClipping = false -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif ); void filterVer(const ComponentID compID, Pel const* src, int srcStride, Pel *dst, int dstStride, int width, int height, int frac, bool isFirst, bool isLast, const ChromaFormat fmt, const ClpRng& clpRng, int nFilterIdx = 0, bool biMCForDMVR = false, bool useAltHpelIf = false); #if JVET_J0090_MEMORY_BANDWITH_MEASURE diff --git a/source/Lib/CommonLib/Mv.cpp b/source/Lib/CommonLib/Mv.cpp index 672add380..56438b3ce 100644 --- a/source/Lib/CommonLib/Mv.cpp +++ b/source/Lib/CommonLib/Mv.cpp @@ -297,6 +297,6 @@ void MvdSuffixInfo::defineNumberOfPredictedBinsInSuffix(const int iHorPrefix, co horOffsetPredictionNumBins = std::min(iAvailBinsInHorSuffix, iNumberOfHorMSBins); verOffsetPredictionNumBins = std::min(iAvailBinsInVerSuffix, iNumberOfVerMSBins); } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif //! \} diff --git a/source/Lib/CommonLib/Mv.h b/source/Lib/CommonLib/Mv.h index df0d58e54..b4d1142db 100644 --- a/source/Lib/CommonLib/Mv.h +++ b/source/Lib/CommonLib/Mv.h @@ -251,7 +251,7 @@ public: { return MV_PRECISION_4PEL == m_amvrPrecIbc[imv] ? 2 : 0; } -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif Mv getSymmvdMv(const Mv& curMvPred, const Mv& tarMvPred) { @@ -270,7 +270,7 @@ public: ver = (ver + mvClipPeriod) & (mvClipPeriod - 1); ver = (ver >= halMvClipPeriod) ? (ver - mvClipPeriod) : ver; } -#if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED +#if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED || JVET_AC0104_IBC_BVD_PREDICTION bool isMvsdApplicable() const { return (getAbsHor() + getAbsVer()) >= 1; @@ -354,7 +354,7 @@ struct MvdSuffixInfo }; -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif namespace std { diff --git a/source/Lib/CommonLib/RdCost.h b/source/Lib/CommonLib/RdCost.h index 0189d821e..de71d009b 100644 --- a/source/Lib/CommonLib/RdCost.h +++ b/source/Lib/CommonLib/RdCost.h @@ -229,13 +229,8 @@ public: void getMotionCost(int add) { m_dCost = m_dLambdaMotionSAD + add; } -#if JVET_AA0070_RRIBC - void setPredictors(Mv pcMv[3][2]); -#if JVET_Z0131_IBC_BVD_BINARIZATION - EstBvdBitsStruct *getBvdBitCosts() { return &m_cBvdBitCosts; } - #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - inline Distortion getbvVerNullCompCost(int x, bool useIMV, int *tempImv, int *tempIdx, Mv bvp1Pel[2]) + inline Distortion getBvVerZeroCompCost(int x, bool useIMV, int *tempImv, int *tempIdx, Mv bvp1Pel[2]) { uint32_t b0 = xGetExpGolombNumberOfBitsIBCH(x - bvp1Pel[0].getHor()) + m_cBvdBitCosts.bitsIdx[0]; uint32_t b1 = xGetExpGolombNumberOfBitsIBCH(x - bvp1Pel[1].getHor()) + m_cBvdBitCosts.bitsIdx[1]; @@ -272,7 +267,7 @@ public: return Distortion(m_dCost * bestCost) >> SCALE_BITS; } - inline Distortion getbvHorNullCompCost(int y, bool useIMV, int *tempImv, int *tempIdx, Mv bvp1Pel[2]) + inline Distortion getBvHorZeroCompCost(int y, bool useIMV, int *tempImv, int *tempIdx, Mv bvp1Pel[2]) { uint32_t b0 = xGetExpGolombNumberOfBitsIBCV(y - bvp1Pel[0].getVer()) + m_cBvdBitCosts.bitsIdx[0]; uint32_t b1 = xGetExpGolombNumberOfBitsIBCV(y - bvp1Pel[1].getVer()) + m_cBvdBitCosts.bitsIdx[1]; @@ -311,6 +306,11 @@ public: } #endif +#if JVET_AA0070_RRIBC + void setPredictors(Mv pcMv[3][2]); +#if JVET_Z0131_IBC_BVD_BINARIZATION + EstBvdBitsStruct *getBvdBitCosts() { return &m_cBvdBitCosts; } + #if JVET_Z0084_IBC_TM && IBC_TM_AMVP inline Distortion getBvCostMultiplePreds(int x, int y, bool useIMV, int rribcFlipType, uint8_t *bvImvResBest = NULL, int *bvpIdxBest = NULL, bool flag = false, AMVPInfo *amvpInfo4Pel = NULL) #else diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 55e96ee10..626e1b793 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -173,25 +173,6 @@ #define JVET_AC0105_DIRECTIONAL_PLANAR 1 // JVET-AC0105: Directional planar #define JVET_AC0071_DBV 1 // JVET-AC0071: Direct block vector mode for chroma prediction -//IBC -#define JVET_Y0058_IBC_LIST_MODIFY 1 // JVET-Y0058: Modifications of IBC merge/AMVP list construction, ARMC-TM-IBC part is included under JVET_W0090_ARMC_TM -#define JVET_Z0075_IBC_HMVP_ENLARGE 1 // JVET-Z0075: Enlarged HMVP table for IBC -#define JVET_Z0084_IBC_TM 1 // JVET-Z0084: Add template matching in IBC modes. [0 = disable, 1 (default) = enable for IBC-AMVP and IBC-MRG, 2 = enable for IBC-AMVP, 3 = enable for IBC-MRG] -#if JVET_Z0084_IBC_TM -#define IBC_TM_AMVP ((JVET_Z0084_IBC_TM) == 1 || (JVET_Z0084_IBC_TM) == 2) // Add template matching to IBC to refine IBC AMVP candidates -#define IBC_TM_MRG ((JVET_Z0084_IBC_TM) == 1 || (JVET_Z0084_IBC_TM) == 3) // Add template matching to IBC to refine IBC merge candidates -#endif -#define JVET_Z0131_IBC_BVD_BINARIZATION 1 // JVET-Z0131: Block vector difference binarization -#define JVET_Z0153_IBC_EXT_REF 1 // JVET-Z0153: Extend reference area for IBC -#define JVET_Z0160_IBC_ZERO_PADDING 1 // JVET-Z0160: Replacement of zero-padding candidates -#define JVET_AA0106_IBCBUF_CTU256 1 // JVET-AA0106: Adjust IBC reference area to 2*128 rows above the current CTU -#define JVET_AA0061_IBC_MBVD 1 // JVET-AA0061: IBC merge mode with block vector differences -#define JVET_AA0070_RRIBC 1 // JVET-AA0070: Reconstruction-Reordered IBC -#define JVET_AC0112_IBC_CIIP 1 // JVET-AC0112: Combined IBC and intra prediction (IBC-CIIP) -#define JVET_AC0112_IBC_GPM 1 // JVET-AC0112: IBC with geometry partitioning mode (IBC-GPM) -#define JVET_AC0112_IBC_LIC 1 // JVET-AC0112: IBC with local illumination compensation (IBC-LIC) -#define JVET_AC0104_IBC_BVD_PREDICTION 1 // JVET-AC0104: IBC block vector difference prediction (part of JVET-AC0113 Test 3.5a) -#define JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV 1 // JVET-AC0060: IBC BVP candidates clustering and BVD sign derivation for BV with one null component (part of JVET-AC0113 Test 3.5a) // Inter #define CIIP_PDPC 1 // Apply pdpc to megre prediction as a new CIIP mode (CIIP_PDPC) additional to CIIP mode #define JVET_X0090_CIIP_FIX 1 // JVET-X0090: combination of CIIP, OBMC and LMCS @@ -259,7 +240,6 @@ #define JVET_Z0061_TM_OBMC 1 // JVET-Z0061: Template matching based OBMC #endif #define JVET_AA0132_CONFIGURABLE_TM_TOOLS 1 // JVET-AA0132: Configuration parameters and SPS flags for template matching tools -#define JVET_AB0079_TM_BCW_MRG 1 // JVET-AB0079: Template matching based BCW index derivation for merge mode with positive weights only #endif #define JVET_W0097_GPM_MMVD_TM 1 // JVET-W0097: GPM-MMVD and GPM-TM, GPM-TM part is controlled by TM_MRG #define JVET_X0141_CIIP_TIMD_TM 1 // JVET-X0141: CIIP with TIMD and TM merge, CIIP-TM part is controlled by TM_MRG, and CIIP-TIMD part is controlled by JVET_W0123_TIMD_FUSION @@ -273,8 +253,34 @@ #define JVET_Z0054_BLK_REF_PIC_REORDER 1 // JVET-Z0054: Block level TM based reordering of reference pictures #define JVET_AA0093_REFINED_MOTION_FOR_ARMC 1 // JVET-AA0093: Refined motion for ARMC #define JVET_AA0093_DIVERSITY_CRITERION_FOR_ARMC 1 // JVET-AA0093: Diversity criterion for ARMC reordering +#define JVET_AB0079_TM_BCW_MRG 1 // JVET-AB0079: Template matching based BCW index derivation for merge mode with positive weights only #define JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION 1 // JVET-AC0185: Enhanced temporal motion information derivation #endif + +//IBC +#define JVET_Y0058_IBC_LIST_MODIFY 1 // JVET-Y0058: Modifications of IBC merge/AMVP list construction, ARMC-TM-IBC part is included under JVET_W0090_ARMC_TM +#define JVET_Z0075_IBC_HMVP_ENLARGE 1 // JVET-Z0075: Enlarged HMVP table for IBC +#define JVET_Z0084_IBC_TM 1 // JVET-Z0084: Add template matching in IBC modes. [0 = disable, 1 (default) = enable for IBC-AMVP and IBC-MRG, 2 = enable for IBC-AMVP, 3 = enable for IBC-MRG] +#if JVET_Z0084_IBC_TM +#define IBC_TM_AMVP ((JVET_Z0084_IBC_TM) == 1 || (JVET_Z0084_IBC_TM) == 2) // Add template matching to IBC to refine IBC AMVP candidates +#define IBC_TM_MRG ((JVET_Z0084_IBC_TM) == 1 || (JVET_Z0084_IBC_TM) == 3) // Add template matching to IBC to refine IBC merge candidates +#endif +#define JVET_Z0131_IBC_BVD_BINARIZATION 1 // JVET-Z0131: Block vector difference binarization +#define JVET_Z0153_IBC_EXT_REF 1 // JVET-Z0153: Extend reference area for IBC +#define JVET_Z0160_IBC_ZERO_PADDING 1 // JVET-Z0160: Replacement of zero-padding candidates +#define JVET_AA0106_IBCBUF_CTU256 1 // JVET-AA0106: Adjust IBC reference area to 2*128 rows above the current CTU +#define JVET_AA0061_IBC_MBVD 1 // JVET-AA0061: IBC merge mode with block vector differences +#define JVET_AA0070_RRIBC 1 // JVET-AA0070: Reconstruction-Reordered IBC +#define JVET_AC0112_IBC_CIIP 1 // JVET-AC0112: Combined IBC and intra prediction (IBC-CIIP) +#define JVET_AC0112_IBC_GPM 1 // JVET-AC0112: IBC with geometry partitioning mode (IBC-GPM) +#define JVET_AC0112_IBC_LIC 1 // JVET-AC0112: IBC with local illumination compensation (IBC-LIC) +#if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED +#define JVET_AC0104_IBC_BVD_PREDICTION 1 // JVET-AC0104: IBC block vector difference prediction (part of JVET-AC0113 Test 3.5a) +#endif +#if JVET_W0090_ARMC_TM +#define JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV 1 // JVET-AC0060: IBC BVP candidates clustering and BVD sign derivation for BV with one null component (part of JVET-AC0113 Test 3.5a) +#endif + // Transform and coefficient coding #define TCQ_8STATES 1 #define JVET_W0119_LFNST_EXTENSION 1 // JVET-W0119: LFNST extension with large kernel diff --git a/source/Lib/CommonLib/Unit.cpp b/source/Lib/CommonLib/Unit.cpp index 2df3d8832..b1201f7dd 100644 --- a/source/Lib/CommonLib/Unit.cpp +++ b/source/Lib/CommonLib/Unit.cpp @@ -380,8 +380,8 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other ) rribcFlipType = other.rribcFlipType; #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - bvOneNullComp = other.bvOneNullComp; - bvNullCompDir = other.bvNullCompDir; + bvOneZeroComp = other.bvOneZeroComp; + bvZeroCompDir = other.bvZeroCompDir; #endif #if JVET_AB0157_TMRL tmrlFlag = other.tmrlFlag; @@ -557,8 +557,8 @@ void CodingUnit::initData() tmrlListIdx = 0; #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - bvOneNullComp = 0; - bvNullCompDir = 0; + bvOneZeroComp = 0; + bvZeroCompDir = 0; #endif #if JVET_AC0094_REF_SAMPLES_OPT areAboveRightUnavail = false; @@ -818,7 +818,7 @@ void PredictionUnit::initData() #endif #endif // inter data -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION colIdx = 0; #endif mergeFlag = false; @@ -976,7 +976,7 @@ PredictionUnit& PredictionUnit::operator=(const IntraPredictionData& predData) PredictionUnit& PredictionUnit::operator=(const InterPredictionData& predData) { -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION colIdx = predData.colIdx; #endif mergeFlag = predData.mergeFlag; @@ -1071,7 +1071,7 @@ PredictionUnit& PredictionUnit::operator=(const InterPredictionData& predData) } #if JVET_AC0104_IBC_BVD_PREDICTION bvdSuffixInfo = predData.bvdSuffixInfo; -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif #if JVET_Z0054_BLK_REF_PIC_REORDER refIdxLC = predData.refIdxLC; refPairIdx = predData.refPairIdx; @@ -1128,7 +1128,7 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other ) mergeFlag = other.mergeFlag; regularMergeFlag = other.regularMergeFlag; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION colIdx = other.colIdx; #endif mergeIdx = other.mergeIdx; @@ -1228,7 +1228,7 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other ) } #if JVET_AC0104_IBC_BVD_PREDICTION bvdSuffixInfo = other.bvdSuffixInfo; -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif #if JVET_Z0054_BLK_REF_PIC_REORDER refIdxLC = other.refIdxLC; diff --git a/source/Lib/CommonLib/Unit.h b/source/Lib/CommonLib/Unit.h index 67e6ecbc6..602343e77 100644 --- a/source/Lib/CommonLib/Unit.h +++ b/source/Lib/CommonLib/Unit.h @@ -410,8 +410,8 @@ struct CodingUnit : public UnitArea int rribcFlipType; #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - int bvOneNullComp; // IBC BV has one null component - int bvNullCompDir; // 1: vertical null comp. 2: horizontal null comp. + int bvOneZeroComp; // IBC BV has one null component + int bvZeroCompDir; // 1: vertical null comp. 2: horizontal null comp. #endif #if JVET_AB0157_TMRL bool tmrlFlag; @@ -524,7 +524,7 @@ struct IntraPredictionData struct InterPredictionData { -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION uint8_t colIdx; #endif bool mergeFlag; @@ -632,7 +632,7 @@ struct InterPredictionData #endif #if JVET_AC0104_IBC_BVD_PREDICTION MvdSuffixInfo bvdSuffixInfo; -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif Mv bv; // block vector for IBC Mv bvd; // block vector difference for IBC diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 26f65ac7d..d8b0baf64 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -2798,7 +2798,7 @@ uint8_t PU::getLFNSTIdx( int intraMode, int mtsMode ) return g_lfnstLut[ intraMode ]; } #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void PU::addMergeHMVPCandSubTMVP(const CodingStructure &cs, MergeCtx &mrgCtx, const int &mrgCandIdx, const uint32_t maxNumMergeCand, int &cnt, const bool isAvailableA1, const MotionInfo miLeft, const bool isAvailableB1, const MotionInfo miAbove, @@ -2819,20 +2819,17 @@ void PU::addMergeHMVPCandSubTMVP(const CodingStructure &cs, MergeCtx &mrgCtx, co #if JVET_Z0075_IBC_HMVP_ENLARGE #if JVET_Z0118_GDR bool isClean = cs.isClean(pu.cu->Y().bottomRight(), CHANNEL_TYPE_LUMA); -#endif // JVET_Z0118_GDR - -#if JVET_Z0118_GDR auto &lut = (isClean) ? cs.motionLut.lut1 : cs.motionLut.lut0; #else auto &lut = cs.motionLut.lut; -#endif // JVET_Z0118_GDR +#endif #else #if JVET_Z0118_GDR auto &lut = ibcFlag ? (isClean ? cs.motionLut.lutIbc1 : cs.motionLut.lutIbc0) : (isClean ? cs.motionLut.lut1 : cs.motionLut.lut0); #else auto &lut = ibcFlag ? cs.motionLut.lutIbc : cs.motionLut.lut; -#endif // JVET_Z0118_GDR +#endif #endif // JVET_Z0075_IBC_HMVP_ENLARGE int numCandInLUT = (int)lut.size(); @@ -4369,7 +4366,7 @@ int PU::reorderInterMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, } } #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void PU::getInterMergeCandidatesSubTMVP(const PredictionUnit &pu, MergeCtx& mrgCtx, int col, const int& mrgCandIdx @@ -5349,20 +5346,10 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, int iRefIdx = 0; int dir = 0; unsigned uiArrayAddr = cnt; -#if !ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION - int cntTmp = cnt; - for (int colIdx = 0; colIdx < (pu.cu->slice->isInterB() ? 2 : 1); colIdx++) - { - if (colIdx && cnt != cntTmp) - { - break; - } -#endif - bool bExistMV = (isC0Avail && getColocatedMVP(pu, REF_PIC_LIST_0, posC0, cColMv, iRefIdx, false + + bool bExistMV = (isC0Avail && getColocatedMVP(pu, REF_PIC_LIST_0, posC0, cColMv, iRefIdx, false #if JVET_Y0134_TMVP_NAMVP_CAND_REORDERING -#if !ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION - , colIdx -#elif JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , 0 #endif , &iRefIdx @@ -5370,9 +5357,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, )) || getColocatedMVP(pu, REF_PIC_LIST_0, posC1, cColMv, iRefIdx, false #if JVET_Y0134_TMVP_NAMVP_CAND_REORDERING -#if !ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION - , colIdx -#elif JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , 0 #endif , &iRefIdx @@ -5388,9 +5373,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, { bExistMV = (isC0Avail && getColocatedMVP(pu, REF_PIC_LIST_1, posC0, cColMv, iRefIdx, false #if JVET_Y0134_TMVP_NAMVP_CAND_REORDERING -#if !ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION - , colIdx -#elif JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , 0 #endif , &iRefIdx @@ -5398,9 +5381,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, )) || getColocatedMVP(pu, REF_PIC_LIST_1, posC1, cColMv, iRefIdx, false #if JVET_Y0134_TMVP_NAMVP_CAND_REORDERING -#if !ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION - , colIdx -#elif JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , 0 #endif , &iRefIdx @@ -5588,9 +5569,6 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, #endif } #endif -#endif -#if !ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION - } #endif } @@ -10132,28 +10110,24 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, const in Position posRT = pu.Y().topRight(); Position posLB = pu.Y().bottomLeft(); - { - bool bAdded = addMVPCandUnscaled( pu, eRefPicList, refIdx, posLB, MD_BELOW_LEFT, *pInfo ); + bool bAdded = addMVPCandUnscaled( pu, eRefPicList, refIdx, posLB, MD_BELOW_LEFT, *pInfo ); - if( !bAdded ) - { - bAdded = addMVPCandUnscaled( pu, eRefPicList, refIdx, posLB, MD_LEFT, *pInfo ); + if( !bAdded ) + { + bAdded = addMVPCandUnscaled( pu, eRefPicList, refIdx, posLB, MD_LEFT, *pInfo ); - } } // Above predictor search + bAdded = addMVPCandUnscaled( pu, eRefPicList, refIdx, posRT, MD_ABOVE_RIGHT, *pInfo ); + + if( !bAdded ) { - bool bAdded = addMVPCandUnscaled( pu, eRefPicList, refIdx, posRT, MD_ABOVE_RIGHT, *pInfo ); + bAdded = addMVPCandUnscaled( pu, eRefPicList, refIdx, posRT, MD_ABOVE, *pInfo ); if( !bAdded ) { - bAdded = addMVPCandUnscaled( pu, eRefPicList, refIdx, posRT, MD_ABOVE, *pInfo ); - - if( !bAdded ) - { - addMVPCandUnscaled( pu, eRefPicList, refIdx, posLT, MD_ABOVE_LEFT, *pInfo ); - } + addMVPCandUnscaled( pu, eRefPicList, refIdx, posLT, MD_ABOVE_LEFT, *pInfo ); } } @@ -10170,7 +10144,7 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, const in } } -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION #if TM_AMVP if (cs.picHeader->getEnableTMVPFlag() && pInfo->numCand < pInfo->maxStorageSize && (pu.lumaSize().width + pu.lumaSize().height > 8)) #else @@ -10408,17 +10382,8 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, const in } } #if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION -#if !ENABLE_INTER_TEMPLATE_MATCHING - int count = 0; -#endif for (int colIdx = 0; colIdx < (pu.cu->slice->isInterB() ? 2 : 1); colIdx++) { -#endif -#if !ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION - if (count) - { - break; - } #endif if ((isC0Avail && getColocatedMVP(pu, eRefPicList, posC0, cColMv, refIdxCol, false #if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION @@ -10430,9 +10395,6 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, const in #endif )) { -#if !ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION - count++; -#endif cColMv.roundTransPrecInternal2Amvr(pu.cu->imv); #if TM_AMVP pInfo->mvCand[pInfo->numCand] = cColMv; @@ -12404,7 +12366,7 @@ void PU::getAffineControlPointCand(const PredictionUnit &pu, MotionInfo mi[4], b affMrgType.mvFieldNeighbours[(affMrgType.numValidMergeCand << 1) + 1][i].mv = cMv[1][i]; affMrgType.mvFieldNeighbours[(affMrgType.numValidMergeCand << 1) + 1][i].refIdx = refIdx[1]; } -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION affMrgType.colIdx[affMrgType.numValidMergeCand] = 0; #endif affMrgType.interDirNeighbours[affMrgType.numValidMergeCand] = dir; @@ -13331,7 +13293,7 @@ const int getAvailableAffineNeighboursForAbovePredictor( const PredictionUnit &p } void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION MergeCtx mrgCtxIn[2], #endif #if JVET_AA0107_RMVF_AFFINE_MERGE_DERIVATION && JVET_W0090_ARMC_TM @@ -13384,7 +13346,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx affMrgCtx.numAffCandToTestEnc = maxNumAffineMergeCand; affMrgCtx.candCost[i] = MAX_UINT64; #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION affMrgCtx.colIdx[i] = 0; #endif } @@ -13406,7 +13368,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx #endif { #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { CHECK(mrgCtx.subPuMvpMiBuf[i].area() == 0 || !mrgCtx.subPuMvpMiBuf[i].buf, "Buffer not initialized"); @@ -13422,7 +13384,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx #endif int pos = 0; -#if !(JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION && ENABLE_INTER_TEMPLATE_MATCHING) +#if !JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION // Get spatial MV const Position posCurLB = pu.Y().bottomLeft(); MotionInfo miLeft; @@ -13460,25 +13422,15 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx #if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION int poc0 = pu.cu->slice->getRefPic(RefPicList(1 - pu.cu->slice->getColFromL0Flag()), pu.cu->slice->getColRefIdx())->getPOC(); int poc1 = pu.cu->slice->getRefPic(RefPicList(1 - pu.cu->slice->getColFromL0Flag2nd()), pu.cu->slice->getColRefIdx2nd())->getPOC(); -#if ENABLE_INTER_TEMPLATE_MATCHING for (int index = 0; index < SUB_TMVP_INDEX; index++) { -#endif for (int colFrameIdx = 0; colFrameIdx < ((pu.cu->slice->getCheckLDC() || (poc0 == poc1)) ? 1 : 2); colFrameIdx++) { -#endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION if (index > 0 && colFrameIdx == 1) { continue; } #endif -#if !ENABLE_INTER_TEMPLATE_MATCHING - if (affMrgCtx.numValidMergeCand == 1) - { - break; - } -#endif #if JVET_Z0139_NA_AFF && JVET_W0090_ARMC_TM #if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION isAvailableSubPu = getInterMergeSubPuMvpCand(pu, mrgCtx, tmpLICFlag, 0, index, mrgCtxIn[colFrameIdx], colFrameIdx); @@ -13505,7 +13457,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx affMrgCtx.affineType[affMrgCtx.numValidMergeCand] = AFFINE_MODEL_NUM; affMrgCtx.mergeType[affMrgCtx.numValidMergeCand] = MRG_TYPE_SUBPU_ATMVP; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION affMrgCtx.colIdx[affMrgCtx.numValidMergeCand] = (index << 1) + colFrameIdx; #endif #if AFFINE_MMVD @@ -13532,9 +13484,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx } #if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION } -#if ENABLE_INTER_TEMPLATE_MATCHING } -#endif #endif } @@ -13627,7 +13577,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx affMrgCtx.interDirNeighbours[affMrgCtx.numValidMergeCand] = puNeigh->interDir; affMrgCtx.affineType[affMrgCtx.numValidMergeCand] = (EAffineModel)(puNeigh->cu->affineType); affMrgCtx.bcwIdx[affMrgCtx.numValidMergeCand] = puNeigh->cu->bcwIdx; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION affMrgCtx.colIdx[affMrgCtx.numValidMergeCand] = 0; #endif #if INTER_LIC @@ -14162,7 +14112,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx } const int MAX_PAIRWISE_NUM = 9; const int preDefinedPairs[MAX_PAIRWISE_NUM][2] = { {0, 1}, {0, 2}, {1, 2}, {0, 3}, {1, 3}, { 2, 3}, { 0, 4}, {1, 4}, { 2, 4} }; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION int iATMVPoffset = 0; for (int index = 0; index < affMrgCtx.numValidMergeCand; index++) { @@ -14268,7 +14218,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx affMrgCtx.mvFieldNeighbours[(cnt << 1) + 0][mvNum].setMvField( Mv( 0, 0 ), 0 ); } affMrgCtx.interDirNeighbours[cnt] = 1; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION affMrgCtx.colIdx[cnt] = 0; #endif @@ -14630,7 +14580,7 @@ void clipColPos(int& posX, int& posY, const PredictionUnit& pu) #endif } -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void PU::getTMVPCandOpt(const PredictionUnit &pu, RefPicList refList, int refIdx, MergeCtx& mrgCtx, MergeCtx mergeCtxIn, int col) { const uint32_t maxNumMergeCand = NUM_TMVP_CANDS; @@ -14747,9 +14697,7 @@ void PU::getTMVPCandOpt(const PredictionUnit &pu, RefPicList refList, int refIdx #endif bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, bool& LICFlag, const int count #if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION -#if ENABLE_INTER_TEMPLATE_MATCHING , int subIdx, MergeCtx mergeCtxIn -#endif , int col #else , int mmvdList @@ -14774,7 +14722,7 @@ bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, b #endif Mv cTMv; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION if (subIdx > mergeCtxIn.numValidMergeCand) { return false; @@ -14890,7 +14838,7 @@ bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, b int xOff = (puWidth >> 1) + tempX; int yOff = (puHeight >> 1) + tempY; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION MotionBuf &mb = mrgCtx.subPuMvpMiBuf[(subIdx << 1) + col]; #else MotionBuf &mb = mrgCtx.subPuMvpMiBuf; @@ -14969,7 +14917,7 @@ bool PU::getInterMergeSubPuMvpCand(const PredictionUnit &pu, MergeCtx& mrgCtx, b #if MULTI_PASS_DMVR void PU::spanMotionInfo(PredictionUnit &pu, const MergeCtx &mrgCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION int colIdx, #endif Mv* bdmvrSubPuMv0, Mv* bdmvrSubPuMv1, Mv* bdofSubPuMvOffset) @@ -15107,7 +15055,7 @@ void PU::spanMotionInfo( PredictionUnit &pu, const MergeCtx &mrgCtx ) } else if (pu.mergeType == MRG_TYPE_SUBPU_ATMVP) { -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { CHECK(mrgCtx.subPuMvpMiBuf[i].area() == 0 || !mrgCtx.subPuMvpMiBuf[i].buf, "Buffer not initialized"); @@ -15118,7 +15066,7 @@ void PU::spanMotionInfo( PredictionUnit &pu, const MergeCtx &mrgCtx ) #if MULTI_PASS_DMVR MotionBuf mb = pu.getMotionBuf(); #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION mb.copyFrom(mrgCtx.subPuMvpMiBuf[pu.colIdx]); #else mb.copyFrom(mrgCtx.subPuMvpMiBuf); @@ -15132,7 +15080,7 @@ void PU::spanMotionInfo( PredictionUnit &pu, const MergeCtx &mrgCtx ) #if JVET_W0123_TIMD_FUSION #if MULTI_PASS_DMVR void PU::spanMotionInfo2(PredictionUnit &pu, const MergeCtx &mrgCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION int colIdx, #endif Mv* bdmvrSubPuMv0, Mv* bdmvrSubPuMv1, Mv* bdofSubPuMvOffset) @@ -15218,7 +15166,7 @@ void PU::spanMotionInfo2( PredictionUnit &pu, const MergeCtx &mrgCtx ) } else if (pu.mergeType == MRG_TYPE_SUBPU_ATMVP) { -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { CHECK(mrgCtx.subPuMvpMiBuf[i].area() == 0 || !mrgCtx.subPuMvpMiBuf[i].buf, "Buffer not initialized"); @@ -15229,7 +15177,7 @@ void PU::spanMotionInfo2( PredictionUnit &pu, const MergeCtx &mrgCtx ) #if MULTI_PASS_DMVR MotionBuf mb = pu.getMotionBuf(); #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION mb.copyFrom(mrgCtx.subPuMvpMiBuf[pu.colIdx]); #else mb.copyFrom(mrgCtx.subPuMvpMiBuf); diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h index 45821ed29..81101a1ff 100644 --- a/source/Lib/CommonLib/UnitTools.h +++ b/source/Lib/CommonLib/UnitTools.h @@ -344,7 +344,7 @@ namespace PU , const uint32_t mvdSimilarityThresh = 1 #endif ); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void addMergeHMVPCandSubTMVP(const CodingStructure &cs, MergeCtx& mrgCtx, const int& mrgCandIdx, const uint32_t maxNumMergeCand, int &cnt , const bool isAvailableA1, const MotionInfo miLeft, const bool isAvailableB1, const MotionInfo miAbove #if !JVET_Z0075_IBC_HMVP_ENLARGE @@ -420,7 +420,7 @@ namespace PU bool isBipredRestriction (const PredictionUnit &pu); #if MULTI_PASS_DMVR void spanMotionInfo ( PredictionUnit &pu, const MergeCtx &mrgCtx = MergeCtx(), -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION int colIdx = 0, #endif Mv* bdmvrSubPuMv0 = nullptr, Mv* bdmvrSubPuMv1 = nullptr, Mv* bdofSubPuMvOffset = nullptr ); @@ -430,7 +430,7 @@ namespace PU #if JVET_W0123_TIMD_FUSION #if MULTI_PASS_DMVR void spanMotionInfo2 ( PredictionUnit &pu, const MergeCtx &mrgCtx = MergeCtx(), -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION int colIdx = 0, #endif Mv* bdmvrSubPuMv0 = nullptr, Mv* bdmvrSubPuMv1 = nullptr, Mv* bdofSubPuMvOffset = nullptr ); @@ -464,7 +464,7 @@ namespace PU int getNonAdjAffParaDivFun(int num1, int num2); #endif void getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION MergeCtx mrgCtx[2], #endif #if JVET_AA0107_RMVF_AFFINE_MERGE_DERIVATION && JVET_W0090_ARMC_TM @@ -488,15 +488,13 @@ namespace PU void setAllAffineMv ( PredictionUnit &pu, Mv affLT, Mv affRT, Mv affLB, RefPicList eRefList, bool clipCPMVs = false ); bool getInterMergeSubPuMvpCand (const PredictionUnit &pu, MergeCtx& mrgCtx, bool& LICFlag, const int count #if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION -#if ENABLE_INTER_TEMPLATE_MATCHING , int subIdx, MergeCtx mergeCtxIn -#endif , int col = 0 #else , int mmvdList #endif ); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION void getTMVPCandOpt(const PredictionUnit &pu, RefPicList refList, int refIdx, MergeCtx &mrgCtx, MergeCtx mergeCtx, int col = 0); #endif #if JVET_Y0128_NON_CTC diff --git a/source/Lib/CommonLib/x86/InterpolationFilterX86.h b/source/Lib/CommonLib/x86/InterpolationFilterX86.h index fca3c1987..4f4ae2adb 100644 --- a/source/Lib/CommonLib/x86/InterpolationFilterX86.h +++ b/source/Lib/CommonLib/x86/InterpolationFilterX86.h @@ -746,7 +746,7 @@ static void simdFilterCopyWithNoClipping(const ClpRng& clpRng, const Pel* src, i InterpolationFilter::filterCopyWithNoClipping(clpRng, src, srcStride, dst, dstStride, width, height); } } -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif // SIMD interpolation horizontal, block width modulo 4 template<X86_VEXT vext, int N, bool shiftBack> @@ -5146,7 +5146,7 @@ void InterpolationFilter::_initInterpolationFilterX86() m_filterCopy[1][1] = simdFilterCopy<vext, true, true>; #if JVET_AC0104_IBC_BVD_PREDICTION m_filterCopyWithNoClipping = simdFilterCopyWithNoClipping<vext>; -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif #else // [taps][bFirst][bLast] m_filterHor[0][0][0] = simdFilter<vext, 8, false, false, false>; @@ -5216,7 +5216,7 @@ void InterpolationFilter::_initInterpolationFilterX86() m_filterCopy[1][1] = simdFilterCopy<vext, true, true>; #if JVET_AC0104_IBC_BVD_PREDICTION m_filterCopyWithNoClipping = simdFilterCopyWithNoClipping<vext>; -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif #endif m_weightedGeoBlk = xWeightedGeoBlk_SSE<vext>; #if JVET_Y0065_GPM_INTRA diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 421e04caf..8cf65e63f 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -3301,7 +3301,7 @@ void CABACReader::prediction_unit( PredictionUnit& pu, MergeCtx& mrgCtx ) rribcData(*pu.cu); #endif #else - bvOneNullComp_data(*pu.cu); + bvOneZeroComp(*pu.cu); #endif #if JVET_AC0112_IBC_LIC cuIbcLicFlag(*pu.cu); @@ -3336,28 +3336,28 @@ void CABACReader::prediction_unit( PredictionUnit& pu, MergeCtx& mrgCtx ) #if JVET_Z0131_IBC_BVD_BINARIZATION #if JVET_AC0104_IBC_BVD_PREDICTION #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - bvdCoding(pu.mvd[REF_PIC_LIST_0], pu.bvdSuffixInfo, pu.cu->bvOneNullComp, pu.cu->bvNullCompDir); + bvdCoding(pu.mvd[REF_PIC_LIST_0], pu.bvdSuffixInfo, pu.cu->bvOneZeroComp, pu.cu->bvZeroCompDir); #else bvdCoding(pu.mvd[REF_PIC_LIST_0], pu.bvdSuffixInfo, pu.cu->rribcFlipType); #endif -#else // !JVET_AC0104_IBC_BVD_PREDICTION +#else #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - bvdCoding(pu.mvd[REF_PIC_LIST_0], pu.cu->bvOneNullComp, pu.cu->bvNullCompDir); + bvdCoding(pu.mvd[REF_PIC_LIST_0], pu.cu->bvOneZeroComp, pu.cu->bvZeroCompDir); #else bvdCoding(pu.mvd[REF_PIC_LIST_0], pu.cu->rribcFlipType); #endif -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif #else #if JVET_AC0104_IBC_BVD_PREDICTION #error Not implemented -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif mvd_coding(pu.mvd[REF_PIC_LIST_0], true, pu.cu->rribcFlipType); #endif #elif JVET_Z0131_IBC_BVD_BINARIZATION bvdCoding(pu.mvd[REF_PIC_LIST_0] #if JVET_AC0104_IBC_BVD_PREDICTION , pu.bvdSuffixInfo -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif ); #else mvd_coding(pu.mvd[REF_PIC_LIST_0]); @@ -3374,11 +3374,11 @@ void CABACReader::prediction_unit( PredictionUnit& pu, MergeCtx& mrgCtx ) #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV && JVET_AA0070_RRIBC if (pu.mvpIdx[REF_PIC_LIST_0] == 0) { - if (pu.cu->bvNullCompDir == 1) + if (pu.cu->bvZeroCompDir == 1) { pu.mvd[REF_PIC_LIST_0].hor = -pu.mvd[REF_PIC_LIST_0].hor; } - else if (pu.cu->bvNullCompDir == 2) + else if (pu.cu->bvZeroCompDir == 2) { pu.mvd[REF_PIC_LIST_0].ver = -pu.mvd[REF_PIC_LIST_0].ver; } @@ -3587,12 +3587,12 @@ void CABACReader::mvsd_data(PredictionUnit& pu) { return; } -#endif // !JVET_AC0104_IBC_BVD_PREDICTION +#endif if (pu.cu->skip || pu.mergeFlag #if !JVET_AC0104_IBC_BVD_PREDICTION || CU::isIBC(*pu.cu) -#endif // !JVET_AC0104_IBC_BVD_PREDICTION +#endif || !pu.isMvsdApplicable()) { return; @@ -3614,7 +3614,7 @@ void CABACReader::mvsd_data(PredictionUnit& pu) { return; } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif if (pu.interDir != 1 /* PRED_L0 */ && pu.cu->smvdMode != 1) { @@ -5743,7 +5743,7 @@ unsigned CABACReader::xReadBvdContextSuffix(int symbol, int param ) return symbol; } -#else //!JVET_AC0104_IBC_BVD_PREDICTION +#else unsigned CABACReader::xReadBvdContext(unsigned ctxT, int offset, int param ) { unsigned symbol = 0; @@ -5771,7 +5771,7 @@ unsigned CABACReader::xReadBvdContext(unsigned ctxT, int offset, int param ) } return symbol; } -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif #endif @@ -5880,33 +5880,34 @@ void CABACReader::bvdCodingRemainder(Mv& rMvd, MvdSuffixInfo& si, const int imv rMvd = Mv(horAbs, verAbs); } } -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif + #if JVET_AA0070_RRIBC #if JVET_AC0104_IBC_BVD_PREDICTION #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV -void CABACReader::bvdCoding(Mv& rMvd, MvdSuffixInfo& si, int bvOneNullComp, int bvNullCompDir) +void CABACReader::bvdCoding(Mv& rMvd, MvdSuffixInfo& si, int bvOneZeroComp, int bvZeroCompDir) #else void CABACReader::bvdCoding(Mv& rMvd, MvdSuffixInfo& si, const int& rribcFlipType) #endif -#else // !JVET_AC0104_IBC_BVD_PREDICTION +#else #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV -void CABACReader::bvdCoding(Mv& rMvd, int bvOneNullComp, int bvNullCompDir) +void CABACReader::bvdCoding(Mv& rMvd, int bvOneZeroComp, int bvZeroCompDir) #else void CABACReader::bvdCoding(Mv& rMvd, const int& rribcFlipType) #endif -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif { int horAbs = 0, verAbs = 0; #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - if (bvOneNullComp) + if (bvOneZeroComp) { - if (bvNullCompDir == 1) + if (bvZeroCompDir == 1) { horAbs = (int) m_BinDecoder.decodeBin(Ctx::Bvd(HOR_BVD_CTX_OFFSET)); } - if (bvNullCompDir == 2) + if (bvZeroCompDir == 2) { verAbs = (int)m_BinDecoder.decodeBin(Ctx::Bvd(VER_BVD_CTX_OFFSET)); } @@ -5927,10 +5928,14 @@ void CABACReader::bvdCoding(Mv& rMvd, const int& rribcFlipType) } #endif #else -void CABACReader::bvdCoding(Mv & rMvd) +#if JVET_AC0104_IBC_BVD_PREDICTION +void CABACReader::bvdCoding( Mv& rMvd, MvdSuffixInfo& si ) +#else +void CABACReader::bvdCoding(Mv& rMvd) +#endif { - horAbs = (int)m_BinDecoder.decodeBin(Ctx::Bvd(HOR_BVD_CTX_OFFSET)); - verAbs = (int)m_BinDecoder.decodeBin(Ctx::Bvd(VER_BVD_CTX_OFFSET)); + int horAbs = (int)m_BinDecoder.decodeBin(Ctx::Bvd(HOR_BVD_CTX_OFFSET)); + int verAbs = (int)m_BinDecoder.decodeBin(Ctx::Bvd(VER_BVD_CTX_OFFSET)); #endif #if JVET_AC0104_IBC_BVD_PREDICTION @@ -5938,12 +5943,12 @@ void CABACReader::bvdCoding(Mv & rMvd) xReadBvdContextPrefix(NUM_HOR_BVD_CTX, HOR_BVD_CTX_OFFSET, BVD_CODING_GOLOMB_ORDER) : -1; int verParam = ( 0 != verAbs ) ? xReadBvdContextPrefix(NUM_VER_BVD_CTX, VER_BVD_CTX_OFFSET, BVD_CODING_GOLOMB_ORDER) : -1; -#else // !JVET_AC0104_IBC_BVD_PREDICTION +#else if (horAbs) { horAbs += xReadBvdContext(NUM_HOR_BVD_CTX, HOR_BVD_CTX_OFFSET, BVD_CODING_GOLOMB_ORDER); #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV && JVET_AA0070_RRIBC - if (!bvOneNullComp) + if (!bvOneZeroComp) { if (m_BinDecoder.decodeBinEP()) { @@ -5961,7 +5966,7 @@ void CABACReader::bvdCoding(Mv & rMvd) { verAbs += xReadBvdContext(NUM_VER_BVD_CTX, VER_BVD_CTX_OFFSET, BVD_CODING_GOLOMB_ORDER); #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV && JVET_AA0070_RRIBC - if (!bvOneNullComp) + if (!bvOneZeroComp) { if (m_BinDecoder.decodeBinEP()) { @@ -5975,19 +5980,19 @@ void CABACReader::bvdCoding(Mv & rMvd) } #endif } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif rMvd = Mv(horAbs, verAbs); #if JVET_AC0104_IBC_BVD_PREDICTION si.horPrefix = horParam; si.verPrefix = verParam; -#else //!JVET_AC0104_IBC_BVD_PREDICTION +#else CHECK(!((horAbs >= MVD_MIN) && (horAbs <= MVD_MAX)) || !((verAbs >= MVD_MIN) && (verAbs <= MVD_MAX)), "Illegal BVD value"); -#endif //JVET_AC0104_IBC_BVD_PREDICTIONS +#endif } -#endif // JVET_Z0131_IBC_BVD_BINARIZATION +#endif #if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED void CABACReader::mvsdIdxFunc(PredictionUnit &pu, RefPicList eRefList) @@ -6061,7 +6066,7 @@ void CABACReader::mvsdIdxFunc(PredictionUnit &pu, RefPicList eRefList) verPrefix < 0 ? 0 : MvdSuffixInfo::xGetGolombGroupMinValue(verPrefix)); trMv.changeTransPrecAmvr2Internal(pu.cu->imv); -#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV +#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV && JVET_AA0070_RRIBC if (0 != pu.cu->rribcFlipType) { pu.mvsdIdx[eRefList] = mvsdIdx; @@ -6117,7 +6122,7 @@ void CABACReader::mvsdIdxFunc(PredictionUnit &pu, RefPicList eRefList) } return; } -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif if (pu.mvd[eRefList].getHor()) @@ -7527,28 +7532,33 @@ void CABACReader::cu_lic_flag( CodingUnit& cu ) #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV -void CABACReader::bvOneNullComp_data(CodingUnit &cu) +void CABACReader::bvOneZeroComp(CodingUnit &cu) { if (!CU::isIBC(cu) || cu.firstPU->mergeFlag) { return; } - cu.bvNullCompDir = 0; + cu.bvZeroCompDir = 0; +#if JVET_AA0070_RRIBC cu.rribcFlipType = 0; +#endif - unsigned ctxId = DeriveCtx::CtxBvOneNullComp(cu); - cu.bvOneNullComp = m_BinDecoder.decodeBin(Ctx::bvOneNullComp(ctxId)); - if (cu.bvOneNullComp) + unsigned ctxId = DeriveCtx::CtxbvOneZeroComp(cu); + cu.bvOneZeroComp = m_BinDecoder.decodeBin(Ctx::bvOneZeroComp(ctxId)); + if (cu.bvOneZeroComp) { // Read the BV direction - cu.bvNullCompDir = cu.bvOneNullComp; - cu.bvNullCompDir += m_BinDecoder.decodeBin(Ctx::bvOneNullComp(3)); + cu.bvZeroCompDir = cu.bvOneZeroComp; + cu.bvZeroCompDir += m_BinDecoder.decodeBin(Ctx::bvOneZeroComp(3)); + +#if JVET_AA0070_RRIBC ctxId = DeriveCtx::CtxRribcFlipType(cu); cu.rribcFlipType = m_BinDecoder.decodeBin(Ctx::rribcFlipType(ctxId)); if (cu.rribcFlipType) { - cu.rribcFlipType = cu.bvNullCompDir; + cu.rribcFlipType = cu.bvZeroCompDir; } +#endif } DTRACE(g_trace_ctx, D_SYNTAX, "rribcData() rribcFlipType = %d\n", cu.rribcFlipType); } diff --git a/source/Lib/DecoderLib/CABACReader.h b/source/Lib/DecoderLib/CABACReader.h index 6013f2b6f..2fd9ca3d4 100644 --- a/source/Lib/DecoderLib/CABACReader.h +++ b/source/Lib/DecoderLib/CABACReader.h @@ -186,88 +186,94 @@ public: void geo_mmvd_idx(PredictionUnit& pu, RefPicList eRefPicList); void geo_merge_idx(PredictionUnit& pu); #if JVET_Y0065_GPM_INTRA - void geo_merge_idx1 ( PredictionUnit& pu, bool isIntra0, bool isIntra1); + void geo_merge_idx1 ( PredictionUnit& pu, bool isIntra0, bool isIntra1); #else - void geo_merge_idx1(PredictionUnit& pu); + void geo_merge_idx1 ( PredictionUnit& pu); #endif #endif #if JVET_AA0058_GPM_ADAPTIVE_BLENDING - void geoAdaptiveBlendingIdx ( PredictionUnit& pu ); + void geoAdaptiveBlendingIdx ( PredictionUnit& pu ); #endif #if JVET_Z0056_GPM_SPLIT_MODE_REORDERING - void geoModeIdx ( PredictionUnit& pu ); + void geoModeIdx ( PredictionUnit& pu ); #endif - void imv_mode ( CodingUnit& cu, MergeCtx& mrgCtx ); - void affine_amvr_mode ( CodingUnit& cu, MergeCtx& mrgCtx ); - void inter_pred_idc ( PredictionUnit& pu ); - void ref_idx ( PredictionUnit& pu, RefPicList eRefList ); + void imv_mode ( CodingUnit& cu, MergeCtx& mrgCtx ); + void affine_amvr_mode ( CodingUnit& cu, MergeCtx& mrgCtx ); + void inter_pred_idc ( PredictionUnit& pu ); + void ref_idx ( PredictionUnit& pu, RefPicList eRefList ); #if JVET_Z0054_BLK_REF_PIC_REORDER void refIdxLC ( PredictionUnit& pu ); void refPairIdx ( PredictionUnit& pu ); #endif - void mvp_flag ( PredictionUnit& pu, RefPicList eRefList ); - void Ciip_flag ( PredictionUnit& pu ); - void smvd_mode ( PredictionUnit& pu ); + void mvp_flag ( PredictionUnit& pu, RefPicList eRefList ); + void Ciip_flag ( PredictionUnit& pu ); + void smvd_mode ( PredictionUnit& pu ); #if MULTI_HYP_PRED - int ref_idx_mh(const int numRef); - void mh_pred_data(PredictionUnit& pu); + int ref_idx_mh ( const int numRef); + void mh_pred_data ( PredictionUnit& pu); #endif #if JVET_X0083_BM_AMVP_MERGE_MODE - void amvpMerge_mode ( PredictionUnit& pu ); + void amvpMerge_mode ( PredictionUnit& pu ); #endif #if JVET_Z0050_CCLM_SLOPE - void cclmDelta ( PredictionUnit& pu, int8_t &delta ); - void cclmDeltaSlope ( PredictionUnit& pu ); + void cclmDelta ( PredictionUnit& pu, int8_t &delta ); + void cclmDeltaSlope ( PredictionUnit& pu ); #endif #if JVET_AA0126_GLM - void glmIdc ( PredictionUnit& pu ); + void glmIdc ( PredictionUnit& pu ); #endif // transform tree (clause 7.3.8.8) - void transform_tree ( CodingStructure& cs, Partitioner& pm, CUCtx& cuCtx, const PartSplit ispType = TU_NO_ISP, const int subTuIdx = -1 ); - bool cbf_comp ( CodingStructure& cs, const CompArea& area, unsigned depth, const bool prevCbf = false, const bool useISP = false ); + void transform_tree ( CodingStructure& cs, Partitioner& pm, CUCtx& cuCtx, const PartSplit ispType = TU_NO_ISP, const int subTuIdx = -1 ); + bool cbf_comp ( CodingStructure& cs, const CompArea& area, unsigned depth, const bool prevCbf = false, const bool useISP = false ); // mvd coding (clause 7.3.8.9) #if JVET_AA0070_RRIBC #if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED - void mvd_coding ( Mv &rMvd, bool codeSign = true, const int &rribcFlipType = 0); + void mvd_coding ( Mv &rMvd, bool codeSign = true, const int &rribcFlipType = 0 ); #else - void mvd_coding ( Mv &rMvd, const int &rribcFlipType = 0); + void mvd_coding ( Mv &rMvd, const int &rribcFlipType = 0 ); #endif #if JVET_Z0131_IBC_BVD_BINARIZATION #if JVET_AC0104_IBC_BVD_PREDICTION #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - void bvdCoding(Mv& rMvd, MvdSuffixInfo& si, int bvOneNullComp = 0, int bvNullCompDir = 0); + void bvdCoding ( Mv& rMvd, MvdSuffixInfo& si, int bvOneZeroComp = 0, int bvZeroCompDir = 0 ); #else - void bvdCoding(Mv& rMvd, MvdSuffixInfo& si, const int& rribcFlipType = 0); + void bvdCoding ( Mv& rMvd, MvdSuffixInfo& si, const int& rribcFlipType = 0 ); #endif - unsigned xReadBvdContextPrefix(unsigned ctxT, int offset, int param); - unsigned xReadBvdContextSuffix(int symbol, int param); - void bvdCodingRemainder(Mv& rMvd, MvdSuffixInfo& si, const int imv); -#else // !JVET_AC0104_IBC_BVD_PREDICTION +#else #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - void bvdCoding(Mv& rMvd, int bvOneNullComp = 0, int bvNullCompDir = 0); + void bvdCoding ( Mv& rMvd, int bvOneZeroComp = 0, int bvZeroCompDir = 0 ); #else - void bvdCoding(Mv& rMvd, const int& rribcFlipType = 0); + void bvdCoding ( Mv& rMvd, const int& rribcFlipType = 0 ); +#endif + unsigned xReadBvdContext ( unsigned ctxT, int offset, int param) ; #endif - unsigned xReadBvdContext(unsigned ctxT, int offset, int param); -#endif // JVET_AC0104_IBC_BVD_PREDICTION #endif #else - void mvd_coding ( Mv &rMvd + void mvd_coding ( Mv &rMvd #if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED , bool codeSign = true #endif ); #if JVET_Z0131_IBC_BVD_BINARIZATION - void bvdCoding ( Mv &rMvd ); - unsigned xReadBvdContext(unsigned ctxT, int offset, int param); +#if JVET_AC0104_IBC_BVD_PREDICTION + void bvdCoding ( Mv &rMvd, MvdSuffixInfo& si ); +#else + void bvdCoding ( Mv &rMvd ); #endif + unsigned xReadBvdContext ( unsigned ctxT, int offset, int param ); +#endif +#endif +#if JVET_AC0104_IBC_BVD_PREDICTION + unsigned xReadBvdContextPrefix ( unsigned ctxT, int offset, int param ); + unsigned xReadBvdContextSuffix ( int symbol, int param ); + void bvdCodingRemainder ( Mv& rMvd, MvdSuffixInfo& si, const int imv ); #endif #if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED - void mvsdIdxFunc(PredictionUnit &pu, RefPicList eRefList); - void mvsdAffineIdxFunc(PredictionUnit &pu, RefPicList eRefList); + void mvsdIdxFunc ( PredictionUnit &pu, RefPicList eRefList ); + void mvsdAffineIdxFunc ( PredictionUnit &pu, RefPicList eRefList ); #endif // transform unit (clause 7.3.8.10) @@ -296,7 +302,7 @@ public: #endif #endif #if SIGN_PREDICTION - void parsePredictedSigns ( TransformUnit &tu, ComponentID compID); + void parsePredictedSigns ( TransformUnit &tu, ComponentID compID); #endif void residual_codingTS ( TransformUnit& tu, ComponentID compID ); void residual_coding_subblockTS( CoeffCodingContext& cctx, TCoeff* coeff ); @@ -319,10 +325,10 @@ public: void cu_lic_flag ( CodingUnit& cu ); #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - void bvOneNullComp_data ( CodingUnit &cu ); + void bvOneZeroComp ( CodingUnit &cu ); #endif #if JVET_AA0070_RRIBC - void rribcData ( CodingUnit &cu ); + void rribcData ( CodingUnit &cu ); #endif #if JVET_Z0135_TEMP_CABAC_WIN_WEIGHT CABACDataStore* m_CABACDataStore; diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index 35aeabfe5..fef96e758 100644 --- a/source/Lib/DecoderLib/DecCu.cpp +++ b/source/Lib/DecoderLib/DecCu.cpp @@ -1423,7 +1423,7 @@ void DecCu::xReconInter(CodingUnit &cu) if (cu.firstPU->bdmvrRefine) { PU::spanMotionInfo(*cu.firstPU, MergeCtx(), -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION cu.firstPU->colIdx, #endif m_mvBufBDMVR[0], m_mvBufBDMVR[1], m_pcInterPred->getBdofSubPuMvOffset()); @@ -1863,7 +1863,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) if (pu.cs->sps->getSbTMVPEnabledFlag()) { Size bufSize = g_miScaling.scale(pu.lumaSize()); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { mrgCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); @@ -1900,7 +1900,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) #endif PU::spanMotionInfo(pu, mrgCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -2006,7 +2006,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) { if( pu.cu->affine ) { -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION MergeCtx mrgCtxAll[2]; for (int i = 0; i < 2; i++) { @@ -2046,7 +2046,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) if (pu.cs->sps->getSbTMVPEnabledFlag()) { Size bufSize = g_miScaling.scale(pu.lumaSize()); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { mrgCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); @@ -2157,7 +2157,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) #if INTER_LIC pu.cu->licFlag = affineMergeCtx.licFlags[pu.mergeIdx]; #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx = affineMergeCtx.colIdx[pu.mergeIdx]; #endif pu.mergeType = affineMergeCtx.mergeType[pu.mergeIdx]; @@ -2205,7 +2205,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) } #endif PU::spanMotionInfo(pu, mrgCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -3005,7 +3005,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) if( !pu.bdmvrRefine ) { PU::spanMotionInfo(pu, mrgCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -3205,9 +3205,11 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) #if JVET_Z0084_IBC_TM && IBC_TM_AMVP PU::fillIBCMvpCand(pu, amvpInfo, m_pcInterPred); #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV +#if JVET_AA0070_RRIBC if (pu.cu->rribcFlipType == 0) +#endif { - if (pu.cu->bvNullCompDir == 1) + if (pu.cu->bvZeroCompDir == 1) { for (int i = 0; i < 2; i++) { @@ -3215,7 +3217,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) amvpInfo.mvCand[i].changePrecision(MV_PRECISION_INT, MV_PRECISION_INTERNAL); } } - else if (pu.cu->bvNullCompDir == 2) + else if (pu.cu->bvZeroCompDir == 2) { const int ctbSize = pu.cs->sps->getCTUSize(); const int numCurrCtuY = (pu.Y().y >> (floorLog2(ctbSize))); @@ -3250,9 +3252,9 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) { cMvPred.setHor(0); } -#else // !// JVET_AA0070_RRIBC - cosnt auto cMvPred = amvpInfo.mvCand[pu.mvpIdx[REF_PIC_LIST_0]]; -#endif // JVET_AA0070_RRIBC +#else + const auto cMvPred = amvpInfo.mvCand[pu.mvpIdx[REF_PIC_LIST_0]]; +#endif pu.bvdSuffixInfo.initPrefixes(pu.mvd[REF_PIC_LIST_0], pu.cu->imv, true); @@ -3269,7 +3271,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) CHECK(cMvd == Mv(0, 0), " zero MVD!"); pu.mvd[REF_PIC_LIST_0] = cMvd; } -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif Mv mvd = pu.mvd[REF_PIC_LIST_0]; #if !JVET_Z0054_BLK_REF_PIC_REORDER @@ -3449,7 +3451,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) if (!pu.bdmvrRefine) #endif PU::spanMotionInfo(pu, mrgCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); diff --git a/source/Lib/DecoderLib/DecCu.h b/source/Lib/DecoderLib/DecCu.h index 2cee0a2df..e8104d779 100644 --- a/source/Lib/DecoderLib/DecCu.h +++ b/source/Lib/DecoderLib/DecCu.h @@ -99,7 +99,7 @@ private: PelStorage m_ciipBuffer; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION MotionInfo m_subPuMiBuf[SUB_TMVP_NUM][(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)]; #else MotionInfo m_subPuMiBuf[(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)]; diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 84035a125..14c51660e 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -2930,7 +2930,7 @@ void CABACWriter::prediction_unit( const PredictionUnit& pu ) rribcData(*pu.cu); #endif #else - bvOneNullComp_data(*pu.cu); + bvOneZeroComp(*pu.cu); #endif #if JVET_AC0112_IBC_LIC cuIbcLicFlag(*pu.cu); @@ -2965,7 +2965,7 @@ void CABACWriter::prediction_unit( const PredictionUnit& pu ) #if JVET_AA0070_RRIBC #if JVET_Z0131_IBC_BVD_BINARIZATION #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - bvdCoding(mvd, 0, pu.cu->bvOneNullComp, pu.cu->bvNullCompDir); // already changed to signaling precision + bvdCoding(mvd, 0, pu.cu->bvOneZeroComp, pu.cu->bvZeroCompDir); // already changed to signaling precision #else bvdCoding(mvd, 0, pu.cu->rribcFlipType); // already changed to signaling precision #endif @@ -3171,12 +3171,12 @@ void CABACWriter::mvsd_data(const PredictionUnit& pu) { return; } -#endif // !JVET_AC0104_IBC_BVD_PREDICTION +#endif if (pu.cu->skip || pu.mergeFlag #if !JVET_AC0104_IBC_BVD_PREDICTION || CU::isIBC(*pu.cu) -#endif // !JVET_AC0104_IBC_BVD_PREDICTION +#endif || !pu.isMvsdApplicable()) { return; @@ -3198,7 +3198,7 @@ void CABACWriter::mvsd_data(const PredictionUnit& pu) { return; } -#endif // !JVET_AC0104_IBC_BVD_PREDICTION +#endif if (pu.interDir != 1 /* PRED_L0 */ && pu.cu->smvdMode != 1) { @@ -5470,7 +5470,7 @@ unsigned CABACWriter::xWriteBvdContextPrefix(unsigned uiSymbol, unsigned ctxT, i } return numBins - 1; // less by 1 as compared to what xReadBvdContextPrefix() returns } -void CABACWriter::xWriteBvdContextSuffix(unsigned uiSymbol, int param, int param_updated, int numSkipMSB ) +void CABACWriter::xWriteBvdContextSuffix(unsigned uiSymbol, int param, int paramUpdated, int numSkipMSB ) { unsigned bins = 0; unsigned numBins = 0; @@ -5484,26 +5484,26 @@ void CABACWriter::xWriteBvdContextSuffix(unsigned uiSymbol, int param, int param } bins <<= 1; numBins++; - param_updated++; + paramUpdated++; - CHECK(param_updated != numBins, "Enc side prefix bits check error"); + CHECK(paramUpdated != numBins, "Enc side prefix bits check error"); if (0 != numSkipMSB) { - CHECK(param_updated == 0, "param_updated = 0"); - param_updated-= numSkipMSB; - unsigned skipMask = ( 1 << (param_updated + numSkipMSB)) -1 - ((1 << (param_updated)) - 1); + CHECK(paramUpdated == 0, "paramUpdated = 0"); + paramUpdated-= numSkipMSB; + unsigned skipMask = ( 1 << (paramUpdated + numSkipMSB)) -1 - ((1 << (paramUpdated)) - 1); uiSymbol &= ~skipMask; - CHECK(uiSymbol >= (1 << param_updated), "uiSymbol >= (1<<param_updated)"); + CHECK(uiSymbol >= (1 << paramUpdated), "uiSymbol >= (1<<paramUpdated)"); } - if (param_updated > 0) + if (paramUpdated > 0) { - CHECK(uiSymbol >= (1 << (param_updated+1)), "uiSymbol >= (1<<param_updated)"); - m_BinEncoder.encodeBinsEP(uiSymbol, param_updated); + CHECK(uiSymbol >= (1 << (paramUpdated+1)), "uiSymbol >= (1<<paramUpdated)"); + m_BinEncoder.encodeBinsEP(uiSymbol, paramUpdated); } } -#else //!JVET_AC0104_IBC_BVD_PREDICTION +#else void CABACWriter::xWriteBvdContext(unsigned uiSymbol, unsigned ctxT, int offset, int param) { unsigned bins = 0; @@ -5540,7 +5540,7 @@ void CABACWriter::xWriteBvdContext(unsigned uiSymbol, unsigned ctxT, int offset, } m_BinEncoder.encodeBinsEP(uiSymbol, param); } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif #endif @@ -5618,16 +5618,14 @@ void CABACWriter::bvdCodingRemainder(const Mv& rMvd, const MvdSuffixInfo& si, in } } -#endif //JVET_AC0104_IBC_BVD_PREDICTION +#endif #if JVET_Z0131_IBC_BVD_BINARIZATION -#if JVET_AA0070_RRIBC #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV -void CABACWriter::bvdCoding(const Mv &rMvd, int8_t imv, int bvOneNullComp, int bvNullCompDir) -#else +void CABACWriter::bvdCoding(const Mv &rMvd, int8_t imv, int bvOneZeroComp, int bvZeroCompDir) +#elif JVET_AA0070_RRIBC void CABACWriter::bvdCoding(const Mv &rMvd, int8_t imv, const int &rribcFlipType) -#endif #else void CABACWriter::bvdCoding( const Mv &rMvd, int8_t imv) #endif @@ -5639,13 +5637,13 @@ void CABACWriter::bvdCoding( const Mv &rMvd, int8_t imv) unsigned verAbs = unsigned( verMvd < 0 ? -verMvd : verMvd ); #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - if (bvOneNullComp) + if (bvOneZeroComp) { - if (bvNullCompDir == 1) + if (bvZeroCompDir == 1) { m_BinEncoder.encodeBin((horAbs > 0), Ctx::Bvd(HOR_BVD_CTX_OFFSET)); } - if (bvNullCompDir == 2) + if (bvZeroCompDir == 2) { m_BinEncoder.encodeBin((verAbs > 0), Ctx::Bvd(VER_BVD_CTX_OFFSET)); } @@ -5681,13 +5679,13 @@ void CABACWriter::bvdCoding( const Mv &rMvd, int8_t imv) { xWriteBvdContextPrefix(verAbs - 1, NUM_VER_BVD_CTX, VER_BVD_CTX_OFFSET, BVD_CODING_GOLOMB_ORDER ); } -#else // !JVET_AC0104_IBC_BVD_PREDICTION +#else if( horAbs > 0 ) { xWriteBvdContext(horAbs - 1, NUM_HOR_BVD_CTX, HOR_BVD_CTX_OFFSET, BVD_CODING_GOLOMB_ORDER); #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV && JVET_AA0070_RRIBC - if (!bvOneNullComp) // not send the sign + if (!bvOneZeroComp) // not send the sign { m_BinEncoder.encodeBinEP((horMvd < 0)); } @@ -5699,7 +5697,7 @@ void CABACWriter::bvdCoding( const Mv &rMvd, int8_t imv) { xWriteBvdContext(verAbs-1, NUM_VER_BVD_CTX, VER_BVD_CTX_OFFSET, BVD_CODING_GOLOMB_ORDER); #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV && JVET_AA0070_RRIBC - if (!bvOneNullComp) // not send the sign + if (!bvOneZeroComp) // not send the sign { m_BinEncoder.encodeBinEP((verMvd < 0)); } @@ -5707,7 +5705,7 @@ void CABACWriter::bvdCoding( const Mv &rMvd, int8_t imv) m_BinEncoder.encodeBinEP((verMvd < 0)); #endif } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif } #endif @@ -5749,7 +5747,7 @@ void CABACWriter::mvsdIdxFunc(const PredictionUnit &pu, RefPicList eRefList) int mvsdIdx = pu.mvsdIdx[eRefList]; -#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV +#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV && JVET_AA0070_RRIBC if (TrMv != Mv(0, 0) && pu.cu->rribcFlipType == 0) #else if (TrMv != Mv(0, 0)) @@ -5793,7 +5791,7 @@ void CABACWriter::mvsdIdxFunc(const PredictionUnit &pu, RefPicList eRefList) verPrefix < 0 ? 0 : MvdSuffixInfo::xGetGolombGroupMinValue(verPrefix)); trMv.changeTransPrecAmvr2Internal(pu.cu->imv); -#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV +#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV && JVET_AA0070_RRIBC if (0 != pu.cu->rribcFlipType) { bvdCodingRemainder(mvd, si, pu.cu->imv); @@ -5840,7 +5838,7 @@ void CABACWriter::mvsdIdxFunc(const PredictionUnit &pu, RefPicList eRefList) bvdCodingRemainder(mvd, si, pu.cu->imv ); return; } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif if (pu.mvd[eRefList].getHor()) @@ -7460,20 +7458,22 @@ void CABACWriter::cu_lic_flag(const CodingUnit& cu) #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV -void CABACWriter::bvOneNullComp_data(const CodingUnit &cu) +void CABACWriter::bvOneZeroComp(const CodingUnit &cu) { if (!CU::isIBC(cu) || cu.firstPU->mergeFlag) { return; } - unsigned ctxId = DeriveCtx::CtxBvOneNullComp(cu); - m_BinEncoder.encodeBin(cu.bvOneNullComp > 0, Ctx::bvOneNullComp(ctxId)); - if (cu.bvOneNullComp) + unsigned ctxId = DeriveCtx::CtxbvOneZeroComp(cu); + m_BinEncoder.encodeBin(cu.bvOneZeroComp > 0, Ctx::bvOneZeroComp(ctxId)); + if (cu.bvOneZeroComp) { // Write the BV direction - m_BinEncoder.encodeBin(cu.bvNullCompDir >> 1, Ctx::bvOneNullComp(3)); + m_BinEncoder.encodeBin(cu.bvZeroCompDir >> 1, Ctx::bvOneZeroComp(3)); +#if JVET_AA0070_RRIBC ctxId = DeriveCtx::CtxRribcFlipType(cu); m_BinEncoder.encodeBin(cu.rribcFlipType > 0, Ctx::rribcFlipType(ctxId)); +#endif } } #endif diff --git a/source/Lib/EncoderLib/CABACWriter.h b/source/Lib/EncoderLib/CABACWriter.h index 31e5434d3..b4414204f 100644 --- a/source/Lib/EncoderLib/CABACWriter.h +++ b/source/Lib/EncoderLib/CABACWriter.h @@ -215,8 +215,8 @@ public: #endif #endif #if JVET_AA0058_GPM_ADAPTIVE_BLENDING - uint64_t geoBldFlagEst(const TempCtx& ctxStart, const int flag); - void geoAdaptiveBlendingIdx(const int idx); + uint64_t geoBldFlagEst (const TempCtx& ctxStart, const int flag); + void geoAdaptiveBlendingIdx (const int idx); #endif #if JVET_Z0056_GPM_SPLIT_MODE_REORDERING void geoModeIdx ( const PredictionUnit& pu); @@ -225,26 +225,26 @@ public: void imv_mode ( const CodingUnit& cu ); void affine_amvr_mode ( const CodingUnit& cu ); void inter_pred_idc ( const PredictionUnit& pu ); - void ref_idx ( const PredictionUnit& pu, RefPicList eRefList ); + void ref_idx ( const PredictionUnit& pu, RefPicList eRefList ); #if JVET_Z0054_BLK_REF_PIC_REORDER - void refIdxLC ( const PredictionUnit& pu ); - void refPairIdx ( const PredictionUnit& pu ); + void refIdxLC ( const PredictionUnit& pu ); + void refPairIdx ( const PredictionUnit& pu ); #endif - void mvp_flag ( const PredictionUnit& pu, RefPicList eRefList ); + void mvp_flag ( const PredictionUnit& pu, RefPicList eRefList ); - void Ciip_flag ( const PredictionUnit& pu ); - void smvd_mode ( const PredictionUnit& pu ); + void Ciip_flag ( const PredictionUnit& pu ); + void smvd_mode ( const PredictionUnit& pu ); #if MULTI_HYP_PRED - void ref_idx_mh(const int numRef, const int refIdx); - void mh_pred_data(const PredictionUnit& pu); + void ref_idx_mh (const int numRef, const int refIdx); + void mh_pred_data (const PredictionUnit& pu); #endif #if JVET_X0083_BM_AMVP_MERGE_MODE - void amvpMerge_mode ( const PredictionUnit& pu ); + void amvpMerge_mode ( const PredictionUnit& pu ); #endif #if JVET_Z0050_CCLM_SLOPE - void cclmDelta ( const PredictionUnit& pu, int8_t delta); - void cclmDeltaSlope ( const PredictionUnit& pu ); + void cclmDelta ( const PredictionUnit& pu, int8_t delta); + void cclmDeltaSlope ( const PredictionUnit& pu ); #endif #if JVET_AA0126_GLM void glmIdc ( const PredictionUnit& pu ); @@ -263,18 +263,18 @@ public: #endif #if JVET_Z0131_IBC_BVD_BINARIZATION #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - void bvdCoding(const Mv &rMvd, int8_t imv, int bvOneNullComp = 0, int bvNullCompDir = 0); + void bvdCoding (const Mv &rMvd, int8_t imv, int bvOneZeroComp = 0, int bvZeroCompDir = 0); #else - void bvdCoding(const Mv &rMvd, int8_t imv, const int &rribcFlipType = 0); + void bvdCoding (const Mv &rMvd, int8_t imv, const int &rribcFlipType = 0); #endif #if JVET_AC0104_IBC_BVD_PREDICTION - void bvdCodingRemainder(const Mv& rMvd, const MvdSuffixInfo& si, int8_t imv); - unsigned xWriteBvdContextPrefix(unsigned uiSymbol, unsigned ctxT, int offset, int param); - void xWriteBvdContextSuffix(unsigned uiSymbol, int param, int param_updated, int numSkipMSB); -#else //!JVET_AC0104_IBC_BVD_PREDICTION - void xWriteBvdContext(unsigned uiSymbol, unsigned ctxT, int offset, int param); -#endif //JVET_AC0104_IBC_BVD_PREDICTION + void bvdCodingRemainder (const Mv& rMvd, const MvdSuffixInfo& si, int8_t imv); + unsigned xWriteBvdContextPrefix (unsigned uiSymbol, unsigned ctxT, int offset, int param); + void xWriteBvdContextSuffix (unsigned uiSymbol, int param, int paramUpdated, int numSkipMSB); +#else + void xWriteBvdContext (unsigned uiSymbol, unsigned ctxT, int offset, int param); +#endif #endif #else void mvd_coding ( const Mv &rMvd, int8_t imv @@ -284,16 +284,20 @@ public: ); #if JVET_Z0131_IBC_BVD_BINARIZATION +#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV + void bvdCoding ( const Mv &rMvd, int8_t imv, int bvOneZeroComp = 0, int bvZeroCompDir = 0 ); +#elif JVET_AA0070_RRIBC + void bvdCoding ( const Mv &rMvd, int8_t imv, const int &rribcFlipType = 0 ); +#else + void bvdCoding ( const Mv &rMvd, int8_t imv ); +#endif #if JVET_AC0104_IBC_BVD_PREDICTION - void bvdCoding(const Mv& rMvd, int8_t imv); - void bvdCodingRemainder(const Mv& rMvd, const MvdSuffixInfo& si, int8_t imv); - - unsigned xWriteBvdContextPrefix(unsigned uiSymbol, unsigned ctxT, int offset, int param); - void xWriteBvdContextSuffix(unsigned uiSymbol, int param, int param_updated, int numSkipMSB = 0); -#else // !JVET_AC0104_IBC_BVD_PREDICTION - void bvdCoding ( const Mv &rMvd, int8_t imv ); - void xWriteBvdContext(unsigned uiSymbol, unsigned ctxT, int offset, int param); -#endif // JVET_AC0104_IBC_BVD_PREDICTION + void bvdCodingRemainder (const Mv& rMvd, const MvdSuffixInfo& si, int8_t imv); + unsigned xWriteBvdContextPrefix (unsigned uiSymbol, unsigned ctxT, int offset, int param); + void xWriteBvdContextSuffix (unsigned uiSymbol, int param, int paramUpdated, int numSkipMSB = 0); +#else + void xWriteBvdContext (unsigned uiSymbol, unsigned ctxT, int offset, int param); +#endif #endif #endif #if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED @@ -348,7 +352,7 @@ public: void rribcData ( const CodingUnit &cu); #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - void bvOneNullComp_data ( const CodingUnit &cu ); + void bvOneZeroComp ( const CodingUnit &cu ); #endif #if JVET_Z0135_TEMP_CABAC_WIN_WEIGHT CABACDataStore* m_CABACDataStore; diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 7bb2c3f78..489999a2b 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -3454,7 +3454,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& if (sps.getSbTMVPEnabledFlag()) { Size bufSize = g_miScaling.scale(tempCS->area.lumaSize()); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { mergeCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); @@ -3664,7 +3664,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif PU::getInterMergeCandidates(pu, mergeCtxtmp, 0); #endif -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION MergeCtx mrgCtxAll[2]; for (int i = 0; i < 2; i++) { @@ -4047,7 +4047,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& pu.regularMergeFlag = false; cu.affine = true; PU::getAffineMergeCand(pu, affineMergeCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , mrgCtxAll #endif #if JVET_AA0107_RMVF_AFFINE_MERGE_DERIVATION && JVET_W0090_ARMC_TM @@ -5331,7 +5331,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& pu.interDir = affineMergeCtx.interDirNeighbours[uiMergeCand]; cu.affineType = affineMergeCtx.affineType[uiMergeCand]; cu.bcwIdx = affineMergeCtx.bcwIdx[uiMergeCand]; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx = affineMergeCtx.colIdx[uiMergeCand]; #endif #if INTER_LIC @@ -5351,7 +5351,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& pu.refIdx[0] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 0][0].refIdx; pu.refIdx[1] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1][0].refIdx; PU::spanMotionInfo(pu, mrgCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -5446,14 +5446,14 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& if( !pu.bdmvrRefine ) { PU::spanMotionInfo(pu, mergeCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); } #else PU::spanMotionInfo(pu, mergeCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -5599,7 +5599,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif { PU::spanMotionInfo(pu, mergeCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR4TM[uiMergeCand << 1], m_mvBufBDMVR4TM[(uiMergeCand << 1) + 1], m_pcInterSearch->getBdofSubPuMvOffset()); @@ -5610,7 +5610,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& if( pu.bmMergeFlag ) { PU::spanMotionInfo(pu, bmMrgCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR4BM[uiMergeCand << 1], m_mvBufBDMVR4BM[(uiMergeCand << 1) + 1], m_pcInterSearch->getBdofSubPuMvOffset()); @@ -5618,7 +5618,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& else #endif PU::spanMotionInfo(pu, mergeCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR[uiMergeCand << 1], m_mvBufBDMVR[(uiMergeCand << 1) + 1], m_pcInterSearch->getBdofSubPuMvOffset()); @@ -5669,7 +5669,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& if( pu.tmMergeFlag ) { PU::spanMotionInfo(pu, mergeCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR4TM[uiMergeCand << 1], m_mvBufBDMVR4TM[(uiMergeCand << 1) + 1], m_mvBufEncBDOF4TM[uiMergeCand]); @@ -5680,7 +5680,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& if( pu.bmMergeFlag ) { PU::spanMotionInfo(pu, bmMrgCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR4BM[uiMergeCand << 1], m_mvBufBDMVR4BM[(uiMergeCand << 1) + 1], m_mvBufEncBDOF4BM[uiMergeCand]); @@ -5688,7 +5688,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& else #endif PU::spanMotionInfo(pu, mergeCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR[uiMergeCand << 1], m_mvBufBDMVR[(uiMergeCand << 1) + 1], m_mvBufEncBDOF[uiMergeCand]); @@ -5709,7 +5709,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& if( pu.tmMergeFlag ) { PU::spanMotionInfo(pu, mergeCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR4TM[uiMergeCand << 1], m_mvBufBDMVR4TM[(uiMergeCand << 1) + 1], m_pcInterSearch->getBdofSubPuMvOffset()); @@ -5720,7 +5720,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& if (pu.bmMergeFlag) { PU::spanMotionInfo(pu, bmMrgCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR4BM[uiMergeCand << 1], m_mvBufBDMVR4BM[(uiMergeCand << 1) + 1], m_mvBufEncBDOF4BM[uiMergeCand]); @@ -5728,7 +5728,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& else #endif PU::spanMotionInfo(pu, mergeCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR[uiMergeCand << 1], m_mvBufBDMVR[(uiMergeCand << 1) + 1], m_pcInterSearch->getBdofSubPuMvOffset()); @@ -5838,7 +5838,7 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct #if TM_MRG for (int i = 0; i < GEO_NUM_TM_MV_CAND; i++) { -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int j = 0; j < SUB_TMVP_NUM; j++) { mergeCtx[i].subPuMvpMiBuf[j] = MotionBuf(m_subPuMiBuf[j], bufSize); @@ -8554,7 +8554,7 @@ void EncCu::xCheckRDCostMergeGeo2Nx2N(CodingStructure *&tempCS, CodingStructure if (sps.getSbTMVPEnabledFlag()) { Size bufSize = g_miScaling.scale(tempCS->area.lumaSize()); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { mergeCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); @@ -9480,7 +9480,7 @@ void EncCu::xCheckSATDCostAffineMerge(CodingStructure *&tempCS, CodingUnit &cu, pu.mv[0].setZero(); pu.mv[1].setZero(); cu.imv = 0; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx = affineMergeCtx.colIdx[uiAffMergeCand]; #endif pu.mergeType = affineMergeCtx.mergeType[uiAffMergeCand]; @@ -9490,7 +9490,7 @@ void EncCu::xCheckSATDCostAffineMerge(CodingStructure *&tempCS, CodingUnit &cu, pu.refIdx[1] = affineMergeCtx.mvFieldNeighbours[(uiAffMergeCand << 1) + 1][0].refIdx; // the SbTmvp use xSubPuMC which will need to access the motion buffer for subblock MV PU::spanMotionInfo(pu, mrgCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -10197,7 +10197,7 @@ void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct pu.refIdx[0] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 0][0].refIdx; pu.refIdx[1] = affineMergeCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1][0].refIdx; PU::spanMotionInfo(pu, mrgCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -10417,7 +10417,7 @@ void EncCu::xCheckRDCostAffineMmvd2Nx2N(CodingStructure *&tempCS, CodingStructur if (sps.getSbTMVPEnabledFlag()) { Size bufSize = g_miScaling.scale(tempCS->area.lumaSize()); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { mergeCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); @@ -10736,7 +10736,7 @@ void EncCu::xCheckRDCostTMMerge2Nx2N(CodingStructure *&tempCS, CodingStructure * if (sps.getSbTMVPEnabledFlag()) { Size bufSize = g_miScaling.scale(tempCS->area.lumaSize()); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { mergeCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); @@ -11131,7 +11131,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct if (sps.getSbTMVPEnabledFlag()) { Size bufSize = g_miScaling.scale(tempCS->area.lumaSize()); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { mergeCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); @@ -11796,7 +11796,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct #endif #else PU::spanMotionInfo(pu, mergeCtxTm -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -12542,7 +12542,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct bool mbvdCandMisAlign = mergeCtxTmp.setIbcMbvdMergeCandiInfo(pu, mergeCand - numPreviousBv, ibcMbvdLUT[mergeCand - numPreviousBv]); CHECK(mbvdCandMisAlign, "MBVD candidate is invalid"); PU::spanMotionInfo(pu, mergeCtxTmp -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -12567,7 +12567,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct #endif mergeCtxTm.setMergeInfo(pu, mergeCand); PU::spanMotionInfo(pu, mergeCtxTm -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -12589,7 +12589,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct #endif mergeCtx.setMergeInfo(pu, mergeCand); PU::spanMotionInfo(pu, mergeCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -14931,7 +14931,7 @@ void EncCu::predInterSearchAdditionalHypothesisMulti(const MEResultVec& in, MERe { // the SbTmvp use xSubPuMC which will need to access the motion buffer for subblock MV PU::spanMotionInfo(pu, mrgCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -14992,7 +14992,7 @@ void EncCu::xCheckRDCostInterMultiHyp2Nx2N(CodingStructure *&tempCS, CodingStruc if (sps.getSbTMVPEnabledFlag()) { Size bufSize = g_miScaling.scale(tempCS->area.lumaSize()); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { mrgCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); @@ -15073,14 +15073,14 @@ void EncCu::xCheckRDCostInterMultiHyp2Nx2N(CodingStructure *&tempCS, CodingStruc else { PU::spanMotionInfo(pu, mrgCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); } #else PU::spanMotionInfo(pu, mrgCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -15112,7 +15112,7 @@ void EncCu::xCheckRDCostInterMultiHyp2Nx2N(CodingStructure *&tempCS, CodingStruc if( pu.bmMergeFlag ) { PU::spanMotionInfo(pu, mrgCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR4BM[pu.mergeIdx << 1], m_mvBufBDMVR4BM[(pu.mergeIdx << 1) + 1], m_pcInterSearch->getBdofSubPuMvOffset()); @@ -15120,7 +15120,7 @@ void EncCu::xCheckRDCostInterMultiHyp2Nx2N(CodingStructure *&tempCS, CodingStruc else #endif PU::spanMotionInfo(pu, mrgCtx, -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif m_mvBufBDMVR[pu.mergeIdx << 1], m_mvBufBDMVR[(pu.mergeIdx << 1) + 1], m_pcInterSearch->getBdofSubPuMvOffset()); diff --git a/source/Lib/EncoderLib/EncCu.h b/source/Lib/EncoderLib/EncCu.h index 20153e7ac..6f461e460 100644 --- a/source/Lib/EncoderLib/EncCu.h +++ b/source/Lib/EncoderLib/EncCu.h @@ -327,7 +327,7 @@ private: #endif double m_AFFBestSATDCost; double m_mergeBestSATDCost; -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION MotionInfo m_subPuMiBuf[SUB_TMVP_NUM][(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)]; #else MotionInfo m_subPuMiBuf[(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)]; diff --git a/source/Lib/EncoderLib/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp index bed42ee8c..276415215 100644 --- a/source/Lib/EncoderLib/InterSearch.cpp +++ b/source/Lib/EncoderLib/InterSearch.cpp @@ -146,7 +146,7 @@ void InterSearch::xEstBvdBitCosts(EstBvdBitsStruct *p) p->bitsIdx[1] = fracBits.getFracBitsArray(Ctx::MVPIdx()).intBits[1]; p->bitsImv[0] = fracBits.getFracBitsArray(Ctx::ImvFlag(1)).intBits[0]; p->bitsImv[1] = fracBits.getFracBitsArray(Ctx::ImvFlag(1)).intBits[1]; -#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV +#if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV && JVET_AA0070_RRIBC p->bitsRribc = fracBits.getFracBitsArray(Ctx::rribcFlipType(0)).intBits[1]; #endif } @@ -2441,13 +2441,13 @@ bool InterSearch::predIBCSearch(CodingUnit& cu, Partitioner& partitioner, const if (pu.cu->rribcFlipType) { - pu.cu->bvOneNullComp = 1; - pu.cu->bvNullCompDir = pu.cu->rribcFlipType; + pu.cu->bvOneZeroComp = 1; + pu.cu->bvZeroCompDir = pu.cu->rribcFlipType; } #if !JVET_AC0112_IBC_CIIP && !JVET_AC0112_IBC_LIC else { - getBestBvpBvOneNullComp(pu, cMv, initCost, &bvpIdxBest , &amvpInfo[0], &amvpInfo4Pel[0]); + getBestBvpBvOneZeroComp(pu, cMv, initCost, &bvpIdxBest , &amvpInfo[0], &amvpInfo4Pel[0]); } #endif #else @@ -2607,7 +2607,7 @@ bool InterSearch::predIBCSearch(CodingUnit& cu, Partitioner& partitioner, const } #else const Mv cMvPred2 = ((pu.cu->imv == 2 && cMv != amvpInfo4Pel.mvCand[bvpIdxBest]) ? amvpInfo4Pel : amvpInfo).mvCand[bvpIdxBest]; -#endif // JVET_AA0070_RRIBC +#endif const Mv cMvdKnownAtDecoder = pu.mvd[REF_PIC_LIST_0];// .getAbsMv(); @@ -2621,25 +2621,24 @@ bool InterSearch::predIBCSearch(CodingUnit& cu, Partitioner& partitioner, const pu.mvsdIdx[REF_PIC_LIST_0] = idx; } -#endif // JVET_AC0104_IBC_BVD_PREDICTION +#endif } return true; } #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV -inline void InterSearch::getBestBvpBvOneNullComp(PredictionUnit &pu, Mv cMv, Distortion initCost, +inline void InterSearch::getBestBvpBvOneZeroComp(PredictionUnit &pu, Mv cMv, Distortion initCost, int *bvpIdxBest, AMVPInfo *amvp1Pel, AMVPInfo *amvp4Pel) { Mv bvpCand[2]; int tempImv = 0, tempIdx = 0; - Distortion bvOneNullCompCost = std::numeric_limits<uint32_t>::max(); + Distortion bvOneZeroCompCost = std::numeric_limits<uint32_t>::max(); if (cMv.getVer() == 0) { bvpCand[0] = Mv(std::max(-(int) pu.lwidth(), -pu.Y().x), 0); bvpCand[1] = Mv(-pu.Y().x, 0); - bvOneNullCompCost = - m_pcRdCost->getbvVerNullCompCost(cMv.getHor(), pu.cs->sps->getAMVREnabledFlag(), &tempImv, &tempIdx, bvpCand); + bvOneZeroCompCost = m_pcRdCost->getBvVerZeroCompCost(cMv.getHor(), pu.cs->sps->getAMVREnabledFlag(), &tempImv, &tempIdx, bvpCand); } else if (cMv.getHor() == 0) { @@ -2649,14 +2648,13 @@ inline void InterSearch::getBestBvpBvOneNullComp(PredictionUnit &pu, Mv cMv, Dis bvpCand[0] = Mv(0, std::max(-(int) pu.lheight(), rrTop)); bvpCand[1] = Mv(0, rrTop); - bvOneNullCompCost = - m_pcRdCost->getbvHorNullCompCost(cMv.getVer(), pu.cs->sps->getAMVREnabledFlag(), &tempImv, &tempIdx, bvpCand); + bvOneZeroCompCost = m_pcRdCost->getBvHorZeroCompCost(cMv.getVer(), pu.cs->sps->getAMVREnabledFlag(), &tempImv, &tempIdx, bvpCand); } - if (bvOneNullCompCost < initCost) + if (bvOneZeroCompCost < initCost) { - pu.cu->bvOneNullComp = 1; - pu.cu->bvNullCompDir = (cMv.getVer() == 0) ? 1 : cMv.getHor() == 0 ? 2 : 0; + pu.cu->bvOneZeroComp = 1; + pu.cu->bvZeroCompDir = (cMv.getVer() == 0) ? 1 : cMv.getHor() == 0 ? 2 : 0; pu.cu->imv = tempImv; *bvpIdxBest = tempIdx; if (pu.cu->imv == 2) @@ -3681,7 +3679,7 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) if (cu.cs->sps->getSbTMVPEnabledFlag()) { Size bufSize = g_miScaling.scale(pu.lumaSize()); -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION for (int i = 0; i < SUB_TMVP_NUM; i++) { mergeCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); @@ -4804,7 +4802,7 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) #endif { PU::spanMotionInfo(pu, mergeCtx -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION , pu.colIdx #endif ); @@ -4840,7 +4838,7 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) if (pu.bdmvrRefine) { PU::spanMotionInfo(*cu.firstPU, MergeCtx(), -#if ENABLE_INTER_TEMPLATE_MATCHING && JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION +#if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx, #endif mvBufEncAmBDMVR_L0, mvBufEncAmBDMVR_L1, getBdofSubPuMvOffset()); diff --git a/source/Lib/EncoderLib/InterSearch.h b/source/Lib/EncoderLib/InterSearch.h index 645c45251..cecf69913 100644 --- a/source/Lib/EncoderLib/InterSearch.h +++ b/source/Lib/EncoderLib/InterSearch.h @@ -1135,7 +1135,7 @@ private: void xxIBCHashSearch(PredictionUnit& pu, Mv* mvPred, int numMvPred, Mv &mv, int& idxMvPred, IbcHashMap& ibcHashMap); #endif #if JVET_AC0060_IBC_BVP_CLUSTER_RRIBC_BVD_SIGN_DERIV - inline void getBestBvpBvOneNullComp(PredictionUnit &pu, Mv cMv, Distortion initCost, int *bvpIdxBest, + inline void getBestBvpBvOneZeroComp(PredictionUnit &pu, Mv cMv, Distortion initCost, int *bvpIdxBest, AMVPInfo *amvp1Pel = NULL, AMVPInfo *amvp4Pel = NULL); #endif public: -- GitLab