Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/TDecTop.cpp


Ignore:
Timestamp:
13 Aug 2015, 17:38:13 (9 years ago)
Author:
tech
Message:

Merged 14.1-update-dev1@1312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibDecoder/TDecTop.cpp

    r1196 r1313  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3838#include "NALread.h"
    3939#include "TDecTop.h"
    40 
    41 #if H_MV
    42 ParameterSetManagerDecoder TDecTop::m_parameterSetManagerDecoder;
    43 #endif
     40#if NH_MV
     41ParameterSetManager TDecTop::m_parameterSetManager;
     42#endif
     43
    4444//! \ingroup TLibDecoder
    4545//! \{
    4646
    47 #if H_3D
     47#if NH_3D
    4848CamParsCollector::CamParsCollector()
    4949: m_bInitialized( false )
     
    8181
    8282Void
    83 CamParsCollector::init( FILE* pCodedScaleOffsetFile, TComVPS* vps)
     83CamParsCollector::init( const TComVPS* vps)
    8484{
    8585  assert( !isInitialized() ); // Only one initialization currently supported
    8686  m_bInitialized            = true;
    8787  m_vps                     = vps;
    88   m_bCamParsVaryOverTime    = false;
    89   m_pCodedScaleOffsetFile   = pCodedScaleOffsetFile;
     88  m_bCamParsVaryOverTime    = false;   
    9089  m_lastPoc                 = -1;   
    9190  m_firstReceivedPoc        = -2;
     
    221220}
    222221
    223 Void
    224 CamParsCollector::setSlice( TComSlice* pcSlice )
     222Void CamParsCollector::setSlice( const TComSlice* pcSlice )
    225223{
    226224  if( pcSlice == 0 )
     
    293291
    294292
    295 #if H_3D_IV_MERGE
     293#if !NH_3D_FIX_TICKET_101
     294#if NH_3D_IV_MERGE
    296295Void
    297296CamParsCollector::copyCamParamForSlice( TComSlice* pcSlice )
     
    302301  }
    303302}
     303#endif
    304304#endif
    305305
     
    348348#endif
    349349
     350
    350351TDecTop::TDecTop()
    351 {
    352   m_pcPic = 0;
    353   m_iMaxRefPicNum = 0;
     352  : m_iMaxRefPicNum(0)
     353  , m_associatedIRAPType(NAL_UNIT_INVALID)
     354  , m_pocCRA(0)
     355  , m_pocRandomAccess(MAX_INT)
     356  , m_cListPic()
     357#if !NH_MV
     358  , m_parameterSetManager()
     359#endif
     360  , m_apcSlicePilot(NULL)
     361  , m_SEIs()
     362  , m_cPrediction()
     363  , m_cTrQuant()
     364  , m_cGopDecoder()
     365  , m_cSliceDecoder()
     366  , m_cCuDecoder()
     367  , m_cEntropyDecoder()
     368  , m_cCavlcDecoder()
     369  , m_cSbacDecoder()
     370  , m_cBinCABAC()
     371  , m_seiReader()
     372  , m_cLoopFilter()
     373  , m_cSAO()
     374  , m_pcPic(NULL)
     375  , m_prevPOC(MAX_INT)
     376  , m_prevTid0POC(0)
     377  , m_bFirstSliceInPicture(true)
     378  , m_bFirstSliceInSequence(true)
     379  , m_prevSliceSkipped(false)
     380  , m_skippedPOC(0)
     381  , m_bFirstSliceInBitstream(true)
     382  , m_lastPOCNoOutputPriorPics(-1)
     383  , m_isNoOutputPriorPics(false)
     384  , m_craNoRaslOutputFlag(false)
     385#if O0043_BEST_EFFORT_DECODING
     386  , m_forceDecodeBitDepth(8)
     387#endif
     388  , m_pDecodedSEIOutputStream(NULL)
     389  , m_warningMessageSkipPicture(false)
     390  , m_prefixSEINALUs()
     391{
    354392#if ENC_DEC_TRACE
    355 #if H_MV
     393#if NH_MV
    356394  if ( g_hTrace == NULL )
    357395  {
    358396#endif
    359   g_hTrace = fopen( "TraceDec.txt", "wb" );
     397  if (g_hTrace == NULL)
     398  {
     399    g_hTrace = fopen( "TraceDec.txt", "wb" );
     400  }
    360401  g_bJustDoIt = g_bEncDecTraceDisable;
    361402  g_nSymbolCounter = 0;
    362 #if H_MV
    363   }
    364 #endif
    365 #endif
    366   m_associatedIRAPType = NAL_UNIT_INVALID;
    367   m_pocCRA = 0;
    368   m_pocRandomAccess = MAX_INT; 
    369   m_prevPOC                = MAX_INT;
    370   m_bFirstSliceInPicture    = true;
    371   m_bFirstSliceInSequence   = true;
    372   m_prevSliceSkipped = false;
    373   m_skippedPOC = 0;
    374 #if SETTING_NO_OUT_PIC_PRIOR
    375   m_bFirstSliceInBitstream  = true;
    376   m_lastPOCNoOutputPriorPics = -1;
    377   m_craNoRaslOutputFlag = false;
    378   m_isNoOutputPriorPics = false;
    379 #endif
    380 #if H_MV
     403#if NH_MV
     404  }
     405#endif
     406#endif
     407#if NH_MV
    381408  m_isLastNALWasEos = false;
    382409  m_layerId = 0;
    383410  m_viewId = 0;
    384 #if H_3D
     411#if NH_3D
    385412  m_viewIndex = 0;
    386413  m_isDepth = false;
    387414  m_pcCamParsCollector = 0;
    388415#endif
    389 #if H_MV
    390   m_targetOptLayerSetIdx = -1;
    391 #endif
    392 #endif
     416#if NH_MV
     417  m_targetOlsIdx = -1;
     418#endif
     419#endif
     420
    393421}
    394422
     
    396424{
    397425#if ENC_DEC_TRACE
    398   fclose( g_hTrace );
    399 #endif
     426#if H_MV_ENC_DEC_TRAC_FIX
     427  if (g_hTrace != stdout && g_hTrace != NULL)
     428#else
     429  if (g_hTrace != stdout)
     430#endif
     431  {
     432    fclose( g_hTrace );
     433#if H_MV_ENC_DEC_TRAC_FIX
     434    g_hTrace = NULL;
     435#endif
     436  }
     437#endif
     438  while (!m_prefixSEINALUs.empty())
     439  {
     440    delete m_prefixSEINALUs.front();
     441    m_prefixSEINALUs.pop_front();
     442  }
    400443}
    401444
     
    410453{
    411454  m_cGopDecoder.destroy();
    412  
     455
    413456  delete m_apcSlicePilot;
    414457  m_apcSlicePilot = NULL;
    415  
     458
    416459  m_cSliceDecoder.destroy();
    417460}
     
    420463{
    421464  // initialize ROM
    422 #if !H_MV
     465#if !NH_MV
    423466  initROM();
    424467#endif
    425 #if H_3D
     468#if NH_MV
    426469  m_cCavlcDecoder.setDecTop( this );
    427470#endif
    428   m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO );
     471  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
    429472  m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder );
    430473  m_cEntropyDecoder.init(&m_cPrediction);
     
    435478  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
    436479  Int iSize = Int( m_cListPic.size() );
    437  
     480
    438481  for (Int i = 0; i < iSize; i++ )
    439482  {
    440483    TComPic* pcPic = *(iterPic++);
    441 #if H_MV
     484#if NH_MV
    442485    if( pcPic )
    443486    {
    444487#endif
    445488    pcPic->destroy();
    446    
     489
    447490    delete pcPic;
    448491    pcPic = NULL;
    449 #if H_MV
    450     }
    451 #endif
    452   }
    453  
     492#if NH_MV
     493    }
     494#endif
     495  }
     496
    454497  m_cSAO.destroy();
    455  
     498
    456499  m_cLoopFilter.        destroy();
    457  
    458 #if !H_MV
     500
     501#if !NH_MV
    459502  // destroy ROM
    460503  destroyROM();
     
    462505}
    463506
    464 Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic )
    465 {
    466   Int  numReorderPics[MAX_TLAYER];
    467   Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow();
    468   Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window();
    469 
    470 #if H_MV
    471     assert( conformanceWindow   .getScaledFlag() );
    472     assert( defaultDisplayWindow.getScaledFlag() );
    473 #endif
    474   for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++)
    475   {
    476 #if H_MV
    477     numReorderPics[temporalLayer] = ( getLayerId() == 0 ) ? pcSlice->getSPS()->getNumReorderPics(temporalLayer) : pcSlice->getVPS()->getNumReorderPics(temporalLayer);
    478 #else
    479     numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer);
    480 #endif
    481   }
    482 #if H_MV
     507Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer )
     508{
     509#if NH_MV
    483510  if ( getLayerId() == 0 )
    484511  { 
    485     m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());
     512    m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer);     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    486513  }
    487514  else
    488515  {
    489     m_iMaxRefPicNum = pcSlice->getVPS()->getMaxDecPicBuffering(pcSlice->getTLayer());
    490 #if H_MV_HLS7_GEN
     516    //GTCIC
     517    //m_iMaxRefPicNum = pcSlice->getVPS()->getMaxDecPicBuffering(pcSlice->getTLayer());   
     518#if H_MV_HLS7_GEN
    491519    TComVPS* vps         = pcSlice->getVPS();
    492520    TComDpbSize* dpbSize = vps->getDpbSize();
     
    498526  }
    499527#else
    500   m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
     528  m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer);     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    501529#endif
    502530  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
    503531  {
    504532    rpcPic = new TComPic();
    505    
    506     rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    507                      conformanceWindow, defaultDisplayWindow, numReorderPics, true);
     533
     534    rpcPic->create ( sps, pps, true);
     535
    508536    m_cListPic.pushBack( rpcPic );
    509    
     537
    510538    return;
    511539  }
    512  
     540
    513541  Bool bBufferIsAvailable = false;
    514542  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
     
    519547    {
    520548      rpcPic->setOutputMark(false);
    521 #if H_MV
     549#if NH_MV
    522550      rpcPic->setPicOutputFlag(false);
    523551#endif
     
    529557    {
    530558      rpcPic->setOutputMark(false);
    531 #if H_MV
     559#if NH_MV
    532560      rpcPic->setPicOutputFlag(false);
    533561#endif
     
    538566    }
    539567  }
    540  
     568
    541569  if ( !bBufferIsAvailable )
    542570  {
     
    547575  }
    548576  rpcPic->destroy();
    549   rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    550                    conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    551 }
    552 
    553 #if H_MV
     577  rpcPic->create ( sps, pps, true);
     578}
     579#if NH_MV
    554580Void TDecTop::endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic, std::vector<Int>& targetDecLayerIdSet )
    555581#else
     
    562588    return;
    563589  }
    564  
    565   TComPic*&   pcPic         = m_pcPic;
     590
     591  TComPic*   pcPic         = m_pcPic;
    566592
    567593  // Execute Deblock + Cleanup
     
    571597  TComSlice::sortPicList( m_cListPic ); // sorting for application output
    572598  poc                 = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
    573   rpcListPic          = &m_cListPic; 
    574   m_cCuDecoder.destroy();       
    575 #if H_MV
     599  rpcListPic          = &m_cListPic;
     600  m_cCuDecoder.destroy();
     601#if NH_MV
    576602  TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); 
    577603  TComSlice::markCurrPic( pcPic );
     
    582608}
    583609
    584 #if SETTING_NO_OUT_PIC_PRIOR
    585 Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic)
    586 {
    587   if (!rpcListPic || !m_isNoOutputPriorPics) return;
    588 
    589   TComList<TComPic*>::iterator  iterPic   = rpcListPic->begin();
    590 
    591   while (iterPic != rpcListPic->end())
    592   {
    593     TComPic*& pcPicTmp = *(iterPic++);
     610Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>* pcListPic)
     611{
     612  if (!pcListPic || !m_isNoOutputPriorPics)
     613  {
     614    return;
     615  }
     616
     617  TComList<TComPic*>::iterator  iterPic   = pcListPic->begin();
     618
     619  while (iterPic != pcListPic->end())
     620  {
     621    TComPic* pcPicTmp = *(iterPic++);
    594622    if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC())
    595623    {
    596624      pcPicTmp->setOutputMark(false);
    597 #if H_MV
     625#if NH_MV
    598626      pcPicTmp->setPicOutputFlag(false);
    599627#endif
     
    601629  }
    602630}
    603 #endif
    604 
    605 Void TDecTop::xCreateLostPicture(Int iLostPoc)
     631
     632Void TDecTop::xCreateLostPicture(Int iLostPoc)
    606633{
    607634  printf("\ninserting lost poc : %d\n",iLostPoc);
    608   TComSlice cFillSlice;
    609   cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
    610   cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
    611   cFillSlice.initSlice();
    612635  TComPic *cFillPic;
    613   xGetNewPicBuffer(&cFillSlice,cFillPic);
    614   cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
    615   cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
     636  xGetNewPicBuffer(*(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), cFillPic, 0);
    616637  cFillPic->getSlice(0)->initSlice();
    617  
     638
    618639  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
    619640  Int closestPoc = 1000000;
     
    638659  }
    639660  cFillPic->setCurrSliceIdx(0);
    640   for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++)
    641   {
    642     cFillPic->getCU(i)->initCU(cFillPic,i);
     661  for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++)
     662  {
     663    cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr);
    643664  }
    644665  cFillPic->getSlice(0)->setReferenced(true);
    645666  cFillPic->getSlice(0)->setPOC(iLostPoc);
     667  xUpdatePreviousTid0POC(cFillPic->getSlice(0));
    646668  cFillPic->setReconMark(true);
    647669  cFillPic->setOutputMark(true);
     
    655677Void TDecTop::xActivateParameterSets()
    656678{
    657   m_parameterSetManagerDecoder.applyPrefetchedPS();
    658  
    659   TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId());
    660   assert (pps != 0);
    661 
    662   TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId());
    663   assert (sps != 0);
    664 
    665 #if H_MV
    666   TComVPS* vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
    667   assert (vps != 0);
    668   if (!m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP(), m_layerId ) )
    669 #else
    670   if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
    671 #endif
    672   {
    673     printf ("Parameter set activation failed!");
    674     assert (0);
    675   }
    676 
    677 #if H_MV
    678   sps->inferSpsMaxDecPicBufferingMinus1( vps, m_targetOptLayerSetIdx, getLayerId(), false );
     679  if (m_bFirstSliceInPicture)
     680  {
     681    const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); // this is a temporary PPS object. Do not store this value
     682    assert (pps != 0);
     683
     684    const TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId());             // this is a temporary SPS object. Do not store this value
     685    assert (sps != 0);
     686
     687    m_parameterSetManager.clearSPSChangedFlag(sps->getSPSId());
     688    m_parameterSetManager.clearPPSChangedFlag(pps->getPPSId());
     689#if NH_MV
     690    const TComVPS* vps = m_parameterSetManager.getVPS(sps->getVPSId());
     691    assert (vps != 0);
     692    if (!m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP(), m_layerId ) )
     693#else
     694    if (false == m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
     695#endif
     696    {
     697      printf ("Parameter set activation failed!");
     698      assert (0);
     699    }
     700
     701#if NH_MV
    679702  // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0
    680703  if ( vps->getVpsNumRepFormatsMinus1() == 0 )
     
    684707  }
    685708  sps->checkRpsMaxNumPics( vps, getLayerId() );
    686 
    687   if( sps->getLayerId() != 0 )
    688   {
    689     sps->inferSpsMaxSubLayersMinus1( true, vps );
    690   }
    691709
    692710  // It is a requirement of bitstream conformance that, when the SPS is referred to by
     
    698716    assert( sps->getMultiLayerExtSpsFlag() == 0 );
    699717  }
    700 
    701   if( sps->getMultiLayerExtSpsFlag() )
    702   {
    703     sps->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? vps->getTemporalNestingFlag() : true );
    704   }
    705 #endif
    706 
    707   if( pps->getDependentSliceSegmentsEnabledFlag() )
    708   {
    709     Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1;
    710 
    711     if (m_cSliceDecoder.getCtxMemSize() != NumCtx)
    712     {
    713       m_cSliceDecoder.initCtxMem(NumCtx);
    714       for ( UInt st = 0; st < NumCtx; st++ )
    715       {
    716         TDecSbac* ctx = NULL;
    717         ctx = new TDecSbac;
    718         ctx->init( &m_cBinCABAC );
    719         m_cSliceDecoder.setCtxMem( ctx, st );
    720       }
    721     }
    722   }
    723 
    724   m_apcSlicePilot->setPPS(pps);
    725   m_apcSlicePilot->setSPS(sps);
    726 #if H_MV
    727   m_apcSlicePilot->setVPS(vps); 
    728   // The nuh_layer_id value of the NAL unit containing the PPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
    729   assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, pps->getLayerId() ) );   
    730   // The nuh_layer_id value of the NAL unit containing the SPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
    731   assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, sps->getLayerId() ) );
    732   sps->inferRepFormat  ( vps , m_layerId );
    733   sps->inferScalingList( m_parameterSetManagerDecoder.getActiveSPS( sps->getSpsScalingListRefLayerId() ) );
    734 
    735 #endif
    736   pps->setSPS(sps);
    737   pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1);
    738   pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
    739 
    740   g_bitDepthY     = sps->getBitDepthY();
    741   g_bitDepthC     = sps->getBitDepthC();
    742   g_uiMaxCUWidth  = sps->getMaxCUWidth();
    743   g_uiMaxCUHeight = sps->getMaxCUHeight();
    744   g_uiMaxCUDepth  = sps->getMaxCUDepth();
    745   g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );
    746 
    747   for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
    748   {
    749     sps->setAMPAcc( i, sps->getUseAMP() );
    750   }
    751 
    752   for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++)
    753   {
    754     sps->setAMPAcc( i, 0 );
    755   }
    756 
    757   m_cSAO.destroy();
    758   m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() );
    759   m_cLoopFilter.create( sps->getMaxCUDepth() );
    760 }
    761 
    762 #if H_MV
     718#endif
     719
     720    xParsePrefixSEImessages();
     721
     722#if RExt__HIGH_BIT_DEPTH_SUPPORT==0
     723    if (sps->getSpsRangeExtension().getExtendedPrecisionProcessingFlag() || sps->getBitDepth(CHANNEL_TYPE_LUMA)>12 || sps->getBitDepth(CHANNEL_TYPE_CHROMA)>12 )
     724    {
     725      printf("High bit depth support must be enabled at compile-time in order to decode this bitstream\n");
     726      assert (0);
     727      exit(1);
     728    }
     729#endif
     730
     731    // NOTE: globals were set up here originally. You can now use:
     732    // g_uiMaxCUDepth = sps->getMaxTotalCUDepth();
     733    // g_uiAddCUDepth = sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize()
     734
     735    //  Get a new picture buffer. This will also set up m_pcPic, and therefore give us a SPS and PPS pointer that we can use.
     736    xGetNewPicBuffer (*(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer());
     737    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
     738#if NH_MV
     739    m_apcSlicePilot->createInterLayerReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer0, m_refPicSetInterLayer1 );
     740#endif
     741
     742    // make the slice-pilot a real slice, and set up the slice-pilot for the next slice
     743    assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
     744    m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx);
     745
     746    // we now have a real slice:
     747    TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx);
     748
     749    // Update the PPS and SPS pointers with the ones of the picture.
     750    pps=pSlice->getPPS();
     751    sps=pSlice->getSPS();
     752
     753#if NH_MV
     754    vps=pSlice->getVPS(); 
     755    // The nuh_layer_id value of the NAL unit containing the PPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
     756    assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, pps->getLayerId() ) );   
     757    // The nuh_layer_id value of the NAL unit containing the SPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
     758    assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, sps->getLayerId() ) );
     759#endif
     760
     761#if NH_3D
     762    if ( !m_pcCamParsCollector->isInitialized() )
     763    {
     764      m_pcCamParsCollector->init( vps );
     765    }
     766#endif
     767    // Initialise the various objects for the new set of settings
     768    m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxTotalCUDepth(), pps->getPpsRangeExtension().getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), pps->getPpsRangeExtension().getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA) );
     769    m_cLoopFilter.create( sps->getMaxTotalCUDepth() );
     770    m_cPrediction.initTempBuff(sps->getChromaFormatIdc());
     771
     772
     773    Bool isField = false;
     774    Bool isTopField = false;
     775
     776    if(!m_SEIs.empty())
     777    {
     778      // Check if any new Picture Timing SEI has arrived
     779      SEIMessages pictureTimingSEIs = getSeisByType(m_SEIs, SEI::PICTURE_TIMING);
     780      if (pictureTimingSEIs.size()>0)
     781      {
     782        SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin());
     783        isField    = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 10) || (pictureTiming->m_picStruct == 11) || (pictureTiming->m_picStruct == 12);
     784        isTopField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 11);
     785      }
     786    }
     787
     788    //Set Field/Frame coding mode
     789    m_pcPic->setField(isField);
     790    m_pcPic->setTopField(isTopField);
     791
     792    // transfer any SEI messages that have been received to the picture
     793    m_pcPic->setSEIs(m_SEIs);
     794    m_SEIs.clear();
     795
     796    // Recursive structure
     797    m_cCuDecoder.create ( sps->getMaxTotalCUDepth(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getChromaFormatIdc() );
     798    m_cCuDecoder.init   ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction );
     799    m_cTrQuant.init     ( sps->getMaxTrSize() );
     800
     801    m_cSliceDecoder.create();
     802  }
     803  else
     804  {
     805    // make the slice-pilot a real slice, and set up the slice-pilot for the next slice
     806    m_pcPic->allocateNewSlice();
     807    assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
     808    m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx);
     809
     810    TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); // we now have a real slice.
     811
     812    const TComSPS *sps = pSlice->getSPS();
     813    const TComPPS *pps = pSlice->getPPS();
     814
     815    // check that the current active PPS has not changed...
     816    if (m_parameterSetManager.getSPSChangedFlag(sps->getSPSId()) )
     817    {
     818      printf("Error - a new SPS has been decoded while processing a picture\n");
     819      exit(1);
     820    }
     821    if (m_parameterSetManager.getPPSChangedFlag(pps->getPPSId()) )
     822    {
     823      printf("Error - a new PPS has been decoded while processing a picture\n");
     824      exit(1);
     825    }
     826
     827    xParsePrefixSEImessages();
     828
     829    // Check if any new SEI has arrived
     830     if(!m_SEIs.empty())
     831     {
     832       // Currently only decoding Unit SEI message occurring between VCL NALUs copied
     833       SEIMessages &picSEI = m_pcPic->getSEIs();
     834       SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
     835       picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
     836       deleteSEIs(m_SEIs);
     837     }
     838  }
     839}
     840Void TDecTop::xParsePrefixSEIsForUnknownVCLNal()
     841{
     842  while (!m_prefixSEINALUs.empty())
     843  {
     844    // do nothing?
     845    printf("Discarding Prefix SEI associated with unknown VCL NAL unit.\n");
     846    delete m_prefixSEINALUs.front();
     847  }
     848  // TODO: discard following suffix SEIs as well?
     849}
     850
     851
     852Void TDecTop::xParsePrefixSEImessages()
     853{
     854  while (!m_prefixSEINALUs.empty())
     855  {
     856    InputNALUnit &nalu=*m_prefixSEINALUs.front();
     857#if NH_MV
     858    m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS( getLayerId() ), m_pDecodedSEIOutputStream );
     859#else
     860    m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream );
     861#endif
     862    delete m_prefixSEINALUs.front();
     863    m_prefixSEINALUs.pop_front();
     864  }
     865}
     866
     867
     868#if NH_MV
    763869Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag  )
    764870{
    765   assert( nalu.m_layerId == m_layerId );
     871  assert( nalu.m_nuhLayerId == m_layerId );
    766872#else
    767873Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
    768874{
    769875#endif
    770   TComPic*&   pcPic         = m_pcPic;
    771   m_apcSlicePilot->initSlice();
     876  m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice
     877                                // it is not associated with picture, sps or pps structures.
    772878
    773879  if (m_bFirstSliceInPicture)
    774880  {
    775     m_uiSliceIdx     = 0;
     881    m_uiSliceIdx = 0;
    776882  }
    777883  else
    778884  {
    779     m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );
     885    m_apcSlicePilot->copySliceInfo( m_pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );
    780886  }
    781887  m_apcSlicePilot->setSliceIdx(m_uiSliceIdx);
     
    788894                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
    789895  m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag);
    790  
    791896  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
    792897  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
    793898
    794 #if H_MV
     899#if ENC_DEC_TRACE
     900  const UInt64 originalSymbolCount = g_nSymbolCounter;
     901#endif
     902
     903#if NH_MV
    795904  m_apcSlicePilot->setRefPicSetInterLayer( & m_refPicSetInterLayer0, &m_refPicSetInterLayer1 );
    796   m_apcSlicePilot->setLayerId( nalu.m_layerId );
    797   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_targetOptLayerSetIdx );
    798 #else
    799   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
    800 #endif
     905  m_apcSlicePilot->setLayerId( nalu.m_nuhLayerId );
     906#endif
     907
     908  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager, m_prevTid0POC);
     909
    801910  // set POC for dependent slices in skipped pictures
    802   if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) 
     911  if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped)
    803912  {
    804913    m_apcSlicePilot->setPOC(m_skippedPOC);
    805914  }
     915
     916  xUpdatePreviousTid0POC(m_apcSlicePilot);
    806917
    807918  m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA);
    808919  m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
    809 
    810 #if H_MV 
    811   TComVPS* vps     = m_apcSlicePilot->getVPS();
    812   Int layerId  = nalu.m_layerId;   
     920#if NH_MV 
     921  const TComVPS* vps     = m_apcSlicePilot->getVPS();
     922  Int layerId            = nalu.m_nuhLayerId;   
    813923  setViewId   ( vps->getViewId   ( layerId )      ); 
    814 #if H_3D
     924#if NH_3D
    815925  setViewIndex( vps->getViewIndex( layerId )      ); 
    816926  setIsDepth  ( vps->getDepthId  ( layerId ) == 1 ); 
     
    819929#endif
    820930
    821 #if SETTING_NO_OUT_PIC_PRIOR
    822931  //For inference of NoOutputOfPriorPicsFlag
    823932  if (m_apcSlicePilot->getRapPicFlag())
     
    865974    }
    866975  }
    867 #endif
    868 
    869 #if FIX_POC_CRA_NORASL_OUTPUT
     976
    870977  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1
    871978  {
    872     Int iMaxPOClsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC();
     979    TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId());
     980    assert (pps != 0);
     981    TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId());
     982    assert (sps != 0);
     983    Int iMaxPOClsb = 1 << sps->getBitsForPOC();
    873984    m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) );
    874   }
    875 #endif
    876 #if H_MV
     985    xUpdatePreviousTid0POC(m_apcSlicePilot);
     986  }
     987#if NH_MV
    877988    xCeckNoClrasOutput();
    878989#endif
    879     // Skip pictures due to random access
    880     if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
    881     {
     990
     991  // Skip pictures due to random access
     992
     993#if NH_MV
     994  if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay, vps))
     995#else
     996  if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
     997#endif
     998  {
    882999    m_prevSliceSkipped = true;
    8831000    m_skippedPOC = m_apcSlicePilot->getPOC();
    884 #if H_MV
     1001#if NH_MV
    8851002    sliceSkippedFlag = true;
    8861003#endif
    887       return false;
    888     }
    889     // Skip TFD pictures associated with BLA/BLANT pictures
    890     if (isSkipPictureForBLA(iPOCLastDisplay))
    891     {
     1004    return false;
     1005  }
     1006  // Skip TFD pictures associated with BLA/BLANT pictures
     1007  if (isSkipPictureForBLA(iPOCLastDisplay))
     1008  {
    8921009    m_prevSliceSkipped = true;
    8931010    m_skippedPOC = m_apcSlicePilot->getPOC();
    894 #if H_MV
     1011#if NH_MV
    8951012    sliceSkippedFlag = true;
    8961013#endif
    897       return false;
    898     }
     1014    return false;
     1015  }
    8991016
    9001017  // clear previous slice skipped flag
     
    9021019
    9031020  //we should only get a different poc for a new picture (with CTU address==0)
    904   if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0))
     1021  if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() != 0))
    9051022  {
    9061023    printf ("Warning, the first slice of a picture might have been lost!\n");
    9071024  }
     1025
    9081026  // exit when a new picture is found
    909   if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence )
     1027  if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() == 0 && !m_bFirstSliceInPicture) )
    9101028  {
    9111029    if (m_prevPOC >= m_pocRandomAccess)
    9121030    {
    9131031      m_prevPOC = m_apcSlicePilot->getPOC();
     1032#if ENC_DEC_TRACE
     1033      //rewind the trace counter since we didn't actually decode the slice
     1034      g_nSymbolCounter = originalSymbolCount;
     1035#endif
    9141036      return true;
    9151037    }
    9161038    m_prevPOC = m_apcSlicePilot->getPOC();
    9171039  }
    918 #if H_MV
     1040#if NH_MV
    9191041  if ( newLayerFlag )
    9201042  {
     
    9281050#endif
    9291051#endif
    930   // actual decoding starts here
    931 #if H_MV
     1052
     1053#if NH_MV
    9321054   // This part needs further testing !
    9331055   if ( m_apcSlicePilot->getPocResetFlag() )
     
    9581080#endif
    9591081
     1082  //detect lost reference picture and insert copy of earlier frame.
     1083  {
     1084    Int lostPoc;
     1085    while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0)
     1086    {
     1087      xCreateLostPicture(lostPoc-1);
     1088    }
     1089  }
     1090
     1091  if (!m_apcSlicePilot->getDependentSliceSegmentFlag())
     1092  {
     1093    m_prevPOC = m_apcSlicePilot->getPOC();
     1094  }
     1095
     1096  // actual decoding starts here
    9601097  xActivateParameterSets();
    9611098
    962 #if H_MV
     1099  m_bFirstSliceInSequence = false;
     1100  m_bFirstSliceInBitstream  = false;
     1101
     1102
     1103  TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx);
     1104
     1105  // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses.
     1106  // Now, having set up the maps, convert them to the correct form.
     1107  pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) );
     1108  pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) );
     1109  if(!pcSlice->getDependentSliceSegmentFlag())
     1110  {
     1111    pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr()));
     1112    pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr()));
     1113  }
     1114
     1115  m_pcPic->setTLayer(nalu.m_temporalId);
     1116
     1117#if NH_MV
    9631118  //Check Multiview Main profile constraint in G.11.1.1
    9641119  //  When ViewOrderIdx[ i ] derived according to any active VPS is equal to 1
     
    9661121  //  inter_view_mv_vert_constraint_flag shall be equal to 1
    9671122  //  in the sps_multilayer_extension( ) syntax structure in each active SPS for that layer.
    968   if( m_apcSlicePilot->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc()==Profile::MULTIVIEWMAIN
     1123  if( pcSlice->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc()==Profile::MULTIVIEWMAIN
    9691124      &&
    970       m_apcSlicePilot->getVPS()->getViewOrderIdx(m_apcSlicePilot->getVPS()->getLayerIdInNuh(getLayerId()))==1
     1125      pcSlice->getVPS()->getViewOrderIdx(pcSlice->getVPS()->getLayerIdInNuh(getLayerId()))==1
    9711126     )
    9721127  {
    973     assert( m_apcSlicePilot->getSPS()->getInterViewMvVertConstraintFlag()==1 );
    974   }
    975 #endif
    976 
    977   if (m_apcSlicePilot->isNextSlice())
    978   {
    979     m_prevPOC = m_apcSlicePilot->getPOC();
    980   }
    981   m_bFirstSliceInSequence = false;
    982 #if SETTING_NO_OUT_PIC_PRIOR 
    983   m_bFirstSliceInBitstream  = false;
    984 #endif
    985   //detect lost reference picture and insert copy of earlier frame.
    986   Int lostPoc;
    987   while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0)
    988   {
    989     xCreateLostPicture(lostPoc-1);
    990   }
    991   if (m_bFirstSliceInPicture)
    992   {
    993     // Buffer initialize for prediction.
    994     m_cPrediction.initTempBuff();
    995     m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
    996 #if H_MV
    997     m_apcSlicePilot->createInterLayerReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer0, m_refPicSetInterLayer1 );
    998 #endif
    999     //  Get a new picture buffer
    1000     xGetNewPicBuffer (m_apcSlicePilot, pcPic);
    1001 
    1002     Bool isField = false;
    1003     Bool isTff = false;
    1004    
    1005     if(!m_SEIs.empty())
    1006     {
    1007       // Check if any new Picture Timing SEI has arrived
    1008       SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING);
    1009       if (pictureTimingSEIs.size()>0)
    1010       {
    1011         SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin());
    1012         isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2);
    1013         isTff =  (pictureTiming->m_picStruct == 1);
    1014       }
    1015     }
    1016    
    1017     //Set Field/Frame coding mode
    1018     m_pcPic->setField(isField);
    1019     m_pcPic->setTopField(isTff);
    1020    
    1021     // transfer any SEI messages that have been received to the picture
    1022     pcPic->setSEIs(m_SEIs);
    1023     m_SEIs.clear();
    1024 
    1025     // Recursive structure
    1026     m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
    1027     m_cCuDecoder.init   ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction );
    1028     m_cTrQuant.init     ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize());
    1029 
    1030     m_cSliceDecoder.create();
    1031   }
    1032   else
    1033   {
    1034     // Check if any new SEI has arrived
    1035     if(!m_SEIs.empty())
    1036     {
    1037       // Currently only decoding Unit SEI message occurring between VCL NALUs copied
    1038       SEIMessages &picSEI = pcPic->getSEIs();
    1039       SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
    1040       picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
    1041       deleteSEIs(m_SEIs);
    1042     }
    1043   }
    1044  
    1045   //  Set picture slice pointer
    1046   TComSlice*  pcSlice = m_apcSlicePilot;
    1047   Bool bNextSlice     = pcSlice->isNextSlice();
    1048 
    1049   UInt i;
    1050   pcPic->getPicSym()->initTiles(pcSlice->getPPS());
    1051 
    1052   //generate the Coding Order Map and Inverse Coding Order Map
    1053   UInt uiEncCUAddr;
    1054   for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr))
    1055   {
    1056     pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr);
    1057     pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i);
    1058   }
    1059   pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame());
    1060   pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame());
    1061 
    1062   //convert the start and end CU addresses of the slice and dependent slice into encoding order
    1063   pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) );
    1064   pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) );
    1065   if(pcSlice->isNextSlice())
    1066   {
    1067     pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr()));
    1068     pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr()));
    1069   }
    1070 
    1071   if (m_bFirstSliceInPicture)
    1072   {
    1073     if(pcPic->getNumAllocatedSlice() != 1)
    1074     {
    1075       pcPic->clearSliceBuffer();
    1076     }
    1077   }
    1078   else
    1079   {
    1080     pcPic->allocateNewSlice();
    1081   }
    1082   assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
    1083   m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx);
    1084   pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);
    1085 
    1086   pcPic->setTLayer(nalu.m_temporalId);
    1087 
    1088 #if H_MV
    1089   pcPic->setLayerId( nalu.m_layerId );
    1090   pcPic->setViewId ( getViewId() );
    1091 #if H_3D
    1092   pcPic->setViewIndex( getViewIndex() );
    1093   pcPic->setIsDepth  ( getIsDepth  () );
     1128    assert( pcSlice->getSPS()->getInterViewMvVertConstraintFlag()==1 );
     1129  }
     1130#endif
     1131#if NH_MV
     1132  m_pcPic->setLayerId( nalu.m_nuhLayerId );
     1133  m_pcPic->setViewId ( getViewId() );
     1134#if NH_3D
     1135  m_pcPic->setViewIndex( getViewIndex() );
     1136  m_pcPic->setIsDepth  ( getIsDepth  () );
    10941137  pcSlice->setIvPicLists( m_ivPicLists );         
    10951138#endif
    10961139#endif
    10971140
    1098 
    1099 
    1100 
    1101   if (bNextSlice)
     1141  if (!pcSlice->getDependentSliceSegmentFlag())
    11021142  {
    11031143    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
    11041144    // Set reference list
    1105 #if H_MV   
     1145#if NH_MV   
    11061146    std::vector< TComPic* > tempRefPicLists[2];
    11071147    std::vector< Bool     > usedAsLongTerm [2];
     
    11101150    pcSlice->getTempRefPicLists( m_cListPic, m_refPicSetInterLayer0, m_refPicSetInterLayer1, tempRefPicLists, usedAsLongTerm, numPocTotalCurr);
    11111151    pcSlice->setRefPicList     ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true );
    1112 #if H_3D
     1152#if NH_3D_NBDV
    11131153    pcSlice->setDefaultRefView();
    11141154#endif
    1115 #if H_3D_ARP
     1155#if NH_3D_ARP
    11161156    pcSlice->setARPStepNum(m_ivPicLists);
    1117     if( pcSlice->getARPStepNum() > 1 )
    1118     {
    1119       // GT: This seems to be broken, not all nuh_layer_ids are necessarily present
    1120       for(Int iLayerId = 0; iLayerId < nalu.m_layerId; iLayerId ++ )
    1121       {
    1122         Int  iViewIdx =   pcSlice->getVPS()->getViewIndex(iLayerId);
    1123         Bool bIsDepth = ( pcSlice->getVPS()->getDepthId  ( iLayerId ) == 1 );
    1124         if( iViewIdx<getViewIndex() && !bIsDepth )
    1125         {
    1126           pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );
    1127         }
    1128       }
    1129     }
    11301157#endif
    11311158#else
     
    11331160#endif
    11341161
    1135 #if H_3D
     1162#if NH_3D
    11361163    pcSlice->checkInCompPredRefLayers();
    1137 #if H_3D_IV_MERGE
     1164#if NH_3D_IV_MERGE
    11381165#if H_3D_FCO
    11391166    //assert( !getIsDepth() );
     
    11431170#endif   
    11441171#endif
    1145 #if H_MV
     1172#if NH_MV
    11461173    if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() )
    11471174    {
     
    11861213            bLowDelay = false;
    11871214          }
    1188         }       
    1189       }
    1190 
    1191       pcSlice->setCheckLDC(bLowDelay);           
     1215        }
     1216      }
     1217
     1218      pcSlice->setCheckLDC(bLowDelay);
    11921219    }
    11931220
    11941221    //---------------
    11951222    pcSlice->setRefPOCList();
    1196 #if  H_3D_TMVP
     1223#if  NH_3D_TMVP
    11971224    if(pcSlice->getLayerId())
    11981225    {
     
    12021229  }
    12031230
    1204   pcPic->setCurrSliceIdx(m_uiSliceIdx);
     1231  m_pcPic->setCurrSliceIdx(m_uiSliceIdx);
    12051232  if(pcSlice->getSPS()->getScalingListFlag())
    12061233  {
    1207     pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList()  );
     1234    TComScalingList scalingList;
    12081235    if(pcSlice->getPPS()->getScalingListPresentFlag())
    12091236    {
    1210       pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList()  );
    1211     }
    1212     if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag())
    1213     {
    1214       pcSlice->setDefaultScalingList();
    1215     }
    1216     m_cTrQuant.setScalingListDec(pcSlice->getScalingList());
     1237      scalingList = pcSlice->getPPS()->getScalingList();
     1238    }
     1239    else if (pcSlice->getSPS()->getScalingListPresentFlag())
     1240    {
     1241      scalingList = pcSlice->getSPS()->getScalingList();
     1242    }
     1243    else
     1244    {
     1245      scalingList.setDefaultScalingList();
     1246    }
     1247    m_cTrQuant.setScalingListDec(scalingList);
    12171248    m_cTrQuant.setUseScalingList(true);
    12181249  }
    12191250  else
    12201251  {
    1221     m_cTrQuant.setFlatScalingList();
     1252    const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] =
     1253    {
     1254        pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA),
     1255        pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA)
     1256    };
     1257    m_cTrQuant.setFlatScalingList(maxLog2TrDynamicRange, pcSlice->getSPS()->getBitDepths());
    12221258    m_cTrQuant.setUseScalingList(false);
    12231259  }
    12241260
    1225 #if H_3D_IV_MERGE
     1261#if !NH_3D_FIX_TICKET_101
     1262#if NH_3D_IV_MERGE
    12261263#if H_3D_FCO
    12271264  if( !pcSlice->getIsDepth() && m_pcCamParsCollector )
     
    12331270  }
    12341271#endif
    1235 
     1272#endif
    12361273  //  Decode a picture
    1237   m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic);
    1238 #if H_3D
     1274  m_cGopDecoder.decompressSlice(&(nalu.getBitstream()), m_pcPic);
     1275
     1276#if NH_3D
    12391277  if( m_pcCamParsCollector )
    12401278  {
     
    12421280  }
    12431281#endif
     1282
    12441283  m_bFirstSliceInPicture = false;
    12451284  m_uiSliceIdx++;
     
    12481287}
    12491288
    1250 Void TDecTop::xDecodeVPS()
     1289Void TDecTop::xDecodeVPS(const std::vector<UChar> &naluData)
    12511290{
    12521291  TComVPS* vps = new TComVPS();
    1253  
     1292
    12541293  m_cEntropyDecoder.decodeVPS( vps );
    1255   m_parameterSetManagerDecoder.storePrefetchedVPS(vps); 
    1256 }
    1257 
    1258 Void TDecTop::xDecodeSPS()
     1294  m_parameterSetManager.storeVPS(vps, naluData);
     1295}
     1296
     1297Void TDecTop::xDecodeSPS(const std::vector<UChar> &naluData)
    12591298{
    12601299  TComSPS* sps = new TComSPS();
    1261 #if H_MV
     1300#if NH_MV
    12621301  sps->setLayerId( getLayerId() );
    12631302#endif
    1264 #if H_3D
    1265   // Preliminary fix. assuming that all sps refer to the same VPS.
    1266   // Parsing dependency should be resolved!
    1267   TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 );
    1268   assert( vps != 0 );
     1303#if O0043_BEST_EFFORT_DECODING
     1304  sps->setForceDecodeBitDepth(m_forceDecodeBitDepth);
     1305#endif
     1306#if NH_3D
     1307  // GT: Please don't add parsing dependency of SPS from VPS here again!!!
     1308#endif
    12691309  m_cEntropyDecoder.decodeSPS( sps );
    1270 #else
    1271   m_cEntropyDecoder.decodeSPS( sps );
    1272 #endif
    1273   m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
    1274 }
    1275 
    1276 Void TDecTop::xDecodePPS()
     1310  m_parameterSetManager.storeSPS(sps, naluData);
     1311}
     1312
     1313Void TDecTop::xDecodePPS(const std::vector<UChar> &naluData)
    12771314{
    12781315  TComPPS* pps = new TComPPS();
    1279 #if H_MV
     1316#if NH_MV
    12801317  pps->setLayerId( getLayerId() );
    12811318#endif
    1282 #if H_3D
    1283   // Assuming that all PPS indirectly refer to the same VPS via different SPS
    1284   // There is no parsing dependency in decoding DLT in PPS.
    1285   // The VPS information passed to decodePPS() is used to arrange the decoded DLT tables to their corresponding layers.
    1286   // This is equivalent to the process of
    1287   //   Step 1) decoding DLT tables based on the number of depth layers, and
    1288   //   Step 2) mapping DLT tables to the depth layers
    1289   // as described in the 3D-HEVC WD.
    1290   TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 );
    1291   m_cEntropyDecoder.decodePPS( pps, vps );
    1292 #else
     1319#if NH_3D_DLT
     1320  // create mapping from depth layer indexes to layer ids
     1321  Int j=0;
     1322  for( Int i=0; i<=m_parameterSetManager.getFirstVPS()->getMaxLayersMinus1(); i++ )
     1323  {
     1324    Int layerId = m_parameterSetManager.getFirstVPS()->getLayerIdInNuh(i);
     1325    if( m_parameterSetManager.getFirstVPS()->getDepthId(layerId) )
     1326      pps->getDLT()->setDepthIdxToLayerId(j++, layerId);
     1327  }
     1328#endif
    12931329  m_cEntropyDecoder.decodePPS( pps );
    1294 #endif
    1295   m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
    1296 }
    1297 
    1298 Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType )
    1299 {
    1300   if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
    1301   {
    1302 #if H_MV
    1303     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) );
    1304 #else
    1305     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
    1306 #endif
    1307   }
    1308   else
    1309   {
    1310 #if H_MV
    1311     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) );
    1312 #else
    1313     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
    1314 #endif
    1315     SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
    1316     if (activeParamSets.size()>0)
    1317     {
    1318       SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
    1319       m_parameterSetManagerDecoder.applyPrefetchedPS();
    1320       assert(seiAps->activeSeqParameterSetId.size()>0);
    1321 #if H_MV
    1322       if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0], m_layerId ))
    1323 #else
    1324       if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] ))
    1325 #endif
    1326       {
    1327         printf ("Warning SPS activation with Active parameter set SEI failed");
    1328       }
    1329     }
    1330   }
    1331 }
    1332 
    1333 #if H_MV
     1330
     1331  m_parameterSetManager.storePPS( pps, naluData);
     1332}
     1333
     1334#if NH_MV
    13341335Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag )
    13351336#else
     
    13371338#endif
    13381339{
     1340#if !NH_MV
     1341  // ignore all NAL units of layers > 0
     1342  if (nalu.m_nuhLayerId > 0)
     1343  {
     1344    fprintf (stderr, "Warning: found NAL unit with nuh_layer_id equal to %d. Ignoring.\n", nalu.m_nuhLayerId);
     1345    return false;
     1346  }
     1347#endif
    13391348  // Initialize entropy decoder
    13401349  m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder);
    1341   m_cEntropyDecoder.setBitstream      (nalu.m_Bitstream);
     1350  m_cEntropyDecoder.setBitstream      (&(nalu.getBitstream()));
    13421351
    13431352  switch (nalu.m_nalUnitType)
    13441353  {
    13451354    case NAL_UNIT_VPS:
    1346       xDecodeVPS();
    1347 #if H_MV
     1355      xDecodeVPS(nalu.getBitstream().getFifo());
     1356#if NH_MV
    13481357      m_isLastNALWasEos = false;
    13491358#endif
    13501359      return false;
    1351      
     1360
    13521361    case NAL_UNIT_SPS:
    1353       xDecodeSPS();
     1362      xDecodeSPS(nalu.getBitstream().getFifo());
    13541363      return false;
    13551364
    13561365    case NAL_UNIT_PPS:
    1357       xDecodePPS();
     1366      xDecodePPS(nalu.getBitstream().getFifo());
    13581367      return false;
    1359      
     1368
    13601369    case NAL_UNIT_PREFIX_SEI:
     1370      // Buffer up prefix SEI messages until SPS of associated VCL is known.
     1371      m_prefixSEINALUs.push_back(new InputNALUnit(nalu));
     1372      return false;
     1373
    13611374    case NAL_UNIT_SUFFIX_SEI:
    1362 #if H_MV
     1375#if NH_MV
    13631376      if ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI )
    13641377      {
     
    13661379      }
    13671380#endif
    1368       xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
     1381      if (m_pcPic)
     1382      {
     1383#if NH_MV
     1384        m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->getSEIs(), nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS( getLayerId() ), m_pDecodedSEIOutputStream );
     1385#else
     1386        m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->getSEIs(), nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream );
     1387#endif
     1388      }
     1389      else
     1390      {
     1391        printf ("Note: received suffix SEI but no picture currently active.\n");
     1392      }
    13691393      return false;
    13701394
     
    13851409    case NAL_UNIT_CODED_SLICE_RASL_N:
    13861410    case NAL_UNIT_CODED_SLICE_RASL_R:
    1387 #if H_MV
     1411#if NH_MV
    13881412      if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N ||
    13891413          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N ||
     
    13981422        m_isLastNALWasEos = false;
    13991423      }
    1400 
    14011424      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag );
    14021425#else
     
    14041427#endif
    14051428      break;
     1429
    14061430    case NAL_UNIT_EOS:
    1407 #if H_MV
     1431#if NH_MV
    14081432      assert( m_isLastNALWasEos == false );
    14091433      //Check layer id of the nalu. if it is not 0, give a warning message and just return without doing anything.
    1410       if (nalu.m_layerId > 0)
     1434      if (nalu.m_nuhLayerId > 0)
    14111435      {
    14121436        printf( "\nThis bitstream has EOS with non-zero layer id.\n" );
     
    14191443      m_pocRandomAccess = MAX_INT;
    14201444      m_prevPOC = MAX_INT;
    1421       m_bFirstSliceInPicture = true;
    1422       m_bFirstSliceInSequence = true;
    14231445      m_prevSliceSkipped = false;
    14241446      m_skippedPOC = 0;
    14251447      return false;
    1426      
     1448
    14271449    case NAL_UNIT_ACCESS_UNIT_DELIMITER:
    1428       // TODO: process AU delimiter
     1450      {
     1451        AUDReader audReader;
     1452        UInt picType;
     1453        audReader.parseAccessUnitDelimiter(&(nalu.getBitstream()),picType);
     1454        printf ("Note: found NAL_UNIT_ACCESS_UNIT_DELIMITER\n");
    14291455      return false;
    1430      
     1456      }
     1457
    14311458    case NAL_UNIT_EOB:
    14321459      return false;
    1433      
     1460
    14341461    case NAL_UNIT_FILLER_DATA:
    1435 #if H_MV
     1462      {
     1463        FDReader fdReader;
     1464        UInt size;
     1465        fdReader.parseFillerData(&(nalu.getBitstream()),size);
     1466        printf ("Note: found NAL_UNIT_FILLER_DATA with %u bytes payload.\n", size);
     1467#if NH_MV
    14361468      assert( m_isLastNALWasEos == false );
    14371469#endif
    14381470      return false;
    1439      
     1471      }
     1472
    14401473    case NAL_UNIT_RESERVED_VCL_N10:
    14411474    case NAL_UNIT_RESERVED_VCL_R11:
     
    14441477    case NAL_UNIT_RESERVED_VCL_N14:
    14451478    case NAL_UNIT_RESERVED_VCL_R15:
    1446      
     1479
    14471480    case NAL_UNIT_RESERVED_IRAP_VCL22:
    14481481    case NAL_UNIT_RESERVED_IRAP_VCL23:
    1449      
     1482
    14501483    case NAL_UNIT_RESERVED_VCL24:
    14511484    case NAL_UNIT_RESERVED_VCL25:
     
    14561489    case NAL_UNIT_RESERVED_VCL30:
    14571490    case NAL_UNIT_RESERVED_VCL31:
    1458      
     1491      printf ("Note: found reserved VCL NAL unit.\n");
     1492      xParsePrefixSEIsForUnknownVCLNal();
     1493      return false;
     1494
    14591495    case NAL_UNIT_RESERVED_NVCL41:
    14601496    case NAL_UNIT_RESERVED_NVCL42:
     
    14641500    case NAL_UNIT_RESERVED_NVCL46:
    14651501    case NAL_UNIT_RESERVED_NVCL47:
     1502      printf ("Note: found reserved NAL unit.\n");
     1503      return false;
    14661504    case NAL_UNIT_UNSPECIFIED_48:
    14671505    case NAL_UNIT_UNSPECIFIED_49:
     
    14801518    case NAL_UNIT_UNSPECIFIED_62:
    14811519    case NAL_UNIT_UNSPECIFIED_63:
     1520      printf ("Note: found unspecified NAL unit.\n");
     1521      return false;
    14821522    default:
    14831523      assert (0);
     1524      break;
    14841525  }
    14851526
     
    14951536Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
    14961537{
    1497   if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && 
     1538  if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) &&
    14981539       m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
    14991540  {
     
    15131554 * If the random access point is CRA/CRANT/BLA/BLANT, TFD pictures with POC less than the POC of the random access point are skipped.
    15141555 * If the random access point is IDR all pictures after the random access point are decoded.
    1515  * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC 
    1516  * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random 
     1556 * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC
     1557 * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random
    15171558 * access point there is no guarantee that the decoder will not crash.
    15181559 */
    1519 Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay)
    1520 {
    1521   if (iSkipFrame)
     1560#if NH_MV
     1561Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay, const TComVPS* vps)
     1562#else
     1563Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay )
     1564#endif
     1565{
     1566  if (iSkipFrame)
    15221567  {
    15231568    iSkipFrame--;   // decrement the counter
    15241569    return true;
    15251570  }
    1526 #if H_MV
     1571#if NH_MV
    15271572  else if ( !m_layerInitilizedFlag[ m_layerId ] ) // start of random access point, m_pocRandomAccess has not been set yet.
    15281573#else
     
    15361581    {
    15371582
    1538 #if H_MV
    1539       if ( xAllRefLayersInitilized() )
     1583#if NH_MV
     1584      if ( xAllRefLayersInitilized( vps ) )
    15401585      {
    15411586        m_layerInitilizedFlag[ m_layerId ] = true;
     
    15531598    else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    15541599    {
    1555 #if H_MV
    1556       if ( xAllRefLayersInitilized() )
     1600#if NH_MV
     1601      if ( xAllRefLayersInitilized( vps) )
    15571602      {
    15581603        m_layerInitilizedFlag[ m_layerId ] = true;
     
    15671612#endif
    15681613    }
    1569     else 
    1570     {
    1571 #if H_MV
     1614    else
     1615    {
     1616#if NH_MV
    15721617      static Bool warningMessage[MAX_NUM_LAYERS];
    15731618      static Bool warningInitFlag = false;
     
    15881633      }
    15891634#else
    1590       static Bool warningMessage = false;
    1591       if(!warningMessage)
     1635      if(!m_warningMessageSkipPicture)
    15921636      {
    15931637        printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture");
    1594         warningMessage = true;
     1638        m_warningMessageSkipPicture = true;
    15951639      }
    15961640#endif
     
    16041648    return true;
    16051649  }
    1606 #if H_MV
     1650  // if we reach here, then the picture is not skipped.
     1651#if NH_MV
    16071652  return !m_layerInitilizedFlag[ getLayerId() ];
    16081653#else
    1609   // if we reach here, then the picture is not skipped.
    1610   return false;
    1611 #endif
    1612 }
    1613 
    1614 #if H_MV
     1654  return false;
     1655#endif
     1656}
     1657#if NH_MV
    16151658TComPic* TDecTop::getPic( Int poc )
    16161659{
     
    16721715}
    16731716
    1674 Bool TDecTop::xAllRefLayersInitilized()
    1675 {
    1676   Bool allRefLayersInitilizedFlag = true;
    1677   TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 );
     1717Bool TDecTop::xAllRefLayersInitilized( const TComVPS* vps )
     1718{
     1719  Bool allRefLayersInitilizedFlag = true;   
    16781720  for (Int i = 0; i < vps->getNumDirectRefLayers( getLayerId()  ); i++ )
    16791721  {
     
    16851727}
    16861728
    1687 #if H_3D
    1688 Void TDecTop::setProfileIdc()
    1689 {
    1690   if (m_targetOptLayerSetIdx != -1 )
    1691   {   
    1692     TComVPS* vps = getPrefetchedVPS();
    1693     Int lsIdx = vps->olsIdxToLsIdx( m_targetOptLayerSetIdx );
    1694     Int lIdx = -1;
    1695     for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ); j++ )
    1696     {
    1697       if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() )
    1698       {
    1699         lIdx = j;
    1700         break;
    1701       }       
    1702     }
    1703     assert( lIdx != -1 );
    1704 
    1705     Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOptLayerSetIdx, lIdx ) )->getGeneralPTL()->getProfileIdc();
    1706     assert( profileIdc == 1 || profileIdc == 6 || profileIdc == 8 );
    1707     m_profileIdc = profileIdc;   
    1708   };
    1709 }
    1710 #endif
    1711 #endif
     1729
     1730Void TDecTop::initFromActiveVps( const TComVPS* vps )
     1731{
     1732  if ( m_targetOlsIdx == -1 )
     1733  {
     1734    // Not normative! Corresponds to specification by "External Means". (Should be set equal to 0, when no external means available. )
     1735    m_targetOlsIdx = vps->getVpsNumLayerSetsMinus1();
     1736  }
     1737#if NH_3D
     1738  // Set profile
     1739  Int lsIdx = vps->olsIdxToLsIdx( m_targetOlsIdx );
     1740  Int lIdx = -1;
     1741  for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ); j++ )
     1742  {
     1743    if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() )
     1744    {
     1745      lIdx = j;
     1746      break;
     1747    }       
     1748  }
     1749  assert( lIdx != -1 );
     1750
     1751  Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOlsIdx, lIdx ) )->getGeneralPTL()->getProfileIdc();
     1752  assert( profileIdc == 1 || profileIdc == 6 || profileIdc == 8 );
     1753  m_profileIdc = profileIdc;   
     1754#endif
     1755}
     1756#endif
     1757
    17121758//! \}
Note: See TracChangeset for help on using the changeset viewer.