From 9738d91e4759601dd7d3c91b01bde1762fef9502 Mon Sep 17 00:00:00 2001
From: jzxu <xujizheng@bytedance.com>
Date: Tue, 22 Oct 2019 16:41:38 +0800
Subject: [PATCH] JVET-P1018: Disable IBC reference wrapping around.

---
 source/Lib/CommonLib/InterPrediction.cpp | 4 ++++
 source/Lib/CommonLib/TypeDef.h           | 2 ++
 source/Lib/DecoderLib/DecCu.cpp          | 4 ++++
 3 files changed, 10 insertions(+)

diff --git a/source/Lib/CommonLib/InterPrediction.cpp b/source/Lib/CommonLib/InterPrediction.cpp
index b0baa9c197..4e2f8f6eda 100644
--- a/source/Lib/CommonLib/InterPrediction.cpp
+++ b/source/Lib/CommonLib/InterPrediction.cpp
@@ -220,7 +220,11 @@ void InterPrediction::init( RdCost* pcRdCost, ChromaFormat chromaFormatIDC, cons
   }
   if (m_IBCBuffer.bufs.empty())
   {
+#if JVET_P1018_IBC_NO_WRAPAROUND
+    m_IBCBufferWidth = 256 * 128 / ctuSize;
+#else
     m_IBCBufferWidth = 128 * 128 / ctuSize;
+#endif
     m_IBCBuffer.create(UnitArea(chromaFormatIDC, Area(0, 0, m_IBCBufferWidth, ctuSize)));
   }
 }
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index 2839b34d28..baa0221479 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -50,6 +50,8 @@
 #include <assert.h>
 #include <cassert>
 
+#define JVET_P1018_IBC_NO_WRAPAROUND                      1 // JVET-P1018: Disable reference sample wrapping around 
+
 #define JVET_P0512_SIMD_HIGH_BITDEPTH                     1 // JVET-P0512: MC SIMD support for high internal bit-depthf
 
 #define JVET_P0491_BDOFPROF_MVD_RANGE                     1 // JVET-P0491: clip the MVD in BDOF/PROF to [-31 31]
diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp
index 32db51ed89..1af546d612 100644
--- a/source/Lib/DecoderLib/DecCu.cpp
+++ b/source/Lib/DecoderLib/DecCu.cpp
@@ -129,7 +129,11 @@ void DecCu::decompressCtu( CodingStructure& cs, const UnitArea& ctuArea )
         const int vSize = cs.slice->getSPS()->getMaxCUHeight() > 64 ? 64 : cs.slice->getSPS()->getMaxCUHeight();
         if((currCU.Y().x % vSize) == 0 && (currCU.Y().y % vSize) == 0)
         {
+#if JVET_P1018_IBC_NO_WRAPAROUND
+          m_pcInterPred->resetVPDUforIBC(cs.pcv->chrFormat, cs.slice->getSPS()->getMaxCUHeight(), vSize, currCU.Y().x  + 128*128/cs.slice->getSPS()->getMaxCUHeight(), currCU.Y().y);
+#else
           m_pcInterPred->resetVPDUforIBC(cs.pcv->chrFormat, cs.slice->getSPS()->getMaxCUHeight(), vSize, currCU.Y().x, currCU.Y().y);
+#endif
         }
       }
 #if !JVET_P0400_REMOVE_SHARED_MERGE_LIST
-- 
GitLab