Commit 2e3d8b41 authored by Karsten Suehring's avatar Karsten Suehring
Browse files

remove pre-calc value for MPM and avoid dynamic memory allocation

parent 67bafee8
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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])
{
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment