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

Last change on this file since 847 was 834, checked in by seregin, 10 years ago

make parameter sets static

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