From 96bf1f76f8c5ae45dd3e39db56b62c91852c6e6a Mon Sep 17 00:00:00 2001
From: Franck Galpin <franck.galpin@interdigital.com>
Date: Fri, 24 May 2024 10:41:56 +0000
Subject: [PATCH] Sps nnlf model

---
 cfg/encoder_intra_nnvc.cfg              |  2 +-
 cfg/encoder_lowdelay_P_nnvc.cfg         |  2 +-
 cfg/encoder_lowdelay_nnvc.cfg           |  2 +-
 cfg/encoder_randomaccess_nnvc.cfg       |  2 +-
 cfg/encoder_randomaccess_nnvc_gop16.cfg |  2 +-
 cfg/nn-based/HOP.cfg                    |  2 +-
 cfg/nn-based/vlop.cfg                   |  2 +-
 sadl                                    |  2 +-
 source/App/DecoderApp/DecApp.cpp        |  2 +
 source/App/DecoderApp/DecAppCfg.cpp     |  2 +
 source/App/DecoderApp/DecAppCfg.h       |  2 +
 source/App/EncoderApp/EncApp.cpp        |  4 ++
 source/App/EncoderApp/EncAppCfg.cpp     | 61 ++++++++++++++++++++++++-
 source/App/EncoderApp/EncAppCfg.h       |  4 ++
 source/Lib/CommonLib/Slice.h            |  9 ++++
 source/Lib/CommonLib/TypeDef.h          | 14 ++++++
 source/Lib/DecoderLib/DecLib.cpp        |  8 ++++
 source/Lib/DecoderLib/DecLib.h          |  2 +-
 source/Lib/DecoderLib/VLCReader.cpp     | 24 ++++++++--
 source/Lib/EncoderLib/EncCfg.h          |  8 ++++
 source/Lib/EncoderLib/EncLib.cpp        |  4 ++
 source/Lib/EncoderLib/VLCWriter.cpp     |  4 ++
 22 files changed, 150 insertions(+), 14 deletions(-)

diff --git a/cfg/encoder_intra_nnvc.cfg b/cfg/encoder_intra_nnvc.cfg
index ba8f633579..2a7336e499 100644
--- a/cfg/encoder_intra_nnvc.cfg
+++ b/cfg/encoder_intra_nnvc.cfg
@@ -109,7 +109,7 @@ FastMIP                      : 1
 FastLFNST                    : 1
 
 NnIntraPred                  : 1
-NnlfOption                   : 1 
+NnlfOption                   : 3 
 
 # Encoder optimization tools
 AffineAmvrEncOpt             : 0
diff --git a/cfg/encoder_lowdelay_P_nnvc.cfg b/cfg/encoder_lowdelay_P_nnvc.cfg
index b198d4cf06..dfc2e9469f 100644
--- a/cfg/encoder_lowdelay_P_nnvc.cfg
+++ b/cfg/encoder_lowdelay_P_nnvc.cfg
@@ -135,7 +135,7 @@ FastMIP                      : 0
 FastLocalDualTreeMode        : 2
 
 NnIntraPred                  : 1 
-NnlfOption                   : 1 
+NnlfOption                   : 3
 
 # Encoder optimization tools
 AffineAmvrEncOpt             : 0
diff --git a/cfg/encoder_lowdelay_nnvc.cfg b/cfg/encoder_lowdelay_nnvc.cfg
index 6658fa05d8..8dfda0b67a 100644
--- a/cfg/encoder_lowdelay_nnvc.cfg
+++ b/cfg/encoder_lowdelay_nnvc.cfg
@@ -139,7 +139,7 @@ FastMIP                      : 0
 FastLocalDualTreeMode        : 2
 
 NnIntraPred                  : 1 
-NnlfOption                   : 1 
+NnlfOption                   : 3
 
 # Encoder optimization tools
 AffineAmvrEncOpt             : 0
diff --git a/cfg/encoder_randomaccess_nnvc.cfg b/cfg/encoder_randomaccess_nnvc.cfg
index 61de524aed..cac5e183ab 100644
--- a/cfg/encoder_randomaccess_nnvc.cfg
+++ b/cfg/encoder_randomaccess_nnvc.cfg
@@ -164,7 +164,7 @@ FastLocalDualTreeMode        : 1
 ChromaTS                     : 1
 
 NnIntraPred                  : 1
-NnlfOption                   : 1 
+NnlfOption                   : 3 
 
 # Encoder optimization tools
 AffineAmvrEncOpt             : 1
diff --git a/cfg/encoder_randomaccess_nnvc_gop16.cfg b/cfg/encoder_randomaccess_nnvc_gop16.cfg
index 606a38c3c4..aef6160b23 100644
--- a/cfg/encoder_randomaccess_nnvc_gop16.cfg
+++ b/cfg/encoder_randomaccess_nnvc_gop16.cfg
@@ -148,7 +148,7 @@ FastLocalDualTreeMode        : 1
 ChromaTS                     : 1
 
 NnIntraPred                  : 1
-NnlfOption                   : 1 
+NnlfOption                   : 3 
 
 # Encoder optimization tools
 AffineAmvrEncOpt             : 1
diff --git a/cfg/nn-based/HOP.cfg b/cfg/nn-based/HOP.cfg
index e872d58485..a110f1ec6a 100644
--- a/cfg/nn-based/HOP.cfg
+++ b/cfg/nn-based/HOP.cfg
@@ -2,4 +2,4 @@ NnlfOption                 : 1
 NnlfModelName		   : models/nnlf_hop3_model_int16.sadl
 CbQpOffset                          : 1 
 CrQpOffset                          : 1 
-NnlfTransInput                      : 0
+
diff --git a/cfg/nn-based/vlop.cfg b/cfg/nn-based/vlop.cfg
index d4a1473717..a9ea708a51 100644
--- a/cfg/nn-based/vlop.cfg
+++ b/cfg/nn-based/vlop.cfg
@@ -1,3 +1,3 @@
 NnlfOption                 : 1   
 NnlfModelName		   : models/nnlf_vlop_model_int16.sadl
-NnlfTransInput                      : 0
+
diff --git a/sadl b/sadl
index ed737f9b94..e068b52b28 160000
--- a/sadl
+++ b/sadl
@@ -1 +1 @@
-Subproject commit ed737f9b945954c806be8077e43441d7a4a056ee
+Subproject commit e068b52b28d73e70010af57a8df54d8e17f143eb
diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp
index 4a5cbadfa4..0cd85e0539 100644
--- a/source/App/DecoderApp/DecApp.cpp
+++ b/source/App/DecoderApp/DecApp.cpp
@@ -742,9 +742,11 @@ void DecApp::xCreateDecLib()
 #if NN_LF_FORCE_USE
   m_cDecLib.setNnlfDebugOption(m_nnlfDebugOption);
 #endif
+#if !NN_LF_UNIFIED_ID
 #if JVET_AH0080_TRANS_INPUT
   m_cDecLib.setUseNnlfTransInput(m_nnlfTransInput);
 #endif
+#endif
 #if JVET_AH0096_CONTENT_ADAPTIVE_LOP
   m_cDecLib.setNnfuOutputFileStem(m_nnfuOutputFileStem);
 #endif
diff --git a/source/App/DecoderApp/DecAppCfg.cpp b/source/App/DecoderApp/DecAppCfg.cpp
index 1c03f10dbf..c01ab0b189 100644
--- a/source/App/DecoderApp/DecAppCfg.cpp
+++ b/source/App/DecoderApp/DecAppCfg.cpp
@@ -85,9 +85,11 @@ bool DecAppCfg::parseCfg( int argc, char* argv[] )
 #if NN_LF_FORCE_USE
   ( "NnlfUnifiedDebugOption",       m_nnlfDebugOption,  0, "Option used to debug stage 1 model. 0: default, 1: apply only on I slice, 2: apply on all slices using I type as input"  )
 #endif
+#if !NN_LF_UNIFIED_ID
 #if JVET_AH0080_TRANS_INPUT
   ( "NnlfTransInput",        m_nnlfTransInput,  true, "apply DCT transform to inputs"  )
 #endif
+#endif
 #if NN_HOP_UNIFIED_TEMPORAL_FILTERING
   ("NnlfHopTemporalModelName",  m_nnModel[NnModel::HOP_UNIFIED_TEMPORA_FILTER], string("models/nnlf_hop_temporal_model_int16.sadl"), "HOP temporal loop filter model name\n")
 #endif
diff --git a/source/App/DecoderApp/DecAppCfg.h b/source/App/DecoderApp/DecAppCfg.h
index 76bc244bf6..477b672429 100644
--- a/source/App/DecoderApp/DecAppCfg.h
+++ b/source/App/DecoderApp/DecAppCfg.h
@@ -67,9 +67,11 @@ protected:
 #if NN_LF_FORCE_USE
   int           m_nnlfDebugOption;
 #endif
+#if !NN_LF_UNIFIED_ID
 #if JVET_AH0080_TRANS_INPUT
   bool         m_nnlfTransInput;
 #endif
+#endif
 #if JVET_AH0096_CONTENT_ADAPTIVE_LOP
   std::string   m_nnfuOutputFileStem;              ///< Directory to save the NNR bitstream and the reconstructed model
 #endif
diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp
index bcef89d4df..fdd5164a94 100644
--- a/source/App/EncoderApp/EncApp.cpp
+++ b/source/App/EncoderApp/EncApp.cpp
@@ -1190,8 +1190,12 @@ void EncApp::xInitLibCfg()
 
 #if NN_COMMON_SPS
   m_cEncLib.setUseNnlf                                           (m_nnlf);
+#if NN_LF_UNIFIED_ID
+  m_cEncLib.setUseNnlfId                                        (m_nnlfId);
+#else
   m_cEncLib.setUseNnlfSet                                        (m_nnlfSet);
 #endif
+#endif
   
 #if NN_LF_UNIFIED
   m_cEncLib.setUseNnlfUnified                                        (m_nnlfUnified);
diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index 3807e5ceb8..7d3d67a17c 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -1180,8 +1180,12 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ("GolombRiceParameterAdaptation",                   m_persistentRiceAdaptationEnabledFlag,            false, "Enable the adaptation of the Golomb-Rice parameter over the course of each slice")
   ("AlignCABACBeforeBypass",                          m_cabacBypassAlignmentEnabledFlag,                false, "Align the CABAC engine to a defined fraction of a bit prior to coding bypass data. Must be 1 in high bit rate profile, 0 otherwise")
 #if NN_COMMON_SPS
+#if NN_LF_UNIFIED_ID
+  ("NnlfOption",                                      m_nnlfOption,                                         3, "NN-based in-loop filter option (0:disable nnlf, 1: enable unified nnlf, 3: enable LOP3, 4: enable HOP4 [legacy: 10: enable nnlf-0, 11: enable nnlf-1, 12: enable nnlf-LC])")
+#else
   ("NnlfOption",                                      m_nnlfOption,                                         1, "NN-based in-loop filter option (0:disable nnlf, 1: enable unified nnlf, [legacy: 10: enable nnlf-0, 11: enable nnlf-1, 12: enable nnlf-LC])")
-  ("NnlfModelName",                                   m_nnModel[NnModel::LOP_UNIFIED_FILTER],           string("models/nnlf_lop3_model_int16.sadl"), "unified nnlf model name."                   )
+#endif
+  ("NnlfModelName",                                   m_nnModel[NnModel::LOP_UNIFIED_FILTER],              string("models/nnlf_lop3_model_int16.sadl"), "unified nnlf model name."                   )
 #endif
 #if NN_LF_UNIFIED
   ( "NnlfBlockSize",                                  m_nnlfBlockSize,                                   128u, "Base inference size of NN-based in-loop filter")
@@ -1201,9 +1205,11 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 #if JVET_AF0193_DECODER_OPTIMIZATION
   ( "NnlfDecOpt",                                     m_nnlfDecOpt,                                     false, "Decoder complexity optimization for NNVC in-loop filter")
 #endif
+#if !NN_LF_UNIFIED
 #if JVET_AH0080_TRANS_INPUT
   ( "NnlfTransInput",                                 m_nnlfTransInput,                                 true, "Apply transform to inputs of loop filter" )
 #endif
+#endif
 #endif
   ("SAO",                                             m_bUseSAO,                                         true, "Enable Sample Adaptive Offset")
   ("TestSAODisableAtPictureLevel",                    m_bTestSAODisableAtPictureLevel,                  false, "Enables the testing of disabling SAO at the picture level after having analysed all blocks")
@@ -2855,11 +2861,62 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 #if NN_LF_UNIFIED
     m_nnlfUnified = false;
 #endif
+#if NN_LF_UNIFIED_ID
+    m_nnlfId=NNLFUnifiedID::UNDEFINED;
+    switch(m_nnlfOption) {
+    case 0:
+      m_nnlf =false;
+      break;
+    case 1:
+      m_nnlf = true;
+      m_nnlfId = NNLFUnifiedID::HOPLOP;
+      m_nnlfUnified = true;
+      break;
+    case 3:
+      m_nnlf = true;
+      m_nnlfId = NNLFUnifiedID::LOP3;
+      m_nnlfUnified = true;
+      m_nnlfTransInput = true;
+      break;
+    case 4:
+      m_nnlf = true;
+      m_nnlfId = NNLFUnifiedID::HOP4;
+      m_nnlfUnified = true;
+      break;
+#if NN_FILTERING_SET_0
+    case 10:
+      m_nnlf = true;
+      m_nnlfId =  NNLFUnifiedID::FILTERSET0;
+      m_nnlfSet0 = true;
+      break;
+#endif
+#if NN_FILTERING_SET_1
+    case 11:
+      m_nnlf = true;
+      m_nnlfId =  NNLFUnifiedID::FILTERSET1;
+      m_nnlfSet1 = true;
+      m_encDbOpt = true;
+      break;
+#endif
+#if NN_FILTERING_SET_LC
+    case 12:
+      m_nnlf = true;
+      m_nnlfId =  NNLFUnifiedID::LOP1;
+      m_nnlfSetLC = true;
+      break;
+#endif
+    default:
+      std::cerr<<"[ERROR] unknown NNLF type "<<m_nnlfOption<<std::endl;
+      exit(-1);
+      break;
+    }
+#endif
+#else
    switch(m_nnlfOption) {
     case 0: break;
 #if NN_LF_UNIFIED
     case 1:
-    m_nnlf = true;
+     m_nnlf = true;
      m_nnlfSet = 3;
      m_nnlfUnified = true;
      break;
diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h
index e110369745..690174f38e 100644
--- a/source/App/EncoderApp/EncAppCfg.h
+++ b/source/App/EncoderApp/EncAppCfg.h
@@ -756,8 +756,12 @@ protected:
 #if NN_COMMON_SPS
   int         m_nnlfOption;
   bool        m_nnlf;
+#if NN_LF_UNIFIED_ID
+  NNLFUnifiedID    m_nnlfId;
+#else
   uint32_t    m_nnlfSet;
 #endif
+#endif
   
 #if NN_LF_UNIFIED
   bool        m_nnlfUnified;
diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h
index 413c251f2f..bdeef36ced 100644
--- a/source/Lib/CommonLib/Slice.h
+++ b/source/Lib/CommonLib/Slice.h
@@ -1497,8 +1497,12 @@ private:
 
 #if NN_COMMON_SPS
   bool              m_nnlfEnabledFlag;
+#if NN_LF_UNIFIED_ID
+  NNLFUnifiedID     m_nnlfid;
+#else
   uint32_t          m_nnlfSet;
 #endif
+#endif
   
 #if NN_LF_UNIFIED
   bool              m_nnlfUnifiedEnabledFlag;
@@ -1789,9 +1793,14 @@ public:
 #if NN_COMMON_SPS
   bool                    getNnlfEnabledFlag() const                                                      { return m_nnlfEnabledFlag; }
   void                    setNnlfEnabledFlag(bool b)                                                      { m_nnlfEnabledFlag = b; }
+#if NN_LF_UNIFIED_ID
+  NNLFUnifiedID           getNnlfId() const                                                               { return m_nnlfid; }
+  void                    setNnlfId(NNLFUnifiedID ui)                                                     { m_nnlfid = ui; }
+#else
   uint32_t                getNnlfSet() const                                                              { return m_nnlfSet; }
   void                    setNnlfSet(uint32_t ui)                                                         { m_nnlfSet = ui; }
 #endif
+#endif
 #if NN_LF_UNIFIED
   bool                    getNnlfUnifiedEnabledFlag() const                                                   { return m_nnlfUnifiedEnabledFlag;   }
   void                    setNnlfUnifiedEnabledFlag( bool b )                                                 { m_nnlfUnifiedEnabledFlag = b;      }
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index 39bf5cbfc2..90f23174fd 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -63,6 +63,7 @@ using TypeSadlLFUnified=int16_t;
 #define JVET_AF0193_DECODER_OPTIMIZATION  1 // JVET-AF0193: decoder complexity optimization for NNVC in-loop filter
 #define JVET_AH0080_TRANS_INPUT           1 // JVET-AH0080: joint LOP model with inputs transformed
 #define JVET_AH0096_CONTENT_ADAPTIVE_LOP  1 // JVET-AH0096: Content-adaptive loop-filter
+#define NN_LF_UNIFIED_ID                  1 // unified the model switch using sps ID
 #endif
 
 
@@ -620,6 +621,19 @@ enum NNInputType
 };
 #endif
 
+#if NN_LF_UNIFIED_ID
+enum class NNLFUnifiedID
+{
+  FILTERSET0  = 0,
+  FILTERSET1  = 1,
+  LOP1 = 2,
+  HOPLOP = 3,
+  LOP3 = 4,
+  HOP4 = 5,
+  UNDEFINED = 6
+};
+#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/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp
index 3ead65ac16..1a1db422d6 100644
--- a/source/Lib/DecoderLib/DecLib.cpp
+++ b/source/Lib/DecoderLib/DecLib.cpp
@@ -790,9 +790,13 @@ void DecLib::executeLoopFilters()
 #if NN_LF_FORCE_USE
     m_nnfilterUnified.forceIntraType(getNnlfDebugOption() == 2 ? true : false);
 #endif
+#if NN_LF_UNIFIED_ID
+    m_nnfilterUnified.nnlfTransInput(cs.sps->getNnlfId()==NNLFUnifiedID::LOP3);
+#else
 #if JVET_AH0080_TRANS_INPUT
     m_nnfilterUnified.nnlfTransInput(getUseNnlfTransInput() == 1 ? true : false);
 #endif
+#endif
 #if JVET_AH0096_CONTENT_ADAPTIVE_LOP
     int picIntraPeriod = m_nnfuIntraPeriod == 0 ? 0 : int(cs.slice->getPOC() / m_nnfuIntraPeriod);
 
@@ -1969,9 +1973,13 @@ void DecLib::xActivateParameterSets( const InputNALUnit nalu )
       m_nnfilterUnified.initTemporal(m_nnModel[NnModel::HOP_UNIFIED_TEMPORA_FILTER]);
     }
 #endif
+#if  NN_LF_UNIFIED_ID
+    m_nnfilterUnified.nnlfTransInput(sps->getNnlfId()==NNLFUnifiedID::LOP3);
+#else
 #if JVET_AH0080_TRANS_INPUT
     m_nnfilterUnified.nnlfTransInput(getUseNnlfTransInput() == 1 ? true : false);
 #endif
+#endif
 #endif
   }
   else
diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h
index 79d077de0b..f9addd106c 100644
--- a/source/Lib/DecoderLib/DecLib.h
+++ b/source/Lib/DecoderLib/DecLib.h
@@ -290,7 +290,7 @@ public:
   void               setNnlfDebugOption( int i )                              { m_nnlfDebugOption = i;          }
   int                getNnlfDebugOption() const                               { return m_nnlfDebugOption;       }
 #endif
-#if JVET_AH0080_TRANS_INPUT
+#if JVET_AH0080_TRANS_INPUT && !NN_LF_UNIFIED_ID
   void               setUseNnlfTransInput(bool b)                                 { m_nnlfTransInput = b; }
   int                getUseNnlfTransInput() const                                 { return m_nnlfTransInput; }
 #endif
diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index eedc3c6f1d..11469f3313 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -1779,8 +1779,28 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
   READ_FLAG(uiCode, "sps_nnlf_enabled_flag");                          pcSPS->setNnlfEnabledFlag ( uiCode ? true : false );
   if (pcSPS->getNnlfEnabledFlag())
   {
-    READ_UVLC(uiCode, "sps_nnlf_set");                                 pcSPS->setNnlfSet ( uiCode);
+#if NN_LF_UNIFIED_ID
+    READ_UVLC(uiCode, "sps_nnlf_model_id");
+    assert(uiCode<(int)NNLFUnifiedID::UNDEFINED);
+    pcSPS->setNnlfId ( (NNLFUnifiedID)uiCode); // dangerous cast
+   // for backward compatiblity
+#if NN_FILTERING_SET_0
+    pcSPS->setNnlfSet0EnabledFlag( pcSPS->getNnlfId()  == NNLFUnifiedID::FILTERSET0 );
+#endif
+#if NN_FILTERING_SET_1
+    pcSPS->setNnlfSet1EnabledFlag( pcSPS->getNnlfId()  == NNLFUnifiedID::FILTERSET1 );
+#endif
+#if NN_FILTERING_SET_LC
+    pcSPS->setNnlfSetLCEnabledFlag( pcSPS->getNnlfId()  == NNLFUnifiedID::LOP1 );
+#endif
+    pcSPS->setNnlfUnifiedEnabledFlag( pcSPS->getNnlfId()  == NNLFUnifiedID::HOPLOP );
+#endif
+#else
+    READ_UVLC(uiCode, "sps_nnlf_set");
+    pcSPS->setNnlfSet ( uiCode);
+#endif
   }
+#if !NN_LF_UNIFIED_ID
 #if NN_FILTERING_SET_0
   pcSPS->setNnlfSet0EnabledFlag(pcSPS->getNnlfEnabledFlag() && pcSPS->getNnlfSet() == 0 ? true : false);
 #endif
@@ -1790,10 +1810,8 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
 #if NN_FILTERING_SET_LC
   pcSPS->setNnlfSetLCEnabledFlag(pcSPS->getNnlfEnabledFlag() && pcSPS->getNnlfSet() == 2 ? true : false);
 #endif
-#if NN_LF_UNIFIED
   pcSPS->setNnlfUnifiedEnabledFlag(pcSPS->getNnlfEnabledFlag() && pcSPS->getNnlfSet() == 3 ? true : false);
 #endif
-#endif
   
 #if NN_LF_UNIFIED
 #if !NN_COMMON_SPS
diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h
index 52d67a3874..bc7c37c4a1 100644
--- a/source/Lib/EncoderLib/EncCfg.h
+++ b/source/Lib/EncoderLib/EncCfg.h
@@ -816,8 +816,12 @@ protected:
 
 #if NN_COMMON_SPS
   bool        m_nnlf;
+#if NN_LF_UNIFIED_ID
+  NNLFUnifiedID m_nnlfId;
+#else
   uint32_t    m_nnlfSet;
 #endif
+#endif
 #if NN_LF_UNIFIED
   bool        m_nnlfUnified;
   uint32_t    m_nnlfUnifiedBlockSize;
@@ -2225,8 +2229,12 @@ public:
   
 #if NN_COMMON_SPS
   void         setUseNnlf(bool b)                                     { m_nnlf = b; }
+#if NN_LF_UNIFIED_ID
+  void         setUseNnlfId(NNLFUnifiedID ui)                             { m_nnlfId = ui; }
+#else
   void         setUseNnlfSet(uint32_t ui)                             { m_nnlfSet = ui; }
 #endif
+#endif
 
 #if NN_LF_UNIFIED
   void         setUseNnlfUnified( bool b )                                { m_nnlfUnified = b;                }
diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp
index 47deb594c6..5c145f88f2 100644
--- a/source/Lib/EncoderLib/EncLib.cpp
+++ b/source/Lib/EncoderLib/EncLib.cpp
@@ -1611,8 +1611,12 @@ void EncLib::xInitSPS( SPS& sps )
 
 #if NN_COMMON_SPS
   sps.setNnlfEnabledFlag(m_nnlf);
+#if NN_LF_UNIFIED_ID
+  sps.setNnlfId(m_nnlfId);
+#else
   sps.setNnlfSet(m_nnlfSet);
 #endif
+#endif
   
 #if NN_LF_UNIFIED
   sps.setNnlfUnifiedEnabledFlag(m_nnlfUnified);
diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp
index c5adef0f0d..f48e77182f 100644
--- a/source/Lib/EncoderLib/VLCWriter.cpp
+++ b/source/Lib/EncoderLib/VLCWriter.cpp
@@ -1048,7 +1048,11 @@ void HLSWriter::codeSPS( const SPS* pcSPS )
   WRITE_FLAG(pcSPS->getNnlfEnabledFlag(), "sps_nnlf_enabled_flag");
   if (pcSPS->getNnlfEnabledFlag())
   {
+#if NN_LF_UNIFIED_ID
+    WRITE_UVLC((uint32_t)pcSPS->getNnlfId(), "sps_nnlf_model_id");
+#else
     WRITE_UVLC(pcSPS->getNnlfSet(), "sps_nnlf_set");
+#endif
   }
 #endif
   
-- 
GitLab