source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp @ 1136

Last change on this file since 1136 was 1133, checked in by seregin, 9 years ago

macro cleanup: O0142_CONDITIONAL_SPS_EXTENSION, Q0177_SPS_TEMP_NESTING_FIX

  • Property svn:eol-style set to native
File size: 104.1 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2014, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TDecTop.cpp
35    \brief    decoder class
36*/
37
38#include "NALread.h"
39#include "TDecTop.h"
40#if RExt__DECODER_DEBUG_BIT_STATISTICS
41#include "TLibCommon/TComCodingStatistics.h"
42#endif
43
44#if SVC_EXTENSION
45UInt  TDecTop::m_prevPOC = MAX_UINT;
46UInt  TDecTop::m_uiPrevLayerId = MAX_UINT;
47Bool  TDecTop::m_bFirstSliceInSequence = true;
48#if POC_RESET_RESTRICTIONS
49Bool  TDecTop::m_checkPocRestrictionsForCurrAu       = false;
50Int   TDecTop::m_pocResetIdcOrCurrAu                 = -1;
51Bool  TDecTop::m_baseLayerIdrFlag                    = false;
52Bool  TDecTop::m_baseLayerPicPresentFlag             = false;
53Bool  TDecTop::m_baseLayerIrapFlag                   = false;
54Bool  TDecTop::m_nonBaseIdrPresentFlag               = false;
55Int   TDecTop::m_nonBaseIdrType                      = -1;
56Bool  TDecTop::m_picNonIdrWithRadlPresentFlag        = false;
57Bool  TDecTop::m_picNonIdrNoLpPresentFlag            = false;
58#endif
59#if POC_RESET_VALUE_RESTRICTION
60Int   TDecTop::m_crossLayerPocResetPeriodId          = -1;
61Int   TDecTop::m_crossLayerPocResetIdc               = -1;
62#endif
63#endif
64
65//! \ingroup TLibDecoder
66//! \{
67
68TDecTop::TDecTop()
69  : m_pDecodedSEIOutputStream(NULL)
70{
71  m_pcPic = 0;
72  m_iMaxRefPicNum = 0;
73#if ENC_DEC_TRACE
74  if (g_hTrace == NULL)
75  {
76    g_hTrace = fopen( "TraceDec.txt", "wb" );
77  }
78  g_bJustDoIt = g_bEncDecTraceDisable;
79  g_nSymbolCounter = 0;
80#endif
81  m_associatedIRAPType = NAL_UNIT_INVALID;
82  m_pocCRA = 0;
83  m_pocRandomAccess = MAX_INT;
84#if !SVC_EXTENSION
85  m_prevPOC                = MAX_INT;
86#endif
87  m_bFirstSliceInPicture    = true;
88#if !SVC_EXTENSION
89  m_bFirstSliceInSequence   = true;
90#endif
91  m_prevSliceSkipped = false;
92  m_skippedPOC = 0;
93  m_bFirstSliceInBitstream  = true;
94  m_lastPOCNoOutputPriorPics = -1;
95  m_craNoRaslOutputFlag = false;
96  m_isNoOutputPriorPics = false;
97
98#if SVC_EXTENSION
99  m_layerId = 0;
100  m_smallestLayerId = 0;
101#if AVC_BASE
102  m_pBLReconFile = NULL;
103#endif
104  memset(m_cIlpPic, 0, sizeof(m_cIlpPic));
105#if Q0177_EOS_CHECKS
106  m_isLastNALWasEos = false;
107#endif
108  m_lastPicHasEos = false;
109#if NO_CLRAS_OUTPUT_FLAG
110  m_noClrasOutputFlag          = false;
111  m_layerInitializedFlag       = false;
112  m_firstPicInLayerDecodedFlag = false; 
113#endif
114#if POC_RESET_IDC_DECODER
115  m_parseIdc = -1;
116  m_lastPocPeriodId = -1;
117  m_prevPicOrderCnt = 0;
118#endif
119#if Q0048_CGS_3D_ASYMLUT
120  m_pColorMappedPic = NULL;
121#endif
122
123#if POC_RESET_RESTRICTIONS
124  resetPocRestrictionCheckParameters();
125#endif
126#if P0297_VPS_POC_LSB_ALIGNED_FLAG
127  m_pocResettingFlag        = false;
128  m_pocDecrementedInDPBFlag = false;
129#endif
130#if CONFORMANCE_BITSTREAM_MODE
131  m_confModeFlag = false;
132#endif
133  m_isOutputLayerFlag = false;
134#endif //SVC_EXTENSION
135}
136
137TDecTop::~TDecTop()
138{
139#if ENC_DEC_TRACE
140  if (g_hTrace != stdout)
141  {
142    fclose( g_hTrace );
143  }
144#endif
145#if Q0048_CGS_3D_ASYMLUT
146  if(m_pColorMappedPic)
147  {
148    m_pColorMappedPic->destroy();
149    delete m_pColorMappedPic;
150    m_pColorMappedPic = NULL;
151  }
152#endif
153}
154
155Void TDecTop::create()
156{
157#if SVC_EXTENSION
158  m_cGopDecoder.create( m_layerId );
159#else
160  m_cGopDecoder.create();
161#endif
162  m_apcSlicePilot = new TComSlice;
163  m_uiSliceIdx = 0;
164}
165
166Void TDecTop::destroy()
167{
168  m_cGopDecoder.destroy();
169
170  delete m_apcSlicePilot;
171  m_apcSlicePilot = NULL;
172
173  m_cSliceDecoder.destroy();
174#if SVC_EXTENSION
175  for(Int i=0; i<MAX_NUM_REF; i++)
176  {
177    if(m_cIlpPic[i])
178    {
179      m_cIlpPic[i]->destroy();
180      delete m_cIlpPic[i];
181      m_cIlpPic[i] = NULL;
182    }
183  }
184#endif
185}
186
187Void TDecTop::init()
188{
189#if !SVC_EXTENSION
190  // initialize ROM
191  initROM();
192#endif
193#if SVC_EXTENSION
194  m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
195  m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder, m_cSAO.getSaoMaxOffsetQVal() );
196#else
197  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
198  m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder );
199#endif
200  m_cEntropyDecoder.init(&m_cPrediction);
201}
202
203Void TDecTop::deletePicBuffer ( )
204{
205  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
206  Int iSize = Int( m_cListPic.size() );
207
208  for (Int i = 0; i < iSize; i++ )
209  {
210    TComPic* pcPic = *(iterPic++);
211#if SVC_EXTENSION
212    if( pcPic )
213    {
214      pcPic->destroy();
215
216      delete pcPic;
217      pcPic = NULL;
218    }
219#else
220    pcPic->destroy();
221
222    delete pcPic;
223    pcPic = NULL;
224#endif
225  }
226
227  m_cSAO.destroy();
228
229  m_cLoopFilter.        destroy();
230 
231#if !SVC_EXTENSION
232  // destroy ROM
233  destroyROM();
234#endif
235}
236
237Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic )
238{
239  Int  numReorderPics[MAX_TLAYER];
240#if SVC_EXTENSION
241  Window &conformanceWindow = pcSlice->getConformanceWindow();
242#else
243  Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow();
244#endif
245  Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window();
246
247  for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++)
248  {
249#if USE_DPB_SIZE_TABLE
250    if( m_commonDecoderParams->getTargetOutputLayerSetIdx() == 0 )
251    {
252      assert( this->getLayerId() == 0 );
253      numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer);
254    }
255    else
256    {
257      TComVPS *vps = pcSlice->getVPS();
258      // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.
259      numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);
260    }
261#else
262    numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer);
263#endif
264  }
265
266#if USE_DPB_SIZE_TABLE
267  if( m_commonDecoderParams->getTargetOutputLayerSetIdx() == 0 )
268  {
269    assert( this->getLayerId() == 0 );
270    m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
271  }
272  else
273  {
274    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( m_commonDecoderParams->getTargetOutputLayerSetIdx(), pcSlice->getVPS()->getLayerIdcForOls( pcSlice->getVPS()->getOutputLayerSetIdx( m_commonDecoderParams->getTargetOutputLayerSetIdx()), pcSlice->getLayerId() ), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
275  }
276#else
277  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
278#endif
279
280#if SVC_EXTENSION
281  m_iMaxRefPicNum += 1; // it should be updated if more than 1 resampling picture is used
282#endif
283
284  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
285  {
286    rpcPic = new TComPic();
287
288#if SVC_EXTENSION
289    if(m_layerId > 0)
290    {
291      xSetSpatialEnhLayerFlag( pcSlice, rpcPic );
292    }
293
294#if REPN_FORMAT_IN_VPS
295    rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, 
296                     conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
297#else
298    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, 
299                     conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
300#endif
301
302#else //SVC_EXTENSION
303    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
304                     conformanceWindow, defaultDisplayWindow, numReorderPics, true);
305#endif //SVC_EXTENSION
306   
307    m_cListPic.pushBack( rpcPic );
308
309    return;
310  }
311
312  Bool bBufferIsAvailable = false;
313  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
314  while (iterPic != m_cListPic.end())
315  {
316    rpcPic = *(iterPic++);
317    if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false)
318    {
319      rpcPic->setOutputMark(false);
320      bBufferIsAvailable = true;
321      break;
322    }
323
324    if ( rpcPic->getSlice( 0 )->isReferenced() == false  && rpcPic->getOutputMark() == false)
325    {
326#if !SVC_EXTENSION
327      rpcPic->setOutputMark(false);
328#endif
329      rpcPic->setReconMark( false );
330      rpcPic->getPicYuvRec()->setBorderExtension( false );
331      bBufferIsAvailable = true;
332      break;
333    }
334  }
335
336  if ( !bBufferIsAvailable )
337  {
338    //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer.
339    m_iMaxRefPicNum++;
340    rpcPic = new TComPic();
341    m_cListPic.pushBack( rpcPic );
342  }
343  rpcPic->destroy();
344
345#if SVC_EXTENSION
346  if( m_layerId > 0 )
347  {
348    xSetSpatialEnhLayerFlag( pcSlice, rpcPic );
349  }
350
351#if REPN_FORMAT_IN_VPS
352  rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
353                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
354#else
355  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
356                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
357#endif
358#else  //SVC_EXTENSION
359  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
360                   conformanceWindow, defaultDisplayWindow, numReorderPics, true);
361#endif //SVC_EXTENSION
362}
363
364Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic)
365{
366  if (!m_pcPic)
367  {
368    /* nothing to deblock */
369    return;
370  }
371
372  TComPic*   pcPic         = m_pcPic;
373
374  // Execute Deblock + Cleanup
375
376  m_cGopDecoder.filterPicture(pcPic);
377
378#if SVC_EXTENSION
379  if( this->getLayerDec(pcPic->getLayerId())->m_isOutputLayerFlag == false )
380  {
381    pcPic->setOutputMark( false );
382  }
383#endif
384
385  TComSlice::sortPicList( m_cListPic ); // sorting for application output
386  poc                 = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
387  rpcListPic          = &m_cListPic;
388  m_cCuDecoder.destroy();
389  m_bFirstSliceInPicture  = true;
390
391  return;
392}
393
394Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>* pcListPic)
395{
396  if (!pcListPic || !m_isNoOutputPriorPics) return;
397
398  TComList<TComPic*>::iterator  iterPic   = pcListPic->begin();
399
400  while (iterPic != pcListPic->end())
401  {
402    TComPic* pcPicTmp = *(iterPic++);
403    if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC())
404    {
405      pcPicTmp->setOutputMark(false);
406    }
407  }
408}
409
410Void TDecTop::xCreateLostPicture(Int iLostPoc)
411{
412  printf("\ninserting lost poc : %d\n",iLostPoc);
413  TComSlice cFillSlice;
414  cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
415  cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
416#if SVC_EXTENSION
417  cFillSlice.setVPS( m_parameterSetManagerDecoder.getFirstVPS() );
418  cFillSlice.initSlice( m_layerId );
419#else
420  cFillSlice.initSlice();
421#endif
422  TComPic *cFillPic;
423  xGetNewPicBuffer(&cFillSlice,cFillPic);
424  cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
425  cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
426#if SVC_EXTENSION
427  cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder.getFirstVPS() );
428  cFillPic->getSlice(0)->initSlice( m_layerId );
429#else
430  cFillPic->getSlice(0)->initSlice();
431#endif
432 
433  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
434  Int closestPoc = 1000000;
435  while ( iterPic != m_cListPic.end())
436  {
437    TComPic * rpcPic = *(iterPic++);
438    if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)<closestPoc&&abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)!=0&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC())
439    {
440      closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc);
441    }
442  }
443  iterPic = m_cListPic.begin();
444  while ( iterPic != m_cListPic.end())
445  {
446    TComPic *rpcPic = *(iterPic++);
447    if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC())
448    {
449      printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC());
450      rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec());
451      break;
452    }
453  }
454  cFillPic->setCurrSliceIdx(0);
455  for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++)
456  {
457    cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr);
458  }
459  cFillPic->getSlice(0)->setReferenced(true);
460  cFillPic->getSlice(0)->setPOC(iLostPoc);
461  cFillPic->setReconMark(true);
462  cFillPic->setOutputMark(true);
463  if(m_pocRandomAccess == MAX_INT)
464  {
465    m_pocRandomAccess = iLostPoc;
466  }
467}
468
469
470Void TDecTop::xActivateParameterSets()
471{
472  m_parameterSetManagerDecoder.applyPrefetchedPS();
473
474  TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId());
475  assert (pps != 0);
476
477  TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId());
478  assert (sps != 0);
479
480  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
481  {
482    printf ("Parameter set activation failed!");
483    assert (0);
484  }
485
486#if SCALINGLIST_INFERRING
487  // scaling list settings and checks
488  TComVPS *activeVPS = m_parameterSetManagerDecoder.getActiveVPS();
489  TComSPS *activeSPS = m_parameterSetManagerDecoder.getActiveSPS();
490  TComPPS *activePPS = m_parameterSetManagerDecoder.getActivePPS();
491
492  if( activeSPS->getInferScalingListFlag() )
493  {
494    UInt refLayerId = activeSPS->getScalingListRefLayerId();
495    TComSPS *refSps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL );
496
497    // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0
498    if( activeVPS->getNonHEVCBaseLayerFlag() )
499    {
500      assert( refLayerId > 0 );
501    }
502
503    // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and
504    // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id
505    assert( refSps->getInferScalingListFlag() == false );
506
507    // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,
508    // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB
509    assert( activeVPS->getRecursiveRefLayerFlag( activeSPS->getLayerId(), refLayerId ) == true );
510   
511    if( activeSPS->getScalingList() != refSps->getScalingList() )
512    {
513      // delete created instance of scaling list since it will be inferred
514      delete activeSPS->getScalingList();
515
516      // infer scaling list
517      activeSPS->setScalingList( refSps->getScalingList() );
518    }
519  }
520
521  if( activePPS->getInferScalingListFlag() )
522  {
523    UInt refLayerId = activePPS->getScalingListRefLayerId();
524    TComPPS *refPps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL );
525
526    // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0
527    if( activeVPS->getNonHEVCBaseLayerFlag() )
528    {
529      assert( refLayerId > 0 );
530    }
531
532    // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and
533    // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id
534    assert( refPps->getInferScalingListFlag() == false );
535
536    // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,
537    // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB
538    assert( activeVPS->getRecursiveRefLayerFlag( activePPS->getLayerId(), refLayerId ) == true );
539   
540    if( activePPS->getScalingList() != refPps->getScalingList() )
541    {
542      // delete created instance of scaling list since it will be inferred
543      delete activePPS->getScalingList();
544
545      // infer scaling list
546      activePPS->setScalingList( refPps->getScalingList() );
547    }
548
549  }
550#endif
551
552#if AVC_BASE
553  if( activeVPS->getNonHEVCBaseLayerFlag() )
554  {
555    TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
556    if( m_layerId > 0 && pBLPic->getPicYuvRec() == NULL )
557    {
558      UInt refLayerId = 0;
559      RepFormat* repFormat = activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(refLayerId) );
560
561      Int  numReorderPics[MAX_TLAYER];
562      Window defaultDisplayWindow;
563
564#if AUXILIARY_PICTURES
565      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true);
566#else
567      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true);
568#endif
569      // it is needed where the VPS is accessed through the slice
570      pBLPic->getSlice(0)->setVPS( activeVPS );
571
572#if O0194_DIFFERENT_BITDEPTH_EL_BL
573      g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] = repFormat->getBitDepthVpsLuma();
574      g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] = repFormat->getBitDepthVpsChroma();
575#endif
576    }
577  }
578#endif
579
580#if SPS_DPB_PARAMS
581  if( m_layerId > 0 )
582  {
583    // When not present sps_max_sub_layers_minus1 is inferred to be equal to vps_max_sub_layers_minus1.
584    sps->setMaxTLayers( activeVPS->getMaxTLayers() );
585
586    // When not present sps_temporal_id_nesting_flag is inferred to be equal to vps_temporal_id_nesting_flag
587    sps->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? activeVPS->getTemporalNestingFlag() : true );
588
589    // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive, due to nuh_layer_id being greater than 0,
590    // it is inferred to be equal to max_vps_dec_pic_buffering_minus1[ TargetOptLayerSetIdx ][ currLayerId ][ i ] of the active VPS, where currLayerId is the nuh_layer_id of the layer that refers to the SPS.
591    for(UInt i=0; i < sps->getMaxTLayers(); i++)
592    {
593      // to avoid compiler warning "array subscript is above array bounds"
594      assert( i < MAX_TLAYER );
595
596      // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive,
597      // due to MultiLayerExtSpsFlag being equal to 1, for a layer that refers to the SPS and has nuh_layer_id equal to currLayerId,
598      // the value of sps_max_dec_pic_buffering_minus1[ i ] is inferred to be equal to max_vps_dec_pic_buffering_minus1[ TargetOlsIdx ][ layerIdx ][ i ] of the active VPS,
599      // where layerIdx is equal to the value such that LayerSetLayerIdList[ TargetDecLayerSetIdx ][ layerIdx ] is equal to currLayerId.
600      if( sps->getMultiLayerExtSpsFlag() )
601      {
602        sps->setMaxDecPicBuffering( activeVPS->getMaxVpsDecPicBufferingMinus1( m_commonDecoderParams->getTargetOutputLayerSetIdx(), activeVPS->getLayerIdcForOls( activeVPS->getOutputLayerSetIdx( m_commonDecoderParams->getTargetOutputLayerSetIdx() ), m_layerId ), i) + 1, i);
603      }
604
605      // The value of sps_max_dec_pic_buffering_minus1[ i ] shall be less than or equal to vps_max_dec_pic_buffering_minus1[ i ] for each value of i.
606      assert( sps->getMaxDecPicBuffering(i) <= activeVPS->getMaxDecPicBuffering(i) );     
607    }
608
609#if P0182_VPS_VUI_PS_FLAG
610    UInt layerIdx = activeVPS->getLayerIdxInVps( m_layerId );
611
612    if( activeVPS->getBaseLayerPSCompatibilityFlag(layerIdx) )
613    {
614      RepFormat* repFormat = activeVPS->getVpsRepFormat(activeVPS->getVpsRepFormatIdx(layerIdx));
615
616      assert( pps->getLayerId() == 0 );
617      assert( sps->getLayerId() == 0 );
618      assert( repFormat->getChromaFormatVpsIdc() == sps->getChromaFormatIdc() );
619      assert( repFormat->getSeparateColourPlaneVpsFlag() == 0 );
620      assert( repFormat->getPicHeightVpsInLumaSamples() == sps->getPicHeightInLumaSamples() );
621      assert( repFormat->getPicWidthVpsInLumaSamples()  == sps->getPicWidthInLumaSamples() );
622      assert( repFormat->getBitDepthVpsLuma()   == sps->getBitDepth(CHANNEL_TYPE_LUMA) );
623      assert( repFormat->getBitDepthVpsChroma() == sps->getBitDepth(CHANNEL_TYPE_CHROMA) );
624      assert( repFormat->getConformanceWindowVps().getWindowLeftOffset()   == sps->getConformanceWindow().getWindowLeftOffset() );
625      assert( repFormat->getConformanceWindowVps().getWindowRightOffset()  == sps->getConformanceWindow().getWindowRightOffset() );
626      assert( repFormat->getConformanceWindowVps().getWindowTopOffset()    == sps->getConformanceWindow().getWindowTopOffset() );
627      assert( repFormat->getConformanceWindowVps().getWindowBottomOffset() == sps->getConformanceWindow().getWindowBottomOffset() );
628    }   
629#endif
630  }
631#endif
632
633#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
634  UInt layerIdx = activeVPS->getLayerIdxInVps(m_apcSlicePilot->getLayerId());
635
636  if ( activeVPS->getVpsExtensionFlag() == 1 && (m_apcSlicePilot->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) )
637  {
638    assert( sps->getPicWidthInLumaSamples()        <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getPicWidthVpsInLumaSamples() );
639    assert( sps->getPicHeightInLumaSamples()       <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getPicHeightVpsInLumaSamples() );
640    assert( sps->getChromaFormatIdc()              <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getChromaFormatVpsIdc() );
641    assert( sps->getBitDepth(CHANNEL_TYPE_LUMA)    <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsLuma() );
642    assert( sps->getBitDepth(CHANNEL_TYPE_CHROMA)  <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsChroma() );
643  }
644  else if ( activeVPS->getVpsExtensionFlag() == 1 )
645  {
646    assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples()  <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples());
647    assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples());
648    assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc()        <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc());
649    assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma()           <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma());
650    assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma()         <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma());
651  }
652#endif
653
654  m_apcSlicePilot->setPPS(pps);
655  m_apcSlicePilot->setSPS(sps);
656  pps->setSPS(sps);
657  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : ((pps->getNumTileRowsMinus1() + 1)*(pps->getNumTileColumnsMinus1() + 1)));
658  pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
659  pps->setMinCuChromaQpAdjSize( sps->getMaxCUWidth() >> ( pps->getMaxCuChromaQpAdjDepth()) );
660
661  for (UInt channel = 0; channel < MAX_NUM_CHANNEL_TYPE; channel++)
662  {
663#if REPN_FORMAT_IN_VPS
664    g_bitDepth[channel] = isLuma(ChannelType(channel)) ? m_apcSlicePilot->getBitDepthY() : m_apcSlicePilot->getBitDepthC();
665#else
666    g_bitDepth[channel] = sps->getBitDepth(ChannelType(channel));
667#endif
668
669    if (sps->getUseExtendedPrecision()) g_maxTrDynamicRange[channel] = std::max<Int>(15, (g_bitDepth[channel] + 6));
670    else                                g_maxTrDynamicRange[channel] = 15;
671  }
672  g_uiMaxCUWidth  = sps->getMaxCUWidth();
673  g_uiMaxCUHeight = sps->getMaxCUHeight();
674  g_uiMaxCUDepth  = sps->getMaxCUDepth();
675  g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() + (Int)getMaxCUDepthOffset(sps->getChromaFormatIdc(), sps->getQuadtreeTULog2MinSize()));
676
677  for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
678  {
679    sps->setAMPAcc( i, sps->getUseAMP() );
680  }
681
682  for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++)
683  {
684    sps->setAMPAcc( i, 0 );
685  }
686
687  m_cSAO.destroy();
688#if REPN_FORMAT_IN_VPS
689  m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), pps->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), pps->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) );
690#else
691  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) );
692#endif
693  m_cLoopFilter.create( sps->getMaxCUDepth() );
694}
695
696#if SVC_EXTENSION
697Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC )
698#else
699Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
700#endif
701{
702#if SVC_EXTENSION
703  m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) );
704#if OUTPUT_LAYER_SET_INDEX
705  // Following check should go wherever the VPS is activated
706  if (!m_apcSlicePilot->getVPS()->getBaseLayerAvailableFlag())
707  {
708    assert(nalu.m_layerId != 0);
709    assert(m_apcSlicePilot->getVPS()->getNumAddLayerSets() > 0);
710    if (getCommonDecoderParams()->getTargetOutputLayerSetIdx() >= 0)
711    {
712      UInt layerIdx = m_apcSlicePilot->getVPS()->getOutputLayerSetIdx(getCommonDecoderParams()->getTargetOutputLayerSetIdx());
713      assert(layerIdx > m_apcSlicePilot->getVPS()->getVpsNumLayerSetsMinus1());
714    }
715  } 
716#endif
717  m_apcSlicePilot->initSlice( nalu.m_layerId );
718#else //SVC_EXTENSION
719  m_apcSlicePilot->initSlice();
720#endif
721
722  if (m_bFirstSliceInPicture)
723  {
724    m_uiSliceIdx = 0;
725  }
726  else
727  {
728    m_apcSlicePilot->copySliceInfo( m_pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );
729  }
730  m_apcSlicePilot->setSliceIdx(m_uiSliceIdx);
731
732  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
733#if POC_RESET_RESTRICTIONS
734  m_apcSlicePilot->setTLayer( nalu.m_temporalId );
735#endif
736  Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N ||
737                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
738                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N  ||
739                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N  ||
740                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
741  m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag);
742  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
743  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
744
745#if ENC_DEC_TRACE
746  const UInt64 originalSymbolCount = g_nSymbolCounter;
747#endif
748
749#if SVC_EXTENSION
750#if VPS_EXTN_DIRECT_REF_LAYERS
751  setRefLayerParams(m_apcSlicePilot->getVPS());
752#endif
753  m_apcSlicePilot->setNumMotionPredRefLayers(m_numMotionPredRefLayers);
754#endif
755  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
756
757  // set POC for dependent slices in skipped pictures
758  if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped)
759  {
760    m_apcSlicePilot->setPOC(m_skippedPOC);
761  }
762
763  m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA);
764  m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
765
766  //For inference of NoOutputOfPriorPicsFlag
767  if (m_apcSlicePilot->getRapPicFlag())
768  {
769    if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || 
770        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) ||
771        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag()))
772    {
773      m_apcSlicePilot->setNoRaslOutputFlag(true);
774    }
775    //the inference for NoOutputPriorPicsFlag
776    if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag())
777    {
778      if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
779      {
780        m_apcSlicePilot->setNoOutputPriorPicsFlag(true);
781      }
782    }
783    else
784    {
785      m_apcSlicePilot->setNoOutputPriorPicsFlag(false);
786    }
787
788    if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
789    {
790      m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag();
791    }
792  }
793  if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag())
794  {
795    m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC();
796    m_isNoOutputPriorPics = true;
797  }
798  else
799  {
800    m_isNoOutputPriorPics = false;
801  }
802
803  //For inference of PicOutputFlag
804  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R)
805  {
806    if ( m_craNoRaslOutputFlag )
807    {
808      m_apcSlicePilot->setPicOutputFlag(false);
809    }
810  }
811
812  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1
813  {
814    Int iMaxPOClsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC();
815    m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) );
816  }
817
818  // Skip pictures due to random access
819  if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
820  {
821    m_prevSliceSkipped = true;
822    m_skippedPOC = m_apcSlicePilot->getPOC();
823    return false;
824  }
825  // Skip TFD pictures associated with BLA/BLANT pictures
826  if (isSkipPictureForBLA(iPOCLastDisplay))
827  {
828    m_prevSliceSkipped = true;
829    m_skippedPOC = m_apcSlicePilot->getPOC();
830    return false;
831  }
832
833  // clear previous slice skipped flag
834  m_prevSliceSkipped = false;
835
836  // exit when a new picture is found
837#if SVC_EXTENSION
838  bNewPOC = m_apcSlicePilot->getPOC() != m_prevPOC || ( m_apcSlicePilot->getFirstSliceInPic() && m_parseIdc == -1 );
839
840#if NO_OUTPUT_OF_PRIOR_PICS
841#if NO_CLRAS_OUTPUT_FLAG
842  if (m_layerId == m_smallestLayerId && m_apcSlicePilot->getRapPicFlag())
843  {
844    if (m_bFirstSliceInSequence)
845    {
846      setNoClrasOutputFlag(true);
847    }
848    else if( m_lastPicHasEos )
849    {
850      setNoClrasOutputFlag(true);
851    }
852    else if ( m_apcSlicePilot->getBlaPicFlag() )
853    {
854      setNoClrasOutputFlag(true);
855    }
856#if O0149_CROSS_LAYER_BLA_FLAG
857    else if (m_apcSlicePilot->getIdrPicFlag() && m_apcSlicePilot->getCrossLayerBLAFlag())
858    {
859      setNoClrasOutputFlag(true);
860    }
861#endif
862    else
863    {
864      setNoClrasOutputFlag(false);
865    }     
866  }
867  else
868  {
869    setNoClrasOutputFlag(false);
870  }
871
872  m_apcSlicePilot->decodingRefreshMarking( m_cListPic, m_noClrasOutputFlag, m_smallestLayerId );
873#endif
874
875  // Derive the value of NoOutputOfPriorPicsFlag
876  if( bNewPOC || m_layerId!=m_uiPrevLayerId )   // i.e. new coded picture
877  {
878    if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getNoRaslOutputFlag() )
879    {
880      this->setNoOutputPriorPicsFlag( true );
881    }
882    else if( m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag() )
883    {
884      this->setNoOutputPriorPicsFlag( m_apcSlicePilot->getNoOutputPriorPicsFlag() );
885    }
886    else
887    {
888      if( this->m_ppcTDecTop[0]->getNoClrasOutputFlag() )
889      {
890        this->setNoOutputPriorPicsFlag( true );
891      }
892    }
893  }
894#endif
895
896#if POC_RESET_IDC_DECODER
897  if( m_parseIdc != -1 ) // Second pass for a POC resetting picture
898  {
899    m_parseIdc++; // Proceed to POC decoding and RPS derivation
900  }
901 
902  if( m_parseIdc == 2 )
903  {
904    bNewPOC = false;
905  }
906
907  if( (bNewPOC || m_layerId!=m_uiPrevLayerId) && (m_parseIdc == -1) ) // Will be true at the first pass
908  {
909  //if (bNewPOC || m_layerId!=m_uiPrevLayerId)
910  // Check if new reset period has started - this is needed just so that the SHM decoder which calls slice header decoding twice
911  // does not invoke the output twice
912  //if( m_lastPocPeriodId[m_apcSlicePilot->getLayerId()] == m_apcSlicePilot->getPocResetPeriodId() )
913    // Update CurrAU marking
914    if(( m_layerId < m_uiPrevLayerId) ||( ( m_layerId == m_uiPrevLayerId) && bNewPOC)) // Decoding a lower layer than or same layer as previous - mark all earlier pictures as not in current AU
915    {
916#if POC_RESET_RESTRICTIONS
917      // New access unit; reset all variables related to POC reset restrictions
918      resetPocRestrictionCheckParameters();
919#endif
920      markAllPicsAsNoCurrAu(m_apcSlicePilot->getVPS());
921#if P0297_VPS_POC_LSB_ALIGNED_FLAG
922      for (UInt i = 0; i < MAX_LAYERS; i++)
923      {
924        m_ppcTDecTop[m_apcSlicePilot->getVPS()->getLayerIdInNuh(i)]->m_pocDecrementedInDPBFlag = false;
925      }
926#endif
927    }
928
929
930#if P0297_VPS_POC_LSB_ALIGNED_FLAG
931    m_pocResettingFlag = false;
932
933    if (m_apcSlicePilot->getPocResetIdc() != 0)
934    {
935      if (m_apcSlicePilot->getVPS()->getVpsPocLsbAlignedFlag())
936      {
937        m_pocResettingFlag = true;
938      }
939      else if (m_pocDecrementedInDPBFlag)
940      {
941        m_pocResettingFlag = false;
942      }
943      else
944      {
945        m_pocResettingFlag = true;
946      }
947    }
948#endif
949
950    if( m_apcSlicePilot->getPocResetIdc() && m_apcSlicePilot->getSliceIdx() == 0 )
951    {
952      Int pocResetPeriodId = m_apcSlicePilot->getPocResetPeriodId();
953      if ( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ||
954        ( m_apcSlicePilot->getPocResetIdc() == 3 && pocResetPeriodId != getLastPocPeriodId() ) )
955      {
956        setLastPocPeriodId(pocResetPeriodId);
957        m_parseIdc = 0;
958      }
959#if POC_RESET_VALUE_RESTRICTION
960      // Check if the POC Reset period ID matches with the Reset Period ID
961      if( pocResetPeriodId == m_crossLayerPocResetPeriodId )
962      {
963        // If matching, and current poc_reset_idc = 3, then the values should match
964        if( m_apcSlicePilot->getPocResetIdc() == 3 )
965        {
966          assert( ( m_apcSlicePilot->getFullPocResetFlag() == false && m_crossLayerPocResetIdc == 1 ) ||
967                  ( m_apcSlicePilot->getFullPocResetFlag() == true  && m_crossLayerPocResetIdc == 2 ) );
968        }
969      }
970      else
971      {
972        // This is the first picture of a POC resetting access unit
973        m_crossLayerPocResetPeriodId = pocResetPeriodId;
974        if( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 )
975        {
976          m_crossLayerPocResetIdc = m_apcSlicePilot->getPocResetIdc();
977        }
978        else
979        { // poc_reset_idc = 3
980          // In this case, the entire POC resetting access unit has been lost.
981          // Need more checking to ensure poc_reset_idc = 3 works.
982          assert ( 0 );
983        }
984      }
985#endif
986    }
987    else
988    {
989      m_parseIdc = 3; // Proceed to decoding POC and RPS
990    }
991  }
992#endif
993
994#if ALIGNED_BUMPING
995#if POC_RESET_IDC_DECODER
996
997#if P0297_VPS_POC_LSB_ALIGNED_FLAG
998  UInt affectedLayerList[MAX_LAYERS];
999  Int  numAffectedLayers;
1000
1001  affectedLayerList[0] = m_apcSlicePilot->getLayerId();
1002  numAffectedLayers = 1;
1003
1004  if (m_apcSlicePilot->getVPS()->getVpsPocLsbAlignedFlag())
1005  {
1006    for (UInt j = 0; j < m_apcSlicePilot->getVPS()->getNumPredictedLayers(m_apcSlicePilot->getLayerId()); j++)
1007    {
1008      affectedLayerList[j + 1] = m_apcSlicePilot->getVPS()->getPredictedLayerId(m_apcSlicePilot->getLayerId(), j);
1009    }
1010    numAffectedLayers = m_apcSlicePilot->getVPS()->getNumPredictedLayers(m_apcSlicePilot->getLayerId()) + 1;
1011  }
1012#endif
1013
1014  //if(  (bNewPOC || m_layerId != m_uiPrevLayerId) && ( m_parseIdc != 1) )
1015#if P0297_VPS_POC_LSB_ALIGNED_FLAG
1016  if (m_parseIdc == 1 && m_pocResettingFlag)
1017#else
1018  if (m_parseIdc == 1)
1019#endif
1020  {
1021    // Invoke output of pictures if the current picture is a POC reset picture
1022    bNewPOC = true;
1023    /* Include reset of all POCs in the layer */
1024
1025  // This operation would do the following:
1026  // 1. Update the other picture in the DPB. This should be done only for the first slice of the picture.
1027  // 2. Update the value of m_pocCRA.
1028  // 3. Reset the POC values at the decoder for the current picture to be zero - will be done later
1029  // 4. update value of POCLastDisplay
1030     
1031  //Do the reset stuff here
1032    Int maxPocLsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC();
1033    Int pocLsbVal;
1034    if( m_apcSlicePilot->getPocResetIdc() == 3 )
1035    {
1036      pocLsbVal = m_apcSlicePilot->getPocLsbVal() ;
1037    }
1038    else
1039    {
1040      pocLsbVal = (m_apcSlicePilot->getPOC() % maxPocLsb);
1041    }
1042
1043    Int pocMsbDelta = 0;
1044    if ( m_apcSlicePilot->getPocMsbValPresentFlag() ) 
1045    {
1046      pocMsbDelta = m_apcSlicePilot->getPocMsbVal() * maxPocLsb;
1047    }
1048    else
1049    {
1050      //This MSB derivation can be made into one function. Item to do next.
1051      Int prevPoc     = this->getPrevPicOrderCnt();
1052      Int prevPocLsb  = prevPoc & (maxPocLsb - 1);
1053      Int prevPocMsb  = prevPoc - prevPocLsb;
1054
1055      pocMsbDelta = m_apcSlicePilot->getCurrMsb( pocLsbVal, prevPocLsb, prevPocMsb, maxPocLsb );
1056    }
1057
1058    Int pocLsbDelta;
1059    if( m_apcSlicePilot->getPocResetIdc() == 2 ||  ( m_apcSlicePilot->getPocResetIdc() == 3 && m_apcSlicePilot->getFullPocResetFlag() ))
1060    {
1061      pocLsbDelta = pocLsbVal;
1062    }
1063    else
1064    {
1065      pocLsbDelta = 0; 
1066    }
1067
1068    Int deltaPocVal  =  pocMsbDelta + pocLsbDelta;
1069
1070#if P0297_VPS_POC_LSB_ALIGNED_FLAG
1071    for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++)
1072    {
1073      if (!m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocDecrementedInDPBFlag)
1074      {
1075        m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocDecrementedInDPBFlag = true;
1076        TComList<TComPic*>::iterator  iterPic = m_ppcTDecTop[affectedLayerList[layerIdx]]->getListPic()->begin();
1077        while (iterPic != m_ppcTDecTop[affectedLayerList[layerIdx]]->getListPic()->end())
1078#else
1079    //Reset all POC for DPB -> basically do it for each slice in the picutre
1080    TComList<TComPic*>::iterator  iterPic = m_cListPic.begin(); 
1081
1082    // Iterate through all picture in DPB
1083    while( iterPic != m_cListPic.end() )
1084#endif
1085    {
1086      TComPic *dpbPic = *iterPic;
1087      // Check if the picture pointed to by iterPic is either used for reference or
1088      // needed for output, are in the same layer, and not the current picture.
1089#if P0297_VPS_POC_LSB_ALIGNED_FLAG
1090      assert(dpbPic->getLayerId() == affectedLayerList[layerIdx]);
1091      if ( (dpbPic->getReconMark()) && (dpbPic->getPicSym()->getSlice(0)->getPicOutputFlag()) )
1092#else
1093      if ( /*  ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) )
1094          &&*/ ( dpbPic->getLayerId() == m_apcSlicePilot->getLayerId() )
1095            && ( dpbPic->getReconMark() ) && ( dpbPic->getPicSym()->getSlice(0)->getPicOutputFlag() ))
1096#endif
1097      {
1098        for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--)
1099        {
1100
1101          TComSlice *slice = dpbPic->getSlice(i);
1102          TComReferencePictureSet *rps = slice->getRPS();
1103          slice->setPOC( slice->getPOC() - deltaPocVal );
1104
1105          // Also adjust the POC value stored in the RPS of each such slice
1106          for(Int j = rps->getNumberOfPictures(); j >= 0; j--)
1107          {
1108            rps->setPOC( j, rps->getPOC(j) - deltaPocVal );
1109          }
1110          // Also adjust the value of refPOC
1111          for(Int k = 0; k < 2; k++)  // For List 0 and List 1
1112          {
1113            RefPicList list = (k == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
1114            for(Int j = 0; j < slice->getNumRefIdx(list); j++)
1115            {
1116              slice->setRefPOC( slice->getRefPOC(list, j) - deltaPocVal, list, j);
1117            }
1118          }
1119        }
1120      }
1121      iterPic++;
1122    }
1123#if P0297_VPS_POC_LSB_ALIGNED_FLAG
1124        // Update the value of pocCRA
1125        m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocCRA -= deltaPocVal;
1126      }
1127    }
1128#else
1129    // Update the value of pocCRA
1130    m_pocCRA -= deltaPocVal;
1131#endif
1132
1133    // Update value of POCLastDisplay
1134    iPOCLastDisplay -= deltaPocVal;
1135  }
1136  Int maxPocLsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC();
1137  Int slicePicOrderCntLsb = m_apcSlicePilot->getPicOrderCntLsb();
1138
1139#if P0297_VPS_POC_LSB_ALIGNED_FLAG
1140  if (m_pocResettingFlag && (m_parseIdc == 1 || m_parseIdc == 2))
1141#else
1142  if (m_parseIdc == 1 || m_parseIdc == 2) // TODO This should be replaced by pocResettingFlag.
1143#endif
1144  {
1145    // Set poc for current slice
1146    if( m_apcSlicePilot->getPocResetIdc() == 1 )
1147    {       
1148      m_apcSlicePilot->setPOC( slicePicOrderCntLsb );
1149    }
1150    else if( m_apcSlicePilot->getPocResetIdc() == 2 )
1151    {
1152      m_apcSlicePilot->setPOC( 0 );
1153    }
1154    else 
1155    {
1156      Int picOrderCntMsb = m_apcSlicePilot->getCurrMsb( slicePicOrderCntLsb, m_apcSlicePilot->getFullPocResetFlag() ? 0 : m_apcSlicePilot->getPocLsbVal(), 0 , maxPocLsb );
1157      m_apcSlicePilot->setPOC( picOrderCntMsb + slicePicOrderCntLsb );
1158    }
1159  }
1160  else if (m_parseIdc == 3)
1161  {
1162    Int picOrderCntMsb = 0;
1163    if( m_apcSlicePilot->getPocMsbValPresentFlag() )
1164    {
1165      picOrderCntMsb = m_apcSlicePilot->getPocMsbVal() * maxPocLsb;
1166    }
1167    else if( m_apcSlicePilot->getIdrPicFlag() )
1168    {
1169      picOrderCntMsb = 0;
1170    }
1171    else
1172    {
1173      Int prevPicOrderCntLsb = this->getPrevPicOrderCnt() & ( maxPocLsb - 1);
1174      Int prevPicOrderCntMsb  = this->getPrevPicOrderCnt() - prevPicOrderCntLsb;
1175      picOrderCntMsb = m_apcSlicePilot->getCurrMsb(slicePicOrderCntLsb, prevPicOrderCntLsb, prevPicOrderCntMsb, maxPocLsb );
1176    }
1177    m_apcSlicePilot->setPOC( picOrderCntMsb + slicePicOrderCntLsb );
1178  }
1179
1180  if( m_parseIdc == 1 || m_parseIdc == 3)
1181  {
1182    // Adjust prevPicOrderCnt
1183    if(    !m_apcSlicePilot->getRaslPicFlag() 
1184        && !m_apcSlicePilot->getRadlPicFlag()
1185        && (m_apcSlicePilot->getNalUnitType() % 2 == 1)
1186        && ( nalu.m_temporalId == 0 )
1187        && !m_apcSlicePilot->getDiscardableFlag() )
1188    {
1189#if P0297_VPS_POC_LSB_ALIGNED_FLAG
1190      for (UInt i = 0; i < numAffectedLayers; i++)
1191      {
1192        m_ppcTDecTop[affectedLayerList[i]]->setPrevPicOrderCnt(m_apcSlicePilot->getPOC());
1193      }
1194#else
1195      this->setPrevPicOrderCnt( m_apcSlicePilot->getPOC() );
1196#endif
1197    }
1198    else if ( m_apcSlicePilot->getPocResetIdc() == 3 )
1199    {
1200#if P0297_VPS_POC_LSB_ALIGNED_FLAG
1201      if (!m_firstPicInLayerDecodedFlag || (m_firstPicInLayerDecodedFlag && m_pocResettingFlag))
1202      {
1203        for (UInt i = 0; i < numAffectedLayers; i++)
1204        {
1205          m_ppcTDecTop[affectedLayerList[i]]->setPrevPicOrderCnt( m_apcSlicePilot->getFullPocResetFlag() 
1206                                                                  ? 0 : m_apcSlicePilot->getPocLsbVal() );
1207        }
1208      }
1209#else
1210      this->setPrevPicOrderCnt( m_apcSlicePilot->getFullPocResetFlag() 
1211                                            ? 0 : m_apcSlicePilot->getPocLsbVal() );
1212#endif
1213    }
1214#else
1215  if (bNewPOC || m_layerId!=m_uiPrevLayerId)
1216  {
1217#endif
1218    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
1219  }
1220#endif
1221#if POC_RESET_IDC_DECODER
1222  if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId || m_parseIdc == 1) && !m_bFirstSliceInSequence )
1223#else
1224  if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence )
1225#endif
1226  {
1227    m_prevPOC = m_apcSlicePilot->getPOC();
1228    curLayerId = m_uiPrevLayerId; 
1229    m_uiPrevLayerId = m_layerId;
1230    return true;
1231  }
1232
1233#if POC_RESET_IDC_DECODER
1234  m_parseIdc = -1;
1235#endif
1236
1237
1238#if R0226_SLICE_TMVP
1239  if ( m_apcSlicePilot->getTLayer() == 0 && m_apcSlicePilot->getEnableTMVPFlag() == 0 )
1240  {
1241    //update all pics in the DPB such that they cannot be used for TMPV ref
1242    TComList<TComPic*>::iterator  iterRefPic = m_cListPic.begin(); 
1243    while( iterRefPic != m_cListPic.end() )
1244    {
1245      TComPic *refPic = *iterRefPic;
1246      if( ( refPic->getLayerId() == m_apcSlicePilot->getLayerId() ) && refPic->getReconMark() )
1247      {
1248        for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--)
1249        {
1250
1251          TComSlice *refSlice = refPic->getSlice(i);
1252          refSlice->setAvailableForTMVPRefFlag( false );
1253        }
1254      }
1255      iterRefPic++;
1256    }
1257  }
1258  m_apcSlicePilot->setAvailableForTMVPRefFlag( true );
1259#endif
1260
1261  // actual decoding starts here
1262  xActivateParameterSets();
1263
1264#if REPN_FORMAT_IN_VPS
1265  // Initialize ILRP if needed, only for the current layer 
1266  // ILRP intialization should go along with activation of parameters sets,
1267  // although activation of parameter sets itself need not be done for each and every slice!!!
1268  xInitILRP(m_apcSlicePilot);
1269#endif
1270  if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) 
1271  {
1272    m_prevPOC = m_apcSlicePilot->getPOC();
1273    curLayerId = m_layerId;
1274    m_uiPrevLayerId = m_layerId;
1275  }
1276  m_bFirstSliceInSequence = false;
1277  m_bFirstSliceInBitstream  = false;
1278
1279  // Alignment of TSA and STSA pictures across AU
1280#if !Q0108_TSA_STSA
1281  if( m_apcSlicePilot->getLayerId() > 0 )
1282  {
1283    // Check for TSA alignment
1284    if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N ||
1285        m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R
1286         )
1287    {
1288      for(Int dependentLayerIdx = 0; dependentLayerIdx < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++)
1289      {
1290        TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic();
1291        TComPic* refpicLayer = m_apcSlicePilot->getRefPic(*cListPic, m_apcSlicePilot->getPOC() );
1292        if( refpicLayer )
1293        {
1294          assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N ||
1295                    m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R );    // TSA pictures should be aligned among depenedent layers
1296        } 
1297      }
1298    }
1299    // Check for STSA alignment
1300    if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N ||
1301         m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R
1302         )
1303    {
1304      for(Int dependentLayerIdx = 0; dependentLayerIdx < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++)
1305      {
1306        TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic();
1307        TComPic* refpicLayer = m_apcSlicePilot->getRefPic(*cListPic, m_apcSlicePilot->getPOC() ); // STSA pictures should be aligned among dependent layers
1308        if( refpicLayer )
1309
1310        {
1311          assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N ||
1312                    m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R );
1313        }
1314      }
1315    }
1316  }
1317#endif
1318
1319#else //SVC_EXTENSION
1320  //we should only get a different poc for a new picture (with CTU address==0)
1321  if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() != 0)) 
1322  {
1323    printf ("Warning, the first slice of a picture might have been lost!\n");
1324  }
1325
1326  // exit when a new picture is found
1327  if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() == 0 && !m_bFirstSliceInPicture) )
1328  {
1329    if (m_prevPOC >= m_pocRandomAccess)
1330    {
1331      m_prevPOC = m_apcSlicePilot->getPOC();
1332#if ENC_DEC_TRACE
1333      //rewind the trace counter since we didn't actually decode the slice
1334      g_nSymbolCounter = originalSymbolCount;
1335#endif
1336      return true;
1337    }
1338    m_prevPOC = m_apcSlicePilot->getPOC();
1339  }
1340
1341  // actual decoding starts here
1342  xActivateParameterSets();
1343
1344  if (!m_apcSlicePilot->getDependentSliceSegmentFlag())
1345  {
1346    m_prevPOC = m_apcSlicePilot->getPOC();
1347  }
1348  m_bFirstSliceInSequence = false;
1349  m_bFirstSliceInBitstream  = false;
1350#endif //SVC_EXTENSION
1351  //detect lost reference picture and insert copy of earlier frame.
1352  Int lostPoc;
1353  while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0)
1354  {
1355    xCreateLostPicture(lostPoc-1);
1356  }
1357  if (m_bFirstSliceInPicture)
1358  {
1359#if AVC_BASE
1360    if( m_layerId > 0 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getNonHEVCBaseLayerFlag() )
1361    {
1362      TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
1363      pBLPic->getSlice(0)->setReferenced(true);
1364      fstream* pFile  = m_ppcTDecTop[0]->getBLReconFile();
1365
1366      if( pFile->good() )
1367      {
1368        Bool is16bit  = g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] > 8 || g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] > 8;
1369        UInt uiWidth  = pBLPic->getPicYuvRec()->getWidth(COMPONENT_Y);
1370        UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(COMPONENT_Y);
1371
1372        Int len = uiWidth * (is16bit ? 2 : 1);
1373        UChar *buf = new UChar[len];
1374
1375        UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2;
1376        if( is16bit )
1377        {
1378            uiPos <<= 1;
1379        }
1380
1381        pFile->seekg((UInt)uiPos, ios::beg );
1382
1383        // read Y component
1384        Pel* pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Y);
1385        UInt uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Y);
1386        for( Int i = 0; i < uiHeight; i++ )
1387        {
1388          pFile->read(reinterpret_cast<Char*>(buf), len);
1389
1390          if( !is16bit )
1391          {
1392            for (Int x = 0; x < uiWidth; x++)
1393            {
1394              pPel[x] = buf[x];
1395            }
1396          }
1397          else
1398          {
1399            for (Int x = 0; x < uiWidth; x++)
1400            {
1401              pPel[x] = (buf[2*x+1] << 8) | buf[2*x];
1402            }
1403          }
1404     
1405          pPel += uiStride;
1406        }
1407
1408        len >>= 1;
1409        uiWidth >>= 1;
1410        uiHeight >>= 1;
1411
1412        // read Cb component
1413        pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cb);
1414        uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cb);
1415        for( Int i = 0; i < uiHeight; i++ )
1416        {
1417          pFile->read(reinterpret_cast<Char*>(buf), len);
1418
1419          if( !is16bit )
1420          {
1421            for( Int x = 0; x < uiWidth; x++ )
1422            {
1423              pPel[x] = buf[x];
1424            }
1425          }
1426          else
1427          {
1428            for( Int x = 0; x < uiWidth; x++ )
1429            {
1430              pPel[x] = (buf[2*x+1] << 8) | buf[2*x];
1431            }
1432          }
1433     
1434          pPel += uiStride;
1435        }
1436
1437        // read Cr component
1438        pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cr);
1439        uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cr);
1440        for( Int i = 0; i < uiHeight; i++ )
1441        {
1442          pFile->read(reinterpret_cast<Char*>(buf), len);
1443
1444          if( !is16bit )
1445          {
1446            for( Int x = 0; x < uiWidth; x++ )
1447            {
1448              pPel[x] = buf[x];
1449            }
1450          }
1451          else
1452          {
1453            for( Int x = 0; x < uiWidth; x++ )
1454            {
1455              pPel[x] = (buf[2*x+1] << 8) | buf[2*x];
1456            }
1457          }
1458     
1459          pPel += uiStride;
1460        }
1461
1462        delete[] buf;
1463      }
1464    }
1465#endif
1466
1467#if NO_OUTPUT_OF_PRIOR_PICS
1468    if ( m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() && getNoClrasOutputFlag() )
1469    {
1470      for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getMaxLayers(); i++)
1471      {
1472        m_ppcTDecTop[i]->setLayerInitializedFlag(false);
1473        m_ppcTDecTop[i]->setFirstPicInLayerDecodedFlag(false);
1474      }
1475    }
1476#endif
1477
1478#if SVC_EXTENSION
1479    xCheckLayerReset();
1480    xSetLayerInitializedFlag();
1481#endif
1482
1483    // Buffer initialize for prediction.
1484    m_cPrediction.initTempBuff(m_apcSlicePilot->getSPS()->getChromaFormatIdc());
1485#if ALIGNED_BUMPING
1486    m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic);
1487#else
1488    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
1489#endif
1490    //  Get a new picture buffer
1491    xGetNewPicBuffer (m_apcSlicePilot, m_pcPic);
1492
1493#if POC_RESET_IDC_DECODER
1494    m_pcPic->setCurrAuFlag( true );
1495#if POC_RESET_RESTRICTIONS
1496    if( m_pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag )
1497    {
1498      // IDR picture with nuh_layer_id > 0 present
1499      m_nonBaseIdrPresentFlag = true;
1500      m_nonBaseIdrType = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL);
1501    }
1502    else
1503    {
1504      if( m_apcSlicePilot->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL )
1505      {
1506        // Picture with nal_unit_type not equal IDR_W_RADL present
1507        m_picNonIdrWithRadlPresentFlag = true;
1508      }
1509      if( m_apcSlicePilot->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_N_LP )
1510      {
1511        // Picture with nal_unit_type not equal IDR_N_LP present
1512        m_picNonIdrNoLpPresentFlag = true;
1513      }
1514    }
1515    if( !m_checkPocRestrictionsForCurrAu )  // Will be true for the first slice/picture of the AU
1516    {
1517      m_checkPocRestrictionsForCurrAu = true;
1518      m_pocResetIdcOrCurrAu = m_apcSlicePilot->getPocResetIdc();
1519      if( m_pcPic->getLayerId() == 0 )
1520      {
1521        // Base layer picture is present
1522        m_baseLayerPicPresentFlag = true;
1523        if( m_apcSlicePilot->isIRAP() )
1524        {
1525          // Base layer picture is IRAP
1526          m_baseLayerIrapFlag = true;
1527        }
1528        if( m_apcSlicePilot->isIDR() )
1529        {
1530          // Base layer picture is IDR
1531          m_baseLayerIdrFlag = true;
1532        }
1533        else
1534        {
1535          if( m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag())
1536          {
1537            /* When the picture with nuh_layer_id equal to 0 in an access unit is not an IDR picture
1538            and vps_base_layer_internal_flag is equal to 1, the value of poc_reset_idc shall not be equal to 2
1539            for any picture in the access unit. */
1540            assert( m_apcSlicePilot->getPocResetIdc() != 2 );
1541          }
1542        }
1543      }
1544    }
1545    else
1546    {
1547      // The value of poc_reset_idc of all coded pictures that are present in the bitstream in an access unit shall be the same.
1548      assert( m_pocResetIdcOrCurrAu == m_apcSlicePilot->getPocResetIdc() );
1549
1550      /* When the picture in an access unit with nuh_layer_id equal to 0 is an IRAP picture and vps_base_layer_internal_flag is equal to 1
1551      and there is at least one other picture in the same access unit that is not an IRAP picture,
1552      the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */
1553      if( m_baseLayerPicPresentFlag && m_baseLayerIrapFlag && !m_apcSlicePilot->isIRAP() && m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag() )
1554      {
1555        assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 );
1556      }
1557
1558      /* When the picture with nuh_layer_id equal to 0 in an access unit is an IDR picture and
1559      vps_base_layer_internal_flag is equal to 1 and there is at least one non-IDR picture in the same access unit,
1560      the value of poc_reset_idc shall be equal to 2 for all pictures in the access unit. */
1561      if( m_baseLayerPicPresentFlag && m_baseLayerIdrFlag && !m_apcSlicePilot->isIDR() && m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag() )
1562      {
1563        assert( m_apcSlicePilot->getPocResetIdc() == 2 );
1564      }
1565
1566      /* When there is at least one picture that has nuh_layer_id greater than 0 and that is an IDR picture
1567      with a particular value of nal_unit_type in an access unit and there is at least one other coded picture
1568      that is present in the bitstream in the same access unit with a different value of nal_unit_type,
1569      the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */
1570      if( m_nonBaseIdrPresentFlag && (
1571            ( m_nonBaseIdrType == 1 && m_picNonIdrWithRadlPresentFlag ) ||
1572            ( m_nonBaseIdrType == 0 && m_picNonIdrNoLpPresentFlag )
1573        ))
1574      {
1575        assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 );
1576      }
1577    }
1578#endif
1579#endif
1580
1581    Bool isField = false;
1582    Bool isTff = false;
1583   
1584    if(!m_SEIs.empty())
1585    {
1586      // Check if any new Picture Timing SEI has arrived
1587      SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING);
1588      if (pictureTimingSEIs.size()>0)
1589      {
1590        SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin());
1591        isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2);
1592        isTff =  (pictureTiming->m_picStruct == 1);
1593      }
1594
1595#if R0226_CONSTRAINT_TMVP_SEI
1596      // Check if any new temporal motion vector prediction constraints SEI has arrived
1597      SEIMessages seiTMVPConstrainsList = extractSeisByType (m_SEIs, SEI::TMVP_CONSTRAINTS);
1598      if (seiTMVPConstrainsList.size() > 0)
1599      {
1600        assert ( m_pcPic->getTLayer() == 0 );  //this SEI can present only for AU with Tid equal to 0
1601        SEITMVPConstrains* tmvpConstraintSEI = (SEITMVPConstrains*) *(seiTMVPConstrainsList.begin());
1602        if ( tmvpConstraintSEI->prev_pics_not_used_flag == 1 )
1603        {
1604          //update all pics in the DPB such that they cannot be used for TMPV ref
1605          TComList<TComPic*>::iterator  iterRefPic = m_cListPic.begin(); 
1606          while( iterRefPic != m_cListPic.end() )
1607          {
1608            TComPic *refPic = *iterRefPic;
1609            if( ( refPic->getLayerId() == m_pcPic->getLayerId() ) && refPic->getReconMark() )
1610            {
1611              for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--)
1612              {
1613                TComSlice *refSlice = refPic->getSlice(i);
1614                refSlice->setAvailableForTMVPRefFlag( false );
1615              }
1616            }
1617            iterRefPic++;
1618          }
1619        }
1620      }
1621#endif
1622    }
1623   
1624    //Set Field/Frame coding mode
1625    m_pcPic->setField(isField);
1626    m_pcPic->setTopField(isTff);
1627
1628    // transfer any SEI messages that have been received to the picture
1629    m_pcPic->setSEIs(m_SEIs);
1630    m_SEIs.clear();
1631
1632    // Recursive structure
1633    m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getChromaFormatIdc() );
1634#if SVC_EXTENSION
1635    m_cCuDecoder.init   ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId );
1636#else
1637    m_cCuDecoder.init   ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction );
1638#endif
1639    m_cTrQuant.init     ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize());
1640
1641    m_cSliceDecoder.create();
1642  }
1643  else
1644  {
1645    // Check if any new SEI has arrived
1646    if(!m_SEIs.empty())
1647    {
1648      // Currently only decoding Unit SEI message occurring between VCL NALUs copied
1649      SEIMessages &picSEI = m_pcPic->getSEIs();
1650      SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
1651      picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
1652      deleteSEIs(m_SEIs);
1653    }
1654  }
1655
1656  //  Set picture slice pointer
1657  TComSlice*  pcSlice = m_apcSlicePilot;
1658
1659  m_pcPic->getPicSym()->initTiles(pcSlice->getPPS());
1660  m_pcPic->getPicSym()->initCtuTsRsAddrMaps();
1661
1662  // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses.
1663  // Now, having set up the maps, convert them to the correct form.
1664  pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) );
1665  pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) );
1666  if(!pcSlice->getDependentSliceSegmentFlag())
1667  {
1668    pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr()));
1669    pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr()));
1670  }
1671
1672  if (m_bFirstSliceInPicture)
1673  {
1674    if(m_pcPic->getNumAllocatedSlice() != 1)
1675    {
1676      m_pcPic->clearSliceBuffer();
1677    }
1678  }
1679  else
1680  {
1681    m_pcPic->allocateNewSlice();
1682  }
1683  assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
1684  m_apcSlicePilot = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx);
1685  m_pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);
1686
1687  m_pcPic->setTLayer(nalu.m_temporalId);
1688
1689#if SVC_EXTENSION
1690  m_pcPic->setLayerId(nalu.m_layerId);
1691  pcSlice->setLayerId(nalu.m_layerId);
1692  pcSlice->setPic(m_pcPic);
1693#endif
1694
1695  if (!pcSlice->getDependentSliceSegmentFlag())
1696  {
1697    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
1698    // Set reference list
1699#if SVC_EXTENSION
1700    if (m_layerId == 0)
1701#endif
1702    pcSlice->setRefPicList( m_cListPic, true );
1703
1704#if SVC_EXTENSION
1705    // Create upsampling reference layer pictures for all possible dependent layers and do it only once for the first slice.
1706    // Other slices might choose which reference pictures to be used for inter-layer prediction
1707    if( m_layerId > 0 && m_uiSliceIdx == 0 && ( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || pcSlice->isIRAP() ) )
1708    {
1709      for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ )
1710      {
1711        UInt refLayerIdc = i;
1712        UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc);
1713#if AVC_BASE
1714        if( refLayerId == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getNonHEVCBaseLayerFlag() )
1715        {         
1716          TComPic* pic = *m_ppcTDecTop[0]->getListPic()->begin();
1717
1718          if( pic )
1719          {
1720            pcSlice->setBaseColPic ( refLayerIdc, pic );
1721          }
1722          else
1723          {
1724            continue;
1725          }
1726        }
1727        else
1728        {
1729#if VPS_EXTN_DIRECT_REF_LAYERS
1730          TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc );
1731#else
1732          TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
1733#endif
1734          TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
1735          if( !pcSlice->setBaseColPic ( *cListPic, refLayerIdc ) )
1736          {
1737            continue;
1738          }
1739        }
1740#else
1741#if VPS_EXTN_DIRECT_REF_LAYERS
1742        TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc );
1743#else
1744        TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
1745#endif
1746        TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
1747        pcSlice->setBaseColPic ( *cListPic, refLayerIdc );
1748#endif
1749
1750#if O0098_SCALED_REF_LAYER_ID
1751        const Window &scalEL = pcSlice->getPPS()->getScaledRefLayerWindowForLayer(refLayerId);
1752#else
1753        const Window &scalEL = pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc);
1754#endif
1755
1756        const Window &windowRL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
1757        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(COMPONENT_Y) - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset();
1758        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(COMPONENT_Y) - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset();
1759        Int widthEL   = m_pcPic->getPicYuvRec()->getWidth(COMPONENT_Y)  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
1760        Int heightEL  = m_pcPic->getPicYuvRec()->getHeight(COMPONENT_Y) - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
1761
1762        // conformance check: the values of RefLayerRegionWidthInSamplesY, RefLayerRegionHeightInSamplesY, ScaledRefRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater than 0
1763        assert(widthEL > 0 && heightEL > 0 && widthBL > 0 && widthEL > 0);
1764
1765        // conformance check: ScaledRefRegionWidthInSamplesY shall be greater or equal to RefLayerRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater or equal to RefLayerRegionHeightInSamplesY
1766        assert(widthEL >= widthBL && heightEL >= heightBL);
1767
1768        // conformance check: when ScaledRefRegionWidthInSamplesY is equal to RefLayerRegionWidthInSamplesY, PhaseHorY shall be equal to 0, when ScaledRefRegionWidthInSamplesC is equal to RefLayerRegionWidthInSamplesC, PhaseHorC shall be equal to 0, when ScaledRefRegionHeightInSamplesY is equal to RefLayerRegionHeightInSamplesY, PhaseVerY shall be equal to 0, and when ScaledRefRegionHeightInSamplesC is equal to RefLayerRegionHeightInSamplesC, PhaseVerC shall be equal to 0.
1769        Bool phaseSetPresentFlag;
1770        Int phaseHorLuma, phaseVerLuma, phaseHorChroma, phaseVerChroma;
1771        pcSlice->getPPS()->getResamplingPhase( refLayerId, phaseSetPresentFlag, phaseHorLuma, phaseVerLuma, phaseHorChroma, phaseVerChroma );
1772
1773        assert( ( (widthEL  != widthBL)  || (phaseHorLuma == 0 && phaseHorChroma == 0) )
1774             && ( (heightEL != heightBL) || (phaseVerLuma == 0 && phaseVerChroma == 0) ) );
1775
1776        g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
1777        g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
1778
1779        g_posScalingFactor[refLayerIdc][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
1780        g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
1781
1782#if Q0048_CGS_3D_ASYMLUT
1783        TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec();
1784        if( pcSlice->getPPS()->getCGSFlag() 
1785#if R0150_CGS_SIGNAL_CONSTRAINTS
1786          && m_c3DAsymLUTPPS.isRefLayer( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) )
1787#endif
1788          )
1789        {
1790#if R0150_CGS_SIGNAL_CONSTRAINTS
1791          assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthY() == m_c3DAsymLUTPPS.getInputBitDepthY() );
1792          assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthC() == m_c3DAsymLUTPPS.getInputBitDepthC() );
1793          assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthY() );
1794          assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthC() );
1795#endif
1796          if(!m_pColorMappedPic)
1797          {
1798            initAsymLut(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0));
1799          }
1800          m_c3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),  m_pColorMappedPic );
1801          pBaseColRec = m_pColorMappedPic;
1802        }
1803#endif
1804        if( m_pcPic->isSpatialEnhLayer(refLayerIdc) )
1805        {
1806          // check for the sample prediction picture type
1807          if( pcSlice->getVPS()->isSamplePredictionType( pcSlice->getVPS()->getLayerIdxInVps(m_layerId), pcSlice->getVPS()->getLayerIdxInVps(refLayerId) ) )
1808          {
1809            m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec());
1810          }
1811        }
1812        else
1813        {
1814          m_pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );
1815        }
1816        pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) );
1817      }
1818    }
1819
1820    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
1821    {
1822      for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
1823      {
1824        UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
1825#if AVC_BASE
1826        if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getNonHEVCBaseLayerFlag() )
1827        {
1828          pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() );
1829        }
1830        else
1831        {
1832#if VPS_EXTN_DIRECT_REF_LAYERS
1833          TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc );
1834#else
1835          TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
1836#endif
1837          TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
1838          pcSlice->setBaseColPic ( *cListPic, refLayerIdc );
1839        }
1840#else
1841#if VPS_EXTN_DIRECT_REF_LAYERS
1842        TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc );
1843#else
1844        TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
1845#endif
1846        TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
1847        pcSlice->setBaseColPic ( *cListPic, refLayerIdc );
1848#endif
1849
1850        pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) );
1851      }
1852
1853      pcSlice->setILRPic( m_cIlpPic );
1854
1855#if REF_IDX_MFM
1856      pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic);
1857    }
1858    else if ( m_layerId > 0 )
1859    {
1860      pcSlice->setRefPicList( m_cListPic, false, NULL);
1861    }
1862#if MFM_ENCCONSTRAINT
1863    if( pcSlice->getMFMEnabledFlag() )
1864    {
1865      TComPic* refPic = pcSlice->getRefPic( pcSlice->getSliceType() == B_SLICE ? ( RefPicList )( 1 - pcSlice->getColFromL0Flag() ) : REF_PIC_LIST_0 , pcSlice->getColRefIdx() );
1866
1867      assert( refPic );
1868
1869      Int refLayerId = refPic->getLayerId();
1870
1871      if( refLayerId != pcSlice->getLayerId() )
1872      {
1873        TComPic* pColBasePic = pcSlice->getBaseColPic( *m_ppcTDecTop[refLayerId]->getListPic() );
1874        assert( pColBasePic->checkSameRefInfo() == true );
1875      }
1876    }
1877#endif
1878#endif
1879   
1880    if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag() && ( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || pcSlice->isIRAP() ) )
1881    {
1882      for(Int dependentLayerIdx = 0; dependentLayerIdx < pcSlice->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++)
1883      {
1884        TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic();
1885        TComPic* refpicLayer = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() );
1886        if(refpicLayer && pcSlice->isIRAP())
1887        {                 
1888          assert(pcSlice->getNalUnitType() == refpicLayer->getSlice(0)->getNalUnitType());
1889        }
1890      }
1891    }
1892   
1893    if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() )
1894    {
1895      TComPic* refPic = pcSlice->getRefPic(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
1896
1897      assert( refPic );
1898#if R0226_SLICE_TMVP
1899      assert ( refPic->getPicSym()->getSlice(0)->getAvailableForTMVPRefFlag() == true );
1900#endif
1901
1902      // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture,
1903      // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
1904      if( refPic->isILR(pcSlice->getLayerId()) )
1905      {
1906        assert( pcSlice->getVPS()->isMotionPredictionType( pcSlice->getVPS()->getLayerIdxInVps(m_layerId), refPic->getLayerIdx() ) );
1907      }
1908    }
1909#endif //SVC_EXTENSION
1910   
1911    // For generalized B
1912    // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
1913    if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0)
1914    {
1915      Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0);
1916      pcSlice->setNumRefIdx        ( REF_PIC_LIST_1, iNumRefIdx );
1917
1918      for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++)
1919      {
1920        pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx);
1921      }
1922    }
1923    if (!pcSlice->isIntra())
1924    {
1925      Bool bLowDelay = true;
1926      Int  iCurrPOC  = pcSlice->getPOC();
1927      Int iRefIdx = 0;
1928
1929      for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++)
1930      {
1931        if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC )
1932        {
1933          bLowDelay = false;
1934        }
1935      }
1936      if (pcSlice->isInterB())
1937      {
1938        for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
1939        {
1940          if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
1941          {
1942            bLowDelay = false;
1943          }
1944        }
1945      }
1946
1947      pcSlice->setCheckLDC(bLowDelay);
1948    }
1949
1950    //---------------
1951    pcSlice->setRefPOCList();
1952  }
1953
1954  m_pcPic->setCurrSliceIdx(m_uiSliceIdx);
1955  if(pcSlice->getSPS()->getScalingListFlag())
1956  {
1957    pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList()  );
1958
1959#if SCALINGLIST_INFERRING
1960    if( pcSlice->getPPS()->getScalingListPresentFlag() || pcSlice->getPPS()->getInferScalingListFlag() )
1961#else
1962    if(pcSlice->getPPS()->getScalingListPresentFlag())
1963#endif
1964    {
1965      pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList()  );
1966    }
1967#if SCALINGLIST_INFERRING
1968    if( m_layerId == 0 || ( m_layerId > 0 && !pcSlice->getPPS()->getInferScalingListFlag() && !pcSlice->getSPS()->getInferScalingListFlag() ) )
1969#endif
1970    if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag())
1971    {
1972      pcSlice->setDefaultScalingList();
1973    }
1974    m_cTrQuant.setScalingListDec(pcSlice->getScalingList(), pcSlice->getSPS()->getChromaFormatIdc());
1975    m_cTrQuant.setUseScalingList(true);
1976  }
1977  else
1978  {
1979    m_cTrQuant.setFlatScalingList(pcSlice->getSPS()->getChromaFormatIdc());
1980    m_cTrQuant.setUseScalingList(false);
1981  }
1982
1983  //  Decode a picture
1984  m_cGopDecoder.decompressSlice(nalu.m_Bitstream, m_pcPic);
1985
1986#if P0297_VPS_POC_LSB_ALIGNED_FLAG
1987  setFirstPicInLayerDecodedFlag(true);
1988#endif
1989#if SVC_EXTENSION
1990  m_lastPicHasEos = false;
1991#endif
1992
1993  m_bFirstSliceInPicture = false;
1994  m_uiSliceIdx++;
1995
1996  return false;
1997}
1998
1999Void TDecTop::xDecodeVPS()
2000{
2001  TComVPS* vps = new TComVPS();
2002
2003  m_cEntropyDecoder.decodeVPS( vps );
2004  m_parameterSetManagerDecoder.storePrefetchedVPS(vps);
2005#if SVC_EXTENSION
2006  checkValueOfTargetOutputLayerSetIdx(vps);
2007#endif
2008}
2009
2010#if SVC_EXTENSION
2011Void TDecTop::xDecodeSPS()
2012{
2013  TComSPS* sps = new TComSPS();
2014#if O0043_BEST_EFFORT_DECODING
2015  sps->setForceDecodeBitDepth(m_forceDecodeBitDepth);
2016#endif
2017  sps->setLayerId(m_layerId);
2018#if SPS_DPB_PARAMS
2019  m_cEntropyDecoder.decodeSPS( sps ); // it should be removed after macro clean up
2020#else
2021  m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder );
2022#endif
2023  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
2024#if !REPN_FORMAT_IN_VPS   // ILRP can only be initialized at activation 
2025  if(m_numLayer>0)
2026  {
2027    xInitILRP(sps);
2028  }
2029#endif
2030}
2031
2032Void TDecTop::xDecodePPS(
2033#if Q0048_CGS_3D_ASYMLUT
2034  TCom3DAsymLUT * pc3DAsymLUT
2035#endif
2036  )
2037{
2038  TComPPS* pps = new TComPPS();
2039
2040#if SCALINGLIST_INFERRING
2041  pps->setLayerId( m_layerId );
2042#endif
2043
2044  m_cEntropyDecoder.decodePPS( pps
2045#if Q0048_CGS_3D_ASYMLUT
2046    , pc3DAsymLUT , m_layerId
2047#endif
2048    );
2049  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
2050}
2051#else
2052Void TDecTop::xDecodeSPS()
2053{
2054  TComSPS* sps = new TComSPS();
2055#if O0043_BEST_EFFORT_DECODING
2056  sps->setForceDecodeBitDepth(m_forceDecodeBitDepth);
2057#endif
2058  m_cEntropyDecoder.decodeSPS( sps );
2059  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
2060}
2061
2062Void TDecTop::xDecodePPS()
2063{
2064  TComPPS* pps = new TComPPS();
2065  m_cEntropyDecoder.decodePPS( pps );
2066  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
2067}
2068#endif //SVC_EXTENSION
2069
2070Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType )
2071{
2072  if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
2073  {
2074#if SVC_EXTENSION
2075    if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit
2076    {
2077      return;
2078    }
2079#endif
2080#if LAYERS_NOT_PRESENT_SEI
2081    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream  );
2082#else
2083    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
2084#endif
2085  }
2086  else
2087  {
2088#if LAYERS_NOT_PRESENT_SEI
2089    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream  );
2090#else
2091    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream );
2092#endif
2093    SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
2094    if (activeParamSets.size()>0)
2095    {
2096      SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
2097#if R0247_SEI_ACTIVE
2098      getLayerDec(0)->m_parameterSetManagerDecoder.applyPrefetchedPS();
2099      assert(seiAps->activeSeqParameterSetId.size()>0);
2100      if( !getLayerDec(0)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) )
2101      {
2102        printf ("Warning SPS activation with Active parameter set SEI failed");
2103      }
2104      for (Int c=1 ; c <= seiAps->numSpsIdsMinus1; c++)
2105      {
2106        Int layerIdx = seiAps->layerSpsIdx[c];
2107        getLayerDec(layerIdx)->m_parameterSetManagerDecoder.applyPrefetchedPS();
2108        if( !getLayerDec(layerIdx)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[layerIdx] ) )
2109        {
2110          printf ("Warning SPS activation with Active parameter set SEI failed");
2111        }
2112      }
2113#else
2114      m_parameterSetManagerDecoder.applyPrefetchedPS();
2115      assert(seiAps->activeSeqParameterSetId.size()>0);
2116      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] ))
2117      {
2118        printf ("Warning SPS activation with Active parameter set SEI failed");
2119      }
2120#endif
2121    }
2122  }
2123}
2124
2125#if SVC_EXTENSION
2126Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC)
2127#else
2128Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
2129#endif
2130{
2131  // Initialize entropy decoder
2132  m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder);
2133  m_cEntropyDecoder.setBitstream      (nalu.m_Bitstream);
2134
2135#if O0137_MAX_LAYERID
2136  // ignore any NAL units with nuh_layer_id == 63
2137  if (nalu.m_layerId == 63 )
2138  { 
2139    return false;
2140  }
2141#endif
2142  switch (nalu.m_nalUnitType)
2143  {
2144    case NAL_UNIT_VPS:
2145#if SVC_EXTENSION
2146      assert( nalu.m_layerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
2147#endif
2148      xDecodeVPS();
2149#if RExt__DECODER_DEBUG_BIT_STATISTICS
2150      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
2151#endif
2152#if SVC_EXTENSION
2153#if Q0177_EOS_CHECKS
2154      m_isLastNALWasEos = false;
2155#endif
2156#if AVC_BASE
2157      if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getNonHEVCBaseLayerFlag() )
2158      {
2159        if( !m_ppcTDecTop[0]->getBLReconFile()->good() )
2160        {
2161          printf( "Base layer YUV input reading error\n" );
2162          exit(EXIT_FAILURE);
2163        }       
2164      }
2165      else
2166      {
2167        TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic();
2168        cListPic->clear();
2169      }
2170#endif
2171      xDeriveSmallestLayerId(m_parameterSetManagerDecoder.getPrefetchedVPS(0));
2172#endif
2173      return false;
2174
2175    case NAL_UNIT_SPS:
2176      xDecodeSPS();
2177#if RExt__DECODER_DEBUG_BIT_STATISTICS
2178      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
2179#endif
2180      return false;
2181
2182    case NAL_UNIT_PPS:
2183      xDecodePPS(
2184#if Q0048_CGS_3D_ASYMLUT
2185        &m_c3DAsymLUTPPS
2186#endif
2187        );
2188#if RExt__DECODER_DEBUG_BIT_STATISTICS
2189      TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0);
2190#endif
2191      return false;
2192
2193    case NAL_UNIT_PREFIX_SEI:
2194    case NAL_UNIT_SUFFIX_SEI:
2195#if Q0177_EOS_CHECKS
2196      if ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI )
2197      {
2198        assert( m_isLastNALWasEos == false );
2199      }
2200#endif
2201      xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
2202      return false;
2203
2204    case NAL_UNIT_CODED_SLICE_TRAIL_R:
2205    case NAL_UNIT_CODED_SLICE_TRAIL_N:
2206    case NAL_UNIT_CODED_SLICE_TSA_R:
2207    case NAL_UNIT_CODED_SLICE_TSA_N:
2208    case NAL_UNIT_CODED_SLICE_STSA_R:
2209    case NAL_UNIT_CODED_SLICE_STSA_N:
2210    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
2211    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
2212    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
2213    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
2214    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
2215    case NAL_UNIT_CODED_SLICE_CRA:
2216    case NAL_UNIT_CODED_SLICE_RADL_N:
2217    case NAL_UNIT_CODED_SLICE_RADL_R:
2218    case NAL_UNIT_CODED_SLICE_RASL_N:
2219    case NAL_UNIT_CODED_SLICE_RASL_R:
2220#if Q0177_EOS_CHECKS
2221      if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N ||
2222          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N ||
2223          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N ||
2224          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
2225          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N )
2226      {
2227        assert( m_isLastNALWasEos == false );
2228      }
2229      else
2230      {
2231        m_isLastNALWasEos = false;
2232      }
2233#endif
2234#if SVC_EXTENSION
2235      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC);
2236#else
2237      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
2238#endif
2239      break;
2240
2241    case NAL_UNIT_EOS:
2242#if Q0177_EOS_CHECKS
2243      assert( m_isLastNALWasEos == false );
2244
2245      m_isLastNALWasEos = true;
2246      m_lastPicHasEos = true;
2247#endif
2248      m_associatedIRAPType = NAL_UNIT_INVALID;
2249      m_pocCRA = 0;
2250      m_pocRandomAccess = MAX_INT;
2251      m_prevPOC = MAX_INT;
2252      m_prevSliceSkipped = false;
2253      m_skippedPOC = 0;
2254      return false;
2255
2256    case NAL_UNIT_ACCESS_UNIT_DELIMITER:
2257      // TODO: process AU delimiter
2258      return false;
2259
2260    case NAL_UNIT_EOB:
2261#if P0130_EOB
2262      //Check layer id of the nalu. if it is not 0, give a warning message.
2263      if (nalu.m_layerId > 0)
2264      {
2265        printf( "\n\nThis bitstream is ended with EOB NALU that has layer id greater than 0\n" );
2266      }
2267#endif
2268      return false;
2269
2270    case NAL_UNIT_FILLER_DATA:
2271#if Q0177_EOS_CHECKS
2272      assert( m_isLastNALWasEos == false );
2273#endif
2274      return false;
2275
2276    case NAL_UNIT_RESERVED_VCL_N10:
2277    case NAL_UNIT_RESERVED_VCL_R11:
2278    case NAL_UNIT_RESERVED_VCL_N12:
2279    case NAL_UNIT_RESERVED_VCL_R13:
2280    case NAL_UNIT_RESERVED_VCL_N14:
2281    case NAL_UNIT_RESERVED_VCL_R15:
2282
2283    case NAL_UNIT_RESERVED_IRAP_VCL22:
2284    case NAL_UNIT_RESERVED_IRAP_VCL23:
2285
2286    case NAL_UNIT_RESERVED_VCL24:
2287    case NAL_UNIT_RESERVED_VCL25:
2288    case NAL_UNIT_RESERVED_VCL26:
2289    case NAL_UNIT_RESERVED_VCL27:
2290    case NAL_UNIT_RESERVED_VCL28:
2291    case NAL_UNIT_RESERVED_VCL29:
2292    case NAL_UNIT_RESERVED_VCL30:
2293    case NAL_UNIT_RESERVED_VCL31:
2294
2295    case NAL_UNIT_RESERVED_NVCL41:
2296    case NAL_UNIT_RESERVED_NVCL42:
2297    case NAL_UNIT_RESERVED_NVCL43:
2298    case NAL_UNIT_RESERVED_NVCL44:
2299    case NAL_UNIT_RESERVED_NVCL45:
2300    case NAL_UNIT_RESERVED_NVCL46:
2301    case NAL_UNIT_RESERVED_NVCL47:
2302    case NAL_UNIT_UNSPECIFIED_48:
2303    case NAL_UNIT_UNSPECIFIED_49:
2304    case NAL_UNIT_UNSPECIFIED_50:
2305    case NAL_UNIT_UNSPECIFIED_51:
2306    case NAL_UNIT_UNSPECIFIED_52:
2307    case NAL_UNIT_UNSPECIFIED_53:
2308    case NAL_UNIT_UNSPECIFIED_54:
2309    case NAL_UNIT_UNSPECIFIED_55:
2310    case NAL_UNIT_UNSPECIFIED_56:
2311    case NAL_UNIT_UNSPECIFIED_57:
2312    case NAL_UNIT_UNSPECIFIED_58:
2313    case NAL_UNIT_UNSPECIFIED_59:
2314    case NAL_UNIT_UNSPECIFIED_60:
2315    case NAL_UNIT_UNSPECIFIED_61:
2316    case NAL_UNIT_UNSPECIFIED_62:
2317    case NAL_UNIT_UNSPECIFIED_63:
2318
2319    default:
2320      assert (0);
2321      break;
2322  }
2323
2324  return false;
2325}
2326
2327/** Function for checking if picture should be skipped because of association with a previous BLA picture
2328 * \param iPOCLastDisplay POC of last picture displayed
2329 * \returns true if the picture should be skipped
2330 * This function skips all TFD pictures that follow a BLA picture
2331 * in decoding order and precede it in output order.
2332 */
2333Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
2334{
2335  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) &&
2336       m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
2337  {
2338    iPOCLastDisplay++;
2339    return true;
2340  }
2341  return false;
2342}
2343
2344/** Function for checking if picture should be skipped because of random access
2345 * \param iSkipFrame skip frame counter
2346 * \param iPOCLastDisplay POC of last picture displayed
2347 * \returns true if the picture shold be skipped in the random access.
2348 * This function checks the skipping of pictures in the case of -s option random access.
2349 * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped.
2350 * It also checks the type of Nal unit type at the random access point.
2351 * 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.
2352 * If the random access point is IDR all pictures after the random access point are decoded.
2353 * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC
2354 * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random
2355 * access point there is no guarantee that the decoder will not crash.
2356 */
2357Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay)
2358{
2359  if (iSkipFrame)
2360  {
2361    iSkipFrame--;   // decrement the counter
2362    return true;
2363  }
2364  else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet.
2365  {
2366    if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
2367        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
2368        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
2369        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL )
2370    {
2371      // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
2372      m_pocRandomAccess = m_apcSlicePilot->getPOC();
2373    }
2374    else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
2375    {
2376      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
2377    }
2378    else
2379    {
2380      static Bool warningMessage = false;
2381      if(!warningMessage)
2382      {
2383        printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture");
2384        warningMessage = true;
2385      }
2386      return true;
2387    }
2388  }
2389  // skip the reordered pictures, if necessary
2390  else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
2391  {
2392    iPOCLastDisplay++;
2393    return true;
2394  }
2395  // if we reach here, then the picture is not skipped.
2396  return false;
2397}
2398
2399#if SVC_EXTENSION
2400#if !REPN_FORMAT_IN_VPS
2401Void TDecTop::xInitILRP(TComSPS *pcSPS)
2402#else
2403Void TDecTop::xInitILRP(TComSlice *slice)
2404#endif
2405{
2406#if REPN_FORMAT_IN_VPS
2407  TComSPS* pcSPS = slice->getSPS();
2408  Int bitDepthY   = slice->getBitDepthY();
2409  Int bitDepthC   = slice->getBitDepthC();
2410  Int picWidth    = slice->getPicWidthInLumaSamples();
2411  Int picHeight   = slice->getPicHeightInLumaSamples();
2412#endif
2413  if(m_layerId>0)
2414  {
2415#if REPN_FORMAT_IN_VPS
2416    g_bitDepth[CHANNEL_TYPE_LUMA]     = bitDepthY;
2417    g_bitDepth[CHANNEL_TYPE_CHROMA]   = bitDepthC;
2418#else
2419    g_bitDepth[CHANNEL_TYPE_LUMA]     = pcSPS->getBitDepthY();
2420    g_bitDepth[CHANNEL_TYPE_CHROMA]   = pcSPS->getBitDepthC();
2421#endif
2422    g_uiMaxCUWidth  = pcSPS->getMaxCUWidth();
2423    g_uiMaxCUHeight = pcSPS->getMaxCUHeight();
2424    g_uiMaxCUDepth  = pcSPS->getMaxCUDepth();
2425    g_uiAddCUDepth  = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() );
2426
2427    Int  numReorderPics[MAX_TLAYER];
2428    Window &conformanceWindow = slice->getConformanceWindow();
2429    Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window();
2430
2431    for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 
2432    {
2433#if USE_DPB_SIZE_TABLE
2434      if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )
2435      {
2436        assert( this->getLayerId() == 0 );
2437        numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);
2438      }
2439      else
2440      {
2441        TComVPS *vps = slice->getVPS();
2442        // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.
2443        numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);
2444      }
2445#else
2446      numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);
2447#endif
2448    }
2449
2450    if (m_cIlpPic[0] == NULL)
2451    {
2452      for (Int j=0; j < m_numDirectRefLayers; j++)
2453      {
2454
2455        m_cIlpPic[j] = new  TComPic;
2456
2457#if AUXILIARY_PICTURES
2458#if REPN_FORMAT_IN_VPS
2459        m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
2460#else
2461        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
2462#endif
2463#else
2464#if REPN_FORMAT_IN_VPS
2465        m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
2466#else
2467        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
2468#endif
2469#endif
2470        for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCtusInFrame(); i++)
2471        {
2472          m_cIlpPic[j]->getPicSym()->getCtu(i)->initCtu(m_cIlpPic[j], i);
2473        }
2474      }
2475    }
2476  }
2477}
2478
2479#if VPS_EXTN_DIRECT_REF_LAYERS
2480TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdx )
2481{
2482  TComVPS* vps = m_parameterSetManagerDecoder.getActiveVPS();
2483  if( vps->getNumDirectRefLayers( m_layerId ) <= 0 )
2484  {
2485    return (TDecTop *)getLayerDec( 0 );
2486  }
2487 
2488  return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdx ) );
2489}
2490#endif
2491
2492#if VPS_EXTN_DIRECT_REF_LAYERS
2493Void TDecTop::setRefLayerParams( TComVPS* vps )
2494{
2495  for(UInt layerIdx = 0; layerIdx < m_numLayer; layerIdx++)
2496  {
2497    TDecTop *decTop = (TDecTop *)getLayerDec(vps->getLayerIdInNuh(layerIdx));
2498    decTop->setNumSamplePredRefLayers(0);
2499    decTop->setNumMotionPredRefLayers(0);
2500    decTop->setNumDirectRefLayers(0);
2501
2502    for(Int j = 0; j < layerIdx; j++)
2503    {
2504      if (vps->getDirectDependencyFlag(layerIdx, j))
2505      {
2506        decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layerIdx));
2507        decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1);
2508
2509        Int samplePredEnabledFlag = (vps->getDirectDependencyType(layerIdx, j) + 1) & 1;
2510        decTop->setNumSamplePredRefLayers(decTop->getNumSamplePredRefLayers() + samplePredEnabledFlag);
2511
2512        Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layerIdx, j) + 1) & 2) >> 1;
2513        decTop->setNumMotionPredRefLayers(decTop->getNumMotionPredRefLayers() + motionPredEnabledFlag);
2514      }
2515    }
2516  }
2517}
2518#endif
2519
2520#if OUTPUT_LAYER_SET_INDEX
2521Void TDecTop::checkValueOfTargetOutputLayerSetIdx(TComVPS *vps)
2522{
2523  CommonDecoderParams* params = this->getCommonDecoderParams();
2524
2525  if( params->getValueCheckedFlag() )
2526  {
2527    return; // Already checked
2528  }
2529
2530  if( params->getTargetOutputLayerSetIdx() == -1 )  // Output layer set index not specified
2531  {
2532    if( params->getTargetLayerId() > vps->getMaxLayerId() )
2533    {
2534      printf( "Warning: specified target layerId %d is greater than max layerId %d. Target layerId is set equal to max layerId %d.\n", params->getTargetLayerId(), vps->getMaxLayerId(), vps->getMaxLayerId() );
2535      params->setTargetLayerId( vps->getMaxLayerId() );
2536    }
2537
2538    Bool layerSetMatchFound = false;
2539    // Output layer set index not assigned.
2540    // Based on the value of targetLayerId, check if any of the output layer matches
2541    // Currently, the target layer ID in the encoder assumes that all the layers are decoded   
2542    // Check if any of the output layer sets match this description
2543    for(Int i = 0; i < vps->getNumOutputLayerSets(); i++)
2544    {
2545      Bool layerSetMatchFlag = false;
2546      Int layerSetIdx = vps->getOutputLayerSetIdx( i );
2547
2548      for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++)
2549      {
2550        if( vps->getLayerSetLayerIdList( layerSetIdx, j ) == params->getTargetLayerId() )
2551        {
2552          layerSetMatchFlag = true;
2553          break;
2554        }
2555      }
2556     
2557      if( layerSetMatchFlag ) // Potential output layer set candidate found
2558      {
2559        // If target dec layer ID list is also included - check if they match
2560        if( params->getTargetDecLayerIdSet() )
2561        {
2562          if( params->getTargetDecLayerIdSet()->size() ) 
2563          {
2564            for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++)
2565            {
2566              if( *(params->getTargetDecLayerIdSet()->begin() + j) != vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, j )))
2567              {
2568                layerSetMatchFlag = false;
2569              }
2570            }
2571          }
2572        }
2573        if( layerSetMatchFlag ) // The target dec layer ID list also matches, if present
2574        {
2575          // Match found
2576          layerSetMatchFound = true;
2577          params->setTargetOutputLayerSetIdx( i );
2578          params->setValueCheckedFlag( true );
2579          break;
2580        }
2581      }
2582    }
2583    assert( layerSetMatchFound ); // No output layer set matched the value of either targetLayerId or targetdeclayerIdlist
2584  }   
2585  else // Output layer set index is assigned - check if the values match
2586  {
2587    // Check if the target decoded layer is the highest layer in the list
2588    assert( params->getTargetOutputLayerSetIdx() < vps->getNumOutputLayerSets() );
2589#if !CONFORMANCE_BITSTREAM_MODE
2590    assert( params->getTargetOutputLayerSetIdx() < vps->getNumLayerSets() );
2591#endif
2592    Int layerSetIdx = vps->getOutputLayerSetIdx( params->getTargetOutputLayerSetIdx() );  // Index to the layer set
2593#if !CONFORMANCE_BITSTREAM_MODE
2594    assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1);
2595#endif
2596   
2597    // Check if the targetdeclayerIdlist matches the output layer set
2598    if( params->getTargetDecLayerIdSet() )
2599    {
2600      if( params->getTargetDecLayerIdSet()->size() ) 
2601      {
2602        for(Int i = 0; i < vps->getNumLayersInIdList( layerSetIdx ); i++)
2603        {
2604          assert( *(params->getTargetDecLayerIdSet()->begin() + i) == vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, i )));
2605        }
2606      }
2607    }
2608    params->setValueCheckedFlag( true );
2609
2610  }
2611
2612  // Set correct value of targetLayerId
2613  Int targetOlsIdx = params->getTargetOutputLayerSetIdx();
2614  Int targetLsIdx = vps->getOutputLayerSetIdx( targetOlsIdx );
2615  params->setTargetLayerId( vps->getLayerSetLayerIdList( targetLsIdx, vps->getNumLayersInIdList(targetLsIdx)-1 ) );
2616
2617  // Check if the current layer is an output layer
2618  for(Int i = 0; i < vps->getNumLayersInIdList( targetLsIdx ); i++)
2619  {
2620    if( vps->getOutputLayerFlag( targetOlsIdx, i ) )
2621    {
2622      this->getLayerDec( vps->getLayerSetLayerIdList( targetLsIdx, i ) )->m_isOutputLayerFlag = true;
2623    }
2624  }
2625}
2626#endif
2627
2628#if POC_RESET_IDC_DECODER
2629Void TDecTop::markAllPicsAsNoCurrAu(TComVPS *vps)
2630{
2631  for(Int i = 0; i < MAX_LAYERS; i++)
2632  {
2633    TComList<TComPic*>* listPic = this->getLayerDec(vps->getLayerIdInNuh(i))->getListPic();
2634    TComList<TComPic*>::iterator  iterPic = listPic->begin();
2635    while ( iterPic != listPic->end() )
2636    {
2637      TComPic *pcPic = *(iterPic);
2638      pcPic->setCurrAuFlag( false );
2639      iterPic++;
2640    }
2641  }
2642}
2643#endif
2644#if Q0048_CGS_3D_ASYMLUT
2645Void TDecTop::initAsymLut(TComSlice *pcSlice)
2646{
2647  if(m_layerId>0)
2648  {
2649    if(!m_pColorMappedPic)
2650    {
2651      Int picWidth    = pcSlice->getPicWidthInLumaSamples();
2652      Int picHeight   = pcSlice->getPicHeightInLumaSamples();
2653      m_pColorMappedPic = new TComPicYuv;
2654      m_pColorMappedPic->create( picWidth, picHeight, pcSlice->getChromaFormatIdc()/*CHROMA_420*/, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
2655    }
2656  }
2657}
2658#endif
2659#if POC_RESET_RESTRICTIONS
2660Void TDecTop::resetPocRestrictionCheckParameters()
2661{
2662  TDecTop::m_checkPocRestrictionsForCurrAu       = false;
2663  TDecTop::m_pocResetIdcOrCurrAu                 = -1;
2664  TDecTop::m_baseLayerIdrFlag                    = false;
2665  TDecTop::m_baseLayerPicPresentFlag             = false;
2666  TDecTop::m_baseLayerIrapFlag                   = false;
2667  TDecTop::m_nonBaseIdrPresentFlag               = false;
2668  TDecTop::m_nonBaseIdrType                      = -1;
2669  TDecTop::m_picNonIdrWithRadlPresentFlag        = false;
2670  TDecTop::m_picNonIdrNoLpPresentFlag            = false;
2671}
2672#endif
2673
2674Void TDecTop::xCheckLayerReset()
2675{
2676  if (m_apcSlicePilot->isIRAP() && m_layerId > m_smallestLayerId)
2677  {
2678    Bool layerResetFlag;
2679    UInt dolLayerId;
2680    if (m_lastPicHasEos)
2681    {
2682      layerResetFlag = true;
2683      dolLayerId = m_layerId;
2684    }
2685    else if ((m_apcSlicePilot->isCRA() && m_apcSlicePilot->getHandleCraAsBlaFlag()) ||
2686      (m_apcSlicePilot->isIDR() && m_apcSlicePilot->getCrossLayerBLAFlag()) || m_apcSlicePilot->isBLA())
2687    {
2688      layerResetFlag = true;
2689      dolLayerId = m_layerId;
2690    }
2691    else
2692    {
2693      layerResetFlag = false;
2694    }
2695
2696    if (layerResetFlag)
2697    {
2698      for (Int i = 0; i < m_apcSlicePilot->getVPS()->getNumPredictedLayers(dolLayerId); i++)
2699      {
2700        UInt iLayerId = m_apcSlicePilot->getVPS()->getPredictedLayerId(dolLayerId, i);
2701        m_ppcTDecTop[iLayerId]->m_layerInitializedFlag = false;
2702        m_ppcTDecTop[iLayerId]->m_firstPicInLayerDecodedFlag = false;
2703      }
2704
2705      for (TComList<TComPic*>::iterator i = m_cListPic.begin(); i != m_cListPic.end(); i++)
2706      {
2707        if ((*i)->getPOC() != m_apcSlicePilot->getPOC())
2708        {
2709          (*i)->getSlice(0)->setReferenced(false);
2710        }
2711      }
2712
2713      for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getNumPredictedLayers(dolLayerId); i++)
2714      {
2715        UInt predLId = m_apcSlicePilot->getVPS()->getPredictedLayerId(dolLayerId, i);
2716        for (TComList<TComPic*>::iterator pic = m_ppcTDecTop[predLId]->getListPic()->begin(); pic != m_ppcTDecTop[predLId]->getListPic()->end(); pic++)
2717        {
2718          if ((*pic)->getSlice(0)->getPOC() != m_apcSlicePilot->getPOC())
2719          {
2720            (*pic)->getSlice(0)->setReferenced(false);
2721          }
2722        }
2723      }
2724    }
2725  }
2726}
2727
2728Void TDecTop::xSetLayerInitializedFlag()
2729{
2730  if (m_apcSlicePilot->isIRAP() && m_apcSlicePilot->getNoRaslOutputFlag())
2731  {
2732    if (m_layerId == 0)
2733    {
2734      m_ppcTDecTop[m_layerId]->setLayerInitializedFlag(true);
2735    }
2736    else if (!m_ppcTDecTop[m_layerId]->getLayerInitializedFlag() && m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId) == 0)
2737    {
2738      m_ppcTDecTop[m_layerId]->setLayerInitializedFlag(true);
2739    }
2740    else if (!m_ppcTDecTop[m_layerId]->getLayerInitializedFlag())
2741    {
2742      Bool refLayersInitialized = true;
2743      for (UInt j = 0; j < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); j++)
2744      {
2745        UInt refLayerId = m_apcSlicePilot->getVPS()->getRefLayerId(m_layerId, j);
2746        if (!m_ppcTDecTop[refLayerId]->getLayerInitializedFlag())
2747        {
2748          refLayersInitialized = false;
2749        }
2750      }
2751      if (refLayersInitialized)
2752      {
2753        m_ppcTDecTop[m_layerId]->setLayerInitializedFlag(true);
2754      }
2755    }
2756  }
2757}
2758
2759Void TDecTop::xDeriveSmallestLayerId(TComVPS* vps)
2760{
2761  UInt smallestLayerId;
2762  Int  targetOlsIdx = m_commonDecoderParams->getTargetOutputLayerSetIdx();
2763  assert( targetOlsIdx >= 0 );
2764
2765  UInt targetDecLayerSetIdx = vps->getOutputLayerSetIdx(targetOlsIdx);
2766  UInt lsIdx = targetDecLayerSetIdx;
2767  UInt targetDecLayerIdList[MAX_LAYERS] = {0};
2768
2769  for (UInt i = 0, j = 0; i < vps->getNumLayersInIdList(lsIdx); i++)
2770  {
2771    if (vps->getNecessaryLayerFlag(targetOlsIdx, i))
2772    {
2773      targetDecLayerIdList[j++] = vps->getLayerSetLayerIdList(lsIdx, i);
2774    }
2775  }
2776
2777  if (targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1())
2778  {
2779    smallestLayerId = 0;
2780  }
2781  else if (vps->getNumLayersInIdList(targetDecLayerSetIdx) == 1)
2782  {
2783    smallestLayerId = 0;
2784  }
2785  else
2786  {
2787    smallestLayerId = targetDecLayerIdList[0];
2788  }
2789
2790  for( UInt layerId = 0; layerId < MAX_VPS_LAYER_IDX_PLUS1; layerId++ )
2791  {
2792    m_ppcTDecTop[layerId]->m_smallestLayerId = smallestLayerId;
2793  }
2794}
2795
2796Void TDecTop::xSetSpatialEnhLayerFlag(TComSlice* slice, TComPic* pic)
2797{
2798  for(UInt i = 0; i < slice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ )
2799  {
2800    const Window scalEL = slice->getPPS()->getScaledRefLayerWindowForLayer(slice->getVPS()->getRefLayerId(m_layerId, i));
2801    const Window refEL = slice->getPPS()->getRefLayerWindowForLayer(slice->getVPS()->getRefLayerId(m_layerId, i));
2802    Bool equalOffsets = scalEL.hasEqualOffset(refEL);
2803    Bool zeroPhase = slice->getPPS()->hasZeroResamplingPhase(slice->getVPS()->getRefLayerId(m_layerId, i));
2804
2805    TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i );
2806    //TComPic*                      pcPic = *(pcTDecTopBase->getListPic()->begin());
2807    TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec(); 
2808
2809    UInt refLayerId = slice->getVPS()->getRefLayerId(m_layerId, i);
2810    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] );
2811
2812    if( pcPicYuvRecBase->getWidth(COMPONENT_Y) == slice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight(COMPONENT_Y) == slice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase )
2813    {
2814      pic->setEqualPictureSizeAndOffsetFlag( i, true );
2815    }
2816
2817    if( !pic->equalPictureSizeAndOffsetFlag(i) || !sameBitDepths
2818#if Q0048_CGS_3D_ASYMLUT
2819      || slice->getPPS()->getCGSFlag() > 0
2820#endif
2821#if LAYER_CTB
2822      || pcTDecTopBase->getActiveSPS()->getMaxCUWidth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUWidth() || pcTDecTopBase->getActiveSPS()->getMaxCUHeight() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUHeight() || pcTDecTopBase->getActiveSPS()->getMaxCUDepth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUDepth()
2823#endif
2824      )
2825    {
2826      pic->setSpatialEnhLayerFlag( i, true );
2827
2828      //only for scalable extension
2829      assert( slice->getVPS()->getScalabilityMask( SCALABILITY_ID ) == true );
2830    }
2831  }
2832}
2833
2834#endif //SVC_EXTENSION
2835
2836
2837//! \}
Note: See TracBrowser for help on using the repository browser.