From 4132064798255274f6ae33f538c8f7f8764a4eab Mon Sep 17 00:00:00 2001 From: Frank Bossen <fbossen@gmail.com> Date: Fri, 17 Jan 2020 15:29:22 +0100 Subject: [PATCH] remove macro JVET_P1026_ISP_LFNST_COMBINATION --- source/Lib/CommonLib/TrQuant.cpp | 2 - source/Lib/CommonLib/TypeDef.h | 1 - source/Lib/CommonLib/UnitTools.cpp | 2 - source/Lib/CommonLib/UnitTools.h | 2 - source/Lib/DecoderLib/CABACReader.cpp | 12 -- source/Lib/EncoderLib/CABACWriter.cpp | 25 --- source/Lib/EncoderLib/CABACWriter.h | 4 - source/Lib/EncoderLib/EncCfg.h | 4 - source/Lib/EncoderLib/EncCu.cpp | 31 ---- source/Lib/EncoderLib/EncModeCtrl.cpp | 4 - source/Lib/EncoderLib/EncModeCtrl.h | 8 - source/Lib/EncoderLib/IntraSearch.cpp | 225 -------------------------- source/Lib/EncoderLib/IntraSearch.h | 17 -- 13 files changed, 337 deletions(-) diff --git a/source/Lib/CommonLib/TrQuant.cpp b/source/Lib/CommonLib/TrQuant.cpp index 79d503401..7d3d62642 100644 --- a/source/Lib/CommonLib/TrQuant.cpp +++ b/source/Lib/CommonLib/TrQuant.cpp @@ -693,12 +693,10 @@ void TrQuant::getTrTypes(const TransformUnit tu, const ComponentID compID, int & trTypeHor = DCT2; trTypeVer = DCT2; -#if JVET_P1026_ISP_LFNST_COMBINATION if (isISP && tu.cu->lfnstIdx) { return; } -#endif if (!tu.cs->sps->getUseMTS()) return; diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 8ab3f93dd..b94b31b85 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -91,7 +91,6 @@ -#define JVET_P1026_ISP_LFNST_COMBINATION 1 // JVET-P1026: Combination of ISP and LFNST #define JVET_P1026_MTS_SIGNALLING 1 // JVET-P1026: CU level MTS signalling diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 0c139b806..dfd91eec3 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -325,7 +325,6 @@ bool CU::canUseISP( const int width, const int height, const int maxTrSize ) return true; } -#if JVET_P1026_ISP_LFNST_COMBINATION bool CU::canUseLfnstWithISP( const CompArea& cuArea, const ISPType ispSplitType ) { if( ispSplitType == NOT_INTRA_SUBPARTITIONS ) @@ -347,7 +346,6 @@ bool CU::canUseLfnstWithISP( const CodingUnit& cu, const ChannelType chType ) CHECK( !isLuma( chType ), "Wrong ISP mode!" ); return CU::canUseLfnstWithISP( cu.blocks[chType == CHANNEL_TYPE_LUMA ? 0 : 1], (ISPType)cu.ispMode ); } -#endif uint32_t CU::getISPSplitDim( const int width, const int height, const PartSplit ispType ) { diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h index 08665d176..7c023e030 100644 --- a/source/Lib/CommonLib/UnitTools.h +++ b/source/Lib/CommonLib/UnitTools.h @@ -99,10 +99,8 @@ namespace CU bool isISPFirst ( const CodingUnit &cu, const CompArea &tuArea, const ComponentID compID ); bool canUseISP ( const CodingUnit &cu, const ComponentID compID ); bool canUseISP ( const int width, const int height, const int maxTrSize = MAX_TB_SIZEY ); -#if JVET_P1026_ISP_LFNST_COMBINATION bool canUseLfnstWithISP ( const CompArea& cuArea, const ISPType ispSplitType ); bool canUseLfnstWithISP ( const CodingUnit& cu, const ChannelType chType ); -#endif uint32_t getISPSplitDim ( const int width, const int height, const PartSplit ispType ); bool allLumaCBFsAreZero ( const CodingUnit& cu ); diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index e5abf11a3..00270ba0a 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -3548,11 +3548,7 @@ void CABACReader::explicit_rdpcm_mode( TransformUnit& tu, ComponentID compID ) void CABACReader::residual_lfnst_mode( CodingUnit& cu, CUCtx& cuCtx ) { int chIdx = cu.isSepTree() && cu.chType == CHANNEL_TYPE_CHROMA ? 1 : 0; -#if JVET_P1026_ISP_LFNST_COMBINATION if ( (cu.ispMode && !CU::canUseLfnstWithISP( cu, cu.chType ) ) || -#else - if( cu.ispMode != NOT_INTRA_SUBPARTITIONS || -#endif (cu.cs->sps->getUseLFNST() && CU::isIntra(cu) && cu.mipFlag && !allowLfnstWithMip(cu.firstPU->lumaSize())) || ( cu.isSepTree() && cu.chType == CHANNEL_TYPE_CHROMA && std::min( cu.blocks[ 1 ].width, cu.blocks[ 1 ].height ) < 4 ) || ( cu.blocks[ chIdx ].lumaSize().width > cu.cs->sps->getMaxTbSize() || cu.blocks[ chIdx ].lumaSize().height > cu.cs->sps->getMaxTbSize() ) @@ -3574,22 +3570,14 @@ void CABACReader::residual_lfnst_mode( CodingUnit& cu, CUCtx& cuCtx ) #else const bool isTrSkip = TU::getCbf(*cu.firstTU, COMPONENT_Y) && cu.firstTU->mtsIdx == MTS_SKIP; #endif -#if JVET_P1026_ISP_LFNST_COMBINATION if ((!cuCtx.lfnstLastScanPos && !cu.ispMode) || nonZeroCoeffNonTsCorner8x8 || isTrSkip) -#else - if( !cuCtx.lfnstLastScanPos || nonZeroCoeffNonTsCorner8x8 || isTrSkip ) -#endif #else #if JVET_P0058_CHROMA_TS const bool isNonDCT2 = (TU::getCbf(*cu.firstTU, ComponentID(COMPONENT_Y)) && cu.firstTU->mtsIdx[COMPONENT_Y] != MTS_DCT2_DCT2); #else const bool isNonDCT2 = (TU::getCbf(*cu.firstTU, ComponentID(COMPONENT_Y)) && cu.firstTU->mtsIdx != MTS_DCT2_DCT2); #endif -#if JVET_P1026_ISP_LFNST_COMBINATION if ((!cuCtx.lfnstLastScanPos && !cu.ispMode) || nonZeroCoeffNonTsCorner8x8 || isNonDCT2) -#else - if( !cuCtx.lfnstLastScanPos || nonZeroCoeffNonTsCorner8x8 || isNonDCT2 ) -#endif #endif { cu.lfnstIdx = 0; diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index d764e78f6..19aaac8d3 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -1349,11 +1349,7 @@ void CABACWriter::cu_residual( const CodingUnit& cu, Partitioner& partitioner, C residual_lfnst_mode( cu, cuCtx ); #if JVET_P1026_MTS_SIGNALLING -#if JVET_P1026_ISP_LFNST_COMBINATION mts_idx ( cu, &cuCtx ); -#else - mts_idx ( cu, cuCtx ); -#endif #endif } @@ -3080,11 +3076,7 @@ void CABACWriter::ts_flag( const TransformUnit& tu, ComponentID compID ) DTRACE( g_trace_ctx, D_SYNTAX, "ts_flag() etype=%d pos=(%d,%d) mtsIdx=%d\n", COMPONENT_Y, tu.cu->lx(), tu.cu->ly(), tsFlag ); } -#if JVET_P1026_ISP_LFNST_COMBINATION void CABACWriter::mts_idx( const CodingUnit& cu, CUCtx* cuCtx ) -#else -void CABACWriter::mts_idx( const CodingUnit& cu, CUCtx& cuCtx ) -#endif { TransformUnit &tu = *cu.firstTU; #if JVET_P0058_CHROMA_TS @@ -3093,13 +3085,8 @@ void CABACWriter::mts_idx( const CodingUnit& cu, CUCtx& cuCtx ) int mtsIdx = tu.mtsIdx; #endif -#if JVET_P1026_ISP_LFNST_COMBINATION if( CU::isMTSAllowed( cu, COMPONENT_Y ) && cuCtx && !cuCtx->violatesMtsCoeffConstraint && cu.lfnstIdx == 0 && mtsIdx != MTS_SKIP && TU::getCbf(tu, COMPONENT_Y) ) -#else - if( CU::isMTSAllowed( cu, COMPONENT_Y ) && !cuCtx.violatesMtsCoeffConstraint && - cu.lfnstIdx == 0 && mtsIdx != MTS_SKIP && TU::getCbf(tu, COMPONENT_Y) ) -#endif { int symbol = mtsIdx != MTS_DCT2_DCT2 ? 1 : 0; int ctxIdx = 0; @@ -3246,11 +3233,7 @@ void CABACWriter::explicit_rdpcm_mode( const TransformUnit& tu, ComponentID comp void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx ) { int chIdx = cu.isSepTree() && cu.chType == CHANNEL_TYPE_CHROMA ? 1 : 0; -#if JVET_P1026_ISP_LFNST_COMBINATION if( ( cu.ispMode && !CU::canUseLfnstWithISP( cu, cu.chType ) ) || -#else - if( cu.ispMode != NOT_INTRA_SUBPARTITIONS || -#endif (cu.cs->sps->getUseLFNST() && CU::isIntra(cu) && cu.mipFlag && !allowLfnstWithMip(cu.firstPU->lumaSize())) || ( cu.isSepTree() && cu.chType == CHANNEL_TYPE_CHROMA && std::min( cu.blocks[ 1 ].width, cu.blocks[ 1 ].height ) < 4 ) || ( cu.blocks[ chIdx ].lumaSize().width > cu.cs->sps->getMaxTbSize() || cu.blocks[ chIdx ].lumaSize().height > cu.cs->sps->getMaxTbSize() ) @@ -3271,22 +3254,14 @@ void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx ) #else const bool isTrSkip = TU::getCbf(*cu.firstTU, COMPONENT_Y) && cu.firstTU->mtsIdx == MTS_SKIP; #endif -#if JVET_P1026_ISP_LFNST_COMBINATION if( (!cuCtx.lfnstLastScanPos && !cu.ispMode) || nonZeroCoeffNonTsCorner8x8 || isTrSkip ) -#else - if( !cuCtx.lfnstLastScanPos || nonZeroCoeffNonTsCorner8x8 || isTrSkip ) -#endif #else #if JVET_P0058_CHROMA_TS const bool isNonDCT2 = (TU::getCbf(*cu.firstTU, ComponentID(COMPONENT_Y)) && cu.firstTU->mtsIdx[COMPONENT_Y] != MTS_DCT2_DCT2); #else const bool isNonDCT2 = (TU::getCbf(*cu.firstTU, ComponentID(COMPONENT_Y)) && cu.firstTU->mtsIdx != MTS_DCT2_DCT2); #endif -#if JVET_P1026_ISP_LFNST_COMBINATION if( (!cuCtx.lfnstLastScanPos && !cu.ispMode) || nonZeroCoeffNonTsCorner8x8 || isNonDCT2 ) -#else - if( !cuCtx.lfnstLastScanPos || nonZeroCoeffNonTsCorner8x8 || isNonDCT2 ) -#endif #endif { return; diff --git a/source/Lib/EncoderLib/CABACWriter.h b/source/Lib/EncoderLib/CABACWriter.h index 5ffc2f5f1..b60defbe3 100644 --- a/source/Lib/EncoderLib/CABACWriter.h +++ b/source/Lib/EncoderLib/CABACWriter.h @@ -151,11 +151,7 @@ public: void residual_coding ( const TransformUnit& tu, ComponentID compID, CUCtx* cuCtx = nullptr ); #if JVET_P1026_MTS_SIGNALLING void ts_flag ( const TransformUnit& tu, ComponentID compID ); -#if JVET_P1026_ISP_LFNST_COMBINATION void mts_idx ( const CodingUnit& cu, CUCtx* cuCtx ); -#else - void mts_idx ( const CodingUnit& cu, CUCtx& cuCtx ); -#endif #else void mts_coding ( const TransformUnit& tu, ComponentID compID ); #endif diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index 089bdff13..e8912b3a6 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -1417,11 +1417,7 @@ public: void setLog2MaxTransformSkipBlockSize ( uint32_t u ) { m_log2MaxTransformSkipBlockSize = u; } bool getIntraSmoothingDisabledFlag () const { return m_intraSmoothingDisabledFlag; } void setIntraSmoothingDisabledFlag (bool bValue) { m_intraSmoothingDisabledFlag=bValue; } -#if JVET_P1026_ISP_LFNST_COMBINATION bool getUseFastISP () const { return m_useFastISP; } -#else - bool getUseFastISP () { return m_useFastISP; } -#endif void setUseFastISP ( bool b ) { m_useFastISP = b; } const int* getdQPs () const { return m_aidQP; } diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 2a6fe2f1d..3b04719db 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -1730,9 +1730,7 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC double dct2Cost = MAX_DOUBLE; -#if JVET_P1026_ISP_LFNST_COMBINATION double bestNonDCT2Cost = MAX_DOUBLE; -#endif double trGrpBestCost [ 4 ] = { MAX_DOUBLE, MAX_DOUBLE, MAX_DOUBLE, MAX_DOUBLE }; double globalBestCost = MAX_DOUBLE; bool bestSelFlag [ 4 ] = { false, false, false, false }; @@ -1754,9 +1752,7 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC #else int grpNumMax = sps.getUseLFNST() ? 4 : 1; #endif -#if JVET_P1026_ISP_LFNST_COMBINATION m_modeCtrl->setISPWasTested(false); -#endif m_pcIntraSearch->invalidateBestModeCost(); #if JVET_P0517_ADAPTIVE_COLOR_TRANSFORM if (sps.getUseColorTrans() && !CS::isDualITree(*tempCS)) @@ -1847,7 +1843,6 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC { continue; } -#if JVET_P1026_ISP_LFNST_COMBINATION #if JVET_P0517_ADAPTIVE_COLOR_TRANSFORM if (m_pcEncCfg->getUseFastISP() && validCandRet && !mtsFlag && !lfnstIdx && !cu.colorTransform) #else @@ -1860,7 +1855,6 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC m_modeCtrl->setBestISPIntraModeRelCU(cu.ispMode ? PU::getFinalIntraMode(*cu.firstPU, CHANNEL_TYPE_LUMA) : UINT8_MAX); m_modeCtrl->setBestDCT2NonISPCostRelCU(m_modeCtrl->getMtsFirstPassNoIspCost()); } -#endif #if JVET_P0517_ADAPTIVE_COLOR_TRANSFORM if (sps.getUseColorTrans() && m_pcEncCfg->getRGBFormatFlag() && !CS::isDualITree(*tempCS) && !cu.colorTransform) @@ -1972,9 +1966,6 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC tempCS->fracBits = m_CABACEstimator->getEstFracBits(); tempCS->cost = m_pcRdCost->calcRdCost(tempCS->fracBits, tempCS->dist); -#if !JVET_P1026_ISP_LFNST_COMBINATION - double bestIspCost = cu.ispMode ? cu.isSepTree() ? tempCS->cost : tempCS->lumaCost : MAX_DOUBLE; -#endif const double tmpCostWithoutSplitFlags = tempCS->cost; xEncodeDontSplit( *tempCS, partitioner ); @@ -1982,11 +1973,7 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC xCheckDQP( *tempCS, partitioner ); // Check if low frequency non-separable transform (LFNST) is too expensive -#if JVET_P1026_ISP_LFNST_COMBINATION if( lfnstIdx && !cuCtx.lfnstLastScanPos && !cu.ispMode ) -#else - if( lfnstIdx && !cuCtx.lfnstLastScanPos ) -#endif { bool cbfAtZeroDepth = cu.isSepTree() ? cu.rootCbf : std::min( cu.firstTU->blocks[ 1 ].width, cu.firstTU->blocks[ 1 ].height ) < 4 ? TU::getCbfAtDepth( *cu.firstTU, COMPONENT_Y, 0 ) : cu.rootCbf; if( cbfAtZeroDepth ) @@ -1999,12 +1986,10 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC { dct2Cost = tempCS->cost; } -#if JVET_P1026_ISP_LFNST_COMBINATION else if (tmpCostWithoutSplitFlags < bestNonDCT2Cost) { bestNonDCT2Cost = tmpCostWithoutSplitFlags; } -#endif if( tempCS->cost < bestCS->cost ) { @@ -2068,34 +2053,20 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC } //we decide to skip the non-DCT-II transforms and LFNST according to the ISP results -#if JVET_P1026_ISP_LFNST_COMBINATION if ((endMtsFlag > 0 || endLfnstIdx > 0) && (cu.ispMode || (bestCS && bestCS->cus[0]->ispMode)) && tempCS->slice->isIntra() && m_pcEncCfg->getUseFastISP()) -#else - if ((endMtsFlag > 0 || endLfnstIdx > 0) && cu.ispMode && !mtsFlag && !lfnstIdx && tempCS->slice->isIntra() && m_pcEncCfg->getUseFastISP()) -#endif { double bestCostDct2NoIsp = m_modeCtrl->getMtsFirstPassNoIspCost(); -#if JVET_P1026_ISP_LFNST_COMBINATION double bestIspCost = m_modeCtrl->getIspCost(); -#endif CHECKD( bestCostDct2NoIsp <= bestIspCost, "wrong cost!" ); double threshold = 1.4; double lfnstThreshold = 1.01 * threshold; -#if JVET_P1026_ISP_LFNST_COMBINATION if( m_modeCtrl->getStopNonDCT2Transforms() || bestCostDct2NoIsp > bestIspCost*lfnstThreshold ) -#else - if( bestCostDct2NoIsp > bestIspCost*lfnstThreshold ) -#endif { endLfnstIdx = lfnstIdx; } -#if JVET_P1026_ISP_LFNST_COMBINATION if ( m_modeCtrl->getStopNonDCT2Transforms() || bestCostDct2NoIsp > bestIspCost*threshold ) -#else - if( bestCostDct2NoIsp > bestIspCost*threshold ) -#endif { skipSecondMtsPass = true; m_modeCtrl->setSkipSecondMTSPass( true ); @@ -2136,12 +2107,10 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC } } } //trGrpIdx -#if JVET_P1026_ISP_LFNST_COMBINATION #if JVET_P0517_ADAPTIVE_COLOR_TRANSFORM if(!adaptiveColorTrans) #endif m_modeCtrl->setBestNonDCT2Cost(bestNonDCT2Cost); -#endif #if JVET_P0517_ADAPTIVE_COLOR_TRANSFORM return foundZeroRootCbf; #endif diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp index 1a70f896c..e404c026e 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.cpp +++ b/source/Lib/EncoderLib/EncModeCtrl.cpp @@ -1584,7 +1584,6 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt { return false; } -#if JVET_P1026_ISP_LFNST_COMBINATION if ( m_pcEncCfg->getUseFastISP() && relatedCU.relatedCuIsValid ) { cuECtx.ispPredModeVal = relatedCU.ispPredModeVal; @@ -1593,7 +1592,6 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt cuECtx.bestNonDCT2Cost = relatedCU.bestNonDCT2Cost; cuECtx.bestISPIntraMode = relatedCU.bestISPIntraMode; } -#endif return true; } else if (encTestmode.type == ETM_PALETTE) @@ -1960,7 +1958,6 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt else if( CU::isIntra( *bestCU ) ) { relatedCU.isIntra = true; -#if JVET_P1026_ISP_LFNST_COMBINATION if ( m_pcEncCfg->getUseFastISP() && cuECtx.ispWasTested && ( !relatedCU.relatedCuIsValid || bestCS->cost < relatedCU.bestCost ) ) { // Compact data @@ -1987,7 +1984,6 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt relatedCU.bestISPIntraMode = cuECtx.bestISPIntraMode; relatedCU.relatedCuIsValid = true; } -#endif } #if ENABLE_SPLIT_PARALLELISM #if REUSE_CU_RESULTS diff --git a/source/Lib/EncoderLib/EncModeCtrl.h b/source/Lib/EncoderLib/EncModeCtrl.h index fa0f810bb..26daef4cb 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.h +++ b/source/Lib/EncoderLib/EncModeCtrl.h @@ -200,7 +200,6 @@ struct ComprCUCtx #endif , bestCostWithoutSplitFlags( MAX_DOUBLE ) , bestCostMtsFirstPassNoIsp( MAX_DOUBLE ) -#if JVET_P1026_ISP_LFNST_COMBINATION , bestCostIsp ( MAX_DOUBLE ) , ispWasTested ( false ) , bestPredModeDCT2 @@ -219,7 +218,6 @@ struct ComprCUCtx , ispLfnstIdx ( 0 ) , stopNonDCT2Transforms ( false ) -#endif { getAreaIdx( cs.area.Y(), *cs.pcv, cuX, cuY, cuW, cuH ); partIdx = ( ( cuX << 8 ) | cuY ); @@ -252,7 +250,6 @@ struct ComprCUCtx #endif double bestCostWithoutSplitFlags; double bestCostMtsFirstPassNoIsp; -#if JVET_P1026_ISP_LFNST_COMBINATION double bestCostIsp; bool ispWasTested; uint16_t bestPredModeDCT2; @@ -265,7 +262,6 @@ struct ComprCUCtx uint8_t ispMode; uint8_t ispLfnstIdx; bool stopNonDCT2Transforms; -#endif template<typename T> T get( int ft ) const { return typeid(T) == typeid(double) ? (T&)extraFeaturesd[ft] : T(extraFeatures[ft]); } template<typename T> void set( int ft, T val ) { extraFeatures [ft] = int64_t( val ); } @@ -353,7 +349,6 @@ public: void setBestCostWithoutSplitFlags ( double cost ) { m_ComprCUCtxList.back().bestCostWithoutSplitFlags = cost; } double getMtsFirstPassNoIspCost () const { return m_ComprCUCtxList.back().bestCostMtsFirstPassNoIsp; } void setMtsFirstPassNoIspCost ( double cost ) { m_ComprCUCtxList.back().bestCostMtsFirstPassNoIsp = cost; } -#if JVET_P1026_ISP_LFNST_COMBINATION double getIspCost () const { return m_ComprCUCtxList.back().bestCostIsp; } void setIspCost ( double val ) { m_ComprCUCtxList.back().bestCostIsp = val; } bool getISPWasTested () const { return m_ComprCUCtxList.back().ispWasTested; } @@ -375,7 +370,6 @@ public: void setISPLfnstIdx ( uint8_t val ) { m_ComprCUCtxList.back().ispLfnstIdx = val; } bool getStopNonDCT2Transforms () const { return m_ComprCUCtxList.back().stopNonDCT2Transforms; } void setStopNonDCT2Transforms ( bool val ) { m_ComprCUCtxList.back().stopNonDCT2Transforms = val; } -#endif void setInterSearch (InterSearch* pcInterSearch) { m_pcInterSearch = pcInterSearch; } void setPltEnc ( bool b ) { m_doPlt = b; } bool getPltEnc() const { return m_doPlt; } @@ -441,14 +435,12 @@ struct CodedCUInfo #if JVET_P0517_ADAPTIVE_COLOR_TRANSFORM char selectColorSpaceOption; // 0 - test both two color spaces; 1 - only test the first color spaces; 2 - only test the second color spaces #endif -#if JVET_P1026_ISP_LFNST_COMBINATION uint16_t ispPredModeVal; double bestDCT2NonISPCost; double bestCost; double bestNonDCT2Cost; bool relatedCuIsValid; uint8_t bestISPIntraMode; -#endif #if ENABLE_SPLIT_PARALLELISM diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index 54aa21819..b4ea0bf94 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -467,7 +467,6 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, m_regIntraRDListWithCosts.clear(); int numTotalPartsHor = (int)width >> floorLog2(CU::getISPSplitDim(width, height, TU_1D_VERT_SPLIT)); int numTotalPartsVer = (int)height >> floorLog2(CU::getISPSplitDim(width, height, TU_1D_HORZ_SPLIT)); -#if JVET_P1026_ISP_LFNST_COMBINATION m_ispTestedModes[0].init( numTotalPartsHor, numTotalPartsVer ); //the total number of subpartitions is modified to take into account the cases where LFNST cannot be combined with ISP due to size restrictions numTotalPartsHor = sps.getUseLFNST() && CU::canUseLfnstWithISP(cu.Y(), HOR_INTRA_SUBPARTITIONS) ? numTotalPartsHor : 0; @@ -476,9 +475,6 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, { m_ispTestedModes[j].init(numTotalPartsHor, numTotalPartsVer); } -#else - m_ispTestedModes.init(numTotalPartsHor, numTotalPartsVer); -#endif } #if JVET_P0059_CHROMA_BDPCM @@ -997,12 +993,8 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, if ( testISP ) { // we reserve positions for ISP in the common full RD list -#if JVET_P1026_ISP_LFNST_COMBINATION const int maxNumRDModesISP = sps.getUseLFNST() ? 16 * NUM_LFNST_NUM_PER_SET : 16; m_curIspLfnstIdx = 0; -#else - const int maxNumRDModesISP = 16; -#endif for (int i = 0; i < maxNumRDModesISP; i++) uiRdModeList.push_back( ModeInfo( false, false, 0, INTRA_SUBPARTITIONS_RESERVED, 0 ) ); } @@ -1026,19 +1018,12 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, // just to be sure numModesForFullRD = ( int ) uiRdModeList.size(); TUIntraSubPartitioner subTuPartitioner( partitioner ); -#if JVET_P1026_ISP_LFNST_COMBINATION if ( testISP ) { m_modeCtrl->setIspCost( MAX_DOUBLE ); m_modeCtrl->setMtsFirstPassNoIspCost( MAX_DOUBLE ); } int bestLfnstIdx = cu.lfnstIdx; -#else - if( !cu.ispMode && !cu.mtsFlag ) - { - m_modeCtrl->setMtsFirstPassNoIspCost( MAX_DOUBLE ); - } -#endif #if JVET_P0517_ADAPTIVE_COLOR_TRANSFORM for (int mode = isSecondColorSpace ? 0 : -2 * int(testBDPCM); mode < (int)uiRdModeList.size(); mode++) @@ -1084,23 +1069,17 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, { if (mode == numNonISPModes) // the list needs to be sorted only once { -#if JVET_P1026_ISP_LFNST_COMBINATION if (m_pcEncCfg->getUseFastISP()) { m_modeCtrl->setBestPredModeDCT2(uiBestPUMode.modeId); } if (!xSortISPCandList(bestCurrentCost, csBest->cost, uiBestPUMode)) break; -#else - xSortISPCandList(bestCurrentCost, csBest->cost); -#endif } xGetNextISPMode(uiRdModeList[mode], (mode > 0 ? &uiRdModeList[mode - 1] : nullptr), Size(width, height)); if (uiRdModeList[mode].ispMod == INTRA_SUBPARTITIONS_RESERVED) continue; -#if JVET_P1026_ISP_LFNST_COMBINATION cu.lfnstIdx = m_curIspLfnstIdx; -#endif #if JVET_P0517_ADAPTIVE_COLOR_TRANSFORM uiOrgMode = uiRdModeList[mode]; } @@ -1135,12 +1114,10 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, bool tmpValidReturn = false; if( cu.ispMode ) { -#if JVET_P1026_ISP_LFNST_COMBINATION if ( m_pcEncCfg->getUseFastISP() ) { m_modeCtrl->setISPWasTested(true); } -#endif tmpValidReturn = xIntraCodingLumaISP(*csTemp, subTuPartitioner, bestCurrentCost); if (csTemp->tus.size() == 0) { @@ -1148,17 +1125,9 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, csTemp->cost = MAX_DOUBLE; continue; } -#if JVET_P1026_ISP_LFNST_COMBINATION // we save the data for future tests m_ispTestedModes[m_curIspLfnstIdx].setModeResults((ISPType)cu.ispMode, (int)uiOrgMode.modeId, (int)csTemp->tus.size(), csTemp->cus[0]->firstTU->cbf[COMPONENT_Y] ? csTemp->cost : MAX_DOUBLE, csBest->cost); csTemp->cost = !tmpValidReturn ? MAX_DOUBLE : csTemp->cost; -#else - if (!cu.mtsFlag && !cu.lfnstIdx) - { - // we save the data for future tests - m_ispTestedModes.setModeResults((ISPType)cu.ispMode, (int)uiOrgMode.modeId, (int)csTemp->tus.size(), csTemp->cus[0]->firstTU->cbf[COMPONENT_Y] ? csTemp->cost : MAX_DOUBLE, csBest->cost); - } -#endif } else { @@ -1223,7 +1192,6 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, { bestCurrentCost = csBest->cost; } -#if JVET_P1026_ISP_LFNST_COMBINATION if ( cu.ispMode ) { m_modeCtrl->setIspCost(csBest->cost); @@ -1233,12 +1201,6 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, { m_modeCtrl->setMtsFirstPassNoIspCost(csBest->cost); } -#else - if( !cu.ispMode && !cu.mtsFlag ) - { - m_modeCtrl->setMtsFirstPassNoIspCost( csBest->cost ); - } -#endif } if( !cu.ispMode && !cu.bdpcmMode && csBest->cost < bestCostNonBDPCM ) { @@ -1279,9 +1241,7 @@ bool IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, #endif } // Mode loop cu.ispMode = uiBestPUMode.ispMod; -#if JVET_P1026_ISP_LFNST_COMBINATION cu.lfnstIdx = bestLfnstIdx; -#endif if( validReturn ) { @@ -2982,11 +2942,7 @@ void IntraSearch::xEncSubdivCbfQT( CodingStructure &cs, Partitioner &partitioner } } -#if JVET_P1026_ISP_LFNST_COMBINATION void IntraSearch::xEncCoeffQT( CodingStructure &cs, Partitioner &partitioner, const ComponentID compID, const int subTuIdx, const PartSplit ispType, CUCtx* cuCtx ) -#else -void IntraSearch::xEncCoeffQT( CodingStructure &cs, Partitioner &partitioner, const ComponentID compID, const int subTuIdx, const PartSplit ispType ) -#endif { const UnitArea &currArea = partitioner.currArea(); @@ -3010,11 +2966,7 @@ void IntraSearch::xEncCoeffQT( CodingStructure &cs, Partitioner &partitioner, co do { -#if JVET_P1026_ISP_LFNST_COMBINATION xEncCoeffQT( cs, partitioner, compID, subTuCounter, ispType, cuCtx ); -#else - xEncCoeffQT( cs, partitioner, compID, subTuCounter, ispType ); -#endif subTuCounter += subTuCounter != -1 ? 1 : 0; } while( partitioner.nextPart( cs ) ); @@ -3038,14 +2990,8 @@ void IntraSearch::xEncCoeffQT( CodingStructure &cs, Partitioner &partitioner, co #if JVET_P1026_MTS_SIGNALLING if( isLuma(compID) ) { -#if JVET_P1026_ISP_LFNST_COMBINATION m_CABACEstimator->residual_coding( currTU, compID, cuCtx ); m_CABACEstimator->mts_idx( *currTU.cu, cuCtx ); -#else - CUCtx cuCtx; - m_CABACEstimator->residual_coding( currTU, compID, &cuCtx ); - m_CABACEstimator->mts_idx( *currTU.cu, cuCtx ); -#endif } else #endif @@ -3054,11 +3000,7 @@ void IntraSearch::xEncCoeffQT( CodingStructure &cs, Partitioner &partitioner, co } } -#if JVET_P1026_ISP_LFNST_COMBINATION uint64_t IntraSearch::xGetIntraFracBitsQT( CodingStructure &cs, Partitioner &partitioner, const bool &bLuma, const bool &bChroma, const int subTuIdx, const PartSplit ispType, CUCtx* cuCtx ) -#else -uint64_t IntraSearch::xGetIntraFracBitsQT( CodingStructure &cs, Partitioner &partitioner, const bool &bLuma, const bool &bChroma, const int subTuIdx, const PartSplit ispType ) -#endif { m_CABACEstimator->resetBits(); @@ -3068,11 +3010,7 @@ uint64_t IntraSearch::xGetIntraFracBitsQT( CodingStructure &cs, Partitioner &par if( bLuma ) { -#if JVET_P1026_ISP_LFNST_COMBINATION xEncCoeffQT( cs, partitioner, COMPONENT_Y, subTuIdx, ispType, cuCtx ); -#else - xEncCoeffQT( cs, partitioner, COMPONENT_Y, subTuIdx, ispType ); -#endif } if( bChroma ) { @@ -3080,13 +3018,11 @@ uint64_t IntraSearch::xGetIntraFracBitsQT( CodingStructure &cs, Partitioner &par xEncCoeffQT( cs, partitioner, COMPONENT_Cr, subTuIdx, ispType ); } -#if JVET_P1026_ISP_LFNST_COMBINATION CodingUnit& cu = *cs.getCU(partitioner.chType); if ( cuCtx && bLuma && cu.isSepTree() && ( !cu.ispMode || ( cu.lfnstIdx && subTuIdx == 0 ) || ( !cu.lfnstIdx && subTuIdx == m_ispTestedModes[cu.lfnstIdx].numTotalParts[cu.ispMode - 1] - 1 ) ) ) { m_CABACEstimator->residual_lfnst_mode(cu, *cuCtx); } -#endif uint64_t fracBits = m_CABACEstimator->getEstFracBits(); return fracBits; @@ -3736,11 +3672,9 @@ bool IntraSearch::xIntraCodingLumaISP(CodingStructure& cs, Partitioner& partitio partitioner.splitCurrArea(ispType, cs); -#if JVET_P1026_ISP_LFNST_COMBINATION CUCtx cuCtx; cuCtx.isDQPCoded = true; cuCtx.isChromaQpAdjCoded = true; -#endif do // subpartitions loop { @@ -3771,11 +3705,7 @@ bool IntraSearch::xIntraCodingLumaISP(CodingStructure& cs, Partitioner& partitio } else { -#if JVET_P1026_ISP_LFNST_COMBINATION singleTmpFracBits = xGetIntraFracBitsQT(cs, partitioner, true, false, subTuCounter, ispType, &cuCtx); -#else - singleTmpFracBits = xGetIntraFracBitsQT(cs, partitioner, true, false, subTuCounter, ispType); -#endif } singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma); } @@ -3787,11 +3717,7 @@ bool IntraSearch::xIntraCodingLumaISP(CodingStructure& cs, Partitioner& partitio subTuCounter++; splitCbfLuma |= TU::getCbfAtDepth(*cs.getTU(partitioner.currArea().lumaPos(), partitioner.chType, subTuCounter - 1), COMPONENT_Y, partitioner.currTrDepth); -#if JVET_P1026_ISP_LFNST_COMBINATION int nSubPartitions = m_ispTestedModes[cu.lfnstIdx].numTotalParts[cu.ispMode - 1]; -#else - int nSubPartitions = m_ispTestedModes.numTotalParts[cu.ispMode - 1]; -#endif if (subTuCounter < nSubPartitions) { // exit condition if the accumulated cost is already larger than the best cost so far (no impact in RD performance) @@ -3840,9 +3766,6 @@ bool IntraSearch::xIntraCodingLumaISP(CodingStructure& cs, Partitioner& partitio } else { -#if !JVET_P1026_ISP_LFNST_COMBINATION - cs.cost = MAX_DOUBLE; -#endif earlySkipISP = true; } } @@ -3886,11 +3809,9 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par CodingStructure *csSplit = nullptr; CodingStructure *csFull = nullptr; -#if JVET_P1026_ISP_LFNST_COMBINATION CUCtx cuCtx; cuCtx.isDQPCoded = true; cuCtx.isChromaQpAdjCoded = true; -#endif if( bCheckSplit ) { @@ -4168,11 +4089,7 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par } else { -#if JVET_P1026_ISP_LFNST_COMBINATION singleTmpFracBits = xGetIntraFracBitsQT( *csFull, partitioner, true, false, subTuCounter, ispType, &cuCtx ); -#else - singleTmpFracBits = xGetIntraFracBitsQT( *csFull, partitioner, true, false, subTuCounter, ispType ); -#endif } singleCostTmp = m_pcRdCost->calcRdCost( singleTmpFracBits, singleDistTmpLuma ); } @@ -4347,21 +4264,15 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par //----- restore context states ----- m_CABACEstimator->getCtx() = ctxStart; -#if JVET_P1026_ISP_LFNST_COMBINATION cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_LUMA] = false; cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] = false; cuCtx.lfnstLastScanPos = false; #if JVET_P1026_MTS_SIGNALLING cuCtx.violatesMtsCoeffConstraint = false; -#endif #endif //----- determine rate and r-d cost ----- -#if JVET_P1026_ISP_LFNST_COMBINATION csSplit->fracBits = xGetIntraFracBitsQT( *csSplit, partitioner, true, false, cu.ispMode ? 0 : -1, ispType, &cuCtx ); -#else - csSplit->fracBits = xGetIntraFracBitsQT( *csSplit, partitioner, true, false, cu.ispMode ? 0 : -1, ispType ); -#endif //--- update cost --- csSplit->cost = m_pcRdCost->calcRdCost(csSplit->fracBits, csSplit->dist); @@ -5703,21 +5614,15 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, { static_vector<ModeInfo, FAST_UDI_MAX_RDMODE_NUM>* rdModeLists[2] = { &m_ispCandListHor, &m_ispCandListVer }; -#if JVET_P1026_ISP_LFNST_COMBINATION const int curIspLfnstIdx = m_curIspLfnstIdx; if (curIspLfnstIdx >= NUM_LFNST_NUM_PER_SET) { //All lfnst indices have been checked return; } -#endif ISPType nextISPcandSplitType; -#if JVET_P1026_ISP_LFNST_COMBINATION auto& ispTestedModes = m_ispTestedModes[curIspLfnstIdx]; -#else - auto& ispTestedModes = m_ispTestedModes; -#endif const bool horSplitIsTerminated = ispTestedModes.splitIsFinished[HOR_INTRA_SUBPARTITIONS - 1]; const bool verSplitIsTerminated = ispTestedModes.splitIsFinished[VER_INTRA_SUBPARTITIONS - 1]; if (!horSplitIsTerminated && !verSplitIsTerminated) @@ -5734,15 +5639,12 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, } else { -#if JVET_P1026_ISP_LFNST_COMBINATION xFinishISPModes(); -#endif return; // no more modes will be tested } int maxNumSubPartitions = ispTestedModes.numTotalParts[nextISPcandSplitType - 1]; -#if JVET_P1026_ISP_LFNST_COMBINATION // We try to break the split here for lfnst > 0 according to the first mode if (curIspLfnstIdx > 0 && ispTestedModes.numTestedModes[nextISPcandSplitType - 1] == 1) { @@ -5770,22 +5672,15 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, return; } } -#endif -#if JVET_P1026_ISP_LFNST_COMBINATION // We try to break the split here for lfnst = 0 or all lfnst indices according to the first two modes if (curIspLfnstIdx == 0 && ispTestedModes.numTestedModes[nextISPcandSplitType - 1] == 2) -#else - if (ispTestedModes.numTestedModes[nextISPcandSplitType - 1] >= 2) -#endif { // Split stop criteria after checking the performance of previously tested intra modes const int thresholdSplit1 = maxNumSubPartitions; bool stopThisSplit = false; -#if JVET_P1026_ISP_LFNST_COMBINATION bool stopThisSplitForAllLFNSTs = false; const int thresholdSplit1ForAllLFNSTs = maxNumSubPartitions - 1; -#endif int mode1 = ispTestedModes.getTestedIntraMode((ISPType)nextISPcandSplitType, 0); mode1 = mode1 == DC_IDX ? -1 : mode1; @@ -5800,14 +5695,11 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, if (numSubPartsBestMode1 < thresholdSplit1 && numSubPartsBestMode2 < thresholdSplit1) { stopThisSplit = true; -#if JVET_P1026_ISP_LFNST_COMBINATION if (curIspLfnstIdx == 0 && numSubPartsBestMode1 < thresholdSplit1ForAllLFNSTs && numSubPartsBestMode2 < thresholdSplit1ForAllLFNSTs) { stopThisSplitForAllLFNSTs = true; } -#endif } -#if JVET_P1026_ISP_LFNST_COMBINATION else { //we stop also if the cost is MAX_DOUBLE for both modes @@ -5818,7 +5710,6 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, stopThisSplit = true; } } -#endif } if (!stopThisSplit) @@ -5826,28 +5717,18 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, // 2) One split type may be discarded by comparing the number of sub-partitions of the best angle modes of both splits ISPType otherSplit = nextISPcandSplitType == HOR_INTRA_SUBPARTITIONS ? VER_INTRA_SUBPARTITIONS : HOR_INTRA_SUBPARTITIONS; int numSubPartsBestMode2OtherSplit = mode2 != -1 ? ispTestedModes.getNumCompletedSubParts(otherSplit, mode2) : -1; -#if JVET_P1026_ISP_LFNST_COMBINATION if (numSubPartsBestMode2OtherSplit != -1 && numSubPartsBestMode2 != -1 && ispTestedModes.bestSplitSoFar != nextISPcandSplitType) -#else - if (numSubPartsBestMode2OtherSplit != -1 && numSubPartsBestMode2 != -1) -#endif { if (numSubPartsBestMode2OtherSplit > numSubPartsBestMode2) { stopThisSplit = true; } -#if JVET_P1026_ISP_LFNST_COMBINATION // both have the same number of subpartitions else if (numSubPartsBestMode2OtherSplit == numSubPartsBestMode2) -#else - else if (numSubPartsBestMode2OtherSplit == numSubPartsBestMode2 && numSubPartsBestMode2OtherSplit == maxNumSubPartitions) -#endif { -#if JVET_P1026_ISP_LFNST_COMBINATION // both have the maximum number of subpartitions, so it compares RD costs to decide if (numSubPartsBestMode2OtherSplit == maxNumSubPartitions) { -#endif double rdCostBestMode2ThisSplit = ispTestedModes.getRDCost(nextISPcandSplitType, mode2); double rdCostBestMode2OtherSplit = ispTestedModes.getRDCost(otherSplit, mode2); double threshold = 1.3; @@ -5855,7 +5736,6 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, { stopThisSplit = true; } -#if JVET_P1026_ISP_LFNST_COMBINATION } else // none of them reached the maximum number of subpartitions with the best angle modes, so it compares the results with the the planar mode { @@ -5865,14 +5745,12 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, stopThisSplit = true; } } -#endif } } } if (stopThisSplit) { ispTestedModes.splitIsFinished[nextISPcandSplitType - 1] = true; -#if JVET_P1026_ISP_LFNST_COMBINATION if (stopThisSplitForAllLFNSTs) { for (int lfnstIdx = 1; lfnstIdx < NUM_LFNST_NUM_PER_SET; lfnstIdx++) @@ -5880,7 +5758,6 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, m_ispTestedModes[lfnstIdx].splitIsFinished[nextISPcandSplitType - 1] = true; } } -#endif return; } } @@ -5896,9 +5773,7 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, { if (ispTestedModes.bestSplitSoFar != candidate.ispMod || ispTestedModes.bestModeSoFar == PLANAR_IDX) { -#if JVET_P1026_ISP_LFNST_COMBINATION ispTestedModes.splitIsFinished[nextISPcandSplitType - 1] = true; -#endif return; } } @@ -5906,28 +5781,17 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, bool testCandidate = true; // we look for a reference mode that has already been tested within the window and decide to test the new one according to the reference mode costs -#if JVET_P1026_ISP_LFNST_COMBINATION if (maxNumSubPartitions > 2 && (curIspLfnstIdx > 0 || (candidate.modeId >= DC_IDX && ispTestedModes.numTestedModes[nextISPcandSplitType - 1] >= 2))) -#else - if (candidate.modeId >= DC_IDX && maxNumSubPartitions > 2 && ispTestedModes.numTestedModes[nextISPcandSplitType - 1] >= 2) -#endif { -#if JVET_P1026_ISP_LFNST_COMBINATION int refLfnstIdx = -1; -#endif const int angWindowSize = 5; int numSubPartsLeftMode, numSubPartsRightMode, numSubPartsRefMode, leftIntraMode = -1, rightIntraMode = -1; int windowSize = candidate.modeId > DC_IDX ? angWindowSize : 1; int numSamples = cuSize.width << floorLog2(cuSize.height); int numSubPartsLimit = numSamples >= 256 ? maxNumSubPartitions - 1 : 2; -#if JVET_P1026_ISP_LFNST_COMBINATION xFindAlreadyTestedNearbyIntraModes(curIspLfnstIdx, (int)candidate.modeId, &refLfnstIdx, &leftIntraMode, &rightIntraMode, (ISPType)candidate.ispMod, windowSize); -#else - xFindAlreadyTestedNearbyIntraModes((int)candidate.modeId, &leftIntraMode, &rightIntraMode, (ISPType)candidate.ispMod, windowSize); -#endif -#if JVET_P1026_ISP_LFNST_COMBINATION if (refLfnstIdx != -1 && refLfnstIdx != curIspLfnstIdx) { CHECK(leftIntraMode != candidate.modeId || rightIntraMode != candidate.modeId, "wrong intra mode and lfnstIdx values!"); @@ -5936,14 +5800,11 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, } else { -#endif numSubPartsLeftMode = leftIntraMode != -1 ? ispTestedModes.getNumCompletedSubParts((ISPType)candidate.ispMod, leftIntraMode) : -1; numSubPartsRightMode = rightIntraMode != -1 ? ispTestedModes.getNumCompletedSubParts((ISPType)candidate.ispMod, rightIntraMode) : -1; numSubPartsRefMode = std::max(numSubPartsLeftMode, numSubPartsRightMode); -#if JVET_P1026_ISP_LFNST_COMBINATION } -#endif if (numSubPartsRefMode > 0) { @@ -5957,30 +5818,21 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, modeInfo = candidate; } } -#if JVET_P1026_ISP_LFNST_COMBINATION else { //the end of the list was reached, so the split is invalidated ispTestedModes.splitIsFinished[nextISPcandSplitType - 1] = true; } -#endif } -#if JVET_P1026_ISP_LFNST_COMBINATION void IntraSearch::xFindAlreadyTestedNearbyIntraModes(int lfnstIdx, int currentIntraMode, int* refLfnstIdx, int* leftIntraMode, int* rightIntraMode, ISPType ispOption, int windowSize) -#else -void IntraSearch::xFindAlreadyTestedNearbyIntraModes(int currentIntraMode, int* leftIntraMode, int* rightIntraMode, ISPType ispOption, int windowSize) -#endif { bool leftModeFound = false, rightModeFound = false; *leftIntraMode = -1; *rightIntraMode = -1; -#if JVET_P1026_ISP_LFNST_COMBINATION *refLfnstIdx = -1; -#endif const unsigned st = ispOption - 1; -#if JVET_P1026_ISP_LFNST_COMBINATION //first we check if the exact intra mode was already tested for another lfnstIdx value if (lfnstIdx > 0) { @@ -6005,40 +5857,27 @@ void IntraSearch::xFindAlreadyTestedNearbyIntraModes(int currentIntraMode, int* } //The mode has not been checked for another lfnstIdx value, so now we look for a similar mode within a window using the same lfnstIdx -#endif for (int k = 1; k <= windowSize; k++) { int off = currentIntraMode - 2 - k; int leftMode = (off < 0) ? NUM_LUMA_MODE + off : currentIntraMode - k; int rightMode = currentIntraMode > DC_IDX ? (((int)currentIntraMode - 2 + k) % 65) + 2 : PLANAR_IDX; -#if JVET_P1026_ISP_LFNST_COMBINATION leftModeFound = leftMode != (int)currentIntraMode ? m_ispTestedModes[lfnstIdx].modeHasBeenTested[leftMode][st] : false; rightModeFound = rightMode != (int)currentIntraMode ? m_ispTestedModes[lfnstIdx].modeHasBeenTested[rightMode][st] : false; -#else - leftModeFound = leftMode != (int)currentIntraMode ? m_ispTestedModes.modeHasBeenTested[leftMode][st] : false; - rightModeFound = rightMode != (int)currentIntraMode ? m_ispTestedModes.modeHasBeenTested[rightMode][st] : false; -#endif if (leftModeFound || rightModeFound) { *leftIntraMode = leftModeFound ? leftMode : -1; *rightIntraMode = rightModeFound ? rightMode : -1; -#if JVET_P1026_ISP_LFNST_COMBINATION *refLfnstIdx = lfnstIdx; -#endif break; } } } -#if JVET_P1026_ISP_LFNST_COMBINATION //It prepares the list of potential intra modes candidates that will be tested using RD costs bool IntraSearch::xSortISPCandList(double bestCostSoFar, double bestNonISPCost, ModeInfo bestNonISPMode) -#else -void IntraSearch::xSortISPCandList(double bestCostSoFar, double bestNonISPCost) -#endif { -#if JVET_P1026_ISP_LFNST_COMBINATION int bestISPModeInRelCU = -1; m_modeCtrl->setStopNonDCT2Transforms(false); @@ -6062,20 +5901,6 @@ void IntraSearch::xSortISPCandList(double bestCostSoFar, double bestNonISPCost) return false; } } -#else - if (m_pcEncCfg->getUseFastISP()) - { - double thSkipISP = 1.4; - if (bestNonISPCost > bestCostSoFar * thSkipISP) - { - for (int splitIdx = 0; splitIdx < NUM_INTRA_SUBPARTITIONS_MODES - 1; splitIdx++) - { - m_ispTestedModes.splitIsFinished[splitIdx] = true; - } - return; - } - } -#endif for (int k = 0; k < m_ispCandListHor.size(); k++) { @@ -6107,7 +5932,6 @@ void IntraSearch::xSortISPCandList(double bestCostSoFar, double bestNonISPCost) ModeInfo refMode = origHadList.at(0); auto* destListPtr = &m_ispCandListHor; - #if JVET_P1026_ISP_LFNST_COMBINATION //List creation if (m_pcEncCfg->getUseFastISP() && bestISPModeInRelCU != -1) //RelCU intra mode @@ -6159,44 +5983,6 @@ void IntraSearch::xSortISPCandList(double bestCostSoFar, double bestNonISPCost) { m_ispTestedModes[j].numOrigModesToTest = (int)destListPtr->size(); } -#else - // 1) Planar - destListPtr->push_back( ModeInfo( refMode.mipFlg, refMode.mipTrFlg, refMode.mRefId, refMode.ispMod, mode1 ) ); - modeIsInList[mode1] = true; - // 2) Best angle in regular intra - if (mode2 != -1) - { - destListPtr->push_back( ModeInfo( refMode.mipFlg, refMode.mipTrFlg, refMode.mRefId, refMode.ispMod, mode2 ) ); - modeIsInList[mode2] = true; - } - // 3) Remaining regular intra modes that were full RD tested (except DC, which is added after the angles from regular intra) - int dcModeIndex = -1; - for (int remModeIdx = 0; remModeIdx < m_regIntraRDListWithCosts.size(); remModeIdx++) - { - int currentMode = m_regIntraRDListWithCosts.at(remModeIdx).modeId; - if (currentMode != mode1 && currentMode != mode2) - { - if (currentMode > DC_IDX) - { - destListPtr->push_back( ModeInfo( refMode.mipFlg, refMode.mipTrFlg, refMode.mRefId, refMode.ispMod, currentMode ) ); - modeIsInList[currentMode] = true; - } - else if (currentMode == DC_IDX) - { - dcModeIndex = remModeIdx; - } - } - } - // 4) DC is added after the angles from regular intra - if (dcModeIndex != -1) - { - destListPtr->push_back( ModeInfo( refMode.mipFlg, refMode.mipTrFlg, refMode.mRefId, refMode.ispMod, DC_IDX ) ); - modeIsInList[DC_IDX] = true; - } - - // 5) We add extra candidates to the list that will only be tested if ISP is likely to win - m_ispTestedModes.numOrigModesToTest = (int)destListPtr->size(); -#endif const int addedModesFromHadList = 3; int newModesAdded = 0; @@ -6213,12 +5999,10 @@ void IntraSearch::xSortISPCandList(double bestCostSoFar, double bestNonISPCost) } } -#if JVET_P1026_ISP_LFNST_COMBINATION if (m_pcEncCfg->getUseFastISP() && bestISPModeInRelCU != -1) { destListPtr->resize(1); } -#endif // Copy modes to other split-type list m_ispCandListVer = m_ispCandListHor; @@ -6228,7 +6012,6 @@ void IntraSearch::xSortISPCandList(double bestCostSoFar, double bestNonISPCost) } // Reset the tested modes information to 0 -#if JVET_P1026_ISP_LFNST_COMBINATION for (int j = 0; j < NUM_LFNST_NUM_PER_SET; j++) { for (int i = 0; i < m_ispCandListHor.size(); i++) @@ -6237,15 +6020,8 @@ void IntraSearch::xSortISPCandList(double bestCostSoFar, double bestNonISPCost) } } return true; -#else - for (int i = 0; i < m_ispCandListHor.size(); i++) - { - m_ispTestedModes.clearISPModeInfo(m_ispCandListHor[i].modeId); - } -#endif } -#if JVET_P1026_ISP_LFNST_COMBINATION void IntraSearch::xSortISPCandListLFNST() { //It resorts the list of intra mode candidates for lfnstIdx > 0 by checking the RD costs for lfnstIdx = 0 @@ -6385,5 +6161,4 @@ void IntraSearch::xFinishISPModes() } } } -#endif diff --git a/source/Lib/EncoderLib/IntraSearch.h b/source/Lib/EncoderLib/IntraSearch.h index de86c0cf6..116458730 100644 --- a/source/Lib/EncoderLib/IntraSearch.h +++ b/source/Lib/EncoderLib/IntraSearch.h @@ -327,12 +327,8 @@ private: static_vector<ModeInfo, FAST_UDI_MAX_RDMODE_NUM> m_ispCandListHor, m_ispCandListVer; static_vector<ModeInfoWithCost, FAST_UDI_MAX_RDMODE_NUM> m_regIntraRDListWithCosts; -#if JVET_P1026_ISP_LFNST_COMBINATION ISPTestedModesInfo m_ispTestedModes[NUM_LFNST_NUM_PER_SET]; int m_curIspLfnstIdx; -#else - ISPTestedModesInfo m_ispTestedModes; -#endif //cost variables for the EMT algorithm and new modes list double m_bestModeCostStore[ NUM_LFNST_NUM_PER_SET ]; // RD cost of the best mode for each PU using DCT2 @@ -454,19 +450,11 @@ protected: void xEncIntraHeader ( CodingStructure &cs, Partitioner& pm, const bool &luma, const bool &chroma, const int subTuIdx = -1 ); void xEncSubdivCbfQT ( CodingStructure &cs, Partitioner& pm, const bool &luma, const bool &chroma, const int subTuIdx = -1, const PartSplit ispType = TU_NO_ISP ); -#if JVET_P1026_ISP_LFNST_COMBINATION uint64_t xGetIntraFracBitsQT ( CodingStructure &cs, Partitioner& pm, const bool &luma, const bool &chroma, const int subTuIdx = -1, const PartSplit ispType = TU_NO_ISP, CUCtx * cuCtx = nullptr ); -#else - uint64_t xGetIntraFracBitsQT ( CodingStructure &cs, Partitioner& pm, const bool &luma, const bool &chroma, const int subTuIdx = -1, const PartSplit ispType = TU_NO_ISP ); -#endif uint64_t xGetIntraFracBitsQTSingleChromaComponent( CodingStructure &cs, Partitioner& pm, const ComponentID compID ); uint64_t xGetIntraFracBitsQTChroma(TransformUnit& tu, const ComponentID &compID); -#if JVET_P1026_ISP_LFNST_COMBINATION void xEncCoeffQT ( CodingStructure &cs, Partitioner& pm, const ComponentID compID, const int subTuIdx = -1, const PartSplit ispType = TU_NO_ISP, CUCtx * cuCtx = nullptr ); -#else - void xEncCoeffQT ( CodingStructure &cs, Partitioner& pm, const ComponentID compID, const int subTuIdx = -1, const PartSplit ispType = TU_NO_ISP ); -#endif void xIntraCodingTUBlock (TransformUnit &tu, const ComponentID &compID, const bool &checkCrossCPrediction, Distortion& ruiDist, const int &default0Save1Load2 = 0, uint32_t* numSig = nullptr, std::vector<TrMode>* trModes=nullptr, const bool loadTr=false ); #if JVET_P0517_ADAPTIVE_COLOR_TRANSFORM @@ -501,16 +489,11 @@ protected: void preCalcPLTIndex ( CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp); #endif void xGetNextISPMode ( ModeInfo& modeInfo, const ModeInfo* lastMode, const Size cuSize ); -#if JVET_P1026_ISP_LFNST_COMBINATION bool xSortISPCandList ( double bestCostSoFar, double bestNonISPCost, ModeInfo bestNonISPMode ); void xSortISPCandListLFNST ( ); void xFindAlreadyTestedNearbyIntraModes ( int currentLfnstIdx, int currentIntraMode, int* refLfnstIdx, int* leftIntraMode, int* rightIntraMode, ISPType ispOption, int windowSize ); bool updateISPStatusFromRelCU ( double bestNonISPCostCurrCu, ModeInfo bestNonISPModeCurrCu, int& bestISPModeInRelCU ); void xFinishISPModes ( ); -#else - void xFindAlreadyTestedNearbyIntraModes ( int currentIntraMode, int* leftIntraMode, int* rightIntraMode, ISPType ispOption, int windowSize ); - void xSortISPCandList ( double bestCostSoFar, double bestNonISPCost ); -#endif };// END CLASS DEFINITION EncSearch //! \} -- GitLab