Changeset 54 in SHVCSoftware for branches/HM-10.0-dev-SHM/source/App


Ignore:
Timestamp:
2 Mar 2013, 09:25:00 (12 years ago)
Author:
seregin
Message:

port simulcast

Location:
branches/HM-10.0-dev-SHM/source/App
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/HM-10.0-dev-SHM/source/App/TAppDecoder/TAppDecCfg.cpp

    r51 r54  
    4141#include "TAppDecCfg.h"
    4242#include "TAppCommon/program_options_lite.h"
     43#if SVC_EXTENSION
     44#include <cassert>
     45#endif
    4346
    4447#ifdef WIN32
     
    6366  Bool do_help = false;
    6467  string cfg_BitstreamFile;
     68#if SVC_EXTENSION
     69  string cfg_ReconFile [MAX_LAYERS];
     70  Int nLayerNum;
     71#if AVC_BASE
     72  string cfg_BLReconFile;
     73#endif
     74#else
    6575  string cfg_ReconFile;
     76#endif
     77#if AVC_SYNTAX || SYNTAX_OUTPUT
     78  string cfg_BLSyntaxFile;
     79#endif
    6680  string cfg_TargetDecLayerIdSetFile;
    6781
     
    7084  ("help", do_help, false, "this help text")
    7185  ("BitstreamFile,b", cfg_BitstreamFile, string(""), "bitstream input file name")
     86#if SVC_EXTENSION
     87  ("ReconFileL%d,-o%d",   cfg_ReconFile,   string(""), MAX_LAYERS, "Layer %d reconstructed YUV output file name\n"
     88                                                     "YUV writing is skipped if omitted")
     89#if AVC_BASE
     90  ("BLReconFile,-ibl",    cfg_BLReconFile,  string(""), "BL reconstructed YUV input file name")
     91  ("BLSourceWidth,-wdt",    m_iBLSourceWidth,        0, "BL source picture width")
     92  ("BLSourceHeight,-hgt",   m_iBLSourceHeight,       0, "BL source picture height")
     93#if AVC_SYNTAX
     94  ("BLSyntaxFile,-ibs",    cfg_BLSyntaxFile,  string(""), "BL syntax input file name") 
     95#endif
     96#endif
     97#else
    7298  ("ReconFile,o",     cfg_ReconFile,     string(""), "reconstructed YUV output file name\n"
    7399                                                     "YUV writing is skipped if omitted")
     100#endif
     101#if SYNTAX_OUTPUT
     102  ("BLSyntaxFile,-ibs",    cfg_BLSyntaxFile,  string(""), "BL syntax input file name")
     103  ("BLSourceWidth,-wdt",    m_iBLSourceWidth,        0, "BL source picture width")
     104  ("BLSourceHeight,-hgt",   m_iBLSourceHeight,       0, "BL source picture height")
     105  ("BLFrames,-fr",          m_iBLFrames,       0, "BL number of frames")
     106#endif
    74107  ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
    75108  ("OutputBitDepth,d", m_outputBitDepthY, 0, "bit depth of YUV output luma component (default: use 0 for native depth)")
    76109  ("OutputBitDepthC,d", m_outputBitDepthC, 0, "bit depth of YUV output chroma component (default: use 0 for native depth)")
     110#if SVC_EXTENSION
     111  ("LayerNum,-ls", nLayerNum, 1, "Number of layers to be decoded.")
     112#endif
    77113  ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers")
    78114  ("SEIDecodedPictureHash", m_decodedPictureHashSEIEnabled, 1, "Control handling of decoded picture hash SEI messages\n"
     
    99135  /* convert std::string to c string for compatability */
    100136  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
     137#if SVC_EXTENSION
     138  m_tgtLayerId = nLayerNum - 1;
     139  assert( m_tgtLayerId >= 0 );
     140  for(UInt layer=0; layer<= m_tgtLayerId; layer++)
     141  {
     142    m_pchReconFile[layer] = cfg_ReconFile[layer].empty() ? NULL : strdup(cfg_ReconFile[layer].c_str());
     143  }
     144#if AVC_BASE
     145  m_pchBLReconFile = cfg_BLReconFile.empty() ? NULL : strdup(cfg_BLReconFile.c_str());
     146#endif
     147#else
    101148  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
     149#endif
     150#if AVC_SYNTAX || SYNTAX_OUTPUT
     151  m_pchBLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
     152#endif
    102153
    103154  if (!m_pchBitstreamFile)
  • branches/HM-10.0-dev-SHM/source/App/TAppDecoder/TAppDecCfg.h

    r51 r54  
    5858protected:
    5959  Char*         m_pchBitstreamFile;                   ///< input bitstream file name
     60#if SVC_EXTENSION
     61  Char*         m_pchReconFile [MAX_LAYERS];          ///< output reconstruction file name
     62#if AVC_BASE
     63  Char*         m_pchBLReconFile;                     ///< input BL reconstruction file name
     64  Int           m_iBLSourceWidth;
     65  Int           m_iBLSourceHeight;
     66#if AVC_SYNTAX
     67  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name 
     68#endif
     69#endif
     70#else
    6071  Char*         m_pchReconFile;                       ///< output reconstruction file name
     72#endif
     73#if SYNTAX_OUTPUT
     74  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
     75  Int           m_iBLSourceWidth;
     76  Int           m_iBLSourceHeight;
     77  Int           m_iBLFrames;
     78#endif
    6179  Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
    6280  Int           m_outputBitDepthY;                     ///< bit depth used for writing output (luma)
     
    6684  Int           m_decodedPictureHashSEIEnabled;       ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
    6785
     86#if SVC_EXTENSION
     87  Int           m_tgtLayerId;                        ///< target layer ID
     88#endif
    6889  std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
    6990  Int           m_respectDefDispWindow;               ///< Only output content inside the default display window
     
    7293  TAppDecCfg()
    7394  : m_pchBitstreamFile(NULL)
     95#if SVC_EXTENSION
     96  , m_tgtLayerId(0)
     97#else
    7498  , m_pchReconFile(NULL)
     99#endif
    75100  , m_iSkipFrame(0)
    76101  , m_outputBitDepthY(0)
     
    79104  , m_decodedPictureHashSEIEnabled(0)
    80105  , m_respectDefDispWindow(0)
     106#if AVC_BASE
     107  , m_iBLSourceWidth(0)
     108  , m_iBLSourceHeight(0)
     109#endif
     110#if SYNTAX_OUTPUT
     111  , m_iBLSourceWidth(0)
     112  , m_iBLSourceHeight(0)
     113  , m_iBLFrames(0)
     114#endif
    81115  {}
    82116  virtual ~TAppDecCfg() {}
  • branches/HM-10.0-dev-SHM/source/App/TAppDecoder/TAppDecTop.cpp

    r51 r54  
    5353// ====================================================================================================================
    5454
     55#if SVC_EXTENSION
     56TAppDecTop::TAppDecTop()
     57{
     58  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
     59  for(UInt layer=0; layer < MAX_LAYERS; layer++)
     60  {
     61    m_aiPOCLastDisplay[layer]  = -MAX_INT;
     62    m_apcTDecTop[layer] = &m_acTDecTop[layer];
     63  }
     64}
     65#else
    5566TAppDecTop::TAppDecTop()
    5667: m_iPOCLastDisplay(-MAX_INT)
     
    5869  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
    5970}
     71#endif
    6072
    6173Void TAppDecTop::create()
     
    7082    m_pchBitstreamFile = NULL;
    7183  }
     84#if SVC_EXTENSION   
     85  for( Int i = 0; i < m_tgtLayerId; i++ )
     86  {
     87    if( m_pchReconFile[i] )
     88    {
     89      free ( m_pchReconFile[i] );
     90      m_pchReconFile[i] = NULL;
     91    }
     92  } 
     93#if AVC_BASE
     94  if( m_pchBLReconFile )
     95  {
     96    free ( m_pchBLReconFile );
     97    m_pchBLReconFile = NULL;
     98  }
     99#endif
     100#else
    72101  if (m_pchReconFile)
    73102  {
     
    75104    m_pchReconFile = NULL;
    76105  }
     106#endif
     107#if AVC_SYNTAX || SYNTAX_OUTPUT
     108  if( m_pchBLSyntaxFile )
     109  {
     110    free ( m_pchBLSyntaxFile );
     111    m_pchBLSyntaxFile = NULL;
     112  }
     113#endif
    77114}
    78115
     
    89126 .
    90127 */
     128#if SVC_EXTENSION
     129Void TAppDecTop::decode()
     130{
     131  Int                poc;
     132  TComList<TComPic*>* pcListPic = NULL;
     133
     134  ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary);
     135  if (!bitstreamFile)
     136  {
     137    fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_pchBitstreamFile);
     138    exit(EXIT_FAILURE);
     139  }
     140
     141  InputByteStream bytestream(bitstreamFile);
     142
     143  // create & initialize internal classes
     144  xCreateDecLib();
     145  xInitDecLib  ();
     146
     147  // main decoder loop
     148  Bool recon_opened[MAX_LAYERS]; // reconstruction file not yet opened. (must be performed after SPS is seen)
     149  for(UInt layer=0; layer<=m_tgtLayerId; layer++)
     150  {
     151    recon_opened[layer] = false;
     152    m_aiPOCLastDisplay[layer] += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
     153  }
     154
     155  UInt curLayerId = 0;     // current layer to be reconstructed
     156
     157#if AVC_BASE
     158  TComPic pcBLPic;
     159  if( !m_pchBLReconFile )
     160  {
     161    printf( "Wrong base layer YUV input file\n" );
     162    exit(EXIT_FAILURE);
     163  }
     164  fstream streamYUV( m_pchBLReconFile, fstream::in | fstream::binary );
     165  if( !streamYUV.good() )
     166  {
     167    printf( "Base layer YUV input reading error\n" );
     168    exit(EXIT_FAILURE);
     169  }
     170  TComList<TComPic*> *cListPic = m_acTDecTop[0].getListPic();
     171  m_acTDecTop[0].setBLsize( m_iBLSourceWidth, m_iBLSourceHeight );
     172  m_acTDecTop[0].setBLReconFile( &streamYUV );
     173  pcBLPic.setLayerId( 0 );
     174  cListPic->pushBack( &pcBLPic );
     175#if AVC_SYNTAX
     176  if( !m_pchBLSyntaxFile )
     177  {
     178    printf( "Wrong base layer syntax file\n" );
     179    exit(EXIT_FAILURE);
     180  }
     181  fstream streamSyntaxFile( m_pchBLSyntaxFile, fstream::in | fstream::binary );
     182  if( !streamSyntaxFile.good() )
     183  {
     184    printf( "Base layer syntax input reading error\n" );
     185    exit(EXIT_FAILURE);
     186  }
     187  m_acTDecTop[0].setBLSyntaxFile( &streamSyntaxFile );
     188#endif
     189#endif
     190
     191  while (!!bitstreamFile)
     192  {
     193    /* location serves to work around a design fault in the decoder, whereby
     194     * the process of reading a new slice that is the first slice of a new frame
     195     * requires the TDecTop::decode() method to be called again with the same
     196     * nal unit. */
     197    streampos location = bitstreamFile.tellg();
     198    AnnexBStats stats = AnnexBStats();
     199
     200    vector<uint8_t> nalUnit;
     201    InputNALUnit nalu;
     202    byteStreamNALUnit(bytestream, nalUnit, stats);
     203
     204    // call actual decoding function
     205    Bool bNewPicture = false;
     206    Bool bNewPOC = false;
     207    if (nalUnit.empty())
     208    {
     209      /* this can happen if the following occur:
     210       *  - empty input file
     211       *  - two back-to-back start_code_prefixes
     212       *  - start_code_prefix immediately followed by EOF
     213       */
     214      fprintf(stderr, "Warning: Attempt to decode an empty NAL unit\n");
     215    }
     216    else
     217    {
     218      read(nalu, nalUnit);
     219      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  ||
     220        (nalu.m_layerId > m_tgtLayerId) )
     221      {
     222        bNewPicture = false;
     223      }
     224      else
     225      {
     226        bNewPicture = m_acTDecTop[nalu.m_layerId].decode(nalu, m_iSkipFrame, m_aiPOCLastDisplay[nalu.m_layerId], curLayerId, bNewPOC);
     227        if (bNewPicture)
     228        {
     229          bitstreamFile.clear();
     230          /* location points to the current nalunit payload[1] due to the
     231           * need for the annexB parser to read three extra bytes.
     232           * [1] except for the first NAL unit in the file
     233           *     (but bNewPicture doesn't happen then) */
     234          bitstreamFile.seekg(location-streamoff(3));
     235          bytestream.reset();
     236        }
     237      }
     238    }
     239    if (bNewPicture || !bitstreamFile)
     240    {
     241      m_acTDecTop[curLayerId].executeLoopFilters(poc, pcListPic);
     242    }
     243
     244    if( pcListPic )
     245    {
     246      if ( m_pchReconFile[curLayerId] && !recon_opened[curLayerId] )
     247      {
     248        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }       
     249        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
     250
     251        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
     252
     253        recon_opened[curLayerId] = true;
     254      }
     255      if ( bNewPicture && bNewPOC &&
     256           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
     257            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
     258            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
     259            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLANT
     260            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA ) )
     261      {
     262        xFlushOutput( pcListPic, curLayerId );
     263      }
     264      // write reconstruction to file
     265      if(bNewPicture)
     266      {
     267        xWriteOutput( pcListPic, curLayerId, nalu.m_temporalId );
     268      }
     269    }
     270  }
     271  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
     272  {
     273    xFlushOutput( m_acTDecTop[layer].getListPic(), layer );
     274  }
     275  // delete buffers
     276#if AVC_BASE
     277  if( streamYUV.is_open() )
     278  {
     279    streamYUV.close();
     280  }
     281#if AVC_SYNTAX
     282  if( streamSyntaxFile.is_open() )
     283  {
     284    streamSyntaxFile.close();
     285  }
     286#endif
     287  pcBLPic.destroy();
     288
     289  for(UInt layer = 1; layer <= m_tgtLayerId; layer++)
     290#else
     291  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
     292#endif
     293  {
     294    m_acTDecTop[layer].deletePicBuffer();
     295  }
     296 
     297  // destroy internal classes
     298  xDestroyDecLib();
     299}
     300#else
    91301Void TAppDecTop::decode()
    92302{
     
    110320  // main decoder loop
    111321  Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
     322
     323#if SYNTAX_OUTPUT
     324  if( !m_pchBLSyntaxFile )
     325  {
     326    printf( "Wrong base layer syntax file\n" );
     327    exit(EXIT_FAILURE);
     328  }
     329  fstream streamSyntaxFile( m_pchBLSyntaxFile, fstream::out | fstream::binary );
     330  if( !streamSyntaxFile.good() )
     331  {
     332    printf( "Base layer syntax input reading error\n" );
     333    exit(EXIT_FAILURE);
     334  }
     335  m_cTDecTop.setBLSyntaxFile( &streamSyntaxFile );
     336
     337  for( Int i = m_iBLFrames * m_iBLSourceWidth * m_iBLSourceHeight * SYNTAX_BYTES / 16; i >= 0; i-- )
     338  {
     339    streamSyntaxFile.put( 0 );
     340  }
     341  streamSyntaxFile.seekp( 0 );
     342#endif
    112343
    113344  while (!!bitstreamFile)
     
    199430  }
    200431 
     432#if SYNTAX_OUTPUT
     433  if( streamSyntaxFile.is_open() )
     434  {
     435    streamSyntaxFile.close();
     436  }
     437#endif
     438 
    201439  xFlushOutput( pcListPic );
    202440  // delete buffers
     
    206444  xDestroyDecLib();
    207445}
     446#endif
    208447
    209448// ====================================================================================================================
     
    213452Void TAppDecTop::xCreateDecLib()
    214453{
     454#if SVC_EXTENSION
     455  // initialize global variables
     456  initROM(); 
     457
     458  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
     459  {
     460    // set layer ID
     461    m_acTDecTop[layer].setLayerId                      ( layer );
     462
     463    // create decoder class
     464    m_acTDecTop[layer].create();
     465
     466    m_acTDecTop[layer].setLayerDec(m_apcTDecTop);   
     467  }
     468#else
    215469  // create decoder class
    216470  m_cTDecTop.create();
     471#endif
    217472}
    218473
    219474Void TAppDecTop::xDestroyDecLib()
    220475{
     476#if SVC_EXTENSION
     477  // destroy ROM
     478  destroyROM();
     479
     480  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
     481  {
     482    if ( m_pchReconFile[layer] )
     483    {
     484      m_acTVideoIOYuvReconFile[layer]. close();
     485    }
     486
     487    // destroy decoder class
     488    m_acTDecTop[layer].destroy();
     489  }
     490#else
    221491  if ( m_pchReconFile )
    222492  {
     
    226496  // destroy decoder class
    227497  m_cTDecTop.destroy();
     498#endif
    228499}
    229500
     
    231502{
    232503  // initialize decoder class
     504#if SVC_EXTENSION
     505  for(UInt layer = 0; layer <= m_tgtLayerId; layer++)
     506  {
     507    m_acTDecTop[layer].init();
     508    m_acTDecTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     509    m_acTDecTop[layer].setNumLayer( m_tgtLayerId + 1 );
     510  }
     511
     512#else
    233513  m_cTDecTop.init();
    234514  m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     515#endif
    235516}
    236517
     
    238519    \todo            DYN_REF_FREE should be revised
    239520 */
     521#if SVC_EXTENSION
     522Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt layerId, UInt tId )
     523#else
    240524Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId )
     525#endif
    241526{
    242527  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
     
    246531  {
    247532    TComPic* pcPic = *(iterPic);
     533#if SVC_EXTENSION
     534    if(pcPic->getOutputMark() && pcPic->getPOC() > m_aiPOCLastDisplay[layerId])
     535#else
    248536    if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay)
     537#endif
    249538    {
    250539       not_displayed++;
     
    258547    TComPic* pcPic = *(iterPic);
    259548   
     549#if SVC_EXTENSION
     550    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
     551#else
    260552    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
     553#endif
    261554    {
    262555      // write to file
    263556       not_displayed--;
     557#if SVC_EXTENSION
     558      if ( m_pchReconFile[layerId] )
     559      {
     560        const Window &conf = pcPic->getConformanceWindow();
     561        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     562        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
     563                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     564                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     565                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     566                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     567      }
     568     
     569      // update POC of display order
     570      m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
     571#else
    264572      if ( m_pchReconFile )
    265573      {
     
    275583      // update POC of display order
    276584      m_iPOCLastDisplay = pcPic->getPOC();
     585#endif
    277586     
    278587      // erase non-referenced picture in the reference picture list after display
     
    302611    \todo            DYN_REF_FREE should be revised
    303612 */
     613#if SVC_EXTENSION
     614Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, UInt layerId )
     615#else
    304616Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
     617#endif
    305618{
    306619  if(!pcListPic)
     
    319632    {
    320633      // write to file
     634#if SVC_EXTENSION
     635      if ( m_pchReconFile[layerId] )
     636      {
     637        const Window &conf = pcPic->getConformanceWindow();
     638        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     639        m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
     640                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     641                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     642                                       conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     643                                       conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     644      }
     645     
     646      // update POC of display order
     647      m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
     648#else
    321649      if ( m_pchReconFile )
    322650      {
     
    332660      // update POC of display order
    333661      m_iPOCLastDisplay = pcPic->getPOC();
     662#endif
    334663     
    335664      // erase non-referenced picture in the reference picture list after display
     
    351680      pcPic->setOutputMark(false);
    352681    }
     682#if !SVC_EXTENSION
    353683#if !DYN_REF_FREE
    354684    if(pcPic)
     
    359689    }
    360690#endif   
     691#endif
    361692    iterPic++;
    362693  }
     694#if SVC_EXTENSION
     695  m_aiPOCLastDisplay[layerId] = -MAX_INT;
     696#else
    363697  pcListPic->clear();
    364698  m_iPOCLastDisplay = -MAX_INT;
     699#endif
    365700}
    366701
  • branches/HM-10.0-dev-SHM/source/App/TAppDecoder/TAppDecTop.h

    r51 r54  
    6161private:
    6262  // class interface
     63#if SVC_EXTENSION
     64  TDecTop                         m_acTDecTop [MAX_LAYERS];                    ///< decoder class
     65  TDecTop*                        m_apcTDecTop [MAX_LAYERS];                   ///< decoder point class
     66  TVideoIOYuv                     m_acTVideoIOYuvReconFile [MAX_LAYERS];        ///< reconstruction YUV class
     67#else
    6368  TDecTop                         m_cTDecTop;                     ///< decoder class
    6469  TVideoIOYuv                     m_cTVideoIOYuvReconFile;        ///< reconstruction YUV class
     70#endif
    6571 
    6672  // for output control
    6773  Bool                            m_abDecFlag[ MAX_GOP ];         ///< decoded flag in one GOP
     74#if SVC_EXTENSION
     75  Int                             m_aiPOCLastDisplay [MAX_LAYERS]; ///< last POC in display order
     76#else
    6877  Int                             m_iPOCLastDisplay;              ///< last POC in display order
     78#endif
    6979 
    7080public:
     
    8191  Void  xInitDecLib       (); ///< initialize decoder class
    8292 
     93#if SVC_EXTENSION
     94  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, UInt layerId, UInt tId ); ///< write YUV to file
     95  Void  xFlushOutput      ( TComList<TComPic*>* pcListPic, UInt layerId ); ///< flush all remaining decoded pictures to file
     96#else
    8397  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic , UInt tId); ///< write YUV to file
    8498  Void  xFlushOutput      ( TComList<TComPic*>* pcListPic ); ///< flush all remaining decoded pictures to file
     99#endif
    85100  Bool  isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet
    86101};
  • branches/HM-10.0-dev-SHM/source/App/TAppDecoder/decmain.cpp

    r51 r54  
    5656  // print information
    5757  fprintf( stdout, "\n" );
    58   fprintf( stdout, "HM software: Decoder Version [%s]", NV_VERSION );
     58  fprintf( stdout, "SHM software: Decoder Version [%s]", NV_VERSION );
    5959  fprintf( stdout, NVM_ONOS );
    6060  fprintf( stdout, NVM_COMPILEDBY );
  • branches/HM-10.0-dev-SHM/source/App/TAppEncoder/TAppEncCfg.cpp

    r51 r54  
    6363// ====================================================================================================================
    6464
     65#if SVC_EXTENSION
     66TAppEncCfg::TAppEncCfg()
     67: m_pBitstreamFile()
     68, m_pColumnWidth()
     69, m_pRowHeight()
     70, m_scalingListFile()
     71#if REF_IDX_FRAMEWORK
     72, m_elRapSliceBEnabled(0)
     73#endif
     74{
     75  for(UInt layer=0; layer<MAX_LAYERS; layer++)
     76  {
     77    m_acLayerCfg[layer].setAppEncCfg(this);
     78  }
     79}
     80#else
    6581TAppEncCfg::TAppEncCfg()
    6682: m_pchInputFile()
     
    7490  m_aidQP = NULL;
    7591}
     92#endif
    7693
    7794TAppEncCfg::~TAppEncCfg()
    7895{
     96#if !SVC_EXTENSION
    7997  if ( m_aidQP )
    8098  {
     
    82100  }
    83101  free(m_pchInputFile);
    84   free(m_pchBitstreamFile);
     102#endif
     103  free(m_pBitstreamFile);
     104#if !SVC_EXTENSION 
    85105  free(m_pchReconFile);
    86106  free(m_pchdQPFile);
     107#endif
    87108  free(m_pColumnWidth);
    88109  free(m_pRowHeight);
     
    141162  return in;
    142163}
     164
     165#if SVC_EXTENSION
     166void TAppEncCfg::getDirFilename(string& filename, string& dir, const string path)
     167{
     168  size_t pos = path.find_last_of("\\");
     169  if(pos != std::string::npos)
     170  {
     171    filename.assign(path.begin() + pos + 1, path.end());
     172    dir.assign(path.begin(), path.begin() + pos + 1);
     173  }
     174  else
     175  {
     176    pos = path.find_last_of("/");
     177    if(pos != std::string::npos)
     178    {
     179      filename.assign(path.begin() + pos + 1, path.end());
     180      dir.assign(path.begin(), path.begin() + pos + 1);
     181    }
     182    else
     183    {
     184      filename = path;
     185      dir.assign("");
     186    }
     187  }
     188}
     189#endif
    143190
    144191static const struct MapStrToProfile {
     
    231278  Bool do_help = false;
    232279 
     280#if SVC_EXTENSION
     281  string  cfg_LayerCfgFile  [MAX_LAYERS];
     282  string  cfg_BitstreamFile;
     283  string* cfg_InputFile     [MAX_LAYERS];
     284  string* cfg_ReconFile     [MAX_LAYERS];
     285  Double* cfg_fQP           [MAX_LAYERS];
     286
     287  Int*    cfg_SourceWidth   [MAX_LAYERS];
     288  Int*    cfg_SourceHeight  [MAX_LAYERS];
     289  Int*    cfg_FrameRate     [MAX_LAYERS];
     290  Int*    cfg_IntraPeriod   [MAX_LAYERS];
     291  Int*    cfg_conformanceMode  [MAX_LAYERS];
     292  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
     293  {
     294    cfg_InputFile[layer]    = &m_acLayerCfg[layer].m_cInputFile;
     295    cfg_ReconFile[layer]    = &m_acLayerCfg[layer].m_cReconFile;
     296    cfg_fQP[layer]          = &m_acLayerCfg[layer].m_fQP;
     297    cfg_SourceWidth[layer]  = &m_acLayerCfg[layer].m_iSourceWidth;
     298    cfg_SourceHeight[layer] = &m_acLayerCfg[layer].m_iSourceHeight;
     299    cfg_FrameRate[layer]    = &m_acLayerCfg[layer].m_iFrameRate;
     300    cfg_IntraPeriod[layer]  = &m_acLayerCfg[layer].m_iIntraPeriod;
     301    cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode;
     302  }
     303#if AVC_SYNTAX
     304  string  cfg_BLSyntaxFile;
     305#endif
     306#else
    233307  string cfg_InputFile;
    234308  string cfg_BitstreamFile;
    235309  string cfg_ReconFile;
    236310  string cfg_dQPFile;
     311#endif
    237312  string cfg_ColumnWidth;
    238313  string cfg_RowHeight;
     
    252327 
    253328  // File, I/O and source parameters
     329#if SVC_EXTENSION
     330  ("InputFile%d,-i%d",        cfg_InputFile,  string(""), MAX_LAYERS, "original YUV input file name for layer %d")
     331  ("ReconFile%d,-o%d",        cfg_ReconFile,  string(""), MAX_LAYERS, "reconstruction YUV input file name for layer %d")
     332  ("LayerConfig%d,-lc%d",     cfg_LayerCfgFile, string(""), MAX_LAYERS, "layer %d configuration file name")
     333  ("SourceWidth%d,-wdt%d",    cfg_SourceWidth, 0, MAX_LAYERS, "Source picture width for layer %d")
     334  ("SourceHeight%d,-hgt%d",   cfg_SourceHeight, 0, MAX_LAYERS, "Source picture height for layer %d")
     335  ("FrameRate%d,-fr%d",       cfg_FrameRate,  0, MAX_LAYERS, "Frame rate for layer %d")
     336  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
     337  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
     338  ("ConformanceMode%d",       cfg_conformanceMode,0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
     339
     340  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
     341  ("InputBitDepth",         m_inputBitDepthY,    8, "Bit-depth of input file")
     342  ("OutputBitDepth",        m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
     343  ("InternalBitDepth",      m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
     344                                                       "If different to InputBitDepth, source data will be converted")
     345  ("InputBitDepthC",        m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
     346  ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
     347  ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
     348
     349#if AVC_BASE
     350  ("InputBLFile,-ibl",        *cfg_InputFile[0],     string(""), "Base layer rec YUV input file name")
     351#if AVC_SYNTAX
     352  ("InputBLSyntaxFile,-ibs",  cfg_BLSyntaxFile,     string(""), "Base layer syntax input file name")
     353#endif
     354#endif
     355#if REF_IDX_FRAMEWORK
     356  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture_")
     357#endif 
     358#else 
    254359  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
    255360  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
     
    272377  ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
    273378  ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
     379#endif
    274380  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
    275381  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
     
    286392  ("FrameOnly",         m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames")
    287393#endif
    288  
     394
    289395  // Unit definition parameters
    290396  ("MaxCUWidth",              m_uiMaxCUWidth,             64u)
     
    302408 
    303409  // Coding structure paramters
     410#if SVC_EXTENSION
     411  ("IntraPeriod%d,-ip%d",  cfg_IntraPeriod, -1, MAX_LAYERS, "intra period in frames for layer %d, (-1: only first frame)")
     412#else
    304413  ("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
     414#endif
    305415  ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
    306416  ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
     
    313423  ("ASR",                     m_bUseASR,                false, "Adaptive motion search range")
    314424
     425#if SVC_EXTENSION
     426  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
     427#else
    315428  // Mode decision parameters
    316429  ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( Double )1.0, "Lambda modifier for temporal layer 0")
     
    322435  ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( Double )1.0, "Lambda modifier for temporal layer 6")
    323436  ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( Double )1.0, "Lambda modifier for temporal layer 7")
     437#endif
    324438
    325439  /* Quantization parameters */
     440#if SVC_EXTENSION
     441  ("QP%d,-q%d",     cfg_fQP,  30.0, MAX_LAYERS, "Qp value for layer %d, if value is float, QP is switched once during encoding")
     442#else
    326443  ("QP,q",          m_fQP,             30.0, "Qp value, if value is float, QP is switched once during encoding")
     444#endif
    327445  ("DeltaQpRD,-dqr",m_uiDeltaQpRD,       0u, "max dQp offset for slice")
    328446  ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
     
    338456  ("AdaptiveQP,-aq",                m_bUseAdaptiveQP,           false, "QP adaptation based on a psycho-visual model")
    339457  ("MaxQPAdaptationRange,-aqr",     m_iQPAdaptationRange,           6, "QP adaptation range")
     458#if !SVC_EXTENSION
    340459  ("dQPFile,m",                     cfg_dQPFile,           string(""), "dQP file name")
     460#endif
    341461  ("RDOQ",                          m_useRDOQ,                  true )
    342462  ("RDOQTS",                        m_useRDOQTS,                true )
     
    526646   */
    527647  /* convert std::string to c string for compatability */
     648#if SVC_EXTENSION
     649  m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
     650#if AVC_SYNTAX
     651  m_BLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
     652#endif
     653#else
    528654  m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
    529   m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
     655  m_phBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
    530656  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
    531657  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
    532  
     658#endif 
     659
    533660  Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
    534661  Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
     
    605732  if (!m_outputBitDepthC) { m_outputBitDepthC = m_internalBitDepthC; }
    606733
     734#if !SVC_EXTENSION
    607735  // TODO:ChromaFmt assumes 4:2:0 below
    608736  switch (m_conformanceMode)
     
    702830  }
    703831  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
    704 
     832#endif
    705833  // check validity of input parameters
    706834  xCheckParameter();
     
    800928  xConfirmPara( m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8" );
    801929  xConfirmPara( m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8" );
     930#if !SVC_EXTENSION 
    802931  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
     932#endif
    803933  xConfirmPara( m_framesToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
    804934  xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
    805935  xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
     936#if !SVC_EXTENSION
    806937  xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
     938#endif
    807939  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
     940#if !SVC_EXTENSION
    808941  xConfirmPara( m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,                    "QP exceeds supported range (-QpBDOffsety to 51)" );
     942#endif
    809943  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,          "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
    810944  xConfirmPara( m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13,              "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)");
     
    821955
    822956  xConfirmPara( m_iQPAdaptationRange <= 0,                                                  "QP Adaptation Range must be more than 0" );
     957#if !SVC_EXTENSION
    823958  if (m_iDecodingRefreshType == 2)
    824959  {
    825960    xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
    826961  }
     962#endif
    827963  xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
    828964  xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,                                    "Minimum partition height size should be larger than or equal to 8");
    829965  xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
    830966  xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
     967#if !SVC_EXTENSION
    831968  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
    832969  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
     970#endif
    833971 
    834972  xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
     
    849987  xConfirmPara(  m_maxNumMergeCand > 5,  "MaxNumMergeCand must be 5 or smaller.");
    850988
     989#if !SVC_EXTENSION
    851990#if ADAPTIVE_QP_SELECTION
    852991  xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
    853992  xConfirmPara( m_bUseAdaptQpSelect == true && (m_cbQpOffset !=0 || m_crQpOffset != 0 ),               "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
     993#endif
    854994#endif
    855995
     
    8771017
    8781018  //TODO:ChromaFmt assumes 4:2:0 below
     1019#if !SVC_EXTENSION
    8791020  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
    8801021  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
     
    8871028  xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
    8881029  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
    889 
     1030#endif
     1031
     1032#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV
     1033  xConfirmPara( REF_IDX_ME_AROUND_ZEROMV && REF_IDX_ME_ZEROMV, "REF_IDX_ME_AROUND_ZEROMV and REF_IDX_ME_ZEROMV cannot be enabled simultaneously");
     1034#endif
    8901035  // max CU width and height should be power of 2
    8911036  UInt ui = m_uiMaxCUWidth;
     
    9041049  }
    9051050
     1051
    9061052  /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
    9071053   * This permits the ability to omit a GOP structure specification */
     1054#if SVC_EXTENSION
     1055  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
     1056  {
     1057    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
     1058#endif
    9081059  if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) {
    9091060    m_GOPList[0] = GOPEntry();
     
    9141065    m_GOPList[0].m_numRefPicsActive = 4;
    9151066  }
     1067#if SVC_EXTENSION
     1068  }
     1069#endif
    9161070 
    9171071  Bool verifiedGOP=false;
     
    9271081  }
    9281082  Int numOK=0;
     1083#if !SVC_EXTENSION
    9291084  xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" );
     1085#endif
    9301086
    9311087  for(Int i=0; i<m_iGOPSize; i++)
     
    9361092    }
    9371093  }
    938  
     1094
     1095#if SVC_EXTENSION
     1096  // verify layer configuration parameters
     1097  for(UInt layer=0; layer<m_numLayers; layer++)
     1098  {
     1099    if(m_acLayerCfg[layer].xCheckParameter())
     1100    {
     1101      printf("\nError: invalid configuration parameter found in layer %d \n", layer);
     1102      check_failed = true;
     1103    }
     1104  }
     1105#endif 
     1106
     1107#if SVC_EXTENSION
     1108  // verify layer configuration parameters
     1109  for(UInt layer=0; layer<m_numLayers; layer++)
     1110  {
     1111    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
     1112#endif
    9391113  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) )
    9401114  {
     
    9451119    }
    9461120  }
     1121#if SVC_EXTENSION
     1122  }
     1123#endif
     1124
    9471125  m_extraRPSs=0;
    9481126  //start looping through frames in coding order until we can verify that the GOP structure is correct.
     
    12061384  }
    12071385
     1386#if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers
     1387  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
     1388  {
     1389    Int m_iSourceWidth = m_acLayerCfg[layer].m_iSourceWidth;
     1390    Int m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight;
     1391#endif
    12081392  if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
    12091393  {
     
    12791463    }
    12801464  }
     1465#if SVC_EXTENSION
     1466  }
     1467#endif
     1468
    12811469  xConfirmPara( m_bUseLComb==false && m_numReorderPics[MAX_TLAYER-1]!=0, "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)" );  // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1.
    12821470  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
     1471#if !SVC_EXTENSION
    12831472  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
    12841473  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
     1474#endif
    12851475
    12861476  xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
     
    13571547{
    13581548  printf("\n");
     1549#if SVC_EXTENSION 
     1550  printf("Total number of layers        : %d\n", m_numLayers            );
     1551  for(UInt layer=0; layer<m_numLayers; layer++)
     1552  {
     1553    printf("=== Layer %d settings === \n", layer);
     1554    m_acLayerCfg[layer].xPrintParameter();
     1555    printf("\n");
     1556  }
     1557  printf("=== Common configuration settings === \n");
     1558  printf("Bitstream      File          : %s\n", m_pBitstreamFile      );
     1559#else
    13591560  printf("Input          File          : %s\n", m_pchInputFile          );
    13601561  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
     
    13621563  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
    13631564  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
     1565#endif
    13641566  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
    13651567  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
     
    13691571  printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
    13701572  printf("Motion search range          : %d\n", m_iSearchRange );
     1573#if !SVC_EXTENSION
    13711574  printf("Intra period                 : %d\n", m_iIntraPeriod );
     1575#endif
    13721576  printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
     1577#if !SVC_EXTENSION
    13731578  printf("QP                           : %5.2f\n", m_fQP );
     1579#endif
    13741580  printf("Max dQP signaling depth      : %d\n", m_iMaxCuDQPDepth);
    13751581
     
    14421648  printf("WPB:%d ", (Int)m_useWeightedBiPred);
    14431649  printf("PME:%d ", m_log2ParallelMergeLevel);
     1650#if !SVC_EXTENSION
    14441651  printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d",
    14451652          m_iWaveFrontSynchro, m_iWaveFrontSubstreams);
     1653#endif
    14461654  printf(" ScalingList:%d ", m_useScalingListId );
    14471655  printf("TMVPMode:%d ", m_TMVPModeId     );
     
    14511659
    14521660  printf(" SignBitHidingFlag:%d ", m_signHideFlag);
     1661#if SVC_EXTENSION
     1662  printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 );
     1663  printf("AVC_BASE:%d ", AVC_BASE);
     1664#if REF_IDX_FRAMEWORK
     1665  printf("REF_IDX_FRAMEWORK:%d ", REF_IDX_FRAMEWORK);
     1666  printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled);
     1667  printf("REF_IDX_ME_AROUND_ZEROMV:%d ", REF_IDX_ME_AROUND_ZEROMV);
     1668  printf("REF_IDX_ME_ZEROMV: %d", REF_IDX_ME_ZEROMV);
     1669#elif INTRA_BL
     1670  printf("INTRA_BL:%d ", INTRA_BL);
     1671#if !AVC_BASE
     1672  printf("SVC_MVP:%d ", SVC_MVP );
     1673  printf("SVC_BL_CAND_INTRA:%d", SVC_BL_CAND_INTRA );
     1674#endif
     1675#endif
     1676#else
    14531677  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
     1678#endif
    14541679  printf("\n\n");
    14551680 
  • branches/HM-10.0-dev-SHM/source/App/TAppEncoder/TAppEncCfg.h

    r51 r54  
    4242
    4343#include "TLibEncoder/TEncCfg.h"
     44#if SVC_EXTENSION
     45#include "TAppEncLayerCfg.h"
     46#endif
    4447#include <sstream>
    4548//! \ingroup TAppEncoder
     
    5558protected:
    5659  // file I/O
     60#if SVC_EXTENSION
     61  TAppEncLayerCfg m_acLayerCfg [MAX_LAYERS];
     62  Int       m_numLayers;                                     ///< number of layers
     63
     64  Char*     m_pBitstreamFile;                                 ///< output bitstream file
     65  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
     66  // source specification
     67  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
     68  Int       m_framesToBeEncoded;                              ///< number of encoded frames
     69#if AVC_SYNTAX
     70  char*     m_BLSyntaxFile;                                   ///< input syntax file
     71#endif
     72#else
    5773  Char*     m_pchInputFile;                                   ///< source file name
    5874  Char*     m_pchBitstreamFile;                               ///< output bitstream file
     
    7187  Int       m_framesToBeEncoded;                              ///< number of encoded frames
    7288  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
    73  
     89#endif 
     90
    7491  // profile/level
    7592  Profile::Name m_profile;
     
    84101 
    85102  // coding structure
     103#if !SVC_EXTENSION
    86104  Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
     105#endif
    87106  Int       m_iDecodingRefreshType;                           ///< random access type
    88107  Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
     
    96115  Bool      m_enableAMP;
    97116  // coding quality
     117#if !SVC_EXTENSION
    98118  Double    m_fQP;                                            ///< QP value of key-picture (floating point)
    99119  Int       m_iQP;                                            ///< QP value of key-picture (integer)
    100120  Char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
    101121  Int*      m_aidQP;                                          ///< array of slice QP values
     122#endif
    102123  Int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
    103124  UInt      m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
     
    192213  UInt*     m_pRowHeight;
    193214  Int       m_iWaveFrontSynchro; //< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
     215#if !SVC_EXTENSION
    194216  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
     217#endif
    195218
    196219  Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
     
    276299  Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
    277300
     301#if REF_IDX_FRAMEWORK
     302  Int       m_elRapSliceBEnabled;
     303#endif
    278304  // internal member functions
    279305  Void  xSetGlobal      ();                                   ///< set global variables
     
    300326  Bool  parseCfg  ( Int argc, Char* argv[] );                 ///< parse configuration file to fill member variables
    301327 
     328#if SVC_EXTENSION
     329  Int  getNumFrameToBeEncoded()    {return m_framesToBeEncoded; }
     330  Int  getNumLayer()               {return m_numLayers;        }
     331  Int  getGOPSize()                {return m_iGOPSize;          }
     332  UInt getInternalBitDepthY()      {return m_internalBitDepthY; }
     333  UInt getInternalBitDepthC()      {return m_internalBitDepthC; }
     334  UInt getMaxCUWidth()             {return m_uiMaxCUWidth;      }
     335  UInt getMaxCUHeight()            {return m_uiMaxCUHeight;     }
     336  UInt getMaxCUDepth()             {return m_uiMaxCUDepth;      }
     337  Int  getDecodingRefreshType()    {return m_iDecodingRefreshType; }
     338  Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
     339  Void getDirFilename(string& filename, string& dir, const string path);
     340#if AVC_SYNTAX
     341  Char* getBLSyntaxFile()           { return m_BLSyntaxFile;      }
     342#endif
     343#endif
    302344};// END CLASS DEFINITION TAppEncCfg
    303345
  • branches/HM-10.0-dev-SHM/source/App/TAppEncoder/TAppEncTop.cpp

    r51 r54  
    11/* The copyright in this software is being made available under the BSD
    2  * License, included below. This software may be subject to other third party
    3  * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
    5  *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
    7  * All rights reserved.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
    10  * modification, are permitted provided that the following conditions are met:
    11  *
    12  *  * Redistributions of source code must retain the above copyright notice,
    13  *    this list of conditions and the following disclaimer.
    14  *  * Redistributions in binary form must reproduce the above copyright notice,
    15  *    this list of conditions and the following disclaimer in the documentation
    16  *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    18  *    be used to endorse or promote products derived from this software without
    19  *    specific prior written permission.
    20  *
    21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
    25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    31  * THE POSSIBILITY OF SUCH DAMAGE.
    32  */
     2* License, included below. This software may be subject to other third party
     3* and contributor rights, including patent rights, and no such rights are
     4* granted under this license. 
     5*
     6* Copyright (c) 2010-2013, ITU/ISO/IEC
     7* All rights reserved.
     8*
     9* Redistribution and use in source and binary forms, with or without
     10* modification, are permitted provided that the following conditions are met:
     11*
     12*  * Redistributions of source code must retain the above copyright notice,
     13*    this list of conditions and the following disclaimer.
     14*  * Redistributions in binary form must reproduce the above copyright notice,
     15*    this list of conditions and the following disclaimer in the documentation
     16*    and/or other materials provided with the distribution.
     17*  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
     18*    be used to endorse or promote products derived from this software without
     19*    specific prior written permission.
     20*
     21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     22* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
     25* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31* THE POSSIBILITY OF SUCH DAMAGE.
     32*/
    3333
    3434/** \file     TAppEncTop.cpp
    35     \brief    Encoder application class
     35\brief    Encoder application class
    3636*/
    3737
     
    6060  m_totalBytes = 0;
    6161  m_essentialBytes = 0;
     62#if SVC_EXTENSION
     63  for(UInt layer=0; layer < MAX_LAYERS; layer++)
     64  {
     65    m_apcTEncTop[layer] = &m_acTEncTop[layer];
     66  }
     67#endif
    6268}
    6369
     
    6672}
    6773
     74#if SVC_EXTENSION
    6875Void TAppEncTop::xInitLibCfg()
    6976{
     77  for(UInt layer=0; layer<m_numLayers; layer++)
     78  {
     79    TComVPS vps;
     80
     81    vps.setMaxTLayers                       ( m_maxTempLayer );
     82    if (m_maxTempLayer == 1)
     83    {
     84      vps.setTemporalNestingFlag(true);
     85    }
     86    vps.setMaxLayers                        ( 1 );
     87    for(Int i = 0; i < MAX_TLAYER; i++)
     88    {
     89      vps.setNumReorderPics                 ( m_numReorderPics[i], i );
     90      vps.setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
     91    }
     92    m_acTEncTop[layer].setVPS(&vps);
     93    m_acTEncTop[layer].setFrameRate                    ( m_acLayerCfg[layer].getFrameRate() );
     94    m_acTEncTop[layer].setFrameSkip                    ( m_FrameSkip );
     95    m_acTEncTop[layer].setSourceWidth                  ( m_acLayerCfg[layer].getSourceWidth() );
     96    m_acTEncTop[layer].setSourceHeight                 ( m_acLayerCfg[layer].getSourceHeight() );
     97    m_acTEncTop[layer].setConformanceMode              ( m_acLayerCfg[layer].getConformanceMode() );
     98    m_acTEncTop[layer].setConformanceWindow            ( m_acLayerCfg[layer].m_confLeft, m_acLayerCfg[layer].m_confRight, m_acLayerCfg[layer].m_confTop, m_acLayerCfg[layer].m_confBottom );
     99    m_acTEncTop[layer].setFramesToBeEncoded            ( m_framesToBeEncoded );
     100
     101    m_acTEncTop[layer].setProfile(m_profile);
     102    m_acTEncTop[layer].setLevel(m_levelTier, m_level);
     103#if L0046_CONSTRAINT_FLAGS
     104    m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlag);
     105    m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlag);
     106    m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
     107    m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
     108#endif
     109
     110#if REF_IDX_MFM
     111    if(layer == 0)
     112    {
     113      m_acTEncTop[layer].setMFMEnabledFlag(false);
     114    }
     115    else
     116    {
     117      m_acTEncTop[layer].setMFMEnabledFlag(true);
     118    }
     119#endif
     120    // set layer ID
     121    m_acTEncTop[layer].setLayerId ( layer );
     122    m_acTEncTop[layer].setNumLayer ( m_numLayers );
     123    m_acTEncTop[layer].setLayerEnc(m_apcTEncTop);
     124
     125    //====== Coding Structure ========
     126    m_acTEncTop[layer].setIntraPeriod                  ( m_acLayerCfg[layer].m_iIntraPeriod );
     127    m_acTEncTop[layer].setDecodingRefreshType          ( m_iDecodingRefreshType );
     128    m_acTEncTop[layer].setGOPSize                      ( m_iGOPSize );
     129    m_acTEncTop[layer].setGopList                      ( m_GOPList );
     130    m_acTEncTop[layer].setExtraRPSs                    ( m_extraRPSs );
     131    for(Int i = 0; i < MAX_TLAYER; i++)
     132    {
     133      m_acTEncTop[layer].setNumReorderPics             ( m_numReorderPics[i], i );
     134      m_acTEncTop[layer].setMaxDecPicBuffering         ( m_maxDecPicBuffering[i], i );
     135    }
     136    for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
     137    {
     138      m_acTEncTop[layer].setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
     139    }
     140    m_acTEncTop[layer].setQP                           ( m_acLayerCfg[layer].getIntQP() );
     141
     142    m_acTEncTop[layer].setPad                          ( m_acLayerCfg[layer].getPad() );
     143
     144    m_acTEncTop[layer].setMaxTempLayer                 ( m_maxTempLayer );
     145    m_acTEncTop[layer].setUseAMP( m_enableAMP );
     146
     147    //===== Slice ========
     148
     149    //====== Loop/Deblock Filter ========
     150    m_acTEncTop[layer].setLoopFilterDisable            ( m_bLoopFilterDisable       );
     151    m_acTEncTop[layer].setLoopFilterOffsetInPPS        ( m_loopFilterOffsetInPPS );
     152    m_acTEncTop[layer].setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
     153    m_acTEncTop[layer].setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
     154    m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
     155
     156    //====== Motion search ========
     157    m_acTEncTop[layer].setFastSearch                   ( m_iFastSearch  );
     158    m_acTEncTop[layer].setSearchRange                  ( m_iSearchRange );
     159    m_acTEncTop[layer].setBipredSearchRange            ( m_bipredSearchRange );
     160
     161    //====== Quality control ========
     162    m_acTEncTop[layer].setMaxDeltaQP                   ( m_iMaxDeltaQP  );
     163    m_acTEncTop[layer].setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
     164
     165    m_acTEncTop[layer].setChromaCbQpOffset             ( m_cbQpOffset     );
     166    m_acTEncTop[layer].setChromaCrQpOffset             ( m_crQpOffset  );
     167
     168#if ADAPTIVE_QP_SELECTION
     169    m_acTEncTop[layer].setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
     170#endif
     171
     172    Int lowestQP;
     173    lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
     174
     175    if ((m_iMaxDeltaQP == 0 ) && (m_acLayerCfg[layer].getIntQP() == lowestQP) && (m_useLossless == true))
     176    {
     177      m_bUseAdaptiveQP = false;
     178    }
     179    m_acTEncTop[layer].setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
     180    m_acTEncTop[layer].setQPAdaptationRange            ( m_iQPAdaptationRange );
     181
     182    //====== Tool list ========
     183    m_acTEncTop[layer].setUseSBACRD                    ( m_bUseSBACRD   );
     184    m_acTEncTop[layer].setDeltaQpRD                    ( m_uiDeltaQpRD  );
     185    m_acTEncTop[layer].setUseASR                       ( m_bUseASR      );
     186    m_acTEncTop[layer].setUseHADME                     ( m_bUseHADME    );
     187    m_acTEncTop[layer].setUseLossless                  ( m_useLossless );
     188    m_acTEncTop[layer].setUseLComb                     ( m_bUseLComb    );
     189    m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs() );
     190    m_acTEncTop[layer].setUseRDOQ                      ( m_useRDOQ     );
     191    m_acTEncTop[layer].setUseRDOQTS                    ( m_useRDOQTS   );
     192#if L0232_RD_PENALTY
     193    m_acTEncTop[layer].setRDpenalty                    ( m_rdPenalty );
     194#endif
     195    m_acTEncTop[layer].setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
     196    m_acTEncTop[layer].setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
     197    m_acTEncTop[layer].setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
     198    m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
     199    m_acTEncTop[layer].setUseFastEnc                   ( m_bUseFastEnc  );
     200    m_acTEncTop[layer].setUseEarlyCU                   ( m_bUseEarlyCU  );
     201    m_acTEncTop[layer].setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
     202    m_acTEncTop[layer].setUseCbfFastMode               ( m_bUseCbfFastMode  );
     203    m_acTEncTop[layer].setUseEarlySkipDetection        ( m_useEarlySkipDetection );
     204
     205    m_acTEncTop[layer].setUseTransformSkip             ( m_useTransformSkip      );
     206    m_acTEncTop[layer].setUseTransformSkipFast         ( m_useTransformSkipFast  );
     207    m_acTEncTop[layer].setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
     208    m_acTEncTop[layer].setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
     209    m_acTEncTop[layer].setUsePCM                       ( m_usePCM );
     210    m_acTEncTop[layer].setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
     211    m_acTEncTop[layer].setMaxNumMergeCand              ( m_maxNumMergeCand );
     212
     213
     214    //====== Weighted Prediction ========
     215    m_acTEncTop[layer].setUseWP                   ( m_useWeightedPred      );
     216    m_acTEncTop[layer].setWPBiPred                ( m_useWeightedBiPred   );
     217    //====== Parallel Merge Estimation ========
     218    m_acTEncTop[layer].setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 );
     219
     220    //====== Slice ========
     221    m_acTEncTop[layer].setSliceMode               ( m_sliceMode                );
     222    m_acTEncTop[layer].setSliceArgument           ( m_sliceArgument            );
     223
     224    //====== Dependent Slice ========
     225    m_acTEncTop[layer].setSliceSegmentMode        ( m_sliceSegmentMode         );
     226    m_acTEncTop[layer].setSliceSegmentArgument    ( m_sliceSegmentArgument     );
     227    Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
     228    if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
     229    {
     230      m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
     231    }
     232    if(m_sliceMode==FIXED_NUMBER_OF_LCU)
     233    {
     234      m_acTEncTop[layer].setSliceArgument ( m_sliceArgument * iNumPartInCU );
     235    }
     236    if(m_sliceMode==FIXED_NUMBER_OF_TILES)
     237    {
     238      m_acTEncTop[layer].setSliceArgument ( m_sliceArgument );
     239    }
     240
     241    if(m_sliceMode == 0 )
     242    {
     243      m_bLFCrossSliceBoundaryFlag = true;
     244    }
     245    m_acTEncTop[layer].setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
     246    m_acTEncTop[layer].setUseSAO ( m_bUseSAO );
     247    m_acTEncTop[layer].setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
     248
     249    m_acTEncTop[layer].setSaoLcuBoundary (m_saoLcuBoundary);
     250    m_acTEncTop[layer].setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
     251    m_acTEncTop[layer].setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
     252    m_acTEncTop[layer].setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
     253
     254    m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     255    m_acTEncTop[layer].setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
     256    m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
     257    m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
     258    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
     259    m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType );
     260    m_acTEncTop[layer].setFramePackingArrangementSEIId( m_framePackingSEIId );
     261    m_acTEncTop[layer].setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
     262    m_acTEncTop[layer].setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
     263    m_acTEncTop[layer].setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
     264    m_acTEncTop[layer].setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
     265    m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
     266    m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
     267    m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
     268    m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     269    m_acTEncTop[layer].setNumRowsMinus1              ( m_iNumRowsMinus1 );
     270    if(m_iUniformSpacingIdr==0)
     271    {
     272      m_acTEncTop[layer].setColumnWidth              ( m_pColumnWidth );
     273      m_acTEncTop[layer].setRowHeight                ( m_pRowHeight );
     274    }
     275    m_acTEncTop[layer].xCheckGSParameters();
     276    Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
     277    if(uiTilesCount == 1)
     278    {
     279      m_bLFCrossTileBoundaryFlag = true;
     280    }
     281    m_acTEncTop[layer].setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
     282    m_acTEncTop[layer].setWaveFrontSynchro           ( m_iWaveFrontSynchro );
     283    m_acTEncTop[layer].setWaveFrontSubstreams        ( m_acLayerCfg[layer].m_iWaveFrontSubstreams );
     284    m_acTEncTop[layer].setTMVPModeId ( m_TMVPModeId );
     285    m_acTEncTop[layer].setUseScalingListId           ( m_useScalingListId  );
     286    m_acTEncTop[layer].setScalingListFile            ( m_scalingListFile   );
     287    m_acTEncTop[layer].setSignHideFlag(m_signHideFlag);
     288#if RATE_CONTROL_LAMBDA_DOMAIN
     289    m_acTEncTop[layer].setUseRateCtrl         ( m_RCEnableRateControl );
     290    m_acTEncTop[layer].setTargetBitrate       ( m_RCTargetBitrate );
     291    m_acTEncTop[layer].setKeepHierBit         ( m_RCKeepHierarchicalBit );
     292    m_acTEncTop[layer].setLCULevelRC          ( m_RCLCULevelRC );
     293    m_acTEncTop[layer].setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
     294    m_acTEncTop[layer].setInitialQP           ( m_RCInitialQP );
     295    m_acTEncTop[layer].setForceIntraQP        ( m_RCForceIntraQP );
     296#else
     297    m_acTEncTop[layer].setUseRateCtrl     ( m_enableRateCtrl);
     298    m_acTEncTop[layer].setTargetBitrate   ( m_targetBitrate);
     299    m_acTEncTop[layer].setNumLCUInUnit    ( m_numLCUInUnit);
     300#endif
     301    m_acTEncTop[layer].setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
     302    m_acTEncTop[layer].setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
     303    m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
     304    m_acTEncTop[layer].setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
     305    m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
     306    m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
     307    m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc );
     308    m_acTEncTop[layer].setSarWidth( m_sarWidth );
     309    m_acTEncTop[layer].setSarHeight( m_sarHeight );
     310    m_acTEncTop[layer].setOverscanInfoPresentFlag( m_overscanInfoPresentFlag );
     311    m_acTEncTop[layer].setOverscanAppropriateFlag( m_overscanAppropriateFlag );
     312    m_acTEncTop[layer].setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag );
     313    m_acTEncTop[layer].setVideoFormat( m_videoFormat );
     314    m_acTEncTop[layer].setVideoFullRangeFlag( m_videoFullRangeFlag );
     315    m_acTEncTop[layer].setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag );
     316    m_acTEncTop[layer].setColourPrimaries( m_colourPrimaries );
     317    m_acTEncTop[layer].setTransferCharacteristics( m_transferCharacteristics );
     318    m_acTEncTop[layer].setMatrixCoefficients( m_matrixCoefficients );
     319    m_acTEncTop[layer].setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag );
     320    m_acTEncTop[layer].setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField );
     321    m_acTEncTop[layer].setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
     322    m_acTEncTop[layer].setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
     323    m_acTEncTop[layer].setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
     324    m_acTEncTop[layer].setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
     325    m_acTEncTop[layer].setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
     326    m_acTEncTop[layer].setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
     327    m_acTEncTop[layer].setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
     328    m_acTEncTop[layer].setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
     329    m_acTEncTop[layer].setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
     330    m_acTEncTop[layer].setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
     331    m_acTEncTop[layer].setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
     332    m_acTEncTop[layer].setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
     333    m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
     334    m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
     335#if SIGNAL_BITRATE_PICRATE_IN_VPS
     336    TComBitRatePicRateInfo *bitRatePicRateInfo = m_cTEncTop[layer].getVPS()->getBitratePicrateInfo();
     337    // The number of bit rate/pic rate have to equal to number of sub-layers.
     338    if(m_bitRatePicRateMaxTLayers)
     339    {
     340      assert(m_bitRatePicRateMaxTLayers == m_cTEncTop[layer].getVPS()->getMaxTLayers());
     341    }
     342    for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
     343    {
     344      bitRatePicRateInfo->setBitRateInfoPresentFlag( i, m_bitRateInfoPresentFlag[i] );
     345      if( bitRatePicRateInfo->getBitRateInfoPresentFlag(i) )
     346      {
     347        bitRatePicRateInfo->setAvgBitRate(i, m_avgBitRate[i]);
     348        bitRatePicRateInfo->setMaxBitRate(i, m_maxBitRate[i]);
     349      }
     350    }
     351    for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
     352    {
     353      bitRatePicRateInfo->setPicRateInfoPresentFlag( i, m_picRateInfoPresentFlag[i] );
     354      if( bitRatePicRateInfo->getPicRateInfoPresentFlag(i) )
     355      {
     356        bitRatePicRateInfo->setAvgPicRate     (i, m_avgPicRate[i]);
     357        bitRatePicRateInfo->setConstantPicRateIdc(i, m_constantPicRateIdc[i]);
     358      }
     359    }
     360#endif
     361#if REF_IDX_FRAMEWORK
     362    m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled);
     363#endif
     364  }
     365}
     366#else
     367Void TAppEncTop::xInitLibCfg()
     368{
    70369  TComVPS vps;
    71  
     370
    72371  vps.setMaxTLayers                       ( m_maxTempLayer );
    73372  if (m_maxTempLayer == 1)
     
    91390  m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
    92391#endif
    93  
     392
    94393  m_cTEncTop.setFrameRate                    ( m_iFrameRate );
    95394  m_cTEncTop.setFrameSkip                    ( m_FrameSkip );
     
    98397  m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
    99398  m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
    100  
     399
    101400  //====== Coding Structure ========
    102401  m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
     
    115414  }
    116415  m_cTEncTop.setQP                           ( m_iQP );
    117  
     416
    118417  m_cTEncTop.setPad                          ( m_aiPad );
    119    
     418
    120419  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
    121420  m_cTEncTop.setUseAMP( m_enableAMP );
    122  
     421
    123422  //===== Slice ========
    124  
     423
    125424  //====== Loop/Deblock Filter ========
    126425  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
     
    155454  m_cTEncTop.setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
    156455  m_cTEncTop.setQPAdaptationRange            ( m_iQPAdaptationRange );
    157  
     456
    158457  //====== Tool list ========
    159458  m_cTEncTop.setUseSBACRD                    ( m_bUseSBACRD   );
     
    186485  m_cTEncTop.setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
    187486  m_cTEncTop.setMaxNumMergeCand              ( m_maxNumMergeCand );
    188  
     487
    189488
    190489  //====== Weighted Prediction ========
     
    214513    m_cTEncTop.setSliceArgument ( m_sliceArgument );
    215514  }
    216  
     515
    217516  if(m_sliceMode == 0 )
    218517  {
     
    336635#endif
    337636}
     637#endif
    338638
    339639Void TAppEncTop::xCreateLib()
    340640{
    341641  // Video I/O
     642#if SVC_EXTENSION
     643  // initialize global variables
     644  initROM();
     645
     646  for(UInt layer=0; layer<m_numLayers; layer++)
     647  {
     648    m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
     649    m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1]);
     650
     651    if (!m_acLayerCfg[layer].getReconFile().empty())
     652    {
     653      m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // write mode
     654    }
     655
     656    m_acTEncTop[layer].create();
     657  }
     658#else
    342659  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
    343660  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
     
    345662  if (m_pchReconFile)
    346663    m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
    347  
     664
    348665  // Neo Decoder
    349666  m_cTEncTop.create();
     667#endif
    350668}
    351669
     
    353671{
    354672  // Video I/O
     673#if SVC_EXTENSION
     674  // destroy ROM
     675  destroyROM();
     676
     677  for(UInt layer=0; layer<m_numLayers; layer++)
     678  {
     679    m_acTVideoIOYuvInputFile[layer].close();
     680    m_acTVideoIOYuvReconFile[layer].close();
     681
     682    m_acTEncTop[layer].destroy();
     683  }
     684#else
    355685  m_cTVideoIOYuvInputFile.close();
    356686  m_cTVideoIOYuvReconFile.close();
    357  
     687
    358688  // Neo Decoder
    359689  m_cTEncTop.destroy();
     690#endif
    360691}
    361692
    362693Void TAppEncTop::xInitLib()
    363694{
     695#if SVC_EXTENSION
     696  for(UInt layer=0; layer<m_numLayers; layer++)
     697  {
     698    m_acTEncTop[layer].init();
     699  }
     700#else
    364701  m_cTEncTop.init();
     702#endif
    365703}
    366704
     
    370708
    371709/**
    372  - create internal class
    373  - initialize internal variable
    374  - until the end of input YUV file, call encoding function in TEncTop class
    375  - delete allocated buffers
    376  - destroy internal class
    377  .
    378  */
     710- create internal class
     711- initialize internal variable
     712- until the end of input YUV file, call encoding function in TEncTop class
     713- delete allocated buffers
     714- destroy internal class
     715.
     716*/
     717#if SVC_EXTENSION
    379718Void TAppEncTop::encode()
    380719{
    381   fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
     720  fstream bitstreamFile(m_pBitstreamFile, fstream::binary | fstream::out);
    382721  if (!bitstreamFile)
    383722  {
    384     fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
     723    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pBitstreamFile);
    385724    exit(EXIT_FAILURE);
    386725  }
    387726
    388   TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
     727  TComPicYuv*       pcPicYuvOrg [MAX_LAYERS];
    389728  TComPicYuv*       pcPicYuvRec = NULL;
    390  
     729
    391730  // initialize internal class & member variables
    392731  xInitLibCfg();
    393732  xCreateLib();
    394733  xInitLib();
    395  
     734
     735  // main encoder loop
     736  Int   iNumEncoded = 0, iTotalNumEncoded = 0;
     737  Bool  bEos = false;
     738
     739  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
     740
     741  for(UInt layer=0; layer<m_numLayers; layer++)
     742  {
     743    // allocate original YUV buffer
     744    pcPicYuvOrg[layer] = new TComPicYuv;
     745#if SVC_UPSAMPLING
     746    pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     747#else
     748    pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     749#endif
     750  }
     751
     752#if AVC_SYNTAX
     753  if( !m_BLSyntaxFile )
     754  {
     755    printf( "Wrong base layer syntax input file\n" );
     756    exit(EXIT_FAILURE);
     757  }
     758  fstream streamSyntaxFile( m_BLSyntaxFile, fstream::in | fstream::binary );
     759  if( !streamSyntaxFile.good() )
     760  {
     761    printf( "Base layer syntax input reading error\n" );
     762    exit(EXIT_FAILURE);
     763  }
     764  m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile );
     765#endif
     766
     767  Bool bFirstFrame = true;
     768  while ( !bEos )
     769  {
     770    // Read enough frames
     771    Bool bFramesReadyToCode = false;
     772    while(!bFramesReadyToCode)
     773    {
     774      for(UInt layer=0; layer<m_numLayers; layer++)
     775      {
     776        // get buffers
     777        xGetBuffer(pcPicYuvRec, layer);
     778
     779        // read input YUV file
     780        m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() );
     781
     782        if(layer == m_numLayers-1)
     783        {
     784          // increase number of received frames
     785          m_iFrameRcvd++;
     786          // check end of file
     787          bEos = (m_iFrameRcvd == m_framesToBeEncoded);
     788        }
     789
     790        m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
     791      }
     792
     793      bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos );
     794    }
     795    Bool flush = 0;
     796    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
     797    if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof())
     798    {
     799      flush = true;
     800      bEos = true;
     801      m_iFrameRcvd--;
     802      m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd);
     803    }
     804
     805    // loop through frames in one GOP
     806    for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ )
     807    {
     808      // layer by layer for each frame
     809      for(UInt layer=0; layer<m_numLayers; layer++)
     810      {
     811        // call encoding function for one frame
     812        m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     813      }
     814    }
     815
     816    iTotalNumEncoded = 0;
     817    for(UInt layer=0; layer<m_numLayers; layer++)
     818    {
     819      // write bistream to file if necessary
     820      iNumEncoded = m_acTEncTop[layer].getNumPicRcvd();
     821      if ( iNumEncoded > 0 )
     822      {
     823        xWriteRecon(layer, iNumEncoded);
     824        iTotalNumEncoded += iNumEncoded;
     825      }
     826      m_acTEncTop[layer].setNumPicRcvd( 0 );
     827    }
     828
     829    // write bitstream out
     830    if(iTotalNumEncoded)
     831    {
     832      xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits);
     833      outputAccessUnits.clear();
     834    }
     835
     836    // print out summary
     837    if (bEos)
     838    {
     839      printOutSummary();
     840    }
     841
     842    bFirstFrame = false;
     843  }
     844  // delete original YUV buffer
     845  for(UInt layer=0; layer<m_numLayers; layer++)
     846  {
     847    pcPicYuvOrg[layer]->destroy();
     848    delete pcPicYuvOrg[layer];
     849    pcPicYuvOrg[layer] = NULL;
     850
     851    // delete used buffers in encoder class
     852    m_acTEncTop[layer].deletePicBuffer();
     853  }
     854
     855#if AVC_SYNTAX
     856  if( streamSyntaxFile.is_open() )
     857  {
     858    streamSyntaxFile.close();
     859  }
     860#endif
     861
     862  // delete buffers & classes
     863  xDeleteBuffer();
     864  xDestroyLib();
     865
     866  printRateSummary();
     867
     868  return;
     869}
     870
     871Void TAppEncTop::printOutSummary()
     872{
     873  UInt layer;
     874
     875  // set frame rate
     876  for(layer = 0; layer < m_numLayers; layer++)
     877  {
     878    m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate());
     879    m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     880    m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     881    m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     882  }
     883
     884  //-- all
     885  printf( "\n\nSUMMARY --------------------------------------------------------\n" );
     886  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     887  for(layer = 0; layer < m_numLayers; layer++)
     888  {
     889    m_gcAnalyzeAll[layer].printOut('a', layer);
     890  }
     891
     892  printf( "\n\nI Slices--------------------------------------------------------\n" );
     893  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     894  for(layer = 0; layer < m_numLayers; layer++)
     895  {
     896    m_gcAnalyzeI[layer].printOut('i', layer);
     897  }
     898
     899  printf( "\n\nP Slices--------------------------------------------------------\n" );
     900  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     901  for(layer = 0; layer < m_numLayers; layer++)
     902  {
     903    m_gcAnalyzeP[layer].printOut('p', layer);
     904  }
     905
     906  printf( "\n\nB Slices--------------------------------------------------------\n" );
     907  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     908  for(layer = 0; layer < m_numLayers; layer++)
     909  {
     910    m_gcAnalyzeB[layer].printOut('b', layer);
     911  }
     912}
     913
     914#else
     915Void TAppEncTop::encode()
     916{
     917  fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
     918  if (!bitstreamFile)
     919  {
     920    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
     921    exit(EXIT_FAILURE);
     922  }
     923
     924  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
     925  TComPicYuv*       pcPicYuvRec = NULL;
     926
     927  // initialize internal class & member variables
     928  xInitLibCfg();
     929  xCreateLib();
     930  xInitLib();
     931
    396932  // main encoder loop
    397933  Int   iNumEncoded = 0;
    398934  Bool  bEos = false;
    399  
     935
    400936  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
    401937
    402938  // allocate original YUV buffer
    403939  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    404  
     940
    405941  while ( !bEos )
    406942  {
     
    410946    // read input YUV file
    411947    m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad );
    412    
     948
    413949    // increase number of received frames
    414950    m_iFrameRcvd++;
    415    
     951
    416952    bEos = (m_iFrameRcvd == m_framesToBeEncoded);
    417953
     
    428964    // call encoding function for one frame
    429965    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
    430    
     966
    431967    // write bistream to file if necessary
    432968    if ( iNumEncoded > 0 )
     
    443979  delete pcPicYuvOrg;
    444980  pcPicYuvOrg = NULL;
    445  
     981
    446982  // delete used buffers in encoder class
    447983  m_cTEncTop.deletePicBuffer();
    448  
     984
    449985  // delete buffers & classes
    450986  xDeleteBuffer();
    451987  xDestroyLib();
    452  
     988
    453989  printRateSummary();
    454990
    455991  return;
    456992}
     993#endif
    457994
    458995// ====================================================================================================================
     
    461998
    462999/**
    463  - application has picture buffer list with size of GOP
    464  - picture buffer list acts as ring buffer
    465  - end of the list has the latest picture
    466  .
    467  */
     1000- application has picture buffer list with size of GOP
     1001- picture buffer list acts as ring buffer
     1002- end of the list has the latest picture
     1003.
     1004*/
     1005#if SVC_EXTENSION
     1006Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
     1007{
     1008  assert( m_iGOPSize > 0 );
     1009
     1010  // org. buffer
     1011  if ( m_acListPicYuvRec[layer].size() == (UInt)m_iGOPSize )
     1012  {
     1013    rpcPicYuvRec = m_acListPicYuvRec[layer].popFront();
     1014
     1015  }
     1016  else
     1017  {
     1018    rpcPicYuvRec = new TComPicYuv;
     1019
     1020#if SVC_UPSAMPLING
     1021    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1022#else
     1023    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1024#endif
     1025
     1026  }
     1027  m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec );
     1028}
     1029
     1030Void TAppEncTop::xDeleteBuffer( )
     1031{
     1032  for(UInt layer=0; layer<m_numLayers; layer++)
     1033  {
     1034    TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_acListPicYuvRec[layer].begin();
     1035
     1036    Int iSize = Int( m_acListPicYuvRec[layer].size() );
     1037
     1038    for ( Int i = 0; i < iSize; i++ )
     1039    {
     1040      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1041      pcPicYuvRec->destroy();
     1042      delete pcPicYuvRec; pcPicYuvRec = NULL;
     1043    }
     1044  } 
     1045}
     1046
     1047Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded)
     1048{
     1049  Int i;
     1050
     1051  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
     1052
     1053  for ( i = 0; i < iNumEncoded; i++ )
     1054  {
     1055    --iterPicYuvRec;
     1056  }
     1057
     1058  for ( i = 0; i < iNumEncoded; i++ )
     1059  {
     1060    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1061    if (!m_acLayerCfg[layer].getReconFile().empty())
     1062    {
     1063      m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
     1064        m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     1065    }
     1066  }
     1067}
     1068
     1069Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
     1070{
     1071  Int i;
     1072
     1073  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1074
     1075  for ( i = 0; i < iNumEncoded; i++ )
     1076  {
     1077    const AccessUnit& au = *(iterBitstream++);
     1078    const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     1079    rateStatsAccum(au, stats);
     1080  }
     1081}
     1082
     1083#else // SVC_EXTENSION
    4681084Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec)
    4691085{
    4701086  assert( m_iGOPSize > 0 );
    471  
     1087
    4721088  // org. buffer
    4731089  if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
     
    4791095  {
    4801096    rpcPicYuvRec = new TComPicYuv;
    481    
     1097
    4821098    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    4831099
     
    4891105{
    4901106  TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
    491  
     1107
    4921108  Int iSize = Int( m_cListPicYuvRec.size() );
    493  
     1109
    4941110  for ( Int i = 0; i < iSize; i++ )
    4951111  {
     
    4981114    delete pcPicYuvRec; pcPicYuvRec = NULL;
    4991115  }
    500  
     1116
    5011117}
    5021118
    5031119/** \param iNumEncoded  number of encoded frames
    504  */
     1120*/
    5051121Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    5061122{
    5071123  Int i;
    508  
     1124
    5091125  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    5101126  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    511  
     1127
    5121128  for ( i = 0; i < iNumEncoded; i++ )
    5131129  {
    5141130    --iterPicYuvRec;
    5151131  }
    516  
     1132
    5171133  for ( i = 0; i < iNumEncoded; i++ )
    5181134  {
     
    5281144  }
    5291145}
     1146#endif
    5301147
    5311148/**
    532  *
    533  */
     1149*
     1150*/
    5341151void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
    5351152{
     
    5721189void TAppEncTop::printRateSummary()
    5731190{
     1191#if SVC_EXTENSION
     1192  Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate();
     1193#else
    5741194  Double time = (Double) m_iFrameRcvd / m_iFrameRate;
     1195#endif
    5751196  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
    5761197#if VERBOSE_RATE
  • branches/HM-10.0-dev-SHM/source/App/TAppEncoder/TAppEncTop.h

    r51 r54  
    5959private:
    6060  // class interface
     61#if SVC_EXTENSION
     62  TEncTop                    m_acTEncTop [MAX_LAYERS];                    ///< encoder class
     63  TEncTop*                   m_apcTEncTop [MAX_LAYERS];                   ///< encoder pointer class
     64  TVideoIOYuv                m_acTVideoIOYuvInputFile [MAX_LAYERS];       ///< input YUV file
     65  TVideoIOYuv                m_acTVideoIOYuvReconFile [MAX_LAYERS];       ///< output reconstruction file
     66
     67  TComList<TComPicYuv*>      m_acListPicYuvRec [MAX_LAYERS];              ///< list of reconstruction YUV files
     68#else
    6169  TEncTop                    m_cTEncTop;                    ///< encoder class
    6270  TVideoIOYuv                m_cTVideoIOYuvInputFile;       ///< input YUV file
     
    6472 
    6573  TComList<TComPicYuv*>      m_cListPicYuvRec;              ///< list of reconstruction YUV files
     74#endif
    6675 
    6776  Int                        m_iFrameRcvd;                  ///< number of received frames
     
    7786 
    7887  /// obtain required buffers
     88#if SVC_EXTENSION
     89  Void xGetBuffer(TComPicYuv*& rpcPicYuvRec, UInt layer);
     90#else
    7991  Void xGetBuffer(TComPicYuv*& rpcPicYuvRec);
     92#endif
    8093 
    8194  /// delete allocated buffers
     
    8396 
    8497  // file I/O
     98#if SVC_EXTENSION
     99  Void xWriteRecon(UInt layer, Int iNumEncoded);
     100  Void xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits);
     101  Void printOutSummary();
     102#else
    85103  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits); ///< write bitstream to file
     104#endif
    86105  void rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& stats);
    87106  void printRateSummary();
     
    92111 
    93112  Void        encode      ();                               ///< main encoding function
     113#if SVC_EXTENSION
     114  TEncTop&    getTEncTop  (UInt layer)   { return  m_acTEncTop[layer]; }      ///< return encoder class pointer reference
     115#else
    94116  TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
     117#endif
    95118};// END CLASS DEFINITION TAppEncTop
    96119
  • branches/HM-10.0-dev-SHM/source/App/TAppEncoder/encmain.cpp

    r51 r54  
    5757  // print information
    5858  fprintf( stdout, "\n" );
    59   fprintf( stdout, "HM software: Encoder Version [%s]", NV_VERSION );
     59  fprintf( stdout, "SHM software: Encoder Version [%s]", NV_VERSION );
    6060  fprintf( stdout, NVM_ONOS );
    6161  fprintf( stdout, NVM_COMPILEDBY );
Note: See TracChangeset for help on using the changeset viewer.