diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index 8b3740b345015e261bacc287e875a2919acad882..88adc04e6f834a4e8f65605dee16344a4b23982e 100644 --- a/source/Lib/DecoderLib/DecCu.cpp +++ b/source/Lib/DecoderLib/DecCu.cpp @@ -214,8 +214,11 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) } #if JVET_M0427_INLOOP_RESHAPER const Slice &slice = *cs.slice; - bool flag = slice.getReshapeInfo().getUseSliceReshaper() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag() ) || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getIBCMode())); - +#if JVET_M0483_IBC + bool flag = slice.getReshapeInfo().getUseSliceReshaper() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())); +#else + bool flag = slice.getReshapeInfo().getUseSliceReshaper() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag()) || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getIBCMode())); +#endif if (flag && slice.getReshapeInfo().getSliceReshapeChromaAdj() && (compID != COMPONENT_Y)) { const Area area = tu.Y().valid() ? tu.Y() : Area(recalcPosition(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].pos()), recalcSize(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].size())); @@ -274,7 +277,11 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size()); PelBuf tmpPred; #endif +#if JVET_M0483_IBC + if (slice.getReshapeInfo().getUseSliceReshaper() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y) +#else if (slice.getReshapeInfo().getUseSliceReshaper() && (m_pcReshape->getCTUFlag() || slice.isIntra() || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getIBCMode())) && compID == COMPONENT_Y) +#endif { #if REUSE_CU_RESULTS { @@ -293,7 +300,11 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) pReco.copyFrom( piPred ); #endif #if JVET_M0427_INLOOP_RESHAPER +#if JVET_M0483_IBC + if (slice.getReshapeInfo().getUseSliceReshaper() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y) +#else if (slice.getReshapeInfo().getUseSliceReshaper() && (m_pcReshape->getCTUFlag() || slice.isIntra() || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getIBCMode())) && compID == COMPONENT_Y) +#endif { #if REUSE_CU_RESULTS { diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index a936ef43438a08a7137c452bce15681ca6cef6fc..3f53a84df6240aa79f39db05785d756d3bedb22d 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -1277,7 +1277,11 @@ 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().getIBCMode()) ) && m_cReshaper.getSliceReshaperInfo().getUseSliceReshaper()) +#if JVET_M0483_IBC + if ((pcSlice->getSliceType() == I_SLICE) && m_cReshaper.getSliceReshaperInfo().getUseSliceReshaper()) +#else + if ((pcSlice->getSliceType() == I_SLICE || (pcSlice->getSliceType() == P_SLICE && pcSlice->getSPS()->getSpsNext().getIBCMode())) && m_cReshaper.getSliceReshaperInfo().getUseSliceReshaper()) +#endif { m_cReshaper.setCTUFlag(false); m_cReshaper.setRecReshaped(true); diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index b7c2fa6f8ba27af4547f066dddb00b1bddbdc83a..abcd1c40d8ef50bf8cedf69d1bd1bd4d7a2ac8cd 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -2205,18 +2205,29 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, if (m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_PQ) { +#if JVET_M0483_IBC + m_pcReshaper->preAnalyzerHDR(pcPic, pcSlice->getSliceType(), m_pcCfg->getReshapeCW(), m_pcCfg->getDualITree()); +#else m_pcReshaper->preAnalyzerHDR(pcPic, pcSlice->getSliceType(), m_pcCfg->getReshapeCW(), m_pcCfg->getDualITree(), m_pcCfg->getIBCMode()); +#endif } else if (m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_SDR) { +#if JVET_M0483_IBC + m_pcReshaper->preAnalyzerSDR(pcPic, pcSlice->getSliceType(), m_pcCfg->getReshapeCW(), m_pcCfg->getDualITree()); +#else m_pcReshaper->preAnalyzerSDR(pcPic, pcSlice->getSliceType(), m_pcCfg->getReshapeCW(), m_pcCfg->getDualITree(), m_pcCfg->getIBCMode()); +#endif } else { THROW("Reshaper for signal other than PQ and SDR currently not defined!"); } - - if (pcSlice->getSliceType() == I_SLICE || (pcSlice->getSliceType()==P_SLICE && m_pcCfg->getIBCMode())) +#if JVET_M0483_IBC + if (pcSlice->getSliceType() == I_SLICE ) +#else + if (pcSlice->getSliceType() == I_SLICE || (pcSlice->getSliceType() == P_SLICE && m_pcCfg->getIBCMode())) +#endif { if (m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_PQ) { diff --git a/source/Lib/EncoderLib/EncReshape.cpp b/source/Lib/EncoderLib/EncReshape.cpp index df0ec3b4467efd5d97d2805d52952cd9687af1a8..e9be72f9f41d4b4bc9438b83af03669f57e52102 100644 --- a/source/Lib/EncoderLib/EncReshape.cpp +++ b/source/Lib/EncoderLib/EncReshape.cpp @@ -107,7 +107,11 @@ void EncReshape::destroy() \param pcPic describe pointer of current coding picture \param sliceType describe the slice type */ +#if JVET_M0483_IBC +void EncReshape::preAnalyzerHDR(Picture *pcPic, const SliceType sliceType, const ReshapeCW& reshapeCW, bool isDualT) +#else void EncReshape::preAnalyzerHDR(Picture *pcPic, const SliceType sliceType, const ReshapeCW& reshapeCW, bool isDualT, bool isIBC) +#endif { if (m_lumaBD >= 10) { @@ -119,11 +123,19 @@ void EncReshape::preAnalyzerHDR(Picture *pcPic, const SliceType sliceType, const } else { - if (sliceType == I_SLICE || (sliceType==P_SLICE && isIBC) ) { m_sliceReshapeInfo.sliceReshaperModelPresentFlag = true; } +#if JVET_M0483_IBC + if (sliceType == I_SLICE ) { m_sliceReshapeInfo.sliceReshaperModelPresentFlag = true; } +#else + if (sliceType == I_SLICE || (sliceType == P_SLICE && isIBC)) { m_sliceReshapeInfo.sliceReshaperModelPresentFlag = true; } +#endif else { m_sliceReshapeInfo.sliceReshaperModelPresentFlag = false; } } - if ((sliceType == I_SLICE || (sliceType == P_SLICE && isIBC)) && isDualT) { m_sliceReshapeInfo.enableChromaAdj = 0; } - else { m_sliceReshapeInfo.enableChromaAdj = 1; } +#if JVET_M0483_IBC + if (sliceType == I_SLICE && isDualT) { m_sliceReshapeInfo.enableChromaAdj = 0; } +#else + if ((sliceType == I_SLICE || (sliceType == P_SLICE && isIBC)) && isDualT) { m_sliceReshapeInfo.enableChromaAdj = 0; } +#endif + else { m_sliceReshapeInfo.enableChromaAdj = 1; } } else { @@ -138,14 +150,21 @@ void EncReshape::preAnalyzerHDR(Picture *pcPic, const SliceType sliceType, const \param sliceType describe the slice type \param reshapeCW describe some input info */ +#if JVET_M0483_IBC +void EncReshape::preAnalyzerSDR(Picture *pcPic, const SliceType sliceType, const ReshapeCW& reshapeCW, bool isDualT) +#else void EncReshape::preAnalyzerSDR(Picture *pcPic, const SliceType sliceType, const ReshapeCW& reshapeCW, bool isDualT, bool isIBC) +#endif { m_sliceReshapeInfo.sliceReshaperModelPresentFlag = true; m_sliceReshapeInfo.sliceReshaperEnableFlag = true; int modIP = pcPic->getPOC() - pcPic->getPOC() / reshapeCW.rspFpsToIp * reshapeCW.rspFpsToIp; - - if (sliceType == I_SLICE || (reshapeCW.rspIntraPeriod == -1 && modIP == 0) || (sliceType== P_SLICE && isIBC)) +#if JVET_M0483_IBC + if (sliceType == I_SLICE || (reshapeCW.rspIntraPeriod == -1 && modIP == 0)) +#else + if (sliceType == I_SLICE || (reshapeCW.rspIntraPeriod == -1 && modIP == 0) || (sliceType == P_SLICE && isIBC)) +#endif { if (m_sliceReshapeInfo.sliceReshaperModelPresentFlag == true) { @@ -460,7 +479,11 @@ void EncReshape::preAnalyzerSDR(Picture *pcPic, const SliceType sliceType, const } m_chromaAdj = m_sliceReshapeInfo.enableChromaAdj; +#if JVET_M0483_IBC + if (sliceType == I_SLICE && isDualT) +#else if ((sliceType == I_SLICE || (sliceType == P_SLICE && isIBC)) && isDualT) +#endif { m_sliceReshapeInfo.enableChromaAdj = 0; } @@ -1123,7 +1146,7 @@ void EncReshape::constructReshaperSDR() int16_t *tempFwdLUT = new int16_t[m_reshapeLUTSize + 1](); int i, j; int cwScaleBins1, cwScaleBins2; - int maxAllowedCW = totCW; + int maxAllowedCW = totCW-1; cwScaleBins1 = m_reshapeCW.binCW[0]; cwScaleBins2 = m_reshapeCW.binCW[1]; @@ -1252,7 +1275,7 @@ void EncReshape::constructReshaperSDR() int sumBins = 0; for (i = 0; i < PIC_CODE_CW_BINS; i++) { sumBins += m_binCW[i]; } - CHECK(sumBins > m_reshapeLUTSize, "SDR CW assignment is wrong!!"); + CHECK(sumBins >= m_reshapeLUTSize, "SDR CW assignment is wrong!!"); memset(tempFwdLUT, 0, (m_reshapeLUTSize + 1) * sizeof(int16_t)); tempFwdLUT[0] = 0; diff --git a/source/Lib/EncoderLib/EncReshape.h b/source/Lib/EncoderLib/EncReshape.h index ce273fea7e557f7aa85f2089ec8405c0f7718e5d..81fc6a0b912f85858bfa820b503694e9f85f0b81 100644 --- a/source/Lib/EncoderLib/EncReshape.h +++ b/source/Lib/EncoderLib/EncReshape.h @@ -105,9 +105,13 @@ public: bool getSrcReshaped() { return m_srcReshaped; } void setSrcReshaped(bool b) { m_srcReshaped = b; } - +#if JVET_M0483_IBC + void preAnalyzerSDR(Picture *pcPic, const SliceType sliceType, const ReshapeCW& reshapeCW, bool isDualT); + void preAnalyzerHDR(Picture *pcPic, const SliceType sliceType, const ReshapeCW& reshapeCW, bool isDualT); +#else void preAnalyzerSDR(Picture *pcPic, const SliceType sliceType, const ReshapeCW& reshapeCW, bool isDualT, bool isIBC); void preAnalyzerHDR(Picture *pcPic, const SliceType sliceType, const ReshapeCW& reshapeCW, bool isDualT, bool isIBC); +#endif void bubbleSortDsd(double *array, int * idx, int n); void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp; *yp = temp; } void swap(double *xp, double *yp) { double temp = *xp; *xp = *yp; *yp = temp; } diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index 6c82913cd89e7cab4d6ca706e3fb066d6ccc1b29..648f5042c0a4acd7a009b5c71769ae65fca662f6 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -1807,7 +1807,11 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp #if JVET_M0427_INLOOP_RESHAPER const Slice &slice = *cs.slice; +#if JVET_M0483_IBC + bool flag = slice.getReshapeInfo().getUseSliceReshaper() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())); +#else bool flag = slice.getReshapeInfo().getUseSliceReshaper() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag()) || (slice.getSliceType() == P_SLICE && slice.getSPS()->getSpsNext().getIBCMode())); +#endif if (flag && slice.getReshapeInfo().getSliceReshapeChromaAdj() && isChroma(compID)) { const Area area = tu.Y().valid() ? tu.Y() : Area(recalcPosition(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].pos()), recalcSize(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].size()));