Commit afb62348 authored by Zhi-Yi Lin's avatar Zhi-Yi Lin Committed by Xiang Li

JVET-O0272: CE2-related: Simplified inverse luma mapping

parent f865549a
......@@ -445,6 +445,9 @@ static constexpr int MV_MIN = -(1 << (MV_BITS - 1));
static const int PIC_ANALYZE_CW_BINS = 32;
static const int PIC_CODE_CW_BINS = 16;
#if JVET_O0272_LMCS_SIMP_INVERSE_MAPPING
static const int LMCS_SEG_SIZE = (PIC_CODE_CW_BINS << 1);
#endif
static const int FP_PREC = 11;
static const int CSCALE_FP_PREC = 11;
#if JVET_O1109_UNFIY_CRS
......
......@@ -52,6 +52,8 @@
#define JVET_O0216_ALF_COEFF_EG3 1 // JVET-O0216/O0302/O0648: using EG3 for ALF coefficients coding
#define JVET_O0272_LMCS_SIMP_INVERSE_MAPPING 1 // JVET-O0272: LMCS simplified inverse mapping
#define JVET_O0247_ALF_CTB_CODING_REDUNDANCY_REMOVAL 1 // JVET-O0247: not signal APS index when number APS is 2
#define JVET_O0637_CHROMA_GRADIENT_LINE_SELECTION 1 // Choose line0 and line3 for gradient computation when chroma is same size as luma
......
......@@ -1054,6 +1054,10 @@ void EncReshape::initLUTfromdQPModel()
}
#endif
#if JVET_O0272_LMCS_SIMP_INVERSE_MAPPING
adjustLmcsPivot();
#endif
int maxAbsDeltaCW = 0, absDeltaCW = 0, deltaCW = 0;
for (int i = m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++)
{
......@@ -1261,6 +1265,11 @@ void EncReshape::constructReshaperSDR()
{
m_binCW[i] = m_binCW[2 * i] + m_binCW[2 * i + 1];
}
#if JVET_O0272_LMCS_SIMP_INVERSE_MAPPING
adjustLmcsPivot();
#endif
m_sliceReshapeInfo.reshaperModelMinBinIdx = 0;
m_sliceReshapeInfo.reshaperModelMaxBinIdx = PIC_CODE_CW_BINS - 1;
for (int i = 0; i < PIC_CODE_CW_BINS; i++)
......@@ -1361,6 +1370,44 @@ void EncReshape::constructReshaperSDR()
#endif
}
#if JVET_O0272_LMCS_SIMP_INVERSE_MAPPING
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 = g_aucLog2[LMCS_SEG_SIZE];
m_reshapePivot[0] = 0;
for (int i = 0; i < PIC_CODE_CW_BINS; i++)
{
m_reshapePivot[i+1] = m_reshapePivot[i] + m_binCW[i];
int segIdxCurr = (m_reshapePivot[i] >> log2SegSize);
int segIdxNext = (m_reshapePivot[i + 1] >> log2SegSize);
if ((segIdxCurr == segIdxNext) && (m_reshapePivot[i] != m_reshapePivot[i + 1]) && (m_reshapePivot[i] != (segIdxCurr << log2SegSize)))
{
int16_t adjustVal = ((segIdxCurr + 1) << log2SegSize) - m_reshapePivot[i + 1];
m_reshapePivot[i + 1] += adjustVal;
m_binCW[i] += adjustVal;
for (int j = i + 1; j < PIC_CODE_CW_BINS; j++)
{
if (m_binCW[j] < (adjustVal + (orgCW >> 3)))
{
adjustVal -= (m_binCW[j] - (orgCW >> 3));
m_binCW[j] = (orgCW >> 3);
}
else
{
m_binCW[j] -= adjustVal;
adjustVal = 0;
}
if (adjustVal == 0)
break;
}
}
}
}
#endif
#if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISM
void EncReshape::copyState(const EncReshape &other)
{
......
......@@ -93,6 +93,9 @@ public:
ReshapeCW * getReshapeCW() { return &m_reshapeCW; }
Pel * getWeightTable() { return m_cwLumaWeight; }
double getCWeight() { return m_chromaWeight; }
#if JVET_O0272_LMCS_SIMP_INVERSE_MAPPING
void adjustLmcsPivot();
#endif
#if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISM
void copyState(const EncReshape& other);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment