diff --git a/source/Lib/CommonLib/Buffer.cpp b/source/Lib/CommonLib/Buffer.cpp index a773bd30664c756d70014d295fbfdc7e9a0dc726..6dd8562fe8119f8c48776a16c1431f44f1e53140 100644 --- a/source/Lib/CommonLib/Buffer.cpp +++ b/source/Lib/CommonLib/Buffer.cpp @@ -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); diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index 6d37b49542cebf6ca0ff73f6b19249b37067d5fb..e047a0c52aa609b4c011c2f2e1d5103d165146ae 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -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 diff --git a/source/Lib/CommonLib/Reshape.cpp b/source/Lib/CommonLib/Reshape.cpp index 85f06103e04aba3cdd177062214aed9fc4e2b613..d0416499292962937e1b89265cfb3aadf65aed84 100644 --- a/source/Lib/CommonLib/Reshape.cpp +++ b/source/Lib/CommonLib/Reshape.cpp @@ -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 } diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index bc180425445f7c099c68df25057fc1cc6c6c5f57..0e45110768324d93f2e2e0ca992d7f3002facec2 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -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