Commit 1f052c85 authored by Taoran Lu's avatar Taoran Lu

rebase

parent e9ffb8d9
......@@ -551,9 +551,9 @@ void EncApp::xInitLibCfg()
#endif
m_cEncLib.setUseALF ( m_alf );
#if JVET_M0427_INLOOP_RESHAPER
m_cEncLib.setReshaper ( m_bLumaReshapeEnable );
m_cEncLib.setReshapeSignalType ( m_uiSignalType );
m_cEncLib.setReshapeIntraCMD ( m_uiIntraCMD );
m_cEncLib.setReshaper ( m_lumaReshapeEnable );
m_cEncLib.setReshapeSignalType ( m_reshapeSignalType );
m_cEncLib.setReshapeIntraCMD ( m_intraCMD );
m_cEncLib.setReshapeCW ( m_reshapeCW );
#endif
}
......
......@@ -707,7 +707,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
#endif
int warnUnknowParameter = 0;
#if ENABLE_TRACING
string sTracingRule;
string sTracingFile;
......@@ -884,9 +883,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
// ADD_NEW_TOOL : (encoder app) add parsing parameters here
#if JVET_M0427_INLOOP_RESHAPER
("LumaReshapeEnable", m_bLumaReshapeEnable, false, "Enable Reshaping for Luma Channel")
("ReshapeSignalType", m_uiSignalType, 0u, "Input signal type: 0: SDR, 1:PQ, 2:HLG")
("IntraCMD", m_uiIntraCMD, 0u, "IntraChroma MD: 0: none, 1:fixed to default wPSNR weight")
("LumaReshapeEnable", m_lumaReshapeEnable, false, "Enable Reshaping for Luma Channel")
("ReshapeSignalType", m_reshapeSignalType, 0u, "Input signal type: 0: SDR, 1:PQ, 2:HLG")
("IntraCMD", m_intraCMD, 0u, "IntraChroma MD: 0: none, 1:fixed to default wPSNR weight")
#endif
("LCTUFast", m_useFastLCTU, false, "Fast methods for large CTU")
("FastMrg", m_useFastMrg, false, "Fast methods for inter merge")
......@@ -1842,13 +1841,13 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
}
#if JVET_M0427_INLOOP_RESHAPER
m_reshapeCW.BinCW.resize(CW_NUMS);
m_reshapeCW.RspFps = m_iFrameRate;
m_reshapeCW.RspIntraPeriod = m_iIntraPeriod;
m_reshapeCW.RspPicSize = m_iSourceWidth*m_iSourceHeight;
m_reshapeCW.binCW.resize(3);
m_reshapeCW.rspFps = m_iFrameRate;
m_reshapeCW.rspIntraPeriod = m_iIntraPeriod;
m_reshapeCW.rspPicSize = m_iSourceWidth*m_iSourceHeight;
const int FpsToIpTable[129] = { 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 128, 128, 128, 128, 128, 128, 128, 128, 128 };
m_reshapeCW.RspFpsToIp = FpsToIpTable[m_iFrameRate];
m_reshapeCW.RspBaseQP = m_iQP;
m_reshapeCW.rspFpsToIp = FpsToIpTable[m_iFrameRate];
m_reshapeCW.rspBaseQP = m_iQP;
#endif
#if ENABLE_TRACING
g_trace_ctx = tracing_init(sTracingFile, sTracingRule);
......@@ -2234,27 +2233,22 @@ bool EncAppCfg::xCheckParameter()
xConfirmPara( m_lumaLevelToDeltaQPMapping.mode && m_uiDeltaQpRD > 0, "Luma-level-based Delta QP cannot be used together with slice level multiple-QP optimization\n" );
#endif
#if JVET_M0427_INLOOP_RESHAPER
if (m_bLumaReshapeEnable && (m_internalBitDepth[CHANNEL_TYPE_LUMA] != 10))
{
m_bLumaReshapeEnable = false;
msg(WARNING, "Reshaping is turned off for luma internal bitdepth not equal to 10.\n");
}
if (!m_bLumaReshapeEnable)
if (!m_lumaReshapeEnable)
{
m_uiSignalType = RESHAPE_SIGNAL_NULL;
m_uiIntraCMD = 0;
m_reshapeSignalType = RESHAPE_SIGNAL_NULL;
m_intraCMD = 0;
}
if (m_bLumaReshapeEnable && m_uiSignalType == RESHAPE_SIGNAL_PQ)
if (m_lumaReshapeEnable && m_reshapeSignalType == RESHAPE_SIGNAL_PQ)
{
m_uiIntraCMD = 1;
m_intraCMD = 1;
}
else if (m_bLumaReshapeEnable && m_uiSignalType == RESHAPE_SIGNAL_SDR)
else if (m_lumaReshapeEnable && m_reshapeSignalType == RESHAPE_SIGNAL_SDR)
{
m_uiIntraCMD = 0;
m_intraCMD = 0;
}
else
{
m_bLumaReshapeEnable = false;
m_lumaReshapeEnable = false;
}
#endif
......@@ -3203,10 +3197,10 @@ void EncAppCfg::xPrintParameter()
}
// ADD_NEW_TOOL (add some output indicating the usage of tools)
#if JVET_M0427_INLOOP_RESHAPER
msg(VERBOSE, "Reshape:%d ", m_bLumaReshapeEnable);
if (m_bLumaReshapeEnable)
msg(VERBOSE, "Reshape:%d ", m_lumaReshapeEnable);
if (m_lumaReshapeEnable)
{
msg(VERBOSE, "(Sigal:%s ", m_uiSignalType==0? "SDR" : "HDR-PQ");
msg(VERBOSE, "(Sigal:%s ", m_reshapeSignalType==0? "SDR" : "HDR-PQ");
msg(VERBOSE, ") ");
}
#endif
......
......@@ -257,9 +257,9 @@ protected:
// ADD_NEW_TOOL : (encoder app) add tool enabling flags and associated parameters here
#if JVET_M0427_INLOOP_RESHAPER
bool m_bLumaReshapeEnable;
uint32_t m_uiSignalType;
uint32_t m_uiIntraCMD;
bool m_lumaReshapeEnable;
uint32_t m_reshapeSignalType;
uint32_t m_intraCMD;
ReshapeCW m_reshapeCW;
#endif
unsigned m_uiMaxCUWidth; ///< max. CU width in pixel
......
......@@ -404,12 +404,6 @@ static const int CHROMA_REFINEMENT_CANDIDATES = 8; /// 8 candidates BV to choose
static const int IBC_FAST_METHOD_NOINTRA_IBCCBF0 = 0x01;
static const int IBC_FAST_METHOD_BUFFERBV = 0X02;
static const int IBC_FAST_METHOD_ADAPTIVE_SEARCHRANGE = 0X04;
#if JVET_M0427_INLOOP_RESHAPER
static const int PIC_ANALYZE_CW_BINS = 32;
static const int PIC_CODE_CW_BINS = 16;
static const int FP_PREC = 14;
static const int CSCALE_FP_PREC = 11;
#endif
#if JVET_M0512_MOTION_BUFFER_COMPRESSION
static constexpr int MV_EXPONENT_BITCOUNT = 4;
static constexpr int MV_MANTISSA_BITCOUNT = 6;
......
......@@ -2942,7 +2942,7 @@ void RdCost::restoreReshapeLumaLevelToWeightTable()
}
}
void RdCost::updateReshapeLumaLevelToWeightTable(sliceReshapeInfo &sliceReshape, Pel *wtTable, double cwt)
void RdCost::updateReshapeLumaLevelToWeightTable(SliceReshapeInfo &sliceReshape, Pel *wtTable, double cwt)
{
if (m_signalType == RESHAPE_SIGNAL_SDR)
{
......@@ -2954,11 +2954,11 @@ void RdCost::updateReshapeLumaLevelToWeightTable(sliceReshapeInfo &sliceReshape,
for (int i = 0; i < PIC_CODE_CW_BINS; i++)
{
if ((i < sliceReshape.reshape_model_min_bin_idx) || (i > sliceReshape.reshape_model_max_bin_idx))
if ((i < sliceReshape.reshaperModelMinBinIdx) || (i > sliceReshape.reshaperModelMaxBinIdx))
weight = 1.0;
else
{
if (sliceReshape.reshape_model_bin_CW_delta[i] == 1 || (sliceReshape.reshape_model_bin_CW_delta[i] == -1 * histLens))
if (sliceReshape.reshaperModelBinCWDelta[i] == 1 || (sliceReshape.reshaperModelBinCWDelta[i] == -1 * histLens))
weight = wBin;
else
{
......
......@@ -304,7 +304,7 @@ public:
void restoreReshapeLumaLevelToWeightTable ();
inline double getWPSNRReshapeLumaLevelWeight (int val) { return m_reshapeLumaLevelToWeightPLUT[val]; }
void setReshapeInfo (uint32_t type, int lumaBD) { m_signalType = type; m_lumaBD = lumaBD; }
void updateReshapeLumaLevelToWeightTable (sliceReshapeInfo &sliceReshape, Pel *wtTable, double cwt);
void updateReshapeLumaLevelToWeightTable (SliceReshapeInfo &sliceReshape, Pel *wtTable, double cwt);
inline std::vector<double>& getLumaLevelWeightTable () { return m_lumaLevelToWeightPLUT; }
#endif
#endif
......
......@@ -48,9 +48,9 @@
Reshape::Reshape()
{
m_bCTUFlag = false;
m_bRecReshaped = false;
m_bReshape = true;
m_CTUFlag = false;
m_recReshaped = false;
m_reshape = true;
}
Reshape::~Reshape()
......@@ -62,10 +62,10 @@ void Reshape::createDec(int bitDepth)
m_lumaBD = bitDepth;
m_reshapeLUTSize = 1 << m_lumaBD;
m_initCW = m_reshapeLUTSize / PIC_CODE_CW_BINS;
if (forwardReshapingLUT.empty())
forwardReshapingLUT.resize(m_reshapeLUTSize, 0);
if (inverseReshapingLUT.empty())
inverseReshapingLUT.resize(m_reshapeLUTSize, 0);
if (m_fwdLUT.empty())
m_fwdLUT.resize(m_reshapeLUTSize, 0);
if (m_invLUT.empty())
m_invLUT.resize(m_reshapeLUTSize, 0);
if (m_binCW.empty())
m_binCW.resize(PIC_CODE_CW_BINS, 0);
if (m_reshapePivot.empty())
......@@ -87,8 +87,8 @@ void Reshape::destroy()
void Reshape::reverseLUT(std::vector<Pel>& inputLUT, std::vector<Pel>& outputLUT, uint16_t lutSize)
{
int i, j;
outputLUT[m_reshapePivot[m_sliceReshapeInfo.reshape_model_min_bin_idx]] = m_sliceReshapeInfo.reshape_model_min_bin_idx*m_initCW;
for (i = m_sliceReshapeInfo.reshape_model_min_bin_idx; i <= m_sliceReshapeInfo.reshape_model_max_bin_idx; i++)
outputLUT[m_reshapePivot[m_sliceReshapeInfo.reshaperModelMinBinIdx]] = m_sliceReshapeInfo.reshaperModelMinBinIdx*m_initCW;
for (i = m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++)
{
int16_t X1 = m_reshapePivot[i];
int16_t X2 = m_reshapePivot[i + 1];
......@@ -106,12 +106,12 @@ void Reshape::reverseLUT(std::vector<Pel>& inputLUT, std::vector<Pel>& outputLUT
}
}
for (i = 0; i < m_reshapePivot[m_sliceReshapeInfo.reshape_model_min_bin_idx]; i++)
outputLUT[i] = outputLUT[m_reshapePivot[m_sliceReshapeInfo.reshape_model_min_bin_idx]];
for (i = m_reshapePivot[m_sliceReshapeInfo.reshape_model_max_bin_idx + 1]; i < m_reshapeLUTSize; i++)
outputLUT[i] = outputLUT[m_reshapePivot[m_sliceReshapeInfo.reshape_model_max_bin_idx + 1]];
for (i = 0; i < m_reshapePivot[m_sliceReshapeInfo.reshaperModelMinBinIdx]; i++)
outputLUT[i] = outputLUT[m_reshapePivot[m_sliceReshapeInfo.reshaperModelMinBinIdx]];
for (i = m_reshapePivot[m_sliceReshapeInfo.reshaperModelMaxBinIdx + 1]; i < m_reshapeLUTSize; i++)
outputLUT[i] = outputLUT[m_reshapePivot[m_sliceReshapeInfo.reshaperModelMaxBinIdx + 1]];
bool clipRange = ((m_sliceReshapeInfo.reshape_model_min_bin_idx > 0) && (m_sliceReshapeInfo.reshape_model_max_bin_idx < (PIC_CODE_CW_BINS - 1)));
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]);
......@@ -139,13 +139,13 @@ int Reshape::calculateChromaAdj(Pel avgLuma)
int Reshape::getPWLIdxInv(int lumaVal)
{
int idxS = 0;
if (lumaVal < m_reshapePivot[m_sliceReshapeInfo.reshape_model_min_bin_idx + 1])
return m_sliceReshapeInfo.reshape_model_min_bin_idx;
else if (lumaVal >= m_reshapePivot[m_sliceReshapeInfo.reshape_model_max_bin_idx])
return m_sliceReshapeInfo.reshape_model_max_bin_idx;
if (lumaVal < m_reshapePivot[m_sliceReshapeInfo.reshaperModelMinBinIdx + 1])
return m_sliceReshapeInfo.reshaperModelMinBinIdx;
else if (lumaVal >= m_reshapePivot[m_sliceReshapeInfo.reshaperModelMaxBinIdx])
return m_sliceReshapeInfo.reshaperModelMaxBinIdx;
else
{
for (idxS = m_sliceReshapeInfo.reshape_model_min_bin_idx; (idxS < m_sliceReshapeInfo.reshape_model_max_bin_idx); idxS++)
for (idxS = m_sliceReshapeInfo.reshaperModelMinBinIdx; (idxS < m_sliceReshapeInfo.reshaperModelMaxBinIdx); idxS++)
{
if (lumaVal < m_reshapePivot[idxS + 1]) break;
}
......@@ -158,21 +158,21 @@ int Reshape::getPWLIdxInv(int lumaVal)
\param tInfo describing the target Slice reshaper info structure
\param sInfo describing the source Slice reshaper info structure
*/
void Reshape::copySliceReshaperInfo(sliceReshapeInfo& tInfo, sliceReshapeInfo& sInfo)
void Reshape::copySliceReshaperInfo(SliceReshapeInfo& tInfo, SliceReshapeInfo& sInfo)
{
tInfo.slice_reshaper_model_present_flag = sInfo.slice_reshaper_model_present_flag;
if (sInfo.slice_reshaper_model_present_flag)
tInfo.sliceReshaperModelPresentFlag = sInfo.sliceReshaperModelPresentFlag;
if (sInfo.sliceReshaperModelPresentFlag)
{
tInfo.reshape_model_max_bin_idx = sInfo.reshape_model_max_bin_idx;
tInfo.reshape_model_min_bin_idx = sInfo.reshape_model_min_bin_idx;
memcpy(tInfo.reshape_model_bin_CW_delta, sInfo.reshape_model_bin_CW_delta, sizeof(int)*(PIC_CODE_CW_BINS));
tInfo.reshaperModelMaxBinIdx = sInfo.reshaperModelMaxBinIdx;
tInfo.reshaperModelMinBinIdx = sInfo.reshaperModelMinBinIdx;
memcpy(tInfo.reshaperModelBinCWDelta, sInfo.reshaperModelBinCWDelta, sizeof(int)*(PIC_CODE_CW_BINS));
tInfo.maxNbitsNeededDeltaCW = sInfo.maxNbitsNeededDeltaCW;
}
tInfo.slice_reshaper_enable_flag = sInfo.slice_reshaper_enable_flag;
if (sInfo.slice_reshaper_enable_flag)
tInfo.uiReshapeChromaAdj = sInfo.uiReshapeChromaAdj;
tInfo.sliceReshaperEnableFlag = sInfo.sliceReshaperEnableFlag;
if (sInfo.sliceReshaperEnableFlag)
tInfo.enableChromaAdj = sInfo.enableChromaAdj;
else
tInfo.uiReshapeChromaAdj = 0;
tInfo.enableChromaAdj = 0;
}
/** Construct reshaper from syntax
......@@ -184,12 +184,12 @@ void Reshape::constructReshaper()
int pwlFwdLUTsize = PIC_CODE_CW_BINS;
int pwlFwdBinLen = m_reshapeLUTSize / PIC_CODE_CW_BINS;
for (int i = 0; i < m_sliceReshapeInfo.reshape_model_min_bin_idx; i++)
for (int i = 0; i < m_sliceReshapeInfo.reshaperModelMinBinIdx; i++)
m_binCW[i] = 0;
for (int i = m_sliceReshapeInfo.reshape_model_max_bin_idx + 1; i < PIC_CODE_CW_BINS; i++)
for (int i = m_sliceReshapeInfo.reshaperModelMaxBinIdx + 1; i < PIC_CODE_CW_BINS; i++)
m_binCW[i] = 0;
for (int i = m_sliceReshapeInfo.reshape_model_min_bin_idx; i <= m_sliceReshapeInfo.reshape_model_max_bin_idx; i++)
m_binCW[i] = (uint16_t)(m_sliceReshapeInfo.reshape_model_bin_CW_delta[i] + (int)m_initCW);
for (int i = m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++)
m_binCW[i] = (uint16_t)(m_sliceReshapeInfo.reshaperModelBinCWDelta[i] + (int)m_initCW);
for (int i = 0; i < pwlFwdLUTsize; i++)
{
......@@ -197,32 +197,32 @@ void Reshape::constructReshaper()
int16_t Y1 = m_reshapePivot[i];
int16_t Y2 = m_reshapePivot[i + 1];
forwardReshapingLUT[i*pwlFwdBinLen] = Clip3((Pel)0, (Pel)((1 << m_lumaBD) - 1), (Pel)Y1);
m_fwdLUT[i*pwlFwdBinLen] = Clip3((Pel)0, (Pel)((1 << m_lumaBD) - 1), (Pel)Y1);
int log2_pwlFwdBinLen = g_aucLog2[pwlFwdBinLen];
int log2PwlFwdBinLen = g_aucLog2[pwlFwdBinLen];
int32_t scale = ((int32_t)(Y2 - Y1) * (1 << FP_PREC) + (1 << (log2_pwlFwdBinLen - 1))) >> (log2_pwlFwdBinLen);
int32_t scale = ((int32_t)(Y2 - Y1) * (1 << FP_PREC) + (1 << (log2PwlFwdBinLen - 1))) >> (log2PwlFwdBinLen);
for (int j = 1; j < pwlFwdBinLen; j++)
{
int tempVal = Y1 + (((int32_t)scale * (int32_t)j + (1 << (FP_PREC - 1))) >> FP_PREC);
forwardReshapingLUT[i*pwlFwdBinLen + j] = Clip3((Pel)0, (Pel)((1 << m_lumaBD) - 1), (Pel)tempVal);
m_fwdLUT[i*pwlFwdBinLen + j] = Clip3((Pel)0, (Pel)((1 << m_lumaBD) - 1), (Pel)tempVal);
}
}
reverseLUT(forwardReshapingLUT, inverseReshapingLUT, m_reshapeLUTSize);
updateChromaDQPLUT();
reverseLUT(m_fwdLUT, m_invLUT, m_reshapeLUTSize);
updateChromaScaleLUT();
}
/** generate chroma residue scaling LUT
* \param void
* \return void
*/
void Reshape::updateChromaDQPLUT()
void Reshape::updateChromaScaleLUT()
{
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++)
{
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 ((i < m_sliceReshapeInfo.reshape_model_min_bin_idx) || (i > m_sliceReshapeInfo.reshape_model_max_bin_idx))
if ((i < m_sliceReshapeInfo.reshaperModelMinBinIdx) || (i > m_sliceReshapeInfo.reshaperModelMaxBinIdx))
m_chromaAdjHelpLUT[i] = 1 << CSCALE_FP_PREC;
else
m_chromaAdjHelpLUT[i] = CW_bin_SC_LUT[Clip3((uint16_t)1, (uint16_t)64, (uint16_t)(binCW >> 1)) - 1];
......
......@@ -55,15 +55,15 @@
class Reshape
{
protected:
sliceReshapeInfo m_sliceReshapeInfo;
bool m_bCTUFlag;
bool m_bRecReshaped;
std::vector<Pel> inverseReshapingLUT;
std::vector<Pel> forwardReshapingLUT;
SliceReshapeInfo m_sliceReshapeInfo;
bool m_CTUFlag;
bool m_recReshaped;
std::vector<Pel> m_invLUT;
std::vector<Pel> m_fwdLUT;
std::vector<int> m_chromaAdjHelpLUT;
std::vector<uint16_t> m_binCW;
uint16_t m_initCW;
bool m_bReshape;
bool m_reshape;
std::vector<Pel> m_reshapePivot;
int m_lumaBD;
int m_reshapeLUTSize;
......@@ -75,24 +75,24 @@ public:
void destroy();
void reverseLUT(std::vector<Pel>& inputLUT, std::vector<Pel>& outputLUT, uint16_t lutSize);
std::vector<Pel>& getFwdLUT() { return forwardReshapingLUT; }
std::vector<Pel>& getInvLUT() { return inverseReshapingLUT; }
std::vector<Pel>& getFwdLUT() { return m_fwdLUT; }
std::vector<Pel>& getInvLUT() { return m_invLUT; }
std::vector<int>& getChromaAdjHelpLUT() { return m_chromaAdjHelpLUT; }
bool getCTUFlag() { return m_bCTUFlag; }
void setCTUFlag(bool bCTUFlag) { m_bCTUFlag = bCTUFlag; }
bool getCTUFlag() { return m_CTUFlag; }
void setCTUFlag(bool b ) { m_CTUFlag = b; }
bool getRecReshaped() { return m_bRecReshaped; }
void setRecReshaped(bool bPicReshaped) { m_bRecReshaped = bPicReshaped; }
bool getRecReshaped() { return m_recReshaped; }
void setRecReshaped(bool b) { m_recReshaped = b; }
int calculateChromaAdj(Pel avgLuma);
int getPWLIdxInv(int lumaVal);
sliceReshapeInfo& getSliceReshaperInfo() { return m_sliceReshapeInfo; }
void copySliceReshaperInfo(sliceReshapeInfo& tInfo, sliceReshapeInfo& sInfo);
SliceReshapeInfo& getSliceReshaperInfo() { return m_sliceReshapeInfo; }
void copySliceReshaperInfo(SliceReshapeInfo& tInfo, SliceReshapeInfo& sInfo);
void constructReshaper();
void updateChromaDQPLUT();
bool getReshapeFlag() { return m_bReshape; }
void setReshapeFlag(bool val) { m_bReshape = val; }
void updateChromaScaleLUT();
bool getReshapeFlag() { return m_reshape; }
void setReshapeFlag(bool b) { m_reshape = b; }
};// END CLASS DEFINITION Reshape
//! \}
......
......@@ -185,9 +185,9 @@ Slice::Slice()
m_sliceReshapeInfo.setUseSliceReshaper(false);
m_sliceReshapeInfo.setSliceReshapeModelPresentFlag(false);
m_sliceReshapeInfo.setSliceReshapeChromaAdj(0);
m_sliceReshapeInfo.reshape_model_min_bin_idx = 0;
m_sliceReshapeInfo.reshape_model_max_bin_idx = PIC_CODE_CW_BINS - 1;
memset(m_sliceReshapeInfo.reshape_model_bin_CW_delta, 0, PIC_CODE_CW_BINS * sizeof(int));
m_sliceReshapeInfo.reshaperModelMinBinIdx = 0;
m_sliceReshapeInfo.reshaperModelMaxBinIdx = PIC_CODE_CW_BINS - 1;
memset(m_sliceReshapeInfo.reshaperModelBinCWDelta, 0, PIC_CODE_CW_BINS * sizeof(int));
#endif
}
......@@ -1902,7 +1902,7 @@ SPS::SPS()
, m_wrapAroundEnabledFlag (false)
, m_wrapAroundOffset ( 0)
#if JVET_M0427_INLOOP_RESHAPER
, m_bUseReshape (false)
, m_lumaReshapeEnable (false)
#endif
{
for(int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
......
......@@ -292,34 +292,34 @@ struct HrdSubLayerInfo
};
#if JVET_M0427_INLOOP_RESHAPER
class sliceReshapeInfo
class SliceReshapeInfo
{
public:
bool slice_reshaper_enable_flag;
bool slice_reshaper_model_present_flag;
unsigned uiReshapeChromaAdj;
uint32_t reshape_model_min_bin_idx;
uint32_t reshape_model_max_bin_idx;
int reshape_model_bin_CW_delta[PIC_CODE_CW_BINS];
bool sliceReshaperEnableFlag;
bool sliceReshaperModelPresentFlag;
unsigned enableChromaAdj;
uint32_t reshaperModelMinBinIdx;
uint32_t reshaperModelMaxBinIdx;
int reshaperModelBinCWDelta[PIC_CODE_CW_BINS];
int maxNbitsNeededDeltaCW;
void setUseSliceReshaper(bool b_useSliceReshaper) { slice_reshaper_enable_flag = b_useSliceReshaper; }
bool getUseSliceReshaper() const { return slice_reshaper_enable_flag; }
void setSliceReshapeModelPresentFlag(bool bflag) { slice_reshaper_model_present_flag = bflag; }
bool getSliceReshapeModelPresentFlag() const { return slice_reshaper_model_present_flag; }
void setSliceReshapeChromaAdj(unsigned uiChromaAdj) { uiReshapeChromaAdj = uiChromaAdj; }
unsigned getSliceReshapeChromaAdj() const { return uiReshapeChromaAdj; }
void setUseSliceReshaper(bool b) { sliceReshaperEnableFlag = b; }
bool getUseSliceReshaper() const { return sliceReshaperEnableFlag; }
void setSliceReshapeModelPresentFlag(bool b) { sliceReshaperModelPresentFlag = b; }
bool getSliceReshapeModelPresentFlag() const { return sliceReshaperModelPresentFlag; }
void setSliceReshapeChromaAdj(unsigned adj) { enableChromaAdj = adj; }
unsigned getSliceReshapeChromaAdj() const { return enableChromaAdj; }
};
struct ReshapeCW
{
std::vector<uint32_t> BinCW;
int RspPicSize;
int RspIntraPeriod;
int RspFps;
int RspBaseQP;
int Tid;
int SliceQP;
int RspFpsToIp;
std::vector<uint32_t> binCW;
int rspPicSize;
int rspIntraPeriod;
int rspFps;
int rspBaseQP;
int rspTid;
int rspSliceQP;
int rspFpsToIp;
};
#endif
......@@ -1066,7 +1066,7 @@ private:
bool m_wrapAroundEnabledFlag;
unsigned m_wrapAroundOffset;
#if JVET_M0427_INLOOP_RESHAPER
bool m_bUseReshape;
bool m_lumaReshapeEnable;
#endif
public:
......@@ -1287,8 +1287,8 @@ public:
void setWrapAroundOffset(unsigned offset) { m_wrapAroundOffset = offset; }
unsigned getWrapAroundOffset() const { return m_wrapAroundOffset; }
#if JVET_M0427_INLOOP_RESHAPER
void setUseReshaper(bool b) { m_bUseReshape = b; }
bool getUseReshaper() const { return m_bUseReshape; }
void setUseReshaper(bool b) { m_lumaReshapeEnable = b; }
bool getUseReshaper() const { return m_lumaReshapeEnable; }
#endif
};
......@@ -1719,13 +1719,10 @@ private:
AlfSliceParam m_alfSliceParam;
LutMotionCand* m_MotionCandLut;
#if JVET_M0170_MRG_SHARELIST
#if JVET_M0427_INLOOP_RESHAPER
sliceReshapeInfo m_sliceReshapeInfo;
#endif
#if JVET_M0427_INLOOP_RESHAPER
sliceReshapeInfo m_sliceReshapeInfo;
SliceReshapeInfo m_sliceReshapeInfo;
#endif
#if JVET_M0170_MRG_SHARELIST
public:
LutMotionCand* m_MotionCandLuTsBkup;
#endif
......@@ -2026,8 +2023,8 @@ public:
void updateMotionLUTs(LutMotionCand* lutMC, CodingUnit & cu);
void copyMotionLUTs(LutMotionCand* Src, LutMotionCand* Dst);
#if JVET_M0427_INLOOP_RESHAPER
const sliceReshapeInfo& getReshapeInfo() const { return m_sliceReshapeInfo; }
sliceReshapeInfo& getReshapeInfo() { return m_sliceReshapeInfo; }
const SliceReshapeInfo& getReshapeInfo() const { return m_sliceReshapeInfo; }
SliceReshapeInfo& getReshapeInfo() { return m_sliceReshapeInfo; }
#endif
protected:
Picture* xGetRefPic (PicList& rcListPic, int poc);
......
......@@ -562,7 +562,7 @@ void TransformUnit::initData()
emtIdx = 0;
#endif
#if JVET_M0427_INLOOP_RESHAPER
m_iChromaAdj = 0;
m_chromaResScaleInv = 0;
#endif
}
......@@ -642,6 +642,6 @@ const CCoeffBuf TransformUnit::getCoeffs(const ComponentID id) const { return CC
PelBuf TransformUnit::getPcmbuf(const ComponentID id) { return PelBuf (m_pcmbuf[id], blocks[id]); }
const CPelBuf TransformUnit::getPcmbuf(const ComponentID id) const { return CPelBuf (m_pcmbuf[id], blocks[id]); }
#if JVET_M0427_INLOOP_RESHAPER
int TransformUnit::getChromaAdj() const { return m_iChromaAdj; }
void TransformUnit::setChromaAdj(int iChromaAdj) { m_iChromaAdj = iChromaAdj; }
int TransformUnit::getChromaAdj() const { return m_chromaResScaleInv; }
void TransformUnit::setChromaAdj(int i) { m_chromaResScaleInv = i; }
#endif
\ No newline at end of file
......@@ -317,9 +317,6 @@ struct CodingUnit : public UnitArea
Size shareParentSize;
#endif
bool ibc;
#if JVET_M0444_SMVD
uint8_t smvdMode;
#endif
#if JVET_M0444_SMVD
uint8_t smvdMode;
#endif
......@@ -439,7 +436,7 @@ struct TransformUnit : public UnitArea
CodingStructure *cs;
ChannelType chType;
#if JVET_M0427_INLOOP_RESHAPER
int m_iChromaAdj;
int m_chromaResScaleInv;
#endif
uint8_t depth;
......@@ -475,7 +472,7 @@ struct TransformUnit : public UnitArea
const CPelBuf getPcmbuf(const ComponentID id) const;
#if JVET_M0427_INLOOP_RESHAPER
int getChromaAdj( ) const;
void setChromaAdj(int iChromaAdj);
void setChromaAdj(int i);
#endif
#if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISM
......
......@@ -211,7 +211,7 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
}
#if JVET_M0427_INLOOP_RESHAPER
const Slice &slice = *cs.slice;
bool bFlag = slice.getReshapeInfo().getUseSliceReshaper() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag() ) || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getCPRMode()));
bool bFlag = slice.getReshapeInfo().getUseSliceReshaper() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag() ) || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getIBCMode()));
if (bFlag && slice.getReshapeInfo().getSliceReshapeChromaAdj() && (compID != COMPONENT_Y))
{
......@@ -260,7 +260,7 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size());
PelBuf tmpPred;
#endif
if (slice.getReshapeInfo().getUseSliceReshaper() && (m_pcReshape->getCTUFlag() || slice.isIntra() || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getCPRMode())) && compID == COMPONENT_Y)
if (slice.getReshapeInfo().getUseSliceReshaper() && (m_pcReshape->getCTUFlag() || slice.isIntra() || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getIBCMode())) && compID == COMPONENT_Y)
{
#if REUSE_CU_RESULTS
{
......@@ -279,7 +279,7 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
pReco.copyFrom( piPred );
#endif
#if JVET_M0427_INLOOP_RESHAPER
if (slice.getReshapeInfo().getUseSliceReshaper() && (m_pcReshape->getCTUFlag() || slice.isIntra() || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getCPRMode())) && compID == COMPONENT_Y)
if (slice.getReshapeInfo().getUseSliceReshaper() && (m_pcReshape->getCTUFlag() || slice.isIntra() || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getIBCMode())) && compID == COMPONENT_Y)
{
#if REUSE_CU_RESULTS
{
......@@ -504,7 +504,7 @@ void DecCu::xReconInter(CodingUnit &cu)
tmpPred.copyFrom(cs.getPredBuf(cu).get(COMPONENT_Y));
}
#endif
if (!cu.firstPU->mhIntraFlag && !cu.cpr )
if (!cu.firstPU->mhIntraFlag && !cu.ibc )
cs.getPredBuf(cu).get(COMPONENT_Y).rspSignal(m_pcReshape->getFwdLUT());
}
#endif
......@@ -530,7 +530,7 @@ void DecCu::xReconInter(CodingUnit &cu)
{
cs.getRecoBuf(cu).copyClip(cs.getPredBuf(cu), cs.slice->clpRngs());
#if JVET_M0427_INLOOP_RESHAPER
if (cs.slice->getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag() && !cu.firstPU->mhIntraFlag && !cu.cpr)
if (cs.slice->getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag() && !cu.firstPU->mhIntraFlag && !cu.ibc)
{
cs.getRecoBuf(cu).get(COMPONENT_Y).rspSignal(m_pcReshape->getFwdLUT());
}
......@@ -604,7 +604,7 @@ void DecCu::xDecodeInterTexture(CodingUnit &cu)
CompArea tmpArea(COMPONENT_Y, areaY.chromaFormat, Position(0, 0), areaY.size());
PelBuf tmpPred = m_tmpStorageLCU->getBuf(tmpArea);
tmpPred.copyFrom(piPredY);
if (!cu.firstPU->mhIntraFlag && !cu.cpr)
if (!cu.firstPU->mhIntraFlag && !cu.ibc)
tmpPred.rspSignal(m_pcReshape->getFwdLUT());
const Pel avgLuma = tmpPred.computeAvg();
int adj = m_pcReshape->calculateChromaAdj(avgLuma);
......
......@@ -1271,7 +1271,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl
{
m_cReshaper.setReshapeFlag(false);
}
if ((pcSlice->getSliceType() == I_SLICE|| (pcSlice->getSliceType() == P_SLICE && pcSlice->getSPS()->getSpsNext().getCPRMode()) ) && m_cReshaper.getSliceReshaperInfo().getUseSliceReshaper())
if ((pcSlice->getSliceType() == I_SLICE|| (pcSlice->getSliceType() == P_SLICE && pcSlice->getSPS()->getSpsNext().getIBCMode()) ) && m_cReshaper.getSliceReshaperInfo().getUseSliceReshaper())
{
m_cReshaper.setCTUFlag(false);
m_cReshaper.setRecReshaped(true);
......
......@@ -854,32 +854,30 @@ void HLSyntaxReader::parseSPSNext( SPSNext& spsNext, const bool usePCM )
}
#if JVET_M0427_INLOOP_RESHAPER
void HLSyntaxReader::parseReshaper(sliceReshapeInfo& info, const SPS* pcSPS, const bool isIntra)
void HLSyntaxReader::parseReshaper(SliceReshapeInfo& info, const SPS* pcSPS, const bool isIntra)
{
unsigned symbol = 0;
READ_FLAG(symbol, "slice_reshape_model_present_flag"); info.setSliceReshapeModelPresentFlag(symbol == 1);
READ_FLAG(symbol, "tile_group_reshaper_model_present_flag"); info.setSliceReshapeModelPresentFlag(symbol == 1);
if (info.getSliceReshapeModelPresentFlag())