Commit c937ccec authored by Yan Zhang's avatar Yan Zhang

High precision mv storage bug fixing

Fix a bug that lead to different result when the macro is on and off
parent 87962805
......@@ -834,7 +834,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
#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]")
("HighPrecMv", m_highPrecisionMv, false, "High precision motion vectors for temporal merging (0:off, 1:on) [default: off]")
#endif
#endif
#if JEM_TOOLS || JVET_K_AFFINE
......@@ -2127,7 +2127,7 @@ bool EncAppCfg::xCheckParameter()
#endif
#if JVET_K_AFFINE
#if !REMOVE_MV_ADAPT_PREC
xConfirmPara( m_Affine && !m_highPrecisionMv, "Affine is not yet implemented for HighPrecMv off." );
xConfirmPara(m_Affine && !m_highPrecisionMv, "Affine is not yet implemented for HighPrecMv off.");
#endif
#endif
#if JEM_TOOLS
......@@ -3416,7 +3416,7 @@ void EncAppCfg::xPrintParameter()
#endif
#if !JEM_TOOLS && (JVET_K0346 || JVET_K_AFFINE)
#if !REMOVE_MV_ADAPT_PREC
msg(VERBOSE, "HighPrecMv:%d ", m_highPrecisionMv);
msg( VERBOSE, "HighPrecMv:%d ", m_highPrecisionMv );
#endif
#endif
msg( VERBOSE, "DisMDC:%d ", m_DisableMotionCompression );
......
......@@ -66,40 +66,21 @@ enum CodingStatisticsType
STATS__CABAC_BITS__REF_FRM_IDX,
STATS__CABAC_BITS__MVD,
STATS__CABAC_BITS__MVD_EP,
#if JEM_TOOLS || JVET_K_AFFINE
STATS__CABAC_BITS__AFFINE_FLAG,
#if JVET_K0337_AFFINE_6PARA
STATS__CABAC_BITS__AFFINE_TYPE,
#endif
#endif
STATS__CABAC_BITS__TRANSFORM_SUBDIV_FLAG,
STATS__CABAC_BITS__QT_ROOT_CBF,
STATS__CABAC_BITS__DELTA_QP_EP,
STATS__CABAC_BITS__CHROMA_QP_ADJUSTMENT,
#if JEM_TOOLS
STATS__CABAC_BITS__LIC_FLAG,
#endif
STATS__CABAC_BITS__QT_CBF,
STATS__CABAC_BITS__CROSS_COMPONENT_PREDICTION,
STATS__CABAC_BITS__TRANSFORM_SKIP_FLAGS,
STATS__CABAC_BITS__LAST_SIG_X_Y,
STATS__CABAC_BITS__SIG_COEFF_GROUP_FLAG,
STATS__CABAC_BITS__SIG_COEFF_MAP_FLAG,
#if JVET_K0072
STATS__CABAC_BITS__PAR_FLAG,
#endif
STATS__CABAC_BITS__GT1_FLAG,
STATS__CABAC_BITS__GT2_FLAG,
STATS__CABAC_BITS__SIGN_BIT,
STATS__CABAC_BITS__ESCAPE_BITS,
STATS__CABAC_BITS__SAO,
#if JVET_K0371_ALF
STATS__CABAC_BITS__ALF,
#endif
#if JEM_TOOLS
STATS__CABAC_BITS__NSST,
#endif
STATS__CABAC_TRM_BITS,
STATS__CABAC_FIXED_BITS,
STATS__CABAC_PCM_ALIGN_BITS,
......@@ -110,10 +91,23 @@ enum CodingStatisticsType
STATS__CABAC_EP_BIT_ALIGNMENT,
STATS__CABAC_BITS__ALIGNED_SIGN_BIT,
STATS__CABAC_BITS__ALIGNED_ESCAPE_BITS,
#if JEM_TOOLS
STATS__CABAC_BITS__OBMC_FLAG,
STATS__CABAC_BITS__OTHER,
STATS__CABAC_BITS__INVALID,
STATS__TOOL_TOTAL_FRAME,// This is a special case and is not included in the report.
#if JEM_TOOLS || JVET_K_AFFINE
STATS__CABAC_BITS__AFFINE_FLAG,
STATS__TOOL_AFF,
#if JVET_K0337_AFFINE_6PARA
STATS__CABAC_BITS__AFFINE_TYPE,
#endif
#if JVET_K0357_AMVR
#endif
#if JVET_K0072
STATS__CABAC_BITS__PAR_FLAG,
#endif
#if JVET_K0371_ALF
STATS__CABAC_BITS__ALF,
#endif
#if JEM_TOOLS || JVET_K0357_AMVR
STATS__CABAC_BITS__IMV_FLAG,
#endif
#if JEM_TOOLS || JVET_K1000_SIMPLIFIED_EMT
......@@ -123,13 +117,14 @@ enum CodingStatisticsType
#if JVET_K0248_GBI
STATS__CABAC_BITS__GBI_IDX,
#endif
STATS__CABAC_BITS__OTHER,
STATS__CABAC_BITS__INVALID,
STATS__TOOL_TOTAL_FRAME,// This is a special case and is not included in the report.
#if JEM_TOOLS || JVET_K1000_SIMPLIFIED_EMT
STATS__TOOL_EMT,
#endif
#if JEM_TOOLS
STATS__TOOL_AFF,
STATS__CABAC_BITS__NSST,
STATS__CABAC_BITS__LIC_FLAG,
STATS__CABAC_BITS__OBMC_FLAG,
STATS__TOOL_NSST,
STATS__TOOL_EMT,
#endif
STATS__TOOL_TOTAL,
STATS__NUM_STATS
......
This diff is collapsed.
......@@ -327,7 +327,7 @@ protected:
#if REMOVE_MV_ADAPT_PREC
void xFrucInsertMv2StartList (const MvField & rMvField, std::list<MvField> & rList);
#else
void xFrucInsertMv2StartList (const MvField & rMvField, std::list<MvField> & rList,bool setHighPrec);
void xFrucInsertMv2StartList (const MvField & rMvField, std::list<MvField> & rList, bool setHighPrec);
#endif
bool xFrucIsInList (const MvField & rMvField, std::list<MvField> & rList);
......
......@@ -507,7 +507,7 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De
int nThreshold = 4;
#if JEM_TOOLS || JVET_K0346 || JVET_K_AFFINE
#if !REMOVE_MV_ADAPT_PREC
if( cu.cs->sps->getSpsNext().getUseHighPrecMv() )
if (cu.cs->sps->getSpsNext().getUseHighPrecMv())
{
mvP0.setHighPrec();
mvP1.setHighPrec();
......@@ -574,7 +574,7 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De
int nThreshold = 4;
#if JEM_TOOLS || JVET_K0346 || JVET_K_AFFINE
#if !REMOVE_MV_ADAPT_PREC
if( cu.cs->sps->getSpsNext().getUseHighPrecMv() )
if (cu.cs->sps->getSpsNext().getUseHighPrecMv())
{
mvP0.setHighPrec();
mvQ0.setHighPrec();
......
......@@ -66,12 +66,12 @@ void roundAffineMv( int& mvx, int& mvy, int nShift )
void clipMv( Mv& rcMv, const Position& pos, const SPS& sps )
{
#if (JEM_TOOLS || JVET_K0346 || JVET_K_AFFINE) && !REMOVE_MV_ADAPT_PREC
int iMvShift = 2 + ( rcMv.highPrec ? VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : 0 );
int iMvShift = 2 + (rcMv.highPrec ? VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : 0);
#else
int iMvShift = 2;
#endif
#if REMOVE_MV_ADAPT_PREC
iMvShift += VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
iMvShift += VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#endif
int iOffset = 8;
int iHorMax = ( sps.getPicWidthInLumaSamples() + iOffset - ( int ) pos.x - 1 ) << iMvShift;
......
......@@ -282,41 +282,39 @@ public:
void roundMV2SignalPrecision()
{
#if REMOVE_MV_ADAPT_PREC
setLowPrec();
setHighPrec();
const int nShift = VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
const int nOffset = 1 << (nShift - 1);
hor = hor >= 0 ? (hor + nOffset) >> nShift : -((-hor + nOffset) >> nShift);
ver = ver >= 0 ? (ver + nOffset) >> nShift : -((-ver + nOffset) >> nShift);
hor = hor >= 0 ? (hor) << VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : -((-hor) << VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE);
ver = ver >= 0 ? (ver) << VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : -((-ver) << VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE);
#else
const bool isHP = highPrec;
setLowPrec();
if( isHP ) setHighPrec();
#endif
}
#if !REMOVE_MV_ADAPT_PREC
void setLowPrec()
{
#if !REMOVE_MV_ADAPT_PREC
if (!highPrec) return;
#endif
const int nShift = VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
const int nOffset = 1 << ( nShift - 1 );
hor = hor >= 0 ? ( hor + nOffset ) >> nShift : -( ( -hor + nOffset ) >> nShift );
ver = ver >= 0 ? ( ver + nOffset ) >> nShift : -( ( -ver + nOffset ) >> nShift );
#if !REMOVE_MV_ADAPT_PREC
highPrec = false;
#endif
}
#endif
#if !REMOVE_MV_ADAPT_PREC
void setHighPrec()
{
#if !REMOVE_MV_ADAPT_PREC
if (highPrec) return;
#endif
hor = hor >= 0 ? ( hor ) << VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : -( ( -hor ) << VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE );
ver = ver >= 0 ? ( ver ) << VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE : -( ( -ver ) << VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE );
#if !REMOVE_MV_ADAPT_PREC
highPrec = true;
#endif
}
#endif
#endif
};// END CLASS DEFINITION MV
#if JVET_K0076_CPR
namespace std
......
......@@ -188,9 +188,9 @@ public:
{
m_mvPredictor = rcMv;
#if (JEM_TOOLS || JVET_K0346 || JVET_K_AFFINE) && !REMOVE_MV_ADAPT_PREC
if( m_mvPredictor.highPrec )
if (m_mvPredictor.highPrec)
{
m_mvPredictor = Mv( m_mvPredictor.hor >> VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE, m_mvPredictor.ver >> VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE, false );
m_mvPredictor = Mv(m_mvPredictor.hor >> VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE, m_mvPredictor.ver >> VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE, false);
}
#endif
}
......
......@@ -1021,7 +1021,7 @@ public:
#endif
#if JEM_TOOLS
#if !REMOVE_MV_ADAPT_PREC
void setUseHighPrecMv ( bool b ) { m_highPrecMv = b; }
void setUseHighPrecMv (bool b) { m_highPrecMv = b; }
bool getUseHighPrecMv () const { return m_highPrecMv; }
#endif
void setUseBIO ( bool b ) { m_BIO = b; }
......@@ -1029,8 +1029,8 @@ public:
#endif
#if !JEM_TOOLS && (JVET_K0346 || JVET_K_AFFINE)
#if !REMOVE_MV_ADAPT_PREC
void setUseHighPrecMv(bool b) { m_highPrecMv = b; }
bool getUseHighPrecMv() const { return m_highPrecMv; }
void setUseHighPrecMv (bool b) { m_highPrecMv = b; }
bool getUseHighPrecMv () const { return m_highPrecMv; }
#endif
#endif
void setDisableMotCompress ( bool b ) { m_DisableMotionCompression = b; }
......
......@@ -1068,6 +1068,13 @@ void TrQuant::xT( const TransformUnit &tu, const ComponentID &compID, const CPel
const unsigned ucMode = getEmtMode ( tu, compID );
const unsigned ucTrIdx = getEmtTrIdx( tu, compID );
if( ucTrIdx != DCT2 )
{
#if RExt__DECODER_DEBUG_TOOL_STATISTICS
CodingStatistics::IncrementStatisticTool( CodingStatisticsClassType{ STATS__TOOL_EMT, uint32_t( iWidth ), uint32_t( iHeight ), compID } );
#endif
}
#if INTRA67_3MPM
#if HEVC_USE_4x4_DSTVII
xTrMxN_EMT(channelBitDepth, resi.buf, resi.stride, dstCoeff.buf, iWidth, iHeight, useDST, maxLog2TrDynamicRange, ucMode, ucTrIdx
......
This diff is collapsed.
......@@ -181,15 +181,15 @@ namespace PU
#if JVET_K0357_AMVR
void applyImv ( PredictionUnit &pu, MergeCtx &mrgCtx, InterPrediction *interPred = NULL );
#endif
#if JEM_TOOLS
bool isAffineMrgFlagCoded (const PredictionUnit &pu );
#if JVET_K0248_GBI
void getAffineMergeCand (const PredictionUnit &pu, MvField (*mvFieldNeighbours)[3], unsigned char &interDirNeighbours, unsigned char &gbiIdx, int &numValidMergeCand);
#else
void getAffineMergeCand (const PredictionUnit &pu, MvField (*mvFieldNeighbours)[3], unsigned char &interDirNeighbours, int &numValidMergeCand );
#endif
#if JEM_TOOLS
bool isAffineMrgFlagCoded (const PredictionUnit &pu );
void setAllAffineMvField ( PredictionUnit &pu, MvField *mvField, RefPicList eRefList );
void setAllAffineMv ( PredictionUnit &pu, Mv affLT, Mv affRT, Mv affLB, RefPicList eRefList
void setAllAffineMv ( PredictionUnit &pu, Mv affLT, Mv affRT, Mv affLB, RefPicList eRefList
#if REMOVE_MV_ADAPT_PREC
, bool setHighPrec = false
#endif
......@@ -200,7 +200,7 @@ namespace PU
bool isAffineMrgFlagCoded (const PredictionUnit &pu );
void getAffineMergeCand (const PredictionUnit &pu, MvField (*mvFieldNeighbours)[3], unsigned char &interDirNeighbours, int &numValidMergeCand );
void setAllAffineMvField ( PredictionUnit &pu, MvField *mvField, RefPicList eRefList );
void setAllAffineMv ( PredictionUnit &pu, Mv affLT, Mv affRT, Mv affLB, RefPicList eRefList
void setAllAffineMv ( PredictionUnit &pu, Mv affLT, Mv affRT, Mv affLB, RefPicList eRefList
#if REMOVE_MV_ADAPT_PREC
, bool setHighPrec = false
#endif
......
......@@ -467,9 +467,11 @@ void DecCu::xDeriveCUMV( CodingUnit &cu )
MergeCtx mrgCtx;
#if RExt__DECODER_DEBUG_TOOL_STATISTICS
#if JEM_TOOLS
if (pu.cu->affine)
CodingStatistics::IncrementStatisticTool(CodingStatisticsClassType{ STATS__TOOL_AFF, pu.Y().width, pu.Y().height });
#if JEM_TOOLS || JVET_K_AFFINE
if( pu.cu->affine )
{
CodingStatistics::IncrementStatisticTool( CodingStatisticsClassType{ STATS__TOOL_AFF, pu.Y().width, pu.Y().height } );
}
#endif
#endif
#if JVET_K0248_GBI
......@@ -607,8 +609,8 @@ void DecCu::xDeriveCUMV( CodingUnit &cu )
mvRT += pu.mvdAffi[eRefList][0];
#endif
#if REMOVE_MV_ADAPT_PREC
mvLT.setHighPrec();
mvRT.setHighPrec();
mvLT <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
mvRT <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#else
CHECK(!mvLT.highPrec, "unexpected lp mv");
CHECK(!mvRT.highPrec, "unexpected lp mv");
......@@ -624,7 +626,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu )
mvLB += pu.mvdAffi[eRefList][0];
#endif
#if REMOVE_MV_ADAPT_PREC
mvLB.setHighPrec();
mvLB <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#else
CHECK(!mvLB.highPrec, "unexpected lp mv");
#endif
......@@ -677,10 +679,15 @@ void DecCu::xDeriveCUMV( CodingUnit &cu )
#else
pu.mv [eRefList] = amvpInfo.mvCand[pu.mvpIdx [eRefList]] + pu.mvd[eRefList];
#endif
#if JEM_TOOLS || JVET_K_AFFINE
if( pu.cs->sps->getSpsNext().getUseAffine())
if( pu.cs->sps->getSpsNext().getUseAffine() )
{
#if REMOVE_MV_ADAPT_PREC
pu.mv[eRefList] <<= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
#else
pu.mv[eRefList].setHighPrec();
#endif
}
#endif
}
......
......@@ -829,13 +829,13 @@ void HLSyntaxReader::parseSPSNext( SPSNext& spsNext, const bool usePCM )
#endif
#if JEM_TOOLS
#if !REMOVE_MV_ADAPT_PREC
READ_FLAG( symbol, "high_precision_motion_vectors" ); spsNext.setUseHighPrecMv ( symbol != 0 );
READ_FLAG( symbol, "high_precision_motion_vectors"); spsNext.setUseHighPrecMv ( symbol != 0 );
#endif
READ_FLAG( symbol, "bio_enable_flag" ); spsNext.setUseBIO ( symbol != 0 );
#endif
#if !JEM_TOOLS && (JVET_K0346 || JVET_K_AFFINE)
#if !REMOVE_MV_ADAPT_PREC
READ_FLAG( symbol, "high_precision_motion_vectors" ); spsNext.setUseHighPrecMv(symbol != 0);
READ_FLAG( symbol, "high_precision_motion_vectors"); spsNext.setUseHighPrecMv ( symbol != 0 );
#endif
#endif
READ_FLAG( symbol, "disable_motion_compression_flag" ); spsNext.setDisableMotCompress ( symbol != 0 );
......
......@@ -2704,10 +2704,10 @@ void CABACWriter::mvd_coding( const Mv &rMvd )
unsigned verAbs = unsigned( verMvd < 0 ? -verMvd : verMvd );
#if (JEM_TOOLS || JVET_K0346 || JVET_K_AFFINE) && !REMOVE_MV_ADAPT_PREC
if( rMvd.highPrec )
if (rMvd.highPrec)
{
CHECK( horAbs & ((1<<VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE)-1), "mvd-x has high precision fractional part." );
CHECK( verAbs & ((1<<VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE)-1), "mvd-y has high precision fractional part." );
CHECK(horAbs & ((1 << VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE) - 1), "mvd-x has high precision fractional part.");
CHECK(verAbs & ((1 << VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE) - 1), "mvd-y has high precision fractional part.");
horAbs >>= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
verAbs >>= VCEG_AZ07_MV_ADD_PRECISION_BIT_FOR_STORE;
}
......
......@@ -767,8 +767,8 @@ public:
#endif
#if !JEM_TOOLS && (JVET_K0346 || JVET_K_AFFINE)
#if !REMOVE_MV_ADAPT_PREC
void setHighPrecisionMv(bool b) { m_highPrecMv = b; }
bool getHighPrecisionMv() { return m_highPrecMv; }
void setHighPrecisionMv ( bool b ) { m_highPrecMv = b; }
bool getHighPrecisionMv () { return m_highPrecMv; }
#endif
#endif
void setDisableMotionCompression ( bool b ) { m_DisableMotionCompression = b; }
......
This diff is collapsed.
......@@ -227,21 +227,19 @@ protected:
void xCheckRDCostMerge2Nx2NFRUC
( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode );
#endif
void xEncodeInterResidual ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode, int residualPass = 0
#if JEM_TOOLS || JVET_K0357_AMVR
#if JVET_K0248_GBI
void xEncodeInterResidual ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode, int residualPass = 0, CodingStructure* imvCS = NULL, int emtMode = 1, bool* bestHasNonResi = NULL, double* equGBiCost = NULL);
#else
void xEncodeInterResidual ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode, int residualPass = 0, CodingStructure* imvCS = NULL, int emtMode = 1, bool* bestHasNonResi = NULL);
, CodingStructure* imvCS = NULL
#endif
#else
#if JVET_K0248_GBI
void xEncodeInterResidual ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode, int residualPass, bool* bestHasNonResi, double* equGBiCost = NULL);
#else
void xEncodeInterResidual ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode, int residualPass, bool* bestHasNonResi);
#if JEM_TOOLS || JVET_K1000_SIMPLIFIED_EMT
, int emtMode = 1
#endif
, bool* bestHasNonResi = NULL
#if JVET_K0248_GBI
, double* equGBiCost = NULL
#endif
);
#if REUSE_CU_RESULTS
void xReuseCachedResult ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &Partitioner );
#endif
#if JVET_K0076_CPR
......
......@@ -978,7 +978,7 @@ void EncLib::xInitSPS(SPS &sps)
#endif
#if !JEM_TOOLS && JVET_K0346 && !JVET_K_AFFINE
#if !REMOVE_MV_ADAPT_PREC
sps.getSpsNext().setUseHighPrecMv(m_highPrecMv);
sps.getSpsNext().setUseHighPrecMv ( m_highPrecMv );
#endif
#endif
sps.getSpsNext().setDisableMotCompress ( m_DisableMotionCompression );
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment