Commit 05f8d980 authored by Xiang Li's avatar Xiang Li

Revert "Merge branch 'High_Precision_Motion_Vector_Storage' into 'master'"

This reverts merge request !106
parent 7442802b
Pipeline #104 passed with stage
......@@ -121,6 +121,7 @@ MTT : 1
EMT : 3
EMTFast : 3
Affine : 1
HighPrecMv : 1
SubPuMvp : 1
MaxNumMergeCand : 6
LMChroma : 1
......
......@@ -121,7 +121,7 @@ MTT : 1
EMT : 3
EMTFast : 3
Affine : 1
HighPrecMv : 1
SubPuMvp : 1
MaxNumMergeCand : 6
LMChroma : 1
......
......@@ -135,6 +135,7 @@ MTT : 1
EMT : 3
EMTFast : 3
Affine : 1
HighPrecMv : 1
SubPuMvp : 1
MaxNumMergeCand : 6
LMChroma : 1
......@@ -157,4 +158,3 @@ AMaxBT : 1
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###
......@@ -241,9 +241,7 @@ void EncApp::xInitLibCfg()
#endif
#endif
#if JEM_TOOLS
#if !REMOVE_MV_ADAPT_PREC
m_cEncLib.setHighPrecisionMv ( m_highPrecisionMv );
#endif
m_cEncLib.setAffine ( m_Affine );
#if JVET_K0337_AFFINE_6PARA
m_cEncLib.setAffineType ( m_AffineType );
......
......@@ -833,14 +833,10 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
("SubPuMvp", m_SubPuMvpMode, 0, "Enable Sub-PU temporal motion vector prediction (0:off, 1:on) [default: off]")
#endif
("SubPuMvpLog2Size", m_SubPuMvpLog2Size, 2u, "Sub-PU TMVP size index: 2^n")
#if !REMOVE_MV_ADAPT_PREC
("HighPrecMv", m_highPrecisionMv, false, "High precision motion vectors for temporal merging (0:off, 1:on) [default: off]")
#endif
("HighPrecMv", m_highPrecisionMv, false, "High precision motion vectors for temporal merging (0:off, 1:on) [default: off]")
#endif
#if JEM_TOOLS || JVET_K_AFFINE
#if !REMOVE_MV_ADAPT_PREC
("HighPrecMv", m_highPrecisionMv, false, "High precision motion vectors for temporal merging (0:off, 1:on) [default: off]")
#endif
("Affine", m_Affine, false, "Enable affine prediction (0:off, 1:on) [default: off]")
#if JVET_K0337_AFFINE_6PARA
( "AffineType", m_AffineType, true, "Enable affine type prediction (0:off, 1:on) [default: on]" )
......@@ -2126,9 +2122,7 @@ bool EncAppCfg::xCheckParameter()
xConfirmPara( !( m_OBMCBlkSize == 4 || m_OBMCBlkSize == 8 ), "OBMC Block Size must be set to 4 or 8 samples" );
#endif
#if JVET_K_AFFINE
#if !REMOVE_MV_ADAPT_PREC
xConfirmPara(m_Affine && !m_highPrecisionMv, "Affine is not yet implemented for HighPrecMv off.");
#endif
xConfirmPara( m_Affine && !m_highPrecisionMv, "Affine is not yet implemented for HighPrecMv off." );
#endif
#if JEM_TOOLS
xConfirmPara( m_DMVR && !m_QTBT, "DMVR without QTBT results in encoder-decoder mismatch!" );
......@@ -3409,15 +3403,11 @@ void EncAppCfg::xPrintParameter()
#endif
#endif
#if JEM_TOOLS
#if !REMOVE_MV_ADAPT_PREC
msg( VERBOSE, "HighPrecMv:%d ", m_highPrecisionMv );
#endif
msg( VERBOSE, "BIO:%d ", m_BIO );
#endif
#if !JEM_TOOLS && (JVET_K0346 || JVET_K_AFFINE)
#if !REMOVE_MV_ADAPT_PREC
msg( VERBOSE, "HighPrecMv:%d ", m_highPrecisionMv );
#endif
msg(VERBOSE, "HighPrecMv:%d ", m_highPrecisionMv);
#endif
msg( VERBOSE, "DisMDC:%d ", m_DisableMotionCompression );
#if JEM_TOOLS
......
......@@ -769,11 +769,7 @@ void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx )
{
pu.cu->ibc = true;
pu.bv = pu.mv[REF_PIC_LIST_0];
#if REMOVE_MV_ADAPT_PREC
pu.bv >>= (2 + VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE);
#else
pu.bv >>= 2; // used for only integer resolution
#endif
}
#endif
#if JEM_TOOLS
......
......@@ -994,15 +994,13 @@ void InterPrediction::xPredInterBlk ( const ComponentID& compID, const Predictio
const bool rndRes = ( !bi || pu.cu->LICFlag );
int iAddPrecShift = 0;
#if !REMOVE_MV_ADAPT_PREC
if (_mv.highPrec)
if( _mv.highPrec )
{
CHECKD(!pu.cs->sps->getSpsNext().getUseHighPrecMv(), "Found a high-precision motion vector, but the high-precision MV extension is disabled!");
#endif
CHECKD( !pu.cs->sps->getSpsNext().getUseHighPrecMv(), "Found a high-precision motion vector, but the high-precision MV extension is disabled!" );
iAddPrecShift = VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#if !REMOVE_MV_ADAPT_PREC
}
#endif
int shiftHor = 2 + iAddPrecShift + ::getComponentScaleX( compID, chFmt );
int shiftVer = 2 + iAddPrecShift + ::getComponentScaleY( compID, chFmt );
......@@ -1012,25 +1010,21 @@ void InterPrediction::xPredInterBlk ( const ComponentID& compID, const Predictio
xFrac <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE - iAddPrecShift;
yFrac <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE - iAddPrecShift;
#if !REMOVE_MV_ADAPT_PREC
CHECKD(!pu.cs->sps->getSpsNext().getUseHighPrecMv() && ((xFrac & 3) != 0), "Invalid fraction");
CHECKD(!pu.cs->sps->getSpsNext().getUseHighPrecMv() && ((yFrac & 3) != 0), "Invalid fraction");
#endif
CHECKD( !pu.cs->sps->getSpsNext().getUseHighPrecMv() && ( ( xFrac & 3 ) != 0 ), "Invalid fraction" );
CHECKD( !pu.cs->sps->getSpsNext().getUseHighPrecMv() && ( ( yFrac & 3 ) != 0 ), "Invalid fraction" );
#elif JVET_K0346 || JVET_K_AFFINE
const ChromaFormat chFmt = pu.chromaFormat;
const bool rndRes = !bi;
int iAddPrecShift = 0;
#if !REMOVE_MV_ADAPT_PREC
if (_mv.highPrec)
{
CHECKD(!pu.cs->sps->getSpsNext().getUseHighPrecMv(), "Found a high-precision motion vector, but the high-precision MV extension is disabled!");
#endif
iAddPrecShift = VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#if !REMOVE_MV_ADAPT_PREC
}
#endif
int shiftHor = 2 + iAddPrecShift + ::getComponentScaleX(compID, chFmt);
int shiftVer = 2 + iAddPrecShift + ::getComponentScaleY(compID, chFmt);
......@@ -1040,10 +1034,9 @@ void InterPrediction::xPredInterBlk ( const ComponentID& compID, const Predictio
xFrac <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE - iAddPrecShift;
yFrac <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE - iAddPrecShift;
#if !REMOVE_MV_ADAPT_PREC
CHECKD(!pu.cs->sps->getSpsNext().getUseHighPrecMv() && ((xFrac & 3) != 0), "Invalid fraction");
CHECKD(!pu.cs->sps->getSpsNext().getUseHighPrecMv() && ((yFrac & 3) != 0), "Invalid fraction");
#endif
#else
const ChromaFormat chFmt = pu.chromaFormat;
const bool rndRes = !bi;
......@@ -1252,11 +1245,10 @@ void InterPrediction::xPredAffineBlk( const ComponentID& compID, const Predictio
Mv mvLT =_mv[0];
Mv mvRT =_mv[1];
Mv mvLB =_mv[2];
#if !REMOVE_MV_ADAPT_PREC
mvLT.setHighPrec();
mvRT.setHighPrec();
mvLB.setHighPrec();
#endif
// get affine sub-block width and height
const int width = pu.Y().width;
......@@ -1426,11 +1418,7 @@ void InterPrediction::xGetLICParams( const CodingUnit& cu,
int& scale,
int& offset )
{
#if REMOVE_MV_ADAPT_PREC
const int lumaShift = 2 + VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#else
const int lumaShift = (mv.highPrec ? 2 + VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : 2);
#endif
const int lumaShift = ( mv.highPrec ? 2 + VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : 2 );
const int horShift = ( lumaShift + ::getComponentScaleX(compID, cu.chromaFormat) );
const int verShift = ( lumaShift + ::getComponentScaleY(compID, cu.chromaFormat) );
const int horIntMv = ( mv.getHor() + ( ( 1 << horShift ) >> 1 ) ) >> horShift;
......@@ -1458,11 +1446,7 @@ void InterPrediction::xGetLICParams( const CodingUnit& cu,
// above
if( cuAbove )
{
#if REMOVE_MV_ADAPT_PREC
Mv subPelMv (horIntMv << horShift, verIntMv << verShift);
#else
Mv subPelMv (horIntMv << horShift, verIntMv << verShift, mv.highPrec);
#endif
Mv subPelMv ( horIntMv << horShift, verIntMv << verShift, mv.highPrec );
clipMv ( subPelMv, cuAbove->lumaPos(), *cu.cs->sps );
const int hOff = ( subPelMv.getHor() >> horShift );
const int vOff = ( subPelMv.getVer() >> verShift ) - 1;
......@@ -1486,11 +1470,7 @@ void InterPrediction::xGetLICParams( const CodingUnit& cu,
// left
if( cuLeft )
{
#if REMOVE_MV_ADAPT_PREC
Mv subPelMv (horIntMv << horShift, verIntMv << verShift);
#else
Mv subPelMv (horIntMv << horShift, verIntMv << verShift, mv.highPrec);
#endif
Mv subPelMv ( horIntMv << horShift, verIntMv << verShift, mv.highPrec );
clipMv ( subPelMv, cuLeft->lumaPos(), *cu.cs->sps );
const int hOff = ( subPelMv.getHor() >> horShift ) - 1;
const int vOff = ( subPelMv.getVer() >> verShift );
......@@ -2973,18 +2953,10 @@ uint32_t InterPrediction::xFrucGetTempMatchCost( PredictionUnit& pu, int nWidth,
if( m_bFrucTemplateAvailabe[0] )
{
Mv mvTop( 0 , - ( FRUC_MERGE_TEMPLATE_SIZE << nMVUnit ) );
#if !REMOVE_MV_ADAPT_PREC
if (pu.cs->sps->getSpsNext().getUseHighPrecMv())
if( pu.cs->sps->getSpsNext().getUseHighPrecMv() )
{
#endif
#if REMOVE_MV_ADAPT_PREC
mvTop <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#else
mvTop.setHighPrec();
#endif
#if !REMOVE_MV_ADAPT_PREC
}
#endif
mvTop += rCurMvField.mv;
clipMv(mvTop, pu.cu->lumaPos(), sps);
......@@ -3004,18 +2976,10 @@ uint32_t InterPrediction::xFrucGetTempMatchCost( PredictionUnit& pu, int nWidth,
if( m_bFrucTemplateAvailabe[1] )
{
Mv mvLeft( - ( FRUC_MERGE_TEMPLATE_SIZE << nMVUnit ) , 0 );
#if !REMOVE_MV_ADAPT_PREC
if (pu.cs->sps->getSpsNext().getUseHighPrecMv())
if( pu.cs->sps->getSpsNext().getUseHighPrecMv() )
{
#endif
#if REMOVE_MV_ADAPT_PREC
mvLeft <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#else
mvLeft.setHighPrec();
#endif
#if !REMOVE_MV_ADAPT_PREC
}
#endif
mvLeft += rCurMvField.mv;
clipMv(mvLeft, pu.cu->lumaPos(), sps);
......@@ -3089,21 +3053,16 @@ bool InterPrediction::xFrucIsInList( const MvField & rMvField , std::list<MvFiel
}
return( false );
}
#if REMOVE_MV_ADAPT_PREC
void InterPrediction::xFrucInsertMv2StartList(const MvField & rMvField, std::list<MvField> & rList)
#else
void InterPrediction::xFrucInsertMv2StartList(const MvField & rMvField, std::list<MvField> & rList, bool setHighPrec)
#endif
void InterPrediction::xFrucInsertMv2StartList( const MvField & rMvField , std::list<MvField> & rList, bool setHighPrec )
{
CHECK( rMvField.refIdx < 0, "invalid ref idx" );
MvField mf = rMvField;
#if !REMOVE_MV_ADAPT_PREC
if (setHighPrec)
if( setHighPrec )
{
mf.mv.setHighPrec();
}
#endif
// do not use zoom in FRUC for now
if( xFrucIsInList( mf , rList ) == false )
......@@ -3123,11 +3082,7 @@ void InterPrediction::xFrucCollectBlkStartMv( PredictionUnit& pu, const MergeCtx
{
MvField mvCnd;
mvCnd.setMvField( pInfo->mvCand[nAMVPIndex], nTargetRefIdx );
#if REMOVE_MV_ADAPT_PREC
xFrucInsertMv2StartList(mvCnd, m_listMVFieldCand[eTargetRefList]);
#else
xFrucInsertMv2StartList(mvCnd, m_listMVFieldCand[eTargetRefList], pu.cs->sps->getSpsNext().getUseHighPrecMv());
#endif
xFrucInsertMv2StartList( mvCnd, m_listMVFieldCand[eTargetRefList], pu.cs->sps->getSpsNext().getUseHighPrecMv() );
}
}
......@@ -3142,11 +3097,7 @@ void InterPrediction::xFrucCollectBlkStartMv( PredictionUnit& pu, const MergeCtx
{
if( nTargetRefIdx >= 0 && ( mergeCtx.mvFieldNeighbours[nMergeIndex].refIdx != nTargetRefIdx || ( nMergeIndex & 0x01 ) != ( int )eTargetRefList ) )
continue;
#if REMOVE_MV_ADAPT_PREC
xFrucInsertMv2StartList(mergeCtx.mvFieldNeighbours[nMergeIndex], m_listMVFieldCand[nMergeIndex & 0x01]);
#else
xFrucInsertMv2StartList(mergeCtx.mvFieldNeighbours[nMergeIndex], m_listMVFieldCand[nMergeIndex & 0x01], pu.cs->sps->getSpsNext().getUseHighPrecMv());
#endif
xFrucInsertMv2StartList( mergeCtx.mvFieldNeighbours[nMergeIndex] , m_listMVFieldCand[nMergeIndex&0x01], pu.cs->sps->getSpsNext().getUseHighPrecMv() );
}
}
......@@ -3175,11 +3126,7 @@ void InterPrediction::xFrucCollectBlkStartMv( PredictionUnit& pu, const MergeCtx
if( nTargetRefIdx >= 0 && ( frucMi.refIdx[eCurList] != nTargetRefIdx || eCurList != eTargetRefList ) )
continue;
mvCand.setMvField( frucMi.mv[eCurList], frucMi.refIdx[eCurList] );
#if REMOVE_MV_ADAPT_PREC
xFrucInsertMv2StartList(mvCand, m_listMVFieldCand[nList & 0x01]);
#else
xFrucInsertMv2StartList(mvCand, m_listMVFieldCand[nList & 0x01], pu.cs->sps->getSpsNext().getUseHighPrecMv());
#endif
xFrucInsertMv2StartList( mvCand , m_listMVFieldCand[nList&0x01], pu.cs->sps->getSpsNext().getUseHighPrecMv() );
}
}
}
......@@ -3235,11 +3182,7 @@ void InterPrediction::xFrucCollectBlkStartMv( PredictionUnit& pu, const MergeCtx
continue;
MvField mvCand;
mvCand.setMvField( neibPU->getMotionInfo( neibPos ).mv[eCurList], neibPU->getMotionInfo( neibPos ).refIdx[eCurList] );
#if REMOVE_MV_ADAPT_PREC
xFrucInsertMv2StartList(mvCand, m_listMVFieldCand[nList & 0x01]);
#else
xFrucInsertMv2StartList(mvCand, m_listMVFieldCand[nList & 0x01], pu.cs->sps->getSpsNext().getUseHighPrecMv());
#endif
xFrucInsertMv2StartList( mvCand , m_listMVFieldCand[nList&0x01], pu.cs->sps->getSpsNext().getUseHighPrecMv() );
}
}
}
......@@ -3252,11 +3195,8 @@ void InterPrediction::xFrucCollectSubBlkStartMv( PredictionUnit& pu, const Merge
rStartMvList.clear();
// start Mv
#if REMOVE_MV_ADAPT_PREC
xFrucInsertMv2StartList(rMvStart, rStartMvList);
#else
xFrucInsertMv2StartList(rMvStart, rStartMvList, pu.cs->sps->getSpsNext().getUseHighPrecMv());
#endif
xFrucInsertMv2StartList( rMvStart , rStartMvList, pu.cs->sps->getSpsNext().getUseHighPrecMv() );
// add some neighbors if not already present
const PredictionUnit *neibPU = NULL;
......@@ -3298,11 +3238,7 @@ void InterPrediction::xFrucCollectSubBlkStartMv( PredictionUnit& pu, const Merge
{
MvField mvCand;
mvCand.setMvField( neibPU->getMotionInfo( neibPos ).mv[eRefPicList], neibPU->getMotionInfo( neibPos ).refIdx[eRefPicList] );
#if REMOVE_MV_ADAPT_PREC
xFrucInsertMv2StartList(mvCand, rStartMvList);
#else
xFrucInsertMv2StartList(mvCand, rStartMvList, pu.cs->sps->getSpsNext().getUseHighPrecMv());
#endif
xFrucInsertMv2StartList( mvCand , rStartMvList, pu.cs->sps->getSpsNext().getUseHighPrecMv() );
}
}
......@@ -3338,12 +3274,11 @@ void InterPrediction::xFrucCollectSubBlkStartMv( PredictionUnit& pu, const Merge
{
CHECK( colMi.isInter == false, "invalid motion info" );
Mv rColMv = colMi.mv[nRefListColPic];
#if !REMOVE_MV_ADAPT_PREC
if (pu.cs->sps->getSpsNext().getUseHighPrecMv())
if( pu.cs->sps->getSpsNext().getUseHighPrecMv() )
{
rColMv.setHighPrec();
}
#endif
mvCand.refIdx = rMvStart.refIdx;
#if JVET_K0157
......@@ -3358,11 +3293,7 @@ void InterPrediction::xFrucCollectSubBlkStartMv( PredictionUnit& pu, const Merge
{
printf( "base" );
}
#if REMOVE_MV_ADAPT_PREC
xFrucInsertMv2StartList(mvCand, rStartMvList);
#else
xFrucInsertMv2StartList(mvCand, rStartMvList, pu.cs->sps->getSpsNext().getUseHighPrecMv());
#endif
xFrucInsertMv2StartList( mvCand , rStartMvList, pu.cs->sps->getSpsNext().getUseHighPrecMv() );
}
}
}
......@@ -3399,21 +3330,13 @@ void InterPrediction::xFrucCollectSubBlkStartMv( PredictionUnit& pu, const Merge
if( rMvStart.refIdx == subPuMi.refIdx[eRefPicList] && subPuMi.interDir & ( 1 << eRefPicList ) )
{
MvField mvCand = MvField( subPuMi.mv[eRefPicList], subPuMi.refIdx[eRefPicList] );
#if REMOVE_MV_ADAPT_PREC
xFrucInsertMv2StartList(mvCand, rStartMvList);
#else
xFrucInsertMv2StartList(mvCand, rStartMvList, pu.cs->sps->getSpsNext().getUseHighPrecMv());
#endif
xFrucInsertMv2StartList( mvCand, rStartMvList, pu.cs->sps->getSpsNext().getUseHighPrecMv() );
}
const MotionInfo subPuExtMi = mergeCtx.subPuMvpExtMiBuf.at( g_miScaling.scale( Position( x, y ) ) );
if( rMvStart.refIdx == subPuExtMi.refIdx[eRefPicList] && subPuExtMi.interDir & ( 1 << eRefPicList ) )
{
MvField mvCand = MvField( subPuExtMi.mv[eRefPicList], subPuExtMi.refIdx[eRefPicList] );
#if REMOVE_MV_ADAPT_PREC
xFrucInsertMv2StartList(mvCand, rStartMvList);
#else
xFrucInsertMv2StartList(mvCand, rStartMvList, pu.cs->sps->getSpsNext().getUseHighPrecMv());
#endif
xFrucInsertMv2StartList( mvCand, rStartMvList, pu.cs->sps->getSpsNext().getUseHighPrecMv() );
}
}
}
......@@ -3462,11 +3385,7 @@ uint32_t InterPrediction::xFrucFindBestMvFromList( MvField* pBestMvField, RefPic
#endif
if( bMvCost )
{
#if REMOVE_MV_ADAPT_PREC
uiCost = xFrucGetMvCost(rMvStart.mv, pos->mv, MAX_INT, FRUC_MERGE_REFINE_MVWEIGHT, VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE);
#else
uiCost = xFrucGetMvCost(rMvStart.mv, pos->mv, MAX_INT, FRUC_MERGE_REFINE_MVWEIGHT, pu.cs->sps->getSpsNext().getUseHighPrecMv() ? VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : 0);
#endif
uiCost = xFrucGetMvCost( rMvStart.mv , pos->mv, MAX_INT, FRUC_MERGE_REFINE_MVWEIGHT, pu.cs->sps->getSpsNext().getUseHighPrecMv() ? VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : 0 );
if( uiCost > uiMinCost )
continue;
}
......@@ -3552,14 +3471,10 @@ uint32_t InterPrediction::xFrucRefineMv( MvField* pBestMvField, RefPicList eCurR
#endif
{
int nSearchStepShift = 0;
#if REMOVE_MV_ADAPT_PREC
nSearchStepShift = VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#else
if (pu.cs->sps->getSpsNext().getUseHighPrecMv())
if( pu.cs->sps->getSpsNext().getUseHighPrecMv() )
{
nSearchStepShift = VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
}
#endif
switch( nSearchMethod )
{
......@@ -3669,12 +3584,10 @@ uint32_t InterPrediction::xFrucRefineMvSearch ( MvField* pBestMvField, RefPicLis
int nBestDirect;
int rSearchRange = pu.cs->sps->getSpsNext().getFRUCRefineRange();
#if !REMOVE_MV_ADAPT_PREC
if (!pu.cs->sps->getSpsNext().getUseHighPrecMv())
if( !pu.cs->sps->getSpsNext().getUseHighPrecMv() )
{
rSearchRange >>= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
}
#endif
for( uint32_t uiRound = 0 ; uiRound < uiMaxSearchRounds ; uiRound++ )
{
nBestDirect = -1;
......@@ -3694,31 +3607,18 @@ uint32_t InterPrediction::xFrucRefineMvSearch ( MvField* pBestMvField, RefPicLis
Mv mvOffset = pSearchOffset[nDirect];
mvOffset <<= nSearchStepShift;
MvField mvCand = mvCurCenter;
#if !REMOVE_MV_ADAPT_PREC
if (mvCand.mv.highPrec && !mvOffset.highPrec)
if( mvCand.mv.highPrec && !mvOffset.highPrec )
{
mvOffset.highPrec = true;
}
#endif
mvCand.mv += mvOffset;
#if DISTORTION_TYPE_BUGFIX
Distortion uiCost = (Distortion) xFrucGetMvCost(
rMvStart.mv, mvCand.mv, rSearchRange, FRUC_MERGE_REFINE_MVWEIGHT,
#if REMOVE_MV_ADAPT_PREC
VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE
#else
pu.cs->sps->getSpsNext().getUseHighPrecMv() ? VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : 0
#endif
);
pu.cs->sps->getSpsNext().getUseHighPrecMv() ? VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : 0);
if (bMvCostZero && uiCost != std::numeric_limits<Distortion>::max())
#else
uint32_t uiCost = xFrucGetMvCost( rMvStart.mv, mvCand.mv, rSearchRange, FRUC_MERGE_REFINE_MVWEIGHT,
#if REMOVE_MV_ADAPT_PREC
VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE
#else
pu.cs->sps->getSpsNext().getUseHighPrecMv() ? VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : 0
#endif
);
uint32_t uiCost = xFrucGetMvCost( rMvStart.mv, mvCand.mv, rSearchRange, FRUC_MERGE_REFINE_MVWEIGHT, pu.cs->sps->getSpsNext().getUseHighPrecMv() ? VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : 0 );
if (bMvCostZero && uiCost != MAX_UINT)
#endif
{
......@@ -4035,14 +3935,11 @@ bool InterPrediction::xFrucGetCurBlkTemplate( PredictionUnit& pu, int nCurBlkWid
{
Mv mvTop( 0 , - ( FRUC_MERGE_TEMPLATE_SIZE << nMVUnit ) );
PelUnitBuf pcMbBuf = ( PelUnitBuf(pu.chromaFormat, PelBuf(m_acYuvPredFrucTemplate[0][0], nCurBlkWidth, FRUC_MERGE_TEMPLATE_SIZE) ) );
#if REMOVE_MV_ADAPT_PREC
mvTop <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#else
if (pu.cs->sps->getSpsNext().getUseHighPrecMv())
if( pu.cs->sps->getSpsNext().getUseHighPrecMv() )
{
mvTop.setHighPrec();
}
#endif
xPredInterBlk(COMPONENT_Y, pu, pu.cs->slice->getPic(), mvTop, pcMbBuf, false, pu.cu->slice->clpRng( COMPONENT_Y ), false, false, FRUC_MERGE_TEMPLATE, false);
}
......@@ -4050,14 +3947,11 @@ bool InterPrediction::xFrucGetCurBlkTemplate( PredictionUnit& pu, int nCurBlkWid
{
Mv mvLeft( - ( FRUC_MERGE_TEMPLATE_SIZE << nMVUnit ) , 0 );
PelUnitBuf pcMbBuf = ( PelUnitBuf(pu.chromaFormat, PelBuf(m_acYuvPredFrucTemplate[1][0], FRUC_MERGE_TEMPLATE_SIZE, nCurBlkHeight) ) );
#if REMOVE_MV_ADAPT_PREC
mvLeft <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#else
if (pu.cs->sps->getSpsNext().getUseHighPrecMv())
if( pu.cs->sps->getSpsNext().getUseHighPrecMv() )
{
mvLeft.setHighPrec();
}
#endif
xPredInterBlk(COMPONENT_Y, pu, pu.cs->slice->getPic(), mvLeft, pcMbBuf, false, pu.cu->slice->clpRng( COMPONENT_Y ), false, false, FRUC_MERGE_TEMPLATE, false);
}
......@@ -4098,16 +3992,12 @@ void InterPrediction::xFrucUpdateTemplate( PredictionUnit& pu, int nWidth, int n
if( m_bFrucTemplateAvailabe[0] )
{
Mv mvOther( 0 , - ( FRUC_MERGE_TEMPLATE_SIZE << nMVUnit ) );
#if REMOVE_MV_ADAPT_PREC
mvOther <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#endif
mvOther += pMvFieldOther->mv;
#if !REMOVE_MV_ADAPT_PREC
if (pu.cs->sps->getSpsNext().getUseHighPrecMv())
if( pu.cs->sps->getSpsNext().getUseHighPrecMv() )
{
mvOther.setHighPrec();
}
#endif
clipMv(mvOther, pu.cu->lumaPos(), sps);
xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(eCurRefPicList, pMvFieldOther->refIdx), mvOther, pcBufPredRefTop, false, pu.cu->slice->clpRng( COMPONENT_Y ), false, false, FRUC_MERGE_TEMPLATE, false);
......@@ -4117,16 +4007,12 @@ void InterPrediction::xFrucUpdateTemplate( PredictionUnit& pu, int nWidth, int n
if (m_bFrucTemplateAvailabe[1])
{
Mv mvOther( -( FRUC_MERGE_TEMPLATE_SIZE << nMVUnit ), 0 );
#if REMOVE_MV_ADAPT_PREC
mvOther <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#endif
mvOther += pMvFieldOther->mv;
#if !REMOVE_MV_ADAPT_PREC
if (pu.cs->sps->getSpsNext().getUseHighPrecMv())
if( pu.cs->sps->getSpsNext().getUseHighPrecMv() )
{
mvOther.setHighPrec();
}
#endif
clipMv(mvOther, pu.cu->lumaPos(), sps);
xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(eCurRefPicList, pMvFieldOther->refIdx), mvOther, pcBufPredRefLeft, false, pu.cu->slice->clpRng( COMPONENT_Y ), false, false, FRUC_MERGE_TEMPLATE, false);
......@@ -4142,15 +4028,13 @@ void InterPrediction::xPredInterLines( const PredictionUnit& pu, const Picture*
const ComponentID compID = COMPONENT_Y;
int iAddPrecShift = 0;
#if !REMOVE_MV_ADAPT_PREC
if (_mv.highPrec)
if( _mv.highPrec )
{
CHECK(!pu.cs->sps->getSpsNext().getUseHighPrecMv(), "Found a high-precision motion vector, but the high-precision MV extension is disabled!");
#endif
CHECK( !pu.cs->sps->getSpsNext().getUseHighPrecMv(), "Found a high-precision motion vector, but the high-precision MV extension is disabled!" );
iAddPrecShift = VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#if !REMOVE_MV_ADAPT_PREC
}
#endif
int shiftHor = 2 + iAddPrecShift + ::getComponentScaleX( compID, chFmt );
int shiftVer = 2 + iAddPrecShift + ::getComponentScaleY( compID, chFmt );
......@@ -4165,10 +4049,8 @@ void InterPrediction::xPredInterLines( const PredictionUnit& pu, const Picture*
xFrac <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE - iAddPrecShift;
yFrac <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE - iAddPrecShift;
#if !REMOVE_MV_ADAPT_PREC
CHECK(!pu.cs->sps->getSpsNext().getUseHighPrecMv() && ((xFrac & 3) != 0), "Invalid fraction");
CHECK(!pu.cs->sps->getSpsNext().getUseHighPrecMv() && ((yFrac & 3) != 0), "Invalid fraction");
#endif
CHECK( !pu.cs->sps->getSpsNext().getUseHighPrecMv() && ( ( xFrac & 3 ) != 0 ), "Invalid fraction" );
CHECK( !pu.cs->sps->getSpsNext().getUseHighPrecMv() && ( ( yFrac & 3 ) != 0 ), "Invalid fraction" );
unsigned width = dstBuf.width;
unsigned height = dstBuf.height;
......@@ -4200,11 +4082,8 @@ void InterPrediction::xFillPredBlckAndBorder( const PredictionUnit& pu, RefPicLi
Mv mv;
const Picture* refPic = pu.cu->slice->getRefPic(eRefPicList, iRefIdx);
#if REMOVE_MV_ADAPT_PREC
const int nMVUnit = 2 + VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#else
const int nMVUnit = 2;
#endif
int dstStride = MAX_CU_SIZE + DMVR_INTME_RANGE*2;
......@@ -4289,13 +4168,12 @@ void InterPrediction::xBIPMVRefine( PredictionUnit& pu, RefPicList eRefPicList,
Mv mvOffset = pSearchOffset[nDirect];
mvOffset <<= nSearchStepShift;
#if !REMOVE_MV_ADAPT_PREC
if (pu.cu->slice->getSPS()->getSpsNext().getUseHighPrecMv())
if( pu.cu->slice->getSPS()->getSpsNext().getUseHighPrecMv() )
{
CHECK(!cMvOrg.highPrec, "wrong");
CHECK( !cMvOrg.highPrec, "wrong" );
mvOffset.highPrec = true;
}
#endif
Mv cMvTemp = cMvCtr;
cMvTemp += mvOffset;
......@@ -4418,11 +4296,7 @@ void InterPrediction::xBIPMVRefine(PredictionUnit& pu, uint32_t nSearchStepShift
const int32_t refStride = m_cYuvPredTempL0.Y().stride;
for (SAD_POINT_INDEX nIdx = SAD_POINT_INDEX::BOTTOM; nIdx <= SAD_POINT_INDEX::TOP_LEFT; ++nIdx)
{
#if REMOVE_MV_ADAPT_PREC
Mv cMvDL0(m_pSearchOffset[nIdx]);
#else
Mv cMvDL0(m_pSearchOffset[nIdx], cMvOrgL0.highPrec);
#endif
const Pel *pRefL0 = m_cYuvPredTempL0.Y().bufAt(cMvDL0.getHor() + (cDistParam.MVDL0.getHor() >> nSearchStepShift), cMvDL0.getVer() + (cDistParam.MVDL0.getVer() >> nSearchStepShift));
const Mv cMvDL1(-cMvDL0);
const Pel* pRefL1 = m_cYuvPredTempL1.Y().bufAt(cMvDL1.getHor() + (cDistParam.MVDL1.getHor() >> nSearchStepShift), cMvDL1.getVer() + (cDistParam.MVDL1.getVer() >> nSearchStepShift));
......@@ -4534,11 +4408,7 @@ void InterPrediction::xBIPMVRefine(PredictionUnit& pu, uint32_t nSearchStepShift
const int32_t refStride = m_HalfPelFilteredBuffL0[0][1].Y().stride;
for (SAD_POINT_INDEX nIdx = SAD_POINT_INDEX::BOTTOM; nIdx <= SAD_POINT_INDEX::LEFT; ++nIdx)
{
#if REMOVE_MV_ADAPT_PREC
Mv cMvDL0(m_pSearchOffset[nIdx]);
#else
Mv cMvDL0(m_pSearchOffset[nIdx], cMvOrgL0.highPrec);
#endif
Mv cMvDL0(m_pSearchOffset[nIdx], cMvOrgL0.highPrec);
Mv cMvDL1(-cMvDL0);
const Pel *pRefL0 = m_filteredBlock[cMvDL0.getAbsHor()][cMvDL0.getAbsVer()][COMPONENT_Y];
const Pel *pRefL1 = m_filteredBlockL1[cMvDL1.getAbsHor()][cMvDL1.getAbsVer()];
......@@ -4626,11 +4496,7 @@ void InterPrediction::xGenerateFracPixel(PredictionUnit& pu, uint32_t nSearchSte
const uint32_t bufferWidth = restAlign ? cuWidth : cuWidth + alignSize;
const uint32_t bufferHeight = cuHeight + 1;
//(0,-/+1)
#if REMOVE_MV_ADAPT_PREC
Mv cMvL0(cMvOrgL0 + Mv(0, -1 << nSearchStepShift));
#else
Mv cMvL0(cMvOrgL0 + Mv(0, -1 << nSearchStepShift, cMvOrgL0.highPrec));
#endif
m_HalfPelFilteredBuffL0[0][1] = PelUnitBuf(pu.chromaFormat, PelBuf(m_filteredBlock[0][1][COMPONENT_Y], bufferStride, bufferWidth, bufferHeight));
clipMv(cMvL0, pu.cu->lumaPos(), *pu.cu->slice->getSPS());
xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(REF_PIC_LIST_0, pu.refIdx[REF_PIC_LIST_0]), cMvL0
......@@ -4640,11 +4506,7 @@ void InterPrediction::xGenerateFracPixel(PredictionUnit& pu, uint32_t nSearchSte
, cuWidth
, cuHeight + 1
);
#if REMOVE_MV_ADAPT_PREC
Mv cMvL1(cMvOrgL1 + Mv(0, -1 << nSearchStepShift));
#else
Mv cMvL1(cMvOrgL1 + Mv(0, -1 << nSearchStepShift, cMvOrgL1.highPrec));
#endif
m_HalfPelFilteredBuffL1[0][1] = PelUnitBuf(pu.chromaFormat, PelBuf(m_filteredBlockL1[0][1], bufferStride, bufferWidth, bufferHeight));
clipMv(cMvL1, pu.cu->lumaPos(), *pu.cu->slice->getSPS());
xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(REF_PIC_LIST_1, pu.refIdx[REF_PIC_LIST_1]), cMvL1
......@@ -4655,11 +4517,7 @@ void InterPrediction::xGenerateFracPixel(PredictionUnit& pu, uint32_t nSearchSte
, cuHeight + 1
);
//(-/+1,0)
#if REMOVE_MV_ADAPT_PREC
cMvL0 = cMvOrgL0 + Mv(-1 << nSearchStepShift, 0);
#else
cMvL0 = cMvOrgL0 + Mv(-1 << nSearchStepShift, 0, cMvOrgL0.highPrec);
#endif
m_HalfPelFilteredBuffL0[1][0] = PelUnitBuf(pu.chromaFormat, PelBuf(m_filteredBlock[1][0][COMPONENT_Y], bufferStride, bufferWidth, bufferHeight));
clipMv(cMvL0, pu.cu->lumaPos(), *pu.cu->slice->getSPS());
xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(REF_PIC_LIST_0, pu.refIdx[REF_PIC_LIST_0]), cMvL0
......@@ -4669,11 +4527,7 @@ void InterPrediction::xGenerateFracPixel(PredictionUnit& pu, uint32_t nSearchSte
, bufferWidth
, cuHeight
);
#if REMOVE_MV_ADAPT_PREC
cMvL1 = cMvOrgL1 + Mv(-1 << nSearchStepShift, 0);
#else
cMvL1 = cMvOrgL1 + Mv(-1 << nSearchStepShift, 0, cMvOrgL1.highPrec);
#endif
m_HalfPelFilteredBuffL1[1][0] = PelUnitBuf(pu.chromaFormat, PelBuf(m_filteredBlockL1[1][0], bufferStride, bufferWidth, bufferHeight));
clipMv(cMvL1, pu.cu->lumaPos(), *pu.cu->slice->getSPS());
xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(REF_PIC_LIST_1, pu.refIdx[REF_PIC_LIST_1]), cMvL1
......@@ -4700,16 +4554,12 @@ void InterPrediction::xProcessDMVR( PredictionUnit& pu, PelUnitBuf &pcYuvDst, co
//mv refinement
uint32_t searchStepShift = 2;
#if !REMOVE_MV_ADAPT_PREC
if (pu.cu->slice->getSPS()->getSpsNext().getUseHighPrecMv())
if( pu.cu->slice->getSPS()->getSpsNext().getUseHighPrecMv() )
{
#endif
searchStepShift += 2;
#if !REMOVE_MV_ADAPT_PREC
pu.mv[0].setHighPrec();