Changeset 368 in 3DVCSoftware


Ignore:
Timestamp:
3 May 2013, 17:16:12 (11 years ago)
Author:
tech
Message:

Fixed erroneously removed parts.

Location:
branches/HTM-DEV-0.1-dev/source
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecCfg.cpp

    r367 r368  
    4242#include "TAppCommon/program_options_lite.h"
    4343
     44#if H_MV
     45#include <cassert>
     46#endif
    4447#ifdef WIN32
    4548#define strdup _strdup
     
    7578  ("OutputBitDepth,d", m_outputBitDepthY, 0, "bit depth of YUV output luma component (default: use 0 for native depth)")
    7679  ("OutputBitDepthC,d", m_outputBitDepthC, 0, "bit depth of YUV output chroma component (default: use 0 for native depth)")
     80#if H_MV
     81  ("MaxLayerId,-ls", m_maxLayerId, MAX_NUM_LAYER_IDS-1, "Maximum LayerId to be decoded.")
     82#endif
    7783  ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers")
    7884  ("SEIDecodedPictureHash", m_decodedPictureHashSEIEnabled, 1, "Control handling of decoded picture hash SEI messages\n"
     
    151157    }
    152158  }
     159#if H_MV
     160  else
     161  {
     162    for ( Int curLayerId = 0; curLayerId <= m_maxLayerId; curLayerId++ )
     163    {
     164      m_targetDecLayerIdSet.push_back( curLayerId );
     165    }
     166  }
     167#endif
    153168
    154169  return true;
    155170}
    156171
     172#if H_MV
     173Void TAppDecCfg::xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName)
     174{
     175  size_t iInLength     = strlen(pchInputFileName);
     176  size_t iAppendLength = strlen(pchStringToAppend);
     177
     178  rpchOutputFileName = (Char*) malloc(iInLength+iAppendLength+1);                       
     179  Char* pCDot = strrchr(pchInputFileName,'.');         
     180  pCDot = pCDot ? pCDot : pchInputFileName + iInLength;       
     181  size_t iCharsToDot = pCDot - pchInputFileName ;
     182  size_t iCharsToEnd = iInLength - iCharsToDot;         
     183  strncpy(rpchOutputFileName                            ,  pchInputFileName            , iCharsToDot  );
     184  strncpy(rpchOutputFileName+ iCharsToDot               ,  pchStringToAppend           , iAppendLength);
     185  strncpy(rpchOutputFileName+ iCharsToDot+iAppendLength ,  pchInputFileName+iCharsToDot, iCharsToEnd  );       
     186  rpchOutputFileName[iInLength+iAppendLength] = '\0';         
     187}
     188#endif
    157189//! \}
  • branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecCfg.h

    r367 r368  
    5858protected:
    5959  Char*         m_pchBitstreamFile;                   ///< input bitstream file name
     60#if H_MV
     61  Int           m_maxLayerId;                         ///< maximum nuh_layer_id decoded
     62  std::vector<Char*> m_pchReconFiles;                 ///< array of output reconstruction file name create from output reconstruction file name
     63#endif
    6064  Char*         m_pchReconFile;                       ///< output reconstruction file name
    6165  Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
     
    6973  Int           m_respectDefDispWindow;               ///< Only output content inside the default display window
    7074
     75#if H_MV
     76  Void xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName); ///< create filenames
     77#endif
    7178public:
    7279  TAppDecCfg()
    7380  : m_pchBitstreamFile(NULL)
     81#if H_MV
     82  , m_maxLayerId(0)
     83  , m_pchReconFiles(NULL)
     84#endif
    7485  , m_pchReconFile(NULL)
    7586  , m_iSkipFrame(0)
  • branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecTop.cpp

    r367 r368  
    5454
    5555TAppDecTop::TAppDecTop()
     56#if !H_MV
    5657: m_iPOCLastDisplay(-MAX_INT)
     58#else
     59: m_numDecoders( 0 )
     60#endif
    5761{
    5862  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
     63#if H_MV
     64  for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) m_layerIdToDecIdx[i] = -1;
     65#endif
    5966}
    6067
     
    7077    m_pchBitstreamFile = NULL;
    7178  }
     79#if H_MV
     80  for (Int decIdx = 0; decIdx < m_numDecoders; decIdx++)
     81  {
     82    if (m_pchReconFiles[decIdx])
     83    {
     84      free (m_pchReconFiles[decIdx]);
     85      m_pchReconFiles[decIdx] = NULL;
     86    }
     87  }
     88#endif
    7289  if (m_pchReconFile)
    7390  {
     
    92109{
    93110  Int                 poc;
     111#if H_MV
     112  poc = -1;
     113#endif
    94114  TComList<TComPic*>* pcListPic = NULL;
    95115
     
    106126  xCreateDecLib();
    107127  xInitDecLib  ();
     128#if !H_MV
    108129  m_iPOCLastDisplay += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
    109130
    110131  // main decoder loop
    111132  Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
     133#else
     134  Int  pocCurrPic        = -MAX_INT;     
     135  Int  pocLastPic        = -MAX_INT;   
     136 
     137  Int  layerIdLastPic    = 0;
     138  Int  layerIdCurrPic    = 0;
     139
     140  Int  decIdxLastPic     = 0;
     141  Int  decIdxCurrPic     = 0;
     142
     143  Bool firstSlice        = true;
     144#endif
    112145 
    113146  while (!!bitstreamFile)
     
    119152    streampos location = bitstreamFile.tellg();
    120153    AnnexBStats stats = AnnexBStats();
     154#if !H_MV
    121155    Bool bPreviousPictureDecoded = false;
     156#endif
    122157
    123158    vector<uint8_t> nalUnit;
     
    127162    // call actual decoding function
    128163    Bool bNewPicture = false;
     164#if H_MV
     165    Bool newSliceDiffPoc   = false;
     166    Bool newSliceDiffLayer = false;
     167    Bool allLayersDecoded  = false;     
     168#endif
    129169    if (nalUnit.empty())
    130170    {
     
    139179    {
    140180      read(nalu, nalUnit);
     181#if H_MV     
     182      Int decIdx     = xGetDecoderIdx( nalu.m_layerId , true );
     183     
     184      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) )
     185      {
     186        bNewPicture = false;
     187      }
     188      else
     189      {
     190        newSliceDiffLayer = nalu.isSlice() && ( nalu.m_layerId != layerIdCurrPic ) && !firstSlice;
     191        newSliceDiffPoc   = m_tDecTop[decIdx]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[decIdx], newSliceDiffLayer );
     192        // decode function only returns true when all of the following conditions are true
     193        // - poc in particular layer changes
     194        // - nalu does not belong to first slice in layer
     195        // - nalu.isSlice() == true     
     196
     197        bNewPicture       = newSliceDiffLayer || newSliceDiffPoc;
     198
     199        if ( nalu.isSlice() && firstSlice )
     200        {
     201          layerIdCurrPic = nalu.m_layerId;
     202          pocCurrPic     = m_tDecTop[decIdx]->getCurrPoc();
     203          decIdxCurrPic  = decIdx;
     204          firstSlice     = false;
     205        }
     206
     207        if ( bNewPicture || !bitstreamFile )
     208        {
     209          layerIdLastPic    = layerIdCurrPic; 
     210          layerIdCurrPic    = nalu.m_layerId;
     211         
     212          pocLastPic        = pocCurrPic;
     213          pocCurrPic        = m_tDecTop[decIdx]->getCurrPoc();
     214         
     215          decIdxLastPic     = decIdxCurrPic;
     216          decIdxCurrPic     = decIdx;
     217
     218          allLayersDecoded = ( pocCurrPic != pocLastPic );
     219        }
     220
     221       
     222#else
    141223      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu)  )
    142224      {
     
    154236      {
    155237        bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay);
     238#endif
    156239        if (bNewPicture)
    157240        {
     
    164247          bytestream.reset();
    165248        }
     249#if !H_MV
    166250        bPreviousPictureDecoded = true;
     251#endif
    167252      }
    168253    }
    169254    if (bNewPicture || !bitstreamFile)
    170255    {
     256#if H_MV
     257      assert( decIdxLastPic != -1 );
     258      m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet );
     259#else
    171260      m_cTDecTop.executeLoopFilters(poc, pcListPic);
    172     }
     261#endif
     262    }
     263#if H_3D
     264    if ( allLayersDecoded || !bitstreamFile )
     265    {
     266      for( Int dI = 0; dI < m_numDecoders; dI++ )
     267      {
     268        TComPic* picLastCoded = m_ivPicLists.getPic( m_tDecTop[dI]->getLayerId(), pocLastPic );
     269        assert( picLastCoded != NULL );       
     270        picLastCoded->compressMotion();         
     271      }
     272    }
     273#endif
    173274
    174275    if( pcListPic )
    175276    {
     277#if H_MV
     278      if ( m_pchReconFiles[decIdxLastPic] && !m_reconOpen[decIdxLastPic] )
     279#else
    176280      if ( m_pchReconFile && !recon_opened )
     281#endif
    177282      {
    178283        if (!m_outputBitDepthY) { m_outputBitDepthY = g_bitDepthY; }
    179284        if (!m_outputBitDepthC) { m_outputBitDepthC = g_bitDepthC; }
    180285
     286#if H_MV
     287        m_tVideoIOYuvReconFile[decIdxLastPic]->open( m_pchReconFiles[decIdxLastPic], true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
     288        m_reconOpen[decIdxLastPic] = true;
     289      }
     290      if ( bNewPicture && newSliceDiffPoc &&
     291#else
    181292        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, g_bitDepthY, g_bitDepthC ); // write mode
    182293        recon_opened = true;
    183294      }
    184295      if ( bNewPicture &&
     296#endif
    185297           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    186298            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
     
    189301            || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP ) )
    190302      {
     303#if H_MV
     304        xFlushOutput( pcListPic, decIdxLastPic );
     305#else
    191306        xFlushOutput( pcListPic );
     307#endif
    192308      }
    193309      // write reconstruction to file
    194310      if(bNewPicture)
    195311      {
     312#if H_MV
     313        xWriteOutput( pcListPic, decIdxLastPic, nalu.m_temporalId );
     314      }
     315    }
     316  }
     317
     318  for(UInt decIdx = 0; decIdx < m_numDecoders; decIdx++)
     319  {
     320    xFlushOutput( m_tDecTop[decIdx]->getListPic(), decIdx );
     321  }
     322#else
    196323        xWriteOutput( pcListPic, nalu.m_temporalId );
    197324      }
     
    202329  // delete buffers
    203330  m_cTDecTop.deletePicBuffer();
     331#endif
    204332     
    205333  // destroy internal classes
     
    213341Void TAppDecTop::xCreateDecLib()
    214342{
     343#if H_MV
     344  // initialize global variables
     345  initROM(); 
     346#else
    215347  // create decoder class
    216348  m_cTDecTop.create();
     349#endif
    217350}
    218351
    219352Void TAppDecTop::xDestroyDecLib()
    220353{
     354#if H_MV
     355  // destroy ROM
     356  destroyROM();
     357
     358  for(Int decIdx = 0; decIdx < m_numDecoders ; decIdx++)
     359  {
     360    if( m_tVideoIOYuvReconFile[decIdx] )
     361    {
     362      m_tVideoIOYuvReconFile[decIdx]->close();
     363      delete m_tVideoIOYuvReconFile[decIdx];
     364      m_tVideoIOYuvReconFile[decIdx] = NULL ;
     365    }
     366
     367    if( m_tDecTop[decIdx] )
     368    {
     369      m_tDecTop[decIdx]->deletePicBuffer();
     370      m_tDecTop[decIdx]->destroy() ;
     371    }
     372    delete m_tDecTop[decIdx] ;
     373    m_tDecTop[decIdx] = NULL ;
     374  }
     375#else
    221376  if ( m_pchReconFile )
    222377  {
     
    226381  // destroy decoder class
    227382  m_cTDecTop.destroy();
     383#endif
    228384}
    229385
    230386Void TAppDecTop::xInitDecLib()
    231387{
     388#if !H_MV
    232389  // initialize decoder class
    233390  m_cTDecTop.init();
    234391  m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     392#endif
    235393}
    236394
     
    238396    \todo            DYN_REF_FREE should be revised
    239397 */
     398#if H_MV
     399Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int decIdx, Int tId )
     400#else
    240401Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, UInt tId )
     402#endif
    241403{
    242404  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
     
    246408  {
    247409    TComPic* pcPic = *(iterPic);
     410#if H_MV
     411    if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx])
     412#else
    248413    if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay)
     414#endif
    249415    {
    250416       not_displayed++;
     
    258424    TComPic* pcPic = *(iterPic);
    259425   
     426#if H_MV
     427    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[decIdx]))
     428#else
    260429    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
     430#endif
    261431    {
    262432      // write to file
    263433       not_displayed--;
     434#if H_MV
     435      if ( m_pchReconFiles[decIdx] )
     436#else
    264437      if ( m_pchReconFile )
     438#endif
    265439      {
    266440        const Window &conf = pcPic->getConformanceWindow();
    267441        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     442#if H_MV
     443        m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
     444#else
    268445        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     446#endif
    269447                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    270448                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     
    274452     
    275453      // update POC of display order
     454#if H_MV
     455      m_pocLastDisplay[decIdx] = pcPic->getPOC();
     456#else
    276457      m_iPOCLastDisplay = pcPic->getPOC();
     458#endif
    277459     
    278460      // erase non-referenced picture in the reference picture list after display
     
    302484    \todo            DYN_REF_FREE should be revised
    303485 */
     486#if H_MV
     487Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx )
     488#else
    304489Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
     490#endif
    305491{
    306492  if(!pcListPic)
     
    319505    {
    320506      // write to file
     507#if H_MV
     508      if ( m_pchReconFiles[decIdx] )
     509#else
    321510      if ( m_pchReconFile )
     511#endif
    322512      {
    323513        const Window &conf = pcPic->getConformanceWindow();
    324514        const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     515#if H_MV
     516        m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
     517#else
    325518        m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     519#endif
    326520                                       conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    327521                                       conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     
    331525     
    332526      // update POC of display order
     527#if H_MV
     528      m_pocLastDisplay[decIdx] = pcPic->getPOC();
     529#else
    333530      m_iPOCLastDisplay = pcPic->getPOC();
     531#endif
    334532     
    335533      // erase non-referenced picture in the reference picture list after display
     
    351549      pcPic->setOutputMark(false);
    352550    }
     551#if !H_MV
    353552#if !DYN_REF_FREE
    354553    if(pcPic)
     
    359558    }
    360559#endif
     560#endif
    361561    iterPic++;
    362562  }
     563#if H_MV
     564  m_pocLastDisplay[decIdx] = -MAX_INT;
     565#else
    363566  pcListPic->clear();
    364567  m_iPOCLastDisplay = -MAX_INT;
     568#endif
    365569}
    366570
     
    375579  for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++)
    376580  {
     581#if H_MV
     582    if ( nalu->m_layerId == (*it) )
     583#else
    377584    if ( nalu->m_reservedZero6Bits == (*it) )
     585#endif
    378586    {
    379587      return true;
  • branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/TAppDecTop.h

    r367 r368  
    6161private:
    6262  // class interface
     63#if H_MV
     64  TDecTop*                        m_tDecTop             [ MAX_NUM_LAYERS ];    ///< decoder classes
     65  TVideoIOYuv*                    m_tVideoIOYuvReconFile[ MAX_NUM_LAYERS ];    ///< reconstruction YUV class
     66  Int                             m_layerIdToDecIdx     [ MAX_NUM_LAYER_IDS ]; ///< maping from layer id to decoder index
     67  Int                             m_numDecoders;                               ///< number of decoder instances
     68  TComPicLists                    m_ivPicLists;                                ///< picture buffers of decoder instances
     69#else
    6370  TDecTop                         m_cTDecTop;                     ///< decoder class
    6471  TVideoIOYuv                     m_cTVideoIOYuvReconFile;        ///< reconstruction YUV class
     72#endif
    6573 
    6674  // for output control
    6775  Bool                            m_abDecFlag[ MAX_GOP ];         ///< decoded flag in one GOP
     76#if H_MV
     77  Int                             m_pocLastDisplay      [ MAX_NUM_LAYERS ]; ///< last POC in display order
     78  Bool                            m_reconOpen           [ MAX_NUM_LAYERS ]; ///< reconstruction file opened
     79#else
    6880  Int                             m_iPOCLastDisplay;              ///< last POC in display order
     81#endif
    6982 
    7083public:
     
    8194  Void  xInitDecLib       (); ///< initialize decoder class
    8295 
     96#if H_MV
     97  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, Int layerId, Int tId ); ///< write YUV to file
     98  Void  xFlushOutput      ( TComList<TComPic*>* pcListPic, Int layerId ); ///< flush all remaining decoded pictures to file
     99  Int   xGetDecoderIdx    ( Int layerId, Bool createFlag = false )
     100  {
     101    Int decIdx = -1;
     102    if ( m_layerIdToDecIdx[ layerId ] != -1 )
     103    {     
     104      decIdx = m_layerIdToDecIdx[ layerId ];
     105    }
     106    else
     107    {     
     108      assert ( createFlag );
     109      assert( m_numDecoders < MAX_NUM_LAYERS );
     110
     111      decIdx = m_numDecoders;
     112     
     113      // Init decoder
     114      m_tDecTop[ decIdx ] =  new TDecTop;
     115      m_tDecTop[ decIdx ]->create();
     116      m_tDecTop[ decIdx ]->init( );
     117      m_tDecTop[ decIdx ]->setLayerId( layerId );
     118      m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     119      m_tDecTop[ decIdx ]->setIvPicLists( &m_ivPicLists );
     120     
     121      // append pic list of new decoder to PicLists
     122      assert( m_ivPicLists.size() == m_numDecoders );
     123      m_ivPicLists.push_back( m_tDecTop[ decIdx ]->getListPic() );
     124
     125      // create recon file related stuff     
     126      Char* pchTempFilename = NULL;
     127      if ( m_pchReconFile )
     128      {     
     129        Char buffer[4];     
     130        sprintf(buffer,"_%i", layerId );
     131        assert ( m_pchReconFile );
     132        xAppendToFileNameEnd( m_pchReconFile , buffer, pchTempFilename );
     133        assert( m_pchReconFiles.size() == m_numDecoders );
     134      }
     135
     136      m_pchReconFiles.push_back( pchTempFilename );   
     137
     138      m_tVideoIOYuvReconFile[ decIdx ] = new TVideoIOYuv;
     139      m_reconOpen           [ decIdx ] = false;
     140
     141      // set others
     142      m_pocLastDisplay      [ decIdx ] = -MAX_INT;
     143      m_layerIdToDecIdx     [ layerId ] = decIdx;
     144
     145      m_numDecoders++;
     146    };
     147    return decIdx;
     148  }
     149#else
    83150  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic , UInt tId); ///< write YUV to file
    84151  Void  xFlushOutput      ( TComList<TComPic*>* pcListPic ); ///< flush all remaining decoded pictures to file
     152#endif
    85153  Bool  isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet
    86154};
  • branches/HTM-DEV-0.1-dev/source/App/TAppDecoder/decmain.cpp

    r367 r368  
    5656  // print information
    5757  fprintf( stdout, "\n" );
     58#if H_MV
     59  fprintf( stdout, "3D-HTM Software: Decoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION ); 
     60#else
    5861  fprintf( stdout, "HM software: Decoder Version [%s]", NV_VERSION );
     62#endif
    5963  fprintf( stdout, NVM_ONOS );
    6064  fprintf( stdout, NVM_COMPILEDBY );
  • branches/HTM-DEV-0.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r367 r368  
    6464
    6565TAppEncCfg::TAppEncCfg()
     66#if H_MV
     67: m_pchBitstreamFile()
     68#else
    6669: m_pchInputFile()
    6770, m_pchBitstreamFile()
    6871, m_pchReconFile()
     72#endif
    6973, m_pchdQPFile()
    7074, m_pColumnWidth()
     
    7276, m_scalingListFile()
    7377{
     78#if !H_MV
    7479  m_aidQP = NULL;
     80#endif
    7581#if J0149_TONE_MAPPING_SEI
    7682  m_startOfCodedInterval = NULL;
     
    8288TAppEncCfg::~TAppEncCfg()
    8389{
     90#if H_MV
     91  for( Int layer = 0; layer < m_aidQP.size(); layer++ )
     92  {
     93    if ( m_aidQP[layer] != NULL )
     94    {
     95      delete[] m_aidQP[layer];
     96      m_aidQP[layer] = NULL;
     97    }
     98  }
     99  for(Int i = 0; i< m_pchInputFileList.size(); i++ )
     100  {
     101    if ( m_pchInputFileList[i] != NULL )
     102      free (m_pchInputFileList[i]);
     103  }
     104#else
    84105  if ( m_aidQP )
    85106  {
    86107    delete[] m_aidQP;
    87108  }
     109#endif
    88110#if J0149_TONE_MAPPING_SEI
    89111  if ( m_startOfCodedInterval )
     
    103125  }
    104126#endif
     127#if !H_MV
    105128  free(m_pchInputFile);
     129#endif
    106130  free(m_pchBitstreamFile);
     131#if H_MV
     132  for(Int i = 0; i< m_pchReconFileList.size(); i++ )
     133  {
     134    if ( m_pchReconFileList[i] != NULL )
     135      free (m_pchReconFileList[i]);
     136  }
     137#else
    107138  free(m_pchReconFile);
     139#endif
    108140  free(m_pchdQPFile);
    109141  free(m_pColumnWidth);
    110142  free(m_pRowHeight);
    111143  free(m_scalingListFile);
     144#if H_MV
     145  for( Int i = 0; i < m_GOPListMvc.size(); i++ )
     146  {
     147    if( m_GOPListMvc[i] )
     148    {
     149      delete[] m_GOPListMvc[i];
     150      m_GOPListMvc[i] = NULL;
     151    }
     152  }
     153#endif
    112154}
    113155
     
    161203  }
    162204#endif
     205#if H_MV
     206  in>>entry.m_numInterViewRefPics;
     207  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
     208  {
     209    in>>entry.m_interViewRefs[i];
     210  }
     211  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
     212  {
     213    in>>entry.m_interViewRefPosL[0][i];
     214  }
     215  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
     216  {
     217    in>>entry.m_interViewRefPosL[1][i];
     218  }
     219#endif
    163220  return in;
    164221}
     
    172229  {"main10", Profile::MAIN10},
    173230  {"main-still-picture", Profile::MAINSTILLPICTURE},
     231#if H_MV
     232  {"main-stereo",    Profile::MAINSTEREO},
     233  {"main-multiview", Profile::MAINMULTIVIEW},
     234#if H_3D
     235  {"main-3d"    , Profile::MAIN3D},
     236#endif
     237#endif
    174238};
    175239
     
    253317  Bool do_help = false;
    254318 
     319#if !H_MV
    255320  string cfg_InputFile;
     321#endif
    256322  string cfg_BitstreamFile;
     323#if !H_MV
    257324  string cfg_ReconFile;
     325#endif
     326#if H_MV
     327  vector<Int>   cfg_dimensionLength;
     328#if H_3D
     329  cfg_dimensionLength.push_back( 2  );  // depth
     330  cfg_dimensionLength.push_back( 32 );  // texture
     331#else
     332  cfg_dimensionLength.push_back( 64 );
     333#endif
     334#endif
    258335  string cfg_dQPFile;
    259336  string cfg_ColumnWidth;
     
    279356 
    280357  // File, I/O and source parameters
     358#if H_MV
     359  ("InputFile_%d,i_%d",       m_pchInputFileList,       (char *) 0 , MAX_NUM_LAYER_IDS , "original Yuv input file name %d")
     360#else
    281361  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
     362#endif
    282363  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
     364#if H_MV
     365  ("ReconFile_%d,o_%d",       m_pchReconFileList,       (char *) 0 , MAX_NUM_LAYER_IDS , "reconstructed Yuv output file name %d")
     366#else
    283367  ("ReconFile,o",           cfg_ReconFile,     string(""), "Reconstructed YUV output file name")
     368#endif
     369#if H_MV
     370  ("NumberOfLayers",        m_numberOfLayers     , 1,                     "Number of layers")
     371#if !H_3D
     372  ("ScalabilityMask",       m_scalabilityMask    , 1                    , "Scalability Mask")   
     373#else
     374  ("ScalabilityMask",       m_scalabilityMask    , 3                    , "Scalability Mask, 1: Texture 3: Texture + Depth ")   
     375#endif 
     376  ("DimensionIdLen",        m_dimensionIdLen     , cfg_dimensionLength  , "Number of bits used to store dimensions Id")
     377  ("ViewId",                m_viewId             , std::vector<Int>(1,0), "View Id")
     378#if H_3D
     379  ("DepthFlag",             m_depthFlag          , std::vector<Int>(1,0), "Depth Flag")
     380#endif
     381  ("LayerIdInNuh",          m_layerIdInNuh       , std::vector<Int>(1,0), "LayerId in Nuh")
     382  ("SplittingFlag",         m_splittingFlag      , false                , "Splitting Flag")   
     383#endif
    284384  ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
    285385  ("SourceHeight,-hgt",     m_iSourceHeight,       0, "Source picture height")
     
    353453
    354454  /* Quantization parameters */
     455#if H_MV
     456  ("QP,q",          m_fQP, std::vector<double>(1,30.0), "Qp values for each layer, if value is float, QP is switched once during encoding")
     457#else
    355458  ("QP,q",          m_fQP,             30.0, "Qp value, if value is float, QP is switched once during encoding")
     459#endif
    356460  ("DeltaQpRD,-dqr",m_uiDeltaQpRD,       0u, "max dQp offset for slice")
    357461  ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
     
    377481 
    378482  // Deblocking filter parameters
     483#if H_MV
     484  ("LoopFilterDisable",              m_bLoopFilterDisable,             std::vector<Bool>(1,false), "Disable Loop Filter per Layer" )
     485#else
    379486  ("LoopFilterDisable",              m_bLoopFilterDisable,             false )
     487#endif
    380488  ("LoopFilterOffsetInPPS",          m_loopFilterOffsetInPPS,          false )
    381489  ("LoopFilterBetaOffset_div2",      m_loopFilterBetaOffsetDiv2,           0 )
     
    390498  ("TransformSkip",            m_useTransformSkip,          false, "Intra transform skipping")
    391499  ("TransformSkipFast",        m_useTransformSkipFast,      false, "Fast intra transform skipping")
     500#if H_MV
     501  ("SAO",                      m_bUseSAO, std::vector<Bool>(1,true), "Enable Sample Adaptive Offset per Layer")
     502#else
    392503  ("SAO",                      m_bUseSAO,                   true,  "Enable Sample Adaptive Offset")
     504#endif
    393505  ("MaxNumOffsetsPerPic",      m_maxNumOffsetsPerPic,       2048,  "Max number of SAO offset per picture (Default: 2048)")   
    394506  ("SAOLcuBoundary",           m_saoLcuBoundary,            false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
     
    572684  ;
    573685 
     686#if H_MV
     687  // parse coding structure
     688  for( Int k = 0; k < MAX_NUM_LAYERS; k++ )
     689  {
     690    m_GOPListMvc.push_back( new GOPEntry[MAX_GOP + 1] );
     691    if( k == 0 )
     692    {
     693      for( Int i = 1; i < MAX_GOP + 1; i++ )
     694      {
     695        std::ostringstream cOSS;
     696        cOSS<<"Frame"<<i;
     697        opts.addOptions()( cOSS.str(), m_GOPListMvc[k][i-1], GOPEntry() );
     698      }
     699    }
     700    else
     701    {
     702      std::ostringstream cOSS1;
     703      cOSS1<<"FrameI"<<"_l"<<k;
     704      opts.addOptions()(cOSS1.str(), m_GOPListMvc[k][MAX_GOP], GOPEntry());
     705
     706      for( Int i = 1; i < MAX_GOP + 1; i++ )
     707      {
     708        std::ostringstream cOSS2;
     709        cOSS2<<"Frame"<<i<<"_l"<<k;
     710        opts.addOptions()(cOSS2.str(), m_GOPListMvc[k][i-1], GOPEntry());
     711      }
     712    }
     713  }
     714#else
    574715  for(Int i=1; i<MAX_GOP+1; i++) {
    575716    std::ostringstream cOSS;
     
    577718    opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry());
    578719  }
     720#endif
    579721  po::setDefaults(opts);
    580722  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
     
    596738   */
    597739  /* convert std::string to c string for compatability */
     740#if !H_MV
    598741  m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
     742#endif
    599743  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
     744#if !H_MV
    600745  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
     746#endif
    601747  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
    602748 
     
    658804    m_pRowHeight = NULL;
    659805  }
     806#if H_MV
     807  free ( pColumnWidth );
     808  free ( pRowHeight   );
     809#endif
    660810#if SIGNAL_BITRATE_PICRATE_IN_VPS
    661811  readBoolString(cfg_bitRateInfoPresentFlag, m_bitRatePicRateMaxTLayers, m_bitRateInfoPresentFlag, "bit rate info. present flag" );
     
    737887 
    738888  // allocate slice-based dQP values
     889#if H_MV
     890  xResizeVector( m_viewId    );
     891#if H_3D
     892  xResizeVector( m_depthFlag );
     893#endif
     894
     895  xResizeVector( m_fQP );
     896
     897  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
     898  {
     899    m_aidQP.push_back( new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ] );
     900    ::memset( m_aidQP[layer], 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
     901
     902    // handling of floating-point QP values
     903    // if QP is not integer, sequence is split into two sections having QP and QP+1
     904    m_iQP.push_back((Int)( m_fQP[layer] ));
     905    if ( m_iQP[layer] < m_fQP[layer] )
     906    {
     907      Int iSwitchPOC = (Int)( m_framesToBeEncoded - (m_fQP[layer] - m_iQP[layer])*m_framesToBeEncoded + 0.5 );
     908
     909      iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
     910      for ( Int i=iSwitchPOC; i<m_framesToBeEncoded + m_iGOPSize + 1; i++ )
     911      {
     912        m_aidQP[layer][i] = 1;
     913      }
     914    }
     915  }
     916
     917  xResizeVector( m_bLoopFilterDisable );
     918  xResizeVector( m_bUseSAO );   
     919
     920#else
    739921  m_aidQP = new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ];
    740922  ::memset( m_aidQP, 0, sizeof(Int)*( m_framesToBeEncoded + m_iGOPSize + 1 ) );
     
    753935    }
    754936  }
     937#endif
    755938 
    756939  // reading external dQP description from file
     
    760943    if ( fpt )
    761944    {
     945#if H_MV
     946      for( Int layer = 0; layer < m_numberOfLayers; layer++ )
     947      {
     948#endif
    762949      Int iValue;
    763950      Int iPOC = 0;
     
    765952      {
    766953        if ( fscanf(fpt, "%d", &iValue ) == EOF ) break;
     954#if H_MV
     955        m_aidQP[layer][ iPOC ] = iValue;
     956        iPOC++;
     957      }
     958#else
    767959        m_aidQP[ iPOC ] = iValue;
    768960        iPOC++;
     961#endif
    769962      }
    770963      fclose(fpt);
     
    9321125  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
    9331126  xConfirmPara( m_framesToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
     1127#if H_MV
     1128  xConfirmPara( m_numberOfLayers > MAX_NUM_LAYER_IDS ,                                      "NumberOfLayers must be less than or equal to MAX_NUM_LAYER_IDS");
     1129
     1130
     1131  xConfirmPara( m_layerIdInNuh[0] != 0      , "LayerIdInNuh must be 0 for the first layer. ");
     1132  xConfirmPara( (m_layerIdInNuh.size()!=1) && (m_layerIdInNuh.size() < m_numberOfLayers) , "LayerIdInNuh must be given for all layers. ");
     1133 
     1134#if H_3D
     1135  xConfirmPara( m_scalabilityMask != 1 && m_scalabilityMask != 3, "Scalability Mask must be equal to 1 or 3. ");
     1136#else
     1137  xConfirmPara( m_scalabilityMask != 1 , "Scalability Mask must be equal to 1. ");
     1138#endif
     1139 
     1140  m_dimIds.push_back( m_viewId );
     1141#if H_3D
     1142  if ( m_scalabilityMask & ( 1 << DEPTH_ID ) )
     1143    m_dimIds.push_back( m_depthFlag );
     1144#endif
     1145
     1146  xConfirmPara(  m_dimensionIdLen.size() < m_dimIds.size(), "DimensionIdLen must be given for all dimensions. "   );
     1147
     1148 for( Int dim = 0; dim < m_dimIds.size(); dim++ )
     1149 {
     1150   xConfirmPara( m_dimIds[dim].size() < m_numberOfLayers,  "DimensionId must be given for all layers and all dimensions. ");
     1151   xConfirmPara( m_dimIds[dim][0] != 0,                    "DimensionId of layer 0 must be 0 in all dimensions. " );
     1152   xConfirmPara( m_dimensionIdLen[dim] < 1 || m_dimensionIdLen[dim] > 8, "DimensionIdLen must be greater than 0 and less than 9 in all dimensions. " );
     1153   for( Int i = 1; i < m_numberOfLayers; i++ )
     1154   {     
     1155     xConfirmPara(  ( m_dimIds[dim][i] < 0 ) || ( m_dimIds[dim][i] > ( ( 1 << m_dimensionIdLen[dim] ) - 1 ) )   , "DimensionId shall be in the range of 0 to 2^DimensionIdLen - 1. " );
     1156   }
     1157 }
     1158
     1159 for( Int i = 0; i < m_numberOfLayers; i++ )
     1160 {
     1161   for( Int j = 0; j < i; j++ )
     1162   {     
     1163     Int numDiff  = 0;
     1164     Int lastDiff = -1;
     1165     for( Int dim = 0; dim < m_dimIds.size(); dim++ )
     1166     {
     1167       if ( m_dimIds[dim][i] != m_dimIds[dim][j] )
     1168       {
     1169         numDiff ++;
     1170         lastDiff = dim;
     1171       }
     1172     }
     1173
     1174     Bool allEqual = ( numDiff == 0 );
     1175
     1176     if ( allEqual )
     1177     {
     1178       printf( "\nError: Positions of Layers %d and %d are identical in scalability space\n", i, j);
     1179     }
     1180
     1181     xConfirmPara( allEqual , "Each layer shall have a different position in scalability space." );
     1182
     1183     if ( numDiff  == 1 )
     1184     {
     1185       Bool inc = m_dimIds[ lastDiff ][ i ] > m_dimIds[ lastDiff ][ j ];
     1186       if ( !inc )
     1187       {       
     1188         printf( "\nError: Positions of Layers %d and %d is not increasing in dimension %d \n", i, j, lastDiff);       
     1189       }
     1190       xConfirmPara( !inc,  "DimensionIds shall be increasing within one dimension. " );
     1191     }
     1192   }
     1193 }
     1194
     1195#endif
    9341196  xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
    9351197  xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
    9361198  xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
    9371199  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
     1200#if H_MV
     1201  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
     1202  {
     1203    xConfirmPara( m_iQP[layer] <  -6 * (m_internalBitDepthY - 8) || m_iQP[layer] > 51,      "QP exceeds supported range (-QpBDOffsety to 51)" );
     1204  }
     1205#else
    9381206  xConfirmPara( m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,                    "QP exceeds supported range (-QpBDOffsety to 51)" );
     1207#endif
    9391208  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,          "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
    9401209  xConfirmPara( m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13,              "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)");
     
    9801249
    9811250#if ADAPTIVE_QP_SELECTION
     1251#if H_MV
     1252  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
     1253  {
     1254    xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP[layer] < 0,                                     "AdaptiveQpSelection must be disabled when QP < 0.");
     1255  }
     1256#else
    9821257  xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
     1258#endif
    9831259  xConfirmPara( m_bUseAdaptQpSelect == true && (m_cbQpOffset !=0 || m_crQpOffset != 0 ),               "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
    9841260#endif
     
    10341310  }
    10351311
     1312#if H_MV
     1313  // validate that POC of same frame is identical across multiple layers
     1314  Bool bErrorMvePoc = false;
     1315  if( m_numberOfLayers > 1 )
     1316  {
     1317    for( Int k = 1; k < m_numberOfLayers; k++ )
     1318    {
     1319      for( Int i = 0; i < MAX_GOP; i++ )
     1320      {
     1321        if( m_GOPListMvc[k][i].m_POC != m_GOPListMvc[0][i].m_POC )
     1322        {
     1323          printf( "\nError: Frame%d_l%d POC %d is not identical to Frame%d POC\n", i, k, m_GOPListMvc[k][i].m_POC, i );
     1324          bErrorMvePoc = true;
     1325        }
     1326      }
     1327    }
     1328  }
     1329  xConfirmPara( bErrorMvePoc,  "Invalid inter-layer POC structure given" );
     1330
     1331  // validate that baseview has no inter-view refs
     1332  Bool bErrorIvpBase = false;
     1333  for( Int i = 0; i < MAX_GOP; i++ )
     1334  {
     1335    if( m_GOPListMvc[0][i].m_numInterViewRefPics != 0 )
     1336    {
     1337      printf( "\nError: Frame%d inter_layer refs not available in layer 0\n", i );
     1338      bErrorIvpBase = true;
     1339    }
     1340  }
     1341  xConfirmPara( bErrorIvpBase, "Inter-layer refs not possible in base layer" );
     1342
     1343  // validate inter-view refs
     1344  Bool bErrorIvpEnhV = false;
     1345  if( m_numberOfLayers > 1 )
     1346  {
     1347    for( Int k = 1; k < m_numberOfLayers; k++ )
     1348    {
     1349      for( Int i = 0; i < MAX_GOP+1; i++ )
     1350      {
     1351        for( Int j = 0; j < m_GOPListMvc[k][i].m_numInterViewRefPics; j++ )
     1352        {
     1353          Int iAbsViewId = m_GOPListMvc[k][i].m_interViewRefs[j] + k;
     1354          if( iAbsViewId < 0 || iAbsViewId >= k )
     1355          {
     1356            printf( "\nError: inter-layer ref pic %d is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interViewRefs[j], i, k );
     1357            bErrorIvpEnhV = true;
     1358          }
     1359          if( m_GOPListMvc[k][i].m_interViewRefPosL[0][j] < -1 || m_GOPListMvc[k][i].m_interViewRefPosL[0][j] > m_GOPListMvc[k][i].m_numRefPicsActive )
     1360          {
     1361            printf( "\nError: inter-layer ref pos %d on L0 is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interViewRefPosL[0][j], i, k );
     1362            bErrorIvpEnhV = true;
     1363          }
     1364          if( m_GOPListMvc[k][i].m_interViewRefPosL[1][j] < -1  || m_GOPListMvc[k][i].m_interViewRefPosL[1][j] > m_GOPListMvc[k][i].m_numRefPicsActive )
     1365          {
     1366            printf( "\nError: inter-layer ref pos %d on L1 is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interViewRefPosL[1][j], i, k );
     1367            bErrorIvpEnhV = true;
     1368          }
     1369        }
     1370        if( i == MAX_GOP ) // inter-view refs at I pic position in base view
     1371        {
     1372          if( m_GOPListMvc[k][MAX_GOP].m_sliceType != 'B' && m_GOPListMvc[k][MAX_GOP].m_sliceType != 'P' && m_GOPListMvc[k][MAX_GOP].m_sliceType != 'I' )
     1373          {
     1374            printf( "\nError: slice type of FrameI_l%d must be equal to B or P or I\n", k );
     1375            bErrorIvpEnhV = true;
     1376          }
     1377
     1378          if( m_GOPListMvc[k][MAX_GOP].m_POC != 0 )
     1379          {
     1380            printf( "\nError: POC %d not possible for FrameI_l%d, must be 0\n", m_GOPListMvc[k][MAX_GOP].m_POC, k );
     1381            bErrorIvpEnhV = true;
     1382          }
     1383
     1384          if( m_GOPListMvc[k][MAX_GOP].m_temporalId != 0 )
     1385          {
     1386            printf( "\nWarning: Temporal id of FrameI_l%d must be 0 (cp. I-frame in base layer)\n", k );
     1387            m_GOPListMvc[k][MAX_GOP].m_temporalId = 0;
     1388          }
     1389
     1390          if( m_GOPListMvc[k][MAX_GOP].m_numRefPics != 0 )
     1391          {
     1392            printf( "\nWarning: temporal references not possible for FrameI_l%d\n", k );
     1393            for( Int j = 0; j < m_GOPListMvc[k][MAX_GOP].m_numRefPics; j++ )
     1394            {
     1395              m_GOPListMvc[k][MAX_GOP].m_referencePics[j] = 0;
     1396            }
     1397            m_GOPListMvc[k][MAX_GOP].m_numRefPics = 0;
     1398          }
     1399
     1400          if( m_GOPListMvc[k][MAX_GOP].m_interRPSPrediction )
     1401          {
     1402            printf( "\nError: inter RPS prediction not possible for FrameI_l%d, must be 0\n", k );
     1403            bErrorIvpEnhV = true;
     1404          }
     1405
     1406          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'I' && m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics != 0 )
     1407          {
     1408            printf( "\nError: inter-layer prediction not possible for FrameI_l%d with slice type I, #IL_ref_pics must be 0\n", k );
     1409            bErrorIvpEnhV = true;
     1410          }
     1411
     1412          if( m_GOPListMvc[k][MAX_GOP].m_numRefPicsActive > m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics )
     1413          {
     1414            m_GOPListMvc[k][MAX_GOP].m_numRefPicsActive = m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics;
     1415          }
     1416
     1417          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'P' )
     1418          {
     1419            if( m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
     1420            {
     1421              printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type P\n", k );
     1422              bErrorIvpEnhV = true;
     1423            }
     1424            else
     1425            {
     1426              for( Int j = 0; j < m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics; j++ )
     1427              {
     1428                if( m_GOPListMvc[k][MAX_GOP].m_interViewRefPosL[1][j] != -1 )
     1429                {
     1430                  printf( "\nError: inter-layer ref pos %d on L1 not possible for FrameI_l%d with slice type P\n", m_GOPListMvc[k][MAX_GOP].m_interViewRefPosL[1][j], k );
     1431                  bErrorIvpEnhV = true;
     1432                }
     1433              }
     1434            }
     1435          }
     1436
     1437          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'B' && m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
     1438          {
     1439            printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type B\n", k );
     1440            bErrorIvpEnhV = true;
     1441          }
     1442        }
     1443      }
     1444    }
     1445  }
     1446  xConfirmPara( bErrorIvpEnhV, "Invalid inter-layer coding structure for enhancement layers given" );
     1447
     1448  // validate temporal coding structure
     1449  if( !bErrorMvePoc && !bErrorIvpBase && !bErrorIvpEnhV )
     1450  {
     1451    for( Int layer = 0; layer < m_numberOfLayers; layer++ )
     1452    {
     1453      GOPEntry* m_GOPList            = m_GOPListMvc           [layer]; // It is not a member, but this name helps avoiding code duplication !!!
     1454      Int&      m_extraRPSs          = m_extraRPSsMvc         [layer]; // It is not a member, but this name helps avoiding code duplication !!!
     1455      Int&      m_maxTempLayer       = m_maxTempLayerMvc      [layer]; // It is not a member, but this name helps avoiding code duplication !!!
     1456      Int*      m_maxDecPicBuffering = m_maxDecPicBufferingMvc[layer]; // It is not a member, but this name helps avoiding code duplication !!!
     1457      Int*      m_numReorderPics     = m_numReorderPicsMvc    [layer]; // It is not a member, but this name helps avoiding code duplication !!!
     1458#endif
    10361459  /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
    10371460   * This permits the ability to omit a GOP structure specification */
     
    10671490  }
    10681491 
     1492#if H_MV
     1493  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable[layer]) )
     1494#else
    10691495  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) )
     1496#endif
    10701497  {
    10711498    for(Int i=0; i<m_iGOPSize; i++)
     
    10831510    if(m_GOPList[curGOP].m_POC<0)
    10841511    {
     1512#if H_MV
     1513      printf("\nError: found fewer Reference Picture Sets than GOPSize for layer %d\n", layer );
     1514#else
    10851515      printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
     1516#endif
    10861517      errorGOP=true;
    10871518    }
     
    11201551          if(!found)
    11211552          {
     1553#if H_MV
     1554            printf("\nError: ref pic %d is not available for GOP frame %d of layer %d\n", m_GOPList[curGOP].m_referencePics[i], curGOP+1, layer);
     1555#else
    11221556            printf("\nError: ref pic %d is not available for GOP frame %d\n",m_GOPList[curGOP].m_referencePics[i],curGOP+1);
     1557#endif
    11231558            errorGOP=true;
    11241559          }
     
    14971932  }
    14981933#endif
     1934#if H_MV
     1935  }
     1936  }
     1937#endif
    14991938
    15001939#undef xConfirmPara
     
    15321971{
    15331972  printf("\n");
     1973#if H_MV
     1974  for( Int layer = 0; layer < m_numberOfLayers; layer++)
     1975  {
     1976    printf("Input File %i                 : %s\n", layer, m_pchInputFileList[layer]);
     1977  }
     1978#else
    15341979  printf("Input          File          : %s\n", m_pchInputFile          );
     1980#endif
    15351981  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
     1982#if H_MV
     1983  for( Int layer = 0; layer < m_numberOfLayers; layer++)
     1984  {
     1985    printf("Reconstruction File %i        : %s\n", layer, m_pchReconFileList[layer]);
     1986  }
     1987#else
    15361988  printf("Reconstruction File          : %s\n", m_pchReconFile          );
     1989#endif
     1990#if H_MV
     1991 xPrintParaVector( "ViewId", m_viewId );
     1992#endif
     1993#if H_3D
     1994 xPrintParaVector( "DepthFlag", m_depthFlag );
     1995#endif
     1996#if H_MV 
     1997  xPrintParaVector( "QP"               , m_fQP                );
     1998  xPrintParaVector( "LoopFilterDisable", m_bLoopFilterDisable );
     1999  xPrintParaVector( "SAO"              , m_bUseSAO            );
     2000#endif
    15372001  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
    15382002  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
     
    15462010  printf("Intra period                 : %d\n", m_iIntraPeriod );
    15472011  printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
     2012#if !H_MV
    15482013  printf("QP                           : %5.2f\n", m_fQP );
     2014#endif
    15492015  printf("Max dQP signaling depth      : %d\n", m_iMaxCuDQPDepth);
    15502016
     
    16112077  }
    16122078  printf("CIP:%d ", m_bUseConstrainedIntraPred);
     2079#if !H_MV
    16132080  printf("SAO:%d ", (m_bUseSAO)?(1):(0));
     2081#endif
    16142082  printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
    16152083  printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization)?(1):(0));
  • branches/HTM-DEV-0.1-dev/source/App/TAppEncoder/TAppEncCfg.h

    r367 r368  
    5555protected:
    5656  // file I/O
     57#if H_MV
     58  std::vector<char*>     m_pchInputFileList;                  ///< source file names
     59#else
    5760  Char*     m_pchInputFile;                                   ///< source file name
     61#endif
    5862  Char*     m_pchBitstreamFile;                               ///< output bitstream file
     63#if H_MV
     64  std::vector<char*>     m_pchReconFileList;                  ///< output reconstruction file names
     65  Int                    m_numberOfLayers;                    ///< number of Layers to Encode
     66#else
    5967  Char*     m_pchReconFile;                                   ///< output reconstruction file
     68#endif
    6069  // VPS specification
     70#if H_MV
     71  std::vector< std::vector<Int> > m_dimIds;                   ///< dimension ids ( pointers to m_viewId and m_depthFlag
     72  std::vector<Int>       m_viewId;                            ///< view id
     73#if H_3D
     74  std::vector<Int>       m_depthFlag;                         ///< depth flag
     75#endif
     76  std::vector<Int>       m_layerIdInNuh;                      ///< layer Id in Nuh for each layer
     77  Bool                   m_splittingFlag;                     ///< Splitting Flag
     78  Int                    m_scalabilityMask;                   ///< Mask indicating scalabilities, 1: texture; 3: texture + depth                                                               
     79  std::vector<Int>       m_dimensionIdLen;                   ///< Length of scalability dimension s
     80#endif
    6181  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
    6282  // source specification
     
    88108  Int       m_iDecodingRefreshType;                           ///< random access type
    89109  Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
     110#if H_MV
     111  Int       m_extraRPSsMvc[MAX_NUM_LAYERS];                       ///< extra RPSs added to handle CRA for each layer
     112  std::vector< GOPEntry* >  m_GOPListMvc;                            ///< the coding structure entries from the config file for each layer
     113  Int       m_numReorderPicsMvc[MAX_NUM_LAYERS][MAX_TLAYER];      ///< total number of reorder pictures for each layer
     114  Int       m_maxDecPicBufferingMvc[MAX_NUM_LAYERS][MAX_TLAYER];  ///< total number of reference pictures needed for decoding for each layer
     115#else
    90116  Int       m_extraRPSs;                                      ///< extra RPSs added to handle CRA
    91117  GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
     
    96122  Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
    97123#endif
     124#endif
    98125#if !L0034_COMBINED_LIST_CLEANUP
    99126  Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
     
    103130  Bool      m_enableAMP;
    104131  // coding quality
     132#if H_MV
     133  std::vector<Double>  m_fQP;                                 ///< QP value of key-picture (floating point) for each layer
     134  std::vector<Int>     m_iQP;                                 ///< QP value of key-picture (integer) for each layer
     135#else
    105136  Double    m_fQP;                                            ///< QP value of key-picture (floating point)
    106137  Int       m_iQP;                                            ///< QP value of key-picture (integer)
     138#endif
    107139  Char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
     140#if H_MV
     141  std::vector<Int*> m_aidQP;                                    ///< array of slice QP values for each layer
     142#else
    108143  Int*      m_aidQP;                                          ///< array of slice QP values
     144#endif
    109145  Int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
    110146  UInt      m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
     
    121157  Int       m_iQPAdaptationRange;                             ///< dQP range by QP adaptation
    122158 
     159#if H_MV
     160  Int       m_maxTempLayerMvc[MAX_NUM_LAYER_IDS];             ///< Max temporal layer for each layer
     161#else
    123162  Int       m_maxTempLayer;                                  ///< Max temporal layer
     163#endif
    124164
    125165  // coding unit (CU) definition
     
    148188  // coding tool (lossless)
    149189  Bool      m_useLossless;                                    ///< flag for using lossless coding
     190#if H_MV
     191  std::vector<Bool> m_bUseSAO;
     192#else
    150193  Bool      m_bUseSAO;
     194#endif
    151195  Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
    152196  Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
    153197  Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
    154198  // coding tools (loop filter)
     199#if H_MV
     200  std::vector<Bool> m_bLoopFilterDisable;                     ///< flag for using deblocking filter for each layer
     201#else
    155202  Bool      m_bLoopFilterDisable;                             ///< flag for using deblocking filter
     203#endif
    156204  Bool      m_loopFilterOffsetInPPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = PPS
    157205  Int       m_loopFilterBetaOffsetDiv2;                     ///< beta offset for deblocking filter
     
    324372  Void  xPrintParameter ();                                   ///< print configuration values
    325373  Void  xPrintUsage     ();                                   ///< print usage
     374#if H_MV
     375  template <typename T>
     376  Void xResizeVector(  std::vector<T> & rpcVector )
     377  {
     378    for( Int layer = 0; rpcVector.size() < m_numberOfLayers; layer++ )
     379    {
     380      assert( rpcVector.size() > 0 );
     381      rpcVector.push_back( rpcVector[layer] );     
     382    }
     383
     384
     385    for( ; rpcVector.size() > m_numberOfLayers; )
     386    {     
     387      rpcVector.pop_back( );     
     388    }
     389
     390  }
     391
     392  template <typename T>
     393  Void xPrintParaVector( std::string description, std::vector<T> & rpcVector )
     394  {
     395    Int iSpace = max(1, ENC_CFG_CONSOUT_SPACE - (Int) description.length() );
     396   
     397    for ( Int i = 0; i < iSpace; i++ )
     398      description.append( " " );
     399     
     400    description.append( ":" );
     401    printf( "%s", description.c_str() );
     402
     403    for(Int i=0;i<rpcVector.size();i++)               
     404      xPrintVectorElem( rpcVector[i] );
     405
     406    printf("\n");
     407  }
     408 
     409  Void xPrintVectorElem( UInt   elem ) { printf(" %d"   , elem            );};
     410  Void xPrintVectorElem( Int    elem ) { printf(" %d"   , elem            );};
     411 
     412  Void xPrintVectorElem( Double elem ) { printf(" %5.2f", elem            );}; 
     413  Void xPrintVectorElem( Bool   elem ) { printf(" %d"   , ( elem ? 1 : 0 ));};
     414#endif
    326415#if SIGNAL_BITRATE_PICRATE_IN_VPS
    327416  Int       m_bitRatePicRateMaxTLayers;                       ///< Indicates max. number of sub-layers for which bit rate is signalled.
     
    333422  Int*      m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
    334423#endif
     424#if H_MV
     425  Int   getGOPSize() { return m_iGOPSize; }
     426#endif
    335427public:
    336428  TAppEncCfg();
  • branches/HTM-DEV-0.1-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r367 r368  
    5757TAppEncTop::TAppEncTop()
    5858{
     59#if !H_MV
    5960  m_iFrameRcvd = 0;
     61#endif
    6062  m_totalBytes = 0;
    6163  m_essentialBytes = 0;
     
    7072  TComVPS vps;
    7173 
     74#if H_MV
     75  Int maxTempLayer = -1;
     76  for (Int j = 0; j < m_numberOfLayers; j++)
     77  {
     78    maxTempLayer = max( m_maxTempLayerMvc[ j ], maxTempLayer );
     79  }
     80
     81  vps.setMaxTLayers                       ( maxTempLayer );
     82  if ( maxTempLayer )
     83  {
     84    vps.setTemporalNestingFlag(true);
     85  }
     86  vps.setMaxLayers( m_numberOfLayers );
     87  for(Int i = 0; i < MAX_TLAYER; i++)
     88  {
     89    Int maxNumReOrderPics  = 0;
     90    Int maxDecPicBuffering = 0;
     91    for (Int j = 0; j < m_numberOfLayers; j++)
     92    {
     93      maxNumReOrderPics  = max( maxNumReOrderPics,  m_numReorderPicsMvc    [ j ][ i ] );     
     94      maxDecPicBuffering = max( maxDecPicBuffering, m_maxDecPicBufferingMvc[ j ][ i ] );     
     95    }
     96
     97    vps.setNumReorderPics                 ( maxNumReOrderPics  ,i );
     98    vps.setMaxDecPicBuffering             ( maxDecPicBuffering ,i );
     99  }
     100#else
    72101  vps.setMaxTLayers                       ( m_maxTempLayer );
    73102  if (m_maxTempLayer == 1)
     
    81110    vps.setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
    82111  }
     112#endif
     113#if H_MV
     114  xSetLayerIds             ( vps );   
     115  xSetDimensionIdAndLength ( vps );
     116  xSetDirectDependencyFlags( vps );
     117
     118  for(Int layer = 0; layer < m_numberOfLayers; layer++)
     119  {
     120    m_frameRcvd                 .push_back(0);
     121    m_acTEncTopList             .push_back(new TEncTop);
     122    m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
     123    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
     124    m_picYuvRec                 .push_back(new TComList<TComPicYuv*>) ;
     125
     126    m_ivPicLists.push_back( m_acTEncTopList[ layer ]->getListPic()  );
     127    TEncTop& m_cTEncTop = *m_acTEncTopList[ layer ];  // It is not a member, but this name helps avoiding code duplication !!!
     128   
     129    m_cTEncTop.setLayerIdInVps( layer );
     130    m_cTEncTop.setLayerId     ( vps.getLayerIdInNuh( layer ) );   
     131    m_cTEncTop.setViewId      ( vps.getViewId      ( layer ) );
     132#if H_3D
     133    m_cTEncTop.setIsDepth     ( vps.getDepthId     ( layer ) != 0 );
     134#endif
     135    m_cTEncTop.setIvPicLists  ( &m_ivPicLists );
     136#endif
    83137  m_cTEncTop.setVPS(&vps);
    84138
     
    103157  m_cTEncTop.setDecodingRefreshType          ( m_iDecodingRefreshType );
    104158  m_cTEncTop.setGOPSize                      ( m_iGOPSize );
     159#if H_MV
     160  m_cTEncTop.setGopList                      ( m_GOPListMvc[layer] );
     161  m_cTEncTop.setExtraRPSs                    ( m_extraRPSsMvc[layer] );
     162  for(Int i = 0; i < MAX_TLAYER; i++)
     163  {
     164    m_cTEncTop.setNumReorderPics             ( m_numReorderPicsMvc[layer][i], i );
     165    m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBufferingMvc[layer][i], i );
     166  }
     167#else
    105168  m_cTEncTop.setGopList                      ( m_GOPList );
    106169  m_cTEncTop.setExtraRPSs                    ( m_extraRPSs );
     
    110173    m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBuffering[i], i );
    111174  }
     175#endif
    112176  for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
    113177  {
    114178    m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
    115179  }
     180#if H_MV
     181  m_cTEncTop.setQP                           ( m_iQP[layer] );
     182#else
    116183  m_cTEncTop.setQP                           ( m_iQP );
     184#endif
    117185
    118186  m_cTEncTop.setPad                          ( m_aiPad );
    119187
     188#if H_MV
     189  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayerMvc[layer] );
     190#else
    120191  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
     192#endif
    121193  m_cTEncTop.setUseAMP( m_enableAMP );
    122194 
     
    124196 
    125197  //====== Loop/Deblock Filter ========
     198#if H_MV
     199  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable[layer]);
     200#else
    126201  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
     202#endif
    127203  m_cTEncTop.setLoopFilterOffsetInPPS        ( m_loopFilterOffsetInPPS );
    128204  m_cTEncTop.setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
     
    151227  Int lowestQP;
    152228  lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
     229#if H_MV
     230  if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layer] == lowestQP) && (m_useLossless == true))
     231#else
    153232  if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true))
     233#endif
    154234  {
    155235    m_bUseAdaptiveQP = false;
     
    167247  m_cTEncTop.setUseLComb                     ( m_bUseLComb    );
    168248#endif
     249#if H_MV
     250  m_cTEncTop.setdQPs                         ( m_aidQP[layer]   );
     251#else
    169252  m_cTEncTop.setdQPs                         ( m_aidQP        );
     253#endif
    170254  m_cTEncTop.setUseRDOQ                      ( m_useRDOQ     );
    171255  m_cTEncTop.setUseRDOQTS                    ( m_useRDOQTS   );
     
    224308  }
    225309  m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
     310#if H_MV
     311  m_cTEncTop.setUseSAO ( m_bUseSAO[layer] );
     312#else
    226313  m_cTEncTop.setUseSAO ( m_bUseSAO );
     314#endif
    227315  m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
    228316
     
    372460  }
    373461#endif
     462#if H_MV
     463  }
     464#endif
    374465}
    375466
    376467Void TAppEncTop::xCreateLib()
    377468{
     469#if H_MV
     470  // initialize global variables
     471  initROM();
     472
     473  for( Int layer=0; layer < m_numberOfLayers; layer++)
     474  {
     475    m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer],     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
     476    m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
     477
     478    if (m_pchReconFileList[layer])
     479    {
     480      m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
     481    }
     482    m_acTEncTopList[layer]->create();
     483  }
     484#else
    378485  // Video I/O
    379486  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
     
    385492  // Neo Decoder
    386493  m_cTEncTop.create();
     494#endif
    387495}
    388496
    389497Void TAppEncTop::xDestroyLib()
    390498{
     499#if H_MV
     500  // destroy ROM
     501  destroyROM();
     502
     503  for(Int layer=0; layer<m_numberOfLayers; layer++)
     504  {
     505    m_acTVideoIOYuvInputFileList[layer]->close();
     506    m_acTVideoIOYuvReconFileList[layer]->close();
     507    delete m_acTVideoIOYuvInputFileList[layer] ;
     508    m_acTVideoIOYuvInputFileList[layer] = NULL;
     509    delete m_acTVideoIOYuvReconFileList[layer] ;
     510    m_acTVideoIOYuvReconFileList[layer] = NULL;
     511    m_acTEncTopList[layer]->deletePicBuffer();
     512    m_acTEncTopList[layer]->destroy();
     513    delete m_acTEncTopList[layer] ;
     514    m_acTEncTopList[layer] = NULL;
     515    delete m_picYuvRec[layer] ;
     516    m_picYuvRec[layer] = NULL;
     517  }
     518#else
    391519  // Video I/O
    392520  m_cTVideoIOYuvInputFile.close();
     
    395523  // Neo Decoder
    396524  m_cTEncTop.destroy();
     525#endif
    397526}
    398527
    399528Void TAppEncTop::xInitLib()
    400529{
     530#if H_MV
     531  for(Int layer=0; layer<m_numberOfLayers; layer++)
     532  {
     533    m_acTEncTopList[layer]->init( );
     534  }
     535#else
    401536  m_cTEncTop.init();
     537#endif
    402538}
    403539
     
    432568 
    433569  // main encoder loop
     570#if H_MV
     571  Bool  allEos = false;
     572  std::vector<Bool>  eos ;
     573  std::vector<Bool>  flush ; 
     574 
     575  Int gopSize    = 1;
     576  Int maxGopSize = 0;
     577  maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); 
     578 
     579  for(Int layer=0; layer < m_numberOfLayers; layer++ )
     580  {
     581    eos  .push_back( false );
     582    flush.push_back( false );
     583  }
     584#else
    434585  Int   iNumEncoded = 0;
    435586  Bool  bEos = false;
     587#endif
    436588 
    437589  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
     
    440592  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    441593 
     594#if H_MV
     595  while ( !allEos )
     596  {
     597    for(Int layer=0; layer < m_numberOfLayers; layer++ )
     598    {
     599      Int frmCnt = 0;
     600      while ( !eos[layer] && !(frmCnt == gopSize))
     601      {
     602        // get buffers
     603        xGetBuffer(pcPicYuvRec, layer);
     604
     605        // read input YUV file
     606        m_acTVideoIOYuvInputFileList[layer]->read      ( pcPicYuvOrg, m_aiPad );
     607        m_acTEncTopList             [layer]->initNewPic( pcPicYuvOrg );
     608
     609        // increase number of received frames
     610        m_frameRcvd[layer]++;
     611       
     612        frmCnt++;
     613
     614        eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded);
     615        allEos = allEos|eos[layer];
     616
     617        // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
     618        if (m_acTVideoIOYuvInputFileList[layer]->isEof())
     619        {
     620          flush          [layer] = true;
     621          eos            [layer]   = true;
     622          m_frameRcvd    [layer]--;
     623          m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]);
     624        }
     625      }
     626    }
     627    for ( Int gopId=0; gopId < gopSize; gopId++ )
     628    {
     629      for(Int layer=0; layer < m_numberOfLayers; layer++ )
     630      {
     631        Int   iNumEncoded = 0;
     632
     633        // call encoding function for one frame         
     634        m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, *m_picYuvRec[layer], outputAccessUnits, iNumEncoded, gopId );       
     635        xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer);
     636        outputAccessUnits.clear();
     637      }
     638
     639    }
     640    gopSize = maxGopSize;
     641  }
     642  for(Int layer=0; layer < m_numberOfLayers; layer++ )
     643  {
     644    m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded() );
     645  }
     646#else
    442647  while ( !bEos )
    443648  {
     
    475680
    476681  m_cTEncTop.printSummary();
     682#endif
    477683
    478684  // delete original YUV buffer
     
    481687  pcPicYuvOrg = NULL;
    482688 
     689#if !H_MV
    483690  // delete used buffers in encoder class
    484691  m_cTEncTop.deletePicBuffer();
     692#endif
    485693
    486694  // delete buffers & classes
     
    493701}
    494702
     703#if H_3D
     704TEncTop* TAppEncTop::getTEncTopView( Int viewId, Bool isDepth )
     705{
     706  TEncTop* encoder = NULL;
     707  for( Int layer = 0; layer < m_acTEncTopList.size(); layer++ )
     708  {
     709    if( m_acTEncTopList[layer]->getViewId()  == viewId &&
     710        m_acTEncTopList[layer]->getIsDepth() == isDepth )
     711    {
     712      encoder = m_acTEncTopList[layer];
     713      break;
     714    }
     715  }
     716  return encoder;
     717}
     718#endif
    495719// ====================================================================================================================
    496720// Protected member functions
     
    503727 .
    504728 */
     729#if H_MV
     730Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
     731#else
    505732Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec)
     733#endif
    506734{
    507735  assert( m_iGOPSize > 0 );
    508736 
    509737  // org. buffer
     738#if H_MV
     739  if ( m_picYuvRec[layer]->size() == (UInt)m_iGOPSize )
     740  {
     741    rpcPicYuvRec = m_picYuvRec[layer]->popFront();
     742#else
    510743  if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
    511744  {
    512745    rpcPicYuvRec = m_cListPicYuvRec.popFront();
     746#endif
    513747
    514748  }
     
    520754
    521755  }
     756#if H_MV
     757  m_picYuvRec[layer]->pushBack( rpcPicYuvRec );
     758#else
    522759  m_cListPicYuvRec.pushBack( rpcPicYuvRec );
     760#endif
    523761}
    524762
    525763Void TAppEncTop::xDeleteBuffer( )
    526764{
     765#if H_MV
     766  for(Int layer=0; layer<m_picYuvRec.size(); layer++)
     767  {
     768    if(m_picYuvRec[layer])
     769    {
     770      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvRec[layer]->begin();
     771      Int iSize = Int( m_picYuvRec[layer]->size() );
     772#else
    527773  TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
    528774 
    529775  Int iSize = Int( m_cListPicYuvRec.size() );
     776#endif
    530777
    531778  for ( Int i = 0; i < iSize; i++ )
     
    536783  }
    537784
     785#if H_MV
     786    }
     787  }
     788#endif 
    538789}
    539790
    540791/** \param iNumEncoded  number of encoded frames
    541792 */
     793#if H_MV
     794Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId)
     795#else
    542796Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
     797#endif
    543798{
    544799  Int i;
    545800 
     801#if H_MV
     802  if( iNumEncoded > 0 )
     803  {
     804    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end();
     805#else
    546806  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    547807  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     808#endif
    548809
    549810  for ( i = 0; i < iNumEncoded; i++ )
     
    555816  {
    556817    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     818#if H_MV
     819      if (m_pchReconFileList[layerId])
     820      {
     821        m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     822      }
     823    }
     824  }
     825  if( ! accessUnits.empty() )
     826  {
     827    list<AccessUnit>::iterator aUIter;
     828    for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ )
     829    {
     830      const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter);
     831      rateStatsAccum(*aUIter, stats);
     832    }
     833  }
     834#else
    557835    if (m_pchReconFile)
    558836    {
     
    564842    rateStatsAccum(au, stats);
    565843  }
     844#endif
    566845}
    567846
     
    609888void TAppEncTop::printRateSummary()
    610889{
     890#if H_MV
     891  Double time = (Double) m_frameRcvd[0] / m_iFrameRate;
     892  printf("\n");
     893#else
    611894  Double time = (Double) m_iFrameRcvd / m_iFrameRate;
     895#endif
    612896  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
    613897#if VERBOSE_RATE
     
    616900}
    617901
     902#if H_MV
     903Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps )
     904{   
     905  vps.setScalabilityMask( m_scalabilityMask );
     906  for( Int dim = 0; dim < m_dimIds.size(); dim++ )
     907  {
     908      vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] );
     909      for( Int layer = 1; layer < vps.getMaxLayers(); layer++ )
     910      {       
     911        vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] );       
     912      } 
     913  }
     914}
     915
     916Void TAppEncTop::xSetDirectDependencyFlags( TComVPS& vps )
     917{
     918  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
     919  {
     920    if( m_GOPListMvc[layer][MAX_GOP].m_POC == -1 )
     921    {
     922      continue;
     923    }
     924    for( Int i = 0; i < getGOPSize()+1; i++ )
     925    {
     926      GOPEntry ge = ( i < getGOPSize() ) ? m_GOPListMvc[layer][i] : m_GOPListMvc[layer][MAX_GOP];
     927      for( Int j = 0; j < ge.m_numInterViewRefPics; j++ )
     928      {
     929        Int interLayerRef = layer + ge.m_interViewRefs[j];
     930        vps.setDirectDependencyFlag( layer, interLayerRef, true );
     931      }
     932    }
     933  }
     934
     935  vps.checkVPSExtensionSyntax();
     936  vps.calcIvRefLayers();
     937}
     938
     939Void TAppEncTop::xSetLayerIds( TComVPS& vps )
     940{
     941  vps.setSplittingFlag     ( m_splittingFlag );
     942
     943  Bool nuhLayerIdPresentFlag = !( m_layerIdInNuh.size() == 1 );
     944  Int  maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ;
     945
     946  vps.setMaxNuhLayerId( maxNuhLayerId );
     947  vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag );
     948
     949  for (Int layer = 0; layer < m_numberOfLayers; layer++ )
     950  {
     951    vps.setLayerIdInNuh( layer, nuhLayerIdPresentFlag ? m_layerIdInNuh[ layer ] : layer );
     952    vps.setLayerIdInVps( vps.getLayerIdInNuh( layer ), layer );
     953  }
     954}
     955
     956Int TAppEncTop::xGetMax( std::vector<Int>& vec )
     957{
     958  Int maxVec = 0;
     959  for ( Int i = 0; i < vec.size(); i++)   
     960    maxVec = max( vec[i], maxVec );
     961  return maxVec;
     962}
     963#endif
    618964
    619965//! \}
  • branches/HTM-DEV-0.1-dev/source/App/TAppEncoder/TAppEncTop.h

    r367 r368  
    5959private:
    6060  // class interface
     61#if H_MV
     62  std::vector<TEncTop*>      m_acTEncTopList ;              ///< encoder class per layer
     63  std::vector<TVideoIOYuv*>  m_acTVideoIOYuvInputFileList;  ///< input YUV file
     64  std::vector<TVideoIOYuv*>  m_acTVideoIOYuvReconFileList;  ///< output reconstruction file
     65 
     66  std::vector<TComList<TComPicYuv*>*>  m_picYuvRec;         ///< list of reconstruction YUV files
     67
     68  std::vector<Int>           m_frameRcvd;                   ///< number of received frames
     69
     70  TComPicLists               m_ivPicLists;                  ///< picture buffers of encoder instances
     71#else
    6172  TEncTop                    m_cTEncTop;                    ///< encoder class
    6273  TVideoIOYuv                m_cTVideoIOYuvInputFile;       ///< input YUV file
     
    6677 
    6778  Int                        m_iFrameRcvd;                  ///< number of received frames
     79#endif
    6880
    6981  UInt m_essentialBytes;
     
    7789 
    7890  /// obtain required buffers
     91#if H_MV
     92  Void xGetBuffer(TComPicYuv*& rpcPicYuvRec, UInt layer);
     93#else
    7994  Void xGetBuffer(TComPicYuv*& rpcPicYuvRec);
     95#endif
    8096
    8197  /// delete allocated buffers
     
    8399 
    84100  // file I/O
     101#if H_MV
     102  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId); ///< write bitstream to file
     103#else
    85104  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits); ///< write bitstream to file
     105#endif
    86106  void rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& stats);
    87107  void printRateSummary();
    88108 
     109#if H_MV
     110  Void xSetLayerIds               ( TComVPS& vps ); 
     111  Void xSetDimensionIdAndLength   ( TComVPS& vps );
     112  Void xSetDirectDependencyFlags  ( TComVPS& vps );
     113  Int  xGetMax( std::vector<Int>& vec);
     114#endif
    89115public:
    90116  TAppEncTop();
     
    92118 
    93119  Void        encode      ();                               ///< main encoding function
     120#if H_MV
     121  TEncTop*    getTEncTopLayer(UInt layer) { return  m_acTEncTopList[layer]; }  ///< return pointer to encoder class for specific layer
     122#if H_3D
     123  TEncTop*    getTEncTopView( Int viewId, Bool isDepth );                      ///< return pointer to encoder class for specific view Id and texture or depth
     124#endif
     125#else
    94126  TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
     127#endif
    95128};// END CLASS DEFINITION TAppEncTop
    96129
  • branches/HTM-DEV-0.1-dev/source/App/TAppEncoder/encmain.cpp

    r367 r368  
    5757  // print information
    5858  fprintf( stdout, "\n" );
     59#if H_MV
     60  fprintf( stdout, "3D-HTM Software: Encoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION ); 
     61#else
    5962  fprintf( stdout, "HM software: Encoder Version [%s]", NV_VERSION );
     63#endif
    6064  fprintf( stdout, NVM_ONOS );
    6165  fprintf( stdout, NVM_COMPILEDBY );
  • branches/HTM-DEV-0.1-dev/source/Lib/TAppCommon/program_options_lite.h

    r367 r368  
    3737#include <map>
    3838
     39#if H_MV
     40#include <vector>
     41#include <errno.h>
     42#include <cstring>
     43
     44#ifdef WIN32
     45#define strdup _strdup
     46#endif
     47#endif
    3948//! \ingroup TAppCommon
    4049//! \{
     
    136145    }
    137146
     147#if H_MV   
     148    template<>
     149    inline void
     150      Option<char*>::parse(const std::string& arg)
     151    {
     152      opt_storage = arg.empty() ? NULL : strdup(arg.c_str()) ;
     153    }
     154
     155    template<>
     156    inline void
     157      Option< std::vector<char*> >::parse(const std::string& arg)
     158    {
     159      opt_storage.clear();
     160
     161      char* pcStart = (char*) arg.data();     
     162      char* pcEnd = strtok (pcStart," ");
     163
     164      while (pcEnd != NULL)
     165      {
     166        size_t uiStringLength = pcEnd - pcStart;
     167        char* pcNewStr = (char*) malloc( uiStringLength + 1 );
     168        strncpy( pcNewStr, pcStart, uiStringLength);
     169        pcNewStr[uiStringLength] = '\0';
     170        pcStart = pcEnd+1;
     171        pcEnd = strtok (NULL, " ,.-");
     172        opt_storage.push_back( pcNewStr );
     173      }     
     174    }
     175
     176
     177    template<>   
     178    inline void
     179      Option< std::vector<double> >::parse(const std::string& arg)
     180    {
     181      char* pcNextStart = (char*) arg.data();
     182      char* pcEnd = pcNextStart + arg.length();
     183
     184      char* pcOldStart = 0;
     185
     186      size_t iIdx = 0;
     187
     188      while (pcNextStart < pcEnd)
     189      {
     190        errno = 0;
     191
     192        if ( iIdx < opt_storage.size() )
     193        {
     194          opt_storage[iIdx] = strtod(pcNextStart, &pcNextStart);
     195        }
     196        else
     197        {
     198          opt_storage.push_back( strtod(pcNextStart, &pcNextStart)) ;
     199        }
     200        iIdx++;
     201
     202        if ( errno == ERANGE || (pcNextStart == pcOldStart) )
     203        {
     204          std::cerr << "Error Parsing Doubles: `" << arg << "'" << std::endl;
     205          exit(EXIT_FAILURE);   
     206        };   
     207        while( (pcNextStart < pcEnd) && ( *pcNextStart == ' ' || *pcNextStart == '\t' || *pcNextStart == '\r' ) ) pcNextStart++; 
     208        pcOldStart = pcNextStart;
     209
     210      }
     211    }
     212
     213    template<>
     214    inline void
     215      Option< std::vector<int> >::parse(const std::string& arg)
     216    {
     217      opt_storage.clear();
     218
     219
     220      char* pcNextStart = (char*) arg.data();
     221      char* pcEnd = pcNextStart + arg.length();
     222
     223      char* pcOldStart = 0;
     224
     225      size_t iIdx = 0;
     226
     227
     228      while (pcNextStart < pcEnd)
     229      {
     230
     231        if ( iIdx < opt_storage.size() )
     232        {
     233          opt_storage[iIdx] = (int) strtol(pcNextStart, &pcNextStart,10);
     234        }
     235        else
     236        {
     237          opt_storage.push_back( (int) strtol(pcNextStart, &pcNextStart,10)) ;
     238        }
     239        iIdx++;
     240        if ( errno == ERANGE || (pcNextStart == pcOldStart) )
     241        {
     242          std::cerr << "Error Parsing Integers: `" << arg << "'" << std::endl;
     243          exit(EXIT_FAILURE);
     244        };   
     245        while( (pcNextStart < pcEnd) && ( *pcNextStart == ' ' || *pcNextStart == '\t' || *pcNextStart == '\r' ) ) pcNextStart++; 
     246        pcOldStart = pcNextStart;
     247      }
     248    }
     249
     250
     251    template<>
     252    inline void
     253      Option< std::vector<bool> >::parse(const std::string& arg)
     254    {
     255      char* pcNextStart = (char*) arg.data();
     256      char* pcEnd = pcNextStart + arg.length();
     257
     258      char* pcOldStart = 0;
     259
     260      size_t iIdx = 0;
     261
     262      while (pcNextStart < pcEnd)
     263      {
     264        if ( iIdx < opt_storage.size() )
     265        {
     266          opt_storage[iIdx] = (strtol(pcNextStart, &pcNextStart,10) != 0);
     267        }
     268        else
     269        {
     270          opt_storage.push_back(strtol(pcNextStart, &pcNextStart,10) != 0) ;
     271        }
     272        iIdx++;
     273
     274        if ( errno == ERANGE || (pcNextStart == pcOldStart) )
     275        {
     276          std::cerr << "Error Parsing Bools: `" << arg << "'" << std::endl;
     277          exit(EXIT_FAILURE);
     278        };   
     279        while( (pcNextStart < pcEnd) && ( *pcNextStart == ' ' || *pcNextStart == '\t' || *pcNextStart == '\r' ) ) pcNextStart++; 
     280        pcOldStart = pcNextStart;
     281      }
     282    }
     283#endif
    138284    /** Option class for argument handling using a user provided function */
    139285    struct OptionFunc : public OptionBase
     
    210356      }
    211357     
     358#if H_MV
     359      template<typename T>
     360      OptionSpecific&
     361        operator()(const std::string& name, std::vector<T>& storage, T default_val, unsigned uiMaxNum, const std::string& desc = "" )
     362      {
     363        std::string cNameBuffer;
     364        std::string cDescriptionBuffer;
     365
     366        cNameBuffer       .resize( name.size() + 10 );
     367        cDescriptionBuffer.resize( desc.size() + 10 );
     368
     369        storage.resize(uiMaxNum);
     370        for ( unsigned int uiK = 0; uiK < uiMaxNum; uiK++ )
     371        {
     372          // isn't there are sprintf function for string??
     373          sprintf((char*) cNameBuffer.c_str()       ,name.c_str(),uiK,uiK);
     374          sprintf((char*) cDescriptionBuffer.c_str(),desc.c_str(),uiK,uiK);
     375
     376          parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescriptionBuffer ));
     377        }
     378
     379        return *this;
     380      }
     381#endif
    212382      /**
    213383       * Add option described by name to the parent Options list,
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibCommon/CommonDef.h

    r367 r368  
    5656// ====================================================================================================================
    5757
     58#if H_MV
     59#define NV_VERSION        "0.1"                 ///< Current software version
     60#define HM_VERSION        "10.1"                ///<
     61#else
    5862#define NV_VERSION        "10.1"                 ///< Current software version
     63#endif
    5964
    6065// ====================================================================================================================
     
    152157}
    153158
     159#if H_MV
     160
     161#define AOF( exp )                  \
     162{                                   \
     163  if( !( exp ) )                    \
     164{                                 \
     165  assert( 0 );                    \
     166}                                 \
     167}
     168
     169#endif
    154170
    155171// ====================================================================================================================
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibCommon/NAL.h

    r367 r368  
    4747  NalUnitType m_nalUnitType; ///< nal_unit_type
    4848  UInt        m_temporalId;  ///< temporal_id
     49#if H_MV
     50  Int         m_layerId;     ///< layer id
     51#else
    4952  UInt        m_reservedZero6Bits; ///< reserved_zero_6bits
     53#endif
    5054
    5155  /** construct an NALunit structure with given header values. */
     
    5357    NalUnitType nalUnitType,
    5458    Int         temporalId = 0,
     59#if H_MV
     60    Int         layerId = 0)
     61#else
    5562    Int         reservedZero6Bits = 0)
     63#endif
    5664    :m_nalUnitType (nalUnitType)
    5765    ,m_temporalId  (temporalId)
     66#if H_MV
     67    ,m_layerId     (layerId)
     68#else
    5869    ,m_reservedZero6Bits(reservedZero6Bits)
     70#endif
    5971  {}
    6072
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibCommon/TComPic.cpp

    r367 r368  
    6464, m_pNDBFilterYuvTmp                      (NULL)
    6565, m_bCheckLTMSB                           (false)
     66#if H_MV
     67, m_layerId                               (0)
     68, m_viewId                                (0)
     69#if H_3D
     70, m_isDepth                               (false)
     71#endif
     72#endif
    6673{
    6774  m_apcPicYuv[0]      = NULL;
     
    464471
    465472}
     473#if H_MV
     474Void TComPic::print( Bool legend )
     475{
     476  if ( legend )
     477    std::cout  << "LId"        << "\t" << "POC"   << "\t" << "Rec"          << "\t" << "Ref"                       << "\t" << "LT"            << std::endl;
     478  else
     479    std::cout  << getLayerId() << "\t" << getPOC()<< "\t" << getReconMark() << "\t" << getSlice(0)->isReferenced() << "\t" << getIsLongTerm() << std::endl;
     480}
     481#endif
    466482
    467483
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibCommon/TComPic.h

    r367 r368  
    8686  SEIMessages  m_SEIs; ///< Any SEI messages that have been received.  If !NULL we own the object.
    8787
     88#if H_MV
     89  Int                   m_layerId;
     90  Int                   m_viewId;
     91#if H_3D
     92  Bool                  m_isDepth;
     93#endif
     94#endif
    8895public:
    8996  TComPic();
     
    98105  Void          setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; }
    99106
     107#if H_MV
     108  Void          setLayerId            ( Int layerId )    { m_layerId      = layerId; }
     109  Int           getLayerId            ()                 { return m_layerId;    }
     110  Void          setViewId             ( Int viewId )     { m_viewId = viewId;   }
     111  Int           getViewId             ()                 { return m_viewId;     }
     112#if H_3D
     113  Void          setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
     114  Bool          getIsDepth            ()                 { return m_isDepth; }
     115#endif
     116#endif
    100117  Bool          getUsedByCurr()             { return m_bUsedByCurr; }
    101118  Void          setUsedByCurr( Bool bUsed ) { m_bUsedByCurr = bUsed; }
     
    164181  std::vector<TComDataCU*>& getOneSliceCUDataForNDBFilter      (Int sliceID) { return m_vSliceCUDataLink[sliceID];}
    165182
     183#if H_MV
     184  Void          print( Bool legend );
     185#endif
    166186  /** transfer ownership of seis to this picture */
    167187  void setSEIs(SEIMessages& seis) { m_SEIs = seis; }
     
    179199};// END CLASS DEFINITION TComPic
    180200
     201#if H_MV
     202class TComPicLists
     203{
     204private:
     205  TComList<TComList<TComPic*>*> m_lists;
     206public:
     207 
     208  Void push_back( TComList<TComPic*>* list ) { m_lists.push_back( list ); }
     209  Int  size     ()                           { return (Int) m_lists.size    (); }
     210
     211  TComPic* getPic( Int layerIdInNuh, Int poc )
     212  {
     213    TComPic* pcPic = NULL;
     214    for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() && pcPic == NULL ); itL++)
     215    {   
     216      for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() && pcPic == NULL ); itP++)
     217      {
     218        if ( ( (*itP)->getPOC() == poc ) && ( (*itP)->getLayerId() == layerIdInNuh ) )
     219        {
     220          pcPic = *itP ;     
     221        }
     222      }
     223    }
     224    return pcPic;
     225  }
     226
     227  Void print( )
     228  {
     229    Bool first = true;     
     230    for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() ); itL++)
     231    {   
     232      for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() ); itP++)
     233      {
     234        if ( first )
     235        {
     236          (*itP)->print( true );       
     237          first = false;
     238        }
     239        (*itP)->print( false );       
     240      }
     241    }
     242  }
     243
     244
     245}; // END CLASS DEFINITION TComPicLists
     246
     247#endif
    181248//! \}
    182249
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibCommon/TComSlice.cpp

    r367 r368  
    107107, m_temporalLayerNonReferenceFlag ( false )
    108108, m_enableTMVPFlag                ( true )
     109#if H_MV
     110, m_layerId                       (0)
     111, m_viewId                        (0)
     112#if H_3D
     113, m_isDepth                       (false)
     114#endif
     115#endif
    109116{
    110117#if L0034_COMBINED_LIST_CLEANUP
     
    138145    m_aiRefPOCList  [0][iNumCount] = 0;
    139146    m_aiRefPOCList  [1][iNumCount] = 0;
     147#if H_MV
     148    m_aiRefLayerIdList[0][iNumCount] = 0;
     149    m_aiRefLayerIdList[1][iNumCount] = 0;
     150#endif
    140151  }
    141152  resetWpScaling();
     
    309320    {
    310321      m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC();
     322#if H_MV
     323      m_aiRefLayerIdList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getLayerId();
     324#endif
    311325    }
    312326  }
     
    354368        for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ )
    355369        {
     370#if H_MV
     371          if ( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() &&
     372               m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getLayerId() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getLayerId() )
     373#else
    356374          if ( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() )
     375#endif
    357376          {
    358377            m_iRefIdxOfL1FromRefIdxOfL0[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC];
     
    376395        for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ )
    377396        {
     397#if H_MV
     398          if ( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() &&
     399               m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getLayerId() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getLayerId() )
     400#else
    378401          if ( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() )
     402#endif
    379403          {
    380404            m_iRefIdxOfL0FromRefIdxOfL1[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC];
     
    396420#endif
    397421
     422#if H_MV
     423Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer , Bool checkNumPocTotalCurr)
     424#else
    398425#if FIX1071
    399426Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr )
     
    401428Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic )
    402429#endif
     430#endif
    403431{
    404432#if FIX1071
     
    414442    }
    415443   
     444#if !H_MV
    416445    m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0);
    417446    m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1);
     447#endif
    418448  }
    419449
     
    425455  UInt NumPocStCurr1 = 0;
    426456  UInt NumPocLtCurr = 0;
     457#if H_MV
     458  Int numDirectRefLayers  = getVPS()->getNumDirectRefLayers( getLayerIdInVps() );
     459  assert( numDirectRefLayers == refPicSetInterLayer.size() );
     460#endif
    427461  Int i;
    428462
     
    473507  TComPic*  rpsCurrList0[MAX_NUM_REF+1];
    474508  TComPic*  rpsCurrList1[MAX_NUM_REF+1];
     509#if H_MV
     510  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + numDirectRefLayers;
     511  assert( numPocTotalCurr == getNumRpsCurrTempList() );
     512#else
    475513  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr;
     514#endif
    476515#if FIX1071
    477516  if (checkNumPocTotalCurr)
     
    513552    rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
    514553  }
     554#if H_MV
     555  for ( i=0; i<numDirectRefLayers;  i++, cIdx++)
     556  {
     557    if( cIdx <= MAX_NUM_REF )
     558    {
     559      rpsCurrList0[cIdx] = refPicSetInterLayer[i];
     560    }
     561  }
     562#endif
    515563
    516564  if (m_eSliceType==B_SLICE)
     
    529577      rpsCurrList1[cIdx] = RefPicSetLtCurr[i];
    530578    }
     579#if H_MV
     580    for ( i=0; i<numDirectRefLayers;  i++, cIdx++)
     581    {
     582      if( cIdx <= MAX_NUM_REF )
     583      {
     584        rpsCurrList1[cIdx] = refPicSetInterLayer[i];
     585      }
     586    }
     587#endif
    531588  }
    532589
     
    570627    }
    571628  }
     629#if H_MV
     630  numRpsCurrTempList = numRpsCurrTempList + getVPS()->getNumDirectRefLayers( getLayerIdInVps() );
     631#endif
    572632  return numRpsCurrTempList;
    573633}
     
    732792  m_iPOC                 = pSrc->m_iPOC;
    733793  m_eNalUnitType         = pSrc->m_eNalUnitType;
     794#if H_MV
     795  m_layerId              = pSrc->m_layerId;
     796#endif
    734797  m_eSliceType           = pSrc->m_eSliceType;
    735798  m_iSliceQp             = pSrc->m_iSliceQp;
     
    784847      m_apcRefPicList[i][j]  = pSrc->m_apcRefPicList[i][j];
    785848      m_aiRefPOCList[i][j]   = pSrc->m_aiRefPOCList[i][j];
     849#if H_MV
     850      m_aiRefLayerIdList[i][j] = pSrc->m_aiRefLayerIdList[i][j];
     851#endif
    786852    }
    787853  }
     
    799865
    800866  // access channel
     867#if H_MV
     868  m_pcVPS                = pSrc->m_pcVPS;
     869#endif
    801870  m_pcSPS                = pSrc->m_pcSPS;
    802871  m_pcPPS                = pSrc->m_pcPPS;
     
    13121381, m_bTemporalIdNestingFlag    (false)
    13131382, m_numHrdParameters          (  0)
     1383#if H_MV
     1384, m_maxNuhLayerId             (  0)
     1385#else
    13141386, m_maxNuhReservedZeroLayerId (  0)
     1387#endif
    13151388, m_hrdParameters             (NULL)
    13161389, m_hrdOpSetIdx               (NULL)
     
    13271400    m_uiMaxLatencyIncrease[i] = 0;
    13281401  }
     1402#if H_MV
     1403  m_avcBaseLayerFlag = false;
     1404  m_splittingFlag    = false;
     1405 
     1406  for( Int i = 0; i < MAX_NUM_SCALABILITY_TYPES; i++ )
     1407  {
     1408    m_scalabilityMask[i] = false;
     1409    m_dimensionIdLen [i]  = -1;
     1410  }
     1411
     1412  m_vpsNuhLayerIdPresentFlag = false;
     1413  m_numOutputLayerSets       = 0;
     1414
     1415  for( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++ )
     1416  {
     1417    m_vpsProfilePresentFlag   [i] = false;
     1418    m_profileLayerSetRefMinus1[i] = 0;
     1419    m_outputLayerSetIdx       [i] = 0;
     1420    for( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++ )
     1421    {
     1422      m_outputLayerFlag[i][j] = false;
     1423    }
     1424  }
     1425
     1426  for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ )
     1427  {
     1428    m_layerIdInVps[i] =  (i == 0 ) ? 0 : -1;         
     1429  }
     1430
     1431  for( Int i = 0; i < MAX_NUM_LAYERS; i++ )
     1432  {
     1433    m_layerIdInNuh      [i] = ( i == 0 ) ? 0 : -1;
     1434    m_numDirectRefLayers[i] = 0;
     1435
     1436    for( Int j = 0; j < MAX_NUM_LAYERS; j++ )
     1437    {
     1438      m_directDependencyFlag[i][j] = false;
     1439      m_refLayerId[i][j]           = -1;
     1440    }
     1441
     1442    for( Int j = 0; j < MAX_NUM_SCALABILITY_TYPES; j++ )
     1443    {
     1444      m_dimensionId[i][j] = 0;
     1445    }
     1446
     1447  }
     1448#endif
    13291449}
    13301450
     
    13361456}
    13371457
     1458#if H_MV
     1459
     1460Bool TComVPS::checkVPSExtensionSyntax()
     1461{
     1462  // check splitting flag constraint
     1463  if ( getSplittingFlag() )
     1464  {
     1465    // Derive dimBitOffset[j]
     1466    Int dimBitOffset[MAX_NUM_SCALABILITY_TYPES+1];
     1467    Int numScalabilityTypes = getNumScalabilityTypes();
     1468    dimBitOffset[0] = 0;
     1469
     1470    for (Int type = 1; type <= numScalabilityTypes; type++ )
     1471    {
     1472      dimBitOffset[ type ] = 0;
     1473      for (Int dimIdx = 0; dimIdx <= type - 1; dimIdx++)
     1474        dimBitOffset[ type ] += ( getDimensionIdLen( dimIdx ) );
     1475    }
     1476
     1477    for (Int type = 0; type < getNumScalabilityTypes(); type++ )
     1478    {
     1479      for( Int layer = 1; layer < getMaxLayers(); layer++ )
     1480      {
     1481        assert( getDimensionId( layer, type ) == ( ( getLayerIdInNuh( layer ) & ( (1 << dimBitOffset[ type + 1 ] ) - 1) ) >> dimBitOffset[ type ] ) );
     1482      };
     1483  };
     1484  }
     1485
     1486  for( Int layer = 1; layer < getMaxLayers(); layer++ )
     1487  {
     1488    // check layer_id_in_nuh constraint
     1489    assert( getLayerIdInNuh( layer ) > getLayerIdInNuh( layer -1 ) );
     1490  }
     1491  return true;
     1492}
     1493
     1494Int TComVPS::getNumScalabilityTypes()
     1495{
     1496  return scalTypeToScalIdx( ScalabilityType(MAX_NUM_SCALABILITY_TYPES) );
     1497}
     1498
     1499Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType )
     1500{
     1501  assert( scalType >= 0 && scalType <= MAX_NUM_SCALABILITY_TYPES );
     1502  assert( scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMask( scalType ) );
     1503
     1504  Int scalIdx = 0;
     1505  for( Int curScalType = 0; curScalType < scalType; curScalType++ )
     1506  {
     1507    scalIdx += ( getScalabilityMask( curScalType ) ? 1 : 0 );
     1508  }
     1509
     1510  return scalIdx;
     1511}
     1512
     1513
     1514
     1515Void TComVPS::setScalabilityMask( UInt val )
     1516{
     1517  for ( Int scalType = 0; scalType < MAX_NUM_SCALABILITY_TYPES; scalType++ )
     1518    setScalabilityMask( scalType, ( val & (1 << scalType ) ) == 1 );
     1519}
     1520
     1521Void TComVPS::calcIvRefLayers()
     1522{
     1523  for( Int i = 1; i <= getMaxLayers(); i++ )
     1524  {
     1525    m_numDirectRefLayers[ i ] = 0;
     1526    for( Int j = 0 ; j < i; j++ )
     1527      if( m_directDependencyFlag[ i ][ j ])
     1528        m_refLayerId[ i ][ m_numDirectRefLayers[ i ]++ ] = m_layerIdInNuh[ j ];   
     1529  }
     1530}
     1531
     1532Int TComVPS::getRefLayerId( Int layerIdInVps, Int idx )
     1533{
     1534  assert( idx >= 0 && idx < m_numDirectRefLayers[layerIdInVps] );     
     1535  Int layerIdInNuh = m_refLayerId[ layerIdInVps ][ idx ];   
     1536  assert ( layerIdInNuh >= 0 );
     1537  return layerIdInNuh;
     1538}
     1539
     1540Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType )
     1541{
     1542  return ( ( layerIdInVps != 0 )&& getScalabilityMask( scalType ) ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0;
     1543}
     1544#endif
    13381545// ------------------------------------------------------------------------------------------------
    13391546// Sequence parameter set (SPS)
     
    13821589, m_vuiParametersPresentFlag  (false)
    13831590, m_vuiParameters             ()
     1591#if H_MV
     1592, m_interViewMvVertConstraintFlag (false)
     1593#endif
    13841594{
    13851595  for ( Int i = 0; i < MAX_TLAYER; i++ )
     
    18452055}
    18462056
     2057#if H_MV
     2058Void TComSlice::createAndApplyIvReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer )
     2059{
     2060  refPicSetInterLayer.clear();
     2061
     2062  for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerIdInVps() ); i++ )
     2063  {
     2064    Int layerIdRef = getVPS()->getRefLayerId( getLayerIdInVps(), i );
     2065    TComPic* picRef = ivPicLists->getPic( layerIdRef, getPOC() ) ;
     2066    assert ( picRef != 0 );
     2067
     2068    picRef->getPicYuvRec()->extendPicBorder();
     2069    picRef->setIsLongTerm( true );       
     2070    picRef->getSlice(0)->setReferenced( true );       
     2071
     2072    refPicSetInterLayer.push_back( picRef );
     2073  }
     2074}
     2075
     2076Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer )
     2077{
     2078  // Mark as shortterm
     2079  for ( Int i = 0; i < refPicSetInterLayer.size(); i++ )
     2080  {
     2081    refPicSetInterLayer[i]->setIsLongTerm( false );
     2082  }
     2083}
     2084
     2085Void TComSlice::markIvRefPicsAsUnused( TComPicLists* ivPicLists, std::vector<Int> targetDecLayerIdSet, TComVPS* vps, Int curLayerId, Int curPoc )
     2086{
     2087  // Fill targetDecLayerIdSet with all layers if empty.
     2088  if (targetDecLayerIdSet.size() == 0 )   
     2089  {
     2090    for ( Int layerIdInVps = 0; layerIdInVps < vps->getMaxLayers(); layerIdInVps++ )
     2091    {
     2092      targetDecLayerIdSet.push_back( vps->getLayerIdInNuh( layerIdInVps ) );
     2093    }
     2094  }     
     2095
     2096  Int numTargetDecLayers = (Int) targetDecLayerIdSet.size();
     2097  Int latestDecIdx;
     2098  for ( latestDecIdx = 0; latestDecIdx < numTargetDecLayers; latestDecIdx++)
     2099  {
     2100    if ( targetDecLayerIdSet[ latestDecIdx ] == curLayerId )
     2101      break;
     2102  }       
     2103
     2104  for( Int i = 0; i <= latestDecIdx; i++ )
     2105  {
     2106    if ( vps->nuhLayerIdIncluded( targetDecLayerIdSet[ i ] ) )
     2107    {
     2108      TComPic* pcPic = ivPicLists->getPic( targetDecLayerIdSet[ i ], curPoc );
     2109      if( pcPic->getSlice(0)->isReferenced() && pcPic->getSlice(0)->getTemporalLayerNonReferenceFlag() )
     2110      {
     2111        Bool remainingInterLayerReferencesFlag = false;
     2112        for( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
     2113        {
     2114          TComVPS* vpsSlice = pcPic->getSlice(0)->getVPS();
     2115          if ( vps->nuhLayerIdIncluded( targetDecLayerIdSet[ j ] ) )
     2116          {
     2117            Int targetDecLayerIdinVPS = vpsSlice->getLayerIdInVps( targetDecLayerIdSet[ j ] );
     2118            for( Int k = 0; k < vpsSlice->getNumDirectRefLayers( targetDecLayerIdinVPS ); k++ )
     2119              if ( targetDecLayerIdSet[ i ] == vpsSlice->getRefLayerId( targetDecLayerIdinVPS,  k  ) )
     2120                remainingInterLayerReferencesFlag = true;
     2121          }
     2122        }
     2123        if( !remainingInterLayerReferencesFlag )
     2124          pcPic->getSlice(0)->setReferenced( false );                   
     2125      }
     2126    }
     2127  }
     2128}
     2129
     2130Void TComSlice::xPrintRefPicList()
     2131
     2132  for ( Int li = 0; li < 2; li++)
     2133  {   
     2134    std::cout << std::endl << "RefPicListL" <<  li << ":" << std::endl;
     2135    for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++)
     2136    {     
     2137      if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true );
     2138       
     2139      m_apcRefPicList[li][rIdx]->print( false );
     2140    }
     2141  }
     2142}
     2143#endif
    18472144/** get scaling matrix from RefMatrixID
    18482145 * \param sizeId size index
     
    20672364  {
    20682365    Int spsId = pps->getSPSId();
     2366#if H_MV
     2367    // active parameter sets per layer should be used here
     2368#else
    20692369    if (!isIRAP && (spsId != m_activeSPSId))
    20702370    {
     
    20722372      return false;
    20732373    }
     2374#endif
    20742375    TComSPS *sps = m_spsMap.getPS(spsId);
    20752376    if (sps)
     
    21262427}
    21272428
     2429#if H_MV
     2430Void TComPTL::copyLevelFrom( TComPTL* source )
     2431{
     2432  getGeneralPTL()->setLevelIdc( source->getGeneralPTL()->getLevelIdc() );
     2433  for( Int subLayer = 0; subLayer < 6; subLayer++ )
     2434  {
     2435    setSubLayerLevelPresentFlag( subLayer, source->getSubLayerLevelPresentFlag( subLayer ) );
     2436    getSubLayerPTL( subLayer )->setLevelIdc( source->getSubLayerPTL( subLayer )->getLevelIdc() );
     2437  }
     2438}
     2439#endif
    21282440#if SIGNAL_BITRATE_PICRATE_IN_VPS
    21292441TComBitRatePicRateInfo::TComBitRatePicRateInfo()
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibCommon/TComSlice.h

    r367 r368  
    5151class TComPic;
    5252class TComTrQuant;
     53#if H_MV
     54class TComPicLists;
     55#endif
    5356// ====================================================================================================================
    5457// Constants
     
    245248  ProfileTierLevel* getGeneralPTL()  { return &m_generalPTL; }
    246249  ProfileTierLevel* getSubLayerPTL(Int i)  { return &m_subLayerPTL[i]; }
     250#if H_MV
     251  Void copyLevelFrom( TComPTL* source );
     252#endif
    247253};
    248254/// VPS class
     
    480486
    481487  UInt        m_numHrdParameters;
     488#if H_MV
     489  UInt        m_maxNuhLayerId;
     490#else
    482491  UInt        m_maxNuhReservedZeroLayerId;
     492#endif
    483493  TComHRD*    m_hrdParameters;
    484494  UInt*       m_hrdOpSetIdx;
    485495  Bool*       m_cprmsPresentFlag;
    486496  UInt        m_numOpSets;
     497#if H_MV
     498  Bool        m_layerIdIncludedFlag[MAX_VPS_OP_SETS_PLUS1][MAX_VPS_NUH_LAYER_ID_PLUS1];
     499#else
    487500  Bool        m_layerIdIncludedFlag[MAX_VPS_OP_SETS_PLUS1][MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1];
    488 
     501#endif
     502
     503#if H_MV
     504  TComPTL     m_pcPTL[MAX_VPS_OP_SETS_PLUS1];
     505#else
    489506  TComPTL     m_pcPTL;
     507#endif
    490508#if SIGNAL_BITRATE_PICRATE_IN_VPS
    491509  TComBitRatePicRateInfo    m_bitRatePicRateInfo;
     
    495513#endif
    496514
     515#if H_MV
     516  Bool        m_avcBaseLayerFlag;
     517  Bool        m_splittingFlag;
     518  Bool        m_scalabilityMask          [MAX_NUM_SCALABILITY_TYPES];
     519  Int         m_dimensionIdLen           [MAX_NUM_SCALABILITY_TYPES];
     520  Bool        m_vpsNuhLayerIdPresentFlag;
     521  Int         m_layerIdInNuh             [MAX_NUM_LAYER_IDS];
     522  Int         m_layerIdInVps             [MAX_NUM_LAYERS   ];
     523  Int         m_dimensionId              [MAX_NUM_LAYER_IDS][MAX_NUM_SCALABILITY_TYPES]; 
     524
     525 
     526  Bool        m_vpsProfilePresentFlag    [MAX_VPS_OP_SETS_PLUS1];
     527  Int         m_profileLayerSetRefMinus1 [MAX_VPS_OP_SETS_PLUS1];
     528  Int         m_numOutputLayerSets;
     529  Int         m_outputLayerSetIdx        [MAX_VPS_OP_SETS_PLUS1];
     530  Bool        m_outputLayerFlag          [MAX_VPS_OP_SETS_PLUS1][MAX_VPS_NUH_LAYER_ID_PLUS1];
     531  Bool        m_directDependencyFlag     [MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];
     532
     533  Int         m_numDirectRefLayers       [ MAX_NUM_LAYERS ];
     534  Int         m_refLayerId               [ MAX_NUM_LAYERS ][MAX_NUM_LAYERS]; 
     535
     536#endif
    497537public:
    498538  TComVPS();
     
    536576  Void    setNumHrdParameters(UInt v)                           { m_numHrdParameters = v;    }
    537577
     578#if H_MV
     579  UInt    getMaxNuhLayerId()                                    { return m_maxNuhLayerId; }
     580  Void    setMaxNuhLayerId(UInt v)                              { m_maxNuhLayerId = v;    }
     581#else
    538582  UInt    getMaxNuhReservedZeroLayerId()                        { return m_maxNuhReservedZeroLayerId; }
    539583  Void    setMaxNuhReservedZeroLayerId(UInt v)                  { m_maxNuhReservedZeroLayerId = v;    }
     584#endif
    540585
    541586  UInt    getMaxOpSets()                                        { return m_numOpSets; }
     
    544589  Void    setLayerIdIncludedFlag(Bool v, UInt opsIdx, UInt id)  { m_layerIdIncludedFlag[opsIdx][id] = v;    }
    545590
     591#if H_MV
     592  TComPTL* getPTL( Int layerSet = 0 ) { return &m_pcPTL[layerSet]; }
     593#else
    546594  TComPTL* getPTL() { return &m_pcPTL; }
     595#endif
    547596#if SIGNAL_BITRATE_PICRATE_IN_VPS
    548597  TComBitRatePicRateInfo *getBitratePicrateInfo() { return &m_bitRatePicRateInfo; }
     
    550599#if L0043_TIMING_INFO
    551600  TimingInfo* getTimingInfo() { return &m_timingInfo; }
     601#endif
     602#if H_MV
     603  Void    setAvcBaseLayerFlag( Bool val )                                  { m_avcBaseLayerFlag = val;  }
     604  Bool    getAvcBaseLayerFlag()                                            { return m_avcBaseLayerFlag; }
     605
     606  Void    setSplittingFlag( Bool val )                                     { m_splittingFlag = val;  }
     607  Bool    getSplittingFlag()                                               { return m_splittingFlag; }
     608
     609  Void    setScalabilityMask( UInt val );
     610
     611  Void    setScalabilityMask( Int scalType, Bool val )              { m_scalabilityMask[scalType] = val;  }
     612  Bool    getScalabilityMask( Int scalType )                        { return m_scalabilityMask[scalType]; }
     613
     614  Int     getNumScalabilityTypes( );
     615
     616  Void    setDimensionIdLen( Int sIdx, Int val )                           { m_dimensionIdLen[sIdx] = val;  }
     617  Int     getDimensionIdLen( Int sIdx )                                    { assert( m_dimensionIdLen[sIdx] > 0) ; return m_dimensionIdLen[sIdx]; } 
     618
     619  Void    setVpsNuhLayerIdPresentFlag( Bool val )                          { m_vpsNuhLayerIdPresentFlag = val; }
     620  Bool    getVpsNuhLayerIdPresentFlag()                                    { return m_vpsNuhLayerIdPresentFlag; }
     621
     622  Void    setLayerIdInNuh( Int layerIdInVps, Int val )                     { m_layerIdInNuh[layerIdInVps] = val;  }
     623  Int     getLayerIdInNuh( Int layerIdInVps )                              { assert( m_layerIdInNuh[layerIdInVps] >= 0 ); return m_layerIdInNuh[layerIdInVps]; }
     624
     625  Void    setLayerIdInVps( Int layerIdInNuh, Int val )                     { m_layerIdInVps[layerIdInNuh] = val;  }
     626  Int     getLayerIdInVps( Int layerIdInNuh )                              { assert( m_layerIdInVps[layerIdInNuh] >= 0 ); return m_layerIdInVps[layerIdInNuh]; }
     627
     628  Bool    nuhLayerIdIncluded( Int layerIdinNuh )                           { return ( m_layerIdInVps[ layerIdinNuh ] > 0 );  }
     629
     630  Void    setDimensionId( Int layerIdInVps, Int scalIdx, Int val )         { m_dimensionId[layerIdInVps][scalIdx] = val;  }
     631  Int     getDimensionId( Int layerIdInVps, Int scalIdx )                  { return m_dimensionId[layerIdInVps][scalIdx]; }
     632
     633  Int     getScalabilityId ( Int layerIdInVps, ScalabilityType scalType );
     634
     635  Int     getViewId  ( Int layerIdInVps )                                  { return getScalabilityId( layerIdInVps, VIEW_ID  ); }
     636#if H_3D 
     637  Int     getDepthId ( Int layerIdInVps )                                  { return getScalabilityId( layerIdInVps, DEPTH_ID ); }
     638#endif
     639
     640
     641  Void    setVpsProfilePresentFlag( Int layerSet, Bool val )               { m_vpsProfilePresentFlag[layerSet] = val;  }
     642  Bool    getVpsProfilePresentFlag( Int layerSet )                         { return m_vpsProfilePresentFlag[layerSet]; }
     643
     644  Void    setProfileLayerSetRefMinus1( Int layerSet, Int val )             { m_profileLayerSetRefMinus1[layerSet] = val;  }
     645  Bool    getProfileLayerSetRefMinus1( Int layerSet )                      { return m_profileLayerSetRefMinus1[layerSet]; }
     646
     647  Void    setNumOutputLayerSets( Int val )                                 { m_numOutputLayerSets = val;  }
     648  Int     getNumOutputLayerSets()                                          { return m_numOutputLayerSets; }
     649
     650  Void    setOutputLayerSetIdx( Int layerSet, Int val )                    { m_outputLayerSetIdx[layerSet] = val;  }
     651  Int     getOutputLayerSetIdx( Int layerSet )                             { return m_outputLayerSetIdx[layerSet]; }
     652
     653  Void    setOutputLayerFlag( Int layerSet, Int layer, Bool val )          { m_outputLayerFlag[layerSet][layer] = val;  }
     654  Bool    getOutputLayerFlag( Int layerSet, Int layer )                    { return m_outputLayerFlag[layerSet][layer]; }
     655
     656  Void    setDirectDependencyFlag( Int layerHigh, Int layerLow, Bool val ) { m_directDependencyFlag[layerHigh][layerLow] = val;  }
     657  Bool    getDirectDependencyFlag( Int layerHigh, Int layerLow )           { return m_directDependencyFlag[layerHigh][layerLow]; }
     658
     659  Void    calcIvRefLayers();
     660
     661  Int     getNumDirectRefLayers( Int layerIdInVps )          { return m_numDirectRefLayers[ layerIdInVps ];  };                               
     662  Int     getRefLayerId        ( Int layerIdInVps, Int idx );;
     663 
     664  Bool    checkVPSExtensionSyntax();
     665  Int     scalTypeToScalIdx   ( ScalabilityType scalType );
    552666#endif
    553667};
     
    853967  static const Int   m_winUnitY[MAX_CHROMA_FORMAT_IDC+1];
    854968  TComPTL     m_pcPTL;
     969#if H_MV
     970  Bool        m_interViewMvVertConstraintFlag;
     971#endif
    855972public:
    856973  TComSPS();
     
    9831100
    9841101  TComPTL* getPTL()     { return &m_pcPTL; }
     1102#if H_MV
     1103  Void setInterViewMvVertConstraintFlag(Bool val) { m_interViewMvVertConstraintFlag = val; }
     1104  Bool getInterViewMvVertConstraintFlag()         { return m_interViewMvVertConstraintFlag;}
     1105#endif
    9851106};
    9861107
     
    10091130  Void       setRefPicSetIdxL1(UInt idx, UInt refPicSetIdx) { m_RefPicSetIdxL1[idx] = refPicSetIdx; }
    10101131  UInt       getRefPicSetIdxL1(UInt idx) { return m_RefPicSetIdxL1[idx]; }
     1132#if H_MV
     1133  // Why not an listIdx for all members, would avoid code duplication??
     1134  Void       setRefPicSetIdxL(UInt li, UInt idx, UInt refPicSetIdx) {( li==0 ? m_RefPicSetIdxL0[idx] : m_RefPicSetIdxL1[idx] ) = refPicSetIdx; };
     1135  Void       setRefPicListModificationFlagL(UInt li, Bool flag) { ( li==0  ? m_bRefPicListModificationFlagL0 : m_bRefPicListModificationFlagL1 ) = flag;  }; 
     1136#endif
    10111137};
    10121138
     
    12631389  TComPic*    m_apcRefPicList [2][MAX_NUM_REF+1];
    12641390  Int         m_aiRefPOCList  [2][MAX_NUM_REF+1];
     1391#if H_MV
     1392  Int         m_aiRefLayerIdList[2][MAX_NUM_REF+1];
     1393#endif
    12651394  Bool        m_bIsUsedAsLongTerm[2][MAX_NUM_REF+1];
    12661395  Int         m_iDepth;
     
    13281457
    13291458  Bool       m_enableTMVPFlag;
     1459#if H_MV
     1460  Int        m_layerId;
     1461  Int        m_viewId;
     1462#if H_3D
     1463  Bool       m_isDepth;
     1464#endif
     1465#endif
    13301466public:
    13311467  TComSlice();
     
    14341570  Void      setDepth            ( Int iDepth )                  { m_iDepth            = iDepth; }
    14351571 
     1572#if H_MV
     1573  Int       getRefLayerId        ( RefPicList e, Int iRefIdx)    { return  m_aiRefLayerIdList[e][iRefIdx]; }
     1574  Void      setRefLayerId        ( Int i, RefPicList e, Int iRefIdx ) { m_aiRefLayerIdList[e][iRefIdx] = i; }
     1575#endif
     1576#if H_MV
     1577  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& interLayerRefPicSet , Bool checkNumPocTotalCurr = false );
     1578#else
    14361579#if FIX1071
    14371580  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false );
    14381581#else
    14391582  Void      setRefPicList       ( TComList<TComPic*>& rcListPic );
     1583#endif
    14401584#endif
    14411585  Void      setRefPOCList       ();
     
    14851629  Void decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum );
    14861630  Void applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *RPSList);
     1631#if H_MV
     1632  Void createAndApplyIvReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer );
     1633  static Void markIvRefPicsAsShortTerm    ( std::vector<TComPic*> refPicSetInterLayer );
     1634  static Void markIvRefPicsAsUnused       ( TComPicLists* ivPicLists, std::vector<Int> targetDecLayerIdSet, TComVPS* vps, Int curLayerId, Int curPoc  );
     1635
     1636
     1637  Void xPrintRefPicList();
     1638#endif
    14871639  Bool isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic );
    14881640  Bool isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic );
     
    15601712  Bool      getEnableTMVPFlag     ()              { return m_enableTMVPFlag;}
    15611713
     1714#if H_MV
     1715  Void      setLayerId            ( Int layerId )    { m_layerId      = layerId; }
     1716  Int       getLayerId            ()                 { return m_layerId;    }
     1717  Int       getLayerIdInVps       ()                 { return getVPS()->getLayerIdInVps( m_layerId ); };
     1718  Void      setViewId             ( Int viewId )     { m_viewId = viewId;   }
     1719  Int       getViewId             ()                 { return m_viewId;     }
     1720#if H_3D
     1721  Void      setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
     1722  Bool      getIsDepth            ()                 { return m_isDepth; }
     1723#endif
     1724#endif
    15621725protected:
    15631726  TComPic*  xGetRefPic  (TComList<TComPic*>& rcListPic,
    15641727                         Int                 poc);
    15651728TComPic*  xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb);
     1729#if H_MV
     1730  TComPic*  xGetInterLayerRefPic( std::vector<TComPic*>& rcListIlPic, Int layerId );
     1731#endif
    15661732};// END CLASS DEFINITION TComSlice
    15671733
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibCommon/TypeDef.h

    r367 r368  
    4545
    4646
     47#if H_MV
     48#define H_3D                        0
     49#endif
    4750
    4851///// ***** HM 10.1 *********
     
    8891#define MAX_VPS_NUM_HRD_PARAMETERS                1
    8992#define MAX_VPS_OP_SETS_PLUS1                     1024
     93#if H_MV
     94#define MAX_VPS_NUH_LAYER_ID_PLUS1  64
     95#define MAX_NUM_SCALABILITY_TYPES   16
     96#define ENC_CFG_CONSOUT_SPACE       29           
     97#else
    9098#define MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1  1
     99#endif
    91100
    92101#define RATE_CONTROL_LAMBDA_DOMAIN                  1  ///< JCTVC-K0103, rate control by R-lambda model
     
    95104#define MAX_CPB_CNT                     32  ///< Upper bound of (cpb_cnt_minus1 + 1)
    96105#define MAX_NUM_LAYER_IDS               64
     106#if H_MV
     107#define MAX_NUM_LAYERS                  64
     108#endif
    97109
    98110#define COEF_REMAIN_BIN_REDUCTION        3 ///< indicates the level at which the VLC
     
    509521    MAIN10 = 2,
    510522    MAINSTILLPICTURE = 3,
     523#if H_MV
     524    MAINSTEREO = 4,
     525    MAINMULTIVIEW = 5,
     526#if H_3D
     527    MAIN3D = 6,
     528#endif
     529#endif
    511530  };
    512531}
     
    540559//! \}
    541560
    542 #endif
     561#if H_MV
     562/// scalability types
     563  enum ScalabilityType
     564  {
     565    VIEW_ID  = 0,
     566#if H_3D
     567    DEPTH_ID = 1,
     568#endif   
     569  };
     570#endif
     571#endif
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibDecoder/NALread.cpp

    r367 r368  
    103103  assert(forbidden_zero_bit == 0);
    104104  nalu.m_nalUnitType = (NalUnitType) bs.read(6);  // nal_unit_type
     105#if H_MV
     106  nalu.m_layerId = bs.read(6);                 // layerId
     107#else
    105108  nalu.m_reservedZero6Bits = bs.read(6);       // nuh_reserved_zero_6bits
    106109  assert(nalu.m_reservedZero6Bits == 0);
     110#endif
    107111  nalu.m_temporalId = bs.read(3) - 1;             // nuh_temporal_id_plus1
    108112
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r367 r368  
    680680  if (uiCode)
    681681  {
     682#if H_MV
     683    READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" );    pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false);
     684#else
    682685    while ( xMoreRbspData() )
    683686    {
    684687      READ_FLAG( uiCode, "sps_extension_data_flag");
    685688    }
     689#endif
    686690  }
    687691}
     
    693697  READ_CODE( 4,  uiCode,  "vps_video_parameter_set_id" );         pcVPS->setVPSId( uiCode );
    694698  READ_CODE( 2,  uiCode,  "vps_reserved_three_2bits" );           assert(uiCode == 3);
     699#if H_MV
     700  READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );              pcVPS->setMaxLayers( uiCode + 1 );
     701#else
    695702  READ_CODE( 6,  uiCode,  "vps_reserved_zero_6bits" );            assert(uiCode == 0);
     703#endif
    696704  READ_CODE( 3,  uiCode,  "vps_max_sub_layers_minus1" );          pcVPS->setMaxTLayers( uiCode + 1 );
    697705  READ_FLAG(     uiCode,  "vps_temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
    698706  assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
     707#if H_MV
     708  READ_CODE( 16, uiCode,  "vps_extension_offset" );               
     709#else
    699710  READ_CODE( 16, uiCode,  "vps_reserved_ffff_16bits" );           assert(uiCode == 0xffff);
     711#endif
    700712  parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1);
    701713#if SIGNAL_BITRATE_PICRATE_IN_VPS
     
    727739
    728740  assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 );
     741#if H_MV
     742  assert( pcVPS->getMaxNuhLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 );
     743  READ_CODE( 6, uiCode, "vps_max_nuh_layer_id" );   pcVPS->setMaxNuhLayerId( uiCode );
     744#else
    729745  assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 );
    730746  READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" );   pcVPS->setMaxNuhReservedZeroLayerId( uiCode );
     747#endif
    731748  READ_UVLC(    uiCode, "vps_max_op_sets_minus1" );               pcVPS->setMaxOpSets( uiCode + 1 );
    732749  for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ )
    733750  {
    734751    // Operation point set
     752#if H_MV
     753    for( UInt i = 0; i <= pcVPS->getMaxNuhLayerId(); i ++ )
     754#else
    735755    for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ )
     756#endif
    736757    {
    737758      READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" );     pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i );
     
    772793  if (uiCode)
    773794  {
     795#if H_MV
     796    m_pcBitstream->readOutTrailingBits();
     797
     798    READ_FLAG( uiCode, "avc_base_layer_flag" );                     pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false );
     799    READ_FLAG( uiCode, "splitting_flag" );                          pcVPS->setSplittingFlag( uiCode == 1 ? true : false );
     800
     801    // Parse scalability_mask[i]   
     802    for( Int sIdx = 0; sIdx < MAX_NUM_SCALABILITY_TYPES; sIdx++ )
     803    {
     804      READ_FLAG( uiCode,  "scalability_mask[i]" );                  pcVPS->setScalabilityMask( sIdx, uiCode == 1 ? true : false );     
     805    }
     806
     807    Int numScalabilityTypes = pcVPS->getNumScalabilityTypes();
     808
     809    // Parse dimension_id_len_minus1[j]   
     810    for( Int sIdx = 0; sIdx < numScalabilityTypes; sIdx++ )
     811    {
     812        READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" );       pcVPS->setDimensionIdLen( sIdx, uiCode + 1 );
     813    }
     814
     815    // vps_nuh_layer_id_present_flag
     816    READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" );           pcVPS->setVpsNuhLayerIdPresentFlag( uiCode == 1 ? true : false );
     817
     818    // parse layer_id_in_nuh[i] and derive LayerIdInVps
     819    pcVPS->setLayerIdInNuh( 0, 0 ); pcVPS->setLayerIdInVps( 0, 0 );
     820   
     821    for( Int layer = 1; layer <= pcVPS->getMaxLayers() - 1; layer++ )
     822    {
     823      UInt layerIdInNuh;
     824      if ( pcVPS->getVpsNuhLayerIdPresentFlag() )
     825      {
     826        READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" );                layerIdInNuh = uiCode;
     827      }
     828      else
     829      {
     830        layerIdInNuh = layer;
     831      }     
     832
     833      pcVPS->setLayerIdInNuh( layer, layerIdInNuh );
     834      pcVPS->setLayerIdInVps( layerIdInNuh, layer );
     835
     836      // parse dimension_id[i][j]
     837      for( Int sIdx = 0; sIdx < numScalabilityTypes; sIdx++ )
     838      {
     839          READ_CODE( pcVPS->getDimensionIdLen( sIdx ), uiCode, "dimension_id[i][j]" );  pcVPS->setDimensionId( layer, sIdx, uiCode );
     840      }
     841    }
     842
     843    for( Int layerSet = 1; layerSet <= pcVPS->getMaxOpSets() - 1; layerSet++ )
     844    {
     845      READ_FLAG(  uiCode, "vps_profile_present_flag[lsIdx]" );    pcVPS->setVpsProfilePresentFlag( layerSet, uiCode == 1 ? true : false );
     846      if( pcVPS->getVpsProfilePresentFlag( layerSet ) == false )
     847      {
     848        READ_UVLC( uiCode, "profile_layer_set_ref_minus1[lsIdx]" ); pcVPS->setProfileLayerSetRefMinus1( layerSet, uiCode );
     849      }
     850
     851      parsePTL ( pcVPS->getPTL( layerSet ), pcVPS->getVpsProfilePresentFlag( layerSet ), pcVPS->getMaxTLayers()-1);
     852      if( pcVPS->getVpsProfilePresentFlag( layerSet ) == false )
     853      {
     854        TComPTL temp = *pcVPS->getPTL( layerSet );
     855        *pcVPS->getPTL( layerSet ) = *pcVPS->getPTL( pcVPS->getProfileLayerSetRefMinus1( layerSet ) + 1 );
     856        pcVPS->getPTL( layerSet )->copyLevelFrom( &temp );
     857      }
     858    }
     859
     860    READ_UVLC( uiCode, "num_output_layer_sets" );                  pcVPS->setNumOutputLayerSets( uiCode );
     861   
     862    for( Int layerSet = 0; layerSet < pcVPS->getNumOutputLayerSets(); layerSet++ )
     863    {
     864      READ_UVLC( uiCode, "output_layer_set_idx[i]" );              pcVPS->setOutputLayerSetIdx( layerSet, uiCode );
     865      for( Int layer = 0; layer <= pcVPS->getMaxNuhLayerId(); layer++ )
     866      {
     867        if( pcVPS->getLayerIdIncludedFlag( pcVPS->getOutputLayerSetIdx( layerSet ), layer ) == true )
     868        {
     869          READ_FLAG( uiCode, "output_layer_flag" );                 pcVPS->setOutputLayerFlag( layerSet, layer, uiCode == 1 ? true : false );
     870        }
     871      }
     872    }
     873
     874    for( Int i = 1; i <= pcVPS->getMaxLayers() - 1; i++ )
     875    {
     876      for( Int j = 0; j < i; j++ )
     877      {
     878        READ_FLAG( uiCode, "direct_dependency_flag[i][j]" );             pcVPS->setDirectDependencyFlag( i, j, uiCode );
     879      }
     880    }
     881   
     882    READ_FLAG( uiCode,  "vps_extension2_flag" );
     883    if (uiCode)
     884    {
     885      while ( xMoreRbspData() )
     886      {
     887        READ_FLAG( uiCode, "vps_extension2_data_flag");
     888      }
     889    }
     890
     891    pcVPS->checkVPSExtensionSyntax();
     892
     893    pcVPS->calcIvRefLayers();
     894
     895#else
    774896    while ( xMoreRbspData() )
    775897    {
    776898      READ_FLAG( uiCode, "vps_extension_data_flag");
    777899    }
     900#endif   
    778901  }
    779902 
     
    791914  TComPPS* pps = NULL;
    792915  TComSPS* sps = NULL;
     916#if H_MV
     917  TComVPS* vps = NULL;
     918#endif
    793919
    794920  UInt firstSliceSegmentInPic;
     
    805931  //!KS: need to add error handling code here, if SPS is not available
    806932  assert(sps!=0);
     933#if H_MV
     934  vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId());
     935  assert(vps!=0);
     936  rpcSlice->setVPS(vps);
     937#endif
    807938  rpcSlice->setSPS(sps);
    808939  rpcSlice->setPPS(pps);
     
    13921523  for (Int i = 0; i < maxNumSubLayersMinus1; i++)
    13931524  {
     1525#if !H_MV
    13941526    if(profilePresentFlag)
    13951527    {
     1528#endif
    13961529      READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode);
    1397     }
     1530#if H_MV
     1531    rpcPTL->setSubLayerProfilePresentFlag( i, profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) );
     1532#else
     1533    }
     1534#endif
    13981535    READ_FLAG( uiCode, "sub_layer_level_present_flag[i]"   ); rpcPTL->setSubLayerLevelPresentFlag  (i, uiCode);
    13991536  }
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibDecoder/TDecGop.cpp

    r367 r368  
    205205  }
    206206
     207#if !H_3D
    207208  rpcPic->compressMotion();
     209#endif
    208210  Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B');
    209211  if (!pcSlice->isReferenced()) c += 32;
    210212
    211213  //-- For time output for each slice
     214#if H_MV
     215  printf("\nLayer %2d   POC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getLayerId(),
     216                                                              pcSlice->getPOC(),
     217                                                              pcSlice->getTLayer(),
     218                                                              c,
     219                                                              pcSlice->getSliceQp() );
     220#else
    212221  printf("\nPOC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(),
    213222                                                    pcSlice->getTLayer(),
    214223                                                    c,
    215224                                                    pcSlice->getSliceQp() );
     225#endif
    216226
    217227  m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
     
    224234    for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++)
    225235    {
     236#if H_MV
     237      if( pcSlice->getLayerId() != pcSlice->getRefLayerId( RefPicList(iRefList), iRefIndex ) )
     238      {
     239        printf( "V%d ", pcSlice->getRefLayerId( RefPicList(iRefList), iRefIndex ) );
     240      }
     241      else
     242      {
     243#endif
    226244      printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex));
     245#if H_MV
     246      }
     247#endif
    227248    }
    228249    printf ("] ");
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r367 r368  
    3939#include "TDecTop.h"
    4040
     41#if H_MV
     42ParameterSetManagerDecoder TDecTop::m_parameterSetManagerDecoder;
     43#endif
    4144//! \ingroup TLibDecoder
    4245//! \{
     
    5760  m_bFirstSliceInPicture    = true;
    5861  m_bFirstSliceInSequence   = true;
     62#if H_MV
     63  m_layerId = 0;
     64  m_viewId = 0;
     65#if H_3D
     66  m_isDepth = false;
     67#endif
     68#endif
    5969}
    6070
     
    8696{
    8797  // initialize ROM
     98#if !H_MV
    8899  initROM();
     100#endif
    89101  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
    90102  m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder );
     
    100112  {
    101113    TComPic* pcPic = *(iterPic++);
     114#if H_MV
     115    if( pcPic )
     116    {
     117#endif
    102118    pcPic->destroy();
    103119   
    104120    delete pcPic;
    105121    pcPic = NULL;
     122#if H_MV
     123    }
     124#endif
    106125  }
    107126 
     
    110129  m_cLoopFilter.        destroy();
    111130 
     131#if !H_MV
    112132  // destroy ROM
    113133  destroyROM();
     134#endif
    114135}
    115136
     
    177198}
    178199
     200#if H_MV
     201Void TDecTop::endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic, std::vector<Int>& targetDecLayerIdSet )
     202#else
    179203Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic)
     204#endif
    180205{
    181206  if (!m_pcPic)
     
    195220  rpcListPic          = &m_cListPic; 
    196221  m_cCuDecoder.destroy();       
     222#if H_MV
     223  TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer ); 
     224  TComSlice::markIvRefPicsAsUnused   ( m_ivPicLists, targetDecLayerIdSet, m_parameterSetManagerDecoder.getActiveVPS(), m_layerId, poc );
     225#endif
    197226  m_bFirstSliceInPicture  = true;
    198227
     
    311340}
    312341
     342#if H_MV
     343Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag )
     344{
     345  assert( nalu.m_layerId == m_layerId );
     346
     347#else
    313348Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
    314349{
     350#endif
    315351  TComPic*&   pcPic         = m_pcPic;
    316352  m_apcSlicePilot->initSlice();
     
    337373  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
    338374
     375#if H_MV
     376  m_apcSlicePilot->setLayerId( nalu.m_layerId );
     377#endif
    339378  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
    340379
     380#if H_MV 
     381  TComVPS* vps     = m_apcSlicePilot->getVPS();
     382  Int layerIdInVps = vps->getLayerIdInVps( nalu.m_layerId );
     383 
     384  setViewId(  vps->getViewId( layerIdInVps  ) );
     385  m_apcSlicePilot->setViewId( getViewId() );
     386#if H_3D
     387  setIsDepth( vps->getDepthId( layerIdInVps ) == 1 );
     388  m_apcSlicePilot->setIsDepth( getIsDepth() );
     389#endif
     390#endif
    341391    // Skip pictures due to random access
    342392    if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
     
    365415    m_prevPOC = m_apcSlicePilot->getPOC();
    366416  }
     417#if H_MV
     418  if ( newLayerFlag )
     419  {
     420    return false;
     421  }
     422#endif
    367423  // actual decoding starts here
    368424  xActivateParameterSets();
     
    384440    m_cPrediction.initTempBuff();
    385441    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
     442#if H_MV
     443    m_apcSlicePilot->createAndApplyIvReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer );
     444#endif
    386445    //  Get a new picture buffer
    387446    xGetNewPicBuffer (m_apcSlicePilot, pcPic);
     
    515574  pcPic->setTLayer(nalu.m_temporalId);
    516575
     576#if H_MV
     577  pcPic->setLayerId( nalu.m_layerId );
     578  pcPic->setViewId ( getViewId() );
     579#if H_3D
     580  pcPic->setIsDepth( getIsDepth() );
     581#endif
     582#endif
    517583  if (bNextSlice)
    518584  {
    519585    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic );
    520586    // Set reference list
     587#if H_MV   
     588    pcSlice->setRefPicList( m_cListPic, m_refPicSetInterLayer, true );   
     589#else
    521590#if FIX1071
    522591    pcSlice->setRefPicList( m_cListPic, true );
     
    525594#endif
    526595
     596#endif
    527597    // For generalized B
    528598    // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
     
    662732}
    663733
     734#if H_MV
     735Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag)
     736#else
    664737Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
     738#endif
    665739{
    666740  // Initialize entropy decoder
     
    703777    case NAL_UNIT_CODED_SLICE_RASL_N:
    704778    case NAL_UNIT_CODED_SLICE_RASL_R:
     779#if H_MV
     780      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag);
     781#else
    705782      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
     783#endif
    706784      break;
    707785    default:
     
    783861}
    784862
     863#if H_MV
     864TComPic* TDecTop::getPic( Int poc )
     865{
     866  xGetPic( m_layerId, poc );
     867  TComList<TComPic*>* listPic = getListPic();
     868  TComPic* pcPic = NULL;
     869  for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++)
     870  {
     871    if( (*it)->getPOC() == poc )
     872    {
     873      pcPic = *it ;
     874      break ;
     875    }
     876  }
     877  return pcPic;
     878}
     879
     880TComPic* TDecTop::xGetPic( Int layerId, Int poc )
     881{
     882  return m_ivPicLists->getPic( layerId, poc ) ;
     883}
     884
     885#endif
    785886//! \}
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibDecoder/TDecTop.h

    r367 r368  
    6161// ====================================================================================================================
    6262
     63#if H_MV
     64class TAppDecTop;
     65#endif
    6366/// decoder class
    6467class TDecTop
     
    7275
    7376  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
     77#if H_MV
     78  static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
     79#else
    7480  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
     81#endif
    7582  TComSlice*              m_apcSlicePilot;
    7683 
     
    98105  Bool                    m_bFirstSliceInPicture;
    99106  Bool                    m_bFirstSliceInSequence;
     107#if H_MV
     108  // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
     109  Int                     m_layerId;
     110  Int                     m_viewId;
     111  TComPicLists*           m_ivPicLists;
     112  std::vector<TComPic*>   m_refPicSetInterLayer;
     113#if H_3D
     114  Bool                    m_isDepth;
     115#endif
     116#endif
    100117
    101118public:
     
    109126
    110127  Void  init();
     128#if H_MV 
     129  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
     130#else 
    111131  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
     132#endif
    112133 
    113134  Void  deletePicBuffer();
    114135
     136#if H_MV
     137  Void endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic,  std::vector<Int>& targetDecLayerIdSet); 
     138#else
    115139  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
     140#endif
    116141 
     142#if H_MV   
     143  TComPic*                getPic                ( Int poc );
     144  TComList<TComPic*>*     getListPic            ()               { return &m_cListPic;  } 
     145  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
     146 
     147  Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
     148  Void                    setLayerId            ( Int layer)     { m_layerId = layer;   }
     149  Int                     getLayerId            ()               { return m_layerId;    }
     150  Void                    setViewId             ( Int viewId  )  { m_viewId  = viewId;  }
     151  Int                     getViewId             ()               { return m_viewId;     } 
     152#if H_3D   
     153  Void                    setIsDepth            ( Bool isDepth ) { m_isDepth = isDepth; }
     154  Bool                    getIsDepth            ()               { return m_isDepth;    }
     155#endif
     156#endif
    117157protected:
    118158  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
     
    120160
    121161  Void      xActivateParameterSets();
     162#if H_MV 
     163  TComPic*  xGetPic( Int layerId, Int poc );
     164  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag ); 
     165#else
    122166  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
     167#endif
    123168  Void      xDecodeVPS();
    124169  Void      xDecodeSPS();
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/NALwrite.cpp

    r367 r368  
    5353  bsNALUHeader.write(0,1);                    // forbidden_zero_bit
    5454  bsNALUHeader.write(nalu.m_nalUnitType, 6);  // nal_unit_type
     55#if H_MV
     56  bsNALUHeader.write(nalu.m_layerId, 6);      // layerId       
     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
     
    142146{
    143147  naluDest.m_nalUnitType = naluSrc.m_nalUnitType;
     148#if H_MV
     149  naluDest.m_layerId  = naluSrc.m_layerId;
     150#else
    144151  naluDest.m_reservedZero6Bits  = naluSrc.m_reservedZero6Bits;
     152#endif
    145153  naluDest.m_temporalId  = naluSrc.m_temporalId;
    146154  naluDest.m_Bitstream   = naluSrc.m_Bitstream;
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/NALwrite.h

    r367 r368  
    5757    NalUnitType nalUnitType,
    5858    UInt temporalID = 0,
     59#if H_MV
     60    Int layerId = 0)
     61#else
    5962    UInt reserved_zero_6bits = 0)
     63#endif
     64#if H_MV
     65  : NALUnit(nalUnitType, temporalID, layerId)
     66#else
    6067  : NALUnit(nalUnitType, temporalID, reserved_zero_6bits)
     68#endif
    6169  , m_Bitstream()
    6270  {}
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncAnalyze.cpp

    r367 r368  
    3636*/
    3737
     38#if !H_MV
    3839#include "TEncAnalyze.h"
     40#endif
    3941
    4042//! \ingroup TLibEncoder
     
    4547//////////////////////////////////////////////////////////////////////
    4648
     49#if !H_MV
    4750TEncAnalyze             m_gcAnalyzeAll;
    4851TEncAnalyze             m_gcAnalyzeI;
    4952TEncAnalyze             m_gcAnalyzeP;
    5053TEncAnalyze             m_gcAnalyzeB;
     54#endif
    5155
    5256//! \}
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncAnalyze.h

    r367 r368  
    150150};
    151151
     152#if !H_MV
    152153extern TEncAnalyze             m_gcAnalyzeAll;
    153154extern TEncAnalyze             m_gcAnalyzeI;
    154155extern TEncAnalyze             m_gcAnalyzeP;
    155156extern TEncAnalyze             m_gcAnalyzeB;
     157#endif
    156158
    157159//! \}
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r367 r368  
    549549  }
    550550
     551#if H_MV
     552  WRITE_FLAG( 1, "sps_extension_flag" );
     553
     554  WRITE_FLAG( pcSPS->getInterViewMvVertConstraintFlag() ? 1 : 0, "inter_view_mv_vert_constraint_flag" );
     555#else
    551556  WRITE_FLAG( 0, "sps_extension_flag" );
     557#endif
    552558}
    553559
     
    556562  WRITE_CODE( pcVPS->getVPSId(),                    4,        "vps_video_parameter_set_id" );
    557563  WRITE_CODE( 3,                                    2,        "vps_reserved_three_2bits" );
     564#if H_MV
     565  WRITE_CODE( pcVPS->getMaxLayers() - 1,            6,        "vps_max_layers_minus1" );
     566#else
    558567  WRITE_CODE( 0,                                    6,        "vps_reserved_zero_6bits" );
     568#endif
    559569  WRITE_CODE( pcVPS->getMaxTLayers() - 1,           3,        "vps_max_sub_layers_minus1" );
    560570  WRITE_FLAG( pcVPS->getTemporalNestingFlag(),                "vps_temporal_id_nesting_flag" );
    561571  assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
     572#if H_MV
     573  WRITE_CODE( 0xffff,                              16,        "vps_extension_offset" );
     574#else
    562575  WRITE_CODE( 0xffff,                              16,        "vps_reserved_ffff_16bits" );
     576#endif
    563577  codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 );
    564578#if SIGNAL_BITRATE_PICRATE_IN_VPS
     
    583597
    584598  assert( pcVPS->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS );
     599#if H_MV
     600  assert( pcVPS->getMaxNuhLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 );
     601  WRITE_CODE( pcVPS->getMaxNuhLayerId(), 6,                 "vps_max_nuh_layer_id" );
     602#else
    585603  assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 );
    586604  WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6,     "vps_max_nuh_reserved_zero_layer_id" );
     605#endif
    587606  pcVPS->setMaxOpSets(1);
    588607  WRITE_UVLC( pcVPS->getMaxOpSets() - 1,                    "vps_max_op_sets_minus1" );
     
    590609  {
    591610    // Operation point set
     611#if H_MV
     612    for( UInt i = 0; i <= pcVPS->getMaxNuhLayerId(); i ++ )
     613#else
    592614    for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ )
     615#endif
    593616    {
    594617      // Only applicable for version 1
     
    631654  }
    632655#endif
     656#if H_MV
     657  WRITE_FLAG( 1,                                             "vps_extension_flag" );
     658
     659  m_pcBitIf->writeAlignOne();                       
     660
     661  WRITE_FLAG( pcVPS->getAvcBaseLayerFlag() ? 1 : 0,          "avc_base_layer_flag" );
     662  WRITE_FLAG( pcVPS->getSplittingFlag() ? 1 : 0,             "splitting_flag" );
     663 
     664  for( Int type = 0; type < MAX_NUM_SCALABILITY_TYPES; type++ )
     665  {
     666    WRITE_FLAG( pcVPS->getScalabilityMask( type ) ? 1 : 0,   "scalability_mask[i]" );
     667  }
     668
     669  for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ); sIdx++ )
     670  {
     671    WRITE_CODE( pcVPS->getDimensionIdLen( sIdx ) - 1 , 3,    "dimension_id_len_minus1[j]");   
     672  }
     673
     674  WRITE_FLAG( pcVPS->getVpsNuhLayerIdPresentFlag() ? 1 : 0,  "vps_nuh_layer_id_present_flag");
     675
     676  for( Int layer = 1; layer <= pcVPS->getMaxLayers() - 1; layer++ )
     677  {
     678    if (pcVPS->getVpsNuhLayerIdPresentFlag() )
     679      WRITE_CODE( pcVPS->getLayerIdInNuh( layer ), 6,          "layer_id_in_nuh[i]");
     680    for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes() ; sIdx++ )
     681    {     
     682      WRITE_CODE( pcVPS->getDimensionId( layer, sIdx ), pcVPS->getDimensionIdLen( sIdx ), "dimension_id[i][j]");     
     683    }
     684  }
     685
     686  for( Int layerSet = 1; layerSet <= pcVPS->getMaxOpSets() - 1; layerSet++ )
     687  {
     688    WRITE_FLAG( pcVPS->getVpsProfilePresentFlag( layerSet ) ? 1 : 0, "vps_profile_present_flag[lsIdx]" );
     689    if( pcVPS->getVpsProfilePresentFlag( layerSet ) == false )
     690    {
     691      WRITE_UVLC( pcVPS->getProfileLayerSetRefMinus1( layerSet ), "profile_layer_set_ref_minus1[lsIdx]" );
     692    }
     693    codePTL( pcVPS->getPTL( layerSet ), pcVPS->getVpsProfilePresentFlag( layerSet ), pcVPS->getMaxTLayers() - 1 );
     694  }
     695
     696  WRITE_UVLC( pcVPS->getNumOutputLayerSets(),                "num_output_layer_sets" );
     697
     698  for( Int layerSet = 0; layerSet < pcVPS->getNumOutputLayerSets(); layerSet++ )
     699  {
     700    WRITE_UVLC( pcVPS->getOutputLayerSetIdx( layerSet ),      "output_layer_set_idx[i]" );
     701    for( Int layer = 0; layer <= pcVPS->getMaxNuhLayerId(); layer++ )
     702    {
     703      if( pcVPS->getLayerIdIncludedFlag( pcVPS->getOutputLayerSetIdx( layerSet ), layer ) == true )
     704      {
     705        WRITE_FLAG( pcVPS->getOutputLayerFlag( layerSet, layer ) ? 1 : 0, "output_layer_flag" );
     706      }
     707    }
     708  }
     709
     710  for( Int i = 1; i <= pcVPS->getMaxLayers() - 1; i++ )
     711  {
     712    for( Int j = 0; j < i; j++ )
     713    {
     714      WRITE_FLAG( pcVPS->getDirectDependencyFlag( i, j ),    "direct_dependency_flag[i][j]" );
     715    }
     716  }
     717  WRITE_FLAG( 0,                                             "vps_extension2_flag" );
     718#else
    633719  WRITE_FLAG( 0,                     "vps_extension_flag" );
     720#endif
    634721 
    635722  //future extensions here..
     
    10041091  for (Int i = 0; i < maxNumSubLayersMinus1; i++)
    10051092  {
     1093#if !H_MV
    10061094    if(profilePresentFlag)
    10071095    {
     1096#endif
    10081097      WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" );
    1009     }
     1098#if !H_MV
     1099    }
     1100#endif
    10101101   
    10111102    WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i),   "sub_layer_level_present_flag[i]" );
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncCfg.h

    r367 r368  
    6969  Int m_numRefIdc;
    7070  Int m_refIdc[MAX_NUM_REF_PICS+1];
     71#if H_MV
     72  Int m_numInterViewRefPics;
     73  Int m_interViewRefs    [MAX_NUM_REF_PICS];
     74  Int m_interViewRefPosL[2][MAX_NUM_REF_PICS]; 
     75#endif
    7176  GOPEntry()
    7277  : m_POC(-1)
     
    8388  , m_deltaRPS(0)
    8489  , m_numRefIdc(0)
     90#if H_MV
     91  , m_numInterViewRefPics(0)
     92#endif
    8593  {
    8694    ::memset( m_referencePics, 0, sizeof(m_referencePics) );
    8795    ::memset( m_usedByCurrPic, 0, sizeof(m_usedByCurrPic) );
    8896    ::memset( m_refIdc,        0, sizeof(m_refIdc) );
     97#if H_MV
     98    ::memset( m_interViewRefs,   0, sizeof(m_interViewRefs) );
     99    ::memset( m_interViewRefPosL[0], -1, sizeof(m_interViewRefPosL[0]) );    ::memset( m_interViewRefPosL[1], -1, sizeof(m_interViewRefPosL[1]) );
     100#endif
    89101  }
    90102};
     
    127139  UInt      m_uiDecodingRefreshType;            ///< the type of decoding refresh employed for the random access.
    128140  Int       m_iGOPSize;
     141#if H_MV
     142  GOPEntry  m_GOPList[MAX_GOP+1];
     143#else
    129144  GOPEntry  m_GOPList[MAX_GOP];
     145#endif
    130146  Int       m_extraRPSs;
    131147  Int       m_maxDecPicBuffering[MAX_TLAYER];
     
    337353  Bool      m_useStrongIntraSmoothing;                        ///< enable the use of strong intra smoothing (bi_linear interpolation) for 32x32 blocks when reference samples are flat.
    338354
     355#if H_MV
     356  Int       m_layerId;
     357  Int       m_layerIdInVps;
     358  Int       m_viewId;
     359#if H_3D
     360  Bool      m_isDepth;
     361#endif
     362#endif
    339363public:
    340364  TEncCfg()
    341365  : m_puiColumnWidth()
    342366  , m_puiRowHeight()
     367#if H_MV
     368  , m_layerId(-1)
     369  , m_layerIdInVps(-1)
     370  , m_viewId(-1)
     371#if H_3D
     372  , m_isDepth(false)
     373#endif
     374#endif
    343375  {}
    344376
     
    362394  Void      setFramesToBeEncoded            ( Int   i )      { m_framesToBeEncoded = i; }
    363395 
     396#if H_MV
     397  Void      setLayerId                       ( Int layerId )      { m_layerId = layerId; }
     398  Int       getLayerId                       ()                   { return m_layerId;    }
     399  Int       getLayerIdInVps                  ()                   { return m_layerIdInVps; }
     400  Void      setLayerIdInVps                  ( Int layerIdInVps)  { m_layerIdInVps = layerIdInVps; }
     401  Void      setViewId                        ( Int viewId  )      { m_viewId  = viewId;  }
     402  Int       getViewId                        ()                   { return m_viewId;    }
     403#if H_3D
     404  Void      setIsDepth                       ( Bool isDepth )   { m_isDepth = isDepth; }
     405  Bool      getIsDepth                       ()                 { return m_isDepth; }
     406#endif
     407#endif
    364408  //====== Coding Structure ========
    365409  Void      setIntraPeriod                  ( Int   i )      { m_uiIntraPeriod = (UInt)i; }
    366410  Void      setDecodingRefreshType          ( Int   i )      { m_uiDecodingRefreshType = (UInt)i; }
    367411  Void      setGOPSize                      ( Int   i )      { m_iGOPSize = i; }
     412#if H_MV
     413  Void      setGopList                      ( GOPEntry*  GOPList ) {  for ( Int i = 0; i < MAX_GOP+1; i++ ) m_GOPList[i] = GOPList[i]; }
     414#else
    368415  Void      setGopList                      ( GOPEntry*  GOPList ) {  for ( Int i = 0; i < MAX_GOP; i++ ) m_GOPList[i] = GOPList[i]; }
     416#endif
    369417  Void      setExtraRPSs                    ( Int   i )      { m_extraRPSs = i; }
    370418  GOPEntry  getGOPEntry                     ( Int   i )      { return m_GOPList[i]; }
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r367 r368  
    100100#endif
    101101#endif
     102#if H_MV
     103  m_layerId      = 0;
     104  m_viewId       = 0;
     105  m_pocLastCoded = -1;
     106#if H_3D
     107  m_isDepth = false;
     108#endif
     109#endif
    102110  return;
    103111}
     
    139147  m_totalCoded         = 0;
    140148
     149#if H_MV
     150  m_ivPicLists           = pcTEncTop->getIvPicLists();
     151  m_layerId              = pcTEncTop->getLayerId();
     152  m_viewId               = pcTEncTop->getViewId();
     153#if H_3D
     154  m_isDepth              = pcTEncTop->getIsDepth();
     155#endif
     156#endif
    141157}
    142158
     
    342358// Public member functions
    343359// ====================================================================================================================
     360#if H_MV
     361Void TEncGOP::initGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP)
     362{
     363  xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut );
     364  m_iNumPicCoded = 0;
     365}
     366#endif
     367#if H_MV
     368Void TEncGOP::compressPicInGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid)
     369#else
    344370Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP)
     371#endif
    345372{
    346373  TComPic*        pcPic;
     
    354381  TComOutputBitstream* pcSubstreamsOut = NULL;
    355382
     383#if !H_MV
    356384  xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut );
    357385 
    358386  m_iNumPicCoded = 0;
     387#endif
    359388  SEIPictureTiming pictureTimingSEI;
    360389#if L0208_SOP_DESCRIPTION_SEI
     
    379408  UInt *accumNalsDU = NULL;
    380409  SEIDecodingUnitInfo decodingUnitInfoSEI;
     410#if !H_MV
    381411  for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
     412#endif
    382413  {
    383414    UInt uiColDir = 1;
     
    438469    if(pocCurr>=m_pcCfg->getFramesToBeEncoded())
    439470    {
     471#if H_MV
     472      delete pcBitstreamRedirect;
     473      return;
     474#else
    440475      continue;
     476#endif
    441477    }
    442478
     
    459495    pcSlice->setLastIDR(m_iLastIDR);
    460496    pcSlice->setSliceIdx(0);
     497#if H_MV
     498    pcPic  ->setLayerId     ( getLayerId() );
     499    pcPic  ->setViewId      ( getViewId()  );
     500    pcSlice->setLayerId     ( getLayerId() );
     501    pcSlice->setViewId      ( getViewId()  );
     502    pcSlice->setVPS         ( m_pcEncTop->getVPS() );
     503#if H_3D
     504    pcPic  ->setIsDepth( getIsDepth() );
     505    pcSlice->setIsDepth( getIsDepth() );
     506#endif
     507#endif
    461508    //set default slice level flag to the same as SPS level flag
    462509    pcSlice->setLFCrossSliceBoundaryFlag(  pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()  );
     
    496543    }
    497544
    498     if(pcSlice->getSliceType()==B_SLICE&&m_pcCfg->getGOPEntry(iGOPid).m_sliceType=='P')
    499     {
    500       pcSlice->setSliceType(P_SLICE);
    501     }
     545#if H_MV
    502546    // Set the nal unit type
    503547    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
     548    if( pcSlice->getSliceType() == B_SLICE )
     549    {
     550      if( m_pcCfg->getGOPEntry( ( pcSlice->getRapPicFlag() && getLayerId() > 0 ) ? MAX_GOP : iGOPid ).m_sliceType == 'P' )
     551      {
     552        pcSlice->setSliceType( P_SLICE );
     553      }
     554    }
     555#else
     556    if(pcSlice->getSliceType()==B_SLICE&&m_pcCfg->getGOPEntry(iGOPid).m_sliceType=='P')
     557    {
     558      pcSlice->setSliceType(P_SLICE);
     559    }
     560    // Set the nal unit type
     561    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
     562#endif
    504563    if(pcSlice->getTemporalLayerNonReferenceFlag())
    505564    {
     
    589648    refPicListModification->setRefPicListModificationFlagL0(0);
    590649    refPicListModification->setRefPicListModificationFlagL1(0);
     650#if H_MV
     651    pcSlice->createAndApplyIvReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer );
     652    pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid ).m_numRefPicsActive,( pcSlice->getRPS()->getNumberOfPictures() + (Int) m_refPicSetInterLayer.size() ) ) );
     653    pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid ).m_numRefPicsActive,( pcSlice->getRPS()->getNumberOfPictures() + (Int) m_refPicSetInterLayer.size() ) ) );
     654    xSetRefPicListModificationsMvc( pcSlice, pocCurr, iGOPid );   
     655#else
    591656    pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures()));
    592657    pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures()));
     658#endif
    593659
    594660#if ADAPTIVE_QP_SELECTION
     
    597663
    598664    //  Set reference list
     665#if H_MV   
     666    pcSlice->setRefPicList( rcListPic, m_refPicSetInterLayer );
     667#else
    599668    pcSlice->setRefPicList ( rcListPic );
     669#endif
    600670
    601671    //  Slice info. refinement
     672#if H_MV
     673    if ( pcSlice->getSliceType() == B_SLICE )
     674    {
     675      if( m_pcCfg->getGOPEntry( ( pcSlice->getRapPicFlag() == true && getLayerId() > 0 ) ? MAX_GOP : iGOPid ).m_sliceType == 'P' )
     676      {
     677        pcSlice->setSliceType( P_SLICE );
     678      }
     679    }
     680#else
    602681    if ( (pcSlice->getSliceType() == B_SLICE) && (pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) )
    603682    {
    604683      pcSlice->setSliceType ( P_SLICE );
    605684    }
     685#endif
    606686#if !L0034_COMBINED_LIST_CLEANUP
    607687    if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb())
     
    10201100    {
    10211101      OutputNALUnit nalu(NAL_UNIT_VPS);
     1102#if H_MV
     1103      if( getLayerId() == 0 )
     1104      {
     1105#endif
    10221106      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    10231107      m_pcEntropyCoder->encodeVPS(m_pcEncTop->getVPS());
     
    10281112#endif
    10291113
     1114#if H_MV
     1115      }
     1116      nalu = NALUnit(NAL_UNIT_SPS, 0, getLayerId());
     1117#else
    10301118      nalu = NALUnit(NAL_UNIT_SPS);
     1119#endif
    10311120      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    10321121      if (m_bSeqFirst)
     
    10611150#endif
    10621151
     1152#if H_MV
     1153      nalu = NALUnit(NAL_UNIT_PPS, 0, getLayerId());
     1154#else
    10631155      nalu = NALUnit(NAL_UNIT_PPS);
     1156#endif
    10641157      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    10651158      m_pcEntropyCoder->encodePPS(pcSlice->getPPS());
     
    13831476          m_pcEntropyCoder->resetEntropy      ();
    13841477          /* start slice NALunit */
     1478#if H_MV
     1479          OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->getTLayer(), getLayerId() );
     1480#else
    13851481          OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->getTLayer() );
     1482#endif
    13861483          Bool sliceSegment = (!pcSlice->isNextSlice());
    13871484          if (!sliceSegment)
     
    16101707      }
    16111708
     1709#if !H_3D
    16121710      pcPic->compressMotion();
     1711#endif
     1712#if H_MV
     1713      m_pocLastCoded = pcPic->getPOC();
     1714#endif
    16131715      //-- For time output for each slice
    16141716      Double dEncTime = (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
     
    19212023
    19222024      pcPic->setReconMark   ( true );
     2025#if H_MV
     2026      TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer ); 
     2027      std::vector<Int> temp;
     2028      TComSlice::markIvRefPicsAsUnused   ( m_ivPicLists, temp, pcPic->getSlice(0)->getVPS(), m_layerId, pcPic->getPOC() );
     2029#endif
    19232030      m_bFirst = false;
    19242031      m_iNumPicCoded++;
     
    19412048  if( accumNalsDU != NULL) delete accumNalsDU;
    19422049
     2050#if !H_MV
    19432051  assert ( m_iNumPicCoded == iNumPicRcvd );
     2052#endif
    19442053}
    19452054
     2055#if !H_MV
    19462056Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded)
    19472057{
     
    19792089  printf("\nRVM: %.3lf\n" , xCalculateRVM());
    19802090}
     2091#endif
    19812092
    19822093Void TEncGOP::preLoopFilterPicAll( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits )
     
    22542365
    22552366  //===== add PSNR =====
     2367#if H_MV
     2368  m_pcEncTop->getAnalyzeAll()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2369#else
    22562370  m_gcAnalyzeAll.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2371#endif
    22572372  TComSlice*  pcSlice = pcPic->getSlice(0);
    22582373  if (pcSlice->isIntra())
    22592374  {
     2375#if H_MV
     2376    m_pcEncTop->getAnalyzeI()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2377#else
    22602378    m_gcAnalyzeI.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2379#endif
    22612380  }
    22622381  if (pcSlice->isInterP())
    22632382  {
     2383#if H_MV
     2384    m_pcEncTop->getAnalyzeP()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2385#else
    22642386    m_gcAnalyzeP.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2387#endif
    22652388  }
    22662389  if (pcSlice->isInterB())
    22672390  {
     2391#if H_MV
     2392    m_pcEncTop->getAnalyzeB()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2393#else
    22682394    m_gcAnalyzeB.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     2395#endif
    22692396  }
    22702397
     
    22732400
    22742401#if ADAPTIVE_QP_SELECTION
     2402#if H_MV
     2403  printf("Layer %3d   POC %4d TId: %1d ( %c-SLICE, nQP %d QP %d ) %10d bits",
     2404    pcSlice->getLayerId(),
     2405    pcSlice->getPOC(),
     2406    pcSlice->getTLayer(),
     2407    c,
     2408    pcSlice->getSliceQpBase(),
     2409    pcSlice->getSliceQp(),
     2410    uibits );
     2411#else
    22752412  printf("POC %4d TId: %1d ( %c-SLICE, nQP %d QP %d ) %10d bits",
    22762413         pcSlice->getPOC(),
     
    22802417         pcSlice->getSliceQp(),
    22812418         uibits );
     2419#endif
     2420#else
     2421#if H_MV
     2422  printf("Layer %3d   POC %4d TId: %1d ( %c-SLICE, QP %d ) %10d bits",
     2423    pcSlice->getLayerId(),
     2424    pcSlice->getPOC()-pcSlice->getLastIDR(),
     2425    pcSlice->getTLayer(),
     2426    c,
     2427    pcSlice->getSliceQp(),
     2428    uibits );
    22822429#else
    22832430  printf("POC %4d TId: %1d ( %c-SLICE, QP %d ) %10d bits",
     
    22872434         pcSlice->getSliceQp(),
    22882435         uibits );
     2436#endif
    22892437
    22902438#endif
     
    22972445    for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++)
    22982446    {
     2447#if H_MV
     2448      if( pcSlice->getLayerId() != pcSlice->getRefLayerId( RefPicList(iRefList), iRefIndex ) )
     2449      {
     2450        printf( "V%d ", pcSlice->getRefLayerId( RefPicList(iRefList), iRefIndex ) );
     2451      }
     2452      else
     2453      {
     2454#endif
    22992455      printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR());
     2456#if H_MV
     2457      }
     2458#endif
    23002459    }
    23012460    printf("]");
     
    26632822}
    26642823#endif
     2824#if H_MV
     2825Void TEncGOP::xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt uiPOCCurr, UInt iGOPid )
     2826{
     2827  TComVPS* vps = pcSlice->getVPS();
     2828  Int layer    = pcSlice->getLayerIdInVps( );
     2829 
     2830  if( pcSlice->getSliceType() == I_SLICE || !(pcSlice->getPPS()->getListsModificationPresentFlag()) || vps->getNumDirectRefLayers( layer ) == 0 )
     2831  {
     2832    return;
     2833  }
     2834
     2835  // analyze inter-view modifications
     2836  GOPEntry ge = m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && ( layer > 0) ) ? MAX_GOP : iGOPid );
     2837
     2838  TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
     2839 
     2840  Int maxRefListSize  = pcSlice->getNumRpsCurrTempList();
     2841  Int numTemporalRefs = maxRefListSize - vps->getNumDirectRefLayers( layer );
     2842
     2843
     2844  for (Int li = 0; li < 2; li ++) // Loop over lists L0 and L1
     2845  {
     2846    Int numModifications = 0;
     2847   
     2848    for( Int k = 0; k < ge.m_numInterViewRefPics; k++ )
     2849    {
     2850      numModifications +=  ( ge.m_interViewRefPosL[li][k] >= 0 ) ? 1 : 0;
     2851    }
     2852
     2853    // set inter-view modifications
     2854    if( (maxRefListSize > 1) && (numModifications > 0) )
     2855    {
     2856      refPicListModification->setRefPicListModificationFlagL( li, true );
     2857      Int tempList[16];
     2858      for( Int k = 0; k < 16; k++ ) { tempList[k] = -1; }
     2859
     2860      Bool isModified = false;
     2861      for( Int k = 0; k < ge.m_numInterViewRefPics; k++ )
     2862      {
     2863        if( ge.m_interViewRefPosL[li][k] >= 0 )
     2864        {
     2865          Int orgIdx    = numTemporalRefs;
     2866          Int targetIdx = ge.m_interViewRefPosL[ li ][ k ];
     2867          for( Int idx = 0; idx < vps->getNumDirectRefLayers( layer ); idx++ )
     2868          {           
     2869            Int refLayer  = vps->getLayerIdInVps( vps->getRefLayerId( layer, idx ) );         
     2870            if( ( layer + ge.m_interViewRefs[ k ]) == refLayer )
     2871            {
     2872              tempList[ targetIdx ] = orgIdx;             
     2873              isModified = ( targetIdx != orgIdx  );
     2874            }
     2875            orgIdx++;
     2876          }
     2877        }
     2878      }
     2879      if( isModified )
     2880      {
     2881        Int temporalRefIdx = 0;
     2882        for( Int i = 0; i < pcSlice->getNumRefIdx( ( li == 0 ) ? REF_PIC_LIST_0 : REF_PIC_LIST_1 ); i++ )
     2883        {
     2884          if( tempList[i] >= 0 )
     2885          {
     2886            refPicListModification->setRefPicSetIdxL( li, i, tempList[i] );
     2887          }
     2888          else
     2889          {
     2890            refPicListModification->setRefPicSetIdxL( li, i, temporalRefIdx );
     2891            temporalRefIdx++;
     2892          }
     2893        }
     2894      }
     2895      else
     2896      {
     2897        refPicListModification->setRefPicListModificationFlagL( li, false );
     2898      }
     2899    }
     2900  }
     2901}
     2902#endif
    26652903//! \}
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncGOP.h

    r367 r368  
    9797  SEIWriter               m_seiWriter;
    9898 
     99#if H_MV
     100  TComPicLists*           m_ivPicLists;
     101  std::vector<TComPic*>   m_refPicSetInterLayer;
     102
     103  Int                     m_pocLastCoded;
     104  Int                     m_layerId; 
     105  Int                     m_viewId;
     106#if H_3D
     107  Bool                    m_isDepth;
     108#endif
     109#endif
    99110  //--Adaptive Loop filter
    100111  TEncSampleAdaptiveOffset*  m_pcSAO;
     
    133144 
    134145  Void  init        ( TEncTop* pcTEncTop );
     146#if H_MV
     147  Void  initGOP     ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP);
     148  Void  compressPicInGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid );
     149#else
    135150  Void  compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );
     151#endif
    136152  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect);
    137153
     154#if H_MV
     155  Int       getPocLastCoded  ()                 { return m_pocLastCoded; } 
     156  Int       getLayerId       ()                 { return m_layerId;    } 
     157  Int       getViewId        ()                 { return m_viewId;    }
     158#if H_3D
     159  Bool      getIsDepth       ()                 { return m_isDepth; }
     160#endif
     161#endif
    138162
    139163  Int   getGOPSize()          { return  m_iGopSize;  }
     
    141165  TComList<TComPic*>*   getListPic()      { return m_pcListPic; }
    142166 
     167#if !H_MV
    143168  Void  printOutSummary      ( UInt uiNumAllPicCoded );
     169#endif
    144170  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits );
    145171 
     
    185211#endif
    186212#endif
     213#if H_MV
     214   Void  xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt uiPOCCurr, UInt iGOPid );
     215#endif
    187216#if L0386_DB_METRIC
    188217  Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp

    r367 r368  
    219219 
    220220  // slice type
     221#if H_MV
     222  SliceType eSliceTypeBaseView;
     223  if( pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0 )
     224  {
     225    eSliceTypeBaseView = I_SLICE;
     226  }
     227  else
     228  {
     229    eSliceTypeBaseView = B_SLICE;
     230  }
     231  SliceType eSliceType = eSliceTypeBaseView;
     232  if( eSliceTypeBaseView == I_SLICE && m_pcCfg->getGOPEntry(MAX_GOP).m_POC == 0 && m_pcCfg->getGOPEntry(MAX_GOP).m_sliceType != 'I' )
     233  {
     234    eSliceType = B_SLICE;
     235  }
     236#else
    221237  SliceType eSliceType;
    222238 
     
    225241 
    226242  rpcSlice->setSliceType    ( eSliceType );
     243#endif
    227244
    228245  // ------------------------------------------------------------------------------------------------------------------
     
    253270    if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless())))
    254271    {
     272#if H_MV
     273      dQP += m_pcCfg->getGOPEntry( (eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid ).m_QPOffset;
     274#else
    255275      dQP += m_pcCfg->getGOPEntry(iGOPid).m_QPOffset;
     276#endif
    256277    }
    257278  }
     
    296317#endif
    297318    // Case #1: I or P-slices (key-frame)
     319#if H_MV
     320    Double dQPFactor;
     321    if( eSliceType != I_SLICE )
     322    {
     323      dQPFactor = m_pcCfg->getGOPEntry( (eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid ).m_QPFactor;
     324    }
     325    else
     326#else
    298327    Double dQPFactor = m_pcCfg->getGOPEntry(iGOPid).m_QPFactor;
    299328    if ( eSliceType==I_SLICE )
     329#endif
    300330    {
    301331      dQPFactor=0.57*dLambda_scale;
     
    332362  if( rpcSlice->getSliceType( ) != I_SLICE )
    333363  {
     364#if H_MV
     365    dLambda *= m_pcCfg->getLambdaModifier( m_pcCfg->getGOPEntry((eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid).m_temporalId );
     366#else
    334367    dLambda *= m_pcCfg->getLambdaModifier( m_pcCfg->getGOPEntry(iGOPid).m_temporalId );
     368#endif
    335369  }
    336370
     
    371405#if HB_LAMBDA_FOR_LDC
    372406  // restore original slice type
     407#if H_MV
     408  eSliceType = eSliceTypeBaseView;
     409  if( eSliceTypeBaseView == I_SLICE && m_pcCfg->getGOPEntry(MAX_GOP).m_POC == 0 && m_pcCfg->getGOPEntry(MAX_GOP).m_sliceType != 'I' )
     410  {
     411    eSliceType = B_SLICE;
     412  }
     413#else
    373414  eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     415#endif
    374416
    375417  rpcSlice->setSliceType        ( eSliceType );
     
    389431  rpcSlice->setSliceQpDeltaCb   ( 0 );
    390432  rpcSlice->setSliceQpDeltaCr   ( 0 );
     433#if H_MV
     434  rpcSlice->setNumRefIdx(REF_PIC_LIST_0,m_pcCfg->getGOPEntry( (eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid ).m_numRefPicsActive);
     435  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry( (eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid ).m_numRefPicsActive);
     436#else
    391437  rpcSlice->setNumRefIdx(REF_PIC_LIST_0,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    392438  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
     439#endif
    393440
    394441#if L0386_DB_METRIC
     
    411458      if ( !m_pcCfg->getLoopFilterOffsetInPPS() && eSliceType!=I_SLICE)
    412459      {
     460#if H_MV
     461        rpcSlice->getPPS()->setDeblockingFilterBetaOffsetDiv2( m_pcCfg->getGOPEntry((eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid).m_betaOffsetDiv2 + m_pcCfg->getLoopFilterBetaOffset() );
     462        rpcSlice->getPPS()->setDeblockingFilterTcOffsetDiv2( m_pcCfg->getGOPEntry((eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid).m_tcOffsetDiv2 + m_pcCfg->getLoopFilterTcOffset() );
     463        rpcSlice->setDeblockingFilterBetaOffsetDiv2( m_pcCfg->getGOPEntry((eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid).m_betaOffsetDiv2 + m_pcCfg->getLoopFilterBetaOffset()  );
     464        rpcSlice->setDeblockingFilterTcOffsetDiv2( m_pcCfg->getGOPEntry((eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid).m_tcOffsetDiv2 + m_pcCfg->getLoopFilterTcOffset() );
     465#else
    413466        rpcSlice->getPPS()->setDeblockingFilterBetaOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_betaOffsetDiv2 + m_pcCfg->getLoopFilterBetaOffset() );
    414467        rpcSlice->getPPS()->setDeblockingFilterTcOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_tcOffsetDiv2 + m_pcCfg->getLoopFilterTcOffset() );
    415468        rpcSlice->setDeblockingFilterBetaOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_betaOffsetDiv2 + m_pcCfg->getLoopFilterBetaOffset()  );
    416469        rpcSlice->setDeblockingFilterTcOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_tcOffsetDiv2 + m_pcCfg->getLoopFilterTcOffset() );
     470#endif
    417471      }
    418472      else
     
    435489  rpcSlice->setDepth            ( depth );
    436490 
     491#if H_MV
     492  pcPic->setTLayer( m_pcCfg->getGOPEntry( (eSliceTypeBaseView == I_SLICE) ? MAX_GOP : iGOPid ).m_temporalId );
     493#else
    437494  pcPic->setTLayer( m_pcCfg->getGOPEntry(iGOPid).m_temporalId );
     495#endif
    438496  if(eSliceType==I_SLICE)
    439497  {
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r367 r368  
    4242#include "TLibCommon/ContextModel.h"
    4343#endif
     44#if H_MV
     45#include "../../App/TAppEncoder/TAppEncTop.h"
     46#endif
    4447
    4548//! \ingroup TLibEncoder
     
    7881  m_pcBitCounters          = NULL;
    7982  m_pcRdCosts              = NULL;
     83#if H_MV
     84  m_ivPicLists = NULL;
     85#endif
    8086}
    8187
     
    8995Void TEncTop::create ()
    9096{
     97#if !H_MV
    9198  // initialize global variables
    9299  initROM();
     100#endif
    93101 
    94102  // create processing unit classes
     
    268276  delete[] m_pcRdCosts;
    269277 
     278#if !H_MV
    270279    // destroy ROM
    271280  destroyROM();
     281#endif
    272282
    273283  return;
     
    319329// ====================================================================================================================
    320330
     331#if H_MV
     332Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg )
     333{
     334  TComPic* pcPicCurr = NULL;
     335
     336  // get original YUV
     337  xGetNewPicBuffer( pcPicCurr );
     338  pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() );
     339
     340  // compute image characteristics
     341  if ( getUseAdaptiveQP() )
     342  {
     343    m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) );
     344  }
     345}
     346#endif
    321347Void TEncTop::deletePicBuffer()
    322348{
     
    345371 \retval  iNumEncoded         number of encoded pictures
    346372 */
     373#if H_MV
     374Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded , Int gopId )
     375{
     376#else
    347377Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded )
    348378{
     379#endif
     380#if H_3D
     381  TComPic* picLastCoded = getPic( getGOPEncoder()->getPocLastCoded() );
     382  if( picLastCoded )
     383  {
     384    picLastCoded->compressMotion();
     385  }
     386#endif
     387#if H_MV
     388  if( gopId == 0)
     389  {
     390    m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 
     391#else
    349392  if (pcPicYuvOrg) {
    350393    // get original YUV
     
    365408    return;
    366409  }
     410#endif
    367411 
    368412#if RATE_CONTROL_LAMBDA_DOMAIN
     
    373417#endif
    374418
     419#if H_MV
     420  }
     421  m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId );
     422
     423  if( gopId + 1 == m_cGOPEncoder.getGOPSize() )
     424  {
     425#else
    375426  // compress GOP
    376427  m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut);
     428#endif
    377429
    378430#if RATE_CONTROL_LAMBDA_DOMAIN
     
    386438  m_iNumPicRcvd       = 0;
    387439  m_uiNumAllPicCoded += iNumEncoded;
     440#if H_MV
     441}
     442#endif
    388443}
    389444
     
    450505Void TEncTop::xInitSPS()
    451506{
     507#if H_MV
     508  m_cSPS.setSPSId( getLayerIdInVps() );
     509#endif
    452510  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
    453511  profileTierLevel.setLevelIdc(m_level);
     
    594652Void TEncTop::xInitPPS()
    595653{
     654#if H_MV
     655  if( m_cVPS.getNumDirectRefLayers( getLayerIdInVps() ) > 0 )
     656  {
     657    m_cPPS.setListsModificationPresentFlag( true );
     658  }
     659  m_cPPS.setPPSId( getLayerIdInVps() );
     660  m_cPPS.setSPSId( getLayerIdInVps() );
     661#endif
    596662  m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
    597663  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
     
    897963Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid )
    898964{
     965#if H_MV
     966  if( slice->getRapPicFlag() == true && getLayerId() > 0 && POCCurr == 0 )
     967  {
     968    TComReferencePictureSet* rps = slice->getLocalRPS();
     969    rps->setNumberOfNegativePictures(0);
     970    rps->setNumberOfPositivePictures(0);
     971    rps->setNumberOfLongtermPictures(0);
     972    rps->setNumberOfPictures(0);
     973    slice->setRPS(rps);
     974  }
     975  else
     976  {
     977#endif
    899978  slice->setRPSidx(GOPid);
    900979
     
    9241003  slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx()));
    9251004  slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures());
     1005#if H_MV
     1006  }
     1007#endif
    9261008
    9271009}
     
    10381120  }
    10391121}
     1122#if H_MV
     1123Void TEncTop::printSummary( Int numAllPicCoded )
     1124{
     1125  assert (numAllPicCoded == m_cAnalyzeAll.getNumPic());
     1126
     1127  //--CFG_KDY
     1128  m_cAnalyzeAll.setFrmRate( getFrameRate() );
     1129  m_cAnalyzeI.setFrmRate( getFrameRate() );
     1130  m_cAnalyzeP.setFrmRate( getFrameRate() );
     1131  m_cAnalyzeB.setFrmRate( getFrameRate() );
     1132
     1133  //-- all
     1134  printf( "\n\nSUMMARY ------------------------------------------- LayerId %2d\n", m_layerId );
     1135
     1136  m_cAnalyzeAll.printOut('a');
     1137
     1138  printf( "\n\nI Slices--------------------------------------------------------\n" );
     1139  m_cAnalyzeI.printOut('i');
     1140
     1141  printf( "\n\nP Slices--------------------------------------------------------\n" );
     1142  m_cAnalyzeP.printOut('p');
     1143
     1144  printf( "\n\nB Slices--------------------------------------------------------\n" );
     1145  m_cAnalyzeB.printOut('b');
     1146
     1147#if _SUMMARY_OUT_
     1148  m_cAnalyzeAll.printSummaryOut();
     1149#endif
     1150#if _SUMMARY_PIC_
     1151  m_cAnalyzeI.printSummary('I');
     1152  m_cAnalyzeP.printSummary('P');
     1153  m_cAnalyzeB.printSummary('B');
     1154#endif
     1155}
     1156
     1157Int TEncTop::getFrameId(Int iGOPid) 
     1158{
     1159  if(m_iPOCLast == 0)
     1160  {
     1161    return(0 );
     1162  }
     1163  else
     1164  {
     1165    return m_iPOCLast -m_iNumPicRcvd+ getGOPEntry(iGOPid).m_POC ;
     1166  }
     1167}
     1168
     1169TComPic* TEncTop::getPic( Int poc )
     1170{
     1171  TComList<TComPic*>* listPic = getListPic();
     1172  TComPic* pcPic = NULL;
     1173  for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++)
     1174  {
     1175    if( (*it)->getPOC() == poc )
     1176    {
     1177      pcPic = *it ;
     1178      break ;
     1179    }
     1180  }
     1181  return pcPic;
     1182}
     1183#endif
    10401184//! \}
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibEncoder/TEncTop.h

    r367 r368  
    7474  TComList<TComPic*>      m_cListPic;                     ///< dynamic list of pictures
    7575 
     76#if H_MV
     77  TComPicLists*           m_ivPicLists;                   ///< access to picture lists of other layers
     78#endif
    7679  // encoder search
    7780  TEncSearch              m_cSearch;                      ///< encoder search class
     
    122125  TEncRateCtrl            m_cRateCtrl;                    ///< Rate control class
    123126 
     127#if H_MV
     128  TEncAnalyze             m_cAnalyzeAll;
     129  TEncAnalyze             m_cAnalyzeI;
     130  TEncAnalyze             m_cAnalyzeP;
     131  TEncAnalyze             m_cAnalyzeB; 
     132#endif
    124133protected:
    125134  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
     
    137146  Void      destroy         ();
    138147  Void      init            ();
     148#if H_MV 
     149  TComPicLists* getIvPicLists() { return m_ivPicLists; }
     150#endif
    139151  Void      deletePicBuffer ();
    140152
    141153  Void      createWPPCoders(Int iNumSubstreams);
    142154 
     155#if H_MV
     156  Void      initNewPic(TComPicYuv* pcPicYuvOrg);
     157#endif
    143158  // -------------------------------------------------------------------------------------------------------------------
    144159  // member access functions
     
    177192#endif
    178193  TComScalingList*        getScalingList        () { return  &m_scalingList;         }
     194#if H_MV
     195  TEncAnalyze*            getAnalyzeAll         () { return &m_cAnalyzeAll; }
     196  TEncAnalyze*            getAnalyzeI           () { return &m_cAnalyzeI;   }
     197  TEncAnalyze*            getAnalyzeP           () { return &m_cAnalyzeP;   }
     198  TEncAnalyze*            getAnalyzeB           () { return &m_cAnalyzeB;   }
     199
     200  Int                     getNumAllPicCoded     () { return m_uiNumAllPicCoded; }
     201 
     202  Int                     getFrameId            (Int iGOPid);
     203 
     204  TComPic*                getPic                ( Int poc );
     205  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
     206#endif
    179207  // -------------------------------------------------------------------------------------------------------------------
    180208  // encoder function
     
    182210
    183211  /// encode several number of pictures until end-of-sequence
     212#if H_MV
     213  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded  , Int gopId  ); 
     214#else
    184215  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
    185216              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 
    186 
     217#endif
     218
     219#if H_MV
     220  Void printSummary      ( Int numAllPicCoded );
     221#else
    187222  void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); }
     223#endif
    188224};
    189225
Note: See TracChangeset for help on using the changeset viewer.