diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 5bda75a751cf51c8b5a54d96c930f658a18a5471..aeddb9224b7b98ecae620cd205f8918d70d1ef05 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -2167,7 +2167,6 @@ public: , lumaWidth ( sps.getPicWidthInLumaSamples() ) , lumaHeight ( sps.getPicHeightInLumaSamples() ) , fastDeltaQPCuMaxSize( Clip3(sps.getMaxCUHeight() >> (sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u) ) - , numMPMs (NUM_MOST_PROBABLE_MODES) , noRQT ( sps.getSpsNext().getUseQTBT() ) , rectCUs ( sps.getSpsNext().getUseQTBT() ) , only2Nx2N ( sps.getSpsNext().getUseQTBT() ) @@ -2209,7 +2208,6 @@ public: const unsigned lumaWidth; const unsigned lumaHeight; const unsigned fastDeltaQPCuMaxSize; - const unsigned numMPMs; const bool noRQT; const bool rectCUs; const bool only2Nx2N; diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 29e609e47241011d056b166923d5693d361bfc33..7be4184a674fa808515c332671586b77a9cf57b5 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -298,7 +298,7 @@ cTUTraverser CU::traverseTUs( const CodingUnit& cu ) int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType &channelType /*= CHANNEL_TYPE_LUMA*/ ) { - const unsigned numMPMs = pu.cs->pcv->numMPMs; + const int numMPMs = NUM_MOST_PROBABLE_MODES; #if JVET_L0283_MULTI_REF_LINE const int extendRefLine = (channelType == CHANNEL_TYPE_LUMA) ? pu.multiRefIdx : 0; #endif @@ -737,7 +737,7 @@ bool PU::isChromaIntraModeCrossCheckMode( const PredictionUnit &pu ) #if JVET_L0100_MULTI_HYPOTHESIS_INTRA int PU::getMHIntraMPMs(const PredictionUnit &pu, unsigned* mpm, const ChannelType &channelType /*= CHANNEL_TYPE_LUMA*/, const bool isChromaMDMS /*= false*/, const unsigned startIdx /*= 0*/) { - const unsigned numMPMs = 3; + const int numMPMs = 3; // Multi-hypothesis intra uses only 3 MPM { int numCand = -1; uint32_t leftIntraDir = DC_IDX, aboveIntraDir = DC_IDX; diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 8b2c28b7ee4f5a4072fc2726bfb6df2b4614ac12..5a5497b54fa875bedcc07ce9e6297348adedbdf8 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -983,8 +983,6 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu ) RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2( STATS__CABAC_BITS__INTRA_DIR_ANG, cu.lumaSize(), CHANNEL_TYPE_LUMA ); - const uint32_t numMPMs = cu.cs->pcv->numMPMs; - // prev_intra_luma_pred_flag int numBlocks = CU::getNumPUs( cu ); int mpmFlag[4]; @@ -1003,15 +1001,14 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu ) PredictionUnit *pu = cu.firstPU; - // mpm_idx / rem_intra_luma_pred_mode + unsigned mpm_pred[NUM_MOST_PROBABLE_MODES]; // mpm_idx / rem_intra_luma_pred_mode for( int k = 0; k < numBlocks; k++ ) { - unsigned *mpm_pred = ( unsigned* ) alloca( numMPMs * sizeof( unsigned ) ); PU::getIntraMPMs( *pu, mpm_pred ); if( mpmFlag[k] ) { - unsigned ipred_idx = 0; + uint32_t ipred_idx = 0; { ipred_idx = m_BinDecoder.decodeBinEP(); if( ipred_idx ) @@ -1047,9 +1044,9 @@ void CABACReader::intra_luma_pred_modes( CodingUnit &cu ) #endif } //postponed sorting of MPMs (only in remaining branch) - std::sort( mpm_pred, mpm_pred + cu.cs->pcv->numMPMs ); + std::sort( mpm_pred, mpm_pred + NUM_MOST_PROBABLE_MODES ); - for( unsigned i = 0; i < cu.cs->pcv->numMPMs; i++ ) + for( uint32_t i = 0; i < NUM_MOST_PROBABLE_MODES; i++ ) { ipred_mode += (ipred_mode >= mpm_pred[i]); } @@ -1765,7 +1762,7 @@ void CABACReader::MHIntra_luma_pred_modes(CodingUnit &cu) RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2(STATS__CABAC_BITS__INTRA_DIR_ANG, cu.lumaSize(), CHANNEL_TYPE_LUMA); - const uint32_t numMPMs = 3; + const int numMPMs = 3; // Multi-hypothesis intra uses only 3 MPM // prev_intra_luma_pred_flag int numBlocks = CU::getNumPUs(cu); @@ -1784,7 +1781,6 @@ void CABACReader::MHIntra_luma_pred_modes(CodingUnit &cu) } unsigned mpm_pred[numMPMs]; - // mpm_idx / rem_intra_luma_pred_mode for (int k = 0; k < numBlocks; k++) { PU::getMHIntraMPMs(*pu, mpm_pred); diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 66e1b1d0e9add550014bf61b6eb2dc4602013a5a..e6dc1d326e6f90fde9f43190b253540417727b90 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -890,22 +890,21 @@ void CABACWriter::intra_luma_pred_modes( const CodingUnit& cu ) return; } - unsigned numMPMs = cu.cs->pcv->numMPMs; - int numBlocks = CU::getNumPUs( cu ); - unsigned *mpm_preds [4]; - unsigned mpm_idxs [4]; - unsigned ipred_modes [4]; + const int numMPMs = NUM_MOST_PROBABLE_MODES; + const int numBlocks = CU::getNumPUs( cu ); + unsigned mpm_preds [4][numMPMs]; + unsigned mpm_idxs [4]; + unsigned ipred_modes [4]; const PredictionUnit* pu = cu.firstPU; // prev_intra_luma_pred_flag for( int k = 0; k < numBlocks; k++ ) { - unsigned*& mpm_pred = mpm_preds[k]; + unsigned* mpm_pred = mpm_preds[k]; unsigned& mpm_idx = mpm_idxs[k]; unsigned& ipred_mode = ipred_modes[k]; - mpm_pred = ( unsigned* ) alloca( numMPMs * sizeof( unsigned ) ); PU::getIntraMPMs( *pu, mpm_pred ); ipred_mode = pu->intraDir[0]; @@ -969,7 +968,7 @@ void CABACWriter::intra_luma_pred_modes( const CodingUnit& cu ) std::sort( mpm_pred, mpm_pred + numMPMs ); { - for (int idx = int(numMPMs) - 1; idx >= 0; idx--) + for (int idx = numMPMs - 1; idx >= 0; idx--) { if (ipred_mode > mpm_pred[idx]) { @@ -995,15 +994,15 @@ void CABACWriter::intra_luma_pred_mode( const PredictionUnit& pu ) { // prev_intra_luma_pred_flag - unsigned numMPMs = pu.cs->pcv->numMPMs; - unsigned *mpm_pred = ( unsigned* ) alloca( numMPMs * sizeof( unsigned ) ); - + const int numMPMs = NUM_MOST_PROBABLE_MODES; + unsigned mpm_pred[numMPMs]; + PU::getIntraMPMs( pu, mpm_pred ); unsigned ipred_mode = pu.intraDir[0]; unsigned mpm_idx = numMPMs; - for( unsigned idx = 0; idx < numMPMs; idx++ ) + for( int idx = 0; idx < numMPMs; idx++ ) { if( ipred_mode == mpm_pred[idx] ) { @@ -1049,7 +1048,7 @@ void CABACWriter::intra_luma_pred_mode( const PredictionUnit& pu ) { std::sort( mpm_pred, mpm_pred + numMPMs ); { - for (int idx = int(numMPMs) - 1; idx >= 0; idx--) + for (int idx = numMPMs - 1; idx >= 0; idx--) { if (ipred_mode > mpm_pred[idx]) { @@ -1749,7 +1748,7 @@ void CABACWriter::MHIntra_luma_pred_modes(const CodingUnit& cu) return; } - const unsigned numMPMs = 3; + const int numMPMs = 3; int numBlocks = CU::getNumPUs(cu); unsigned mpm_idxs[4]; unsigned pred_modes[4]; @@ -1768,7 +1767,7 @@ void CABACWriter::MHIntra_luma_pred_modes(const CodingUnit& cu) mpm_idx = numMPMs; - for (unsigned idx = 0; idx < numMPMs; idx++) + for (int idx = 0; idx < numMPMs; idx++) { if (pred_mode == mpm_pred[idx]) { diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index 2e8376650e925ca594c81d6cd86793cb26d823be..ee87dae1a0f12f0bdcec91f3fea53031e635f7f8 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -496,8 +496,8 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner ) } #if JVET_L0283_MULTI_REF_LINE pu.multiRefIdx = 1; - unsigned numMPMs = pu.cs->pcv->numMPMs; - unsigned *multiRefMPM = (unsigned*)alloca(pu.cs->pcv->numMPMs * sizeof(unsigned)); + const int numMPMs = NUM_MOST_PROBABLE_MODES; + unsigned multiRefMPM [numMPMs]; PU::getIntraMPMs(pu, multiRefMPM); for (int mRefNum = 1; mRefNum < numOfPassesExtendRef; mRefNum++) { @@ -540,8 +540,8 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner ) #endif if( m_pcEncCfg->getFastUDIUseMPMEnabled() ) { - unsigned numMPMs = pu.cs->pcv->numMPMs; - unsigned *uiPreds = ( unsigned* ) alloca( numMPMs * sizeof( unsigned ) ); + const int numMPMs = NUM_MOST_PROBABLE_MODES; + unsigned uiPreds[numMPMs]; #if JVET_L0283_MULTI_REF_LINE pu.multiRefIdx = 0;