diff --git a/source/Lib/CommonLib/Mv.h b/source/Lib/CommonLib/Mv.h index 7b2872a9e3de226d00f631e0e636ec46021bf802..ae36efa1d994d1cf574f8a1350f3a7b1b46f356c 100644 --- a/source/Lib/CommonLib/Mv.h +++ b/source/Lib/CommonLib/Mv.h @@ -165,8 +165,13 @@ public: const Mv scaleMv( int iScale ) const { +#if JVET_M0479_18BITS_MV_CLIP + const int mvx = Clip3( -131072, 131071, (iScale * getHor() + 127 + (iScale * getHor() < 0)) >> 8 ); + const int mvy = Clip3( -131072, 131071, (iScale * getVer() + 127 + (iScale * getVer() < 0)) >> 8 ); +#else const int mvx = Clip3( -32768, 32767, (iScale * getHor() + 127 + (iScale * getHor() < 0)) >> 8 ); const int mvy = Clip3( -32768, 32767, (iScale * getVer() + 127 + (iScale * getVer() < 0)) >> 8 ); +#endif return Mv( mvx, mvy ); } diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index e1a5da86a21c4a72d2eda4fcfd056ab103c5d074..d4a16eb0e1d8bf66ab1e8ec728a4e0a451045243 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #include <assert.h> #include <cassert> +#define JVET_M0479_18BITS_MV_CLIP 1 + #define JVET_M0464_UNI_MTS 1 #if JVET_M0464_UNI_MTS diff --git a/source/Lib/EncoderLib/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp index 3026b1d2d16eeb0cb965eda040d89bc97dec04ff..c9e0f2f80beb13e4c70f477c0f27f4b6e53a495c 100644 --- a/source/Lib/EncoderLib/InterSearch.cpp +++ b/source/Lib/EncoderLib/InterSearch.cpp @@ -4160,8 +4160,13 @@ void InterSearch::xAffineMotionEstimation( PredictionUnit& pu, for ( int i = 0; i < mvNum; i++ ) { acMvTemp[i] += acDeltaMv[i]; +#if JVET_M0479_18BITS_MV_CLIP + acMvTemp[i].hor = Clip3( -131072, 131071, acMvTemp[i].hor ); + acMvTemp[i].ver = Clip3( -131072, 131071, acMvTemp[i].ver ); +#else acMvTemp[i].hor = Clip3( -32768, 32767, acMvTemp[i].hor ); acMvTemp[i].ver = Clip3( -32768, 32767, acMvTemp[i].ver ); +#endif acMvTemp[i].roundToPrecision(MV_PRECISION_INTERNAL, MV_PRECISION_QUARTER); clipMv(acMvTemp[i], pu.cu->lumaPos(), pu.cu->lumaSize(),