diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index 6b1c5e9c7418f31b2d6240b12226d6ddeef8c346..e1d3a6e6717a9dc258107fb838f0d2450d8f5186 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -169,6 +169,7 @@ namespace DQIntern ::memset( m_tuParameters, 0, sizeof(m_tuParameters) ); uint32_t raster2id[ MAX_CU_SIZE * MAX_CU_SIZE ]; + ::memset(raster2id, 0, sizeof(raster2id)); #if JVET_M0102_INTRA_SUBPARTITIONS for( int ch = 0; ch < MAX_NUM_CHANNEL_TYPE; ch++ ) @@ -235,11 +236,24 @@ namespace DQIntern NbInfoSbb& nbSbb = sId2NbSbb[ scanId ]; const int begSbb = scanId - ( scanId & (groupSize-1) ); // first pos in current subblock int cpos[5]; - cpos[0] = ( posX < blockWidth -1 ? ( raster2id[rpos+1 ] - begSbb < groupSize ? raster2id[rpos+1 ] - begSbb : 0 ) : 0 ); - cpos[1] = ( posX < blockWidth -2 ? ( raster2id[rpos+2 ] - begSbb < groupSize ? raster2id[rpos+2 ] - begSbb : 0 ) : 0 ); - cpos[2] = ( posX < blockWidth -1 && posY < blockHeight-1 ? ( raster2id[rpos+1+blockWidth] - begSbb < groupSize ? raster2id[rpos+1+blockWidth] - begSbb : 0 ) : 0 ); - cpos[3] = ( posY < blockHeight-1 ? ( raster2id[rpos+ blockWidth] - begSbb < groupSize ? raster2id[rpos+ blockWidth] - begSbb : 0 ) : 0 ); - cpos[4] = ( posY < blockHeight-2 ? ( raster2id[rpos+2*blockWidth] - begSbb < groupSize ? raster2id[rpos+2*blockWidth] - begSbb : 0 ) : 0 ); + + const bool condX1 = posX + 1 < blockWidth; + const bool condX2 = posX + 2 < blockWidth; + const bool condY1 = posY + 1 < blockHeight; + const bool condY2 = posY + 2 < blockHeight; + + const int ras0 = condX1 ? raster2id[rpos + 1] : 0; + const int ras1 = condX2 ? raster2id[rpos + 2] : 0; + const int ras2 = condX1 && condY1 ? raster2id[rpos + 1 + blockWidth] : 0; + const int ras3 = condY1 ? raster2id[rpos + blockWidth] : 0; + const int ras4 = condY2 ? raster2id[rpos + 2 * blockWidth] : 0; + + cpos[0] = ras0 >= begSbb && ras0 < groupSize + begSbb ? ras0 - begSbb : 0; + cpos[1] = ras1 >= begSbb && ras1 < groupSize + begSbb ? ras1 - begSbb : 0; + cpos[2] = ras2 >= begSbb && ras2 < groupSize + begSbb ? ras2 - begSbb : 0; + cpos[3] = ras3 >= begSbb && ras3 < groupSize + begSbb ? ras3 - begSbb : 0; + cpos[4] = ras4 >= begSbb && ras4 < groupSize + begSbb ? ras4 - begSbb : 0; + for( nbSbb.num = 0; true; ) { int nk = -1; @@ -267,11 +281,11 @@ namespace DQIntern NbInfoOut& nbOut = sId2NbOut[ scanId ]; const int begSbb = scanId - ( scanId & (groupSize-1) ); // first pos in current subblock int cpos[5]; - cpos[0] = ( posX < blockWidth -1 ? ( raster2id[rpos+1 ] - begSbb >= groupSize ? raster2id[rpos+1 ] : 0 ) : 0 ); - cpos[1] = ( posX < blockWidth -2 ? ( raster2id[rpos+2 ] - begSbb >= groupSize ? raster2id[rpos+2 ] : 0 ) : 0 ); - cpos[2] = ( posX < blockWidth -1 && posY < blockHeight-1 ? ( raster2id[rpos+1+blockWidth] - begSbb >= groupSize ? raster2id[rpos+1+blockWidth] : 0 ) : 0 ); - cpos[3] = ( posY < blockHeight-1 ? ( raster2id[rpos+ blockWidth] - begSbb >= groupSize ? raster2id[rpos+ blockWidth] : 0 ) : 0 ); - cpos[4] = ( posY < blockHeight-2 ? ( raster2id[rpos+2*blockWidth] - begSbb >= groupSize ? raster2id[rpos+2*blockWidth] : 0 ) : 0 ); + cpos[0] = ( posX + 1 < blockWidth ? ( raster2id[rpos+1 ] >= groupSize + begSbb ? raster2id[rpos+1 ] : 0 ) : 0 ); + cpos[1] = ( posX + 2 < blockWidth ? ( raster2id[rpos+2 ] >= groupSize + begSbb ? raster2id[rpos+2 ] : 0 ) : 0 ); + cpos[2] = ( posX + 1 < blockWidth && posY + 1 < blockHeight ? ( raster2id[rpos+1+blockWidth] >= groupSize + begSbb ? raster2id[rpos+1+blockWidth] : 0 ) : 0 ); + cpos[3] = ( posY + 1 < blockHeight ? ( raster2id[rpos+ blockWidth] >= groupSize + begSbb ? raster2id[rpos+ blockWidth] : 0 ) : 0 ); + cpos[4] = ( posY + 2 < blockHeight ? ( raster2id[rpos+2*blockWidth] >= groupSize + begSbb ? raster2id[rpos+2*blockWidth] : 0 ) : 0 ); for( nbOut.num = 0; true; ) { int nk = -1; @@ -311,6 +325,7 @@ namespace DQIntern const int begSbb = scanId - ( scanId & (groupSize-1) ); // first pos in current subblock for( int k = 0; k < nbOut.num; k++ ) { + CHECK(begSbb > nbOut.outPos[k], "Position must be past sub block begin"); nbOut.outPos[k] -= begSbb; } nbOut.maxDist -= scanId; @@ -401,7 +416,13 @@ namespace DQIntern m_chType = chType; m_width = width; m_height = height; +#if JVET_M0257 + const uint32_t nonzeroWidth = std::min<uint32_t>(JVET_C0024_ZERO_OUT_TH, m_width); + const uint32_t nonzeroHeight = std::min<uint32_t>(JVET_C0024_ZERO_OUT_TH, m_height); + m_numCoeff = nonzeroWidth * nonzeroHeight; +#else m_numCoeff = m_width * m_height; +#endif #if JVET_M0102_INTRA_SUBPARTITIONS m_log2SbbWidth = g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][0]; m_log2SbbHeight = g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][1]; @@ -414,8 +435,8 @@ namespace DQIntern m_sbbSize = ( 1 << m_log2SbbSize ); m_sbbMask = m_sbbSize - 1; #if JVET_M0257 - m_widthInSbb = std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_width) >> m_log2SbbWidth; - m_heightInSbb = std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_height) >> m_log2SbbHeight; + m_widthInSbb = nonzeroWidth >> m_log2SbbWidth; + m_heightInSbb = nonzeroHeight >> m_log2SbbHeight; #else m_widthInSbb = m_width >> m_log2SbbWidth; m_heightInSbb = m_height >> m_log2SbbHeight; diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index c14c2b68efbfe8bef9961e3c5f53b2195f64a04f..b42f52342eda15e1c663d0b8845d521ff76c9edf 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -1900,9 +1900,6 @@ SPSNext::SPSNext( SPS& sps ) #else , m_IntraEMT ( false ) , m_InterEMT ( false ) -#endif -#if JVET_M0140_SBT - , m_SBT ( false ) #endif , m_Affine ( false ) , m_AffineType ( false ) @@ -1954,6 +1951,10 @@ SPS::SPS() #if JVET_M0147_DMVR , m_DMVR ( false ) #endif +#if JVET_M0140_SBT +, m_SBT ( false ) +, m_MaxSbtSize ( 32 ) +#endif #if HEVC_VPS , m_VPSId ( 0) #endif diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index f2688be6a1d5e5856199de7a7eb71bb344026251..63a2bd032ab21892b74b5ca0ad7ecf8f2d28a38f 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -848,10 +848,6 @@ private: #else bool m_IntraEMT; // 18 bool m_InterEMT; // 19 -#endif -#if JVET_M0140_SBT - bool m_SBT; - uint8_t m_MaxSbtSize; #endif bool m_Affine; bool m_AffineType; @@ -932,12 +928,6 @@ public: bool getUseIntraEMT () const { return m_IntraEMT; } void setUseInterEMT ( bool b ) { m_InterEMT = b; } bool getUseInterEMT () const { return m_InterEMT; } -#endif -#if JVET_M0140_SBT - void setUseSBT ( bool b ) { m_SBT = b; } - bool getUseSBT () const { return m_SBT; } - void setMaxSbtSize ( uint8_t val ) { m_MaxSbtSize = val; } - uint8_t getMaxSbtSize () const { return m_MaxSbtSize; } #endif void setUseGBi ( bool b ) { m_GBi = b; } bool getUseGBi () const { return m_GBi; } @@ -1002,6 +992,10 @@ private: #if JVET_M0147_DMVR bool m_DMVR; #endif +#if JVET_M0140_SBT + bool m_SBT; + uint8_t m_MaxSbtSize; +#endif #if HEVC_VPS int m_VPSId; #endif @@ -1327,6 +1321,12 @@ public: void setIBCFlag(unsigned IBCFlag) { m_IBCFlag = IBCFlag; } unsigned getIBCFlag() const { return m_IBCFlag; } #endif +#if JVET_M0140_SBT + void setUseSBT( bool b ) { m_SBT = b; } + bool getUseSBT() const { return m_SBT; } + void setMaxSbtSize( uint8_t val ) { m_MaxSbtSize = val; } + uint8_t getMaxSbtSize() const { return m_MaxSbtSize; } +#endif }; diff --git a/source/Lib/CommonLib/Unit.cpp b/source/Lib/CommonLib/Unit.cpp index a2f4bc6ecd06ce6905415b7aa95fe22be017a974..aed894214e8ef54511e2fa2b3df9679bff5ae53e 100644 --- a/source/Lib/CommonLib/Unit.cpp +++ b/source/Lib/CommonLib/Unit.cpp @@ -353,13 +353,17 @@ void CodingUnit::initData() #if JVET_M0140_SBT const uint8_t CodingUnit::checkAllowedSbt() const { - if( !slice->getSPS()->getSpsNext().getUseSBT() ) + if( !slice->getSPS()->getUseSBT() ) { return 0; } //check on prediction mode - if( predMode == MODE_INTRA ) //intra +#if JVET_M0483_IBC + if( predMode == MODE_INTRA || predMode == MODE_IBC ) //intra or IBC +#else + if( predMode == MODE_INTRA || ibc ) //intra or IBC +#endif { return 0; } @@ -375,7 +379,7 @@ const uint8_t CodingUnit::checkAllowedSbt() const memset( allow_type, false, NUMBER_SBT_IDX * sizeof( bool ) ); //parameter - int maxSbtCUSize = cs->sps->getSpsNext().getMaxSbtSize(); + int maxSbtCUSize = cs->sps->getMaxSbtSize(); int minSbtCUSize = 1 << ( MIN_CU_LOG2 + 1 ); //check on size diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index a947cc6adbac8b9553d62b8f8fd533f572f506b4..abc137c5671813430951618f54e6970031f2ff54 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 90e810a09f7c610a9e8cb289c4d56da0724d4317..fa33c9e2a6bc99ae3206358a4cd4d7f561c8f031 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -1316,7 +1316,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/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index a94f9710d62db7b0f034d2c77d1f5d7b15628ff0..4eb2afbab5acf94be7d067f87f7862dc519431f3 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -815,13 +815,6 @@ void HLSyntaxReader::parseSPSNext( SPSNext& spsNext, const bool usePCM ) } #endif -#if JVET_M0140_SBT - READ_FLAG( symbol, "sbt_enable_flag" ); spsNext.setUseSBT ( symbol != 0 ); - if( spsNext.getUseSBT() ) - { - READ_FLAG( symbol, "max_sbt_size_64_flag" ); spsNext.setMaxSbtSize ( symbol ? 64 : 32 ); - } -#endif READ_FLAG( symbol, "affine_flag" ); spsNext.setUseAffine ( symbol != 0 ); if ( spsNext.getUseAffine() ) { @@ -1127,6 +1120,13 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) } } #endif +#if JVET_M0140_SBT + READ_FLAG(uiCode, "sbt_enable_flag"); pcSPS->setUseSBT(uiCode != 0); + if( pcSPS->getUseSBT() ) + { + READ_FLAG(uiCode, "max_sbt_size_64_flag"); pcSPS->setMaxSbtSize(uiCode != 0 ? 64 : 32); + } +#endif READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); CHECK(uiCode > 64, "Invalid code"); diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index b93231088587e50d5fab776cd78de6e3bfdd7015..4317ca13d9405822fe80eaa761733acb20cd6c9f 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -714,10 +714,10 @@ void EncCu::xCompressCU( CodingStructure *&tempCS, CodingStructure *&bestCS, Par bestCS->chType = partitioner.chType; m_modeCtrl->initCULevel( partitioner, *tempCS ); #if JVET_M0140_SBT - if( partitioner.currQtDepth == 0 && partitioner.currMtDepth == 0 && !tempCS->slice->isIntra() && ( sps.getSpsNext().getUseSBT() || sps.getSpsNext().getUseInterMTS() ) ) + if( partitioner.currQtDepth == 0 && partitioner.currMtDepth == 0 && !tempCS->slice->isIntra() && ( sps.getUseSBT() || sps.getSpsNext().getUseInterMTS() ) ) { auto slsSbt = dynamic_cast<SaveLoadEncInfoSbt*>( m_modeCtrl ); - int maxSLSize = sps.getSpsNext().getUseSBT() ? tempCS->slice->getSPS()->getSpsNext().getMaxSbtSize() : MTS_INTER_MAX_CU_SIZE; + int maxSLSize = sps.getUseSBT() ? tempCS->slice->getSPS()->getMaxSbtSize() : MTS_INTER_MAX_CU_SIZE; slsSbt->resetSaveloadSbt( maxSLSize ); } m_sbtCostSave[0] = m_sbtCostSave[1] = MAX_DOUBLE; @@ -3504,6 +3504,9 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct #if !JVET_M0464_UNI_MTS cu.emtFlag = false; #endif +#if JVET_M0140_SBT + cu.sbtInfo = 0; +#endif PredictionUnit &pu = tempCS->addPU(cu, partitioner.chType);// tempCS->addPU(cu); pu.intraDir[0] = DC_IDX; // set intra pred for ibc block @@ -3591,6 +3594,9 @@ void EncCu::xCheckRDCostIBCMode(CodingStructure *&tempCS, CodingStructure *&best cu.ibc = true; #endif cu.imv = 0; +#if JVET_M0140_SBT + cu.sbtInfo = 0; +#endif CU::addPUs(cu); diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 5647a9d002519914820273ecc45f55c74fef40b7..35b96a12227bcbbb8c4cc4084d0b0cedac4dc600 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -2219,18 +2219,30 @@ 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!"); + THROW("Reshaper for other signal currently not defined!"); } +#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/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 76b3aef55aec3723872343c0bdee53683daead2c..ebe96c8a98fe743422d72aa4d7046cc5c93a80cc 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -911,10 +911,10 @@ void EncLib::xInitSPS(SPS &sps) sps.getSpsNext().setUseInterEMT ( m_InterEMT ); #endif #if JVET_M0140_SBT - sps.getSpsNext().setUseSBT ( m_SBT ); - if( sps.getSpsNext().getUseSBT() ) + sps.setUseSBT ( m_SBT ); + if( sps.getUseSBT() ) { - sps.getSpsNext().setMaxSbtSize ( m_iSourceWidth >= 1920 ? 64 : 32 ); + sps.setMaxSbtSize ( m_iSourceWidth >= 1920 ? 64 : 32 ); } #endif sps.getSpsNext().setUseCompositeRef ( m_compositeRefEnabled ); diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp index cac92f3864e957079f60ad703f052f1d9dd427e0..cacfc4768dcc21cbe3573b7b0ef1ddfbb4b6fb6b 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.cpp +++ b/source/Lib/EncoderLib/EncModeCtrl.cpp @@ -727,6 +727,7 @@ void BestEncInfoCache::create( const ChromaFormat chFmt ) if( gp_sizeIdxInfo->isCuSize( gp_sizeIdxInfo->sizeFrom( hIdx ) ) && y + ( gp_sizeIdxInfo->sizeFrom( hIdx ) >> MIN_CU_LOG2 ) <= ( MAX_CU_SIZE >> MIN_CU_LOG2 ) ) { m_bestEncInfo[x][y][wIdx][hIdx] = new BestEncodingInfo; + ::memset(m_bestEncInfo[x][y][wIdx][hIdx], 0, sizeof(BestEncodingInfo)); int w = gp_sizeIdxInfo->sizeFrom( wIdx ); int h = gp_sizeIdxInfo->sizeFrom( hIdx ); 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/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp index 22b5d5e4b828bbe9110ecab4f723a92a7f6361b6..b609261953894e51f221f858df5496a6c4367f2e 100644 --- a/source/Lib/EncoderLib/InterSearch.cpp +++ b/source/Lib/EncoderLib/InterSearch.cpp @@ -6425,7 +6425,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par #if APPLY_SBT_SL_ON_MTS //skip MTS if DCT2 is the best - if( mtsAllowed && ( !tu.cu->slice->getSPS()->getSpsNext().getUseSBT() || CU::getSbtIdx( m_histBestSbt ) != SBT_OFF_DCT ) ) + if( mtsAllowed && ( !tu.cu->slice->getSPS()->getUseSBT() || CU::getSbtIdx( m_histBestSbt ) != SBT_OFF_DCT ) ) #else if( mtsAllowed ) #endif @@ -6434,7 +6434,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par { #if APPLY_SBT_SL_ON_MTS //skip the non-best Mts mode - if( !tu.cu->slice->getSPS()->getSpsNext().getUseSBT() || ( m_histBestMtsIdx == MAX_UCHAR || m_histBestMtsIdx == i ) ) + if( !tu.cu->slice->getSPS()->getUseSBT() || ( m_histBestMtsIdx == MAX_UCHAR || m_histBestMtsIdx == i ) ) { #endif trModes.push_back( TrMode( i, true ) ); 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())); diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 823751dc792402248f445100f41d940d689eaec5..4bed5da8cd9df34c803d4c6e993743e860aae4f1 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -555,13 +555,6 @@ void HLSWriter::codeSPSNext( const SPSNext& spsNext, const bool usePCM ) } #endif -#if JVET_M0140_SBT - WRITE_FLAG( spsNext.getUseSBT() ? 1 : 0, "sbt_enable_flag" ); - if( spsNext.getUseSBT() ) - { - WRITE_FLAG( spsNext.getMaxSbtSize() == 64 ? 1 : 0, "max_sbt_size_64_flag" ); - } -#endif WRITE_FLAG( spsNext.getUseAffine() ? 1 : 0, "affine_flag" ); if ( spsNext.getUseAffine() ) { @@ -797,6 +790,13 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) } } #endif +#if JVET_M0140_SBT + WRITE_FLAG( pcSPS->getUseSBT() ? 1 : 0, "sbt_enable_flag"); + if( pcSPS->getUseSBT() ) + { + WRITE_FLAG(pcSPS->getMaxSbtSize() == 64 ? 1 : 0, "max_sbt_size_64_flag"); + } +#endif CHECK( pcSPS->getMaxTLayers() == 0, "Maximum number of T-layers is '0'" );