Ignore:
Timestamp:
12 Nov 2014, 08:09:17 (10 years ago)
Author:
seregin
Message:

initial porting

File:
1 edited

Legend:

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

    r903 r916  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    3838#include "NALread.h"
    3939#include "TDecTop.h"
     40#if RExt__DECODER_DEBUG_BIT_STATISTICS
     41#include "TLibCommon/TComCodingStatistics.h"
     42#endif
    4043
    4144#if SVC_EXTENSION
     
    6467
    6568TDecTop::TDecTop()
     69  : m_pDecodedSEIOutputStream(NULL)
    6670{
    6771  m_pcPic = 0;
    6872  m_iMaxRefPicNum = 0;
    6973#if ENC_DEC_TRACE
    70   g_hTrace = fopen( "TraceDec.txt", "wb" );
     74  if (g_hTrace == NULL)
     75  {
     76    g_hTrace = fopen( "TraceDec.txt", "wb" );
     77  }
    7178  g_bJustDoIt = g_bEncDecTraceDisable;
    7279  g_nSymbolCounter = 0;
     
    7481  m_associatedIRAPType = NAL_UNIT_INVALID;
    7582  m_pocCRA = 0;
    76   m_pocRandomAccess = MAX_INT;         
     83  m_pocRandomAccess = MAX_INT;
    7784#if !SVC_EXTENSION
    7885  m_prevPOC                = MAX_INT;
     
    9198  m_prevSliceSkipped = false;
    9299  m_skippedPOC = 0;
    93 #if SETTING_NO_OUT_PIC_PRIOR
    94100  m_bFirstSliceInBitstream  = true;
    95101  m_lastPOCNoOutputPriorPics = -1;
    96102  m_craNoRaslOutputFlag = false;
    97103  m_isNoOutputPriorPics = false;
    98 #endif
    99104#if Q0177_EOS_CHECKS
    100105  m_isLastNALWasEos = false;
     
    129134{
    130135#if ENC_DEC_TRACE
    131   fclose( g_hTrace );
     136  if (g_hTrace != stdout)
     137  {
     138    fclose( g_hTrace );
     139  }
    132140#endif
    133141#if Q0048_CGS_3D_ASYMLUT
     
    155163{
    156164  m_cGopDecoder.destroy();
    157  
     165
    158166  delete m_apcSlicePilot;
    159167  m_apcSlicePilot = NULL;
    160  
     168
    161169  m_cSliceDecoder.destroy();
    162170#if SVC_EXTENSION
     
    189197}
    190198
    191 #if SVC_EXTENSION
    192 #if !REPN_FORMAT_IN_VPS
    193 Void TDecTop::xInitILRP(TComSPS *pcSPS)
    194 #else
    195 Void TDecTop::xInitILRP(TComSlice *slice)
    196 #endif
    197 {
    198 #if REPN_FORMAT_IN_VPS
    199   TComSPS* pcSPS = slice->getSPS();
    200   Int bitDepthY   = slice->getBitDepthY();
    201   Int bitDepthC   = slice->getBitDepthC();
    202   Int picWidth    = slice->getPicWidthInLumaSamples();
    203   Int picHeight   = slice->getPicHeightInLumaSamples();
    204 #endif
    205   if(m_layerId>0)
    206   {
    207 #if REPN_FORMAT_IN_VPS
    208     g_bitDepthY     = bitDepthY;
    209     g_bitDepthC     = bitDepthC;
    210 #else
    211     g_bitDepthY     = pcSPS->getBitDepthY();
    212     g_bitDepthC     = pcSPS->getBitDepthC();
    213 #endif
    214     g_uiMaxCUWidth  = pcSPS->getMaxCUWidth();
    215     g_uiMaxCUHeight = pcSPS->getMaxCUHeight();
    216     g_uiMaxCUDepth  = pcSPS->getMaxCUDepth();
    217     g_uiAddCUDepth  = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() );
    218 
    219     Int  numReorderPics[MAX_TLAYER];
    220 #if R0156_CONF_WINDOW_IN_REP_FORMAT
    221     Window &conformanceWindow = slice->getConformanceWindow();
    222 #else
    223     Window &conformanceWindow = pcSPS->getConformanceWindow();
    224 #endif
    225     Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window();
    226 
    227     for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++)
    228     {
    229 #if USE_DPB_SIZE_TABLE
    230       if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )
    231       {
    232         assert( this->getLayerId() == 0 );
    233         numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);
    234       }
    235       else
    236       {
    237         TComVPS *vps = slice->getVPS();
    238         // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.
    239         numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);
    240       }
    241 #else
    242       numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);
    243 #endif
    244     }
    245 
    246     if (m_cIlpPic[0] == NULL)
    247     {
    248       for (Int j=0; j < m_numDirectRefLayers; j++)
    249       {
    250 
    251         m_cIlpPic[j] = new  TComPic;
    252 
    253 #if AUXILIARY_PICTURES
    254 #if REPN_FORMAT_IN_VPS
    255         m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
    256 #else
    257         m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
    258 #endif
    259 #else
    260 #if REPN_FORMAT_IN_VPS
    261         m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
    262 #else
    263         m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
    264 #endif
    265 #endif
    266         for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++)
    267         {
    268           m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i);
    269         }
    270       }
    271     }
    272   }
    273 }
    274 #endif
    275 
    276199Void TDecTop::deletePicBuffer ( )
    277200{
    278201  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
    279202  Int iSize = Int( m_cListPic.size() );
    280  
     203
    281204  for (Int i = 0; i < iSize; i++ )
    282205  {
     
    292215#else
    293216    pcPic->destroy();
    294    
     217
    295218    delete pcPic;
    296219    pcPic = NULL;
    297220#endif
    298221  }
    299  
     222
    300223  m_cSAO.destroy();
    301  
     224
    302225  m_cLoopFilter.        destroy();
    303226 
     
    318241  Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window();
    319242
    320   for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 
     243  for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++)
    321244  {
    322245#if USE_DPB_SIZE_TABLE
     
    409332#if O0194_DIFFERENT_BITDEPTH_EL_BL
    410333        UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, i);
    411         Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
     334        Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] );
    412335
    413336#if REF_IDX_MFM
    414         if( pcPicYuvRecBase->getWidth() == pcSlice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight() == pcSlice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase )
     337        if( pcPicYuvRecBase->getWidth(COMPONENT_Y) == pcSlice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight(COMPONENT_Y) == pcSlice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase )
    415338        {
    416339          rpcPic->setEqualPictureSizeAndOffsetFlag( i, true );
     
    469392    }
    470393
    471 #if AUXILIARY_PICTURES
    472394#if REPN_FORMAT_IN_VPS
    473395    rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     
    477399                     conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    478400#endif
    479 #else
    480 #if REPN_FORMAT_IN_VPS
    481     rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    482                      conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    483 #else
    484     rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    485                      conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    486 #endif
    487 #endif
    488401
    489402#else //SVC_EXTENSION
    490     rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     403    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    491404                     conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    492405#endif //SVC_EXTENSION
    493406   
    494407    m_cListPic.pushBack( rpcPic );
    495    
     408
    496409    return;
    497410  }
    498  
     411
    499412  Bool bBufferIsAvailable = false;
    500413  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
     
    520433    }
    521434  }
    522  
     435
    523436  if ( !bBufferIsAvailable )
    524437  {
     
    531444
    532445#if SVC_EXTENSION
    533 #if AUXILIARY_PICTURES
    534446#if REPN_FORMAT_IN_VPS
    535447  rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     
    539451                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    540452#endif
    541 #else
    542 #if REPN_FORMAT_IN_VPS
    543   rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    544                    conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    545 
    546 #else
    547   rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    548                    conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
    549 #endif
    550 #endif
    551453#else  //SVC_EXTENSION
    552   rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     454  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    553455                   conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    554456#endif //SVC_EXTENSION
     
    562464    return;
    563465  }
    564  
    565   TComPic*&   pcPic         = m_pcPic;
     466
     467  TComPic*   pcPic         = m_pcPic;
    566468
    567469  // Execute Deblock + Cleanup
     470
    568471  m_cGopDecoder.filterPicture(pcPic);
    569472
    570473  TComSlice::sortPicList( m_cListPic ); // sorting for application output
    571474  poc                 = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
    572   rpcListPic          = &m_cListPic; 
    573   m_cCuDecoder.destroy();       
     475  rpcListPic          = &m_cListPic;
     476  m_cCuDecoder.destroy();
    574477  m_bFirstSliceInPicture  = true;
    575478
     
    577480}
    578481
    579 #if SETTING_NO_OUT_PIC_PRIOR
    580 Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic)
     482Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>* pcListPic)
    581483{
    582   if (!rpcListPic || !m_isNoOutputPriorPics) return;
    583 
    584   TComList<TComPic*>::iterator  iterPic   = rpcListPic->begin();
    585 
    586   while (iterPic != rpcListPic->end())
    587   {
    588     TComPic*& pcPicTmp = *(iterPic++);
     484  if (!pcListPic || !m_isNoOutputPriorPics) return;
     485
     486  TComList<TComPic*>::iterator  iterPic   = pcListPic->begin();
     487
     488  while (iterPic != pcListPic->end())
     489  {
     490    TComPic* pcPicTmp = *(iterPic++);
    589491    if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC())
    590492    {
     
    593495  }
    594496}
    595 #endif
    596 
    597 #if EARLY_REF_PIC_MARKING
    598 Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet)
    599 {
    600   UInt currTid = m_pcPic->getTLayer();
    601   UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1);
    602   UInt latestDecLayerId = m_layerId;
    603   UInt numTargetDecLayers = 0;
    604   Int targetDecLayerIdList[MAX_LAYERS];
    605   UInt latestDecIdx = 0;
    606   TComSlice* pcSlice = m_pcPic->getSlice(0);
    607 
    608   if ( currTid != highestTid )  // Marking  process is only applicaple for highest decoded TLayer
    609   {
    610     return;
    611   }
    612 
    613   // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture
    614   if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N  ||
    615           pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N    ||
    616           pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N   ||
    617           pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N   ||
    618           pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N   ||
    619           pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10     ||
    620           pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12     ||
    621           pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced()))
    622   {
    623     return;
    624   }
    625 
    626   if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers
    627   {
    628     return;
    629   }
    630 
    631   for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++)
    632   {
    633     if ( latestDecLayerId == (*it) )
    634     {
    635       latestDecIdx = numTargetDecLayers;
    636     }
    637     targetDecLayerIdList[numTargetDecLayers++] = (*it);
    638   }
    639 
    640   Int remainingInterLayerReferencesFlag = 0;
    641 #if O0225_MAX_TID_FOR_REF_LAYERS
    642   for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
    643   {
    644     Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]);
    645     if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 )
    646     {
    647 #else
    648   if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 )
    649   {
    650     for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
    651     {
    652 #endif
    653       for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ )
    654       {
    655         if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) )
    656         {
    657           remainingInterLayerReferencesFlag = 1;
    658         }
    659       }
    660     }
    661   }
    662 
    663   if ( remainingInterLayerReferencesFlag == 0 )
    664   {
    665     pcSlice->setReferenced(false);
    666   }
    667 }
    668 #endif
    669 
    670 Void TDecTop::xCreateLostPicture(Int iLostPoc)
     497
     498Void TDecTop::xCreateLostPicture(Int iLostPoc)
    671499{
    672500  printf("\ninserting lost poc : %d\n",iLostPoc);
     
    713541  }
    714542  cFillPic->setCurrSliceIdx(0);
    715   for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++)
    716   {
    717     cFillPic->getCU(i)->initCU(cFillPic,i);
     543  for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++)
     544  {
     545    cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr);
    718546  }
    719547  cFillPic->getSlice(0)->setReferenced(true);
     
    731559{
    732560  m_parameterSetManagerDecoder.applyPrefetchedPS();
    733  
     561
    734562  TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId());
    735563  assert (pps != 0);
     
    854682
    855683#if O0194_DIFFERENT_BITDEPTH_EL_BL
    856       g_bitDepthYLayer[0] = repFormat->getBitDepthVpsLuma();
    857       g_bitDepthCLayer[0] = repFormat->getBitDepthVpsChroma();
     684      g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] = repFormat->getBitDepthVpsLuma();
     685      g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] = repFormat->getBitDepthVpsChroma();
    858686#endif
    859687    }
     
    919747#endif
    920748
    921   if( pps->getDependentSliceSegmentsEnabledFlag() )
    922   {
    923     Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1;
    924 
    925     if (m_cSliceDecoder.getCtxMemSize() != NumCtx)
    926     {
    927       m_cSliceDecoder.initCtxMem(NumCtx);
    928       for ( UInt st = 0; st < NumCtx; st++ )
    929       {
    930         TDecSbac* ctx = NULL;
    931         ctx = new TDecSbac;
    932         ctx->init( &m_cBinCABAC );
    933         m_cSliceDecoder.setCtxMem( ctx, st );
    934       }
    935     }
    936   }
     749#if R0227_REP_FORMAT_CONSTRAINT //Conformance checking for rep format -- rep format of current picture of current layer shall never be greater rep format defined in VPS for the current layer
     750  if ( activeVPS->getVpsExtensionFlag() == 1 && (m_apcSlicePilot->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) )
     751  {
     752    UInt layerId = m_apcSlicePilot->getLayerId();
     753    assert( sps->getPicWidthInLumaSamples()  <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getPicWidthVpsInLumaSamples() );
     754    assert( sps->getPicHeightInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getPicHeightVpsInLumaSamples() );
     755    assert( sps->getChromaFormatIdc()        <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getChromaFormatVpsIdc() );
     756    assert( sps->getBitDepth(CHANNEL_TYPE_LUMA)              <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getBitDepthVpsLuma() );
     757    assert( sps->getBitDepth(CHANNEL_TYPE_CHROMA)            <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getBitDepthVpsChroma() );
     758  }
     759  else if ( activeVPS->getVpsExtensionFlag() == 1 )
     760  {
     761    UInt layerId = m_apcSlicePilot->getLayerId();
     762    assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getPicWidthVpsInLumaSamples()  <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getPicWidthVpsInLumaSamples());
     763    assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getPicHeightVpsInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getPicHeightVpsInLumaSamples());
     764    assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getChromaFormatVpsIdc()        <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getChromaFormatVpsIdc());
     765    assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getBitDepthVpsLuma()           <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getBitDepthVpsLuma());
     766    assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getBitDepthVpsChroma()         <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getBitDepthVpsChroma());
     767  }
     768#endif
    937769
    938770  m_apcSlicePilot->setPPS(pps);
    939771  m_apcSlicePilot->setSPS(sps);
    940772  pps->setSPS(sps);
     773  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : ((pps->getNumTileRowsMinus1() + 1)*(pps->getNumTileColumnsMinus1() + 1)));
     774  pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
     775  pps->setMinCuChromaQpAdjSize( sps->getMaxCUWidth() >> ( pps->getMaxCuChromaQpAdjDepth()) );
     776
     777  for (UInt channel = 0; channel < MAX_NUM_CHANNEL_TYPE; channel++)
     778  {
    941779#if REPN_FORMAT_IN_VPS
    942   pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1);
    943 #else
    944   pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1);
    945 #endif
    946   pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
    947 
    948 #if REPN_FORMAT_IN_VPS
    949   g_bitDepthY     = m_apcSlicePilot->getBitDepthY();
    950   g_bitDepthC     = m_apcSlicePilot->getBitDepthC();
    951 #else
    952   g_bitDepthY     = sps->getBitDepthY();
    953   g_bitDepthC     = sps->getBitDepthC();
    954 #endif
     780    g_bitDepth[channel] = isLuma(ChannelType(channel)) ? m_apcSlicePilot->getBitDepthY() : m_apcSlicePilot->getBitDepthC();
     781#else
     782    g_bitDepth[channel] = sps->getBitDepth(ChannelType(channel));
     783#endif
     784
     785    if (sps->getUseExtendedPrecision()) g_maxTrDynamicRange[channel] = std::max<Int>(15, (g_bitDepth[channel] + 6));
     786    else                                g_maxTrDynamicRange[channel] = 15;
     787  }
    955788  g_uiMaxCUWidth  = sps->getMaxCUWidth();
    956789  g_uiMaxCUHeight = sps->getMaxCUHeight();
    957790  g_uiMaxCUDepth  = sps->getMaxCUDepth();
    958   g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );
     791  g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() + (Int)getMaxCUDepthOffset(sps->getChromaFormatIdc(), sps->getQuadtreeTULog2MinSize()));
    959792
    960793  for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
     
    970803  m_cSAO.destroy();
    971804#if REPN_FORMAT_IN_VPS
    972 #if AUXILIARY_PICTURES
    973   m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() );
    974 #else
    975   m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() );
    976 #endif
    977 #else
    978   m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() );
     805  m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), pps->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), pps->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) );
    979806#endif
    980807  m_cLoopFilter.create( sps->getMaxCUDepth() );
     
    991818#endif
    992819{
    993   TComPic*&   pcPic         = m_pcPic;
    994820#if SVC_EXTENSION
    995821  m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) );
     
    1009835  if (m_bFirstSliceInPicture)
    1010836  {
    1011     m_uiSliceIdx     = 0;
     837    m_uiSliceIdx = 0;
    1012838  }
    1013839  else
    1014840  {
    1015     m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );
     841    m_apcSlicePilot->copySliceInfo( m_pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );
    1016842  }
    1017843  m_apcSlicePilot->setSliceIdx(m_uiSliceIdx);
     
    1027853                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
    1028854  m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag);
    1029  
    1030855  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
    1031856  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
     857
     858#if ENC_DEC_TRACE
     859  const UInt64 originalSymbolCount = g_nSymbolCounter;
     860#endif
    1032861
    1033862#if SVC_EXTENSION
     
    1040869
    1041870  // set POC for dependent slices in skipped pictures
    1042   if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) 
     871  if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped)
    1043872  {
    1044873    m_apcSlicePilot->setPOC(m_skippedPOC);
     
    1048877  m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
    1049878
    1050 #if SETTING_NO_OUT_PIC_PRIOR
    1051879  //For inference of NoOutputOfPriorPicsFlag
    1052880  if (m_apcSlicePilot->getRapPicFlag())
     
    1086914  }
    1087915
    1088   //TODO: HENDRY -- Probably do the checking for max number of positive and negative pics here
    1089 
    1090 
    1091916  //For inference of PicOutputFlag
    1092917  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R)
     
    1097922    }
    1098923  }
    1099 #endif
    1100 
    1101 #if FIX_POC_CRA_NORASL_OUTPUT
     924
    1102925  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1
    1103926  {
     
    1105928    m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) );
    1106929  }
    1107 #endif
    1108930
    1109931  // Skip pictures due to random access
     
    15071329#endif
    15081330#if POC_RESET_IDC_DECODER
    1509   if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId || m_parseIdc == 1) && !m_bFirstSliceInSequence )
    1510 #else
    1511   if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence )
     1331  if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId || m_parseIdc == 1) && !m_bFirstSliceInSequence )
     1332#else
     1333  if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence )
    15121334#endif
    15131335  {
     
    15471369
    15481370  // actual decoding starts here
    1549     xActivateParameterSets();
     1371  xActivateParameterSets();
    15501372
    15511373#if REPN_FORMAT_IN_VPS
     
    15551377  xInitILRP(m_apcSlicePilot);
    15561378#endif
    1557   if (m_apcSlicePilot->isNextSlice())
     1379  if (!m_apcSlicePilot->getDependentSliceSegmentFlag())
    15581380  {
    15591381    m_prevPOC = m_apcSlicePilot->getPOC();
     
    15621384  }
    15631385  m_bFirstSliceInSequence = false;
    1564 #if SETTING_NO_OUT_PIC_PRIOR 
    15651386  m_bFirstSliceInBitstream  = false;
    1566 #endif
    15671387#if POC_RESET_FLAG
    15681388  // This operation would do the following:
     
    16701490#else //SVC_EXTENSION
    16711491  //we should only get a different poc for a new picture (with CTU address==0)
    1672   if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0))
     1492  if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() != 0)) 
    16731493  {
    16741494    printf ("Warning, the first slice of a picture might have been lost!\n");
    16751495  }
     1496
    16761497  // exit when a new picture is found
    1677   if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence )
     1498  if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() == 0 && !m_bFirstSliceInPicture) )
    16781499  {
    16791500    if (m_prevPOC >= m_pocRandomAccess)
    16801501    {
    16811502      m_prevPOC = m_apcSlicePilot->getPOC();
     1503#if ENC_DEC_TRACE
     1504      //rewind the trace counter since we didn't actually decode the slice
     1505      g_nSymbolCounter = originalSymbolCount;
     1506#endif
    16821507      return true;
    16831508    }
     
    16881513  xActivateParameterSets();
    16891514
    1690   if (m_apcSlicePilot->isNextSlice())
     1515  if (!m_apcSlicePilot->getDependentSliceSegmentFlag())
    16911516  {
    16921517    m_prevPOC = m_apcSlicePilot->getPOC();
    16931518  }
    16941519  m_bFirstSliceInSequence = false;
     1520  m_bFirstSliceInBitstream  = false;
    16951521#endif //SVC_EXTENSION
    16961522  //detect lost reference picture and insert copy of earlier frame.
     
    17151541      if( pFile->good() )
    17161542      {
    1717         Bool is16bit  = g_bitDepthYLayer[0] > 8 || g_bitDepthCLayer[0] > 8;
    1718         UInt uiWidth  = pBLPic->getPicYuvRec()->getWidth();
    1719         UInt uiHeight = pBLPic->getPicYuvRec()->getHeight();
     1543        Bool is16bit  = g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] > 8 || g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] > 8;
     1544        UInt uiWidth  = pBLPic->getPicYuvRec()->getWidth(COMPONENT_Y);
     1545        UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(COMPONENT_Y);
    17201546
    17211547        Int len = uiWidth * (is16bit ? 2 : 1);
     
    17311557
    17321558        // read Y component
    1733         Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr();
    1734         UInt uiStride = pBLPic->getPicYuvRec()->getStride();
     1559        Pel* pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Y);
     1560        UInt uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Y);
    17351561        for( Int i = 0; i < uiHeight; i++ )
    17361562        {
     
    17601586
    17611587        // read Cb component
    1762         pPel = pBLPic->getPicYuvRec()->getCbAddr();
    1763         uiStride = pBLPic->getPicYuvRec()->getCStride();
     1588        pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cb);
     1589        uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cb);
    17641590        for( Int i = 0; i < uiHeight; i++ )
    17651591        {
     
    17851611
    17861612        // read Cr component
    1787         pPel = pBLPic->getPicYuvRec()->getCrAddr();
    1788         uiStride = pBLPic->getPicYuvRec()->getCStride();
     1613        pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cr);
     1614        uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cr);
    17891615        for( Int i = 0; i < uiHeight; i++ )
    17901616        {
     
    18251651#endif
    18261652    // Buffer initialize for prediction.
    1827     m_cPrediction.initTempBuff();
     1653    m_cPrediction.initTempBuff(m_apcSlicePilot->getSPS()->getChromaFormatIdc());
    18281654#if ALIGNED_BUMPING
    18291655    m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic);
     
    18321658#endif
    18331659    //  Get a new picture buffer
    1834     xGetNewPicBuffer (m_apcSlicePilot, pcPic);
     1660    xGetNewPicBuffer (m_apcSlicePilot, m_pcPic);
    18351661
    18361662#if POC_RESET_IDC_DECODER
    1837     pcPic->setCurrAuFlag( true );
     1663    m_pcPic->setCurrAuFlag( true );
    18381664#if POC_RESET_RESTRICTIONS
    1839     if( pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag )
     1665    if( m_pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag )
    18401666    {
    18411667      // IDR picture with nuh_layer_id > 0 present
     
    18601686      m_checkPocRestrictionsForCurrAu = true;
    18611687      m_pocResetIdcOrCurrAu = m_apcSlicePilot->getPocResetIdc();
    1862       if( pcPic->getLayerId() == 0 )
     1688      if( m_pcPic->getLayerId() == 0 )
    18631689      {
    18641690        // Base layer picture is present
     
    19411767      if (seiTMVPConstrainsList.size() > 0)
    19421768      {
    1943         assert ( pcPic->getTLayer() == 0 );  //this SEI can present only for AU with Tid equal to 0
     1769        assert ( m_pcPic->getTLayer() == 0 );  //this SEI can present only for AU with Tid equal to 0
    19441770        SEITMVPConstrains* tmvpConstraintSEI = (SEITMVPConstrains*) *(seiTMVPConstrainsList.begin());
    19451771        if ( tmvpConstraintSEI->prev_pics_not_used_flag == 1 )
     
    19501776          {
    19511777            TComPic *refPic = *iterRefPic;
    1952             if( ( refPic->getLayerId() == pcPic->getLayerId() ) && refPic->getReconMark() )
     1778            if( ( refPic->getLayerId() == m_pcPic->getLayerId() ) && refPic->getReconMark() )
    19531779            {
    19541780              for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--)
     
    19701796
    19711797    // transfer any SEI messages that have been received to the picture
    1972     pcPic->setSEIs(m_SEIs);
     1798    m_pcPic->setSEIs(m_SEIs);
    19731799    m_SEIs.clear();
    19741800
    19751801    // Recursive structure
    1976     m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
     1802    m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getChromaFormatIdc() );
    19771803#if SVC_EXTENSION
    19781804    m_cCuDecoder.init   ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId );
     
    19901816    {
    19911817      // Currently only decoding Unit SEI message occurring between VCL NALUs copied
    1992       SEIMessages &picSEI = pcPic->getSEIs();
     1818      SEIMessages &picSEI = m_pcPic->getSEIs();
    19931819      SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
    19941820      picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
     
    19961822    }
    19971823  }
    1998  
     1824
    19991825  //  Set picture slice pointer
    20001826  TComSlice*  pcSlice = m_apcSlicePilot;
    2001   Bool bNextSlice     = pcSlice->isNextSlice();
    2002 
    2003   UInt i;
    2004   pcPic->getPicSym()->initTiles(pcSlice->getPPS());
    2005 
    2006   //generate the Coding Order Map and Inverse Coding Order Map
    2007   UInt uiEncCUAddr;
    2008   for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr))
    2009   {
    2010     pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr);
    2011     pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i);
    2012   }
    2013   pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame());
    2014   pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame());
    2015 
    2016   //convert the start and end CU addresses of the slice and dependent slice into encoding order
    2017   pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) );
    2018   pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) );
    2019   if(pcSlice->isNextSlice())
    2020   {
    2021     pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr()));
    2022     pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr()));
    2023   }
    2024 
    2025   if (m_bFirstSliceInPicture)
    2026   {
    2027     if(pcPic->getNumAllocatedSlice() != 1)
    2028     {
    2029       pcPic->clearSliceBuffer();
     1827
     1828  m_pcPic->getPicSym()->initTiles(pcSlice->getPPS());
     1829  m_pcPic->getPicSym()->initCtuTsRsAddrMaps();
     1830
     1831  // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses.
     1832  // Now, having set up the maps, convert them to the correct form.
     1833  pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) );
     1834  pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) );
     1835  if(!pcSlice->getDependentSliceSegmentFlag())
     1836  {
     1837    pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr()));
     1838    pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr()));
     1839  }
     1840
     1841  if (m_bFirstSliceInPicture)
     1842  {
     1843    if(m_pcPic->getNumAllocatedSlice() != 1)
     1844    {
     1845      m_pcPic->clearSliceBuffer();
    20301846    }
    20311847  }
    20321848  else
    20331849  {
    2034     pcPic->allocateNewSlice();
    2035   }
    2036   assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
    2037   m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx);
    2038   pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);
    2039 
    2040   pcPic->setTLayer(nalu.m_temporalId);
     1850    m_pcPic->allocateNewSlice();
     1851  }
     1852  assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
     1853  m_apcSlicePilot = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx);
     1854  m_pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);
     1855
     1856  m_pcPic->setTLayer(nalu.m_temporalId);
    20411857
    20421858#if SVC_EXTENSION
    2043   pcPic->setLayerId(nalu.m_layerId);
     1859  m_pcPic->setLayerId(nalu.m_layerId);
    20441860  pcSlice->setLayerId(nalu.m_layerId);
    2045   pcSlice->setPic(pcPic);
    2046 #endif
    2047 
    2048   if (bNextSlice)
     1861  pcSlice->setPic(m_pcPic);
     1862#endif
     1863
     1864  if (!pcSlice->getDependentSliceSegmentFlag())
    20491865  {
    20501866    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
     
    20631879      if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) )
    20641880#endif
    2065       for( i = 0; i < pcSlice->getNumILRRefIdx(); i++ )
     1881      for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ )
    20661882      {
    20671883        UInt refLayerIdc = i;
     
    21241940#if REF_REGION_OFFSET
    21251941        const Window &windowRL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
    2126         Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth() - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset();
    2127         Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset();
    2128 #else
    2129         Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();
    2130         Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();
     1942        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(COMPONENT_Y) - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset();
     1943        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(COMPONENT_Y) - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset();
     1944#else
     1945        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(COMPONENT_Y);
     1946        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(COMPONENT_Y);
    21311947#if Q0200_CONFORMANCE_BL_SIZE
    21321948        Int chromaFormatIdc = pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc();
     
    21361952#endif
    21371953#endif
    2138         Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    2139         Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     1954        Int widthEL   = m_pcPic->getPicYuvRec()->getWidth(COMPONENT_Y)  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     1955        Int heightEL  = m_pcPic->getPicYuvRec()->getHeight(COMPONENT_Y) - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
    21401956
    21411957#if RESAMPLING_FIX
     
    21882004#endif
    21892005#if SVC_EXTENSION
    2190         if( pcPic->isSpatialEnhLayer(refLayerIdc) )
     2006        if( m_pcPic->isSpatialEnhLayer(refLayerIdc) )
    21912007        {
    21922008          // check for the sample prediction picture type
     
    21962012#if O0194_JOINT_US_BITSHIFT
    21972013#if Q0048_CGS_3D_ASYMLUT
    2198             m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
    2199 #else
    2200             m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     2014            m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     2015#else
     2016            m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
    22012017#endif
    22022018#else
    22032019#if Q0048_CGS_3D_ASYMLUT
    22042020#if MOVE_SCALED_OFFSET_TO_PPS
    2205           m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
    2206 #else
    2207           m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
    2208 #endif
    2209 #else
    2210           m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     2021          m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
     2022#else
     2023          m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
     2024#endif
     2025#else
     2026          m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    22112027#endif
    22122028#endif
     
    22152031#if Q0048_CGS_3D_ASYMLUT
    22162032#if REF_REGION_OFFSET
    2217           m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, altRL );
    2218 #else
    2219           m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    2220 #endif
    2221 #else
    2222           m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     2033          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL, altRL );
     2034#else
     2035          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL );
     2036#endif
     2037#else
     2038          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL );
    22232039#endif
    22242040#else
    22252041#if Q0048_CGS_3D_ASYMLUT
    2226             m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    2227 #else
    2228             m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     2042            m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL );
     2043#else
     2044            m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL );
    22292045#endif
    22302046#endif
     
    22342050        else
    22352051        {
    2236           pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );
    2237         }
    2238         pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
     2052          m_pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );
     2053        }
     2054        pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) );
    22392055#endif //SVC_EXTENSION
    22402056      }
     
    22432059    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
    22442060    {
    2245       for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     2061      for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
    22462062      {
    22472063        UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
     
    22752091#endif
    22762092
    2277         pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
     2093        pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) );
    22782094      }
    22792095
     
    23742190            bLowDelay = false;
    23752191          }
    2376         }       
    2377       }
    2378 
    2379       pcSlice->setCheckLDC(bLowDelay);           
     2192        }
     2193      }
     2194
     2195      pcSlice->setCheckLDC(bLowDelay);
    23802196    }
    23812197
     
    23842200  }
    23852201
    2386   pcPic->setCurrSliceIdx(m_uiSliceIdx);
     2202  m_pcPic->setCurrSliceIdx(m_uiSliceIdx);
    23872203  if(pcSlice->getSPS()->getScalingListFlag())
    23882204  {
     
    23992215      pcSlice->setDefaultScalingList();
    24002216    }
    2401     m_cTrQuant.setScalingListDec(pcSlice->getScalingList());
     2217    m_cTrQuant.setScalingListDec(pcSlice->getScalingList(), pcSlice->getSPS()->getChromaFormatIdc());
    24022218    m_cTrQuant.setUseScalingList(true);
    24032219  }
    24042220  else
    24052221  {
    2406     m_cTrQuant.setFlatScalingList();
     2222    m_cTrQuant.setFlatScalingList(pcSlice->getSPS()->getChromaFormatIdc());
    24072223    m_cTrQuant.setUseScalingList(false);
    24082224  }
    24092225
    24102226  //  Decode a picture
    2411   m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic);
     2227  m_cGopDecoder.decompressSlice(nalu.m_Bitstream, m_pcPic);
    24122228
    24132229#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     
    24242240{
    24252241  TComVPS* vps = new TComVPS();
    2426  
     2242
    24272243  m_cEntropyDecoder.decodeVPS( vps );
    2428   m_parameterSetManagerDecoder.storePrefetchedVPS(vps); 
     2244  m_parameterSetManagerDecoder.storePrefetchedVPS(vps);
    24292245}
    24302246
     
    24332249{
    24342250  TComSPS* sps = new TComSPS();
     2251#if O0043_BEST_EFFORT_DECODING
     2252  sps->setForceDecodeBitDepth(m_forceDecodeBitDepth);
     2253#endif
    24352254  sps->setLayerId(m_layerId);
    24362255#if SPS_DPB_PARAMS
     
    24712290{
    24722291  TComSPS* sps = new TComSPS();
     2292#if O0043_BEST_EFFORT_DECODING
     2293  sps->setForceDecodeBitDepth(m_forceDecodeBitDepth);
     2294#endif
    24732295  m_cEntropyDecoder.decodeSPS( sps );
    24742296  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
     
    24932315    }
    24942316#if LAYERS_NOT_PRESENT_SEI
    2495     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
    2496 #else
    2497     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
     2317    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
     2318#else
     2319    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
    24982320#endif
    24992321  }
     
    25012323  {
    25022324#if LAYERS_NOT_PRESENT_SEI
    2503     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
    2504 #else
    2505     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
     2325    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
     2326#else
     2327    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
    25062328#endif
    25072329    SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
     
    25392361  {
    25402362#if LAYERS_NOT_PRESENT_SEI
    2541     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
    2542 #else
    2543     m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
     2363    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream  );
     2364#else
     2365    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
     2366
    25442367#endif
    25452368  }
     
    25472370  {
    25482371#if LAYERS_NOT_PRESENT_SEI
    2549     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
    2550 #else
    2551     m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
     2372    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
     2373#else
     2374    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
    25522375#endif
    25532376    SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
     
    25902413#endif
    25912414      xDecodeVPS();
     2415#if RExt__DECODER_DEBUG_BIT_STATISTICS
     2416      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
     2417#endif
    25922418#if Q0177_EOS_CHECKS
    25932419      m_isLastNALWasEos = false;
     
    26132439#endif
    26142440      return false;
    2615      
     2441
    26162442    case NAL_UNIT_SPS:
    26172443      xDecodeSPS();
     2444#if RExt__DECODER_DEBUG_BIT_STATISTICS
     2445      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
     2446#endif
    26182447      return false;
    26192448
     
    26242453#endif
    26252454        );
     2455#if RExt__DECODER_DEBUG_BIT_STATISTICS
     2456      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
     2457#endif
    26262458      return false;
    2627      
     2459
    26282460    case NAL_UNIT_PREFIX_SEI:
    26292461    case NAL_UNIT_SUFFIX_SEI:
     
    26732505#endif
    26742506      break;
    2675      
     2507
    26762508    case NAL_UNIT_EOS:
    26772509#if Q0177_EOS_CHECKS
     
    26892521      m_pocRandomAccess = MAX_INT;
    26902522      m_prevPOC = MAX_INT;
    2691       m_bFirstSliceInPicture = true;
    2692       m_bFirstSliceInSequence = true;
    26932523      m_prevSliceSkipped = false;
    26942524      m_skippedPOC = 0;
    26952525      return false;
    2696      
     2526
    26972527    case NAL_UNIT_ACCESS_UNIT_DELIMITER:
    26982528      // TODO: process AU delimiter
    26992529      return false;
    2700      
     2530
    27012531    case NAL_UNIT_EOB:
    27022532#if P0130_EOB
     
    27082538#endif
    27092539      return false;
    2710      
     2540
    27112541    case NAL_UNIT_FILLER_DATA:
    27122542#if Q0177_EOS_CHECKS
     
    27142544#endif
    27152545      return false;
    2716      
     2546
    27172547    case NAL_UNIT_RESERVED_VCL_N10:
    27182548    case NAL_UNIT_RESERVED_VCL_R11:
     
    27212551    case NAL_UNIT_RESERVED_VCL_N14:
    27222552    case NAL_UNIT_RESERVED_VCL_R15:
    2723      
     2553
    27242554    case NAL_UNIT_RESERVED_IRAP_VCL22:
    27252555    case NAL_UNIT_RESERVED_IRAP_VCL23:
    2726      
     2556
    27272557    case NAL_UNIT_RESERVED_VCL24:
    27282558    case NAL_UNIT_RESERVED_VCL25:
     
    27332563    case NAL_UNIT_RESERVED_VCL30:
    27342564    case NAL_UNIT_RESERVED_VCL31:
    2735      
     2565
    27362566    case NAL_UNIT_RESERVED_NVCL41:
    27372567    case NAL_UNIT_RESERVED_NVCL42:
     
    27602590    default:
    27612591      assert (0);
     2592      break;
    27622593  }
    27632594
     
    27732604Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
    27742605{
    2775   if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && 
     2606  if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) &&
    27762607       m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
    27772608  {
     
    27912622 * If the random access point is CRA/CRANT/BLA/BLANT, TFD pictures with POC less than the POC of the random access point are skipped.
    27922623 * If the random access point is IDR all pictures after the random access point are decoded.
    2793  * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC 
    2794  * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random 
     2624 * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC
     2625 * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random
    27952626 * access point there is no guarantee that the decoder will not crash.
    27962627 */
    27972628Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay)
    27982629{
    2799   if (iSkipFrame) 
     2630  if (iSkipFrame)
    28002631  {
    28012632    iSkipFrame--;   // decrement the counter
     
    28162647      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
    28172648    }
    2818     else 
     2649    else
    28192650    {
    28202651      static Bool warningMessage = false;
     
    28342665  }
    28352666  // if we reach here, then the picture is not skipped.
    2836   return false; 
     2667  return false;
    28372668}
    28382669
    28392670#if SVC_EXTENSION
     2671#if !REPN_FORMAT_IN_VPS
     2672Void TDecTop::xInitILRP(TComSPS *pcSPS)
     2673#else
     2674Void TDecTop::xInitILRP(TComSlice *slice)
     2675#endif
     2676{
     2677#if REPN_FORMAT_IN_VPS
     2678  TComSPS* pcSPS = slice->getSPS();
     2679  Int bitDepthY   = slice->getBitDepthY();
     2680  Int bitDepthC   = slice->getBitDepthC();
     2681  Int picWidth    = slice->getPicWidthInLumaSamples();
     2682  Int picHeight   = slice->getPicHeightInLumaSamples();
     2683#endif
     2684  if(m_layerId>0)
     2685  {
     2686#if REPN_FORMAT_IN_VPS
     2687    g_bitDepth[CHANNEL_TYPE_LUMA]     = bitDepthY;
     2688    g_bitDepth[CHANNEL_TYPE_CHROMA]   = bitDepthC;
     2689#else
     2690    g_bitDepth[CHANNEL_TYPE_LUMA]     = pcSPS->getBitDepthY();
     2691    g_bitDepth[CHANNEL_TYPE_CHROMA]   = pcSPS->getBitDepthC();
     2692#endif
     2693    g_uiMaxCUWidth  = pcSPS->getMaxCUWidth();
     2694    g_uiMaxCUHeight = pcSPS->getMaxCUHeight();
     2695    g_uiMaxCUDepth  = pcSPS->getMaxCUDepth();
     2696    g_uiAddCUDepth  = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() );
     2697
     2698    Int  numReorderPics[MAX_TLAYER];
     2699#if R0156_CONF_WINDOW_IN_REP_FORMAT
     2700    Window &conformanceWindow = slice->getConformanceWindow();
     2701#else
     2702    Window &conformanceWindow = pcSPS->getConformanceWindow();
     2703#endif
     2704    Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window();
     2705
     2706    for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++)
     2707    {
     2708#if USE_DPB_SIZE_TABLE
     2709      if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )
     2710      {
     2711        assert( this->getLayerId() == 0 );
     2712        numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);
     2713      }
     2714      else
     2715      {
     2716        TComVPS *vps = slice->getVPS();
     2717        // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.
     2718        numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);
     2719      }
     2720#else
     2721      numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);
     2722#endif
     2723    }
     2724
     2725    if (m_cIlpPic[0] == NULL)
     2726    {
     2727      for (Int j=0; j < m_numDirectRefLayers; j++)
     2728      {
     2729
     2730        m_cIlpPic[j] = new  TComPic;
     2731
     2732#if AUXILIARY_PICTURES
     2733#if REPN_FORMAT_IN_VPS
     2734        m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
     2735#else
     2736        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
     2737#endif
     2738#else
     2739#if REPN_FORMAT_IN_VPS
     2740        m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
     2741#else
     2742        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
     2743#endif
     2744#endif
     2745        for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCtusInFrame(); i++)
     2746        {
     2747          m_cIlpPic[j]->getPicSym()->getCtu(i)->initCtu(m_cIlpPic[j], i);
     2748        }
     2749      }
     2750    }
     2751  }
     2752}
     2753
    28402754#if VPS_EXTN_DIRECT_REF_LAYERS
    28412755TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc )
     
    29022816  }
    29032817}
    2904 
     2818#endif
     2819
     2820#if EARLY_REF_PIC_MARKING
     2821Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet)
     2822{
     2823  UInt currTid = m_pcPic->getTLayer();
     2824  UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1);
     2825  UInt latestDecLayerId = m_layerId;
     2826  UInt numTargetDecLayers = 0;
     2827  Int targetDecLayerIdList[MAX_LAYERS];
     2828  UInt latestDecIdx = 0;
     2829  TComSlice* pcSlice = m_pcPic->getSlice(0);
     2830
     2831  if ( currTid != highestTid )  // Marking  process is only applicaple for highest decoded TLayer
     2832  {
     2833    return;
     2834  }
     2835
     2836  // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture
     2837  if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N  ||
     2838          pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N    ||
     2839          pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N   ||
     2840          pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N   ||
     2841          pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N   ||
     2842          pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10     ||
     2843          pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12     ||
     2844          pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced()))
     2845  {
     2846    return;
     2847  }
     2848
     2849  if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers
     2850  {
     2851    return;
     2852  }
     2853
     2854  for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++)
     2855  {
     2856    if ( latestDecLayerId == (*it) )
     2857    {
     2858      latestDecIdx = numTargetDecLayers;
     2859    }
     2860    targetDecLayerIdList[numTargetDecLayers++] = (*it);
     2861  }
     2862
     2863  Int remainingInterLayerReferencesFlag = 0;
     2864#if O0225_MAX_TID_FOR_REF_LAYERS
     2865  for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
     2866  {
     2867    Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]);
     2868    if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 )
     2869    {
     2870#else
     2871  if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 )
     2872  {
     2873    for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
     2874    {
     2875#endif
     2876      for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ )
     2877      {
     2878        if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) )
     2879        {
     2880          remainingInterLayerReferencesFlag = 1;
     2881        }
     2882      }
     2883    }
     2884  }
     2885
     2886  if ( remainingInterLayerReferencesFlag == 0 )
     2887  {
     2888    pcSlice->setReferenced(false);
     2889  }
     2890}
    29052891#endif
    29062892
Note: See TracChangeset for help on using the changeset viewer.