diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index 7819b74f6cdba7fc62e5781535169eef0c0292a7..2f61085e4608b249ced66ef7c3e4f3ace4f8d4c7 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -1169,9 +1169,21 @@ static const int ADAPTIVE_SUB_GROUP_SIZE_MMVD_AFF = AF_MMVD_MAX_REFINE_NUM; #endif #if JVET_AG0276_NLIC +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +static const int CFG_ALT_MRG_MAX_NUM_CANDS = 16; +#if (JVET_Y0134_TMVP_NAMVP_CAND_REORDERING && JVET_W0090_ARMC_TM) || JVET_Z0075_IBC_HMVP_ENLARGE +static const int ALT_MRG_MAX_NUM_CANDS = std::min(CFG_ALT_MRG_MAX_NUM_CANDS, NUM_MERGE_CANDS); +#else +static const int ALT_MRG_MAX_NUM_CANDS = std::min(CFG_ALT_MRG_MAX_NUM_CANDS, MRG_MAX_NUM_CANDS); +#endif +#else static const int ALT_MRG_MAX_NUM_CANDS = 16; +#endif static const int ALT_AFF_MRG_MAX_NUM_CANDS = 6; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +static const int LIC_INHERIT_ALT_MRG_MAX_NUM_CANDS = 10; +#endif #if JVET_AG0276_LIC_SLOPE_ADJUST static const int LIC_SLOPE_MAX_NUM_DELTA = 2; #endif @@ -1427,7 +1439,9 @@ static const int TOTAL_GEO_BLENDING_NUM = 6; // GPM 0~ #define GET_SGPM_BLD_IDX(a, b) \ (std::min(a, b) <= 4 ? 1 : std::min(a, b) <= 8 ? 2 : std::min(a, b) <= 16 ? 3 : std::min(a, b) <= 32 ? 4 : 5) #endif - +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV +static const int GPM_BLENDING_SIZE_THRESHOLD = 32; +#endif #if ENABLE_OBMC static const unsigned int defaultWeight[2][4] = { {27, 16, 6, 0}, {27, 0, 0, 0} }; #endif diff --git a/source/Lib/CommonLib/ContextModelling.cpp b/source/Lib/CommonLib/ContextModelling.cpp index 62437f961408dbebc07d52878da7c0929c9c428c..7b5b8d81c3f942a1b95b55cd05eb5291eca0bea9 100644 --- a/source/Lib/CommonLib/ContextModelling.cpp +++ b/source/Lib/CommonLib/ContextModelling.cpp @@ -652,6 +652,9 @@ void MergeCtx::copyRegularMergeCand(int dstCandIdx, MergeCtx& srcCtx, int srcCan #endif #if INTER_LIC licFlags [dstCandIdx] = srcCtx.licFlags [srcCandIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + copyLICParamFromCtx(dstCandIdx, srcCtx, srcCandIdx); +#endif #endif interDirNeighbours[dstCandIdx] = srcCtx.interDirNeighbours[srcCandIdx]; useAltHpelIf [dstCandIdx] = srcCtx.useAltHpelIf [srcCandIdx]; @@ -731,9 +734,20 @@ void MergeCtx::saveMergeInfo(PredictionUnit& puTmp, PredictionUnit pu) #if JVET_AG0276_LIC_SLOPE_ADJUST puTmp.cu->licDelta = pu.cu->licDelta; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + puTmp.cu->licInheritPara = pu.cu->licInheritPara; + for (int list = 0; list < 2; list++) + { + for (int comp = 0; comp < 3; comp++) + { + puTmp.cu->licScale[list][comp] = pu.cu->licScale[list][comp]; + puTmp.cu->licOffset[list][comp] = pu.cu->licOffset[list][comp]; + } + } +#endif } #endif -void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) +void MergeCtx::setMergeInfo(PredictionUnit& pu, int candIdx) { #if JVET_X0049_ADAPT_DMVR pu.mergeIdx = candIdx; @@ -743,20 +757,20 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) } #endif #if !JVET_Z0075_IBC_HMVP_ENLARGE - CHECK( candIdx >= numValidMergeCand, "Merge candidate does not exist" ); + CHECK(candIdx >= numValidMergeCand, "Merge candidate does not exist"); #endif - pu.regularMergeFlag = !(pu.ciipFlag || pu.cu->geoFlag); - pu.mergeFlag = true; + pu.regularMergeFlag = !(pu.ciipFlag || pu.cu->geoFlag); + pu.mergeFlag = true; pu.mmvdMergeFlag = false; - pu.interDir = interDirNeighbours[candIdx]; + pu.interDir = interDirNeighbours[candIdx]; pu.cu->imv = (!pu.cu->geoFlag && useAltHpelIf[candIdx]) ? IMV_HPEL : 0; #if !JVET_X0049_ADAPT_DMVR - pu.mergeIdx = candIdx; + pu.mergeIdx = candIdx; #endif - pu.mergeType = CU::isIBC( *pu.cu ) ? MRG_TYPE_IBC : MRG_TYPE_DEFAULT_N; - pu.mv [REF_PIC_LIST_0] = mvFieldNeighbours[(candIdx << 1) + 0].mv; - pu.mv [REF_PIC_LIST_1] = mvFieldNeighbours[(candIdx << 1) + 1].mv; + pu.mergeType = CU::isIBC(*pu.cu) ? MRG_TYPE_IBC : MRG_TYPE_DEFAULT_N; + pu.mv[REF_PIC_LIST_0] = mvFieldNeighbours[(candIdx << 1) + 0].mv; + pu.mv[REF_PIC_LIST_1] = mvFieldNeighbours[(candIdx << 1) + 1].mv; #if MULTI_PASS_DMVR pu.bdmvrRefine = false; #endif @@ -765,6 +779,14 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) #if JVET_AG0276_NLIC pu.cu->altLMFlag = altLMFlag[candIdx]; pu.cu->altLMParaUnit = altLMParaNeighbours[candIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool initializeAltLM = !pu.cu->altLMFlag + && !pu.cu->geoFlag; + if (initializeAltLM) + { + pu.cu->altLMParaUnit.resetAltLinearModel(); + } +#endif #endif if (CU::isIBC(*pu.cu)) @@ -772,9 +794,9 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) pu.bv = pu.mv[REF_PIC_LIST_0]; pu.bv.changePrecision(MV_PRECISION_INTERNAL, MV_PRECISION_INT); // used for only integer resolution #if JVET_AD0208_IBC_ADAPT_FOR_CAM_CAPTURED_CONTENTS - if(!pu.cs->sps->getIBCFracFlag()) + if (!pu.cs->sps->getIBCFracFlag()) #endif - pu.cu->imv = pu.cu->imv == IMV_HPEL ? 0 : pu.cu->imv; + pu.cu->imv = pu.cu->imv == IMV_HPEL ? 0 : pu.cu->imv; #if MULTI_HYP_PRED pu.addHypData.clear(); pu.numMergedAddHyps = 0; @@ -796,7 +818,7 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) pu.cu->rribcFlipType = 0; #endif } - pu.cu->bcwIdx = ( interDirNeighbours[candIdx] == 3 ) ? bcwIdx[candIdx] : BCW_DEFAULT; + pu.cu->bcwIdx = (interDirNeighbours[candIdx] == 3) ? bcwIdx[candIdx] : BCW_DEFAULT; #if MULTI_HYP_PRED if (pu.ciipFlag #if TM_MRG || (JVET_Z0084_IBC_TM && IBC_TM_MRG) @@ -834,6 +856,10 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) #if INTER_LIC pu.cu->licFlag = pu.cs->slice->getUseLIC() ? licFlags[candIdx] : false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + CHECK(!licFlags[candIdx] && licInheritPara[candIdx], "!licFlags[candIdx] && licInheritPara[candIdx]"); + setLICParamToPu(pu, candIdx, licInheritPara[candIdx]); +#endif #if JVET_AG0276_LIC_SLOPE_ADJUST pu.cu->licDelta = 0; #endif @@ -846,8 +872,215 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) #endif } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +template <typename MergeCtxType> +void MergeCtx::setLICParamToPu(const MergeCtxType& src, PredictionUnit& pu, int candIdx, bool hasLIC) +{ + hasLIC &= pu.cs->slice->getUseLIC(); + if(hasLIC) + { + pu.cu->licInheritPara = src.licInheritPara[candIdx]; + for (int list = 0; list < 2; list++) + { + if (src.interDirNeighbours[candIdx] & (list + 1)) + { + for (int comp = 0; comp < 3; comp++) + { + pu.cu->licScale [list][comp] = src.licScale [candIdx][list][comp]; + pu.cu->licOffset[list][comp] = src.licOffset[candIdx][list][comp]; + } + } + else + { + for (int comp = 0; comp < 3; comp++) + { + pu.cu->licScale [list][comp] = 32; + pu.cu->licOffset[list][comp] = 0; + } + } + } + } + else + { + pu.cu->licInheritPara = false; + for (int list = 0; list < 2; list++) + { + for (int comp = 0; comp < 3; comp++) + { + pu.cu->licScale [list][comp] = 32; + pu.cu->licOffset[list][comp] = 0; + } + } + } +} + +template <typename MergeCtxType> +void MergeCtx::loadLICParamFromPu(MergeCtxType& dst, const PredictionUnit* pu, int candIdx, bool allowAltModel, bool hasLIC) +{ + hasLIC &= (pu != nullptr && pu->cs->slice->getUseLIC()); +#if JVET_AG0276_NLIC + allowAltModel &= (pu != nullptr); + if (pu->cu->altLMFlag && !allowAltModel) + { + hasLIC = false; + } +#endif + + if (!hasLIC) + { + MergeCtx::setDefaultLICParamToCtx(dst, candIdx); +#if JVET_AG0276_NLIC + dst.altLMParaNeighbours[candIdx].resetAltLinearModel(); +#endif + return; + } + + CHECK(pu == nullptr, "pu cannot be a null pointer"); + dst.licInheritPara[candIdx] = true; +#if JVET_AG0276_NLIC + if (allowAltModel) + { + dst.altLMParaNeighbours[candIdx] = pu->cu->altLMParaUnit; + } + else + { + dst.altLMParaNeighbours[candIdx].resetAltLinearModel(); + } + +#endif + +#if JVET_AG0276_NLIC + if (allowAltModel && pu->cu->altLMFlag) + { + setLICParamUsingAltLM(dst, candIdx); +#if JVET_AG0276_LIC_FLAG_SIGNALING + dst.altLMParaNeighbours[candIdx] = pu->cu->altLMBRParaUnit; +#endif + return; + } +#endif + + for (int list = 0; list < 2; list++) + { + for (int comp = 0; comp < 3; comp++) + { + dst.licScale [candIdx][list][comp] = pu->cu->licScale [list][comp]; + dst.licOffset[candIdx][list][comp] = pu->cu->licOffset[list][comp]; + } + } +} + +template <typename MergeCtxType> +void MergeCtx::loadLICParamFromMotInfo(MergeCtxType& dst, const MotionInfo* mi, int candIdx, bool allowAltModel, bool hasLIC) +{ + CHECK(true, "Invalid function"); +} + +template <typename MergeCtxType> +void MergeCtx::copyLICParamFromCtx(MergeCtxType& dst, int candIdxDst, const MergeCtxType& src, int candIdxSrc) +{ + dst.licInheritPara[candIdxDst] = src.licInheritPara[candIdxSrc]; + for (int list = 0; list < 2; list++) + { + if (src.interDirNeighbours[candIdxSrc] & (list + 1)) + { + for (int comp = 0; comp < 3; comp++) + { + dst.licScale [candIdxDst][list][comp] = src.licScale [candIdxSrc][list][comp]; + dst.licOffset[candIdxDst][list][comp] = src.licOffset[candIdxSrc][list][comp]; + } + } + else + { + for (int comp = 0; comp < 3; comp++) + { + dst.licScale [candIdxDst][list][comp] = 32; + dst.licOffset[candIdxDst][list][comp] = 0; + } + } + } +} + +template <typename MergeCtxType> +void MergeCtx::setDefaultLICParamToCtx(MergeCtxType& dst, int candIdx) +{ + dst.licInheritPara[candIdx] = false; + for (int list = 0; list < 2; list++) + { + for (int comp = 0; comp < 3; comp++) + { + dst.licScale [candIdx][list][comp] = 32; + dst.licOffset[candIdx][list][comp] = 0; + } + } +} + +template <typename MergeCtxType> +void MergeCtx::setInheritAndLICFlags(MergeCtxType& dst, int candIdx) +{ + bool licL0 = false; + bool licL1 = false; + + if (dst.interDirNeighbours[candIdx] & 1) + { + licL0 = dst.licScale [candIdx][0][0] != 32 || dst.licScale [candIdx][0][1] != 32 || dst.licScale [candIdx][0][2] != 32 || + dst.licOffset[candIdx][0][0] != 0 || dst.licOffset[candIdx][0][1] != 0 || dst.licOffset[candIdx][0][2] != 0; + } + + if (dst.interDirNeighbours[candIdx] & 2) + { + licL1 = dst.licScale [candIdx][1][0] != 32 || dst.licScale [candIdx][1][1] != 32 || dst.licScale [candIdx][1][2] != 32 || + dst.licOffset[candIdx][1][0] != 0 || dst.licOffset[candIdx][1][1] != 0 || dst.licOffset[candIdx][1][2] != 0; + } + + dst.licInheritPara[candIdx] = (licL0 | licL1); + dst.licFlags[candIdx] = dst.licInheritPara[candIdx]; +} + +#if JVET_AG0276_NLIC +template <typename MergeCtxType> +void MergeCtx::setLICParamUsingAltLM(MergeCtxType& dst, int candIdx) +{ + dst.licInheritPara[candIdx] = true; + for (int list = 0; list < 2; list++) + { + if (dst.interDirNeighbours[candIdx] & (list + 1)) + { + for (int comp = 0; comp < 3; comp++) + { + dst.licScale [candIdx][list][comp] = dst.altLMParaNeighbours[candIdx].scale [comp]; + dst.licOffset[candIdx][list][comp] = dst.altLMParaNeighbours[candIdx].offset[comp]; + } + } + else + { + for (int comp = 0; comp < 3; comp++) + { + dst.licScale [candIdx][list][comp] = 32; + dst.licOffset[candIdx][list][comp] = 0; + } + } + } +} +#endif + +void MergeCtx::setLICParamToPu ( PredictionUnit& pu, int candIdx, bool hasLIC) { MergeCtx::setLICParamToPu (*this, pu, candIdx, hasLIC); } +void MergeCtx::loadLICParamFromPu (const PredictionUnit* pu, int candIdx, bool allowAltModel, bool hasLIC) { MergeCtx::loadLICParamFromPu (*this, pu, candIdx, allowAltModel, hasLIC); } +void MergeCtx::loadLICParamFromMotInfo (const MotionInfo* mi, int candIdx, bool allowAltModel, bool hasLIC) { MergeCtx::loadLICParamFromMotInfo (*this, mi, candIdx, allowAltModel, hasLIC); } +void MergeCtx::copyLICParamFromCtx (int candIdx, const MergeCtx& src, int candIdxSrc) { MergeCtx::copyLICParamFromCtx (*this, candIdx, src, candIdxSrc); } +void MergeCtx::setDefaultLICParamToCtx (int candIdx) { MergeCtx::setDefaultLICParamToCtx (*this, candIdx); } +void MergeCtx::setInheritAndLICFlags (int candIdx) { MergeCtx::setInheritAndLICFlags (*this, candIdx); } +#if JVET_AG0276_NLIC +void MergeCtx::setLICParamUsingAltLM (int candIdx) { MergeCtx::setLICParamUsingAltLM (*this, candIdx); } +#endif +#endif + #if JVET_AG0112_REGRESSION_BASED_GPM_BLENDING -int8_t MergeCtx::getDir( Slice* slice, int candIdx, MvField *mvField ) +int8_t MergeCtx::getDir( Slice* slice, int candIdx, MvField *mvField +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , int* scale, int* offset +#endif +) { if (candIdx < 0) { @@ -858,6 +1091,22 @@ int8_t MergeCtx::getDir( Slice* slice, int candIdx, MvField *mvField ) mvField[REF_PIC_LIST_1].refIdx = mvFieldNeighbours[(candIdx << 1) + 1].refIdx; mvField[REF_PIC_LIST_0].mv = mvFieldNeighbours[(candIdx << 1) + 0].mv; mvField[REF_PIC_LIST_1].mv = mvFieldNeighbours[(candIdx << 1) + 1].mv; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (licFlags[candIdx]) + { + scale [REF_PIC_LIST_0] = licScale [candIdx][0][COMPONENT_Y]; + scale [REF_PIC_LIST_1] = licScale [candIdx][1][COMPONENT_Y]; + offset[REF_PIC_LIST_0] = licOffset[candIdx][0][COMPONENT_Y]; + offset[REF_PIC_LIST_1] = licOffset[candIdx][1][COMPONENT_Y]; + } + else + { + scale [REF_PIC_LIST_0] = 32; + scale [REF_PIC_LIST_1] = 32; + offset[REF_PIC_LIST_0] = 0; + offset[REF_PIC_LIST_1] = 0; + } +#endif int8_t refIdx[2] = { -1, -1 }; Mv mv[2]; @@ -879,10 +1128,18 @@ int8_t MergeCtx::getDir( Slice* slice, int candIdx, MvField *mvField ) { poc0 = slice->getRefPic(REF_PIC_LIST_0, refIdx[0])->getPOC(); poc1 = slice->getRefPic(REF_PIC_LIST_1, refIdx[1])->getPOC(); - if ( poc0 == poc1 && mv[0] == mv[1] ) + if ( poc0 == poc1 && mv[0] == mv[1] +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + && scale [0] == scale[1] && offset[0] == offset[1] +#endif + ) { mvField[REF_PIC_LIST_1].refIdx = -1; mvField[REF_PIC_LIST_1].mv.setZero(); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + scale [REF_PIC_LIST_1] = 32; + offset[REF_PIC_LIST_1] = 0; +#endif return 0; } } @@ -954,6 +1211,9 @@ bool MergeCtx::xCheckSimilarMotion(int mergeCandIndex, uint32_t mvdSimilarityThr { for (uint32_t ui = 0; ui < mergeCandIndex; ui++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(licInheritPara[ui] == licInheritPara[mergeCandIndex]) +#endif if (interDirNeighbours[ui] == interDirNeighbours[mergeCandIndex]) { if (interDirNeighbours[ui] == 3) @@ -967,6 +1227,18 @@ bool MergeCtx::xCheckSimilarMotion(int mergeCandIndex, uint32_t mvdSimilarityThr if (mvDiffL0.getAbsHor() < mvdSimilarityThresh && mvDiffL0.getAbsVer() < mvdSimilarityThresh && mvDiffL1.getAbsHor() < mvdSimilarityThresh && mvDiffL1.getAbsVer() < mvdSimilarityThresh) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (licInheritPara[ui]) + { + for (int comp = 0; comp < 1; comp++) + { + if (licScale[ui][0][comp] != licScale[mergeCandIndex][0][comp]) return false; + if (licOffset[ui][0][comp] != licOffset[mergeCandIndex][0][comp]) return false; + if (licScale[ui][1][comp] != licScale[mergeCandIndex][1][comp]) return false; + if (licOffset[ui][1][comp] != licOffset[mergeCandIndex][1][comp]) return false; + } + } +#endif return true; } } @@ -978,6 +1250,16 @@ bool MergeCtx::xCheckSimilarMotion(int mergeCandIndex, uint32_t mvdSimilarityThr Mv mvDiff = mvFieldNeighbours[(ui << 1)].mv - mvFieldNeighbours[(mergeCandIndex << 1)].mv; if (mvDiff.getAbsHor() < mvdSimilarityThresh && mvDiff.getAbsVer() < mvdSimilarityThresh) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (licInheritPara[ui]) + { + for (int comp = 0; comp < 1; comp++) + { + if (licScale[ui][0][comp] != licScale[mergeCandIndex][0][comp]) return false; + if (licOffset[ui][0][comp] != licOffset[mergeCandIndex][0][comp]) return false; + } + } +#endif return true; } } @@ -989,6 +1271,16 @@ bool MergeCtx::xCheckSimilarMotion(int mergeCandIndex, uint32_t mvdSimilarityThr Mv mvDiff = mvFieldNeighbours[(ui << 1) + 1].mv - mvFieldNeighbours[(mergeCandIndex << 1) + 1].mv; if (mvDiff.getAbsHor() < mvdSimilarityThresh && mvDiff.getAbsVer() < mvdSimilarityThresh) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (licInheritPara[ui]) + { + for (int comp = 0; comp < 1; comp++) + { + if (licScale[ui][1][comp] != licScale[mergeCandIndex][1][comp]) return false; + if (licOffset[ui][1][comp] != licOffset[mergeCandIndex][1][comp]) return false; + } + } +#endif return true; } } @@ -1005,6 +1297,9 @@ bool MergeCtx::xCheckSimilarMotion(int mergeCandIndex, uint32_t mvdSimilarityThr for (uint32_t ui = 0; ui < mergeCandIndex; ui++) #endif { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(licInheritPara[ui] == licInheritPara[mergeCandIndex]) +#endif if (interDirNeighbours[ui] == interDirNeighbours[mergeCandIndex]) { if (interDirNeighbours[ui] == 3) @@ -1014,6 +1309,18 @@ bool MergeCtx::xCheckSimilarMotion(int mergeCandIndex, uint32_t mvdSimilarityThr mvFieldNeighbours[(ui << 1) ].mv == mvFieldNeighbours[(mergeCandIndex << 1) ].mv && mvFieldNeighbours[(ui << 1) + 1].mv == mvFieldNeighbours[(mergeCandIndex << 1) + 1].mv) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (licInheritPara[ui]) + { + for (int comp = 0; comp < 1; comp++) + { + if (licScale[ui][0][comp] != licScale[mergeCandIndex][0][comp]) return false; + if (licOffset[ui][0][comp] != licOffset[mergeCandIndex][0][comp]) return false; + if (licScale[ui][1][comp] != licScale[mergeCandIndex][1][comp]) return false; + if (licOffset[ui][1][comp] != licOffset[mergeCandIndex][1][comp]) return false; + } + } +#endif return true; } } @@ -1022,6 +1329,16 @@ bool MergeCtx::xCheckSimilarMotion(int mergeCandIndex, uint32_t mvdSimilarityThr if (mvFieldNeighbours[(ui << 1)].refIdx == mvFieldNeighbours[(mergeCandIndex << 1)].refIdx && mvFieldNeighbours[(ui << 1)].mv == mvFieldNeighbours[(mergeCandIndex << 1)].mv) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (licInheritPara[ui]) + { + for (int comp = 0; comp < 1; comp++) + { + if (licScale[ui][0][comp] != licScale[mergeCandIndex][0][comp]) return false; + if (licOffset[ui][0][comp] != licOffset[mergeCandIndex][0][comp]) return false; + } + } +#endif return true; } } @@ -1030,6 +1347,16 @@ bool MergeCtx::xCheckSimilarMotion(int mergeCandIndex, uint32_t mvdSimilarityThr if (mvFieldNeighbours[(ui << 1) + 1].refIdx == mvFieldNeighbours[(mergeCandIndex << 1) + 1].refIdx && mvFieldNeighbours[(ui << 1) + 1].mv == mvFieldNeighbours[(mergeCandIndex << 1) + 1].mv) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (licInheritPara[ui]) + { + for (int comp = 0; comp < 1; comp++) + { + if (licScale[ui][1][comp] != licScale[mergeCandIndex][1][comp]) return false; + if (licOffset[ui][1][comp] != licOffset[mergeCandIndex][1][comp]) return false; + } + } +#endif return true; } } @@ -1049,6 +1376,9 @@ void MergeCtx::initMrgCand(int cnt) #endif #if INTER_LIC licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setDefaultLICParamToCtx(cnt); +#endif #endif #if JVET_AC0112_IBC_LIC ibcLicFlags[cnt] = false; @@ -1065,6 +1395,10 @@ void MergeCtx::initMrgCand(int cnt) interDirNeighbours[cnt] = 0; mvFieldNeighbours[(cnt << 1)].refIdx = NOT_VALID; mvFieldNeighbours[(cnt << 1) + 1].refIdx = NOT_VALID; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mvFieldNeighbours[(cnt << 1) + 0].mv.setZero(); + mvFieldNeighbours[(cnt << 1) + 1].mv.setZero(); +#endif useAltHpelIf[cnt] = false; #if MULTI_HYP_PRED addHypNeighbours[cnt].clear(); @@ -1414,22 +1748,45 @@ void MergeCtx::setGeoMmvdMergeInfo(PredictionUnit& pu, int mergeIdx, int mmvdIdx #if JVET_AG0276_NLIC pu.cu->altLMFlag = altLMFlag[mergeIdx]; pu.cu->altLMParaUnit = altLMParaNeighbours[mergeIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool initializeAltLM = !pu.cu->altLMFlag + && !pu.cu->geoFlag; + if (initializeAltLM) + { + pu.cu->altLMParaUnit.resetAltLinearModel(); + } +#endif #endif #if INTER_LIC pu.cu->licFlag = pu.cs->slice->getUseLIC() ? licFlags[mergeIdx] : false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setLICParamToPu(pu, mergeIdx, licInheritPara[mergeIdx]); +#endif #if JVET_AG0276_LIC_SLOPE_ADJUST pu.cu->licDelta = 0; #endif +#if !JVET_AH0314_LIC_INHERITANCE_FOR_MRG if (pu.interDir == 3) { CHECK(pu.cu->licFlag, "LIC is not used with bi-prediction in merge"); } #endif +#endif } void MergeCtx::copyMergeCtx(MergeCtx & orgMergeCtx) { memcpy(interDirNeighbours, orgMergeCtx.interDirNeighbours, MRG_MAX_NUM_CANDS * sizeof(unsigned char)); memcpy(mvFieldNeighbours, orgMergeCtx.mvFieldNeighbours, (MRG_MAX_NUM_CANDS << 1) * sizeof(MvField)); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + for (int i = 0; i < MRG_MAX_NUM_CANDS; ++i) + { + copyLICParamFromCtx(i, orgMergeCtx, i); +#if JVET_AG0276_NLIC + licFlags[i] = orgMergeCtx.licFlags[i]; + altLMParaNeighbours[i] = orgMergeCtx.altLMParaNeighbours[i]; +#endif + } +#endif } #endif #if JVET_Y0067_ENHANCED_MMVD_MVD_SIGN_PRED @@ -1706,9 +2063,20 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx) #if JVET_AG0276_NLIC pu.cu->altLMFlag = altLMFlag[fPosBaseIdx]; pu.cu->altLMParaUnit = altLMParaNeighbours[fPosBaseIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool initializeAltLM = !pu.cu->altLMFlag + && !pu.cu->geoFlag; + if (initializeAltLM) + { + pu.cu->altLMParaUnit.resetAltLinearModel(); + } +#endif #endif #if INTER_LIC pu.cu->licFlag = licFlags[fPosBaseIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setLICParamToPu(pu, fPosBaseIdx, licInheritPara[fPosBaseIdx]); +#endif #if JVET_AG0276_LIC_SLOPE_ADJUST pu.cu->licDelta = 0; #endif @@ -1884,6 +2252,19 @@ bool AffineMergeCtx::xCheckSimilarMotion(int mergeCandIndex, uint32_t mvdSimilar return false; } #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +void AffineMergeCtx::setLICParamToPu ( PredictionUnit& pu, int candIdx, bool hasLIC) { MergeCtx::setLICParamToPu (*this, pu, candIdx, hasLIC); } +void AffineMergeCtx::setLICParamToPu ( PredictionUnit& pu, int candIdx, bool hasLIC) const { MergeCtx::setLICParamToPu (*this, pu, candIdx, hasLIC); } +void AffineMergeCtx::loadLICParamFromPu (const PredictionUnit* pu, int candIdx, bool allowAltModel, bool hasLIC) { MergeCtx::loadLICParamFromPu (*this, pu, candIdx, allowAltModel, hasLIC); } +void AffineMergeCtx::loadLICParamFromMotInfo (const MotionInfo* mi, int candIdx, bool allowAltModel, bool hasLIC) { MergeCtx::loadLICParamFromMotInfo (*this, mi, candIdx, allowAltModel, hasLIC); } +void AffineMergeCtx::copyLICParamFromCtx (int candIdx, const AffineMergeCtx& src, int candIdxSrc) { MergeCtx::copyLICParamFromCtx (*this, candIdx, src, candIdxSrc); } +void AffineMergeCtx::setDefaultLICParamToCtx (int candIdx) { MergeCtx::setDefaultLICParamToCtx (*this, candIdx); } +void AffineMergeCtx::setInheritAndLICFlags (int candIdx) { MergeCtx::setInheritAndLICFlags (*this, candIdx); } +#if JVET_AG0276_NLIC +void AffineMergeCtx::setLICParamUsingAltLM (int candIdx) { MergeCtx::setLICParamUsingAltLM (*this, candIdx); } +#endif +#endif + #if JVET_AG0276_NLIC bool AffineMergeCtx::xCheckSimilarMotion1(int mergeCandIndex, uint32_t mvdSimilarityThresh, bool isAlt) const { @@ -2265,11 +2646,15 @@ bool MergeCtx::setIbcMbvdMergeCandiInfo(PredictionUnit& pu, int candIdx, int can void AltLMMergeCtx::initAltLMMergeCtx(int idx) { altLMParaNeighbours[idx].resetAltLinearModel(); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + initMrgCand(idx); +#else mvFieldNeighbours[(idx << 1) + 0].setMvField(Mv(), -1); mvFieldNeighbours[(idx << 1) + 1].setMvField(Mv(), -1); interDirNeighbours[idx] = 0; bcwIdx[idx] = BCW_DEFAULT; useAltHpelIf[idx] = false; +#endif } bool AltLMMergeCtx::xCheckSameMotion(int mrgCandIdx, uint32_t mvdSimilarityThresh) @@ -2708,6 +3093,9 @@ void AffineMergeCtx::setAffMergeInfo(PredictionUnit &pu, int candIdx, int8_t mmv #endif #if INTER_LIC pu.cu->licFlag = licFlags[candIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setLICParamToPu(pu, candIdx, licInheritPara[candIdx]); +#endif #endif #if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx = colIdx[candIdx]; diff --git a/source/Lib/CommonLib/ContextModelling.h b/source/Lib/CommonLib/ContextModelling.h index a0ea15254837b2eeab754b70a5df4066ba4d857f..2b58835eee88b72000b82a5d53b2150c8191e915 100644 --- a/source/Lib/CommonLib/ContextModelling.h +++ b/source/Lib/CommonLib/ContextModelling.h @@ -775,6 +775,11 @@ public: uint8_t bcwIdx[NUM_MERGE_CANDS]; #if INTER_LIC bool licFlags[NUM_MERGE_CANDS]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool licInheritPara[NUM_MERGE_CANDS]; + int16_t licScale[NUM_MERGE_CANDS][2][3]; + int16_t licOffset[NUM_MERGE_CANDS][2][3]; +#endif #endif #if JVET_AC0112_IBC_LIC bool ibcLicFlags[NUM_MERGE_CANDS]; @@ -805,6 +810,11 @@ public: uint8_t bcwIdx [ MRG_MAX_NUM_CANDS ]; #if INTER_LIC bool licFlags [ MRG_MAX_NUM_CANDS ]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool licInheritPara[MRG_MAX_NUM_CANDS]; + int16_t licScale[MRG_MAX_NUM_CANDS][2][3]; + int16_t licOffset[MRG_MAX_NUM_CANDS][2][3]; +#endif #endif #if JVET_AC0112_IBC_LIC bool ibcLicFlags [ MRG_MAX_NUM_CANDS ]; @@ -869,8 +879,33 @@ public: void saveMergeInfo(PredictionUnit& puTmp, PredictionUnit pu); #endif void setMergeInfo( PredictionUnit& pu, int candIdx ); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + template <typename MergeCtxType> static void setLICParamToPu (const MergeCtxType& src, PredictionUnit& pu, int candIdx, bool hasLIC); + template <typename MergeCtxType> static void loadLICParamFromPu ( MergeCtxType& dst, const PredictionUnit* pu, int candIdx, bool allowAltModel, bool hasLIC); + template <typename MergeCtxType> static void loadLICParamFromMotInfo ( MergeCtxType& dst, const MotionInfo* mi, int candIdx, bool allowAltModel, bool hasLIC); + template <typename MergeCtxType> static void copyLICParamFromCtx ( MergeCtxType& dst, int candIdxDst, const MergeCtxType& src, int candIdxSrc); + template <typename MergeCtxType> static void setDefaultLICParamToCtx ( MergeCtxType& dst, int candIdx); + template <typename MergeCtxType> static void setInheritAndLICFlags ( MergeCtxType& dst, int candIdx); +#if JVET_AG0276_NLIC + template <typename MergeCtxType> static void setLICParamUsingAltLM ( MergeCtxType& dst, int candIdx); +#endif + + void setLICParamToPu ( PredictionUnit& pu, int candIdx, bool hasLIC); + void loadLICParamFromPu (const PredictionUnit* pu, int candIdx, bool allowAltModel, bool hasLIC); + void loadLICParamFromMotInfo (const MotionInfo* mi, int candIdx, bool allowAltModel, bool hasLIC); + void copyLICParamFromCtx (int candIdx, const MergeCtx& src, int candIdxSrc); + void setDefaultLICParamToCtx (int candIdx); + void setInheritAndLICFlags (int candIdx); +#if JVET_AG0276_NLIC + void setLICParamUsingAltLM (int candIdx); +#endif +#endif #if JVET_AG0112_REGRESSION_BASED_GPM_BLENDING - int8_t getDir( Slice* slice, int candIdx, MvField* mvField ); + int8_t getDir( Slice* slice, int candIdx, MvField* mvField +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , int* scale, int* offset +#endif + ); #endif #if JVET_AE0169_BIPREDICTIVE_IBC void setIbcL1Info( PredictionUnit& pu, int candIdx ); @@ -938,6 +973,11 @@ public: #endif #if INTER_LIC bool licFlags[RMVF_AFFINE_MRG_MAX_CAND_LIST_SIZE]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool licInheritPara[RMVF_AFFINE_MRG_MAX_CAND_LIST_SIZE]; + int16_t licScale[RMVF_AFFINE_MRG_MAX_CAND_LIST_SIZE][2][3]; + int16_t licOffset[RMVF_AFFINE_MRG_MAX_CAND_LIST_SIZE][2][3]; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL bool obmcFlags[RMVF_AFFINE_MRG_MAX_CAND_LIST_SIZE]; @@ -963,6 +1003,18 @@ public: #if JVET_AG0276_NLIC bool xCheckSimilarMotion1(int mergeCandIndex, uint32_t mvdSimilarityThresh = 1, bool isAltLM = false) const; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + void setLICParamToPu ( PredictionUnit& pu, int candIdx, bool hasLIC); + void setLICParamToPu ( PredictionUnit& pu, int candIdx, bool hasLIC) const; + void loadLICParamFromPu (const PredictionUnit* pu, int candIdx, bool allowAltModel, bool hasLIC); + void loadLICParamFromMotInfo (const MotionInfo* mi, int candIdx, bool allowAltModel, bool hasLIC); + void copyLICParamFromCtx (int candIdx, const AffineMergeCtx& src, int candIdxSrc); + void setDefaultLICParamToCtx (int candIdx); + void setInheritAndLICFlags (int candIdx); +#if JVET_AG0276_NLIC + void setLICParamUsingAltLM (int candIdx); +#endif +#endif }; #else class AffineMergeCtx @@ -976,6 +1028,11 @@ public: EAffineModel affineType[AFFINE_MRG_MAX_NUM_CANDS]; #if INTER_LIC bool licFlags[AFFINE_MRG_MAX_NUM_CANDS]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool licInheritPara[AFFINE_MRG_MAX_NUM_CANDS]; + int16_t licScale[AFFINE_MRG_MAX_NUM_CANDS][2][3]; + int16_t licOffset[AFFINE_MRG_MAX_NUM_CANDS][2][3]; +#endif #endif uint8_t bcwIdx[AFFINE_MRG_MAX_NUM_CANDS]; int numValidMergeCand; @@ -989,19 +1046,35 @@ public: #if JVET_AB0112_AFFINE_DMVR bool xCheckSimilarMotion(int mergeCandIndex, uint32_t mvdSimilarityThresh = 1) const; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + void setLICParamToPu ( PredictionUnit& pu, int candIdx, bool hasLIC); + void loadLICParamFromPu (const PredictionUnit* pu, int candIdx, bool allowAltModel, bool hasLIC); + void loadLICParamFromMotInfo (const MotionInfo* mi, int candIdx, bool allowAltModel, bool hasLIC); + void copyLICParamFromCtx (int candIdx, const AffineMergeCtx& src, int candIdxSrc); + void setDefaultLICParamToCtx (int candIdx); + void setInheritAndLICFlags (int candIdx); +#if JVET_AG0276_NLIC + void setLICParamUsingAltLM (int candIdx); +#endif +#endif }; #endif #if JVET_AG0276_NLIC class AltLMMergeCtx +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +: public MergeCtx +#endif { public: AltLMInterUnit altLMParaNeighbours[ALT_MRG_MAX_NUM_CANDS]; +#if !JVET_AH0314_LIC_INHERITANCE_FOR_MRG MvField mvFieldNeighbours[ALT_MRG_MAX_NUM_CANDS << 1]; uint8_t bcwIdx[ALT_MRG_MAX_NUM_CANDS]; unsigned char interDirNeighbours[ALT_MRG_MAX_NUM_CANDS]; bool useAltHpelIf[ALT_MRG_MAX_NUM_CANDS]; int numValidMergeCand; +#endif void initAltLMMergeCtx(int idx); bool xCheckSameMotion(int cnt, uint32_t mvdSimilarityThresh); diff --git a/source/Lib/CommonLib/Contexts_ecm12.inl b/source/Lib/CommonLib/Contexts_ecm12.inl index f7a15cabf3f2ef054707a3794cf52d4f6d6b1c9f..e86c2e8a0a84f8daf7d29ab2e719b50713caa46f 100644 --- a/source/Lib/CommonLib/Contexts_ecm12.inl +++ b/source/Lib/CommonLib/Contexts_ecm12.inl @@ -475,7 +475,24 @@ const CtxSet ContextSetCfg::GeoMmvdStepMvpIdx = ContextSetCfg::addCtxSet({ }); const CtxSet ContextSetCfg::GeoBldFlag = ContextSetCfg::addCtxSet({ -// ctx 97 100 +// ctx 97 104 +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + { 58, 22, 45, 13, 58, 22, 45, 13 }, + { 60, 36, 58, 36, 60, 36, 58, 36 }, + { 35, 35, 35, 35, 35, 35, 35, 35 }, + { 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1 }, + { 8, 8, 8, 8, 8, 8, 8, 8 }, + { 11, 18, 18, 11, 11, 18, 18, 11 }, + { 4, 18, 11, 11, 4, 18, 11, 11 }, + { 18, 18, 18, 18, 18, 18, 18, 18 }, + { 132, 116, 116, 117, 132, 116, 116, 117 }, + { 118, 116, 132, 118, 118, 116, 132, 118 }, + { 117, 116, 116, 117, 117, 116, 116, 117 }, + { 118, 117, 133, 119, 118, 117, 133, 119 }, + { 119, 119, 119, 119, 119, 119, 119, 119 }, + { 119, 119, 119, 119, 119, 119, 119, 119 }, +#else { 58, 22, 45, 13 }, { 60, 36, 58, 36 }, { 35, 35, 35, 35 }, @@ -491,6 +508,7 @@ const CtxSet ContextSetCfg::GeoBldFlag = ContextSetCfg::addCtxSet({ { 118, 117, 133, 119 }, { 119, 119, 119, 119 }, { 119, 119, 119, 119 }, +#endif }); const CtxSet ContextSetCfg::GeoSubModeIdx = ContextSetCfg::addCtxSet({ diff --git a/source/Lib/CommonLib/Contexts_ecm13.inl b/source/Lib/CommonLib/Contexts_ecm13.inl index 1b05c9d71c4448dc530149f153da1373eff96c4c..7eed3bfceb264f187f36e77f61cd7fbff72903e2 100644 --- a/source/Lib/CommonLib/Contexts_ecm13.inl +++ b/source/Lib/CommonLib/Contexts_ecm13.inl @@ -595,7 +595,29 @@ const CtxSet ContextSetCfg::GeoMmvdStepMvpIdx = ContextSetCfg::addCtxSet({ }); const CtxSet ContextSetCfg::GeoBldFlag = ContextSetCfg::addCtxSet({ -// ctx 97 100 +// ctx 97 104 +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + { 58, 22, 45, 13, 58, 22, 45, 13 }, + { 60, 36, 58, 36, 60, 36, 58, 36 }, + { 35, 35, 35, 35, 35, 35, 35, 35 }, + { 58, 22, 52, 13, 58, 22, 52, 13 }, + { 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1 }, + { 8, 8, 8, 8, 8, 8, 8, 8 }, + { 1, 2, 1, 1, 1, 2, 1, 1 }, + { 11, 18, 18, 11, 11, 18, 18, 11 }, + { 4, 18, 11, 11, 4, 18, 11, 11 }, + { 18, 18, 18, 18, 18, 18, 18, 18 }, + { 4, 18, 18, 4, 4, 18, 18, 4 }, + { 132, 116, 116, 117, 132, 116, 116, 117 }, + { 118, 116, 132, 118, 118, 116, 132, 118 }, + { 117, 116, 116, 117, 117, 116, 116, 117 }, + { 118, 117, 133, 119, 118, 117, 133, 119 }, + { 119, 119, 119, 119, 119, 119, 119, 119 }, + { 119, 119, 119, 119, 119, 119, 119, 119 }, + { 132, 115, 116, 117, 132, 115, 116, 117 }, + { 117, 115, 117, 117, 117, 115, 117, 117 }, +#else { 58, 22, 45, 13 }, { 60, 36, 58, 36 }, { 35, 35, 35, 35 }, @@ -616,6 +638,7 @@ const CtxSet ContextSetCfg::GeoBldFlag = ContextSetCfg::addCtxSet({ { 119, 119, 119, 119 }, { 132, 115, 116, 117 }, { 117, 115, 117, 117 }, +#endif }); const CtxSet ContextSetCfg::GeoSubModeIdx = ContextSetCfg::addCtxSet({ diff --git a/source/Lib/CommonLib/InterPrediction.cpp b/source/Lib/CommonLib/InterPrediction.cpp index e0eace014cceff87a65ec2af7177bf389a89f519..b40470313b18b2e3281afb879397da51e35be940 100644 --- a/source/Lib/CommonLib/InterPrediction.cpp +++ b/source/Lib/CommonLib/InterPrediction.cpp @@ -1673,10 +1673,40 @@ void InterPrediction::xPredInterUni(const PredictionUnit &pu, const RefPicList & CHECK( bioApplied, "BIO is not allowed with affine" ); m_iRefListIdx = eRefPicList; bool genChromaMv = (!luma && chroma && compID == COMPONENT_Cb); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + if (pu.cu->licInheritPara) + { + CHECK(!pu.cu->licFlag, "LIC flag should be true"); + pu.cu->licFlag = false; + } +#endif #if JVET_Z0136_OOB xPredAffineBlk(compID, pu, pu.cu->slice->getRefPic(eRefPicList, iRefIdx)->unscaledPic, mv, pcYuvPred, bi, pu.cu->slice->clpRng(compID), eRefPicList, genChromaMv, pu.cu->slice->getScalingRatio(eRefPicList, iRefIdx)); #else xPredAffineBlk(compID, pu, pu.cu->slice->getRefPic(eRefPicList, iRefIdx)->unscaledPic, mv, pcYuvPred, bi, pu.cu->slice->clpRng(compID), genChromaMv, pu.cu->slice->getScalingRatio(eRefPicList, iRefIdx)); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + if (pu.cu->licInheritPara) + { + const ClpRng& clpRng = pu.cu->slice->clpRng(compID); + bool nonTrivialModel = pu.cu->licFlag && (pu.cu->licScale[m_iRefListIdx][compID] != 32 || pu.cu->licOffset[m_iRefListIdx][compID] != 0); + if (nonTrivialModel && !pu.cs->sps->getRprEnabledFlag() && !m_isAddHypMC) + { + if (bi) + { + const int biShift = IF_INTERNAL_PREC - clpRng.bd; + const Pel biOffset = -IF_INTERNAL_OFFS; + pcYuvPred.bufs[compID].toLast(clpRng); + pcYuvPred.bufs[compID].linearTransform(pu.cu->licScale[m_iRefListIdx][compID], m_LICShift, pu.cu->licOffset[m_iRefListIdx][compID], true, clpRng); + pcYuvPred.bufs[compID].linearTransform(1, -biShift, biOffset, false, clpRng); + } + else + { + pcYuvPred.bufs[compID].linearTransform(pu.cu->licScale[m_iRefListIdx][compID], m_LICShift, pu.cu->licOffset[m_iRefListIdx][compID], true, clpRng); + } + } + pu.cu->licFlag = true; + } #endif } else @@ -2047,9 +2077,11 @@ void InterPrediction::xPredInterBiBDMVR(PredictionUnit &pu, PelUnitBuf &pcYuvPre { #if INTER_LIC #if JVET_AF0159_AFFINE_SUBPU_BDOF_REFINEMENT - if (pu.cu->affine || pu.cu->licFlag + if (pu.cu->affine || + pu.cu->licFlag #else - if (pu.cu->affine || m_subPuMC || pu.cu->licFlag + if (pu.cu->affine || m_subPuMC || + pu.cu->licFlag #endif #if ENABLE_OBMC || pu.cu->isobmcMC @@ -2658,9 +2690,11 @@ void InterPrediction::xPredInterBiBDMVR2(PredictionUnit &pu, PelUnitBuf &pcYuvPr { #if INTER_LIC #if JVET_AF0159_AFFINE_SUBPU_BDOF_REFINEMENT - if (pu.cu->affine || pu.cu->licFlag + if (pu.cu->affine || + pu.cu->licFlag #else - if (pu.cu->affine || m_subPuMC || pu.cu->licFlag + if (pu.cu->affine || m_subPuMC || + pu.cu->licFlag #endif #if ENABLE_OBMC || pu.cu->isobmcMC @@ -3917,6 +3951,14 @@ void InterPrediction::xPredInterBlk ( const ComponentID& compID, const Predictio #endif const bool isResamplingPossible = pu.cs->sps->getRprEnabledFlag(); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + const unsigned origWidth = dstPic.bufs[compID].width; + const unsigned origHeight = dstPic.bufs[compID].height; + int backupWidth = dstPic.bufs[compID].width; + int backupHeight = dstPic.bufs[compID].height; + Pel *backupDstBufPtr = dstPic.bufs[compID].buf; + int backupDstBufStride = dstPic.bufs[compID].stride; +#endif if( isResamplingPossible && !isIBC && xPredInterBlkRPR( scalingRatio, *pu.cs->pps, CompArea( compID, chFmt, pu.blocks[compID], Size( dstPic.bufs[compID].width, dstPic.bufs[compID].height ) ), refPic, mv, dstPic.bufs[compID].buf, dstPic.bufs[compID].stride, bi, wrapRef, clpRng, 0, useAltHpelIf ) ) { @@ -4002,11 +4044,17 @@ void InterPrediction::xPredInterBlk ( const ComponentID& compID, const Predictio height = dmvrHeight; } // backup data +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + backupWidth = width; + backupHeight = height; + backupDstBufPtr = dstBuf.buf; + backupDstBufStride = dstBuf.stride; +#else int backupWidth = width; int backupHeight = height; Pel *backupDstBufPtr = dstBuf.buf; int backupDstBufStride = dstBuf.stride; - +#endif if (bioApplied && compID == COMPONENT_Y) { #if MULTI_PASS_DMVR || SAMPLE_BASED_BDOF @@ -4273,6 +4321,55 @@ void InterPrediction::xPredInterBlk ( const ComponentID& compID, const Predictio #endif #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->geoFlag) + { + bool nonTrivialModel = pu.cu->licFlag && (pu.cu->licScale[m_iRefListIdx][compID] != 32 || pu.cu->licOffset[m_iRefListIdx][compID] != 0); + if (nonTrivialModel && !pu.cs->sps->getRprEnabledFlag() && !m_isAddHypMC) + { + if (bi) + { + const int biShift = IF_INTERNAL_PREC - clpRng.bd; + const Pel biOffset = -IF_INTERNAL_OFFS; + if (bioApplied && compID == COMPONENT_Y) + { +#if JVET_AF0159_AFFINE_SUBPU_BDOF_REFINEMENT + dstBuf.stride = origWidth + ((BIO_EXTEND_SIZE + 1) << 1); + dstBuf.buf = m_filteredBlockTmp[2 + m_iRefListIdx][compID]; + dstBuf.buf += 2 * (dstBuf.stride + 1); +#else + dstBuf.stride = backupWidth; + dstBuf.buf = m_filteredBlockTmp[2 + m_iRefListIdx][compID]; +#endif + dstBuf.width = backupWidth; + dstBuf.height = backupHeight; + } + + dstBuf.toLast(clpRng); + dstBuf.linearTransform(pu.cu->licScale[m_iRefListIdx][compID], m_LICShift, pu.cu->licOffset[m_iRefListIdx][compID], true, clpRng); + dstBuf.linearTransform(1, -biShift, biOffset, false, clpRng); + if (bioApplied && compID == COMPONENT_Y) + { + dstBuf.buf = backupDstBufPtr; + dstBuf.stride = backupDstBufStride; + dstBuf.width = origWidth; + dstBuf.height = origHeight; + } + } + else + { + dstBuf.linearTransform(pu.cu->licScale[m_iRefListIdx][compID], m_LICShift, pu.cu->licOffset[m_iRefListIdx][compID], true, clpRng); + } + } + if (!m_isAddHypMC) + { + m_scale [m_iRefListIdx][compID] = pu.cu->licScale[m_iRefListIdx][compID]; + m_offset[m_iRefListIdx][compID] = pu.cu->licOffset[m_iRefListIdx][compID]; + m_shift [m_iRefListIdx][compID] = m_LICShift; + } + return; + } +#endif #if JVET_W0090_ARMC_TM || JVET_Z0056_GPM_SPLIT_MODE_REORDERING #if JVET_AD0213_LIC_IMP Slice* slice = pu.cu->slice; @@ -4285,6 +4382,31 @@ void InterPrediction::xPredInterBlk ( const ComponentID& compID, const Predictio if( pu.cu->licFlag && !pu.ciipFlag ) #endif { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara && !pu.cs->sps->getRprEnabledFlag() + && !pu.ciipFlag + && !m_isAddHypMC + ) + { + //CHECK(pu.ciipFlag, "pu.ciipFlag && pu.cu->licInheritPara"); + if (bi) + { + const int biShift = IF_INTERNAL_PREC - clpRng.bd; + const Pel biOffset = -IF_INTERNAL_OFFS; + dstBuf.toLast(clpRng); + dstBuf.linearTransform(pu.cu->licScale[m_iRefListIdx][compID], m_LICShift, pu.cu->licOffset[m_iRefListIdx][compID], true, clpRng); + dstBuf.linearTransform(1, -biShift, biOffset, false, clpRng); + } + else + { + dstBuf.linearTransform(pu.cu->licScale[m_iRefListIdx][compID], m_LICShift, pu.cu->licOffset[m_iRefListIdx][compID], true, clpRng); + } + m_scale [m_iRefListIdx][compID] = pu.cu->licScale[m_iRefListIdx][compID]; + m_offset[m_iRefListIdx][compID] = pu.cu->licOffset[m_iRefListIdx][compID]; + m_shift [m_iRefListIdx][compID] = m_LICShift; + return; + } +#endif CHECK( pu.cu->geoFlag, "Geometric mode is not used with LIC" ); CHECK( CU::isIBC( *pu.cu ), "IBC mode is not used with LIC" ); #if !JVET_AD0213_LIC_IMP @@ -6894,7 +7016,23 @@ void InterPrediction::xWeightedAverage( #endif return; } - if (bioApplied) + +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (bioApplied && (pu.cu->geoFlag && chromaOnly)) + { +#if JVET_AG0276_LIC_BDOF_BDMVR + m_bdofMvRefined = (pu.cu->licFlag == false); +#else + m_bdofMvRefined = true; +#endif + } +#endif + + if (bioApplied +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + && !(pu.cu->geoFlag && chromaOnly) +#endif + ) { #if !JVET_Z0136_OOB const int src0Stride = pu.lwidth() + 2 * BIO_EXTEND_SIZE + 2; @@ -8046,11 +8184,26 @@ void InterPrediction::subBlockOBMC(PredictionUnit &pu, PelUnitBuf* pDst) subPu.cu->bcwIdx = neighPu->cu->bcwIdx; for (int refList = 0; refList < 2; refList++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(neighPu->interDir & (refList + 1)) + { +#endif for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) { subPu.cu->licScale[refList][comp] = neighPu->cu->licScale[refList][comp]; subPu.cu->licOffset[refList][comp] = neighPu->cu->licOffset[refList][comp]; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } + else + { + for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) + { + subPu.cu->licScale[refList][comp] = 32; + subPu.cu->licOffset[refList][comp] = 0; + } + } +#endif } #endif #if JVET_AG0276_NLIC @@ -8100,11 +8253,26 @@ void InterPrediction::subBlockOBMC(PredictionUnit &pu, PelUnitBuf* pDst) subPu.cu->BcwIdx = neighPu->cu->BcwIdx; for (int refList = 0; refList < 2; refList++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (neighPu->interDir & (refList + 1)) + { +#endif for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) { subPu.cu->licScale[refList][comp] = neighPu->cu->licScale[refList][comp]; subPu.cu->licOffset[refList][comp] = neighPu->cu->licOffset[refList][comp]; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } + else + { + for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) + { + subPu.cu->licScale[refList][comp] = 32; + subPu.cu->licOffset[refList][comp] = 0; + } + } +#endif } #endif xSubBlockMotionCompensation(subPu, cTmp1); @@ -8165,11 +8333,26 @@ void InterPrediction::subBlockOBMC(PredictionUnit &pu, PelUnitBuf* pDst) subPu.cu->licFlag = licFlag; for (int refList = 0; refList < 2; refList++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.interDir & (refList + 1)) + { +#endif for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) { subPu.cu->licScale[refList][comp] = licScale[refList][comp]; subPu.cu->licOffset[refList][comp] = licOffset[refList][comp]; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } + else + { + for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) + { + subPu.cu->licScale[refList][comp] = 32; + subPu.cu->licOffset[refList][comp] = 0; + } + } +#endif } subPu.cu->bcwIdx = bcwIdx; #endif @@ -8945,6 +9128,10 @@ bool InterPrediction::getGeoBlendCand( const CodingUnit& cu, MergeCtx& geoMrgCtx maxNumMergeCandidates = std::min((int)maxNumMergeCandidates, geoMrgCtx.numValidMergeCand); Slice* slice = cu.cs->slice; MvField mvFieldA[2], mvFieldB[2]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + int scaleA[2], offsetA[2]; + int scaleB[2], offsetB[2]; +#endif int numGeoBlendInfoCand = 0; geoMrgCtx.setGeoMrgDuplicate( *cu.firstPU ); bool* mrgDuplicated = geoMrgCtx.mrgDuplicated; @@ -8961,7 +9148,14 @@ bool InterPrediction::getGeoBlendCand( const CodingUnit& cu, MergeCtx& geoMrgCtx } MvField mvFieldTmp[2]; - int dir = geoMrgCtx.getDir( slice, mergeCand, mvFieldTmp ); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + int scaleTmp[2], offsetTmp[2]; +#endif + int dir = geoMrgCtx.getDir( slice, mergeCand, mvFieldTmp +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , scaleTmp, offsetTmp +#endif + ); if (dir == 0 || dir == 2) { listMergeCand0.push_back(mergeCand); @@ -8989,8 +9183,16 @@ bool InterPrediction::getGeoBlendCand( const CodingUnit& cu, MergeCtx& geoMrgCtx uint8_t mergeCand0 = pairMergeCand.first; uint8_t mergeCand1 = pairMergeCand.second; - int dir0 = geoMrgCtx.getDir( slice, mergeCand0, mvFieldA ); - int dir1 = geoMrgCtx.getDir( slice, mergeCand1, mvFieldB ); + int dir0 = geoMrgCtx.getDir( slice, mergeCand0, mvFieldA +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , scaleA, offsetA +#endif + ); + int dir1 = geoMrgCtx.getDir( slice, mergeCand1, mvFieldB +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , scaleB, offsetB +#endif + ); if ( dir0 < 0 || dir0 == 1 ) { // should contain at least ref-list-0 @@ -9008,7 +9210,11 @@ bool InterPrediction::getGeoBlendCand( const CodingUnit& cu, MergeCtx& geoMrgCtx for (int i = 0; i < numGeoBlendInfoCand && !bSame; i++) { GeoBlendInfo& tgeoBI = geoBlendInfo[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bSame = tgeoBI.isSame(mvFieldA, mvFieldB, scaleA, scaleB, offsetA, offsetB) || tgeoBI.isSame(mvFieldB, mvFieldA, scaleB, scaleA, offsetB, offsetA); +#else bSame = tgeoBI.isSame( mvFieldA, mvFieldB ) || tgeoBI.isSame( mvFieldB, mvFieldA ); +#endif } if (bSame) { @@ -9017,7 +9223,13 @@ bool InterPrediction::getGeoBlendCand( const CodingUnit& cu, MergeCtx& geoMrgCtx m_tplBuffers.set( mergeCand0, mergeCand1, cu.lumaSize() ); - Distortion uiCostTmp = deriveBcwBlendingBiDir( *cu.firstPU, mvFieldA, mvFieldB ); // template distortion cost + Distortion uiCostTmp = deriveBcwBlendingBiDir( *cu.firstPU, mvFieldA, mvFieldB +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , geoMrgCtx.licFlags[mergeCand0], geoMrgCtx.licFlags[mergeCand1] + , scaleA, scaleB + , offsetA, offsetB +#endif + ); // template distortion cost if ( uiCostTmp < MAX_UINT64 ) { @@ -9030,6 +9242,16 @@ bool InterPrediction::getGeoBlendCand( const CodingUnit& cu, MergeCtx& geoMrgCtx geoBI.mvFieldA[1] = mvFieldA[1]; geoBI.mvFieldB[0] = mvFieldB[0]; geoBI.mvFieldB[1] = mvFieldB[1]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + geoBI.scaleA [0] = scaleA [0]; + geoBI.scaleA [1] = scaleA [1]; + geoBI.offsetA[0] = offsetA[0]; + geoBI.offsetA[1] = offsetA[1]; + geoBI.scaleB [0] = scaleB [0]; + geoBI.scaleB [1] = scaleB [1]; + geoBI.offsetB[0] = offsetB[0]; + geoBI.offsetB[1] = offsetB[1]; +#endif geoBI.dir[0] = dir0; geoBI.dir[1] = dir1; @@ -9081,6 +9303,10 @@ void InterPrediction::motionCompensationGeoBlend( CodingUnit& cu, MergeCtx& geoM const int mergeIdx = cu.firstPU->geoMergeIdx0; GeoBlendInfo geoBI; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licFlag = false; + geoMrgCtx.setLICParamToPu(*cu.firstPU, NOT_VALID, false); +#endif bool bFoundGeoBlendCand = getGeoBlendCand( cu, geoMrgCtx, mergeIdx, geoBI ); if ( !bFoundGeoBlendCand ) { @@ -11849,6 +12075,9 @@ void InterPrediction::sortInterMergeMMVDCandidates(PredictionUnit &pu, MergeCtx #endif #if INTER_LIC pu.cu->licFlag = mrgCtx.licFlags[fPosBaseIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setLICParamToPu(pu, fPosBaseIdx, mrgCtx.licInheritPara[fPosBaseIdx]); +#endif #endif pu.cu->bcwIdx = (mrgCtx.interDirNeighbours[fPosBaseIdx] == 3) ? mrgCtx.bcwIdx[fPosBaseIdx] : BCW_DEFAULT; pu.refIdx[REF_PIC_LIST_0] = refList0; @@ -12355,6 +12584,9 @@ void InterPrediction::sortAffineMergeCandidates(PredictionUnit pu, AffineMergeC #endif #if JVET_AD0213_LIC_IMP pu.cu->licFlag = affMrgCtx.licFlags[pu.mergeIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setLICParamToPu(pu, pu.mergeIdx, pu.cu->licFlag); +#endif #endif //Store posList0 = 0; @@ -12606,7 +12838,11 @@ void InterPrediction::sortAffineMergeCandidates(PredictionUnit pu, AffineMergeC pu.mergeType = affMrgCtx.mergeType[pu.mergeIdx]; #if INTER_LIC pu.cu->licFlag = affMrgCtx.licFlags[pu.mergeIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setLICParamToPu(pu, pu.mergeIdx, pu.cu->licFlag); +#else pu.cu->licFlag = false; +#endif #endif pu.interDir = affMrgCtx.interDirNeighbours[pu.mergeIdx]; pu.cu->affineType = affMrgCtx.affineType[pu.mergeIdx]; @@ -13055,7 +13291,13 @@ Distortion InterPrediction::deriveBcwBlending( PredictionUnit& pu, bool bUniDir[ return uiCost; } -Distortion InterPrediction::deriveBcwBlendingBiDir( PredictionUnit& pu, MvField mvfldA[2], MvField mvfldB[2] ) +Distortion InterPrediction::deriveBcwBlendingBiDir( PredictionUnit& pu, MvField mvfldA[2], MvField mvfldB[2] +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , bool isLicA, bool isLicB + , int scaleA[2], int scaleB[2] + , int offsetA[2], int offsetB[2] +#endif +) { if ( pu.ciipFlag || !pu.cs->sps->getUseAML() ) { @@ -13098,6 +13340,12 @@ Distortion InterPrediction::deriveBcwBlendingBiDir( PredictionUnit& pu, MvField MvField mvFieldStore[2]; mvFieldStore[0].setMvField( pu.mv[0], pu.refIdx[0] ); mvFieldStore[1].setMvField( pu.mv[1], pu.refIdx[1] ); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool licFlagStore = pu.cu->licFlag; + bool inheritStore = pu.cu->licInheritPara; + int scaleStore [2] = { pu.cu->licScale [0][COMPONENT_Y] , pu.cu->licScale [1][COMPONENT_Y] }; + int offsetStore[2] = { pu.cu->licOffset[0][COMPONENT_Y] , pu.cu->licOffset[1][COMPONENT_Y] }; +#endif bool bUniDirTab[2] = { true, true }; @@ -13107,6 +13355,26 @@ Distortion InterPrediction::deriveBcwBlendingBiDir( PredictionUnit& pu, MvField int refIdx[2]; refIdx[0] = mvField[0].refIdx; refIdx[1] = mvField[1].refIdx; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (iPart) + { + pu.cu->licFlag = isLicB; + pu.cu->licInheritPara = isLicB; + pu.cu->licScale [0][COMPONENT_Y] = scaleB [0]; + pu.cu->licScale [1][COMPONENT_Y] = scaleB [1]; + pu.cu->licOffset[0][COMPONENT_Y] = offsetB[0]; + pu.cu->licOffset[1][COMPONENT_Y] = offsetB[1]; + } + else + { + pu.cu->licFlag = isLicA; + pu.cu->licInheritPara = isLicA; + pu.cu->licScale [0][COMPONENT_Y] = scaleA [0]; + pu.cu->licScale [1][COMPONENT_Y] = scaleA [1]; + pu.cu->licOffset[0][COMPONENT_Y] = offsetA[0]; + pu.cu->licOffset[1][COMPONENT_Y] = offsetA[1]; + } +#endif #if JVET_Z0067_RPR_ENABLE bool bRefIsRescaled = false; @@ -13219,6 +13487,14 @@ Distortion InterPrediction::deriveBcwBlendingBiDir( PredictionUnit& pu, MvField pu.mv[1] = mvFieldStore[1].mv; pu.refIdx[0] = mvFieldStore[0].refIdx; pu.refIdx[1] = mvFieldStore[1].refIdx; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pu.cu->licFlag = licFlagStore; + pu.cu->licInheritPara = inheritStore; + pu.cu->licScale [0][COMPONENT_Y] = scaleStore [0]; + pu.cu->licScale [1][COMPONENT_Y] = scaleStore [1]; + pu.cu->licOffset[0][COMPONENT_Y] = offsetStore[0]; + pu.cu->licOffset[1][COMPONENT_Y] = offsetStore[1]; +#endif return uiCost; } @@ -13470,7 +13746,9 @@ void InterPrediction::adjustMergeCandidatesBcwIdx(PredictionUnit& pu, MergeCtx& #if JVET_AF0128_LIC_MERGE_TM void InterPrediction::adjustMergeCandidatesLicFlag(PredictionUnit& pu, MergeCtx& mrgCtx, const int mergeIdx) { - if (pu.cu->geoFlag || !pu.cs->sps->getTMToolsEnableFlag() || !pu.cs->slice->getUseLIC()) + if ( + pu.cu->geoFlag || + !pu.cs->sps->getTMToolsEnableFlag() || !pu.cs->slice->getUseLIC()) { return; } @@ -13522,6 +13800,10 @@ void InterPrediction::adjustMergeCandidatesLicFlag(PredictionUnit& pu, MergeCtx& mrgCtx.setMergeInfo(pu, uiMergeCand); origLICFlag = pu.cu->licFlag; pu.cu->licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + CHECK(pu.cu->licInheritPara, "licInheritPara is initially true "); + pu.cu->licInheritPara = false; // Set false for getBlkAMLRefTemplate to get non-LIC MC results +#endif #if JVET_Z0067_RPR_ENABLE bool bRefIsRescaled = false; for (uint32_t refList = 0; refList < NUM_REF_PIC_LIST_01; refList++) @@ -13551,18 +13833,17 @@ void InterPrediction::adjustMergeCandidatesLicFlag(PredictionUnit& pu, MergeCtx& if (m_bAMLTemplateAvailabe[0]) { m_pcRdCost->setDistParam(cDistParam, pcBufPredCurTop.Y(), pcBufPredRefTop.Y(), pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y, false); - uiCost += cDistParam.distFunc(cDistParam); } if (m_bAMLTemplateAvailabe[1]) { m_pcRdCost->setDistParam(cDistParam, pcBufPredCurLeft.Y(), pcBufPredRefLeft.Y(), pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y, false); - uiCost += cDistParam.distFunc(cDistParam); } - if (origLICFlag == licFlag) + if (origLICFlag == licFlag + ) { if (pu.cu->slice->getCheckLDB()) { @@ -13582,6 +13863,12 @@ void InterPrediction::adjustMergeCandidatesLicFlag(PredictionUnit& pu, MergeCtx& } //for (int licFlag = 0; licFlag < 2; licFlag++) pu.cu->licFlag = bestLICFlag; mrgCtx.licFlags[uiMergeCand] = bestLICFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (!bestLICFlag) + { + mrgCtx.setDefaultLICParamToCtx(uiMergeCand); + } +#endif } // for (uint32_t uiMergeCand = 0; uiMergeCand < mrgCtx.numValidMergeCand; uiMergeCand++) pu.mergeIdx = mergeIdx; } @@ -13743,6 +14030,9 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer #endif #if INTER_LIC pairMergeCand.licFlags[cnt] = mvpMergeCandCtx.licFlags[rdCandList[0]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pairMergeCand.setDefaultLICParamToCtx(cnt); +#endif #endif pairMergeCand.bcwIdx[cnt] = mvpMergeCandCtx.bcwIdx[rdCandList[0]]; pairMergeCand.useAltHpelIf[cnt] = mvpMergeCandCtx.useAltHpelIf[rdCandList[0]]; @@ -13802,6 +14092,9 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer if (averageUsed && !(((pu.cu->slice->getPOC() - pu.cu->slice->getRefPOC(REF_PIC_LIST_0, 0)) == 1) && pu.cu->slice->getPicHeader()->getMvdL1ZeroFlag())) { pairMergeCand.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pairMergeCand.setDefaultLICParamToCtx(cnt); +#endif } #endif @@ -13811,6 +14104,9 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer if (interDir == 3) { pairMergeCand.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pairMergeCand.setDefaultLICParamToCtx(cnt); +#endif } #endif uint32_t mvdSimilarityThresh = 1; @@ -13978,17 +14274,32 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer } #endif -#if JVET_AG0276_NLIC -void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMergeCandCtx, AltLMMergeCtx& altLMMrgCtx, int numRetrievedMergeCand) +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG +void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMergeCandCtx +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , AltLMMergeCtx* pMrgCtxAlt + , AltLMMergeCtx* pMrgCtxInherit +#else + , AltLMMergeCtx& altLMMrgCtx +#endif + , int numRetrievedMergeCand) { MergeCtx altLMMergeCand; altLMMergeCand.numValidMergeCand = 0; altLMMergeCand.numCandToTestEnc = 0; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(pMrgCtxAlt != nullptr) + { + AltLMMergeCtx& altLMMrgCtx = *pMrgCtxAlt; +#endif for (uint32_t mrgIdx = 0; mrgIdx < altLMMrgCtx.numValidMergeCand; mrgIdx++) { altLMMergeCand.altLMFlag[altLMMergeCand.numValidMergeCand] = true; altLMMergeCand.altLMParaNeighbours[altLMMergeCand.numValidMergeCand] = altLMMrgCtx.altLMParaNeighbours[mrgIdx]; altLMMergeCand.licFlags[altLMMergeCand.numValidMergeCand] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + altLMMergeCand.setDefaultLICParamToCtx(altLMMergeCand.numValidMergeCand); +#endif altLMMergeCand.interDirNeighbours[altLMMergeCand.numValidMergeCand] = altLMMrgCtx.interDirNeighbours[mrgIdx]; altLMMergeCand.mvFieldNeighbours[(altLMMergeCand.numValidMergeCand << 1) + 0] = altLMMrgCtx.mvFieldNeighbours[(mrgIdx << 1) + 0]; altLMMergeCand.mvFieldNeighbours[(altLMMergeCand.numValidMergeCand << 1) + 1] = altLMMrgCtx.mvFieldNeighbours[(mrgIdx << 1) + 1]; @@ -14000,14 +14311,51 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer altLMMergeCand.numValidMergeCand++; altLMMergeCand.numCandToTestEnc++; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + MergeCtx inheritedMrgCand; + inheritedMrgCand.numValidMergeCand = 0; + inheritedMrgCand.numCandToTestEnc = 0; + if (pMrgCtxInherit != nullptr) + { + AltLMMergeCtx& altLMMrgCtx = *pMrgCtxInherit; + for (uint32_t mrgIdx = 0; mrgIdx < altLMMrgCtx.numValidMergeCand; mrgIdx++) + { + inheritedMrgCand.altLMFlag[inheritedMrgCand.numValidMergeCand] = false; + inheritedMrgCand.altLMParaNeighbours[inheritedMrgCand.numValidMergeCand].resetAltLinearModel(); + inheritedMrgCand.licFlags[inheritedMrgCand.numValidMergeCand] = altLMMrgCtx.licFlags[mrgIdx]; + inheritedMrgCand.copyLICParamFromCtx(inheritedMrgCand.numValidMergeCand, altLMMrgCtx, mrgIdx); + + inheritedMrgCand.interDirNeighbours[inheritedMrgCand.numValidMergeCand] = altLMMrgCtx.interDirNeighbours[mrgIdx]; + inheritedMrgCand.mvFieldNeighbours[(inheritedMrgCand.numValidMergeCand << 1) + 0] = altLMMrgCtx.mvFieldNeighbours[(mrgIdx << 1) + 0]; + inheritedMrgCand.mvFieldNeighbours[(inheritedMrgCand.numValidMergeCand << 1) + 1] = altLMMrgCtx.mvFieldNeighbours[(mrgIdx << 1) + 1]; + inheritedMrgCand.useAltHpelIf[inheritedMrgCand.numValidMergeCand] = altLMMrgCtx.useAltHpelIf[mrgIdx]; + inheritedMrgCand.bcwIdx[inheritedMrgCand.numValidMergeCand] = altLMMrgCtx.bcwIdx[mrgIdx]; + inheritedMrgCand.addHypNeighbours[inheritedMrgCand.numValidMergeCand].clear(); + inheritedMrgCand.candCost[inheritedMrgCand.numValidMergeCand] = MAX_UINT64; + + inheritedMrgCand.numValidMergeCand++; + inheritedMrgCand.numCandToTestEnc++; + } + } +#endif - if (mvpMergeCandCtx.numValidMergeCand + altLMMergeCand.numValidMergeCand <= 1) + if (mvpMergeCandCtx.numValidMergeCand + altLMMergeCand.numValidMergeCand +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + + inheritedMrgCand.numValidMergeCand +#endif + <= 1) { for (uint32_t mrgIdx = 0; mrgIdx < altLMMergeCand.numValidMergeCand; mrgIdx++) { mvpMergeCandCtx.altLMFlag[mvpMergeCandCtx.numValidMergeCand] = altLMMergeCand.altLMFlag[mrgIdx]; mvpMergeCandCtx.altLMParaNeighbours[mvpMergeCandCtx.numValidMergeCand] = altLMMergeCand.altLMParaNeighbours[mrgIdx]; mvpMergeCandCtx.licFlags[mvpMergeCandCtx.numValidMergeCand] = altLMMergeCand.licFlags[mrgIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mvpMergeCandCtx.setDefaultLICParamToCtx(mvpMergeCandCtx.numValidMergeCand); +#endif mvpMergeCandCtx.interDirNeighbours[mvpMergeCandCtx.numValidMergeCand] = altLMMergeCand.interDirNeighbours[mrgIdx]; mvpMergeCandCtx.mvFieldNeighbours[(mvpMergeCandCtx.numValidMergeCand << 1) + 0] = altLMMergeCand.mvFieldNeighbours[(mrgIdx << 1) + 0]; mvpMergeCandCtx.mvFieldNeighbours[(mvpMergeCandCtx.numValidMergeCand << 1) + 1] = altLMMergeCand.mvFieldNeighbours[(mrgIdx << 1) + 1]; @@ -14017,23 +14365,58 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer mvpMergeCandCtx.candCost[mvpMergeCandCtx.numValidMergeCand] = altLMMergeCand.candCost[mrgIdx]; mvpMergeCandCtx.numValidMergeCand++; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + for (uint32_t mrgIdx = 0; mrgIdx < inheritedMrgCand.numValidMergeCand; mrgIdx++) + { + mvpMergeCandCtx.altLMFlag[mvpMergeCandCtx.numValidMergeCand] = inheritedMrgCand.altLMFlag[mrgIdx]; + mvpMergeCandCtx.altLMParaNeighbours[mvpMergeCandCtx.numValidMergeCand] = inheritedMrgCand.altLMParaNeighbours[mrgIdx]; + mvpMergeCandCtx.licFlags[mvpMergeCandCtx.numValidMergeCand] = inheritedMrgCand.licFlags[mrgIdx]; + mvpMergeCandCtx.copyLICParamFromCtx(mvpMergeCandCtx.numValidMergeCand, inheritedMrgCand, mrgIdx); + + mvpMergeCandCtx.interDirNeighbours[mvpMergeCandCtx.numValidMergeCand] = inheritedMrgCand.interDirNeighbours[mrgIdx]; + mvpMergeCandCtx.mvFieldNeighbours[(mvpMergeCandCtx.numValidMergeCand << 1) + 0] = inheritedMrgCand.mvFieldNeighbours[(mrgIdx << 1) + 0]; + mvpMergeCandCtx.mvFieldNeighbours[(mvpMergeCandCtx.numValidMergeCand << 1) + 1] = inheritedMrgCand.mvFieldNeighbours[(mrgIdx << 1) + 1]; + mvpMergeCandCtx.useAltHpelIf[mvpMergeCandCtx.numValidMergeCand] = inheritedMrgCand.useAltHpelIf[mrgIdx]; + mvpMergeCandCtx.bcwIdx[mvpMergeCandCtx.numValidMergeCand] = inheritedMrgCand.bcwIdx[mrgIdx]; + mvpMergeCandCtx.addHypNeighbours[mvpMergeCandCtx.numValidMergeCand] = inheritedMrgCand.addHypNeighbours[mrgIdx]; + mvpMergeCandCtx.candCost[mvpMergeCandCtx.numValidMergeCand] = inheritedMrgCand.candCost[mrgIdx]; + mvpMergeCandCtx.numValidMergeCand++; + } +#endif return; } int numCandInCategory = MAX_INT; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + const int maxBufferSize = NUM_MERGE_CANDS + + MRG_MAX_NUM_CANDS + + ALT_MRG_MAX_NUM_CANDS + + LIC_INHERIT_ALT_MRG_MAX_NUM_CANDS + ; + uint32_t rdCandList [maxBufferSize]; + uint32_t candCategory[maxBufferSize]; + Distortion candCostList[maxBufferSize]; +#else uint32_t rdCandList[NUM_MERGE_CANDS + MRG_MAX_NUM_CANDS + ALT_MRG_MAX_NUM_CANDS]; uint32_t candCategory[NUM_MERGE_CANDS + MRG_MAX_NUM_CANDS + ALT_MRG_MAX_NUM_CANDS]; Distortion candCostList[NUM_MERGE_CANDS + MRG_MAX_NUM_CANDS + ALT_MRG_MAX_NUM_CANDS]; +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + for (uint32_t j = 0; j < maxBufferSize; j++) +#else for (uint32_t j = 0; j < NUM_MERGE_CANDS + MRG_MAX_NUM_CANDS + ALT_MRG_MAX_NUM_CANDS; j++) +#endif { rdCandList[j] = j; candCategory[j] = MAX_UINT; candCostList[j] = MAX_UINT64; } +#if !JVET_AH0314_LIC_INHERITANCE_FOR_MRG Distortion uiCost; +#endif DistParam cDistParam; cDistParam.applyWeight = false; @@ -14046,9 +14429,18 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer PelUnitBuf pcBufPredCurTop = (PelUnitBuf(pu.chromaFormat, PelBuf(m_acYuvCurAMLTemplate[0][0], nWidth, AML_MERGE_TEMPLATE_SIZE))); PelUnitBuf pcBufPredCurLeft = (PelUnitBuf(pu.chromaFormat, PelBuf(m_acYuvCurAMLTemplate[1][0], AML_MERGE_TEMPLATE_SIZE, nHeight))); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + auto reordering = [&](MergeCtx& mvpMergeCandCtx, int groupId, int cumulativeNumValidMergeCand) + { + Distortion uiCost; +#endif for (uint32_t uiMergeCand = 0; uiMergeCand < mvpMergeCandCtx.numValidMergeCand; uiMergeCand++) { - if (mvpMergeCandCtx.numCandToTestEnc != mvpMergeCandCtx.numValidMergeCand) + if ( +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + groupId == 0 && +#endif + mvpMergeCandCtx.numCandToTestEnc != mvpMergeCandCtx.numValidMergeCand) { if (uiMergeCand >= mvpMergeCandCtx.numCandToTestEnc) { @@ -14110,9 +14502,20 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer uiCost = mvpMergeCandCtx.candCost[uiMergeCand]; } - updateCandList(uiMergeCand, 0, uiCost, mvpMergeCandCtx.numValidMergeCand, rdCandList, candCategory, candCostList); + updateCandList(uiMergeCand +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , groupId, uiCost, cumulativeNumValidMergeCand +#else + , 0, uiCost, mvpMergeCandCtx.numValidMergeCand +#endif + , rdCandList, candCategory, candCostList); } pu.mergeIdx = origMergeIdx; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + }; + + reordering(mvpMergeCandCtx, 0, mvpMergeCandCtx.numValidMergeCand); +#endif MergeCtx pairMergeCand; pairMergeCand.numValidMergeCand = 0; @@ -14141,6 +14544,9 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer #endif #if INTER_LIC pairMergeCand.licFlags[cnt] = mvpMergeCandCtx.licFlags[rdCandList[0]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pairMergeCand.setDefaultLICParamToCtx(cnt); +#endif #endif pairMergeCand.bcwIdx[cnt] = mvpMergeCandCtx.bcwIdx[rdCandList[0]]; pairMergeCand.useAltHpelIf[cnt] = mvpMergeCandCtx.useAltHpelIf[rdCandList[0]]; @@ -14200,6 +14606,9 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer if (averageUsed && !(((pu.cu->slice->getPOC() - pu.cu->slice->getRefPOC(REF_PIC_LIST_0, 0)) == 1) && pu.cu->slice->getPicHeader()->getMvdL1ZeroFlag())) { pairMergeCand.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pairMergeCand.setDefaultLICParamToCtx(cnt); +#endif } #endif @@ -14209,6 +14618,9 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer if (interDir == 3) { pairMergeCand.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pairMergeCand.setDefaultLICParamToCtx(cnt); +#endif } #endif uint32_t mvdSimilarityThresh = 1; @@ -14243,6 +14655,9 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer if (pairAdded) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + reordering(pairMergeCand, 1, mvpMergeCandCtx.numValidMergeCand + pairMergeCand.numValidMergeCand); +#else for (uint32_t uiMergeCand = 0; uiMergeCand < pairMergeCand.numValidMergeCand; uiMergeCand++) { if (pairMergeCand.candCost[uiMergeCand] == MAX_UINT64) @@ -14280,10 +14695,14 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer updateCandList(uiMergeCand, 1, uiCost, (mvpMergeCandCtx.numValidMergeCand + pairMergeCand.numValidMergeCand), rdCandList, candCategory, candCostList); } pu.mergeIdx = origMergeIdx; +#endif } if (altLMMergeCand.numValidMergeCand) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + reordering(altLMMergeCand, 2, mvpMergeCandCtx.numValidMergeCand + pairMergeCand.numValidMergeCand + altLMMergeCand.numValidMergeCand); +#else for (uint32_t uiMergeCand = 0; uiMergeCand < altLMMergeCand.numValidMergeCand; uiMergeCand++) { if (altLMMergeCand.candCost[uiMergeCand] == MAX_UINT64) @@ -14321,14 +14740,33 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer updateCandList(uiMergeCand, 2, uiCost, (mvpMergeCandCtx.numValidMergeCand + pairMergeCand.numValidMergeCand + altLMMergeCand.numValidMergeCand), rdCandList, candCategory, candCostList); } pu.mergeIdx = origMergeIdx; +#endif + } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (inheritedMrgCand.numValidMergeCand) + { + reordering(inheritedMrgCand, 3, mvpMergeCandCtx.numValidMergeCand + pairMergeCand.numValidMergeCand + altLMMergeCand.numValidMergeCand + inheritedMrgCand.numValidMergeCand); } +#endif Distortion cost = pu.cs->slice->getCostForARMC(); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + uint32_t candToBeRemoved = maxBufferSize; +#else uint32_t candToBeRemoved = NUM_MERGE_CANDS + MRG_MAX_NUM_CANDS + ALT_MRG_MAX_NUM_CANDS; +#endif Distortion min = MAX_UINT64; - numCandInCategory = std::min(numRetrievedMergeCand, mvpMergeCandCtx.numValidMergeCand + pairMergeCand.numValidMergeCand + altLMMergeCand.numValidMergeCand); - for (int sizeCandList = mvpMergeCandCtx.numCandToTestEnc + pairMergeCand.numValidMergeCand + altLMMergeCand.numValidMergeCand; sizeCandList > 1; sizeCandList--) + numCandInCategory = std::min(numRetrievedMergeCand, mvpMergeCandCtx.numValidMergeCand + pairMergeCand.numValidMergeCand + altLMMergeCand.numValidMergeCand +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + + inheritedMrgCand.numValidMergeCand +#endif + ); + for (int sizeCandList = mvpMergeCandCtx.numCandToTestEnc + pairMergeCand.numValidMergeCand + altLMMergeCand.numValidMergeCand +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + + inheritedMrgCand.numValidMergeCand +#endif + ; sizeCandList > 1; sizeCandList--) { min = MAX_UINT64; for (uint32_t uiMergeCand = 0; uiMergeCand < sizeCandList - 1; ++uiMergeCand) @@ -14380,6 +14818,9 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer { if (altLMMergeCand.numValidMergeCand) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + reordering(altLMMergeCand, 2, mvpMergeCandCtx.numValidMergeCand + altLMMergeCand.numValidMergeCand); +#else for (uint32_t uiMergeCand = 0; uiMergeCand < altLMMergeCand.numValidMergeCand; uiMergeCand++) { if (altLMMergeCand.candCost[uiMergeCand] == MAX_UINT64) @@ -14417,11 +14858,28 @@ void InterPrediction::adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMer updateCandList(uiMergeCand, 2, uiCost, (mvpMergeCandCtx.numValidMergeCand + altLMMergeCand.numValidMergeCand), rdCandList, candCategory, candCostList); } pu.mergeIdx = origMergeIdx; +#endif } - numCandInCategory = std::min(numRetrievedMergeCand, mvpMergeCandCtx.numValidMergeCand + altLMMergeCand.numValidMergeCand); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (inheritedMrgCand.numValidMergeCand) + { + reordering(inheritedMrgCand, 3, mvpMergeCandCtx.numValidMergeCand + altLMMergeCand.numValidMergeCand + inheritedMrgCand.numValidMergeCand); + } +#endif + numCandInCategory = std::min(numRetrievedMergeCand, mvpMergeCandCtx.numValidMergeCand + altLMMergeCand.numValidMergeCand +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + + inheritedMrgCand.numValidMergeCand +#endif + ); } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + int numGroups = 4; + const MergeCtx* mrgCtx2toN[] = { &pairMergeCand, &altLMMergeCand, &inheritedMrgCand}; + updateCandInMultiCandidateGroups(rdCandList, candCategory, numCandInCategory, mvpMergeCandCtx, mrgCtx2toN, numGroups); +#else updateCandInThreeCandidateGroups(mvpMergeCandCtx, pairMergeCand, altLMMergeCand, rdCandList, candCategory, numCandInCategory); +#endif for (int idx = 0; idx < numCandInCategory; idx++) { @@ -14455,6 +14913,44 @@ void InterPrediction::updateCandList(uint32_t uiCand, uint32_t uiCandGrp, Distor } } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +void InterPrediction::updateCandInMultiCandidateGroups(uint32_t* rdCandList, uint32_t* rdCandGrpList, int numCandInCategory, MergeCtx& mrgCtx, const MergeCtx** mrgCtx2toN, int N) +{ + std::vector<const MergeCtx*> mrgList; + mrgList.reserve(N); + + MergeCtx mrgCtxTmp = mrgCtx; + mrgList.push_back(&mrgCtxTmp); + for (int i = 0; i < N - 1; ++i) + { + mrgList.push_back(mrgCtx2toN[i]); + } + + //update + for (uint32_t uiMergeCand = 0; uiMergeCand < numCandInCategory; uiMergeCand++) + { + const MergeCtx& srcMrgCtx = *mrgList[rdCandGrpList[uiMergeCand]]; + const uint32_t srcMrgIdx = rdCandList[uiMergeCand]; + + mrgCtx.bcwIdx[uiMergeCand] = srcMrgCtx.bcwIdx[srcMrgIdx]; + mrgCtx.interDirNeighbours[uiMergeCand] = srcMrgCtx.interDirNeighbours[srcMrgIdx]; + mrgCtx.mvFieldNeighbours[(uiMergeCand << 1)] = srcMrgCtx.mvFieldNeighbours[srcMrgIdx << 1]; + mrgCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1] = srcMrgCtx.mvFieldNeighbours[(srcMrgIdx << 1) + 1]; + mrgCtx.useAltHpelIf[uiMergeCand] = srcMrgCtx.useAltHpelIf[srcMrgIdx]; + mrgCtx.altLMFlag[uiMergeCand] = srcMrgCtx.altLMFlag[srcMrgIdx]; + mrgCtx.altLMParaNeighbours[uiMergeCand] = srcMrgCtx.altLMParaNeighbours[srcMrgIdx]; +#if INTER_LIC + mrgCtx.licFlags[uiMergeCand] = srcMrgCtx.licFlags[srcMrgIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(uiMergeCand, srcMrgCtx, srcMrgIdx); +#endif +#endif +#if MULTI_HYP_PRED + mrgCtx.addHypNeighbours[uiMergeCand] = srcMrgCtx.addHypNeighbours[srcMrgIdx]; +#endif + } +} +#else void InterPrediction::updateCandInThreeCandidateGroups(MergeCtx& mrgCtx, MergeCtx mrgCtx2, MergeCtx mrgCtx3, uint32_t* rdCandList, uint32_t* rdCandGrpList, int numCandInCategory) { MergeCtx mrgCtxTmp; @@ -14469,6 +14965,9 @@ void InterPrediction::updateCandInThreeCandidateGroups(MergeCtx& mrgCtx, MergeCt mrgCtxTmp.altLMParaNeighbours[uiMergeCand] = mrgCtx.altLMParaNeighbours[uiMergeCand]; #if INTER_LIC mrgCtxTmp.licFlags[uiMergeCand] = mrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtxTmp.copyLICParamFromCtx(uiMergeCand, mrgCtx, uiMergeCand); +#endif #endif #if MULTI_HYP_PRED mrgCtxTmp.addHypNeighbours[uiMergeCand] = mrgCtx.addHypNeighbours[uiMergeCand]; @@ -14488,6 +14987,9 @@ void InterPrediction::updateCandInThreeCandidateGroups(MergeCtx& mrgCtx, MergeCt mrgCtx.altLMParaNeighbours[uiMergeCand] = mrgCtx3.altLMParaNeighbours[rdCandList[uiMergeCand]]; #if INTER_LIC mrgCtx.licFlags[uiMergeCand] = mrgCtx3.licFlags[rdCandList[uiMergeCand]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(uiMergeCand, mrgCtx3, rdCandList[uiMergeCand]); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[uiMergeCand] = mrgCtx3.addHypNeighbours[rdCandList[uiMergeCand]]; @@ -14504,6 +15006,9 @@ void InterPrediction::updateCandInThreeCandidateGroups(MergeCtx& mrgCtx, MergeCt mrgCtx.altLMParaNeighbours[uiMergeCand] = mrgCtx2.altLMParaNeighbours[rdCandList[uiMergeCand]]; #if INTER_LIC mrgCtx.licFlags[uiMergeCand] = mrgCtx2.licFlags[rdCandList[uiMergeCand]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(uiMergeCand, mrgCtx2, rdCandList[uiMergeCand]); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[uiMergeCand] = mrgCtx2.addHypNeighbours[rdCandList[uiMergeCand]]; @@ -14522,6 +15027,9 @@ void InterPrediction::updateCandInThreeCandidateGroups(MergeCtx& mrgCtx, MergeCt #endif #if INTER_LIC mrgCtx.licFlags[uiMergeCand] = mrgCtxTmp.licFlags[rdCandList[uiMergeCand]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(uiMergeCand, mrgCtxTmp, rdCandList[uiMergeCand]); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[uiMergeCand] = mrgCtxTmp.addHypNeighbours[rdCandList[uiMergeCand]]; @@ -14530,6 +15038,7 @@ void InterPrediction::updateCandInThreeCandidateGroups(MergeCtx& mrgCtx, MergeCt } } #endif +#endif #if JVET_AA0093_DIVERSITY_CRITERION_FOR_ARMC void InterPrediction::updateCandInTwoCandidateGroups(MergeCtx& mrgCtx, uint32_t* rdCandList, int numCandInCategory, MergeCtx mrgCtx2) @@ -14548,6 +15057,9 @@ void InterPrediction::updateCandInTwoCandidateGroups(MergeCtx& mrgCtx, uint32_t #endif #if INTER_LIC mrgCtxTmp.licFlags[uiMergeCand] = mrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtxTmp.copyLICParamFromCtx(uiMergeCand, mrgCtx, uiMergeCand); +#endif #endif #if MULTI_HYP_PRED mrgCtxTmp.addHypNeighbours[uiMergeCand] = mrgCtx.addHypNeighbours[uiMergeCand]; @@ -14561,7 +15073,7 @@ void InterPrediction::updateCandInTwoCandidateGroups(MergeCtx& mrgCtx, uint32_t { mrgCtx.bcwIdx[uiMergeCand] = mrgCtx2.bcwIdx[rdCandList[uiMergeCand] - mrgCtx.numValidMergeCand]; mrgCtx.interDirNeighbours[uiMergeCand] = mrgCtx2.interDirNeighbours[rdCandList[uiMergeCand] - mrgCtx.numValidMergeCand]; - mrgCtx.mvFieldNeighbours[(uiMergeCand << 1)] = mrgCtx2.mvFieldNeighbours[((rdCandList[uiMergeCand] -mrgCtx.numValidMergeCand) << 1)]; + mrgCtx.mvFieldNeighbours[(uiMergeCand << 1)] = mrgCtx2.mvFieldNeighbours[((rdCandList[uiMergeCand] - mrgCtx.numValidMergeCand) << 1)]; mrgCtx.mvFieldNeighbours[(uiMergeCand << 1) + 1] = mrgCtx2.mvFieldNeighbours[((rdCandList[uiMergeCand] - mrgCtx.numValidMergeCand) << 1) + 1]; mrgCtx.useAltHpelIf[uiMergeCand] = mrgCtx2.useAltHpelIf[rdCandList[uiMergeCand] - mrgCtx.numValidMergeCand]; #if JVET_AG0276_NLIC @@ -14570,6 +15082,9 @@ void InterPrediction::updateCandInTwoCandidateGroups(MergeCtx& mrgCtx, uint32_t #endif #if INTER_LIC mrgCtx.licFlags[uiMergeCand] = mrgCtx2.licFlags[rdCandList[uiMergeCand] - mrgCtx.numValidMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(uiMergeCand, mrgCtx2, rdCandList[uiMergeCand] - mrgCtx.numValidMergeCand); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[uiMergeCand] = mrgCtx2.addHypNeighbours[rdCandList[uiMergeCand] - mrgCtx.numValidMergeCand]; @@ -14589,6 +15104,9 @@ void InterPrediction::updateCandInTwoCandidateGroups(MergeCtx& mrgCtx, uint32_t #endif #if INTER_LIC mrgCtx.licFlags[uiMergeCand] = mrgCtxTmp.licFlags[rdCandList[uiMergeCand]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(uiMergeCand, mrgCtxTmp, rdCandList[uiMergeCand]); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[uiMergeCand] = mrgCtxTmp.addHypNeighbours[rdCandList[uiMergeCand]]; @@ -14614,6 +15132,9 @@ void InterPrediction::updateCandInOneCandidateGroup(MergeCtx& mrgCtx, uint32_t* #endif #if INTER_LIC mrgCtxTmp.licFlags[uiMergeCand] = mrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtxTmp.copyLICParamFromCtx(uiMergeCand, mrgCtx, uiMergeCand); +#endif #endif #if MULTI_HYP_PRED mrgCtxTmp.addHypNeighbours[uiMergeCand] = mrgCtx.addHypNeighbours[uiMergeCand]; @@ -14633,6 +15154,9 @@ void InterPrediction::updateCandInOneCandidateGroup(MergeCtx& mrgCtx, uint32_t* #endif #if INTER_LIC mrgCtx.licFlags[uiMergeCand] = mrgCtxTmp.licFlags[rdCandList[uiMergeCand]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(uiMergeCand, mrgCtxTmp, rdCandList[uiMergeCand]); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[uiMergeCand] = mrgCtxTmp.addHypNeighbours[rdCandList[uiMergeCand]]; @@ -14703,25 +15227,25 @@ void InterPrediction::adjustInterMergeCandidates(PredictionUnit &pu, MergeCtx& const RefPicList eRefPicList = refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0; bRefIsRescaled |= (pu.refIdx[refList] >= 0) ? pu.cu->slice->getRefPic(eRefPicList, pu.refIdx[refList])->isRefScaled(pu.cs->pps) : false; } - if ( !bRefIsRescaled ) + if (!bRefIsRescaled) #endif { #endif - getBlkAMLRefTemplate(pu, pcBufPredRefTop, pcBufPredRefLeft); + getBlkAMLRefTemplate(pu, pcBufPredRefTop, pcBufPredRefLeft); - if (m_bAMLTemplateAvailabe[0]) - { - m_pcRdCost->setDistParam(cDistParam, pcBufPredCurTop.Y(), pcBufPredRefTop.Y(), pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y, false); + if (m_bAMLTemplateAvailabe[0]) + { + m_pcRdCost->setDistParam(cDistParam, pcBufPredCurTop.Y(), pcBufPredRefTop.Y(), pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y, false); - uiCost += cDistParam.distFunc(cDistParam); - } + uiCost += cDistParam.distFunc(cDistParam); + } - if (m_bAMLTemplateAvailabe[1]) - { - m_pcRdCost->setDistParam(cDistParam, pcBufPredCurLeft.Y(), pcBufPredRefLeft.Y(), pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y, false); + if (m_bAMLTemplateAvailabe[1]) + { + m_pcRdCost->setDistParam(cDistParam, pcBufPredCurLeft.Y(), pcBufPredRefLeft.Y(), pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y, false); - uiCost += cDistParam.distFunc(cDistParam); - } + uiCost += cDistParam.distFunc(cDistParam); + } #if JVET_Y0128_NON_CTC } #endif @@ -14779,11 +15303,11 @@ void InterPrediction::adjustMergeCandidatesInOneCandidateGroup(PredictionUnit &p #if TM_MRG if (( #if JVET_AA0132_CONFIGURABLE_TM_TOOLS - pu.cs->sps->getUseTMMrgMode() && + pu.cs->sps->getUseTMMrgMode() && #endif - pu.tmMergeFlag) || (mvpMergeCandCtx.numCandToTestEnc != mvpMergeCandCtx.numValidMergeCand && uiMergeCand > mvpMergeCandCtx.numCandToTestEnc )) + pu.tmMergeFlag) || (mvpMergeCandCtx.numCandToTestEnc != mvpMergeCandCtx.numValidMergeCand && uiMergeCand > mvpMergeCandCtx.numCandToTestEnc)) #else - if ((mvpMergeCandCtx.numCandToTestEnc != mvpMergeCandCtx.numValidMergeCand && uiMergeCand > mvpMergeCandCtx.numCandToTestEnc )) + if ((mvpMergeCandCtx.numCandToTestEnc != mvpMergeCandCtx.numValidMergeCand && uiMergeCand > mvpMergeCandCtx.numCandToTestEnc)) #endif { uiCost = mvpMergeCandCtx.candCost[uiMergeCand]; @@ -14813,17 +15337,17 @@ void InterPrediction::adjustMergeCandidatesInOneCandidateGroup(PredictionUnit &p { #endif - getBlkAMLRefTemplate(pu, pcBufPredRefTop, pcBufPredRefLeft); - if (m_bAMLTemplateAvailabe[0]) - { - m_pcRdCost->setDistParam(cDistParam, pcBufPredCurTop.Y(), pcBufPredRefTop.Y(), pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y, false); - uiCost += cDistParam.distFunc(cDistParam); - } - if (m_bAMLTemplateAvailabe[1]) - { - m_pcRdCost->setDistParam(cDistParam, pcBufPredCurLeft.Y(), pcBufPredRefLeft.Y(), pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y, false); - uiCost += cDistParam.distFunc(cDistParam); - } + getBlkAMLRefTemplate(pu, pcBufPredRefTop, pcBufPredRefLeft); + if (m_bAMLTemplateAvailabe[0]) + { + m_pcRdCost->setDistParam(cDistParam, pcBufPredCurTop.Y(), pcBufPredRefTop.Y(), pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y, false); + uiCost += cDistParam.distFunc(cDistParam); + } + if (m_bAMLTemplateAvailabe[1]) + { + m_pcRdCost->setDistParam(cDistParam, pcBufPredCurLeft.Y(), pcBufPredRefLeft.Y(), pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y, false); + uiCost += cDistParam.distFunc(cDistParam); + } #if JVET_Z0067_RPR_ENABLE } #endif @@ -14836,7 +15360,7 @@ void InterPrediction::adjustMergeCandidatesInOneCandidateGroup(PredictionUnit &p updateCandInOneCandidateGroup(mvpMergeCandCtx, rdCandList, applyBDMVR, mvBufBDMVR, mvBufBDMVRTmp, subRefineList, subRefineListTmp, numCandInCategory); } -void InterPrediction::updateCandInOneCandidateGroup(MergeCtx& mrgCtx, uint32_t* rdCandList, bool* applyBDMVR, Mv** mvBufBDMVR, Mv** mvBufBDMVRTmp, bool subRefineList[][2], bool subRefineListTmp[][2],int numCandInCategory) +void InterPrediction::updateCandInOneCandidateGroup(MergeCtx& mrgCtx, uint32_t* rdCandList, bool* applyBDMVR, Mv** mvBufBDMVR, Mv** mvBufBDMVRTmp, bool subRefineList[][2], bool subRefineListTmp[][2], int numCandInCategory) { bool applyBDMVRTmp[10]; MergeCtx mrgCtxTmp; @@ -14853,6 +15377,9 @@ void InterPrediction::updateCandInOneCandidateGroup(MergeCtx& mrgCtx, uint32_t* #endif #if INTER_LIC mrgCtxTmp.licFlags[uiMergeCand] = mrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtxTmp.copyLICParamFromCtx(uiMergeCand, mrgCtx, uiMergeCand); +#endif #endif #if MULTI_HYP_PRED mrgCtxTmp.addHypNeighbours[uiMergeCand] = mrgCtx.addHypNeighbours[uiMergeCand]; @@ -14876,6 +15403,9 @@ void InterPrediction::updateCandInOneCandidateGroup(MergeCtx& mrgCtx, uint32_t* #endif #if INTER_LIC mrgCtx.licFlags[uiMergeCand] = mrgCtxTmp.licFlags[rdCandList[uiMergeCand]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(uiMergeCand, mrgCtxTmp, rdCandList[uiMergeCand]); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[uiMergeCand] = mrgCtxTmp.addHypNeighbours[rdCandList[uiMergeCand]]; @@ -15060,6 +15590,9 @@ void InterPrediction::updateCandInfo(MergeCtx& mrgCtx, uint32_t(*RdCandList)[MR #endif #if INTER_LIC mrgCtxTmp.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtxTmp.setDefaultLICParamToCtx(ui); +#endif #endif #if MULTI_HYP_PRED mrgCtxTmp.addHypNeighbours[ui].clear(); @@ -15084,6 +15617,9 @@ void InterPrediction::updateCandInfo(MergeCtx& mrgCtx, uint32_t(*RdCandList)[MR #endif #if INTER_LIC mrgCtxTmp.licFlags[uiMergeCand] = mrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtxTmp.copyLICParamFromCtx(uiMergeCand, mrgCtx, uiMergeCand); +#endif #endif #if MULTI_HYP_PRED mrgCtxTmp.addHypNeighbours[uiMergeCand] = mrgCtx.addHypNeighbours[uiMergeCand]; @@ -15112,6 +15648,9 @@ void InterPrediction::updateCandInfo(MergeCtx& mrgCtx, uint32_t(*RdCandList)[MR #endif #if INTER_LIC mrgCtx.licFlags [uiMergeCand] = mrgCtxTmp.licFlags [srcCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(uiMergeCand, mrgCtxTmp, srcCand); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours [uiMergeCand] = mrgCtxTmp.addHypNeighbours [srcCand]; @@ -15128,6 +15667,9 @@ void InterPrediction::updateCandInfo(MergeCtx& mrgCtx, uint32_t(*RdCandList)[MR #endif #if INTER_LIC mrgCtx.licFlags[uiMergeCand] = mrgCtxTmp.licFlags[RdCandList[uiMergeCand / ADAPTIVE_SUB_GROUP_SIZE][uiMergeCand%ADAPTIVE_SUB_GROUP_SIZE]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(uiMergeCand, mrgCtxTmp, RdCandList[uiMergeCand / ADAPTIVE_SUB_GROUP_SIZE][uiMergeCand%ADAPTIVE_SUB_GROUP_SIZE]); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[uiMergeCand] = mrgCtxTmp.addHypNeighbours[RdCandList[uiMergeCand / ADAPTIVE_SUB_GROUP_SIZE][uiMergeCand%ADAPTIVE_SUB_GROUP_SIZE]]; @@ -15371,6 +15913,13 @@ void InterPrediction::getBlkAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf const int lumaShift = 2 + MV_FRACTIONAL_BITS_DIFF; const int horShift = (lumaShift + ::getComponentScaleX(COMPONENT_Y, pu.chromaFormat)); const int verShift = (lumaShift + ::getComponentScaleY(COMPONENT_Y, pu.chromaFormat)); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + CHECK(!pu.cu->licFlag, ""); + pu.cu->licFlag = false; + } +#endif #if JVET_AA0093_ENHANCED_MMVD_EXTENSION if (!bLoadSave && xCheckIdenticalMotion(pu)) @@ -15378,6 +15927,9 @@ void InterPrediction::getBlkAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf if (xCheckIdenticalMotion(pu)) #endif { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + m_iRefListIdx = 0; +#endif mvCurr = pu.mv[0]; /*const int horIntMv = (mvCurr.getHor() + ((1 << horShift) >> 1)) >> horShift; const int verIntMv = (mvCurr.getVer() + ((1 << verShift) >> 1)) >> verShift; @@ -15466,6 +16018,20 @@ void InterPrediction::getBlkAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf } #endif } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + const ClpRng& clpRng = pu.cu->slice->clpRng(COMPONENT_Y); + if (m_bAMLTemplateAvailabe[0]) + { + pcBufPredRefTop.Y().linearTransform(pu.cu->licScale[REF_PIC_LIST_0][0], m_LICShift, pu.cu->licOffset[REF_PIC_LIST_0][0], true, clpRng); + } + if (m_bAMLTemplateAvailabe[1]) + { + pcBufPredRefLeft.Y().linearTransform(pu.cu->licScale[REF_PIC_LIST_0][0], m_LICShift, pu.cu->licOffset[REF_PIC_LIST_0][0], true, clpRng); + } + } +#endif } else { @@ -15531,6 +16097,15 @@ void InterPrediction::getBlkAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf xPredInterBlk( COMPONENT_Y, pu, pu.cu->slice->getRefPic( eRefPicList, pu.refIdx[refList] ), mvTop, pcMbBuf, true, pu.cu->slice->clpRng( COMPONENT_Y ), false, false, SCALE_1X, 0, 0, false, NULL, 0, true ); #endif +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + const ClpRng& clpRng = pu.cu->slice->clpRng(COMPONENT_Y); + pcMbBuf.Y().toLast(clpRng); + pcMbBuf.Y().linearTransform(pu.cu->licScale[refList][0], m_LICShift, pu.cu->licOffset[refList][0], true, clpRng); + pcMbBuf.Y().linearTransform(1, -biShift, biOffset, false, clpRng); + } #endif } else @@ -15553,6 +16128,13 @@ void InterPrediction::getBlkAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf xPredInterBlk( COMPONENT_Y, pu, pu.cu->slice->getRefPic( eRefPicList, pu.refIdx[refList] ), mvTop, pcMbBuf, false, pu.cu->slice->clpRng( COMPONENT_Y ), false, false, SCALE_1X, 0, 0, false, NULL, 0, true ); #endif +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + const ClpRng& clpRng = pu.cu->slice->clpRng(COMPONENT_Y); + pcMbBuf.Y().linearTransform(pu.cu->licScale[refList][0], m_LICShift, pu.cu->licOffset[refList][0], true, clpRng); + } #endif } #if JVET_AG0276_NLIC @@ -15596,6 +16178,15 @@ void InterPrediction::getBlkAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(eRefPicList, pu.refIdx[refList]), mvLeft, pcMbBuf, true, pu.cu->slice->clpRng(COMPONENT_Y), false, false, SCALE_1X, 0, 0, false, NULL, 0, true); #endif +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + const ClpRng& clpRng = pu.cu->slice->clpRng(COMPONENT_Y); + pcMbBuf.Y().toLast(clpRng); + pcMbBuf.Y().linearTransform(pu.cu->licScale[refList][0], m_LICShift, pu.cu->licOffset[refList][0], true, clpRng); + pcMbBuf.Y().linearTransform(1, -biShift, biOffset, false, clpRng); + } #endif } else @@ -15618,6 +16209,13 @@ void InterPrediction::getBlkAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf xPredInterBlk( COMPONENT_Y, pu, pu.cu->slice->getRefPic( eRefPicList, pu.refIdx[refList] ), mvLeft, pcMbBuf, false, pu.cu->slice->clpRng( COMPONENT_Y ), false, false, SCALE_1X, 0, 0, false, NULL, 0, true ); #endif +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + const ClpRng& clpRng = pu.cu->slice->clpRng(COMPONENT_Y); + pcMbBuf.Y().linearTransform(pu.cu->licScale[refList][0], m_LICShift, pu.cu->licOffset[refList][0], true, clpRng); + } #endif } #if JVET_AG0276_NLIC @@ -15749,6 +16347,12 @@ void InterPrediction::getBlkAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf } #endif } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + pu.cu->licFlag = true; + } +#endif } #if JVET_AD0213_LIC_IMP void InterPrediction::getBlkAMLRefTemplateAlt(PredictionUnit &pu, PelUnitBuf &pcBufPredRefTop, PelUnitBuf &pcBufPredRefLeft, int8_t posList0, int8_t posList1, bool load0, bool load1) @@ -15761,6 +16365,13 @@ void InterPrediction::getBlkAMLRefTemplateAlt(PredictionUnit &pu, PelUnitBuf &pc const int verShift = (lumaShift + ::getComponentScaleY(COMPONENT_Y, pu.chromaFormat)); CHECK(pu.refIdx[REF_PIC_LIST_0] < 0 || pu.refIdx[REF_PIC_LIST_1] < 0, "the function only deals with MMVD bi-pred reordering"); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + CHECK(!pu.cu->licFlag, ""); + pu.cu->licFlag = false; + } +#endif PelUnitBuf pcBufPredRefLeftTranspose = PelUnitBuf(pu.chromaFormat, PelBuf(pcBufPredRefLeft.Y().buf, pcBufPredRefLeft.Y().height, pcBufPredRefLeft.Y().width)); @@ -15805,6 +16416,15 @@ void InterPrediction::getBlkAMLRefTemplateAlt(PredictionUnit &pu, PelUnitBuf &pc #else xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(eRefPicList, pu.refIdx[refList]), mvTop, pcMbBuf, true, pu.cu->slice->clpRng(COMPONENT_Y), false, false, SCALE_1X, 0, 0, false, NULL, 0, true, true, mvCurr); #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + const ClpRng& clpRng = pu.cu->slice->clpRng(COMPONENT_Y); + pcMbBuf.Y().toLast(clpRng); + pcMbBuf.Y().linearTransform(pu.cu->licScale[refList][0], m_LICShift, pu.cu->licOffset[refList][0], true, clpRng); + pcMbBuf.Y().linearTransform(1, -biShift, biOffset, false, clpRng); + } +#endif #if JVET_AG0276_NLIC if (m_bAMLTemplateAvailabe[1]) { @@ -15838,6 +16458,15 @@ void InterPrediction::getBlkAMLRefTemplateAlt(PredictionUnit &pu, PelUnitBuf &pc #else xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(eRefPicList, pu.refIdx[refList]), mvLeft, pcMbBuf, true, pu.cu->slice->clpRng(COMPONENT_Y), false, false, SCALE_1X, 0, 0, false, NULL, 0, true, true, mvCurr); #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + const ClpRng& clpRng = pu.cu->slice->clpRng(COMPONENT_Y); + pcMbBuf.Y().toLast(clpRng); + pcMbBuf.Y().linearTransform(pu.cu->licScale[refList][0], m_LICShift, pu.cu->licOffset[refList][0], true, clpRng); + pcMbBuf.Y().linearTransform(1, -biShift, biOffset, false, clpRng); + } +#endif #if JVET_AG0276_NLIC m_skipDoLic = false; #endif @@ -15881,6 +16510,12 @@ void InterPrediction::getBlkAMLRefTemplateAlt(PredictionUnit &pu, PelUnitBuf &pc } #endif } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (pu.cu->licInheritPara) + { + pu.cu->licFlag = true; + } +#endif } #endif #endif @@ -15968,6 +16603,9 @@ void InterPrediction::adjustAffineMergeCandidates(PredictionUnit &pu, AffineMer #endif #if INTER_LIC pu.cu->licFlag = affMrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setLICParamToPu(pu, uiMergeCand, pu.cu->licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL pu.cu->obmcFlag = affMrgCtx.obmcFlags[uiMergeCand]; @@ -16177,6 +16815,9 @@ void InterPrediction::updateAffineCandInfo(PredictionUnit &pu, AffineMergeCtx& #endif #if INTER_LIC affMrgCtxTmp.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtxTmp.setDefaultLICParamToCtx(i); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtxTmp.obmcFlags[i] = true; @@ -16208,6 +16849,9 @@ void InterPrediction::updateAffineCandInfo(PredictionUnit &pu, AffineMergeCtx& #endif #if INTER_LIC affMrgCtxTmp.licFlags[uiMergeCand] = affMrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtxTmp.copyLICParamFromCtx(uiMergeCand, affMrgCtx, uiMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtxTmp.obmcFlags[uiMergeCand] = affMrgCtx.obmcFlags[uiMergeCand]; @@ -16248,6 +16892,9 @@ void InterPrediction::updateAffineCandInfo(PredictionUnit &pu, AffineMergeCtx& #endif #if INTER_LIC affMrgCtx.licFlags[uiMergeCand] = affMrgCtxTmp.licFlags[srcCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.copyLICParamFromCtx(uiMergeCand, affMrgCtxTmp, srcCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[uiMergeCand] = affMrgCtxTmp.obmcFlags[srcCand]; @@ -16271,6 +16918,9 @@ void InterPrediction::updateAffineCandInfo(PredictionUnit &pu, AffineMergeCtx& #endif #if INTER_LIC affMrgCtx.licFlags[uiMergeCand] = affMrgCtxTmp.licFlags[RdCandList[uiMergeCand / ADAPTIVE_AFFINE_SUB_GROUP_SIZE][uiMergeCand%ADAPTIVE_AFFINE_SUB_GROUP_SIZE]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.copyLICParamFromCtx(uiMergeCand, affMrgCtxTmp, RdCandList[uiMergeCand / ADAPTIVE_AFFINE_SUB_GROUP_SIZE][uiMergeCand%ADAPTIVE_AFFINE_SUB_GROUP_SIZE]); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[uiMergeCand] = affMrgCtxTmp.obmcFlags[RdCandList[uiMergeCand / ADAPTIVE_AFFINE_SUB_GROUP_SIZE][uiMergeCand % ADAPTIVE_AFFINE_SUB_GROUP_SIZE]]; @@ -16407,6 +17057,9 @@ void InterPrediction::adjustAffineMergeCandidates(PredictionUnit &pu, AffineMerg #endif #if INTER_LIC pu.cu->licFlag = affMrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setLICParamToPu(pu, uiMergeCand, pu.cu->licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL pu.cu->obmcFlag = affMrgCtx.obmcFlags[uiMergeCand]; @@ -16528,6 +17181,9 @@ void InterPrediction::adjustAffineMergeCandidates(PredictionUnit &pu, AffineMerg pu.cu->altLMParaUnit = altLMRMVFCand.altLMParaNeighbours[uiMergeCand]; #if INTER_LIC pu.cu->licFlag = altLMRMVFCand.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + altLMRMVFCand.setLICParamToPu(pu, uiMergeCand, pu.cu->licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL pu.cu->obmcFlag = altLMRMVFCand.obmcFlags[uiMergeCand]; @@ -16630,6 +17286,9 @@ void InterPrediction::adjustAffineMergeCandidates(PredictionUnit &pu, AffineMerg pu.cu->altLMParaUnit = altLMAffMergeCand.altLMParaNeighbours[uiMergeCand]; #if INTER_LIC pu.cu->licFlag = altLMAffMergeCand.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + altLMAffMergeCand.setLICParamToPu(pu, uiMergeCand, pu.cu->licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL pu.cu->obmcFlag = altLMAffMergeCand.obmcFlags[uiMergeCand]; @@ -16796,6 +17455,9 @@ void InterPrediction::updateAffineCandInThreeGrp(PredictionUnit &pu, AffineMerge affMrgCtxTmp.altLMParaNeighbours[uiMergeCand] = affMrgCtx.altLMParaNeighbours[uiMergeCand]; #if INTER_LIC affMrgCtxTmp.licFlags[uiMergeCand] = affMrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtxTmp.copyLICParamFromCtx(uiMergeCand, affMrgCtx, uiMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtxTmp.obmcFlags[uiMergeCand] = affMrgCtx.obmcFlags[uiMergeCand]; @@ -16822,6 +17484,9 @@ void InterPrediction::updateAffineCandInThreeGrp(PredictionUnit &pu, AffineMerge affMrgCtx.altLMParaNeighbours[uiMergeCand] = affMrgCtxTmp.altLMParaNeighbours[rdCandList[uiMergeCand]]; #if INTER_LIC affMrgCtx.licFlags[uiMergeCand] = affMrgCtxTmp.licFlags[rdCandList[uiMergeCand]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.copyLICParamFromCtx(uiMergeCand, affMrgCtxTmp, rdCandList[uiMergeCand]); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[uiMergeCand] = affMrgCtxTmp.obmcFlags[rdCandList[uiMergeCand]]; @@ -16845,6 +17510,9 @@ void InterPrediction::updateAffineCandInThreeGrp(PredictionUnit &pu, AffineMerge affMrgCtx.altLMParaNeighbours[uiMergeCand] = altLMAffMrgCtx1.altLMParaNeighbours[rdCandList[uiMergeCand]]; #if INTER_LIC affMrgCtx.licFlags[uiMergeCand] = altLMAffMrgCtx1.licFlags[rdCandList[uiMergeCand]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.copyLICParamFromCtx(uiMergeCand, altLMAffMrgCtx1, rdCandList[uiMergeCand]); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[uiMergeCand] = altLMAffMrgCtx1.obmcFlags[rdCandList[uiMergeCand]]; @@ -16868,6 +17536,9 @@ void InterPrediction::updateAffineCandInThreeGrp(PredictionUnit &pu, AffineMerge affMrgCtx.altLMParaNeighbours[uiMergeCand] = altLMAffMrgCtx.altLMParaNeighbours[rdCandList[uiMergeCand]]; #if INTER_LIC affMrgCtx.licFlags[uiMergeCand] = altLMAffMrgCtx.licFlags[rdCandList[uiMergeCand]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.copyLICParamFromCtx(uiMergeCand, altLMAffMrgCtx, rdCandList[uiMergeCand]); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[uiMergeCand] = altLMAffMrgCtx.obmcFlags[rdCandList[uiMergeCand]]; @@ -17186,6 +17857,19 @@ void InterPrediction::getAffAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf int LICshift[2] = { 0 }; int scale[2] = { 0 }; int offset[2] = { 0 }; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + if (pu.cu->licInheritPara) + { + CHECK(!pu.cu->licFlag, "LIC flag must be set when inherited LIC mode is used"); + pu.cu->licFlag = false; + LICshift[0] = m_LICShift; + scale [0] = pu.cu->licScale [0][0]; + offset [0] = pu.cu->licOffset[0][0]; + LICshift[1] = m_LICShift; + scale [1] = pu.cu->licScale [1][0]; + offset [1] = pu.cu->licOffset[1][0]; + } +#endif #endif const int bitDepth = pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA); #if JVET_AA0093_ENHANCED_MMVD_EXTENSION @@ -17194,6 +17878,9 @@ void InterPrediction::getAffAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf if (xCheckIdenticalMotion(pu)) #endif { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + m_iRefListIdx = 0; +#endif Pel * refLeftTemplate = m_acYuvRefAMLTemplate[1][0]; Pel * refAboveTemplate = m_acYuvRefAMLTemplate[0][0]; int numTemplate[2] = { 0, 0 }; // 0:Above, 1:Left @@ -17220,12 +17907,23 @@ void InterPrediction::getAffAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf } #endif #if INTER_LIC - if (pu.cu->licFlag) + if (pu.cu->licFlag +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + || pu.cu->licInheritPara +#endif + ) { Pel *recLeftTemplate = m_acYuvCurAMLTemplate[1][0]; Pel *recAboveTemplate = m_acYuvCurAMLTemplate[0][0]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + if (pu.cu->licFlag) + { +#endif xGetLICParamGeneral(*pu.cu, COMPONENT_Y, numTemplate, refLeftTemplate, refAboveTemplate, recLeftTemplate, recAboveTemplate, LICshift[0], scale[0], offset[0]); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + } +#endif if (m_bAMLTemplateAvailabe[0]) { PelBuf & dstBuf = pcBufPredRefTop.bufs[0]; @@ -17409,6 +18107,12 @@ void InterPrediction::getAffAMLRefTemplate(PredictionUnit &pu, PelUnitBuf &pcBuf LICshift[refList] = m_shift[refList][0]; } } +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + if (pu.cu->licInheritPara) + { + pu.cu->licFlag = true; + } #endif if (m_bAMLTemplateAvailabe[0]) { @@ -17567,6 +18271,19 @@ void InterPrediction::getAffAMLRefTemplateAlt(PredictionUnit &pu, PelUnitBuf &pc int licShift[2] = { 0 }; int scale[2] = { 0 }; int offset[2] = { 0 }; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + if (pu.cu->licInheritPara) + { + CHECK(!pu.cu->licFlag, "LCI flag must be set when inherited LIC mode is used"); + pu.cu->licFlag = false; + licShift[0] = m_LICShift; + scale[0] = pu.cu->licScale[0][0]; + offset[0] = pu.cu->licOffset[0][0]; + licShift[1] = m_LICShift; + scale[1] = pu.cu->licScale[1][0]; + offset[1] = pu.cu->licOffset[1][0]; + } +#endif const int bitDepth = pu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA); const ClpRng &clpRng = pu.cu->cs->slice->clpRng(COMPONENT_Y); const int biShift = IF_INTERNAL_PREC - bitDepth; @@ -17609,12 +18326,23 @@ void InterPrediction::getAffAMLRefTemplateAlt(PredictionUnit &pu, PelUnitBuf &pc #endif ); #if INTER_LIC - if (pu.cu->licFlag) + if (pu.cu->licFlag +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + || pu.cu->licInheritPara +#endif + ) { Pel *recLeftTemplate = m_acYuvCurAMLTemplate[1][0]; Pel *recAboveTemplate = m_acYuvCurAMLTemplate[0][0]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + if (pu.cu->licFlag) + { +#endif xGetLICParamGeneral(*pu.cu, COMPONENT_Y, numTemplate, refLeftTemplate, refAboveTemplate, recLeftTemplate, recAboveTemplate, licShift[refList], scale[refList], offset[refList]); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + } +#endif if (m_bAMLTemplateAvailabe[0]) { srcAbovePred.bufs[0].linearTransform(scale[refList], licShift[refList], offset[refList], true, clpRng); @@ -17634,6 +18362,12 @@ void InterPrediction::getAffAMLRefTemplateAlt(PredictionUnit &pu, PelUnitBuf &pc srcLeftPred.bufs[0].linearTransform(1, -biShift, biOffset, false, clpRngDummy); } } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + if (pu.cu->licInheritPara) + { + pu.cu->licFlag = true; + } +#endif if (m_bAMLTemplateAvailabe[0]) { PelUnitBuf srcPred[2]; @@ -17773,6 +18507,9 @@ void InterPrediction::updateIBCCandInfo(PredictionUnit &pu, MergeCtx& mrgCtx, u #endif #if INTER_LIC mrgCtxTmp.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtxTmp.setDefaultLICParamToCtx(ui); +#endif #endif #if JVET_AC0112_IBC_LIC mrgCtxTmp.ibcLicFlags[ui] = false; @@ -17989,6 +18726,9 @@ void InterPrediction::adjustAffineMergeCandidatesOneGroup(PredictionUnit &pu, A #endif #if INTER_LIC pu.cu->licFlag = affMrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setLICParamToPu(pu, uiMergeCand, pu.cu->licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL pu.cu->obmcFlag = affMrgCtx.obmcFlags[uiMergeCand]; @@ -18094,6 +18834,9 @@ void InterPrediction::updateAffineCandInfo2(PredictionUnit &pu, AffineMergeCtx& #endif #if INTER_LIC affMrgCtxTmp.licFlags[uiMergeCand] = affMrgCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtxTmp.copyLICParamFromCtx(uiMergeCand, affMrgCtx, uiMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtxTmp.obmcFlags[uiMergeCand] = affMrgCtx.obmcFlags[uiMergeCand]; @@ -18117,6 +18860,9 @@ void InterPrediction::updateAffineCandInfo2(PredictionUnit &pu, AffineMergeCtx& #endif #if INTER_LIC affMrgCtx.licFlags[uiMergeCand] = affMrgCtxTmp.licFlags[rdCandList[uiMergeCand / listsize][uiMergeCand%listsize]]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.copyLICParamFromCtx(uiMergeCand, affMrgCtxTmp, rdCandList[uiMergeCand / listsize][uiMergeCand%listsize]); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[uiMergeCand] = affMrgCtxTmp.obmcFlags[rdCandList[uiMergeCand / listsize][uiMergeCand % listsize]]; @@ -18143,6 +18889,9 @@ void InterPrediction::updateIBCCandInfo( PredictionUnit &pu, MergeCtx& mrgCtx, #endif #if INTER_LIC mrgCtxTmp.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtxTmp.setDefaultLICParamToCtx(ui); +#endif #endif #if JVET_AC0112_IBC_LIC mrgCtxTmp.ibcLicFlags[ui] = false; @@ -18340,11 +19089,26 @@ int InterPrediction::selectOBMCmode(PredictionUnit &pu, PredictionUnit &subblock subblockPu.cu->bcwIdx = tmpPu->cu->bcwIdx; for (int refList = 0; refList < 2; refList++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (tmpPu->interDir & (refList + 1)) + { +#endif for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) { subblockPu.cu->licScale[refList][comp] = tmpPu->cu->licScale[refList][comp]; subblockPu.cu->licOffset[refList][comp] = tmpPu->cu->licOffset[refList][comp]; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } + else + { + for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) + { + subblockPu.cu->licScale[refList][comp] = 32; + subblockPu.cu->licOffset[refList][comp] = 0; + } + } +#endif } #endif getBlkOBMCRefTemplate(subblockPu, pcBufPredRefTop1, isAbove, neigMi); @@ -18426,11 +19190,26 @@ int InterPrediction::selectOBMCmode(PredictionUnit &pu, PredictionUnit &subblock subblockPu.cu->bcwIdx = tmpPu->cu->bcwIdx; for (int refList = 0; refList < 2; refList++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (tmpPu->interDir & (refList + 1)) + { +#endif for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) { subblockPu.cu->licScale[refList][comp] = tmpPu->cu->licScale[refList][comp]; subblockPu.cu->licOffset[refList][comp] = tmpPu->cu->licOffset[refList][comp]; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } + else + { + for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) + { + subblockPu.cu->licScale[refList][comp] = 32; + subblockPu.cu->licOffset[refList][comp] = 0; + } + } +#endif } #endif getBlkOBMCRefTemplate(subblockPu, pcBufPredRefLeft1, isAbove, neigMi); @@ -20146,9 +20925,29 @@ void InterPrediction::xLicCompAdj(const PredictionUnit& pu, PelUnitBuf& pcYuvPre } else if (pu.cu->licFlag && !(pu.ciipFlag && !(((slice.getPOC() - slice.getRefPOC(REF_PIC_LIST_0, 0)) == 1) && slice.getCheckLDC())) && pu.refIdx[0] >= 0 && pu.refIdx[1] >= 0) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool useInheritedMode = pu.cu->licInheritPara || pu.cu->geoFlag; +#endif + #if !JVET_AF0190_RPR_TMP_REORDER_LIC if (!pu.cs->sps->getRprEnabledFlag()) { +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(useInheritedMode) + { + for (uint32_t refList = 0; refList < 2; refList++) + { + for (int compID = 0; compID < MAX_NUM_COMPONENT; compID++) + { + m_scale [refList][compID] = pu.cu->licScale[refList][compID]; + m_offset[refList][compID] = pu.cu->licOffset[refList][compID]; + m_shift [refList][compID] = m_LICShift; + } + } + } + else + { #endif for (uint32_t licIdx = 0; licIdx < NUM_LIC_ITERATION; licIdx++) { @@ -20192,6 +20991,9 @@ void InterPrediction::xLicCompAdj(const PredictionUnit& pu, PelUnitBuf& pcYuvPre } } } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } +#endif const Pel biOffset = -IF_INTERNAL_OFFS; for (int refList = 0; refList < NUM_REF_PIC_LIST_01; refList++) @@ -20209,11 +21011,18 @@ void InterPrediction::xLicCompAdj(const PredictionUnit& pu, PelUnitBuf& pcYuvPre continue; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (!useInheritedMode) // Note: for LIC inheritance mode, linearTransform has been done at the end of xPredInterBlk and thus it can be bypassed here. However, linearTransform is not performed at xPredInterBlk when LIC-BDOF condition is true, and has to be performed at xLicCompAdjBdof + { +#endif const ClpRng& clpRng = pu.cu->slice->clpRng(ComponentID(compID)); const int biShift = IF_INTERNAL_PREC - clpRng.bd; curSrcPred.bufs[compID].toLast(clpRng); curSrcPred.bufs[compID].linearTransform(m_scale[refList][compID], m_shift[refList][compID], m_offset[refList][compID], true, clpRng); curSrcPred.bufs[compID].linearTransform(1, -biShift, biOffset, false, clpRng); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } +#endif } } #if !JVET_AF0190_RPR_TMP_REORDER_LIC @@ -20224,6 +21033,26 @@ void InterPrediction::xLicCompAdj(const PredictionUnit& pu, PelUnitBuf& pcYuvPre #if JVET_AG0276_LIC_BDOF_BDMVR void InterPrediction::xLicCompAdjBdof(const PredictionUnit& pu, PelUnitBuf& pcYuvPred, const bool lumaOnly, const bool chromaOnly) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool useInheritedMode = pu.cu->licInheritPara || pu.cu->geoFlag; +#endif + +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (useInheritedMode) + { + for (uint32_t refList = 0; refList < 2; refList++) + { + for (int compID = 0; compID < MAX_NUM_COMPONENT; compID++) + { + m_scale [refList][compID] = pu.cu->licScale[refList][compID]; + m_offset[refList][compID] = pu.cu->licOffset[refList][compID]; + m_shift [refList][compID] = m_LICShift; + } + } + } + else + { +#endif for (uint32_t licIdx = 0; licIdx < NUM_LIC_ITERATION; licIdx++) { int licRefList = (licIdx % 2); @@ -20264,6 +21093,9 @@ void InterPrediction::xLicCompAdjBdof(const PredictionUnit& pu, PelUnitBuf& pcYu } } } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } +#endif const Pel biOffset = -IF_INTERNAL_OFFS; for (int refList = 0; refList < NUM_REF_PIC_LIST_01; refList++) @@ -21500,7 +22332,14 @@ void InterPrediction::deriveTemplateLIC(TplMatchingCtrl& tplCtrl, RefPicList eRe const CodingUnit& cu = tplCtrl.m_cu; const PredictionUnit& pu = tplCtrl.m_pu; Mv mv = tplCtrl.getFinalMv(); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool licParamExists = pu.cu->geoFlag; +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (!licParamExists) + { +#endif m_numTemplate[COMPONENT_Y][0] = m_numTemplate[COMPONENT_Y][1] = 0; clipMv(mv, pu.lumaPos(), pu.lumaSize(), *pu.cs->sps, *pu.cs->pps); #if JVET_AF0190_RPR_TMP_REORDER_LIC @@ -21509,7 +22348,22 @@ void InterPrediction::deriveTemplateLIC(TplMatchingCtrl& tplCtrl, RefPicList eRe xGetSublkTemplate(cu, COMPONENT_Y, tplCtrl.m_refPic, mv, pu.blocks[COMPONENT_Y].width, pu.blocks[COMPONENT_Y].height, 0, 0, m_numTemplate[COMPONENT_Y], refLeftTemplate, refAboveTemplate, recLeftTemplate, recAboveTemplate); m_fillLicTpl[COMPONENT_Y] = true; xGetLICParamGeneral(*pu.cu, COMPONENT_Y, m_numTemplate[COMPONENT_Y], refLeftTemplate, refAboveTemplate, recLeftTemplate, recAboveTemplate, m_shift[eRefList][COMPONENT_Y], m_scale[eRefList][COMPONENT_Y], m_offset[eRefList][COMPONENT_Y]); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (licParamExists && m_scale[eRefList][COMPONENT_Y] != 0) // When scale!=0, current template has been modified by TplMatchingCtrl::inverseCurTemplateLIC, and thus cannot be used to compute LIC error if curTpl is not going to be re-filled + { +#if JVET_AG0276_LIC_SLOPE_ADJUST + tplCtrl.m_minCost = (tplCtrl.m_minCost * abs(m_scale[eRefList][COMPONENT_Y]) + ((Distortion)1 << (m_shift[eRefList][COMPONENT_Y] - 1))) >> m_shift[eRefList][COMPONENT_Y]; +#else + CHECK(m_scale[eRefList][COMPONENT_Y] < 0, "Invalid scale of LIC"); + tplCtrl.m_minCost = (tplCtrl.m_minCost * m_scale[eRefList][COMPONENT_Y] + ((Distortion)1 << (m_shift[eRefList][COMPONENT_Y] - 1))) >> m_shift[eRefList][COMPONENT_Y]; +#endif + return; + } +#endif #if JVET_AA0093_REFINED_MOTION_FOR_ARMC tplCtrl.m_minCost = tplCtrl.xGetTempMatchLICError<tplSize>(mv, m_shift[eRefList][COMPONENT_Y], m_scale[eRefList][COMPONENT_Y], m_offset[eRefList][COMPONENT_Y]); #else @@ -21551,9 +22405,27 @@ Distortion InterPrediction::deriveTMMv(const PredictionUnit& pu, bool fillCurTpl { return std::numeric_limits<Distortion>::max(); } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool licParamExists = pu.cu->licFlag && pu.cu->geoFlag; + if (licParamExists) + { + m_scale [eRefList][COMPONENT_Y] = pu.cu->licScale [eRefList][COMPONENT_Y]; + m_offset[eRefList][COMPONENT_Y] = pu.cu->licOffset[eRefList][COMPONENT_Y]; + m_shift [eRefList][COMPONENT_Y] = m_LICShift; + } +#endif if (otherMvf == nullptr) // uni prediction { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG // remove LIC model + if (!licParamExists || (licParamExists && m_scale[eRefList][COMPONENT_Y] != 0)) + { + if (licParamExists) + { + pu.cu->licFlag = false; + tplCtrl.inverseCurTemplateLIC(m_shift[eRefList][COMPONENT_Y], m_scale[eRefList][COMPONENT_Y], m_offset[eRefList][COMPONENT_Y]); + } +#endif #if TM_MRG && JVET_AA0093_REFINED_MOTION_FOR_ARMC if (pu.reduceTplSize && pu.tmMergeFlag #if JVET_AA0132_CONFIGURABLE_TM_TOOLS @@ -21569,6 +22441,12 @@ Distortion InterPrediction::deriveTMMv(const PredictionUnit& pu, bool fillCurTpl tplCtrl.deriveMvUni<TM_TPL_SIZE>(); #if TM_MRG && JVET_AA0093_REFINED_MOTION_FOR_ARMC } +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG // recover LIC flag + pu.cu->licFlag = licParamExists ? true : pu.cu->licFlag; #endif mv = tplCtrl.getFinalMv(); #if JVET_AD0213_LIC_IMP @@ -21618,7 +22496,19 @@ Distortion InterPrediction::deriveTMMv(const PredictionUnit& pu, bool fillCurTpl else #endif tplCtrl.removeHighFreq<1>(otherRefPic, otherMvf->mv, getBcwWeight(cu.bcwIdx, eRefList)); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG // remove LIC model (tpl=1) + if (!licParamExists || (licParamExists && m_scale[eRefList][COMPONENT_Y] != 0)) + { + if (licParamExists) + { + pu.cu->licFlag = false; + tplCtrl.inverseCurTemplateLIC(m_shift[eRefList][COMPONENT_Y], m_scale[eRefList][COMPONENT_Y], m_offset[eRefList][COMPONENT_Y]); + } +#endif tplCtrl.deriveMvUni<1>(); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } +#endif } else { @@ -21631,9 +22521,24 @@ Distortion InterPrediction::deriveTMMv(const PredictionUnit& pu, bool fillCurTpl else #endif tplCtrl.removeHighFreq<TM_TPL_SIZE>(otherRefPic, otherMvf->mv, getBcwWeight(cu.bcwIdx, eRefList)); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG // remove LIC model (tpl=4) + if (!licParamExists || (licParamExists && m_scale[eRefList][COMPONENT_Y] != 0)) + { + if (licParamExists) + { + pu.cu->licFlag = false; + tplCtrl.inverseCurTemplateLIC(m_shift[eRefList][COMPONENT_Y], m_scale[eRefList][COMPONENT_Y], m_offset[eRefList][COMPONENT_Y]); + } +#endif tplCtrl.deriveMvUni<TM_TPL_SIZE>(); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } +#endif #if TM_MRG && JVET_AA0093_REFINED_MOTION_FOR_ARMC } +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG // recover LIC flag + pu.cu->licFlag = licParamExists ? true : pu.cu->licFlag; #endif mv = tplCtrl.getFinalMv(); #if JVET_AD0213_LIC_IMP @@ -22155,6 +23060,28 @@ void TplMatchingCtrl::removeHighFreqLIC(const Picture& otherRefPic, const Mv& ot } #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG // Function: inverseCurTemplateLIC +void TplMatchingCtrl::inverseCurTemplateLIC(int shift, int scale, int offset) +{ + CHECK(scale == 0, "Scale cannot be zero"); + + // cur - scale * pred / 32 - offset => [ ( 32 * N/scale ) * cur / N + ( 32 * N/scale ) * (-offset) / N ] - pred = invScale * cur / N + invOffset - pred + const int invShift = 16; + int invScale = ((1 << (shift + invShift)) + (scale > 0 ? (scale >> 1) : -(scale >> 1))) / scale; + int invOffset = ((-offset * invScale) + (1 << (invShift - 1))) >> invShift; + + for (int isLeftTpl = 0; isLeftTpl <= 1; ++isLeftTpl) + { + PelBuf& curTplBuf = isLeftTpl == 0 ? m_curTplAbove : m_curTplLeft; + if (curTplBuf.buf != nullptr) + { + const ClpRng& clpRng = m_cu.cs->slice->clpRng(COMPONENT_Y); + curTplBuf.linearTransform(invScale, invShift, invOffset, false, clpRng); + } + } +} +#endif + template <int tplSize, bool trueAfalseL> bool TplMatchingCtrl::xFillCurTemplate(Pel* tpl) { @@ -24123,7 +25050,6 @@ void InterPrediction::bmAffineIntSearch(const PredictionUnit &pu, Mv(&mvOffset)[ for (int list = 0; list < 2; list++) { mvInitial[list] = it->m_mv[list]; - xBDMVRFillBlkPredPelBuffer(subPu, *m_bmRefPic[list], mvInitial[list] - mvPreInterOffset, predBuf[list], pu.cs->slice->clpRng(COMPONENT_Y)); //bi-linear interpolation } Distortion currSubBlkCost; @@ -27582,6 +28508,9 @@ void InterPrediction::xAddHypMC(PredictionUnit& pu, PelUnitBuf& predBuf, PelUnit #endif #if INTER_LIC auto savedLICFlag = pu.cu->licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + auto savedLICInheritePara = pu.cu->licInheritPara; +#endif #endif MultiHypVec savedHypVec = pu.addHypData; pu.addHypData.clear(); @@ -27622,6 +28551,9 @@ void InterPrediction::xAddHypMC(PredictionUnit& pu, PelUnitBuf& predBuf, PelUnit #endif #if INTER_LIC fakePredData.cu->licFlag = mhData.licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + fakePredData.cu->licInheritPara = false; +#endif #if JVET_AD0213_LIC_IMP m_isAddHypMC = true; #endif @@ -27643,6 +28575,9 @@ void InterPrediction::xAddHypMC(PredictionUnit& pu, PelUnitBuf& predBuf, PelUnit #endif #if INTER_LIC pu.cu->licFlag = savedLICFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pu.cu->licInheritPara = savedLICInheritePara; +#endif #endif pu.cu->imv = savedIMV; pu.cu->affine = savedAffine; @@ -27825,6 +28760,9 @@ void InterPrediction::getAmvpMergeModeMergeList(PredictionUnit& pu, MvField* mvF bmMergeCtx.useAltHpelIf[mergeIdx] = false; bmMergeCtx.addHypNeighbours[mergeIdx].clear(); bmMergeCtx.candCost[mergeIdx] = MAX_UINT64; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bmMergeCtx.setDefaultLICParamToCtx(mergeIdx); +#endif } PredictionUnit tmpPU = pu; adjustMergeCandidatesInOneCandidateGroup(tmpPU, bmMergeCtx, bmMergeCtx.numValidMergeCand); @@ -27834,6 +28772,9 @@ void InterPrediction::getAmvpMergeModeMergeList(PredictionUnit& pu, MvField* mvF #endif pu.cu->licFlag = bmMergeCtx.licFlags[0]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bmMergeCtx.setLICParamToPu(pu, 0, bmMergeCtx.licInheritPara[0]); +#endif if (bmMergeCtx.licFlags[0]) { pu.mv[refListAmvp] = amvpLicInfo.mvCand[bestMvpIdxToTest]; @@ -27871,6 +28812,9 @@ void InterPrediction::getAmvpMergeModeMergeList(PredictionUnit& pu, MvField* mvF else { pu.cu->licFlag = bmMergeCtx.licFlags[1]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bmMergeCtx.setLICParamToPu(pu, 1, bmMergeCtx.licInheritPara[1]); +#endif if (bmMergeCtx.licFlags[1]) { pu.mv[refListAmvp] = amvpLicInfo.mvCand[bestMvpIdxToTest]; diff --git a/source/Lib/CommonLib/InterPrediction.h b/source/Lib/CommonLib/InterPrediction.h index 8a7352e0ca0fbe63a6f46568ee257b69a2021012..ff4a13a22169c01c1a8889dcad7a39dc4e40832a 100644 --- a/source/Lib/CommonLib/InterPrediction.h +++ b/source/Lib/CommonLib/InterPrediction.h @@ -1153,8 +1153,15 @@ public: #if JVET_Z0102_NO_ARMC_FOR_ZERO_CAND void adjustMergeCandidates(PredictionUnit& pu, MergeCtx& smvpMergeCandCtx, int numRetrievedMergeCand); #endif -#if JVET_AG0276_NLIC - void adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMergeCandCtx, AltLMMergeCtx& altLMMrgCtx, int numRetrievedMergeCand); +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG + void adjustMergeCandidates(PredictionUnit& pu, MergeCtx& mvpMergeCandCtx +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , AltLMMergeCtx* pMrgCtxAlt + , AltLMMergeCtx* pMrgCtxInherit +#else + , AltLMMergeCtx& altLMMrgCtx +#endif + , int numRetrievedMergeCand); #endif #if JVET_AB0079_TM_BCW_MRG void adjustMergeCandidatesBcwIdx(PredictionUnit& pu, MergeCtx& mrgCtx, const int mergeIdx = -1); @@ -1164,7 +1171,13 @@ public: #endif #if JVET_AG0112_REGRESSION_BASED_GPM_BLENDING Distortion deriveBcwBlending( PredictionUnit& pu, bool bUniDir[2] ); - Distortion deriveBcwBlendingBiDir( PredictionUnit& pu, MvField mvfld0[2], MvField mvfld1[2] ); + Distortion deriveBcwBlendingBiDir( PredictionUnit& pu, MvField mvfld0[2], MvField mvfld1[2] +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , bool isLicA, bool isLicB + , int scaleA[2], int scaleB[2] + , int offsetA[2], int offsetB[2] +#endif + ); #endif #if JVET_Y0134_TMVP_NAMVP_CAND_REORDERING void adjustMergeCandidatesInOneCandidateGroup(PredictionUnit &pu, MergeCtx& smvpMergeCandCtx, int numRetrievedMergeCand, int mrgCandIdx = -1); @@ -1173,10 +1186,14 @@ public: void updateCandInTwoCandidateGroups(MergeCtx& mrgCtx, uint32_t* rdCandList, int numCandInCategory, MergeCtx mrgCtx2); #endif #endif -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG void updateCandList(uint32_t uiCand, uint32_t uiCandGrp, Distortion uiCost, uint32_t uiMrgCandNum, uint32_t* rdCandList, uint32_t* rdCandGrpList, Distortion* candCostList); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + void updateCandInMultiCandidateGroups(uint32_t* rdCandList, uint32_t* rdCandGrpList, int numCandInCategory, MergeCtx& mrgCtx, const MergeCtx** mrgCtx2toN = nullptr, int N = 1); +#else void updateCandInThreeCandidateGroups(MergeCtx& mrgCtx, MergeCtx mrgCtx2, MergeCtx mrgCtx3, uint32_t* rdCandList, uint32_t* rdCandGrpList, int numCandInCategory); #endif +#endif #if JVET_AA0093_REFINED_MOTION_FOR_ARMC void adjustMergeCandidatesInOneCandidateGroup(PredictionUnit &pu, MergeCtx& smvpMergeCandCtx, bool* applyBDMVR, Mv** mvBufBDMVR, Mv** mvBufBDMVRTmp, int numRetrievedMergeCand, bool subRefineList[][2] = NULL, bool subRefineListTmp[][2] = NULL, int mrgCandIdx = -1); void updateCandInOneCandidateGroup(MergeCtx& mrgCtx, uint32_t* rdCandList, bool* applyBDMVR, Mv** mvBufBDMVR, Mv** mvBufBDMVRTmp, bool subRefineList[][2] = NULL, bool subRefineListTmp[][2] = NULL, int numCandInCategory = -1); @@ -1799,6 +1816,9 @@ public: Distortion getMinCost () { return m_minCost; } Mv getFinalMv () { return m_mvFinal; } static int getDeltaMean (const PelBuf& bufCur, const PelBuf& bufRef, const int rowSubShift, const int bd); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + void inverseCurTemplateLIC (int shift, int scale, int offset); +#endif template <int tplSize> void deriveMvUni (); #if JVET_AF0163_TM_SUBBLOCK_REFINEMENT @@ -1818,7 +1838,7 @@ private: #endif template <int tplSize, bool trueAfalseL> void xRemoveHighFreq (const Picture& otherRefPic, const Mv& otherRefMv, const uint8_t curRefBcwWeight); #if JVET_AD0213_LIC_IMP - template <int tplSize, bool trueAfalseL> void xRemoveHighFreqLIC(const Picture& otherRefPic, const Mv& otherRefMv, const uint8_t curRefBcwWeight, int shift, int scale, int offet); + template <int tplSize, bool trueAfalseL> void xRemoveHighFreqLIC (const Picture& otherRefPic, const Mv& otherRefMv, const uint8_t curRefBcwWeight, int shift, int scale, int offet); #endif template <int tplSize, int searchPattern> void xRefineMvSearch (int maxSearchRounds, int searchStepShift); #if MULTI_PASS_DMVR diff --git a/source/Lib/CommonLib/MotionInfo.h b/source/Lib/CommonLib/MotionInfo.h index b0c4de04a858aaced38de0cbf34c953636aa69b4..d5ff7628669378d33491158f69d09eab9f7c5816 100644 --- a/source/Lib/CommonLib/MotionInfo.h +++ b/source/Lib/CommonLib/MotionInfo.h @@ -204,13 +204,17 @@ struct MotionInfo #if JVET_AG0164_AFFINE_GPM int8_t gpmPartIdx; - MotionInfo() : isSCC(false), isRefSCC(false), isRefRefSCC(false), isInter(false), isIBCmot(false), interDir(0), useAltHpelIf(false), sliceIdx(0), refIdx{ NOT_VALID, NOT_VALID }, bcwIdx(0), usesLIC(false),gpmPartIdx(-1) { } + MotionInfo() : isSCC(false), isRefSCC(false), isRefRefSCC(false), isInter(false), isIBCmot(false), interDir(0), useAltHpelIf(false), sliceIdx(0), refIdx{ NOT_VALID, NOT_VALID }, bcwIdx(0), usesLIC(false),gpmPartIdx(-1) + { + } // ensure that MotionInfo(0) produces '\x000....' bit pattern - needed to work with AreaBuf - don't use this constructor for anything else MotionInfo(int i) : isSCC(false), isRefSCC(false), isRefRefSCC(false), isInter(i != 0), isIBCmot(false), interDir(0), useAltHpelIf(false), sliceIdx(0), refIdx{ 0, 0 }, bcwIdx(0), usesLIC(false), gpmPartIdx(-1){ CHECKD(i != 0, "The argument for this constructor has to be '0'"); } #else #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL #if INTER_LIC - MotionInfo() : isSCC(false), isRefSCC(false), isRefRefSCC(false), isInter(false), isIBCmot(false), interDir(0), useAltHpelIf(false), sliceIdx(0), refIdx{ NOT_VALID, NOT_VALID }, bcwIdx(0), usesLIC(false) { } + MotionInfo() : isSCC(false), isRefSCC(false), isRefRefSCC(false), isInter(false), isIBCmot(false), interDir(0), useAltHpelIf(false), sliceIdx(0), refIdx{ NOT_VALID, NOT_VALID }, bcwIdx(0), usesLIC(false) + { + } // ensure that MotionInfo(0) produces '\x000....' bit pattern - needed to work with AreaBuf - don't use this constructor for anything else MotionInfo(int i) : isSCC(false), isRefSCC(false), isRefRefSCC(false), isInter(i != 0),isIBCmot(false), interDir(0), useAltHpelIf(false), sliceIdx(0), refIdx{ 0, 0 }, bcwIdx(0), usesLIC(false) { CHECKD(i != 0, "The argument for this constructor has to be '0'"); } #else @@ -220,7 +224,9 @@ struct MotionInfo #endif #else #if INTER_LIC - MotionInfo() : isInter(false), isIBCmot(false), interDir(0), useAltHpelIf(false), sliceIdx(0), refIdx{ NOT_VALID, NOT_VALID }, bcwIdx(0), usesLIC(false) { } + MotionInfo() : isInter(false), isIBCmot(false), interDir(0), useAltHpelIf(false), sliceIdx(0), refIdx{ NOT_VALID, NOT_VALID }, bcwIdx(0), usesLIC(false) + { + } // ensure that MotionInfo(0) produces '\x000....' bit pattern - needed to work with AreaBuf - don't use this constructor for anything else MotionInfo(int i) : isInter(i != 0), isIBCmot(false), interDir(0), useAltHpelIf(false), sliceIdx(0), refIdx{ 0, 0 }, bcwIdx(0), usesLIC(false) { CHECKD(i != 0, "The argument for this constructor has to be '0'"); } #else diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 26dd739a685ec5ed73361ed80558c9308e963ac3..25a24b18653d36e369b43fee57f9baad84fc68d4 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -261,6 +261,7 @@ #define JVET_AG0276_LIC_FLAG_SIGNALING 1 // JVET-AG0276: signal LIC flag for merge mode #define JVET_AG0276_LIC_BDOF_BDMVR 1 // JVET-AG0276: LIC BDOF and BDMVR #define JVET_AG0276_LIC_SLOPE_ADJUST 1 // JVET-AG0276: LIC with slope adjustment +#define JVET_AH0314_LIC_INHERITANCE_FOR_MRG 1 // JVET-AH0314: LIC model inheritance for merge modes (regular merge and GPM) #endif #define NON_ADJACENT_MRG_CAND 1 // Add non-adjacent merge candidates #define MULTI_HYP_PRED 1 // Multiple hypothesis prediction @@ -331,6 +332,7 @@ #define JVET_AG0098_AMVP_WITH_SBTMVP 1 // JVET-AG0098: AMVP with SbTMVP mode #define JVET_AG0067_DMVR_EXTENSIONS 1 // JVET-AG0067: On DMVR Extensions #define JVET_AH0069_CMVP 1 // JVET-AH0069: Chained motion vector prediction +#define JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV 1 // JVET-AH0314: Adaptive GPM blending // Inter template matching tools #define ENABLE_INTER_TEMPLATE_MATCHING 1 // It controls whether template matching is enabled for inter prediction diff --git a/source/Lib/CommonLib/Unit.cpp b/source/Lib/CommonLib/Unit.cpp index fc5d743a20d96d33265dadcae519e2afc97beeb3..4e0de0fe51039d3cf85da99ccdf55203e19d8c4d 100644 --- a/source/Lib/CommonLib/Unit.cpp +++ b/source/Lib/CommonLib/Unit.cpp @@ -434,6 +434,9 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other ) #endif #if INTER_LIC licFlag = other.licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + licInheritPara = other.licInheritPara; +#endif #if JVET_AD0213_LIC_IMP for (int i = 0; i < 2; i++) { @@ -686,13 +689,21 @@ void CodingUnit::initData() #endif #if INTER_LIC licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + licInheritPara = false; +#endif #if JVET_AD0213_LIC_IMP for (int i = 0; i < 2; i++) { for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + licScale[i][comp] = 32; + licOffset[i][comp] = 0; +#else licScale[i][comp] = MAX_INT; licOffset[i][comp] = MAX_INT; +#endif } } #endif diff --git a/source/Lib/CommonLib/Unit.h b/source/Lib/CommonLib/Unit.h index c761201a422907bc92600b4a26d82f4daaba9584..b20c7c12dd1cf237bf13160d5c85086d0d91fdbf 100644 --- a/source/Lib/CommonLib/Unit.h +++ b/source/Lib/CommonLib/Unit.h @@ -449,6 +449,9 @@ struct CodingUnit : public UnitArea #endif #if INTER_LIC bool licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool licInheritPara; +#endif #if JVET_AD0213_LIC_IMP int licScale[2][3]; int licOffset[2][3]; @@ -844,6 +847,10 @@ struct GeoBlendInfo Distortion uiCostTmp; // uicost template MvField mvFieldA[2]; MvField mvFieldB[2]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + int scaleA[2], scaleB[2]; + int offsetA[2], offsetB[2]; +#endif int dir[2]; // 0,1 or 2 (bi-dir) int mergeCand[2]; Distortion sad = 0; // sad of CU prediction @@ -852,10 +859,19 @@ struct GeoBlendInfo int iOrder; // before re-ordering int iMergeIdx; - bool isSame( MvField mvOtherFieldA[2], MvField mvOtherFieldB[2] ) + bool isSame( MvField mvOtherFieldA[2], MvField mvOtherFieldB[2] +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , int scaleOtherA [2], int scaleOtherB [2] + , int offsetOtherA[2], int offsetOtherB[2] +#endif + ) { bool bSameA = (mvFieldA[0] == mvOtherFieldA[0]) && (mvFieldA[1] == mvOtherFieldA[1]); bool bSameB = (mvFieldB[0] == mvOtherFieldB[0]) && (mvFieldB[1] == mvOtherFieldB[1]); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bSameA &= (scaleA[0] == scaleOtherA[0] && offsetA[0] == offsetOtherA[0]) && (scaleA[1] == scaleOtherA[1] && offsetA[1] == offsetOtherA[1]); + bSameB &= (scaleB[0] == scaleOtherB[0] && offsetB[0] == offsetOtherB[0]) && (scaleB[1] == scaleOtherB[1] && offsetB[1] == offsetOtherB[1]); +#endif return bSameA && bSameB; } }; diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 7f04e00fe35d855528e9fc6971d2aaeb582d3b0f..d1f97ce9afed4dcf442e0e23dc58cb8651cbbd0f 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -5538,6 +5538,7 @@ bool PU::addMergeHMVPCand(const CodingStructure &cs, MergeCtx &mrgCtx, const int int num_avai_candInLUT = (int)lut.size(); + #if JVET_AA0070_RRIBC && !JVET_Z0075_IBC_HMVP_ENLARGE int cPosCurX = pu.lx() + (pu.lwidth() >> 1); int cPosCurY = pu.ly() + (pu.lheight() >> 1); @@ -6105,6 +6106,9 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif #if JVET_AC0112_IBC_LIC mrgCtx.ibcLicFlags[ui] =false; @@ -8555,6 +8559,9 @@ void PU::getInterMergeCandidatesSubTMVP(const PredictionUnit &pu, MergeCtx& mrgC #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mrgCtx.interDirNeighbours[ui] = 0; mrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -8943,6 +8950,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; const CodingStructure &cs = *pu.cs; const Slice &slice = *pu.cs->slice; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool allowAltModel = true; +#endif #if TM_MRG #if JVET_AE0046_BI_GPM const uint32_t mvdSimilarityThresh = pu.tmMergeFlag ? PU::getTMMvdThreshold(pu) : (enableTh4Gpm ? getBiGpmThreshold(pu) : 1); @@ -8999,6 +9009,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif #if JVET_AC0112_IBC_LIC mrgCtx.ibcLicFlags[ui] = false; @@ -9118,6 +9131,14 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, #else mrgCtx.licFlags[cnt] = miAbove.usesLIC; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.loadLICParamFromPu(puAbove, cnt, allowAltModel, mrgCtx.licFlags[cnt]); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[cnt] = false; +#endif + + #endif mrgCtx.mvFieldNeighbours[cnt << 1].setMvField(miAbove.mv[0], miAbove.refIdx[0]); @@ -9209,6 +9230,12 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, #else mrgCtx.licFlags[cnt] = miLeft.usesLIC; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.loadLICParamFromPu(puLeft, cnt, allowAltModel, mrgCtx.licFlags[cnt]); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[cnt] = false; +#endif #endif // get Mv from Left mrgCtx.mvFieldNeighbours[cnt << 1].setMvField(miLeft.mv[0], miLeft.refIdx[0]); @@ -9301,6 +9328,12 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, #else mrgCtx.licFlags[cnt] = miAboveRight.usesLIC; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.loadLICParamFromPu(puAboveRight, cnt, allowAltModel, mrgCtx.licFlags[cnt]); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[cnt] = false; +#endif #endif mrgCtx.mvFieldNeighbours[cnt << 1].setMvField( miAboveRight.mv[0], miAboveRight.refIdx[0] ); @@ -9390,6 +9423,12 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, #else mrgCtx.licFlags[cnt] = miBelowLeft.usesLIC; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.loadLICParamFromPu(puLeftBottom, cnt, allowAltModel, mrgCtx.licFlags[cnt]); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[cnt] = false; +#endif #endif // get Mv from Bottom-Left mrgCtx.mvFieldNeighbours[cnt << 1].setMvField( miBelowLeft.mv[0], miBelowLeft.refIdx[0] ); @@ -9495,6 +9534,12 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, #else mrgCtx.licFlags[cnt] = miAboveLeft.usesLIC; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.loadLICParamFromPu(puAboveLeft, cnt, allowAltModel, mrgCtx.licFlags[cnt]); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[cnt] = false; +#endif #endif // get Mv from Above-Left mrgCtx.mvFieldNeighbours[cnt << 1].setMvField( miAboveLeft.mv[0], miAboveLeft.refIdx[0] ); @@ -9659,6 +9704,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.bcwIdx[uiArrayAddr] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[uiArrayAddr] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(uiArrayAddr); +#endif #endif mrgCtx.useAltHpelIf[uiArrayAddr] = false; #if MULTI_HYP_PRED @@ -9707,6 +9755,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.bcwIdx[cnt] = tmvpMrgCtx->bcwIdx[ui]; #if INTER_LIC mrgCtx.licFlags[cnt] = tmvpMrgCtx->licFlags[ui]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(cnt, *tmvpMrgCtx, ui); +#endif #endif mrgCtx.interDirNeighbours[cnt] = tmvpMrgCtx->interDirNeighbours[ui]; mrgCtx.mvFieldNeighbours[cnt << 1] = tmvpMrgCtx->mvFieldNeighbours[ui << 1]; @@ -9751,6 +9802,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.bcwIdx[cnt] = tmvpMrgCtx->bcwIdx[0]; #if INTER_LIC mrgCtx.licFlags[cnt] = tmvpMrgCtx->licFlags[0]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(cnt, *tmvpMrgCtx, 0); +#endif #endif mrgCtx.interDirNeighbours[cnt] = tmvpMrgCtx->interDirNeighbours[0]; mrgCtx.mvFieldNeighbours[cnt << 1] = tmvpMrgCtx->mvFieldNeighbours[0]; @@ -9794,6 +9848,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.bcwIdx[cnt] = tmvpMrgCtx->bcwIdx[0]; #if INTER_LIC mrgCtx.licFlags[cnt] = tmvpMrgCtx->licFlags[0]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(cnt, *tmvpMrgCtx, 0); +#endif #endif mrgCtx.interDirNeighbours[cnt] = tmvpMrgCtx->interDirNeighbours[0]; mrgCtx.mvFieldNeighbours[cnt << 1] = tmvpMrgCtx->mvFieldNeighbours[0]; @@ -9932,6 +9989,13 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, #else mrgCtx.licFlags[cnt] = miNeighbor.usesLIC; #endif + +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.loadLICParamFromPu(puNonAdjacent, cnt, allowAltModel, mrgCtx.licFlags[cnt]); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[cnt] = false; +#endif #endif if (slice.isInterB()) { @@ -9988,6 +10052,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.bcwIdx[cnt] = namvpMrgCtx->bcwIdx[ui]; #if INTER_LIC mrgCtx.licFlags[cnt] = namvpMrgCtx->licFlags[ui]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.copyLICParamFromCtx(cnt, *namvpMrgCtx, ui); +#endif #endif mrgCtx.interDirNeighbours[cnt] = namvpMrgCtx->interDirNeighbours[ui]; mrgCtx.mvFieldNeighbours[cnt << 1] = namvpMrgCtx->mvFieldNeighbours[ui << 1]; @@ -10279,6 +10346,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.mvFieldNeighbours[cnt * 2 + 1].setMvField( Mv( 0, 0 ), NOT_VALID ); #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if MULTI_HYP_PRED @@ -10317,6 +10387,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.mvFieldNeighbours[cnt * 2 + refListId].setMvField( avgMv, refIdxI ); #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif averageUsed = true; #endif } @@ -10346,6 +10419,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, } mrgCtx.interDirNeighbours[cnt] = interDir; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif if( interDir > 0 ) { #if INTER_LIC @@ -10353,6 +10429,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, if (interDir == 3) { mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif } #endif #endif @@ -10435,6 +10514,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.bcwIdx [ mrgCtx.numValidMergeCand ] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags [ mrgCtx.numValidMergeCand ] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(mrgCtx.numValidMergeCand); +#endif #endif mrgCtx.useAltHpelIf [ mrgCtx.numValidMergeCand ] = false; #if MULTI_HYP_PRED @@ -10462,6 +10544,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.bcwIdx [uiArrayAddr ] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags [uiArrayAddr ] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(uiArrayAddr); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[uiArrayAddr].clear(); @@ -10628,6 +10713,9 @@ bool PU::addBMMergeHMVPCand(const CodingStructure &cs, MergeCtx &mrgCtx, const i #else mrgCtx.licFlags[cnt] = miNeighbor.usesLIC; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #if !JVET_Z0075_IBC_HMVP_ENLARGE if (ibcFlag) { @@ -11092,6 +11180,9 @@ void PU::getRMVFAffineGuideCand(const PredictionUnit &pu, const PredictionUnit & int iNumPredDir = cs.slice->isInterP() ? 1 : 2; Mv cMV[2][3]; Mv cMVOri[2][3]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool allowAltModel = true; +#endif std::vector<RMVFInfo> mvpInfoVec[2]; std::vector<RMVFInfo> mvpInfoVecOri; @@ -11542,6 +11633,10 @@ void PU::getRMVFAffineGuideCand(const PredictionUnit &pu, const PredictionUnit & affMrgCtx.bcwIdx[i] = abovePU.cu->bcwIdx; #if INTER_LIC affMrgCtx.licFlags[i] = abovePU.cu->licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.loadLICParamFromPu(&abovePU, i, allowAltModel, affMrgCtx.licFlags[i]); + affMrgCtx.licInheritPara[i] = false; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL #if JVET_AD0213_LIC_IMP @@ -11629,8 +11724,15 @@ void PU::getRMVFAffineGuideCand(const PredictionUnit &pu, const PredictionUnit & #if INTER_LIC #if JVET_AD0213_LIC_IMP affMrgCtx.licFlags[i] = abovePU.cu->licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.loadLICParamFromPu(&abovePU, i, allowAltModel, affMrgCtx.licFlags[i]); + affMrgCtx.licInheritPara[i] = false; +#endif #else affMrgCtx.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setDefaultLICParamToCtx(i); +#endif #endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL @@ -11882,6 +11984,9 @@ void PU::getInterBMCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mrgCtx.interDirNeighbours[ui] = 0; mrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -12517,6 +12622,9 @@ void PU::getInterBMCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.mvFieldNeighbours[cnt * 2 + 1].setMvField(Mv(0, 0), NOT_VALID); #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[cnt].clear(); @@ -12585,6 +12693,9 @@ void PU::getInterBMCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif #if MULTI_HYP_PRED mrgCtx.addHypNeighbours[cnt].clear(); @@ -12640,6 +12751,9 @@ void PU::getTmvpBMCand(const PredictionUnit &pu, MergeCtx& mrgCtx) #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mrgCtx.interDirNeighbours[ui] = 0; mrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -12863,6 +12977,9 @@ void PU::getNonAdjacentBMCand(const PredictionUnit &pu, MergeCtx& mrgCtx) #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mrgCtx.interDirNeighbours[ui] = 0; mrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -13038,6 +13155,9 @@ void PU::getTmvpMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mrgCtx.interDirNeighbours[ui] = 0; mrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -13208,6 +13328,9 @@ void PU::getTmvpMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif mrgCtx.useAltHpelIf[cnt] = false; #if MULTI_HYP_PRED @@ -13249,6 +13372,9 @@ void PU::getTmvpMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif mrgCtx.useAltHpelIf[cnt] = false; #if MULTI_HYP_PRED @@ -13286,6 +13412,9 @@ void PU::getTmvpMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif mrgCtx.useAltHpelIf[cnt] = false; #if MULTI_HYP_PRED @@ -13453,6 +13582,9 @@ void PU::getTmvpMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif mrgCtx.useAltHpelIf[cnt] = false; #if MULTI_HYP_PRED @@ -13489,6 +13621,9 @@ void PU::getTmvpMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif mrgCtx.useAltHpelIf[cnt] = false; #if MULTI_HYP_PRED @@ -13520,6 +13655,9 @@ void PU::getTmvpMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif mrgCtx.useAltHpelIf[cnt] = false; #if MULTI_HYP_PRED @@ -13575,6 +13713,9 @@ void PU::getNonAdjacentMergeCandSubTMVP(const PredictionUnit &pu, MergeCtx& mrgC #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mrgCtx.interDirNeighbours[ui] = 0; mrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -13758,6 +13899,9 @@ void PU::getNonAdjacentMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; const CodingStructure &cs = *pu.cs; const Slice &slice = *pu.cs->slice; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool allowAltModel = true; +#endif #if TM_MRG #if JVET_AA0132_CONFIGURABLE_TM_TOOLS || JVET_AA0093_DIVERSITY_CRITERION_FOR_ARMC @@ -13786,6 +13930,9 @@ void PU::getNonAdjacentMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mrgCtx.interDirNeighbours[ui] = 0; mrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -13856,6 +14003,12 @@ void PU::getNonAdjacentMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) #else mrgCtx.licFlags[cnt] = miNeighbor.usesLIC; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.loadLICParamFromPu(puNonAdjacent, cnt, allowAltModel, mrgCtx.licFlags[cnt]); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[cnt] = false; +#endif #endif if (slice.isInterB()) { @@ -13930,6 +14083,12 @@ void PU::getNonAdjacentMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) #else mrgCtx.licFlags[cnt] = miNeighbor.usesLIC; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.loadLICParamFromPu(puNonAdjacent, cnt, allowAltModel, mrgCtx.licFlags[cnt]); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[cnt] = false; +#endif #endif if (slice.isInterB()) { @@ -13963,7 +14122,7 @@ void PU::getNonAdjacentMergeCand(const PredictionUnit &pu, MergeCtx& mrgCtx) } #endif -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG uint32_t PU::getAltMergeMvdThreshold(const PredictionUnit &pu) { uint32_t numPixels = pu.lwidth() * pu.lheight(); @@ -13982,11 +14141,22 @@ uint32_t PU::getAltMergeMvdThreshold(const PredictionUnit &pu) } #if JVET_AG0276_LIC_FLAG_SIGNALING -bool PU::isValidAltMergeCandidate(const PredictionUnit &pu, bool isBRCand) +bool PU::isValidAltMergeCandidate(const PredictionUnit &pu, bool isBRCand +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , bool isLicInheritCand +#endif +) #else -bool PU::isValidAltMergeCandidate(const PredictionUnit &pu) +bool PU::isValidAltMergeCandidate(const PredictionUnit &pu +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , bool isLicInheritCand +#endif +) #endif { +#if JVET_AG0276_LIC_FLAG_SIGNALING && JVET_AH0314_LIC_INHERITANCE_FOR_MRG + CHECK(isBRCand && isLicInheritCand, "Impossible comfiguration"); +#endif bool valid = true; if (!CU::isInter(*pu.cu)) { @@ -14001,6 +14171,13 @@ bool PU::isValidAltMergeCandidate(const PredictionUnit &pu) valid = false; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (isLicInheritCand) + { + valid &= pu.cu->licFlag; + } +#endif + if (!valid) { return false; @@ -14019,6 +14196,13 @@ bool PU::isValidAltMergeCandidate(const PredictionUnit &pu) #else bool trivial = (pu.cu->altLMParaUnit.scale[0] == 32 && pu.cu->altLMParaUnit.offset[0] == 0); #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (isLicInheritCand) + { + trivial = (!(pu.interDir & 0x01) || (pu.cu->licScale[0][0] == 32 && pu.cu->licOffset[0][0] == 0)) + && (!(pu.interDir & 0x02) || (pu.cu->licScale[1][0] == 32 && pu.cu->licOffset[1][0] == 0)); + } +#endif if (trivial) { @@ -14027,19 +14211,74 @@ bool PU::isValidAltMergeCandidate(const PredictionUnit &pu) return true; } -void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) +void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , bool isLicInheritCand +#endif +) { - const uint32_t maxNumMergeCand = ALT_MRG_MAX_NUM_CANDS; + const uint32_t maxNumMergeCand = +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + isLicInheritCand ? LIC_INHERIT_ALT_MRG_MAX_NUM_CANDS : +#endif + ALT_MRG_MAX_NUM_CANDS; const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; const CodingStructure& cs = *pu.cs; const Slice& slice = *pu.cs->slice; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool allowAltModel = true; +#endif const uint32_t mvdSimilarityThresh = getAltMergeMvdThreshold(pu); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cMrgCtx.numValidMergeCand = 0; +#endif for (int i = 0; i < maxNumMergeCand; i++) { cMrgCtx.initAltLMMergeCtx(i); } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + auto setLicModelAndMotionSimilarityCheck = [&](int& cnt, const PredictionUnit* puNei) + { + bool isValid = (isLicInheritCand && puNei->cu->licFlag && !puNei->cu->altLMFlag); + isValid |= !isLicInheritCand; + if (isValid) + { + if (isLicInheritCand) + { + cMrgCtx.licFlags[cnt] = true; + cMrgCtx.loadLICParamFromPu(puNei, cnt, allowAltModel, true); +#if JVET_AG0276_NLIC + cMrgCtx.altLMParaNeighbours[cnt].resetAltLinearModel(); +#endif + cMrgCtx.setInheritAndLICFlags(cnt); + isValid = cMrgCtx.licInheritPara[cnt]; + } + else + { +#if JVET_AG0276_NLIC + cMrgCtx.licFlags[cnt] = false; + cMrgCtx.setDefaultLICParamToCtx(cnt); + cMrgCtx.altLMParaNeighbours[cnt] = puNei->cu->altLMParaUnit; +#else + CHECK(true, "Unsupported mode"); +#endif + } + } + + if (isValid && !cMrgCtx.xCheckSameMotion(cnt, mvdSimilarityThresh)) + { + cnt++; + cMrgCtx.numValidMergeCand = cnt; + } + else + { + cMrgCtx.initAltLMMergeCtx(cnt); + } + }; +#endif + int cnt = 0; const Position posLT = pu.Y().topLeft(); @@ -14049,7 +14288,14 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) // above const PredictionUnit *puAbove = cs.getPURestricted(posRT.offset(0, -1), pu, pu.chType); bool isAvailableB1 = puAbove && isDiffMER(pu.lumaPos(), posRT.offset(0, -1), plevel) && CU::isInter(*puAbove->cu); - if (isAvailableB1 && PU::isValidAltMergeCandidate(*puAbove)) + if (isAvailableB1 && PU::isValidAltMergeCandidate(*puAbove +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_LIC_FLAG_SIGNALING + , false +#endif + , isLicInheritCand +#endif + )) { MotionInfo miAbove = puAbove->getMotionInfo(posRT.offset(0, -1)); cMrgCtx.interDirNeighbours[cnt] = miAbove.interDir; @@ -14060,6 +14306,9 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.mvFieldNeighbours[(cnt << 1) + 1].setMvField(miAbove.mv[1], miAbove.refIdx[1]); } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setLicModelAndMotionSimilarityCheck(cnt, puAbove); +#else cMrgCtx.altLMParaNeighbours[cnt] = puAbove->cu->altLMParaUnit; if (!cMrgCtx.xCheckSameMotion(cnt, mvdSimilarityThresh)) { @@ -14069,6 +14318,7 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.initAltLMMergeCtx(cnt); } +#endif } if (cnt == maxNumMergeCand) @@ -14079,7 +14329,14 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) //left const PredictionUnit* puLeft = cs.getPURestricted(posLB.offset(-1, 0), pu, pu.chType); const bool isAvailableA1 = puLeft && isDiffMER(pu.lumaPos(), posLB.offset(-1, 0), plevel) && CU::isInter(*puLeft->cu); - if (isAvailableA1 && PU::isValidAltMergeCandidate(*puLeft)) + if (isAvailableA1 && PU::isValidAltMergeCandidate(*puLeft +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_LIC_FLAG_SIGNALING + , false +#endif + , isLicInheritCand +#endif + )) { MotionInfo miLeft = puLeft->getMotionInfo(posLB.offset(-1, 0)); cMrgCtx.interDirNeighbours[cnt] = miLeft.interDir; @@ -14090,6 +14347,9 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.mvFieldNeighbours[(cnt << 1) + 1].setMvField(miLeft.mv[1], miLeft.refIdx[1]); } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setLicModelAndMotionSimilarityCheck(cnt, puLeft); +#else cMrgCtx.altLMParaNeighbours[cnt] = puLeft->cu->altLMParaUnit; if (!cMrgCtx.xCheckSameMotion(cnt, mvdSimilarityThresh)) { @@ -14099,6 +14359,7 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.initAltLMMergeCtx(cnt); } +#endif } if (cnt == maxNumMergeCand) @@ -14109,7 +14370,14 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) // above right const PredictionUnit *puAboveRight = cs.getPURestricted(posRT.offset(1, -1), pu, pu.chType); const bool isAvailableB0 = puAboveRight && isDiffMER(pu.lumaPos(), posRT.offset(1, -1), plevel) && CU::isInter(*puAboveRight->cu); - if (isAvailableB0 && PU::isValidAltMergeCandidate(*puAboveRight)) + if (isAvailableB0 && PU::isValidAltMergeCandidate(*puAboveRight +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_LIC_FLAG_SIGNALING + , false +#endif + , isLicInheritCand +#endif + )) { MotionInfo miAboveRight = puAboveRight->getMotionInfo(posRT.offset(1, -1)); cMrgCtx.interDirNeighbours[cnt] = miAboveRight.interDir; @@ -14120,6 +14388,9 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.mvFieldNeighbours[(cnt << 1) + 1].setMvField(miAboveRight.mv[1], miAboveRight.refIdx[1]); } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setLicModelAndMotionSimilarityCheck(cnt, puAboveRight); +#else cMrgCtx.altLMParaNeighbours[cnt] = puAboveRight->cu->altLMParaUnit; if (!cMrgCtx.xCheckSameMotion(cnt, mvdSimilarityThresh)) { @@ -14129,6 +14400,7 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.initAltLMMergeCtx(cnt); } +#endif } if (cnt == maxNumMergeCand) @@ -14139,7 +14411,14 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) //left bottom const PredictionUnit *puLeftBottom = cs.getPURestricted(posLB.offset(-1, 1), pu, pu.chType); bool isAvailableA0 = puLeftBottom && isDiffMER(pu.lumaPos(), posLB.offset(-1, 1), plevel) && CU::isInter(*puLeftBottom->cu); - if (isAvailableA0 && PU::isValidAltMergeCandidate(*puLeftBottom)) + if (isAvailableA0 && PU::isValidAltMergeCandidate(*puLeftBottom +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_LIC_FLAG_SIGNALING + , false +#endif + , isLicInheritCand +#endif + )) { MotionInfo miBelowLeft = puLeftBottom->getMotionInfo(posLB.offset(-1, 1)); cMrgCtx.interDirNeighbours[cnt] = miBelowLeft.interDir; @@ -14150,6 +14429,9 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.mvFieldNeighbours[(cnt << 1) + 1].setMvField(miBelowLeft.mv[1], miBelowLeft.refIdx[1]); } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setLicModelAndMotionSimilarityCheck(cnt, puLeftBottom); +#else cMrgCtx.altLMParaNeighbours[cnt] = puLeftBottom->cu->altLMParaUnit; if (!cMrgCtx.xCheckSameMotion(cnt, mvdSimilarityThresh)) { @@ -14159,6 +14441,7 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.initAltLMMergeCtx(cnt); } +#endif } if (cnt == maxNumMergeCand) @@ -14169,7 +14452,14 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) // above left const PredictionUnit *puAboveLeft = cs.getPURestricted(posLT.offset(-1, -1), pu, pu.chType); bool isAvailableB2 = puAboveLeft && isDiffMER(pu.lumaPos(), posLT.offset(-1, -1), plevel) && CU::isInter(*puAboveLeft->cu); - if (isAvailableB2 && PU::isValidAltMergeCandidate(*puAboveLeft)) + if (isAvailableB2 && PU::isValidAltMergeCandidate(*puAboveLeft +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_LIC_FLAG_SIGNALING + , false +#endif + , isLicInheritCand +#endif + )) { MotionInfo miAboveLeft = puAboveLeft->getMotionInfo(posLT.offset(-1, -1)); cMrgCtx.interDirNeighbours[cnt] = miAboveLeft.interDir; @@ -14180,6 +14470,9 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.mvFieldNeighbours[(cnt << 1) + 1].setMvField(miAboveLeft.mv[1], miAboveLeft.refIdx[1]); } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setLicModelAndMotionSimilarityCheck(cnt, puAboveLeft); +#else cMrgCtx.altLMParaNeighbours[cnt] = puAboveLeft->cu->altLMParaUnit; if (!cMrgCtx.xCheckSameMotion(cnt, mvdSimilarityThresh)) { @@ -14189,6 +14482,7 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.initAltLMMergeCtx(cnt); } +#endif } if (cnt == maxNumMergeCand) @@ -14228,7 +14522,14 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) const PredictionUnit *puNonAdjacent = cs.getPURestricted(posLT.offset(offsetX, offsetY), pu, pu.chType); bool isAvailableNonAdjacent = puNonAdjacent && isDiffMER(pu.lumaPos(), posLT.offset(offsetX, offsetY), plevel) && CU::isInter(*puNonAdjacent->cu); - if (isAvailableNonAdjacent && PU::isValidAltMergeCandidate(*puNonAdjacent)) + if (isAvailableNonAdjacent && PU::isValidAltMergeCandidate(*puNonAdjacent +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_LIC_FLAG_SIGNALING + , false +#endif + , isLicInheritCand +#endif + )) { MotionInfo miNeighbor = puNonAdjacent->getMotionInfo(posLT.offset(offsetX, offsetY)); cMrgCtx.interDirNeighbours[cnt] = miNeighbor.interDir; @@ -14239,6 +14540,9 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.mvFieldNeighbours[(cnt << 1) + 1].setMvField(miNeighbor.mv[1], miNeighbor.refIdx[1]); } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setLicModelAndMotionSimilarityCheck(cnt, puNonAdjacent); +#else cMrgCtx.altLMParaNeighbours[cnt] = puNonAdjacent->cu->altLMParaUnit; if (!cMrgCtx.xCheckSameMotion(cnt, mvdSimilarityThresh)) { @@ -14248,6 +14552,7 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.initAltLMMergeCtx(cnt); } +#endif } } } @@ -14274,7 +14579,14 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) const PredictionUnit *puNonAdjacent = cs.getPURestricted(posLT.offset(offsetX, offsetY), pu, pu.chType); bool isAvailableNonAdjacent = puNonAdjacent && isDiffMER(pu.lumaPos(), posLT.offset(offsetX, offsetY), plevel) && CU::isInter(*puNonAdjacent->cu); - if (isAvailableNonAdjacent && PU::isValidAltMergeCandidate(*puNonAdjacent)) + if (isAvailableNonAdjacent && PU::isValidAltMergeCandidate(*puNonAdjacent +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_LIC_FLAG_SIGNALING + , false +#endif + , isLicInheritCand +#endif + )) { MotionInfo miNeighbor = puNonAdjacent->getMotionInfo(posLT.offset(offsetX, offsetY)); cMrgCtx.interDirNeighbours[cnt] = miNeighbor.interDir; @@ -14285,6 +14597,9 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.mvFieldNeighbours[(cnt << 1) + 1].setMvField(miNeighbor.mv[1], miNeighbor.refIdx[1]); } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + setLicModelAndMotionSimilarityCheck(cnt, puNonAdjacent); +#else cMrgCtx.altLMParaNeighbours[cnt] = puNonAdjacent->cu->altLMParaUnit; if (!cMrgCtx.xCheckSameMotion(cnt, mvdSimilarityThresh)) { @@ -14294,6 +14609,7 @@ void PU::getAltMergeCandidates(const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx) { cMrgCtx.initAltLMMergeCtx(cnt); } +#endif } } } @@ -17820,6 +18136,9 @@ bool PU::checkLastAffineMergeCandRedundancy(const PredictionUnit& pu, AffineMerg affMrgCtx.bcwIdx[lastIdx] = BCW_DEFAULT; #if INTER_LIC affMrgCtx.licFlags[lastIdx] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setDefaultLICParamToCtx(lastIdx); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[lastIdx] = true; @@ -17947,6 +18266,9 @@ bool PU::addMergeHMVPCandFromAffModel(const PredictionUnit& pu, MergeCtx& mrgCtx mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif #if MULTI_HYP_PRED && JVET_AD0213_LIC_IMP mrgCtx.addHypNeighbours[cnt].clear(); @@ -18023,6 +18345,9 @@ bool PU::addMergeHMVPCandFromAffModel(const PredictionUnit& pu, MergeCtx& mrgCtx mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif #if MULTI_HYP_PRED && JVET_AD0213_LIC_IMP mrgCtx.addHypNeighbours[cnt].clear(); @@ -18072,12 +18397,18 @@ bool PU::addOneMergeHMVPCandFromAffModel(const PredictionUnit& pu, MergeCtx& mrg #endif ) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bICflag &= pu.cs->slice->getUseLIC(); +#endif Mv cMv[2]; int HistParameters[2][4]; mrgCtx.interDirNeighbours[cnt] = 0; mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif mrgCtx.useAltHpelIf[cnt] = false; mrgCtx.mvFieldNeighbours[(cnt << 1) + 0].setMvField(Mv(), -1); @@ -18125,6 +18456,9 @@ bool PU::addOneMergeHMVPCandFromAffModel(const PredictionUnit& pu, MergeCtx& mrg mrgCtx.bcwIdx [cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif #if MULTI_HYP_PRED && JVET_AD0213_LIC_IMP mrgCtx.addHypNeighbours[cnt].clear(); @@ -18138,6 +18472,9 @@ bool PU::addOneMergeHMVPCandFromAffModel(const PredictionUnit& pu, MergeCtx& mrg #if INTER_LIC mrgCtx.licFlags[cnt] = bICflag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #if !JVET_AD0213_LIC_IMP CHECK(bICflag && mvInfo.interDir == 3, "LIC cannot be used for Bi"); #endif @@ -18154,6 +18491,9 @@ bool PU::addOneMergeHMVPCandFromAffModel(const PredictionUnit& pu, MergeCtx& mrg mrgCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC mrgCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif #if MULTI_HYP_PRED && JVET_AD0213_LIC_IMP mrgCtx.addHypNeighbours[cnt].clear(); @@ -18173,6 +18513,9 @@ bool PU::addOneAffineMergeHMVPCand(const PredictionUnit & pu, AffineMergeCtx & a #endif ) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bICflag &= pu.cs->slice->getUseLIC(); +#endif Mv cMv[2][3]; int aiHistParameters[2][4]; affMrgCtx.interDirNeighbours[affMrgCtx.numValidMergeCand] = 0; @@ -18232,6 +18575,9 @@ bool PU::addOneAffineMergeHMVPCand(const PredictionUnit & pu, AffineMergeCtx & a #if INTER_LIC affMrgCtx.licFlags[affMrgCtx.numValidMergeCand] = bICflag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setDefaultLICParamToCtx(affMrgCtx.numValidMergeCand); +#endif #if !JVET_AD0213_LIC_IMP CHECK( bICflag && mvInfo.interDir == 3, "LIC cannot be used for Bi"); #endif @@ -18307,6 +18653,9 @@ bool PU::addOneInheritedHMVPAffineMergeCand(const PredictionUnit& pu, AffineMerg #if INTER_LIC affMrgCtx.licFlags[affMrgCtx.numValidMergeCand] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setDefaultLICParamToCtx(affMrgCtx.numValidMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[affMrgCtx.numValidMergeCand] = true; @@ -19221,6 +19570,9 @@ void PU::getAffineControlPointCand(const PredictionUnit &pu, MotionInfo mi[4], b affMrgType.bcwIdx[affMrgType.numValidMergeCand] = (dir == 3) ? bcwIdx : BCW_DEFAULT; #if INTER_LIC affMrgType.licFlags[affMrgType.numValidMergeCand] = LICFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgType.setDefaultLICParamToCtx(affMrgType.numValidMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL #if JVET_AD0213_LIC_IMP @@ -19931,6 +20283,9 @@ bool PU::addNonAdjAffineConstructedCPMV(const PredictionUnit &pu, MotionInfo miN #else affMrgCtx.licFlags[affMrgCtx.numValidMergeCand] = (dir != 3) ? bLICFlag : false; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setDefaultLICParamToCtx(affMrgCtx.numValidMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL #if JVET_AD0213_LIC_IMP @@ -19996,6 +20351,9 @@ void PU::getNonAdjCstMergeCand(const PredictionUnit &pu, AffineMergeCtx &affMrgC #endif #if INTER_LIC affMrgCtx.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setDefaultLICParamToCtx(i); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[i] = true; @@ -20197,6 +20555,9 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx { const CodingStructure &cs = *pu.cs; const Slice &slice = *pu.cs->slice; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool allowAltModel = true; +#endif #if JVET_AA0107_RMVF_AFFINE_MERGE_DERIVATION #if JVET_W0090_ARMC_TM #if JVET_AE0174_NONINTER_TM_TOOLS_CONTROL @@ -20235,6 +20596,9 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx #endif #if INTER_LIC affMrgCtx.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + affMrgCtx.setDefaultLICParamToCtx(i); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[i] = true; @@ -20552,6 +20916,12 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx CHECK( puNeigh->interDir == 3 && puNeigh->cu->licFlag, "LIC should not be enabled for affine bi-pred" ); #endif affMrgCtx.licFlags[affMrgCtx.numValidMergeCand] = puNeigh->cu->licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.loadLICParamFromPu(puNeigh, affMrgCtx.numValidMergeCand, allowAltModel, puNeigh->cu->licFlag); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.licInheritPara[affMrgCtx.numValidMergeCand] = false; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL #if JVET_AD0213_LIC_IMP @@ -20678,6 +21048,12 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx CHECK(puNeigh->interDir == 3 && puNeigh->cu->licFlag, "LIC should not be enabled for affine bi-pred"); #endif affMrgCtx.licFlags[affMrgCtx.numValidMergeCand] = puNeigh->cu->licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.loadLICParamFromPu(puNeigh, affMrgCtx.numValidMergeCand, allowAltModel, puNeigh->cu->licFlag); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.licInheritPara[affMrgCtx.numValidMergeCand] = false; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL #if JVET_AD0213_LIC_IMP @@ -20728,6 +21104,9 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx #endif #if INTER_LIC affMrgCtxTemp.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtxTemp.setDefaultLICParamToCtx(i); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtxTemp.obmcFlags[i] = true; @@ -20777,6 +21156,10 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx #endif #if INTER_LIC affMrgCtx.licFlags[affMrgCtx.numValidMergeCand] = affMrgCtxTemp.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.copyLICParamFromCtx(affMrgCtx.numValidMergeCand, affMrgCtxTemp, i); + affMrgCtx.licInheritPara[affMrgCtx.numValidMergeCand] = false; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[affMrgCtx.numValidMergeCand] = affMrgCtxTemp.obmcFlags[i]; @@ -20833,6 +21216,10 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx #endif #if INTER_LIC affMrgCtx.licFlags[affMrgCtx.numValidMergeCand] = affMrgCtxTemp.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.copyLICParamFromCtx(affMrgCtx.numValidMergeCand, affMrgCtxTemp, i); + affMrgCtx.licInheritPara[affMrgCtx.numValidMergeCand] = false; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[affMrgCtx.numValidMergeCand] = affMrgCtxTemp.obmcFlags[i]; @@ -20879,6 +21266,9 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx affMrgCtxTemp.bcwIdx[i] = BCW_DEFAULT; #if INTER_LIC affMrgCtxTemp.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtxTemp.setDefaultLICParamToCtx(i); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtxTemp.obmcFlags[i] = true; @@ -20917,6 +21307,16 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx break; } } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + bool isInherited = pu.cu->geoFlag; + if (isInherited) + { + for (int i = 0; i < affMrgCtxTemp.numValidMergeCand; ++i) + { + affMrgCtxTemp.setInheritAndLICFlags(i); + } + } +#endif PredictionUnit pu2 = pu; m_pcInterSearch->adjustAffineMergeCandidatesOneGroup(pu2, affMrgCtxTemp, affMrgCtxTemp.numValidMergeCand); int counter = 0; @@ -20949,6 +21349,10 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx affMrgCtx.bcwIdx[affMrgCtx.numValidMergeCand] = affMrgCtxTemp.bcwIdx[i]; #if INTER_LIC affMrgCtx.licFlags[affMrgCtx.numValidMergeCand] = affMrgCtxTemp.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.copyLICParamFromCtx(affMrgCtx.numValidMergeCand, affMrgCtxTemp, i); + affMrgCtx.licInheritPara[affMrgCtx.numValidMergeCand] = false; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[affMrgCtx.numValidMergeCand] = affMrgCtxTemp.obmcFlags[i]; @@ -20975,6 +21379,10 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx } else { +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + bool isInherited = pu.cu->geoFlag; + bool doReturn = false; #endif int counter = 0; int numAdded = 0; @@ -20984,11 +21392,21 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx getRMVFAffineGuideCand(pu, *npu[i], affMrgCtx, mvpInfoVec, mrgCandIdx); if (affMrgCtx.numValidMergeCand != 0 && (affMrgCtx.numValidMergeCand - 1 == mrgCandIdx)) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + doReturn = true; + break; +#else return; +#endif } if (affMrgCtx.numValidMergeCand == maxNumAffineMergeCand) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + doReturn = true; + break; +#else return; +#endif } counter += affMrgCtx.numValidMergeCand - numAdded; if (counter >= numAffNeighExtend2) @@ -20996,6 +21414,19 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx break; } } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + if (isInherited) + { + for (int i = 0; i < affMrgCtx.numValidMergeCand; ++i) + { + affMrgCtx.setInheritAndLICFlags(i); + } + } + if (doReturn) + { + return; + } +#endif #if JVET_W0090_ARMC_TM } #endif @@ -21427,6 +21858,9 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx #if INTER_LIC affMrgCtx.licFlags[affMrgCtx.numValidMergeCand] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affMrgCtx.setDefaultLICParamToCtx(affMrgCtx.numValidMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtx.obmcFlags[affMrgCtx.numValidMergeCand] = true; @@ -21496,6 +21930,16 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx affMrgCtx.interDirNeighbours[cnt] = 1; #if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION affMrgCtx.colIdx[cnt] = 0; +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM +#if JVET_AG0276_NLIC + affMrgCtx.altLMFlag[cnt] = false; + affMrgCtx.altLMParaNeighbours[cnt].resetAltLinearModel(); +#endif +#if INTER_LIC + affMrgCtx.licFlags[cnt] = false; + affMrgCtx.setDefaultLICParamToCtx(cnt); +#endif #endif if ( slice.isInterB() ) @@ -21535,6 +21979,9 @@ void PU::getBMAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affineBM { const CodingStructure &cs = *pu.cs; const Slice &slice = *pu.cs->slice; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool allowAltModel = true; +#endif const uint32_t maxNumAffineMergeCand = AFFINE_ADAPTIVE_DMVR_INIT_SIZE; const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; @@ -21558,6 +22005,9 @@ void PU::getBMAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affineBM #endif #if INTER_LIC affineBMMergeCtx.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeCtx.setDefaultLICParamToCtx(i); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affineBMMergeCtx.obmcFlags[i] = true; @@ -21660,6 +22110,10 @@ void PU::getBMAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affineBM CHECK(puNeigh->interDir == 3 && puNeigh->cu->licFlag, "LIC should not be enabled for affine bi-pred"); #endif affineBMMergeCtx.licFlags[affineBMMergeCtx.numValidMergeCand] = puNeigh->cu->licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeCtx.loadLICParamFromPu(puNeigh, affineBMMergeCtx.numValidMergeCand, allowAltModel, puNeigh->cu->licFlag); + affineBMMergeCtx.licInheritPara[affineBMMergeCtx.numValidMergeCand] = false; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL #if JVET_AD0213_LIC_IMP @@ -21727,6 +22181,9 @@ void PU::getBMAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affineBM #endif #if INTER_LIC affineBMMergeCtx.licFlags[affineBMMergeCtx.numValidMergeCand] = affineMergeRMVFCtx.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeCtx.copyLICParamFromCtx(affineBMMergeCtx.numValidMergeCand, affineMergeRMVFCtx, i); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affineBMMergeCtx.obmcFlags[affineBMMergeCtx.numValidMergeCand] = affineMergeRMVFCtx.obmcFlags[i]; @@ -22327,6 +22784,9 @@ void PU::getBMAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affineBM #if INTER_LIC affineBMMergeCtx.licFlags[affineBMMergeCtx.numValidMergeCand] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeCtx.setDefaultLICParamToCtx(affineBMMergeCtx.numValidMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affineBMMergeCtx.obmcFlags[affineBMMergeCtx.numValidMergeCand] = true; @@ -22419,6 +22879,9 @@ void PU::getBMAffineMergeCand(const PredictionUnit &pu, AffineMergeCtx& affineBM affineBMMergeCtx.bcwIdx[cnt] = BCW_DEFAULT; #if INTER_LIC affineBMMergeCtx.licFlags[cnt] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeCtx.setDefaultLICParamToCtx(cnt); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affineBMMergeCtx.obmcFlags[cnt] = true; @@ -22462,6 +22925,9 @@ void PU::getRMVFAffineCand(const PredictionUnit &pu, AffineMergeCtx& affineMerge #endif #if INTER_LIC affMrgCtxTemp.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + affMrgCtxTemp.setDefaultLICParamToCtx(i); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affMrgCtxTemp.obmcFlags[i] = true; @@ -22498,6 +22964,16 @@ void PU::getRMVFAffineCand(const PredictionUnit &pu, AffineMergeCtx& affineMerge break; } } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + bool isInherited = pu.cu->geoFlag; + if (isInherited) + { + for (int i = 0; i < affMrgCtxTemp.numValidMergeCand; ++i) + { + affMrgCtxTemp.setInheritAndLICFlags(i); + } + } +#endif affineMergeRMVFOriCtx = affMrgCtxTemp; PredictionUnit pu2 = pu; #if JVET_AG0164_AFFINE_GPM @@ -22544,6 +23020,16 @@ void PU::getRMVFAffineCand(const PredictionUnit &pu, AffineMergeCtx& affineMerge break; } } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + bool isInherited = pu.cu->geoFlag; + if (isInherited) + { + for (int i = 0; i < affMrgCtxTemp.numValidMergeCand; ++i) + { + affMrgCtxTemp.setInheritAndLICFlags(i); + } + } +#endif #if JVET_W0090_ARMC_TM } #endif @@ -22759,6 +23245,9 @@ bool PU::getBMNonAdjCstMergeCand(const PredictionUnit &pu, AffineMergeCtx &affin affineBMMergeCtx.licFlags[affineBMMergeCtx.numValidMergeCand] = (dir != 3) ? bLICFlag : false; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeCtx.setDefaultLICParamToCtx(affineBMMergeCtx.numValidMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL #if JVET_AD0213_LIC_IMP @@ -23233,6 +23722,9 @@ void PU::getTMVPCandOpt(const PredictionUnit &pu, RefPicList refList, int refIdx #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mrgCtx.interDirNeighbours[ui] = 0; mrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -24828,11 +25320,14 @@ void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx ) #endif #if INTER_LIC geoMrgCtx.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + geoMrgCtx.setDefaultLICParamToCtx(i); +#endif #endif } #if JVET_W0097_GPM_MMVD_TM #if JVET_AE0046_BI_GPM - if ( pu.gpmDirMode || (mergeCtx == NULL) ) + if ( pu.gpmDirMode || (mergeCtx == NULL)) #else if (mergeCtx == NULL) #endif @@ -24860,6 +25355,16 @@ void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx ) { memcpy(tmpMergeCtx.interDirNeighbours, mergeCtx->interDirNeighbours, maxNumMergeCand * sizeof(unsigned char)); memcpy(tmpMergeCtx.mvFieldNeighbours, mergeCtx->mvFieldNeighbours, (maxNumMergeCand << 1) * sizeof(MvField)); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + for (int i = 0; i < maxNumMergeCand; ++i) + { + tmpMergeCtx.copyLICParamFromCtx(i, *mergeCtx, i); +#if JVET_AG0276_NLIC + tmpMergeCtx.licFlags[i] = mergeCtx->licFlags[i]; + tmpMergeCtx.altLMParaNeighbours[i] = mergeCtx->altLMParaNeighbours[i]; +#endif + } +#endif } #endif @@ -24870,17 +25375,42 @@ void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx ) geoMrgCtx = tmpMergeCtx; geoMrgCtx.numValidMergeCand = maxNumMergeCand; - for (int32_t i = 0; i < maxNumMergeCand; i++) { geoMrgCtx.useAltHpelIf[i] = false; geoMrgCtx.bcwIdx[i] = BCW_DEFAULT; #if JVET_AG0276_NLIC geoMrgCtx.altLMFlag[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(!pu.cu->geoFlag) +#endif geoMrgCtx.altLMParaNeighbours[i].resetAltLinearModel(); #endif #if INTER_LIC +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_NLIC + bool isLic = geoMrgCtx.licFlags[i]; +#endif +#endif geoMrgCtx.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + geoMrgCtx.licInheritPara[i] = false; + if(pu.cu->geoFlag) + { + geoMrgCtx.setInheritAndLICFlags(i); +#if JVET_AG0276_NLIC + if (isLic && !geoMrgCtx.licInheritPara[i]) + { + geoMrgCtx.setLICParamUsingAltLM(i); + geoMrgCtx.setInheritAndLICFlags(i); + } +#endif + } +#else + geoMrgCtx.setDefaultLICParamToCtx(i); +#endif +#endif #endif #if MULTI_HYP_PRED geoMrgCtx.addHypNeighbours[i].clear(); @@ -24900,6 +25430,34 @@ void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx ) geoMrgCtx.mvFieldNeighbours[(geoMrgCtx.numValidMergeCand << 1) + parity].mv = tmpMergeCtx.mvFieldNeighbours[(i << 1) + parity].mv; geoMrgCtx.mvFieldNeighbours[(geoMrgCtx.numValidMergeCand << 1) + !parity].refIdx = -1; geoMrgCtx.mvFieldNeighbours[(geoMrgCtx.numValidMergeCand << 1) + parity].refIdx = tmpMergeCtx.mvFieldNeighbours[(i << 1) + parity].refIdx; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_NLIC + bool isLic = tmpMergeCtx.licFlags[i]; +#endif + geoMrgCtx.licFlags[geoMrgCtx.numValidMergeCand] = false; + geoMrgCtx.licInheritPara[geoMrgCtx.numValidMergeCand] = false; + if (pu.cu->geoFlag) + { + for (int comp = 0; comp < 3; comp++) + { + geoMrgCtx.licScale [geoMrgCtx.numValidMergeCand][ parity][comp] = tmpMergeCtx.licScale [i][parity][comp]; + geoMrgCtx.licScale [geoMrgCtx.numValidMergeCand][!parity][comp] = 32; + geoMrgCtx.licOffset[geoMrgCtx.numValidMergeCand][ parity][comp] = tmpMergeCtx.licOffset[i][parity][comp]; + geoMrgCtx.licOffset[geoMrgCtx.numValidMergeCand][!parity][comp] = 0; + } +#if JVET_AG0276_NLIC + geoMrgCtx.altLMParaNeighbours[geoMrgCtx.numValidMergeCand] = tmpMergeCtx.altLMParaNeighbours[i]; +#endif + geoMrgCtx.setInheritAndLICFlags(geoMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + if (isLic && !geoMrgCtx.licInheritPara[geoMrgCtx.numValidMergeCand]) + { + geoMrgCtx.setLICParamUsingAltLM(geoMrgCtx.numValidMergeCand); + geoMrgCtx.setInheritAndLICFlags(geoMrgCtx.numValidMergeCand); + } +#endif + } +#endif #if JVET_W0097_GPM_MMVD_TM if (geoMrgCtx.xCheckSimilarMotion(geoMrgCtx.numValidMergeCand, PU::getBDMVRMvdThreshold(pu))) { @@ -24925,6 +25483,34 @@ void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx ) geoMrgCtx.mvFieldNeighbours[(geoMrgCtx.numValidMergeCand << 1) + parity].mv = Mv(0, 0); geoMrgCtx.mvFieldNeighbours[(geoMrgCtx.numValidMergeCand << 1) + !parity].refIdx = tmpMergeCtx.mvFieldNeighbours[(i << 1) + !parity].refIdx; geoMrgCtx.mvFieldNeighbours[(geoMrgCtx.numValidMergeCand << 1) + parity].refIdx = -1; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_NLIC + bool isLic = tmpMergeCtx.licFlags[i]; +#endif + geoMrgCtx.licFlags[geoMrgCtx.numValidMergeCand] = false; + geoMrgCtx.licInheritPara[geoMrgCtx.numValidMergeCand] = false; + if (pu.cu->geoFlag) + { + for (int comp = 0; comp < 3; comp++) + { + geoMrgCtx.licScale [geoMrgCtx.numValidMergeCand][!parity][comp] = tmpMergeCtx.licScale [i][!parity][comp]; + geoMrgCtx.licScale [geoMrgCtx.numValidMergeCand][ parity][comp] = 32; + geoMrgCtx.licOffset[geoMrgCtx.numValidMergeCand][!parity][comp] = tmpMergeCtx.licOffset[i][!parity][comp]; + geoMrgCtx.licOffset[geoMrgCtx.numValidMergeCand][ parity][comp] = 0; + } +#if JVET_AG0276_NLIC + geoMrgCtx.altLMParaNeighbours[geoMrgCtx.numValidMergeCand] = tmpMergeCtx.altLMParaNeighbours[i]; +#endif + geoMrgCtx.setInheritAndLICFlags(geoMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + if (isLic && !geoMrgCtx.licInheritPara[geoMrgCtx.numValidMergeCand]) + { + geoMrgCtx.setLICParamUsingAltLM(geoMrgCtx.numValidMergeCand); + geoMrgCtx.setInheritAndLICFlags(geoMrgCtx.numValidMergeCand); + } +#endif + } +#endif #if JVET_W0097_GPM_MMVD_TM if (geoMrgCtx.xCheckSimilarMotion(geoMrgCtx.numValidMergeCand, PU::getBDMVRMvdThreshold(pu))) { @@ -24960,6 +25546,34 @@ void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx ) geoMrgCtx.mvFieldNeighbours[(geoMrgCtx.numValidMergeCand << 1) + parity].mv = Mv(0, 0); geoMrgCtx.mvFieldNeighbours[(geoMrgCtx.numValidMergeCand << 1) + !parity].refIdx = tmpMergeCtx.mvFieldNeighbours[(i << 1) + !parity].refIdx; geoMrgCtx.mvFieldNeighbours[(geoMrgCtx.numValidMergeCand << 1) + parity].refIdx = -1; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_NLIC + bool isLic = tmpMergeCtx.licFlags[i]; +#endif + geoMrgCtx.licFlags[geoMrgCtx.numValidMergeCand] = false; + geoMrgCtx.licInheritPara[geoMrgCtx.numValidMergeCand] = false; + if (pu.cu->geoFlag) + { + for (int comp = 0; comp < 3; comp++) + { + geoMrgCtx.licScale [geoMrgCtx.numValidMergeCand][!parity][comp] = tmpMergeCtx.licScale [i][!parity][comp]; + geoMrgCtx.licScale [geoMrgCtx.numValidMergeCand][ parity][comp] = 32; + geoMrgCtx.licOffset[geoMrgCtx.numValidMergeCand][!parity][comp] = tmpMergeCtx.licOffset[i][!parity][comp]; + geoMrgCtx.licOffset[geoMrgCtx.numValidMergeCand][ parity][comp] = 0; + } +#if JVET_AG0276_NLIC + geoMrgCtx.altLMParaNeighbours[geoMrgCtx.numValidMergeCand] = tmpMergeCtx.altLMParaNeighbours[i]; +#endif + geoMrgCtx.setInheritAndLICFlags(geoMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + if (isLic && !geoMrgCtx.licInheritPara[geoMrgCtx.numValidMergeCand]) + { + geoMrgCtx.setLICParamUsingAltLM(geoMrgCtx.numValidMergeCand); + geoMrgCtx.setInheritAndLICFlags(geoMrgCtx.numValidMergeCand); + } +#endif + } +#endif if (geoMrgCtx.xCheckSimilarMotion(geoMrgCtx.numValidMergeCand, PU::getBDMVRMvdThreshold(pu))) { continue; @@ -25011,6 +25625,15 @@ void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx ) geoMrgCtx.interDirNeighbours[geoMrgCtx.numValidMergeCand] = 1; geoMrgCtx.mvFieldNeighbours[geoMrgCtx.numValidMergeCand * 2].setMvField(avgMv, firstAvailRefIdx); geoMrgCtx.mvFieldNeighbours[geoMrgCtx.numValidMergeCand * 2 + 1].setMvField(Mv(0, 0), NOT_VALID); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if INTER_LIC + geoMrgCtx.licFlags[geoMrgCtx.numValidMergeCand] = false; + geoMrgCtx.setDefaultLICParamToCtx(geoMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + geoMrgCtx.altLMParaNeighbours[geoMrgCtx.numValidMergeCand].resetAltLinearModel(); +#endif +#endif +#endif if (!geoMrgCtx.xCheckSimilarMotion(geoMrgCtx.numValidMergeCand, PU::getBDMVRMvdThreshold(pu))) { @@ -25052,6 +25675,15 @@ void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx ) geoMrgCtx.interDirNeighbours[geoMrgCtx.numValidMergeCand] = 2; geoMrgCtx.mvFieldNeighbours[geoMrgCtx.numValidMergeCand * 2 + 1].setMvField(avgMv, firstAvailRefIdx); geoMrgCtx.mvFieldNeighbours[geoMrgCtx.numValidMergeCand * 2].setMvField(Mv(0, 0), NOT_VALID); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if INTER_LIC + geoMrgCtx.licFlags[geoMrgCtx.numValidMergeCand] = false; + geoMrgCtx.setDefaultLICParamToCtx(geoMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + geoMrgCtx.altLMParaNeighbours[geoMrgCtx.numValidMergeCand].resetAltLinearModel(); +#endif +#endif +#endif if (!geoMrgCtx.xCheckSimilarMotion(geoMrgCtx.numValidMergeCand, PU::getBDMVRMvdThreshold(pu))) { geoMrgCtx.numValidMergeCand++; @@ -25110,6 +25742,15 @@ void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx ) ++r; ++refcnt; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if INTER_LIC + geoMrgCtx.licFlags[geoMrgCtx.numValidMergeCand] = false; + geoMrgCtx.setDefaultLICParamToCtx(geoMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + geoMrgCtx.altLMParaNeighbours[geoMrgCtx.numValidMergeCand].resetAltLinearModel(); +#endif +#endif +#endif geoMrgCtx.numValidMergeCand++; #if JVET_Z0127_SPS_MHP_MAX_MRG_CAND @@ -25572,6 +26213,9 @@ void PU::spanGeoMotionInfo( PredictionUnit &pu, MergeCtx &geoMrgCtx, const uint8 #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL spanSCCInfo(pu); #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + spanLicFlags(pu, pu.cu->licFlag); +#endif } #if JVET_AE0169_GPM_IBC_IBC @@ -26555,6 +27199,9 @@ void PU::spanGeoMMVDMotionInfo( PredictionUnit &pu, MergeCtx &geoMrgCtx, const u #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL spanSCCInfo(pu); #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + spanLicFlags(pu, pu.cu->licFlag); +#endif } #if JVET_AC0112_IBC_CIIP @@ -29060,7 +29707,11 @@ bool PU::isAffineGPMValid(const PredictionUnit& pu) return true; } -void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgCtx, InterPrediction* pcInterPred, AffineMergeCtx* affMergeCtx) +void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgCtx, InterPrediction* pcInterPred +#if !JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , AffineMergeCtx* affMergeCtx +#endif +) { AffineMergeCtx tmpMergeCtx; @@ -29097,6 +29748,9 @@ void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgC #endif #if INTER_LIC gpmAffMrgCtx.licFlags[i] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + gpmAffMrgCtx.setDefaultLICParamToCtx(i); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL gpmAffMrgCtx.obmcFlags[i] = false; @@ -29110,7 +29764,9 @@ void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgC #endif } +#if !JVET_AH0314_LIC_INHERITANCE_FOR_MRG if (affMergeCtx == NULL) +#endif { #if TM_MRG const bool tmMergeFlag = pu.tmMergeFlag; @@ -29168,6 +29824,7 @@ void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgC pu.tmMergeFlag = tmMergeFlag; #endif } +#if !JVET_AH0314_LIC_INHERITANCE_FOR_MRG else { tmpMergeCtx.numValidMergeCand = affMergeCtx->numValidMergeCand; @@ -29177,7 +29834,11 @@ void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgC memcpy(tmpMergeCtx.bcwIdx, affMergeCtx->bcwIdx, tmpMergeCtx.numValidMergeCand * sizeof(uint8_t)); memcpy(tmpMergeCtx.licFlags, affMergeCtx->licFlags, tmpMergeCtx.numValidMergeCand * sizeof(bool)); } +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + bool useInherited = pu.cu->geoFlag; +#endif int affCandIdx = 0; for (int32_t i = 0; i < tmpMergeCtx.numValidMergeCand; i++) { @@ -29199,6 +29860,34 @@ void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgC gpmAffMrgCtx.mvFieldNeighbours[(gpmAffMrgCtx.numValidMergeCand << 1) + (!parity)][cpmvIdx].refIdx = -1; gpmAffMrgCtx.mvFieldNeighbours[(gpmAffMrgCtx.numValidMergeCand << 1) + parity][cpmvIdx].refIdx = tmpMergeCtx.mvFieldNeighbours[(i << 1) + parity][cpmvIdx].refIdx; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM +#if JVET_AG0276_NLIC + bool isLic = tmpMergeCtx.licFlags[i]; +#endif + gpmAffMrgCtx.licFlags[gpmAffMrgCtx.numValidMergeCand] = false; + gpmAffMrgCtx.licInheritPara[gpmAffMrgCtx.numValidMergeCand] = false; + if (useInherited) + { + for (int comp = 0; comp < 3; comp++) + { + gpmAffMrgCtx.licScale [gpmAffMrgCtx.numValidMergeCand][ parity][comp] = tmpMergeCtx.licScale [i][parity][comp]; + gpmAffMrgCtx.licScale [gpmAffMrgCtx.numValidMergeCand][!parity][comp] = 32; + gpmAffMrgCtx.licOffset[gpmAffMrgCtx.numValidMergeCand][ parity][comp] = tmpMergeCtx.licOffset[i][parity][comp]; + gpmAffMrgCtx.licOffset[gpmAffMrgCtx.numValidMergeCand][!parity][comp] = 0; + } +#if JVET_AG0276_NLIC + gpmAffMrgCtx.altLMParaNeighbours[gpmAffMrgCtx.numValidMergeCand] = tmpMergeCtx.altLMParaNeighbours[i]; +#endif + gpmAffMrgCtx.setInheritAndLICFlags(gpmAffMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + if (isLic && !gpmAffMrgCtx.licInheritPara[gpmAffMrgCtx.numValidMergeCand]) + { + gpmAffMrgCtx.setLICParamUsingAltLM(gpmAffMrgCtx.numValidMergeCand); + gpmAffMrgCtx.setInheritAndLICFlags(gpmAffMrgCtx.numValidMergeCand); + } +#endif + } +#endif if (gpmAffMrgCtx.xCheckSimilarMotion(gpmAffMrgCtx.numValidMergeCand)) { @@ -29226,6 +29915,34 @@ void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgC gpmAffMrgCtx.mvFieldNeighbours[(gpmAffMrgCtx.numValidMergeCand << 1) + (!parity)][cpmvIdx].refIdx = tmpMergeCtx.mvFieldNeighbours[(i << 1) + (!parity)][cpmvIdx].refIdx; gpmAffMrgCtx.mvFieldNeighbours[(gpmAffMrgCtx.numValidMergeCand << 1) + parity][cpmvIdx].refIdx = -1; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM +#if JVET_AG0276_NLIC + bool isLic = tmpMergeCtx.licFlags[i]; +#endif + gpmAffMrgCtx.licFlags[gpmAffMrgCtx.numValidMergeCand] = false; + gpmAffMrgCtx.licInheritPara[gpmAffMrgCtx.numValidMergeCand] = false; + if (useInherited) + { + for (int comp = 0; comp < 3; comp++) + { + gpmAffMrgCtx.licScale [gpmAffMrgCtx.numValidMergeCand][!parity][comp] = tmpMergeCtx.licScale [i][!parity][comp]; + gpmAffMrgCtx.licScale [gpmAffMrgCtx.numValidMergeCand][ parity][comp] = 32; + gpmAffMrgCtx.licOffset[gpmAffMrgCtx.numValidMergeCand][!parity][comp] = tmpMergeCtx.licOffset[i][!parity][comp]; + gpmAffMrgCtx.licOffset[gpmAffMrgCtx.numValidMergeCand][ parity][comp] = 0; + } +#if JVET_AG0276_NLIC + gpmAffMrgCtx.altLMParaNeighbours[gpmAffMrgCtx.numValidMergeCand] = tmpMergeCtx.altLMParaNeighbours[i]; +#endif + gpmAffMrgCtx.setInheritAndLICFlags(gpmAffMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + if (isLic && !gpmAffMrgCtx.licInheritPara[gpmAffMrgCtx.numValidMergeCand]) + { + gpmAffMrgCtx.setLICParamUsingAltLM(gpmAffMrgCtx.numValidMergeCand); + gpmAffMrgCtx.setInheritAndLICFlags(gpmAffMrgCtx.numValidMergeCand); + } +#endif + } +#endif if (gpmAffMrgCtx.xCheckSimilarMotion(gpmAffMrgCtx.numValidMergeCand)) { continue; @@ -29264,6 +29981,34 @@ void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgC gpmAffMrgCtx.mvFieldNeighbours[(gpmAffMrgCtx.numValidMergeCand << 1) + (!parity)][cpmvIdx].refIdx = tmpMergeCtx.mvFieldNeighbours[(i << 1) + (!parity)][cpmvIdx].refIdx; gpmAffMrgCtx.mvFieldNeighbours[(gpmAffMrgCtx.numValidMergeCand << 1) + (parity)][cpmvIdx].refIdx = -1; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM +#if JVET_AG0276_NLIC + bool isLic = tmpMergeCtx.licFlags[i]; +#endif + gpmAffMrgCtx.licFlags[gpmAffMrgCtx.numValidMergeCand] = false; + gpmAffMrgCtx.licInheritPara[gpmAffMrgCtx.numValidMergeCand] = false; + if (useInherited) + { + for (int comp = 0; comp < 3; comp++) + { + gpmAffMrgCtx.licScale [gpmAffMrgCtx.numValidMergeCand][!parity][comp] = tmpMergeCtx.licScale [i][!parity][comp]; + gpmAffMrgCtx.licScale [gpmAffMrgCtx.numValidMergeCand][ parity][comp] = 32; + gpmAffMrgCtx.licOffset[gpmAffMrgCtx.numValidMergeCand][!parity][comp] = tmpMergeCtx.licOffset[i][!parity][comp]; + gpmAffMrgCtx.licOffset[gpmAffMrgCtx.numValidMergeCand][ parity][comp] = 0; + } +#if JVET_AG0276_NLIC + gpmAffMrgCtx.altLMParaNeighbours[gpmAffMrgCtx.numValidMergeCand] = tmpMergeCtx.altLMParaNeighbours[i]; +#endif + gpmAffMrgCtx.setInheritAndLICFlags(gpmAffMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + if (isLic && !gpmAffMrgCtx.licInheritPara[gpmAffMrgCtx.numValidMergeCand]) + { + gpmAffMrgCtx.setLICParamUsingAltLM(gpmAffMrgCtx.numValidMergeCand); + gpmAffMrgCtx.setInheritAndLICFlags(gpmAffMrgCtx.numValidMergeCand); + } +#endif + } +#endif if (gpmAffMrgCtx.xCheckSimilarMotion(gpmAffMrgCtx.numValidMergeCand)) { continue; @@ -29319,6 +30064,15 @@ void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgC gpmAffMrgCtx.mvFieldNeighbours[gpmAffMrgCtx.numValidMergeCand * 2 + 1][0].setMvField(Mv(0, 0), NOT_VALID); gpmAffMrgCtx.mvFieldNeighbours[gpmAffMrgCtx.numValidMergeCand * 2 + 1][1].setMvField(Mv(0, 0), NOT_VALID); gpmAffMrgCtx.mvFieldNeighbours[gpmAffMrgCtx.numValidMergeCand * 2 + 1][2].setMvField(Mv(0, 0), NOT_VALID); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if INTER_LIC + gpmAffMrgCtx.licFlags[gpmAffMrgCtx.numValidMergeCand] = false; + gpmAffMrgCtx.setDefaultLICParamToCtx(gpmAffMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + gpmAffMrgCtx.altLMParaNeighbours[gpmAffMrgCtx.numValidMergeCand].resetAltLinearModel(); +#endif +#endif +#endif if (!gpmAffMrgCtx.xCheckSimilarMotion(gpmAffMrgCtx.numValidMergeCand)) { @@ -29369,6 +30123,15 @@ void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgC gpmAffMrgCtx.mvFieldNeighbours[gpmAffMrgCtx.numValidMergeCand * 2][0].setMvField(Mv(0, 0), NOT_VALID); gpmAffMrgCtx.mvFieldNeighbours[gpmAffMrgCtx.numValidMergeCand * 2][1].setMvField(Mv(0, 0), NOT_VALID); gpmAffMrgCtx.mvFieldNeighbours[gpmAffMrgCtx.numValidMergeCand * 2][2].setMvField(Mv(0, 0), NOT_VALID); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if INTER_LIC + gpmAffMrgCtx.licFlags[gpmAffMrgCtx.numValidMergeCand] = false; + gpmAffMrgCtx.setDefaultLICParamToCtx(gpmAffMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + gpmAffMrgCtx.altLMParaNeighbours[gpmAffMrgCtx.numValidMergeCand].resetAltLinearModel(); +#endif +#endif +#endif if (!gpmAffMrgCtx.xCheckSimilarMotion(gpmAffMrgCtx.numValidMergeCand)) { @@ -29419,6 +30182,15 @@ void PU::getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgC ++r; ++refcnt; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if INTER_LIC + gpmAffMrgCtx.licFlags[gpmAffMrgCtx.numValidMergeCand] = false; + gpmAffMrgCtx.setDefaultLICParamToCtx(gpmAffMrgCtx.numValidMergeCand); +#if JVET_AG0276_NLIC + gpmAffMrgCtx.altLMParaNeighbours[gpmAffMrgCtx.numValidMergeCand].resetAltLinearModel(); +#endif +#endif +#endif gpmAffMrgCtx.numValidMergeCand++; @@ -29548,3 +30320,5 @@ void CU::saveModelsInHEIP(const CodingUnit &cu) } } #endif + + diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h index cd7a642dea606365d6f7c080807bf161756a7086..9c02f938532341e37998dd47217508d4891eb0ed 100644 --- a/source/Lib/CommonLib/UnitTools.h +++ b/source/Lib/CommonLib/UnitTools.h @@ -314,13 +314,25 @@ namespace PU , bool enableTh4Gpm = false #endif ); -#if JVET_AG0276_NLIC - void getAltMergeCandidates (const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx); +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG + void getAltMergeCandidates (const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , bool isLicInheritCand = false +#endif + ); #if JVET_AG0276_LIC_FLAG_SIGNALING void getAltBRMergeCandidates (const PredictionUnit &pu, AltLMMergeCtx& cMrgCtx); - bool isValidAltMergeCandidate (const PredictionUnit &pu, bool isBRCand = false); + bool isValidAltMergeCandidate (const PredictionUnit &pu, bool isBRCand = false +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , bool isLicInheritCand = false +#endif + ); #else - bool isValidAltMergeCandidate (const PredictionUnit &pu); + bool isValidAltMergeCandidate (const PredictionUnit &pu +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , bool isLicInheritCand = false +#endif + ); #endif uint32_t getAltMergeMvdThreshold (const PredictionUnit &pu); #endif @@ -734,7 +746,11 @@ namespace PU #endif #if JVET_AG0164_AFFINE_GPM - void getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgCtx, InterPrediction* pcInterPred, AffineMergeCtx* affMergeCtx = NULL); + void getGeoAffMergeCandidates(PredictionUnit& pu, AffineMergeCtx& gpmAffMrgCtx, InterPrediction* pcInterPred +#if !JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , AffineMergeCtx* affMergeCtx = NULL +#endif + ); bool isAffineGPMValid(const PredictionUnit& pu); bool isAffineGPMSizeValid(const PredictionUnit& pu); diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index fcdfcf6f0ff88e2a966d8f0ae347edae1721b0e4..fe70ad864577c22528ce7f193def8d3508432f2c 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -6062,6 +6062,43 @@ void CABACReader::geo_merge_idx1(PredictionUnit& pu) #if JVET_AA0058_GPM_ADAPTIVE_BLENDING void CABACReader::geoAdaptiveBlendingIdx( PredictionUnit& pu ) { +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + int blkSizeSmall = pu.lwidth() < pu.lheight() ? pu.lwidth() : pu.lheight(); + int offset = (blkSizeSmall < GPM_BLENDING_SIZE_THRESHOLD) ? 0 : 4; + int bin0 = m_BinDecoder.decodeBin(Ctx::GeoBldFlag(0 + offset)); + if (bin0 == 1) + { + pu.geoBldIdx = 2; //1 + } + else + { + int bin1 = m_BinDecoder.decodeBin(Ctx::GeoBldFlag(1 + offset)); + if (bin1 == 0) + { + int bin2 = m_BinDecoder.decodeBin(Ctx::GeoBldFlag(3 + offset)); + if (bin2 == 0) + { + pu.geoBldIdx = 4; //000 + } + else + { + pu.geoBldIdx = 3; //001 + } + } + else + { + int bin2 = m_BinDecoder.decodeBin(Ctx::GeoBldFlag(2 + offset)); + if (bin2 == 0) + { + pu.geoBldIdx = 1; //010 + } + else + { + pu.geoBldIdx = 0; //011 + } + } + } +#else int bin0 = m_BinDecoder.decodeBin( Ctx::GeoBldFlag( 0 ) ); if( bin0 == 1 ) { @@ -6095,6 +6132,13 @@ void CABACReader::geoAdaptiveBlendingIdx( PredictionUnit& pu ) } } } +#endif +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + if (blkSizeSmall >= GPM_BLENDING_SIZE_THRESHOLD) + { + pu.geoBldIdx++; + } +#endif DTRACE(g_trace_ctx, D_SYNTAX, "geo_adaptive_blending_idx() geo_bld_idx=%d\n", pu.geoBldIdx); } #endif diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index 172098601ae64b0ebda96ee12781e8273454a19b..467f5d0c7ef48dcd6f60170d059357ace937a7fc 100644 --- a/source/Lib/DecoderLib/DecCu.cpp +++ b/source/Lib/DecoderLib/DecCu.cpp @@ -1985,6 +1985,9 @@ void DecCu::xReconInter(CodingUnit &cu) cu.licOffset[list][comp] = 0; } else +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (!cu.licInheritPara) +#endif { m_pcInterPred->setLicParam(list, comp, cu.licScale[list][comp], cu.licOffset[list][comp]); } @@ -2008,12 +2011,19 @@ void DecCu::xReconInter(CodingUnit &cu) #if INTER_LIC bool orgLicFlag = cu.licFlag; cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool orgLicInheritedFlag = cu.licInheritPara; + cu.licInheritPara = false; +#endif #endif bool orgCiipFlag = cu.firstPU->ciipFlag; cu.firstPU->ciipFlag = false; m_pcInterPred->xPredWoRefinement(*cu.firstPU, predBeforeMCAdjBuffer); #if INTER_LIC cu.licFlag = orgLicFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = orgLicInheritedFlag; +#endif #endif cu.firstPU->ciipFlag = orgCiipFlag; } @@ -2249,8 +2259,15 @@ void DecCu::xReconInter(CodingUnit &cu) } else { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.secAltLMParaUnit.resetAltLinearModel(); +#else cu.secAltLMParaUnit = cu.altLMParaUnit; +#endif } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.altLMParaUnit.resetAltLinearModel(); +#endif if (CU::isSecLicParaNeeded(cu) && CU::isAllowSecLicPara(cu)) { UnitArea localUnitArea(cu.chromaFormat, Area(0, 0, cu.lumaSize().width, cu.lumaSize().height)); @@ -2788,6 +2805,14 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) #endif #if INTER_LIC m_geoTmMrgCtx0.licFlags[pu.geoMergeIdx0] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + m_geoTmMrgCtx0.copyLICParamFromCtx(pu.geoMergeIdx0, m_geoMrgCtx, pu.geoMergeIdx0); + m_geoTmMrgCtx0.licFlags[pu.geoMergeIdx0] = m_geoTmMrgCtx0.licInheritPara[pu.geoMergeIdx0]; +#else + m_geoTmMrgCtx0.setDefaultLICParamToCtx(pu.geoMergeIdx0); +#endif +#endif #endif #if MULTI_HYP_PRED m_geoTmMrgCtx0.addHypNeighbours[pu.geoMergeIdx0] = m_geoMrgCtx.addHypNeighbours[pu.geoMergeIdx0]; @@ -2846,6 +2871,14 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) #endif #if INTER_LIC m_geoTmMrgCtx1.licFlags[pu.geoMergeIdx1] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + m_geoTmMrgCtx1.copyLICParamFromCtx(pu.geoMergeIdx1, m_geoMrgCtx, pu.geoMergeIdx1); + m_geoTmMrgCtx1.licFlags[pu.geoMergeIdx1] = m_geoTmMrgCtx1.licInheritPara[pu.geoMergeIdx1]; +#else + m_geoTmMrgCtx1.setDefaultLICParamToCtx(pu.geoMergeIdx1); +#endif +#endif #endif #if MULTI_HYP_PRED m_geoTmMrgCtx1.addHypNeighbours[pu.geoMergeIdx1] = m_geoMrgCtx.addHypNeighbours[pu.geoMergeIdx1]; @@ -3058,6 +3091,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) #endif #if INTER_LIC affineMergeCtx.licFlags[cnt] = !affineRMVFCtxOppositeLic.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + affineMergeCtx.licInheritPara[cnt] = false; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affineMergeCtx.obmcFlags[cnt] = affineRMVFCtxOppositeLic.obmcFlags[i]; @@ -3096,6 +3132,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) #endif #if INTER_LIC pu.cu->licFlag = affineMergeCtx.licFlags[pu.mergeIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, pu.mergeIdx, pu.cu->licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL pu.cu->obmcFlag = affineMergeCtx.obmcFlags[pu.mergeIdx]; @@ -3334,6 +3373,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) #endif #if INTER_LIC pu.cu->licFlag = affineMergeCtx.licFlags[pu.mergeIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, pu.mergeIdx, pu.cu->licFlag); +#endif #endif #if JVET_AC0185_ENHANCED_TEMPORAL_MOTION_DERIVATION pu.colIdx = affineMergeCtx.colIdx[pu.mergeIdx]; @@ -3839,6 +3881,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) pu.cu->bcwIdx = mrgCtx.bcwIdx[candIdx]; #if JVET_AD0213_LIC_IMP pu.cu->licFlag = mrgCtx.licFlags[candIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setLICParamToPu(pu, candIdx, mrgCtx.licInheritPara[candIdx]); +#endif #endif pu.mv[0] = mrgCtx.mvFieldNeighbours[candIdx << 1].mv; pu.mv[1] = mrgCtx.mvFieldNeighbours[(candIdx << 1) + 1].mv; @@ -3922,6 +3967,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) pu.cu->bcwIdx = mrgCtx.bcwIdx[candIdx]; #if JVET_AD0213_LIC_IMP pu.cu->licFlag = mrgCtx.licFlags[candIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setLICParamToPu(pu, candIdx, mrgCtx.licInheritPara[candIdx]); +#endif #endif pu.mv[0] = mrgCtx.mvFieldNeighbours[candIdx << 1].mv; pu.mv[1] = mrgCtx.mvFieldNeighbours[(candIdx << 1) + 1].mv; @@ -4043,6 +4091,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) for (int i = 0; i < mrgCtx.numValidMergeCand; i++) { mrgCtx.licFlags[i] = !mrgCtx.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[i] = false; +#endif } } #endif @@ -4073,6 +4124,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) for (int i = 0; i < mrgCtx.numValidMergeCand; i++) { mrgCtx.licFlags[i] = !mrgCtx.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[i] = false; +#endif } } #endif @@ -4118,6 +4172,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mrgCtx.interDirNeighbours[ui] = 0; mrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -4185,10 +4242,13 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) for (int i = 0; i < mrgCtx.numValidMergeCand; i++) { mrgCtx.licFlags[i] = !mrgCtx.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[i] = false; +#endif } } #endif -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG if (pu.tmMergeFlag || pu.ciipFlag) { #endif @@ -4213,19 +4273,55 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) #endif AltLMMergeCtx altLMMrgCtx; PU::getAltMergeCandidates(pu, altLMMrgCtx); - m_pcInterPred->adjustMergeCandidates(pu, mrgCtx, altLMMrgCtx, pu.cs->sps->getMaxNumMergeCand()); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + AltLMMergeCtx mrgCtxInherited; + PU::getAltMergeCandidates(pu, mrgCtxInherited, true); +#endif + m_pcInterPred->adjustMergeCandidates(pu, mrgCtx +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , &altLMMrgCtx + , &mrgCtxInherited +#else + , altLMMrgCtx +#endif + , pu.cs->sps->getMaxNumMergeCand()); #if JVET_AG0276_LIC_FLAG_SIGNALING } else { AltLMMergeCtx altLMBRMrgCtx; PU::getAltBRMergeCandidates(pu, altLMBRMrgCtx); - m_pcInterPred->adjustMergeCandidates(pu, mrgCtx, altLMBRMrgCtx, pu.cs->sps->getMaxNumMergeCand()); + m_pcInterPred->adjustMergeCandidates(pu, mrgCtx +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , &altLMBRMrgCtx + , nullptr +#else + , altLMBRMrgCtx +#endif + , pu.cs->sps->getMaxNumMergeCand()); } #endif } else { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AG0276_LIC_FLAG_SIGNALING + if (!PU::isOppositeLIC(pu)) +#else + if(true) +#endif + { + AltLMMergeCtx mrgCtxInherited; + PU::getAltMergeCandidates(pu, mrgCtxInherited, true); + m_pcInterPred->adjustMergeCandidates(pu, mrgCtx, nullptr, &mrgCtxInherited, +#if TM_MRG + pu.tmMergeFlag ? pu.cs->sps->getMaxNumTMMergeCand() : +#endif + pu.cs->sps->getMaxNumMergeCand()); + } + else + { +#endif #if JVET_Z0102_NO_ARMC_FOR_ZERO_CAND m_pcInterPred->adjustMergeCandidates(pu, mrgCtx, #if TM_MRG @@ -4234,9 +4330,20 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) pu.cs->sps->getMaxNumMergeCand()); #else m_pcInterPred->adjustMergeCandidatesInOneCandidateGroup(pu, mrgCtx, pu.mergeIdx + 1, pu.mergeIdx); +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } #endif } } +#elif JVET_AH0314_LIC_INHERITANCE_FOR_MRG + } + else + { + AltLMMergeCtx mrgCtxInherited; + PU::getAltMergeCandidates(pu, mrgCtxInherited, true); + m_pcInterPred->adjustMergeCandidates(pu, mrgCtx, nullptr, &mrgCtxInherited, pu.cs->sps->getMaxNumMergeCand()); + } #endif #if JVET_AB0079_TM_BCW_MRG m_pcInterPred->adjustMergeCandidatesBcwIdx(pu, mrgCtx, pu.mergeIdx); @@ -4283,6 +4390,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) for (int i = 0; i < mrgCtx.numValidMergeCand; i++) { mrgCtx.licFlags[i] = !mrgCtx.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[i] = false; +#endif } } #endif @@ -4307,6 +4417,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) #endif #if INTER_LIC mrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mrgCtx.interDirNeighbours[ui] = 0; mrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -4374,6 +4487,9 @@ void DecCu::xDeriveCUMV(CodingUnit &cu) for (int i = 0; i < mrgCtx.numValidMergeCand; i++) { mrgCtx.licFlags[i] = !mrgCtx.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.licInheritPara[i] = false; +#endif } } #endif diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 69bb99c0ea724bc856ce8bf529a851e03a138020..b3286014de340b7a6e2ae0230d423c453611c8ee 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -4975,8 +4975,20 @@ void CABACWriter::merge_idx( const PredictionUnit& pu ) } #endif #if JVET_AA0058_GPM_ADAPTIVE_BLENDING +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + int blkSizeSmall = pu.lwidth() < pu.lheight() ? pu.lwidth() : pu.lheight(); + if (blkSizeSmall < GPM_BLENDING_SIZE_THRESHOLD) + { + geoAdaptiveBlendingIdx(pu, pu.geoBldIdx); + } + else + { + geoAdaptiveBlendingIdx(pu, pu.geoBldIdx - 1); + } +#else geoAdaptiveBlendingIdx(pu.geoBldIdx); #endif +#endif #if JVET_W0097_GPM_MMVD_TM #if JVET_Y0065_GPM_INTRA @@ -5898,18 +5910,57 @@ uint64_t CABACWriter::geo_affFlag_est(const TempCtx& ctxStart, const int flag, i #if JVET_AA0058_GPM_ADAPTIVE_BLENDING +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV +uint64_t CABACWriter::geoBldFlagEst(const PredictionUnit& pu, const TempCtx& ctxStart, const int flag) +#else uint64_t CABACWriter::geoBldFlagEst(const TempCtx& ctxStart, const int flag) +#endif { getCtx() = ctxStart; resetBits(); - +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + int blkSizeSmall = pu.lwidth() < pu.lheight() ? pu.lwidth() : pu.lheight(); + if (blkSizeSmall < GPM_BLENDING_SIZE_THRESHOLD) + { + geoAdaptiveBlendingIdx(pu, flag); + } + else + geoAdaptiveBlendingIdx(pu, flag - 1); +#else geoAdaptiveBlendingIdx(flag); +#endif return getEstFracBits(); } +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV +void CABACWriter::geoAdaptiveBlendingIdx(const PredictionUnit& pu, const int idx) +#else void CABACWriter::geoAdaptiveBlendingIdx(const int idx) +#endif { +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + int blkSizeSmall = pu.lwidth() < pu.lheight() ? pu.lwidth() : pu.lheight(); + int offset = (blkSizeSmall < GPM_BLENDING_SIZE_THRESHOLD) ? 0 : 4; + if (idx == 2) + { + m_BinEncoder.encodeBin(1, Ctx::GeoBldFlag(0 + offset)); + } + else + { + m_BinEncoder.encodeBin(0, Ctx::GeoBldFlag(0 + offset)); + if (idx == 0 || idx == 1) + { + m_BinEncoder.encodeBin(1, Ctx::GeoBldFlag(1 + offset)); + m_BinEncoder.encodeBin(idx == 0, Ctx::GeoBldFlag(2 + offset)); + } + else + { + m_BinEncoder.encodeBin(0, Ctx::GeoBldFlag(1 + offset)); + m_BinEncoder.encodeBin(idx == 3, Ctx::GeoBldFlag(3 + offset)); + } + } +#else if (idx == 2) { m_BinEncoder.encodeBin(1, Ctx::GeoBldFlag(0)); @@ -5928,6 +5979,7 @@ void CABACWriter::geoAdaptiveBlendingIdx(const int idx) m_BinEncoder.encodeBin(idx == 3, Ctx::GeoBldFlag(3)); } } +#endif DTRACE(g_trace_ctx, D_SYNTAX, "geo_adaptive_blending_idx() geo_bld_idx=%d\n", idx); } #endif diff --git a/source/Lib/EncoderLib/CABACWriter.h b/source/Lib/EncoderLib/CABACWriter.h index 45e3b5933726d79e0af9ceecdff4921fdf8cd761..2627ae6352cbd55044493a8f304e30c9819a220f 100644 --- a/source/Lib/EncoderLib/CABACWriter.h +++ b/source/Lib/EncoderLib/CABACWriter.h @@ -252,9 +252,14 @@ public: uint64_t geo_affFlag_est(const TempCtx& ctxStart, const int flag, int ctxOffset); #endif #if JVET_AA0058_GPM_ADAPTIVE_BLENDING +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + uint64_t geoBldFlagEst (const PredictionUnit& pu, const TempCtx& ctxStart, const int flag); + void geoAdaptiveBlendingIdx (const PredictionUnit& pu, const int idx); +#else uint64_t geoBldFlagEst (const TempCtx& ctxStart, const int flag); void geoAdaptiveBlendingIdx (const int idx); #endif +#endif #if JVET_Z0056_GPM_SPLIT_MODE_REORDERING void geoModeIdx ( const PredictionUnit& pu); void geoModeIdx ( const uint8_t geoMode, const uint8_t altCodeIdx = 0); diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index c8d243a75d36621bada9d64e982c99faec713dd7..8438496e6b3f67a560bbc117687500a3855b4993 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -3754,6 +3754,9 @@ void EncCu::xCheckRDCostHashInter( CodingStructure *&tempCS, CodingStructure *&b cu.qp = encTestMode.qp; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif CU::addPUs(cu); cu.mmvdSkip = false; @@ -3841,7 +3844,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& MergeCtx mergeCtxCIIPtmp; #endif #endif -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG MergeCtx mergeOrgCtx; #endif #if JVET_AG0276_LIC_FLAG_SIGNALING @@ -3930,7 +3933,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& for (int i = 0; i < SUB_TMVP_NUM; i++) { mergeCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG mergeOrgCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); #endif mrgCtx.subPuMvpMiBuf[i] = MotionBuf(m_subPuMiBuf[i], bufSize); @@ -4019,6 +4022,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& cu.tileIdx = tempCS->pps->getTileIdx( tempCS->area.lumaPos() ); #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif PredictionUnit pu( tempCS->area ); @@ -4145,7 +4151,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& m_pcInterSearch->adjustMergeCandidatesLicFlag(pu, mergeCtx); } #endif -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG mergeOrgCtx = mergeCtx; #endif #if JVET_AG0276_LIC_FLAG_SIGNALING @@ -4155,6 +4161,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& for (int i = 0; i < mergeCtx.numValidMergeCand; i++) { mergeCtxOppositeLic.licFlags[i] = !mergeCtx.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mergeCtxOppositeLic.licInheritPara[i] = false; +#endif } } #endif @@ -4169,7 +4178,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& if (!sps.getUseTmvpNmvpReordering()) { m_pcInterSearch->adjustInterMergeCandidates(pu, mergeCtx); -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG mergeOrgCtx = mergeCtx; #endif } @@ -4182,24 +4191,49 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #else m_pcInterSearch->adjustMergeCandidatesInOneCandidateGroup(pu, mergeCtx, pu.cs->sps->getMaxNumMergeCand()); #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + AltLMMergeCtx mrgCtxInherited; + PU::getAltMergeCandidates(pu, mrgCtxInherited, true); +#endif #if JVET_AG0276_NLIC if (pu.cs->sps->getUseAltLM() && !CU::isTLCond(*pu.cu)) { AltLMMergeCtx altLMMrgCtx; PU::getAltMergeCandidates(pu, altLMMrgCtx); - m_pcInterSearch->adjustMergeCandidates(pu, mergeOrgCtx, altLMMrgCtx, pu.cs->sps->getMaxNumMergeCand()); + m_pcInterSearch->adjustMergeCandidates(pu, mergeOrgCtx +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , &altLMMrgCtx + , &mrgCtxInherited +#else + , altLMMrgCtx +#endif + , pu.cs->sps->getMaxNumMergeCand()); #if JVET_AG0276_LIC_FLAG_SIGNALING if (hasOppositelicMrg && pu.cs->sps->getUseMergeOppositeLic()) { AltLMMergeCtx altLMBRMrgCtx; PU::getAltBRMergeCandidates(pu, altLMBRMrgCtx); - m_pcInterSearch->adjustMergeCandidates(pu, mergeCtxOppositeLic, altLMBRMrgCtx, pu.cs->sps->getMaxNumMergeCand()); + m_pcInterSearch->adjustMergeCandidates(pu, mergeCtxOppositeLic +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + , &altLMBRMrgCtx + , nullptr +#else + , altLMBRMrgCtx +#endif + , pu.cs->sps->getMaxNumMergeCand()); } #endif } else { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + m_pcInterSearch->adjustMergeCandidates(pu, mergeOrgCtx + , nullptr + , &mrgCtxInherited + , pu.cs->sps->getMaxNumMergeCand()); +#else mergeOrgCtx = mergeCtx; +#endif #if JVET_AG0276_LIC_FLAG_SIGNALING if (hasOppositelicMrg && pu.cs->sps->getUseMergeOppositeLic()) { @@ -4212,6 +4246,11 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& { m_pcInterSearch->adjustMergeCandidates(pu, mergeCtxOppositeLic, pu.cs->sps->getMaxNumMergeCand()); } +#elif JVET_AH0314_LIC_INHERITANCE_FOR_MRG + m_pcInterSearch->adjustMergeCandidates(pu, mergeOrgCtx + , nullptr + , &mrgCtxInherited + , pu.cs->sps->getMaxNumMergeCand()); #endif } } @@ -4238,6 +4277,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC mergeCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mergeCtx.interDirNeighbours[ui] = 0; mergeCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -4255,6 +4297,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC mergeCtxOppositeLic.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mergeCtxOppositeLic.setDefaultLICParamToCtx(ui); +#endif #endif mergeCtxOppositeLic.interDirNeighbours[ui] = 0; mergeCtxOppositeLic.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -4268,7 +4313,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& } #endif -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG if (mergeOrgCtx.numValidMergeCand != pu.cs->sps->getMaxNumMergeCand()) { mergeOrgCtx.numValidMergeCand = pu.cs->sps->getMaxNumMergeCand(); @@ -4280,6 +4325,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& mergeOrgCtx.altLMParaNeighbours[ui].resetAltLinearModel(); #if INTER_LIC mergeOrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mergeOrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif mergeOrgCtx.interDirNeighbours[ui] = 0; mergeOrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -4292,6 +4340,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& } #endif + #if JVET_AB0079_TM_BCW_MRG mrgCtxCiip.numValidMergeCand = mergeCtx.numValidMergeCand; #if JVET_Z0102_NO_ARMC_FOR_ZERO_CAND @@ -4310,6 +4359,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC mrgCtxCiip.licFlags[uiMergeCand] = mergeCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mrgCtxCiip.copyLICParamFromCtx(uiMergeCand, mergeCtx, uiMergeCand); +#endif #endif #if MULTI_HYP_PRED mrgCtxCiip.addHypNeighbours[uiMergeCand] = mergeCtx.addHypNeighbours[uiMergeCand]; @@ -4324,7 +4376,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& ) { m_pcInterSearch->adjustMergeCandidatesBcwIdx(pu, mergeCtx); -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG m_pcInterSearch->adjustMergeCandidatesBcwIdx(pu, mergeOrgCtx); MergeCtx mergeCtxTemp; mergeCtxTemp = mergeCtx; @@ -4422,6 +4474,12 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC memcpy(ciipTmMrgCtx.licFlags, mergeCtxtmp.licFlags, CIIP_TM_MRG_MAX_NUM_CANDS * sizeof(bool)); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + for (int ui = 0; ui < CIIP_TM_MRG_MAX_NUM_CANDS; ui++) + { + ciipTmMrgCtx.copyLICParamFromCtx(ui, mergeCtxtmp, ui); + } +#endif #endif #if MULTI_HYP_PRED memcpy(ciipTmMrgCtx.addHypNeighbours, mergeCtxtmp.addHypNeighbours, CIIP_TM_MRG_MAX_NUM_CANDS * sizeof(MultiHypVec)); @@ -4638,6 +4696,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& for (int i = 0; i < tmMrgCtxOppositeLic.numValidMergeCand; i++) { tmMrgCtxOppositeLic.licFlags[i] = !tmMrgCtx.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + tmMrgCtxOppositeLic.licInheritPara[i] = false; +#endif } } #endif @@ -4755,6 +4816,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC tmMrgCtx.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + tmMrgCtx.setDefaultLICParamToCtx(ui); +#endif #endif tmMrgCtx.interDirNeighbours[ui] = 0; tmMrgCtx.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -4781,6 +4845,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC tmMrgCtxOppositeLic.licFlags[ui] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + tmMrgCtxOppositeLic.setDefaultLICParamToCtx(ui); +#endif #endif tmMrgCtxOppositeLic.interDirNeighbours[ui] = 0; tmMrgCtxOppositeLic.mvFieldNeighbours[(ui << 1)].refIdx = NOT_VALID; @@ -5081,6 +5148,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC affineMergeCtxOppositeLic.licFlags[cntAffOppositeLic] = !affineMergeCtx.licFlags[i]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + affineMergeCtxOppositeLic.licInheritPara[cntAffOppositeLic] = false; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affineMergeCtxOppositeLic.obmcFlags[cntAffOppositeLic] = affineMergeCtx.obmcFlags[i]; @@ -5153,6 +5223,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineMergeCtxTmp.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtxTmp.setLICParamToPu(pu, uiAffMergeCand, cu.licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag = affineMergeCtxTmp.obmcFlags[uiAffMergeCand]; @@ -5471,6 +5544,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineMergeCtx.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, uiAffMergeCand, pu.cu->licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag = affineMergeCtx.obmcFlags[uiAffMergeCand]; @@ -5570,6 +5646,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineBMMergeCtx.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeCtx.setLICParamToPu(pu, uiAffMergeCand, pu.cu->licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag = affineBMMergeCtx.obmcFlags[uiAffMergeCand]; @@ -5645,6 +5724,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC affineBMMergeL0.licFlags[uiAffMergeCand] = affineBMMergeCtx.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeL0.copyLICParamFromCtx(uiAffMergeCand, affineBMMergeCtx, uiAffMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affineBMMergeL0.obmcFlags[uiAffMergeCand] = affineBMMergeCtx.obmcFlags[uiAffMergeCand]; @@ -5668,6 +5750,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC affineBMMergeL1.licFlags[uiAffMergeCand] = affineBMMergeCtx.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeL1.copyLICParamFromCtx(uiAffMergeCand, affineBMMergeCtx, uiAffMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affineBMMergeL1.obmcFlags[uiAffMergeCand] = affineBMMergeCtx.obmcFlags[uiAffMergeCand]; @@ -5718,6 +5803,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineMergeCtxOppositeLic.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + affineMergeCtxOppositeLic.setLICParamToPu(pu, NOT_VALID, false); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag = affineMergeCtxOppositeLic.obmcFlags[uiAffMergeCand]; @@ -5825,6 +5913,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC affineMergeCtx.licFlags[index] = affineMergeCtx.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.copyLICParamFromCtx(index, affineMergeCtx, uiAffMergeCand); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL affineMergeCtx.obmcFlags[index] = affineMergeCtx.obmcFlags[uiAffMergeCand]; @@ -5858,6 +5949,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineMergeCtx.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, uiAffMergeCand, cu.licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag = affineMergeCtx.obmcFlags[uiAffMergeCand]; @@ -5969,6 +6063,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineMergeCtxOppositeLic.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + affineMergeCtxOppositeLic.setLICParamToPu(pu, NOT_VALID, false); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag = affineMergeCtxOppositeLic.obmcFlags[uiAffMergeCand]; @@ -6424,6 +6521,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.skip = false; cu.mmvdSkip = false; @@ -6628,7 +6728,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& { #if MERGE_ENC_OPT #if JVET_AB0079_TM_BCW_MRG -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG xCheckSATDCostCiipMerge(tempCS, cu, pu, mrgCtxCiip, acMergeTempBuffer, singleMergeTempBuffer, acMergeTmpBuffer, uiNumMrgSATDCand, rdModeList, candCostList, distParam, ctxStart, mergeOrgCtx); #else xCheckSATDCostCiipMerge(tempCS, cu, pu, mrgCtxCiip, acMergeTempBuffer, singleMergeTempBuffer, acMergeTmpBuffer, uiNumMrgSATDCand, rdModeList, candCostList, distParam, ctxStart); @@ -7105,13 +7205,21 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #if JVET_AD0213_LIC_IMP for (int list = 0; list < 2; list++) { for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licScale[list][comp] = 32; + cu.licOffset[list][comp] = 0; +#else cu.licScale[list][comp] = MAX_INT; cu.licOffset[list][comp] = MAX_INT; +#endif } } #endif @@ -7183,6 +7291,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineMergeCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + affineMergeCtx.setLICParamToPu(pu, NOT_VALID, false); +#endif #endif #if JVET_AG0276_NLIC cu.altLMFlag = affineMergeCtx.altLMFlag[uiMergeCand]; @@ -7332,6 +7443,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC pu.cu->licFlag = affineMergeCtxTmp.licFlags[pu.mergeIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtxTmp.setLICParamToPu(pu, pu.mergeIdx, pu.cu->licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL pu.cu->obmcFlag = affineMergeCtxTmp.obmcFlags[pu.mergeIdx]; @@ -7352,6 +7466,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& pu.mergeType = affineMergeCtx.mergeType [pu.mergeIdx]; #if INTER_LIC pu.cu->licFlag = affineMergeCtx.licFlags [pu.mergeIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, pu.mergeIdx, pu.cu->licFlag); +#endif #endif pu.interDir = affineMergeCtx.interDirNeighbours[pu.mergeIdx]; pu.cu->affineType = affineMergeCtx.affineType [pu.mergeIdx]; @@ -7402,6 +7519,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineBMMergeL0.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeL0.setLICParamToPu(pu, uiMergeCand, cu.licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag = affineBMMergeL0.obmcFlags[uiMergeCand]; @@ -7450,6 +7570,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineBMMergeL1.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineBMMergeL1.setLICParamToPu(pu, uiMergeCand, cu.licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag = affineBMMergeL1.obmcFlags[uiMergeCand]; @@ -7504,6 +7627,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineMergeCtxOppositeLic.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + affineMergeCtxOppositeLic.setLICParamToPu(pu, NOT_VALID, false); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag = affineMergeCtxOppositeLic.obmcFlags[uiMergeCand]; @@ -7556,6 +7682,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& #endif #if INTER_LIC cu.licFlag = affineMergeCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, uiMergeCand, cu.licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag = affineMergeCtx.obmcFlags[uiMergeCand]; @@ -7813,9 +7942,19 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& { for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(!cu.licInheritPara) +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + CHECK(cu.licScale[list][comp] != 32 || cu.licOffset[list][comp] != 0, "invalid lic parameters for ciip mode"); +#else CHECK(cu.licScale[list][comp] != MAX_INT || cu.licScale[list][comp] != MAX_INT, "invalid lic parameters for ciip mode"); +#endif if (alwCond) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(!cu.licInheritPara) +#endif m_pcInterSearch->setLicParam(list, comp, pu.cu->licScale[list][comp], pu.cu->licOffset[list][comp]); } else @@ -7938,6 +8077,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& pu.mmvdEncOptMode = 0; m_pcInterSearch->motionCompensation(pu); #if JVET_AD0213_LIC_IMP +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(!cu.licInheritPara) +#endif if (pu.cu->licFlag) { for (int list = 0; list < 2; list++) @@ -7960,6 +8102,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& pu.mvRefine = true; m_pcInterSearch->motionCompensation(pu); #if JVET_AD0213_LIC_IMP +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(!cu.licInheritPara) +#endif if (pu.cu->licFlag) { for (int list = 0; list < 2; list++) @@ -8128,7 +8273,10 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& m_pcInterSearch->motionCompensation(pu, REF_PIC_LIST_X, false, true); #endif #if JVET_AD0213_LIC_IMP - if (pu.cu->licFlag) +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (!cu.licInheritPara) +#endif + if (pu.cu->licFlag) { for (int list = 0; list < 2; list++) { @@ -8150,6 +8298,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& if (pu.cu->licFlag) { m_pcInterSearch->motionCompensation(pu); +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(!cu.licInheritPara) +#endif for (int list = 0; list < 2; list++) { if (pu.refIdx[list] >= 0) @@ -8248,6 +8399,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& pu.cu->licOffset[list][comp] = 0; } else +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (!cu.licInheritPara) +#endif { m_pcInterSearch->setLicParam(list, comp, pu.cu->licScale[list][comp], pu.cu->licOffset[list][comp]); } @@ -8483,8 +8637,12 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct double geoTMFlagCost[2]; #endif #if JVET_AA0058_GPM_ADAPTIVE_BLENDING +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + double geoBldFlagCost[TOTAL_GEO_BLENDING_NUM]; +#else double geoBldFlagCost[GEO_BLENDING_NUM]; #endif +#endif #if JVET_AG0164_AFFINE_GPM double geoAffMergeIdxCost[GEO_MAX_NUM_UNI_AFF_CANDS]; uint8_t maxNumGpmAffMergeCandidates = tempCS->sps->getMaxNumGpmAffCand(); @@ -8539,6 +8697,7 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct geoTMFlagCost[idx] = (double)fracBits * sqrtLambdaFracBits; } #endif +#if !JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV #if JVET_AA0058_GPM_ADAPTIVE_BLENDING for (int idx = 0; idx < GEO_BLENDING_NUM; idx++) { @@ -8546,6 +8705,7 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct geoBldFlagCost[idx] = (double)fracBits * sqrtLambdaFracBits; } #endif +#endif #if JVET_Y0065_GPM_INTRA bool bUseOnlyOneVector = (tempCS->slice->isInterP() || tempCS->sps->getMaxNumGeoCand() == 1); double geoIntraFlag0Cost[2], geoIntraFlag1Cost[2][2], geoIntraIdxCost[GEO_MAX_NUM_INTRA_CANDS]; @@ -8579,6 +8739,9 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct #endif #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.bcwIdx = BCW_DEFAULT; cu.geoFlag = true; @@ -8643,9 +8806,22 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct #endif maxNumMergeCandidates = min((int)maxNumMergeCandidates, mergeCtx[GEO_TM_OFF].numValidMergeCand); #else - PU::getGeoMergeCandidates(pu, mergeCtx, &m_mergeCand); + PU::getGeoMergeCandidates(pu, mergeCtx + , &m_mergeCand + ); maxNumMergeCandidates = min((int)maxNumMergeCandidates, mergeCtx.numValidMergeCand); #endif +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + int blkSizeSmall = pu.lwidth() < pu.lheight() ? pu.lwidth() : pu.lheight(); + int startIdx = (blkSizeSmall < GPM_BLENDING_SIZE_THRESHOLD) ? 0 : 1; + int endIdx = (blkSizeSmall < GPM_BLENDING_SIZE_THRESHOLD) ? GEO_BLENDING_NUM : TOTAL_GEO_BLENDING_NUM; + for (uint8_t idx = startIdx; idx < endIdx; idx++) + { + uint64_t fracBits = m_CABACEstimator->geoBldFlagEst(pu, ctxStart, idx); + geoBldFlagCost[idx] = (double)fracBits * sqrtLambdaFracBits; + } + m_CABACEstimator->getCtx() = ctxStart; +#endif #if JVET_AG0164_AFFINE_GPM AffineMergeCtx affMergeCtx; int numRegularGpmMergeCand = maxNumMergeCandidates; @@ -9065,6 +9241,10 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct GeoBlendInfo geoBlendInfo[GEO_BLEND_MAX_NUM_CANDS]; int numGeoBlendInfoCand = 0; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licFlag = false; + mergeCtx[GEO_TM_OFF].setLICParamToPu(*cu.firstPU, NOT_VALID, false); +#endif GeoBlendInfo geoBIdst; m_pcInterSearch->getGeoBlendCand( cu, mergeCtx[GEO_TM_OFF], -1, geoBIdst, geoBlendInfo, &numGeoBlendInfoCand ); @@ -9412,7 +9592,14 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct bool mmvdFlag1 = false; #if JVET_AA0058_GPM_ADAPTIVE_BLENDING +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + int blkSizeSmall = pu.lwidth() < pu.lheight() ? pu.lwidth() : pu.lheight(); + int startIdx = (blkSizeSmall < GPM_BLENDING_SIZE_THRESHOLD) ? 0 : 1; + int endIdx = (blkSizeSmall < GPM_BLENDING_SIZE_THRESHOLD) ? GEO_BLENDING_NUM : TOTAL_GEO_BLENDING_NUM; + for (uint8_t bldIdx = startIdx; bldIdx < endIdx; bldIdx++) +#else for (uint8_t bldIdx = 0; bldIdx < GEO_BLENDING_NUM; bldIdx++) +#endif { geoCombinations[candidateIdx * GEO_BLENDING_NUM + bldIdx] = m_acGeoWeightedBuffer[candidateIdx * GEO_BLENDING_NUM + bldIdx].getBuf(localUnitArea); #if JVET_Y0065_GPM_INTRA @@ -10157,6 +10344,9 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct cu.mtsFlag = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.bcwIdx = BCW_DEFAULT; cu.geoFlag = true; @@ -10267,6 +10457,36 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct pu.gpmDmvrRefinePart1 = pu.geoMergeIdx1 < refinePossible.size() ? refinePossible[pu.geoMergeIdx1] : false; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + { + int targetMergeIdx = pu.geoMergeIdx1; +#if JVET_AG0164_AFFINE_GPM + bool isAffine = pu.affineGPM[1]; +#endif +#if JVET_Y0065_GPM_INTRA +#if JVET_AG0164_AFFINE_GPM + if (targetMergeIdx >= GEO_MAX_ALL_INTER_UNI_CANDS) +#else + if (targetMergeIdx >= GEO_MAX_NUM_UNI_CANDS) +#endif + { + targetMergeIdx = pu.geoMergeIdx0; +#if JVET_AG0164_AFFINE_GPM + isAffine = pu.affineGPM[0]; +#endif + } +#endif +#if JVET_AG0164_AFFINE_GPM + if (isAffine) + { + affMergeCtx.setAffMergeInfo(pu, targetMergeIdx); + pu.cu->affine = false; + } + else +#endif + mergeCtxRegular.setMergeInfo(pu, targetMergeIdx); + } +#endif #if TM_MRG MergeCtx *mergeTmCtx0 = nullptr; MergeCtx *mergeTmCtx1 = nullptr; @@ -10456,6 +10676,9 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct cu.mtsFlag = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.bcwIdx = BCW_DEFAULT; cu.geoFlag = true; @@ -10803,6 +11026,14 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct #endif #if INTER_LIC mergeCtx[i].licFlags[idx] = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mergeCtx[i].copyLICParamFromCtx(idx, mergeCtx[GEO_TM_OFF], idx); + mergeCtx[i].licFlags[idx] = mergeCtx[i].licInheritPara[idx]; +#else + mergeCtx[i].setDefaultLICParamToCtx(idx); +#endif +#endif #endif mergeCtx[i].interDirNeighbours[idx] = mergeCtx[GEO_TM_OFF].interDirNeighbours[idx]; mergeCtx[i].mvFieldNeighbours[(idx << 1)].mv = mergeCtx[GEO_TM_OFF].mvFieldNeighbours[(idx << 1)].mv; @@ -11046,7 +11277,14 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct #endif #if JVET_AA0058_GPM_ADAPTIVE_BLENDING +#if JVET_AH0314_ADAPTIVE_GPM_BLENDING_IMPROV + int blkSizeSmall = pu.lwidth() < pu.lheight() ? pu.lwidth() : pu.lheight(); + int startIdx = (blkSizeSmall < GPM_BLENDING_SIZE_THRESHOLD) ? 0 : 1; + int endIdx = (blkSizeSmall < GPM_BLENDING_SIZE_THRESHOLD) ? GEO_BLENDING_NUM : TOTAL_GEO_BLENDING_NUM; + for (uint8_t bldIdx = startIdx; bldIdx < endIdx; bldIdx++) +#else for (uint8_t bldIdx = 0; bldIdx < GEO_BLENDING_NUM; bldIdx++) +#endif { geoCombinations[candidateIdx * GEO_BLENDING_NUM + bldIdx] = m_acGeoWeightedBuffer[candidateIdx * GEO_BLENDING_NUM + bldIdx].getBuf(localUnitArea); @@ -11812,6 +12050,13 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct else if (tmFlag0) { predSrc0 = geoTmBuffer[mrgTmCand0]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (isIntra1) + { + int geoTmType = g_geoTmShape[0][g_geoParams[splitDir][0]]; + mergeCtx[geoTmType].setMergeInfo(pu, mergeCand0); + } +#endif } #endif #if JVET_AG0164_AFFINE_GPM @@ -11822,12 +12067,25 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct predSrc0 = geoMMVDBuf[mergeCand0][mmvdCand0]; chromaAvailPtr0 = &isGeoMMVDChromaAvail[mergeCand0][mmvdCand0]; predSrcTemp0 = geoMMVDTempBuf[mergeCand0][mmvdCand0]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (isIntra1) + { + affMergeCtx.setAffMergeInfo(pu, mergeCand0, mmvdCand0); + } +#endif } else { predSrc0 = geoBuffer[mergeCand0]; chromaAvailPtr0 = &isGeoChromaAvail[mergeCand0]; predSrcTemp0 = geoTempBuf[mergeCand0]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (isIntra1) + { + affMergeCtx.setAffMergeInfo(pu, mergeCand0); + pu.cu->affine = false; + } +#endif } } #endif @@ -11851,6 +12109,12 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct #if JVET_AG0164_AFFINE_GPM chromaAvailPtr0 = &isGeoChromaAvail[mergeCand0]; predSrcTemp0 = geoTempBuf[mergeCand0]; +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (isIntra1) + { + mergeCtxRegular.setMergeInfo(pu, mergeCand0); + } #endif } @@ -11862,6 +12126,10 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct else if (tmFlag1) { predSrc1 = geoTmBuffer[mrgTmCand1]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + int geoTmType = g_geoTmShape[1][g_geoParams[splitDir][0]]; + mergeCtx[geoTmType].setMergeInfo(pu, mergeCand1); +#endif } #endif #if JVET_AG0164_AFFINE_GPM @@ -11872,12 +12140,19 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct predSrc1 = geoMMVDBuf[mergeCand1][mmvdCand1]; chromaAvailPtr1 = &isGeoMMVDChromaAvail[mergeCand1][mmvdCand1]; predSrcTemp1 = geoMMVDTempBuf[mergeCand1][mmvdCand1]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + affMergeCtx.setAffMergeInfo(pu, mergeCand1, mmvdCand1); +#endif } else { predSrc1 = geoBuffer[mergeCand1]; chromaAvailPtr1 = &isGeoChromaAvail[mergeCand1]; predSrcTemp1 = geoTempBuf[mergeCand1]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + affMergeCtx.setAffMergeInfo(pu, mergeCand1); + pu.cu->affine = false; +#endif } } #endif @@ -11886,7 +12161,9 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct predSrc1 = geoMMVDBuf[mergeCand1][mmvdCand1]; chromaAvailPtr1 = &isGeoMMVDChromaAvail[mergeCand1][mmvdCand1]; predSrcTemp1 = geoMMVDTempBuf[mergeCand1][mmvdCand1]; +#if !JVET_AH0314_LIC_INHERITANCE_FOR_MRG if (isIntra0) +#endif { #if TM_MRG mergeCtx[GEO_TM_OFF].setGeoMmvdMergeInfo(pu, mergeCand1, mmvdCand1); @@ -11901,6 +12178,9 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct #if JVET_AG0164_AFFINE_GPM chromaAvailPtr1 = &isGeoChromaAvail[mergeCand1]; predSrcTemp1 = geoTempBuf[mergeCand1]; +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mergeCtxRegular.setMergeInfo(pu, mergeCand1); #endif } @@ -12311,6 +12591,9 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct cu.mtsFlag = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.bcwIdx = BCW_DEFAULT; cu.geoFlag = true; @@ -12494,9 +12777,75 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct pu.gpmDmvrRefinePart1 = refinePossible[pu.geoMergeIdx1]; } #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG +#if TM_MRG + MergeCtx* mrgTmCtx0 = (pu.geoTmFlag0 == 0 ? nullptr : &mergeCtx[g_geoTmShape[0][g_geoParams[pu.geoSplitDir][0]]]); + MergeCtx* mrgTmCtx1 = (pu.geoTmFlag1 == 0 ? nullptr : &mergeCtx[g_geoTmShape[1][g_geoParams[pu.geoSplitDir][0]]]); +#endif +#if JVET_Y0065_GPM_INTRA +#if JVET_AG0164_AFFINE_GPM + if (pu.geoMergeIdx1 >= GEO_MAX_ALL_INTER_UNI_CANDS) +#else + if (pu.geoMergeIdx1 >= GEO_MAX_NUM_UNI_CANDS) +#endif + { +#if TM_MRG + if (pu.geoTmFlag0) + { + mrgTmCtx0->setMergeInfo(pu, pu.geoMergeIdx0); + } + else +#endif +#if JVET_AG0164_AFFINE_GPM + if(pu.affineGPM[0]) + { + affMergeCtx.setAffMergeInfo(pu, pu.geoMergeIdx0, pu.geoMMVDFlag0 ? pu.geoMMVDIdx0 : -1); + pu.cu->affine = false; + } + else +#endif + if (pu.geoMMVDFlag0) + { + mergeCtxRegular.setGeoMmvdMergeInfo(pu, pu.geoMergeIdx0, pu.geoMMVDIdx0); + } + else + { + mergeCtxRegular.setMergeInfo(pu, pu.geoMergeIdx0); + } + } + else +#endif + { +#if TM_MRG + if (pu.geoTmFlag1) + { + mrgTmCtx1->setMergeInfo(pu, pu.geoMergeIdx1); + } + else +#endif +#if JVET_AG0164_AFFINE_GPM + if(pu.affineGPM[1]) + { + affMergeCtx.setAffMergeInfo(pu, pu.geoMergeIdx1, pu.geoMMVDFlag1 ? pu.geoMMVDIdx1 : -1); + pu.cu->affine = false; + } + else +#endif + if (pu.geoMMVDFlag1) + { + mergeCtxRegular.setGeoMmvdMergeInfo(pu, pu.geoMergeIdx1, pu.geoMMVDIdx1); + } + else + { + mergeCtxRegular.setMergeInfo(pu, pu.geoMergeIdx1); + } + } +#endif #if TM_MRG +#if !JVET_AH0314_LIC_INHERITANCE_FOR_MRG MergeCtx* mrgTmCtx0 = (pu.geoTmFlag0 == 0 ? nullptr : &mergeCtx[g_geoTmShape[0][g_geoParams[pu.geoSplitDir][0]]]); MergeCtx* mrgTmCtx1 = (pu.geoTmFlag1 == 0 ? nullptr : &mergeCtx[g_geoTmShape[1][g_geoParams[pu.geoSplitDir][0]]]); +#endif #if JVET_AA0058_GPM_ADAPTIVE_BLENDING #if JVET_AE0046_BI_GPM Mv* bdofSubPuMvOffsetPart0 = pu.gpmDmvrRefinePart0 ? (pu.geoTmFlag0 ? m_mvBufEncBDOF4GPM[g_geoTmShape[0][g_geoParams[pu.geoSplitDir][0]]][pu.geoMergeIdx0] : m_mvBufEncBDOF4GPM[GEO_TM_OFF][pu.geoMergeIdx0]) : nullptr; @@ -12606,6 +12955,9 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct cu.mtsFlag = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.bcwIdx = BCW_DEFAULT; cu.geoBlendFlag = true; @@ -12690,7 +13042,11 @@ void EncCu::xCheckRDCostMergeGeoComb2Nx2N(CodingStructure *&tempCS, CodingStruct } } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + mergeCtx[GEO_TM_OFF].setMergeInfo(pu, geoBI.mergeCand[1]); +#else mergeCtx[GEO_TM_OFF].setMergeInfo(pu, 0); +#endif pu.interDir = 3; pu.mergeIdx = MAX_UCHAR; @@ -12798,6 +13154,9 @@ void EncCu::xCheckRDCostMergeGeo2Nx2N(CodingStructure *&tempCS, CodingStructure cu.mtsFlag = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.bcwIdx = BCW_DEFAULT; cu.geoFlag = true; @@ -13091,6 +13450,9 @@ void EncCu::xCheckRDCostMergeGeo2Nx2N(CodingStructure *&tempCS, CodingStructure cu.mtsFlag = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.bcwIdx = BCW_DEFAULT; cu.geoFlag = true; @@ -13122,6 +13484,38 @@ void EncCu::xCheckRDCostMergeGeo2Nx2N(CodingStructure *&tempCS, CodingStructure } #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + int targetMergeIdx = pu.geoMergeIdx1; +#if JVET_AG0164_AFFINE_GPM + bool isAffine = pu.affineGPM[1]; +#endif +#if JVET_Y0065_GPM_INTRA +#if JVET_AG0164_AFFINE_GPM + if (targetMergeIdx >= GEO_MAX_ALL_INTER_UNI_CANDS) +#else + if (targetMergeIdx >= GEO_MAX_NUM_UNI_CANDS) +#endif + { + targetMergeIdx = pu.geoMergeIdx0; +#if JVET_AG0164_AFFINE_GPM + isAffine = pu.affineGPM[0]; +#endif + } +#endif +#if JVET_AG0164_AFFINE_GPM + if (isAffine) + { + affMergeCtx.setAffMergeInfo(pu, targetMergeIdx); + pu.cu->affine = false; + } + else + { +#endif + mergeCtxRegular.setMergeInfo(pu, targetMergeIdx); +#if JVET_AG0164_AFFINE_GPM + } +#endif +#endif PU::spanGeoMotionInfo(pu, mergeCtx, pu.geoSplitDir, pu.geoMergeIdx0, pu.geoMergeIdx1); tempCS->getPredBuf().copyFrom(geoCombinations[candidateIdx]); #if ENABLE_OBMC @@ -13166,6 +13560,9 @@ void EncCu::xCheckSATDCostRegularMerge(CodingStructure *&tempCS, CodingUnit &cu, #endif #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif #if JVET_AG0276_LIC_FLAG_SIGNALING pu.mergeOppositeLic = false; @@ -13362,12 +13759,16 @@ void EncCu::xCheckSATDCostRegularMerge(CodingStructure *&tempCS, CodingUnit &cu, pu.bdmvrRefine = false; #endif } + #if JVET_AG0135_AFFINE_CIIP void EncCu::xCheckSATDCostCiipAffineMerge(CodingStructure *&tempCS, CodingUnit &cu, PredictionUnit &pu, AffineMergeCtx affineMergeCtx, MergeCtx mergeCtx, PelUnitBuf *acMergeTempBuffer[MMVD_MRG_MAX_RD_NUM], PelUnitBuf *&singleMergeTempBuffer, PelUnitBuf acMergeCIIPAffineBuffer[AFFINE_MRG_MAX_NUM_CANDS] , unsigned& uiNumMrgSATDCand, static_vector<ModeInfo, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> &rdModeList, static_vector<double, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> &candCostList, DistParam distParam, const TempCtx &ctxStart) { #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif #if JVET_AG0276_LIC_FLAG_SIGNALING pu.affineOppositeLic = false; @@ -13536,6 +13937,9 @@ void EncCu::xCheckSATDCostRegularMergeOppositeLic(CodingStructure *&tempCS, Codi #endif #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif pu.mergeOppositeLic = true; cu.mmvdSkip = false; @@ -13654,7 +14058,7 @@ void EncCu::xCheckSATDCostRegularMergeOppositeLic(CodingStructure *&tempCS, Codi } #endif void EncCu::xCheckSATDCostCiipMerge(CodingStructure *&tempCS, CodingUnit &cu, PredictionUnit &pu, MergeCtx mergeCtx, PelUnitBuf *acMergeTempBuffer[MMVD_MRG_MAX_RD_NUM], PelUnitBuf *&singleMergeTempBuffer, PelUnitBuf acMergeTmpBuffer[MRG_MAX_NUM_CANDS] -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG , unsigned& uiNumMrgSATDCand, static_vector<ModeInfo, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> &rdModeList, static_vector<double, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> &candCostList, DistParam distParam, const TempCtx &ctxStart, MergeCtx mergeCtx1) #else , unsigned& uiNumMrgSATDCand, static_vector<ModeInfo, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> &rdModeList, static_vector<double, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> &candCostList, DistParam distParam, const TempCtx &ctxStart) @@ -13666,6 +14070,9 @@ void EncCu::xCheckSATDCostCiipMerge(CodingStructure *&tempCS, CodingUnit &cu, Pr #endif #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.mmvdSkip = false; cu.geoFlag = false; @@ -13707,7 +14114,7 @@ void EncCu::xCheckSATDCostCiipMerge(CodingStructure *&tempCS, CodingUnit &cu, Pr //acMergeTmpBuffer[mergeCand] = m_acMergeTmpBuffer[mergeCand].getBuf(localUnitArea); // estimate merge bits -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG // lic flag is used to generate luma prediction samples for SATD RD to ensure the identical results as anchor; however, the correct solution is to remove such condition on lic flag if (mergeCtx1.licFlags[mergeCand]) { @@ -13724,7 +14131,7 @@ void EncCu::xCheckSATDCostCiipMerge(CodingStructure *&tempCS, CodingUnit &cu, Pr { #endif mergeCtx.setMergeInfo(pu, mergeCand); -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG m_pcInterSearch->motionCompensation(pu, acMergeTmpBuffer[mergeCand], REF_PIC_LIST_X, true, false); } #endif @@ -13810,6 +14217,9 @@ void EncCu::xCheckSATDCostCiipTmMerge(CodingStructure *&tempCS, CodingUnit &cu, #endif #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.mmvdSkip = false; cu.geoFlag = false; @@ -13949,6 +14359,9 @@ void EncCu::xCheckSATDCostMmvdMerge(CodingStructure *&tempCS, CodingUnit &cu, Pr #endif #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.mmvdSkip = true; cu.geoFlag = false; @@ -14090,6 +14503,9 @@ void EncCu::xCheckSATDCostAffineMergeOppositeLic(CodingStructure *&tempCS, Codin cu.affine = true; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif pu.affineOppositeLic = true; pu.afMmvdFlag = false; @@ -14124,6 +14540,9 @@ void EncCu::xCheckSATDCostAffineMergeOppositeLic(CodingStructure *&tempCS, Codin #endif #if INTER_LIC cu.licFlag = affineMergeCtx.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, uiAffMergeCand, cu.licFlag); +#endif #endif pu.mv[0].setZero(); pu.mv[1].setZero(); @@ -14232,6 +14651,9 @@ void EncCu::xCheckSATDCostAffineMerge(CodingStructure *&tempCS, CodingUnit &cu, cu.affine = true; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif #if JVET_AG0276_LIC_FLAG_SIGNALING pu.affineOppositeLic = false; @@ -14272,6 +14694,9 @@ void EncCu::xCheckSATDCostAffineMerge(CodingStructure *&tempCS, CodingUnit &cu, #endif #if INTER_LIC cu.licFlag = affineMergeCtx.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, uiAffMergeCand, cu.licFlag); +#endif #endif pu.mv[0].setZero(); pu.mv[1].setZero(); @@ -14402,6 +14827,9 @@ void EncCu::xCheckSATDCostBMAffineMerge(CodingStructure *&tempCS, CodingUnit &cu cu.affine = true; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag= true; @@ -14442,6 +14870,9 @@ void EncCu::xCheckSATDCostBMAffineMerge(CodingStructure *&tempCS, CodingUnit &cu #endif #if INTER_LIC cu.licFlag = affineMergeCtx.licFlags[uiAffMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, uiAffMergeCand, cu.licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL cu.obmcFlag= affineMergeCtx.obmcFlags[uiAffMergeCand]; @@ -14563,6 +14994,9 @@ void EncCu::xCheckSATDCostTMMerge( CodingStructure*& tempCS, #if JVET_AG0276_LIC_FLAG_SIGNALING pu.tmMergeFlagOppositeLic = false; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif const double sqrtLambdaForFirstPassIntra = m_pcRdCost->getMotionLambda() * FRAC_BITS_SCALE; int insertPos = -1; @@ -14661,6 +15095,9 @@ void EncCu::xCheckSATDCostTMMergeOppositeLic( CodingStructure*& tempCS, pu.regularMergeFlag = false; pu.tmMergeFlag = true; pu.tmMergeFlagOppositeLic = true; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif const double sqrtLambdaForFirstPassIntra = m_pcRdCost->getMotionLambda() * FRAC_BITS_SCALE; int insertPos = -1; for (uint32_t uiMergeCand = 0; uiMergeCand < mrgCtx.numValidMergeCand; uiMergeCand++) @@ -14753,6 +15190,9 @@ void EncCu::xCheckSATDCostAffineMmvdMerge( CodingStructure*& tempCS, cu.imv = IMV_OFF; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif pu.mergeFlag = true; @@ -14866,6 +15306,9 @@ void EncCu::xCheckSATDCostAffineMmvdMerge( CodingStructure*& tempCS, #endif #if INTER_LIC pu.cu->licFlag = affineMergeCtx.licFlags [pu.mergeIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, pu.mergeIdx, pu.cu->licFlag); +#endif #endif #if JVET_AD0193_ADAPTIVE_OBMC_CONTROL pu.cu->obmcFlag = affineMergeCtx.obmcFlags [pu.mergeIdx]; @@ -14948,6 +15391,9 @@ void EncCu::xCheckSATDCostGeoMerge(CodingStructure *&tempCS, CodingUnit &cu, Pre cu.mtsFlag = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.bcwIdx = BCW_DEFAULT; cu.geoFlag = true; @@ -15177,6 +15623,9 @@ void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct cu.mmvdSkip = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif PredictionUnit pu( tempCS->area ); @@ -15255,6 +15704,9 @@ void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct cu.affine = true; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.predMode = MODE_INTER; cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; @@ -15289,6 +15741,9 @@ void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct cu.bcwIdx = affineMergeCtx.bcwIdx[uiMergeCand]; #if INTER_LIC cu.licFlag = affineMergeCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, uiMergeCand, cu.licFlag); +#endif #endif pu.mergeType = affineMergeCtx.mergeType[uiMergeCand]; @@ -15390,6 +15845,9 @@ void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct cu.tileIdx = tempCS->pps->getTileIdx( tempCS->area.lumaPos() ); #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.skip = false; cu.affine = true; @@ -15409,6 +15867,9 @@ void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct cu.bcwIdx = affineMergeCtx.bcwIdx[uiMergeCand]; #if INTER_LIC cu.licFlag = affineMergeCtx.licFlags[uiMergeCand]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, uiMergeCand, cu.licFlag); +#endif #endif pu.mergeType = affineMergeCtx.mergeType[uiMergeCand]; @@ -15539,6 +16000,9 @@ void EncCu::xCheckRDCostAffineMmvd2Nx2N(CodingStructure *&tempCS, CodingStructur cu.geoFlag = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif PredictionUnit pu(tempCS->area); @@ -15598,6 +16062,9 @@ void EncCu::xCheckRDCostAffineMmvd2Nx2N(CodingStructure *&tempCS, CodingStructur cu.affine = true; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.predMode = MODE_INTER; cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; @@ -15637,6 +16104,9 @@ void EncCu::xCheckRDCostAffineMmvd2Nx2N(CodingStructure *&tempCS, CodingStructur pu.cu->affineType = affineMergeCtx.affineType [pu.mergeIdx]; #if INTER_LIC pu.cu->licFlag = affineMergeCtx.licFlags [pu.mergeIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, pu.mergeIdx, pu.cu->licFlag); +#endif #endif pu.cu->bcwIdx = affineMergeCtx.bcwIdx [pu.mergeIdx]; pu.mmvdMergeFlag = false; @@ -15724,6 +16194,9 @@ void EncCu::xCheckRDCostAffineMmvd2Nx2N(CodingStructure *&tempCS, CodingStructur cu.affine = true; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.predMode = MODE_INTER; cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; @@ -15746,6 +16219,9 @@ void EncCu::xCheckRDCostAffineMmvd2Nx2N(CodingStructure *&tempCS, CodingStructur pu.mergeType = affineMergeCtx.mergeType [pu.mergeIdx]; #if INTER_LIC pu.cu->licFlag = affineMergeCtx.licFlags [pu.mergeIdx]; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG && JVET_AG0164_AFFINE_GPM + affineMergeCtx.setLICParamToPu(pu, pu.mergeIdx, pu.cu->licFlag); +#endif #endif pu.interDir = affineMergeCtx.interDirNeighbours[pu.mergeIdx]; pu.cu->affineType = affineMergeCtx.affineType [pu.mergeIdx]; @@ -15858,6 +16334,9 @@ void EncCu::xCheckRDCostTMMerge2Nx2N(CodingStructure *&tempCS, CodingStructure * cu.tileIdx = tempCS->pps->getTileIdx( tempCS->area.lumaPos() ); #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif PredictionUnit pu( tempCS->area ); @@ -15983,6 +16462,9 @@ void EncCu::xCheckRDCostTMMerge2Nx2N(CodingStructure *&tempCS, CodingStructure * cu.tileIdx = tempCS->pps->getTileIdx( tempCS->area.lumaPos() ); #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.skip = false; cu.mmvdSkip = false; @@ -16089,6 +16571,9 @@ void EncCu::xCheckRDCostTMMerge2Nx2N(CodingStructure *&tempCS, CodingStructure * cu.mmvdSkip = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.affine = false; cu.geoFlag = false; @@ -16289,6 +16774,9 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct pu.regularMergeFlag = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif cu.geoFlag = false; #if JVET_AC0112_IBC_LIC @@ -16527,6 +17015,9 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct cu.mmvdSkip = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif #if JVET_AC0112_IBC_LIC cu.ibcLicFlag = false; @@ -18493,6 +18984,9 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct cu.sbtInfo = 0; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif #if JVET_AC0112_IBC_LIC cu.ibcLicFlag = false; @@ -19132,6 +19626,9 @@ void EncCu::xCheckRDCostIBCMode(CodingStructure *&tempCS, CodingStructure *&best pu.regularMergeFlag = false; #if INTER_LIC cu.licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif #if JVET_AC0112_IBC_CIIP @@ -19663,6 +20160,7 @@ void EncCu::xCheckRDCostInter( CodingStructure *&tempCS, CodingStructure *&bestC } #endif + CodingUnit &cu = tempCS->addCU( tempCS->area, partitioner.chType ); partitioner.setCUData( cu ); @@ -19886,7 +20384,10 @@ void EncCu::xCheckRDCostInter( CodingStructure *&tempCS, CodingStructure *&bestC #endif m_pcInterSearch->motionCompensation( *(cu.firstPU), predBuf, REF_PIC_LIST_X ); #if JVET_AD0213_LIC_IMP - if (cu.licFlag) +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (!cu.licInheritPara) +#endif + if (cu.licFlag) { for (int list = 0; list < 2; list++) { @@ -19926,6 +20427,9 @@ void EncCu::xCheckRDCostInter( CodingStructure *&tempCS, CodingStructure *&bestC #endif m_pcInterSearch->motionCompensation( *(cuBest->firstPU), predBuf, REF_PIC_LIST_X ); #if JVET_AD0213_LIC_IMP +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(!cuBest->licInheritPara) +#endif if (cuBest->licFlag) { for (int list = 0; list < 2; list++) @@ -20176,6 +20680,7 @@ bool EncCu::xCheckRDCostInterIMV(CodingStructure *&tempCS, CodingStructure *&bes } #endif + CodingUnit &cu = tempCS->addCU( tempCS->area, partitioner.chType ); partitioner.setCUData( cu ); @@ -20413,6 +20918,9 @@ bool EncCu::xCheckRDCostInterIMV(CodingStructure *&tempCS, CodingStructure *&bes #endif m_pcInterSearch->motionCompensation( *(cu.firstPU), predBuf, REF_PIC_LIST_X ); #if JVET_AD0213_LIC_IMP +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(!cu.licInheritPara) +#endif if (cu.licFlag) { for (int list = 0; list < 2; list++) @@ -20453,7 +20961,10 @@ bool EncCu::xCheckRDCostInterIMV(CodingStructure *&tempCS, CodingStructure *&bes #endif m_pcInterSearch->motionCompensation( *(cuBest->firstPU), predBuf, REF_PIC_LIST_X ); #if JVET_AD0213_LIC_IMP - if (cuBest->licFlag) +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (!cuBest->licInheritPara) +#endif + if (cuBest->licFlag) { for (int list = 0; list < 2; list++) { @@ -22202,7 +22713,10 @@ void EncCu::xCheckRDCostInterMultiHyp2Nx2N(CodingStructure *&tempCS, CodingStruc m_pcInterSearch->motionCompensation(pu); #endif #if JVET_AD0213_LIC_IMP - if (pu.cu->licFlag) +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (!pu.cu->licInheritPara) +#endif + if (pu.cu->licFlag) { for (int list = 0; list < 2; list++) { @@ -22527,6 +23041,9 @@ void EncCu::xCheckSATDCostBMMerge(CodingStructure*& tempCS, pu.cu->bcwIdx = mrgCtx.bcwIdx[candIdx]; #if JVET_AD0213_LIC_IMP pu.cu->licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif #endif pu.mv[REF_PIC_LIST_0] = mrgCtx.mvFieldNeighbours[(candIdx << 1)].mv; pu.mv[REF_PIC_LIST_1] = mrgCtx.mvFieldNeighbours[(candIdx << 1) + 1].mv; @@ -22734,6 +23251,9 @@ void EncCu::xCheckSATDCostBMMerge(CodingStructure*& tempCS, #if MULTI_PASS_DMVR pu.bdmvrRefine = false; #endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cu.licInheritPara = false; +#endif } #endif //! \} diff --git a/source/Lib/EncoderLib/EncCu.h b/source/Lib/EncoderLib/EncCu.h index 64bdcf4bca88f497d5a6179aef84e387d56a8be0..2d69e526c8afe057143725a172fb65ba2050b12b 100644 --- a/source/Lib/EncoderLib/EncCu.h +++ b/source/Lib/EncoderLib/EncCu.h @@ -579,7 +579,7 @@ protected: (CodingStructure *&tempCS, CodingUnit &cu, PredictionUnit &pu, AffineMergeCtx affineMergeCtx, MergeCtx mergeCtx, PelUnitBuf *acMergeTempBuffer[MMVD_MRG_MAX_RD_NUM], PelUnitBuf *&singleMergeTempBuffer, PelUnitBuf acMergeAffineBuffer[AFFINE_MRG_MAX_NUM_CANDS] , unsigned& uiNumMrgSATDCand, static_vector<ModeInfo, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> &rdModeList, static_vector<double, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> &candCostList, DistParam distParam, const TempCtx &ctxStart); #endif -#if JVET_AG0276_NLIC +#if JVET_AG0276_NLIC || JVET_AH0314_LIC_INHERITANCE_FOR_MRG void xCheckSATDCostCiipMerge(CodingStructure *&tempCS, CodingUnit &cu, PredictionUnit &pu, MergeCtx mergeCtx, PelUnitBuf *acMergeTempBuffer[MMVD_MRG_MAX_RD_NUM], PelUnitBuf *&singleMergeTempBuffer, PelUnitBuf acMergeTmpBuffer[MRG_MAX_NUM_CANDS], unsigned& uiNumMrgSATDCand, static_vector<ModeInfo, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> &rdModeList, static_vector<double, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> &candCostList, DistParam distParam, const TempCtx &ctxStart, MergeCtx mergeCtx1); #else diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp index 5cd6407fcee07168028bc9ffcf0d4534a734c0fe..cad2d26ea06e65e528bcf9cdad4940d16c0142b6 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.cpp +++ b/source/Lib/EncoderLib/EncModeCtrl.cpp @@ -2512,7 +2512,11 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt } else { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + cuECtx.bestCU->secAltLMParaUnit.resetAltLinearModel(); +#else cuECtx.bestCU->secAltLMParaUnit = cuECtx.bestCU->altLMParaUnit; +#endif } cuECtx.bestCU->altLMParaUnit.resetAltLinearModel(); #if JVET_AG0276_LIC_FLAG_SIGNALING @@ -2550,12 +2554,19 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt #if INTER_LIC bool orgLicFlag = bestCU->licFlag; bestCU->licFlag = false; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bool orgLicInheritedFlag = bestCU->licInheritPara; + bestCU->licInheritPara = false; +#endif #endif bool orgCiipFlag = bestCU->firstPU->ciipFlag; bestCU->firstPU->ciipFlag = false; m_pcInterSearch->xPredWoRefinement(*bestCU->firstPU, predBeforeMCAdjBuffer); #if INTER_LIC bestCU->licFlag = orgLicFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + bestCU->licInheritPara = orgLicInheritedFlag; +#endif #endif bestCU->firstPU->ciipFlag = orgCiipFlag; } diff --git a/source/Lib/EncoderLib/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp index 44d8f8342037407079b81d4e1eabb0194ee9b3e1..fce10e84aaa548b8584030cd1731b43addad429f 100644 --- a/source/Lib/EncoderLib/InterSearch.cpp +++ b/source/Lib/EncoderLib/InterSearch.cpp @@ -6825,7 +6825,6 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) biPredResult.cu = cu; biPredResult.pu = pu; biPredResult.pu.interDir = 3; - biPredResult.cu.smvdMode = 1 + curRefList; biPredResult.pu.mv[curRefList] = cCurMvField.mv; @@ -7489,6 +7488,9 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner) motionCompensation( pu, predBuf, REF_PIC_LIST_X ); #endif #if JVET_AD0213_LIC_IMP +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if(!pu.cu->licInheritPara) +#endif if (pu.cu->licFlag) { for (int list = 0; list < 2; list++) @@ -7914,6 +7916,9 @@ void InterSearch::predInterSearchAdditionalHypothesis(PredictionUnit& pu, const #endif #if INTER_LIC auto savedLICFlag = pu.cu->licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + auto savedLICInheritePara = pu.cu->licInheritPara; +#endif #endif tempMHPredData.isMrg = true; #if JVET_Z0127_SPS_MHP_MAX_MRG_CAND @@ -7959,6 +7964,9 @@ void InterSearch::predInterSearchAdditionalHypothesis(PredictionUnit& pu, const #endif const auto savedAffine = pu.cu->affine; const auto savedIMV = pu.cu->imv; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + m_isAddHypMC = true; +#endif for (int i = 0; i < maxNumMergeCandidates; i++) { // get prediction for the additional hypothesis @@ -7972,6 +7980,9 @@ void InterSearch::predInterSearchAdditionalHypothesis(PredictionUnit& pu, const #if JVET_AG0276_NLIC fakePredData.cu->altLMFlag = m_geoMrgCtx.altLMFlag[i]; fakePredData.cu->altLMParaUnit = m_geoMrgCtx.altLMParaNeighbours[i]; +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + fakePredData.cu->licInheritPara = false; #endif fakePredData.mvRefine = true; if (savedLICFlag) @@ -7987,10 +7998,16 @@ void InterSearch::predInterSearchAdditionalHypothesis(PredictionUnit& pu, const #if JVET_AG0276_NLIC fakePredData.cu->altLMFlag = savedAltLMFlag; fakePredData.cu->altLMParaUnit = savedAltLMParaUnit; +#endif +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + fakePredData.cu->licInheritPara = savedLICInheritePara; #endif fakePredData.cu->imv = savedIMV; fakePredData.cu->affine = savedAffine; } +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + m_isAddHypMC = false; +#endif if (savedLICFlag) { setGeoTmpBuffer(m_mhpMrgTempBufSet + 0x2); @@ -8158,6 +8175,9 @@ void InterSearch::predInterSearchAdditionalHypothesis(PredictionUnit& pu, const #endif #if INTER_LIC pu.cu->licFlag = tempMHPredData.licFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pu.cu->licInheritPara = false; +#endif #endif xMotionEstimation(pu, tempOrigBuf, eRefPicList, cMvPred, iRefIdxPred, cMv, tempMHPredData.mvpIdx, uiBits, uiCostTemp, amvpInfo, false, g_addHypWeight[tempMHPredData.weightIdx]); xCheckBestMVP(eRefPicList, cMv, cMvPred, tempMHPredData.mvpIdx, amvpInfo, uiBits, uiCostTemp, pu.cu->imv); @@ -8167,6 +8187,9 @@ void InterSearch::predInterSearchAdditionalHypothesis(PredictionUnit& pu, const #endif #if INTER_LIC pu.cu->licFlag = savedLICFlag; +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pu.cu->licInheritPara = savedLICInheritePara; +#endif #endif tempMHPredData.mv = cMv; tempMHPredData.mv.mvCliptoStorageBitDepth(); @@ -11280,7 +11303,6 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit& pu, } biPredResult.pu.interDir = 3; - biPredResult.pu.mvpIdx[iRefList] = aaiMvpIdxBi[iRefList][iRefIdxTemp]; biPredResult.pu.mvpIdx[1 - iRefList] = aaiMvpIdxBi[1 - iRefList][iRefIdxBi[1 - iRefList]]; biPredResult.pu.mvpNum[iRefList] = aaiMvpNum[iRefList][iRefIdxTemp]; @@ -16102,8 +16124,13 @@ void InterSearch::checkEncLicOff(CodingUnit& cu, MergeCtx& mergeCtx) { for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pu.cu->licScale[list][comp] = 32; + pu.cu->licOffset[list][comp] = 0; +#else pu.cu->licScale[list][comp] = MAX_INT; pu.cu->licOffset[list][comp] = MAX_INT; +#endif } } #endif @@ -16216,6 +16243,9 @@ void InterSearch::checkEncLicOn(CodingUnit& cu, MergeCtx& mergeCtx) } motionCompensation(pu, m_predictionBeforeLIC, REF_PIC_LIST_X); #if JVET_AD0213_LIC_IMP +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + if (!pu.cu->licInheritPara) +#endif for (int list = 0; list < 2; list++) { if (pu.refIdx[list] >= 0) @@ -16271,8 +16301,13 @@ void InterSearch::checkEncLicOn(CodingUnit& cu, MergeCtx& mergeCtx) { for (int comp = 0; comp < MAX_NUM_COMPONENT; comp++) { +#if JVET_AH0314_LIC_INHERITANCE_FOR_MRG + pu.cu->licScale[list][comp] = 32; + pu.cu->licOffset[list][comp] = 0; +#else pu.cu->licScale[list][comp] = MAX_INT; pu.cu->licOffset[list][comp] = MAX_INT; +#endif } } #endif