From 09b318daa7b83c22070c8cd122a46cb52a364f77 Mon Sep 17 00:00:00 2001
From: Jonathan Taquet <jonathan.taquet@crf.canon.fr>
Date: Mon, 29 Jul 2019 08:13:51 +0000
Subject: [PATCH] fix: preprocessor conditions not refactored to code
 conditions

---
 source/App/EncoderApp/EncAppCfg.cpp |  4 ++--
 source/Lib/DecoderLib/VLCReader.cpp | 10 +++++-----
 source/Lib/EncoderLib/VLCWriter.cpp |  5 ++---
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index 2cbafe556..fdce40a52 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -942,7 +942,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ("UseNonLinearAlfChroma",                           m_useNonLinearAlfChroma,                           true, "Non-linear adaptive loop filters for Chroma Channels")
 #if JVET_O0090_ALF_CHROMA_FILTER_ALTERNATIVES_CTB
   ("MaxNumAlfAlternativesChroma",                     m_maxNumAlfAlternativesChroma,
-                                                                    (unsigned)MAX_NUM_ALF_ALTERNATIVES_CHROMA, "Maximum number of alternative Chroma filters (1-" MACRO_TO_STRING(MAX_NUM_ALF_ALTERNATIVES_CHROMA) ", inclusive)")
+                                                                    (unsigned)MAX_NUM_ALF_ALTERNATIVES_CHROMA, std::string("Maximum number of alternative Chroma filters (1-") + std::to_string(MAX_NUM_ALF_ALTERNATIVES_CHROMA) + std::string (", inclusive)") )
 #endif
   ("MIP",                                             m_MIP,                                             true,  "Enable MIP (matrix-based intra prediction)")
   ("FastMIP",                                         m_useFastMIP,                                     false,  "Fast encoder search for MIP (matrix-based intra prediction)")
@@ -1958,7 +1958,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 #if JVET_O0090_ALF_CHROMA_FILTER_ALTERNATIVES_CTB
   if ( m_alf )
   {
-    CHECK( m_maxNumAlfAlternativesChroma < 1 || m_maxNumAlfAlternativesChroma > MAX_NUM_ALF_ALTERNATIVES_CHROMA, "The maximum number of ALF Chroma filter alternatives must be in the range (1-" MACRO_TO_STRING(MAX_NUM_ALF_ALTERNATIVES_CHROMA) ", inclusive)" );
+    CHECK( m_maxNumAlfAlternativesChroma < 1 || m_maxNumAlfAlternativesChroma > MAX_NUM_ALF_ALTERNATIVES_CHROMA, std::string("The maximum number of ALF Chroma filter alternatives must be in the range (1-") + std::to_string(MAX_NUM_ALF_ALTERNATIVES_CHROMA) + std::string (", inclusive)") );
   }
 
 #endif
diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index 8588f7a2d..1f7817fab 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -860,11 +860,11 @@ void HLSyntaxReader::parseAlfAps( APS* aps )
   if (param.newFilterFlag[CHANNEL_TYPE_CHROMA])
   {
 #if JVET_O0090_ALF_CHROMA_FILTER_ALTERNATIVES_CTB
-#if MAX_NUM_ALF_ALTERNATIVES_CHROMA > 1
-    READ_UVLC( code, "alf_chroma_num_alts_minus1" );
-#else
-    code = 0;
-#endif
+    if( MAX_NUM_ALF_ALTERNATIVES_CHROMA > 1 )
+      READ_UVLC( code, "alf_chroma_num_alts_minus1" );
+    else
+      code = 0;
+
     param.numAlternativesChroma = code + 1;
 
     for( int altIdx=0; altIdx < param.numAlternativesChroma; ++altIdx )
diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp
index 2477edcbc..90f7a64f4 100644
--- a/source/Lib/EncoderLib/VLCWriter.cpp
+++ b/source/Lib/EncoderLib/VLCWriter.cpp
@@ -536,9 +536,8 @@ void HLSWriter::codeAlfAps( APS* pcAPS )
   if (param.newFilterFlag[CHANNEL_TYPE_CHROMA])
   {
 #if JVET_O0090_ALF_CHROMA_FILTER_ALTERNATIVES_CTB
-#if MAX_NUM_ALF_ALTERNATIVES_CHROMA > 1
-    WRITE_UVLC( param.numAlternativesChroma - 1, "alf_chroma_num_alts_minus1" );
-#endif
+    if( MAX_NUM_ALF_ALTERNATIVES_CHROMA > 1 )
+      WRITE_UVLC( param.numAlternativesChroma - 1, "alf_chroma_num_alts_minus1" );
     for( int altIdx=0; altIdx < param.numAlternativesChroma; ++altIdx )
     {
       WRITE_FLAG( param.nonLinearFlag[CHANNEL_TYPE_CHROMA][altIdx], "alf_nonlinear_enable_flag_chroma" );
-- 
GitLab