diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 64d89ad33a29fd705a9cf989c8ac9518d528387d..fb5afb8a8d8e9147506da93ed39e817da4dddf43 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -867,6 +867,9 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, int mmvdList, const int& mrgCandIdx ) { +#if JVET_Q0297_MER + const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; +#endif const CodingStructure &cs = *pu.cs; const Slice &slice = *pu.cs->slice; #if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE @@ -897,7 +900,11 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, // above const PredictionUnit *puAbove = cs.getPURestricted(posRT.offset(0, -1), pu, pu.chType); +#if JVET_Q0297_MER + bool isAvailableB1 = puAbove && isDiffMER(pu.lumaPos(), posRT.offset(0, -1), plevel) && pu.cu != puAbove->cu && CU::isInter(*puAbove->cu); +#else bool isAvailableB1 = puAbove && isDiffMER(pu, *puAbove) && pu.cu != puAbove->cu && CU::isInter(*puAbove->cu); +#endif if (isAvailableB1) { @@ -931,7 +938,11 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, //left const PredictionUnit* puLeft = cs.getPURestricted(posLB.offset(-1, 0), pu, pu.chType); +#if JVET_Q0297_MER + const bool isAvailableA1 = puLeft && isDiffMER(pu.lumaPos(), posLB.offset(-1, 0), plevel) && pu.cu != puLeft->cu && CU::isInter(*puLeft->cu); +#else const bool isAvailableA1 = puLeft && isDiffMER(pu, *puLeft) && pu.cu != puLeft->cu && CU::isInter(*puLeft->cu); +#endif if (isAvailableA1) { @@ -968,7 +979,11 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, // above right const PredictionUnit *puAboveRight = cs.getPURestricted( posRT.offset( 1, -1 ), pu, pu.chType ); +#if JVET_Q0297_MER + bool isAvailableB0 = puAboveRight && isDiffMER( pu.lumaPos(), posRT.offset(1, -1), plevel) && CU::isInter( *puAboveRight->cu ); +#else bool isAvailableB0 = puAboveRight && isDiffMER( pu, *puAboveRight ) && CU::isInter( *puAboveRight->cu ); +#endif if( isAvailableB0 ) { @@ -1006,7 +1021,11 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, //left bottom const PredictionUnit *puLeftBottom = cs.getPURestricted( posLB.offset( -1, 1 ), pu, pu.chType ); +#if JVET_Q0297_MER + bool isAvailableA0 = puLeftBottom && isDiffMER( pu.lumaPos(), posLB.offset(-1, 1), plevel) && CU::isInter( *puLeftBottom->cu ); +#else bool isAvailableA0 = puLeftBottom && isDiffMER( pu, *puLeftBottom ) && CU::isInter( *puLeftBottom->cu ); +#endif if( isAvailableA0 ) { @@ -1047,7 +1066,11 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, { const PredictionUnit *puAboveLeft = cs.getPURestricted( posLT.offset( -1, -1 ), pu, pu.chType ); +#if JVET_Q0297_MER + bool isAvailableB2 = puAboveLeft && isDiffMER( pu.lumaPos(), posLT.offset(-1, -1), plevel ) && CU::isInter( *puAboveLeft->cu ); +#else bool isAvailableB2 = puAboveLeft && isDiffMER( pu, *puAboveLeft ) && CU::isInter( *puAboveLeft->cu ); +#endif if( isAvailableB2 ) { @@ -1547,15 +1570,13 @@ bool PU::getColocatedMVP(const PredictionUnit &pu, const RefPicList &eRefPicList return true; } -bool PU::isDiffMER(const PredictionUnit &pu1, const PredictionUnit &pu2) -{ - const unsigned xN = pu1.lumaPos().x; - const unsigned yN = pu1.lumaPos().y; - const unsigned xP = pu2.lumaPos().x; - const unsigned yP = pu2.lumaPos().y; - #if JVET_Q0297_MER - unsigned plevel = pu1.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; +bool PU::isDiffMER(const Position &pos1, const Position &pos2, const unsigned plevel) +{ + const unsigned xN = pos1.x; + const unsigned yN = pos1.y; + const unsigned xP = pos2.x; + const unsigned yP = pos2.y; if ((xN >> plevel) != (xP >> plevel)) { @@ -1565,8 +1586,18 @@ bool PU::isDiffMER(const PredictionUnit &pu1, const PredictionUnit &pu2) if ((yN >> plevel) != (yP >> plevel)) { return true; + } + + return false; } #else +bool PU::isDiffMER(const PredictionUnit &pu1, const PredictionUnit &pu2) +{ + const unsigned xN = pu1.lumaPos().x; + const unsigned yN = pu1.lumaPos().y; + const unsigned xP = pu2.lumaPos().x; + const unsigned yP = pu2.lumaPos().y; + if ((xN >> 2) != (xP >> 2)) { return true; @@ -1576,10 +1607,10 @@ bool PU::isDiffMER(const PredictionUnit &pu1, const PredictionUnit &pu2) { return true; } -#endif return false; } +#endif bool PU::isAddNeighborMv(const Mv& currMv, Mv* neighborMvs, int numNeighborMv) { @@ -2451,12 +2482,15 @@ const int getAvailableAffineNeighboursForLeftPredictor( const PredictionUnit &pu { const Position posLB = pu.Y().bottomLeft(); int num = 0; +#if JVET_Q0297_MER + const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; +#endif const PredictionUnit *puLeftBottom = pu.cs->getPURestricted( posLB.offset( -1, 1 ), pu, pu.chType ); if ( puLeftBottom && puLeftBottom->cu->affine && puLeftBottom->mergeType == MRG_TYPE_DEFAULT_N #if JVET_Q0297_MER - && PU::isDiffMER(pu, *puLeftBottom) + && PU::isDiffMER(pu.lumaPos(), posLB.offset(-1, 1), plevel) #endif ) { @@ -2468,7 +2502,7 @@ const int getAvailableAffineNeighboursForLeftPredictor( const PredictionUnit &pu if ( puLeft && puLeft->cu->affine && puLeft->mergeType == MRG_TYPE_DEFAULT_N #if JVET_Q0297_MER - && PU::isDiffMER(pu, *puLeft) + && PU::isDiffMER(pu.lumaPos(), posLB.offset(-1, 0), plevel) #endif ) { @@ -2483,13 +2517,16 @@ const int getAvailableAffineNeighboursForAbovePredictor( const PredictionUnit &p { const Position posLT = pu.Y().topLeft(); const Position posRT = pu.Y().topRight(); +#if JVET_Q0297_MER + const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; +#endif int num = numAffNeighLeft; const PredictionUnit* puAboveRight = pu.cs->getPURestricted( posRT.offset( 1, -1 ), pu, pu.chType ); if ( puAboveRight && puAboveRight->cu->affine && puAboveRight->mergeType == MRG_TYPE_DEFAULT_N #if JVET_Q0297_MER - && PU::isDiffMER(pu, *puAboveRight) + && PU::isDiffMER(pu.lumaPos(), posRT.offset(1, -1), plevel) #endif ) { @@ -2501,7 +2538,7 @@ const int getAvailableAffineNeighboursForAbovePredictor( const PredictionUnit &p if ( puAbove && puAbove->cu->affine && puAbove->mergeType == MRG_TYPE_DEFAULT_N #if JVET_Q0297_MER - && PU::isDiffMER(pu, *puAbove) + && PU::isDiffMER(pu.lumaPos(), posRT.offset(0, -1), plevel) #endif ) { @@ -2513,7 +2550,7 @@ const int getAvailableAffineNeighboursForAbovePredictor( const PredictionUnit &p if ( puAboveLeft && puAboveLeft->cu->affine && puAboveLeft->mergeType == MRG_TYPE_DEFAULT_N #if JVET_Q0297_MER - && PU::isDiffMER(pu, *puAboveLeft) + && PU::isDiffMER(pu.lumaPos(), posLT.offset(-1, -1), plevel) #endif ) { @@ -2529,6 +2566,9 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx const CodingStructure &cs = *pu.cs; const Slice &slice = *pu.cs->slice; const uint32_t maxNumAffineMergeCand = slice.getPicHeader()->getMaxNumAffineMergeCand(); +#if JVET_Q0297_MER + const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; +#endif for ( int i = 0; i < maxNumAffineMergeCand; i++ ) { @@ -2563,7 +2603,11 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx //left const PredictionUnit* puLeft = cs.getPURestricted( posCurLB.offset( -1, 0 ), pu, pu.chType ); +#if JVET_Q0297_MER + const bool isAvailableA1 = puLeft && isDiffMER(pu.lumaPos(), posCurLB.offset(-1, 0), plevel) && pu.cu != puLeft->cu && CU::isInter( *puLeft->cu ); +#else const bool isAvailableA1 = puLeft && isDiffMER( pu, *puLeft ) && pu.cu != puLeft->cu && CU::isInter( *puLeft->cu ); +#endif if ( isAvailableA1 ) { miLeft = puLeft->getMotionInfo( posCurLB.offset( -1, 0 ) ); @@ -2673,7 +2717,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx if ( puNeigh && CU::isInter( *puNeigh->cu ) #if JVET_Q0297_MER - && PU::isDiffMER(pu, *puNeigh) + && PU::isDiffMER(pu.lumaPos(), pos, plevel) #endif ) { @@ -2694,7 +2738,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx if ( puNeigh && CU::isInter( *puNeigh->cu ) #if JVET_Q0297_MER - && PU::isDiffMER(pu, *puNeigh) + && PU::isDiffMER(pu.lumaPos(), pos, plevel) #endif ) { @@ -2715,7 +2759,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx if ( puNeigh && CU::isInter( *puNeigh->cu ) #if JVET_Q0297_MER - && PU::isDiffMER(pu, *puNeigh) + && PU::isDiffMER(pu.lumaPos(), pos, plevel) #endif ) { diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h index bf8a058370742abebd006cb515bf7250486e7506..b51a96028f762c7ff856958c71e1e19a8a92fdc5 100644 --- a/source/Lib/CommonLib/UnitTools.h +++ b/source/Lib/CommonLib/UnitTools.h @@ -142,7 +142,11 @@ namespace PU void getIBCMergeCandidates (const PredictionUnit &pu, MergeCtx& mrgCtx, const int& mrgCandIdx = -1); void getInterMMVDMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const int& mrgCandIdx = -1); int getDistScaleFactor(const int &currPOC, const int &currRefPOC, const int &colPOC, const int &colRefPOC); +#if JVET_Q0297_MER + bool isDiffMER (const Position &pos1, const Position &pos2, const unsigned plevel); +#else bool isDiffMER (const PredictionUnit &pu, const PredictionUnit &pu2); +#endif bool getColocatedMVP (const PredictionUnit &pu, const RefPicList &eRefPicList, const Position &pos, Mv& rcMv, const int &refIdx, bool sbFlag); void fillMvpCand ( PredictionUnit &pu, const RefPicList &eRefPicList, const int &refIdx, AMVPInfo &amvpInfo ); void fillIBCMvpCand (PredictionUnit &pu, AMVPInfo &amvpInfo);