From 75098135d763335a971694080e73e403584e44a5 Mon Sep 17 00:00:00 2001
From: Yue Li <yue.li@bytedance.com>
Date: Thu, 18 Aug 2022 16:45:15 -0700
Subject: [PATCH] add a Macro related to training data generation of
 JVET-AA0111 (disabled by default)

---
 source/Lib/CommonLib/TypeDef.h            |  1 +
 source/Lib/EncoderLib/EncNNFilterSet1.cpp | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index b478ce7ed5..3c3c7c63bf 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -94,6 +94,7 @@ using TypeSadl = float;
 #if NN_FILTERING_SET_1
 #define SCALE_NN_RESIDUE                                  1
 #define COMBINE_NN_WITH_LF                                1
+#define BYPASS_INTER_SLICE                                0 // only used for training data generation
 #endif
 
 #if SCALE_NN_RESIDUE
diff --git a/source/Lib/EncoderLib/EncNNFilterSet1.cpp b/source/Lib/EncoderLib/EncNNFilterSet1.cpp
index d335c6cbc4..002858b761 100644
--- a/source/Lib/EncoderLib/EncNNFilterSet1.cpp
+++ b/source/Lib/EncoderLib/EncNNFilterSet1.cpp
@@ -301,6 +301,22 @@ void EncNNFilterSet1::cnnFilterEncoder(Picture *pic, const double *lambdas)
   
   int numParams = cs.sps->getNnlfSet1MaxNumParams();
   
+#if BYPASS_INTER_SLICE
+  if (pcSlice->getSliceType() != I_SLICE)
+  {
+    for (int chal = 0; chal < numValidChannels; chal++)
+    {
+      const ChannelType chType = ChannelType( chal );
+      pcSlice->setNnlfSet1Mode(chType, 0);
+      for (int paramIdx = 0; paramIdx < numParams; paramIdx ++)
+      {
+        pcSlice->setNnScaleFlag(false, paramIdx, chType);
+      }
+    }
+    return;
+  }
+#endif
+  
   cnnFilterPicture(pic, numParams);
 
   double minCost[2]       = {MAX_DOUBLE, MAX_DOUBLE};
-- 
GitLab