Changeset 54 in SHVCSoftware


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

port simulcast

Location:
branches/HM-10.0-dev-SHM/source
Files:
4 added
70 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 );
  • branches/HM-10.0-dev-SHM/source/Lib/TAppCommon/program_options_lite.h

    r51 r54  
    209209        return *this;
    210210      }
    211      
     211#if 1 //SVC_EXTENSION
     212      template<typename T>
     213      OptionSpecific&
     214        operator()(const std::string& name, T* storage, T default_val, unsigned uiMaxNum, const std::string& desc = "" )
     215      {
     216        std::string cNameBuffer;
     217        std::string cDescriptionBuffer;
     218
     219        cNameBuffer       .resize( name.size() + 10 );
     220        cDescriptionBuffer.resize( desc.size() + 10 );
     221
     222        for ( unsigned int uiK = 0; uiK < uiMaxNum; uiK++ )
     223        {
     224          // isn't there are sprintf function for string??
     225          sprintf((char*) cNameBuffer.c_str()       ,name.c_str(),uiK,uiK);
     226          sprintf((char*) cDescriptionBuffer.c_str(),desc.c_str(),uiK,uiK);
     227
     228          size_t pos = cNameBuffer.find_first_of('\0');
     229          if(pos != std::string::npos)
     230            cNameBuffer.resize(pos);
     231     
     232          parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescriptionBuffer ));
     233        }
     234
     235        return *this;
     236      }
     237
     238      template<typename T>
     239      OptionSpecific&
     240        operator()(const std::string& name, T** storage, T default_val, unsigned uiMaxNum, const std::string& desc = "" )
     241      {
     242        std::string cNameBuffer;
     243        std::string cDescriptionBuffer;
     244
     245        cNameBuffer       .resize( name.size() + 10 );
     246        cDescriptionBuffer.resize( desc.size() + 10 );
     247
     248        for ( unsigned int uiK = 0; uiK < uiMaxNum; uiK++ )
     249        {
     250          // isn't there are sprintf function for string??
     251          sprintf((char*) cNameBuffer.c_str()       ,name.c_str(),uiK,uiK);
     252          sprintf((char*) cDescriptionBuffer.c_str(),desc.c_str(),uiK,uiK);
     253
     254          size_t pos = cNameBuffer.find_first_of('\0');
     255          if(pos != std::string::npos)
     256            cNameBuffer.resize(pos);
     257
     258          parent.addOption(new Option<T>( cNameBuffer, *(storage[uiK]), default_val, cDescriptionBuffer ));
     259        }
     260
     261        return *this;
     262      }
     263#endif
    212264      /**
    213265       * Add option described by name to the parent Options list,
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/CommonDef.h

    r51 r54  
    5656// ====================================================================================================================
    5757
    58 #define NV_VERSION        "10.0"                 ///< Current software version
     58#define NV_VERSION        "1.2"                 ///< Current software version
    5959
    6060// ====================================================================================================================
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/ContextTables.h

    r51 r54  
    9292#define NUM_SAO_MERGE_FLAG_CTX        1       ///< number of context models for SAO merge flags
    9393#define NUM_SAO_TYPE_IDX_CTX          1       ///< number of context models for SAO type index
     94#if INTRA_BL
     95#define NUM_INTRA_BL_PRED_CTX         3
     96#endif
    9497
    9598#define NUM_TRANSFORMSKIP_FLAG_CTX    1       ///< number of context models for transform skipping
     
    327330};
    328331
     332#if INTRA_BL
     333static const UChar
     334INIT_INTRA_BL_PRED_FLAG[3][NUM_INTRA_BL_PRED_CTX] =
     335{
     336  { 185,  185,  201, },
     337  { 197,  197,  185, },
     338  { 197,  197,  185, },
     339};
     340#endif
    329341static const UChar
    330342INIT_TRANSFORMSKIP_FLAG[3][2*NUM_TRANSFORMSKIP_FLAG_CTX] =
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/NAL.h

    r51 r54  
    4747  NalUnitType m_nalUnitType; ///< nal_unit_type
    4848  UInt        m_temporalId;  ///< temporal_id
     49#if SVC_EXTENSION
     50  UInt        m_layerId;   ///< layer id
     51#endif
    4952  UInt        m_reservedZero6Bits; ///< reserved_zero_6bits
    5053
     
    5356    NalUnitType nalUnitType,
    5457    Int         temporalId = 0,
     58#if SVC_EXTENSION
     59    UInt        layerId = 0,
     60#endif
    5561    Int         reservedZero6Bits = 0)
    5662    :m_nalUnitType (nalUnitType)
    5763    ,m_temporalId  (temporalId)
     64#if SVC_EXTENSION
     65    ,m_layerId   (layerId)
     66#endif
    5867    ,m_reservedZero6Bits(reservedZero6Bits)
    5968  {}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComDataCU.cpp

    r51 r54  
    359359  m_uiTotalBins        = 0;
    360360  m_uiNumPartition     = pcPic->getNumPartInCU();
     361
     362#if SVC_EXTENSION
     363  m_layerId           = pcPic->getLayerId();
     364#endif
    361365 
    362366  for(Int i=0; i<pcPic->getNumPartInCU(); i++)
     
    16471651  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
    16481652 
     1653#if INTRA_BL
     1654  iLeftIntraDir  = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) && ( !pcTempCU->isIntraBL( uiTempPartIdx ) ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
     1655#else
    16491656  iLeftIntraDir  = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
     1657#endif
    16501658 
    16511659  // Get intra direction of above PU
    16521660  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true );
    16531661 
     1662#if INTRA_BL
     1663  iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) && ( !pcTempCU->isIntraBL( uiTempPartIdx ) ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
     1664#else
    16541665  iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
     1666#endif
     1667 
     1668#if SVC_BL_CAND_INTRA
     1669  if(m_layerId > 0)
     1670  {
     1671    UInt uiCUAddrBase, uiAbsPartAddrBase;
     1672    pcTempCU = getBaseColCU( uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase );
     1673
     1674    if(pcTempCU->getPredictionMode( uiAbsPartAddrBase ) == MODE_INTRA )
     1675    {
     1676      Int iColBaseDir = pcTempCU->getLumaIntraDir( uiAbsPartAddrBase );
     1677      if( iColBaseDir != iAboveIntraDir && iColBaseDir != iLeftIntraDir && iAboveIntraDir != iLeftIntraDir)
     1678      {
     1679        uiIntraDirPred[0] = iColBaseDir;
     1680        uiIntraDirPred[1] = iLeftIntraDir;
     1681        uiIntraDirPred[2] = iAboveIntraDir;
     1682        if( piMode )
     1683        {
     1684          *piMode = 2;
     1685        }
     1686        uiPredNum = 3;
     1687        return uiPredNum;
     1688      }
     1689      else
     1690      {
     1691        iAboveIntraDir = (iColBaseDir == iLeftIntraDir) ? iAboveIntraDir : iLeftIntraDir;
     1692        iLeftIntraDir  = iColBaseDir;
     1693      }
     1694    }
     1695  }
     1696#endif
    16551697 
    16561698  uiPredNum = 3;
     
    17301772  UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2;
    17311773  PartSize  partSize  = getPartitionSize( absPartIdx );
     1774#if INTRA_BL
     1775  UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter();
     1776#else
    17321777  UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter();
     1778#endif
    17331779  Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0;
    17341780  Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) );
     
    17521798  return log2MinTUSizeInCU;
    17531799}
     1800
     1801#if INTRA_BL
     1802UInt TComDataCU::getCtxIntraBLFlag( UInt uiAbsPartIdx )
     1803{
     1804  TComDataCU* pcTempCU;
     1805  UInt        uiTempPartIdx;
     1806  UInt        uiCtx = 0;
     1807 
     1808  // Get BCBP of left PU
     1809#if DEPENDENT_SLICES
     1810  Bool bDepSliceRestriction = ( !m_pcSlice->getPPS()->getDependentSliceEnabledFlag());
     1811  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction );
     1812#else
     1813  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
     1814#endif 
     1815  uiCtx    = ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0;
     1816 
     1817  // Get BCBP of above PU
     1818#if DEPENDENT_SLICES
     1819  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction );
     1820#else
     1821  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
     1822#endif 
     1823  uiCtx   += ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0;
     1824 
     1825  return uiCtx;
     1826}
     1827#endif
     1828
     1829#if REF_IDX_ME_ZEROMV
     1830Bool TComDataCU::xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1)
     1831{
     1832  Bool checkZeroMVILR = true;
     1833
     1834  if(uhInterDir&0x1)  //list0
     1835  {
     1836    Int refIdxL0 = cMvFieldL0.getRefIdx();
     1837    if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->getIsILR())
     1838      checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0);
     1839  }
     1840  if(uhInterDir&0x2)  //list1
     1841  {
     1842    Int refIdxL1  = cMvFieldL1.getRefIdx();
     1843    if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->getIsILR())
     1844      checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0);
     1845  }
     1846
     1847  return checkZeroMVILR;
     1848}
     1849
     1850Bool TComDataCU::xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx)
     1851{
     1852  RefPicList eRefPicList = iRefList > 0? REF_PIC_LIST_1: REF_PIC_LIST_0;
     1853  assert(eRefPicList == REF_PIC_LIST_1);
     1854
     1855  Bool checkZeroMVILR = true;
     1856
     1857  if(getSlice()->getRefPic(eRefPicList, iRefIdx)->getIsILR())
     1858  {
     1859    AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo();
     1860    TComMv    cMv        = pcAMVPInfo->m_acMvCand[MvpIdx];
     1861    checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0);
     1862  }
     1863
     1864  return checkZeroMVILR;
     1865}
     1866#endif
    17541867
    17551868UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx )
     
    24062519  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
    24072520  deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
     2521#if SVC_MVP
     2522  // BL collocated
     2523  TComDataCU *pcColCU = 0;
     2524  UInt uiCUAddrBase, uiAbsPartAddrBase ;
     2525  TComMvField cMvFieldBaseColCU[2];
     2526  if(m_layerId) 
     2527  {
     2528#if MV_SCALING_POS_FIX
     2529    pcColCU = getBaseColCU( xP + nPSW/2, yP + nPSH/2, uiCUAddrBase, uiAbsPartAddrBase );
     2530#else
     2531    UInt uiPartIdxCenter;
     2532    xDeriveCenterIdx( cCurPS, uiPUIdx, uiPartIdxCenter );
     2533    uiPartIdxCenter -= m_uiAbsIdxInLCU;
     2534    pcColCU = getBaseColCU( uiPartIdxCenter, uiCUAddrBase, uiAbsPartAddrBase );
     2535#endif
     2536   
     2537#if INTRA_BL
     2538    if( pcColCU && pcColCU->isIntraBL( uiAbsPartAddrBase ) )
     2539    {
     2540      pcColCU = NULL;
     2541    }
     2542#endif
     2543   
     2544    if(pcColCU && !pcColCU->isIntra( uiAbsPartAddrBase ) )
     2545    {
     2546      abCandIsInter[iCount] = true;
     2547
     2548      // get interDir
     2549      puhInterDirNeighbours[iCount] = pcColCU->getInterDir( uiAbsPartAddrBase );
     2550
     2551      pcMvFieldNeighbours[(iCount << 1)].setMvField( TComMv(0,0), -1);
     2552      pcMvFieldNeighbours[(iCount << 1) + 1].setMvField( TComMv(0,0), -1);
     2553
     2554      if( puhInterDirNeighbours[iCount] & 1 )
     2555      {
     2556        pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_0, cMvFieldBaseColCU[0]);
     2557        scaleBaseMV( pcMvFieldNeighbours[iCount<<1], cMvFieldBaseColCU[0] );
     2558      }
     2559
     2560      if ( getSlice()->isInterB() && puhInterDirNeighbours[iCount] & 2 )
     2561      {
     2562        pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_1, cMvFieldBaseColCU[1] );
     2563        scaleBaseMV( pcMvFieldNeighbours[(iCount<<1)+1], cMvFieldBaseColCU[1] );
     2564      }
     2565
     2566      if( puhInterDirNeighbours[iCount] > 0 )
     2567      {
     2568        if ( mrgCandIdx == iCount )
     2569        {
     2570          return;
     2571        }
     2572        iCount ++;
     2573      }
     2574    }
     2575  }
     2576#endif
    24082577
    24092578  //left
     
    24112580  TComDataCU* pcCULeft = 0;
    24122581  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
     2582#if INTRA_BL
     2583  if( pcCULeft && pcCULeft->isIntraBL( uiLeftPartIdx ) )
     2584  {
     2585    pcCULeft = NULL;
     2586  }
     2587#endif
    24132588  Bool isAvailableA1 = pcCULeft &&
    24142589  pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
     2590#if SVC_MVP
     2591  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) &&
     2592#endif
    24152593  !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
    24162594  !pcCULeft->isIntra( uiLeftPartIdx ) ;
     
    24422620  TComDataCU* pcCUAbove = 0;
    24432621  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
     2622#if INTRA_BL
     2623  if( pcCUAbove && pcCUAbove->isIntraBL( uiAbovePartIdx ) )
     2624  {
     2625    pcCUAbove = NULL;
     2626  }
     2627#endif
    24442628  Bool isAvailableB1 = pcCUAbove &&
     2629#if SVC_MVP
     2630  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) &&
     2631#endif
    24452632  pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
    24462633  !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
     
    24732660  TComDataCU* pcCUAboveRight = 0;
    24742661  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
     2662#if INTRA_BL
     2663  if( pcCUAboveRight && pcCUAboveRight->isIntraBL( uiAboveRightPartIdx ) )
     2664  {
     2665    pcCUAboveRight = NULL;
     2666  }
     2667#endif
    24752668  Bool isAvailableB0 = pcCUAboveRight &&
     2669#if SVC_MVP
     2670  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveRight->hasEqualMotion( uiAboveRightPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) &&
     2671#endif
    24762672  pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
    24772673  !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
     
    25002696
    25012697  //left bottom
     2698#if SVC_MVP
     2699  if( iCount < 4 )
     2700  {
     2701#endif
    25022702  UInt uiLeftBottomPartIdx = 0;
    25032703  TComDataCU* pcCULeftBottom = 0;
    25042704  pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
     2705#if INTRA_BL
     2706  if( pcCULeftBottom && pcCULeftBottom->isIntraBL( uiLeftBottomPartIdx ) )
     2707  {
     2708    pcCULeftBottom = NULL;
     2709  }
     2710#endif
    25052711  Bool isAvailableA0 = pcCULeftBottom &&
    25062712  pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
     2713#if SVC_MVP
     2714  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeftBottom->hasEqualMotion( uiLeftBottomPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0]))
     2715#endif
    25072716  !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
    25082717  if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
     
    25282737    return;
    25292738  }
     2739#if SVC_MVP
     2740  }
     2741#endif
     2742
    25302743  // above left
    25312744  if( iCount < 4 )
     
    25342747    TComDataCU* pcCUAboveLeft = 0;
    25352748    pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
     2749#if INTRA_BL
     2750    if( pcCUAboveLeft && pcCUAboveLeft->isIntraBL( uiAboveLeftPartIdx ) )
     2751    {
     2752      pcCUAboveLeft = NULL;
     2753    }
     2754#endif
    25362755    Bool isAvailableB2 = pcCUAboveLeft &&
    25372756    pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
     2757#if SVC_MVP
     2758    ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveLeft->hasEqualMotion( uiAboveLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] ))
     2759#endif
    25382760    !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
    25392761    if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
     
    28403062  UInt idx;
    28413063  tmpCU = getPUBelowLeft(idx, uiPartIdxLB);
     3064#if INTRA_BL
     3065  bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx));
     3066#else
    28423067  bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA);
     3068#endif
    28433069
    28443070  if (!bAddedSmvp)
    28453071  {
    28463072    tmpCU = getPULeft(idx, uiPartIdxLB);
     3073#if INTRA_BL
     3074    bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx));
     3075#else
    28473076    bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA);
     3077#endif
    28483078  }
    28493079
     
    34063636  if (scaleFactor > 0)
    34073637  {
     3638#if SVC_MVP
     3639    m_acCUMvField[0].compress(m_pePredMode, m_puhInterDir, scaleFactor);
     3640    m_acCUMvField[1].compress(m_pePredMode, m_puhInterDir, scaleFactor);   
     3641#else
    34083642    m_acCUMvField[0].compress(m_pePredMode, scaleFactor);
    34093643    m_acCUMvField[1].compress(m_pePredMode, scaleFactor);   
     3644#endif
    34103645  }
    34113646}
     
    38394074}
    38404075
     4076#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
     4077Void TComDataCU::getBaseLumaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride )
     4078{
     4079  TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec();
     4080  UInt uiStrideBase = pcBaseRec->getStride();
     4081  Pel* piBase = pcBaseRec->getLumaAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx );
     4082 
     4083  for ( UInt y = 0; y < uiHeight; y ++ )
     4084  {
     4085    memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) );
     4086  }
     4087}
     4088
     4089Void TComDataCU::getBaseChromaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, UInt uiChromaId )
     4090{
     4091  TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec();
     4092
     4093  UInt uiStrideBase = pcBaseRec->getCStride();
     4094  Pel* piBase;
     4095 
     4096  if( uiChromaId == 0 )
     4097  {
     4098    piBase = pcBaseRec->getCbAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx );
     4099  }
     4100  else
     4101  {
     4102    piBase = pcBaseRec->getCrAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx );
     4103  }
     4104 
     4105  for ( UInt y = 0; y < uiHeight; y ++ )
     4106  {
     4107    memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) );
     4108  }
     4109}
     4110
     4111#endif
     4112
     4113#if SVC_COL_BLK
     4114TComDataCU*  TComDataCU::getBaseColCU( UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
     4115{
     4116#if 1 // it should provide identical resutls
     4117  UInt uiPelX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiCuAbsPartIdx] ];
     4118  UInt uiPelY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiCuAbsPartIdx] ];
     4119
     4120  return getBaseColCU( uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase );
     4121#else
     4122  TComPic* cBaseColPic = m_pcSlice->getBaseColPic();
     4123
     4124#if SVC_UPSAMPLING
     4125  Int iBWidth   = cBaseColPic->getPicYuvRec()->getWidth () - cBaseColPic->getPicYuvRec()->getPicCropLeftOffset() - cBaseColPic->getPicYuvRec()->getPicCropRightOffset();
     4126  Int iBHeight  = cBaseColPic->getPicYuvRec()->getHeight() - cBaseColPic->getPicYuvRec()->getPicCropTopOffset() - cBaseColPic->getPicYuvRec()->getPicCropBottomOffset();
     4127
     4128  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth() - m_pcPic->getPicYuvRec()->getPicCropLeftOffset() - m_pcPic->getPicYuvRec()->getPicCropRightOffset();
     4129  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight() - m_pcPic->getPicYuvRec()->getPicCropTopOffset() - m_pcPic->getPicYuvRec()->getPicCropBottomOffset();
     4130#else
     4131  Int iBWidth   = cBaseColPic->getPicYuvRec()->getWidth();
     4132  Int iBHeight  = cBaseColPic->getPicYuvRec()->getHeight();
     4133
     4134  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth();
     4135  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight();
     4136#endif
     4137
     4138  if (iBWidth == iEWidth && iEHeight == iBHeight)
     4139  {
     4140    uiAbsPartIdxBase = uiCuAbsPartIdx + m_uiAbsIdxInLCU;
     4141    uiCUAddrBase = m_uiCUAddr;
     4142  }
     4143  else
     4144  {
     4145    UInt uiMinUnitSize = m_pcPic->getMinCUWidth();
     4146    UInt uiRasterAddr  = g_auiZscanToRaster[uiCuAbsPartIdx];
     4147    UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
     4148
     4149    Int iEX = m_uiCUPelX + uiMinUnitSize*(uiRasterAddr%uiNumPartInCUWidth);
     4150    Int iEY = m_uiCUPelY + uiMinUnitSize*(uiRasterAddr/uiNumPartInCUWidth);
     4151
     4152    Int iBX = (iEX*iBWidth + iEWidth/2)/iEWidth;
     4153    Int iBY = (iEY*iBHeight+ iEHeight/2)/iEHeight;
     4154
     4155    uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth);
     4156
     4157    assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame());
     4158   
     4159    UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth()
     4160                          + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize;
     4161
     4162    uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase];
     4163  }
     4164
     4165  return cBaseColPic->getCU(uiCUAddrBase);
     4166#endif
     4167}
     4168
     4169TComDataCU*  TComDataCU::getBaseColCU( UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
     4170{
     4171  TComPic* cBaseColPic = m_pcSlice->getBaseColPic();
     4172
     4173#if SVC_UPSAMPLING
     4174  const Window &confBL = cBaseColPic->getPicYuvRec()->getConformanceWindow();
     4175  const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow();
     4176
     4177  Int iBWidth   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     4178  Int iBHeight  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     4179
     4180  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     4181  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     4182#else
     4183  Int iBWidth   = cBaseColPic->getPicYuvRec()->getWidth();
     4184  Int iBHeight  = cBaseColPic->getPicYuvRec()->getHeight();
     4185
     4186  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth();
     4187  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight();
     4188#endif
     4189
     4190  uiPelX = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getWidth() - 1, uiPelX);
     4191  uiPelY = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getHeight() - 1, uiPelY);
     4192
     4193  UInt uiMinUnitSize = m_pcPic->getMinCUWidth();
     4194
     4195  Int iBX = (uiPelX*iBWidth + iEWidth/2)/iEWidth;
     4196  Int iBY = (uiPelY*iBHeight+ iEHeight/2)/iEHeight;
     4197
     4198  if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight())
     4199  {
     4200    return NULL;
     4201  }
     4202
     4203#if AVC_SYNTAX
     4204  if( iBX >= iBWidth || iBY >= iBHeight ) //outside of the reference layer cropped picture
     4205  {
     4206    return NULL;
     4207  }
     4208#endif
     4209
     4210  uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth);
     4211
     4212  assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame());
     4213
     4214  UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth()
     4215    + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize;
     4216
     4217  uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase];
     4218
     4219  return cBaseColPic->getCU(uiCUAddrBase);
     4220}
     4221
     4222Void TComDataCU::scaleBaseMV( TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase )
     4223{
     4224  TComMvField cMvFieldBase;
     4225  TComMv cMv;
     4226
     4227#if MV_SCALING_FIX
     4228  const Window &confBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
     4229  const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow();
     4230
     4231  Int iBWidth   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     4232  Int iBHeight  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     4233
     4234  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     4235  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     4236#else
     4237  Int iBWidth   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
     4238  Int iBHeight  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
     4239
     4240  Int iEWidth   = m_pcPic->getPicYuvRec()->getWidth();
     4241  Int iEHeight  = m_pcPic->getPicYuvRec()->getHeight();
     4242#endif
     4243
     4244  Int iMvX = (rcMvFieldBase.getHor()*iEWidth + (iBWidth/2 -1) * (rcMvFieldBase.getHor() > 0 ? 1: -1) )/iBWidth;
     4245  Int iMvY = (rcMvFieldBase.getVer()*iEHeight + (iBHeight/2 -1) * (rcMvFieldBase.getVer() > 0 ? 1: -1) )/iBHeight;
     4246
     4247  cMv.set(iMvX, iMvY);
     4248
     4249  rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() );
     4250}
     4251#endif
     4252
     4253#if SVC_MVP
     4254Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, UChar uchInterDir, TComMvField* pcMvField  )
     4255{
     4256  if ( getInterDir( uiAbsPartIdx ) != uchInterDir )
     4257  {
     4258    return false;
     4259  }
     4260
     4261  for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
     4262  {
     4263    if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) )
     4264    {
     4265      if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx )  != pcMvField[uiRefListIdx].getMv() ||
     4266        getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getRefIdx() )
     4267      {
     4268        return false;
     4269      }
     4270    }
     4271  }
     4272
     4273  return true;
     4274}
     4275#endif
    38414276
    38424277//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComDataCU.h

    r51 r54  
    125125  Int           m_unitSize;           ///< size of a "minimum partition"
    126126 
     127#if SVC_EXTENSION
     128  UInt          m_layerId;          ///< layer id
     129#endif
     130
    127131  // -------------------------------------------------------------------------------------------------------------------
    128132  // CU data
     
    434438  Void          compressMV            ();
    435439 
     440#if SVC_EXTENSION
     441  Void          setLayerId (UInt layerId) { m_layerId = layerId; }
     442  UInt          getLayerId ()               { return m_layerId; }
     443#endif
     444 
    436445  // -------------------------------------------------------------------------------------------------------------------
    437446  // utility functions for neighbouring information
     
    476485  Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
    477486 
     487#if SVC_MVP
     488  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, UChar uchInterDir, TComMvField* pcMvField  );
     489#endif
    478490 
    479491  // -------------------------------------------------------------------------------------------------------------------
     
    481493  // -------------------------------------------------------------------------------------------------------------------
    482494 
     495#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
     496  Void          getBaseLumaBlk   ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride );
     497  Void          getBaseChromaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, UInt uiChromaId );
     498#endif
     499#if INTRA_BL
     500  Bool          isIntraBL ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA_BL; }
     501  Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA || m_pePredMode[ uiPartIdx ] == MODE_INTRA_BL; }
     502#else
    483503  Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; }
     504#endif
    484505  Bool          isSkipped ( UInt uiPartIdx );                                                     ///< SKIP (no residual)
    485506  Bool          isBipredRestriction( UInt puIdx );
     
    507528  UInt          getSliceSegmentStartCU  ( UInt pos )                  { return m_sliceSegmentStartCU[pos-m_uiAbsIdxInLCU];                                                                                   }
    508529  UInt&         getTotalBins            ()                            { return m_uiTotalBins;                                                                                                  }
     530
     531#if INTRA_BL
     532  UInt          getCtxIntraBLFlag               ( UInt   uiAbsPartIdx                                 );
     533#endif 
     534
     535#if REF_IDX_ME_ZEROMV
     536  Bool xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
     537  Bool xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx);
     538#endif
     539
    509540  // -------------------------------------------------------------------------------------------------------------------
    510541  // member functions for RD cost storage
     
    518549  UInt          getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra);
    519550
     551#if SVC_COL_BLK
     552  TComDataCU*   getBaseColCU( UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
     553  TComDataCU*   getBaseColCU( UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
     554  Void          scaleBaseMV( TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase );
     555#endif
    520556};
    521557
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComMotionInfo.cpp

    r51 r54  
    328328 * \param scale      Factor by which to subsample motion information
    329329 */
     330#if SVC_MVP
     331Void TComCUMvField::compress(Char* pePredMode, UChar* peInterDir, Int scale)
     332#else
    330333Void TComCUMvField::compress(Char* pePredMode, Int scale)
     334#endif
    331335{
    332336  Int N = scale * scale;
     
    347351      pePredMode[ uiPartIdx + i ] = predMode;
    348352      m_piRefIdx[ uiPartIdx + i ] = iRefIdx;
     353#if SVC_MVP
     354      peInterDir[ uiPartIdx + i ] = peInterDir[ uiPartIdx ];
     355#endif
    349356    }
    350357  }
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComMotionInfo.h

    r51 r54  
    141141  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
    142142
     143#if AVC_SYNTAX
     144  Void           setMv    (TComMv cMv,  Int iIdx )         { m_pcMv    [iIdx] = cMv; }
     145  Void           setRefIdx(Int iRefIdx, Int iIdx   )       { m_piRefIdx[iIdx] =  iRefIdx; }
     146#endif
     147
    143148  Void setNumPartition( Int iNumPart )
    144149  {
     
    153158  }
    154159 
     160#if SVC_MVP
     161  Void compress(Char* pePredMode, UChar* peInterDir, Int scale);
     162#else
    155163  Void compress(Char* pePredMode, Int scale);
     164#endif
     165
     166#if REF_IDX_MFM
     167  Void setMvField( TComMvField const& mvField, Int iIdx )
     168  {
     169    m_pcMv[iIdx]      = mvField.getMv();
     170    m_piRefIdx[iIdx]  = mvField.getRefIdx();
     171    return;
     172  }
     173
     174  Void setMvField( TComMv cMv, Int iRefIdx, Int iIdx )
     175  {
     176    m_pcMv[iIdx]      = cMv;
     177    m_piRefIdx[iIdx]  = iRefIdx;
     178    return;
     179  }
     180#endif
    156181};
    157182
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPic.cpp

    r51 r54  
    6464, m_pNDBFilterYuvTmp                      (NULL)
    6565, m_bCheckLTMSB                           (false)
     66#if SVC_EXTENSION
     67, m_layerId( 0 )
     68, m_bSpatialEnhLayer( false )
     69, m_pcFullPelBaseRec( NULL )
     70#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
     71, m_bIsILR                                (false)
     72#endif
     73#endif
    6674{
    6775  m_apcPicYuv[0]      = NULL;
     
    7280{
    7381}
    74 
     82#if SVC_UPSAMPLING
     83Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
     84                      Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual)
     85
     86{
     87  m_apcPicSym     = new TComPicSym;  m_apcPicSym   ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
     88  if (!bIsVirtual)
     89  {
     90    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
     91  }
     92  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
     93
     94  if (m_bSpatialEnhLayer)
     95  {
     96    m_pcFullPelBaseRec = new TComPicYuv;  m_pcFullPelBaseRec->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
     97  }
     98
     99  m_layerId = pcSps->getLayerId(); 
     100
     101  // there are no SEI messages associated with this picture initially
     102  if (m_SEIs.size() > 0)
     103  {
     104    deleteSEIs (m_SEIs);
     105  }
     106  m_bUsedByCurr = false;
     107
     108  /* store conformance window parameters with picture */
     109  m_conformanceWindow = conformanceWindow;
     110 
     111  /* store display window parameters with picture */
     112  m_defaultDisplayWindow = defaultDisplayWindow;
     113
     114  /* store number of reorder pics with picture */
     115  memcpy(m_numReorderPics, numReorderPics, MAX_TLAYER*sizeof(Int));
     116
     117  return;
     118}
     119#if REF_IDX_FRAMEWORK
     120Void TComPic::createWithOutYuv( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, TComSPS* pcSps,  Bool bIsVirtual)
     121{
     122  m_apcPicSym     = new TComPicSym;  m_apcPicSym   ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
     123  if (!bIsVirtual)
     124  {
     125    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
     126  }
     127  m_apcPicYuv[1]  = NULL;
     128 
     129#if SVC_UPSAMPLING
     130  if (m_bSpatialEnhLayer)
     131  {
     132    m_pcFullPelBaseRec = new TComPicYuv;  m_pcFullPelBaseRec->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
     133  }
     134#endif
     135
     136  /* there are no SEI messages associated with this picture initially */
     137  m_SEIs = NULL;
     138  m_bUsedByCurr = false;
     139  return;
     140}
     141#endif
     142#else
    75143Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
    76144                      Int *numReorderPics, Bool bIsVirtual)
     
    102170  return;
    103171}
     172#endif
    104173
    105174Void TComPic::destroy()
     
    127196 
    128197  deleteSEIs(m_SEIs);
     198#if SVC_EXTENSION && SVC_UPSAMPLING
     199  if (m_bSpatialEnhLayer)
     200  {
     201    m_pcFullPelBaseRec->destroy();
     202    delete m_pcFullPelBaseRec;
     203    m_pcFullPelBaseRec  = NULL;
     204  }
     205#endif
    129206}
    130207
     
    465542}
    466543
     544#if REF_IDX_FRAMEWORK
     545Void copyOnetoOnePicture(    // SVC_NONCOLL
     546                  Pel *in,       
     547                  Pel *out,     
     548                  Int nCols,
     549                  Int nRows,
     550                  Int fullRowWidth)
     551{
     552  Int rX;
     553
     554  for (rX = 0; rX < nRows; rX++)       
     555  {
     556    memcpy( out, in, sizeof(Pel) * nCols );
     557    in = in + fullRowWidth;
     558    out = out + fullRowWidth;
     559  }
     560}
     561
     562Void TComPic:: copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut)
     563{
     564  Int upsampledRowWidthLuma = pcPicYuvOut->getStride(); // 2 * pcPicYuvOut->getLumaMargin() + pcPicYuvOut->getWidth();
     565  Int upsampledRowWidthCroma = pcPicYuvOut->getCStride(); //2 * pcPicYuvOut->getChromaMargin() + (pcPicYuvOut->getWidth()>>1);
     566
     567  copyOnetoOnePicture(
     568    pcPicYuvIn->getLumaAddr(),       
     569    pcPicYuvOut->getLumaAddr(),     
     570    pcPicYuvOut->getWidth(),
     571    pcPicYuvOut->getHeight(),
     572    upsampledRowWidthLuma);
     573  copyOnetoOnePicture(
     574    pcPicYuvIn->getCrAddr(),       
     575    pcPicYuvOut->getCrAddr(),     
     576    pcPicYuvOut->getWidth()>>1,
     577    pcPicYuvOut->getHeight()>>1,
     578    upsampledRowWidthCroma);
     579  copyOnetoOnePicture(
     580    pcPicYuvIn->getCbAddr(),       
     581    pcPicYuvOut->getCbAddr(),     
     582    pcPicYuvOut->getWidth()>>1,
     583    pcPicYuvOut->getHeight()>>1,
     584    upsampledRowWidthCroma);
     585}
     586
     587#if REF_IDX_MFM
     588#if !REUSE_BLKMAPPING
     589Void TComPic::deriveUnitIdxBase( UInt uiUpsamplePelX, UInt uiUpsamplePelY, UInt ratio, UInt& uiBaseCUAddr, UInt& uiBaseAbsPartIdx )
     590{
     591  //pixel in the base layer
     592
     593  UInt uiPelX       = (uiUpsamplePelX<<1)/ratio;
     594  UInt uiPelY       = (uiUpsamplePelY<<1)/ratio;
     595  UInt uiBaseWidth  = getPicYuvRec()->getWidth();
     596  UInt uiBaseHeight = getPicYuvRec()->getHeight();
     597 
     598  UInt uiWidthInCU       = ( uiBaseWidth % g_uiMaxCUWidth  ) ? uiBaseWidth /g_uiMaxCUWidth  + 1 : uiBaseWidth /g_uiMaxCUWidth;
     599
     600#if MFM_CLIPPING_FIX
     601  uiPelX     = (UInt)Clip3<UInt>(0, getPicYuvRec()->getWidth() - 1, uiPelX);
     602  uiPelY     = (UInt)Clip3<UInt>(0, getPicYuvRec()->getHeight() - 1, uiPelY);
     603#else
     604  UInt uiHeightInCU      = ( uiBaseHeight% g_uiMaxCUHeight ) ? uiBaseHeight/ g_uiMaxCUHeight + 1 : uiBaseHeight/ g_uiMaxCUHeight;
     605
     606  uiPelX     = (UInt)Clip3<UInt>(0, uiWidthInCU * g_uiMaxCUWidth - 1, uiPelX);
     607  uiPelY     = (UInt)Clip3<UInt>(0, uiHeightInCU * g_uiMaxCUHeight - 1, uiPelY);
     608#endif
     609 
     610  uiBaseCUAddr = uiPelY / g_uiMaxCUHeight * uiWidthInCU + uiPelX / g_uiMaxCUWidth;
     611
     612  UInt uiWidthMinPU = g_uiMaxCUWidth / (1<<g_uiMaxCUDepth);
     613  UInt uiHeightMinPU = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
     614 
     615  UInt uiAbsPelX = uiPelX - (uiPelX / g_uiMaxCUWidth) * g_uiMaxCUWidth;
     616  UInt uiAbsPelY = uiPelY - (uiPelY / g_uiMaxCUHeight) * g_uiMaxCUHeight;
     617
     618  UInt RasterIdx = uiAbsPelY / uiHeightMinPU * (g_uiMaxCUWidth/uiWidthMinPU) + uiAbsPelX / uiWidthMinPU;
     619  uiBaseAbsPartIdx = g_auiRasterToZscan[RasterIdx];
     620
     621  return;
     622}
     623#endif
     624
     625Void TComPic::copyUpsampledMvField(TComPic* pcPicBase)
     626{
     627#if !REUSE_MVSCALE || !REUSE_BLKMAPPING || AVC_SYNTAX
     628  Int iBWidth   = pcPicBase->getPicYuvRec()->getWidth () - pcPicBase->getPicYuvRec()->getPicCropLeftOffset() - pcPicBase->getPicYuvRec()->getPicCropRightOffset();
     629  Int iBHeight  = pcPicBase->getPicYuvRec()->getHeight() - pcPicBase->getPicYuvRec()->getPicCropTopOffset() - pcPicBase->getPicYuvRec()->getPicCropBottomOffset();
     630
     631  Int iEWidth   = getPicYuvRec()->getWidth() -  getPicYuvRec()->getPicCropLeftOffset() - getPicYuvRec()->getPicCropRightOffset();
     632  Int iEHeight  = getPicYuvRec()->getHeight() - getPicYuvRec()->getPicCropTopOffset() -  getPicYuvRec()->getPicCropBottomOffset();
     633#endif
     634 
     635#if !REUSE_MVSCALE  || !REUSE_BLKMAPPING
     636  UInt upSampleRatio = 0;
     637  if(iEWidth == iBWidth && iEHeight == iBHeight)
     638  {
     639    upSampleRatio = 2;
     640  }
     641  else if(2*iEWidth == 3*iBWidth && 2*iEHeight == 3*iBHeight)
     642  {
     643    upSampleRatio = 3;
     644  }
     645  else if(iEWidth == 2*iBWidth && iEHeight == 2*iBHeight)
     646  {
     647    upSampleRatio = 4;
     648  }
     649  else
     650  {
     651    assert(0);
     652  }
     653#endif
     654
     655  UInt uiNumPartitions   = 1<<(g_uiMaxCUDepth<<1);
     656  UInt uiWidthMinPU      = g_uiMaxCUWidth/(1<<g_uiMaxCUDepth);
     657  UInt uiHeightMinPU     = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
     658  Int  unitNum           = max (1, (Int)((16/uiWidthMinPU)*(16/uiHeightMinPU)) );
     659
     660  for(UInt cuIdx = 0; cuIdx < getPicSym()->getNumberOfCUsInFrame(); cuIdx++)  //each LCU
     661  {
     662    TComDataCU*             pcCUDes = getCU(cuIdx);
     663
     664    for(UInt uiAbsPartIdx = 0; uiAbsPartIdx < uiNumPartitions; uiAbsPartIdx+=unitNum )  //each 16x16 unit
     665    {
     666      //pixel position of each unit in up-sampled layer
     667      UInt  uiPelX = pcCUDes->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
     668      UInt  uiPelY = pcCUDes->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
     669      UInt uiBaseCUAddr, uiBaseAbsPartIdx;
     670
     671#if REUSE_BLKMAPPING
     672      TComDataCU *pcColCU = 0;
     673      pcColCU = pcCUDes->getBaseColCU(uiPelX + 8, uiPelY + 8, uiBaseCUAddr, uiBaseAbsPartIdx);
     674#else
     675      pcPicBase->deriveUnitIdxBase(uiPelX + 8, uiPelY + 8, upSampleRatio, uiBaseCUAddr, uiBaseAbsPartIdx);
     676#endif
     677
     678#if AVC_SYNTAX
     679      Int iBX = ( (uiPelX + 8) * iBWidth + iEWidth/2 ) / iEWidth;
     680      Int iBY = ( (uiPelY + 8) * iBHeight+ iEHeight/2 ) / iEHeight;
     681
     682#if REUSE_BLKMAPPING
     683      if( ( iBX < iBWidth && iBY < iBHeight ) && pcColCU && (pcColCU->getPredictionMode(uiBaseAbsPartIdx) != MODE_NONE) && (pcColCU->getPredictionMode(uiBaseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
     684#else
     685      if( ( iBX < iBWidth && iBY < iBHeight ) && (pcPicBase->getCU(uiBaseCUAddr)->getPredictionMode(uiBaseAbsPartIdx) != MODE_NONE) && (pcPicBase->getCU(uiBaseCUAddr)->getPredictionMode(uiBaseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
     686#endif
     687#else
     688#if REUSE_BLKMAPPING
     689      if( pcColCU && (pcColCU->getPredictionMode(uiBaseAbsPartIdx) != MODE_NONE) && (pcColCU->getPredictionMode(uiBaseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
     690#else
     691      if( (pcPicBase->getCU(uiBaseCUAddr)->getPredictionMode(uiBaseAbsPartIdx) != MODE_NONE) && (pcPicBase->getCU(uiBaseCUAddr)->getPredictionMode(uiBaseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
     692#endif
     693#endif
     694      {
     695        for(UInt refPicList = 0; refPicList < 2; refPicList++)  //for each reference list
     696        {
     697#if REUSE_MVSCALE
     698          TComMvField sMvFieldBase, sMvField;
     699#if REUSE_BLKMAPPING
     700          pcColCU->getMvField( pcColCU, uiBaseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
     701#else
     702          pcPicBase->getCU(uiBaseCUAddr)->getMvField( pcPicBase->getCU(uiBaseCUAddr), uiBaseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
     703#endif
     704          pcCUDes->scaleBaseMV( sMvField, sMvFieldBase );
     705#else
     706          TComMv cMv = pcPicBase->getCU(uiBaseCUAddr)->getCUMvField((RefPicList)refPicList)->getMv(uiBaseAbsPartIdx);
     707          Int refIdx = pcPicBase->getCU(uiBaseCUAddr)->getCUMvField((RefPicList)refPicList)->getRefIdx(uiBaseAbsPartIdx);
     708
     709          Int Hor =  ((Int)upSampleRatio * cMv.getHor())/2 ;
     710          Int Ver =  ((Int)upSampleRatio * cMv.getVer())/2 ;
     711
     712          TComMv cScaledMv(Hor, Ver);
     713          TComMvField sMvField;
     714          sMvField.setMvField(cScaledMv, refIdx);
     715#endif
     716
     717          pcCUDes->getCUMvField((RefPicList)refPicList)->setMvField(sMvField, uiAbsPartIdx);
     718          pcCUDes->setPredictionMode(uiAbsPartIdx, MODE_INTER);
     719        }
     720      }
     721      else
     722      {
     723        TComMvField zeroMvField;  //zero MV and invalid reference index
     724        pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(zeroMvField, uiAbsPartIdx);
     725        pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(zeroMvField, uiAbsPartIdx);
     726        pcCUDes->setPredictionMode(uiAbsPartIdx, MODE_INTRA);
     727      }
     728
     729      for(UInt i = 1; i < unitNum; i++ ) 
     730      {
     731        pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_0)->getMv(uiAbsPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiAbsPartIdx), uiAbsPartIdx + i);
     732        pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_1)->getMv(uiAbsPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiAbsPartIdx), uiAbsPartIdx + i);
     733        pcCUDes->setPredictionMode(uiAbsPartIdx+i, pcCUDes->getPredictionMode(uiAbsPartIdx))  ;
     734      }
     735    }
     736      memset( pcCUDes->getPartitionSize(), SIZE_2Nx2N, sizeof(char)*uiNumPartitions);
     737  }
     738}
     739#endif
     740
     741#endif
     742
     743#if AVC_SYNTAX
     744Void TComPic::readBLSyntax( fstream* filestream, UInt numBytes )
     745{
     746  if( !filestream->good() )
     747  {
     748    return;
     749  }
     750
     751  UInt   uiWidth      = this->getPicYuvRec()->getWidth() - this->getPicYuvRec()->getPicCropLeftOffset() - this->getPicYuvRec()->getPicCropRightOffset();
     752  UInt   uiHeight     = this->getPicYuvRec()->getHeight() - this->getPicYuvRec()->getPicCropTopOffset() - this->getPicYuvRec()->getPicCropBottomOffset();
     753  UInt64 uiPOC        = (UInt64)this->getPOC();
     754  UInt   uiPartWidth  = uiWidth / 4;
     755  UInt   uiPartHeight = uiHeight / 4;
     756
     757  UInt uiNumPartInWidth    = this->getNumPartInWidth();
     758  UInt uiNumPartInHeight   = this->getNumPartInHeight();
     759  UInt uiNumPartLCUInWidth = this->getFrameWidthInCU();
     760
     761  UInt64 uiPos = (UInt64)uiPOC * uiWidth * uiHeight * numBytes / 16;
     762   
     763  filestream->seekg( uiPos, ios_base::beg );
     764
     765  for( Int i = 0; i < uiPartHeight; i++ )
     766  {
     767    for( Int j = 0; j < uiPartWidth; j++ )
     768    {
     769      UInt uiX = ( j / uiNumPartInWidth );
     770      UInt uiY = ( i / uiNumPartInHeight );
     771
     772      UInt uiLCUAddr = uiY * uiNumPartLCUInWidth + uiX;
     773      UInt uiPartAddr = ( i - uiY * uiNumPartInHeight ) * uiNumPartInWidth + ( j - uiX * uiNumPartInWidth );
     774      uiPartAddr = g_auiRasterToZscan[uiPartAddr];
     775     
     776      TComDataCU* pcCU = this->getCU( uiLCUAddr );
     777     
     778      TComMv mv;
     779      Short temp;
     780
     781      // RefIdxL0
     782      Char refIdxL0 = -1;
     783      filestream->read( &refIdxL0, 1 );
     784      assert( refIdxL0 >= -1 );
     785      pcCU->getCUMvField( REF_PIC_LIST_0 )->setRefIdx( (Int)refIdxL0, uiPartAddr );
     786
     787      // RefIdxL1
     788      Char refIdxL1 = -1;
     789      filestream->read( &refIdxL1, 1 );
     790      assert( refIdxL1 >= -1 );
     791      pcCU->getCUMvField( REF_PIC_LIST_1 )->setRefIdx( (Int)refIdxL1, uiPartAddr );
     792
     793      // MV L0
     794      temp = 0;
     795      filestream->read( reinterpret_cast<char*>(&temp), 2 );
     796      mv.setHor( (Short)temp );
     797      temp = 0;
     798      filestream->read( reinterpret_cast<char*>(&temp), 2 );
     799      mv.setVer( (Short)temp );
     800      pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv( mv, uiPartAddr );
     801
     802      // MV L1
     803      temp = 0;
     804      filestream->read( reinterpret_cast<char*>(&temp), 2 );
     805      mv.setHor( (Short)temp );
     806      temp = 0;
     807      filestream->read( reinterpret_cast<char*>(&temp), 2 );
     808      mv.setVer( (Short)temp );
     809      pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv( mv, uiPartAddr );
     810
     811      // set dependent information
     812      pcCU->setPredictionMode( uiPartAddr, ( refIdxL0 == NOT_VALID && refIdxL1 == NOT_VALID ) ? MODE_INTRA : MODE_INTER );
     813      UInt uiInterDir = ( refIdxL0 != NOT_VALID ) + ( refIdxL1 != NOT_VALID && this->getSlice(0)->isInterB() ) * 2;
     814      assert( uiInterDir >= 0 && uiInterDir <= 3 );
     815      pcCU->setInterDir( uiPartAddr, uiInterDir );     
     816    }
     817  }
     818}
     819#endif
     820
     821#if SYNTAX_OUTPUT
     822Void TComPic::wrireBLSyntax( fstream* filestream, UInt numBytes )
     823{
     824  if( !filestream->good() )
     825  {
     826    return;
     827  }
     828
     829  UInt   uiWidth      = this->getPicYuvRec()->getWidth() - getSlice(0)->getSPS()->getPicCropLeftOffset() - getSlice(0)->getSPS()->getPicCropRightOffset();
     830  UInt   uiHeight     = this->getPicYuvRec()->getHeight() - getSlice(0)->getSPS()->getPicCropTopOffset() - getSlice(0)->getSPS()->getPicCropBottomOffset();
     831  UInt64 uiPOC        = (UInt64)this->getPOC();
     832  UInt   uiPartWidth  = uiWidth / 4;
     833  UInt   uiPartHeight = uiHeight / 4;
     834
     835  UInt uiNumPartInWidth    = this->getNumPartInWidth();
     836  UInt uiNumPartInHeight   = this->getNumPartInHeight();
     837  UInt uiNumPartLCUInWidth = this->getFrameWidthInCU();
     838
     839  filestream->seekg( uiPOC * uiWidth * uiHeight * numBytes / 16 );
     840   
     841  for( Int i = 0; i < uiPartHeight; i++ )
     842  {
     843    for( Int j = 0; j < uiPartWidth; j++ )
     844    {
     845      UInt uiX = ( j / uiNumPartInWidth );
     846      UInt uiY = ( i / uiNumPartInHeight );
     847
     848      UInt uiLCUAddr = uiY * uiNumPartLCUInWidth + uiX;
     849      UInt uiPartAddr = ( i - uiY * uiNumPartInHeight ) * uiNumPartInWidth + ( j - uiX * uiNumPartInWidth );
     850      uiPartAddr = g_auiRasterToZscan[uiPartAddr];
     851     
     852      TComDataCU* pcCU = this->getCU( uiLCUAddr );
     853     
     854      TComMv mv;
     855      Short temp;
     856      Char refIdxL0 = NOT_VALID, refIdxL1 = NOT_VALID;
     857
     858      // RefIdx
     859      if( !pcCU->isIntra( uiPartAddr ) )
     860      {
     861        refIdxL0 = (Char)pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr );
     862        refIdxL1 = (Char)pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr );
     863      }
     864      assert( refIdxL0 >= - 1 && refIdxL1 >= - 1 );
     865      filestream->put( refIdxL0 );
     866      filestream->put( refIdxL1 );
     867
     868      // MV L0
     869      mv.setZero();
     870      if( refIdxL0 >= 0 )
     871      {
     872        mv = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr );
     873      }
     874      temp = (Short)mv.getHor();
     875      filestream->write( reinterpret_cast<char*>(&temp), 2 );
     876      temp = (Short)mv.getVer();
     877      filestream->write( reinterpret_cast<char*>(&temp), 2 );
     878
     879      // MV L1
     880      mv.setZero();
     881      if( refIdxL1 >= 0 )
     882      {
     883        mv = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr );
     884      }
     885      temp = (Short)mv.getHor();
     886      filestream->write( reinterpret_cast<char*>(&temp), 2 );
     887      temp = (Short)mv.getVer();
     888      filestream->write( reinterpret_cast<char*>(&temp), 2 );
     889    }
     890  }
     891}
     892#endif
     893
    467894
    468895//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPic.h

    r51 r54  
    4545#include "TComBitStream.h"
    4646#include "SEI.h"
     47#if AVC_BASE || SYNTAX_OUTPUT
     48#include <fstream>
     49#endif
    4750
    4851//! \ingroup TLibCommon
     
    5861private:
    5962  UInt                  m_uiTLayer;               //  Temporal layer
     63#if SVC_EXTENSION
     64  UInt                  m_layerId;              //  Layer ID
     65#endif
    6066  Bool                  m_bUsedByCurr;            //  Used by current picture
    6167  Bool                  m_bIsLongTerm;            //  IS long term picture
     
    8591
    8692  SEIMessages  m_SEIs; ///< Any SEI messages that have been received.  If !NULL we own the object.
     93#if SVC_EXTENSION
     94  Bool                  m_bSpatialEnhLayer;       // whether current layer is a spatial enhancement layer,
     95  TComPicYuv*           m_pcFullPelBaseRec;    // upsampled base layer recontruction for difference domain inter prediction
     96#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
     97  Bool                  m_bIsILR;                 //  Is ILR picture
     98#endif
     99#endif
    87100
    88101public:
     
    90103  virtual ~TComPic();
    91104 
     105#if SVC_UPSAMPLING
    92106  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
    93                         Int *numReorderPics, Bool bIsVirtual = false );
    94                        
     107                        Int *numReorderPics, TComSPS* pcSps = NULL, Bool bIsVirtual = false );
     108#if REF_IDX_FRAMEWORK
     109  Void          createWithOutYuv( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, TComSPS* pcSps = NULL, Bool bIsVirtual = false ); 
     110  Void          setPicYuvRec(TComPicYuv *pPicYuv) { m_apcPicYuv[1]=pPicYuv; }
     111#endif
     112#else
     113  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
     114                        Int *numReorderPics, Bool bIsVirtual = false );                       
     115#endif
    95116  virtual Void  destroy();
    96117 
    97118  UInt          getTLayer()                { return m_uiTLayer;   }
    98119  Void          setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; }
     120#if SVC_EXTENSION
     121  Void          setLayerId (UInt layerId) { m_layerId = layerId; }
     122  UInt          getLayerId ()               { return m_layerId; }
     123  Bool          isSpatialEnhLayer()             { return m_bSpatialEnhLayer; }
     124  Void          setSpatialEnhLayerFlag (Bool b) { m_bSpatialEnhLayer = b; }
     125  Void          setFullPelBaseRec   ( TComPicYuv* p) { m_pcFullPelBaseRec = p; }
     126  TComPicYuv*   getFullPelBaseRec   ()  { return  m_pcFullPelBaseRec;  }
     127#endif
     128#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
     129  Void          setIsILR( Bool bIsILR)      {m_bIsILR = bIsILR;}
     130  Bool          getIsILR()                  {return m_bIsILR;}
     131#endif
     132
     133#if REF_IDX_MFM
     134  Void          copyUpsampledMvField  (  TComPic* pcPicBase );
     135#if !REUSE_BLKMAPPING
     136  Void          deriveUnitIdxBase     (  UInt uiUpsamplePelX, UInt uiUpsamplePelY, UInt ratio, UInt& uiBaseCUAddr, UInt& uiBaseAbsPartIdx );
     137#endif
     138#endif
    99139
    100140  Bool          getUsedByCurr()             { return m_bUsedByCurr; }
     
    177217  const SEIMessages& getSEIs() const { return m_SEIs; }
    178218
     219#if REF_IDX_FRAMEWORK
     220  Void  copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut);
     221#endif
     222#if AVC_SYNTAX
     223  Void readBLSyntax( fstream* filestream, UInt numBytes );
     224#endif
     225#if SYNTAX_OUTPUT
     226  Void wrireBLSyntax( fstream* filestream, UInt numBytes );
     227#endif
     228
    179229};// END CLASS DEFINITION TComPic
    180230
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPicSym.cpp

    r51 r54  
    147147  m_apcTComDataCU = NULL;
    148148
     149#if AVC_BASE || REF_IDX_FRAMEWORK
     150  if( m_apcTComTile )
     151  {
     152#endif
    149153  for(Int i = 0; i < (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1); i++ )
    150154  {
     
    152156  }
    153157  delete [] m_apcTComTile;
     158#if AVC_BASE || REF_IDX_FRAMEWORK
     159  }
     160#endif
    154161
    155162  m_apcTComTile = NULL;
     
    178185  {
    179186    m_apcTComSlice[m_uiNumAllocatedSlice-1]->copySliceInfo( m_apcTComSlice[m_uiNumAllocatedSlice-2] );
     187#if SET_SLICE_LAYER_ID
     188    m_apcTComSlice[m_uiNumAllocatedSlice-1]->initSlice( m_apcTComSlice[m_uiNumAllocatedSlice-1]->getLayerId() );
     189#else
    180190    m_apcTComSlice[m_uiNumAllocatedSlice-1]->initSlice();
     191#endif
    181192  }
    182193}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPicSym.h

    r51 r54  
    122122  TComDataCU*&  getCU( UInt uiCUAddr )  { return m_apcTComDataCU[uiCUAddr];     }
    123123 
     124#if AVC_SYNTAX
     125  UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
     126  UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
     127  UInt        getMaxDepth()             { return m_uhTotalDepth;               }
     128#endif
     129 
    124130  Void        setSlice(TComSlice* p, UInt i) { m_apcTComSlice[i] = p;           }
    125131  UInt        getNumAllocatedSlice()    { return m_uiNumAllocatedSlice;         }
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPicYuv.cpp

    r51 r54  
    6060  m_piPicOrgU       = NULL;
    6161  m_piPicOrgV       = NULL;
    62  
    6362  m_bIsBorderExtended = false;
    6463}
     
    6766{
    6867}
    69 
     68#if SVC_UPSAMPLING
     69Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
     70#else
    7071Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth )
     72#endif
    7173{
    7274  m_iPicWidth       = iPicWidth;
    7375  m_iPicHeight      = iPicHeight;
    7476 
     77#if SVC_UPSAMPLING
     78  if(pcSps != NULL)
     79  {
     80    m_conformanceWindow = pcSps->getConformanceWindow();
     81  }
     82#endif
     83
    7584  // --> After config finished!
    7685  m_iCuWidth        = uiMaxCUWidth;
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPicYuv.h

    r51 r54  
    4242#include "CommonDef.h"
    4343#include "TComRom.h"
    44 
     44#if SVC_UPSAMPLING
     45#include "TComSlice.h"
     46#endif
    4547//! \ingroup TLibCommon
    4648//! \{
     
    8688  Int   m_iChromaMarginY;
    8789 
     90#if SVC_UPSAMPLING
     91  Window  m_conformanceWindow;
     92#endif
     93
    8894  Bool  m_bIsBorderExtended;
    8995 
     
    98104  //  Memory management
    99105  // ------------------------------------------------------------------------------------------------
     106#if SVC_UPSAMPLING
     107  Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
     108#else
     109  Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
     110#endif 
    100111 
    101   Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
    102112  Void  destroy     ();
    103113 
     
    112122  Int   getHeight   ()     { return  m_iPicHeight;   }
    113123 
     124#if SVC_EXTENSION
     125  Void   setHeight   ( Int iPicHeight )     { m_iPicHeight = iPicHeight; }
     126#endif
     127
     128#if JCTVC_L0178
     129  Void   setWidth   ( Int iPicWidth )     { m_iPicWidth = iPicWidth; }
     130#endif
    114131  Int   getStride   ()     { return (m_iPicWidth     ) + (m_iLumaMarginX  <<1); }
    115132  Int   getCStride  ()     { return (m_iPicWidth >> 1) + (m_iChromaMarginX<<1); }
     
    140157  Pel*  getCrAddr   ( Int iCuAddr, Int uiAbsZorderIdx ) { return m_piPicOrgV + m_cuOffsetC[iCuAddr] + m_buOffsetC[g_auiZscanToRaster[uiAbsZorderIdx]]; }
    141158 
     159#if SVC_UPSAMPLING
     160  Window& getConformanceWindow()                           { return  m_conformanceWindow;             }
     161  Void    setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
     162#endif
     163
    142164  // ------------------------------------------------------------------------------------------------
    143165  //  Miscellaneous
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPrediction.cpp

    r51 r54  
    407407}
    408408
     409#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
     410Void TComPrediction::getBaseBlk( TComDataCU* pcCU, TComYuv* pcYuvPred, Int iPartAddr, Int iWidth, Int iHeight )
     411{
     412  pcCU->getBaseLumaBlk( iWidth, iHeight, iPartAddr, pcYuvPred->getLumaAddr( iPartAddr ), pcYuvPred->getStride() );
     413  pcCU->getBaseChromaBlk( iWidth >> 1, iHeight >> 1, iPartAddr, pcYuvPred->getCbAddr( iPartAddr ), pcYuvPred->getCStride(), 0 );
     414  pcCU->getBaseChromaBlk( iWidth >> 1, iHeight >> 1, iPartAddr, pcYuvPred->getCrAddr( iPartAddr ), pcYuvPred->getCStride(), 1 );
     415}
     416#endif
    409417
    410418Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
     
    758766  return;
    759767}
     768
     769#if SVC_UPSAMPLING
     770Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic)
     771{
     772  m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic);
     773}
     774#endif
    760775//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComPrediction.h

    r51 r54  
    4848#include "TComWeightPrediction.h"
    4949
     50#if SVC_UPSAMPLING
     51#include "TComDataCU.h"
     52#include "TComUpsampleFilter.h"
     53#endif
    5054//! \ingroup TLibCommon
    5155//! \{
     
    7074  TComInterpolationFilter m_if;
    7175 
     76#if SVC_UPSAMPLING
     77  TComUpsampleFilter      m_cUsf;
     78#endif
     79
    7280  Pel*   m_pLumaRecBuffer;       ///< array for downsampled reconstructed luma sample
    7381  Int    m_iLumaRecStride;       ///< stride of #m_pLumaRecBuffer array
     
    94102  Void    initTempBuff();
    95103 
     104#if INTRA_BL
     105  Void getBaseBlk ( TComDataCU* pcCU, TComYuv* pcYuvPred, Int iPartAddr, Int iWidth, Int iHeight );
     106#endif
    96107  // inter
    97108  Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 );
     
    110121  Int  getPredicBufHeight()       { return m_iYuvExtHeight; }
    111122
     123#if SVC_UPSAMPLING
     124  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
     125#endif
    112126};
    113127
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComSlice.cpp

    r51 r54  
    8181, m_bNoBackPredFlag               ( false )
    8282, m_uiTLayer                      ( 0 )
     83#if SVC_EXTENSION
     84, m_layerId                     ( 0 )
     85, m_pcBaseColPic                  ( NULL )
     86#endif
    8387, m_bTLayerSwitchingFlag          ( false )
    8488, m_sliceMode                   ( 0 )
     
    136140
    137141
     142#if SET_SLICE_LAYER_ID
     143Void TComSlice::initSlice( UInt layerId )
     144#else
    138145Void TComSlice::initSlice()
    139 {
     146#endif
     147{
     148#if SET_SLICE_LAYER_ID
     149  m_layerId = layerId;
     150#endif
    140151  m_aiNumRefIdx[0]      = 0;
    141152  m_aiNumRefIdx[1]      = 0;
     
    344355Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic )
    345356{
     357#if REF_IDX_FRAMEWORK
     358  if( m_eSliceType == I_SLICE || ( getSPS()->getLayerId() &&
     359      (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
     360      (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) ) )
     361#else
    346362  if (m_eSliceType == I_SLICE)
     363#endif
    347364  {
    348365    ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList));
     
    12611278, m_vuiParametersPresentFlag  (false)
    12621279, m_vuiParameters             ()
     1280#if SVC_EXTENSION
     1281, m_layerId(0)
     1282#endif
    12631283{
    12641284  for ( Int i = 0; i < MAX_TLAYER; i++ )
     
    19261946//! activate a PPS and depending on isIDR parameter also SPS and VPS
    19271947//! \returns true, if activation is successful
     1948#if SVC_EXTENSION
     1949Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIDR, UInt layerId)
     1950#else
    19281951Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIDR)
     1952#endif
    19291953{
    19301954  TComPPS *pps = m_ppsMap.getPS(ppsId);
     
    19321956  {
    19331957    Int spsId = pps->getSPSId();
     1958#if SVC_EXTENSION
     1959    if (!isIDR && (spsId != layerId ))
     1960#else
    19341961    if (!isIDR && (spsId != m_activeSPSId))
     1962#endif
    19351963    {
    19361964      printf("Warning: tried to activate PPS referring to a inactive SPS at non-IDR.");
     
    20012029}
    20022030#endif
     2031
     2032#if SVC_EXTENSION
     2033#if AVC_SYNTAX
     2034Void TComSlice::initBaseLayerRPL( TComSlice *pcSlice )
     2035{
     2036// Assumed that RPL of the base layer is same to the EL, otherwise this information should be also dumped and read from the metadata file
     2037  setPOC( pcSlice->getPOC() );
     2038  if( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA )
     2039  {
     2040    setSliceType( I_SLICE );
     2041  }
     2042  else
     2043  {
     2044    setSliceType( pcSlice->getSliceType() );
     2045  }
     2046
     2047  if( this->isIntra() )
     2048  {
     2049    return;
     2050  }
     2051
     2052  //initialize reference POC of BL
     2053  for( Int iRefPicList = 0; iRefPicList < 2; iRefPicList++ )
     2054  {
     2055    RefPicList eRefPicList = RefPicList( iRefPicList );
     2056
     2057    assert( pcSlice->getNumRefIdx( eRefPicList) > 0 );
     2058    setNumRefIdx( eRefPicList, pcSlice->getNumRefIdx( eRefPicList ) - 1 );
     2059    assert( getNumRefIdx( eRefPicList) <= MAX_NUM_REF);
     2060
     2061    for(Int refIdx = 0; refIdx < getNumRefIdx( eRefPicList ); refIdx++)
     2062    {
     2063      setRefPOC( pcSlice->getRefPic( eRefPicList, refIdx )->getPOC(), eRefPicList, refIdx );
     2064      setRefPic( pcSlice->getRefPic( eRefPicList, refIdx ), eRefPicList, refIdx );
     2065      /*
     2066      // should be set if the base layer has its own instance of the reference picture lists, currently EL RPL is reused.
     2067      getRefPic( eRefPicList, refIdx )->setLayerId( 0 );
     2068      getRefPic( eRefPicList, refIdx )->setIsLongTerm( pcSlice->getRefPic( eRefPicList, refIdx )->getIsLongTerm() );
     2069      getRefPic( eRefPicList, refIdx )->setIsUsedAsLongTerm( pcSlice->getRefPic( eRefPicList, refIdx )->getIsUsedAsLongTerm() );
     2070      */
     2071
     2072    }
     2073  } 
     2074  return;
     2075}
     2076#endif
     2077
     2078Void TComSlice::setBaseColPic(  TComList<TComPic*>& rcListPic, UInt layerID )
     2079
     2080  if (layerID == 0)
     2081  {
     2082    m_pcBaseColPic = NULL;
     2083    return;
     2084  }       
     2085  setBaseColPic(xGetRefPic(rcListPic, getPOC()));
     2086}
     2087#endif
     2088
     2089#if REF_IDX_FRAMEWORK
     2090Void TComSlice::addRefPicList( TComPic **pIlpPicList, Int iRefPicNum, Int iInsertOffset )
     2091{
     2092  if(getSPS()->getLayerId() && m_eSliceType != I_SLICE)
     2093  {
     2094#if REF_IDX_MFM
     2095    assert(iRefPicNum == 1);
     2096    if( getPOC() != 0 )
     2097    {
     2098      pIlpPicList[0]->copyUpsampledMvField(getBaseColPic());
     2099    }
     2100#endif
     2101    //add to list 0;
     2102    Int iOffset;
     2103    m_aiNumRefIdx[REF_PIC_LIST_0] += iInsertOffset;
     2104    iOffset = m_aiNumRefIdx[REF_PIC_LIST_0];
     2105    for (Int i=0; i<iRefPicNum; i++)
     2106    {
     2107      pIlpPicList[i]->setIsLongTerm(1);  //mark ilp as long-term reference
     2108      pIlpPicList[i]->setIsUsedAsLongTerm(1);  //mark ilp as long-term reference
     2109      m_apcRefPicList[REF_PIC_LIST_0][iOffset + i] = pIlpPicList[i];
     2110      m_aiNumRefIdx[REF_PIC_LIST_0]++;
     2111      //m_aiNumRefIdx[REF_PIC_LIST_C]++;
     2112    }
     2113    if(m_eSliceType == B_SLICE)
     2114    {
     2115      m_aiNumRefIdx[REF_PIC_LIST_1] += iInsertOffset;
     2116      iOffset = m_aiNumRefIdx[REF_PIC_LIST_1];
     2117      for (Int i=0; i<iRefPicNum; i++)
     2118      {
     2119        pIlpPicList[i]->setIsLongTerm(1);  //mark ilp as long-term reference
     2120        pIlpPicList[i]->setIsUsedAsLongTerm(1);  //mark ilp as long-term reference
     2121        m_apcRefPicList[REF_PIC_LIST_1][iOffset + i] = pIlpPicList[i];
     2122        m_aiNumRefIdx[REF_PIC_LIST_1]++;
     2123        //m_aiNumRefIdx[REF_PIC_LIST_C]++;
     2124      }
     2125    }
     2126  }
     2127}
     2128
     2129#if REF_IDX_MFM
     2130Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic *pcRefPicBL )
     2131{
     2132  //set reference picture POC of each ILP reference
     2133  Int thePoc = ilpPic[0]->getPOC();
     2134  assert(thePoc >= 0);
     2135  assert(thePoc == pcRefPicBL->getPOC());
     2136
     2137#if REUSE_MVSCALE || REUSE_BLKMAPPING
     2138  ilpPic[0]->getSlice(0)->setBaseColPic( pcRefPicBL );
     2139#endif
     2140
     2141  //initialize reference POC of ILP
     2142  for(Int refIdx = 0; refIdx < MAX_NUM_REF; refIdx++)
     2143  {
     2144    ilpPic[0]->getSlice(0)->setRefPOC(0, REF_PIC_LIST_0, refIdx);
     2145    ilpPic[0]->getSlice(0)->setRefPOC(0, REF_PIC_LIST_1, refIdx);
     2146
     2147    ilpPic[0]->getSlice(0)->setRefPic(NULL, REF_PIC_LIST_0, refIdx);
     2148    ilpPic[0]->getSlice(0)->setRefPic(NULL, REF_PIC_LIST_1, refIdx);
     2149  }
     2150
     2151  //set reference POC of ILP
     2152  ilpPic[0]->getSlice(0)->setNumRefIdx(REF_PIC_LIST_0, pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0));
     2153  assert(ilpPic[0]->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0) <= MAX_NUM_REF);
     2154  ilpPic[0]->getSlice(0)->setNumRefIdx(REF_PIC_LIST_1, pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1));
     2155  assert(ilpPic[0]->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1) <= MAX_NUM_REF);
     2156
     2157  for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0); refIdx++)
     2158  {
     2159    ilpPic[0]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(REF_PIC_LIST_0, refIdx), REF_PIC_LIST_0, refIdx);
     2160  }
     2161  for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1); refIdx++)
     2162  {
     2163    ilpPic[0]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(REF_PIC_LIST_1, refIdx), REF_PIC_LIST_1, refIdx);
     2164  }
     2165  for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0); refIdx++)
     2166  {
     2167    ilpPic[0]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(REF_PIC_LIST_0, refIdx), REF_PIC_LIST_0, refIdx);
     2168  }
     2169  for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1); refIdx++)
     2170  {
     2171    ilpPic[0]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(REF_PIC_LIST_1, refIdx), REF_PIC_LIST_1, refIdx);
     2172  }
     2173  return;
     2174}
     2175#endif
     2176
     2177
     2178#endif
    20032179//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComSlice.h

    r51 r54  
    5151class TComPic;
    5252class TComTrQuant;
     53
     54#if SVC_EXTENSION
     55class TComPicYuv;
     56#endif
    5357// ====================================================================================================================
    5458// Constants
     
    850854  static const Int   m_winUnitY[MAX_CHROMA_FORMAT_IDC+1];
    851855  TComPTL     m_pcPTL;
     856
     857#if SVC_EXTENSION
     858  UInt m_layerId;
     859#endif
     860#if REF_IDX_MFM
     861  Bool m_bMFMEnabledFlag;
     862#endif
    852863public:
    853864  TComSPS();
     
    976987
    977988  TComPTL* getPTL()     { return &m_pcPTL; }
     989
     990#if SVC_EXTENSION
     991  Void     setLayerId(UInt layerId) { m_layerId = layerId; }
     992  UInt     getLayerId() { return m_layerId; }
     993#endif
     994#if REF_IDX_MFM
     995  Void     setMFMEnabledFlag(Bool flag) {m_bMFMEnabledFlag = flag;}
     996  Bool     getMFMEnabledFlag()          {return m_bMFMEnabledFlag;}
     997#endif
    978998};
    979999
     
    12831303  Bool        m_bNoBackPredFlag;
    12841304  UInt        m_uiTLayer;
     1305#if SVC_EXTENSION
     1306  UInt        m_layerId;
     1307  TComPic*    m_pcBaseColPic;
     1308  TComPicYuv* m_pcFullPelBaseRec;
     1309#endif
    12851310  Bool        m_bTLayerSwitchingFlag;
    12861311
     
    13191344  TComSlice();
    13201345  virtual ~TComSlice();
     1346#if SET_SLICE_LAYER_ID
     1347  Void      initSlice       ( UInt layerId );
     1348#else
    13211349  Void      initSlice       ();
     1350#endif
    13221351
    13231352  Void      setVPS          ( TComVPS* pcVPS ) { m_pcVPS = pcVPS; }
     
    14171446  Void      setDepth            ( Int iDepth )                  { m_iDepth            = iDepth; }
    14181447 
     1448#if SVC_EXTENSION 
     1449  Void      setBaseColPic       ( TComPic* p)                   { m_pcBaseColPic = p; }
     1450  Void      setBaseColPic       ( TComList<TComPic*>& rcListPic , UInt layerID );
     1451  TComPic*  getBaseColPic       ()  { return m_pcBaseColPic; }
     1452
     1453  Void      setLayerId (UInt layerId) { m_layerId = layerId; }
     1454  UInt      getLayerId ()               { return m_layerId; }
     1455
     1456  Void        setFullPelBaseRec   ( TComPicYuv* p) { m_pcFullPelBaseRec = p; }
     1457  TComPicYuv* getFullPelBaseRec   ()  { return  m_pcFullPelBaseRec;  }
     1458
     1459#if AVC_SYNTAX
     1460  Void      initBaseLayerRPL( TComSlice *pcSlice );
     1461#endif
     1462#endif
     1463
     1464#if REF_IDX_MFM
     1465  Void      setRefPOCListILP(TComPic** ilpPic, TComPic *pcRefPicBL);
     1466#endif
     1467
    14191468  Void      setRefPicList       ( TComList<TComPic*>& rcListPic );
    14201469  Void      setRefPOCList       ();
     
    15361585  Void      setEnableTMVPFlag     ( Bool   b )    { m_enableTMVPFlag = b; }
    15371586  Bool      getEnableTMVPFlag     ()              { return m_enableTMVPFlag;}
    1538 
     1587#if REF_IDX_FRAMEWORK
     1588  Void      addRefPicList( TComPic **pIlpPicList, Int iRefPicNum, Int iInsertOffset=0 );
     1589#endif
    15391590protected:
    15401591  TComPic*  xGetRefPic  (TComList<TComPic*>& rcListPic,
     
    16251676  //! activate a PPS and depending on isIDR parameter also SPS and VPS
    16261677  //! \returns true, if activation is successful
     1678#if SVC_EXTENSION
     1679  Bool activatePPS(Int ppsId, Bool isIDR, UInt layerId);
     1680#else
    16271681  Bool activatePPS(Int ppsId, Bool isIDR);
     1682#endif
    16281683
    16291684  TComVPS* getActiveVPS(){ return m_vpsMap.getPS(m_activeVPSId); };
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComTrQuant.cpp

    r51 r54  
    12361236    uiMode = pcCU->getLumaIntraDir( uiAbsPartIdx );
    12371237  }
     1238#if INTRA_BL_DST4x4
     1239  else if(eTType == TEXT_LUMA && pcCU->isIntraBL(uiAbsPartIdx) )
     1240  {
     1241    uiMode = DC_IDX; //Using DST
     1242  }
     1243#endif
    12381244  else
    12391245  {
     
    13091315    Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTxt];
    13101316    assert(scalingListType < 6);
     1317#if NO_RESIDUAL_FLAG_FOR_BLPRED
     1318    if(pcCU->isIntraBL(uiAbsPartIdx) && eTxt == TEXT_LUMA)
     1319    {
     1320      invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, DC_IDX, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
     1321    }
     1322    else
     1323    {
     1324      invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, REG_DCT, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
     1325    }
     1326#else
    13111327    invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, REG_DCT, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
     1328#endif
    13121329  }
    13131330  else
     
    18031820  Int     ui16CtxCbf          = 0;
    18041821  Int     iBestLastIdxP1      = 0;
     1822#if NO_RESIDUAL_FLAG_FOR_BLPRED
     1823  if( (!pcCU->isIntra( uiAbsPartIdx ) || pcCU->isIntraBL( uiAbsPartIdx )) && eTType == TEXT_LUMA && pcCU->getTransformIdx( uiAbsPartIdx ) == 0 )
     1824#else
    18051825  if( !pcCU->isIntra( uiAbsPartIdx ) && eTType == TEXT_LUMA && pcCU->getTransformIdx( uiAbsPartIdx ) == 0 )
     1826#endif
    18061827  {
    18071828    ui16CtxCbf   = 0;
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComYuv.cpp

    r51 r54  
    184184}
    185185
     186#if NO_RESIDUAL_FLAG_FOR_BLPRED
     187Void TComYuv::copyFromPicLuma  ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiWidth, UInt uiHeight )
     188{
     189  Int  y;
     190
     191  Pel* pDst     = getLumaAddr(uiAbsZorderIdx);
     192  Pel* pSrc     = pcPicYuvSrc->getLumaAddr ( iCuAddr, uiZorderIdxInCU + uiAbsZorderIdx );
     193
     194  UInt  iDstStride  = getStride();
     195  UInt  iSrcStride  = pcPicYuvSrc->getStride();
     196  for ( y = uiHeight; y != 0; y-- )
     197  {
     198    ::memcpy( pDst, pSrc, sizeof(Pel)*uiWidth);
     199    pDst += iDstStride;
     200    pSrc += iSrcStride;
     201  }
     202}
     203
     204Void TComYuv::copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId  )
     205{
     206  Int  y;
     207
     208  if (!uiChromaId)
     209  {
     210    Pel* pDstU      = getCbAddr(uiAbsZorderIdx);
     211    Pel* pSrcU      = pcPicYuvSrc->getCbAddr( iCuAddr, uiZorderIdxInCU + uiAbsZorderIdx );
     212
     213    UInt  iDstStride = getCStride();
     214    UInt  iSrcStride = pcPicYuvSrc->getCStride();
     215    for ( y = uiCHeight; y != 0; y-- )
     216    {
     217      ::memcpy( pDstU, pSrcU, sizeof(Pel)*(uiCWidth) );
     218      pSrcU += iSrcStride;
     219      pDstU += iDstStride;
     220    }
     221  }
     222  else
     223  {
     224    Pel* pDstV      = getCrAddr(uiAbsZorderIdx);
     225    Pel* pSrcV      = pcPicYuvSrc->getCrAddr( iCuAddr, uiZorderIdxInCU + uiAbsZorderIdx );
     226
     227    UInt  iDstStride = getCStride();
     228    UInt  iSrcStride = pcPicYuvSrc->getCStride();
     229    for ( y = uiCHeight; y != 0; y-- )
     230    {
     231      ::memcpy( pDstV, pSrcV, sizeof(Pel)*(uiCWidth) );
     232      pSrcV += iSrcStride;
     233      pDstV += iDstStride;
     234    }
     235  }
     236}
     237#endif
     238
    186239Void TComYuv::copyToPartYuv( TComYuv* pcYuvDst, UInt uiDstPartIdx )
    187240{
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TComYuv.h

    r51 r54  
    115115  Void    copyFromPicLuma      ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
    116116  Void    copyFromPicChroma    ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
     117#if NO_RESIDUAL_FLAG_FOR_BLPRED
     118  Void    copyFromPicLuma  ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiWidth, UInt uiHeight );
     119  Void    copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId  );
     120#endif
    117121 
    118122  //  Copy Small YUV buffer to the part of other Big YUV buffer
  • branches/HM-10.0-dev-SHM/source/Lib/TLibCommon/TypeDef.h

    r51 r54  
    3838#ifndef _TYPEDEF__
    3939#define _TYPEDEF__
     40
     41#define SVC_EXTENSION                    1
     42
     43#define SYNTAX_BYTES                     10      ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
     44
     45#if SVC_EXTENSION
     46#define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
     47
     48#define SVC_COL_BLK                      1      ///< get co-located block
     49#define SVC_UPSAMPLING                   1      ///< upsampling filters
     50#define PHASE_DERIVATION_IN_INTEGER      1      ///< upsampling filters implementation using only integer arithmetic
     51#define SET_SLICE_LAYER_ID               1      ///< set layerId to the slice
     52#define BUGFIX_925                       1      ///< bug fix ticket #925
     53#define ENCODER_BUGFIX                   1      ///< L0167: encoder bug fix for inter mode
     54#define CHROMA_UPSAMPLING                1      ///< L0335: Chroma upsampling with 5 bits coefficients
     55
     56#define MV_SCALING_FIX                   1      ///< fixing the base layer MV scaling
     57#define MV_SCALING_POS_FIX               1      ///< use center pixels to get co-located base layer block
     58#define MFM_CLIPPING_FIX                 1      ///< set the right picture size for the clipping
     59
     60#define AVC_BASE                         0      ///< YUV BL reading for AVC base SVC
     61#define REF_IDX_FRAMEWORK                0      ///< inter-layer reference framework
     62
     63#if AVC_BASE
     64#define AVC_SYNTAX                       1      ///< Syntax reading for AVC base
     65#endif
     66
     67#if REF_IDX_FRAMEWORK
     68#define REF_IDX_ME_AROUND_ZEROMV         0      ///< added ME around zero MV for inter-layer reference picture
     69#define REF_IDX_ME_ZEROMV                1      ///< L0051: use zero motion for inter-layer reference picture (without fractional ME)
     70#define ENCODER_FAST_MODE                1      ///< L0174: enable encoder fast mode. TestMethod 1 is enabled by setting to 1 and TestMethod 2 is enable by setting to 2. By default it is set to 1.
     71#if !AVC_BASE || AVC_SYNTAX
     72#define REF_IDX_MFM                      1      ///< L0336: motion vector mapping of inter-layer reference picture
     73#endif
     74
     75#if REF_IDX_MFM
     76#define REUSE_MVSCALE                    1      ///< using the base layer MV scaling function
     77#define REUSE_BLKMAPPING                 1      ///< using the base layer get co-located block function
     78#endif
     79
     80#else
     81#define INTRA_BL                         0      ///< inter-layer texture prediction
     82
     83#if INTRA_BL
     84#define INTRA_BL_DST4x4                  1      ///< L0067/L0204: DST4x4 for Intra BL
     85#define NO_RESIDUAL_FLAG_FOR_BLPRED      1      ///< L0437: Root cbf for Intra_BL
     86
     87// Hooks
     88#if !AVC_BASE || AVC_SYNTAX
     89#define SVC_MVP                          1      ///< motion hook for merge mode as an example
     90#if !AVC_SYNTAX
     91#define SVC_BL_CAND_INTRA                0      ///< Intra Base Mode Prediction hook as an example
     92#endif
     93#endif
     94
     95#if SVC_UPSAMPLING
     96#define JCTVC_L0178                      1      ///< implementation of JCTVC-L0178 (code only supports right and bottom croppping offsets)
     97#endif
     98
     99#endif
     100#endif
     101#else
     102#define SYNTAX_OUTPUT                    0
     103#endif
    40104
    41105//! \ingroup TLibCommon
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/NALread.cpp

    r51 r54  
    100100  nalu.m_nalUnitType = (NalUnitType) bs.read(6);  // nal_unit_type
    101101  nalu.m_reservedZero6Bits = bs.read(6);       // nuh_reserved_zero_6bits
     102#if SVC_EXTENSION
     103  nalu.m_layerId = nalu.m_reservedZero6Bits;
     104#else
    102105  assert(nalu.m_reservedZero6Bits == 0);
     106#endif
    103107  nalu.m_temporalId = bs.read(3) - 1;             // nuh_temporal_id_plus1
    104108
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r51 r54  
    697697  }
    698698  READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" );            pcSPS->setTMVPFlagsPresent(uiCode);
    699 
     699#if REF_IDX_MFM
     700  if(pcSPS->getLayerId() > 0)
     701  {
     702    READ_FLAG( uiCode, "sps_enh_mfm_enable_flag" );
     703    pcSPS->setMFMEnabledFlag( uiCode ? true : false );
     704    assert(pcSPS->getMFMEnabledFlag());
     705  }
     706#endif
    700707  READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" );  pcSPS->setUseStrongIntraSmoothing(uiCode);
    701708
     
    19271934}
    19281935
     1936#if INTRA_BL
     1937Void TDecCavlc::parseIntraBLFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     1938{
     1939  assert(0);
     1940}
     1941#endif
     1942
    19291943//! \}
    19301944
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecCAVLC.h

    r51 r54  
    120120  Void updateContextTables  ( SliceType /*eSliceType*/, Int /*iQp*/ ) { return; }
    121121
     122#if INTRA_BL
     123  Void parseIntraBLFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
     124#endif
     125
    122126  Void xParsePredWeightTable ( TComSlice* pcSlice );
    123127  Void  parseScalingList               ( TComScalingList* scalingList );
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecCu.cpp

    r51 r54  
    3737
    3838#include "TDecCu.h"
     39#if SVC_EXTENSION
     40#include "TDecTop.h"
     41#endif
     42
    3943
    4044//! \ingroup TLibDecoder
     
    5660}
    5761
     62#if SVC_EXTENSION
     63Void TDecCu::init(TDecTop** ppcDecTop, TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction, UInt layerId)
     64{
     65  m_pcEntropyDecoder  = pcEntropyDecoder;
     66  m_pcTrQuant         = pcTrQuant;
     67  m_pcPrediction      = pcPrediction;
     68  m_ppcTDecTop = ppcDecTop;
     69  m_layerId = layerId;
     70
     71  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
     72  {
     73    m_ppcCU     [ui]->setLayerId(layerId);
     74  }
     75}
     76#else
    5877Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction)
    5978{
     
    6281  m_pcPrediction      = pcPrediction;
    6382}
     83#endif
    6484
    6585/**
     
    128148
    129149  // start from the top level CU
     150#if SVC_EXTENSION
     151  pcCU->setLayerId(m_layerId);
     152#endif
    130153  xDecodeCU( pcCU, 0, 0, ruiIsLast);
    131154}
     
    311334    return;
    312335  }
     336#if INTRA_BL
     337  m_pcEntropyDecoder->decodeIntraBLFlag( pcCU, uiAbsPartIdx, 0, uiDepth );
     338  if ( pcCU->isIntraBL( uiAbsPartIdx ) )
     339  {
     340    pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
     341  }
     342  else
     343  {
     344#endif
    313345
    314346  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
     
    325357    }
    326358  }
     359#if INTRA_BL
     360  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
     361  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
     362  }
     363#endif
    327364
    328365  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
    329366  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
    330367 
     368#if !INTRA_BL
    331369  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
    332370  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
     371#endif
    333372 
    334373  // Coefficient decoding
     
    401440      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
    402441      break;
     442#if INTRA_BL
     443    case MODE_INTRA_BL:
     444#if NO_RESIDUAL_FLAG_FOR_BLPRED
     445      xReconIntraBL( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
     446#else
     447      xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
     448#endif
     449      break;
     450#endif
    403451    default:
    404452      assert(0);
     
    468516 
    469517  //===== get prediction signal =====
     518#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
     519  if(pcCU->isIntraBL ( uiAbsPartIdx ) )
     520  {
     521    pcCU->getBaseLumaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride );
     522  }
     523  else
     524#endif
    470525  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    471526 
     
    552607 
    553608  //===== get prediction signal =====
     609#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
     610  if(pcCU->isIntraBL ( uiAbsPartIdx ) )
     611  {
     612    pcCU->getBaseChromaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride, uiChromaId );
     613  }
     614  else
     615#endif
    554616  {
    555617    if( uiChromaPredMode == DM_CHROMA_IDX )
     
    869931}
    870932
     933#if NO_RESIDUAL_FLAG_FOR_BLPRED
     934Void
     935TDecCu::xReconIntraBL( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     936{
     937  m_ppcYuvReco[uiDepth]->copyFromPicLuma  ( pcCU->getSlice()->getFullPelBaseRec(),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, pcCU->getWidth(0), pcCU->getHeight(0));
     938  m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 0);
     939  m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 1);
     940
     941  // inter recon
     942  xDecodeInterTexture( pcCU, 0, uiDepth );
     943
     944  // clip for only non-zero cbp case
     945  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
     946  {
     947    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
     948  }
     949  else
     950  {
     951    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
     952  }
     953}
     954#endif
     955
    871956//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecCu.h

    r51 r54  
    4949//! \ingroup TLibDecoder
    5050//! \{
     51#if SVC_EXTENSION
     52class TDecTop;
     53#endif
    5154
    5255// ====================================================================================================================
     
    6972
    7073  Bool                m_bDecodeDQP;
     74#if SVC_EXTENSION
     75  TDecTop**           m_ppcTDecTop;
     76  UInt                m_layerId;   
     77#endif
     78 
     79#if INTRA_BL
     80  TComPicYuv*         m_pcPicYuvRecBase;       ///< reconstructed base layer
     81#endif
    7182 
    7283public:
     
    7586 
    7687  /// initialize access channels
     88#if SVC_EXTENSION
     89  Void  init                    ( TDecTop** ppcDecTop, TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction, UInt layerId );
     90#else
    7791  Void  init                    ( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction );
     92#endif
    7893 
    7994  /// create internal buffers
     
    89104  Void  decompressCU            ( TComDataCU* pcCU );
    90105 
     106#if SVC_EXTENSION
     107  TDecTop*   getLayerDec        ( UInt LayerId )  { return m_ppcTDecTop[LayerId]; }
     108#if INTRA_BL
     109  Void  setBaseRecPic           ( TComPicYuv* p ) { m_pcPicYuvRecBase = p; }
     110#endif
     111#endif
    91112protected:
    92113 
     
    101122  Void  xIntraRecLumaBlk        ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv );
    102123  Void  xIntraRecChromaBlk      ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, UInt uiChromaId );
     124#if NO_RESIDUAL_FLAG_FOR_BLPRED
     125  Void  xReconIntraBL           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     126#endif
    103127 
    104128  Void  xReconPCM               ( TComDataCU* pcCU, UInt uiDepth );
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecEntropy.cpp

    r51 r54  
    5858}
    5959
     60#if INTRA_BL
     61Void TDecEntropy::decodeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     62{
     63  m_pcEntropyDecoderIf->parseIntraBLFlag( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth );
     64}
     65#endif
     66
    6067/** decode merge flag
    6168 * \param pcSubCU
     
    104111Void TDecEntropy::decodePredInfo    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
    105112{
     113#if INTRA_BL
     114  if( pcCU->isIntraBL( uiAbsPartIdx ) )                                 // Do nothing for Intra BL mode.
     115  {
     116    return;
     117  }
     118#endif
    106119  if( pcCU->isIntra( uiAbsPartIdx ) )                                 // If it is Intra mode, encode intra prediction mode.
    107120  {
     
    175188      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
    176189      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
     190#if REF_IDX_FRAMEWORK  // HM bug fix
     191      if(uiPartIdx)
     192      {
     193        for(UInt ui=0; ui<uiMergeIndex+1; ui++)
     194        {
     195          cMvFieldNeighbours[(ui<<1)].setMvField(TComMv(), NOT_VALID);
     196          cMvFieldNeighbours[(ui<<1)+1].setMvField(TComMv(), NOT_VALID);
     197        }
     198      }
     199#endif
    177200      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
    178201      {
     
    437460   
    438461    pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
     462#if INTRA_BL
     463#if NO_RESIDUAL_FLAG_FOR_BLPRED
     464    if( ( !pcCU->isIntra(uiAbsPartIdx) || pcCU->isIntraBL(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
     465#else
     466    if( ( !pcCU->isIntra(uiAbsPartIdx) ) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
     467#endif
     468#else
    439469    if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
     470#endif
    440471    {
    441472      pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth );
     
    535566  UInt uiChromaOffset = uiLumaOffset>>2;
    536567 
     568#if NO_RESIDUAL_FLAG_FOR_BLPRED
     569  if( pcCU->isIntra(uiAbsPartIdx) && !pcCU->isIntraBL(uiAbsPartIdx) )
     570#else
    537571  if( pcCU->isIntra(uiAbsPartIdx) )
     572#endif
    538573  {
    539574  }
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecEntropy.h

    r51 r54  
    102102  virtual Void parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0;
    103103  virtual Void parseTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType) = 0;
     104
     105#if INTRA_BL
     106  virtual Void parseIntraBLFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) = 0;
     107#endif
     108
    104109  virtual Void updateContextTables( SliceType eSliceType, Int iQp ) = 0;
    105110 
     
    157162  Void updateContextTables    ( SliceType eSliceType, Int iQp ) { m_pcEntropyDecoderIf->updateContextTables( eSliceType, iQp ); }
    158163 
     164#if INTRA_BL
     165  Void decodeIntraBLFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
     166#endif
    159167 
    160168private:
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecGop.cpp

    r51 r54  
    4343#include "libmd5/MD5.h"
    4444#include "TLibCommon/SEI.h"
     45#if SVC_EXTENSION
     46#include "TDecTop.h"
     47#endif
    4548
    4649#include <time.h>
     
    6770}
    6871
     72#if SVC_EXTENSION
     73Void TDecGop::create(UInt layerId)
     74{
     75  m_layerId = layerId;
     76}
     77#else
    6978Void TDecGop::create()
    7079{
    7180 
    7281}
    73 
     82#endif
    7483
    7584Void TDecGop::destroy()
    7685{
    7786}
    78 
     87#if SVC_EXTENSION
     88Void TDecGop::init(TDecTop**               ppcDecTop,
     89                   TDecEntropy*            pcEntropyDecoder,
     90#else
    7991Void TDecGop::init( TDecEntropy*            pcEntropyDecoder,
     92#endif
    8093                   TDecSbac*               pcSbacDecoder,
    8194                   TDecBinCABAC*           pcBinCABAC,
     
    93106  m_pcLoopFilter          = pcLoopFilter;
    94107  m_pcSAO  = pcSAO;
     108#if SVC_EXTENSION   
     109  m_ppcTDecTop            = ppcDecTop;
     110#endif
    95111}
    96112
     
    210226
    211227  //-- For time output for each slice
     228#if SVC_EXTENSION
     229  printf("\nPOC %4d LId: %1d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(),
     230                                                    rpcPic->getLayerId(),
     231                                                    pcSlice->getTLayer(),
     232                                                    c,
     233                                                    pcSlice->getSliceQp() );
     234#else
    212235  printf("\nPOC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(),
    213236                                                    pcSlice->getTLayer(),
    214237                                                    c,
    215238                                                    pcSlice->getSliceQp() );
    216 
     239#endif
    217240  m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
    218241  printf ("[DT %6.3f] ", m_dDecTime );
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecGop.h

    r51 r54  
    8787  std::vector<Bool> m_LFCrossSliceBoundaryFlag;
    8888
     89#if SVC_EXTENSION
     90  UInt                  m_layerId;
     91  TDecTop**             m_ppcTDecTop;
     92#endif
    8993public:
    9094  TDecGop();
    9195  virtual ~TDecGop();
    9296 
     97#if SVC_EXTENSION
     98Void  init      ( TDecTop**               ppcDecTop,
     99                  TDecEntropy*            pcEntropyDecoder,
     100#else
    93101  Void  init    ( TDecEntropy*            pcEntropyDecoder,
     102#endif
    94103                 TDecSbac*               pcSbacDecoder,
    95104                 TDecBinCABAC*           pcBinCABAC,
     
    99108                 TComSampleAdaptiveOffset* pcSAO
    100109                 );
     110#if SVC_EXTENSION
     111  Void  create  (UInt layerId);
     112#else
    101113  Void  create  ();
     114#endif
    102115  Void  destroy ();
    103116  Void  decompressSlice(TComInputBitstream* pcBitstream, TComPic*& rpcPic );
     
    105118
    106119  void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; }
     120#if SVC_EXTENSION
     121  TDecTop*   getLayerDec(UInt LayerId)  { return m_ppcTDecTop[LayerId]; }
     122#endif
    107123
    108124};
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecSbac.cpp

    r51 r54  
    7777, m_cTransformSkipSCModel     ( 1,             2,               NUM_TRANSFORMSKIP_FLAG_CTX    , m_contextModels + m_numContextModels, m_numContextModels)
    7878, m_CUTransquantBypassFlagSCModel( 1,          1,               NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)
     79#if INTRA_BL
     80, m_cIntraBLPredFlagSCModel   (1,              1,               NUM_INTRA_BL_PRED_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
     81#endif
    7982{
    8083  assert( m_numContextModels <= MAX_NUM_CTX_MOD );
     
    135138
    136139  m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
     140#if INTRA_BL
     141  m_cIntraBLPredFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
     142#endif
    137143  m_cTransformSkipSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
    138144  m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
     
    179185  m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
    180186  m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
     187#if INTRA_BL
     188  m_cIntraBLPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
     189#endif
    181190  m_cTransformSkipSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
    182191  m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
     
    431440}
    432441
     442#if INTRA_BL
     443Void TDecSbac::parseIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     444{
     445  if( pcCU->getLayerId() == 0 )
     446  {
     447    return;
     448  }
     449
     450  UInt uiSymbol = 0;
     451
     452  UInt uiCtxIntraBL = pcCU->getCtxIntraBLFlag( uiAbsPartIdx ) ;
     453  m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraBLPredFlagSCModel.get( 0, 0, uiCtxIntraBL ));
     454  DTRACE_CABAC_VL( g_nSymbolCounter++ );
     455  DTRACE_CABAC_T( "\tIntrBLFlag" );
     456  DTRACE_CABAC_T( "\tuiSymbol: ");
     457  DTRACE_CABAC_V( uiSymbol );
     458  DTRACE_CABAC_T( "\n");
     459
     460  if ( uiSymbol )
     461  {
     462    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
     463    pcCU->setPredModeSubParts( MODE_INTRA_BL, uiAbsPartIdx, uiDepth );
     464    pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth );
     465    pcCU->setLumaIntraDirSubParts ( DC_IDX, uiAbsPartIdx, uiDepth );   
     466  }
     467}
     468#endif
     469
    433470/** parse merge flag
    434471 * \param pcCU
     
    521558  PartSize eMode;
    522559 
     560#if INTRA_BL
     561  if ( pcCU->isIntraBL( uiAbsPartIdx ) )
     562  {
     563    assert( 0 );
     564  }
     565#endif
    523566  if ( pcCU->isIntra( uiAbsPartIdx ) )
    524567  {
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecSbac.h

    r51 r54  
    131131  Void  parseScalingList ( TComScalingList* /*scalingList*/ ) {}
    132132
     133#if INTRA_BL
     134  Void parseIntraBLFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
     135#endif
    133136private:
    134137  UInt m_uiLastDQpNonZero;
     
    167170  ContextModel3DBuffer m_cTransformSkipSCModel;
    168171  ContextModel3DBuffer m_CUTransquantBypassFlagSCModel;
     172#if INTRA_BL
     173  ContextModel3DBuffer m_cIntraBLPredFlagSCModel;
     174#endif
    169175};
    170176
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecSlice.cpp

    r51 r54  
    100100}
    101101
    102 Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder)
     102#if SVC_EXTENSION
     103Void TDecSlice::init(TDecTop** ppcDecTop,TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder)
    103104{
    104105  m_pcEntropyDecoder  = pcEntropyDecoder;
    105106  m_pcCuDecoder       = pcCuDecoder;
    106 }
     107  m_ppcTDecTop        = ppcDecTop;
     108}
     109#else
     110Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder)
     111{
     112  m_pcEntropyDecoder  = pcEntropyDecoder;
     113  m_pcCuDecoder       = pcCuDecoder;
     114}
     115#endif
    107116
    108117Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders)
     
    184193  UInt uiTileLCUX;
    185194  Int iNumSubstreamsPerTile = 1; // if independent.
     195#if INTRA_BL
     196  m_pcCuDecoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec() : NULL);
     197#endif
    186198  Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag();
    187199  uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr();
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecSlice.h

    r51 r54  
    7272  TDecBinCABAC*   m_pcBufferLowLatBinCABACs;
    7373  std::vector<TDecSbac*> CTXMem;
     74#if SVC_EXTENSION
     75  TDecTop**       m_ppcTDecTop;
     76#endif
    7477 
    7578public:
     
    7780  virtual ~TDecSlice();
    7881 
     82#if SVC_EXTENSION 
     83  Void  init              ( TDecTop** ppcDecTop, TDecEntropy* pcEntropyDecoder, TDecCu* pcMbDecoder );
     84#else
    7985  Void  init              ( TDecEntropy* pcEntropyDecoder, TDecCu* pcMbDecoder );
     86#endif
    8087  Void  create            ();
    8188  Void  destroy           ();
     
    8491  Void      initCtxMem(  UInt i );
    8592  Void      setCtxMem( TDecSbac* sb, Int b )   { CTXMem[b] = sb; }
     93#if SVC_EXTENSION
     94  TDecTop*  getLayerDec   ( UInt LayerId )  { return m_ppcTDecTop[LayerId]; } 
     95#endif
    8696};
    8797
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecTop.cpp

    r51 r54  
    3939#include "TDecTop.h"
    4040
     41#if SVC_EXTENSION
     42ParameterSetManagerDecoder TDecTop::m_parameterSetManagerDecoder;  // storage for parameter sets
     43UInt  TDecTop::m_prevPOC = MAX_UINT;
     44UInt  TDecTop::m_uiPrevLayerId = MAX_UINT;
     45Bool  TDecTop::m_bFirstSliceInSequence = true;
     46#endif
     47
    4148//! \ingroup TLibDecoder
    4249//! \{
     
    5461  m_prevRAPisBLA = false;
    5562  m_pocRandomAccess = MAX_INT;         
     63#if !SVC_EXTENSION
    5664  m_prevPOC                = MAX_INT;
     65#endif
    5766  m_bFirstSliceInPicture    = true;
     67#if !SVC_EXTENSION
    5868  m_bFirstSliceInSequence   = true;
     69#endif
     70#if SVC_EXTENSION
     71  m_layerId = 0;
     72#if AVC_BASE
     73  m_pBLReconFile = NULL;
     74#endif
     75#endif
     76#if REF_IDX_FRAMEWORK
     77  memset(m_cIlpPic, 0, sizeof(m_cIlpPic));
     78#endif
     79#if AVC_SYNTAX || SYNTAX_OUTPUT
     80  m_pBLSyntaxFile = NULL;
     81#endif
     82
    5983}
    6084
     
    6892Void TDecTop::create()
    6993{
     94#if SVC_EXTENSION
     95  m_cGopDecoder.create( m_layerId );
     96#else
    7097  m_cGopDecoder.create();
     98#endif
    7199  m_apcSlicePilot = new TComSlice;
    72100  m_uiSliceIdx = 0;
     
    81109 
    82110  m_cSliceDecoder.destroy();
     111#if REF_IDX_FRAMEWORK
     112  for(Int i=0; i<MAX_NUM_REF; i++)
     113  {
     114    if(m_cIlpPic[i])
     115    {
     116      //m_cIlpPic[i]->setPicYuvRec(NULL);
     117      m_cIlpPic[i]->destroy();
     118      delete m_cIlpPic[i];
     119      m_cIlpPic[i] = NULL;
     120    }
     121  }   
     122#endif
    83123}
    84124
    85125Void TDecTop::init()
    86126{
     127#if !SVC_EXTENSION
    87128  // initialize ROM
    88129  initROM();
     130#endif
     131#if SVC_EXTENSION
     132  m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
     133  m_cSliceDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cCuDecoder );
     134#else
    89135  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
    90136  m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder );
     137#endif
    91138  m_cEntropyDecoder.init(&m_cPrediction);
    92139}
     140
     141#if REF_IDX_FRAMEWORK
     142Void TDecTop::xInitILRP(TComSPS *pcSPS)
     143{
     144  if(m_layerId>0)
     145  {
     146    if (m_cIlpPic[0] == NULL)
     147    {
     148      for (Int j=0; j<1/*MAX_NUM_REF*/; j++)
     149      {
     150        m_cIlpPic[j] = new  TComPic;
     151        //m_cIlpPic[j]->createWithOutYuv(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, &m_cSPS, true);
     152#if SVC_UPSAMPLING
     153        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, pcSPS, true);
     154#else
     155        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
     156#endif
     157#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || REF_IDX_MFM
     158        m_cIlpPic[j]->setIsILR(true);
     159#endif
     160        for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++)
     161        {
     162          m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i);
     163        }
     164      }
     165    }
     166  }
     167}
     168
     169Void TDecTop::setILRPic(TComPic *pcPic)
     170{
     171  if(m_cIlpPic[0])
     172  {
     173    //m_cIlpPic[0]->setPicYuvRec(pcPic->getFullPelBaseRec());
     174    m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec());
     175    m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC());
     176    m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false);
     177    m_cIlpPic[0]->getPicYuvRec()->extendPicBorder();
     178  }
     179}
     180#endif
    93181
    94182Void TDecTop::deletePicBuffer ( )
     
    100188  {
    101189    TComPic* pcPic = *(iterPic++);
     190#if SVC_EXTENSION
     191    if( pcPic )
     192    {
     193      pcPic->destroy();
     194
     195      delete pcPic;
     196      pcPic = NULL;
     197    }
     198#else
    102199    pcPic->destroy();
    103200   
    104201    delete pcPic;
    105202    pcPic = NULL;
     203#endif
    106204  }
    107205 
     
    110208  m_cLoopFilter.        destroy();
    111209 
     210#if !SVC_EXTENSION
    112211  // destroy ROM
    113212  destroyROM();
     213#endif
    114214}
    115215
     
    129229  {
    130230    rpcPic = new TComPic();
     231
     232#if SVC_EXTENSION //Temporal solution, should be modified
     233    if(m_layerId > 0)
     234    {
     235      TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 );
     236      //TComPic*                      pcPic = *(pcTDecTopBase->getListPic()->begin());
     237      TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec();
     238      if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() )
     239      {
     240        rpcPic->setSpatialEnhLayerFlag( true );
     241      }
     242    }
     243#endif
    131244   
     245#if SVC_UPSAMPLING
     246    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     247                     conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
     248#else
    132249    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    133250                     conformanceWindow, defaultDisplayWindow, numReorderPics, true);
     251#endif
    134252    rpcPic->getPicSym()->allocSaoParam(&m_cSAO);
    135253    m_cListPic.pushBack( rpcPic );
     
    152270    if ( rpcPic->getSlice( 0 )->isReferenced() == false  && rpcPic->getOutputMark() == false)
    153271    {
     272#if !SVC_EXTENSION
    154273      rpcPic->setOutputMark(false);
     274#endif
    155275      rpcPic->setReconMark( false );
    156276      rpcPic->getPicYuvRec()->setBorderExtension( false );
     
    168288  }
    169289  rpcPic->destroy();
     290
     291#if SVC_UPSAMPLING
     292  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     293                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
     294
     295#else
    170296  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    171297                   conformanceWindow, defaultDisplayWindow, numReorderPics, true);
     298#endif
    172299  rpcPic->getPicSym()->allocSaoParam(&m_cSAO);
    173300}
     
    187314  m_cGopDecoder.filterPicture(pcPic);
    188315
     316#if SYNTAX_OUTPUT
     317  pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES );
     318#endif
    189319  TComSlice::sortPicList( m_cListPic ); // sorting for application output
    190320  poc                 = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
     
    202332  cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
    203333  cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
     334#if SET_SLICE_LAYER_ID
     335  cFillSlice.initSlice( m_parameterSetManagerDecoder.getFirstSPS()->getLayerId() );
     336#else
    204337  cFillSlice.initSlice();
     338#endif
    205339  TComPic *cFillPic;
    206340  xGetNewPicBuffer(&cFillSlice,cFillPic);
    207341  cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
    208342  cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
     343#if SET_SLICE_LAYER_ID
     344  cFillPic->getSlice(0)->initSlice( cFillPic->getLayerId() );
     345#else
    209346  cFillPic->getSlice(0)->initSlice();
     347#endif
    210348 
    211349  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
     
    256394  assert (sps != 0);
    257395
     396#if SVC_EXTENSION
     397  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->getIdrPicFlag(), m_apcSlicePilot->getLayerId() ))
     398#else
    258399  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->getIdrPicFlag()))
     400#endif
    259401  {
    260402    printf ("Parameter set activation failed!");
     
    283425}
    284426
     427#if SVC_EXTENSION
     428Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC )
     429#else
    285430Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
     431#endif
    286432{
    287433  TComPic*&   pcPic         = m_pcPic;
     434#if SET_SLICE_LAYER_ID
     435  m_apcSlicePilot->initSlice( nalu.m_layerId );
     436#else
    288437  m_apcSlicePilot->initSlice();
     438#endif
    289439
    290440  if (m_bFirstSliceInPicture)
     
    324474
    325475  // exit when a new picture is found
     476#if SVC_EXTENSION
     477  bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC);
     478  if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence )
     479  {
     480    m_prevPOC = m_apcSlicePilot->getPOC();
     481    curLayerId = m_uiPrevLayerId;
     482    m_uiPrevLayerId = m_layerId;
     483    return true;
     484  }
     485#else
    326486  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence)
    327487  {
     
    333493    m_prevPOC = m_apcSlicePilot->getPOC();
    334494  }
     495#endif
    335496  // actual decoding starts here
    336497  xActivateParameterSets();
     
    339500  {
    340501    m_prevPOC = m_apcSlicePilot->getPOC();
     502#if SVC_EXTENSION
     503    curLayerId = m_layerId;
     504    m_uiPrevLayerId = m_layerId;
     505#endif
    341506  }
    342507  m_bFirstSliceInSequence = false;
     
    349514  if (m_bFirstSliceInPicture)
    350515  {
     516#if AVC_BASE
     517  if( m_layerId == 1 )
     518  {
     519    TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     520    fstream* pFile  = m_ppcTDecTop[0]->getBLReconFile();
     521    UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth() - pBLPic->getPicYuvRec()->getPicCropLeftOffset() - pBLPic->getPicYuvRec()->getPicCropRightOffset();;
     522    UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight() - pBLPic->getPicYuvRec()->getPicCropTopOffset() - pBLPic->getPicYuvRec()->getPicCropBottomOffset();
     523       
     524    if( pFile->good() )
     525    {
     526      UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2;
     527
     528      pFile->seekg((UInt)uiPos, ios::beg );
     529
     530      Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr();
     531      UInt uiStride = pBLPic->getPicYuvRec()->getStride();
     532      for( Int i = 0; i < uiHeight; i++ )
     533      {
     534        for( Int j = 0; j < uiWidth; j++ )
     535        {
     536          pPel[j] = pFile->get();
     537        }
     538        pPel += uiStride;
     539      }
     540
     541      pPel = pBLPic->getPicYuvRec()->getCbAddr();
     542      uiStride = pBLPic->getPicYuvRec()->getCStride();
     543      for( Int i = 0; i < uiHeight/2; i++ )
     544      {
     545        for( Int j = 0; j < uiWidth/2; j++ )
     546        {
     547          pPel[j] = pFile->get();
     548        }
     549        pPel += uiStride;
     550      }
     551
     552      pPel = pBLPic->getPicYuvRec()->getCrAddr();
     553      uiStride = pBLPic->getPicYuvRec()->getCStride();
     554      for( Int i = 0; i < uiHeight/2; i++ )
     555      {
     556        for( Int j = 0; j < uiWidth/2; j++ )
     557        {
     558          pPel[j] = pFile->get();
     559        }
     560        pPel += uiStride;
     561      }
     562    }
     563  }
     564#endif
     565
    351566    // Buffer initialize for prediction.
    352567    m_cPrediction.initTempBuff();
     
    361576    // Recursive structure
    362577    m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
     578#if SVC_EXTENSION
     579    m_cCuDecoder.init   ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId );
     580#else
    363581    m_cCuDecoder.init   ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction );
     582#endif
    364583    m_cTrQuant.init     ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize());
    365584
     
    483702  pcPic->setTLayer(nalu.m_temporalId);
    484703
     704#if SVC_EXTENSION
     705  pcPic->setLayerId(nalu.m_layerId);
     706  pcSlice->setLayerId(nalu.m_layerId);
     707#endif
     708
    485709  if (bNextSlice)
    486710  {
    487711    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA );
     712#if !REF_IDX_FRAMEWORK || AVC_SYNTAX
    488713    // Set reference list
    489714    pcSlice->setRefPicList( m_cListPic );
     715#endif
     716
     717#if SVC_EXTENSION   
     718    if(m_layerId > 0)
     719    {
     720#if AVC_BASE
     721      pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() );
     722#if AVC_SYNTAX
     723      TComPic* pBLPic = pcSlice->getBaseColPic();
     724      if( pcSlice->getPOC() == 0 )
     725      {
     726        // initialize partition order.
     727        UInt* piTmp = &g_auiZscanToRaster[0];
     728        initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
     729        initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
     730      }     
     731      pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
     732      pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
     733#endif
     734
     735#else
     736      TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
     737      TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
     738      pcSlice->setBaseColPic ( *cListPic, m_layerId );
     739#endif
     740#if SVC_UPSAMPLING
     741      if ( pcPic->isSpatialEnhLayer())
     742      {   
     743        m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
     744      }
     745      else
     746      {
     747        pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() );
     748      }
     749      pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() );
     750#endif
     751    }
     752#endif
     753
     754#if REF_IDX_FRAMEWORK
     755#if !AVC_SYNTAX
     756    // Set reference list
     757    pcSlice->setRefPicList( m_cListPic );
     758#endif
     759    if(m_layerId > 0)
     760    {
     761      setILRPic(pcPic);
     762#if REF_IDX_MFM
     763      pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
     764#endif
     765
     766      pcSlice->addRefPicList ( m_cIlpPic,
     767                               1,
     768                               ((pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
     769                                (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ? 0: -1);
     770    }
     771#endif
    490772
    491773    // For generalized B
     
    590872{
    591873  TComSPS* sps = new TComSPS();
     874#if SVC_EXTENSION
     875  sps->setLayerId(m_layerId);
     876#endif
    592877  m_cEntropyDecoder.decodeSPS( sps );
    593878  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
     879#if REF_IDX_MFM
     880  m_pcSPS = sps;
     881  setMFMEnabledFlag(sps->getMFMEnabledFlag());
     882#endif
     883#if REF_IDX_FRAMEWORK
     884  if(m_numLayer>0)
     885  {
     886    xInitILRP(sps);
     887  }
     888#endif
    594889}
    595890
     
    637932}
    638933
     934#if SVC_EXTENSION
     935Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC)
     936#else
    639937Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
     938#endif
    640939{
    641940  // Initialize entropy decoder
     
    651950    case NAL_UNIT_SPS:
    652951      xDecodeSPS();
     952#if AVC_BASE
     953      {
     954        TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     955        if( nalu.m_layerId == 1 && pBLPic->getPicYuvRec() == NULL )
     956        {
     957#if SVC_UPSAMPLING
     958#if AVC_SYNTAX
     959          TComSPS* sps = new TComSPS();
     960          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, sps, true);
     961#else
     962          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL, true);
     963#endif
     964#else
     965          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
     966#endif
     967        }
     968      }
     969#endif
    653970      return false;
    654971
     
    678995    case NAL_UNIT_CODED_SLICE_RASL_N:
    679996    case NAL_UNIT_CODED_SLICE_TFD:
     997#if SVC_EXTENSION
     998      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC);
     999#else
    6801000      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
     1001#endif
    6811002      break;
    6821003    default:
  • branches/HM-10.0-dev-SHM/source/Lib/TLibDecoder/TDecTop.h

    r51 r54  
    7272
    7373  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
     74#if SVC_EXTENSION
     75  static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
     76#else
    7477  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
     78#endif
     79
     80#if REF_IDX_MFM
     81  TComSPS*               m_pcSPS;
     82  Bool                   m_bMFMEnabledFlag;
     83#endif
     84
    7585  TComSlice*              m_apcSlicePilot;
    7686 
     
    95105  TComPic*                m_pcPic;
    96106  UInt                    m_uiSliceIdx;
     107#if !SVC_EXTENSION
    97108  Int                     m_prevPOC;
     109#endif
    98110  Bool                    m_bFirstSliceInPicture;
     111#if !SVC_EXTENSION
    99112  Bool                    m_bFirstSliceInSequence;
     113#endif
     114
     115#if SVC_EXTENSION
     116  static UInt             m_prevPOC;        // POC of the previous slice
     117  static UInt             m_uiPrevLayerId;  // LayerId of the previous slice
     118  static Bool             m_bFirstSliceInSequence;
     119  UInt                    m_layerId;     
     120  UInt                    m_numLayer;
     121  TDecTop**               m_ppcTDecTop;
     122#if AVC_BASE
     123  fstream*                m_pBLReconFile;
     124  Int                     m_iBLSourceWidth;
     125  Int                     m_iBLSourceHeight;
     126#endif
     127#endif
     128#if AVC_SYNTAX || SYNTAX_OUTPUT
     129  fstream*               m_pBLSyntaxFile;
     130#endif
     131#if REF_IDX_FRAMEWORK
     132  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
     133#endif
    100134
    101135public:
     
    109143
    110144  Void  init();
     145#if SVC_EXTENSION
     146  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
     147#else
    111148  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
     149#endif
    112150 
    113151  Void  deletePicBuffer();
    114152
    115153  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
     154
     155#if SVC_EXTENSION
     156  UInt      getLayerId            () { return m_layerId;              }
     157  Void      setLayerId            (UInt layer) { m_layerId = layer; }
     158  UInt      getNumLayer           () { return m_numLayer;             }
     159  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
     160  TComList<TComPic*>*      getListPic() { return &m_cListPic; }
     161  Void                setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
     162  TDecTop*            getLayerDec(UInt layer)   { return m_ppcTDecTop[layer]; }
     163#if AVC_BASE
     164  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
     165  fstream*  getBLReconFile() { return m_pBLReconFile; }
     166  Void      setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; }
     167  Int       getBLWidth() { return  m_iBLSourceWidth; }
     168  Int       getBLHeight() { return  m_iBLSourceHeight; }
     169#endif
     170#endif
     171#if AVC_SYNTAX || SYNTAX_OUTPUT
     172  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
     173  fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
     174#endif
     175#if REF_IDX_FRAMEWORK
     176  Void      xInitILRP(TComSPS *pcSPS);
     177  Void      setILRPic(TComPic *pcPic);
     178#endif
     179#if REF_IDX_MFM
     180  TComSPS*  getSPS()                       {return m_pcSPS;}
     181  Void      setMFMEnabledFlag(Bool flag)   {m_bMFMEnabledFlag = flag;}
     182  Bool      getMFMEnabledFlag()            {return m_bMFMEnabledFlag;}
     183#endif
    116184
    117185protected:
     
    120188
    121189  Void      xActivateParameterSets();
     190#if SVC_EXTENSION
     191  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
     192#else
    122193  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
     194#endif
    123195  Void      xDecodeVPS();
    124196  Void      xDecodeSPS();
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/NALwrite.cpp

    r51 r54  
    5353  bsNALUHeader.write(0,1);                    // forbidden_zero_bit
    5454  bsNALUHeader.write(nalu.m_nalUnitType, 6);  // nal_unit_type
     55#if SVC_EXTENSION
     56  bsNALUHeader.write(nalu.m_layerId, 6); // reserved_one_5bits
     57#else
    5558  bsNALUHeader.write(nalu.m_reservedZero6Bits, 6);                   // nuh_reserved_zero_6bits
     59#endif
    5660  bsNALUHeader.write(nalu.m_temporalId+1, 3); // nuh_temporal_id_plus1
    5761
     
    145149  naluDest.m_temporalId  = naluSrc.m_temporalId;
    146150  naluDest.m_Bitstream   = naluSrc.m_Bitstream;
     151#if SVC_EXTENSION
     152  naluDest.m_layerId   = naluSrc.m_layerId;
     153#endif
    147154}
    148155
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/NALwrite.h

    r51 r54  
    5757    NalUnitType nalUnitType,
    5858    UInt temporalID = 0,
     59#if SVC_EXTENSION
     60    UInt     layerId = 0,
     61#endif
    5962    UInt reserved_zero_6bits = 0)
     63#if SVC_EXTENSION
     64  : NALUnit(nalUnitType, temporalID, layerId, reserved_zero_6bits)
     65#else
    6066  : NALUnit(nalUnitType, temporalID, reserved_zero_6bits)
     67#endif
    6168  , m_Bitstream()
    6269  {}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncAnalyze.cpp

    r51 r54  
    4545//////////////////////////////////////////////////////////////////////
    4646
     47#if SVC_EXTENSION
     48TEncAnalyze             m_gcAnalyzeAll [MAX_LAYERS];
     49TEncAnalyze             m_gcAnalyzeI [MAX_LAYERS];
     50TEncAnalyze             m_gcAnalyzeP [MAX_LAYERS];
     51TEncAnalyze             m_gcAnalyzeB [MAX_LAYERS];
     52#else
    4753TEncAnalyze             m_gcAnalyzeAll;
    4854TEncAnalyze             m_gcAnalyzeI;
    4955TEncAnalyze             m_gcAnalyzeP;
    5056TEncAnalyze             m_gcAnalyzeB;
     57#endif
    5158
    5259//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncAnalyze.h

    r51 r54  
    8888  Void    setFrmRate  (Double dFrameRate) { m_dFrmRate = dFrameRate; } //--CFG_KDY
    8989  Void    clear() { m_dPSNRSumY = m_dPSNRSumU = m_dPSNRSumV = m_dAddBits = m_uiNumPic = 0;  }
     90#if SVC_EXTENSION
     91  Void    printOut ( Char cDelim, UInt layer )
     92  {
     93    Double dFps     =   m_dFrmRate; //--CFG_KDY
     94    Double dScale   = dFps / 1000 / (Double)m_uiNumPic;
     95   
     96    printf( "    L%d\t %8d    %c"          "%12.4lf  "    "%8.4lf  "   "%8.4lf  "    "%8.4lf\n",
     97           layer,
     98           getNumPic(), cDelim,
     99           getBits() * dScale,
     100           getPsnrY() / (Double)getNumPic(),
     101           getPsnrU() / (Double)getNumPic(),
     102           getPsnrV() / (Double)getNumPic() );
     103  }
     104#else
    90105  Void    printOut ( Char cDelim )
    91106  {
     
    102117           getPsnrV() / (Double)getNumPic() );
    103118  }
     119#endif
    104120 
    105121  Void    printSummaryOut ()
     
    150166};
    151167
     168#if SVC_EXTENSION
     169extern TEncAnalyze             m_gcAnalyzeAll [MAX_LAYERS];
     170extern TEncAnalyze             m_gcAnalyzeI [MAX_LAYERS];
     171extern TEncAnalyze             m_gcAnalyzeP [MAX_LAYERS];
     172extern TEncAnalyze             m_gcAnalyzeB [MAX_LAYERS];
     173#else
    152174extern TEncAnalyze             m_gcAnalyzeAll;
    153175extern TEncAnalyze             m_gcAnalyzeI;
    154176extern TEncAnalyze             m_gcAnalyzeP;
    155177extern TEncAnalyze             m_gcAnalyzeB;
     178#endif
    156179
    157180//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncCavlc.cpp

    r51 r54  
    545545  }
    546546  WRITE_FLAG( pcSPS->getTMVPFlagsPresent()  ? 1 : 0,           "sps_temporal_mvp_enable_flag" );
    547 
     547#if REF_IDX_MFM
     548  if( pcSPS->getLayerId() > 0 )
     549  {
     550    assert(pcSPS->getMFMEnabledFlag());
     551    WRITE_FLAG( pcSPS->getMFMEnabledFlag() ? 1 : 0,          "sps_enh_mfm_enable_flag" );
     552  }
     553#endif
    548554  WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(),             "sps_strong_intra_smoothing_enable_flag" );
    549555
     
    15491555  return true;
    15501556}
     1557
     1558#if INTRA_BL
     1559Void TEncCavlc::codeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
     1560{
     1561  assert(0);
     1562}
     1563
     1564#endif
    15511565//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncCavlc.h

    r51 r54  
    114114  Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    115115  Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
     116#if INTRA_BL
     117  Void codeIntraBLFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx );
     118#endif
    116119 
    117120  Void codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode );
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncCfg.h

    r51 r54  
    298298
    299299  Bool      m_useStrongIntraSmoothing;                        ///< enable the use of strong intra smoothing (bi_linear interpolation) for 32x32 blocks when reference samples are flat.
     300#if SVC_EXTENSION
     301  UInt      m_layerId;   
     302  UInt      m_numLayer;
     303#endif
     304#if REF_IDX_FRAMEWORK
     305  Int      m_elRapSliceBEnabled;
     306#endif
    300307
    301308public:
     
    692699  Void setFrameOnlyConstraintFlag(Bool b) { m_frameOnlyConstraintFlag = b; }
    693700#endif
     701
     702#if SVC_EXTENSION
     703  UInt      getLayerId            () { return m_layerId;              }
     704  Void      setLayerId            (UInt layer) { m_layerId = layer; }
     705  UInt      getNumLayer           () { return m_numLayer;             } 
     706  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
     707  Void      setConformanceMode    (Int mode)     { m_conformanceMode = mode; }
     708  Void      setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
     709#endif
     710#if REF_IDX_FRAMEWORK
     711  Void      setElRapSliceTypeB(Int bEnabled) {m_elRapSliceBEnabled = bEnabled;}
     712  Int       getElRapSliceTypeB()              {return m_elRapSliceBEnabled;}
     713#endif
    694714};
    695715
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncCu.cpp

    r51 r54  
    211211  m_pcRdCost           = pcEncTop->getRdCost();
    212212 
     213#if SVC_EXTENSION
     214  m_ppcTEncTop         = pcEncTop->getLayerEnc();
     215  for(UInt i=0 ; i< m_uhTotalDepth-1 ; i++)
     216  {   
     217    m_ppcBestCU[i]->setLayerId(pcEncTop->getLayerId());
     218    m_ppcTempCU[i]->setLayerId(pcEncTop->getLayerId());
     219  }
     220#endif
     221 
    213222  m_pcEntropyCoder     = pcEncTop->getEntropyCoder();
    214223  m_pcCavlcCoder       = pcEncTop->getCavlcCoder();
     
    445454  if(!bSliceEnd && !bSliceStart && bInsidePicture )
    446455  {
     456#if (ENCODER_FAST_MODE)
     457    bool testInter = true;
     458    if (rpcBestCU->getLayerId() > 0)
     459    {
     460      if (rpcBestCU->getSlice()->getBaseColPic()->getSlice(0)->getSliceType() == I_SLICE)
     461      {
     462        testInter = false;
     463      }
     464
     465    }
     466#endif
    447467    for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
    448468    {
     
    459479
    460480      // do inter modes, SKIP and 2Nx2N
     481#if (ENCODER_FAST_MODE == 1)
     482      if( rpcBestCU->getSlice()->getSliceType() != I_SLICE && testInter )
     483#else
    461484      if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
     485#endif
    462486      {
    463487        // 2Nx2N
     
    480504          }
    481505        }
     506#if (ENCODER_FAST_MODE == 2)
     507        if (testInter)
     508        {
     509#endif
    482510
    483511        if(!m_pcEncCfg->getUseEarlySkipDetection())
     
    493521          }
    494522        }
     523#if (ENCODER_FAST_MODE == 2)
     524    }
     525#endif
     526
    495527      }
    496528
     
    531563
    532564        // do inter modes, NxN, 2NxN, and Nx2N
     565#if (ENCODER_FAST_MODE)
     566      if( rpcBestCU->getSlice()->getSliceType() != I_SLICE && testInter )
     567#else
    533568        if( rpcBestCU->getSlice()->getSliceType() != I_SLICE )
     569#endif
    534570        {
    535571          // 2Nx2N, NxN
     
    685721        {
    686722          // speedup for inter frames
     723#if (ENCODER_FAST_MODE)
     724        if( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
     725          !testInter ||
     726          rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
     727          rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0   ||
     728          rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     ) // avoid very complex intra if it is unlikely
     729#else
    687730          if( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
    688731            rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
    689732            rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0   ||
    690733            rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     ) // avoid very complex intra if it is unlikely
     734#endif
    691735          {
    692736            xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
     
    716760          }
    717761        }
     762#if INTRA_BL
     763      if(m_pcPicYuvRecBase)
     764      {
     765        xCheckRDCostIntraBL( rpcBestCU, rpcTempCU );
     766        rpcTempCU->initEstData( uiDepth, iQP );
     767      }
     768#endif
     769
     770#if (ENCODER_FAST_MODE)
     771        if(pcPic->getLayerId() > 0)
     772        {
     773          xCheckRDCostILRUni( rpcBestCU, rpcTempCU);
     774          rpcTempCU->initEstData( uiDepth, iQP );
     775       }
     776#endif
     777
    718778        if (isAddLowestQP && (iQP == lowestQP))
    719779        {
     
    11501210    return;
    11511211  }
     1212#if INTRA_BL
     1213  m_pcEntropyCoder->encodeIntraBLFlag( pcCU, uiAbsPartIdx );
     1214  if ( !pcCU->isIntraBL( uiAbsPartIdx ) )
     1215  {
     1216#endif
    11521217  m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx );
    11531218 
     
    11681233  // prediction Info ( Intra : direction mode, Inter : Mv, reference idx )
    11691234  m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx );
     1235#if INTRA_BL
     1236  }
     1237#endif
    11701238 
    11711239  // Encode Coefficients
     
    12211289    for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
    12221290    {
    1223       {
     1291#if REF_IDX_ME_ZEROMV
     1292      Bool bZeroMVILR = rpcTempCU->xCheckZeroMVILRMerge(uhInterDirNeighbours[uiMergeCand], cMvFieldNeighbours[0 + 2*uiMergeCand], cMvFieldNeighbours[1 + 2*uiMergeCand]);
     1293      if(bZeroMVILR)
     1294      {
     1295#endif
    12241296        if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1))
    12251297        {
     
    12711343    }
    12721344    }
     1345#if REF_IDX_ME_ZEROMV
    12731346   }
     1347#endif
    12741348  }
    12751349
     
    13771451 
    13781452  m_pcEntropyCoder->resetBits();
     1453#if INTRA_BL
     1454  m_pcEntropyCoder->encodeIntraBLFlag ( rpcTempCU, 0,       true );
     1455#endif
    13791456  if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
    13801457  {
     
    14301507
    14311508  m_pcEntropyCoder->resetBits();
     1509#if INTRA_BL
     1510  m_pcEntropyCoder->encodeIntraBLFlag ( rpcTempCU, 0,       true );
     1511#endif
    14321512  if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
    14331513  {
     
    16811761}
    16821762#endif
     1763
     1764#if INTRA_BL
     1765Void TEncCu::xCheckRDCostIntraBL( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU )
     1766{
     1767  UInt uiDepth = rpcTempCU->getDepth( 0 );
     1768  rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
     1769  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
     1770  rpcTempCU->setPredModeSubParts( MODE_INTRA_BL, 0, uiDepth ); 
     1771  rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uiDepth );
     1772
     1773  m_pcPredSearch->setBaseRecPic( m_pcPicYuvRecBase );
     1774#if NO_RESIDUAL_FLAG_FOR_BLPRED
     1775  rpcTempCU->setDepthSubParts( uiDepth, 0 );
     1776  //   rpcTempCU->setLumaIntraDirSubParts( DC_IDX, 0, uiDepth );
     1777  //   rpcTempCU->setChromIntraDirSubParts( DC_IDX, 0, uiDepth );
     1778  m_ppcPredYuvTemp[uiDepth]->copyFromPicLuma  ( rpcTempCU->getSlice()->getFullPelBaseRec(),  rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, rpcTempCU->getWidth(0), rpcTempCU->getHeight(0));
     1779  m_ppcPredYuvTemp[uiDepth]->copyFromPicChroma( rpcTempCU->getSlice()->getFullPelBaseRec(),  rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, (rpcTempCU->getWidth(0)>>1), (rpcTempCU->getHeight(0)>>1), 0);
     1780  m_ppcPredYuvTemp[uiDepth]->copyFromPicChroma( rpcTempCU->getSlice()->getFullPelBaseRec(),  rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, (rpcTempCU->getWidth(0)>>1), (rpcTempCU->getHeight(0)>>1), 1);
     1781  m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcResiYuvBest[uiDepth], m_ppcRecoYuvTemp[uiDepth], false );
     1782  rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
     1783#else
     1784
     1785  m_pcPredSearch->estIntraBLPredQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth] );
     1786
     1787  m_pcEntropyCoder->resetBits();
     1788  m_pcEntropyCoder->encodeIntraBLFlag ( rpcTempCU, 0,       true );
     1789  m_pcEntropyCoder->encodeSkipFlag( rpcTempCU, 0,       true );
     1790  if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
     1791  {
     1792    m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0,          true );
     1793  }
     1794
     1795  // Encode Coefficients
     1796  Bool bCodeDQP = getdQPFlag();
     1797  m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP );
     1798  setdQPFlag( bCodeDQP );
     1799 
     1800  if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
     1801 
     1802  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
     1803  if(m_pcEncCfg->getUseSBACRD())
     1804  {
     1805    rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
     1806  }
     1807  rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
     1808#endif
     1809 
     1810  xCheckDQP( rpcTempCU );
     1811  xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth);
     1812}
     1813#endif
     1814
     1815
     1816
     1817
    16831818//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncCu.h

    r51 r54  
    8484  //  Access channel
    8585  TEncCfg*                m_pcEncCfg;
     86#if INTRA_BL
     87  TComPicYuv*             m_pcPicYuvRecBase;       ///< reconstructed base layer
     88#endif
    8689  TEncSearch*             m_pcPredSearch;
    8790  TComTrQuant*            m_pcTrQuant;
    8891  TComBitCounter*         m_pcBitCounter;
    8992  TComRdCost*             m_pcRdCost;
     93 
     94#if SVC_EXTENSION
     95  TEncTop**               m_ppcTEncTop;
     96#endif
    9097 
    9198  TEncEntropy*            m_pcEntropyCoder;
     
    124131  UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; }
    125132#endif
     133#if INTRA_BL
     134  Void  setBaseRecPic       ( TComPicYuv* p ) { m_pcPicYuvRecBase = p; }   
     135#endif
    126136protected:
    127137  Void  finishCU            ( TComDataCU*  pcCU, UInt uiAbsPartIdx,           UInt uiDepth        );
     
    144154#endif
    145155  Void  xCheckRDCostIntra   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
     156#if INTRA_BL
     157  Void  xCheckRDCostIntraBL ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU  );
     158#endif
     159#if ENCODER_FAST_MODE
     160  Void  xCheckRDCostILRUni  ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU );
     161#endif
    146162  Void  xCheckDQP           ( TComDataCU*  pcCU );
    147163 
     
    168184#endif
    169185
     186#if SVC_EXTENSION
     187  TEncTop*   getLayerEnc(UInt LayerId)  {return m_ppcTEncTop[LayerId]; }
     188#endif
     189
    170190  Void  xFillPCMBuffer     ( TComDataCU*& pCU, TComYuv* pOrgYuv );
    171191};
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncEntropy.cpp

    r51 r54  
    166166  }
    167167
     168#if INTRA_BL
     169  if( pcCU->isIntraBL( uiAbsPartIdx ) )
     170  {
     171    return;
     172  }
     173#endif
     174
    168175  m_pcEntropyCoderIf->codePredMode( pcCU, uiAbsPartIdx );
    169176}
     
    244251    }
    245252  }
     253#if INTRA_BL
     254    if( pcCU->isIntra(uiAbsPartIdx) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
     255#else
    246256 
    247257  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
     258#endif
    248259  {
    249260    assert( uiSubdiv );
     
    331342    }
    332343   
     344#if INTRA_BL
     345#if NO_RESIDUAL_FLAG_FOR_BLPRED
     346    if( ( !pcCU->isIntra( uiAbsPartIdx ) || pcCU->isIntraBL(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
     347#else
     348    if( ( !pcCU->isIntra( uiAbsPartIdx ) ) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
     349#endif
     350#else
    333351    if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
     352#endif
    334353    {
    335354      assert( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, 0 ) );
     
    412431Void TEncEntropy::encodePredInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
    413432{
     433#if INTRA_BL
     434  assert ( !pcCU->isIntraBL( uiAbsPartIdx ) );
     435#endif
    414436  if( bRD )
    415437  {
     
    585607  UInt uiChromaOffset = uiLumaOffset>>2;
    586608   
     609#if NO_RESIDUAL_FLAG_FOR_BLPRED
     610  if( pcCU->isIntra(uiAbsPartIdx) && !pcCU->isIntraBL(uiAbsPartIdx) )
     611#else
    587612  if( pcCU->isIntra(uiAbsPartIdx) )
     613#endif
    588614  {
    589615    DTRACE_CABAC_VL( g_nSymbolCounter++ )
     
    733759}
    734760
     761#if INTRA_BL
     762Void TEncEntropy::encodeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
     763{
     764  if( pcCU->getLayerId() == 0 )
     765  {
     766    return;
     767  }
     768
     769  if( bRD )
     770  {
     771    uiAbsPartIdx = 0;
     772  }
     773  m_pcEntropyCoderIf->codeIntraBLFlag( pcCU, uiAbsPartIdx );
     774}
     775#endif
    735776//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncEntropy.h

    r51 r54  
    8686  virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    8787 
     88#if INTRA_BL
     89  virtual Void codeIntraBLFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
     90#endif
    8891  virtual Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    8992  virtual Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
     
    161164  Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
    162165  Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
     166#if INTRA_BL
     167  Void encodeIntraBLFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
     168#endif
    163169  Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
    164170  Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncGOP.cpp

    r51 r54  
    9797  xResetNonNestedSEIPresentFlags();
    9898#endif
     99#if SVC_UPSAMPLING
     100  m_pcPredSearch        = NULL;
     101#endif
    99102  return;
    100103}
     
    106109/** Create list to contain pointers to LCU start addresses of slice.
    107110 */
     111#if SVC_EXTENSION
     112Void  TEncGOP::create( UInt layerId )
     113{
     114  m_bLongtermTestPictureHasBeenCoded = 0;
     115  m_bLongtermTestPictureHasBeenCoded2 = 0;
     116  m_layerId = layerId;
     117}
     118#else
    108119Void  TEncGOP::create()
    109120{
     
    111122  m_bLongtermTestPictureHasBeenCoded2 = 0;
    112123}
     124#endif
    113125
    114126Void  TEncGOP::destroy()
     
    121133  m_pcCfg                = pcTEncTop;
    122134  m_pcSliceEncoder       = pcTEncTop->getSliceEncoder();
    123   m_pcListPic            = pcTEncTop->getListPic();
    124  
     135  m_pcListPic            = pcTEncTop->getListPic(); 
    125136  m_pcEntropyCoder       = pcTEncTop->getEntropyCoder();
    126137  m_pcCavlcCoder         = pcTEncTop->getCavlcCoder();
     
    136147  m_totalCoded         = 0;
    137148
     149#if SVC_EXTENSION
     150  m_ppcTEncTop           = pcTEncTop->getLayerEnc();
     151#endif
     152#if SVC_UPSAMPLING
     153  m_pcPredSearch         = pcTEncTop->getPredSearch();                       ///< encoder search class
     154#endif
    138155}
    139156
     
    239256// Public member functions
    240257// ====================================================================================================================
     258#if SVC_EXTENSION
     259Void TEncGOP::compressGOP( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP)
     260#else
    241261Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP)
     262#endif
    242263{
    243264  TComPic*        pcPic;
     
    261282  UInt *accumNalsDU = NULL;
    262283  SEIDecodingUnitInfo decodingUnitInfoSEI;
     284#if SVC_EXTENSION
     285  for ( Int iGOPid=iPicIdInGOP; iGOPid < iPicIdInGOP+1; iGOPid++ )
     286#else
    263287  for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
     288#endif
    264289  {
    265290    UInt uiColDir = 1;
     
    337362    m_pcSliceEncoder->setSliceIdx(0);
    338363    pcPic->setCurrSliceIdx(0);
     364#if SVC_EXTENSION
     365    pcPic->setLayerId( m_layerId );
     366#endif
    339367
    340368    m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() );
     
    384412    // Set the nal unit type
    385413    pcSlice->setNalUnitType(getNalUnitType(pocCurr));
     414#if REF_IDX_FRAMEWORK
     415    if( m_layerId > 0 && (uiPOCCurr % m_pcCfg->getIntraPeriod() == 0) )
     416    {
     417      pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA);
     418    }
     419    if( m_layerId > 0 && !m_pcEncTop->getElRapSliceTypeB() )
     420    {
     421      if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
     422          (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) &&
     423           pcSlice->getSliceType() == B_SLICE )
     424      {
     425        pcSlice->setSliceType(P_SLICE);
     426      }
     427    }
     428#endif
    386429    if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
    387430    {
     
    470513#endif     
    471514
     515#if SVC_EXTENSION     
     516      if(m_layerId > 0)
     517      {
     518        TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic();
     519        pcSlice->setBaseColPic (*cListPic, m_layerId );
     520#if SVC_UPSAMPLING
     521        if ( pcPic->isSpatialEnhLayer())
     522        {   
     523          m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
     524        }
     525        else
     526        {
     527          pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() );
     528        }
     529        pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() );
     530#endif
     531      }
     532#endif
     533
     534#if REF_IDX_FRAMEWORK
     535    if( pcSlice->getSliceType() == B_SLICE )
     536    {
     537      pcSlice->setColFromL0Flag(1-uiColDir);
     538    }
     539#endif
     540
    472541    //  Set reference list
    473542    pcSlice->setRefPicList ( rcListPic );
     543#if REF_IDX_FRAMEWORK
     544    if(m_layerId > 0)
     545    {
     546      m_pcEncTop->setILRPic(pcPic);
     547
     548#if REF_IDX_MFM
     549      pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic());
     550#endif
     551      pcSlice->addRefPicList ( m_pcEncTop->getIlpList(), 1);
     552
     553#if REF_IDX_MFM
     554      Bool found         = false;
     555      UInt ColFromL0Flag = pcSlice->getColFromL0Flag();
     556      UInt ColRefIdx     = pcSlice->getColRefIdx();
     557      for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
     558      {
     559        if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->getIsILR() )
     560        {
     561          ColRefIdx = colIdx;
     562          found = true;
     563          break;
     564        }
     565      }
     566
     567      if( found == false )
     568      {
     569        ColFromL0Flag = 1 - ColFromL0Flag;
     570        for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
     571        {
     572          if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->getIsILR() )
     573          {
     574            ColRefIdx = colIdx;
     575            found = true;
     576            break;
     577          }
     578        }
     579      }
     580
     581      if(found == true)
     582      {
     583        pcSlice->setColFromL0Flag(ColFromL0Flag);
     584        pcSlice->setColRefIdx(ColRefIdx);
     585      }
     586#endif
     587    }
     588#endif
    474589
    475590    //  Slice info. refinement
     
    493608    if (pcSlice->getSliceType() == B_SLICE)
    494609    {
     610#if !REF_IDX_FRAMEWORK
    495611      pcSlice->setColFromL0Flag(1-uiColDir);
     612#endif
    496613      Bool bLowDelay = true;
    497614      Int  iCurrPOC  = pcSlice->getPOC();
     
    780897    m_storedStartCUAddrForEncodingSliceSegment.push_back(nextCUAddr);
    781898    startCUAddrSliceSegmentIdx++;
     899#if AVC_BASE
     900    if( m_layerId == 0 )
     901    {
     902      pcPic->getPicYuvOrg()->copyToPic( pcPic->getPicYuvRec() );
     903#if AVC_SYNTAX
     904      pcPic->readBLSyntax( m_ppcTEncTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
     905#endif
     906      return;
     907    }
     908#endif
    782909
    783910    while(nextCUAddr<uiRealEndAddress) // determine slice boundaries
     
    8781005    if ( m_bSeqFirst )
    8791006    {
     1007#if SVC_EXTENSION
     1008      OutputNALUnit nalu(NAL_UNIT_VPS, 0, m_layerId);
     1009#else
    8801010      OutputNALUnit nalu(NAL_UNIT_VPS);
     1011#endif
    8811012      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    8821013      m_pcEntropyCoder->encodeVPS(m_pcEncTop->getVPS());
     
    8871018#endif
    8881019
     1020#if SVC_EXTENSION
     1021      nalu = NALUnit(NAL_UNIT_SPS, 0, m_layerId);
     1022#else
    8891023      nalu = NALUnit(NAL_UNIT_SPS);
     1024#endif
    8901025      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    8911026      if (m_bSeqFirst)
     
    9201055#endif
    9211056
     1057#if SVC_EXTENSION
     1058      nalu = NALUnit(NAL_UNIT_PPS, 0, m_layerId);
     1059#else
    9221060      nalu = NALUnit(NAL_UNIT_PPS);
     1061#endif
    9231062      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    9241063      m_pcEntropyCoder->encodePPS(pcSlice->getPPS());
     
    11741313          m_pcEntropyCoder->resetEntropy      ();
    11751314          /* start slice NALunit */
     1315#if SVC_EXTENSION
     1316          OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->getTLayer(), m_layerId );
     1317#else
    11761318          OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->getTLayer() );
     1319#endif
    11771320          Bool sliceSegment = (!pcSlice->isNextSlice());
    11781321          if (!sliceSegment)
     
    14361579          digestStr = digestToString(sei_recon_picture_digest.digest, 4);
    14371580        }
     1581#if SVC_EXTENSION
     1582        OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer(), m_layerId);
     1583#else
    14381584        OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer());
     1585#endif
    14391586
    14401587        /* write the SEI messages */
     
    17081855  if( accumNalsDU != NULL) delete accumNalsDU;
    17091856
     1857#if SVC_EXTENSION
     1858  assert ( m_iNumPicCoded <= 1 );
     1859#else
    17101860  assert ( m_iNumPicCoded == iNumPicRcvd );
     1861#endif
    17111862}
    17121863
     1864#if !SVC_EXTENSION
    17131865Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded)
    17141866{
     
    17461898  printf("\nRVM: %.3lf\n" , xCalculateRVM());
    17471899}
     1900#endif
    17481901
    17491902Void TEncGOP::preLoopFilterPicAll( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits )
     
    20202173
    20212174  //===== add PSNR =====
     2175#if SVC_EXTENSION
     2176  m_gcAnalyzeAll[m_layerId].addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2177  TComSlice*  pcSlice = pcPic->getSlice(0);
     2178  if (pcSlice->isIntra())
     2179  {
     2180    m_gcAnalyzeI[m_layerId].addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2181  }
     2182  if (pcSlice->isInterP())
     2183  {
     2184    m_gcAnalyzeP[m_layerId].addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2185  }
     2186  if (pcSlice->isInterB())
     2187  {
     2188    m_gcAnalyzeB[m_layerId].addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2189  }
     2190#else
    20222191  m_gcAnalyzeAll.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
    20232192  TComSlice*  pcSlice = pcPic->getSlice(0);
     
    20342203    m_gcAnalyzeB.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
    20352204  }
     2205#endif
    20362206
    20372207  Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B');
    20382208  if (!pcSlice->isReferenced()) c += 32;
    20392209
     2210#if SVC_EXTENSION
     2211#if ADAPTIVE_QP_SELECTION
     2212  printf("POC %4d LId: %1d TId: %1d ( %c-SLICE, nQP %d QP %d ) %10d bits",
     2213         pcSlice->getPOC(),
     2214         pcSlice->getLayerId(),
     2215         pcSlice->getTLayer(),
     2216         c,
     2217         pcSlice->getSliceQpBase(),
     2218         pcSlice->getSliceQp(),
     2219         uibits );
     2220#else
     2221  printf("POC %4d LId: %1d TId: %1d ( %c-SLICE, QP %d ) %10d bits",
     2222         pcSlice->getPOC()-pcSlice->getLastIDR(),
     2223         pcSlice->getLayerId(),
     2224         pcSlice->getTLayer(),
     2225         c,
     2226         pcSlice->getSliceQp(),
     2227         uibits );
     2228#endif
     2229#else
    20402230#if ADAPTIVE_QP_SELECTION
    20412231  printf("POC %4d TId: %1d ( %c-SLICE, nQP %d QP %d ) %10d bits",
     
    20542244         uibits );
    20552245#endif
     2246#endif
    20562247
    20572248  printf(" [Y %6.4lf dB    U %6.4lf dB    V %6.4lf dB]", dYPSNR, dUPSNR, dVPSNR );
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncGOP.h

    r51 r54  
    8383  Bool                    m_bFirst;
    8484 
     85#if SVC_EXTENSION
     86  UInt                    m_layerId;     
     87#endif
     88
    8589  //  Access channel
    8690  TEncTop*                m_pcEncTop;
     
    8892  TEncSlice*              m_pcSliceEncoder;
    8993  TComList<TComPic*>*     m_pcListPic;
     94 
     95#if SVC_EXTENSION
     96  TEncTop**               m_ppcTEncTop;
     97#if SVC_UPSAMPLING
     98  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
     99#endif 
     100#endif
    90101 
    91102  TEncEntropy*            m_pcEntropyCoder;
     
    125136  virtual ~TEncGOP();
    126137 
     138#if SVC_EXTENSION
     139  Void  create      ( UInt layerId );
     140#else
    127141  Void  create      ();
     142#endif
    128143  Void  destroy     ();
    129144 
    130145  Void  init        ( TEncTop* pcTEncTop );
     146#if SVC_EXTENSION
     147  Void  compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );
     148#else
    131149  Void  compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );
     150#endif
    132151  Void xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice);
    133152
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncPic.cpp

    r51 r54  
    126126 * \return Void
    127127 */
     128#if SVC_UPSAMPLING
     129Void TEncPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
     130                      Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual )
     131
     132#else
    128133Void TEncPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
    129134                      Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, Bool bIsVirtual )
     135#endif
    130136{
     137#if SVC_UPSAMPLING
     138  TComPic::create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, 
     139                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSps, bIsVirtual );
     140#else
    131141  TComPic::create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, 
    132142                   conformanceWindow, defaultDisplayWindow, numReorderPics, bIsVirtual );
     143#endif
    133144  m_uiMaxAQDepth = uiMaxAQDepth;
    134145  if ( uiMaxAQDepth > 0 )
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncPic.h

    r51 r54  
    4141#include "TLibCommon/CommonDef.h"
    4242#include "TLibCommon/TComPic.h"
    43 
     43#if SVC_UPSAMPLING
     44#include "TLibCommon/TComSlice.h"
     45#endif
    4446//! \ingroup TLibEncoder
    4547//! \{
     
    103105  virtual ~TEncPic();
    104106
     107#if SVC_UPSAMPLING
     108  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth,   
     109                        Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual = false );
     110#else
    105111  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth,   
    106112                        Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, Bool bIsVirtual = false );
     113#endif
    107114  virtual Void  destroy();
    108115
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncSbac.cpp

    r51 r54  
    8383, m_cTransformSkipSCModel     ( 1,             2,               NUM_TRANSFORMSKIP_FLAG_CTX    , m_contextModels + m_numContextModels, m_numContextModels)
    8484, m_CUTransquantBypassFlagSCModel( 1,          1,               NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)
     85#if INTRA_BL
     86, m_cIntraBLPredFlagSCModel   (1,              1,               NUM_INTRA_BL_PRED_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
     87#endif
    8588{
    8689  assert( m_numContextModels <= MAX_NUM_CTX_MOD );
     
    131134  m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
    132135  m_cSaoMergeSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );
     136#if INTRA_BL
     137  m_cIntraBLPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
     138#endif
    133139  m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
    134140  m_cTransformSkipSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
     
    163169      curCost  = m_cCUSplitFlagSCModel.calcCost       ( curSliceType, qp, (UChar*)INIT_SPLIT_FLAG );
    164170      curCost += m_cCUSkipFlagSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_SKIP_FLAG );
     171#if INTRA_BL
     172      curCost += m_cIntraBLPredFlagSCModel.calcCost   ( curSliceType, qp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
     173#endif
    165174      curCost += m_cCUMergeFlagExtSCModel.calcCost    ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT);
    166175      curCost += m_cCUMergeIdxExtSCModel.calcCost     ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT);
     
    234243  m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
    235244  m_cSaoMergeSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );
     245#if INTRA_BL
     246  m_cIntraBLPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
     247#endif
    236248  m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
    237249  m_cTransformSkipSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
     
    416428{
    417429  PartSize eSize         = pcCU->getPartitionSize( uiAbsPartIdx );
     430#if INTRA_BL
     431  assert( !pcCU->isIntraBL( uiAbsPartIdx ) );
     432#endif
    418433  if ( pcCU->isIntra( uiAbsPartIdx ) )
    419434  {
     
    15841599  this->xCopyContextsFrom(pScr);
    15851600}
     1601
     1602#if INTRA_BL
     1603/** code intra_bl flag
     1604 * \param pcCU
     1605 * \param uiAbsPartIdx
     1606 * \returns Void
     1607 */
     1608Void TEncSbac::codeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
     1609{
     1610  // get context function is here
     1611  UInt uiSymbol = pcCU->isIntraBL( uiAbsPartIdx ) ? 1 : 0;
     1612
     1613  UInt uiCtxIntraBL = pcCU->getCtxIntraBLFlag( uiAbsPartIdx ) ;
     1614  m_pcBinIf->encodeBin(uiSymbol, m_cIntraBLPredFlagSCModel.get( 0, 0, uiCtxIntraBL ));
     1615
     1616  DTRACE_CABAC_VL( g_nSymbolCounter++ );
     1617  DTRACE_CABAC_T( "\tuiSymbol: ");
     1618  DTRACE_CABAC_V( uiSymbol );
     1619  DTRACE_CABAC_T( "\n");
     1620}
     1621#endif
    15861622//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncSbac.h

    r51 r54  
    134134  Void codeMVPIdx        ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
    135135 
     136#if INTRA_BL
     137  Void codeIntraBLFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
     138#endif
    136139  Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    137140  Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
     
    204207  ContextModel3DBuffer m_cTransformSkipSCModel;
    205208  ContextModel3DBuffer m_CUTransquantBypassFlagSCModel;
     209#if INTRA_BL
     210  ContextModel3DBuffer m_cIntraBLPredFlagSCModel;
     211#endif
    206212};
    207213
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncSearch.cpp

    r51 r54  
    906906        m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    907907      }
    908      
     908#if INTRA_BL
     909      m_pcEntropyCoder->encodeIntraBLFlag ( pcCU, 0, true );
     910      if( pcCU->isIntraBL( 0 ) )
     911      {
     912        return;
     913      }
     914#endif     
    909915      m_pcEntropyCoder  ->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
    910916
     
    944950    }
    945951  }
     952#if INTRA_BL
     953  if( pcCU->isIntraBL( 0 ) )
     954  {
     955    return;
     956  }
     957#endif
    946958  if( bChroma )
    947959  {
     
    10431055    pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
    10441056    //===== get prediction signal =====
     1057#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
     1058    if(pcCU->isIntraBL ( uiAbsPartIdx ) )
     1059    {
     1060      pcCU->getBaseLumaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride );
     1061    }
     1062    else
     1063#endif
    10451064    predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    10461065    // save prediction
     
    12281247
    12291248    //===== get prediction signal =====
     1249#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
     1250  if(pcCU->isIntraBL ( uiAbsPartIdx ) )
     1251  {
     1252    pcCU->getBaseChromaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride, uiChromaId );
     1253  }
     1254  else
     1255#endif
    12301256    {
    12311257      predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
     
    30393065  Int iHeight = 0;
    30403066
     3067#if REF_IDX_FRAMEWORK  // HM bug fix
     3068  for( UInt uiMergeCand = 0; uiMergeCand < pcCU->getSlice()->getMaxNumMergeCand(); ++uiMergeCand )
     3069  {
     3070    uhInterDirNeighbours[uiMergeCand] = 0;
     3071    cMvFieldNeighbours[0 + 2*uiMergeCand].setMvField(TComMv(), NOT_VALID);
     3072    cMvFieldNeighbours[1 + 2*uiMergeCand].setMvField(TComMv(), NOT_VALID);
     3073  }
     3074#endif
    30413075  pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight );
    30423076  UInt uiDepth = pcCU->getDepth( uiAbsPartIdx );
     
    30603094  for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
    30613095  {
    3062     {
     3096#if REF_IDX_ME_ZEROMV
     3097    Bool bZeroMVILR = pcCU->xCheckZeroMVILRMerge(uhInterDirNeighbours[uiMergeCand], cMvFieldNeighbours[0 + 2*uiMergeCand], cMvFieldNeighbours[1 + 2*uiMergeCand]);
     3098    if(bZeroMVILR)
     3099    {
     3100#endif
    30633101      UInt uiCostCand = MAX_UINT;
    30643102      UInt uiBitsCand = 0;
     
    30843122        uiMergeIndex = uiMergeCand;
    30853123      }
    3086     }
     3124#if REF_IDX_ME_ZEROMV
     3125    }
     3126#endif
    30873127  }
    30883128}
     
    32093249    UInt          uiBitsTempL0[MAX_NUM_REF];
    32103250
     3251#if (ENCODER_FAST_MODE)
     3252    Bool          testILR;
     3253#endif
     3254
    32113255    xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
    32123256   
     
    32303274      RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
    32313275     
     3276#if (ENCODER_FAST_MODE)
     3277      if (pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1)
     3278      {
     3279        testILR = false;
     3280      }
     3281      else
     3282      {
     3283        testILR = true;
     3284      }
     3285#endif
     3286
    32323287      for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ )
    32333288      {
     3289#if (ENCODER_FAST_MODE)
     3290        TComPic* pcPic    = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp );
     3291        if( !testILR && pcPic->getIsILR() && (ePartSize == SIZE_2Nx2N) )
     3292        {
     3293          continue;
     3294        }
     3295#endif
     3296
    32343297        uiBitsTemp = uiMbBits[iRefList];
    32353298        if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
     
    32483311        if(pcCU->getSlice()->getMvdL1ZeroFlag() && iRefList==1 && biPDistTemp < bestBiPDist)
    32493312        {
     3313#if REF_IDX_ME_ZEROMV
     3314          Bool bZeroMVILR = pcCU->xCheckZeroMVILRMvdL1Zero(iRefList, iRefIdxTemp, aaiMvpIdx[iRefList][iRefIdxTemp]);
     3315          if(bZeroMVILR)
     3316          {
     3317#endif
    32503318          bestBiPDist = biPDistTemp;
    32513319          bestBiPMvpL1 = aaiMvpIdx[iRefList][iRefIdxTemp];
    32523320          bestBiPRefIdxL1 = iRefIdxTemp;
     3321#if REF_IDX_ME_ZEROMV
     3322          }
     3323#endif
    32533324        }
    32543325
     
    33433414        }
    33443415
     3416#if ENCODER_BUGFIX
     3417        if ( ( iRefList == 0 && uiCostTemp < uiCost[iRefList] ) ||
     3418            ( iRefList == 1 &&  pcCU->getSlice()->getNoBackPredFlag() && iRefIdxTemp == iRefIdx[0] ) ||
     3419            ( iRefList == 1 && !pcCU->getSlice()->getNoBackPredFlag() && uiCostTemp < uiCost[iRefList] ) )
     3420#else
    33453421        if ( ( iRefList == 0 && uiCostTemp < uiCost[iRefList] ) ||
    33463422            ( iRefList == 1 &&  pcCU->getSlice()->getNoBackPredFlag() && iRefIdxTemp == iRefIdx[0] ) ||
    33473423            ( iRefList == 1 && (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0) && (iRefIdxTemp==0 || iRefIdxTemp == iRefIdx[0]) && !pcCU->getSlice()->getNoBackPredFlag() && (iRefIdxTemp == pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)) ) ||
    33483424            ( iRefList == 1 && !pcCU->getSlice()->getNoBackPredFlag() && uiCostTemp < uiCost[iRefList] ) )
     3425#endif
    33493426          {
    33503427            uiCost[iRefList] = uiCostTemp;
     
    33753452    }
    33763453    //  Bi-directional prediction
     3454#if REF_IDX_ME_ZEROMV
     3455    if ( (pcCU->getSlice()->isInterB()) && (pcCU->isBipredRestriction(iPartIdx) == false) && !(pcCU->getSlice()->getMvdL1ZeroFlag() && bestBiPDist == MAX_INT) )
     3456#else
    33773457    if ( (pcCU->getSlice()->isInterB()) && (pcCU->isBipredRestriction(iPartIdx) == false) )
     3458#endif
    33783459    {
    33793460     
     
    34493530        Bool bChanged = false;
    34503531       
     3532#if (ENCODER_FAST_MODE)
     3533        Bool     testIter = true;
     3534        TComPic* pcPic    = pcCU->getSlice()->getRefPic( RefPicList(1 - iRefList), iRefIdxBi[1 - iRefList] );
     3535        if(pcPic->getIsILR() && (ePartSize == SIZE_2Nx2N))
     3536          testIter = false;  //the fixed part is ILR, skip this iteration       
     3537        if(testIter)
     3538        {
     3539#endif
    34513540        iRefStart = 0;
    34523541        iRefEnd   = pcCU->getSlice()->getNumRefIdx(eRefPicList)-1;
     
    34543543        for ( Int iRefIdxTemp = iRefStart; iRefIdxTemp <= iRefEnd; iRefIdxTemp++ )
    34553544        {
     3545#if (ENCODER_FAST_MODE)
     3546            Bool testRefIdx = true;
     3547            pcPic           = pcCU->getSlice()->getRefPic( RefPicList(iRefList) , iRefIdxTemp );
     3548            if(pcPic->getIsILR() && (ePartSize == SIZE_2Nx2N))
     3549              testRefIdx = false;  //the refined part is ILR, skip this reference pic           
     3550            if(testRefIdx)
     3551            {
     3552#endif
    34563553          uiBitsTemp = uiMbBits[2] + uiMotBits[1-iRefList];
    34573554          if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
     
    34873584            }
    34883585          }
     3586#if (ENCODER_FAST_MODE)
     3587            }
     3588#endif
     3589          }
     3590#if (ENCODER_FAST_MODE)
    34893591        } // for loop-iRefIdxTemp
     3592#endif
    34903593       
    34913594        if ( !bChanged )
     
    41044207  setWpScalingDistParam( pcCU, iRefIdxPred, eRefPicList );
    41054208  //  Do integer search
     4209#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV
     4210#if REF_IDX_ME_AROUND_ZEROMV
     4211  if( pcCU->getSlice()->getRefPic(eRefPicList, iRefIdxPred )->getIsILR())  //ILR reference pic
     4212  {
     4213    xPatternSearchILR  ( pcCU, pcPatternKey, piRefY, iRefStride, rcMv, ruiCost );
     4214  }
     4215  else  //non ILR reference pic
     4216  {
    41064217  if ( !m_iFastSearch || bBi )
    41074218  {
     
    41124223    rcMv = *pcMvPred;
    41134224    xPatternSearchFast  ( pcCU, pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost );
    4114   }
     4225    }
     4226  }
     4227#endif
     4228#if REF_IDX_ME_ZEROMV
     4229  if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getIsILR())  //ILR reference pic
     4230  {
     4231    rcMv.setZero();  //use Mv(0, 0) for integer ME
     4232  }
     4233  else  //non ILR reference pic
     4234  {
     4235    if ( !m_iFastSearch || bBi )
     4236    {
     4237      xPatternSearch      ( pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost );
     4238    }
     4239    else
     4240    {
     4241      rcMv = *pcMvPred;
     4242      xPatternSearchFast  ( pcCU, pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost );
     4243    }
     4244  }
     4245#endif
     4246#else
     4247  if ( !m_iFastSearch || bBi )
     4248  {
     4249    xPatternSearch      ( pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost );
     4250  }
     4251  else
     4252  {
     4253    rcMv = *pcMvPred;
     4254    xPatternSearchFast  ( pcCU, pcPatternKey, piRefY, iRefStride, &cMvSrchRngLT, &cMvSrchRngRB, rcMv, ruiCost );
     4255  }
     4256#endif
    41154257 
    41164258  m_pcRdCost->getMotionCost( 1, 0 );
     
    41184260 
    41194261  {
     4262#if REF_IDX_ME_ZEROMV
     4263    if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getIsILR())  //ILR reference pic
     4264    {
     4265      xPatternSearchFracDIFMv0( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi );
     4266    }
     4267    else    //non ILR reference pic
     4268    {
     4269      xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost, bBi );
     4270    }
     4271#else
    41204272    xPatternSearchFracDIF( pcCU, pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost
    41214273                          ,bBi
    41224274                          );
     4275#endif
    41234276  }
    41244277 
     
    44574610Void TEncSearch::encodeResAndCalcRdInterCU( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* pcYuvPred, TComYuv*& rpcYuvResi, TComYuv*& rpcYuvResiBest, TComYuv*& rpcYuvRec, Bool bSkipRes )
    44584611{
     4612#if NO_RESIDUAL_FLAG_FOR_BLPRED
     4613  if ( pcCU->isIntra(0) && !pcCU->isIntraBL(0))
     4614#else
    44594615  if ( pcCU->isIntra(0) )
     4616#endif
    44604617  {
    44614618    return;
     
    45684725      pcCU->setTransformSkipSubParts ( 0, 0, 0, 0, pcCU->getDepth(0) );
    45694726    }
     4727#if NO_RESIDUAL_FLAG_FOR_BLPRED
     4728    else if(pcCU->getLayerId() > 0 && pcCU->isIntraBL(0) && uiZeroDistortion == uiDistortion) // all zeros
     4729    {
     4730      const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (pcCU->getDepth(0) << 1);
     4731      ::memset( pcCU->getTransformIdx()      , 0, uiQPartNum * sizeof(UChar) );
     4732      ::memset( pcCU->getCbf( TEXT_LUMA )    , 0, uiQPartNum * sizeof(UChar) );
     4733      ::memset( pcCU->getCbf( TEXT_CHROMA_U ), 0, uiQPartNum * sizeof(UChar) );
     4734      ::memset( pcCU->getCbf( TEXT_CHROMA_V ), 0, uiQPartNum * sizeof(UChar) );
     4735      ::memset( pcCU->getCoeffY()            , 0, uiWidth * uiHeight * sizeof( TCoeff )      );
     4736      ::memset( pcCU->getCoeffCb()           , 0, uiWidth * uiHeight * sizeof( TCoeff ) >> 2 );
     4737      ::memset( pcCU->getCoeffCr()           , 0, uiWidth * uiHeight * sizeof( TCoeff ) >> 2 );
     4738      pcCU->setTransformSkipSubParts ( 0, 0, 0, 0, pcCU->getDepth(0) );
     4739    }
     4740#endif
    45704741    else
    45714742    {
     
    48665037      Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA];
    48675038      assert(scalingListType < 6);     
     5039#if NO_RESIDUAL_FLAG_FOR_BLPRED
     5040      if(pcCU->isIntraBL(uiAbsPartIdx) )
     5041      {
     5042        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,DC_IDX, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
     5043      }
     5044      else
     5045      {
     5046        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
     5047      }
     5048#else
    48685049      m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
     5050#endif
    48695051     
    48705052      const UInt uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),
     
    51365318        assert(scalingListType < 6);     
    51375319
     5320#if NO_RESIDUAL_FLAG_FOR_BLPRED
     5321        if(pcCU->isIntraBL(uiAbsPartIdx) )
     5322        {
     5323          m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,DC_IDX, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
     5324        }
     5325        else
     5326        {
     5327          m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
     5328        }
     5329#else
    51385330        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
     5331#endif
    51395332
    51405333        uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),
     
    54675660
    54685661  {
     5662#if INTRA_BL
     5663#if NO_RESIDUAL_FLAG_FOR_BLPRED
     5664    assert( !pcCU->isIntra(uiAbsPartIdx) || pcCU->isIntraBL(uiAbsPartIdx));
     5665#else
     5666    assert( !pcCU->isIntra(uiAbsPartIdx) );
     5667#endif
     5668#else
    54695669    assert( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA );
     5670#endif
    54705671    if( bSubdivAndCbf )
    54715672    {
     
    57015902    }
    57025903    m_pcEntropyCoder->encodeSkipFlag ( pcCU, 0, true );
     5904#if INTRA_BL
     5905    if(m_pcEncCfg->getLayerId())
     5906    {
     5907      m_pcEntropyCoder->encodeIntraBLFlag(pcCU, 0, true);
     5908#if !NO_RESIDUAL_FLAG_FOR_BLPRED
     5909      assert( pcCU->isIntraBL( 0 ) == false );
     5910#endif
     5911    }
     5912#endif
     5913#if NO_RESIDUAL_FLAG_FOR_BLPRED
     5914    if( !pcCU->isIntraBL(0))
     5915    {
     5916#endif
    57035917    m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    57045918    m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
    57055919    m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
     5920#if NO_RESIDUAL_FLAG_FOR_BLPRED
     5921    }
     5922#endif
    57065923    Bool bDummy = false;
    57075924    m_pcEntropyCoder->encodeCoeff   ( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0), bDummy );
     
    59526169}
    59536170
     6171#if REF_IDX_ME_ZEROMV
     6172Void TEncSearch::xPatternSearchFracDIFMv0(TComDataCU* pcCU,
     6173                                          TComPattern* pcPatternKey,
     6174                                          Pel* piRefY,
     6175                                          Int iRefStride,
     6176                                          TComMv* pcMvInt,
     6177                                          TComMv& rcMvHalf,
     6178                                          TComMv& rcMvQter,
     6179                                          UInt& ruiCost,
     6180                                          Bool biPred
     6181                                          )
     6182{
     6183  assert(pcMvInt->getHor() == 0 && pcMvInt->getVer() == 0);
     6184  Int         iOffset    = pcMvInt->getHor() + pcMvInt->getVer() * iRefStride;
     6185  m_pcRdCost->setDistParam( pcPatternKey, piRefY + iOffset, iRefStride, 1, m_cDistParam, m_pcEncCfg->getUseHADME() );
     6186  m_pcRdCost->setCostScale ( 2 );
     6187  setDistParamComp(0);
     6188  ruiCost = m_cDistParam.DistFunc( &m_cDistParam );  //SATD
     6189  ruiCost += m_pcRdCost->getCost( pcMvInt->getHor(), pcMvInt->getVer() );  //SATD rdCost
     6190  rcMvHalf.setZero();
     6191  rcMvQter.setZero();
     6192}
     6193#endif
     6194
     6195#if REF_IDX_ME_AROUND_ZEROMV
     6196//ILR integer pixel motion estimation search
     6197//pcCU is CU pointer
     6198//pcPatterney contains target PU infor
     6199//piRefY is the PU at the same position as the source PU, but in the reference pic
     6200//iRefStride is the reference stride
     6201//rcMv output best integer MV
     6202//ruiSAD outputs the SAD of best integer MV
     6203Void TEncSearch::xPatternSearchILR( TComDataCU* pcCU, TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, TComMv& rcMv, UInt& ruiSAD )
     6204{
     6205  Int      candMvX[5] = {0, -1, 1,  0, 0};
     6206  Int      candMvY[5] = {0,  0, 0, -1, 1};
     6207  Int      numCand    = 1;
     6208  Int      iBestX = 0;
     6209  Int      iBestY = 0;
     6210  Int      uiSadBest = MAX_UINT;
     6211  UInt     uiSad;
     6212
     6213  Pel*  piRefSrch;
     6214
     6215  //-- jclee for using the SAD function pointer
     6216  m_pcRdCost->setDistParam( pcPatternKey, piRefY, iRefStride,  m_cDistParam );
     6217
     6218  // fast encoder decision: use subsampled SAD for integer ME
     6219  if ( m_pcEncCfg->getUseFastEnc() )
     6220  {
     6221    if ( m_cDistParam.iRows > 8 )
     6222    {
     6223      m_cDistParam.iSubShift = 1;
     6224    }
     6225  }
     6226
     6227  for(Int candId = 0; candId < numCand; candId++)
     6228  {
     6229    piRefSrch         = piRefY + (candMvY[candId] * iRefStride) + candMvX[candId];
     6230    m_cDistParam.pCur = piRefSrch;
     6231
     6232    setDistParamComp(0);
     6233   
     6234    uiSad = m_cDistParam.DistFunc( &m_cDistParam );  //SAD
     6235
     6236    //motion cost
     6237    uiSad += m_pcRdCost->getCost( candMvX[candId], candMvY[candId] );  //SAD rdCost
     6238
     6239    if(uiSad < uiSadBest)
     6240    {
     6241      uiSadBest = uiSad;
     6242      iBestX    = candMvX[candId];
     6243      iBestY    = candMvY[candId];
     6244    }
     6245  }
     6246
     6247  rcMv.set( iBestX, iBestY );
     6248
     6249  ruiSAD = uiSadBest - m_pcRdCost->getCost( iBestX, iBestY );
     6250  return;
     6251}
     6252#endif
     6253
     6254#if ENCODER_FAST_MODE
     6255Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv )
     6256{
     6257  rpcPredYuv->clear();
     6258  rpcRecoYuv->clear();
     6259
     6260  Int           iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;
     6261
     6262  TComMv        cMv[2];
     6263  TComMv        cMvPred[2][33];
     6264  TComMv        cMvTemp[2][33];
     6265  TComMv        TempMv;
     6266
     6267  Int           iRefIdx[2]={0,0};
     6268
     6269  Int           aaiMvpIdx[2][33];
     6270  Int           aaiMvpNum[2][33];
     6271
     6272  UInt          uiMbBits[3] = {1, 1, 0};
     6273  UInt          uiLastMode = 0;
     6274
     6275  UInt          uiCost[2]   = { MAX_UINT, MAX_UINT };     //uni, rdCost
     6276  UInt          uiCostTemp;
     6277  UInt          biPDistTemp = MAX_INT;
     6278  UInt          uiBitsTemp;
     6279
     6280  PartSize      ePartSize = pcCU->getPartitionSize( 0 );  //2Nx2N
     6281  Int           iPartIdx  = 0;                            //one PU in CU
     6282  UInt          uiPartAddr;
     6283  Int           iRoiWidth, iRoiHeight;
     6284
     6285  xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
     6286  pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
     6287
     6288  for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++)  //list
     6289  {
     6290    RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
     6291
     6292    Int  iRefIdxTemp = -1;
     6293    Bool foundILR    = false;
     6294    for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ )
     6295      if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->getIsILR() )
     6296      {
     6297        iRefIdxTemp = refIdx;
     6298        foundILR    = true;
     6299        break;
     6300      }
     6301
     6302    if(!foundILR)  //no ILR in eRefPiclist
     6303      continue; 
     6304
     6305    uiBitsTemp = uiMbBits[iRefList];
     6306    if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
     6307    {
     6308      uiBitsTemp += iRefIdxTemp+1;
     6309      if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
     6310    }
     6311
     6312    xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp);
     6313    aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr);
     6314    aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr);
     6315
     6316    uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
     6317
     6318    xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     6319    xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
     6320
     6321    if( uiCostTemp < uiCost[iRefList] )
     6322    {
     6323      uiCost[iRefList] = uiCostTemp;
     6324
     6325      cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
     6326      iRefIdx[iRefList] = iRefIdxTemp;
     6327
     6328      pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     6329      pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     6330    }
     6331  }
     6332
     6333  if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT )  //no ILR in both list0 and list1
     6334    return false;
     6335
     6336  //  Clear Motion Field
     6337  pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
     6338  pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
     6339  pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
     6340  pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
     6341
     6342  pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6343  pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6344  pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6345  pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6346
     6347  if( uiCost[0] <= uiCost[1] )  //list0 ILR
     6348  {
     6349    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv    ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx );
     6350    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx );
     6351
     6352    TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
     6353    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
     6354
     6355    pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
     6356
     6357    pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6358    pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6359  }
     6360  else if( uiCost[1] < uiCost[0] )  //list1 ILR
     6361  {
     6362    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv    ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx );
     6363    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx );
     6364
     6365    TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
     6366    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
     6367
     6368    pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
     6369
     6370    pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6371    pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6372  }
     6373  else
     6374    assert(0);
     6375
     6376  pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
     6377
     6378  motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx );
     6379
     6380  setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
     6381
     6382  return true;
     6383}
     6384
     6385
     6386#endif
     6387
     6388#if INTRA_BL
     6389Void
     6390TEncSearch::estIntraBLPredQT( TComDataCU* pcCU,
     6391                           TComYuv*    pcOrgYuv,
     6392                           TComYuv*    pcPredYuv,
     6393                           TComYuv*    pcResiYuv,
     6394                           TComYuv*    pcRecoYuv )
     6395{
     6396  UInt    uiDepth        = pcCU->getDepth(0);
     6397  UInt    uiOverallDistY = 0;
     6398  UInt    uiOverallDistC = 0;
     6399 
     6400  //===== set QP and clear Cbf =====
     6401  if ( pcCU->getSlice()->getPPS()->getUseDQP() == true)
     6402  {
     6403    pcCU->setQPSubParts( pcCU->getQP(0), 0, uiDepth );
     6404  }
     6405  else
     6406  {
     6407    pcCU->setQPSubParts( pcCU->getSlice()->getSliceQp(), 0, uiDepth );
     6408  }
     6409 
     6410  //===== init pattern for luma prediction =====
     6411  Bool bAboveAvail = false;
     6412  Bool bLeftAvail  = false;
     6413  pcCU->getPattern()->initPattern   ( pcCU, 0, 0 );
     6414  pcCU->getPattern()->initAdiPattern( pcCU, 0, 0, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
     6415 
     6416  pcCU->setLumaIntraDirSubParts ( DC_IDX, 0, uiDepth );
     6417 
     6418  // set context models
     6419  if( m_bUseSBACRD )
     6420  {
     6421    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
     6422  }
     6423 
     6424  // determine residual for partition
     6425  Double dPUCost   = 0.0;
     6426  xRecurIntraCodingQT( pcCU, 0, 0, false, pcOrgYuv, pcPredYuv, pcResiYuv, uiOverallDistY, uiOverallDistC, false, dPUCost );
     6427  xSetIntraResultQT( pcCU, 0, 0, false, pcRecoYuv );
     6428 
     6429  //=== update PU data ====
     6430  pcCU->copyToPic( uiDepth, 0, 0 );
     6431   
     6432  //===== reset context models =====
     6433  if(m_bUseSBACRD)
     6434  {
     6435    m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
     6436  }
     6437
     6438  //===== set distortion (rate and r-d costs are determined later) =====
     6439  pcCU->getTotalDistortion() = uiOverallDistY + uiOverallDistC;
     6440}
     6441
     6442#endif
    59546443//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncSearch.h

    r51 r54  
    9797  TEncCfg*        m_pcEncCfg;
    9898 
     99#if SVC_EXTENSION
     100  TEncTop**       m_ppcTEncTop;
     101#if INTRA_BL
     102  TComPicYuv*     m_pcPicYuvRecBase;       ///< reconstructed base layer
     103#endif
     104#endif
     105 
    99106  // interface to classes
    100107  TComTrQuant*    m_pcTrQuant;
     
    186193                                  UInt        uiPreCalcDistC );
    187194 
     195#if INTRA_BL
     196  Void setBaseRecPic            ( TComPicYuv* pcPicYuvRecBase ) { m_pcPicYuvRecBase = pcPicYuvRecBase; } 
     197  TComPicYuv* getBaseRecPic     ()                              { return m_pcPicYuvRecBase; }
     198  Void  estIntraBLPredQT        ( TComDataCU* pcCU,
     199                                  TComYuv*    pcOrgYuv,
     200                                  TComYuv*    pcPredYuv,
     201                                  TComYuv*    pcResiYuv,
     202                                  TComYuv*    pcRecoYuv );
     203#endif
    188204 
    189205  /// encoder estimation - inter prediction (non-skip)
     
    198214#endif
    199215                                );
     216 
     217#if (ENCODER_FAST_MODE)
     218  Bool predInterSearchILRUni    ( TComDataCU* pcCU,
     219                                  TComYuv*    pcOrgYuv,
     220                                  TComYuv*&   rpcPredYuv,
     221                                  TComYuv*&   rpcResiYuv,
     222                                  TComYuv*&   rpcRecoYuv
     223                                );
     224
     225#endif
    200226 
    201227  /// encode residual and compute rd-cost for inter mode
     
    436462                                   ,Bool biPred
    437463                                   );
    438  
     464#if REF_IDX_ME_AROUND_ZEROMV
     465  Void xPatternSearchILR         ( TComDataCU*    pcCU,
     466                                   TComPattern*   pcPatternKey,
     467                                   Pel*           piRefY,
     468                                   Int            iRefStride,
     469                                   TComMv&        rcMv,
     470                                   UInt&          ruiSAD );
     471#endif
     472 
     473#if REF_IDX_ME_ZEROMV
     474  Void xPatternSearchFracDIFMv0  ( TComDataCU*   pcCU,
     475                                   TComPattern*  pcPatternKey,
     476                                   Pel*          piRefY,
     477                                   Int           iRefStride,
     478                                   TComMv*       pcMvInt,
     479                                   TComMv&       rcMvHalf,
     480                                   TComMv&       rcMvQter,
     481                                   UInt&         ruiCost,
     482                                   Bool          biPred );
     483#endif
    439484  Void xExtDIFUpSamplingH( TComPattern* pcPattern, Bool biPred  );
    440485  Void xExtDIFUpSamplingQ( TComPattern* pcPatternKey, TComMv halfPelRef, Bool biPred );
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncSlice.cpp

    r51 r54  
    137137  m_pcCfg             = pcEncTop;
    138138  m_pcListPic         = pcEncTop->getListPic();
    139  
     139#if SVC_EXTENSION
     140  m_ppcTEncTop        = pcEncTop->getLayerEnc();
     141#endif 
    140142  m_pcGOPEncoder      = pcEncTop->getGOPEncoder();
    141143  m_pcCuEncoder       = pcEncTop->getCuEncoder();
     
    186188  rpcSlice->setSliceBits(0);
    187189  rpcSlice->setPic( pcPic );
     190#if SET_SLICE_LAYER_ID
     191  rpcSlice->initSlice( pcPic->getLayerId() );
     192#else
    188193  rpcSlice->initSlice();
     194#endif
    189195  rpcSlice->setPicOutputFlag( true );
    190196  rpcSlice->setPOC( pocCurr );
     197#if SVC_EXTENSION && !SET_SLICE_LAYER_ID
     198  rpcSlice->setLayerId( pcPic->getLayerId());
     199#endif
    191200 
    192201  // depth computation based on GOP size
     
    369378  eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
    370379 
     380#if REF_IDX_FRAMEWORK
     381  if(m_pcCfg->getLayerId() > 0)
     382  {
     383    eSliceType=B_SLICE;
     384  }
     385#endif
    371386  rpcSlice->setSliceType        ( eSliceType );
    372387#endif
     
    877892  UInt uiTileStartLCU = 0;
    878893  UInt uiTileLCUX     = 0;
     894
     895#if INTRA_BL
     896  m_pcCuEncoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec() : NULL);
     897#endif
     898
    879899  Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag();
    880900  uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
     
    924944    TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
    925945    pcCU->initCU( rpcPic, uiCUAddr );
     946#if SVC_EXTENSION
     947    pcCU->setLayerId(m_pcCfg->getLayerId());
     948#endif
    926949
    927950#if !RATE_CONTROL_LAMBDA_DOMAIN
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncSlice.h

    r51 r54  
    6666  TEncCfg*                m_pcCfg;                              ///< encoder configuration class
    6767 
     68#if SVC_EXTENSION
     69  TEncTop**               m_ppcTEncTop;
     70#endif 
     71
    6872  // pictures
    6973  TComList<TComPic*>*     m_pcListPic;                          ///< list of pictures
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncTop.cpp

    r51 r54  
    4545//! \ingroup TLibEncoder
    4646//! \{
     47#if SVC_EXTENSION 
     48Int TEncTop::m_iSPSIdCnt = 0;
     49Int TEncTop::m_iPPSIdCnt = 0;
     50#endif
    4751
    4852// ====================================================================================================================
     
    7882  m_pcBitCounters          = NULL;
    7983  m_pcRdCosts              = NULL;
     84#if REF_IDX_FRAMEWORK
     85  memset(m_cIlpPic, 0, sizeof(m_cIlpPic));
     86#endif
     87#if REF_IDX_MFM
     88  m_bMFMEnabledFlag = false;
     89#endif
    8090}
    8191
     
    8999Void TEncTop::create ()
    90100{
     101#if !SVC_EXTENSION
    91102  // initialize global variables
    92103  initROM();
     104#endif
    93105 
    94106  // create processing unit classes
     107#if SVC_EXTENSION
     108  m_cGOPEncoder.        create( m_layerId );
     109#else
    95110  m_cGOPEncoder.        create();
     111#endif
    96112  m_cSliceEncoder.      create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
    97113  m_cCuEncoder.         create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
     
    268284  delete[] m_pcRdCosts;
    269285 
     286#if !SVC_EXTENSION
    270287  // destroy ROM
    271288  destroyROM();
    272  
     289#endif
     290#if REF_IDX_FRAMEWORK
     291  for(Int i=0; i<MAX_NUM_REF; i++)
     292  {
     293    if(m_cIlpPic[i])
     294    {
     295      //m_cIlpPic[i]->setPicYuvRec(NULL);
     296      m_cIlpPic[i]->destroy();
     297      delete m_cIlpPic[i];
     298      m_cIlpPic[i] = NULL;
     299    }
     300  }   
     301#endif
    273302  return;
    274303}
     
    313342
    314343  m_iMaxRefPicNum = 0;
     344#if SVC_EXTENSION
     345  m_iSPSIdCnt ++;
     346  m_iPPSIdCnt ++;
     347#endif
     348#if REF_IDX_FRAMEWORK
     349  xInitILRP();
     350#endif
    315351}
    316352
     
    345381 \retval  iNumEncoded         number of encoded pictures
    346382 */
    347 Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded )
     383#if SVC_EXTENSION
     384Void TEncTop::encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP )
     385{
     386  // compress GOP
     387#if RATE_CONTROL_LAMBDA_DOMAIN
     388  if ( m_RCEnableRateControl )
     389  {
     390    m_cRateCtrl.initRCGOP( m_iNumPicRcvd );
     391  }
     392#endif
     393
     394  // compress GOP
     395  m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut);
     396
     397#if RATE_CONTROL_LAMBDA_DOMAIN
     398  if ( m_RCEnableRateControl )
     399  {
     400    m_cRateCtrl.destroyRCGOP();
     401  }
     402#endif
     403 
     404  m_uiNumAllPicCoded ++;
     405}
     406
     407Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg )
    348408{
    349409  if (pcPicYuvOrg) {
     
    359419    }
    360420  }
     421}
     422#else
     423Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded )
     424{
     425  if (pcPicYuvOrg) {
     426    // get original YUV
     427    TComPic* pcPicCurr = NULL;
     428    xGetNewPicBuffer( pcPicCurr );
     429    pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
     430
     431    // compute image characteristics
     432    if ( getUseAdaptiveQP() )
     433    {
     434      m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
     435    }
     436  }
    361437 
    362438  if (!m_iNumPicRcvd || (!flush && m_iPOCLast != 0 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize))
     
    387463  m_uiNumAllPicCoded += iNumEncoded;
    388464}
     465#endif
    389466
    390467// ====================================================================================================================
     
    421498    {
    422499      TEncPic* pcEPic = new TEncPic;
     500#if SVC_EXTENSION //Temporal solution, should be modified
     501      if(m_layerId > 0)
     502      {
     503        TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 );
     504        if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() )
     505        {
     506          pcEPic->setSpatialEnhLayerFlag( true );
     507        }
     508      }
     509#endif
     510
     511#if SVC_UPSAMPLING
     512      pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
     513                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS);
     514#else
    423515      pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
    424516                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
     517#endif
    425518      rpcPic = pcEPic;
    426519    }
     
    429522      rpcPic = new TComPic;
    430523
     524#if SVC_EXTENSION //Temporal solution, should be modified
     525      if(m_layerId > 0)
     526      {
     527        TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 );
     528        if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() )
     529        {
     530          rpcPic->setSpatialEnhLayerFlag( true );
     531        }
     532      }
     533#endif
     534
     535#if SVC_UPSAMPLING
     536      rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     537                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS);
     538#else
    431539      rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    432540                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
     541#endif
    433542    }
    434543    if (getUseSAO())
     
    450559Void TEncTop::xInitSPS()
    451560{
     561#if SVC_EXTENSION
     562  m_cSPS.setLayerId(m_layerId);
     563#endif
     564#if REF_IDX_MFM
     565  m_cSPS.setMFMEnabledFlag(m_bMFMEnabledFlag);
     566#endif
    452567  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
    453568  profileTierLevel.setLevelIdc(m_level);
     
    484599  m_cSPS.setMinTrDepth    ( 0                   );
    485600  m_cSPS.setMaxTrDepth    ( 1                   );
     601#if SVC_EXTENSION
     602  m_cSPS.setSPSId         ( m_iSPSIdCnt       );
     603#endif
    486604 
    487605  m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize);
     
    690808    }
    691809  }
     810#if SVC_EXTENSION
     811  m_cPPS.setPPSId         ( m_iPPSIdCnt         );
     812  m_cPPS.setSPSId         ( m_iSPSIdCnt         );
     813#endif
    692814}
    693815
     
    9811103  }
    9821104}
     1105
     1106#if REF_IDX_FRAMEWORK
     1107Void TEncTop::xInitILRP()
     1108{
     1109  if(m_layerId>0)
     1110  {
     1111    if (m_cIlpPic[0] == NULL)
     1112    {
     1113      for (Int j=0; j<1/*MAX_NUM_REF*/; j++)
     1114      {
     1115        m_cIlpPic[j] = new  TComPic;
     1116        //m_cIlpPic[j]->createWithOutYuv(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, &m_cSPS, true);
     1117#if SVC_UPSAMPLING
     1118        m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, &m_cSPS, true);
     1119#else
     1120        m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
     1121#endif
     1122#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
     1123        m_cIlpPic[j]->setIsILR(true);
     1124#endif
     1125        for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++)
     1126        {
     1127          m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i);
     1128        }
     1129      }
     1130    }
     1131  }
     1132}
     1133
     1134Void TEncTop::setILRPic(TComPic *pcPic)
     1135{
     1136  if(m_cIlpPic[0])
     1137  {
     1138    //m_cIlpPic[0]->setPicYuvRec(pcPic->getFullPelBaseRec());
     1139    m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec());
     1140    m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC());
     1141    m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false);
     1142    m_cIlpPic[0]->getPicYuvRec()->extendPicBorder();
     1143  }
     1144}
     1145#endif
    9831146//! \}
  • branches/HM-10.0-dev-SHM/source/Lib/TLibEncoder/TEncTop.h

    r51 r54  
    7373  UInt                    m_uiNumAllPicCoded;             ///< number of coded pictures
    7474  TComList<TComPic*>      m_cListPic;                     ///< dynamic list of pictures
     75#if SVC_EXTENSION
     76  static Int              m_iSPSIdCnt;                    ///< next Id number for SPS   
     77  static Int              m_iPPSIdCnt;                    ///< next Id number for PPS   
     78#if AVC_SYNTAX
     79  fstream*                m_pBLSyntaxFile;
     80#endif
     81#endif
    7582 
    7683  // encoder search
     
    122129  TEncRateCtrl            m_cRateCtrl;                    ///< Rate control class
    123130 
     131#if SVC_EXTENSION
     132  TEncTop**               m_ppcTEncTop;
     133  TEncTop*                getLayerEnc(UInt layer)   { return m_ppcTEncTop[layer]; }
     134#endif
     135#if REF_IDX_FRAMEWORK
     136  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
     137#endif
     138#if REF_IDX_MFM
     139  Bool                    m_bMFMEnabledFlag;
     140#endif
    124141protected:
    125142  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
     
    129146  Void  xInitPPSforTiles  ();
    130147  Void  xInitRPS          ();                             ///< initialize PPS from encoder options
    131 
     148#if REF_IDX_FRAMEWORK
     149  Void xInitILRP();
     150#endif
    132151public:
    133152  TEncTop();
     
    174193  Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid );
    175194  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
     195#if SVC_EXTENSION
     196  Void                    setLayerEnc(TEncTop** p) {m_ppcTEncTop = p;}
     197  TEncTop**               getLayerEnc()            {return m_ppcTEncTop;}
     198  Int                     getPOCLast            () { return m_iPOCLast;               }
     199  Int                     getNumPicRcvd         () { return m_iNumPicRcvd;            }
     200  Void                    setNumPicRcvd         ( Int num ) { m_iNumPicRcvd = num;      }
     201#endif
     202
    176203  // -------------------------------------------------------------------------------------------------------------------
    177204  // encoder function
     
    179206
    180207  /// encode several number of pictures until end-of-sequence
     208#if SVC_EXTENSION
     209#if REF_IDX_FRAMEWORK
     210  TComPic** getIlpList() { return m_cIlpPic; }
     211  Void setILRPic(TComPic *pcPic);
     212#endif
     213#if REF_IDX_MFM
     214  Void setMFMEnabledFlag       (Bool flag)   {m_bMFMEnabledFlag = flag;}
     215  Bool getMFMEnabledFlag()                   {return m_bMFMEnabledFlag;}   
     216#endif
     217#if AVC_SYNTAX
     218  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
     219  fstream*  getBLSyntaxFile() { return m_pBLSyntaxFile; }
     220#endif
     221  Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
     222              std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP  );
     223  Void encodePrep( TComPicYuv* pcPicYuvOrg );
     224#else
    181225  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
    182226              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 
     227#endif
    183228
    184229  void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); }
Note: See TracChangeset for help on using the changeset viewer.