Commit 93a5dee9 authored by Taoran Lu's avatar Taoran Lu Committed by Xiang Li

N0220 LMCS simplifications

parent 1a33f26e
......@@ -407,6 +407,9 @@ void AreaBuf<Pel>::scaleSignal(const int scale, const bool dir, const ClpRng& cl
{
for (unsigned x = 0; x < width; x++)
{
#if JVET_N0220_LMCS_SIMPLIFICATION
src[x] = (Pel)Clip3((Pel)(-maxAbsclipBD - 1), (Pel)maxAbsclipBD, src[x]);
#endif
sign = src[x] >= 0 ? 1 : -1;
absval = sign * src[x];
int val = sign * ((absval * scale + (1 << (CSCALE_FP_PREC - 1))) >> CSCALE_FP_PREC);
......
......@@ -419,7 +419,11 @@ static constexpr int MV_MANTISSA_LIMIT = (1 << (MV_MANTISSA_BITCOUNT - 1))
static constexpr int MV_EXPONENT_MASK = ((1 << MV_EXPONENT_BITCOUNT) - 1);
static const int PIC_ANALYZE_CW_BINS = 32;
static const int PIC_CODE_CW_BINS = 16;
#if JVET_N0220_LMCS_SIMPLIFICATION
static const int FP_PREC = 11;
#else
static const int FP_PREC = 14;
#endif
static const int CSCALE_FP_PREC = 11;
// ====================================================================================================================
// Macro functions
......
......@@ -110,12 +110,19 @@ void Reshape::reverseLUT(std::vector<Pel>& inputLUT, std::vector<Pel>& outputLUT
for (i = m_reshapePivot[m_sliceReshapeInfo.reshaperModelMaxBinIdx + 1]; i < m_reshapeLUTSize; i++)
outputLUT[i] = outputLUT[m_reshapePivot[m_sliceReshapeInfo.reshaperModelMaxBinIdx + 1]];
#if JVET_N0220_LMCS_SIMPLIFICATION
for (i = 0; i < lutSize; i++)
{
outputLUT[i] = Clip3((Pel)0, (Pel)((1<<m_lumaBD)-1), outputLUT[i]);
}
#else
bool clipRange = ((m_sliceReshapeInfo.reshaperModelMinBinIdx > 0) && (m_sliceReshapeInfo.reshaperModelMaxBinIdx < (PIC_CODE_CW_BINS - 1)));
for (i = 0; i < lutSize; i++)
{
if (clipRange) outputLUT[i] = Clip3((Pel)(16<<(m_lumaBD-8)), (Pel)(235<<(m_lumaBD-8)), outputLUT[i]);
else outputLUT[i] = Clip3((Pel)0, (Pel)((1<<m_lumaBD)-1), outputLUT[i]);
}
#endif
}
......@@ -217,6 +224,16 @@ void Reshape::constructReshaper()
*/
void Reshape::updateChromaScaleLUT()
{
#if JVET_N0220_LMCS_SIMPLIFICATION
for (int i = 0; i < PIC_CODE_CW_BINS; i++)
{
uint16_t binCW = m_lumaBD > 10 ? (m_binCW[i] >> (m_lumaBD - 10)) : m_lumaBD < 10 ? (m_binCW[i] << (10 -m_lumaBD)): m_binCW[i];
if (binCW == 0)
m_chromaAdjHelpLUT[i] = 1 << CSCALE_FP_PREC;
else
m_chromaAdjHelpLUT[i] = m_initCW * (1 << CSCALE_FP_PREC) / binCW;
}
#else
const int16_t CW_bin_SC_LUT[2 * PIC_ANALYZE_CW_BINS] = { 16384, 16384, 16384, 16384, 16384, 16384, 16384, 8192, 8192, 8192, 8192, 5461, 5461, 5461, 5461, 4096, 4096, 4096, 4096, 3277, 3277, 3277, 3277, 2731, 2731, 2731, 2731, 2341, 2341, 2341, 2048, 2048, 2048, 1820, 1820, 1820, 1638, 1638, 1638, 1638, 1489, 1489, 1489, 1489, 1365, 1365, 1365, 1365, 1260, 1260, 1260, 1260, 1170, 1170, 1170, 1170, 1092, 1092, 1092, 1092, 1024, 1024, 1024, 1024 }; //p=11
for (int i = 0; i < PIC_CODE_CW_BINS; i++)
{
......@@ -226,6 +243,7 @@ void Reshape::updateChromaScaleLUT()
else
m_chromaAdjHelpLUT[i] = CW_bin_SC_LUT[Clip3((uint16_t)1, (uint16_t)64, (uint16_t)(binCW >> 1)) - 1];
}
#endif
}
......
......@@ -50,6 +50,8 @@
#include <assert.h>
#include <cassert>
#define JVET_N0220_LMCS_SIMPLIFICATION 1
#define JCTVC_Y0038_PARAMS 1
#define JVET_MMVD_OFF_MACRO 0
......
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