diff --git a/source/Lib/CommonLib/ContextModelling.cpp b/source/Lib/CommonLib/ContextModelling.cpp index 823198497933bde7453070e5204c3111785777d0..6e64f1b2f727f234d743dbe65ea691f1eb553004 100644 --- a/source/Lib/CommonLib/ContextModelling.cpp +++ b/source/Lib/CommonLib/ContextModelling.cpp @@ -447,11 +447,43 @@ void MergeCtx::setMmvdMergeCandiInfo(PredictionUnit& pu, int candIdx) { const int scale = PU::getDistScaleFactor(currPoc, poc0, currPoc, poc1); tempMv[1] = tempMv[0]; +#if MMVD_LTRP + const bool bIsL0RefLongTerm = slice.getRefPic(REF_PIC_LIST_0, refList0)->longTerm; + const bool bIsL1RefLongTerm = slice.getRefPic(REF_PIC_LIST_1, refList1)->longTerm; + if (bIsL0RefLongTerm || bIsL1RefLongTerm) + { + if ((poc1 - currPoc)*(poc0 - currPoc) > 0) + { + tempMv[0] = tempMv[1]; + } + else + { + tempMv[0].set(-1 * tempMv[1].getHor(), -1 * tempMv[1].getVer()); + } + } + else +#endif tempMv[0] = tempMv[1].scaleMv(scale); } else { const int scale = PU::getDistScaleFactor(currPoc, poc1, currPoc, poc0); +#if MMVD_LTRP + const bool bIsL0RefLongTerm = slice.getRefPic(REF_PIC_LIST_0, refList0)->longTerm; + const bool bIsL1RefLongTerm = slice.getRefPic(REF_PIC_LIST_1, refList1)->longTerm; + if (bIsL0RefLongTerm || bIsL1RefLongTerm) + { + if ((poc1 - currPoc)*(poc0 - currPoc) > 0) + { + tempMv[1] = tempMv[0]; + } + else + { + tempMv[1].set(-1 * tempMv[0].getHor(), -1 * tempMv[0].getVer()); + } + } + else +#endif tempMv[1] = tempMv[0].scaleMv(scale); } diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index bc180425445f7c099c68df25057fc1cc6c6c5f57..ced9c082fbb010645b11783caf2bfd0a6eb17157 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #include <assert.h> #include <cassert> +#define MMVD_LTRP 1 // MVD scaling for MMVD considering LTRP from JVET-N0332 + #define JCTVC_Y0038_PARAMS 1 #define JVET_MMVD_OFF_MACRO 0