Ignore:
Timestamp:
13 Jul 2015, 20:38:11 (9 years ago)
Author:
seregin
Message:

port rev 4219 and rev 4246

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r1229 r1235  
    223223}
    224224
    225 Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic )
    226 {
    227   Int  numReorderPics[MAX_TLAYER];
    228 #if SVC_EXTENSION
    229   Window &conformanceWindow = pcSlice->getConformanceWindow();
     225#if SVC_EXTENSION
     226Void TDecTop::xGetNewPicBuffer( const TComVPS &vps, const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer )
    230227#else
    231   Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow();
    232 #endif
    233   Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window();
    234 
    235   for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++)
    236   {
    237 #if SVC_EXTENSION
    238     if( m_commonDecoderParams->getTargetOutputLayerSetIdx() == 0 )
    239     {
    240       assert( this->getLayerId() == 0 );
    241       numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer);
    242     }
    243     else
    244     {
    245       TComVPS *vps = pcSlice->getVPS();
    246       // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.
    247       numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);
    248     }
    249 #else
    250     numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer);
    251 #endif
    252   }
    253 
     228Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer )
     229#endif
     230{
    254231#if SVC_EXTENSION
    255232  if( m_commonDecoderParams->getTargetOutputLayerSetIdx() == 0 )
    256233  {
    257     assert( this->getLayerId() == 0 );
    258     m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
     234    assert( m_layerId == 0 );
     235    m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer);     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    259236  }
    260237  else
    261238  {
    262     m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( m_commonDecoderParams->getTargetOutputLayerSetIdx(), pcSlice->getVPS()->getLayerIdcForOls( pcSlice->getVPS()->getOutputLayerSetIdx( m_commonDecoderParams->getTargetOutputLayerSetIdx()), pcSlice->getLayerId() ), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
     239    m_iMaxRefPicNum = vps.getMaxVpsDecPicBufferingMinus1( m_commonDecoderParams->getTargetOutputLayerSetIdx(), vps.getLayerIdcForOls( vps.getOutputLayerSetIdx( m_commonDecoderParams->getTargetOutputLayerSetIdx()), m_layerId ), temporalLayer ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    263240  }
    264241
    265242  m_iMaxRefPicNum += 1; // it should be updated if more than 1 resampling picture is used
    266243#else
    267   m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
     244  m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer);     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    268245#endif
    269246 
     
    275252    if(m_layerId > 0)
    276253    {
    277       xSetSpatialEnhLayerFlag( pcSlice, rpcPic );
    278     }
    279 
    280     rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    281                      conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
     254      xSetSpatialEnhLayerFlag( vps, sps, pps, rpcPic );
     255    }
     256
     257    rpcPic->create( vps, sps, pps, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true, m_layerId);
    282258#else //SVC_EXTENSION
    283     rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    284                      conformanceWindow, defaultDisplayWindow, numReorderPics, true);
     259    rpcPic->create ( sps, pps, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
    285260#endif //SVC_EXTENSION
    286261   
     
    326301  if( m_layerId > 0 )
    327302  {
    328     xSetSpatialEnhLayerFlag( pcSlice, rpcPic );
    329   }
    330 
    331   rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    332                    conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
     303    xSetSpatialEnhLayerFlag( vps, sps, pps, rpcPic );
     304  }
     305
     306  rpcPic->create( vps, sps, pps, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true, m_layerId);
    333307#else  //SVC_EXTENSION
    334   rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    335                    conformanceWindow, defaultDisplayWindow, numReorderPics, true);
     308  rpcPic->create ( sps, pps, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
    336309#endif //SVC_EXTENSION
    337310}
     
    386359{
    387360  printf("\ninserting lost poc : %d\n",iLostPoc);
    388   TComSlice cFillSlice;
    389   cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
    390   cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
    391 #if SVC_EXTENSION
    392   cFillSlice.setVPS( m_parameterSetManagerDecoder.getFirstVPS() );
    393   cFillSlice.initSlice( m_layerId );
    394 #else
    395   cFillSlice.initSlice();
    396 #endif
    397361  TComPic *cFillPic;
    398   xGetNewPicBuffer(&cFillSlice,cFillPic);
    399   cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
    400   cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
    401 #if SVC_EXTENSION
    402   cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder.getFirstVPS() );
     362#if SVC_EXTENSION
     363  xGetNewPicBuffer(*(m_parameterSetManager.getFirstVPS()), *(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), cFillPic, 0);
    403364  cFillPic->getSlice(0)->initSlice( m_layerId );
    404365#else
     366  xGetNewPicBuffer(*(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), cFillPic, 0);
    405367  cFillPic->getSlice(0)->initSlice();
    406368#endif
     
    445407Void TDecTop::xActivateParameterSets()
    446408{
    447   m_parameterSetManagerDecoder.applyPrefetchedPS();
    448 
    449   TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId());
    450   assert (pps != 0);
    451 
    452   TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId());
    453   assert (sps != 0);
    454 
    455   if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
    456   {
    457     printf ("Parameter set activation failed!");
    458     assert (0);
    459   }
    460 
    461 #if SVC_EXTENSION
    462   // scaling list settings and checks
    463   TComVPS *activeVPS = m_parameterSetManagerDecoder.getActiveVPS();
    464   TComSPS *activeSPS = m_parameterSetManagerDecoder.getActiveSPS();
    465   TComPPS *activePPS = m_parameterSetManagerDecoder.getActivePPS();
    466 
    467   if( activeSPS->getInferScalingListFlag() )
    468   {
    469     UInt refLayerId = activeSPS->getScalingListRefLayerId();
    470     TComSPS *refSps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL );
    471 
    472     // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0
    473     if( activeVPS->getNonHEVCBaseLayerFlag() )
    474     {
    475       assert( refLayerId > 0 );
    476     }
    477 
    478     // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and
    479     // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id
    480     assert( refSps->getInferScalingListFlag() == false );
    481 
    482     // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,
    483     // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB
    484     assert( activeVPS->getRecursiveRefLayerFlag( activeSPS->getLayerId(), refLayerId ) == true );
    485    
    486     if( activeSPS->getScalingList() != refSps->getScalingList() )
    487     {
    488       // delete created instance of scaling list since it will be inferred
    489       delete activeSPS->getScalingList();
    490 
    491       // infer scaling list
    492       activeSPS->setScalingList( refSps->getScalingList() );
    493     }
    494   }
    495 
    496   if( activePPS->getInferScalingListFlag() )
    497   {
    498     UInt refLayerId = activePPS->getScalingListRefLayerId();
    499     TComPPS *refPps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL );
    500 
    501     // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0
    502     if( activeVPS->getNonHEVCBaseLayerFlag() )
    503     {
    504       assert( refLayerId > 0 );
    505     }
    506 
    507     // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and
    508     // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id
    509     assert( refPps->getInferScalingListFlag() == false );
    510 
    511     // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,
    512     // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB
    513     assert( activeVPS->getRecursiveRefLayerFlag( activePPS->getLayerId(), refLayerId ) == true );
    514    
    515     if( activePPS->getScalingList() != refPps->getScalingList() )
    516     {
    517       // delete created instance of scaling list since it will be inferred
    518       delete activePPS->getScalingList();
    519 
    520       // infer scaling list
    521       activePPS->setScalingList( refPps->getScalingList() );
    522     }
    523 
    524   }
     409  if (m_bFirstSliceInPicture)
     410  {
     411    const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); // this is a temporary PPS object. Do not store this value
     412    assert (pps != 0);
     413
     414#if SVC_EXTENSION
     415    TComSPS *updateSPS = m_parameterSetManager.getSPS(pps->getSPSId());             // this is a temporary SPS object. Do not store this value
     416#endif
     417    const TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId());             // this is a temporary SPS object. Do not store this value
     418    assert (sps != 0);
     419
     420    m_parameterSetManager.clearSPSChangedFlag(sps->getSPSId());
     421    m_parameterSetManager.clearPPSChangedFlag(pps->getPPSId());
     422
     423    if (false == m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
     424    {
     425      printf ("Parameter set activation failed!");
     426      assert (0);
     427    }
     428
     429#if SVC_EXTENSION
     430    // scaling list settings and checks
     431    TComVPS *vps = m_parameterSetManager.getVPS(sps->getVPSId());
     432    assert (vps != 0);
     433
     434    m_parameterSetManager.clearVPSChangedFlag(sps->getVPSId());   
     435
     436    if( sps->getInferScalingListFlag() )
     437    {
     438      UInt refLayerId = sps->getScalingListRefLayerId();
     439      const TComSPS *refSps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL );
     440
     441      // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0
     442      if( vps->getNonHEVCBaseLayerFlag() )
     443      {
     444        assert( refLayerId > 0 );
     445      }
     446
     447      // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and
     448      // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id
     449      assert( refSps->getInferScalingListFlag() == false );
     450
     451      // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,
     452      // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB
     453      assert( vps->getRecursiveRefLayerFlag( sps->getLayerId(), refLayerId ) == true );
     454    }
     455
     456    if( pps->getInferScalingListFlag() )
     457    {
     458      UInt refLayerId = pps->getScalingListRefLayerId();
     459      const TComPPS *refPps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL );
     460
     461      // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0
     462      if( vps->getNonHEVCBaseLayerFlag() )
     463      {
     464        assert( refLayerId > 0 );
     465      }
     466
     467      // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and
     468      // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id
     469      assert( refPps->getInferScalingListFlag() == false );
     470
     471      // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,
     472      // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB
     473      assert( vps->getRecursiveRefLayerFlag( pps->getLayerId(), refLayerId ) == true );
     474    }
    525475
    526476#if AVC_BASE
    527   if( activeVPS->getNonHEVCBaseLayerFlag() )
    528   {
    529     TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
    530     if( m_layerId > 0 && pBLPic->getPicYuvRec() == NULL )
    531     {
    532       UInt refLayerId = 0;
    533       RepFormat* repFormat = activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(refLayerId) );
    534 
    535       Int  numReorderPics[MAX_TLAYER];
    536       Window defaultDisplayWindow;
    537 
    538 #if AUXILIARY_PICTURES
    539       pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true);
     477    if( vps->getNonHEVCBaseLayerFlag() )
     478    {
     479      TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     480      if( m_layerId > 0 && pBLPic->getPicYuvRec() == NULL )
     481      {
     482        UInt refLayerId = 0;
     483        const RepFormat* repFormat = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(refLayerId) );
     484
     485        pBLPic->create( *vps, *sps, *pps, sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), true, refLayerId);
     486
     487        // it is needed where the VPS is accessed through the slice
     488        pBLPic->getSlice(0)->setVPS( vps );
     489
     490        g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] = repFormat->getBitDepthVpsLuma();
     491        g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] = repFormat->getBitDepthVpsChroma();
     492      }
     493    }
     494#endif
     495
     496    if( m_layerId > 0 )
     497    {
     498      // When not present sps_max_sub_layers_minus1 is inferred to be equal to vps_max_sub_layers_minus1.
     499      updateSPS->setMaxTLayers( vps->getMaxTLayers() );
     500
     501      // When not present sps_temporal_id_nesting_flag is inferred to be equal to vps_temporal_id_nesting_flag
     502      updateSPS->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? vps->getTemporalNestingFlag() : true );
     503
     504      // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive, due to nuh_layer_id being greater than 0,
     505      // it is inferred to be equal to max_vps_dec_pic_buffering_minus1[ TargetOptLayerSetIdx ][ currLayerId ][ i ] of the active VPS, where currLayerId is the nuh_layer_id of the layer that refers to the SPS.
     506      for(UInt i=0; i < sps->getMaxTLayers(); i++)
     507      {
     508        // to avoid compiler warning "array subscript is above array bounds"
     509        assert( i < MAX_TLAYER );
     510
     511        // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive,
     512        // due to MultiLayerExtSpsFlag being equal to 1, for a layer that refers to the SPS and has nuh_layer_id equal to currLayerId,
     513        // the value of sps_max_dec_pic_buffering_minus1[ i ] is inferred to be equal to max_vps_dec_pic_buffering_minus1[ TargetOlsIdx ][ layerIdx ][ i ] of the active VPS,
     514        // where layerIdx is equal to the value such that LayerSetLayerIdList[ TargetDecLayerSetIdx ][ layerIdx ] is equal to currLayerId.
     515        if( sps->getMultiLayerExtSpsFlag() )
     516        {
     517          updateSPS->setMaxDecPicBuffering( vps->getMaxVpsDecPicBufferingMinus1( m_commonDecoderParams->getTargetOutputLayerSetIdx(), vps->getLayerIdcForOls( vps->getOutputLayerSetIdx( m_commonDecoderParams->getTargetOutputLayerSetIdx() ), m_layerId ), i) + 1, i);
     518        }
     519
     520        // The value of sps_max_dec_pic_buffering_minus1[ i ] shall be less than or equal to vps_max_dec_pic_buffering_minus1[ i ] for each value of i.
     521        assert( sps->getMaxDecPicBuffering(i) <= vps->getMaxDecPicBuffering(i) );     
     522      }
     523
     524      UInt layerIdx = vps->getLayerIdxInVps( m_layerId );
     525
     526      if( vps->getBaseLayerPSCompatibilityFlag(layerIdx) )
     527      {
     528        const RepFormat* repFormat = vps->getVpsRepFormat(vps->getVpsRepFormatIdx(layerIdx));
     529
     530        assert( pps->getLayerId() == 0 );
     531        assert( sps->getLayerId() == 0 );
     532        assert( repFormat->getChromaFormatVpsIdc() == sps->getChromaFormatIdc() );
     533        assert( repFormat->getSeparateColourPlaneVpsFlag() == 0 );
     534        assert( repFormat->getPicHeightVpsInLumaSamples() == sps->getPicHeightInLumaSamples() );
     535        assert( repFormat->getPicWidthVpsInLumaSamples()  == sps->getPicWidthInLumaSamples() );
     536        assert( repFormat->getBitDepthVpsLuma()   == sps->getBitDepth(CHANNEL_TYPE_LUMA) );
     537        assert( repFormat->getBitDepthVpsChroma() == sps->getBitDepth(CHANNEL_TYPE_CHROMA) );
     538        assert( repFormat->getConformanceWindowVps().getWindowLeftOffset()   == sps->getConformanceWindow().getWindowLeftOffset() );
     539        assert( repFormat->getConformanceWindowVps().getWindowRightOffset()  == sps->getConformanceWindow().getWindowRightOffset() );
     540        assert( repFormat->getConformanceWindowVps().getWindowTopOffset()    == sps->getConformanceWindow().getWindowTopOffset() );
     541        assert( repFormat->getConformanceWindowVps().getWindowBottomOffset() == sps->getConformanceWindow().getWindowBottomOffset() );
     542      }   
     543    }
     544
     545    //Conformance checking for rep format -- rep format of current picture of current layer shall never be greater rep format defined in VPS for the current layer
     546    UInt layerIdx = vps->getLayerIdxInVps(m_apcSlicePilot->getLayerId());
     547
     548    if ( vps->getVpsExtensionFlag() == 1 && (m_apcSlicePilot->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) )
     549    {
     550      assert( sps->getPicWidthInLumaSamples()        <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getPicWidthVpsInLumaSamples() );
     551      assert( sps->getPicHeightInLumaSamples()       <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getPicHeightVpsInLumaSamples() );
     552      assert( sps->getChromaFormatIdc()              <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getChromaFormatVpsIdc() );
     553      assert( sps->getBitDepth(CHANNEL_TYPE_LUMA)    <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsLuma() );
     554      assert( sps->getBitDepth(CHANNEL_TYPE_CHROMA)  <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsChroma() );
     555    }
     556    else if ( vps->getVpsExtensionFlag() == 1 )
     557    {
     558      assert( vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples()  <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples());
     559      assert( vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples());
     560      assert( vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc()        <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc());
     561      assert( vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma()           <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma());
     562      assert( vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma()         <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma());
     563    }
     564#endif //SVC_EXTENSION
     565
     566    // TODO: remove the use of the following globals:
     567    for (UInt channel = 0; channel < MAX_NUM_CHANNEL_TYPE; channel++)
     568    {
     569#if SVC_EXTENSION
     570      g_bitDepth[channel] = isLuma(ChannelType(channel)) ? vps->getBitDepthY(sps, m_apcSlicePilot->getLayerId()) : vps->getBitDepthC(sps, m_apcSlicePilot->getLayerId());
    540571#else
    541       pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true);
    542 #endif
    543       // it is needed where the VPS is accessed through the slice
    544       pBLPic->getSlice(0)->setVPS( activeVPS );
    545 
    546       g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] = repFormat->getBitDepthVpsLuma();
    547       g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] = repFormat->getBitDepthVpsChroma();
    548     }
    549   }
    550 #endif
    551 
    552   if( m_layerId > 0 )
    553   {
    554     // When not present sps_max_sub_layers_minus1 is inferred to be equal to vps_max_sub_layers_minus1.
    555     sps->setMaxTLayers( activeVPS->getMaxTLayers() );
    556 
    557     // When not present sps_temporal_id_nesting_flag is inferred to be equal to vps_temporal_id_nesting_flag
    558     sps->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? activeVPS->getTemporalNestingFlag() : true );
    559 
    560     // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive, due to nuh_layer_id being greater than 0,
    561     // it is inferred to be equal to max_vps_dec_pic_buffering_minus1[ TargetOptLayerSetIdx ][ currLayerId ][ i ] of the active VPS, where currLayerId is the nuh_layer_id of the layer that refers to the SPS.
    562     for(UInt i=0; i < sps->getMaxTLayers(); i++)
    563     {
    564       // to avoid compiler warning "array subscript is above array bounds"
    565       assert( i < MAX_TLAYER );
    566 
    567       // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive,
    568       // due to MultiLayerExtSpsFlag being equal to 1, for a layer that refers to the SPS and has nuh_layer_id equal to currLayerId,
    569       // the value of sps_max_dec_pic_buffering_minus1[ i ] is inferred to be equal to max_vps_dec_pic_buffering_minus1[ TargetOlsIdx ][ layerIdx ][ i ] of the active VPS,
    570       // where layerIdx is equal to the value such that LayerSetLayerIdList[ TargetDecLayerSetIdx ][ layerIdx ] is equal to currLayerId.
    571       if( sps->getMultiLayerExtSpsFlag() )
    572       {
    573         sps->setMaxDecPicBuffering( activeVPS->getMaxVpsDecPicBufferingMinus1( m_commonDecoderParams->getTargetOutputLayerSetIdx(), activeVPS->getLayerIdcForOls( activeVPS->getOutputLayerSetIdx( m_commonDecoderParams->getTargetOutputLayerSetIdx() ), m_layerId ), i) + 1, i);
    574       }
    575 
    576       // The value of sps_max_dec_pic_buffering_minus1[ i ] shall be less than or equal to vps_max_dec_pic_buffering_minus1[ i ] for each value of i.
    577       assert( sps->getMaxDecPicBuffering(i) <= activeVPS->getMaxDecPicBuffering(i) );     
    578     }
    579 
    580     UInt layerIdx = activeVPS->getLayerIdxInVps( m_layerId );
    581 
    582     if( activeVPS->getBaseLayerPSCompatibilityFlag(layerIdx) )
    583     {
    584       RepFormat* repFormat = activeVPS->getVpsRepFormat(activeVPS->getVpsRepFormatIdx(layerIdx));
    585 
    586       assert( pps->getLayerId() == 0 );
    587       assert( sps->getLayerId() == 0 );
    588       assert( repFormat->getChromaFormatVpsIdc() == sps->getChromaFormatIdc() );
    589       assert( repFormat->getSeparateColourPlaneVpsFlag() == 0 );
    590       assert( repFormat->getPicHeightVpsInLumaSamples() == sps->getPicHeightInLumaSamples() );
    591       assert( repFormat->getPicWidthVpsInLumaSamples()  == sps->getPicWidthInLumaSamples() );
    592       assert( repFormat->getBitDepthVpsLuma()   == sps->getBitDepth(CHANNEL_TYPE_LUMA) );
    593       assert( repFormat->getBitDepthVpsChroma() == sps->getBitDepth(CHANNEL_TYPE_CHROMA) );
    594       assert( repFormat->getConformanceWindowVps().getWindowLeftOffset()   == sps->getConformanceWindow().getWindowLeftOffset() );
    595       assert( repFormat->getConformanceWindowVps().getWindowRightOffset()  == sps->getConformanceWindow().getWindowRightOffset() );
    596       assert( repFormat->getConformanceWindowVps().getWindowTopOffset()    == sps->getConformanceWindow().getWindowTopOffset() );
    597       assert( repFormat->getConformanceWindowVps().getWindowBottomOffset() == sps->getConformanceWindow().getWindowBottomOffset() );
    598     }   
    599   }
    600 
    601   //Conformance checking for rep format -- rep format of current picture of current layer shall never be greater rep format defined in VPS for the current layer
    602   UInt layerIdx = activeVPS->getLayerIdxInVps(m_apcSlicePilot->getLayerId());
    603 
    604   if ( activeVPS->getVpsExtensionFlag() == 1 && (m_apcSlicePilot->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) )
    605   {
    606     assert( sps->getPicWidthInLumaSamples()        <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getPicWidthVpsInLumaSamples() );
    607     assert( sps->getPicHeightInLumaSamples()       <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getPicHeightVpsInLumaSamples() );
    608     assert( sps->getChromaFormatIdc()              <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getChromaFormatVpsIdc() );
    609     assert( sps->getBitDepth(CHANNEL_TYPE_LUMA)    <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsLuma() );
    610     assert( sps->getBitDepth(CHANNEL_TYPE_CHROMA)  <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsChroma() );
    611   }
    612   else if ( activeVPS->getVpsExtensionFlag() == 1 )
    613   {
    614     assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples()  <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples());
    615     assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples());
    616     assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc()        <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc());
    617     assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma()           <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma());
    618     assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma()         <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma());
    619   }
    620 #endif //SVC_EXTENSION
    621 
    622   m_apcSlicePilot->setPPS(pps);
    623   m_apcSlicePilot->setSPS(sps);
    624   pps->setSPS(sps);
    625   pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : ((pps->getNumTileRowsMinus1() + 1)*(pps->getNumTileColumnsMinus1() + 1)));
    626   pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
    627   pps->setMinCuChromaQpAdjSize( sps->getMaxCUWidth() >> ( pps->getMaxCuChromaQpAdjDepth()) );
    628 
    629   for (UInt channel = 0; channel < MAX_NUM_CHANNEL_TYPE; channel++)
    630   {
    631 #if SVC_EXTENSION
    632     g_bitDepth[channel] = isLuma(ChannelType(channel)) ? m_apcSlicePilot->getBitDepthY() : m_apcSlicePilot->getBitDepthC();
     572      g_bitDepth[channel] = sps->getBitDepth(ChannelType(channel));
     573#endif
     574      g_maxTrDynamicRange[channel] = (sps->getUseExtendedPrecision()) ? std::max<Int>(15, (g_bitDepth[channel] + 6)) : 15;
     575    }
     576    g_uiMaxCUWidth  = sps->getMaxCUWidth();
     577    g_uiMaxCUHeight = sps->getMaxCUHeight();
     578    g_uiMaxCUDepth  = sps->getMaxCUDepth();
     579#if SVC_EXTENSION
     580    g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() + (Int)getMaxCUDepthOffset(vps->getChromaFormatIdc(sps, m_apcSlicePilot->getLayerId()), sps->getQuadtreeTULog2MinSize()));
    633581#else
    634     g_bitDepth[channel] = sps->getBitDepth(ChannelType(channel));
    635 #endif
    636 
    637     if (sps->getUseExtendedPrecision()) g_maxTrDynamicRange[channel] = std::max<Int>(15, (g_bitDepth[channel] + 6));
    638     else                                g_maxTrDynamicRange[channel] = 15;
    639   }
    640   g_uiMaxCUWidth  = sps->getMaxCUWidth();
    641   g_uiMaxCUHeight = sps->getMaxCUHeight();
    642   g_uiMaxCUDepth  = sps->getMaxCUDepth();
    643   g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() + (Int)getMaxCUDepthOffset(sps->getChromaFormatIdc(), sps->getQuadtreeTULog2MinSize()));
    644 
    645   for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
    646   {
    647     sps->setAMPAcc( i, sps->getUseAMP() );
    648   }
    649 
    650   for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++)
    651   {
    652     sps->setAMPAcc( i, 0 );
    653   }
    654 
    655   m_cSAO.destroy();
    656 #if SVC_EXTENSION
    657   m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), pps->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), pps->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) );
     582    g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() + (Int)getMaxCUDepthOffset(sps->getChromaFormatIdc(), sps->getQuadtreeTULog2MinSize()));
     583#endif
     584
     585    //  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.
     586#if SVC_EXTENSION
     587    xGetNewPicBuffer( *(vps), *(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer() );
    658588#else
    659   m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), pps->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), pps->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) );
    660 #endif
    661   m_cLoopFilter.create( sps->getMaxCUDepth() );
     589    xGetNewPicBuffer (*(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer());
     590#endif
     591
     592#if ALIGNED_BUMPING
     593    m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic);
     594#else
     595    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
     596#endif
     597
     598    // make the slice-pilot a real slice, and set up the slice-pilot for the next slice
     599    assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
     600    m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx);
     601
     602    // we now have a real slice:
     603    TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx);
     604
     605    // Update the PPS and SPS pointers with the ones of the picture.
     606    pps=pSlice->getPPS();
     607    sps=pSlice->getSPS();
     608
     609    // Initialise the various objects for the new set of settings
     610#if SVC_EXTENSION
     611    m_cSAO.create( pSlice->getPicWidthInLumaSamples(), pSlice->getPicHeightInLumaSamples(), pSlice->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), pps->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), pps->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) );
     612#else
     613    m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), pps->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), pps->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) );
     614#endif
     615    m_cLoopFilter.create( sps->getMaxCUDepth() );
     616    m_cPrediction.initTempBuff(sps->getChromaFormatIdc());
     617
     618    Bool isField = false;
     619    Bool isTopField = false;
     620
     621    if(!m_SEIs.empty())
     622    {
     623      // Check if any new Picture Timing SEI has arrived
     624      SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING);
     625      if (pictureTimingSEIs.size()>0)
     626      {
     627        SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin());
     628        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);
     629        isTopField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 11);
     630      }
     631     
     632#if Q0189_TMVP_CONSTRAINTS
     633      // Check if any new temporal motion vector prediction constraints SEI has arrived
     634      SEIMessages seiTMVPConstrainsList = extractSeisByType (m_SEIs, SEI::TMVP_CONSTRAINTS);
     635      if (seiTMVPConstrainsList.size() > 0)
     636      {
     637        assert ( m_pcPic->getTLayer() == 0 );  //this SEI can present only for AU with Tid equal to 0
     638        SEITMVPConstrains* tmvpConstraintSEI = (SEITMVPConstrains*) *(seiTMVPConstrainsList.begin());
     639        if ( tmvpConstraintSEI->prev_pics_not_used_flag == 1 )
     640        {
     641          //update all pics in the DPB such that they cannot be used for TMPV ref
     642          TComList<TComPic*>::iterator  iterRefPic = m_cListPic.begin(); 
     643          while( iterRefPic != m_cListPic.end() )
     644          {
     645            TComPic *refPic = *iterRefPic;
     646            if( ( refPic->getLayerId() == m_pcPic->getLayerId() ) && refPic->getReconMark() )
     647            {
     648              for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--)
     649              {
     650                TComSlice *refSlice = refPic->getSlice(i);
     651                refSlice->setAvailableForTMVPRefFlag( false );
     652              }
     653            }
     654            iterRefPic++;
     655          }
     656        }
     657      }
     658#endif
     659    }
     660
     661    //Set Field/Frame coding mode
     662    m_pcPic->setField(isField);
     663    m_pcPic->setTopField(isTopField);
     664
     665    // transfer any SEI messages that have been received to the picture
     666    m_pcPic->setSEIs(m_SEIs);
     667    m_SEIs.clear();
     668
     669    // Recursive structure
     670#if SVC_EXTENSION
     671    m_cCuDecoder.create ( sps->getMaxCUDepth(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), pSlice->getChromaFormatIdc() );
     672    m_cCuDecoder.init   ( m_ppcTDecTop, &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, m_layerId );
     673#else
     674    m_cCuDecoder.create ( sps->getMaxCUDepth(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getChromaFormatIdc() );
     675    m_cCuDecoder.init   ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction );
     676#endif
     677    m_cTrQuant.init     ( sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxTrSize());
     678
     679    m_cSliceDecoder.create();
     680  }
     681  else
     682  {
     683    // make the slice-pilot a real slice, and set up the slice-pilot for the next slice
     684    m_pcPic->allocateNewSlice();
     685    assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
     686    m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx);
     687
     688    TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); // we now have a real slice.
     689
     690    const TComSPS *sps = pSlice->getSPS();
     691    const TComPPS *pps = pSlice->getPPS();
     692
     693    // check that the current active PPS has not changed...
     694    if (m_parameterSetManager.getSPSChangedFlag(sps->getSPSId()) )
     695    {
     696      printf("Error - a new SPS has been decoded while processing a picture\n");
     697      exit(1);
     698    }
     699    if (m_parameterSetManager.getPPSChangedFlag(pps->getPPSId()) )
     700    {
     701      printf("Error - a new PPS has been decoded while processing a picture\n");
     702      exit(1);
     703    }
     704
     705    // Check if any new SEI has arrived
     706    if(!m_SEIs.empty())
     707    {
     708      // Currently only decoding Unit SEI message occurring between VCL NALUs copied
     709      SEIMessages &picSEI = m_pcPic->getSEIs();
     710      SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
     711      picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
     712      deleteSEIs(m_SEIs);
     713    }
     714  }
     715
    662716}
    663717
     
    669723{
    670724#if SVC_EXTENSION
    671   m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) );
    672 
    673   // Following check should go wherever the VPS is activated
    674   if( !m_apcSlicePilot->getVPS()->getBaseLayerAvailableFlag() )
    675   {
    676     assert(nalu.m_layerId != 0);
    677     assert(m_apcSlicePilot->getVPS()->getNumAddLayerSets() > 0);
    678 
    679     if( m_commonDecoderParams->getTargetOutputLayerSetIdx() >= 0 )
    680     {
    681       UInt layerIdx = m_apcSlicePilot->getVPS()->getOutputLayerSetIdx(getCommonDecoderParams()->getTargetOutputLayerSetIdx());
    682       assert(layerIdx > m_apcSlicePilot->getVPS()->getVpsNumLayerSetsMinus1());
    683     }
    684   } 
    685 
    686725  m_apcSlicePilot->initSlice( nalu.m_layerId );
     726  m_apcSlicePilot->setTLayer( nalu.m_temporalId );
    687727#else //SVC_EXTENSION
    688   m_apcSlicePilot->initSlice();
     728  m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice
     729                                // it is not associated with picture, sps or pps structures.
    689730#endif
    690731
     
    700741
    701742  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
    702 #if SVC_EXTENSION
    703   m_apcSlicePilot->setTLayer( nalu.m_temporalId );
    704 #endif
     743
    705744  Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N ||
    706745                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
     
    716755#endif
    717756
    718 #if SVC_EXTENSION
    719   setRefLayerParams(m_apcSlicePilot->getVPS());
     757  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager);
     758
     759#if SVC_EXTENSION
     760  const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId());
     761  assert (pps != 0);
     762  const TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId());
     763  assert (sps != 0);
     764  const TComVPS *vps = m_parameterSetManager.getVPS(sps->getVPSId());
     765  assert (vps != 0);
     766
     767  // Following check should go wherever the VPS is activated
     768  if( !vps->getBaseLayerAvailableFlag() )
     769  {
     770    assert( nalu.m_layerId != 0 );
     771    assert( vps->getNumAddLayerSets() > 0 );
     772
     773    if( m_commonDecoderParams->getTargetOutputLayerSetIdx() >= 0 )
     774    {
     775      UInt layerIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() );
     776      assert( layerIdx > vps->getVpsNumLayerSetsMinus1() );
     777    }
     778  } 
     779
     780  setRefLayerParams(vps);
    720781  m_apcSlicePilot->setNumMotionPredRefLayers(m_numMotionPredRefLayers);
    721782#endif
    722   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
    723783
    724784  // set POC for dependent slices in skipped pictures
     
    779839  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1
    780840  {
    781     Int iMaxPOClsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC();
     841#if !SVC_EXTENSION
     842    TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId());
     843    assert (pps != 0);
     844    TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId());
     845    assert (sps != 0);
     846#endif
     847    Int iMaxPOClsb = 1 << sps->getBitsForPOC();
    782848    m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) );
    783849  }
     
    892958    if( m_apcSlicePilot->getPocResetIdc() != 0 )
    893959    {
    894       if( m_apcSlicePilot->getVPS()->getVpsPocLsbAlignedFlag() )
     960      if( vps->getVpsPocLsbAlignedFlag() )
    895961      {
    896962        m_pocResettingFlag = true;
     
    9561022  numAffectedLayers = 1;
    9571023
    958   if( m_apcSlicePilot->getVPS()->getVpsPocLsbAlignedFlag() )
    959   {
    960     for( UInt j = 0; j < m_apcSlicePilot->getVPS()->getNumPredictedLayers(m_apcSlicePilot->getLayerId()); j++ )
    961     {
    962       affectedLayerList[j + 1] = m_apcSlicePilot->getVPS()->getPredictedLayerId(m_apcSlicePilot->getLayerId(), j);
    963     }
    964     numAffectedLayers = m_apcSlicePilot->getVPS()->getNumPredictedLayers(m_apcSlicePilot->getLayerId()) + 1;
     1024  if( vps->getVpsPocLsbAlignedFlag() )
     1025  {
     1026    for( UInt j = 0; j < vps->getNumPredictedLayers(m_apcSlicePilot->getLayerId()); j++ )
     1027    {
     1028      affectedLayerList[j + 1] = vps->getPredictedLayerId(m_apcSlicePilot->getLayerId(), j);
     1029    }
     1030    numAffectedLayers = vps->getNumPredictedLayers(m_apcSlicePilot->getLayerId()) + 1;
    9651031  }
    9661032
     
    11671233  m_apcSlicePilot->setAvailableForTMVPRefFlag( true );
    11681234
    1169   // actual decoding starts here
    1170   xActivateParameterSets();
    1171 
    11721235  // Initialize ILRP if needed, only for the current layer 
    11731236  // ILRP intialization should go along with activation of parameters sets,
     
    11751238  xInitILRP(m_apcSlicePilot);
    11761239
    1177   if (!m_apcSlicePilot->getDependentSliceSegmentFlag())
    1178   {
    1179     m_prevPOC = m_apcSlicePilot->getPOC();
    1180     curLayerId = m_layerId;
    1181     m_uiPrevLayerId = m_layerId;
    1182   }
    1183   m_bFirstSliceInSequence = false;
    1184   m_bFirstSliceInBitstream  = false;
    1185 
    11861240#else //SVC_EXTENSION
    11871241  //we should only get a different poc for a new picture (with CTU address==0)
     
    12051259    m_prevPOC = m_apcSlicePilot->getPOC();
    12061260  }
     1261#endif //SVC_EXTENSION
     1262
     1263  //detect lost reference picture and insert copy of earlier frame.
     1264  {
     1265    Int lostPoc;
     1266    while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0)
     1267    {
     1268      xCreateLostPicture(lostPoc-1);
     1269    }
     1270  }
     1271
     1272  if (!m_apcSlicePilot->getDependentSliceSegmentFlag())
     1273  {
     1274    m_prevPOC = m_apcSlicePilot->getPOC();
     1275#if SVC_EXTENSION
     1276    curLayerId = m_layerId;
     1277    m_uiPrevLayerId = m_layerId;
     1278#endif
     1279  }
    12071280
    12081281  // actual decoding starts here
    12091282  xActivateParameterSets();
    12101283
    1211   if (!m_apcSlicePilot->getDependentSliceSegmentFlag())
    1212   {
    1213     m_prevPOC = m_apcSlicePilot->getPOC();
    1214   }
    12151284  m_bFirstSliceInSequence = false;
    12161285  m_bFirstSliceInBitstream  = false;
    1217 #endif //SVC_EXTENSION
    1218 
    1219   //detect lost reference picture and insert copy of earlier frame.
    1220   Int lostPoc;
    1221   while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0)
    1222   {
    1223     xCreateLostPicture(lostPoc-1);
    1224   }
     1286
     1287  TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx);
     1288
     1289#if SVC_EXTENSION
    12251290  if (m_bFirstSliceInPicture)
    12261291  {
    1227 #if SVC_EXTENSION
    12281292#if AVC_BASE
    1229     if( m_layerId > 0 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getNonHEVCBaseLayerFlag() )
     1293    if( m_layerId > 0 && vps->getNonHEVCBaseLayerFlag() )
    12301294    {
    12311295      TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     
    13361400    if ( m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() && getNoClrasOutputFlag() )
    13371401    {
    1338       for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getMaxLayers(); i++)
     1402      for (UInt i = 0; i < vps->getMaxLayers(); i++)
    13391403      {
    13401404        m_ppcTDecTop[i]->setLayerInitializedFlag(false);
     
    13451409    xCheckLayerReset();
    13461410    xSetLayerInitializedFlag();
    1347 #endif
    1348 
    1349     // Buffer initialize for prediction.
    1350     m_cPrediction.initTempBuff(m_apcSlicePilot->getSPS()->getChromaFormatIdc());
    1351 #if ALIGNED_BUMPING
    1352     m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic);
    1353 #else
    1354     m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
    1355 #endif
    1356     //  Get a new picture buffer
    1357     xGetNewPicBuffer (m_apcSlicePilot, m_pcPic);
    1358 
     1411   
    13591412#if SVC_POC
    13601413    m_pcPic->setCurrAuFlag( true );
     
    13991452        else
    14001453        {
    1401           if( m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag())
     1454          if( vps->getBaseLayerInternalFlag())
    14021455          {
    14031456            /* When the picture with nuh_layer_id equal to 0 in an access unit is not an IDR picture
     
    14171470      and there is at least one other picture in the same access unit that is not an IRAP picture,
    14181471      the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */
    1419       if( m_baseLayerPicPresentFlag && m_baseLayerIrapFlag && !m_apcSlicePilot->isIRAP() && m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag() )
     1472      if( m_baseLayerPicPresentFlag && m_baseLayerIrapFlag && !m_apcSlicePilot->isIRAP() && vps->getBaseLayerInternalFlag() )
    14201473      {
    14211474        assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 );
     
    14251478      vps_base_layer_internal_flag is equal to 1 and there is at least one non-IDR picture in the same access unit,
    14261479      the value of poc_reset_idc shall be equal to 2 for all pictures in the access unit. */
    1427       if( m_baseLayerPicPresentFlag && m_baseLayerIdrFlag && !m_apcSlicePilot->isIDR() && m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag() )
     1480      if( m_baseLayerPicPresentFlag && m_baseLayerIdrFlag && !m_apcSlicePilot->isIDR() && vps->getBaseLayerInternalFlag() )
    14281481      {
    14291482        assert( m_apcSlicePilot->getPocResetIdc() == 2 );
     
    14431496    }
    14441497#endif
    1445 
    1446     Bool isField = false;
    1447     Bool isTopField = false;
    1448    
    1449     if(!m_SEIs.empty())
    1450     {
    1451       // Check if any new Picture Timing SEI has arrived
    1452       SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING);
    1453       if (pictureTimingSEIs.size()>0)
    1454       {
    1455         SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin());
    1456         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);
    1457         isTopField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 11);
    1458       }
    1459 
    1460 #if Q0189_TMVP_CONSTRAINTS
    1461       // Check if any new temporal motion vector prediction constraints SEI has arrived
    1462       SEIMessages seiTMVPConstrainsList = extractSeisByType (m_SEIs, SEI::TMVP_CONSTRAINTS);
    1463       if (seiTMVPConstrainsList.size() > 0)
    1464       {
    1465         assert ( m_pcPic->getTLayer() == 0 );  //this SEI can present only for AU with Tid equal to 0
    1466         SEITMVPConstrains* tmvpConstraintSEI = (SEITMVPConstrains*) *(seiTMVPConstrainsList.begin());
    1467         if ( tmvpConstraintSEI->prev_pics_not_used_flag == 1 )
    1468         {
    1469           //update all pics in the DPB such that they cannot be used for TMPV ref
    1470           TComList<TComPic*>::iterator  iterRefPic = m_cListPic.begin(); 
    1471           while( iterRefPic != m_cListPic.end() )
    1472           {
    1473             TComPic *refPic = *iterRefPic;
    1474             if( ( refPic->getLayerId() == m_pcPic->getLayerId() ) && refPic->getReconMark() )
    1475             {
    1476               for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--)
    1477               {
    1478                 TComSlice *refSlice = refPic->getSlice(i);
    1479                 refSlice->setAvailableForTMVPRefFlag( false );
    1480               }
    1481             }
    1482             iterRefPic++;
    1483           }
    1484         }
    1485       }
    1486 #endif
    1487     }
    1488    
    1489     //Set Field/Frame coding mode
    1490     m_pcPic->setField(isField);
    1491     m_pcPic->setTopField(isTopField);
    1492 
    1493     // transfer any SEI messages that have been received to the picture
    1494     m_pcPic->setSEIs(m_SEIs);
    1495     m_SEIs.clear();
    1496 
    1497     // Recursive structure
    1498     m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getChromaFormatIdc() );
    1499 #if SVC_EXTENSION
    1500     m_cCuDecoder.init   ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId );
    1501 #else
    1502     m_cCuDecoder.init   ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction );
    1503 #endif
    1504     m_cTrQuant.init     ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize());
    1505 
    1506     m_cSliceDecoder.create();
    1507   }
    1508   else
    1509   {
    1510     // Check if any new SEI has arrived
    1511     if(!m_SEIs.empty())
    1512     {
    1513       // Currently only decoding Unit SEI message occurring between VCL NALUs copied
    1514       SEIMessages &picSEI = m_pcPic->getSEIs();
    1515       SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
    1516       picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
    1517       deleteSEIs(m_SEIs);
    1518     }
    1519   }
    1520 
    1521   //  Set picture slice pointer
    1522   TComSlice*  pcSlice = m_apcSlicePilot;
    1523 
    1524   m_pcPic->getPicSym()->initTiles(pcSlice->getPPS());
    1525   m_pcPic->getPicSym()->initCtuTsRsAddrMaps();
    1526 
     1498  }
     1499#endif //SVC_EXTENSION
     1500   
    15271501  // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses.
    15281502  // Now, having set up the maps, convert them to the correct form.
     
    15341508    pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr()));
    15351509  }
    1536 
    1537   if (m_bFirstSliceInPicture)
    1538   {
    1539     if(m_pcPic->getNumAllocatedSlice() != 1)
    1540     {
    1541       m_pcPic->clearSliceBuffer();
    1542     }
    1543   }
    1544   else
    1545   {
    1546     m_pcPic->allocateNewSlice();
    1547   }
    1548   assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
    1549   m_apcSlicePilot = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx);
    1550   m_pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);
    1551 
     1510   
    15521511  m_pcPic->setTLayer(nalu.m_temporalId);
    15531512
     
    15771536        UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc);
    15781537#if AVC_BASE
    1579         if( refLayerId == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getNonHEVCBaseLayerFlag() )
     1538        if( refLayerId == 0 && m_parameterSetManager.getActiveVPS()->getNonHEVCBaseLayerFlag() )
    15801539        {         
    15811540          TComPic* pic = *m_ppcTDecTop[0]->getListPic()->begin();
     
    16191578
    16201579        // conformance check: when ScaledRefRegionWidthInSamplesY is equal to RefLayerRegionWidthInSamplesY, PhaseHorY shall be equal to 0, when ScaledRefRegionWidthInSamplesC is equal to RefLayerRegionWidthInSamplesC, PhaseHorC shall be equal to 0, when ScaledRefRegionHeightInSamplesY is equal to RefLayerRegionHeightInSamplesY, PhaseVerY shall be equal to 0, and when ScaledRefRegionHeightInSamplesC is equal to RefLayerRegionHeightInSamplesC, PhaseVerC shall be equal to 0.
    1621         Bool phaseSetPresentFlag;
    1622         Int phaseHorLuma, phaseVerLuma, phaseHorChroma, phaseVerChroma;
    1623         pcSlice->getPPS()->getResamplingPhase( refLayerId, phaseSetPresentFlag, phaseHorLuma, phaseVerLuma, phaseHorChroma, phaseVerChroma );
    1624 
    1625         assert( ( (widthEL  != widthBL)  || (phaseHorLuma == 0 && phaseHorChroma == 0) )
    1626              && ( (heightEL != heightBL) || (phaseVerLuma == 0 && phaseVerChroma == 0) ) );
     1580        const ResamplingPhase &resamplingPhase = pcSlice->getPPS()->getResamplingPhase( refLayerId );
     1581
     1582        assert( ( (widthEL  != widthBL)  || (resamplingPhase.phaseHorLuma == 0 && resamplingPhase.phaseHorChroma == 0) )
     1583             && ( (heightEL != heightBL) || (resamplingPhase.phaseVerLuma == 0 && resamplingPhase.phaseVerChroma == 0) ) );
    16271584
    16281585        g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
     
    16731630        UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
    16741631#if AVC_BASE
    1675         if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getNonHEVCBaseLayerFlag() )
     1632        if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && pcSlice->getVPS()->getNonHEVCBaseLayerFlag() )
    16761633        {
    16771634          pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() );
     
    17921749  if(pcSlice->getSPS()->getScalingListFlag())
    17931750  {
    1794     pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList()  );
    1795 
    1796 #if SVC_EXTENSION
    1797     if( pcSlice->getPPS()->getScalingListPresentFlag() || pcSlice->getPPS()->getInferScalingListFlag() )
     1751    TComScalingList scalingList;
     1752
     1753#if SVC_EXTENSION
     1754    if( pcSlice->getPPS()->getInferScalingListFlag() )
     1755    {
     1756      const TComPPS *refPps = m_ppcTDecTop[pcSlice->getPPS()->getScalingListRefLayerId()]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL );
     1757      scalingList = refPps->getScalingList();
     1758    }
     1759    else
     1760#endif
     1761    if(pcSlice->getPPS()->getScalingListPresentFlag())
     1762    {
     1763      scalingList = pcSlice->getPPS()->getScalingList();
     1764    }
     1765#if SVC_EXTENSION
     1766    else if( pcSlice->getSPS()->getInferScalingListFlag() )
     1767    {
     1768      const TComSPS *refSps = m_ppcTDecTop[pcSlice->getSPS()->getScalingListRefLayerId()]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL );
     1769      scalingList = refSps->getScalingList();
     1770    }
     1771#endif
     1772    else if (pcSlice->getSPS()->getScalingListPresentFlag())
     1773    {
     1774      scalingList = pcSlice->getSPS()->getScalingList();
     1775    }
     1776    else
     1777    {
     1778      scalingList.setDefaultScalingList();
     1779    }
     1780#if SVC_EXTENSION
     1781    m_cTrQuant.setScalingListDec(scalingList, pcSlice->getChromaFormatIdc());
    17981782#else
    1799     if(pcSlice->getPPS()->getScalingListPresentFlag())
    1800 #endif
    1801     {
    1802       pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList()  );
    1803     }
    1804 
    1805 #if SVC_EXTENSION
    1806     if( m_layerId == 0 || ( m_layerId > 0 && !pcSlice->getPPS()->getInferScalingListFlag() && !pcSlice->getSPS()->getInferScalingListFlag() ) )
    1807 #endif
    1808     if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag())
    1809     {
    1810       pcSlice->setDefaultScalingList();
    1811     }
    1812     m_cTrQuant.setScalingListDec(pcSlice->getScalingList(), pcSlice->getSPS()->getChromaFormatIdc());
     1783    m_cTrQuant.setScalingListDec(scalingList, pcSlice->getSPS()->getChromaFormatIdc());
     1784#endif
    18131785    m_cTrQuant.setUseScalingList(true);
    18141786  }
    18151787  else
    18161788  {
     1789#if SVC_EXTENSION
     1790    m_cTrQuant.setFlatScalingList(pcSlice->getChromaFormatIdc());
     1791#else
    18171792    m_cTrQuant.setFlatScalingList(pcSlice->getSPS()->getChromaFormatIdc());
     1793#endif
    18181794    m_cTrQuant.setUseScalingList(false);
    18191795  }
     
    18331809}
    18341810
    1835 Void TDecTop::xDecodeVPS()
     1811Void TDecTop::xDecodeVPS(const std::vector<UChar> *pNaluData)
    18361812{
    18371813  TComVPS* vps = new TComVPS();
    18381814
    18391815  m_cEntropyDecoder.decodeVPS( vps );
    1840   m_parameterSetManagerDecoder.storePrefetchedVPS(vps);
     1816  m_parameterSetManager.storeVPS(vps, pNaluData);
    18411817#if SVC_EXTENSION
    18421818  checkValueOfTargetOutputLayerSetIdx(vps);
    1843 #endif
    1844 }
    1845 
    1846 Void TDecTop::xDecodeSPS()
     1819
     1820#if AVC_BASE
     1821  if( vps->getNonHEVCBaseLayerFlag() )
     1822  {
     1823    if( !m_ppcTDecTop[0]->getBLReconFile()->good() )
     1824    {
     1825      printf( "Base layer YUV input reading error\n" );
     1826      exit(EXIT_FAILURE);
     1827    }       
     1828  }
     1829  else
     1830  {
     1831    TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic();
     1832    cListPic->clear();
     1833  }
     1834#endif
     1835
     1836  xDeriveSmallestLayerId(vps);
     1837#endif
     1838}
     1839
     1840Void TDecTop::xDecodeSPS(const std::vector<UChar> *pNaluData)
    18471841{
    18481842  TComSPS* sps = new TComSPS();
     
    18541848#endif
    18551849  m_cEntropyDecoder.decodeSPS( sps );
    1856   m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
     1850  m_parameterSetManager.storeSPS(sps, pNaluData);
    18571851}
    18581852
    18591853#if CGS_3D_ASYMLUT
    1860 Void TDecTop::xDecodePPS( TCom3DAsymLUT * pc3DAsymLUT )
     1854Void TDecTop::xDecodePPS( const std::vector<UChar> *pNaluData, TCom3DAsymLUT * pc3DAsymLUT )
    18611855#else
    1862 Void TDecTop::xDecodePPS()
     1856Void TDecTop::xDecodePPS(const std::vector<UChar> *pNaluData)
    18631857#endif
    18641858{
     
    18731867  m_cEntropyDecoder.decodePPS( pps );
    18741868#endif
    1875   m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
     1869  m_parameterSetManager.storePPS( pps, pNaluData);
    18761870}
    18771871
     
    18871881#endif
    18881882#if LAYERS_NOT_PRESENT_SEI
    1889     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream  );
     1883    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream  );
    18901884#else
    1891     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
     1885    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream );
    18921886#endif
    18931887  }
     
    18951889  {
    18961890#if LAYERS_NOT_PRESENT_SEI
    1897     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream  );
     1891    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream  );
    18981892#else
    1899     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
     1893    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream );
    19001894#endif
    19011895    SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
     
    19041898      SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
    19051899#if R0247_SEI_ACTIVE
    1906       getLayerDec(0)->m_parameterSetManagerDecoder.applyPrefetchedPS();
    19071900      assert(seiAps->activeSeqParameterSetId.size()>0);
    1908       if( !getLayerDec(0)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) )
     1901      if( !getLayerDec(0)->m_parameterSetManager.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) )
    19091902      {
    19101903        printf ("Warning SPS activation with Active parameter set SEI failed");
     
    19131906      {
    19141907        Int layerIdx = seiAps->layerSpsIdx[c];
    1915         getLayerDec(layerIdx)->m_parameterSetManagerDecoder.applyPrefetchedPS();
    1916         if( !getLayerDec(layerIdx)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[layerIdx] ) )
     1908        if( !getLayerDec(layerIdx)->m_parameterSetManager.activateSPSWithSEI( seiAps->activeSeqParameterSetId[layerIdx] ) )
    19171909        {
    19181910          printf ("Warning SPS activation with Active parameter set SEI failed");
     
    19201912      }
    19211913#else
    1922       m_parameterSetManagerDecoder.applyPrefetchedPS();
    19231914      assert(seiAps->activeSeqParameterSetId.size()>0);
    1924       if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] ))
     1915      if (! m_parameterSetManager.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] ))
    19251916      {
    19261917        printf ("Warning SPS activation with Active parameter set SEI failed");
     
    19541945      assert( nalu.m_layerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
    19551946#endif
    1956       xDecodeVPS();
     1947      xDecodeVPS(nalu.m_Bitstream->getFifo());
    19571948#if RExt__DECODER_DEBUG_BIT_STATISTICS
    19581949      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
    19591950#endif
    19601951#if SVC_EXTENSION
    1961       m_isLastNALWasEos = false;
    1962 #if AVC_BASE
    1963       if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getNonHEVCBaseLayerFlag() )
    1964       {
    1965         if( !m_ppcTDecTop[0]->getBLReconFile()->good() )
    1966         {
    1967           printf( "Base layer YUV input reading error\n" );
    1968           exit(EXIT_FAILURE);
    1969         }       
    1970       }
    1971       else
    1972       {
    1973         TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic();
    1974         cListPic->clear();
    1975       }
    1976 #endif
    1977       xDeriveSmallestLayerId(m_parameterSetManagerDecoder.getPrefetchedVPS(0));
     1952      m_isLastNALWasEos = false;   
    19781953#endif
    19791954      return false;
    19801955
    19811956    case NAL_UNIT_SPS:
    1982       xDecodeSPS();
     1957      xDecodeSPS(nalu.m_Bitstream->getFifo());
    19831958#if RExt__DECODER_DEBUG_BIT_STATISTICS
    19841959      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
     
    19871962
    19881963    case NAL_UNIT_PPS:
    1989       xDecodePPS(
    19901964#if CGS_3D_ASYMLUT
    1991         &m_c3DAsymLUTPPS
    1992 #endif
    1993         );
     1965      xDecodePPS( nalu.m_Bitstream->getFifo(), &m_c3DAsymLUTPPS );
     1966#else
     1967      xDecodePPS(nalu.m_Bitstream->getFifo());
     1968#endif
    19941969#if RExt__DECODER_DEBUG_BIT_STATISTICS
    19951970      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
     
    22052180Void TDecTop::xInitILRP(TComSlice *slice)
    22062181{
    2207   TComSPS* pcSPS = slice->getSPS();
     2182  const TComVPS* vps  = slice->getVPS();
     2183  const TComSPS* sps  = slice->getSPS();
     2184
    22082185  Int bitDepthY   = slice->getBitDepthY();
    22092186  Int bitDepthC   = slice->getBitDepthC();
    2210   Int picWidth    = slice->getPicWidthInLumaSamples();
    2211   Int picHeight   = slice->getPicHeightInLumaSamples();
    22122187
    22132188  if( m_layerId > 0 )
     
    22162191    g_bitDepth[CHANNEL_TYPE_LUMA]     = bitDepthY;
    22172192    g_bitDepth[CHANNEL_TYPE_CHROMA]   = bitDepthC;
    2218     g_uiMaxCUWidth  = pcSPS->getMaxCUWidth();
    2219     g_uiMaxCUHeight = pcSPS->getMaxCUHeight();
    2220     g_uiMaxCUDepth  = pcSPS->getMaxCUDepth();
    2221     g_uiAddCUDepth  = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() );
     2193    g_uiMaxCUWidth  = sps->getMaxCUWidth();
     2194    g_uiMaxCUHeight = sps->getMaxCUHeight();
     2195    g_uiMaxCUDepth  = sps->getMaxCUDepth();
     2196    g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );
    22222197
    22232198    Int  numReorderPics[MAX_TLAYER];
    2224     Window &conformanceWindow = slice->getConformanceWindow();
    2225     Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window();
    22262199
    22272200    for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++ )
     
    22302203      {
    22312204        assert( this->getLayerId() == 0 );
    2232         numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);
     2205        numReorderPics[temporalLayer] = sps->getNumReorderPics(temporalLayer);
    22332206      }
    22342207      else
    2235       {
    2236         TComVPS *vps = slice->getVPS();
     2208      {       
    22372209        // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.
    22382210        numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);
     
    22442216      for (Int j=0; j < m_numDirectRefLayers; j++)
    22452217      {
    2246 
    22472218        m_cIlpPic[j] = new  TComPic;
    22482219
    2249 #if AUXILIARY_PICTURES
    2250         m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
    2251 #else
    2252         m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
    2253 #endif
     2220        m_cIlpPic[j]->create(*vps, *sps, *slice->getPPS(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true, m_layerId);
     2221
    22542222        for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCtusInFrame(); i++)
    22552223        {
     
    22632231TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdx )
    22642232{
    2265   TComVPS* vps = m_parameterSetManagerDecoder.getActiveVPS();
     2233  const TComVPS* vps = m_parameterSetManager.getActiveVPS();
    22662234  if( vps->getNumDirectRefLayers( m_layerId ) <= 0 )
    22672235  {
     
    22722240}
    22732241
    2274 Void TDecTop::setRefLayerParams( TComVPS* vps )
     2242Void TDecTop::setRefLayerParams( const TComVPS* vps )
    22752243{
    22762244  for(UInt layerIdx = 0; layerIdx < m_numLayer; layerIdx++)
     
    24042372}
    24052373
    2406 Void TDecTop::markAllPicsAsNoCurrAu(TComVPS *vps)
     2374Void TDecTop::markAllPicsAsNoCurrAu( const TComVPS *vps )
    24072375{
    24082376  for(Int i = 0; i < MAX_LAYERS; i++)
    24092377  {
    2410     TComList<TComPic*>* listPic = this->getLayerDec(vps->getLayerIdInNuh(i))->getListPic();
     2378    TComList<TComPic*>* listPic = m_ppcTDecTop[vps->getLayerIdInNuh(i)]->getListPic();
    24112379    TComList<TComPic*>::iterator  iterPic = listPic->begin();
    24122380    while ( iterPic != listPic->end() )
     
    25702538}
    25712539
    2572 Void TDecTop::xSetSpatialEnhLayerFlag(TComSlice* slice, TComPic* pic)
    2573 {
    2574   for(UInt i = 0; i < slice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ )
    2575   {
    2576     const Window scalEL = slice->getPPS()->getScaledRefLayerWindowForLayer(slice->getVPS()->getRefLayerId(m_layerId, i));
    2577     const Window refEL = slice->getPPS()->getRefLayerWindowForLayer(slice->getVPS()->getRefLayerId(m_layerId, i));
     2540Void TDecTop::xSetSpatialEnhLayerFlag( const TComVPS &vps, const TComSPS &sps, const TComPPS &pps, TComPic* pic )
     2541{
     2542  for(UInt i = 0; i < vps.getNumDirectRefLayers( m_layerId ); i++ )
     2543  {
     2544    const Window scalEL = pps.getScaledRefLayerWindowForLayer(vps.getRefLayerId(m_layerId, i));
     2545    const Window refEL = pps.getRefLayerWindowForLayer(vps.getRefLayerId(m_layerId, i));
    25782546    Bool equalOffsets = scalEL.hasEqualOffset(refEL);
    2579     Bool zeroPhase = slice->getPPS()->hasZeroResamplingPhase(slice->getVPS()->getRefLayerId(m_layerId, i));
     2547    Bool zeroPhase = pps.hasZeroResamplingPhase(vps.getRefLayerId(m_layerId, i));
    25802548
    25812549    TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i );
    2582     //TComPic*                      pcPic = *(pcTDecTopBase->getListPic()->begin());
    25832550    TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec();
    25842551
    2585     UInt refLayerId = slice->getVPS()->getRefLayerId(m_layerId, i);
     2552    UInt refLayerId = vps.getRefLayerId(m_layerId, i);
    25862553    Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] );
    25872554
    2588     if( pcPicYuvRecBase->getWidth(COMPONENT_Y) == slice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight(COMPONENT_Y) == slice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase )
     2555    if( pcPicYuvRecBase->getWidth(COMPONENT_Y) == vps.getPicWidthInLumaSamples(&sps, m_layerId) && pcPicYuvRecBase->getHeight(COMPONENT_Y) == vps.getPicHeightInLumaSamples(&sps, m_layerId) && equalOffsets && zeroPhase )
    25892556    {
    25902557      pic->setEqualPictureSizeAndOffsetFlag( i, true );
     
    25932560    if( !pic->equalPictureSizeAndOffsetFlag(i) || !sameBitDepths
    25942561#if CGS_3D_ASYMLUT
    2595       || slice->getPPS()->getCGSFlag() > 0
     2562      || pps.getCGSFlag() > 0
    25962563#endif
    25972564#if LAYER_CTB
     
    26032570
    26042571      //only for scalable extension
    2605       assert( slice->getVPS()->getScalabilityMask( SCALABILITY_ID ) == true );
     2572      assert( vps.getScalabilityMask( SCALABILITY_ID ) == true );
    26062573    }
    26072574  }
Note: See TracChangeset for help on using the changeset viewer.