From 083edcb6e46ad5543d0db5213073e7eae1965438 Mon Sep 17 00:00:00 2001
From: Xiaozhong Xu <xiaozhongxu@tencent.com>
Date: Wed, 21 Nov 2018 22:52:24 -0500
Subject: [PATCH] disallow current picture to be the collocated picture

---
 source/Lib/DecoderLib/DecLib.cpp | 7 +++++++
 source/Lib/EncoderLib/EncGOP.cpp | 8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp
index 00d2f45b2..617f6907d 100644
--- a/source/Lib/DecoderLib/DecLib.cpp
+++ b/source/Lib/DecoderLib/DecLib.cpp
@@ -1155,6 +1155,13 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl
   }
 #endif
 
+#if JVET_L0293_CPR
+  if (pcSlice->getSPS()->getSpsNext().getCPRMode() && pcSlice->getEnableTMVPFlag())
+  {
+    CHECK(pcSlice->getRefPic(RefPicList(pcSlice->isInterB() ? 1 - pcSlice->getColFromL0Flag() : 0), pcSlice->getColRefIdx())->getPOC() == pcSlice->getPOC(), "curr ref picture cannot be collocated picture");
+  }
+#endif
+
 
   //  Decode a picture
   m_cSliceDecoder.decompressSlice( pcSlice, &(nalu.getBitstream()) );
diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp
index 29b659ed7..ddb531fba 100644
--- a/source/Lib/EncoderLib/EncGOP.cpp
+++ b/source/Lib/EncoderLib/EncGOP.cpp
@@ -1791,6 +1791,14 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
       pcSlice->setEnableTMVPFlag(0);
     }
 
+#if JVET_L0293_CPR
+    // disable TMVP when current picture is the only ref picture
+    if (pcSlice->isIRAP() && pcSlice->getSPS()->getSpsNext().getCPRMode())
+    {
+      pcSlice->setEnableTMVPFlag(0);
+    }
+#endif
+
     // set adaptive search range for non-intra-slices
     if (m_pcCfg->getUseASR() && !pcSlice->isIRAP())
     {
-- 
GitLab