Ignore:
Timestamp:
4 Sep 2015, 21:28:58 (9 years ago)
Author:
tech
Message:

Clean-ups. HLS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-15.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp

    r1313 r1317  
    3535    \brief    decoder class
    3636*/
    37 
    3837#include "NALread.h"
    3938#include "TDecTop.h"
     
    127126  }
    128127}
    129 
    130 
    131 
    132128
    133129Void
     
    290286}
    291287
    292 
    293 #if !NH_3D_FIX_TICKET_101
    294 #if NH_3D_IV_MERGE
    295 Void
    296 CamParsCollector::copyCamParamForSlice( TComSlice* pcSlice )
    297 {
    298   if( m_bCamParsVaryOverTime )
    299   {
    300     pcSlice->setCamparaSlice( m_aaiCodedScale, m_aaiCodedOffset );
    301   }
    302 }
    303 #endif
    304 #endif
    305 
    306 
    307288Void
    308289CamParsCollector::xOutput( Int iPOC )
     
    351332TDecTop::TDecTop()
    352333  : m_iMaxRefPicNum(0)
     334#if !NH_MV
    353335  , m_associatedIRAPType(NAL_UNIT_INVALID)
    354   , m_pocCRA(0)
     336  , m_pocCRA(0) 
    355337  , m_pocRandomAccess(MAX_INT)
    356338  , m_cListPic()
    357 #if !NH_MV
    358339  , m_parameterSetManager()
    359340#endif
     
    373354  , m_cSAO()
    374355  , m_pcPic(NULL)
     356#if !NH_MV
    375357  , m_prevPOC(MAX_INT)
    376358  , m_prevTid0POC(0)
     
    383365  , m_isNoOutputPriorPics(false)
    384366  , m_craNoRaslOutputFlag(false)
     367#endif
    385368#if O0043_BEST_EFFORT_DECODING
    386369  , m_forceDecodeBitDepth(8)
    387370#endif
    388371  , m_pDecodedSEIOutputStream(NULL)
     372#if !NH_MV
    389373  , m_warningMessageSkipPicture(false)
     374#endif
    390375  , m_prefixSEINALUs()
     376{
     377#if !NH_MV
     378#if ENC_DEC_TRACE
     379  if (g_hTrace == NULL)
     380  {
     381    g_hTrace = fopen( "TraceDec.txt", "wb" );
     382  }
     383  g_bJustDoIt = g_bEncDecTraceDisable;
     384  g_nSymbolCounter = 0;
     385#endif
     386#endif
     387
     388#if NH_MV
     389  m_layerId                       = 0;
     390  m_viewId                        = 0;
     391
     392#if NH_3D
     393  m_viewIndex                     = 0;
     394  m_isDepth                       = false;
     395  m_pcCamParsCollector            = 0;
     396#endif
     397
     398  m_decodingProcess               = CLAUSE_8;
     399  m_targetOlsIdx                  = -1;
     400  m_smallestLayerId               = -1;
     401  m_isInOwnTargetDecLayerIdList   = 0;
     402  m_prevPicOrderCnt               = 0;
     403  m_pocDecrementedInDpbFlag       = NULL;
     404  m_firstPicInLayerDecodedFlag    = NULL;
     405  m_lastPresentPocResetIdc        = NULL;
     406
     407  m_prevIrapPoc                   = MIN_INT;
     408  m_prevIrapDecodingOrder         = MIN_INT;
     409  m_prevStsaDecOrder              = MIN_INT;
     410  m_prevStsaTemporalId            = MIN_INT;
     411#endif
     412}
     413
     414TDecTop::~TDecTop()
    391415{
    392416#if ENC_DEC_TRACE
    393417#if NH_MV
    394   if ( g_hTrace == NULL )
    395   {
    396 #endif
    397   if (g_hTrace == NULL)
    398   {
    399     g_hTrace = fopen( "TraceDec.txt", "wb" );
    400   }
    401   g_bJustDoIt = g_bEncDecTraceDisable;
    402   g_nSymbolCounter = 0;
    403 #if NH_MV
    404   }
    405 #endif
    406 #endif
    407 #if NH_MV
    408   m_isLastNALWasEos = false;
    409   m_layerId = 0;
    410   m_viewId = 0;
    411 #if NH_3D
    412   m_viewIndex = 0;
    413   m_isDepth = false;
    414   m_pcCamParsCollector = 0;
    415 #endif
    416 #if NH_MV
    417   m_targetOlsIdx = -1;
    418 #endif
    419 #endif
    420 
    421 }
    422 
    423 TDecTop::~TDecTop()
    424 {
    425 #if ENC_DEC_TRACE
    426 #if H_MV_ENC_DEC_TRAC_FIX
    427418  if (g_hTrace != stdout && g_hTrace != NULL)
     419  {
     420    fclose( g_hTrace );
     421    g_hTrace = NULL;
     422  }
    428423#else
    429424  if (g_hTrace != stdout)
    430 #endif
    431425  {
    432426    fclose( g_hTrace );
    433 #if H_MV_ENC_DEC_TRAC_FIX
    434     g_hTrace = NULL;
    435 #endif
    436   }
     427  }
     428#endif 
    437429#endif
    438430  while (!m_prefixSEINALUs.empty())
     
    452444Void TDecTop::destroy()
    453445{
     446
     447#if NH_MV
     448  m_cSAO.destroy();
     449  m_cLoopFilter.        destroy();
     450#endif
     451
    454452  m_cGopDecoder.destroy();
    455453
     
    474472}
    475473
     474#if !NH_MV
    476475Void TDecTop::deletePicBuffer ( )
    477476{
     477
    478478  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
    479479  Int iSize = Int( m_cListPic.size() );
     
    482482  {
    483483    TComPic* pcPic = *(iterPic++);
    484 #if NH_MV
    485     if( pcPic )
    486     {
    487 #endif
    488484    pcPic->destroy();
    489485
    490486    delete pcPic;
    491487    pcPic = NULL;
    492 #if NH_MV
    493     }
    494 #endif
    495488  }
    496489
     
    499492  m_cLoopFilter.        destroy();
    500493
    501 #if !NH_MV
    502494  // destroy ROM
    503495  destroyROM();
    504 #endif
    505496}
    506497
    507498Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer )
    508499{
    509 #if NH_MV
    510   if ( getLayerId() == 0 )
    511   { 
    512     m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer);     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    513   }
    514   else
    515   {
    516     //GTCIC
    517     //m_iMaxRefPicNum = pcSlice->getVPS()->getMaxDecPicBuffering(pcSlice->getTLayer());   
    518 #if H_MV_HLS7_GEN
    519     TComVPS* vps         = pcSlice->getVPS();
    520     TComDpbSize* dpbSize = vps->getDpbSize();
    521     Int lsIdx            = vps->olsIdxToLsIdx( getTargetOutputLayerSetIdx()); // Is this correct, seems to be missing in spec?
    522     Int layerIdx         = vps->getIdxInLayerSet     ( lsIdx, getLayerId() );
    523     Int subDpbIdx        = dpbSize->getSubDpbAssigned( lsIdx, layerIdx );
    524     m_iMaxRefPicNum      = dpbSize->getMaxVpsDecPicBufferingMinus1(getTargetOutputLayerSetIdx(), subDpbIdx , vps->getSubLayersVpsMaxMinus1( vps->getLayerIdInVps( getLayerId() ) ) + 1 ) + 1 ; 
    525 #endif   
    526   }
    527 #else
    528500  m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer);     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
    529 #endif
    530501  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
    531502  {
     
    547518    {
    548519      rpcPic->setOutputMark(false);
    549 #if NH_MV
    550       rpcPic->setPicOutputFlag(false);
    551 #endif
    552520      bBufferIsAvailable = true;
    553521      break;
     
    557525    {
    558526      rpcPic->setOutputMark(false);
    559 #if NH_MV
    560       rpcPic->setPicOutputFlag(false);
    561 #endif
    562527      rpcPic->setReconMark( false );
    563528      rpcPic->getPicYuvRec()->setBorderExtension( false );
     
    577542  rpcPic->create ( sps, pps, true);
    578543}
    579 #if NH_MV
    580 Void TDecTop::endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic, std::vector<Int>& targetDecLayerIdSet )
    581 #else
     544
    582545Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic)
    583 #endif
    584546{
    585547  if (!m_pcPic)
     
    599561  rpcListPic          = &m_cListPic;
    600562  m_cCuDecoder.destroy();
    601 #if NH_MV
    602   TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); 
    603   TComSlice::markCurrPic( pcPic );
    604 #endif
    605563  m_bFirstSliceInPicture  = true;
    606 
    607564  return;
    608565}
     
    623580    {
    624581      pcPicTmp->setOutputMark(false);
    625 #if NH_MV
    626       pcPicTmp->setPicOutputFlag(false);
    627 #endif
    628582    }
    629583  }
     
    673627  }
    674628}
    675 
    676 
     629#endif
     630
     631
     632#if NH_MV
     633Void TDecTop::activatePSsAndInitPicOrSlice( TComPic* newPic )
     634{
     635  if ( m_apcSlicePilot->getFirstSliceSegementInPicFlag() )
     636  {
     637    assert( newPic != NULL );
     638
     639#else
    677640Void TDecTop::xActivateParameterSets()
    678641{
    679642  if (m_bFirstSliceInPicture)
    680643  {
     644#endif
    681645    const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); // this is a temporary PPS object. Do not store this value
    682646    assert (pps != 0);
     
    690654    const TComVPS* vps = m_parameterSetManager.getVPS(sps->getVPSId());
    691655    assert (vps != 0);
    692     if (!m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP(), m_layerId ) )
     656    // TBD: check the condition on m_firstPicInLayerDecodedFlag
     657    if (!m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP() || !m_firstPicInLayerDecodedFlag[m_layerId] , m_layerId ) )
    693658#else
    694659    if (false == m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
     
    700665
    701666#if NH_MV
    702   // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0
    703   if ( vps->getVpsNumRepFormatsMinus1() == 0 )
    704   {
    705     //, it is a requirement of bitstream conformance that the value of update_rep_format_flag shall be equal to 0.
    706     assert( sps->getUpdateRepFormatFlag() == false );
    707   }
    708   sps->checkRpsMaxNumPics( vps, getLayerId() );
    709 
    710   // It is a requirement of bitstream conformance that, when the SPS is referred to by
    711   // any current picture that belongs to an independent non-base layer, the value of
    712   // MultiLayerExtSpsFlag derived from the SPS shall be equal to 0.
    713 
    714   if ( m_layerId > 0 && vps->getNumRefLayers( m_layerId ) == 0 )
    715   { 
    716     assert( sps->getMultiLayerExtSpsFlag() == 0 );
    717   }
     667    if ( decProcAnnexG() )
     668    {
     669      // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0
     670      if ( vps->getVpsNumRepFormatsMinus1() == 0 )
     671      {
     672        //, it is a requirement of bitstream conformance that the value of update_rep_format_flag shall be equal to 0.
     673        assert( sps->getUpdateRepFormatFlag() == false );
     674      }
     675      sps->checkRpsMaxNumPics( vps, getLayerId() );
     676
     677      // It is a requirement of bitstream conformance that, when the SPS is referred to by
     678      // any current picture that belongs to an independent non-base layer, the value of
     679      // MultiLayerExtSpsFlag derived from the SPS shall be equal to 0.
     680
     681      if ( m_layerId > 0 && vps->getNumRefLayers( m_layerId ) == 0 )
     682      { 
     683        assert( sps->getMultiLayerExtSpsFlag() == 0 );
     684      }
     685    }
    718686#endif
    719687
     
    734702
    735703    //  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.
     704#if !NH_MV
    736705    xGetNewPicBuffer (*(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer());
     706
    737707    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
    738 #if NH_MV
    739     m_apcSlicePilot->createInterLayerReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer0, m_refPicSetInterLayer1 );
     708#else
     709    m_pcPic = newPic;
    740710#endif
    741711
     
    752722
    753723#if NH_MV
     724    pSlice->setPic( m_pcPic );
    754725    vps=pSlice->getVPS(); 
    755726    // 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.
     
    803774  else
    804775  {
     776#if NH_MV
     777    assert( m_pcPic != NULL );
     778    assert( newPic  == NULL );
     779#endif
    805780    // make the slice-pilot a real slice, and set up the slice-pilot for the next slice
    806781    m_pcPic->allocateNewSlice();
     
    828803
    829804    // 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 }
     805    if(!m_SEIs.empty())
     806    {
     807      // Currently only decoding Unit SEI message occurring between VCL NALUs copied
     808      SEIMessages &picSEI = m_pcPic->getSEIs();
     809      SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
     810      picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
     811      deleteSEIs(m_SEIs);
     812    }
     813  }
     814}
     815
    840816Void TDecTop::xParsePrefixSEIsForUnknownVCLNal()
    841817{
     
    865841}
    866842
    867 
    868 #if NH_MV
    869 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag  )
    870 {
    871   assert( nalu.m_nuhLayerId == m_layerId );
     843#if !NH_MV
     844Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
     845{
     846  m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice
     847  // it is not associated with picture, sps or pps structures.
     848  if (m_bFirstSliceInPicture)
     849  {
    872850#else
    873 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
    874 {
    875 #endif
     851Void TDecTop::decodeSliceHeader(InputNALUnit &nalu )
     852{
     853  // Initialize entropy decoder
     854  m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder);
     855  m_cEntropyDecoder.setBitstream      (&(nalu.getBitstream()));
     856
     857  assert( nalu.m_nuhLayerId == m_layerId );   
    876858  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.
    878 
    879   if (m_bFirstSliceInPicture)
    880   {
     859  // it is not associated with picture, sps or pps structures.
     860  m_apcSlicePilot->setLayerId( nalu.m_nuhLayerId );
     861  m_cEntropyDecoder.decodeFirstSliceSegmentInPicFlag( m_apcSlicePilot );   
     862  if ( m_apcSlicePilot->getFirstSliceSegementInPicFlag() )
     863  {
     864#endif 
    881865    m_uiSliceIdx = 0;
    882866  }
     
    889873  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
    890874  Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N ||
    891                            m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
    892                            m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N  ||
    893                            m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N  ||
    894                            m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
     875    m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
     876    m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N  ||
     877    m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N  ||
     878    m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
    895879  m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag);
     880#if !NH_MV
    896881  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
     882#endif
    897883  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
    898 
     884#if NH_MV
     885  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager );
     886#else
    899887#if ENC_DEC_TRACE
    900888  const UInt64 originalSymbolCount = g_nSymbolCounter;
    901889#endif
     890    m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager, m_prevTid0POC);
     891#endif
    902892
    903893#if NH_MV
    904   m_apcSlicePilot->setRefPicSetInterLayer( & m_refPicSetInterLayer0, &m_refPicSetInterLayer1 );
    905   m_apcSlicePilot->setLayerId( nalu.m_nuhLayerId );
    906 #endif
    907 
    908   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager, m_prevTid0POC);
    909 
     894}
     895#else
    910896  // set POC for dependent slices in skipped pictures
    911897  if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped)
     
    915901
    916902  xUpdatePreviousTid0POC(m_apcSlicePilot);
    917 
    918903  m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA);
    919904  m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
    920 #if NH_MV 
    921   const TComVPS* vps     = m_apcSlicePilot->getVPS();
    922   Int layerId            = nalu.m_nuhLayerId;   
    923   setViewId   ( vps->getViewId   ( layerId )      ); 
    924 #if NH_3D
    925   setViewIndex( vps->getViewIndex( layerId )      ); 
    926   setIsDepth  ( vps->getDepthId  ( layerId ) == 1 ); 
    927   m_ivPicLists->setVPS( vps );
    928 #endif
    929 #endif
     905
    930906
    931907  //For inference of NoOutputOfPriorPicsFlag
    932908  if (m_apcSlicePilot->getRapPicFlag())
    933909  {
    934     if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) ||
     910      if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) ||
    935911        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) ||
    936912        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag()))
    937     {
    938       m_apcSlicePilot->setNoRaslOutputFlag(true);
    939     }
     913      {
     914        m_apcSlicePilot->setNoRaslOutputFlag(true);
     915      }
    940916    //the inference for NoOutputPriorPicsFlag
    941917    if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag())
     
    948924    else
    949925    {
    950       m_apcSlicePilot->setNoOutputPriorPicsFlag(false);
     926      m_apcSlicePilot->setNoOutputPriorPicsFlag(false); 
    951927    }
    952928
     
    974950    }
    975951  }
    976 
     952 
    977953  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1
    978954  {
     
    985961    xUpdatePreviousTid0POC(m_apcSlicePilot);
    986962  }
    987 #if NH_MV
    988     xCeckNoClrasOutput();
    989 #endif
    990963
    991964  // Skip pictures due to random access
    992 
    993 #if NH_MV
    994   if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay, vps))
    995 #else
    996965  if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
    997 #endif
    998966  {
    999967    m_prevSliceSkipped = true;
    1000968    m_skippedPOC = m_apcSlicePilot->getPOC();
    1001 #if NH_MV
    1002     sliceSkippedFlag = true;
    1003 #endif
    1004969    return false;
    1005970  }
     
    1009974    m_prevSliceSkipped = true;
    1010975    m_skippedPOC = m_apcSlicePilot->getPOC();
    1011 #if NH_MV
    1012     sliceSkippedFlag = true;
    1013 #endif
    1014976    return false;
    1015977  }
     
    1030992    {
    1031993      m_prevPOC = m_apcSlicePilot->getPOC();
     994
    1032995#if ENC_DEC_TRACE
    1033996      //rewind the trace counter since we didn't actually decode the slice
     
    10381001    m_prevPOC = m_apcSlicePilot->getPOC();
    10391002  }
    1040 #if NH_MV
    1041   if ( newLayerFlag )
    1042   {
    1043     return false;
    1044   }
    1045 #if ENC_DEC_TRACE
    1046 #if H_MV_ENC_DEC_TRAC
    1047   // parse remainder of SH
    1048    g_disableHLSTrace = false;
    1049 #endif
    1050 #endif
    1051 #endif
    1052 
    1053 #if NH_MV
    1054    // This part needs further testing !
    1055    if ( m_apcSlicePilot->getPocResetFlag() )
    1056    {   
    1057      xResetPocInPicBuffer();
    1058    }
    1059 
    1060    if ( m_apcSlicePilot->getTLayer() == 0 && m_apcSlicePilot->getEnableTMVPFlag() == 0 )
    1061   {
    1062     //update all pics in the DPB such that they cannot be used for TMPV ref
    1063     TComList<TComPic*>::iterator  iterRefPic = m_cListPic.begin(); 
    1064     while( iterRefPic != m_cListPic.end() )
    1065     {
    1066       TComPic *refPic = *iterRefPic;
    1067       if( ( refPic->getLayerId() == m_apcSlicePilot->getLayerId() ) && refPic->getReconMark() )
    1068       {
    1069         for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--)
    1070         {
    1071 
    1072           TComSlice *refSlice = refPic->getSlice(i);
    1073           refSlice->setAvailableForTMVPRefFlag( false );
    1074         }
    1075       }
    1076       iterRefPic++;
    1077     }
    1078   }
    1079   m_apcSlicePilot->setAvailableForTMVPRefFlag( true );
    1080 #endif
    10811003
    10821004  //detect lost reference picture and insert copy of earlier frame.
     
    10931015    m_prevPOC = m_apcSlicePilot->getPOC();
    10941016  }
    1095 
    10961017  // actual decoding starts here
    10971018  xActivateParameterSets();
     
    11031024  TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx);
    11041025
    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);
     1026#endif
    11161027
    11171028#if NH_MV
    1118   //Check Multiview Main profile constraint in G.11.1.1
    1119   //  When ViewOrderIdx[ i ] derived according to any active VPS is equal to 1
    1120   //  for the layer with nuh_layer_id equal to i in subBitstream,
    1121   //  inter_view_mv_vert_constraint_flag shall be equal to 1
    1122   //  in the sps_multilayer_extension( ) syntax structure in each active SPS for that layer.
    1123   if( pcSlice->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc()==Profile::MULTIVIEWMAIN
     1029Void TDecTop::decodeSliceSegment(InputNALUnit &nalu )
     1030{
     1031  TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx);
     1032
     1033  if ( m_pcPic->getHasGeneratedRefPics() )
     1034  {
     1035    if ( pcSlice->getFirstSliceSegementInPicFlag() )
     1036    {
     1037      std::cout << std:: setfill(' ')
     1038        << "Layer "  << std::setw(2) << m_pcPic->getLayerId()
     1039        << "   POC " << std::setw(4) << m_pcPic->getPOC()
     1040        << " Reference pictures missing. Skipping picture." << std::endl;
     1041    }
     1042  }
     1043  else
     1044  {
     1045    //Check Multiview Main profile constraint in G.11.1.1
     1046    //  When ViewOrderIdx[ i ] derived according to any active VPS is equal to 1
     1047    //  for the layer with nuh_layer_id equal to i in subBitstream,
     1048    //  inter_view_mv_vert_constraint_flag shall be equal to 1
     1049    //  in the sps_multilayer_extension( ) syntax structure in each active SPS for that layer.
     1050    if( pcSlice->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc()==Profile::MULTIVIEWMAIN
    11241051      &&
    11251052      pcSlice->getVPS()->getViewOrderIdx(pcSlice->getVPS()->getLayerIdInNuh(getLayerId()))==1
    1126      )
    1127   {
    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() );
     1053      )
     1054    {
     1055      assert( pcSlice->getSPS()->getInterViewMvVertConstraintFlag()==1 );
     1056    }
     1057
     1058    m_pcPic->setLayerId( nalu.m_nuhLayerId );
     1059    m_pcPic->setViewId ( getViewId() );
    11341060#if NH_3D
    1135   m_pcPic->setViewIndex( getViewIndex() );
    1136   m_pcPic->setIsDepth  ( getIsDepth  () );
    1137   pcSlice->setIvPicLists( m_ivPicLists );         
    1138 #endif
    1139 #endif
    1140 
    1141   if (!pcSlice->getDependentSliceSegmentFlag())
    1142   {
    1143     pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
    1144     // Set reference list
    1145 #if NH_MV   
    1146     std::vector< TComPic* > tempRefPicLists[2];
    1147     std::vector< Bool     > usedAsLongTerm [2];
    1148     Int       numPocTotalCurr;
    1149 
    1150     pcSlice->getTempRefPicLists( m_cListPic, m_refPicSetInterLayer0, m_refPicSetInterLayer1, tempRefPicLists, usedAsLongTerm, numPocTotalCurr);
    1151     pcSlice->setRefPicList     ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true );
     1061    m_pcPic->setViewIndex( getViewIndex() );
     1062    m_pcPic->setIsDepth  ( getIsDepth  () );
     1063    pcSlice->setIvPicLists( m_dpb );         
     1064#endif
     1065#endif
     1066   
     1067    // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses.
     1068    // Now, having set up the maps, convert them to the correct form.
     1069    pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) );
     1070    pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) );
     1071    if(!pcSlice->getDependentSliceSegmentFlag())
     1072    {
     1073      pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr()));
     1074      pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr()));
     1075    }
     1076
     1077    m_pcPic->setTLayer(nalu.m_temporalId);
     1078
     1079
     1080    if (!pcSlice->getDependentSliceSegmentFlag())
     1081    {
     1082#if !NH_MV
     1083      pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
     1084      // Set reference list
     1085      pcSlice->setRefPicList( m_cListPic, true );
     1086#else
     1087      if (pcSlice->getSliceType() != I_SLICE )
     1088      {
     1089        if( m_decProcPocAndRps == ANNEX_F )
     1090        {
     1091          pcSlice->f834decProcForRefPicListConst();
     1092        }
     1093        else if ( m_decProcPocAndRps == CLAUSE_8 )
     1094        {
     1095          pcSlice->cl834DecProcForRefPicListConst();
     1096        }
     1097        else
     1098        {
     1099          assert( false );
     1100        }
     1101      }
    11521102#if NH_3D_NBDV
    1153     pcSlice->setDefaultRefView();
     1103      pcSlice->setDefaultRefView();
    11541104#endif
    11551105#if NH_3D_ARP
    1156     pcSlice->setARPStepNum(m_ivPicLists);
    1157 #endif
    1158 #else
    1159     pcSlice->setRefPicList( m_cListPic, true );
    1160 #endif
    1161 
    1162 #if NH_3D
    1163     pcSlice->checkInCompPredRefLayers();
    1164 #if NH_3D_IV_MERGE
    1165 #if H_3D_FCO
    1166     //assert( !getIsDepth() );
    1167 #else
    1168     assert( !getIsDepth() || ( pcSlice->getTexturePic() != 0 ) );
    1169 #endif
    1170 #endif   
    1171 #endif
    1172 #if NH_MV
    1173     if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() )
    1174     {
    1175       TComPic* refPic = pcSlice->getRefPic(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
    1176 
    1177       assert ( refPic );
    1178       assert ( refPic->getPicSym()->getSlice(0)->getAvailableForTMVPRefFlag() == true );
    1179     }
    1180 #endif
    1181 
    1182     // For generalized B
    1183     // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
    1184     if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0)
    1185     {
    1186       Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0);
    1187       pcSlice->setNumRefIdx        ( REF_PIC_LIST_1, iNumRefIdx );
    1188 
    1189       for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++)
    1190       {
    1191         pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx);
    1192       }
    1193     }
    1194     if (!pcSlice->isIntra())
    1195     {
    1196       Bool bLowDelay = true;
    1197       Int  iCurrPOC  = pcSlice->getPOC();
    1198       Int iRefIdx = 0;
    1199 
    1200       for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++)
    1201       {
    1202         if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC )
     1106      pcSlice->setPocsInCurrRPSs();
     1107      pcSlice->setARPStepNum(m_dpb);
     1108#endif     
     1109#endif
     1110
     1111      // For generalized B
     1112      // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
     1113      if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0)
     1114      {
     1115        Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0);
     1116        pcSlice->setNumRefIdx        ( REF_PIC_LIST_1, iNumRefIdx );
     1117
     1118        for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++)
    12031119        {
    1204           bLowDelay = false;
     1120          pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx);
    12051121        }
    12061122      }
    1207       if (pcSlice->isInterB())
    1208       {
    1209         for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
     1123      if (!pcSlice->isIntra())
     1124      {
     1125        Bool bLowDelay = true;
     1126        Int  iCurrPOC  = pcSlice->getPOC();
     1127        Int iRefIdx = 0;
     1128
     1129        for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++)
    12101130        {
    1211           if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
     1131          if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC )
    12121132          {
    12131133            bLowDelay = false;
    12141134          }
    12151135        }
    1216       }
    1217 
    1218       pcSlice->setCheckLDC(bLowDelay);
    1219     }
    1220 
    1221     //---------------
    1222     pcSlice->setRefPOCList();
     1136        if (pcSlice->isInterB())
     1137        {
     1138          for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
     1139          {
     1140            if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
     1141            {
     1142              bLowDelay = false;
     1143            }
     1144          }
     1145        }
     1146
     1147        pcSlice->setCheckLDC(bLowDelay);
     1148      }
     1149
     1150      //---------------
     1151      pcSlice->setRefPOCList();
    12231152#if  NH_3D_TMVP
    1224     if(pcSlice->getLayerId())
    1225     {
    1226       pcSlice->generateAlterRefforTMVP();
    1227     }
    1228 #endif
    1229   }
    1230 
    1231   m_pcPic->setCurrSliceIdx(m_uiSliceIdx);
    1232   if(pcSlice->getSPS()->getScalingListFlag())
    1233   {
    1234     TComScalingList scalingList;
    1235     if(pcSlice->getPPS()->getScalingListPresentFlag())
    1236     {
    1237       scalingList = pcSlice->getPPS()->getScalingList();
    1238     }
    1239     else if (pcSlice->getSPS()->getScalingListPresentFlag())
    1240     {
    1241       scalingList = pcSlice->getSPS()->getScalingList();
     1153      if(pcSlice->getLayerId())
     1154      {
     1155        pcSlice->generateAlterRefforTMVP();
     1156      }
     1157#endif
     1158    }
     1159
     1160    m_pcPic->setCurrSliceIdx(m_uiSliceIdx);
     1161    if(pcSlice->getSPS()->getScalingListFlag())
     1162    {
     1163      TComScalingList scalingList;
     1164      if(pcSlice->getPPS()->getScalingListPresentFlag())
     1165      {
     1166        scalingList = pcSlice->getPPS()->getScalingList();
     1167      }
     1168      else if (pcSlice->getSPS()->getScalingListPresentFlag())
     1169      {
     1170        scalingList = pcSlice->getSPS()->getScalingList();
     1171      }
     1172      else
     1173      {
     1174        scalingList.setDefaultScalingList();
     1175      }
     1176      m_cTrQuant.setScalingListDec(scalingList);
     1177      m_cTrQuant.setUseScalingList(true);
    12421178    }
    12431179    else
    12441180    {
    1245       scalingList.setDefaultScalingList();
    1246     }
    1247     m_cTrQuant.setScalingListDec(scalingList);
    1248     m_cTrQuant.setUseScalingList(true);
    1249   }
    1250   else
    1251   {
    1252     const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] =
    1253     {
     1181      const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] =
     1182      {
    12541183        pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA),
    12551184        pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA)
    1256     };
    1257     m_cTrQuant.setFlatScalingList(maxLog2TrDynamicRange, pcSlice->getSPS()->getBitDepths());
    1258     m_cTrQuant.setUseScalingList(false);
    1259   }
    1260 
    1261 #if !NH_3D_FIX_TICKET_101
    1262 #if NH_3D_IV_MERGE
    1263 #if H_3D_FCO
    1264   if( !pcSlice->getIsDepth() && m_pcCamParsCollector )
     1185      };
     1186      m_cTrQuant.setFlatScalingList(maxLog2TrDynamicRange, pcSlice->getSPS()->getBitDepths());
     1187      m_cTrQuant.setUseScalingList(false);
     1188    }
     1189
     1190#if NH_3D
     1191    if ( decProcAnnexI() )
     1192    {
     1193      pcSlice->checkInCompPredRefLayers();
     1194    }
     1195#endif
     1196
     1197    //  Decode a picture
     1198    m_cGopDecoder.decompressSlice(&(nalu.getBitstream()), m_pcPic);
     1199
     1200#if NH_3D
     1201    if( m_pcCamParsCollector )
     1202    {
     1203      m_pcCamParsCollector->setSlice( pcSlice );
     1204    }
     1205#endif
     1206
     1207#if !NH_MV
     1208    m_bFirstSliceInPicture = false;
    12651209#else
    1266   if( pcSlice->getIsDepth() && m_pcCamParsCollector )
    1267 #endif
    1268   {
    1269     m_pcCamParsCollector->copyCamParamForSlice( pcSlice );
    1270   }
    1271 #endif
    1272 #endif
    1273   //  Decode a picture
    1274   m_cGopDecoder.decompressSlice(&(nalu.getBitstream()), m_pcPic);
    1275 
    1276 #if NH_3D
    1277   if( m_pcCamParsCollector )
    1278   {
    1279     m_pcCamParsCollector->setSlice( pcSlice );
    1280   }
    1281 #endif
    1282 
    1283   m_bFirstSliceInPicture = false;
     1210  }
     1211#endif
    12841212  m_uiSliceIdx++;
    12851213
     1214#if !NH_MV
    12861215  return false;
    1287 }
     1216#endif
     1217}
     1218
    12881219
    12891220Void TDecTop::xDecodeVPS(const std::vector<UChar> &naluData)
     
    13331264
    13341265#if NH_MV
    1335 Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag )
     1266Bool TDecTop::decodeNonVclNalu(InputNALUnit& nalu )
    13361267#else
    13371268Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
     
    13541285    case NAL_UNIT_VPS:
    13551286      xDecodeVPS(nalu.getBitstream().getFifo());
    1356 #if NH_MV
    1357       m_isLastNALWasEos = false;
    1358 #endif
    13591287      return false;
    13601288
     
    13731301
    13741302    case NAL_UNIT_SUFFIX_SEI:
    1375 #if NH_MV
    1376       if ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI )
    1377       {
    1378         assert( m_isLastNALWasEos == false );
    1379       }
    1380 #endif
    13811303      if (m_pcPic)
    13821304      {
     
    14101332    case NAL_UNIT_CODED_SLICE_RASL_R:
    14111333#if NH_MV
    1412       if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N ||
    1413           nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N ||
    1414           nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N ||
    1415           nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
    1416           nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N )
    1417       {
    1418         assert( m_isLastNALWasEos == false );
    1419       }
    1420       else
    1421       {
    1422         m_isLastNALWasEos = false;
    1423       }
    1424       return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag );
     1334      assert( false );
     1335      return 1;
    14251336#else
    14261337      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
     
    14291340
    14301341    case NAL_UNIT_EOS:
    1431 #if NH_MV
    1432       assert( m_isLastNALWasEos == false );
    1433       //Check layer id of the nalu. if it is not 0, give a warning message and just return without doing anything.
    1434       if (nalu.m_nuhLayerId > 0)
    1435       {
    1436         printf( "\nThis bitstream has EOS with non-zero layer id.\n" );
    1437         return false;
    1438       }
    1439       m_isLastNALWasEos = true;
    1440 #endif
     1342#if !NH_MV
    14411343      m_associatedIRAPType = NAL_UNIT_INVALID;
    14421344      m_pocCRA = 0;
     
    14451347      m_prevSliceSkipped = false;
    14461348      m_skippedPOC = 0;
     1349#endif
    14471350      return false;
    14481351
     
    14651368        fdReader.parseFillerData(&(nalu.getBitstream()),size);
    14661369        printf ("Note: found NAL_UNIT_FILLER_DATA with %u bytes payload.\n", size);
    1467 #if NH_MV
    1468       assert( m_isLastNALWasEos == false );
    1469 #endif
    14701370      return false;
    14711371      }
     
    15281428}
    15291429
     1430#if !NH_MV
    15301431/** Function for checking if picture should be skipped because of association with a previous BLA picture
    15311432 * \param iPOCLastDisplay POC of last picture displayed
     
    15581459 * access point there is no guarantee that the decoder will not crash.
    15591460 */
    1560 #if NH_MV
    1561 Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay, const TComVPS* vps)
    1562 #else
    15631461Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay )
    1564 #endif
    15651462{
    15661463  if (iSkipFrame)
     
    15691466    return true;
    15701467  }
    1571 #if NH_MV
    1572   else if ( !m_layerInitilizedFlag[ m_layerId ] ) // start of random access point, m_pocRandomAccess has not been set yet.
    1573 #else
    15741468  else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet.
    1575 #endif
    15761469  {
    15771470    if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
     
    15811474    {
    15821475
    1583 #if NH_MV
    1584       if ( xAllRefLayersInitilized( vps ) )
    1585       {
    1586         m_layerInitilizedFlag[ m_layerId ] = true;
    1587         m_pocRandomAccess = m_apcSlicePilot->getPOC();
    1588       }
    1589       else
    1590       {
    1591         return true;
    1592       }
    1593 #else
    15941476      // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
    15951477      m_pocRandomAccess = m_apcSlicePilot->getPOC();
    1596 #endif
    15971478    }
    15981479    else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    15991480    {
    1600 #if NH_MV
    1601       if ( xAllRefLayersInitilized( vps) )
    1602       {
    1603         m_layerInitilizedFlag[ m_layerId ] = true;
    1604         m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
    1605       }
    1606       else
    1607       {
    1608         return true;
    1609       }
    1610 #else
    16111481      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
    1612 #endif
    16131482    }
    16141483    else
    16151484    {
    1616 #if NH_MV
    1617       static Bool warningMessage[MAX_NUM_LAYERS];
    1618       static Bool warningInitFlag = false;
    1619      
    1620       if (!warningInitFlag)
    1621       {
    1622         for ( Int i = 0; i < MAX_NUM_LAYERS; i++)
    1623         {
    1624           warningMessage[i] = true;
    1625         }
    1626         warningInitFlag = true;
    1627       }
    1628 
    1629       if ( warningMessage[getLayerId()] )
    1630       {
    1631         printf("\nLayer%3d   No valid random access point. VCL NAL units of this layer are discarded until next layer initialization picture. ", getLayerId() );
    1632         warningMessage[m_layerId] = false;
    1633       }
    1634 #else
    16351485      if(!m_warningMessageSkipPicture)
    16361486      {
     
    16381488        m_warningMessageSkipPicture = true;
    16391489      }
    1640 #endif
    16411490      return true;
    16421491    }
     
    16491498  }
    16501499  // if we reach here, then the picture is not skipped.
    1651 #if NH_MV
    1652   return !m_layerInitilizedFlag[ getLayerId() ];
     1500  return false;
     1501}
     1502
    16531503#else
    1654   return false;
    1655 #endif
    1656 }
    1657 #if NH_MV
    1658 TComPic* TDecTop::getPic( Int poc )
    1659 {
    1660   xGetPic( m_layerId, poc );
    1661   TComList<TComPic*>* listPic = getListPic();
    1662   TComPic* pcPic = NULL;
    1663   for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++)
    1664   {
    1665     if( (*it)->getPOC() == poc )
    1666     {
    1667       pcPic = *it ;
    1668       break ;
    1669     }
    1670   }
    1671   return pcPic;
    1672 }
    1673 
    1674 TComPic* TDecTop::xGetPic( Int layerId, Int poc )
     1504
     1505Int TDecTop::preDecodePoc( Bool firstPicInLayerDecodedFlag, Bool isFstPicOfAllLayOfPocResetPer, Bool isPocResettingPicture )
     1506{
     1507  //Output of this process is PicOrderCntVal, the picture order count of the current picture.
     1508  //  Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and
     1509  //  motion vector prediction and for decoder conformance checking (see clause F.13.5).
     1510
     1511  //  Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal.
     1512
     1513  TComSlice* slice = m_apcSlicePilot;
     1514  const Int nuhLayerId   = slice->getLayerId();
     1515  const TComVPS*   vps   = slice->getVPS();
     1516  const TComSPS*   sps   = slice->getSPS();
     1517
     1518  Int pocDecrementedInDpbFlag = m_pocDecrementedInDpbFlag[ nuhLayerId ];
     1519
     1520  if ( isFstPicOfAllLayOfPocResetPer )
     1521  {
     1522    //  When the current picture is the first picture among all layers of a POC resetting period,
     1523    //  the variable PocDecrementedInDPBFlag[ i ] is set equal to 0 for each value of i in the range of 0 to 62, inclusive.
     1524    pocDecrementedInDpbFlag = false;
     1525  }
     1526
     1527  //  The variable pocResettingFlag is derived as follows:
     1528  Bool pocResettingFlag;
     1529  if ( isPocResettingPicture )
     1530  {
     1531    //-  If the current picture is a POC resetting picture, the following applies:   
     1532    if( vps->getVpsPocLsbAlignedFlag()  )
     1533    {
     1534      //  -  If vps_poc_lsb_aligned_flag is equal to 0, pocResettingFlag is set equal to 1.
     1535      pocResettingFlag = true;
     1536    }
     1537    else if ( pocDecrementedInDpbFlag )
     1538    {
     1539      //  -  Otherwise, if PocDecrementedInDPBFlag[ nuh_layer_id ] is equal to 1, pocResettingFlag is set equal to 0.
     1540      pocResettingFlag = false;
     1541    }
     1542    else
     1543    {
     1544      //  -  Otherwise, pocResettingFlag is set equal to 1.
     1545      pocResettingFlag = true;
     1546    }
     1547  }
     1548  else
     1549  {
     1550    //  -  Otherwise, pocResettingFlag is set equal to 0.
     1551    pocResettingFlag = false;
     1552  }
     1553
     1554  Int picOrderCntMsb;
     1555  Int picOrderCntVal;
     1556
     1557  //  Depending on pocResettingFlag, the following applies:
     1558  if ( pocResettingFlag )
     1559  {
     1560    //-  The PicOrderCntVal of the current picture is derived as follows:
     1561    if( slice->getPocResetIdc()  ==  1 )
     1562    {
     1563      picOrderCntVal = slice->getSlicePicOrderCntLsb();
     1564    }
     1565    else if (slice->getPocResetIdc()  ==  2 )
     1566    {
     1567      picOrderCntVal = 0;
     1568    }
     1569    else
     1570    {
     1571      picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 0, sps->getMaxPicOrderCntLsb() );
     1572      picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb();
     1573    }
     1574  }
     1575  else
     1576  {
     1577    //-  Otherwise (pocResettingFlag is equal to 0), the following applies:
     1578    //-  The PicOrderCntVal of the current picture is derived as follows:
     1579
     1580    if( slice->getPocMsbCycleValPresentFlag() )
     1581    {
     1582      picOrderCntMsb = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb();
     1583    }
     1584    else if( !firstPicInLayerDecodedFlag  ||
     1585      slice->getNalUnitType()  ==  NAL_UNIT_CODED_SLICE_IDR_N_LP || slice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_W_RADL )
     1586    {
     1587      picOrderCntMsb = 0; //     (F 62)
     1588    }   
     1589    else
     1590    {
     1591      Int prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 );
     1592      Int prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb;
     1593      picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() );
     1594    }
     1595    picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb();
     1596  } 
     1597  return picOrderCntVal;
     1598}
     1599
     1600Void TDecTop::inferPocResetPeriodId()
     1601{
     1602  // Infer PocResetPeriodId
     1603  // When not present, the value of poc_reset_period_id is inferred as follows:
     1604
     1605  if ( !m_apcSlicePilot->getHasPocResetPeriodIdPresent() )
     1606  {
     1607    if ( m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] != MIN_INT )
     1608    {
     1609      // - If the previous picture picA that has poc_reset_period_id present in the slice segment header is present in the same layer
     1610      //   of the bitstream as the current picture, the value of poc_reset_period_id is inferred to be equal to the value of the
     1611      //   poc_reset_period_id of picA.
     1612
     1613      m_apcSlicePilot->setPocResetPeriodId( m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] );
     1614    }
     1615    else
     1616    {
     1617      //- Otherwise, the value of poc_reset_period_id is inferred to be equal to 0.
     1618      m_apcSlicePilot->setPocResetPeriodId( 0 );
     1619    }
     1620  }
     1621  else
     1622  {
     1623    m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] = m_apcSlicePilot->getPocResetPeriodId(); 
     1624  }
     1625}
     1626
     1627
     1628Void TDecTop::decodePocAndRps( )
    16751629{
    1676   return m_ivPicLists->getPic( layerId, poc ) ;
    1677 }
    1678 
    1679 Void TDecTop::xResetPocInPicBuffer()
    1680 {
    1681   TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
    1682   while (iterPic != m_cListPic.end())
    1683   {
    1684     TComPic* pic = *(iterPic++);
    1685     if ( pic->getReconMark() )
    1686     {
    1687       for( Int i = 0; i < pic->getNumAllocatedSlice(); i++)
    1688       {
    1689         TComSlice* slice = pic->getSlice( i );
    1690         slice->setPOC ( slice->getPOC() - m_apcSlicePilot->getPocBeforeReset() );           
    1691       }         
    1692     }     
    1693   }
    1694 }
    1695 
    1696 Void TDecTop::xCeckNoClrasOutput()
    1697 {
    1698   // This part needs further testing!
    1699   if ( getLayerId() == 0 )
     1630  assert( m_uiSliceIdx == 0 );
     1631  Int nuhLayerId = m_pcPic->getLayerId();
     1632  if ( m_decProcPocAndRps == CLAUSE_8 )
     1633  {
     1634    // 8.1.3 Decoding process for a coded picture with nuh_layer_id equal to 0
     1635
     1636    // Variables and functions relating to picture order count are derived as
     1637    // specified in clause 8.3.1. This needs to be invoked only for the first slice
     1638    // segment of a picture.
     1639    x831DecProcForPicOrderCount( );
     1640
     1641    // The decoding process for RPS in clause 8.3.2 is invoked, wherein reference
     1642    // pictures may be marked as "unused for reference" or "used for long-term
     1643    // reference". This needs to be invoked only for the first slice segment of a
     1644    // picture.
     1645    x832DecProcForRefPicSet    (  false );
     1646  }
     1647  else if( m_decProcPocAndRps == ANNEX_F )
     1648  {
     1649    // F.8.1.3 Common decoding process for a coded picture
     1650
     1651    if (nuhLayerId == 0 )
     1652    {
     1653      // F.8.1.4 Decoding process for a coded picture with nuh_layer_id equal to
     1654      // --> Clause 8.1.3 is invoked with replacments of 8.3.1, 8.3.2, and 8.3.3 by F.8.3.1, 8.3.2, and 8.3.3
     1655
     1656      // Variables and functions relating to picture order count are derived as
     1657      // specified in clause 8.3.1. This needs to be invoked only for the first slice
     1658      // segment of a picture.
     1659      xF831DecProcForPicOrderCount( );
     1660
     1661      // The decoding process for RPS in clause 8.3.2 is invoked, wherein reference
     1662      // pictures may be marked as "unused for reference" or "used for long-term
     1663      // reference". This needs to be invoked only for the first slice segment of a
     1664      // picture.
     1665      xF832DecProcForRefPicSet( );
     1666    }
     1667    else
     1668    {
     1669      // F.8.1.5 Decoding process for starting the decoding of a coded picture with
     1670      // nuh_layer_id greater than 0
     1671
     1672      // Variables and functions relating to picture order count are derived in clause F.8.3.1.
     1673      // This needs to be invoked only for the first slice segment of a picture. It is a requirement
     1674      // of bitstream conformance that PicOrderCntVal of each picture in an access unit shall have the
     1675      // same value during and at the end of decoding of the access unit
     1676      xF831DecProcForPicOrderCount( );
     1677
     1678      // The decoding process for RPS in clause F.8.3.2 is invoked, wherein only reference pictures with
     1679      // nuh_layer_id equal to that of CurrPic may be marked as "unused for reference" or "used for
     1680      // long-term reference" and any picture with a different value of nuh_layer_id is not marked.
     1681      // This needs to be invoked only for the first slice segment of a picture.
     1682      xF832DecProcForRefPicSet( );
     1683    }
     1684  }
     1685  else
     1686  {
     1687    assert( false );
     1688  }
     1689}
     1690
     1691Void TDecTop::genUnavailableRefPics( )
     1692{
     1693  assert( m_uiSliceIdx == 0 );
     1694  Int nuhLayerId = m_pcPic->getLayerId();
     1695  if ( m_decProcPocAndRps == CLAUSE_8 )
     1696  {
     1697    // 8.1.3 Decoding process for a coded picture with nuh_layer_id equal to 0
     1698
     1699    if ( m_pcPic->isBla() || ( m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) )
     1700    {
     1701      // When the current picture is a BLA picture or is a CRA picture
     1702      // with NoRaslOutputFlag equal to 1, the decoding process for generating
     1703      // unavailable reference pictures specified in clause 8.3.3 is invoked,
     1704      // which needs to be invoked only for the first slice segment of a picture.
     1705      x8331GenDecProcForGenUnavilRefPics();       
     1706    }
     1707  }
     1708  else if( m_decProcPocAndRps == ANNEX_F )
     1709  {
     1710    // F.8.1.3 Common decoding process for a coded picture
     1711
     1712    if (nuhLayerId == 0 )
     1713    {
     1714      // F.8.1.4 Decoding process for a coded picture with nuh_layer_id equal to
     1715      // --> Clause 8.1.3 is invoked with replacments of 8.3.1, 8.3.2, and 8.3.3 by F.8.3.1, 8.3.2, and 8.3.3
     1716
     1717      if ( m_pcPic->isBla() || ( m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) )
     1718      {
     1719        // When the current picture is a BLA picture or is a CRA picture
     1720        // with NoRaslOutputFlag equal to 1, the decoding process for generating
     1721        // unavailable reference pictures specified in clause 8.3.3 is invoked,
     1722        // which needs to be invoked only for the first slice segment of a picture.
     1723        xF833DecProcForGenUnavRefPics();
     1724      }
     1725#if NH_MV_FIX_INIT_NUM_ACTIVE_REF_LAYER_PICS
     1726      TComDecodedRps* decRps = m_pcPic->getDecodedRps();
     1727      decRps->m_numActiveRefLayerPics0 = 0;
     1728      decRps->m_numActiveRefLayerPics1 = 0;     
     1729#endif
     1730    }
     1731    else
     1732    {
     1733      // F.8.1.5 Decoding process for starting the decoding of a coded picture with
     1734      // nuh_layer_id greater than 0
     1735
     1736      if ( !m_firstPicInLayerDecodedFlag[ nuhLayerId ] )
     1737      {
     1738        // When FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 0, the decoding process for generating
     1739        // unavailable reference pictures for pictures first in decoding order within a layer specified in
     1740        // clause F.8.1.7 is invoked, which needs to be invoked only for the first slice segment of a picture.
     1741        xF817DecProcForGenUnavRefPicForPicsFrstInDecOrderInLay();
     1742      }
     1743
     1744      if ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] && ( m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() ) )
     1745      {
     1746        // When FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 1 and the current picture is an IRAP
     1747        // picture with NoRaslOutputFlag equal to 1, the decoding process for generating unavailable reference
     1748        // pictures specified in clause F.8.3.3 is invoked, which needs to be invoked only for the first slice
     1749        // segment of a picture.
     1750        xF833DecProcForGenUnavRefPics();
     1751      }
     1752
     1753      if ( decProcAnnexG() )
     1754      {
     1755        // G.1.2 --> G.1.3
     1756        xG813DecProcForInterLayerRefPicSet();
     1757      }
     1758    }
     1759  }
     1760  else
     1761  {
     1762    assert( false );
     1763  }
     1764
     1765  xCheckUnavailableRefPics();     
     1766}
     1767Void TDecTop::executeLoopFilters( )
     1768{
     1769  assert( m_pcPic != NULL );
     1770  if ( !m_pcPic->getHasGeneratedRefPics() && !m_pcPic->getIsGenerated() )
     1771  {
     1772    m_cGopDecoder.filterPicture( m_pcPic );
     1773  }
     1774  m_cCuDecoder.destroy();
     1775}
     1776
     1777Void TDecTop::finalizePic()
     1778{
     1779  if( m_pcPic->isIrap() )
     1780  {
     1781    m_prevIrapPoc           = m_pcPic->getPOC();
     1782    m_prevIrapDecodingOrder = m_pcPic->getDecodingOrder();
     1783  }
     1784  if( m_pcPic->isStsa() )
     1785  {
     1786    m_prevStsaDecOrder      = m_pcPic->getDecodingOrder();
     1787    m_prevStsaTemporalId    = m_pcPic->getTemporalId()   ;
     1788  }
     1789}
     1790
     1791
     1792Void TDecTop::initFromActiveVps( const TComVPS* vps )
     1793{   
     1794  setViewId   ( vps->getViewId   ( getLayerId() )      ); 
     1795#if NH_3D
     1796  setViewIndex( vps->getViewIndex( getLayerId() )      ); 
     1797  setIsDepth  ( vps->getDepthId  ( getLayerId() ) == 1 ); 
     1798#endif
     1799
     1800  if ( !vps->getVpsExtensionFlag() )
     1801  {
     1802    m_decodingProcess = CLAUSE_8;
     1803    m_isInOwnTargetDecLayerIdList = ( getLayerId() ==  0 );
     1804  }
     1805  else
     1806  { 
     1807    if ( m_targetOlsIdx == -1 )
     1808    {
     1809      // Corresponds to specification by "External Means". (Should be set equal to 0, when no external means available. )
     1810      m_targetOlsIdx = vps->getVpsNumLayerSetsMinus1();
     1811    }
     1812
     1813    Int targetDecLayerSetIdx = vps->olsIdxToLsIdx( m_targetOlsIdx );
     1814
     1815    if ( targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1() && vps->getVpsBaseLayerInternalFlag() )
     1816    {
     1817      m_smallestLayerId = 0;
     1818    }
     1819    else if ( targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1() && !vps->getVpsBaseLayerInternalFlag() )
     1820    {
     1821      m_smallestLayerId = 0;
     1822    }
     1823    else if ( targetDecLayerSetIdx > vps->getVpsNumLayerSetsMinus1() && vps->getNumLayersInIdList( targetDecLayerSetIdx) == 1 )
     1824    {
     1825     
     1826      // m_smallestLayerId = 0;       
     1827      // For now don't do change of layer id here.
     1828      m_smallestLayerId = vps->getTargetDecLayerIdList( targetDecLayerSetIdx )[ 0 ];   
     1829    }
     1830    else
     1831    {
     1832      m_smallestLayerId = vps->getTargetDecLayerIdList( targetDecLayerSetIdx )[ 0 ];   
     1833    }
     1834
     1835
     1836    // Set profile
     1837    Int lsIdx = vps->olsIdxToLsIdx( m_targetOlsIdx );
     1838    Int lIdx = -1;
     1839    for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ) ; j++ )
     1840    {
     1841      if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() )
     1842      {       
     1843        lIdx = j;         
     1844        break;
     1845      }       
     1846    }
     1847    m_isInOwnTargetDecLayerIdList = (lIdx != -1);
     1848
     1849    if ( m_isInOwnTargetDecLayerIdList )
     1850    {
     1851      Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOlsIdx, lIdx ) )->getGeneralPTL()->getProfileIdc();
     1852      assert( profileIdc == 1 || profileIdc == 6 || profileIdc == 8 );
     1853
     1854      if (  profileIdc == 6 )
     1855      {
     1856        m_decodingProcess = ANNEX_G;
     1857      }
     1858      else if (profileIdc == 7 )
     1859      {
     1860        m_decodingProcess = ANNEX_H;
     1861      }
     1862      else if (profileIdc == 8 )
     1863      {
     1864        m_decodingProcess = ANNEX_I;
     1865      }
     1866    }
     1867  }
     1868}
     1869
     1870
     1871Bool TDecTop::getFirstSliceSegementInPicFlag()
     1872{
     1873  return m_apcSlicePilot->getFirstSliceSegementInPicFlag();
     1874}
     1875
     1876Void TDecTop::x831DecProcForPicOrderCount()
     1877{
     1878  /////////////////////////////////////////////////////
     1879  // 8.3.1 Decoding process for picture order count //
     1880  /////////////////////////////////////////////////////
     1881
     1882  //  Output of this process is PicOrderCntVal, the picture order count of the current picture.
     1883  //  Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and
     1884  //  motion vector prediction, and for decoder conformance checking (see clause C.5).
     1885  //  Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal.
     1886
     1887  const TComSlice* curSlice = m_pcPic->getSlice(0);
     1888
     1889  Int prevPicOrderCntLsb = MIN_INT;
     1890  Int prevPicOrderCntMsb = MIN_INT; 
     1891  if (!(m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() )  ) 
     1892  {
     1893    //  When the current picture is not an IRAP picture with NoRaslOutputFlag equal to 1,
     1894    //  the variables prevPicOrderCntLsb and prevPicOrderCntMsb are derived as follows:
     1895
     1896    //  -  Let prevTid0Pic be the previous picture in decoding order that has TemporalId equal to 0 and that is not a RASL picture,
     1897    //     a RADL picture or an SLNR picture.
     1898
     1899    //  -  The variable prevPicOrderCntLsb is set equal to slice_pic_order_cnt_lsb of prevTid0Pic.
     1900    prevPicOrderCntLsb = m_prevTid0PicSlicePicOrderCntLsb;
     1901
     1902    //  -  The variable prevPicOrderCntMsb is set equal to PicOrderCntMsb of prevTid0Pic.
     1903    prevPicOrderCntMsb = m_prevTid0PicPicOrderCntMsb;
     1904  }
     1905
     1906  //  The variable PicOrderCntMsb of the current picture is derived as follows: 
     1907 
     1908  Int slicePicOrderCntLsb = curSlice->getSlicePicOrderCntLsb();
     1909
     1910  Int picOrderCntMsb;
     1911
     1912  if (m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag()  )
     1913  {
     1914    //-  If the current picture is an IRAP picture with NoRaslOutputFlag equal to 1, PicOrderCntMsb is set equal to 0.
     1915    picOrderCntMsb = 0;
     1916  }
     1917  else
     1918  {
     1919    Int maxPicOrderCntLsb   = curSlice->getSPS()->getMaxPicOrderCntLsb();
     1920
     1921  //  -  Otherwise, PicOrderCntMsb is derived as follows:
     1922
     1923    if( ( slicePicOrderCntLsb < prevPicOrderCntLsb )  &&
     1924      ( ( prevPicOrderCntLsb - slicePicOrderCntLsb )  >=  ( maxPicOrderCntLsb / 2 ) ) )
     1925    {
     1926      picOrderCntMsb = prevPicOrderCntMsb + maxPicOrderCntLsb;   // (8 1)
     1927    }
     1928    else if( (slicePicOrderCntLsb > prevPicOrderCntLsb )  &&
     1929    ( ( slicePicOrderCntLsb - prevPicOrderCntLsb ) > ( maxPicOrderCntLsb / 2 ) ) )
     1930    {
     1931      picOrderCntMsb = prevPicOrderCntMsb - maxPicOrderCntLsb;
     1932    }
     1933    else
     1934    {
     1935      picOrderCntMsb = prevPicOrderCntMsb;
     1936    }
     1937  }
     1938 
     1939  //PicOrderCntVal is derived as follows:
     1940  Int picOrderCntVal = picOrderCntMsb + slicePicOrderCntLsb; //   (8 2)
     1941
     1942  //  NOTE 1 - All IDR pictures will have PicOrderCntVal equal to 0 since slice_pic_order_cnt_lsb is inferred to be 0 for IDR
     1943  //  pictures and prevPicOrderCntLsb and prevPicOrderCntMsb are both set equal to 0.
     1944
     1945  m_pcPic->getSlice(0)->setPOC( picOrderCntVal );
     1946
     1947  // Update prevTid0Pic
     1948  //   Let prevTid0Pic be the previous picture in decoding order that has TemporalId equal to 0 and that is not a RASL picture, a RADL picture or an SLNR picture.
     1949  if( curSlice->getTemporalId() == 0  && !m_pcPic->isRasl() && !m_pcPic->isRadl() && !m_pcPic->isSlnr() )
     1950  {
     1951    m_prevTid0PicSlicePicOrderCntLsb = slicePicOrderCntLsb;     
     1952    m_prevTid0PicPicOrderCntMsb      = picOrderCntMsb; 
     1953  }
     1954}
     1955
     1956Void TDecTop::xF831DecProcForPicOrderCount()
     1957{
     1958  //Output of this process is PicOrderCntVal, the picture order count of the current picture.
     1959  //  Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and
     1960  //  motion vector prediction and for decoder conformance checking (see clause F.13.5).
     1961
     1962  //  Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal.
     1963
     1964  const TComSlice* slice = m_pcPic->getSlice(0);
     1965  const Int nuhLayerId   = m_pcPic->getLayerId();
     1966  const TComVPS*   vps   = slice->getVPS();
     1967  const TComSPS*   sps   = slice->getSPS();
     1968  if ( m_pcPic->getIsFstPicOfAllLayOfPocResetPer() )
     1969  {
     1970    //  When the current picture is the first picture among all layers of a POC resetting period,
     1971    //  the variable PocDecrementedInDPBFlag[ i ] is set equal to 0 for each value of i in the range of 0 to 62, inclusive.
     1972    for (Int i = 0; i <= 62; i++)
     1973    {
     1974      m_pocDecrementedInDpbFlag[ i ] = 0;
     1975    }
     1976  }
     1977
     1978  //  The variable pocResettingFlag is derived as follows:
     1979  Bool pocResettingFlag;
     1980  if (m_pcPic->getIsPocResettingPic() )
     1981  {
     1982    //-  If the current picture is a POC resetting picture, the following applies:   
     1983    if( vps->getVpsPocLsbAlignedFlag()  )
     1984    {
     1985      //  -  If vps_poc_lsb_aligned_flag is equal to 0, pocResettingFlag is set equal to 1.
     1986      pocResettingFlag = true;
     1987    }
     1988    else if ( m_pocDecrementedInDpbFlag[ nuhLayerId ] )
     1989    {
     1990      //  -  Otherwise, if PocDecrementedInDPBFlag[ nuh_layer_id ] is equal to 1, pocResettingFlag is set equal to 0.
     1991      pocResettingFlag = false;
     1992    }
     1993    else
     1994    {
     1995      //  -  Otherwise, pocResettingFlag is set equal to 1.
     1996      pocResettingFlag = true;
     1997    }
     1998  }
     1999  else
     2000  {
     2001    //  -  Otherwise, pocResettingFlag is set equal to 0.
     2002    pocResettingFlag = false;
     2003  }
     2004
     2005  //  The list affectedLayerList is derived as follows:
     2006  std::vector<Int> affectedLayerList;
     2007  if (! vps->getVpsPocLsbAlignedFlag() )
     2008  {
     2009    //-  If vps_poc_lsb_aligned_flag is equal to 0, affectedLayerList consists of the nuh_layer_id of the current picture.
     2010    affectedLayerList.push_back( nuhLayerId );
     2011  }
     2012  else
     2013  {
     2014    //  -  Otherwise, affectedLayerList consists of the nuh_layer_id of the current picture and the nuh_layer_id values
     2015    //     equal to IdPredictedLayer[ currNuhLayerId ][ j ] for all values of j in the range of 0 to NumPredictedLayers[ currNuhLayerId ] - 1,
     2016    //     inclusive, where currNuhLayerId is the nuh_layer_id value of the current picture.
     2017    affectedLayerList.push_back( nuhLayerId );
     2018    Int currNuhLayerId = nuhLayerId;
     2019    for (Int j = 0; j <= vps->getNumPredictedLayers( currNuhLayerId )-1; j++ )
     2020    {
     2021      affectedLayerList.push_back( vps->getIdPredictedLayer(currNuhLayerId, j ) );
     2022    }
     2023  }
     2024 
     2025  Int picOrderCntMsb;
     2026  Int picOrderCntVal;
     2027
     2028  //  Depending on pocResettingFlag, the following applies:
     2029  if ( pocResettingFlag )
     2030  {
     2031    //-  If pocResettingFlag is equal to 1, the following applies:
     2032    if ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] )
     2033    {
     2034      //-  The variables pocMsbDelta, pocLsbDelta and DeltaPocVal are derived as follows:
     2035      Int pocMsbDelta;
     2036      Int pocLsbDelta;
     2037      Int deltaPocVal;       
     2038
     2039      {
     2040        Int pocLsbVal;
     2041        Int prevPicOrderCntLsb;
     2042        Int prevPicOrderCntMsb;
     2043
     2044        if( slice->getPocResetIdc() ==  3 )
     2045        {
     2046          pocLsbVal = slice->getPocLsbVal();
     2047        }     
     2048        else
     2049        {
     2050          pocLsbVal = slice->getSlicePicOrderCntLsb();
     2051        }
     2052
     2053        if( slice->getPocMsbCycleValPresentFlag() )
     2054        {
     2055          pocMsbDelta = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb();   // (F 60)
     2056        }     
     2057        else
     2058        {
     2059          prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 );
     2060          prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb;
     2061
     2062          pocMsbDelta = xGetCurrMsb( pocLsbVal, prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() );
     2063        }
     2064
     2065        if( slice->getPocResetIdc() == 2 ||  ( slice->getPocResetIdc() == 3  &&  slice->getFullPocResetFlag() ) )
     2066        {
     2067          pocLsbDelta = pocLsbVal;
     2068        }
     2069        else
     2070        {
     2071          pocLsbDelta = 0;
     2072        }
     2073        deltaPocVal = pocMsbDelta + pocLsbDelta;
     2074      }
     2075
     2076      //-  The PicOrderCntVal of each picture that has nuh_layer_id value nuhLayerId for which PocDecrementedInDPBFlag[ nuhLayerId ] is equal to 0
     2077      //   and that is equal to any value in affectedLayerList is decremented by DeltaPocVal.
     2078      for (Int i = 0; i < (Int) affectedLayerList.size(); i++ )
     2079      {
     2080        if ( !m_pocDecrementedInDpbFlag[ affectedLayerList[i] ] )
     2081        {
     2082          m_dpb->decrementPocsInSubDpb( affectedLayerList[i], deltaPocVal );
     2083        }
     2084      }
     2085
     2086      //-  PocDecrementedInDPBFlag[ nuhLayerId ] is set equal to 1 for each value of nuhLayerId included in affectedLayerList.
     2087      for (Int i = 0; i < (Int) affectedLayerList.size(); i++ )
     2088      {
     2089        m_pocDecrementedInDpbFlag[ affectedLayerList[i] ] = true;
     2090      }
     2091    }
     2092
     2093    //-  The PicOrderCntVal of the current picture is derived as follows:
     2094    if( slice->getPocResetIdc()  ==  1 )
     2095    {
     2096      picOrderCntVal = slice->getSlicePicOrderCntLsb();
     2097    }
     2098    else if (slice->getPocResetIdc()  ==  2 )
     2099    {
     2100      picOrderCntVal = 0;
     2101    }
     2102    else
     2103    {
     2104       picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 0, sps->getMaxPicOrderCntLsb() );
     2105       picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb();
     2106    }
     2107  }
     2108  else
     2109  {
     2110    //-  Otherwise (pocResettingFlag is equal to 0), the following applies:
     2111    //-  The PicOrderCntVal of the current picture is derived as follows:
     2112   
     2113    if( slice->getPocMsbCycleValPresentFlag() )
     2114    {
     2115      picOrderCntMsb = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb();
     2116    }
     2117    else if( !m_firstPicInLayerDecodedFlag[ nuhLayerId ]  ||
     2118    slice->getNalUnitType()  ==  NAL_UNIT_CODED_SLICE_IDR_N_LP || slice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_W_RADL )
     2119    {
     2120      picOrderCntMsb = 0; //     (F 62)
     2121    }   
     2122    else
     2123    {
     2124        Int prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 );
     2125        Int prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb;
     2126        picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() );
     2127    }
     2128    picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb();
     2129  }
     2130 
     2131  m_pcPic->getSlice(0)->setPOC( picOrderCntVal );
     2132 
     2133  for (Int lId = 0; lId < (Int) affectedLayerList.size(); lId++ )
     2134  { 
     2135    //  The value of PrevPicOrderCnt[ lId ] for each of the lId values included in affectedLayerList is derived as follows:
     2136
     2137    if (!m_pcPic->isRasl() && !m_pcPic->isRadl() && !m_pcPic->isSlnr() && slice->getTemporalId() == 0 && !slice->getDiscardableFlag() )
     2138    {
     2139      //-  If the current picture is not a RASL picture, a RADL picture or a sub-layer non-reference picture, and the current picture
     2140      //   has TemporalId equal to 0 and discardable_flag equal to 0, PrevPicOrderCnt[ lId ] is set equal to PicOrderCntVal.
     2141      m_prevPicOrderCnt = picOrderCntVal;
     2142    }
     2143    else if ( slice->getPocResetIdc() == 3 &&  (
     2144      ( !m_firstPicInLayerDecodedFlag[ nuhLayerId ]) ||
     2145      ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] && m_pcPic->getIsPocResettingPic() )
     2146      ) )
     2147    {
     2148      //  -  Otherwise, when poc_reset_idc is equal to 3 and one of the following conditions is true, PrevPicOrderCnt[ lId ] is set equal to ( full_poc_reset_flag ? 0 : poc_lsb_val ):
     2149      //     -  FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 0.
     2150      //     -  FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 1 and the current picture is a POC resetting picture.
     2151      m_prevPicOrderCnt = ( slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal() );
     2152    }
     2153  }
     2154}
     2155
     2156Int TDecTop::xGetCurrMsb( Int cl, Int pl, Int pm, Int ml )
     2157{
     2158  Int currMsb;
     2159  if ((pl - cl) >= (ml/ 2))
     2160  {
     2161    currMsb = pm + ml;
     2162  }
     2163  else if ( (cl - pl) > (ml / 2))
     2164  {
     2165    currMsb = pm - ml;
     2166  }
     2167  else
     2168  {
     2169    currMsb = pm;
     2170  }
     2171
     2172  return currMsb; 
     2173}   
     2174
     2175
     2176
     2177Void TDecTop::x832DecProcForRefPicSet(  Bool annexFModifications )
     2178{
     2179  ///////////////////////////////////////////////////////////////////////////////////////
     2180  // 8.3.2 8.3.2 Decoding process for reference picture set
     2181  ///////////////////////////////////////////////////////////////////////////////////////
     2182
     2183  TComSlice* slice = m_pcPic->getSlice( 0 );
     2184  const TComSPS* sps = slice->getSPS();
     2185  //  This process is invoked once per picture, after decoding of a slice header but prior to the decoding of any coding unit and prior
     2186  //  to the decoding process for reference picture list construction for the slice as specified in clause 8.3.3.
     2187  //  This process may result in one or more reference pictures in the DPB being marked as "unused for reference" or
     2188  //  "used for long-term reference".
     2189
     2190  // The variable currPicLayerId is set equal to nuh_layer_id of the current picture.
     2191  Int currPicLayerId = m_pcPic->getLayerId();
     2192  Int picOrderCntVal = m_pcPic->getPOC();
     2193
     2194  if (m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag()  )
     2195  {     
     2196    // When the current picture is an IRAP picture with NoRaslOutputFlag equal to 1,
     2197    // all reference pictures with nuh_layer_id equal to currPicLayerId currently in the
     2198    // DPB (if any) are marked as "unused for reference".
     2199    m_dpb->markSubDpbAsUnusedForReference( currPicLayerId );
     2200  }
     2201  // Short-term reference pictures are identified by their PicOrderCntVal values. Long-term reference pictures are identified either by
     2202  // their PicOrderCntVal values or their slice_pic_order_cnt_lsb values.
     2203
     2204  // Five lists of picture order count values are constructed to derive the RPS. These five lists are PocStCurrBefore,
     2205  // PocStCurrAfter, PocStFoll, PocLtCurr and PocLtFoll, with NumPocStCurrBefore, NumPocStCurrAfter, NumPocStFoll,
     2206  // NumPocLtCurr and NumPocLtFoll number of elements, respectively. The five lists and the five variables are derived as follows:
     2207 
     2208  TComDecodedRps* decRps = m_pcPic->getDecodedRps();
     2209
     2210  std::vector<Int>& pocStCurrBefore = decRps->m_pocStCurrBefore;
     2211  std::vector<Int>& pocStCurrAfter  = decRps->m_pocStCurrAfter;
     2212  std::vector<Int>& pocStFoll       = decRps->m_pocStFoll;
     2213  std::vector<Int>& pocLtCurr       = decRps->m_pocLtCurr;
     2214  std::vector<Int>& pocLtFoll       = decRps->m_pocLtFoll;
     2215
     2216  Int& numPocStCurrBefore = decRps->m_numPocStCurrBefore;
     2217  Int& numPocStCurrAfter  = decRps->m_numPocStCurrAfter;
     2218  Int& numPocStFoll       = decRps->m_numPocStFoll;
     2219  Int& numPocLtCurr       = decRps->m_numPocLtCurr;
     2220  Int& numPocLtFoll       = decRps->m_numPocLtFoll;   
     2221
     2222  std::vector<Int> currDeltaPocMsbPresentFlag, follDeltaPocMsbPresentFlag;
     2223
     2224  if (m_pcPic->isIdr() )
     2225  {
     2226    // - If the current picture is an IDR picture, PocStCurrBefore, PocStCurrAfter, PocStFoll,
     2227    //   PocLtCurr and PocLtFoll are all set to be empty, and NumPocStCurrBefore,
     2228    //   NumPocStCurrAfter, NumPocStFoll, NumPocLtCurr and NumPocLtFoll are all set equal to 0.
     2229
     2230    pocStCurrBefore.clear();
     2231    pocStCurrAfter .clear();
     2232    pocStFoll      .clear();
     2233    pocLtCurr      .clear();
     2234    pocLtFoll      .clear();
     2235    numPocStCurrBefore = 0;
     2236    numPocStCurrAfter  = 0;
     2237    numPocStFoll       = 0;
     2238    numPocLtCurr       = 0;
     2239    numPocLtFoll       = 0;
     2240  }
     2241  else
     2242  {
     2243    const TComStRefPicSet* stRps  = slice->getStRps( slice->getCurrRpsIdx() );
     2244    // -  Otherwise, the following applies:
     2245
     2246    Int j = 0;
     2247    Int k = 0;
     2248    for( Int i = 0; i < stRps->getNumNegativePicsVar() ; i++ )
     2249    {
     2250      if( stRps->getUsedByCurrPicS0Var( i  ) )
     2251      {
     2252        pocStCurrBefore.push_back( picOrderCntVal + stRps->getDeltaPocS0Var( i ) ); j++;
     2253      }
     2254      else
     2255      {
     2256        pocStFoll      .push_back( picOrderCntVal + stRps->getDeltaPocS0Var( i ) ); k++;
     2257      }
     2258    }
     2259    numPocStCurrBefore = j;   
     2260
     2261    j = 0;
     2262    for (Int i = 0; i < stRps->getNumPositivePicsVar(); i++ )
     2263    {
     2264      if (stRps->getUsedByCurrPicS1Var( i ) )
     2265      {
     2266        pocStCurrAfter.push_back( picOrderCntVal + stRps->getDeltaPocS1Var( i ) ); j++;
     2267      }
     2268      else
     2269      {
     2270        pocStFoll     .push_back( picOrderCntVal + stRps->getDeltaPocS1Var( i ) ); k++;
     2271      }
     2272    }
     2273    numPocStCurrAfter = j;
     2274    numPocStFoll = k; //    (8 5)
     2275
     2276
     2277    j = 0;
     2278    k = 0;
     2279    for( Int i = 0; i < slice->getNumLongTermSps( ) + slice->getNumLongTermPics(); i++ )
     2280    {
     2281      Int pocLt = slice->getPocLsbLtVar( i );
     2282      if( slice->getDeltaPocMsbPresentFlag( i ) )
     2283      {
     2284        pocLt  +=  picOrderCntVal - slice->getDeltaPocMsbCycleLtVar( i ) * sps->getMaxPicOrderCntLsb() -
     2285          ( picOrderCntVal & ( sps->getMaxPicOrderCntLsb() - 1 ) );
     2286      }
     2287
     2288      if( slice->getUsedByCurrPicLtVar(i))
     2289      {
     2290        pocLtCurr.push_back( pocLt );
     2291        currDeltaPocMsbPresentFlag.push_back( slice->getDeltaPocMsbPresentFlag( i ) ); j++;
     2292      }
     2293      else
     2294      {
     2295        pocLtFoll.push_back( pocLt );
     2296        follDeltaPocMsbPresentFlag.push_back( slice->getDeltaPocMsbPresentFlag( i ) ); k++;
     2297      }
     2298    }
     2299    numPocLtCurr = j;
     2300    numPocLtFoll = k;
     2301  }
     2302
     2303  assert(numPocStCurrAfter  == pocStCurrAfter   .size() );
     2304  assert(numPocStCurrBefore == pocStCurrBefore  .size() );
     2305  assert(numPocStFoll       == pocStFoll        .size() ); 
     2306  assert(numPocLtCurr       == pocLtCurr        .size() ); 
     2307  assert(numPocLtFoll       == pocLtFoll        .size() );
     2308
     2309  // where PicOrderCntVal is the picture order count of the current picture as specified in clause 8.3.1.
     2310
     2311  //   NOTE 2 - A value of CurrRpsIdx in the range of 0 to num_short_term_ref_pic_sets - 1, inclusive,
     2312  //   indicates that a candidate short-term RPS from the active SPS for the current layer is being used,
     2313  //   where CurrRpsIdx is the index of the candidate short-term RPS into the list of candidate short-term RPSs signalled
     2314  //   in the active SPS for the current layer. CurrRpsIdx equal to num_short_term_ref_pic_sets indicates that
     2315  //   the short-term RPS of the current picture is directly signalled in the slice header.
     2316
     2317  for (Int i = 0; i <= numPocLtCurr - 1; i++  )
     2318  {
     2319      // For each i in the range of 0 to NumPocLtCurr - 1, inclusive, when CurrDeltaPocMsbPresentFlag[ i ] is equal to 1,
     2320      // it is a requirement of bitstream conformance that the following conditions apply:
     2321    if ( currDeltaPocMsbPresentFlag[i] )
     2322    {
     2323      // -  There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive,
     2324      //    for which PocLtCurr[ i ] is equal to PocStCurrBefore[ j ].
     2325      for (Int j = 0; j <= numPocStCurrBefore - 1; j++ )
     2326      {
     2327        assert(!( pocLtCurr[ i ] == pocStCurrBefore[ j ] ) );
     2328      }
     2329
     2330      // -  There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive,
     2331      //    for which PocLtCurr[ i ] is equal to PocStCurrAfter[ j ].
     2332      for (Int j = 0; j <= numPocStCurrAfter - 1; j++ )
     2333      {
     2334        assert(!( pocLtCurr[ i ] == pocStCurrAfter[ j ] ) );
     2335      }
     2336
     2337      // -  There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive,
     2338      //    for which PocLtCurr[ i ] is equal to PocStFoll[ j ].
     2339      for (Int j = 0; j <= numPocStFoll - 1; j++ )
     2340      {
     2341        assert(!( pocLtCurr[ i ] == pocStFoll[ j ] ) );
     2342      }
     2343
     2344      // -  There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive,
     2345      //    where j is not equal to i, for which PocLtCurr[ i ] is equal to PocLtCurr[ j ].
     2346      for (Int j = 0; j <= numPocLtCurr - 1; j++ )
     2347      {
     2348        if ( i != j )
     2349        {       
     2350          assert(!( pocLtCurr[ i ] == pocLtCurr[ j ] ) );
     2351        }
     2352      }
     2353    }
     2354  }
     2355
     2356  for (Int i = 0; i <= numPocLtFoll - 1; i++  )
     2357  {
     2358    // For each i in the range of 0 to NumPocLtFoll - 1, inclusive, when FollDeltaPocMsbPresentFlag[ i ] is equal to 1,
     2359    // it is a requirement of bitstream conformance that the following conditions apply:
     2360    if ( follDeltaPocMsbPresentFlag[i] )
     2361    {
     2362      // -  There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive,
     2363      //    for which PocLtFoll[ i ] is equal to PocStCurrBefore[ j ].
     2364      for (Int j = 0; j <= numPocStCurrBefore - 1; j++ )
     2365      {
     2366        assert(!( pocLtFoll[ i ] == pocStCurrBefore[ j ] ) );
     2367      }
     2368
     2369      // -  There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive,
     2370      //    for which PocLtFoll[ i ] is equal to PocStCurrAfter[ j ].
     2371      for (Int j = 0; j <= numPocStCurrAfter - 1; j++ )
     2372      {
     2373        assert(!( pocLtFoll[ i ] == pocStCurrAfter[ j ] ) );
     2374      }
     2375
     2376      // -  There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive,
     2377      //    for which PocLtFoll[ i ] is equal to PocStFoll[ j ].
     2378      for (Int j = 0; j <= numPocStFoll - 1; j++ )
     2379      {
     2380        assert(!( pocLtFoll[ i ] == pocStFoll[ j ] ) );
     2381      }
     2382
     2383      // -  There shall be no j in the range of 0 to NumPocLtFoll - 1, inclusive,
     2384      //    where j is not equal to i, for which PocLtFoll[ i ] is equal to PocLtFoll[ j ].
     2385      for (Int j = 0; j <= numPocLtFoll - 1; j++ )
     2386      {
     2387        if (j != i)
     2388        {
     2389          assert(!( pocLtFoll[ i ] == pocLtFoll[ j ] ) );
     2390        }
     2391      }
     2392
     2393      // -  There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive,
     2394      //    for which PocLtFoll[ i ] is equal to PocLtCurr[ j ].
     2395      for (Int j = 0; j <= numPocLtCurr - 1; j++ )
     2396      {
     2397        assert(!( pocLtFoll[ i ] == pocLtCurr[ j ] ) );
     2398      }
     2399    }
     2400  }
     2401
     2402  Int maxPicOrderCntLsb = sps->getMaxPicOrderCntLsb();
     2403  for (Int i = 0; i <= numPocLtCurr - 1; i++  )
     2404  {
     2405    // For each i in the range of 0 to NumPocLtCurr - 1, inclusive, when CurrDeltaPocMsbPresentFlag[ i ] is equal to 0,
     2406    // it is a requirement of bitstream conformance that the following conditions apply:
     2407    if ( currDeltaPocMsbPresentFlag[ i ] == 0  )
     2408    {
     2409      // -  There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive,
     2410      //    for which PocLtCurr[ i ] is equal to ( PocStCurrBefore[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2411      for (Int j = 0; j <= numPocStCurrBefore - 1; j++ )
     2412      {
     2413        assert(!( pocLtCurr[ i ] == ( pocStCurrBefore[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2414      }
     2415
     2416      // -  There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive,
     2417      //    for which PocLtCurr[ i ] is equal to ( PocStCurrAfter[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2418      for (Int j = 0; j <= numPocStCurrAfter - 1; j++ )
     2419      {
     2420        assert(!( pocLtCurr[ i ] == ( pocStCurrAfter[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2421      }
     2422
     2423      // -  There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive,
     2424      //    for which PocLtCurr[ i ] is equal to ( PocStFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2425      for (Int j = 0; j <= numPocStFoll - 1; j++ )
     2426      {
     2427        assert(!( pocLtCurr[ i ] == ( pocStFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2428      }
     2429
     2430      // -  There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive,
     2431      //    where j is not equal to i, for which PocLtCurr[ i ] is equal to ( PocLtCurr[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2432      for (Int j = 0; j <= numPocLtCurr - 1; j++ )
     2433      {
     2434        if (j != i)
     2435        {
     2436          assert(!( pocLtCurr[ i ] == ( pocLtCurr[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2437        }
     2438      }
     2439    }
     2440  }
     2441
     2442  for (Int i = 0; i <= numPocLtFoll - 1; i++  )
     2443  {
     2444    // For each i in the range of 0 to NumPocLtFoll - 1, inclusive, when FollDeltaPocMsbPresentFlag[ i ] is equal to 0,
     2445    // it is a requirement of bitstream conformance that the following conditions apply:
     2446    if ( follDeltaPocMsbPresentFlag[ i ] == 0  )
     2447    {
     2448      // -  There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive,
     2449      //    for which PocLtFoll[ i ] is equal to ( PocStCurrBefore[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2450      for (Int j = 0; j <= numPocStCurrBefore - 1; j++ )
     2451      {
     2452        assert(!( pocLtFoll[ i ] == ( pocStCurrBefore[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2453      }
     2454
     2455      // -  There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive,
     2456      //    for which PocLtFoll[ i ] is equal to ( PocStCurrAfter[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2457      for (Int j = 0; j <= numPocStCurrAfter - 1; j++ )
     2458      {
     2459        assert(!( pocLtFoll[ i ] == ( pocStCurrAfter[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2460      }
     2461
     2462      // -  There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive,
     2463      //    for which PocLtFoll[ i ] is equal to ( PocStFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2464      for (Int j = 0; j <= numPocStFoll - 1; j++ )
     2465      {
     2466        assert(!( pocLtFoll[ i ] == ( pocStFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2467      }
     2468
     2469      // -  There shall be no j in the range of 0 to NumPocLtFoll - 1, inclusive,
     2470      //    where j is not equal to i, for which PocLtFoll[ i ] is equal to ( PocLtFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2471      for (Int j = 0; j <= numPocLtFoll - 1; j++ )
     2472      {
     2473        if (j != i)
     2474        {
     2475          assert(!( pocLtFoll[ i ] == ( pocLtFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2476        }         
     2477      }
     2478
     2479      // -  There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive,
     2480      //    for which PocLtFoll[ i ] is equal to ( PocLtCurr[ j ] & ( MaxPicOrderCntLsb - 1 ) ).
     2481      for (Int j = 0; j <= numPocLtCurr - 1; j++ )
     2482      {
     2483        assert(!( pocLtFoll[ i ] == ( pocLtCurr[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) );
     2484      }
     2485    }
     2486  }
     2487
     2488  if ( !annexFModifications )
     2489  { 
     2490    // The variable NumPicTotalCurr is derived as specified in clause 7.4.7.2.
     2491
     2492    // It is a requirement of bitstream conformance that the following applies to the value of NumPicTotalCurr:
     2493    if ( m_pcPic->isBla() || m_pcPic->isCra() )
     2494    {
     2495      // -  If the current picture is a BLA or CRA picture, the value of NumPicTotalCurr shall be equal to 0.
     2496      assert( slice->getNumPicTotalCurr() == 0 );
     2497    }
     2498    else
     2499    {
     2500      // -  Otherwise,
     2501      if ( slice->isInterP() || slice->isInterB() )
     2502      {
     2503        // when the current picture contains a P or B slice, the value of NumPicTotalCurr shall not be equal to 0.
     2504        assert( slice->getNumPicTotalCurr() != 0 );
     2505      }
     2506    }
     2507  }
     2508   
     2509  // The RPS of the current picture consists of five RPS lists; RefPicSetStCurrBefore, RefPicSetStCurrAfter, RefPicSetStFoll,
     2510  // RefPicSetLtCurr and RefPicSetLtFoll. RefPicSetStCurrBefore, RefPicSetStCurrAfter and RefPicSetStFoll are collectively
     2511  // referred to as the short-term RPS. RefPicSetLtCurr and RefPicSetLtFoll are collectively referred to as the long-term RPS.
     2512
     2513  std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore;
     2514  std::vector<TComPic*>& refPicSetStCurrAfter  = decRps->m_refPicSetStCurrAfter ;
     2515  std::vector<TComPic*>& refPicSetStFoll       = decRps->m_refPicSetStFoll      ;
     2516  std::vector<TComPic*>& refPicSetLtCurr       = decRps->m_refPicSetLtCurr      ;
     2517  std::vector<TComPic*>& refPicSetLtFoll       = decRps->m_refPicSetLtFoll      ;
     2518 
     2519  std::vector<TComPic*>** refPicSetsCurr       = decRps->m_refPicSetsCurr       ;
     2520  std::vector<TComPic*>** refPicSetsLt         = decRps->m_refPicSetsLt         ;
     2521  std::vector<TComPic*>** refPicSetsAll        = decRps->m_refPicSetsAll        ;
     2522  //   NOTE 3 - RefPicSetStCurrBefore, RefPicSetStCurrAfter and RefPicSetLtCurr contain all reference pictures that may be
     2523  //   used for inter prediction of the current picture and one or more pictures that follow the current picture in decoding order.
     2524  //   RefPicSetStFoll and RefPicSetLtFoll consist of all reference pictures that are not used for inter prediction of the current
     2525  //   picture but may be used in inter prediction for one or more pictures that follow the current picture in decoding order.
     2526
     2527  // The derivation process for the RPS and picture marking are performed according to the following ordered steps:
     2528  // 1.  The following applies:
     2529
     2530  TComSubDpb* dpb = m_dpb->getSubDpb( getLayerId(), false );   
     2531  assert( refPicSetLtCurr.empty() );
     2532  for( Int i = 0; i < numPocLtCurr; i++ )
     2533  {
     2534    if( !currDeltaPocMsbPresentFlag[ i ] )
     2535    {   
     2536      refPicSetLtCurr.push_back( dpb->getPicFromLsb( pocLtCurr[ i ], maxPicOrderCntLsb ) );       
     2537    }
     2538    else
     2539    {
     2540      refPicSetLtCurr.push_back(dpb->getPic( pocLtCurr[ i ] ));       
     2541    }   
     2542  }
     2543
     2544  assert( refPicSetLtFoll.empty() );
     2545  for( Int i = 0; i < numPocLtFoll; i++ )
     2546  {
     2547   if( !follDeltaPocMsbPresentFlag[ i ] )
     2548   {
     2549     refPicSetLtFoll.push_back(dpb->getPicFromLsb(pocLtFoll[ i ], maxPicOrderCntLsb ));
     2550   }
     2551   else
     2552   {
     2553     refPicSetLtFoll.push_back(dpb->getPic( pocLtFoll[ i ] ));       
     2554   }
     2555  }
     2556 
     2557  // 2.  All reference pictures that are included in RefPicSetLtCurr or RefPicSetLtFoll and have nuh_layer_id equal
     2558  //     to currPicLayerId are marked as "used for long-term reference".
     2559  for (Int i = 0; i < numPocLtCurr; i++)
     2560  {
     2561    if ( refPicSetLtCurr[i] != NULL )
     2562    {
     2563      refPicSetLtCurr[i]->markAsUsedForLongTermReference();
     2564    }   
     2565  }
     2566
     2567  for (Int i = 0; i < numPocLtFoll; i++)
     2568  {
     2569    if ( refPicSetLtFoll[i] != NULL )
     2570    {
     2571      refPicSetLtFoll[i]->markAsUsedForLongTermReference();
     2572    }   
     2573  }
     2574
     2575  // 3.  The following applies:
     2576  assert( refPicSetStCurrBefore.empty() );
     2577  for( Int i = 0; i < numPocStCurrBefore; i++ )
     2578  {
     2579    refPicSetStCurrBefore.push_back(dpb->getShortTermRefPic( pocStCurrBefore[ i ] ));
     2580  }
     2581
     2582  assert( refPicSetStCurrAfter.empty() );
     2583  for( Int i = 0; i < numPocStCurrAfter; i++ )
     2584  {
     2585    refPicSetStCurrAfter.push_back(dpb->getShortTermRefPic( pocStCurrAfter[ i ] ));
     2586  }
     2587
     2588  assert( refPicSetStFoll.empty() );
     2589  for( Int i = 0; i < numPocStFoll; i++ )
     2590  {
     2591    refPicSetStFoll.push_back(dpb->getShortTermRefPic( pocStFoll[ i ] ));
     2592  }
     2593 
     2594  // 4.  All reference pictures in the DPB that are not included in RefPicSetLtCurr, RefPicSetLtFoll, RefPicSetStCurrBefore,
     2595  //     RefPicSetStCurrAfter, or RefPicSetStFoll and have nuh_layer_id equal to currPicLayerId are marked as "unused for reference".
     2596  TComSubDpb picsToMark = (*dpb);
     2597  for (Int j = 0; j < 5; j++ )
     2598  {
     2599    picsToMark.removePics( *refPicSetsAll[j] );
     2600  } 
     2601  picsToMark.markAllAsUnusedForReference();
     2602 
     2603  //     NOTE 4 - There may be one or more entries in the RPS lists that are equal to "no reference picture" because
     2604  //     the corresponding pictures are not present in the DPB. Entries in RefPicSetStFoll or RefPicSetLtFoll that are equal
     2605  //     to "no reference picture" should be ignored. An unintentional picture loss should be inferred for each entry in
     2606  //     RefPicSetStCurrBefore, RefPicSetStCurrAfter, or RefPicSetLtCurr that is equal to "no reference picture".
     2607
     2608  //     NOTE 5 - A picture cannot be included in more than one of the five RPS lists.
     2609
     2610 
     2611  // It is a requirement of bitstream conformance that the RPS is restricted as follows:
     2612
     2613
     2614#if NH_MV_FIX_NO_REF_PICS_CHECK
     2615  if ( !annexFModifications || m_firstPicInLayerDecodedFlag[ m_pcPic->getLayerId() ] )
     2616  {
     2617#endif
     2618    for (Int j = 0; j < 3; j++ )
     2619    {
     2620      // -  There shall be no entry in RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr
     2621      //    for which one or more of the following are true:
     2622
     2623      std::vector<TComPic*>* currSet = refPicSetsCurr[j];
     2624      for (Int i = 0; i < currSet->size(); i++)
     2625      {
     2626        TComPic* pic = (*currSet)[i];
     2627
     2628        // -  The entry is equal to "no reference picture".
     2629        assert( ! (pic == NULL ) );
     2630
     2631        // -  The entry is an SLNR picture and has TemporalId equal to that of the current picture.
     2632        assert( !( pic->isSlnr() && pic->getTemporalId() == m_pcPic->getTemporalId() ) );
     2633
     2634        // -  The entry is a picture that has TemporalId greater than that of the current picture.
     2635        assert( !(  pic->getTemporalId() > m_pcPic->getTemporalId() ) );
     2636      }     
     2637    }
     2638#if NH_MV_FIX_NO_REF_PICS_CHECK
     2639  }
     2640#endif
     2641 
     2642  //  -  There shall be no entry in RefPicSetLtCurr or RefPicSetLtFoll for which the
     2643  //     difference between the picture order count value of the current picture and the picture order count
     2644  //     value of the entry is greater than or equal to 2^24.
     2645  for (Int j = 0; j < 2; j++ )
    17002646  {   
    1701     NalUnitType nut = m_apcSlicePilot->getNalUnitType();
    1702 
    1703     Bool isBLA =  ( nut == NAL_UNIT_CODED_SLICE_BLA_W_LP  )  || ( nut == NAL_UNIT_CODED_SLICE_BLA_N_LP ) || ( nut == NAL_UNIT_CODED_SLICE_BLA_W_RADL );
    1704     Bool isIDR  = ( nut == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) || ( nut == NAL_UNIT_CODED_SLICE_IDR_N_LP );
    1705     Bool noClrasOutputFlag  = isBLA || ( isIDR  &&  m_apcSlicePilot->getCrossLayerBlaFlag() );
    1706 
    1707     if ( noClrasOutputFlag )
    1708     {
    1709       for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
    1710       {
    1711         m_layerInitilizedFlag[i] = false;
    1712       }
    1713     }
    1714   }
    1715 }
    1716 
    1717 Bool TDecTop::xAllRefLayersInitilized( const TComVPS* vps )
    1718 {
    1719   Bool allRefLayersInitilizedFlag = true;   
    1720   for (Int i = 0; i < vps->getNumDirectRefLayers( getLayerId()  ); i++ )
    1721   {
    1722     Int refLayerId = vps->getIdDirectRefLayer( m_layerId, i );
    1723     allRefLayersInitilizedFlag = allRefLayersInitilizedFlag && m_layerInitilizedFlag[ refLayerId ];
    1724   }
    1725 
    1726   return allRefLayersInitilizedFlag;
    1727 }
    1728 
    1729 
    1730 Void 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 }
     2647    std::vector<TComPic*>* ltSet = refPicSetsLt[j];
     2648    for (Int i = 0; i < ltSet->size(); i++)
     2649    {
     2650      TComPic* pic = (*ltSet)[i];
     2651      if( pic != NULL )
     2652      {
     2653        assert(!( abs( m_pcPic->getPOC() - pic->getPOC() ) >= (1 << 24) ));
     2654      }
     2655    }
     2656  }
     2657
     2658  //   -  When the current picture is a temporal sub-layer access (TSA) picture, there shall be no picture
     2659  //      included in the RPS with TemporalId greater than or equal to the TemporalId of the current picture.
     2660  if (m_pcPic->isTsa() )
     2661  {
     2662    for (Int j = 0; j < 5; j++ )
     2663    {   
     2664      std::vector<TComPic*>* aSet = refPicSetsAll[j];
     2665      for (Int i = 0; i < aSet->size(); i++)
     2666      {
     2667        TComPic* pic = (*aSet)[i];
     2668        if( pic != NULL )
     2669        {
     2670          assert( ! (pic->getTemporalId() >= m_pcPic->getTemporalId() ) );
     2671        }
     2672      }
     2673    }
     2674  }
     2675
     2676  //   -  When the current picture is a step-wise temporal sub-layer access (STSA) picture,
     2677  //      there shall be no picture included in RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr that has
     2678  //      TemporalId equal to that of the current picture.
     2679  if (m_pcPic->isStsa() )
     2680  {
     2681    for (Int j = 0; j < 3; j++ )
     2682    {   
     2683      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2684      for (Int i = 0; i < cSet->size(); i++)
     2685      {
     2686        TComPic* pic = (*cSet)[i];
     2687        if( pic != NULL )
     2688        {
     2689          assert( ! (pic->getTemporalId() == m_pcPic->getTemporalId() ) );
     2690        }
     2691      }
     2692    }
     2693  }
     2694
     2695  //   -  When the current picture is a picture that follows, in decoding order, an STSA picture
     2696  //      that has TemporalId equal to that of the current picture, there shall be no picture that has
     2697  //      TemporalId equal to that of the current picture included in RefPicSetStCurrBefore, RefPicSetStCurrAfter
     2698  //      or RefPicSetLtCurr that precedes the STSA picture in decoding order.
     2699  if ( m_pcPic->getDecodingOrder() > m_prevStsaDecOrder && m_pcPic->getTemporalId() == m_prevStsaTemporalId  )
     2700  {
     2701    for (Int j = 0; j < 3; j++ )
     2702    {   
     2703      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2704      for (Int i = 0; i < cSet->size(); i++)
     2705      {
     2706        TComPic* pic = (*cSet)[i];
     2707        if( pic != NULL )
     2708        {
     2709          assert( ! (pic->getTemporalId() == m_pcPic->getTemporalId() && pic->getDecodingOrder() < m_prevStsaDecOrder  ) );
     2710        }
     2711      }
     2712    }
     2713  }
     2714 
     2715  //   -  When the current picture is a CRA picture, there shall be no picture included in the RPS that
     2716  //      precedes, in output order or decoding order, any preceding IRAP picture in decoding order (when present).
     2717  if ( m_pcPic->isCra() )
     2718  {
     2719    for (Int j = 0; j < 5; j++ )
     2720    {   
     2721      std::vector<TComPic*>* aSet = refPicSetsAll[j];
     2722      for (Int i = 0; i < aSet->size(); i++)
     2723      {
     2724        // TBD check whether it sufficient to test only the last IRAP
     2725        TComPic* pic = (*aSet)[i];
     2726        if( pic != NULL )
     2727        {       
     2728          assert( ! (pic->getPOC()           < m_prevIrapPoc           ) );           
     2729          assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) );
     2730        }
     2731      }
     2732    }
     2733  }
     2734 
     2735  Bool isTrailingPicture = ( !m_pcPic->isIrap() ) && ( m_pcPic->getPOC() > m_prevIrapPoc );
     2736  //   -  When the current picture is a trailing picture, there shall be no picture in RefPicSetStCurrBefore,
     2737  //      RefPicSetStCurrAfter or RefPicSetLtCurr that was generated by the decoding process for generating unavailable
     2738  //      reference pictures as specified in clause 8.3.3.
     2739  if ( isTrailingPicture )
     2740  {
     2741    for (Int j = 0; j < 3; j++ )
     2742    {   
     2743      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2744      for (Int i = 0; i < cSet->size(); i++)
     2745      {
     2746        TComPic* pic = (*cSet)[i];
     2747        if( pic != NULL )
     2748        {
     2749          assert( ! (pic->getIsGeneratedCl833() ) );
     2750        }
     2751      }
     2752    }
     2753  }
     2754
     2755  //   -  When the current picture is a trailing picture, there shall be no picture in the RPS that precedes the
     2756  //      associated IRAP picture in output order or decoding order.
     2757  if ( isTrailingPicture )
     2758  {
     2759    for (Int j = 0; j < 5; j++ )
     2760    {   
     2761      std::vector<TComPic*>* aSet = refPicSetsAll[j];
     2762      for (Int i = 0; i < aSet->size(); i++)
     2763      {
     2764        // TBD check whether it sufficient to test only the last IRAP
     2765         TComPic* pic = (*aSet)[i];
     2766        if( pic != NULL )
     2767        {         
     2768          assert( ! (pic->getPOC()           < m_prevIrapPoc           ) );
     2769          assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) );
     2770        }
     2771      }
     2772    }
     2773  }
     2774
     2775  //   -  When the current picture is a RADL picture, there shall be no picture included in RefPicSetStCurrBefore,
     2776  //      RefPicSetStCurrAfter or RefPicSetLtCurr that is any of the following:
     2777  if ( m_pcPic->isRadl() )
     2778  {
     2779    for (Int j = 0; j < 3; j++ )
     2780    {   
     2781      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2782      for (Int i = 0; i < cSet->size(); i++)
     2783      {       
     2784        TComPic* pic = (*cSet)[i];
     2785        if( pic != NULL )
     2786        {       
     2787          // -  A RASL picture
     2788          assert( ! (pic->isRasl() ) );
     2789          // -  A picture that was generated by the decoding process for generating unavailable reference pictures
     2790          //    as specified in clause 8.3.3
     2791          assert( ! (pic->getIsGeneratedCl833() ) );
     2792          // -  A picture that precedes the associated IRAP picture in decoding order
     2793          assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) );
     2794        }
     2795      }
     2796    }
     2797  }
     2798 
     2799 
     2800  if ( sps->getTemporalIdNestingFlag() )
     2801  {
     2802    // -  When sps_temporal_id_nesting_flag is equal to 1, the following applies:
     2803    //    -  Let tIdA be the value of TemporalId of the current picture picA.
     2804    TComPic* picA = m_pcPic;
     2805    Int      tIdA = picA->getTemporalId();
     2806    //   -  Any picture picB with TemporalId equal to tIdB that is less than or equal to tIdA shall not be included in
     2807    //      RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr of picA when there exists a picture picC that
     2808    //      has TemporalId less than tIdB, follows picB in decoding order, and precedes picA in decoding order.
     2809    for (Int j = 0; j < 3; j++ )
     2810    {   
     2811      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2812      for (Int i = 0; i < cSet->size(); i++)
     2813      {
     2814        TComPic* picB = (*cSet)[i];
     2815        if( picB != NULL )
     2816        {
     2817          Int tIdB = picB->getTemporalId();
     2818
     2819          if (tIdB <= tIdA)
     2820          {
     2821            for ( TComSubDpb::iterator itP = dpb->begin(); itP != dpb->end(); itP++ )
     2822            {
     2823              TComPic* picC = (*itP);
     2824              assert(! ( picC->getTemporalId() < tIdB && picC->getDecodingOrder() > picB->getDecodingOrder() && picC->getDecodingOrder() < picA->getDecodingOrder()  )  );
     2825            }
     2826          }
     2827        }
     2828      }
     2829    }
     2830  }   
     2831}
     2832
     2833
     2834Void TDecTop::xF832DecProcForRefPicSet()
     2835{
     2836  ///////////////////////////////////////////////////////////////////////////////////////
     2837  // F.8.3.2 Decoding process for reference picture set
     2838  ///////////////////////////////////////////////////////////////////////////////////////
     2839
     2840  // The specifications in clause 8.3.2 apply with the following changes:
     2841  // -  The references to clauses 7.4.7.2, 8.3.1, 8.3.3 and 8.3.4 are replaced with references to
     2842  //    clauses F.7.4.7.2, F.8.3.1, F.8.3.3 and F.8.3.4, respectively.
     2843
     2844  x832DecProcForRefPicSet( true );
     2845
     2846  // -  The following specifications are added:
     2847  if (m_pcPic->isIrap() && m_pcPic->getLayerId() == m_smallestLayerId )
     2848  {
     2849    // -  When the current picture is an IRAP picture with nuh_layer_id equal to SmallestLayerId,
     2850    //    all reference pictures with any value of nuh_layer_id currently in the DPB (if any) are marked
     2851    //    as "unused for reference" when at least one of the following conditions is true:
     2852
     2853    if ( m_pcPic->getNoClrasOutputFlag() || m_pcPic->getActivatesNewVps() )
     2854    {
     2855      // -  The current picture has NoClrasOutputFlag is equal to 1.
     2856      // -  The current picture activates a new VPS.
     2857      m_dpb->markAllSubDpbAsUnusedForReference( );
     2858    }
     2859  }
     2860
     2861  // -  It is a requirement of bitstream conformance that the RPS is restricted as follows:
     2862  // -  When the current picture is a CRA picture, there shall be no picture in RefPicSetStCurrBefore, RefPicSetStCurrAfter
     2863  //    or RefPicSetLtCurr.
     2864
     2865  std::vector<TComPic*>** refPicSetsCurr       = m_pcPic->getDecodedRps()->m_refPicSetsCurr;
     2866
     2867  if ( m_pcPic->isCra() )
     2868  {
     2869    for (Int j = 0; j < 3; j++ )   
     2870    {   
     2871      std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     2872      assert ( cSet->size() == 0 );
     2873    }
     2874  }
     2875
     2876  // -  The constraints specified in clause 8.3.2 on the value of NumPicTotalCurr are replaced with the following:
     2877  //    -  It is a requirement of bitstream conformance that the following applies to the value of NumPicTotalCurr:
     2878  Int numPicTotalCurr = m_pcPic->getSlice(0)->getNumPicTotalCurr();
     2879  Int currPicLayerId  = m_pcPic->getLayerId();
     2880  const TComVPS* vps  = m_pcPic->getSlice(0)->getVPS();
     2881
     2882  if ( ( m_pcPic->isBla() || m_pcPic->isCra() ) && (  (currPicLayerId == 0 ) || ( vps->getNumDirectRefLayers( currPicLayerId ) == 0 ) ) )
     2883  {   
     2884    assert( numPicTotalCurr == 0 );
     2885    // -  If the current picture is a BLA or CRA picture and either currPicLayerId is equal to 0 or
     2886    //     NumDirectRefLayers[ currPicLayerId ] is equal to 0, the value of NumPicTotalCurr shall be equal to 0.
     2887  }
     2888  else
     2889  {
     2890    // TBD: check all slices
     2891    if ( m_pcPic->getSlice(0)->getSliceType() == P_SLICE  ||  m_pcPic->getSlice(0)->getSliceType() == B_SLICE )
     2892    {
     2893      // -  Otherwise, when the current picture contains a P or B slice, the value of NumPicTotalCurr shall not be equal to 0.
     2894      assert( numPicTotalCurr != 0 );
     2895    }
     2896  }
     2897}
     2898
     2899
     2900Void TDecTop::xG813DecProcForInterLayerRefPicSet()
     2901{
     2902  ////////////////////////////////////////////////////////////////////
     2903  // G.8.1.3 Decoding process for inter-layer reference picture set //
     2904  ////////////////////////////////////////////////////////////////////
     2905
     2906  // Outputs of this process are updated lists of inter-layer reference pictures RefPicSetInterLayer0 and RefPicSetInterLayer1
     2907  // and the variables NumActiveRefLayerPics0 and NumActiveRefLayerPics1.
     2908
     2909  TComDecodedRps* decRps = m_pcPic->getDecodedRps();
     2910  TComSlice* slice       = m_pcPic->getSlice( 0 );
     2911  const TComVPS* vps     =  slice->getVPS();
     2912
     2913  Int&                   numActiveRefLayerPics0 = decRps->m_numActiveRefLayerPics0;
     2914  Int&                   numActiveRefLayerPics1 = decRps->m_numActiveRefLayerPics1;
     2915
     2916  std::vector<TComPic*>& refPicSetInterLayer0   = decRps->m_refPicSetInterLayer0;
     2917  std::vector<TComPic*>& refPicSetInterLayer1   = decRps->m_refPicSetInterLayer1;
     2918
     2919  // The variable currLayerId is set equal to nuh_layer_id of the current picture.
     2920  Int currLayerId = getLayerId();
     2921
     2922  // The lists RefPicSetInterLayer0 and RefPicSetInterLayer1 are first emptied, NumActiveRefLayerPics0 and NumActiveRefLayerPics1
     2923  // are set equal to 0 and the following applies:
     2924
     2925  refPicSetInterLayer0.clear();
     2926  refPicSetInterLayer1.clear();
     2927
     2928  numActiveRefLayerPics0 = 0;
     2929  numActiveRefLayerPics1 = 0;
     2930
     2931  Int viewIdCurrLayerId  = vps->getViewId( currLayerId );
     2932  Int viewId0            = vps->getViewId( 0   );
     2933
     2934  for( Int i = 0; i < slice->getNumActiveRefLayerPics(); i++ )   
     2935  {
     2936    Int viewIdRefPicLayerIdi = vps->getViewId( slice->getRefPicLayerId( i ) );
     2937
     2938    Bool refPicSet0Flag =
     2939      ( ( viewIdCurrLayerId <=  viewId0  &&  viewIdCurrLayerId <=  viewIdRefPicLayerIdi )  ||
     2940      ( viewIdCurrLayerId >=  viewId0  &&  viewIdCurrLayerId >=  viewIdRefPicLayerIdi ) );
     2941
     2942    TComPic* picX = m_dpb->getAu(slice->getPOC(), false )->getPic( slice->getRefPicLayerId( i ) );
     2943    if ( picX != NULL )
     2944    {
     2945      // there is a picture picX in the DPB that is in the same access unit as the current picture and has
     2946      // nuh_layer_id equal to RefPicLayerId[ i ]
     2947
     2948      if ( refPicSet0Flag )
     2949      {
     2950        refPicSetInterLayer0.push_back( picX );
     2951        refPicSetInterLayer0[ numActiveRefLayerPics0++ ]->markAsUsedForLongTermReference();
     2952      }
     2953      else
     2954      {
     2955        refPicSetInterLayer1.push_back( picX );
     2956        refPicSetInterLayer1[ numActiveRefLayerPics1++ ]->markAsUsedForLongTermReference();
     2957      }
     2958
     2959      // There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1.
     2960      assert( ! picX->getSlice(0)->getDiscardableFlag() );
     2961
     2962      // If the current picture is a RADL picture, there shall be no entry in RefPicSetInterLayer0 or RefPicSetInterLayer1
     2963      // that is a RASL picture.
     2964      if ( m_pcPic->isRadl() )
     2965      {
     2966        assert( ! picX->isRasl() );
     2967      }
     2968    }
     2969    else
     2970    {
     2971      if( refPicSet0Flag )
     2972      {
     2973        refPicSetInterLayer0.push_back( NULL ); // "no reference picture" (G 1)
     2974        numActiveRefLayerPics0++;
     2975      }
     2976      else
     2977      {
     2978        refPicSetInterLayer1.push_back( NULL ); // "no reference picture";
     2979        numActiveRefLayerPics1++;
     2980      }
     2981      // There shall be no entry equal to "no reference picture" in RefPicSetInterLayer0 or RefPicSetInterLayer1.
     2982      assert( false );
     2983    }
     2984  }
     2985}
     2986
     2987
     2988Void TDecTop::x8331GenDecProcForGenUnavilRefPics()
     2989{
     2990  ///////////////////////////////////////////////////////////////////////////////////////
     2991  // 8.3.3.1  General decoding process for generating unavailable reference pictures ////
     2992  ///////////////////////////////////////////////////////////////////////////////////////
     2993
     2994  // This process is invoked once per coded picture when the current picture is a
     2995  // BLA picture or is a CRA picture with NoRaslOutputFlag equal to 1.
     2996
     2997  assert( m_pcPic->isBla() || (m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) );
     2998  TComDecodedRps* decRps = m_pcPic->getDecodedRps();
     2999
     3000  std::vector<TComPic*>& refPicSetStFoll      = decRps->m_refPicSetStFoll;
     3001  std::vector<TComPic*>& refPicSetLtFoll      = decRps->m_refPicSetLtFoll;
     3002
     3003  const std::vector<Int>& pocStFoll             = decRps->m_pocStFoll;
     3004  const std::vector<Int>& pocLtFoll             = decRps->m_pocLtFoll;
     3005
     3006  const Int               numPocStFoll          = decRps->m_numPocStFoll;
     3007  const Int               numPocLtFoll          = decRps->m_numPocLtFoll;   
     3008
     3009  // When this process is invoked, the following applies:
     3010  for ( Int i = 0 ; i <= numPocStFoll - 1; i++ )
     3011  {
     3012    if ( refPicSetStFoll[ i ] == NULL )
     3013    {
     3014      //-  For each RefPicSetStFoll[ i ], with i in the range of 0 to NumPocStFoll - 1, inclusive, that is equal
     3015      //   to "no reference picture", a picture is generated as specified in clause 8.3.3.2, and the following applies:
     3016      TComPic* genPic = x8332GenOfOneUnavailPic( true ); 
     3017
     3018      // -  The value of PicOrderCntVal for the generated picture is set equal to PocStFoll[ i ].
     3019      genPic->getSlice(0)->setPOC( pocStFoll[ i ] );
     3020
     3021      //-  The value of PicOutputFlag for the generated picture is set equal to 0. 
     3022      genPic->setPicOutputFlag( false );
     3023
     3024      // -  The generated picture is marked as "used for short-term reference".
     3025      genPic->markAsUsedForShortTermReference();
     3026
     3027      // -  RefPicSetStFoll[ i ] is set to be the generated reference picture.
     3028      refPicSetStFoll[ i ] = genPic;
     3029
     3030      // -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id of the current picture.
     3031      genPic->setLayerId( m_pcPic-> getLayerId() );
     3032
     3033      // Insert to DPB
     3034      m_dpb->addNewPic( genPic );
     3035    }
     3036  }
     3037
     3038  for ( Int i = 0 ; i <= numPocLtFoll - 1; i++ )
     3039  {
     3040    if ( refPicSetLtFoll[ i ] == NULL )
     3041    {
     3042      //-  For each RefPicSetLtFoll[ i ], with i in the range of 0 to NumPocLtFoll - 1, inclusive, that is equal to
     3043      //   "no reference picture", a picture is generated as specified in clause 8.3.3.2, and the following applies:
     3044      TComPic* genPic = x8332GenOfOneUnavailPic( true ); 
     3045
     3046      //-  The value of PicOrderCntVal for the generated picture is set equal to PocLtFoll[ i ].
     3047      genPic->getSlice(0)->setPOC( pocStFoll[ i ] );
     3048
     3049      //  -  The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtFoll[ i ] & ( MaxPicOrderCntLsb - 1 ) ).
     3050      genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtFoll[ i ] & ( m_pcPic->getSlice(0)->getSPS()->getMaxPicOrderCntLsb() - 1 ) ) );
     3051
     3052      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.   
     3053      genPic->setPicOutputFlag( false );
     3054
     3055      //  -  The generated picture is marked as "used for long-term reference".
     3056      genPic->markAsUsedForLongTermReference();
     3057
     3058      //  -  RefPicSetLtFoll[ i ] is set to be the generated reference picture.
     3059      refPicSetLtFoll[ i ] = genPic;
     3060
     3061      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id of the current picture.
     3062      genPic->setLayerId( m_pcPic-> getLayerId() );
     3063
     3064      // Insert to DPB
     3065      m_dpb->addNewPic( genPic );
     3066    }
     3067  }
     3068}
     3069
     3070
     3071TComPic* TDecTop::x8332GenOfOneUnavailPic( Bool calledFromCl8331 )
     3072{
     3073  ///////////////////////////////////////////////////////////////////////////////////////
     3074  // 8.3.3.2 Generation of one unavailable picture
     3075  ///////////////////////////////////////////////////////////////////////////////////////
     3076
     3077  TComPic* genPic = new TComPic;
     3078  genPic->create( *m_pcPic->getSlice(0)->getSPS(), *m_pcPic->getSlice(0)->getPPS(), true );
     3079  genPic->setIsGenerated( true );     
     3080  genPic->setIsGeneratedCl833( calledFromCl8331 );
     3081  return genPic;
     3082}
     3083
     3084
     3085Void TDecTop::xF817DecProcForGenUnavRefPicForPicsFrstInDecOrderInLay()
     3086{
     3087  ///////////////////////////////////////////////////////////////////////////////////////
     3088  // F.8.1.7 Decoding process for generating unavailable reference pictures for pictures
     3089  //         first in decoding order within a layer
     3090  ///////////////////////////////////////////////////////////////////////////////////////
     3091
     3092  //  This process is invoked for a picture with nuh_layer_id equal to layerId, when FirstPicInLayerDecodedFlag[layerId ] is equal to 0.   
     3093  assert( !m_firstPicInLayerDecodedFlag[ getLayerId() ] );
     3094
     3095
     3096  TComDecodedRps* decRps = m_pcPic->getDecodedRps();
     3097
     3098  std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore;
     3099  std::vector<TComPic*>& refPicSetStCurrAfter  = decRps->m_refPicSetStCurrAfter;
     3100  std::vector<TComPic*>& refPicSetStFoll       = decRps->m_refPicSetStFoll;
     3101  std::vector<TComPic*>& refPicSetLtCurr       = decRps->m_refPicSetLtCurr;
     3102  std::vector<TComPic*>& refPicSetLtFoll       = decRps->m_refPicSetLtFoll;
     3103
     3104
     3105  const std::vector<Int>& pocStCurrBefore      = decRps->m_pocStCurrBefore;
     3106  const std::vector<Int>& pocStCurrAfter       = decRps->m_pocStCurrAfter;
     3107  const std::vector<Int>& pocStFoll            = decRps->m_pocStFoll;
     3108  const std::vector<Int>& pocLtCurr            = decRps->m_pocLtCurr;
     3109  const std::vector<Int>& pocLtFoll            = decRps->m_pocLtFoll;
     3110
     3111  const Int numPocStCurrBefore                 = decRps->m_numPocStCurrBefore;
     3112  const Int numPocStCurrAfter                  = decRps->m_numPocStCurrAfter;
     3113  const Int numPocStFoll                       = decRps->m_numPocStFoll;
     3114  const Int numPocLtCurr                       = decRps->m_numPocLtCurr;
     3115  const Int numPocLtFoll                       = decRps->m_numPocLtFoll;   
     3116
     3117  Int nuhLayerId = m_pcPic-> getLayerId();
     3118  for ( Int i = 0 ; i <= numPocStCurrBefore - 1; i++ )
     3119  {
     3120    if ( refPicSetStCurrBefore[ i ] == NULL )
     3121    {
     3122      //-  For each RefPicSetStCurrBefore[ i ], with i in the range of 0 to NumPocStCurrBefore - 1, inclusive, that is
     3123      //  equal to "no reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies:
     3124      TComPic* genPic = x8332GenOfOneUnavailPic( false ); 
     3125
     3126      //-  The value of PicOrderCntVal for the generated picture is set equal to PocStCurrBefore[ i ].
     3127      genPic->getSlice(0)->setPOC( pocStCurrBefore[ i ] );
     3128
     3129      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.
     3130      genPic->setPicOutputFlag( false );
     3131
     3132      //  -  The generated picture is marked as "used for short-term reference".
     3133      genPic->markAsUsedForShortTermReference();
     3134
     3135      //  -  RefPicSetStCurrBefore[ i ] is set to be the generated reference picture.
     3136      refPicSetStCurrBefore[ i ] = genPic;
     3137
     3138      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id.
     3139      genPic->setLayerId( nuhLayerId );
     3140
     3141      // Insert to DPB
     3142      m_dpb->addNewPic( genPic );
     3143    }
     3144  }
     3145
     3146  for ( Int i = 0 ; i <= numPocStCurrAfter - 1; i++ )
     3147  {
     3148    if ( refPicSetStCurrAfter[ i ] == NULL )
     3149    {
     3150      //  -  For each RefPicSetStCurrAfter[ i ], with i in the range of 0 to NumPocStCurrAfter - 1, inclusive, that is equal
     3151      //     to "no reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies:
     3152      TComPic* genPic = x8332GenOfOneUnavailPic( false ); 
     3153
     3154      //  -  The value of PicOrderCntVal for the generated picture is set equal to PocStCurrAfter[ i ].
     3155      genPic->getSlice(0)->setPOC( pocStCurrAfter[ i ] );
     3156
     3157      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.
     3158      genPic->setPicOutputFlag( false );
     3159
     3160      //  -  The generated picture is marked as "used for short-term reference".
     3161      genPic->markAsUsedForShortTermReference();
     3162
     3163      //  -  RefPicSetStCurrAfter[ i ] is set to be the generated reference picture.
     3164      refPicSetStCurrAfter[ i ] = genPic;
     3165
     3166      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id.
     3167      genPic->setLayerId( nuhLayerId );
     3168
     3169      // Insert to DPB
     3170      m_dpb->addNewPic( genPic );
     3171
     3172    }
     3173  }
     3174
     3175  for ( Int i = 0 ; i <= numPocStFoll - 1; i++ )
     3176  {
     3177    if ( refPicSetStFoll[ i ] == NULL )
     3178    {
     3179      //  -  For each RefPicSetStFoll[ i ], with i in the range of 0 to NumPocStFoll - 1, inclusive, that is equal to "no
     3180      //     reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies:
     3181      TComPic* genPic = x8332GenOfOneUnavailPic( false ); 
     3182
     3183      //  -  The value of PicOrderCntVal for the generated picture is set equal to PocStFoll[ i ].
     3184      genPic->getSlice(0)->setPOC( pocStFoll[ i ] );
     3185
     3186      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.
     3187      genPic->setPicOutputFlag( false );
     3188
     3189      //  -  The generated picture is marked as "used for short-term reference".
     3190      genPic->markAsUsedForShortTermReference();
     3191
     3192      //  -  RefPicSetStFoll[ i ] is set to be the generated reference picture.
     3193      refPicSetStFoll[ i ] = genPic;
     3194
     3195      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id.
     3196      genPic->setLayerId( nuhLayerId );
     3197
     3198      // Insert to DPB
     3199      m_dpb->addNewPic( genPic );
     3200    }
     3201  }
     3202
     3203  Int maxPicOrderCntLsb = m_pcPic->getSlice(0)->getSPS()->getMaxPicOrderCntLsb(); 
     3204  for ( Int i = 0 ; i <= numPocLtCurr - 1; i++ )
     3205  {
     3206    if ( refPicSetLtCurr[ i ] == NULL )
     3207    {
     3208      //  -  For each RefPicSetLtCurr[ i ], with i in the range of 0 to NumPocLtCurr - 1, inclusive, that is equal to "no
     3209      //     reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies:
     3210      TComPic* genPic = x8332GenOfOneUnavailPic( false ); 
     3211
     3212      //  -  The value of PicOrderCntVal for the generated picture is set equal to PocLtCurr[ i ].
     3213      genPic->getSlice(0)->setPOC( pocLtCurr[ i ] );
     3214
     3215      //  -  The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtCurr[ i ] & (
     3216      //     MaxPicOrderCntLsb - 1 ) ).
     3217      genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtCurr[ i ] & ( maxPicOrderCntLsb - 1 ) ) );
     3218
     3219      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.
     3220      genPic->setPicOutputFlag( false );
     3221
     3222      //  -  The generated picture is marked as "used for long-term reference".
     3223      genPic->markAsUsedForLongTermReference();
     3224
     3225      //  -  RefPicSetLtCurr[ i ] is set to be the generated reference picture.
     3226      refPicSetLtCurr[ i ] = genPic;
     3227
     3228      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id.
     3229      genPic->setLayerId( nuhLayerId );
     3230
     3231      // Insert to DPB
     3232      m_dpb->addNewPic( genPic );
     3233    }
     3234  }
     3235
     3236  for ( Int i = 0 ; i <= numPocLtFoll - 1; i++ )
     3237  {
     3238    if ( refPicSetLtFoll[ i ] == NULL )
     3239    {
     3240      //  -  For each RefPicSetLtFoll[ i ], with i in the range of 0 to NumPocLtFoll - 1, inclusive, that is equal to "no
     3241      //     reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies:
     3242      TComPic* genPic = x8332GenOfOneUnavailPic( false ); 
     3243
     3244      //  -  The value of PicOrderCntVal for the generated picture is set equal to PocLtFoll[ i ].
     3245      genPic->getSlice(0)->setPOC( pocLtFoll[ i ] );
     3246
     3247      //  -  The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtCurr[ i ] & (
     3248      //     MaxPicOrderCntLsb - 1 ) ).
     3249      genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtCurr[ i ] & ( maxPicOrderCntLsb - 1 ) ) );
     3250
     3251      //  -  The value of PicOutputFlag for the generated picture is set equal to 0.
     3252      genPic->setPicOutputFlag( false );
     3253
     3254      //  -  The generated picture is marked as "used for long-term reference".
     3255      genPic->markAsUsedForLongTermReference();
     3256
     3257      //  -  RefPicSetLtFoll[ i ] is set to be the generated reference picture.
     3258      refPicSetLtFoll[ i ] = genPic;
     3259
     3260      //  -  The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id.
     3261      genPic->setLayerId( nuhLayerId );
     3262
     3263      // Insert to DPB
     3264      m_dpb->addNewPic( genPic );
     3265    }
     3266  }
     3267}
     3268
     3269Void TDecTop::xF833DecProcForGenUnavRefPics()
     3270{
     3271  ///////////////////////////////////////////////////////////////////////////////////////
     3272  // F.8.3.3 Decoding process for generating unavailable reference picture
     3273  ///////////////////////////////////////////////////////////////////////////////////////
     3274
     3275  x8331GenDecProcForGenUnavilRefPics();
     3276}
     3277
     3278Void TDecTop::xCheckUnavailableRefPics()
     3279{
     3280  std::vector<TComPic*>** refPicSetsCurr       = m_pcPic->getDecodedRps()->m_refPicSetsCurr;
     3281
     3282  Bool hasGeneratedRefPic = false;
     3283  for (Int j = 0; j < 3; j++ )   
     3284  {   
     3285    std::vector<TComPic*>* cSet = refPicSetsCurr[j];
     3286    for (Int i = 0 ; i < cSet->size();  i++ )
     3287    {
     3288      assert( (*cSet)[i] != NULL );
     3289      if ((*cSet)[i]->getIsGenerated() )
     3290      {
     3291        hasGeneratedRefPic = true;
     3292      }
     3293    }
     3294  }
     3295  m_pcPic->setHasGeneratedRefPics( hasGeneratedRefPic );
     3296}
     3297
    17563298#endif
    17573299
Note: See TracChangeset for help on using the changeset viewer.