diff --git a/source/Lib/CommonLib/CodingStructure.cpp b/source/Lib/CommonLib/CodingStructure.cpp index 89aeff42909655da58d96aaa0b88444a6c8adeb9..29a7f787f4666b8e7108224d07563fe9c53922ac 100644 --- a/source/Lib/CommonLib/CodingStructure.cpp +++ b/source/Lib/CommonLib/CodingStructure.cpp @@ -1096,7 +1096,7 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe } } -void CodingStructure::useSubStructure( const CodingStructure& subStruct, const ChannelType chType, const UnitArea &subArea, const bool cpyPred /*= true*/, const bool cpyReco /*= true*/, const bool cpyOrgResi /*= true*/, const bool cpyResi /*= true*/ ) +void CodingStructure::useSubStructure( const CodingStructure& subStruct, const ChannelType chType, const UnitArea &subArea, const bool cpyPred /*= true*/, const bool cpyReco /*= true*/, const bool cpyOrgResi /*= true*/, const bool cpyResi /*= true*/, const bool updateCost /*= true*/ ) { UnitArea clippedArea = clipArea( subArea, *picture ); @@ -1132,10 +1132,13 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C prevPLT = subStruct.prevPLT; - fracBits += subStruct.fracBits; - dist += subStruct.dist; - cost += subStruct.cost; - costDbOffset += subStruct.costDbOffset; + if ( updateCost ) + { + fracBits += subStruct.fracBits; + dist += subStruct.dist; + cost += subStruct.cost; + costDbOffset += subStruct.costDbOffset; + } if( parent ) { // allow this to be false at the top level diff --git a/source/Lib/CommonLib/CodingStructure.h b/source/Lib/CommonLib/CodingStructure.h index 57cda86111b280b86e5551145fc9f743bad31ffe..e7e71bc35f679d62889f21079063d7d8c49e5248 100644 --- a/source/Lib/CommonLib/CodingStructure.h +++ b/source/Lib/CommonLib/CodingStructure.h @@ -172,8 +172,8 @@ public: void initSubStructure( CodingStructure& cs, const ChannelType chType, const UnitArea &subArea, const bool &isTuEnc); void copyStructure (const CodingStructure& cs, const ChannelType chType, const bool copyTUs = false, const bool copyRecoBuffer = false); - void useSubStructure (const CodingStructure& cs, const ChannelType chType, const UnitArea &subArea, const bool cpyPred, const bool cpyReco, const bool cpyOrgResi, const bool cpyResi); - void useSubStructure (const CodingStructure& cs, const ChannelType chType, const bool cpyPred, const bool cpyReco, const bool cpyOrgResi, const bool cpyResi) { useSubStructure(cs, chType, cs.area, cpyPred, cpyReco, cpyOrgResi, cpyResi); } + void useSubStructure (const CodingStructure& cs, const ChannelType chType, const UnitArea &subArea, const bool cpyPred, const bool cpyReco, const bool cpyOrgResi, const bool cpyResi, const bool updateCost); + void useSubStructure (const CodingStructure& cs, const ChannelType chType, const bool cpyPred, const bool cpyReco, const bool cpyOrgResi, const bool cpyResi, const bool updateCost) { useSubStructure(cs, chType, cs.area, cpyPred, cpyReco, cpyOrgResi, cpyResi, updateCost); } void clearTUs(); void clearPUs(); diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 8e63c8799cf65a3acff745f0f0a059e49264c261..517e430b8fd1462ecbc1bb85ef656c237aa4ae5d 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -338,7 +338,7 @@ void EncCu::compressCtu( CodingStructure& cs, const UnitArea& area, const unsign // all signals were already copied during compression if the CTU was split - at this point only the structures are copied to the top level CS const bool copyUnsplitCTUSignals = bestCS->cus.size() == 1; cs.useSubStructure(*bestCS, partitioner.chType, CS::getArea(*bestCS, area, partitioner.chType), copyUnsplitCTUSignals, - false, false, copyUnsplitCTUSignals); + false, false, copyUnsplitCTUSignals, true); if (CS::isDualITree (cs) && isChromaEnabled (cs.pcv->chrFormat)) { @@ -356,7 +356,7 @@ void EncCu::compressCtu( CodingStructure& cs, const UnitArea& area, const unsign const bool copyUnsplitCTUSignals = bestCS->cus.size() == 1; cs.useSubStructure(*bestCS, partitioner.chType, CS::getArea(*bestCS, area, partitioner.chType), - copyUnsplitCTUSignals, false, false, copyUnsplitCTUSignals); + copyUnsplitCTUSignals, false, false, copyUnsplitCTUSignals, true); } if (m_pcEncCfg->getUseRateCtrl()) @@ -1180,7 +1180,7 @@ void EncCu::copyState( EncCu* other, Partitioner& partitioner, const UnitArea& c bool keepResi = KEEP_PRED_AND_RESI_SIGNALS; bool keepPred = true; - dst->useSubStructure( *src, partitioner.chType, currArea, keepPred, true, keepResi, keepResi ); + dst->useSubStructure( *src, partitioner.chType, currArea, keepPred, true, keepResi, keepResi, true ); dst->cost = src->cost; dst->dist = src->dist; @@ -1335,7 +1335,7 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, } bool keepResi = KEEP_PRED_AND_RESI_SIGNALS; - tempCS->useSubStructure( *bestSubCS, partitioner.chType, CS::getArea( *tempCS, subCUArea, partitioner.chType ), KEEP_PRED_AND_RESI_SIGNALS, true, keepResi, keepResi ); + tempCS->useSubStructure( *bestSubCS, partitioner.chType, CS::getArea( *tempCS, subCUArea, partitioner.chType ), KEEP_PRED_AND_RESI_SIGNALS, true, keepResi, keepResi, true ); if( partitioner.currQgEnable() ) { @@ -1449,7 +1449,7 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, assert( tempCS->treeType == TREE_L ); uint32_t numCuPuTu[6]; tempCS->picture->cs->getNumCuPuTuOffset( numCuPuTu ); - tempCS->picture->cs->useSubStructure( *tempCS, partitioner.chType, CS::getArea( *tempCS, partitioner.currArea(), partitioner.chType ), false, true, false, false ); + tempCS->picture->cs->useSubStructure( *tempCS, partitioner.chType, CS::getArea( *tempCS, partitioner.currArea(), partitioner.chType ), false, true, false, false, false ); if (isChromaEnabled(tempCS->pcv->chrFormat)) { @@ -1471,7 +1471,7 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, bool keepResi = KEEP_PRED_AND_RESI_SIGNALS; //bestCSChroma->treeType = tempCSChroma->treeType = TREE_C; CHECK( bestCSChroma->treeType != TREE_C || tempCSChroma->treeType != TREE_C, "wrong treeType for chroma CS" ); - tempCS->useSubStructure( *bestCSChroma, partitioner.chType, CS::getArea( *bestCSChroma, partitioner.currArea(), partitioner.chType ), KEEP_PRED_AND_RESI_SIGNALS, true, keepResi, true ); + tempCS->useSubStructure( *bestCSChroma, partitioner.chType, CS::getArea( *bestCSChroma, partitioner.currArea(), partitioner.chType ), KEEP_PRED_AND_RESI_SIGNALS, true, keepResi, true, true ); //release tmp resource tempCSChroma->releaseIntermediateData(); diff --git a/source/Lib/EncoderLib/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp index ad660bb8f98565b81297db018b67525996c19d08..7940ab788ad7ec8bf086ca90011d0e405d34a468 100644 --- a/source/Lib/EncoderLib/InterSearch.cpp +++ b/source/Lib/EncoderLib/InterSearch.cpp @@ -7209,7 +7209,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par if( bCheckFull && anyCbfSet && csSplit->cost < csFull->cost ) { - cs.useSubStructure( *csSplit, partitioner.chType, currArea, false, false, false, true ); + cs.useSubStructure( *csSplit, partitioner.chType, currArea, false, false, false, true, true ); cs.cost = csSplit->cost; } } diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index 29be70ab385de60de57353f4a969524c9c2ce9fe..aabab7610bc5334fae7edc84ea2342cf9ac22c01 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -1190,12 +1190,12 @@ bool IntraSearch::estIntraPredLumaQT(CodingUnit &cu, Partitioner &partitioner, c { if (cu.colorTransform) { - cs.useSubStructure(*csBest, partitioner.chType, pu, true, true, KEEP_PRED_AND_RESI_SIGNALS, KEEP_PRED_AND_RESI_SIGNALS); + cs.useSubStructure(*csBest, partitioner.chType, pu, true, true, KEEP_PRED_AND_RESI_SIGNALS, KEEP_PRED_AND_RESI_SIGNALS, true); } else { cs.useSubStructure(*csBest, partitioner.chType, pu.singleChan(CHANNEL_TYPE_LUMA), true, true, KEEP_PRED_AND_RESI_SIGNALS, - KEEP_PRED_AND_RESI_SIGNALS); + KEEP_PRED_AND_RESI_SIGNALS, true); } } csBest->releaseIntermediateData();