From c5e6df59b9abb8aa122953f89a250f4c76f061de Mon Sep 17 00:00:00 2001
From: Kiyofumi Abe <abe.kiyo@jp.panasonic.com>
Date: Wed, 23 Oct 2019 22:14:40 +0200
Subject: [PATCH] Update EncReshape.cpp I have confirmed that this modification
 can be consistent with the specification and there is no problem with the
 coding results.

---
 source/Lib/CommonLib/CommonDef.h     | 2 +-
 source/Lib/EncoderLib/EncReshape.cpp | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h
index f491e1beb..b3894ed01 100644
--- a/source/Lib/CommonLib/CommonDef.h
+++ b/source/Lib/CommonLib/CommonDef.h
@@ -458,7 +458,7 @@ static const int MVD_MIN =                               -(1 << 17);
 
 static const int PIC_ANALYZE_CW_BINS =                           32;
 static const int PIC_CODE_CW_BINS =                              16;
-static const int LMCS_SEG_SIZE =            (PIC_CODE_CW_BINS << 1);
+static const int LMCS_SEG_NUM =                                  32;
 static const int FP_PREC =                                       11;
 static const int CSCALE_FP_PREC =                                11;
 static const int  NEIG_NUM_LOG  =                                 6;
diff --git a/source/Lib/EncoderLib/EncReshape.cpp b/source/Lib/EncoderLib/EncReshape.cpp
index 247c4cb3c..b92b0cdb4 100644
--- a/source/Lib/EncoderLib/EncReshape.cpp
+++ b/source/Lib/EncoderLib/EncReshape.cpp
@@ -1016,8 +1016,6 @@ void EncReshape::constructReshaperLMCS()
     }
   }
 
-  adjustLmcsPivot();
-
   if (bdShift != 0)
   {
     for (int i = 0; i < PIC_ANALYZE_CW_BINS; i++)
@@ -1026,6 +1024,8 @@ void EncReshape::constructReshaperLMCS()
     }
   }
 
+  adjustLmcsPivot();
+
   int maxAbsDeltaCW = 0, absDeltaCW = 0, deltaCW = 0;
   for (int i = m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++)
   {
@@ -1080,7 +1080,7 @@ void EncReshape::adjustLmcsPivot()
   int bdShift = m_lumaBD - 10;
   int totCW = bdShift != 0 ? (bdShift > 0 ? m_reshapeLUTSize / (1 << bdShift) : m_reshapeLUTSize * (1 << (-bdShift))) : m_reshapeLUTSize;
   int orgCW = totCW / PIC_CODE_CW_BINS;
-  int log2SegSize = floorLog2(LMCS_SEG_SIZE);
+  int log2SegSize = m_lumaBD - floorLog2(LMCS_SEG_NUM);
 
   m_reshapePivot[0] = 0;
   for (int i = 0; i < PIC_CODE_CW_BINS; i++)
-- 
GitLab