From 81c72e4106f9b3051d40dc8f128bdfe15c1cf32b Mon Sep 17 00:00:00 2001
From: Yue Li <yue.li@bytedance.com>
Date: Sun, 14 Aug 2022 20:49:32 -0700
Subject: [PATCH]  code cleanup and renaming regarding JVET-AA0111

---
 models/.DS_Store                              | Bin 6148 -> 0 bytes
 ...et1_ChromaCNNFilter_InterSlice_float.sadl} | Bin
 ...et1_ChromaCNNFilter_InterSlice_int16.sadl} | Bin
 ...et1_ChromaCNNFilter_IntraSlice_float.sadl} | Bin
 ...et1_ChromaCNNFilter_IntraSlice_int16.sadl} | Bin
 ...fSet1_LumaCNNFilter_InterSlice_float.sadl} | Bin
 ...fSet1_LumaCNNFilter_InterSlice_int16.sadl} | Bin
 ...fSet1_LumaCNNFilter_IntraSlice_float.sadl} | Bin
 ...fSet1_LumaCNNFilter_IntraSlice_int16.sadl} | Bin
 source/App/DecoderAnalyserApp/CMakeLists.txt  |   2 -
 source/App/DecoderApp/CMakeLists.txt          |   2 -
 source/App/DecoderApp/DecApp.cpp              |  14 +-
 source/App/DecoderApp/DecAppCfg.cpp           |  13 +-
 source/App/DecoderApp/DecAppCfg.h             |  12 +-
 source/App/DecoderApp/decmain.cpp             |  13 -
 source/App/EncoderApp/CMakeLists.txt          |   2 -
 source/App/EncoderApp/EncApp.cpp              |  20 +-
 source/App/EncoderApp/EncAppCfg.cpp           |  19 +-
 source/App/EncoderApp/EncAppCfg.h             |  22 +-
 source/Lib/CommonAnalyserLib/CMakeLists.txt   |   5 +-
 source/Lib/CommonLib/CMakeLists.txt           |   5 +-
 source/Lib/CommonLib/CNNFilter.h              |  39 ---
 source/Lib/CommonLib/Contexts.cpp             |   6 +-
 source/Lib/CommonLib/Contexts.h               |   4 +-
 .../{CNNFilter.cpp => NNFilterSet1.cpp}       | 311 +++++-------------
 source/Lib/CommonLib/NNFilterSet1.h           |  72 ++++
 source/Lib/CommonLib/NNInference.h            |   2 +
 source/Lib/CommonLib/Picture.h                |  30 +-
 source/Lib/CommonLib/Slice.cpp                |   9 +-
 source/Lib/CommonLib/Slice.h                  |  81 +++--
 source/Lib/CommonLib/TypeDef.h                |  19 +-
 source/Lib/DecoderLib/CABACReader.cpp         |  40 +--
 source/Lib/DecoderLib/DecLib.cpp              |  62 ++--
 source/Lib/DecoderLib/DecLib.h                |  36 +-
 source/Lib/DecoderLib/DecSlice.cpp            |  20 +-
 source/Lib/DecoderLib/VLCReader.cpp           |  79 +++--
 source/Lib/EncoderLib/CABACWriter.cpp         |  42 +--
 source/Lib/EncoderLib/CABACWriter.h           |   6 +-
 source/Lib/EncoderLib/EncCNNFilter.h          |  47 ---
 source/Lib/EncoderLib/EncCfg.h                |  57 ++--
 source/Lib/EncoderLib/EncGOP.cpp              |  58 ++--
 source/Lib/EncoderLib/EncGOP.h                |  12 +-
 source/Lib/EncoderLib/EncLib.cpp              |  18 +-
 .../{EncCNNFilter.cpp => EncNNFilterSet1.cpp} | 197 ++++++-----
 source/Lib/EncoderLib/EncNNFilterSet1.h       |  80 +++++
 .../EncoderLib/EncSampleAdaptiveOffset.cpp    |   4 +-
 source/Lib/EncoderLib/VLCWriter.cpp           |  41 +--
 47 files changed, 708 insertions(+), 793 deletions(-)
 delete mode 100644 models/.DS_Store
 rename models/{JVET_Z_EE_1.6_ChromaCNNFilter_InterSlice_float.sadl => NnlfSet1_ChromaCNNFilter_InterSlice_float.sadl} (100%)
 rename models/{JVET_Z_EE_1.6_ChromaCNNFilter_InterSlice_int16.sadl => NnlfSet1_ChromaCNNFilter_InterSlice_int16.sadl} (100%)
 rename models/{JVET_Z_EE_1.6_ChromaCNNFilter_IntraSlice_float.sadl => NnlfSet1_ChromaCNNFilter_IntraSlice_float.sadl} (100%)
 rename models/{JVET_Z_EE_1.6_ChromaCNNFilter_IntraSlice_int16.sadl => NnlfSet1_ChromaCNNFilter_IntraSlice_int16.sadl} (100%)
 rename models/{JVET_Z_EE_1.6_LumaCNNFilter_InterSlice_float.sadl => NnlfSet1_LumaCNNFilter_InterSlice_float.sadl} (100%)
 rename models/{JVET_Z_EE_1.6_LumaCNNFilter_InterSlice_int16.sadl => NnlfSet1_LumaCNNFilter_InterSlice_int16.sadl} (100%)
 rename models/{JVET_Z_EE_1.6_LumaCNNFilter_IntraSlice_float.sadl => NnlfSet1_LumaCNNFilter_IntraSlice_float.sadl} (100%)
 rename models/{JVET_Z_EE_1.6_LumaCNNFilter_IntraSlice_int16.sadl => NnlfSet1_LumaCNNFilter_IntraSlice_int16.sadl} (100%)
 delete mode 100644 source/Lib/CommonLib/CNNFilter.h
 rename source/Lib/CommonLib/{CNNFilter.cpp => NNFilterSet1.cpp} (62%)
 create mode 100644 source/Lib/CommonLib/NNFilterSet1.h
 delete mode 100644 source/Lib/EncoderLib/EncCNNFilter.h
 rename source/Lib/EncoderLib/{EncCNNFilter.cpp => EncNNFilterSet1.cpp} (63%)
 create mode 100644 source/Lib/EncoderLib/EncNNFilterSet1.h

diff --git a/models/.DS_Store b/models/.DS_Store
deleted file mode 100644
index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 6148
zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3
zem<@ulZcFPQ@L2!n>{z**<q8>++&mCkOWA81W14cNZ<zv;LbK1Poaz?KmsK2CSc!(
z0ynLxE!0092;Krf2c+FF_Fe*7ECH>lEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ
zLs35+`xjp>T0<F0fCPF1$Cyrb|F7^5{eNG?83~ZUUlGt@xh*qZDeu<Z%US-OSsOPv
j)R!Z4KLME7ReXlK;d!wEw5GODWMKRea10D2@KpjYNUI8I

diff --git a/models/JVET_Z_EE_1.6_ChromaCNNFilter_InterSlice_float.sadl b/models/NnlfSet1_ChromaCNNFilter_InterSlice_float.sadl
similarity index 100%
rename from models/JVET_Z_EE_1.6_ChromaCNNFilter_InterSlice_float.sadl
rename to models/NnlfSet1_ChromaCNNFilter_InterSlice_float.sadl
diff --git a/models/JVET_Z_EE_1.6_ChromaCNNFilter_InterSlice_int16.sadl b/models/NnlfSet1_ChromaCNNFilter_InterSlice_int16.sadl
similarity index 100%
rename from models/JVET_Z_EE_1.6_ChromaCNNFilter_InterSlice_int16.sadl
rename to models/NnlfSet1_ChromaCNNFilter_InterSlice_int16.sadl
diff --git a/models/JVET_Z_EE_1.6_ChromaCNNFilter_IntraSlice_float.sadl b/models/NnlfSet1_ChromaCNNFilter_IntraSlice_float.sadl
similarity index 100%
rename from models/JVET_Z_EE_1.6_ChromaCNNFilter_IntraSlice_float.sadl
rename to models/NnlfSet1_ChromaCNNFilter_IntraSlice_float.sadl
diff --git a/models/JVET_Z_EE_1.6_ChromaCNNFilter_IntraSlice_int16.sadl b/models/NnlfSet1_ChromaCNNFilter_IntraSlice_int16.sadl
similarity index 100%
rename from models/JVET_Z_EE_1.6_ChromaCNNFilter_IntraSlice_int16.sadl
rename to models/NnlfSet1_ChromaCNNFilter_IntraSlice_int16.sadl
diff --git a/models/JVET_Z_EE_1.6_LumaCNNFilter_InterSlice_float.sadl b/models/NnlfSet1_LumaCNNFilter_InterSlice_float.sadl
similarity index 100%
rename from models/JVET_Z_EE_1.6_LumaCNNFilter_InterSlice_float.sadl
rename to models/NnlfSet1_LumaCNNFilter_InterSlice_float.sadl
diff --git a/models/JVET_Z_EE_1.6_LumaCNNFilter_InterSlice_int16.sadl b/models/NnlfSet1_LumaCNNFilter_InterSlice_int16.sadl
similarity index 100%
rename from models/JVET_Z_EE_1.6_LumaCNNFilter_InterSlice_int16.sadl
rename to models/NnlfSet1_LumaCNNFilter_InterSlice_int16.sadl
diff --git a/models/JVET_Z_EE_1.6_LumaCNNFilter_IntraSlice_float.sadl b/models/NnlfSet1_LumaCNNFilter_IntraSlice_float.sadl
similarity index 100%
rename from models/JVET_Z_EE_1.6_LumaCNNFilter_IntraSlice_float.sadl
rename to models/NnlfSet1_LumaCNNFilter_IntraSlice_float.sadl
diff --git a/models/JVET_Z_EE_1.6_LumaCNNFilter_IntraSlice_int16.sadl b/models/NnlfSet1_LumaCNNFilter_IntraSlice_int16.sadl
similarity index 100%
rename from models/JVET_Z_EE_1.6_LumaCNNFilter_IntraSlice_int16.sadl
rename to models/NnlfSet1_LumaCNNFilter_IntraSlice_int16.sadl
diff --git a/source/App/DecoderAnalyserApp/CMakeLists.txt b/source/App/DecoderAnalyserApp/CMakeLists.txt
index a1da18bf76..ad272ca1f3 100644
--- a/source/App/DecoderAnalyserApp/CMakeLists.txt
+++ b/source/App/DecoderAnalyserApp/CMakeLists.txt
@@ -7,8 +7,6 @@ file( GLOB SRC_FILES "../DecoderApp/*.cpp" )
 # get include files
 file( GLOB INC_FILES "../DecoderApp/*.h" )
 
-include_directories(../../../sadl)
-
 # get additional libs for gcc on Ubuntu systems
 if( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
   if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
diff --git a/source/App/DecoderApp/CMakeLists.txt b/source/App/DecoderApp/CMakeLists.txt
index 440691ed28..4e71c5c1e1 100644
--- a/source/App/DecoderApp/CMakeLists.txt
+++ b/source/App/DecoderApp/CMakeLists.txt
@@ -7,8 +7,6 @@ file( GLOB SRC_FILES "*.cpp" )
 # get include files
 file( GLOB INC_FILES "*.h" )
 
-include_directories(../../../sadl)
-
 # get additional libs for gcc on Ubuntu systems
 if( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
   if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp
index 64958e2cb8..905836ee27 100644
--- a/source/App/DecoderApp/DecApp.cpp
+++ b/source/App/DecoderApp/DecApp.cpp
@@ -575,14 +575,14 @@ void DecApp::xCreateDecLib()
 #endif
   );
   m_cDecLib.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
-
-#if CNN_FILTERING
-  m_cDecLib.setCnnlfInterLumaModelName                           (m_cnnlfInterLumaModelName);
-  m_cDecLib.setCnnlfInterChromaModelName                         (m_cnnlfInterChromaModelName);
-  m_cDecLib.setCnnlfIntraLumaModelName                           (m_cnnlfIntraLumaModelName);
-  m_cDecLib.setCnnlfIntraChromaModelName                         (m_cnnlfIntraChromaModelName);
-#endif
   
+#if NN_FILTERING_SET_1
+  m_cDecLib.setNnlfSet1InterLumaModelName                           (m_nnlfSet1InterLumaModelName);
+  m_cDecLib.setNnlfSet1InterChromaModelName                         (m_nnlfSet1InterChromaModelName);
+  m_cDecLib.setNnlfSet1IntraLumaModelName                           (m_nnlfSet1IntraLumaModelName);
+  m_cDecLib.setNnlfSet1IntraChromaModelName                         (m_nnlfSet1IntraChromaModelName);
+#endif
+
   if (!m_outputDecodedSEIMessagesFilename.empty())
   {
     std::ostream &os=m_seiMessageFileStream.is_open() ? m_seiMessageFileStream : std::cout;
diff --git a/source/App/DecoderApp/DecAppCfg.cpp b/source/App/DecoderApp/DecAppCfg.cpp
index 3f1fbf617c..d1c4c1192f 100644
--- a/source/App/DecoderApp/DecAppCfg.cpp
+++ b/source/App/DecoderApp/DecAppCfg.cpp
@@ -81,13 +81,13 @@ bool DecAppCfg::parseCfg( int argc, char* argv[] )
   ("DumpBasename",                  m_dumpBasename,                        string(""), "basename for data dumping\n")
 #endif
   
-#if CNN_FILTERING
-  ( "CnnlfInterLumaModel",                             m_cnnlfInterLumaModelName,                string("models/JVET_Z_EE_1.6_LumaCNNFilter_InterSlice_int16.sadl"), "Cnnlf inter luma model name")
-  ( "CnnlfInterChromaModel",                           m_cnnlfInterChromaModelName,              string("models/JVET_Z_EE_1.6_ChromaCNNFilter_InterSlice_int16.sadl"), "Cnnlf inter chroma model name")
-  ( "CnnlfIntraLumaModel",                             m_cnnlfIntraLumaModelName,                string("models/JVET_Z_EE_1.6_LumaCNNFilter_IntraSlice_int16.sadl"), "Cnnlf intra luma model name")
-  ( "CnnlfIntraChromaModel",                           m_cnnlfIntraChromaModelName,              string("models/JVET_Z_EE_1.6_ChromaCNNFilter_IntraSlice_int16.sadl"), "Cnnlf intra chroma model name")
+#if NN_FILTERING_SET_1
+  ( "NnlfSet1InterLumaModel",                             m_nnlfSet1InterLumaModelName,                string("models/NnlfSet1_LumaCNNFilter_InterSlice_int16.sadl"), "NnlfSet1 inter luma model name")
+  ( "NnlfSet1InterChromaModel",                           m_nnlfSet1InterChromaModelName,              string("models/NnlfSet1_ChromaCNNFilter_InterSlice_int16.sadl"), "NnlfSet1 inter chroma model name")
+  ( "NnlfSet1IntraLumaModel",                             m_nnlfSet1IntraLumaModelName,                string("models/NnlfSet1_LumaCNNFilter_IntraSlice_int16.sadl"), "NnlfSet1 intra luma model name")
+  ( "NnlfSet1IntraChromaModel",                           m_nnlfSet1IntraChromaModelName,              string("models/NnlfSet1_ChromaCNNFilter_IntraSlice_int16.sadl"), "NnlfSet1 intra chroma model name")
 #endif
-  
+    
   ("OplFile,-opl",              m_oplFilename ,                        string(""), "opl-file name without extension for conformance testing\n")
 
 #if ENABLE_SIMD_OPT
@@ -261,7 +261,6 @@ DecAppCfg::DecAppCfg()
 : m_bitstreamFileName()
 , m_reconFileName()
 , m_oplFilename()
-
 , m_iSkipFrame(0)
 // m_outputBitDepth array initialised below
 , m_outputColourSpaceConvert(IPCOLOURSPACE_UNCHANGED)
diff --git a/source/App/DecoderApp/DecAppCfg.h b/source/App/DecoderApp/DecAppCfg.h
index dd6e708fa1..0058ade751 100644
--- a/source/App/DecoderApp/DecAppCfg.h
+++ b/source/App/DecoderApp/DecAppCfg.h
@@ -61,14 +61,14 @@ protected:
 
 #if NNVC_DUMP_DATA
   std::string   m_dumpBasename;                         ///< output basename for data
-#endif
+#endif  
   std::string   m_oplFilename;                        ///< filename to output conformance log.
 
-#if CNN_FILTERING
-  std::string   m_cnnlfInterLumaModelName;              ///<inter luma cnnlf model
-  std::string   m_cnnlfInterChromaModelName;            ///<inter chroma cnnlf model
-  std::string   m_cnnlfIntraLumaModelName;              ///<intra luma cnnlf model
-  std::string   m_cnnlfIntraChromaModelName;            ///<inra chroma cnnlf model
+#if NN_FILTERING_SET_1
+  std::string   m_nnlfSet1InterLumaModelName;              ///<inter luma nnlf set1 model
+  std::string   m_nnlfSet1InterChromaModelName;            ///<inter chroma nnlf set1 model
+  std::string   m_nnlfSet1IntraLumaModelName;              ///<intra luma nnlf set1 model
+  std::string   m_nnlfSet1IntraChromaModelName;            ///<inra chroma nnlf set1 model
 #endif
 
   int           m_iSkipFrame;                           ///< counter for frames prior to the random access point to skip
diff --git a/source/App/DecoderApp/decmain.cpp b/source/App/DecoderApp/decmain.cpp
index f1590c75ae..c8a6e3bd70 100644
--- a/source/App/DecoderApp/decmain.cpp
+++ b/source/App/DecoderApp/decmain.cpp
@@ -40,9 +40,6 @@
 #include <time.h>
 #include "DecApp.h"
 #include "program_options_lite.h"
-#if CNN_FILTERING
-#include <chrono>
-#endif
 
 //! \ingroup DecoderApp
 //! \{
@@ -84,11 +81,7 @@ int main(int argc, char* argv[])
 
   // starting time
   double dResult;
-#if CNN_FILTERING
-  auto startTime  = std::chrono::steady_clock::now();
-#else
   clock_t lBefore = clock();
-#endif
 
   // call decoding function
 #ifndef _DEBUG
@@ -115,13 +108,7 @@ int main(int argc, char* argv[])
 #endif
 
   // ending time
-#if CNN_FILTERING
-  auto endTime = std::chrono::steady_clock::now();
-  dResult = std::chrono::duration_cast<std::chrono::milliseconds>( endTime - startTime).count();
-  dResult = dResult / 1000.0;
-#else
   dResult = (double)(clock()-lBefore) / CLOCKS_PER_SEC;
-#endif
   printf("\n Total Time: %12.3f sec.\n", dResult);
 
   delete pcDecApp;
diff --git a/source/App/EncoderApp/CMakeLists.txt b/source/App/EncoderApp/CMakeLists.txt
index befdbe2e23..dd87e52d1f 100644
--- a/source/App/EncoderApp/CMakeLists.txt
+++ b/source/App/EncoderApp/CMakeLists.txt
@@ -7,8 +7,6 @@ file( GLOB SRC_FILES "*.cpp" )
 # get include files
 file( GLOB INC_FILES "*.h" )
 
-include_directories(../../../sadl)
-
 # get additional libs for gcc on Ubuntu systems
 if( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
   if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp
index 2f833372e1..cd3d2d1b75 100644
--- a/source/App/EncoderApp/EncApp.cpp
+++ b/source/App/EncoderApp/EncApp.cpp
@@ -243,11 +243,11 @@ void EncApp::xInitLibCfg()
   }
   vps.setProfileTierLevel(ptls);
   vps.setVPSExtensionFlag                                        ( false );
-#if CNN_FILTERING
-  m_cEncLib.setCnnlfInterLumaModelName                           (m_cnnlfInterLumaModelName);
-  m_cEncLib.setCnnlfInterChromaModelName                         (m_cnnlfInterChromaModelName);
-  m_cEncLib.setCnnlfIntraLumaModelName                           (m_cnnlfIntraLumaModelName);
-  m_cEncLib.setCnnlfIntraChromaModelName                         (m_cnnlfIntraChromaModelName);
+#if NN_FILTERING_SET_1
+  m_cEncLib.setNnlfSet1InterLumaModelName                        (m_nnlfSet1InterLumaModelName);
+  m_cEncLib.setNnlfSet1InterChromaModelName                      (m_nnlfSet1InterChromaModelName);
+  m_cEncLib.setNnlfSet1IntraLumaModelName                        (m_nnlfSet1IntraLumaModelName);
+  m_cEncLib.setNnlfSet1IntraChromaModelName                      (m_nnlfSet1IntraChromaModelName);
 #endif
   m_cEncLib.setProfile                                           ( m_profile);
   m_cEncLib.setLevel                                             ( m_levelTier, m_level);
@@ -1061,11 +1061,11 @@ void EncApp::xInitLibCfg()
 #endif
   m_cEncLib.setUseCCALF                                          ( m_ccalf );
   m_cEncLib.setCCALFQpThreshold                                  ( m_ccalfQpThreshold );
-#if CNN_FILTERING
-  m_cEncLib.setUseCnnlf                                          (m_cnnlf);
-  m_cEncLib.setCnnlfInferSizeBase                                (m_cnnlfInferSizeBase);
-  m_cEncLib.setCnnlfInferSizeExtension                           (m_cnnlfInferSizeExtension);
-  m_cEncLib.setCnnlfMaxNumParams                                 (m_cnnlfMaxNumParams);
+#if NN_FILTERING_SET_1
+  m_cEncLib.setUseNnlfSet1                                       (m_nnlfSet1);
+  m_cEncLib.setNnlfSet1InferSizeBase                             (m_nnlfSet1InferSizeBase);
+  m_cEncLib.setNnlfSet1InferSizeExtension                        (m_nnlfSet1InferSizeExtension);
+  m_cEncLib.setNnlfSet1MaxNumParams                              (m_nnlfSet1MaxNumParams);
 #endif
   m_cEncLib.setLmcs                                              ( m_lmcsEnabled );
   m_cEncLib.setReshapeSignalType                                 ( m_reshapeSignalType );
diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index 0c4d5a88f2..de2ce561ee 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -1414,15 +1414,15 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 #endif
   ( "CCALF",                                           m_ccalf,                                  true, "Cross-component Adaptive Loop Filter" )
   ( "CCALFQpTh",                                       m_ccalfQpThreshold,                         37, "QP threshold above which encoder reduces CCALF usage")
-#if CNN_FILTERING
-  ( "Cnnlf",                                           m_cnnlf,                                  true, "CNN-based loop filter" )
-  ( "CnnlfInferSizeBase",                              m_cnnlfInferSizeBase,                     128u, "Base inference size of CNN-based loop filter" )
-  ( "CnnlfInferSizeExtension",                         m_cnnlfInferSizeExtension,                8u,   "Extension of inference size of CNN-based loop filter" )
-  ( "CnnlfMaxNumParams",                               m_cnnlfMaxNumParams,                      3u,   "Number of conditional parameters of CNN-based loop filter" )
-  ( "CnnlfInterLumaModel",                             m_cnnlfInterLumaModelName,                string("models/JVET_Z_EE_1.6_LumaCNNFilter_InterSlice_int16.sadl"), "Cnnlf inter luma model name")
-  ( "CnnlfInterChromaModel",                           m_cnnlfInterChromaModelName,              string("models/JVET_Z_EE_1.6_ChromaCNNFilter_InterSlice_int16.sadl"), "Cnnlf inter chroma model name")
-  ( "CnnlfIntraLumaModel",                             m_cnnlfIntraLumaModelName,                string("models/JVET_Z_EE_1.6_LumaCNNFilter_IntraSlice_int16.sadl"), "Cnnlf intra luma model name")
-  ( "CnnlfIntraChromaModel",                           m_cnnlfIntraChromaModelName,              string("models/JVET_Z_EE_1.6_ChromaCNNFilter_IntraSlice_int16.sadl"), "Cnnlf intra chroma model name")
+#if NN_FILTERING_SET_1
+  ( "NnlfSet1",                                       m_nnlfSet1,                                true, "NN-based loop filter set 1" )
+  ( "NnlfSet1InferSizeBase",                          m_nnlfSet1InferSizeBase,                   128u, "Base inference size of NN-based loop filter set 1" )
+  ( "NnlfSet1InferSizeExtension",                     m_nnlfSet1InferSizeExtension,                8u,   "Extension of inference size of NN-based loop filter set 1" )
+  ( "NnlfSet1MaxNumParams",                           m_nnlfSet1MaxNumParams,                      3u,   "Number of conditional parameters of NN-based loop filter set 1" )
+  ( "NnlfSet1InterLumaModel",                         m_nnlfSet1InterLumaModelName,              string("models/NnlfSet1_LumaCNNFilter_InterSlice_int16.sadl"), "NnlfSet1 inter luma model name")
+  ( "NnlfSet1InterChromaModel",                       m_nnlfSet1InterChromaModelName,            string("models/NnlfSet1_ChromaCNNFilter_InterSlice_int16.sadl"), "NnlfSet1 inter chroma model name")
+  ( "NnlfSet1IntraLumaModel",                         m_nnlfSet1IntraLumaModelName,              string("models/NnlfSet1_LumaCNNFilter_IntraSlice_int16.sadl"), "NnlfSet1 intra luma model name")
+  ( "NnlfSet1IntraChromaModel",                       m_nnlfSet1IntraChromaModelName,            string("models/NnlfSet1_ChromaCNNFilter_IntraSlice_int16.sadl"), "NnlfSet1 intra chroma model name")
 #endif
   ( "RPR",                                            m_rprEnabledFlag,                          true, "Reference Sample Resolution" )
   ( "ScalingRatioHor",                                m_scalingRatioHor,                          1.0, "Scaling ratio in hor direction" )
@@ -3986,6 +3986,7 @@ void EncAppCfg::xPrintParameter()
   msg( VERBOSE, "Tiles: %dx%d ", m_numTileCols, m_numTileRows );
   msg( VERBOSE, "Slices: %d ", m_numSlicesInPic);
   msg( VERBOSE, "MCTS:%d ", m_MCTSEncConstraint );
+  msg( VERBOSE, "NNLFSET1:%d ", (m_nnlfSet1)?(1):(0));
   msg( VERBOSE, "SAO:%d ", (m_bUseSAO)?(1):(0));
   msg( VERBOSE, "ALF:%d ", m_alf ? 1 : 0 );
   msg( VERBOSE, "CCALF:%d ", m_ccalf ? 1 : 0 );
diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h
index 3b2417ca3c..831d04c479 100644
--- a/source/App/EncoderApp/EncAppCfg.h
+++ b/source/App/EncoderApp/EncAppCfg.h
@@ -86,13 +86,13 @@ protected:
   std::string m_bitstreamFileName;                            ///< output bitstream file
   std::string m_reconFileName;                                ///< output reconstruction file
 
-#if CNN_FILTERING
-  std::string m_cnnlfInterLumaModelName;                      ///<inter luma cnnlf model
-  std::string m_cnnlfInterChromaModelName;                    ///<inter chroma cnnlf model
-  std::string m_cnnlfIntraLumaModelName;                      ///<intra luma cnnlf model
-  std::string m_cnnlfIntraChromaModelName;                    ///<inra chroma cnnlf model
+#if NN_FILTERING_SET_1
+  std::string m_nnlfSet1InterLumaModelName;                   ///<inter luma nnlf set1 model
+  std::string m_nnlfSet1InterChromaModelName;                 ///<inter chroma nnlf set1 model
+  std::string m_nnlfSet1IntraLumaModelName;                   ///<intra luma nnlf set1 model
+  std::string m_nnlfSet1IntraChromaModelName;                 ///<inra chroma nnlf set1 model
 #endif
-
+  
   // Lambda modifiers
   double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
   std::vector<double> m_adIntraLambdaModifier;                ///< Lambda modifier for Intra pictures, one for each temporal layer. If size>temporalLayer, then use [temporalLayer], else if size>0, use [size()-1], else use m_adLambdaModifier.
@@ -709,11 +709,11 @@ protected:
   bool        m_ccalf;
   int         m_ccalfQpThreshold;
   
-#if CNN_FILTERING
-  bool        m_cnnlf;
-  unsigned    m_cnnlfInferSizeBase;
-  unsigned    m_cnnlfInferSizeExtension;
-  unsigned    m_cnnlfMaxNumParams;
+#if NN_FILTERING_SET_1
+  bool        m_nnlfSet1;
+  unsigned    m_nnlfSet1InferSizeBase;
+  unsigned    m_nnlfSet1InferSizeExtension;
+  unsigned    m_nnlfSet1MaxNumParams;
 #endif
 
   bool        m_rprEnabledFlag;
diff --git a/source/Lib/CommonAnalyserLib/CMakeLists.txt b/source/Lib/CommonAnalyserLib/CMakeLists.txt
index 12e809461a..5a9612c09c 100644
--- a/source/Lib/CommonAnalyserLib/CMakeLists.txt
+++ b/source/Lib/CommonAnalyserLib/CMakeLists.txt
@@ -109,12 +109,13 @@ elseif( UNIX OR MINGW )
 endif()
 
 if( MSVC )  
-  set_property( SOURCE CNNFilter.cpp APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2 -DNDEBUG=1 ")
+  set_property( SOURCE NNFilterSet1.cpp APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2 -DNDEBUG=1 ")
 elseif( UNIX OR MINGW )
-  set_property( SOURCE CNNFilter.cpp APPEND PROPERTY COMPILE_FLAGS " -DNDEBUG=1 -mavx512f -mavx512bw")
+  set_property( SOURCE NNFilterSet1.cpp APPEND PROPERTY COMPILE_FLAGS " -DNDEBUG=1 -mavx512f -mavx512bw")
 endif()
 
 
+
 # example: place header files in different folders
 source_group( "Natvis Files" FILES ${NATVIS_FILES} )
 
diff --git a/source/Lib/CommonLib/CMakeLists.txt b/source/Lib/CommonLib/CMakeLists.txt
index 1ec6b73465..a7f610055e 100644
--- a/source/Lib/CommonLib/CMakeLists.txt
+++ b/source/Lib/CommonLib/CMakeLists.txt
@@ -107,11 +107,12 @@ elseif( UNIX OR MINGW )
 endif()
 
 if( MSVC )  
-  set_property( SOURCE CNNFilter.cpp APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2 -DNDEBUG=1 ")
+  set_property( SOURCE NNFilterSet1.cpp APPEND PROPERTY COMPILE_FLAGS "/arch:AVX2 -DNDEBUG=1 ")
 elseif( UNIX OR MINGW )
-  set_property( SOURCE CNNFilter.cpp APPEND PROPERTY COMPILE_FLAGS "-DNDEBUG=1 -mavx512f -mavx512bw")
+  set_property( SOURCE NNFilterSet1.cpp APPEND PROPERTY COMPILE_FLAGS "-DNDEBUG=1 -mavx512f -mavx512bw")
 endif()
 
+
 # example: place header files in different folders
 source_group( "Natvis Files" FILES ${NATVIS_FILES} )
 
diff --git a/source/Lib/CommonLib/CNNFilter.h b/source/Lib/CommonLib/CNNFilter.h
deleted file mode 100644
index b17fd8d6e8..0000000000
--- a/source/Lib/CommonLib/CNNFilter.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/** \file     CNNFilter.h
-    \brief    convolutional neural network-based fiter class (header)
-*/
-
-#ifndef __CNNFILTER__
-#define __CNNFILTER__
-
-#include "CommonDef.h"
-#include "Unit.h"
-#include "Picture.h"
-#include "Reshape.h"
-//! \ingroup CommonLib
-//! \{
-
-
-class CNNFilter
-{
-public:
-  CNNFilter();
-  
-  std::vector<PelStorage> m_tempBuf;
-  std::string m_interLuma, m_interChroma, m_intraLuma, m_intraChroma;
-#if SCALE_NN_RESIDUE
-  std::vector<PelStorage> m_tempScaledBuf;
-#endif
-  template<typename T> void cnnFilterLumaBlock( Picture* pic, UnitArea inferArea, int extLeft, int extRight, int extTop, int extBottom, int paramIdx, bool inter);
-  template<typename T> void cnnFilterChromaBlock( Picture* pic, UnitArea inferArea, int extLeft, int extRight, int extTop, int extBottom, int paramIdx, bool inter);
-  void cnnFilter( Picture* pic);
-#if SCALE_NN_RESIDUE
-  void scaleResidualBlock(Picture *pic, UnitArea inferArea, int paramIdx, ComponentID compID);
-#endif
-  void create(const int picWidth, const int picHeight, const ChromaFormat format, const int cnnlfNumParams);
-  void init(std::string interLuma, std::string interChroma, std::string intraLuma, std::string intraChroma);
-  void destroy();
-};
-
-//! \}
-#endif
-
diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp
index e96338f914..124f94fc6c 100644
--- a/source/Lib/CommonLib/Contexts.cpp
+++ b/source/Lib/CommonLib/Contexts.cpp
@@ -783,8 +783,9 @@ const CtxSet ContextSetCfg::ctbAlfFlag = ContextSetCfg::addCtxSet
   {  62,  39,  39,  54,  39,  39,  31,  39,  39, },
   {   0,   0,   0,   4,   0,   0,   1,   0,   0, },
 });
-#if CNN_FILTERING
-const CtxSet ContextSetCfg::cnnlfParamIdx = ContextSetCfg::addCtxSet
+
+#if NN_FILTERING_SET_1
+const CtxSet ContextSetCfg::nnlfSet1ParamIdx = ContextSetCfg::addCtxSet
 ({
   {  33,  52,  25,  61, },
   {  13,  23,  4,  61, },
@@ -792,6 +793,7 @@ const CtxSet ContextSetCfg::cnnlfParamIdx = ContextSetCfg::addCtxSet
   {   0,   0,   4,   0, },
 });
 #endif
+
 const CtxSet ContextSetCfg::ctbAlfAlternative = ContextSetCfg::addCtxSet
 ({
   {  11,  26, },
diff --git a/source/Lib/CommonLib/Contexts.h b/source/Lib/CommonLib/Contexts.h
index f6a4c5aaa2..23276f0285 100644
--- a/source/Lib/CommonLib/Contexts.h
+++ b/source/Lib/CommonLib/Contexts.h
@@ -261,8 +261,8 @@ public:
   static const CtxSet   ctbAlfAlternative;
   static const CtxSet   AlfUseTemporalFilt;
   static const CtxSet   CcAlfFilterControlFlag;
-#if CNN_FILTERING
-  static const CtxSet   cnnlfParamIdx;
+#if NN_FILTERING_SET_1
+  static const CtxSet   nnlfSet1ParamIdx;
 #endif
   static const CtxSet   CiipFlag;
   static const CtxSet   SmvdFlag;
diff --git a/source/Lib/CommonLib/CNNFilter.cpp b/source/Lib/CommonLib/NNFilterSet1.cpp
similarity index 62%
rename from source/Lib/CommonLib/CNNFilter.cpp
rename to source/Lib/CommonLib/NNFilterSet1.cpp
index 4c9f096fee..c100d75887 100644
--- a/source/Lib/CommonLib/CNNFilter.cpp
+++ b/source/Lib/CommonLib/NNFilterSet1.cpp
@@ -1,9 +1,42 @@
-/** \file     CNNFilter.cpp
-    \brief    convolutional neural network-based filter class
+/* The copyright in this software is being made available under the BSD
+* License, included below. This software may be subject to other third party
+* and contributor rights, including patent rights, and no such rights are
+* granted under this license.
+*
+* Copyright (c) 2010-2020, ITU/ISO/IEC
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+*  * Redistributions of source code must retain the above copyright notice,
+*    this list of conditions and the following disclaimer.
+*  * Redistributions in binary form must reproduce the above copyright notice,
+*    this list of conditions and the following disclaimer in the documentation
+*    and/or other materials provided with the distribution.
+*  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
+*    be used to endorse or promote products derived from this software without
+*    specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
 */
-#include "CNNFilter.h"
+
+/** \file     NNFilterSet1.cpp
+    \brief    neural network-based filter set1 class
+*/
+#include "NNFilterSet1.h"
 #include "NNInference.h"
-#if CNN_FILTERING
+#if NN_FILTERING_SET_1
 #include "UnitTools.h"
 #include "UnitPartitioner.h"
 #include "CodingStructure.h"
@@ -26,35 +59,35 @@ using namespace std;
 //! \ingroup CommonLib
 //! \{
 
-CNNFilter::CNNFilter()
+NNFilterSet1::NNFilterSet1()
 {
 }
-void CNNFilter::create( const int picWidth, const int picHeight, const ChromaFormat format, const int cnnlfNumParams)
+void NNFilterSet1::create( const int picWidth, const int picHeight, const ChromaFormat format, const int nnlfSet1NumParams)
 {
   if (m_tempBuf.size() > 0)
     return;
-  m_tempBuf.resize(cnnlfNumParams);
-  for (int i = 0; i < cnnlfNumParams; i ++)
+  m_tempBuf.resize(nnlfSet1NumParams);
+  for (int i = 0; i < nnlfSet1NumParams; i ++)
   {
     m_tempBuf[i].create(format, Area(0, 0, picWidth, picHeight));
   }
 
 #if SCALE_NN_RESIDUE
-  m_tempScaledBuf.resize(cnnlfNumParams);
-  for (int i = 0; i < cnnlfNumParams; i ++)
+  m_tempScaledBuf.resize(nnlfSet1NumParams);
+  for (int i = 0; i < nnlfSet1NumParams; i ++)
   {
     m_tempScaledBuf[i].create(format, Area(0, 0, picWidth, picHeight));
   }
 #endif
 }
-void CNNFilter::init(std::string interLuma, std::string interChroma, std::string intraLuma, std::string intraChroma)
+void NNFilterSet1::init(std::string interLuma, std::string interChroma, std::string intraLuma, std::string intraChroma)
 {
   m_interLuma = interLuma;
   m_interChroma = interChroma;
   m_intraLuma = intraLuma;
   m_intraChroma = intraChroma;
 }
-void CNNFilter::destroy()
+void NNFilterSet1::destroy()
 {
   for (int i = 0; i < m_tempBuf.size(); i++)
   {
@@ -91,7 +124,8 @@ static std::vector<ModelData<float>> models=initSpace<float>();
 #endif
 
 template<typename T>
-static ModelData<T> &getModel(int ver, int hor, bool luma, bool inter, const string modelName) {
+static ModelData<T> &getModel(int ver, int hor, bool luma, bool inter, const string modelName)
+{
   ModelData<T> *ptr = nullptr;
   for(auto &m: models)
   {
@@ -111,22 +145,6 @@ static ModelData<T> &getModel(int ver, int hor, bool luma, bool inter, const str
     models.resize(models.size()+1);
     ptr = &models.back();
     ModelData<T> &m = *ptr;
-    if  (luma && inter)
-    {
-      cout << "[INFO] luma inter model loading" << endl;
-    }
-    else if (luma && !inter)
-    {
-      cout << "[INFO] luma intra model loading" << endl;
-    }
-    else if (!luma && inter)
-    {
-      cout << "[INFO] chroma inter model loading" << endl;
-    }
-    else if (!luma && !inter)
-    {
-      cout << "[INFO] chroma intra model loading" << endl;
-    }
     ifstream file(modelName, ios::binary);
     m.model.load(file);
     m.luma = luma;
@@ -192,10 +210,6 @@ static ModelData<T> &getModel(int ver, int hor, bool luma, bool inter, const str
         inputId ++;
       }
     }
-    if  (luma&&inter)        cout << "[INFO] luma inter model initilization" << endl;
-    else if (luma&&!inter)   cout << "[INFO] luma intra model initilization" << endl;
-    else if (!luma&&inter)   cout << "[INFO] chroma inter model initilization" << endl;
-    else if (!luma&&!inter)  cout << "[INFO] chroma intra model initilization" << endl;
     if (!m.model.init(m.inputs))
     {
       cerr << "[ERROR] issue during initialization" << endl;
@@ -207,133 +221,6 @@ static ModelData<T> &getModel(int ver, int hor, bool luma, bool inter, const str
   return m;
 }
 
-template<typename T>
-void prepareInputsLuma (Picture* pic, UnitArea inferArea, vector<sadl::Tensor<T>> &inputs, int qp, bool inter)
-{
-  double inputScale = 1024;
-#if NN_FIXED_POINT_IMPLEMENTATION
-  int shiftInput = NN_INPUT_PRECISION;
-#else
-  int shiftInput = 0;
-#endif
-  PelBuf bufRec = pic->getRecBeforeDbfBuf(inferArea).get(COMPONENT_Y);
-  PelBuf bufPred = pic->getPredBufCustom(inferArea).get(COMPONENT_Y);
-  PelBuf bufPartition = pic->getCuAverageBuf(inferArea).get(COMPONENT_Y);
-  PelBuf bufBsMap = pic->getBsMapBuf(inferArea).get(COMPONENT_Y);
-  
-  sadl::Tensor<T>* inputRec, *inputPred, *inputPartition, *inputBs, *inputQp;
-  if (inter)
-  {
-    inputRec = &inputs[0];
-    inputPred = &inputs[1];
-    inputBs = &inputs[2];
-    inputQp = &inputs[3];
-  }
-  else
-  {
-    inputRec = &inputs[0];
-    inputPred = &inputs[1];
-    inputPartition = &inputs[2];
-    inputBs = &inputs[3];
-    inputQp = &inputs[4];
-  }
-  
-  int hor = inferArea.lwidth();
-  int ver = inferArea.lheight();
-  
-  for (int yy = 0; yy < ver; yy++)
-  {
-    for (int xx = 0; xx < hor; xx++)
-    {
-      (*inputRec)(0, yy, xx, 0) = bufRec.at(xx, yy) / inputScale * (1 << shiftInput);
-      (*inputPred)(0, yy, xx, 0) = bufPred.at(xx, yy) / inputScale * (1 << shiftInput);
-      (*inputBs)(0, yy, xx, 0) = bufBsMap.at(xx, yy) / inputScale * (1 << shiftInput);
-      (*inputQp)(0, yy, xx, 0) = qp / 64.0 * (1 << shiftInput);
-      if (!inter)
-      {
-        (*inputPartition)(0, yy, xx, 0) = bufPartition.at(xx, yy) / inputScale * (1 << shiftInput);
-      }
-    }
-  }
-}
-
-template<typename T>
-void prepareInputsChroma (Picture* pic, UnitArea inferArea, vector<sadl::Tensor<T>> &inputs, int qp, bool inter)
-{
-  double inputScale = 1024;
-#if NN_FIXED_POINT_IMPLEMENTATION
-  int shiftInput = NN_INPUT_PRECISION;
-#else
-  int shiftInput = 0;
-#endif
-  PelBuf bufRecY = pic->getRecBeforeDbfBuf(inferArea).get(COMPONENT_Y);
-  PelBuf bufRecCb = pic->getRecBeforeDbfBuf(inferArea).get(COMPONENT_Cb);
-  PelBuf bufRecCr = pic->getRecBeforeDbfBuf(inferArea).get(COMPONENT_Cr);
-  
-  PelBuf bufPredCb = pic->getPredBufCustom(inferArea).get(COMPONENT_Cb);
-  PelBuf bufPredCr = pic->getPredBufCustom(inferArea).get(COMPONENT_Cr);
-  
-  PelBuf bufPartitionCb = pic->getCuAverageBuf(inferArea).get(COMPONENT_Cb);
-  PelBuf bufPartitionCr = pic->getCuAverageBuf(inferArea).get(COMPONENT_Cr);
-  
-  PelBuf bufBsMapCb = pic->getBsMapBuf(inferArea).get(COMPONENT_Cb);
-  PelBuf bufBsMapCr = pic->getBsMapBuf(inferArea).get(COMPONENT_Cr);
-  
-  sadl::Tensor<T>* inputRecCrossComponent, *inputRec, *inputPred, *inputPartition, *inputBs, *inputQp;
-  
-  if (inter)
-  {
-    inputRecCrossComponent = &inputs[0];
-    inputRec = &inputs[1];
-    inputPred = &inputs[2];
-    inputBs = &inputs[3];
-    inputQp = &inputs[4];
-  }
-  else
-  {
-    inputRecCrossComponent = &inputs[0];
-    inputRec = &inputs[1];
-    inputPred = &inputs[2];
-    inputPartition = &inputs[3];
-    inputBs = &inputs[4];
-    inputQp = &inputs[5];
-  }
-  
-  int hor = inferArea.lwidth();
-  int ver = inferArea.lheight();
-  
-  int horC = inferArea.lwidth() >> 1;
-  int verC = inferArea.lheight() >> 1;
-  
-  for (int yy = 0; yy < ver; yy++)
-  {
-    for (int xx = 0; xx < hor; xx++)
-    {
-      (*inputRecCrossComponent)(0, yy, xx, 0) = bufRecY.at(xx, yy) / inputScale * (1 << shiftInput);
-    }
-  }
-  
-  for (int yy = 0; yy < verC; yy++)
-  {
-    for (int xx = 0; xx < horC; xx++)
-    {
-
-      (*inputRec)(0, yy, xx, 0) = bufRecCb.at(xx, yy) / inputScale * (1 << shiftInput);
-      (*inputRec)(0, yy, xx, 1) = bufRecCr.at(xx, yy) / inputScale * (1 << shiftInput);
-      (*inputPred)(0, yy, xx, 0) = bufPredCb.at(xx, yy) / inputScale * (1 << shiftInput);
-      (*inputPred)(0, yy, xx, 1) = bufPredCr.at(xx, yy) / inputScale * (1 << shiftInput);
-      (*inputBs)(0, yy, xx, 0) = bufBsMapCb.at(xx, yy) / inputScale * (1 << shiftInput);
-      (*inputBs)(0, yy, xx, 1) = bufBsMapCr.at(xx, yy) / inputScale * (1 << shiftInput);
-      (*inputQp)(0, yy, xx, 0) = qp / 64.0 * (1 << shiftInput);
-      if (!inter)
-      {
-        (*inputPartition)(0, yy, xx, 0) = bufPartitionCb.at(xx, yy) / inputScale * (1 << shiftInput);
-        (*inputPartition)(0, yy, xx, 1) = bufPartitionCr.at(xx, yy) / inputScale * (1 << shiftInput);
-      }
-    }
-  }
-}
-
 template<typename T>
 void extractOutputsLuma (Picture* pic, sadl::Model<T> &m, PelStorage& tempBuf, PelStorage& tempScaledBuf, UnitArea inferArea, int extLeft, int extRight, int extTop, int extBottom, bool inter)
 {
@@ -357,7 +244,11 @@ void extractOutputsLuma (Picture* pic, sadl::Model<T> &m, PelStorage& tempBuf, P
   int hor = inferArea.lwidth();
   int ver = inferArea.lheight();
   
+#if FUSE_NN_AND_LF
   PelBuf bufRec = pic->getRecBeforeDbfBuf(inferArea).get(COMPONENT_Y);
+#else
+  PelBuf bufRec = pic->getRecoBuf(inferArea).get(COMPONENT_Y);
+#endif
   
   for (int c = 0; c < 4; c++) // output includes 4 sub images
   {
@@ -447,7 +338,7 @@ int log2InputScale = 10;
 }
 
 template<typename T>
-void CNNFilter::cnnFilterLumaBlock(Picture* pic, UnitArea inferArea, int extLeft, int extRight, int extTop, int extBottom, int paramIdx, bool inter)
+void NNFilterSet1::cnnFilterLumaBlock(Picture* pic, UnitArea inferArea, int extLeft, int extRight, int extTop, int extBottom, int paramIdx, bool inter)
 {
   //at::init_num_threads(); // use all available threads
   
@@ -470,7 +361,6 @@ void CNNFilter::cnnFilterLumaBlock(Picture* pic, UnitArea inferArea, int extLeft
   }
   int qp = inter ? seqQp - delta : sliceQp - delta;
   
-#if NN_COMMON_API
   std::vector<InputData> listInputData;
   if (inter)
   {
@@ -496,24 +386,8 @@ void CNNFilter::cnnFilterLumaBlock(Picture* pic, UnitArea inferArea, int extLeft
     listInputData.push_back(inputBs);
     listInputData.push_back(inputQp);
   }
-  NNInference::prepareInputs<T>(pic, inferArea, inputs, -1, qp, inter, listInputData);
+  NNInference::prepareInputs<T>(pic, inferArea, inputs, -1, qp, -1, listInputData);
   NNInference::infer<T>(model, inputs);
-#else
-  prepareInputsLuma<T>(pic, inferArea, inputs, qp, inter);
-  
-  // inference
-  chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
-  if (!model.apply(inputs))
-  {
-    cerr << "[ERROR] issue during luma model inference" << endl;
-    exit(-1);
-  }
-  chrono::steady_clock::time_point t2 = chrono::steady_clock::now();
-  chrono::duration<double> dt = chrono::duration_cast<chrono::duration<double>>(t2 - t1);
-  cout << "[INFO] luma model takes "<< dt.count() * 1000. << " ms" <<endl;
-
-  if (border_to_skip) cout<<"[INFO] discard border size="<<model.result().border_skip<<endl;
-#endif
   
   // get outputs
   extractOutputsLuma(pic, model, m_tempBuf[paramIdx], m_tempScaledBuf[paramIdx], inferArea, extLeft, extRight, extTop, extBottom, inter);
@@ -521,7 +395,7 @@ void CNNFilter::cnnFilterLumaBlock(Picture* pic, UnitArea inferArea, int extLeft
 }
 
 template<typename T>
-void CNNFilter::cnnFilterChromaBlock(Picture* pic, UnitArea inferArea, int extLeft, int extRight, int extTop, int extBottom, int paramIdx, bool inter)
+void NNFilterSet1::cnnFilterChromaBlock(Picture* pic, UnitArea inferArea, int extLeft, int extRight, int extTop, int extBottom, int paramIdx, bool inter)
 {
 
   //at::init_num_threads();
@@ -545,7 +419,6 @@ void CNNFilter::cnnFilterChromaBlock(Picture* pic, UnitArea inferArea, int extLe
   }
   int qp = inter ? seqQp - delta : sliceQp - delta;
   
-#if NN_COMMON_API
   std::vector<InputData> listInputData;
   
   if (inter)
@@ -576,46 +449,30 @@ void CNNFilter::cnnFilterChromaBlock(Picture* pic, UnitArea inferArea, int extLe
     listInputData.push_back(inputBs);
     listInputData.push_back(inputQp);
   }
-  NNInference::prepareInputs<T>(pic, inferArea, inputs, -1, qp, inter, listInputData);
+  NNInference::prepareInputs<T>(pic, inferArea, inputs, -1, qp, -1, listInputData);
   NNInference::infer<T>(model, inputs);
-#else
-  prepareInputsChroma<T>(pic, inferArea, inputs, qp, inter);
-  
-  // inference
-  chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
-  if (!model.apply(inputs))
-  {
-    cerr << "[ERROR] issue during chroma model inference" << endl;
-    exit(-1);
-  }
-  chrono::steady_clock::time_point t2 = chrono::steady_clock::now();
-  chrono::duration<double> dt = chrono::duration_cast<chrono::duration<double>>(t2 - t1);
-  cout << "[INFO] chroma model takes " << dt.count() * 1000. << " ms"<<endl;
-
-  if (border_to_skip) cout << "[INFO] discard border size=" << model.result().border_skip << endl;
-#endif
   
   // get outputs
   extractOutputsChroma(pic, model, m_tempBuf[paramIdx], m_tempScaledBuf[paramIdx], inferArea, extLeft, extRight, extTop, extBottom, inter);
 
 }
 
-void CNNFilter::cnnFilter(Picture* pic)
+void NNFilterSet1::cnnFilter(Picture* pic)
 {
   CodingStructure&  cs            = *pic->cs;
   Slice* pcSlice                  = cs.slice;
   const PreCalcValues& pcv        = *cs.pcv;
-  int extension = cs.sps->getCnnlfInferSizeExtension();
+  int extension = cs.sps->getNnlfSet1InferSizeExtension();
   for (int chal = 0; chal < MAX_NUM_CHANNEL_TYPE; chal ++)
   {
     const ChannelType chType = ChannelType( chal );
-    CnnlfInferGranularity cnnlfInferGranularity = pcSlice->getCnnlfInferGranularity(chType);
-    std::vector<uint8_t>* cnnlfParamIdx = pic->getCnnlfParamIdx(cnnlfInferGranularity);
-    int blockSize = cs.sps->getCnnlfInferSize (cnnlfInferGranularity);
-    for( int blockIdx = 0; blockIdx < pcv.sizeInCnnlfInferSize[cnnlfInferGranularity]; blockIdx++ )
+    NnlfSet1InferGranularity nnlfSet1InferGranularity = pcSlice->getNnlfSet1InferGranularity(chType);
+    std::vector<uint8_t>* nnlfSet1ParamIdx = pic->getNnlfSet1ParamIdx(nnlfSet1InferGranularity);
+    int blockSize = cs.sps->getNnlfSet1InferSize (nnlfSet1InferGranularity);
+    for( int blockIdx = 0; blockIdx < pcv.sizeInNnlfSet1InferSize[nnlfSet1InferGranularity]; blockIdx++ )
     {
-      int xPosInBlocks        = blockIdx % pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
-      int yPosInBlocks        = blockIdx / pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
+      int xPosInBlocks        = blockIdx % pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
+      int yPosInBlocks        = blockIdx / pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
       int xPos = xPosInBlocks * blockSize;
       int yPos = yPosInBlocks * blockSize;
       int width = (xPos + blockSize > pcv.lumaWidth) ? (pcv.lumaWidth - xPos) : blockSize;
@@ -633,34 +490,34 @@ void CNNFilter::cnnFilter(Picture* pic)
       int extWidth = width + extLeft + extRight;
       int extHeight =  height + extTop + extBottom;
       const UnitArea extBlock( cs.area.chromaFormat, Area( extXPos, extYPos, extWidth, extHeight ) );
-      if (cnnlfParamIdx[chal][blockIdx] && chal == 0)
+      if (nnlfSet1ParamIdx[chal][blockIdx] && chal == 0)
       {
 #if NN_FIXED_POINT_IMPLEMENTATION
-        cnnFilterLumaBlock<int16_t>(pic, extBlock, extLeft, extRight, extTop, extBottom, cnnlfParamIdx[chal][blockIdx]-1, pcSlice->getSliceType() != I_SLICE);
+        cnnFilterLumaBlock<int16_t>(pic, extBlock, extLeft, extRight, extTop, extBottom, nnlfSet1ParamIdx[chal][blockIdx]-1, pcSlice->getSliceType() != I_SLICE);
 #else
-        cnnFilterLumaBlock<float>(pic, extBlock, extLeft, extRight, extTop, extBottom, cnnlfParamIdx[chal][blockIdx]-1, pcSlice->getSliceType() != I_SLICE);
+        cnnFilterLumaBlock<float>(pic, extBlock, extLeft, extRight, extTop, extBottom, nnlfSet1ParamIdx[chal][blockIdx]-1, pcSlice->getSliceType() != I_SLICE);
 #endif
       }
-      if (cnnlfParamIdx[chal][blockIdx] && chal > 0)
+      if (nnlfSet1ParamIdx[chal][blockIdx] && chal > 0)
       {
 #if NN_FIXED_POINT_IMPLEMENTATION
-        cnnFilterChromaBlock<int16_t>(pic, extBlock, extLeft >> 1, extRight >> 1, extTop >> 1, extBottom >> 1, cnnlfParamIdx[chal][blockIdx]-1, pcSlice->getSliceType() != I_SLICE);
+        cnnFilterChromaBlock<int16_t>(pic, extBlock, extLeft >> 1, extRight >> 1, extTop >> 1, extBottom >> 1, nnlfSet1ParamIdx[chal][blockIdx]-1, pcSlice->getSliceType() != I_SLICE);
 #else
-        cnnFilterChromaBlock<float>(pic, extBlock, extLeft >> 1, extRight >> 1, extTop >> 1, extBottom >> 1, cnnlfParamIdx[chal][blockIdx]-1, pcSlice->getSliceType() != I_SLICE);
+        cnnFilterChromaBlock<float>(pic, extBlock, extLeft >> 1, extRight >> 1, extTop >> 1, extBottom >> 1, nnlfSet1ParamIdx[chal][blockIdx]-1, pcSlice->getSliceType() != I_SLICE);
 #endif
       }
 
 #if SCALE_NN_RESIDUE
-      if (cnnlfParamIdx[chal][blockIdx] && pcSlice->getNnScaleFlag(cnnlfParamIdx[chal][blockIdx] - 1, chType))
+      if (nnlfSet1ParamIdx[chal][blockIdx] && pcSlice->getNnScaleFlag(nnlfSet1ParamIdx[chal][blockIdx] - 1, chType))
       {
         if (chType == CHANNEL_TYPE_LUMA)
         {
-          scaleResidualBlock(pic, block, cnnlfParamIdx[chal][blockIdx] - 1, COMPONENT_Y);
+          scaleResidualBlock(pic, block, nnlfSet1ParamIdx[chal][blockIdx] - 1, COMPONENT_Y);
         }
         else
         {
-          scaleResidualBlock(pic, block, cnnlfParamIdx[chal][blockIdx] - 1, COMPONENT_Cb);
-          scaleResidualBlock(pic, block, cnnlfParamIdx[chal][blockIdx] - 1, COMPONENT_Cr);
+          scaleResidualBlock(pic, block, nnlfSet1ParamIdx[chal][blockIdx] - 1, COMPONENT_Cb);
+          scaleResidualBlock(pic, block, nnlfSet1ParamIdx[chal][blockIdx] - 1, COMPONENT_Cr);
         }
       }
 #endif
@@ -670,35 +527,35 @@ void CNNFilter::cnnFilter(Picture* pic)
   {
     const ComponentID compID = ComponentID( comp );
     int chal = toChannelType(compID);
-    CnnlfInferGranularity cnnlfInferGranularity = pcSlice->getCnnlfInferGranularity(toChannelType(compID));
-    std::vector<uint8_t>* cnnlfParamIdx = pic->getCnnlfParamIdx(cnnlfInferGranularity);
-    int blockSize = cs.sps->getCnnlfInferSize (cnnlfInferGranularity);
+    NnlfSet1InferGranularity nnlfSet1InferGranularity = pcSlice->getNnlfSet1InferGranularity(toChannelType(compID));
+    std::vector<uint8_t>* nnlfSet1ParamIdx = pic->getNnlfSet1ParamIdx(nnlfSet1InferGranularity);
+    int blockSize = cs.sps->getNnlfSet1InferSize (nnlfSet1InferGranularity);
     
-    for( int blockIdx = 0; blockIdx < pcv.sizeInCnnlfInferSize[cnnlfInferGranularity]; blockIdx++ )
+    for( int blockIdx = 0; blockIdx < pcv.sizeInNnlfSet1InferSize[nnlfSet1InferGranularity]; blockIdx++ )
     {
-      int xPosInBlocks        = blockIdx % pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
-      int yPosInBlocks        = blockIdx / pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
+      int xPosInBlocks        = blockIdx % pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
+      int yPosInBlocks        = blockIdx / pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
       int xPos = xPosInBlocks * blockSize;
       int yPos = yPosInBlocks * blockSize;
       int width = (xPos + blockSize > pcv.lumaWidth) ? (pcv.lumaWidth - xPos) : blockSize;
       int height = (yPos + blockSize > pcv.lumaHeight) ? (pcv.lumaHeight - yPos) : blockSize;
       
       const UnitArea block( cs.area.chromaFormat, Area( xPos, yPos, width, height ) );
-      if (cnnlfParamIdx[chal][blockIdx])
+      if (nnlfSet1ParamIdx[chal][blockIdx])
       {
 #if SCALE_NN_RESIDUE
-        if (pcSlice->getNnScaleFlag(cnnlfParamIdx[chal][blockIdx] - 1, toChannelType(compID)))
-          pic->getRecoBuf(block).get(compID).copyFrom(m_tempScaledBuf[cnnlfParamIdx[chal][blockIdx] - 1].getBuf(block).get(compID));
+        if (pcSlice->getNnScaleFlag(nnlfSet1ParamIdx[chal][blockIdx] - 1, toChannelType(compID)))
+          pic->getRecoBuf(block).get(compID).copyFrom(m_tempScaledBuf[nnlfSet1ParamIdx[chal][blockIdx] - 1].getBuf(block).get(compID));
         else
 #endif
-        pic->getRecoBuf(block).get(compID).copyFrom(m_tempBuf[cnnlfParamIdx[chal][blockIdx] - 1].getBuf(block).get(compID));
+        pic->getRecoBuf(block).get(compID).copyFrom(m_tempBuf[nnlfSet1ParamIdx[chal][blockIdx] - 1].getBuf(block).get(compID));
       }
     }
   }
 }
 
 #if SCALE_NN_RESIDUE
-void CNNFilter::scaleResidualBlock(Picture *pic, UnitArea inferArea, int paramIdx, ComponentID compID)
+void NNFilterSet1::scaleResidualBlock(Picture *pic, UnitArea inferArea, int paramIdx, ComponentID compID)
 {
 
   CodingStructure &cs         = *pic->cs;
diff --git a/source/Lib/CommonLib/NNFilterSet1.h b/source/Lib/CommonLib/NNFilterSet1.h
new file mode 100644
index 0000000000..4e84967fc4
--- /dev/null
+++ b/source/Lib/CommonLib/NNFilterSet1.h
@@ -0,0 +1,72 @@
+/* The copyright in this software is being made available under the BSD
+* License, included below. This software may be subject to other third party
+* and contributor rights, including patent rights, and no such rights are
+* granted under this license.
+*
+* Copyright (c) 2010-2020, ITU/ISO/IEC
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+*  * Redistributions of source code must retain the above copyright notice,
+*    this list of conditions and the following disclaimer.
+*  * Redistributions in binary form must reproduce the above copyright notice,
+*    this list of conditions and the following disclaimer in the documentation
+*    and/or other materials provided with the distribution.
+*  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
+*    be used to endorse or promote products derived from this software without
+*    specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/** \file     NNFilterSet1.h
+    \brief    neural network-based fiter set1 class (header)
+*/
+
+#ifndef __NNFILTERSET1__
+#define __NNFILTERSET1__
+
+#include "CommonDef.h"
+#include "Unit.h"
+#include "Picture.h"
+#include "Reshape.h"
+//! \ingroup CommonLib
+//! \{
+
+
+class NNFilterSet1
+{
+public:
+  NNFilterSet1();
+  
+  std::vector<PelStorage> m_tempBuf;
+  std::string m_interLuma, m_interChroma, m_intraLuma, m_intraChroma;
+#if SCALE_NN_RESIDUE
+  std::vector<PelStorage> m_tempScaledBuf;
+#endif
+  template<typename T> void cnnFilterLumaBlock( Picture* pic, UnitArea inferArea, int extLeft, int extRight, int extTop, int extBottom, int paramIdx, bool inter);
+  template<typename T> void cnnFilterChromaBlock( Picture* pic, UnitArea inferArea, int extLeft, int extRight, int extTop, int extBottom, int paramIdx, bool inter);
+  void cnnFilter( Picture* pic);
+#if SCALE_NN_RESIDUE
+  void scaleResidualBlock(Picture *pic, UnitArea inferArea, int paramIdx, ComponentID compID);
+#endif
+  void create(const int picWidth, const int picHeight, const ChromaFormat format, const int nnlfSet1NumParams);
+  void init(std::string interLuma, std::string interChroma, std::string intraLuma, std::string intraChroma);
+  void destroy();
+};
+
+//! \}
+#endif
+
diff --git a/source/Lib/CommonLib/NNInference.h b/source/Lib/CommonLib/NNInference.h
index bb2060d5f0..3109b420b8 100644
--- a/source/Lib/CommonLib/NNInference.h
+++ b/source/Lib/CommonLib/NNInference.h
@@ -39,6 +39,7 @@
 #define __NNINFERENCE__
 
 #include "CommonDef.h"
+#if NN_COMMON_API
 #include "Unit.h"
 #include "Picture.h"
 #include "Reshape.h"
@@ -210,4 +211,5 @@ public:
 };
 //! \}
 #endif
+#endif
 
diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h
index 25417d7093..ebbab4d161 100644
--- a/source/Lib/CommonLib/Picture.h
+++ b/source/Lib/CommonLib/Picture.h
@@ -342,36 +342,36 @@ public:
 #endif
 
   std::vector<SAOBlkParam> m_sao[2];
-
-#if CNN_FILTERING
-  std::vector<uint8_t> m_cnnlfParamIdx[MAX_NUM_CNNLF_INFER_GRANULARITY][MAX_NUM_CHANNEL_TYPE];
-  uint8_t* getCnnlfParamIdx( int gra, int chal ) { return m_cnnlfParamIdx[gra][chal].data(); }
-  std::vector<uint8_t>* getCnnlfParamIdx(int gra) { return m_cnnlfParamIdx[gra]; }
+  
+#if NN_FILTERING_SET_1
+  std::vector<uint8_t> m_nnlfSet1ParamIdx[MAX_NUM_CNNLF_INFER_GRANULARITY][MAX_NUM_CHANNEL_TYPE];
+  uint8_t* getNnlfSet1ParamIdx( int gra, int chal ) { return m_nnlfSet1ParamIdx[gra][chal].data(); }
+  std::vector<uint8_t>* getNnlfSet1ParamIdx(int gra) { return m_nnlfSet1ParamIdx[gra]; }
 #if SCALE_NN_RESIDUE
-  std::vector<uint8_t> m_cnnlfBackupParamIdx[MAX_NUM_CNNLF_INFER_GRANULARITY][MAX_NUM_CHANNEL_TYPE];
-  uint8_t *            getCnnlfBackupParamIdx(int gra, int chal) { return m_cnnlfBackupParamIdx[gra][chal].data();  }
-  std::vector<uint8_t> *getCnnlfBackupParamIdx(int gra)
+  std::vector<uint8_t> m_nnlfSet1BackupParamIdx[MAX_NUM_CNNLF_INFER_GRANULARITY][MAX_NUM_CHANNEL_TYPE];
+  uint8_t *            getNnlfSet1BackupParamIdx(int gra, int chal) { return m_nnlfSet1BackupParamIdx[gra][chal].data();  }
+  std::vector<uint8_t> *getNnlfSet1BackupParamIdx(int gra)
   {
-    return m_cnnlfBackupParamIdx[gra];
+    return m_nnlfSet1BackupParamIdx[gra];
   }
 #endif
-  void resizeCnnlfParamIdx(const unsigned int *numEntries)
+  void resizeNnlfSet1ParamIdx(const unsigned int *numEntries)
   {
     for (int gra = 0; gra < MAX_NUM_CNNLF_INFER_GRANULARITY; gra ++)
     {
       for( int chal = 0; chal < MAX_NUM_CHANNEL_TYPE; chal++ )
       {
-        m_cnnlfParamIdx[gra][chal].resize( numEntries[gra] );
-        std::fill( m_cnnlfParamIdx[gra][chal].begin(), m_cnnlfParamIdx[gra][chal].end(), 0 );
+        m_nnlfSet1ParamIdx[gra][chal].resize( numEntries[gra] );
+        std::fill( m_nnlfSet1ParamIdx[gra][chal].begin(), m_nnlfSet1ParamIdx[gra][chal].end(), 0 );
 #if SCALE_NN_RESIDUE
-        m_cnnlfBackupParamIdx[gra][chal].resize(numEntries[gra]);
-        std::fill(m_cnnlfBackupParamIdx[gra][chal].begin(), m_cnnlfBackupParamIdx[gra][chal].end(), 0);
+        m_nnlfSet1BackupParamIdx[gra][chal].resize(numEntries[gra]);
+        std::fill(m_nnlfSet1BackupParamIdx[gra][chal].begin(), m_nnlfSet1BackupParamIdx[gra][chal].end(), 0);
 #endif
       }
     }
   }
 #endif
-  
+
   std::vector<uint8_t> m_alfCtuEnableFlag[MAX_NUM_COMPONENT];
   uint8_t* getAlfCtuEnableFlag( int compIdx ) { return m_alfCtuEnableFlag[compIdx].data(); }
   std::vector<uint8_t>* getAlfCtuEnableFlag() { return m_alfCtuEnableFlag; }
diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp
index 2783172816..c22bd45fb8 100644
--- a/source/Lib/CommonLib/Slice.cpp
+++ b/source/Lib/CommonLib/Slice.cpp
@@ -2171,18 +2171,11 @@ void Slice::startProcessingTimer()
   m_iProcessingStartTime = clock();
 }
 
-#if CNN_FILTERING
-void Slice::stopProcessingTimer(double elapsedTime)
-{
-  m_dProcessingTime += elapsedTime;
-}
-#else
 void Slice::stopProcessingTimer()
 {
   m_dProcessingTime += (double)(clock()-m_iProcessingStartTime) / CLOCKS_PER_SEC;
   m_iProcessingStartTime = 0;
 }
-#endif
 
 unsigned Slice::getMinPictureDistance() const
 {
@@ -2935,7 +2928,7 @@ SPS::SPS()
     m_maxNumReorderPics[i]    = 0;
   }
   
-#if CNN_FILTERING
+#if NN_FILTERING_SET_1
   for ( int i = 0; i < MAX_NUM_CNNLF_INFER_GRANULARITY; i++ )
   {
     m_nnlfSet1InferSize[i] = 128;
diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h
index 8207209245..43b58db6c8 100644
--- a/source/Lib/CommonLib/Slice.h
+++ b/source/Lib/CommonLib/Slice.h
@@ -1397,7 +1397,7 @@ private:
   unsigned    m_dualITree;
   uint32_t              m_uiMaxCUWidth;
   uint32_t              m_uiMaxCUHeight;
-  
+
   RPLList           m_RPLList0;
   RPLList           m_RPLList1;
   uint32_t          m_numRPL0;
@@ -1478,11 +1478,11 @@ private:
 
   bool              m_alfEnabledFlag;
   bool              m_ccalfEnabledFlag;
-#if CNN_FILTERING
-  bool              m_cnnlfEnabledFlag;
-  unsigned          m_cnnlfInferSize[MAX_NUM_CNNLF_INFER_GRANULARITY];
-  unsigned          m_cnnlfInferSizeExtension;
-  unsigned          m_cnnlfMaxNumParams;
+#if NN_FILTERING_SET_1
+  bool              m_nnlfSet1EnabledFlag;
+  unsigned          m_nnlfSet1InferSize[MAX_NUM_CNNLF_INFER_GRANULARITY];
+  unsigned          m_nnlfSet1InferSizeExtension;
+  unsigned          m_nnlfSet1MaxNumParams;
 #endif
   bool              m_wrapAroundEnabledFlag;
   unsigned          m_IBCFlag;
@@ -1664,13 +1664,13 @@ public:
   uint32_t                    getMaxCUWidth() const                                                           { return  m_uiMaxCUWidth;                                              }
   void                    setMaxCUHeight( uint32_t u )                                                        { m_uiMaxCUHeight = u;                                                 }
   uint32_t                    getMaxCUHeight() const                                                          { return  m_uiMaxCUHeight;                                             }
-#if CNN_FILTERING
-  void                    setCnnlfInferSize( uint32_t* cnnlfInferSize ) { m_cnnlfInferSize[0] = cnnlfInferSize[0]; m_cnnlfInferSize[1] = cnnlfInferSize[1]; m_cnnlfInferSize[2] = cnnlfInferSize[2];}
-  uint32_t                getCnnlfInferSize(CnnlfInferGranularity cnnlfInferGranularity) const                { return  m_cnnlfInferSize[cnnlfInferGranularity];                     }
-  void                    setCnnlfInferSizeExtension( uint32_t cnnlfInferSizeExtension )                      { m_cnnlfInferSizeExtension = cnnlfInferSizeExtension;                 }
-  uint32_t                getCnnlfInferSizeExtension() const                                                  { return  m_cnnlfInferSizeExtension;                                   }
-  void                    setCnnlfMaxNumParams( uint32_t cnnlfMaxNumParams )                                  { m_cnnlfMaxNumParams = cnnlfMaxNumParams;                             }
-  uint32_t                getCnnlfMaxNumParams() const                                                        { return  m_cnnlfMaxNumParams;                                         }
+#if NN_FILTERING_SET_1
+  void                    setNnlfSet1InferSize( uint32_t* nnlfSet1InferSize )                                 { m_nnlfSet1InferSize[0] = nnlfSet1InferSize[0]; m_nnlfSet1InferSize[1] = nnlfSet1InferSize[1]; m_nnlfSet1InferSize[2] = nnlfSet1InferSize[2];}
+  uint32_t                getNnlfSet1InferSize(NnlfSet1InferGranularity nnlfSet1InferGranularity) const       { return  m_nnlfSet1InferSize[nnlfSet1InferGranularity];                     }
+  void                    setNnlfSet1InferSizeExtension( uint32_t nnlfSet1InferSizeExtension )                { m_nnlfSet1InferSizeExtension = nnlfSet1InferSizeExtension;                 }
+  uint32_t                getNnlfSet1InferSizeExtension() const                                               { return  m_nnlfSet1InferSizeExtension;                                   }
+  void                    setNnlfSet1MaxNumParams( uint32_t nnlfSet1MaxNumParams )                            { m_nnlfSet1MaxNumParams = nnlfSet1MaxNumParams;                             }
+  uint32_t                getNnlfSet1MaxNumParams() const                                                     { return  m_nnlfSet1MaxNumParams;                                         }
 #endif
   bool                    getTransformSkipEnabledFlag() const                                                 { return m_transformSkipEnabledFlag;                                   }
   void                    setTransformSkipEnabledFlag( bool b )                                               { m_transformSkipEnabledFlag = b;                                      }
@@ -1741,9 +1741,9 @@ public:
   void                    setALFEnabledFlag( bool b )                                                     { m_alfEnabledFlag = b; }
   bool                    getCCALFEnabledFlag() const                                                     { return m_ccalfEnabledFlag; }
   void                    setCCALFEnabledFlag( bool b )                                                   { m_ccalfEnabledFlag = b; }
-#if CNN_FILTERING
-  bool                    getCnnlfEnabledFlag() const                                                     { return m_cnnlfEnabledFlag; }
-  void                    setCnnlfEnabledFlag( bool b )                                                   { m_cnnlfEnabledFlag = b; }
+#if NN_FILTERING_SET_1
+  bool                    getNnlfSet1EnabledFlag() const                                                  { return m_nnlfSet1EnabledFlag; }
+  void                    setNnlfSet1EnabledFlag( bool b )                                                { m_nnlfSet1EnabledFlag = b; }
 #endif
   void                    setJointCbCrEnabledFlag(bool bVal)                                              { m_JointCbCrEnabledFlag = bVal; }
   bool                    getJointCbCrEnabledFlag() const                                                 { return m_JointCbCrEnabledFlag; }
@@ -2616,9 +2616,13 @@ class Slice
 private:
   //  Bitstream writing
   bool                       m_saoEnabledFlag[MAX_NUM_CHANNEL_TYPE];
-#if CNN_FILTERING
-  uint8_t                    m_cnnlfMode[MAX_NUM_CHANNEL_TYPE]; // 0: slice off
-  CnnlfInferGranularity      m_cnnlfInferGranularity[MAX_NUM_CHANNEL_TYPE];
+#if NN_FILTERING_SET_1
+  uint8_t                    m_nnlfSet1Mode[MAX_NUM_CHANNEL_TYPE]; // 0: slice off
+  NnlfSet1InferGranularity   m_nnlfSet1InferGranularity[MAX_NUM_CHANNEL_TYPE];
+#if SCALE_NN_RESIDUE
+  bool                       m_sliceNnScaleFlag[3][MAX_NUM_CHANNEL_TYPE];
+  int                        m_nnScale[3][MAX_NUM_CHANNEL_TYPE];
+#endif
 #endif
   int                        m_iPOC;
   int                        m_iLastIDR;
@@ -2732,12 +2736,7 @@ private:
   int                        m_tileGroupCcAlfCrApsId;
   bool                       m_disableSATDForRd;
   bool                       m_isLossless;
-
-#if SCALE_NN_RESIDUE
-  bool                       m_sliceNnScaleFlag[3][MAX_NUM_CHANNEL_TYPE];
-  int                        m_nnScale[3][MAX_NUM_CHANNEL_TYPE];
-#endif
-
+  
 public:
                               Slice();
   virtual                     ~Slice();
@@ -2760,11 +2759,11 @@ public:
   APS**                       getAlfAPSs()                                           { return m_alfApss;                                             }
   void                        setSaoEnabledFlag(ChannelType chType, bool s)          {m_saoEnabledFlag[chType] =s;                                   }
   bool                        getSaoEnabledFlag(ChannelType chType) const            { return m_saoEnabledFlag[chType];                              }
-#if CNN_FILTERING
-  void                        setCnnlfMode(ChannelType chType, uint8_t m)            {m_cnnlfMode[chType] = m;                                       }
-  uint8_t                     getCnnlfMode(ChannelType chType) const                 { return m_cnnlfMode[chType];                                   }
-  void                        setCnnlfInferGranularity(ChannelType chType, CnnlfInferGranularity cnnlfInferGranularity)   {m_cnnlfInferGranularity[chType] = cnnlfInferGranularity; }
-  CnnlfInferGranularity       getCnnlfInferGranularity(ChannelType chType) const     { return m_cnnlfInferGranularity[chType];                       }
+#if NN_FILTERING_SET_1
+  void                        setNnlfSet1Mode(ChannelType chType, uint8_t m)            {m_nnlfSet1Mode[chType] = m;                                       }
+  uint8_t                     getNnlfSet1Mode(ChannelType chType) const                 { return m_nnlfSet1Mode[chType];                                   }
+  void                        setNnlfSet1InferGranularity(ChannelType chType, NnlfSet1InferGranularity nnlfSet1InferGranularity)   {m_nnlfSet1InferGranularity[chType] = nnlfSet1InferGranularity; }
+  NnlfSet1InferGranularity    getNnlfSet1InferGranularity(ChannelType chType) const     { return m_nnlfSet1InferGranularity[chType];                       }
 
 #if SCALE_NN_RESIDUE
   void setNnScale(int sc, uint8_t paramIdx, ChannelType chType) { m_nnScale[paramIdx][chType] = sc; }
@@ -2772,7 +2771,7 @@ public:
 
   void setNnScaleFlag(bool b, int paramIdx, ChannelType chType) { m_sliceNnScaleFlag[paramIdx][chType] = b; }
   bool getNnScaleFlag(int paramIdx, ChannelType chType) const { return m_sliceNnScaleFlag[paramIdx][chType]; }
-#endif 
+#endif
 
 #endif
   ReferencePictureList*       getRPL0()                                              { return &m_RPL0;                                              }
@@ -3013,11 +3012,7 @@ public:
   ClpRngs&                    getClpRngs()                                            { return m_clpRngs;}
   unsigned                    getMinPictureDistance()                           const ;
   void startProcessingTimer();
-#if CNN_FILTERING
-  void stopProcessingTimer(double elapsedTime);
-#else
   void stopProcessingTimer();
-#endif
   void resetProcessingTime()       { m_dProcessingTime = m_iProcessingStartTime = 0; }
   double getProcessingTime() const { return m_dProcessingTime; }
 
@@ -3097,10 +3092,10 @@ public:
     , widthInCtus         ( (pps.getPicWidthInLumaSamples () + sps.getMaxCUWidth () - 1) / sps.getMaxCUWidth () )
     , heightInCtus        ( (pps.getPicHeightInLumaSamples() + sps.getMaxCUHeight() - 1) / sps.getMaxCUHeight() )
     , sizeInCtus          ( widthInCtus * heightInCtus )
-#if CNN_FILTERING
-    , widthInCnnlfInferSize {(pps.getPicWidthInLumaSamples () + sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_SMALL) - 1) / sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_SMALL), (pps.getPicWidthInLumaSamples () + sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_BASE) - 1) / sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_BASE), (pps.getPicWidthInLumaSamples () + sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_LARGE) - 1) / sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_LARGE)}
-    , heightInCnnlfInferSize {(pps.getPicHeightInLumaSamples () + sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_SMALL) - 1) / sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_SMALL), (pps.getPicHeightInLumaSamples () + sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_BASE) - 1) / sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_BASE), (pps.getPicHeightInLumaSamples () + sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_LARGE) - 1) / sps.getCnnlfInferSize(CNNLF_INFER_GRANULARITY_LARGE)}
-    , sizeInCnnlfInferSize {widthInCnnlfInferSize[CNNLF_INFER_GRANULARITY_SMALL] * heightInCnnlfInferSize[CNNLF_INFER_GRANULARITY_SMALL], widthInCnnlfInferSize[CNNLF_INFER_GRANULARITY_BASE] * heightInCnnlfInferSize[CNNLF_INFER_GRANULARITY_BASE], widthInCnnlfInferSize[CNNLF_INFER_GRANULARITY_LARGE] * heightInCnnlfInferSize[CNNLF_INFER_GRANULARITY_LARGE]}
+#if NN_FILTERING_SET_1
+    , widthInNnlfSet1InferSize {(pps.getPicWidthInLumaSamples () + sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_SMALL) - 1) / sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_SMALL), (pps.getPicWidthInLumaSamples () + sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_BASE) - 1) / sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_BASE), (pps.getPicWidthInLumaSamples () + sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_LARGE) - 1) / sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_LARGE)}
+    , heightInNnlfSet1InferSize {(pps.getPicHeightInLumaSamples () + sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_SMALL) - 1) / sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_SMALL), (pps.getPicHeightInLumaSamples () + sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_BASE) - 1) / sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_BASE), (pps.getPicHeightInLumaSamples () + sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_LARGE) - 1) / sps.getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_LARGE)}
+    , sizeInNnlfSet1InferSize {widthInNnlfSet1InferSize[CNNLF_INFER_GRANULARITY_SMALL] * heightInNnlfSet1InferSize[CNNLF_INFER_GRANULARITY_SMALL], widthInNnlfSet1InferSize[CNNLF_INFER_GRANULARITY_BASE] * heightInNnlfSet1InferSize[CNNLF_INFER_GRANULARITY_BASE], widthInNnlfSet1InferSize[CNNLF_INFER_GRANULARITY_LARGE] * heightInNnlfSet1InferSize[CNNLF_INFER_GRANULARITY_LARGE]}
 #endif
     , lumaWidth           ( pps.getPicWidthInLumaSamples() )
     , lumaHeight          ( pps.getPicHeightInLumaSamples() )
@@ -3135,10 +3130,10 @@ public:
   const unsigned     widthInCtus;
   const unsigned     heightInCtus;
   const unsigned     sizeInCtus;
-#if CNN_FILTERING
-  const uint32_t     widthInCnnlfInferSize[MAX_NUM_CNNLF_INFER_GRANULARITY];
-  const uint32_t     heightInCnnlfInferSize[MAX_NUM_CNNLF_INFER_GRANULARITY];
-  const uint32_t     sizeInCnnlfInferSize[MAX_NUM_CNNLF_INFER_GRANULARITY];
+#if NN_FILTERING_SET_1
+  const uint32_t     widthInNnlfSet1InferSize[MAX_NUM_CNNLF_INFER_GRANULARITY];
+  const uint32_t     heightInNnlfSet1InferSize[MAX_NUM_CNNLF_INFER_GRANULARITY];
+  const uint32_t     sizeInNnlfSet1InferSize[MAX_NUM_CNNLF_INFER_GRANULARITY];
 #endif
   const unsigned     lumaWidth;
   const unsigned     lumaHeight;
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index 068d66ab7b..1cebee12ba 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -50,10 +50,11 @@
 #include <assert.h>
 #include <cassert>
 
-
 // clang-format off
 
+// used by both nn filter sets
 #define NN_COMMON_API                                     1
+#define NN_FIXED_POINT_IMPLEMENTATION                     1
 
 #define NNVC_INFO_ENCODER                                 1 // add some info in encoder logs necessary to extract data
 #define NNVC_DUMP_DATA                                    1
@@ -67,12 +68,12 @@
 #define NNVC_USE_QP                                       1 // QP slice
 #define NNVC_USE_SLICETYPE                                1 // slice type
 
-#define CNN_FILTERING                                     1
+// nn filter set 1
+#define NN_FILTERING_SET_1                                1
 
-#if CNN_FILTERING
+#if NN_FILTERING_SET_1
 #define SCALE_NN_RESIDUE                                  1
 #define COMBINE_NN_WITH_LF                                1
-#define NN_FIXED_POINT_IMPLEMENTATION                     1
 #endif
 
 #if SCALE_NN_RESIDUE
@@ -90,11 +91,10 @@
 #if NN_FIXED_POINT_IMPLEMENTATION
 #define NN_INPUT_PRECISION                                13
 #define NN_OUPUTPUT_PRECISION                             13
-#endif
+#endif //end of filter set 1
 
 //########### place macros to be removed in next cycle below this line ###############
 
-
 #define JVET_V0056                                        1 // MCTF changes as presented in JVET-V0056
 
 #define JVET_S0096_RPL_CONSTRAINT                         1// JVET-S0096 aspect 1: When pps_rpl_info_in_ph_flag is equal to 1 and ph_inter_slice_allowed_flag is equal to 1, the value of num_ref_entries[ 0 ][ RplsIdx[ 0 ] ] shall be greater than 0.
@@ -462,8 +462,9 @@ enum ComponentID
   JOINT_CbCr          = MAX_NUM_COMPONENT,
   MAX_NUM_TBLOCKS     = MAX_NUM_COMPONENT
 };
-#if CNN_FILTERING
-enum CnnlfInferGranularity
+
+#if NN_FILTERING_SET_1
+enum NnlfSet1InferGranularity
 {
   CNNLF_INFER_GRANULARITY_SMALL  = 0, // half base size
   CNNLF_INFER_GRANULARITY_BASE  = 1, // specified in SPS
@@ -471,6 +472,7 @@ enum CnnlfInferGranularity
   MAX_NUM_CNNLF_INFER_GRANULARITY  = 3
 };
 #endif
+
 #if NN_COMMON_API
 enum NNInputType
 {
@@ -484,6 +486,7 @@ enum NNInputType
   MAX_NUM_NN_INPUT  = 7
 };
 #endif
+
 #define MAP_CHROMA(c) (ComponentID(c))
 
 enum InputColourSpaceConversion // defined in terms of conversion prior to input of encoder.
diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp
index 7aca4738b8..41cfaa1ad9 100644
--- a/source/Lib/DecoderLib/CABACReader.cpp
+++ b/source/Lib/DecoderLib/CABACReader.cpp
@@ -144,48 +144,48 @@ void CABACReader::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i
 
 
   sao( cs, ctuRsAddr );
-#if CNN_FILTERING
-  if ( cs.sps->getCnnlfEnabledFlag() && ctuRsAddr == 0)
+#if NN_FILTERING_SET_1
+  if ( cs.sps->getNnlfSet1EnabledFlag() && ctuRsAddr == 0)
   {
     for( int chal = 0; chal < MAX_NUM_CHANNEL_TYPE; chal++ )
     {
-      CnnlfInferGranularity cnnlfInferGranularity = cs.slice->getCnnlfInferGranularity(ChannelType(chal));
-      uint8_t* cnnlfParamIdx = cs.slice->getPic()->getCnnlfParamIdx( cnnlfInferGranularity, chal );
-      uint8_t sliceCnnlfMode = cs.slice->getCnnlfMode(ChannelType(chal));
-      int numParams = cs.sps->getCnnlfMaxNumParams();
-      for( int unitIdx = 0; unitIdx < cs.pcv->sizeInCnnlfInferSize[cnnlfInferGranularity]; unitIdx++ )
+      NnlfSet1InferGranularity nnlfSet1InferGranularity = cs.slice->getNnlfSet1InferGranularity(ChannelType(chal));
+      uint8_t* nnlfSet1ParamIdx = cs.slice->getPic()->getNnlfSet1ParamIdx( nnlfSet1InferGranularity, chal );
+      uint8_t sliceNnlfSet1Mode = cs.slice->getNnlfSet1Mode(ChannelType(chal));
+      int numParams = cs.sps->getNnlfSet1MaxNumParams();
+      for( int unitIdx = 0; unitIdx < cs.pcv->sizeInNnlfSet1InferSize[nnlfSet1InferGranularity]; unitIdx++ )
       {
-        if (sliceCnnlfMode < numParams + 1)
+        if (sliceNnlfSet1Mode < numParams + 1)
         {
-          cnnlfParamIdx[unitIdx] = sliceCnnlfMode;
+          nnlfSet1ParamIdx[unitIdx] = sliceNnlfSet1Mode;
           continue;
         }
-        bool useCnnlf, useFirstParam = false;
-        useCnnlf = m_BinDecoder.decodeBin( Ctx::cnnlfParamIdx( chal * 2 + 0 ) );
+        bool useNnlfSet1, useFirstParam = false;
+        useNnlfSet1 = m_BinDecoder.decodeBin( Ctx::nnlfSet1ParamIdx( chal * 2 + 0 ) );
         if (numParams == 1)
         {
-          cnnlfParamIdx[unitIdx] = useCnnlf ? 1 : 0;
+          nnlfSet1ParamIdx[unitIdx] = useNnlfSet1 ? 1 : 0;
         }
-        else if (!useCnnlf)
+        else if (!useNnlfSet1)
         {
-          cnnlfParamIdx[unitIdx] = 0;
+          nnlfSet1ParamIdx[unitIdx] = 0;
         }
         else
         {
-          useFirstParam = m_BinDecoder.decodeBin( Ctx::cnnlfParamIdx( chal * 2 + 1 ) );
+          useFirstParam = m_BinDecoder.decodeBin( Ctx::nnlfSet1ParamIdx( chal * 2 + 1 ) );
           if (numParams == 2)
           {
-            cnnlfParamIdx[unitIdx] = useFirstParam ? 1 : 2;
+            nnlfSet1ParamIdx[unitIdx] = useFirstParam ? 1 : 2;
           }
           else if (useFirstParam)
           {
-            cnnlfParamIdx[unitIdx] = 1;
+            nnlfSet1ParamIdx[unitIdx] = 1;
           }
           else
           {
-            uint32_t cnnlfParamIdxMinus2 = 0;
-            xReadTruncBinCode(cnnlfParamIdxMinus2, numParams - 1);
-            cnnlfParamIdx[unitIdx] = cnnlfParamIdxMinus2 + 2;
+            uint32_t nnlfSet1ParamIdxMinus2 = 0;
+            xReadTruncBinCode(nnlfSet1ParamIdxMinus2, numParams - 1);
+            nnlfSet1ParamIdx[unitIdx] = nnlfSet1ParamIdxMinus2 + 2;
           }
         }
 
diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp
index cb8c4ba122..7d280a8685 100644
--- a/source/Lib/DecoderLib/DecLib.cpp
+++ b/source/Lib/DecoderLib/DecLib.cpp
@@ -58,10 +58,6 @@
 #include "CommonLib/CodingStatistics.h"
 #endif
 
-#if CNN_FILTERING
-#include <chrono>
-#endif
-
 bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::string& bitstreamFileName, ParameterSetMap<APS> *apsMap, bool bDecodeUntilPocFound /* = false */, int debugCTU /* = -1*/, int debugPOC /* = -1*/ )
 {
   int      poc;
@@ -494,8 +490,8 @@ void DecLib::create()
 {
   m_apcSlicePilot = new Slice;
   m_uiSliceSegmentIdx = 0;
-#if CNN_FILTERING
-  m_pcCNNFilter = new CNNFilter;
+#if NN_FILTERING_SET_1
+  m_pcNNFilterSet1 = new NNFilterSet1;
 #endif
 }
 
@@ -509,12 +505,12 @@ void DecLib::destroy()
     delete m_dci;
     m_dci = NULL;
   }
-#if CNN_FILTERING
-  if (m_pcCNNFilter)
+#if NN_FILTERING_SET_1
+  if (m_pcNNFilterSet1)
   {
-    m_pcCNNFilter->destroy();
-    delete m_pcCNNFilter;
-    m_pcCNNFilter = NULL;
+    m_pcNNFilterSet1->destroy();
+    delete m_pcNNFilterSet1;
+    m_pcNNFilterSet1 = NULL;
   }
 #endif
   m_cSliceDecoder.destroy();
@@ -631,18 +627,16 @@ void DecLib::executeLoopFilters()
 
   m_pcPic->cs->slice->startProcessingTimer();
 
-#if CNN_FILTERING
-  auto startTime = std::chrono::steady_clock::now();
-#endif
-  
   CodingStructure& cs = *m_pcPic->cs;
-#if CNN_FILTERING
-  if (cs.sps->getCnnlfEnabledFlag())
+  
+#if NN_FILTERING_SET_1
+  if (cs.sps->getNnlfSet1EnabledFlag())
   {
-    m_pcCNNFilter->create(cs.pcv->lumaWidth, cs.pcv->lumaHeight, cs.pcv->chrFormat, cs.sps->getCnnlfMaxNumParams());
-    m_pcCNNFilter->init(getCnnlfInterLumaModelName(), getCnnlfInterChromaModelName(), getCnnlfIntraLumaModelName(), getCnnlfIntraChromaModelName());
+    m_pcNNFilterSet1->create(cs.pcv->lumaWidth, cs.pcv->lumaHeight, cs.pcv->chrFormat, cs.sps->getNnlfSet1MaxNumParams());
+    m_pcNNFilterSet1->init(getNnlfSet1InterLumaModelName(), getNnlfSet1InterChromaModelName(), getNnlfSet1IntraLumaModelName(), getNnlfSet1IntraChromaModelName());
   }
 #endif
+
   if (cs.sps->getUseLmcs() && cs.picHeader->getLmcsEnabledFlag())
   {
       const PreCalcValues& pcv = *cs.pcv;
@@ -677,6 +671,7 @@ void DecLib::executeLoopFilters()
         }
       }
 #endif
+
       m_cReshaper.setRecReshaped(false);
       m_cSAO.setReshaper(&m_cReshaper);
   }
@@ -686,6 +681,7 @@ void DecLib::executeLoopFilters()
 #if NNVC_USE_REC_BEFORE_DBF
   m_pcPic->getRecBeforeDbfBuf().copyFrom(m_pcPic->getRecoBuf());
 #endif
+
   // deblocking filter
   m_cLoopFilter.loopFilterPic( cs );
 #if NNVC_USE_REC_AFTER_DBF
@@ -693,26 +689,26 @@ void DecLib::executeLoopFilters()
 #endif
   CS::setRefinedMotionField(cs);
   
-  if( cs.sps->getSAOEnabledFlag() )
-  {
-    m_cSAO.SAOProcess( cs, cs.picture->getSAO() );
-  }
-  
 #if COMBINE_NN_WITH_LF && !FUSE_NN_AND_LF
-  if (cs.sps->getCnnlfEnabledFlag())
+  if (cs.sps->getNnlfSet1EnabledFlag())
   {
-    m_pcPic->getRecoBuf().copyFrom(m_pcPic->getUnfilteredRecBuf());
+    m_pcPic->getRecoBuf().copyFrom(m_pcPic->getRecBeforeDbfBuf());
   }
 #endif
   
   //CNN filter
-#if CNN_FILTERING
-  if (cs.sps->getCnnlfEnabledFlag())
+#if NN_FILTERING_SET_1
+  if (cs.sps->getNnlfSet1EnabledFlag())
   {
-    m_pcCNNFilter->cnnFilter(m_pcPic);
+    m_pcNNFilterSet1->cnnFilter(m_pcPic);
   }
 #endif
-
+  
+  if( cs.sps->getSAOEnabledFlag() )
+  {
+    m_cSAO.SAOProcess( cs, cs.picture->getSAO() );
+  }
+  
   if( cs.sps->getALFEnabledFlag() )
   {
     m_cALF.getCcAlfFilterParam() = cs.slice->m_ccAlfFilterParam;
@@ -746,13 +742,7 @@ void DecLib::executeLoopFilters()
     }
   }
 
-#if CNN_FILTERING
-  auto endTime = std::chrono::steady_clock::now();
-  auto encTime = std::chrono::duration_cast<std::chrono::milliseconds>( endTime - startTime).count();
-  m_pcPic->cs->slice->stopProcessingTimer(encTime/1000.0);
-#else
   m_pcPic->cs->slice->stopProcessingTimer();
-#endif
 }
 
 void DecLib::finishPictureLight(int& poc, PicList*& rpcListPic )
diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h
index 16cfdaf2fd..a0c4431258 100644
--- a/source/Lib/DecoderLib/DecLib.h
+++ b/source/Lib/DecoderLib/DecLib.h
@@ -54,8 +54,8 @@
 #include "CommonLib/SEI.h"
 #include "CommonLib/Unit.h"
 #include "CommonLib/Reshape.h"
-#if CNN_FILTERING
-#include "CommonLib/CNNFilter.h"
+#if NN_FILTERING_SET_1
+#include "CommonLib/NNFilterSet1.h"
 #endif
 
 class InputNALUnit;
@@ -71,11 +71,11 @@ bool tryDecodePicture( Picture* pcPic, const int expectedPoc, const std::string&
 class DecLib
 {
 private:
-#if CNN_FILTERING
-  std::string             m_cnnlfInterLumaModelName;                      ///<inter luma cnnlf model
-  std::string             m_cnnlfInterChromaModelName;                    ///<inter chroma cnnlf model
-  std::string             m_cnnlfIntraLumaModelName;                      ///<intra luma cnnlf model
-  std::string             m_cnnlfIntraChromaModelName;                    ///<inra chroma cnnlf model
+#if NN_FILTERING_SET_1
+  std::string             m_nnlfSet1InterLumaModelName;                      ///<inter luma nnlfSet1 model
+  std::string             m_nnlfSet1InterChromaModelName;                    ///<inter chroma nnlfSet1 model
+  std::string             m_nnlfSet1IntraLumaModelName;                      ///<intra luma nnlfSet1 model
+  std::string             m_nnlfSet1IntraChromaModelName;                    ///<inra chroma nnlfSet1 model
 #endif
   int                     m_iMaxRefPicNum;
   bool m_isFirstGeneralHrd;
@@ -123,8 +123,8 @@ private:
   AdaptiveLoopFilter      m_cALF;
   Reshape                 m_cReshaper;                        ///< reshaper class
   HRD                     m_HRD;
-#if CNN_FILTERING
-  CNNFilter*              m_pcCNNFilter;
+#if NN_FILTERING_SET_1
+  NNFilterSet1*           m_pcNNFilterSet1;
 #endif
   // decoder side RD cost computation
   RdCost                  m_cRdCost;                      ///< RD cost computation class
@@ -222,15 +222,15 @@ public:
   void  create  ();
   void  destroy ();
   
-#if CNN_FILTERING
-  std::string      getCnnlfInterLumaModelName()                { return m_cnnlfInterLumaModelName;   }
-  std::string      getCnnlfInterChromaModelName()              { return m_cnnlfInterChromaModelName; }
-  std::string      getCnnlfIntraLumaModelName()                { return m_cnnlfIntraLumaModelName;   }
-  std::string      getCnnlfIntraChromaModelName()              { return m_cnnlfIntraChromaModelName; }
-  void             setCnnlfInterLumaModelName(std::string s)   { m_cnnlfInterLumaModelName = s;      }
-  void             setCnnlfInterChromaModelName(std::string s) { m_cnnlfInterChromaModelName = s;    }
-  void             setCnnlfIntraLumaModelName(std::string s)   { m_cnnlfIntraLumaModelName = s;      }
-  void             setCnnlfIntraChromaModelName(std::string s) { m_cnnlfIntraChromaModelName = s;    }
+#if NN_FILTERING_SET_1
+  std::string      getNnlfSet1InterLumaModelName()                { return m_nnlfSet1InterLumaModelName;   }
+  std::string      getNnlfSet1InterChromaModelName()              { return m_nnlfSet1InterChromaModelName; }
+  std::string      getNnlfSet1IntraLumaModelName()                { return m_nnlfSet1IntraLumaModelName;   }
+  std::string      getNnlfSet1IntraChromaModelName()              { return m_nnlfSet1IntraChromaModelName; }
+  void             setNnlfSet1InterLumaModelName(std::string s)   { m_nnlfSet1InterLumaModelName = s;      }
+  void             setNnlfSet1InterChromaModelName(std::string s) { m_nnlfSet1InterChromaModelName = s;    }
+  void             setNnlfSet1IntraLumaModelName(std::string s)   { m_nnlfSet1IntraLumaModelName = s;      }
+  void             setNnlfSet1IntraChromaModelName(std::string s) { m_nnlfSet1IntraChromaModelName = s;    }
 #endif
 
   void  setDecodedPictureHashSEIEnabled(int enabled) { m_decodedPictureHashSEIEnabled=enabled; }
diff --git a/source/Lib/DecoderLib/DecSlice.cpp b/source/Lib/DecoderLib/DecSlice.cpp
index 166e1e226c..944e1b0ebb 100644
--- a/source/Lib/DecoderLib/DecSlice.cpp
+++ b/source/Lib/DecoderLib/DecSlice.cpp
@@ -41,10 +41,6 @@
 
 #include <vector>
 
-#if CNN_FILTERING
-#include <chrono>
-#endif
-
 //! \ingroup DecoderLib
 //! \{
 
@@ -79,10 +75,6 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb
   //-- For time output for each slice
   slice->startProcessingTimer();
 
-#if CNN_FILTERING
-  auto startTime = std::chrono::steady_clock::now();
-#endif
-  
   const SPS*     sps          = slice->getSPS();
   Picture*       pic          = slice->getPic();
   CABACReader&   cabacReader  = *m_CABACDecoder->getCABACReader( 0 );
@@ -110,9 +102,11 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb
     cs.picture->resizeAlfCtbFilterIndex(cs.pcv->sizeInCtus);
     cs.picture->resizeAlfCtuAlternative( cs.pcv->sizeInCtus );
   }
-#if CNN_FILTERING
-  cs.picture->resizeCnnlfParamIdx( cs.pcv->sizeInCnnlfInferSize );
+
+#if NN_FILTERING_SET_1
+  cs.picture->resizeNnlfSet1ParamIdx( cs.pcv->sizeInNnlfSet1InferSize );
 #endif
+  
   const unsigned numSubstreams = slice->getNumberOfSubstreamSizes() + 1;
 
   // init each couple {EntropyDecoder, Substream}
@@ -304,13 +298,7 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb
   {
     delete substr;
   }
-#if CNN_FILTERING
-  auto endTime = std::chrono::steady_clock::now();
-  auto encTime = std::chrono::duration_cast<std::chrono::milliseconds>( endTime - startTime).count();
-  slice->stopProcessingTimer(encTime/1000.0);
-#else
   slice->stopProcessingTimer();
-#endif
 }
 
 //! \}
diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index 77dcd22ae4..d8fb951d63 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -1717,7 +1717,20 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
     pcSPS->derivedChromaQPMappingTables();
   }
 
-
+#if NN_FILTERING_SET_1
+  READ_FLAG( uiCode, "sps_nnlf_set1_enabled_flag" );                    pcSPS->setNnlfSet1EnabledFlag ( uiCode ? true : false );
+  if (pcSPS->getNnlfSet1EnabledFlag())
+  {
+    READ_UVLC( uiCode, "sps_nnlf_set1_infer_size_base" );
+    unsigned nnlfSet1InferSize[] = {uiCode >> 1, uiCode, uiCode << 1};
+    pcSPS->setNnlfSet1InferSize (nnlfSet1InferSize );
+    READ_UVLC( uiCode, "sps_nnlf_set1_infer_size_extension" );
+    pcSPS->setNnlfSet1InferSizeExtension ( uiCode );
+    READ_UVLC( uiCode, "sps_nnlf_set1_max_num_params" );
+    pcSPS->setNnlfSet1MaxNumParams (uiCode );
+  }
+#endif
+  
   READ_FLAG( uiCode, "sps_sao_enabled_flag" );                      pcSPS->setSAOEnabledFlag ( uiCode ? true : false );
   READ_FLAG( uiCode, "sps_alf_enabled_flag" );                      pcSPS->setALFEnabledFlag ( uiCode ? true : false );
   if (pcSPS->getALFEnabledFlag() && pcSPS->getChromaFormatIdc() != CHROMA_400)
@@ -1728,20 +1741,6 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
   {
     pcSPS->setCCALFEnabledFlag(false);
   }
-  
-#if CNN_FILTERING
-  READ_FLAG( uiCode, "sps_cnnlf_enabled_flag" );                    pcSPS->setCnnlfEnabledFlag ( uiCode ? true : false );
-  if (pcSPS->getCnnlfEnabledFlag())
-  {
-    READ_UVLC( uiCode, "sps_cnnlf_infer_size_base" );
-    unsigned cnnlfInferSize[] = {uiCode >> 1, uiCode, uiCode << 1};
-    pcSPS->setCnnlfInferSize (cnnlfInferSize );
-    READ_UVLC( uiCode, "sps_cnnlf_infer_size_extension" );
-    pcSPS->setCnnlfInferSizeExtension ( uiCode );
-    READ_UVLC( uiCode, "sps_cnnlf_max_num_params" );
-    pcSPS->setCnnlfMaxNumParams (uiCode );
-  }
-#endif
 
   READ_FLAG(uiCode, "sps_lmcs_enable_flag");                   pcSPS->setUseLmcs(uiCode == 1);
 
@@ -4175,25 +4174,25 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par
     {
       pcSlice->setUseChromaQpAdj(false);
     }
-
-#if CNN_FILTERING
-    if (sps->getCnnlfEnabledFlag())
+  
+#if NN_FILTERING_SET_1
+    if (sps->getNnlfSet1EnabledFlag())
     {
-      READ_UVLC(uiCode, "slice_luma_cnnlf_mode");  pcSlice->setCnnlfMode(CHANNEL_TYPE_LUMA, uiCode);
-      READ_UVLC(uiCode, "slice_chroma_cnnlf_mode");  pcSlice->setCnnlfMode(CHANNEL_TYPE_CHROMA, uiCode);
+      READ_UVLC(uiCode, "slice_luma_nnlf_set1_mode");  pcSlice->setNnlfSet1Mode(CHANNEL_TYPE_LUMA, uiCode);
+      READ_UVLC(uiCode, "slice_chroma_nnlf_set1_mode");  pcSlice->setNnlfSet1Mode(CHANNEL_TYPE_CHROMA, uiCode);
 
 #if SCALE_NN_RESIDUE
       for (int chal = 0; chal < MAX_NUM_CHANNEL_TYPE; chal++)
       {
         ChannelType chType = ChannelType(chal);
-        if (pcSlice->getCnnlfMode(chType))
+        if (pcSlice->getNnlfSet1Mode(chType))
         {
-          int numParams = sps->getCnnlfMaxNumParams();
-          if (pcSlice->getCnnlfMode(chType) == numParams + 1)
+          int numParams = sps->getNnlfSet1MaxNumParams();
+          if (pcSlice->getNnlfSet1Mode(chType) == numParams + 1)
           {
             for (int paramIdx = 0; paramIdx < numParams; paramIdx++)
             {
-              READ_FLAG(uiCode, "slice_cnnlf_scale_flag");
+              READ_FLAG(uiCode, "slice_nnlf_set1_scale_flag");
               pcSlice->setNnScaleFlag(uiCode != 0, paramIdx, chType);
               if (uiCode)
               {
@@ -4204,45 +4203,45 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par
           }
           else
           {
-            READ_FLAG(uiCode, "slice_cnnlf_scale_flag");
-            pcSlice->setNnScaleFlag(uiCode != 0, pcSlice->getCnnlfMode(chType) - 1, chType);
+            READ_FLAG(uiCode, "slice_nnlf_set1_scale_flag");
+            pcSlice->setNnScaleFlag(uiCode != 0, pcSlice->getNnlfSet1Mode(chType) - 1, chType);
             if (uiCode)
             {
               READ_SCODE(NN_RESIDUE_SCALE_SHIFT + 1, iCode, "nnScale");
-              pcSlice->setNnScale(iCode + (1 << NN_RESIDUE_SCALE_SHIFT), pcSlice->getCnnlfMode(chType) - 1, chType);
+              pcSlice->setNnScale(iCode + (1 << NN_RESIDUE_SCALE_SHIFT), pcSlice->getNnlfSet1Mode(chType) - 1, chType);
             }
           }
         }
       }
 #endif
       
-      CnnlfInferGranularity cnnlfInferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
-      CnnlfInferGranularity cnnlfInferGranularityChroma = CNNLF_INFER_GRANULARITY_BASE;
+      NnlfSet1InferGranularity nnlfSet1InferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
+      NnlfSet1InferGranularity nnlfSet1InferGranularityChroma = CNNLF_INFER_GRANULARITY_BASE;
       if (pcSlice ->getSliceType() == I_SLICE)
       {
-        cnnlfInferGranularityLuma = CNNLF_INFER_GRANULARITY_LARGE;
-        cnnlfInferGranularityChroma = CNNLF_INFER_GRANULARITY_LARGE;
+        nnlfSet1InferGranularityLuma = CNNLF_INFER_GRANULARITY_LARGE;
+        nnlfSet1InferGranularityChroma = CNNLF_INFER_GRANULARITY_LARGE;
       }
       else if (pcSlice->getSliceQp() < 23)
       {
-        cnnlfInferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
-        cnnlfInferGranularityChroma = CNNLF_INFER_GRANULARITY_BASE;
+        nnlfSet1InferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
+        nnlfSet1InferGranularityChroma = CNNLF_INFER_GRANULARITY_BASE;
       }
       else if (pcSlice->getSliceQp() < 29)
       {
-        cnnlfInferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
-        cnnlfInferGranularityChroma = CNNLF_INFER_GRANULARITY_LARGE;
+        nnlfSet1InferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
+        nnlfSet1InferGranularityChroma = CNNLF_INFER_GRANULARITY_LARGE;
       }
       else
       {
-        cnnlfInferGranularityLuma = pps->getPicWidthInLumaSamples() <=832 ? CNNLF_INFER_GRANULARITY_BASE : CNNLF_INFER_GRANULARITY_LARGE;
-        cnnlfInferGranularityChroma = CNNLF_INFER_GRANULARITY_LARGE;
+        nnlfSet1InferGranularityLuma = pps->getPicWidthInLumaSamples() <=832 ? CNNLF_INFER_GRANULARITY_BASE : CNNLF_INFER_GRANULARITY_LARGE;
+        nnlfSet1InferGranularityChroma = CNNLF_INFER_GRANULARITY_LARGE;
       }
-      pcSlice->setCnnlfInferGranularity(CHANNEL_TYPE_LUMA, cnnlfInferGranularityLuma);
-      pcSlice->setCnnlfInferGranularity(CHANNEL_TYPE_CHROMA, cnnlfInferGranularityChroma);
+      pcSlice->setNnlfSet1InferGranularity(CHANNEL_TYPE_LUMA, nnlfSet1InferGranularityLuma);
+      pcSlice->setNnlfSet1InferGranularity(CHANNEL_TYPE_CHROMA, nnlfSet1InferGranularityChroma);
     }
 #endif
-  
+
     if (sps->getSAOEnabledFlag() && !pps->getSaoInfoInPhFlag())
     {
       READ_FLAG(uiCode, "sh_sao_luma_used_flag");  pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (bool)uiCode);
diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp
index b72a82fb49..8b3977a11e 100644
--- a/source/Lib/EncoderLib/CABACWriter.cpp
+++ b/source/Lib/EncoderLib/CABACWriter.cpp
@@ -166,15 +166,15 @@ void CABACWriter::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i
   {
     sao( *cs.slice, ctuRsAddr );
   }
-#if CNN_FILTERING
-  if (cs.sps->getCnnlfEnabledFlag() && !skipSao && ctuRsAddr == 0)
+#if NN_FILTERING_SET_1
+  if (cs.sps->getNnlfSet1EnabledFlag() && !skipSao && ctuRsAddr == 0)
   {
-    int numParams = cs.sps->getCnnlfMaxNumParams();
+    int numParams = cs.sps->getNnlfSet1MaxNumParams();
     for (int chal = 0; chal < MAX_NUM_CHANNEL_TYPE; chal++)
     {
-      if (cs.slice->getCnnlfMode(ChannelType(chal)) < (numParams + 1))
+      if (cs.slice->getNnlfSet1Mode(ChannelType(chal)) < (numParams + 1))
         continue;
-      codeCnnlfParamIdx(cs, ChannelType(chal));
+      codeNnlfSet1ParamIdx(cs, ChannelType(chal));
     }
   }
 #endif
@@ -3245,36 +3245,38 @@ void CABACWriter::exp_golomb_eqprob( unsigned symbol, unsigned count )
   m_BinEncoder.encodeBinsEP(bins, numBins);
   m_BinEncoder.encodeBinsEP(symbol, count);
 }
-#if CNN_FILTERING
-void CABACWriter::codeCnnlfParamIdx( CodingStructure& cs, ChannelType chType)
+
+#if NN_FILTERING_SET_1
+void CABACWriter::codeNnlfSet1ParamIdx( CodingStructure& cs, ChannelType chType)
 {
-  CnnlfInferGranularity cnnlfInferGranularity = cs.slice->getCnnlfInferGranularity(chType);
-  for( int unitIdx = 0; unitIdx < cs.pcv->sizeInCnnlfInferSize[cnnlfInferGranularity]; unitIdx++ )
+  NnlfSet1InferGranularity nnlfSet1InferGranularity = cs.slice->getNnlfSet1InferGranularity(chType);
+  for( int unitIdx = 0; unitIdx < cs.pcv->sizeInNnlfSet1InferSize[nnlfSet1InferGranularity]; unitIdx++ )
   {
-    codeCnnlfParamIdx( cs, unitIdx, chType );
+    codeNnlfSet1ParamIdx( cs, unitIdx, chType );
   }
 }
 
-void CABACWriter::codeCnnlfParamIdx( CodingStructure& cs, uint32_t unitRsAddr, const int chal)
+void CABACWriter::codeNnlfSet1ParamIdx( CodingStructure& cs, uint32_t unitRsAddr, const int chal)
 {
-  CnnlfInferGranularity cnnlfInferGranularity = cs.slice->getCnnlfInferGranularity(ChannelType(chal));
-  uint8_t* cnnlfParamIdx = cs.slice->getPic()->getCnnlfParamIdx( cnnlfInferGranularity, chal );
-  uint8_t uiCode = cnnlfParamIdx[unitRsAddr];
-  uint8_t cnnlfMaxNumParams = cs.sps->getCnnlfMaxNumParams();
+  NnlfSet1InferGranularity nnlfSet1InferGranularity = cs.slice->getNnlfSet1InferGranularity(ChannelType(chal));
+  uint8_t* nnlfSet1ParamIdx = cs.slice->getPic()->getNnlfSet1ParamIdx( nnlfSet1InferGranularity, chal );
+  uint8_t uiCode = nnlfSet1ParamIdx[unitRsAddr];
+  uint8_t nnlfSet1MaxNumParams = cs.sps->getNnlfSet1MaxNumParams();
 
-  m_BinEncoder.encodeBin( uiCode > 0, Ctx::cnnlfParamIdx( chal * 2 + 0 ) );
+  m_BinEncoder.encodeBin( uiCode > 0, Ctx::nnlfSet1ParamIdx( chal * 2 + 0 ) );
   
-  if (cnnlfMaxNumParams > 1 && uiCode > 0)
+  if (nnlfSet1MaxNumParams > 1 && uiCode > 0)
   {
-    m_BinEncoder.encodeBin( uiCode == 1, Ctx::cnnlfParamIdx( chal * 2 + 1 ) );
+    m_BinEncoder.encodeBin( uiCode == 1, Ctx::nnlfSet1ParamIdx( chal * 2 + 1 ) );
   }
-  if (cnnlfMaxNumParams > 2 && uiCode > 1)
+  if (nnlfSet1MaxNumParams > 2 && uiCode > 1)
   {
-    xWriteTruncBinCode(uiCode - 2, cnnlfMaxNumParams - 1);
+    xWriteTruncBinCode(uiCode - 2, nnlfSet1MaxNumParams - 1);
   }
 
 }
 #endif
+
 void CABACWriter::codeAlfCtuEnableFlags( CodingStructure& cs, ChannelType channel, AlfParam* alfParam)
 {
   if( isLuma( channel ) )
diff --git a/source/Lib/EncoderLib/CABACWriter.h b/source/Lib/EncoderLib/CABACWriter.h
index 5a078c017a..5a45752317 100644
--- a/source/Lib/EncoderLib/CABACWriter.h
+++ b/source/Lib/EncoderLib/CABACWriter.h
@@ -164,9 +164,9 @@ public:
   void codeCcAlfFilterControlIdc(uint8_t idcVal, CodingStructure &cs, const ComponentID compID, const int curIdx,
                                  const uint8_t *filterControlIdc, Position lumaPos, const int filterCount);
 
-#if CNN_FILTERING
-  void        codeCnnlfParamIdx         ( CodingStructure& cs, ChannelType chType);
-  void        codeCnnlfParamIdx         ( CodingStructure& cs, uint32_t ctuRsAddr, const int chal );
+#if NN_FILTERING_SET_1
+  void        codeNnlfSet1ParamIdx         ( CodingStructure& cs, ChannelType chType);
+  void        codeNnlfSet1ParamIdx         ( CodingStructure& cs, uint32_t ctuRsAddr, const int chal );
 #endif
   
 private:
diff --git a/source/Lib/EncoderLib/EncCNNFilter.h b/source/Lib/EncoderLib/EncCNNFilter.h
deleted file mode 100644
index 9804c428ce..0000000000
--- a/source/Lib/EncoderLib/EncCNNFilter.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/** \file     EncCNNFilter.h
-    \brief    encoder convolutional neural network-based filter class (header)
-*/
-
-#ifndef __ENCCNNFILTER__
-#define __ENCCNNFILTER__
-
-#include "CommonDef.h"
-#include "Unit.h"
-#include "Picture.h"
-#include "Reshape.h"
-#include "CABACWriter.h"
-#include "CommonLib/CNNFilter.h"
-//! \ingroup CommonLib
-//! \{
-
-
-class EncCNNFilter : public CNNFilter
-{
-public:
-  EncCNNFilter();
-  virtual ~EncCNNFilter();
-  
-  //for RDO
-  CABACWriter*           m_CABACEstimator;
-  CtxCache*              m_CtxCache;
-  double                 m_lambda[MAX_NUM_COMPONENT];
-  bool                   m_singleModelISlice;
-
-  void                   initCABACEstimator( CABACEncoder* cabacEncoder, CtxCache* ctxCache, Slice* pcSlice );
-
-#if SCALE_NN_RESIDUE
-  void                   scaleFactorDerivation(Picture *pic, int paramIdx);
-  void                   scalePicture(Picture* pic, int numParams);
-#endif
-  void                   cnnFilterEncoder(Picture *pic, const double *lambdas);
-  void                   cnnFilterPicture(Picture* pic, int numParams);
-#if SCALE_NN_RESIDUE
-  void                   calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, int numParams, double* minCost, bool scaled);
-#else
-  void                   calcRDCost(Picture *pic,std::vector<PelStorage>& tempBuf, int numParams, double* minCost)
-#endif
-};
-
-//! \}
-#endif
-
diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h
index 7134aeed9f..b2064197bd 100644
--- a/source/Lib/EncoderLib/EncCfg.h
+++ b/source/Lib/EncoderLib/EncCfg.h
@@ -158,11 +158,11 @@ class EncCfg
 {
 protected:
   //==== File I/O ========
-#if CNN_FILTERING
-  std::string m_cnnlfInterLumaModelName;                      ///<inter luma cnnlf model
-  std::string m_cnnlfInterChromaModelName;                    ///<inter chroma cnnlf model
-  std::string m_cnnlfIntraLumaModelName;                      ///<intra luma cnnlf model
-  std::string m_cnnlfIntraChromaModelName;                    ///<inra chroma cnnlf model
+#if NN_FILTERING_SET_1
+  std::string m_nnlfSet1InterLumaModelName;                      ///<inter luma nnlf set1 model
+  std::string m_nnlfSet1InterChromaModelName;                    ///<inter chroma nnlf set1 model
+  std::string m_nnlfSet1IntraLumaModelName;                      ///<intra luma nnlf set1 model
+  std::string m_nnlfSet1IntraChromaModelName;                    ///<inra chroma nnlf set1 model
 #endif
   int       m_iFrameRate;
   int       m_FrameSkip;
@@ -751,11 +751,11 @@ protected:
 #endif
   bool        m_ccalf;
   int         m_ccalfQpThreshold;
-#if CNN_FILTERING
-  bool        m_cnnlf;
-  unsigned    m_cnnlfInferSizeBase;
-  unsigned    m_cnnlfInferSizeExtension;
-  unsigned    m_cnnlfMaxNumParams;
+#if NN_FILTERING_SET_1
+  bool        m_nnlfSet1;
+  unsigned    m_nnlfSet1InferSizeBase;
+  unsigned    m_nnlfSet1InferSizeExtension;
+  unsigned    m_nnlfSet1MaxNumParams;
 #endif
 #if JVET_O0756_CALCULATE_HDRMETRICS
   double                       m_whitePointDeltaE[hdrtoolslib::NB_REF_WHITE];
@@ -788,16 +788,17 @@ public:
   virtual ~EncCfg()
   {}
 
-#if CNN_FILTERING
-  std::string      getCnnlfInterLumaModelName()                { return m_cnnlfInterLumaModelName;   }
-  std::string      getCnnlfInterChromaModelName()              { return m_cnnlfInterChromaModelName; }
-  std::string      getCnnlfIntraLumaModelName()                { return m_cnnlfIntraLumaModelName;   }
-  std::string      getCnnlfIntraChromaModelName()              { return m_cnnlfIntraChromaModelName; }
-  void             setCnnlfInterLumaModelName(std::string s)   { m_cnnlfInterLumaModelName = s;      }
-  void             setCnnlfInterChromaModelName(std::string s) { m_cnnlfInterChromaModelName = s;    }
-  void             setCnnlfIntraLumaModelName(std::string s)   { m_cnnlfIntraLumaModelName = s;      }
-  void             setCnnlfIntraChromaModelName(std::string s) { m_cnnlfIntraChromaModelName = s;    }
+#if NN_FILTERING_SET_1
+  std::string      getNnlfSet1InterLumaModelName()                { return m_nnlfSet1InterLumaModelName;   }
+  std::string      getNnlfSet1InterChromaModelName()              { return m_nnlfSet1InterChromaModelName; }
+  std::string      getNnlfSet1IntraLumaModelName()                { return m_nnlfSet1IntraLumaModelName;   }
+  std::string      getNnlfSet1IntraChromaModelName()              { return m_nnlfSet1IntraChromaModelName; }
+  void             setNnlfSet1InterLumaModelName(std::string s)   { m_nnlfSet1InterLumaModelName = s;      }
+  void             setNnlfSet1InterChromaModelName(std::string s) { m_nnlfSet1InterChromaModelName = s;    }
+  void             setNnlfSet1IntraLumaModelName(std::string s)   { m_nnlfSet1IntraLumaModelName = s;      }
+  void             setNnlfSet1IntraChromaModelName(std::string s) { m_nnlfSet1IntraChromaModelName = s;    }
 #endif
+  
   void setProfile(Profile::Name profile) { m_profile = profile; }
   void setLevel(Level::Tier tier, Level::Name level) { m_levelTier = tier; m_level = level; }
   bool      getFrameOnlyConstraintFlag() const { return m_frameOnlyConstraintFlag; }
@@ -1962,15 +1963,15 @@ public:
   bool         getUseCCALF()                                    const { return m_ccalf; }
   void         setCCALFQpThreshold( int b )                           { m_ccalfQpThreshold = b; }
   int          getCCALFQpThreshold()                            const { return m_ccalfQpThreshold; }
-#if CNN_FILTERING
-  void         setUseCnnlf( bool b )                                  { m_cnnlf = b; }
-  bool         getUseCnnlf()                                    const { return m_cnnlf; }
-  void         setCnnlfInferSizeBase( unsigned s )                    { m_cnnlfInferSizeBase = s; }
-  unsigned     getCnnlfInferSizeBase()                          const { return m_cnnlfInferSizeBase; }
-  void         setCnnlfInferSizeExtension( unsigned s )               { m_cnnlfInferSizeExtension = s; }
-  unsigned     getCnnlfInferSizeExtension()                     const { return m_cnnlfInferSizeExtension; }
-  void         setCnnlfMaxNumParams( unsigned s )                     { m_cnnlfMaxNumParams = s; }
-  unsigned     getCnnlfMaxNumParams()                           const { return m_cnnlfMaxNumParams; }
+#if NN_FILTERING_SET_1
+  void         setUseNnlfSet1( bool b )                               { m_nnlfSet1 = b; }
+  bool         getUseNnlfSet1()                                 const { return m_nnlfSet1; }
+  void         setNnlfSet1InferSizeBase( unsigned s )                 { m_nnlfSet1InferSizeBase = s; }
+  unsigned     getNnlfSet1InferSizeBase()                       const { return m_nnlfSet1InferSizeBase; }
+  void         setNnlfSet1InferSizeExtension( unsigned s )            { m_nnlfSet1InferSizeExtension = s; }
+  unsigned     getNnlfSet1InferSizeExtension()                  const { return m_nnlfSet1InferSizeExtension; }
+  void         setNnlfSet1MaxNumParams( unsigned s )                  { m_nnlfSet1MaxNumParams = s; }
+  unsigned     getNnlfSet1MaxNumParams()                        const { return m_nnlfSet1MaxNumParams; }
 #endif
 #if JVET_O0756_CALCULATE_HDRMETRICS
   void        setWhitePointDeltaE( uint32_t index, double value )     { m_whitePointDeltaE[ index ] = value; }
diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp
index 75654047f4..4864b40f27 100644
--- a/source/Lib/EncoderLib/EncGOP.cpp
+++ b/source/Lib/EncoderLib/EncGOP.cpp
@@ -178,8 +178,8 @@ void  EncGOP::create()
 {
   m_bLongtermTestPictureHasBeenCoded = 0;
   m_bLongtermTestPictureHasBeenCoded2 = 0;
-#if CNN_FILTERING
-  m_pcCNNFilter =  new EncCNNFilter;
+#if NN_FILTERING_SET_1
+  m_pcNNFilterSet1 =  new EncNNFilterSet1;
 #endif
 }
 
@@ -205,12 +205,12 @@ void  EncGOP::destroy()
     delete m_picOrig;
     m_picOrig = NULL;
   }
-#if CNN_FILTERING
-  if (m_pcCNNFilter)
+#if NN_FILTERING_SET_1
+  if (m_pcNNFilterSet1)
   {
-    m_pcCNNFilter->destroy();
-    delete m_pcCNNFilter;
-    m_pcCNNFilter = NULL;
+    m_pcNNFilterSet1->destroy();
+    delete m_pcNNFilterSet1;
+    m_pcNNFilterSet1 = NULL;
   }
 #endif
 }
@@ -232,11 +232,11 @@ void EncGOP::init ( EncLib* pcEncLib )
   m_HRD                = pcEncLib->getHRD();
 
   m_AUWriterIf = pcEncLib->getAUWriterIf();
-
-#if CNN_FILTERING
-  m_pcCNNFilter->create(m_pcCfg->getSourceWidth(), m_pcCfg->getSourceHeight(), m_pcCfg->getChromaFormatIdc(), m_pcCfg->getCnnlfMaxNumParams());
-#endif
   
+#if NN_FILTERING_SET_1
+  m_pcNNFilterSet1->create(m_pcCfg->getSourceWidth(), m_pcCfg->getSourceHeight(), m_pcCfg->getChromaFormatIdc(), m_pcCfg->getNnlfSet1MaxNumParams());
+#endif
+
 #if WCG_EXT
   if (m_pcCfg->getLmcs())
   {
@@ -2759,8 +2759,8 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
       pcPic->resizeAlfCtbFilterIndex(numberOfCtusInFrame);
     }
 
-#if CNN_FILTERING
-    pcPic->resizeCnnlfParamIdx( pcPic->cs->pcv->sizeInCnnlfInferSize );
+#if NN_FILTERING_SET_1
+    pcPic->resizeNnlfSet1ParamIdx( pcPic->cs->pcv->sizeInNnlfSet1InferSize );
 #endif
     
     bool decPic = false;
@@ -3041,6 +3041,22 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
 
       CS::setRefinedMotionField(cs);
       
+#if COMBINE_NN_WITH_LF && !FUSE_NN_AND_LF
+      if ( cs.sps->getNnlfSet1EnabledFlag() )
+      {
+        pcPic->getRecoBuf().copyFrom(pcPic->getRecBeforeDbfBuf());
+      }
+#endif
+      
+#if NN_FILTERING_SET_1
+      if ( cs.sps->getNnlfSet1EnabledFlag() )
+      {
+        m_pcNNFilterSet1->init(m_pcEncLib->getNnlfSet1InterLumaModelName(), m_pcEncLib->getNnlfSet1InterChromaModelName(), m_pcEncLib->getNnlfSet1IntraLumaModelName(), m_pcEncLib->getNnlfSet1IntraChromaModelName());
+        m_pcNNFilterSet1->initCABACEstimator( m_pcEncLib->getCABACEncoder(), m_pcEncLib->getCtxCache(), pcSlice );
+        m_pcNNFilterSet1->cnnFilterEncoder(pcPic, pcSlice->getLambdas());
+      }
+#endif
+
       if( pcSlice->getSPS()->getSAOEnabledFlag() )
       {
         bool sliceEnabled[MAX_NUM_COMPONENT];
@@ -3071,22 +3087,6 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
         }
       }
       
-#if COMBINE_NN_WITH_LF && !FUSE_NN_AND_LF
-      if ( cs.sps->getCnnlfEnabledFlag() )
-      {
-        pcPic->getRecoBuf().copyFrom(pcPic->getUnfilteredRecBuf());
-      }
-#endif
-      
-#if CNN_FILTERING
-      if ( cs.sps->getCnnlfEnabledFlag() )
-      {
-        m_pcCNNFilter->init(m_pcEncLib->getCnnlfInterLumaModelName(), m_pcEncLib->getCnnlfInterChromaModelName(), m_pcEncLib->getCnnlfIntraLumaModelName(), m_pcEncLib->getCnnlfIntraChromaModelName());
-        m_pcCNNFilter->initCABACEstimator( m_pcEncLib->getCABACEncoder(), m_pcEncLib->getCtxCache(), pcSlice );
-        m_pcCNNFilter->cnnFilterEncoder(pcPic, pcSlice->getLambdas());
-      }
-#endif
-
       if( pcSlice->getSPS()->getALFEnabledFlag() )
       {
         m_pcALF->destroy();
diff --git a/source/Lib/EncoderLib/EncGOP.h b/source/Lib/EncoderLib/EncGOP.h
index 43c87bf25e..16f562712e 100644
--- a/source/Lib/EncoderLib/EncGOP.h
+++ b/source/Lib/EncoderLib/EncGOP.h
@@ -71,8 +71,8 @@
 #include <chrono>
 #endif
 
-#if CNN_FILTERING
-#include "EncoderLib/EncCNNFilter.h"
+#if NN_FILTERING_SET_1
+#include "EncoderLib/EncNNFilterSet1.h"
 #endif
 
 //! \ingroup EncoderLib
@@ -139,11 +139,11 @@ private:
   EncCfg*                 m_pcCfg;
   EncSlice*               m_pcSliceEncoder;
   PicList*                m_pcListPic;
-
-#if CNN_FILTERING
-  EncCNNFilter*           m_pcCNNFilter;
-#endif
   
+#if NN_FILTERING_SET_1
+  EncNNFilterSet1*        m_pcNNFilterSet1;
+#endif
+
   HLSWriter*              m_HLSWriter;
   LoopFilter*             m_pcLoopFilter;
 
diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp
index c6bf1b5afb..9065d7a0c7 100644
--- a/source/Lib/EncoderLib/EncLib.cpp
+++ b/source/Lib/EncoderLib/EncLib.cpp
@@ -1293,7 +1293,7 @@ void EncLib::xInitSPS( SPS& sps )
   sps.setMaxCUHeight            ( m_maxCUHeight       );
   sps.setLog2MinCodingBlockSize ( m_log2MinCUSize );
   sps.setChromaFormatIdc        ( m_chromaFormatIDC   );
-  
+
   sps.setCTUSize                             ( m_CTUSize );
   sps.setSplitConsOverrideEnabledFlag        ( m_useSplitConsOverride );
   sps.setMinQTSizes                          ( m_uiMinQT );
@@ -1413,20 +1413,20 @@ void EncLib::xInitSPS( SPS& sps )
   sps.setFieldSeqFlag(false);
   sps.setVuiParametersPresentFlag(getVuiParametersPresentFlag());
   
-#if CNN_FILTERING
-  sps.setCnnlfEnabledFlag(m_cnnlf);
-  if (sps.getCnnlfEnabledFlag())
+#if NN_FILTERING_SET_1
+  sps.setNnlfSet1EnabledFlag(m_nnlfSet1);
+  if (sps.getNnlfSet1EnabledFlag())
   {
-    unsigned cnnlfInferSize[] = {m_cnnlfInferSizeBase >> 1, m_cnnlfInferSizeBase, m_cnnlfInferSizeBase << 1};
-    sps.setCnnlfInferSize(cnnlfInferSize);
-    sps.setCnnlfInferSizeExtension(m_cnnlfInferSizeExtension);
+    unsigned nnlfSet1InferSize[] = {m_nnlfSet1InferSizeBase >> 1, m_nnlfSet1InferSizeBase, m_nnlfSet1InferSizeBase << 1};
+    sps.setNnlfSet1InferSize(nnlfSet1InferSize);
+    sps.setNnlfSet1InferSizeExtension(m_nnlfSet1InferSizeExtension);
     if (m_intraPeriod == 1)
     {
-      sps.setCnnlfMaxNumParams(1); // to be removed
+      sps.setNnlfSet1MaxNumParams(1); // to be removed
     }
     else
     {
-      sps.setCnnlfMaxNumParams(m_cnnlfMaxNumParams);
+      sps.setNnlfSet1MaxNumParams(m_nnlfSet1MaxNumParams);
     }
   }
 #endif
diff --git a/source/Lib/EncoderLib/EncCNNFilter.cpp b/source/Lib/EncoderLib/EncNNFilterSet1.cpp
similarity index 63%
rename from source/Lib/EncoderLib/EncCNNFilter.cpp
rename to source/Lib/EncoderLib/EncNNFilterSet1.cpp
index 5373d7c16b..d335c6cbc4 100644
--- a/source/Lib/EncoderLib/EncCNNFilter.cpp
+++ b/source/Lib/EncoderLib/EncNNFilterSet1.cpp
@@ -1,9 +1,42 @@
-/** \file     EncCNNFilter.cpp
-    \brief    encoder convolutional neural network-based filter class
+/* The copyright in this software is being made available under the BSD
+* License, included below. This software may be subject to other third party
+* and contributor rights, including patent rights, and no such rights are
+* granted under this license.
+*
+* Copyright (c) 2010-2020, ITU/ISO/IEC
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+*  * Redistributions of source code must retain the above copyright notice,
+*    this list of conditions and the following disclaimer.
+*  * Redistributions in binary form must reproduce the above copyright notice,
+*    this list of conditions and the following disclaimer in the documentation
+*    and/or other materials provided with the distribution.
+*  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
+*    be used to endorse or promote products derived from this software without
+*    specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "EncCNNFilter.h"
-#if CNN_FILTERING
+/** \file     EncNNFilterSet1.cpp
+    \brief    encoder  neural network-based filter set1 class
+*/
+
+#include "EncNNFilterSet1.h"
+#if NN_FILTERING_SET_1
 #include "UnitTools.h"
 #include "UnitPartitioner.h"
 #include "CodingStructure.h"
@@ -20,18 +53,18 @@
 //! \ingroup CommonLib
 //! \{
 
-#define CNNLFCtx(c) SubCtx( Ctx::cnnlfParamIdx, c )
+#define CNNLFCtx(c) SubCtx( Ctx::nnlfSet1ParamIdx, c )
 
-EncCNNFilter::EncCNNFilter()
+EncNNFilterSet1::EncNNFilterSet1()
 {
   m_CABACEstimator = NULL;
   m_singleModelISlice = false;
 }
 
-EncCNNFilter::~EncCNNFilter()
+EncNNFilterSet1::~EncNNFilterSet1()
 {
 }
-void EncCNNFilter::initCABACEstimator( CABACEncoder* cabacEncoder, CtxCache* ctxCache, Slice* pcSlice )
+void EncNNFilterSet1::initCABACEstimator( CABACEncoder* cabacEncoder, CtxCache* ctxCache, Slice* pcSlice )
 {
   m_CABACEstimator = cabacEncoder->getCABACEstimator( pcSlice->getSPS() );
   m_CtxCache       = ctxCache;
@@ -56,54 +89,54 @@ double getDistortion(PelBuf buf1, PelBuf buf2, int width, int height)
   }
   return dist;
 }
-void setCnnlfInferGranularity(Picture* pic)
+void setNnlfSet1InferGranularity(Picture* pic)
 {
   Slice* pcSlice                  = pic->cs->slice;
-  CnnlfInferGranularity cnnlfInferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
-  CnnlfInferGranularity cnnlfInferGranularityChroma = CNNLF_INFER_GRANULARITY_BASE;
+  NnlfSet1InferGranularity nnlfSet1InferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
+  NnlfSet1InferGranularity nnlfSet1InferGranularityChroma = CNNLF_INFER_GRANULARITY_BASE;
   if (pcSlice ->getSliceType() == I_SLICE)
   {
-    pcSlice->setCnnlfInferGranularity(CHANNEL_TYPE_LUMA, CNNLF_INFER_GRANULARITY_LARGE);
-    pcSlice->setCnnlfInferGranularity(CHANNEL_TYPE_CHROMA, CNNLF_INFER_GRANULARITY_LARGE);
+    pcSlice->setNnlfSet1InferGranularity(CHANNEL_TYPE_LUMA, CNNLF_INFER_GRANULARITY_LARGE);
+    pcSlice->setNnlfSet1InferGranularity(CHANNEL_TYPE_CHROMA, CNNLF_INFER_GRANULARITY_LARGE);
     return;
   }
   if (pcSlice->getSliceQp() < 23)
   {
-    cnnlfInferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
-    cnnlfInferGranularityChroma = CNNLF_INFER_GRANULARITY_BASE;
+    nnlfSet1InferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
+    nnlfSet1InferGranularityChroma = CNNLF_INFER_GRANULARITY_BASE;
   }
   else if (pcSlice->getSliceQp() < 29)
   {
-    cnnlfInferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
-    cnnlfInferGranularityChroma = CNNLF_INFER_GRANULARITY_LARGE;
+    nnlfSet1InferGranularityLuma = CNNLF_INFER_GRANULARITY_BASE;
+    nnlfSet1InferGranularityChroma = CNNLF_INFER_GRANULARITY_LARGE;
   }
   else
   {
-    cnnlfInferGranularityLuma = pic->getPicWidthInLumaSamples() <=832 ? CNNLF_INFER_GRANULARITY_BASE : CNNLF_INFER_GRANULARITY_LARGE;
-    cnnlfInferGranularityChroma = CNNLF_INFER_GRANULARITY_LARGE;
+    nnlfSet1InferGranularityLuma = pic->getPicWidthInLumaSamples() <=832 ? CNNLF_INFER_GRANULARITY_BASE : CNNLF_INFER_GRANULARITY_LARGE;
+    nnlfSet1InferGranularityChroma = CNNLF_INFER_GRANULARITY_LARGE;
   }
-  pcSlice->setCnnlfInferGranularity(CHANNEL_TYPE_LUMA, cnnlfInferGranularityLuma);
-  pcSlice->setCnnlfInferGranularity(CHANNEL_TYPE_CHROMA, cnnlfInferGranularityChroma);
+  pcSlice->setNnlfSet1InferGranularity(CHANNEL_TYPE_LUMA, nnlfSet1InferGranularityLuma);
+  pcSlice->setNnlfSet1InferGranularity(CHANNEL_TYPE_CHROMA, nnlfSet1InferGranularityChroma);
 }
 
-void EncCNNFilter::cnnFilterPicture(Picture* pic, int numParams)
+void EncNNFilterSet1::cnnFilterPicture(Picture* pic, int numParams)
 {
   CodingStructure&  cs            = *pic->cs;
   Slice* pcSlice                  = cs.slice;
   const PreCalcValues& pcv        = *cs.pcv;
-  int extension = cs.sps->getCnnlfInferSizeExtension();
+  int extension = cs.sps->getNnlfSet1InferSizeExtension();
   const int  numValidChannels = getNumberValidChannels( cs.area.chromaFormat );
   for (int paramIdx = 0; paramIdx < numParams; paramIdx ++)
   {
     for( int chal = 0; chal < numValidChannels; chal++ )
     {
       const ChannelType chType = ChannelType( chal );
-      CnnlfInferGranularity cnnlfInferGranularity = pcSlice->getCnnlfInferGranularity(chType);
-      int blockSize = cs.sps->getCnnlfInferSize (cnnlfInferGranularity);
-      for( int blockIdx = 0; blockIdx < pcv.sizeInCnnlfInferSize[cnnlfInferGranularity]; blockIdx++ )
+      NnlfSet1InferGranularity nnlfSet1InferGranularity = pcSlice->getNnlfSet1InferGranularity(chType);
+      int blockSize = cs.sps->getNnlfSet1InferSize (nnlfSet1InferGranularity);
+      for( int blockIdx = 0; blockIdx < pcv.sizeInNnlfSet1InferSize[nnlfSet1InferGranularity]; blockIdx++ )
       {
-        int xPosInBlocks        = blockIdx % pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
-        int yPosInBlocks        = blockIdx / pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
+        int xPosInBlocks        = blockIdx % pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
+        int yPosInBlocks        = blockIdx / pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
         int xPos = xPosInBlocks * blockSize;
         int yPos = yPosInBlocks * blockSize;
         int width = (xPos + blockSize > pcv.lumaWidth) ? (pcv.lumaWidth - xPos) : blockSize;
@@ -124,7 +157,7 @@ void EncCNNFilter::cnnFilterPicture(Picture* pic, int numParams)
         if (chal == 0)
         {
 #if NN_FIXED_POINT_IMPLEMENTATION
-          cnnFilterLumaBlock<int16_t>(pic, extBlock, extLeft, extRight, extTop, extBottom, paramIdx, pcSlice->getSliceType() != I_SLICE);
+          cnnFilterLumaBlock<int16_t>(pic, extBlock, extLeft, extRight, extTop, extBottom, paramIdx, pcSlice->getSliceType() != I_SLICE); 
 #else
           cnnFilterLumaBlock<float>(pic, extBlock, extLeft, extRight, extTop, extBottom, paramIdx, pcSlice->getSliceType() != I_SLICE);
 #endif
@@ -142,9 +175,9 @@ void EncCNNFilter::cnnFilterPicture(Picture* pic, int numParams)
   }
 }
 #if SCALE_NN_RESIDUE
-void EncCNNFilter::calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, int numParams, double* minCost, bool scaled)
+void EncNNFilterSet1::calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, int numParams, double* minCost, bool scaled)
 #else
-void EncCNNFilter::calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, int numParams, double* minCost)
+void EncNNFilterSet1::calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, int numParams, double* minCost)
 #endif
 {
   CodingStructure&  cs            = *pic->cs;
@@ -154,9 +187,9 @@ void EncCNNFilter::calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, in
   for( int chal = 0; chal < numValidChannels; chal++ )
   {
     const ChannelType chType = ChannelType( chal );
-    CnnlfInferGranularity cnnlfInferGranularity = pcSlice->getCnnlfInferGranularity(chType);
-    int blockSize = cs.sps->getCnnlfInferSize (cnnlfInferGranularity);
-    std::vector<uint8_t>* cnnlfParamIdx = pic->getCnnlfParamIdx(cnnlfInferGranularity);
+    NnlfSet1InferGranularity nnlfSet1InferGranularity = pcSlice->getNnlfSet1InferGranularity(chType);
+    int blockSize = cs.sps->getNnlfSet1InferSize (nnlfSet1InferGranularity);
+    std::vector<uint8_t>* nnlfSet1ParamIdx = pic->getNnlfSet1ParamIdx(nnlfSet1InferGranularity);
     
     int64_t distSliceLevelOff = 0, distCtuLevelOn = 0, distSliceLevelOn[numParams];
     for (int paramIdx = 0; paramIdx < numParams; paramIdx ++)
@@ -165,10 +198,10 @@ void EncCNNFilter::calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, in
     }
     
     // calculate distortion
-    for( int blockIdx = 0; blockIdx < pcv.sizeInCnnlfInferSize[cnnlfInferGranularity]; blockIdx++ )
+    for( int blockIdx = 0; blockIdx < pcv.sizeInNnlfSet1InferSize[nnlfSet1InferGranularity]; blockIdx++ )
     {
-      int xPosInBlocks        = blockIdx % pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
-      int yPosInBlocks        = blockIdx / pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
+      int xPosInBlocks        = blockIdx % pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
+      int yPosInBlocks        = blockIdx / pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
       int xPos = xPosInBlocks * blockSize;
       int yPos = yPosInBlocks * blockSize;
       int width = (xPos + blockSize > pcv.lumaWidth) ? (pcv.lumaWidth - xPos) : blockSize;
@@ -176,20 +209,20 @@ void EncCNNFilter::calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, in
       
       const UnitArea block( cs.area.chromaFormat, Area( xPos, yPos, width, height ) );
 
-      // block distortion w/o cnnlf
+      // block distortion w/o nnlfSet1
       double distRec = chal == 0 ? getDistortion(pic->getOrigBuf(block).get(COMPONENT_Y), pic->getRecoBuf(block).get(COMPONENT_Y), width, height) : getDistortion(pic->getOrigBuf(block).get(COMPONENT_Cb), pic->getRecoBuf(block).get(COMPONENT_Cb), width >> 1, height >> 1) + getDistortion(pic->getOrigBuf(block).get(COMPONENT_Cr), pic->getRecoBuf(block).get(COMPONENT_Cr), width >> 1, height >> 1);
       
-      // slice distortion w/o cnnlf
+      // slice distortion w/o nnlfSet1
       distSliceLevelOff += distRec;
       
       double distBest = distRec;
       int paramIdxBest = -1;
       for (int paramIdx = 0; paramIdx < numParams; paramIdx ++)
       {
-        // block distortion w/ cnnlf paramIdx
+        // block distortion w/ nnlfSet1 paramIdx
         double distTemp = chal == 0 ? getDistortion(pic->getOrigBuf(block).get(COMPONENT_Y), tempBuf[paramIdx].getBuf(block).get(COMPONENT_Y), width, height) : getDistortion(pic->getOrigBuf(block).get(COMPONENT_Cb), tempBuf[paramIdx].getBuf(block).get(COMPONENT_Cb), width >> 1, height >> 1) + getDistortion(pic->getOrigBuf(block).get(COMPONENT_Cr), tempBuf[paramIdx].getBuf(block).get(COMPONENT_Cr), width >> 1, height >> 1);
         
-        // slice distortion w/ cnnlf paramIdx
+        // slice distortion w/ nnlfSet1 paramIdx
         distSliceLevelOn[paramIdx] += distTemp;
         
         // the best for the block
@@ -199,14 +232,14 @@ void EncCNNFilter::calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, in
       
       // the best for the slice
       distCtuLevelOn += distBest;
-      cnnlfParamIdx[chal][blockIdx] = paramIdxBest + 1;
+      nnlfSet1ParamIdx[chal][blockIdx] = paramIdxBest + 1;
     }
     
     // calculate RD cost
     const TempCtx  ctxStart ( m_CtxCache, CNNLFCtx( m_CABACEstimator->getCtx() ) );
     m_CABACEstimator->getCtx() = CNNLFCtx( ctxStart );
     m_CABACEstimator->resetBits();
-    m_CABACEstimator->codeCnnlfParamIdx(cs, chType);
+    m_CABACEstimator->codeNnlfSet1ParamIdx(cs, chType);
     double rate = FRAC_BITS_SCALE * m_CABACEstimator->getEstFracBits();
     double costSliceLevelOff = (double)distSliceLevelOff;
     double costCtuLevelOn;
@@ -235,12 +268,12 @@ void EncCNNFilter::calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, in
     if (costSliceLevelOff < costCtuLevelOn)
     {
       costBest = costSliceLevelOff;
-      pcSlice->setCnnlfMode(chType, 0);
+      pcSlice->setNnlfSet1Mode(chType, 0);
     }
     else
     {
       costBest = costCtuLevelOn;
-      pcSlice->setCnnlfMode(chType, numParams + 1);
+      pcSlice->setNnlfSet1Mode(chType, numParams + 1);
     }
     
     for (int paramIdx = 0; paramIdx < numParams; paramIdx ++)
@@ -248,14 +281,14 @@ void EncCNNFilter::calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, in
       if (costSliceLevelOn[paramIdx] < costBest)
       {
         costBest = costSliceLevelOn[paramIdx];
-        pcSlice->setCnnlfMode(chType, paramIdx + 1);
+        pcSlice->setNnlfSet1Mode(chType, paramIdx + 1);
       }
     }
     
     minCost[chal] = costBest;
   }
 }
-void EncCNNFilter::cnnFilterEncoder(Picture *pic, const double *lambdas)
+void EncNNFilterSet1::cnnFilterEncoder(Picture *pic, const double *lambdas)
 {
   CodingStructure&  cs            = *pic->cs;
   Slice* pcSlice                  = cs.slice;
@@ -264,9 +297,9 @@ void EncCNNFilter::cnnFilterEncoder(Picture *pic, const double *lambdas)
   const int  numValidComponents = getNumberValidComponents( cs.area.chromaFormat );
   const int  numValidChannels = getNumberValidChannels( cs.area.chromaFormat );
   
-  setCnnlfInferGranularity(pic);
+  setNnlfSet1InferGranularity(pic);
   
-  int numParams = cs.sps->getCnnlfMaxNumParams();
+  int numParams = cs.sps->getNnlfSet1MaxNumParams();
   
   cnnFilterPicture(pic, numParams);
 
@@ -276,33 +309,33 @@ void EncCNNFilter::cnnFilterEncoder(Picture *pic, const double *lambdas)
   calcRDCost(pic, m_tempBuf, numParams, minCost, false);
   scalePicture(pic, numParams);
   double minScaledCost[2] = {MAX_DOUBLE, MAX_DOUBLE};
-  double sliceCnnlfMode[2];
+  double sliceNnlfSet1Mode[2];
   for( int chal = 0; chal < numValidChannels; chal++ )
   {
     const ChannelType chType = ChannelType( chal );
-    CnnlfInferGranularity cnnlfInferGranularity = pcSlice->getCnnlfInferGranularity(chType);
-    std::vector<uint8_t> *cnnlfParamIdx = pic->getCnnlfParamIdx(cnnlfInferGranularity);
-    std::vector<uint8_t> *cnnlfBackupParamIdx = pic->getCnnlfBackupParamIdx(cnnlfInferGranularity);
-    for (int blockIdx = 0; blockIdx < pcv.sizeInCnnlfInferSize[cnnlfInferGranularity]; blockIdx++)
+    NnlfSet1InferGranularity nnlfSet1InferGranularity = pcSlice->getNnlfSet1InferGranularity(chType);
+    std::vector<uint8_t> *nnlfSet1ParamIdx = pic->getNnlfSet1ParamIdx(nnlfSet1InferGranularity);
+    std::vector<uint8_t> *nnlfSet1BackupParamIdx = pic->getNnlfSet1BackupParamIdx(nnlfSet1InferGranularity);
+    for (int blockIdx = 0; blockIdx < pcv.sizeInNnlfSet1InferSize[nnlfSet1InferGranularity]; blockIdx++)
     {
-      cnnlfBackupParamIdx[chal][blockIdx] = cnnlfParamIdx[chal][blockIdx];
+      nnlfSet1BackupParamIdx[chal][blockIdx] = nnlfSet1ParamIdx[chal][blockIdx];
     }
-    sliceCnnlfMode[chal] = pcSlice->getCnnlfMode(chType);
+    sliceNnlfSet1Mode[chal] = pcSlice->getNnlfSet1Mode(chType);
   }
   calcRDCost(pic, m_tempScaledBuf, numParams, minScaledCost, true);
   for (int chal = 0; chal < numValidChannels; chal++)
   {
     const ChannelType chType = ChannelType( chal );
-    CnnlfInferGranularity cnnlfInferGranularity = pcSlice->getCnnlfInferGranularity(chType);
+    NnlfSet1InferGranularity nnlfSet1InferGranularity = pcSlice->getNnlfSet1InferGranularity(chType);
     if (minCost[chal] <= minScaledCost[chal])
     {
-      std::vector<uint8_t> *cnnlfParamIdx       = pic->getCnnlfParamIdx(cnnlfInferGranularity);
-      std::vector<uint8_t> *cnnlfBackupParamIdx = pic->getCnnlfBackupParamIdx(cnnlfInferGranularity);
-      for (int blockIdx = 0; blockIdx < pcv.sizeInCnnlfInferSize[cnnlfInferGranularity]; blockIdx++)
+      std::vector<uint8_t> *nnlfSet1ParamIdx       = pic->getNnlfSet1ParamIdx(nnlfSet1InferGranularity);
+      std::vector<uint8_t> *nnlfSet1BackupParamIdx = pic->getNnlfSet1BackupParamIdx(nnlfSet1InferGranularity);
+      for (int blockIdx = 0; blockIdx < pcv.sizeInNnlfSet1InferSize[nnlfSet1InferGranularity]; blockIdx++)
       {
-        cnnlfParamIdx[chal][blockIdx] = cnnlfBackupParamIdx[chal][blockIdx];
+        nnlfSet1ParamIdx[chal][blockIdx] = nnlfSet1BackupParamIdx[chal][blockIdx];
       }
-      pcSlice->setCnnlfMode(chType, sliceCnnlfMode[chal]);
+      pcSlice->setNnlfSet1Mode(chType, sliceNnlfSet1Mode[chal]);
       for (int paramIdx = 0; paramIdx < numParams; paramIdx ++)
       {
         pcSlice->setNnScaleFlag(false, paramIdx, chType);
@@ -324,14 +357,14 @@ void EncCNNFilter::cnnFilterEncoder(Picture *pic, const double *lambdas)
   {
     const ComponentID compID = ComponentID( comp );
     int chal = toChannelType(compID);
-    CnnlfInferGranularity cnnlfInferGranularity = pcSlice->getCnnlfInferGranularity(toChannelType(compID));
-    int blockSize = cs.sps->getCnnlfInferSize (cnnlfInferGranularity);
-    int sliceCnnlfMode = pcSlice->getCnnlfMode(toChannelType(compID));
+    NnlfSet1InferGranularity nnlfSet1InferGranularity = pcSlice->getNnlfSet1InferGranularity(toChannelType(compID));
+    int blockSize = cs.sps->getNnlfSet1InferSize (nnlfSet1InferGranularity);
+    int sliceNnlfSet1Mode = pcSlice->getNnlfSet1Mode(toChannelType(compID));
 
-    for( int blockIdx = 0; blockIdx < pcv.sizeInCnnlfInferSize[cnnlfInferGranularity]; blockIdx++ )
+    for( int blockIdx = 0; blockIdx < pcv.sizeInNnlfSet1InferSize[nnlfSet1InferGranularity]; blockIdx++ )
     {
-      int xPosInBlocks        = blockIdx % pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
-      int yPosInBlocks        = blockIdx / pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
+      int xPosInBlocks        = blockIdx % pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
+      int yPosInBlocks        = blockIdx / pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
       int xPos = xPosInBlocks * blockSize;
       int yPos = yPosInBlocks * blockSize;
       int width = (xPos + blockSize > pcv.lumaWidth) ? (pcv.lumaWidth - xPos) : blockSize;
@@ -339,17 +372,17 @@ void EncCNNFilter::cnnFilterEncoder(Picture *pic, const double *lambdas)
       
       const UnitArea block( cs.area.chromaFormat, Area( xPos, yPos, width, height ) );
       
-      std::vector<uint8_t>* cnnlfParamIdx = pic->getCnnlfParamIdx(cnnlfInferGranularity);
-      if (sliceCnnlfMode < (numParams + 1))
-        cnnlfParamIdx[chal][blockIdx] = sliceCnnlfMode;
-      if (cnnlfParamIdx[chal][blockIdx])
+      std::vector<uint8_t>* nnlfSet1ParamIdx = pic->getNnlfSet1ParamIdx(nnlfSet1InferGranularity);
+      if (sliceNnlfSet1Mode < (numParams + 1))
+        nnlfSet1ParamIdx[chal][blockIdx] = sliceNnlfSet1Mode;
+      if (nnlfSet1ParamIdx[chal][blockIdx])
       {
 #if SCALE_NN_RESIDUE
-        if (pcSlice->getNnScaleFlag(cnnlfParamIdx[chal][blockIdx]-1, toChannelType(compID)))
-          pic->getRecoBuf(block).get(compID).copyFrom(m_tempScaledBuf[cnnlfParamIdx[chal][blockIdx] - 1].getBuf(block).get(compID));
+        if (pcSlice->getNnScaleFlag(nnlfSet1ParamIdx[chal][blockIdx]-1, toChannelType(compID)))
+          pic->getRecoBuf(block).get(compID).copyFrom(m_tempScaledBuf[nnlfSet1ParamIdx[chal][blockIdx] - 1].getBuf(block).get(compID));
         else
 #endif
-          pic->getRecoBuf(block).get(compID).copyFrom(m_tempBuf[cnnlfParamIdx[chal][blockIdx] - 1].getBuf(block).get(compID));
+          pic->getRecoBuf(block).get(compID).copyFrom(m_tempBuf[nnlfSet1ParamIdx[chal][blockIdx] - 1].getBuf(block).get(compID));
       }
     }
   }
@@ -358,7 +391,7 @@ void EncCNNFilter::cnnFilterEncoder(Picture *pic, const double *lambdas)
 
 #if SCALE_NN_RESIDUE
 #define NN_SCALE_STABLIZING_FACTOR (0.1 * (1 << NN_RESIDUE_ADDITIONAL_SHIFT))
-void EncCNNFilter::scaleFactorDerivation(Picture *pic, int paramIdx)
+void EncNNFilterSet1::scaleFactorDerivation(Picture *pic, int paramIdx)
 {
   CodingStructure &cs      = *pic->cs;
   Slice *          pcSlice = cs.slice;
@@ -466,7 +499,7 @@ void EncCNNFilter::scaleFactorDerivation(Picture *pic, int paramIdx)
 
 }
 
-void EncCNNFilter::scalePicture(Picture* pic, int numParams)
+void EncNNFilterSet1::scalePicture(Picture* pic, int numParams)
 {
   CodingStructure&  cs            = *pic->cs;
   Slice* pcSlice                  = cs.slice;
@@ -482,12 +515,12 @@ void EncCNNFilter::scalePicture(Picture* pic, int numParams)
     for (int comp = 0; comp < numValidComponents; comp++)
     {
       const ComponentID compID              = ComponentID(comp);
-      CnnlfInferGranularity cnnlfInferGranularity = pcSlice->getCnnlfInferGranularity(toChannelType(compID));
-      int blockSize = cs.sps->getCnnlfInferSize (cnnlfInferGranularity);
-      for (int blockIdx = 0; blockIdx < pcv.sizeInCnnlfInferSize[cnnlfInferGranularity]; blockIdx++)
+      NnlfSet1InferGranularity nnlfSet1InferGranularity = pcSlice->getNnlfSet1InferGranularity(toChannelType(compID));
+      int blockSize = cs.sps->getNnlfSet1InferSize (nnlfSet1InferGranularity);
+      for (int blockIdx = 0; blockIdx < pcv.sizeInNnlfSet1InferSize[nnlfSet1InferGranularity]; blockIdx++)
       {
-        int xPosInBlocks = blockIdx % pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
-        int yPosInBlocks = blockIdx / pcv.widthInCnnlfInferSize[cnnlfInferGranularity];
+        int xPosInBlocks = blockIdx % pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
+        int yPosInBlocks = blockIdx / pcv.widthInNnlfSet1InferSize[nnlfSet1InferGranularity];
         int xPos            = xPosInBlocks * blockSize;
         int yPos            = yPosInBlocks * blockSize;
         int width           = (xPos + blockSize > pcv.lumaWidth) ? (pcv.lumaWidth - xPos) : blockSize;
diff --git a/source/Lib/EncoderLib/EncNNFilterSet1.h b/source/Lib/EncoderLib/EncNNFilterSet1.h
new file mode 100644
index 0000000000..a7f9990d71
--- /dev/null
+++ b/source/Lib/EncoderLib/EncNNFilterSet1.h
@@ -0,0 +1,80 @@
+/* The copyright in this software is being made available under the BSD
+* License, included below. This software may be subject to other third party
+* and contributor rights, including patent rights, and no such rights are
+* granted under this license.
+*
+* Copyright (c) 2010-2020, ITU/ISO/IEC
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+*  * Redistributions of source code must retain the above copyright notice,
+*    this list of conditions and the following disclaimer.
+*  * Redistributions in binary form must reproduce the above copyright notice,
+*    this list of conditions and the following disclaimer in the documentation
+*    and/or other materials provided with the distribution.
+*  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
+*    be used to endorse or promote products derived from this software without
+*    specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/** \file     EncNNFilterSet1.h
+    \brief    encoder neural network-based filter set1 class (header)
+*/
+
+#ifndef __ENCNNFILTERSET1__
+#define __ENCNNFILTERSET1__
+
+#include "CommonDef.h"
+#include "Unit.h"
+#include "Picture.h"
+#include "Reshape.h"
+#include "CABACWriter.h"
+#include "CommonLib/NNFilterSet1.h"
+//! \ingroup CommonLib
+//! \{
+
+
+class EncNNFilterSet1 : public NNFilterSet1
+{
+public:
+  EncNNFilterSet1();
+  virtual ~EncNNFilterSet1();
+  
+  //for RDO
+  CABACWriter*           m_CABACEstimator;
+  CtxCache*              m_CtxCache;
+  double                 m_lambda[MAX_NUM_COMPONENT];
+  bool                   m_singleModelISlice;
+
+  void                   initCABACEstimator( CABACEncoder* cabacEncoder, CtxCache* ctxCache, Slice* pcSlice );
+
+#if SCALE_NN_RESIDUE
+  void                   scaleFactorDerivation(Picture *pic, int paramIdx);
+  void                   scalePicture(Picture* pic, int numParams);
+#endif
+  void                   cnnFilterEncoder(Picture *pic, const double *lambdas);
+  void                   cnnFilterPicture(Picture* pic, int numParams);
+#if SCALE_NN_RESIDUE
+  void                   calcRDCost(Picture *pic, std::vector<PelStorage>& tempBuf, int numParams, double* minCost, bool scaled);
+#else
+  void                   calcRDCost(Picture *pic,std::vector<PelStorage>& tempBuf, int numParams, double* minCost);
+#endif
+};
+
+//! \}
+#endif
+
diff --git a/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp b/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp
index e14f09ffb7..90f743093d 100644
--- a/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp
+++ b/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp
@@ -213,8 +213,8 @@ void EncSampleAdaptiveOffset::SAOProcess( CodingStructure& cs, bool* sliceEnable
 #endif
                                           const bool bTestSAODisableAtPictureLevel, const double saoEncodingRate, const double saoEncodingRateChroma, const bool isPreDBFSamplesUsed, bool isGreedyMergeEncoding )
 {
-#if CNN_FILTERING
-  if (cs.sps->getCnnlfEnabledFlag())
+#if NN_FILTERING_SET_1
+  if (cs.sps->getNnlfSet1EnabledFlag())
   {
     sliceEnabled[0] = sliceEnabled[1] = sliceEnabled[2] = false;
     return;
diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp
index 86a2bbbbbe..647e7e8a73 100644
--- a/source/Lib/EncoderLib/VLCWriter.cpp
+++ b/source/Lib/EncoderLib/VLCWriter.cpp
@@ -1000,21 +1000,22 @@ void HLSWriter::codeSPS( const SPS* pcSPS )
     }
   }
 
+#if NN_FILTERING_SET_1
+  WRITE_FLAG( pcSPS->getNnlfSet1EnabledFlag(),                                          "sps_nnlf_set1_enabled_flag" );
+  if (pcSPS->getNnlfSet1EnabledFlag())
+  {
+    WRITE_UVLC( pcSPS->getNnlfSet1InferSize(CNNLF_INFER_GRANULARITY_BASE),              "sps_nnlf_set1_infer_size_base" );
+    WRITE_UVLC( pcSPS->getNnlfSet1InferSizeExtension(),                                 "sps_nnlf_set1_infer_size_extension" );
+    WRITE_UVLC( pcSPS->getNnlfSet1MaxNumParams(),                                       "sps_nnlf_set1_max_num_params" );
+  }
+#endif
+  
   WRITE_FLAG( pcSPS->getSAOEnabledFlag(),                                            "sps_sao_enabled_flag");
   WRITE_FLAG( pcSPS->getALFEnabledFlag(),                                            "sps_alf_enabled_flag" );
   if (pcSPS->getALFEnabledFlag() && pcSPS->getChromaFormatIdc() != CHROMA_400)
   {
     WRITE_FLAG( pcSPS->getCCALFEnabledFlag(),                                            "sps_ccalf_enabled_flag" );
   }
-#if CNN_FILTERING
-  WRITE_FLAG( pcSPS->getCnnlfEnabledFlag(),                                          "sps_cnnlf_enabled_flag" );
-  if (pcSPS->getCnnlfEnabledFlag())
-  {
-    WRITE_UVLC( pcSPS->getCnnlfInferSize(CNNLF_INFER_GRANULARITY_BASE),              "sps_cnnlf_infer_size_base" );
-    WRITE_UVLC( pcSPS->getCnnlfInferSizeExtension(),                                 "sps_cnnlf_infer_size_extension" );
-    WRITE_UVLC( pcSPS->getCnnlfMaxNumParams(),                                       "sps_cnnlf_max_num_params" );
-  }
-#endif
   WRITE_FLAG(pcSPS->getUseLmcs() ? 1 : 0, "sps_lmcs_enable_flag");
   WRITE_FLAG(pcSPS->getUseWP() ? 1 : 0, "sps_weighted_pred_flag");           // Use of Weighting Prediction (P_SLICE)
   WRITE_FLAG(pcSPS->getUseWPBiPred() ? 1 : 0, "sps_weighted_bipred_flag");   // Use of Weighting Bi-Prediction (B_SLICE)
@@ -2482,24 +2483,24 @@ void HLSWriter::codeSliceHeader         ( Slice* pcSlice, PicHeader *picHeader )
       WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "sh_cu_chroma_qp_offset_enabled_flag");
     }
 
-#if CNN_FILTERING
-    if (pcSlice->getSPS()->getCnnlfEnabledFlag())
+#if NN_FILTERING_SET_1
+    if (pcSlice->getSPS()->getNnlfSet1EnabledFlag())
     {
-      WRITE_UVLC( pcSlice->getCnnlfMode( CHANNEL_TYPE_LUMA ), "slice_luma_cnnlf_mode" );
-      WRITE_UVLC( pcSlice->getCnnlfMode( CHANNEL_TYPE_CHROMA ), "slice_chroma_cnnlf_mode" );
+      WRITE_UVLC( pcSlice->getNnlfSet1Mode( CHANNEL_TYPE_LUMA ), "slice_luma_nnlf_set1_mode" );
+      WRITE_UVLC( pcSlice->getNnlfSet1Mode( CHANNEL_TYPE_CHROMA ), "slice_chroma_nnlf_set1_mode" );
 
 #if SCALE_NN_RESIDUE
       for (int chal = 0; chal < MAX_NUM_CHANNEL_TYPE; chal++)
       {
         ChannelType chType = ChannelType(chal);
-        if (pcSlice->getCnnlfMode(chType))
+        if (pcSlice->getNnlfSet1Mode(chType))
         {
-          int numParams = pcSlice->getSPS()->getCnnlfMaxNumParams();
-          if (pcSlice->getCnnlfMode(chType) == numParams + 1)
+          int numParams = pcSlice->getSPS()->getNnlfSet1MaxNumParams();
+          if (pcSlice->getNnlfSet1Mode(chType) == numParams + 1)
           {
             for (int paramIdx = 0; paramIdx < numParams; paramIdx++)
             {
-              WRITE_FLAG(pcSlice->getNnScaleFlag( paramIdx, chType) , "slice_cnnlf_scale_flag");
+              WRITE_FLAG(pcSlice->getNnScaleFlag( paramIdx, chType) , "slice_nnlf_set1_scale_flag");
               if (pcSlice->getNnScaleFlag(paramIdx, chType))
               {
                 WRITE_SCODE(pcSlice->getNnScale(paramIdx, chType) - (1 << NN_RESIDUE_SCALE_SHIFT), NN_RESIDUE_SCALE_SHIFT + 1, "nnScale");
@@ -2508,10 +2509,10 @@ void HLSWriter::codeSliceHeader         ( Slice* pcSlice, PicHeader *picHeader )
           }
           else
           {
-            WRITE_FLAG(pcSlice->getNnScaleFlag( pcSlice->getCnnlfMode(chType) - 1, chType) , "slice_cnnlf_scale_flag");
-            if (pcSlice->getNnScaleFlag(pcSlice->getCnnlfMode(chType) - 1, chType))
+            WRITE_FLAG(pcSlice->getNnScaleFlag( pcSlice->getNnlfSet1Mode(chType) - 1, chType) , "slice_nnlf_set1_scale_flag");
+            if (pcSlice->getNnScaleFlag(pcSlice->getNnlfSet1Mode(chType) - 1, chType))
             {
-              WRITE_SCODE(pcSlice->getNnScale( pcSlice->getCnnlfMode(chType) - 1, chType) - (1 << NN_RESIDUE_SCALE_SHIFT), NN_RESIDUE_SCALE_SHIFT + 1, "nnScale");
+              WRITE_SCODE(pcSlice->getNnScale( pcSlice->getNnlfSet1Mode(chType) - 1, chType) - (1 << NN_RESIDUE_SCALE_SHIFT), NN_RESIDUE_SCALE_SHIFT + 1, "nnScale");
             }
           }
         }
-- 
GitLab