From 7f17d7ae3a080f5c492d07eb29cce25b4f94ea4c Mon Sep 17 00:00:00 2001
From: Frank Bossen <fbossen@gmail.com>
Date: Fri, 19 May 2023 11:25:32 -0400
Subject: [PATCH] Rename and initialize m_RCCpbSaturationEnabled

---
 source/App/EncoderApp/EncApp.cpp    |  2 +-
 source/App/EncoderApp/EncAppCfg.cpp | 10 +++++-----
 source/App/EncoderApp/EncAppCfg.h   |  5 +++--
 source/Lib/EncoderLib/EncCfg.h      | 12 +++++++-----
 source/Lib/EncoderLib/EncLib.cpp    |  2 +-
 5 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp
index dbe3b9730..aae808bb0 100644
--- a/source/App/EncoderApp/EncApp.cpp
+++ b/source/App/EncoderApp/EncApp.cpp
@@ -1317,7 +1317,7 @@ void EncApp::xInitLibCfg( int layerIdx )
     m_cEncLib.setUseLCUSeparateModel(m_RCUseLCUSeparateModel);
     m_cEncLib.setInitialQP(m_RCInitialQP);
     m_cEncLib.setForceIntraQP(m_RCForceIntraQP);
-    m_cEncLib.setCpbSaturationEnabled(m_RCCpbSaturationEnabled);
+    m_cEncLib.setCpbSaturationEnabled(m_rcCpbSaturationEnabled);
     m_cEncLib.setCpbSize(m_RCCpbSize);
     m_cEncLib.setInitialCpbFullness(m_RCInitialCpbFullness);
   }
diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index c23d4da32..e60d2f7cc 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -1311,7 +1311,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ( "RCLCUSeparateModel",                             m_RCUseLCUSeparateModel,                           true, "Rate control: use CTU level separate R-lambda model" )
   ( "InitialQP",                                      m_RCInitialQP,                                        0, "Rate control: initial QP" )
   ( "RCForceIntraQP",                                 m_RCForceIntraQP,                                 false, "Rate control: force intra QP to be equal to initial QP" )
-  ( "RCCpbSaturation",                                m_RCCpbSaturationEnabled,                         false, "Rate control: enable target bits saturation to avoid CPB overflow and underflow" )
+  ( "RCCpbSaturation",                                m_rcCpbSaturationEnabled,                         false, "Rate control: enable target bits saturation to avoid CPB overflow and underflow" )
   ( "RCCpbSize",                                      m_RCCpbSize,                                         0u, "Rate control: CPB size" )
   ( "RCInitialCpbFullness",                           m_RCInitialCpbFullness,                             0.9, "Rate control: initial CPB fullness" )
   ("CostMode",                                        m_costMode,                         COST_STANDARD_LOSSY, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).")
@@ -4943,7 +4943,7 @@ bool EncAppCfg::xCheckParameter()
       }
     }
     xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
-    if ((m_RCCpbSaturationEnabled) && (m_level!=Level::NONE) && (m_profile!=Profile::NONE))
+    if (m_rcCpbSaturationEnabled && m_level != Level::NONE && m_profile != Profile::NONE)
     {
       uint32_t uiLevelIdx = (m_level / 16) * 4 + (uint32_t)((m_level % 16) / 3);
       xConfirmPara(m_RCCpbSize > g_uiMaxCpbSize[m_levelTier][uiLevelIdx], "RCCpbSize should be smaller than or equal to Max CPB size according to tier and level");
@@ -4952,7 +4952,7 @@ bool EncAppCfg::xCheckParameter()
   }
   else
   {
-    xConfirmPara( m_RCCpbSaturationEnabled != 0, "Target bits saturation cannot be processed without Rate control" );
+    xConfirmPara(m_rcCpbSaturationEnabled != 0, "Target bits saturation cannot be processed without Rate control");
   }
 
   if (m_framePackingSEIEnabled)
@@ -5360,8 +5360,8 @@ void EncAppCfg::xPrintParameter()
     msg( DETAILS, "UseLCUSeparateModel                    : %d\n", m_RCUseLCUSeparateModel );
     msg( DETAILS, "InitialQP                              : %d\n", m_RCInitialQP );
     msg( DETAILS, "ForceIntraQP                           : %d\n", m_RCForceIntraQP );
-    msg( DETAILS, "CpbSaturation                          : %d\n", m_RCCpbSaturationEnabled );
-    if (m_RCCpbSaturationEnabled)
+    msg(DETAILS, "CpbSaturation                          : %d\n", m_rcCpbSaturationEnabled);
+    if (m_rcCpbSaturationEnabled)
     {
       msg( DETAILS, "CpbSize                                : %d\n", m_RCCpbSize);
       msg( DETAILS, "InitalCpbFullness                      : %.2f\n", m_RCInitialCpbFullness);
diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h
index 393d12207..884645f42 100644
--- a/source/App/EncoderApp/EncAppCfg.h
+++ b/source/App/EncoderApp/EncAppCfg.h
@@ -851,9 +851,10 @@ protected:
   bool      m_RCUseLCUSeparateModel;              ///< use separate R-lambda model at LCU level                        NOTE: code-tidy - rename to m_RCUseCtuSeparateModel
   int       m_RCInitialQP;                        ///< inital QP for rate control
   bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
-  bool      m_RCCpbSaturationEnabled;             ///< enable target bits saturation to avoid CPB overflow and underflow
-  uint32_t      m_RCCpbSize;                          ///< CPB size
+  bool      m_rcCpbSaturationEnabled;             // enable target bits saturation to avoid CPB overflow and underflow
+  uint32_t  m_RCCpbSize;                          ///< CPB size
   double    m_RCInitialCpbFullness;               ///< initial CPB fullness
+
   ScalingListMode m_useScalingListId;                         ///< using quantization matrix
   std::string m_scalingListFileName;                          ///< quantization matrix file name
   bool      m_disableScalingMatrixForLfnstBlks;
diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h
index cfa62a9d6..e338ac5ff 100644
--- a/source/Lib/EncoderLib/EncCfg.h
+++ b/source/Lib/EncoderLib/EncCfg.h
@@ -901,6 +901,7 @@ protected:
   uint32_t      m_maxNumIBCMergeCand;                 ///< Max number of IBC merge candidates
   ScalingListMode m_useScalingListId;             ///< Using quantization matrix i.e. 0=off, 1=default, 2=file.
   std::string m_scalingListFileName;              ///< quantization matrix file name
+
   bool      m_disableScalingMatrixForAlternativeColourSpace;
   bool      m_scalingMatrixDesignatedColourSpace;
   bool      m_sliceLevelRpl;                      ///< code reference picture lists in slice headers rather than picture header
@@ -928,8 +929,8 @@ protected:
   bool      m_RCUseLCUSeparateModel;
   int       m_RCInitialQP;
   bool      m_RCForceIntraQP;
-  bool      m_RCCpbSaturationEnabled;
-  uint32_t      m_RCCpbSize;
+  bool      m_rcCpbSaturationEnabled = false;
+  uint32_t  m_RCCpbSize;
   double    m_RCInitialCpbFullness;
   CostMode  m_costMode;                                       ///< The cost function to use, primarily when considering lossless coding.
   bool      m_TSRCdisableLL;                                  ///< Disable TSRC for lossless
@@ -2593,9 +2594,10 @@ public:
   void         setInitialQP           ( int QP )                     { m_RCInitialQP = QP;             }
   bool         getForceIntraQP        ()                             { return m_RCForceIntraQP;        }
   void         setForceIntraQP        ( bool b )                     { m_RCForceIntraQP = b;           }
-  bool         getCpbSaturationEnabled()                             { return m_RCCpbSaturationEnabled;}
-  void         setCpbSaturationEnabled( bool b )                     { m_RCCpbSaturationEnabled = b;   }
-  uint32_t         getCpbSize             ()                             { return m_RCCpbSize;}
+
+  bool         getCpbSaturationEnabled() { return m_rcCpbSaturationEnabled; }
+  void         setCpbSaturationEnabled(bool b) { m_rcCpbSaturationEnabled = b; }
+  uint32_t     getCpbSize() { return m_RCCpbSize; }
   void         setCpbSize             ( uint32_t ui )                    { m_RCCpbSize = ui;   }
   double       getInitialCpbFullness  ()                             { return m_RCInitialCpbFullness;  }
   void         setInitialCpbFullness  (double f)                     { m_RCInitialCpbFullness = f;     }
diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp
index 68273fc3c..1b5d665db 100644
--- a/source/Lib/EncoderLib/EncLib.cpp
+++ b/source/Lib/EncoderLib/EncLib.cpp
@@ -177,7 +177,7 @@ void EncLib::init(AUWriterIf *auWriterIf)
     sps0.setLongTermRefsPresent(true);
   }
 
-  if (m_RCCpbSaturationEnabled)
+  if (m_rcCpbSaturationEnabled)
   {
     m_cRateCtrl.initHrdParam(sps0.getGeneralHrdParameters(), sps0.getOlsHrdParameters(), m_frameRate,
                              m_RCInitialCpbFullness);
-- 
GitLab