From e9ffb8d9f9060fbdac123a046637586a2de956e3 Mon Sep 17 00:00:00 2001
From: Taoran Lu <tlu@dolby.com>
Date: Fri, 25 Jan 2019 18:07:24 -0800
Subject: [PATCH] address discussion points and rebase

---
 cfg/encoder_lowdelay_P_vtm.cfg   |  1 +
 source/Lib/CommonLib/CommonDef.h | 11 ++---------
 source/Lib/CommonLib/RdCost.cpp  | 15 ---------------
 source/Lib/CommonLib/RdCost.h    |  4 ----
 source/Lib/EncoderLib/EncGOP.cpp |  7 ++++---
 5 files changed, 7 insertions(+), 31 deletions(-)

diff --git a/cfg/encoder_lowdelay_P_vtm.cfg b/cfg/encoder_lowdelay_P_vtm.cfg
index 9c2f8ece3..a0bf5ade9 100644
--- a/cfg/encoder_lowdelay_P_vtm.cfg
+++ b/cfg/encoder_lowdelay_P_vtm.cfg
@@ -131,6 +131,7 @@ MHIntra                      : 1
 IBC                          : 0      # turned off in CTC
 AllowDisFracMMVD             : 1
 AffineAmvr                   : 0
+LumaReshapeEnable            : 1      # luma reshaping. 0: disable 1:enable 
 
 # Fast tools
 PBIntraFast                  : 1
diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h
index b22a87a15..faf4e097a 100644
--- a/source/Lib/CommonLib/CommonDef.h
+++ b/source/Lib/CommonLib/CommonDef.h
@@ -418,17 +418,10 @@ static constexpr int MV_MANTISSA_LIMIT       = (1 << (MV_MANTISSA_BITCOUNT - 1))
 static constexpr int MV_EXPONENT_MASK        = ((1 << MV_EXPONENT_BITCOUNT) - 1);
 #endif
 #if JVET_M0427_INLOOP_RESHAPER
-static const int MAX_LUMA_RESHAPING_LUT_SIZE =                 1024;
-static const int CSCALE_FP_PREC =                                11;
 static const int PIC_ANALYZE_CW_BINS =                           32;
-static const int FP_PREC =                                       14;
-static const int log2_MAX_LUMA_RESHAPING_LUT_SIZE =              10;
-static const int log2_PIC_ANALYZE_CW_BINS =                       5;
-static const int PIC_ANALYZE_WIN_SIZE =                           5;
-static const int CW_NUMS =                                        3;
-static const int MAX_FRAME_RATE =                               128;
 static const int PIC_CODE_CW_BINS =                              16;
-static const int log2_PIC_CODE_CW_BINS =                          4;
+static const int FP_PREC =                                       14;
+static const int CSCALE_FP_PREC =                                11;
 #endif
 // ====================================================================================================================
 // Macro functions
diff --git a/source/Lib/CommonLib/RdCost.cpp b/source/Lib/CommonLib/RdCost.cpp
index b4e7d5c45..a5f84b9da 100644
--- a/source/Lib/CommonLib/RdCost.cpp
+++ b/source/Lib/CommonLib/RdCost.cpp
@@ -2881,18 +2881,6 @@ void RdCost::saveUnadjustedLambda()
 
 void RdCost::initLumaLevelToWeightTable()
 {
-#if JVET_M0427_INLOOP_RESHAPER
-  if (m_iSignalType == RESHAPE_SIGNAL_SDR)
-  {
-    double weight = 1.0;
-    for (int i = 0; i < LUMA_LEVEL_TO_DQP_LUT_MAXSIZE; i++)
-    {
-      m_lumaLevelToWeightPLUT[i] = weight;
-    }
-    return;
-  }
-#endif
-
   for (int i = 0; i < LUMA_LEVEL_TO_DQP_LUT_MAXSIZE; i++) {
     double x = i;
     double y;
@@ -2914,9 +2902,6 @@ void RdCost::initLumaLevelToWeightTable()
     
     m_lumaLevelToWeightPLUT[i] = pow(2.0, y / 3.0);      // or power(10, dQp/10)      they are almost equal       
   }
-#if JVET_M0427_INLOOP_RESHAPER
-  memcpy(m_reshapeLumaLevelToWeightPLUT, m_lumaLevelToWeightPLUT, LUMA_LEVEL_TO_DQP_LUT_MAXSIZE * sizeof(double));
-#endif
 }
 
 #if JVET_M0427_INLOOP_RESHAPER
diff --git a/source/Lib/CommonLib/RdCost.h b/source/Lib/CommonLib/RdCost.h
index 476b59b6e..d031f6e07 100644
--- a/source/Lib/CommonLib/RdCost.h
+++ b/source/Lib/CommonLib/RdCost.h
@@ -115,10 +115,6 @@ private:
   static int              m_lumaBD;
 #else
   static double           m_lumaLevelToWeightPLUT[LUMA_LEVEL_TO_DQP_LUT_MAXSIZE];
-#if JVET_M0427_INLOOP_RESHAPER
-  static double           m_reshapeLumaLevelToWeightPLUT[LUMA_LEVEL_TO_DQP_LUT_MAXSIZE];
-  static uint32_t         m_iSignalType;
-  static double           m_chroma_weight;
 #endif
 #endif
   double                  m_DistScale;
diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp
index 71550a641..842e3bb19 100644
--- a/source/Lib/EncoderLib/EncGOP.cpp
+++ b/source/Lib/EncoderLib/EncGOP.cpp
@@ -186,15 +186,16 @@ void EncGOP::init ( EncLib* pcEncLib )
   }
   else if (m_pcCfg->getLumaLevelToDeltaQPMapping().mode)
   {
+#endif
+    pcEncLib->getRdCost()->initLumaLevelToWeightTable();
 #if JVET_M0427_INLOOP_RESHAPER
-  memcpy(pcEncLib->getALF()->getLumaLevelWeightTable(), pcEncLib->getRdCost()->getLumaLevelWeightTable(), LUMA_LEVEL_TO_DQP_LUT_MAXSIZE * sizeof(double));
+  }
+  pcEncLib->getALF()->getLumaLevelWeightTable() = pcEncLib->getRdCost()->getLumaLevelWeightTable();
   int alfWSSD = 0;
-
   if (m_pcCfg->getReshaper() && m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_PQ )
   {
     alfWSSD = 1;
   }
-
   pcEncLib->getALF()->setAlfWSSD(alfWSSD);
 #endif
     pcEncLib->getRdCost()->initLumaLevelToWeightTable();
-- 
GitLab