Changeset 1378 in SHVCSoftware


Ignore:
Timestamp:
23 Jul 2015, 20:39:49 (9 years ago)
Author:
seregin
Message:

dynamic memory allocation at decoder

Location:
branches/SHM-dev/source/App
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp

    r1338 r1378  
    6767{
    6868  memset( m_apcTDecTop, NULL, sizeof(m_apcTDecTop) );
     69  memset( m_apcTVideoIOYuvReconFile, NULL, sizeof(m_apcTVideoIOYuvReconFile) );
    6970
    7071  for(UInt layer=0; layer < MAX_LAYERS; layer++)
    7172  {
    7273    m_aiPOCLastDisplay[layer]  = -MAX_INT;
    73     m_apcTDecTop[layer] = &m_acTDecTop[layer];
    7474  }
    7575}
     
    106106      free ( m_pchReconFile[i] );
    107107      m_pchReconFile[i] = NULL;
     108    }
     109
     110    if( m_apcTDecTop[i] )
     111    {
     112      delete m_apcTDecTop[i];
     113      m_apcTDecTop[i] = NULL;
     114    }
     115
     116    if( m_apcTVideoIOYuvReconFile[i] )
     117    {
     118      delete m_apcTVideoIOYuvReconFile[i];
     119      m_apcTVideoIOYuvReconFile[i] = NULL;
    108120    }
    109121  }
     
    195207    streamYUV.open( m_pchBLReconFile, fstream::in | fstream::binary );
    196208  }
    197   TComList<TComPic*> *cListPic = m_acTDecTop[0].getListPic();
    198   m_acTDecTop[0].setBLReconFile( &streamYUV );
     209  TComList<TComPic*> *cListPic = m_apcTDecTop[0]->getListPic();
     210  m_apcTDecTop[0]->setBLReconFile( &streamYUV );
    199211  pcBLPic.setLayerId( 0 );
    200212  cListPic->pushBack( &pcBLPic );
     
    245257      else
    246258      {
    247         bNewPicture = m_acTDecTop[nalu.m_nuhLayerId].decode(nalu, m_iSkipFrame, m_aiPOCLastDisplay[nalu.m_nuhLayerId], curLayerId, bNewPOC);
     259        bNewPicture = m_apcTDecTop[nalu.m_nuhLayerId]->decode(nalu, m_iSkipFrame, m_aiPOCLastDisplay[nalu.m_nuhLayerId], curLayerId, bNewPOC);
    248260
    249261#if SVC_POC
    250         if( (bNewPicture && m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 3) || (m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 0) )
     262        if( (bNewPicture && m_apcTDecTop[nalu.m_nuhLayerId]->getParseIdc() == 3) || (m_apcTDecTop[nalu.m_nuhLayerId]->getParseIdc() == 0) )
    251263#else
    252264        if (bNewPicture)
     
    268280        }
    269281#if SVC_POC
    270         else if(m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 1)
     282        else if(m_apcTDecTop[nalu.m_nuhLayerId]->getParseIdc() == 1)
    271283        {
    272284          bitstreamFile.clear();
     
    284296
    285297#if SVC_POC
    286     if( ( (bNewPicture && m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 3) || m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 0 || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) &&
    287         !m_acTDecTop[nalu.m_nuhLayerId].getFirstSliceInSequence() )
     298    if( ( (bNewPicture && m_apcTDecTop[nalu.m_nuhLayerId]->getParseIdc() == 3) || m_apcTDecTop[nalu.m_nuhLayerId]->getParseIdc() == 0 || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) &&
     299        !m_apcTDecTop[nalu.m_nuhLayerId]->getFirstSliceInSequence() )
    288300#else
    289301    if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) &&
    290         !m_acTDecTop[nalu.m_nuhLayerId].getFirstSliceInSequence() )
     302        !m_apcTDecTop[nalu.m_nuhLayerId]->getFirstSliceInSequence() )
    291303#endif
    292304    {
    293305      if (!loopFiltered[curLayerId] || bitstreamFile)
    294306      {
    295         m_acTDecTop[curLayerId].executeLoopFilters(poc, pcListPic);
     307        m_apcTDecTop[curLayerId]->executeLoopFilters(poc, pcListPic);
    296308      }
    297309      loopFiltered[curLayerId] = (nalu.m_nalUnitType == NAL_UNIT_EOS);
     
    299311      if (nalu.m_nalUnitType == NAL_UNIT_EOS)
    300312      {
    301         m_acTDecTop[nalu.m_nuhLayerId].setFirstSliceInSequence(true);
     313        m_apcTDecTop[nalu.m_nuhLayerId]->setFirstSliceInSequence(true);
    302314      }
    303315    }
    304316    else if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) &&
    305               m_acTDecTop[nalu.m_nuhLayerId].getFirstSliceInSequence () )
    306     {
    307       m_acTDecTop[nalu.m_nuhLayerId].setFirstSliceInPicture (true);
     317              m_apcTDecTop[nalu.m_nuhLayerId]->getFirstSliceInSequence () )
     318    {
     319      m_apcTDecTop[nalu.m_nuhLayerId]->setFirstSliceInPicture (true);
    308320    }
    309321
    310322#if SVC_POC
    311     if( bNewPicture && m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() == 0 )
     323    if( bNewPicture && m_apcTDecTop[nalu.m_nuhLayerId]->getParseIdc() == 0 )
    312324    {
    313325      outputAllPictures( nalu.m_nuhLayerId, true );
     
    327339          }
    328340        }
    329         m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
     341        m_apcTVideoIOYuvReconFile[curLayerId]->open( m_pchReconFile[curLayerId], true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
    330342
    331343        openedReconFile[curLayerId] = true;
     
    334346      Bool outputPicturesFlag = true; 
    335347
    336       if( m_acTDecTop[nalu.m_nuhLayerId].getNoOutputPriorPicsFlag() )
     348      if( m_apcTDecTop[nalu.m_nuhLayerId]->getNoOutputPriorPicsFlag() )
    337349      {
    338350        outputPicturesFlag = false;
     
    345357
    346358#if SVC_POC
    347       if( bNewPicture && m_acTDecTop[nalu.m_nuhLayerId].getParseIdc() != 0 )
     359      if( bNewPicture && m_apcTDecTop[nalu.m_nuhLayerId]->getParseIdc() != 0 )
    348360      // New picture, slice header parsed but picture not decoded
    349361#else
     
    397409  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
    398410  {
    399     xFlushOutput( m_acTDecTop[layer].getListPic(), layer );
     411    xFlushOutput( m_apcTDecTop[layer]->getListPic(), layer );
    400412  }
    401413#endif
    402414  // delete buffers
    403415#if AVC_BASE
    404   UInt layerIdxmin = m_acTDecTop[0].getBLReconFile()->is_open() ? 1 : 0;
     416  UInt layerIdxmin = m_apcTDecTop[0]->getBLReconFile()->is_open() ? 1 : 0;
    405417
    406418  if( streamYUV.is_open() )
     
    418430#endif
    419431  {
    420     m_acTDecTop[layer].deletePicBuffer();
     432    m_apcTDecTop[layer]->deletePicBuffer();
    421433  }
    422434
     
    607619#endif
    608620  {
     621    m_apcTDecTop[layer] = new TDecTop;
     622    m_apcTVideoIOYuvReconFile[layer] = new TVideoIOYuv;
     623
    609624    // set layer ID
    610     m_acTDecTop[layer].setLayerId                      ( layer );
     625    m_apcTDecTop[layer]->setLayerId                      ( layer );
    611626
    612627    // create decoder class
    613     m_acTDecTop[layer].create();
    614 
    615     m_acTDecTop[layer].setLayerDec(m_apcTDecTop);
     628    m_apcTDecTop[layer]->create();
     629
     630    m_apcTDecTop[layer]->setLayerDec(m_apcTDecTop);
    616631  }
    617632#else
     
    635650    if ( m_pchReconFile[layer] )
    636651    {
    637       m_acTVideoIOYuvReconFile[layer].close();
     652      m_apcTVideoIOYuvReconFile[layer]->close();
    638653    }
    639654
    640655    // destroy decoder class
    641     m_acTDecTop[layer].destroy();
     656    m_apcTDecTop[layer]->destroy();
    642657  }
    643658#else
     
    662677#endif
    663678  {
    664     m_acTDecTop[layer].init();
    665     m_acTDecTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     679    m_apcTDecTop[layer]->init();
     680    m_apcTDecTop[layer]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
    666681#if CONFORMANCE_BITSTREAM_MODE
    667     m_acTDecTop[layer].setNumLayer( MAX_LAYERS );
    668 #else
    669     m_acTDecTop[layer].setNumLayer( m_tgtLayerId + 1 );
    670 #endif
    671     m_acTDecTop[layer].setCommonDecoderParams( &m_commonDecoderParams );
     682    m_apcTDecTop[layer]->setNumLayer( MAX_LAYERS );
     683#else
     684    m_apcTDecTop[layer]->setNumLayer( m_tgtLayerId + 1 );
     685#endif
     686    m_apcTDecTop[layer]->setCommonDecoderParams( &m_commonDecoderParams );
    672687  }
    673688#if CONFORMANCE_BITSTREAM_MODE
    674689  for(UInt layer = 0; layer < MAX_VPS_LAYER_IDX_PLUS1; layer++)
    675690  {
    676     m_acTDecTop[layer].setConfModeFlag( m_confModeFlag );
     691    m_apcTDecTop[layer]->setConfModeFlag( m_confModeFlag );
    677692  }
    678693#endif
     
    799814            Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    800815
    801             m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     816            m_apcTVideoIOYuvReconFile[layerId]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    802817              m_outputColourSpaceConvert,
    803818              conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
     
    894909          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    895910
    896           m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(), m_outputColourSpaceConvert,
     911          m_apcTVideoIOYuvReconFile[layerId]->write( pcPic->getPicYuvRec(), m_outputColourSpaceConvert,
    897912            conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
    898913            conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
     
    10181033          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    10191034
    1020           m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), m_outputColourSpaceConvert,
     1035          m_apcTVideoIOYuvReconFile[layerId]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(), m_outputColourSpaceConvert,
    10211036            conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
    10221037            conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
     
    10961111          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    10971112
    1098           m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
     1113          m_apcTVideoIOYuvReconFile[layerId]->write( pcPic->getPicYuvRec(),
    10991114                                                   m_outputColourSpaceConvert,
    11001115                                                   conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
     
    12321247
    12331248    TComPicYuv* pPicCYuvRec = pic->getPicYuvRec();
    1234     m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec, m_outputColourSpaceConvert,
     1249    m_apcTVideoIOYuvReconFile[layerId]->write( pPicCYuvRec, m_outputColourSpaceConvert,
    12351250      conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
    12361251      conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
     
    13621377Void TAppDecTop::markAllPicturesAsErased(Int layerIdx)
    13631378{
    1364   TComList<TComPic*>::iterator  iterPic = m_acTDecTop[layerIdx].getListPic()->begin();
    1365   Int iSize = Int( m_acTDecTop[layerIdx].getListPic()->size() );
     1379  TComList<TComPic*>::iterator  iterPic = m_apcTDecTop[layerIdx]->getListPic()->begin();
     1380  Int iSize = Int( m_apcTDecTop[layerIdx]->getListPic()->size() );
    13661381 
    13671382  for (Int i = 0; i < iSize; i++ )
     
    13741389
    13751390      // pcPic is statically created for the external (AVC) base layer, no need to delete it
    1376       if( !m_acTDecTop[layerIdx].getParameterSetManager()->getActiveVPS()->getNonHEVCBaseLayerFlag() || layerIdx )
     1391      if( !m_apcTDecTop[layerIdx]->getParameterSetManager()->getActiveVPS()->getNonHEVCBaseLayerFlag() || layerIdx )
    13771392      {
    13781393        delete pcPic;
     
    13821397  }
    13831398
    1384   m_acTDecTop[layerIdx].getListPic()->clear();
     1399  m_apcTDecTop[layerIdx]->getListPic()->clear();
    13851400}
    13861401
     
    14671482      Int picPosition = (Int)std::distance( listOfPocsInEachLayer[layerId].begin(), it );
    14681483      Int j;
    1469       for(j = 0, iterPic = m_acTDecTop[layerId].getListPic()->begin(); j < listOfPocsPositionInEachLayer[layerId][picPosition]; j++) // Picture to be output
     1484      for(j = 0, iterPic = m_apcTDecTop[layerId]->getListPic()->begin(); j < listOfPocsPositionInEachLayer[layerId][picPosition]; j++) // Picture to be output
    14701485      {
    14711486        iterPic++;
     
    15131528      Int layerId = dpbStatus.m_targetDecLayerIdList[dpbLayerCtr];
    15141529      // Output all picutres "decoded" in that layer that have POC less than the current picture
    1515       std::vector<TComPic> *layerBuffer = (m_acTDecTop->getLayerDec(layerId))->getConfListPic();
     1530      std::vector<TComPic> *layerBuffer = m_apcTDecTop[layerId]->getConfListPic();
    15161531      // Write all pictures to the file.
    15171532      if( this->getDecodedYuvLayerRefresh(layerId) )
     
    15201535        strcpy(tempFileName, this->getDecodedYuvLayerFileName( layerId ).c_str());
    15211536
    1522         const TComVPS *vps = m_acTDecTop->getLayerDec(layerId)->getParameterSetManager()->getActiveVPS();
    1523         const TComSPS *sps = m_acTDecTop->getLayerDec(layerId)->getParameterSetManager()->getActiveSPS();
     1537        const TComVPS *vps = m_apcTDecTop[layerId]->getParameterSetManager()->getActiveVPS();
     1538        const TComSPS *sps = m_apcTDecTop[layerId]->getParameterSetManager()->getActiveSPS();
    15241539        const BitDepths &bitDpeths = vps->getBitDepths(sps, layerId);
    15251540        Int bitDepth[] = {bitDpeths.recon[CHANNEL_TYPE_LUMA], bitDpeths.recon[CHANNEL_TYPE_CHROMA]};
     
    15761591    TComList<TComPic*>::iterator iterPic;
    15771592    Int j;
    1578     for(j = 0, iterPic = m_acTDecTop[0].getListPic()->begin(); j < listOfPocsPositionInEachLayer[0][0]; j++) // Picture to be output
     1593    for(j = 0, iterPic = m_apcTDecTop[0]->getListPic()->begin(); j < listOfPocsPositionInEachLayer[0][0]; j++) // Picture to be output
    15791594    {
    15801595      iterPic++;
     
    16001615    for( Int i = 0; i < MAX_VPS_LAYER_IDX_PLUS1; i++ )
    16011616    {
    1602       if( m_acTDecTop[i].getListPic()->empty() )
     1617      if( m_apcTDecTop[i]->getListPic()->empty() )
    16031618      {
    16041619        assert( listOfPocsInEachLayer[i].size() == 0 );
     
    16161631
    16171632        // Picture to be output
    1618         for( j = 0, iterPic = m_acTDecTop[i].getListPic()->begin(); j < listOfPocsPositionInEachLayer[i][picPosition]; j++ )
     1633        for( j = 0, iterPic = m_apcTDecTop[i]->getListPic()->begin(); j < listOfPocsPositionInEachLayer[i][picPosition]; j++ )
    16191634        {
    16201635          iterPic++;
     
    16511666  for( Int layerIdx = 0; layerIdx < MAX_VPS_LAYER_IDX_PLUS1; layerIdx++ )
    16521667  {
    1653     TComList <TComPic*> *pcListPic = m_acTDecTop[layerIdx].getListPic();
     1668    TComList <TComPic*> *pcListPic = m_apcTDecTop[layerIdx]->getListPic();
    16541669    TComList<TComPic*>::iterator iterPic = pcListPic->begin();
    16551670    while ( iterPic != pcListPic->end() )
     
    17031718  for( Int i = 0; i < MAX_VPS_LAYER_IDX_PLUS1; i++ )
    17041719  {
    1705     if( m_acTDecTop[i].getListPic()->empty() )
     1720    if( m_apcTDecTop[i]->getListPic()->empty() )
    17061721    {
    17071722      continue;
     
    17101725    // To check # AUs that have at least one picture not output,
    17111726    // For each layer, populate listOfPOcs if not already present
    1712     TComList<TComPic*>::iterator iterPic = m_acTDecTop[i].getListPic()->begin();
     1727    TComList<TComPic*>::iterator iterPic = m_apcTDecTop[i]->getListPic()->begin();
    17131728    Int picPositionInList = 0;
    1714     while (iterPic != m_acTDecTop[i].getListPic()->end())
     1729    while (iterPic != m_apcTDecTop[i]->getListPic()->end())
    17151730    {
    17161731      TComPic* pic = *(iterPic);
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h

    r1292 r1378  
    6464  // class interface
    6565#if SVC_EXTENSION
    66   TDecTop                         m_acTDecTop [MAX_LAYERS];                             ///< decoder class [WARNING] suppose to use MAX_NUM_LAYER_IDS but decoder crashes, pending for further investigation
    67   TDecTop*                        m_apcTDecTop [MAX_NUM_LAYER_IDS];                     ///< decoder point class
    68   TVideoIOYuv                     m_acTVideoIOYuvReconFile [MAX_NUM_LAYER_IDS];         ///< reconstruction YUV class
     66  TDecTop*                        m_apcTDecTop[MAX_NUM_LAYER_IDS];                     ///< decoder point class
     67  TVideoIOYuv*                    m_apcTVideoIOYuvReconFile[MAX_NUM_LAYER_IDS];        ///< reconstruction YUV class
    6968#else
    7069  TDecTop                         m_cTDecTop;                     ///< decoder class
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r1377 r1378  
    16661666{
    16671667  UInt layer;
    1668   const TComVPS *vps = m_apcTEncTop[0]->getVPS();
    16691668  const Int rateMultiplier = isField ? 2 : 1;
    16701669
Note: See TracChangeset for help on using the changeset viewer.