source: 3DVCSoftware/branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp @ 852

Last change on this file since 852 was 852, checked in by tech, 10 years ago

Update HM-12.0 -> HM-13.0.

  • Property svn:eol-style set to native
File size: 51.0 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 H_MV
42ParameterSetManagerDecoder TDecTop::m_parameterSetManagerDecoder;
43#endif
44//! \ingroup TLibDecoder
45//! \{
46
47#if H_3D
48CamParsCollector::CamParsCollector()
49: m_bInitialized( false )
50{
51  m_aaiCodedOffset         = new Int* [ MAX_NUM_LAYERS ];
52  m_aaiCodedScale          = new Int* [ MAX_NUM_LAYERS ];
53  m_aiViewId               = new Int  [ MAX_NUM_LAYERS ];
54
55  m_bViewReceived          = new Bool [ MAX_NUM_LAYERS ];
56  for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ )
57  {
58    m_aaiCodedOffset      [ uiId ] = new Int [ MAX_NUM_LAYERS ];
59    m_aaiCodedScale       [ uiId ] = new Int [ MAX_NUM_LAYERS ];
60  }
61
62  xCreateLUTs( (UInt)MAX_NUM_LAYERS, (UInt)MAX_NUM_LAYERS, m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
63  m_iLog2Precision   = LOG2_DISP_PREC_LUT;
64  m_uiBitDepthForLUT = 8; // fixed
65}
66
67CamParsCollector::~CamParsCollector()
68{
69  for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ )
70  {
71    delete [] m_aaiCodedOffset      [ uiId ];
72    delete [] m_aaiCodedScale       [ uiId ];
73  }
74  delete [] m_aaiCodedOffset;
75  delete [] m_aaiCodedScale;
76  delete [] m_aiViewId; 
77  delete [] m_bViewReceived;
78
79  xDeleteArray( m_adBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 );
80  xDeleteArray( m_aiBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 );
81}
82
83Void
84CamParsCollector::init( FILE* pCodedScaleOffsetFile )
85{
86  m_bInitialized            = true;
87  m_pCodedScaleOffsetFile   = pCodedScaleOffsetFile;
88  m_uiCamParsCodedPrecision = 0;
89  m_bCamParsVaryOverTime    = false;
90  m_iLastViewIndex             = -1;
91  m_iLastPOC                = -1;
92  m_uiMaxViewIndex             = 0;
93}
94
95Void
96CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT)
97{
98
99  uiNumberSourceViews = std::max( (UInt) 1, uiNumberSourceViews );
100  uiNumberTargetViews = std::max( (UInt) 1, uiNumberTargetViews );
101
102  radLUT         = new Double***[ uiNumberSourceViews ];
103  raiLUT         = new Int   ***[ uiNumberSourceViews ];
104
105  for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ )
106  {
107    radLUT        [ uiSourceView ] = new Double**[ uiNumberTargetViews ];
108    raiLUT        [ uiSourceView ] = new Int   **[ uiNumberTargetViews ];
109
110    for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ )
111    {
112      radLUT        [ uiSourceView ][ uiTargetView ]      = new Double*[ 2 ];
113      radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ];
114      radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ];
115
116      raiLUT        [ uiSourceView ][ uiTargetView ]      = new Int*   [ 2 ];
117      raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ 257 ];
118      raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ 257 ];
119    }
120  }
121}
122
123Void
124  CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT)
125{
126  Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_uiCamParsCodedPrecision + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
127  Int     iLog2DivChroma = iLog2DivLuma + 1;
128
129  iOffset <<= m_uiBitDepthForLUT;
130
131  Double dScale  = (Double) iScale  / (( Double ) ( 1 << iLog2DivLuma ));
132  Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma ));
133
134  // offsets including rounding offsets
135  Int64 iOffsetLuma   = iOffset + ( ( 1 << iLog2DivLuma   ) >> 1 );
136  Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 );
137
138
139  for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ )
140  {
141
142    // real-valued look-up tables
143    Double  dShiftLuma      = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
144    Double  dShiftChroma    = dShiftLuma / 2;
145    radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma;
146    radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma;
147
148    // integer-valued look-up tables
149    Int64   iTempScale      = (Int64)uiDepthValue * iScale;
150    Int64   iShiftLuma      = ( iTempScale + iOffsetLuma   ) >> iLog2DivLuma;
151    Int64   iShiftChroma    = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma;
152    raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma;
153    raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma;
154  }
155
156  radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
157  radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
158  raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
159  raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
160}
161
162Void
163CamParsCollector::uninit()
164{
165  m_bInitialized = false;
166}
167
168Void
169CamParsCollector::setSlice( TComSlice* pcSlice )
170{
171
172  if( pcSlice == 0 )
173  {
174    AOF( xIsComplete() );
175    if( m_bCamParsVaryOverTime || m_iLastPOC == 0 )
176    {
177      xOutput( m_iLastPOC );
178    }
179    return;
180  }
181 
182  if ( pcSlice->getIsDepth())
183  {
184    return;
185  }
186
187  Bool  bFirstAU          = ( pcSlice->getPOC()     == 0 );
188  Bool  bFirstSliceInAU   = ( pcSlice->getPOC()     != Int ( m_iLastPOC ) );
189  Bool  bFirstSliceInView = ( pcSlice->getViewIndex()  != UInt( m_iLastViewIndex ) || bFirstSliceInAU );
190
191  AOT(  bFirstSliceInAU  &&   pcSlice->getViewIndex()  != 0 );
192  AOT( !bFirstSliceInAU  &&   pcSlice->getViewIndex()   < UInt( m_iLastViewIndex ) );
193 
194  AOT( !bFirstSliceInAU  &&   pcSlice->getViewIndex()   > UInt( m_iLastViewIndex + 1 ) );
195 
196  AOT( !bFirstAU         &&   pcSlice->getViewIndex()   > m_uiMaxViewIndex );
197
198  if ( !bFirstSliceInView )
199  {
200    if( m_bCamParsVaryOverTime ) // check consistency of slice parameters here
201    {
202      UInt uiViewIndex = pcSlice->getViewIndex();
203      for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < uiViewIndex; uiBaseViewIndex++ )
204      {
205        AOF( m_aaiCodedScale [ uiBaseViewIndex ][ uiViewIndex ] == pcSlice->getCodedScale    () [ uiBaseViewIndex ] );
206        AOF( m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ] == pcSlice->getCodedOffset   () [ uiBaseViewIndex ] );
207        AOF( m_aaiCodedScale [ uiViewIndex ][ uiBaseViewIndex ] == pcSlice->getInvCodedScale () [ uiBaseViewIndex ] );
208        AOF( m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ] == pcSlice->getInvCodedOffset() [ uiBaseViewIndex ] );
209      }
210    }
211    return;
212  }
213
214  if( bFirstSliceInAU )
215  {
216    if( !bFirstAU )
217    {
218      AOF( xIsComplete() );
219      xOutput( m_iLastPOC );
220    }
221    ::memset( m_bViewReceived, false, MAX_NUM_LAYERS * sizeof( Bool ) );
222  }
223
224  UInt uiViewIndex                       = pcSlice->getViewIndex();
225  m_bViewReceived[ uiViewIndex ]         = true;
226  if( bFirstAU )
227  {
228    m_uiMaxViewIndex                     = std::max( m_uiMaxViewIndex, uiViewIndex );
229    m_aiViewId[ uiViewIndex ]            = pcSlice->getViewId();
230
231    if( uiViewIndex == 1 )
232    {
233      m_uiCamParsCodedPrecision       = pcSlice->getVPS()->getCamParPrecision     ();
234      m_bCamParsVaryOverTime          = pcSlice->getVPS()->hasCamParInSliceHeader ( uiViewIndex );
235    }
236    else if( uiViewIndex > 1 )
237    {
238      AOF( m_uiCamParsCodedPrecision == pcSlice->getVPS()->getCamParPrecision     () );
239      AOF( m_bCamParsVaryOverTime    == pcSlice->getVPS()->hasCamParInSliceHeader ( uiViewIndex ) );
240    }
241
242    for( UInt uiBaseIndex = 0; uiBaseIndex < uiViewIndex; uiBaseIndex++ )
243    {
244      if( m_bCamParsVaryOverTime )
245      {
246        m_aaiCodedScale [ uiBaseIndex ][ uiViewIndex ]  = pcSlice->getCodedScale    () [ uiBaseIndex ];
247        m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ]  = pcSlice->getCodedOffset   () [ uiBaseIndex ];
248        m_aaiCodedScale [ uiViewIndex ][ uiBaseIndex ]  = pcSlice->getInvCodedScale () [ uiBaseIndex ];
249        m_aaiCodedOffset[ uiViewIndex ][ uiBaseIndex ]  = pcSlice->getInvCodedOffset() [ uiBaseIndex ];
250        xInitLUTs( uiBaseIndex, uiViewIndex, m_aaiCodedScale[ uiBaseIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
251        xInitLUTs( uiViewIndex, uiBaseIndex, m_aaiCodedScale[ uiViewIndex ][ uiBaseIndex ], m_aaiCodedOffset[ uiViewIndex ][ uiBaseIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
252      }
253      else
254      {
255        m_aaiCodedScale [ uiBaseIndex ][ uiViewIndex ]  = pcSlice->getVPS()->getCodedScale    (uiViewIndex) [ uiBaseIndex ];
256        m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ]  = pcSlice->getVPS()->getCodedOffset   (uiViewIndex) [ uiBaseIndex ];
257        m_aaiCodedScale [ uiViewIndex ][ uiBaseIndex ]  = pcSlice->getVPS()->getInvCodedScale (uiViewIndex) [ uiBaseIndex ];
258        m_aaiCodedOffset[ uiViewIndex ][ uiBaseIndex ]  = pcSlice->getVPS()->getInvCodedOffset(uiViewIndex) [ uiBaseIndex ];
259        xInitLUTs( uiBaseIndex, uiViewIndex, m_aaiCodedScale[ uiBaseIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
260        xInitLUTs( uiViewIndex, uiBaseIndex, m_aaiCodedScale[ uiViewIndex ][ uiBaseIndex ], m_aaiCodedOffset[ uiViewIndex ][ uiBaseIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
261      }
262    }
263  }
264  else
265  {
266    AOF( m_aiViewId[ uiViewIndex ] == pcSlice->getViewId() );
267    if( m_bCamParsVaryOverTime )
268    {
269      for( UInt uiBaseIndex = 0; uiBaseIndex < uiViewIndex; uiBaseIndex++ )
270      {
271        m_aaiCodedScale [ uiBaseIndex ][ uiViewIndex ]  = pcSlice->getCodedScale    () [ uiBaseIndex ];
272        m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ]  = pcSlice->getCodedOffset   () [ uiBaseIndex ];
273        m_aaiCodedScale [ uiViewIndex ][ uiBaseIndex ]  = pcSlice->getInvCodedScale () [ uiBaseIndex ];
274        m_aaiCodedOffset[ uiViewIndex ][ uiBaseIndex ]  = pcSlice->getInvCodedOffset() [ uiBaseIndex ];
275
276        xInitLUTs( uiBaseIndex, uiViewIndex, m_aaiCodedScale[ uiBaseIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
277        xInitLUTs( uiViewIndex, uiBaseIndex, m_aaiCodedScale[ uiViewIndex ][ uiBaseIndex ], m_aaiCodedOffset[ uiViewIndex ][ uiBaseIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
278      }
279    }
280  }
281 
282  m_iLastViewIndex = (Int)pcSlice->getViewIndex(); 
283  m_iLastPOC       = (Int)pcSlice->getPOC();
284}
285
286#if H_3D_IV_MERGE
287Void
288CamParsCollector::copyCamParamForSlice( TComSlice* pcSlice )
289{
290  if( m_bCamParsVaryOverTime )
291  {
292    pcSlice->setCamparaSlice( m_aaiCodedScale, m_aaiCodedOffset );
293  }
294}
295#endif
296
297Bool
298CamParsCollector::xIsComplete()
299{
300  for( UInt uiView = 0; uiView <= m_uiMaxViewIndex; uiView++ )
301  {
302    if( m_bViewReceived[ uiView ] == 0 )
303    {
304      return false;
305    }
306  }
307  return true;
308}
309
310Void
311CamParsCollector::xOutput( Int iPOC )
312{
313  if( m_pCodedScaleOffsetFile )
314  {
315    if( iPOC == 0 )
316    {
317      fprintf( m_pCodedScaleOffsetFile, "#  ViewIndex       ViewId\n" );
318      fprintf( m_pCodedScaleOffsetFile, "#----------- ------------\n" );
319      for( UInt uiViewIndex = 0; uiViewIndex <= m_uiMaxViewIndex; uiViewIndex++ )
320      {
321        fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewIndex, m_aiViewId[ uiViewIndex ] );
322      }
323      fprintf( m_pCodedScaleOffsetFile, "\n\n");
324      fprintf( m_pCodedScaleOffsetFile, "# StartFrame     EndFrame   TargetView     BaseView   CodedScale  CodedOffset    Precision\n" );
325      fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" );
326    }
327    if( iPOC == 0 || m_bCamParsVaryOverTime )
328    {
329      Int iS = iPOC;
330      Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) );
331      for( UInt uiViewIndex = 0; uiViewIndex <= m_uiMaxViewIndex; uiViewIndex++ )
332      {
333        for( UInt uiBaseIndex = 0; uiBaseIndex <= m_uiMaxViewIndex; uiBaseIndex++ )
334        {
335          if( uiViewIndex != uiBaseIndex )
336          {
337            fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n",
338              iS, iE, uiViewIndex, uiBaseIndex, m_aaiCodedScale[ uiBaseIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ], m_uiCamParsCodedPrecision );
339          }
340        }
341      }
342    }
343  }
344}
345#endif
346TDecTop::TDecTop()
347{
348  m_pcPic = 0;
349  m_iMaxRefPicNum = 0;
350#if ENC_DEC_TRACE
351#if H_MV
352  if ( g_hTrace == NULL )
353  {
354#endif
355  g_hTrace = fopen( "TraceDec.txt", "wb" );
356  g_bJustDoIt = g_bEncDecTraceDisable;
357  g_nSymbolCounter = 0;
358#if H_MV
359  }
360#endif
361#endif
362  m_associatedIRAPType = NAL_UNIT_INVALID;
363  m_pocCRA = 0;
364  m_pocRandomAccess = MAX_INT; 
365  m_prevPOC                = MAX_INT;
366  m_bFirstSliceInPicture    = true;
367  m_bFirstSliceInSequence   = true;
368  m_prevSliceSkipped = false;
369  m_skippedPOC = 0;
370#if H_MV
371  m_layerId = 0;
372  m_viewId = 0;
373#if H_3D
374  m_viewIndex = 0; 
375  m_isDepth = false;
376  m_pcCamParsCollector = 0;
377#endif
378#endif
379}
380
381TDecTop::~TDecTop()
382{
383#if ENC_DEC_TRACE
384  fclose( g_hTrace );
385#endif
386}
387
388Void TDecTop::create()
389{
390  m_cGopDecoder.create();
391  m_apcSlicePilot = new TComSlice;
392  m_uiSliceIdx = 0;
393}
394
395Void TDecTop::destroy()
396{
397  m_cGopDecoder.destroy();
398 
399  delete m_apcSlicePilot;
400  m_apcSlicePilot = NULL;
401 
402  m_cSliceDecoder.destroy();
403}
404
405Void TDecTop::init()
406{
407  // initialize ROM
408#if !H_MV
409  initROM();
410#endif
411  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO );
412  m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder );
413  m_cEntropyDecoder.init(&m_cPrediction);
414}
415
416Void TDecTop::deletePicBuffer ( )
417{
418  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
419  Int iSize = Int( m_cListPic.size() );
420 
421  for (Int i = 0; i < iSize; i++ )
422  {
423    TComPic* pcPic = *(iterPic++);
424#if H_MV
425    if( pcPic )
426    {
427#endif
428    pcPic->destroy();
429   
430    delete pcPic;
431    pcPic = NULL;
432#if H_MV
433    }
434#endif
435  }
436 
437  m_cSAO.destroy();
438 
439  m_cLoopFilter.        destroy();
440 
441#if !H_MV
442  // destroy ROM
443  destroyROM();
444#endif
445}
446
447Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic )
448{
449  Int  numReorderPics[MAX_TLAYER];
450  Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow();
451  Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window();
452
453#if H_MV
454    assert( conformanceWindow   .getScaledFlag() ); 
455    assert( defaultDisplayWindow.getScaledFlag() );
456#endif
457  for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 
458  {
459    numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer);
460  }
461
462  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
463  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
464  {
465    rpcPic = new TComPic();
466   
467    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, 
468                     conformanceWindow, defaultDisplayWindow, numReorderPics, true);
469    m_cListPic.pushBack( rpcPic );
470   
471    return;
472  }
473 
474  Bool bBufferIsAvailable = false;
475  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
476  while (iterPic != m_cListPic.end())
477  {
478    rpcPic = *(iterPic++);
479    if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false)
480    {
481      rpcPic->setOutputMark(false);
482      bBufferIsAvailable = true;
483      break;
484    }
485
486    if ( rpcPic->getSlice( 0 )->isReferenced() == false  && rpcPic->getOutputMark() == false)
487    {
488      rpcPic->setOutputMark(false);
489      rpcPic->setReconMark( false );
490      rpcPic->getPicYuvRec()->setBorderExtension( false );
491      bBufferIsAvailable = true;
492      break;
493    }
494  }
495 
496  if ( !bBufferIsAvailable )
497  {
498    //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer.
499    m_iMaxRefPicNum++;
500    rpcPic = new TComPic();
501    m_cListPic.pushBack( rpcPic );
502  }
503  rpcPic->destroy();
504  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
505                   conformanceWindow, defaultDisplayWindow, numReorderPics, true);
506}
507
508#if H_MV
509Void TDecTop::endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic, std::vector<Int>& targetDecLayerIdSet )
510#else
511Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic)
512#endif
513{
514  if (!m_pcPic)
515  {
516    /* nothing to deblock */
517    return;
518  }
519 
520  TComPic*&   pcPic         = m_pcPic;
521
522  // Execute Deblock + Cleanup
523
524  m_cGopDecoder.filterPicture(pcPic);
525
526  TComSlice::sortPicList( m_cListPic ); // sorting for application output
527  poc                 = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
528  rpcListPic          = &m_cListPic; 
529  m_cCuDecoder.destroy();       
530#if H_MV
531  TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); 
532  TComSlice::markCurrPic( pcPic ); 
533  TComSlice::markIvRefPicsAsUnused   ( m_ivPicLists, targetDecLayerIdSet, m_parameterSetManagerDecoder.getActiveVPS(), m_layerId, poc ); 
534#endif
535  m_bFirstSliceInPicture  = true;
536
537  return;
538}
539
540Void TDecTop::xCreateLostPicture(Int iLostPoc) 
541{
542  printf("\ninserting lost poc : %d\n",iLostPoc);
543  TComSlice cFillSlice;
544  cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
545  cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
546  cFillSlice.initSlice();
547  TComPic *cFillPic;
548  xGetNewPicBuffer(&cFillSlice,cFillPic);
549  cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
550  cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
551  cFillPic->getSlice(0)->initSlice();
552 
553  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
554  Int closestPoc = 1000000;
555  while ( iterPic != m_cListPic.end())
556  {
557    TComPic * rpcPic = *(iterPic++);
558    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())
559    {
560      closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc);
561    }
562  }
563  iterPic = m_cListPic.begin();
564  while ( iterPic != m_cListPic.end())
565  {
566    TComPic *rpcPic = *(iterPic++);
567    if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC())
568    {
569      printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC());
570      rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec());
571      break;
572    }
573  }
574  cFillPic->setCurrSliceIdx(0);
575  for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) 
576  {
577    cFillPic->getCU(i)->initCU(cFillPic,i);
578  }
579  cFillPic->getSlice(0)->setReferenced(true);
580  cFillPic->getSlice(0)->setPOC(iLostPoc);
581  cFillPic->setReconMark(true);
582  cFillPic->setOutputMark(true);
583  if(m_pocRandomAccess == MAX_INT)
584  {
585    m_pocRandomAccess = iLostPoc;
586  }
587}
588
589
590Void TDecTop::xActivateParameterSets()
591{
592  m_parameterSetManagerDecoder.applyPrefetchedPS();
593 
594  TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId());
595  assert (pps != 0);
596
597  TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId());
598  assert (sps != 0);
599
600#if H_MV
601  TComVPS* vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
602  assert (vps != 0); 
603  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP(), m_layerId ) )
604#else
605  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
606#endif
607  {
608    printf ("Parameter set activation failed!");
609    assert (0);
610  }
611
612  if( pps->getDependentSliceSegmentsEnabledFlag() )
613  {
614    Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1;
615
616    if (m_cSliceDecoder.getCtxMemSize() != NumCtx)
617    {
618      m_cSliceDecoder.initCtxMem(NumCtx);
619      for ( UInt st = 0; st < NumCtx; st++ )
620      {
621        TDecSbac* ctx = NULL;
622        ctx = new TDecSbac;
623        ctx->init( &m_cBinCABAC );
624        m_cSliceDecoder.setCtxMem( ctx, st );
625      }
626    }
627  }
628
629  m_apcSlicePilot->setPPS(pps);
630  m_apcSlicePilot->setSPS(sps);
631#if H_MV
632  m_apcSlicePilot->setVPS(vps); 
633  // The nuh_layer_id value of the NAL unit containing the PPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
634  assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getInDirectDependencyFlag( m_layerId, pps->getLayerId() ) );   
635  // The nuh_layer_id value of the NAL unit containing the SPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
636  assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getInDirectDependencyFlag( m_layerId, sps->getLayerId() ) );
637  sps->inferRepFormat  ( vps , m_layerId ); 
638  sps->inferScalingList( m_parameterSetManagerDecoder.getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); 
639#endif
640  pps->setSPS(sps);
641  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1);
642  pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
643
644  g_bitDepthY     = sps->getBitDepthY();
645  g_bitDepthC     = sps->getBitDepthC();
646  g_uiMaxCUWidth  = sps->getMaxCUWidth();
647  g_uiMaxCUHeight = sps->getMaxCUHeight();
648  g_uiMaxCUDepth  = sps->getMaxCUDepth();
649  g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );
650
651  for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
652  {
653    sps->setAMPAcc( i, sps->getUseAMP() );
654  }
655
656  for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++)
657  {
658    sps->setAMPAcc( i, 0 );
659  }
660
661  m_cSAO.destroy();
662  m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() );
663  m_cLoopFilter.create( sps->getMaxCUDepth() );
664}
665
666#if H_MV
667Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag  )
668{
669  assert( nalu.m_layerId == m_layerId ); 
670#else
671Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
672{
673#endif
674  TComPic*&   pcPic         = m_pcPic;
675  m_apcSlicePilot->initSlice();
676
677  if (m_bFirstSliceInPicture)
678  {
679    m_uiSliceIdx     = 0;
680  }
681  else
682  {
683    m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );
684  }
685  m_apcSlicePilot->setSliceIdx(m_uiSliceIdx);
686
687  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
688  Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N ||
689                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
690                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N  ||
691                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N  ||
692                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N);
693  m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag);
694 
695  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
696  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
697
698#if H_MV
699  m_apcSlicePilot->setRefPicSetInterLayer( & m_refPicSetInterLayer0, &m_refPicSetInterLayer1 ); 
700  m_apcSlicePilot->setLayerId( nalu.m_layerId );
701#endif
702  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
703
704  // set POC for dependent slices in skipped pictures
705  if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) 
706  {
707    m_apcSlicePilot->setPOC(m_skippedPOC);
708  }
709
710  m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA);
711  m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
712
713#if H_MV 
714  TComVPS* vps     = m_apcSlicePilot->getVPS();
715  Int layerId  = nalu.m_layerId;   
716  setViewId   ( vps->getViewId   ( layerId )      ); 
717#if H_3D
718  setViewIndex( vps->getViewIndex( layerId )      ); 
719  setIsDepth  ( vps->getDepthId  ( layerId ) == 1 ); 
720  m_ivPicLists->setVPS( vps ); 
721#endif
722#endif
723
724#if H_MV
725    xCeckNoClrasOutput();
726#endif
727    // Skip pictures due to random access
728    if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
729    {
730    m_prevSliceSkipped = true;
731    m_skippedPOC = m_apcSlicePilot->getPOC();
732#if H_MV
733    sliceSkippedFlag = true; 
734#endif
735      return false;
736    }
737    // Skip TFD pictures associated with BLA/BLANT pictures
738    if (isSkipPictureForBLA(iPOCLastDisplay))
739    {
740    m_prevSliceSkipped = true;
741    m_skippedPOC = m_apcSlicePilot->getPOC();
742#if H_MV
743    sliceSkippedFlag = true; 
744#endif
745      return false;
746    }
747
748  // clear previous slice skipped flag
749  m_prevSliceSkipped = false;
750
751  //we should only get a different poc for a new picture (with CTU address==0)
752  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0))
753  {
754    printf ("Warning, the first slice of a picture might have been lost!\n");
755  }
756  // exit when a new picture is found
757  if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence )
758  {
759    if (m_prevPOC >= m_pocRandomAccess)
760    {
761      m_prevPOC = m_apcSlicePilot->getPOC();
762      return true;
763    }
764    m_prevPOC = m_apcSlicePilot->getPOC();
765  }
766#if H_MV
767  if ( newLayerFlag )
768  {
769    return false; 
770  }
771#if ENC_DEC_TRACE
772#if H_MV_ENC_DEC_TRAC
773  // parse remainder of SH
774   g_disableHLSTrace = false; 
775#endif
776#endif
777#endif
778  // actual decoding starts here
779#if H_MV
780   // This part needs further testing !
781   if ( m_apcSlicePilot->getPocResetFlag() )
782   {   
783     xResetPocInPicBuffer();
784   }
785#endif
786  xActivateParameterSets();
787
788  if (m_apcSlicePilot->isNextSlice()) 
789  {
790    m_prevPOC = m_apcSlicePilot->getPOC();
791  }
792  m_bFirstSliceInSequence = false;
793  //detect lost reference picture and insert copy of earlier frame.
794  Int lostPoc;
795  while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0)
796  {
797    xCreateLostPicture(lostPoc-1);
798  }
799  if (m_bFirstSliceInPicture)
800  {
801    // Buffer initialize for prediction.
802    m_cPrediction.initTempBuff();
803    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
804#if H_MV
805    m_apcSlicePilot->createInterLayerReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); 
806#endif
807    //  Get a new picture buffer
808    xGetNewPicBuffer (m_apcSlicePilot, pcPic);
809
810    Bool isField = false;
811    Bool isTff = false;
812   
813    if(!m_SEIs.empty())
814    {
815      // Check if any new Picture Timing SEI has arrived
816      SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING);
817      if (pictureTimingSEIs.size()>0)
818      {
819        SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin());
820        isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2);
821        isTff =  (pictureTiming->m_picStruct == 1);
822      }
823    }
824   
825    //Set Field/Frame coding mode
826    m_pcPic->setField(isField);
827    m_pcPic->setTopField(isTff);
828   
829    // transfer any SEI messages that have been received to the picture
830    pcPic->setSEIs(m_SEIs);
831    m_SEIs.clear();
832
833    // Recursive structure
834    m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
835    m_cCuDecoder.init   ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction );
836    m_cTrQuant.init     ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize());
837
838    m_cSliceDecoder.create();
839  }
840  else
841  {
842    // Check if any new SEI has arrived
843    if(!m_SEIs.empty())
844    {
845      // Currently only decoding Unit SEI message occurring between VCL NALUs copied
846      SEIMessages &picSEI = pcPic->getSEIs();
847      SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
848      picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
849      deleteSEIs(m_SEIs);
850    }
851  }
852 
853  //  Set picture slice pointer
854  TComSlice*  pcSlice = m_apcSlicePilot;
855  Bool bNextSlice     = pcSlice->isNextSlice();
856
857  UInt uiCummulativeTileWidth;
858  UInt uiCummulativeTileHeight;
859  UInt i, j, p;
860
861  //set NumColumnsMins1 and NumRowsMinus1
862  pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() );
863  pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() );
864
865  //create the TComTileArray
866  pcPic->getPicSym()->xCreateTComTileArray();
867
868  if( pcSlice->getPPS()->getUniformSpacingFlag() )
869  {
870    //set the width for each tile
871    for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++)
872    {
873      for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++)
874      {
875        pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->
876          setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) 
877          - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) );
878      }
879    }
880
881    //set the height for each tile
882    for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++)
883    {
884      for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++)
885      {
886        pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->
887          setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) 
888          - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) );   
889      }
890    }
891  }
892  else
893  {
894    //set the width for each tile
895    for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++)
896    {
897      uiCummulativeTileWidth = 0;
898      for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++)
899      {
900        pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) );
901        uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i);
902      }
903      pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth );
904    }
905
906    //set the height for each tile
907    for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++)
908    {
909      uiCummulativeTileHeight = 0;
910      for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++)
911      { 
912        pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) );
913        uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i);
914      }
915      pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight );
916    }
917  }
918
919  pcPic->getPicSym()->xInitTiles();
920
921  //generate the Coding Order Map and Inverse Coding Order Map
922  UInt uiEncCUAddr;
923  for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr))
924  {
925    pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr);
926    pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i);
927  }
928  pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame());
929  pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame());
930
931  //convert the start and end CU addresses of the slice and dependent slice into encoding order
932  pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) );
933  pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) );
934  if(pcSlice->isNextSlice())
935  {
936    pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr()));
937    pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr()));
938  }
939
940  if (m_bFirstSliceInPicture) 
941  {
942    if(pcPic->getNumAllocatedSlice() != 1)
943    {
944      pcPic->clearSliceBuffer();
945    }
946  }
947  else
948  {
949    pcPic->allocateNewSlice();
950  }
951  assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
952  m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); 
953  pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);
954
955  pcPic->setTLayer(nalu.m_temporalId);
956
957#if H_MV
958  pcPic->setLayerId( nalu.m_layerId );
959  pcPic->setViewId ( getViewId() );
960#if H_3D
961  pcPic->setViewIndex( getViewIndex() );
962  pcPic->setIsDepth  ( getIsDepth  () );
963#endif
964#endif
965  if (bNextSlice)
966  {
967    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic );
968    // Set reference list
969#if H_MV   
970    std::vector< TComPic* > tempRefPicLists[2];
971    std::vector< Bool     > usedAsLongTerm [2];
972    Int       numPocTotalCurr;
973
974    pcSlice->getTempRefPicLists( m_cListPic, m_refPicSetInterLayer0, m_refPicSetInterLayer1, tempRefPicLists, usedAsLongTerm, numPocTotalCurr);
975    pcSlice->setRefPicList     ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true ); 
976#if H_3D_ARP
977    pcSlice->setARPStepNum(m_ivPicLists);
978    if( pcSlice->getARPStepNum() > 1 )
979    {
980      // GT: This seems to be broken, not all nuh_layer_ids are necessarily present
981      for(Int iLayerId = 0; iLayerId < nalu.m_layerId; iLayerId ++ )
982      {
983        Int  iViewIdx =   pcSlice->getVPS()->getViewIndex(iLayerId);
984        Bool bIsDepth = ( pcSlice->getVPS()->getDepthId  ( iLayerId ) == 1 );
985        if( iViewIdx<getViewIndex() && !bIsDepth )
986        {
987          pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );
988        }
989      }
990    }
991#endif
992#else
993    pcSlice->setRefPicList( m_cListPic, true );
994#endif
995
996#if H_3D
997    pcSlice->setIvPicLists( m_ivPicLists );         
998#if H_3D_IV_MERGE
999#if H_3D_FCO
1000    //assert( !getIsDepth() );
1001#else
1002    assert( !getIsDepth() || ( pcSlice->getTexturePic() != 0 ) );
1003#endif
1004#endif   
1005#endif
1006    // For generalized B
1007    // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
1008    if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0)
1009    {
1010      Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0);
1011      pcSlice->setNumRefIdx        ( REF_PIC_LIST_1, iNumRefIdx );
1012
1013      for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++)
1014      {
1015        pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx);
1016      }
1017    }
1018    if (!pcSlice->isIntra())
1019    {
1020      Bool bLowDelay = true;
1021      Int  iCurrPOC  = pcSlice->getPOC();
1022      Int iRefIdx = 0;
1023
1024      for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++)
1025      {
1026        if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC )
1027        {
1028          bLowDelay = false;
1029        }
1030      }
1031      if (pcSlice->isInterB())
1032      {
1033        for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
1034        {
1035          if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
1036          {
1037            bLowDelay = false;
1038          }
1039        }       
1040      }
1041
1042      pcSlice->setCheckLDC(bLowDelay);           
1043    }
1044
1045    //---------------
1046    pcSlice->setRefPOCList();
1047#if  H_3D_TMVP
1048    if(pcSlice->getLayerId())
1049      pcSlice->generateAlterRefforTMVP();
1050#endif
1051  }
1052
1053  pcPic->setCurrSliceIdx(m_uiSliceIdx);
1054  if(pcSlice->getSPS()->getScalingListFlag())
1055  {
1056    pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList()  );
1057    if(pcSlice->getPPS()->getScalingListPresentFlag())
1058    {
1059      pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList()  );
1060    }
1061    if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag())
1062    {
1063      pcSlice->setDefaultScalingList();
1064    }
1065    m_cTrQuant.setScalingListDec(pcSlice->getScalingList());
1066    m_cTrQuant.setUseScalingList(true);
1067  }
1068  else
1069  {
1070    m_cTrQuant.setFlatScalingList();
1071    m_cTrQuant.setUseScalingList(false);
1072  }
1073
1074#if H_3D_IV_MERGE
1075  if( pcSlice->getIsDepth() && m_pcCamParsCollector )
1076  {
1077    m_pcCamParsCollector->copyCamParamForSlice( pcSlice );
1078  }
1079#endif
1080
1081  //  Decode a picture
1082  m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic);
1083#if H_3D
1084  if( m_pcCamParsCollector )
1085  {
1086    m_pcCamParsCollector->setSlice( pcSlice );
1087  }
1088#endif
1089  m_bFirstSliceInPicture = false;
1090  m_uiSliceIdx++;
1091
1092  return false;
1093}
1094
1095Void TDecTop::xDecodeVPS()
1096{
1097  TComVPS* vps = new TComVPS();
1098 
1099  m_cEntropyDecoder.decodeVPS( vps );
1100  m_parameterSetManagerDecoder.storePrefetchedVPS(vps); 
1101}
1102
1103Void TDecTop::xDecodeSPS()
1104{
1105  TComSPS* sps = new TComSPS();
1106#if H_MV
1107  sps->setLayerId( getLayerId() ); 
1108#endif
1109#if H_3D
1110  // Preliminary fix. assuming that all sps refer to the same SPS.
1111  // Parsing dependency should be resolved!
1112  TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); 
1113  assert( vps != 0 ); 
1114  m_cEntropyDecoder.decodeSPS( sps, vps->getViewIndex( m_layerId ), ( vps->getDepthId( m_layerId ) == 1 ) );
1115#else
1116  m_cEntropyDecoder.decodeSPS( sps );
1117#endif
1118  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
1119}
1120
1121Void TDecTop::xDecodePPS()
1122{
1123  TComPPS* pps = new TComPPS();
1124#if H_MV
1125  pps->setLayerId( getLayerId() ); 
1126#endif
1127#if H_3D
1128  // Assuming that all PPS indirectly refer to the same VPS via different SPS
1129  // There is no parsing dependency in decoding DLT in PPS.
1130  // The VPS information passed to decodePPS() is used to arrange the decoded DLT tables to their corresponding layers.
1131  // This is equivalent to the process of
1132  //   Step 1) decoding DLT tables based on the number of depth layers, and
1133  //   Step 2) mapping DLT tables to the depth layers
1134  // as described in the 3D-HEVC WD.
1135  TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 );
1136  m_cEntropyDecoder.decodePPS( pps, vps );
1137#else
1138  m_cEntropyDecoder.decodePPS( pps );
1139#endif
1140  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
1141}
1142
1143Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType )
1144{
1145  if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
1146  {
1147#if H_MV
1148    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) );
1149#else
1150    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
1151#endif
1152  }
1153  else
1154  {
1155#if H_MV
1156    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) );
1157#else
1158    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
1159#endif
1160    SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
1161    if (activeParamSets.size()>0)
1162    {
1163      SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
1164      m_parameterSetManagerDecoder.applyPrefetchedPS();
1165      assert(seiAps->activeSeqParamSetId.size()>0);
1166#if H_MV
1167      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0], m_layerId ))
1168#else
1169      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))
1170#endif
1171      {
1172        printf ("Warning SPS activation with Active parameter set SEI failed");
1173      }
1174    }
1175  }
1176}
1177
1178#if H_MV
1179Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag )
1180#else
1181Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
1182#endif
1183{
1184  // Initialize entropy decoder
1185  m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder);
1186  m_cEntropyDecoder.setBitstream      (nalu.m_Bitstream);
1187
1188  switch (nalu.m_nalUnitType)
1189  {
1190    case NAL_UNIT_VPS:
1191      xDecodeVPS();
1192      return false;
1193     
1194    case NAL_UNIT_SPS:
1195      xDecodeSPS();
1196      return false;
1197
1198    case NAL_UNIT_PPS:
1199      xDecodePPS();
1200      return false;
1201     
1202    case NAL_UNIT_PREFIX_SEI:
1203    case NAL_UNIT_SUFFIX_SEI:
1204      xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
1205      return false;
1206
1207    case NAL_UNIT_CODED_SLICE_TRAIL_R:
1208    case NAL_UNIT_CODED_SLICE_TRAIL_N:
1209    case NAL_UNIT_CODED_SLICE_TSA_R:
1210    case NAL_UNIT_CODED_SLICE_TSA_N:
1211    case NAL_UNIT_CODED_SLICE_STSA_R:
1212    case NAL_UNIT_CODED_SLICE_STSA_N:
1213    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
1214    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
1215    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
1216    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
1217    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
1218    case NAL_UNIT_CODED_SLICE_CRA:
1219    case NAL_UNIT_CODED_SLICE_RADL_N:
1220    case NAL_UNIT_CODED_SLICE_RADL_R:
1221    case NAL_UNIT_CODED_SLICE_RASL_N:
1222    case NAL_UNIT_CODED_SLICE_RASL_R:
1223#if H_MV
1224      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag );
1225#else
1226      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
1227#endif
1228      break;
1229    case NAL_UNIT_EOS:
1230      m_associatedIRAPType = NAL_UNIT_INVALID;
1231      m_pocCRA = 0;
1232      m_pocRandomAccess = MAX_INT;
1233      m_prevPOC = MAX_INT;
1234      m_bFirstSliceInPicture = true;
1235      m_bFirstSliceInSequence = true;
1236      m_prevSliceSkipped = false;
1237      m_skippedPOC = 0;
1238      return false;
1239     
1240    case NAL_UNIT_ACCESS_UNIT_DELIMITER:
1241      // TODO: process AU delimiter
1242      return false;
1243     
1244    case NAL_UNIT_EOB:
1245      return false;
1246     
1247     
1248    case NAL_UNIT_RESERVED_VCL_N10:
1249    case NAL_UNIT_RESERVED_VCL_R11:
1250    case NAL_UNIT_RESERVED_VCL_N12:
1251    case NAL_UNIT_RESERVED_VCL_R13:
1252    case NAL_UNIT_RESERVED_VCL_N14:
1253    case NAL_UNIT_RESERVED_VCL_R15:
1254     
1255    case NAL_UNIT_RESERVED_IRAP_VCL22:
1256    case NAL_UNIT_RESERVED_IRAP_VCL23:
1257     
1258    case NAL_UNIT_RESERVED_VCL24:
1259    case NAL_UNIT_RESERVED_VCL25:
1260    case NAL_UNIT_RESERVED_VCL26:
1261    case NAL_UNIT_RESERVED_VCL27:
1262    case NAL_UNIT_RESERVED_VCL28:
1263    case NAL_UNIT_RESERVED_VCL29:
1264    case NAL_UNIT_RESERVED_VCL30:
1265    case NAL_UNIT_RESERVED_VCL31:
1266     
1267    case NAL_UNIT_FILLER_DATA:
1268    case NAL_UNIT_RESERVED_NVCL41:
1269    case NAL_UNIT_RESERVED_NVCL42:
1270    case NAL_UNIT_RESERVED_NVCL43:
1271    case NAL_UNIT_RESERVED_NVCL44:
1272    case NAL_UNIT_RESERVED_NVCL45:
1273    case NAL_UNIT_RESERVED_NVCL46:
1274    case NAL_UNIT_RESERVED_NVCL47:
1275    case NAL_UNIT_UNSPECIFIED_48:
1276    case NAL_UNIT_UNSPECIFIED_49:
1277    case NAL_UNIT_UNSPECIFIED_50:
1278    case NAL_UNIT_UNSPECIFIED_51:
1279    case NAL_UNIT_UNSPECIFIED_52:
1280    case NAL_UNIT_UNSPECIFIED_53:
1281    case NAL_UNIT_UNSPECIFIED_54:
1282    case NAL_UNIT_UNSPECIFIED_55:
1283    case NAL_UNIT_UNSPECIFIED_56:
1284    case NAL_UNIT_UNSPECIFIED_57:
1285    case NAL_UNIT_UNSPECIFIED_58:
1286    case NAL_UNIT_UNSPECIFIED_59:
1287    case NAL_UNIT_UNSPECIFIED_60:
1288    case NAL_UNIT_UNSPECIFIED_61:
1289    case NAL_UNIT_UNSPECIFIED_62:
1290    case NAL_UNIT_UNSPECIFIED_63:
1291    default:
1292      assert (0);
1293  }
1294
1295  return false;
1296}
1297
1298/** Function for checking if picture should be skipped because of association with a previous BLA picture
1299 * \param iPOCLastDisplay POC of last picture displayed
1300 * \returns true if the picture should be skipped
1301 * This function skips all TFD pictures that follow a BLA picture
1302 * in decoding order and precede it in output order.
1303 */
1304Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
1305{
1306  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) && 
1307       m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
1308  {
1309    iPOCLastDisplay++;
1310    return true;
1311  }
1312  return false;
1313}
1314
1315/** Function for checking if picture should be skipped because of random access
1316 * \param iSkipFrame skip frame counter
1317 * \param iPOCLastDisplay POC of last picture displayed
1318 * \returns true if the picture shold be skipped in the random access.
1319 * This function checks the skipping of pictures in the case of -s option random access.
1320 * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped.
1321 * It also checks the type of Nal unit type at the random access point.
1322 * 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.
1323 * If the random access point is IDR all pictures after the random access point are decoded.
1324 * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC
1325 * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random
1326 * access point there is no guarantee that the decoder will not crash.
1327 */
1328Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay)
1329{
1330  if (iSkipFrame) 
1331  {
1332    iSkipFrame--;   // decrement the counter
1333    return true;
1334  }
1335#if H_MV
1336  else if ( !m_layerInitilizedFlag[ m_layerId ] ) // start of random access point, m_pocRandomAccess has not been set yet.
1337#else
1338  else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet.
1339#endif
1340  {
1341    if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
1342        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
1343        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
1344        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL )
1345    {
1346
1347#if H_MV
1348      if ( xAllRefLayersInitilized() )
1349      {
1350        m_layerInitilizedFlag[ m_layerId ] = true; 
1351        m_pocRandomAccess = m_apcSlicePilot->getPOC();
1352      }
1353      else
1354      {
1355        return true; 
1356      }
1357#else
1358      // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
1359      m_pocRandomAccess = m_apcSlicePilot->getPOC();
1360#endif
1361    }
1362    else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
1363    {
1364#if H_MV
1365      if ( xAllRefLayersInitilized() )
1366      {
1367        m_layerInitilizedFlag[ m_layerId ] = true; 
1368        m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
1369      }
1370      else 
1371      {
1372        return true; 
1373      }
1374#else
1375      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
1376#endif
1377    }
1378    else 
1379    {
1380#if H_MV
1381      static Bool warningMessage[MAX_NUM_LAYERS];
1382      static Bool warningInitFlag = false;
1383     
1384      if (!warningInitFlag)
1385      {
1386        for ( Int i = 0; i < MAX_NUM_LAYERS; i++)
1387        {
1388          warningMessage[i] = true; 
1389        }
1390        warningInitFlag = true; 
1391      }
1392
1393      if ( warningMessage[getLayerId()] )
1394      {
1395        printf("\nLayer%3d   No valid random access point. VCL NAL units of this layer are discarded until next layer initialization picture. ", getLayerId() ); 
1396        warningMessage[m_layerId] = false; 
1397      }
1398#else
1399      static Bool warningMessage = false;
1400      if(!warningMessage)
1401      {
1402        printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture");
1403        warningMessage = true;
1404      }
1405#endif
1406      return true;
1407    }
1408  }
1409  // skip the reordered pictures, if necessary
1410  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))
1411  {
1412    iPOCLastDisplay++;
1413    return true;
1414  }
1415#if H_MV
1416  return !m_layerInitilizedFlag[ getLayerId() ]; 
1417#else
1418  // if we reach here, then the picture is not skipped.
1419  return false; 
1420#endif
1421}
1422
1423#if H_MV
1424TComPic* TDecTop::getPic( Int poc )
1425{
1426  xGetPic( m_layerId, poc ); 
1427  TComList<TComPic*>* listPic = getListPic();
1428  TComPic* pcPic = NULL;
1429  for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++)
1430  {
1431    if( (*it)->getPOC() == poc )
1432    {
1433      pcPic = *it ;
1434      break ;
1435    }
1436  }
1437  return pcPic;
1438}
1439
1440TComPic* TDecTop::xGetPic( Int layerId, Int poc )
1441{ 
1442  return m_ivPicLists->getPic( layerId, poc ) ;
1443}
1444
1445Void TDecTop::xResetPocInPicBuffer()
1446{
1447  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
1448  while (iterPic != m_cListPic.end())
1449  {
1450    TComPic* pic = *(iterPic++);
1451    if ( pic->getReconMark() )
1452    {
1453      for( Int i = 0; i < pic->getNumAllocatedSlice(); i++)
1454      {
1455        TComSlice* slice = pic->getSlice( i ); 
1456        slice->setPOC ( slice->getPOC() - m_apcSlicePilot->getPocBeforeReset() );           
1457      }         
1458    }     
1459  }
1460}
1461
1462#if H_MV
1463Void TDecTop::xCeckNoClrasOutput()
1464{
1465  // This part needs further testing!
1466  if ( getLayerId() == 0 )
1467  {   
1468    NalUnitType nut = m_apcSlicePilot->getNalUnitType(); 
1469
1470    Bool isBLA =  ( nut == NAL_UNIT_CODED_SLICE_BLA_W_LP  )  || ( nut == NAL_UNIT_CODED_SLICE_BLA_N_LP ) || ( nut == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); 
1471    Bool isIDR  = ( nut == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) || ( nut == NAL_UNIT_CODED_SLICE_IDR_N_LP ); 
1472    Bool noClrasOutputFlag  = isBLA || ( isIDR  &&  m_apcSlicePilot->getCrossLayerBlaFlag() ); 
1473
1474    if ( noClrasOutputFlag ) 
1475    {
1476      for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
1477      {
1478        m_layerInitilizedFlag[i] = false; 
1479      } 
1480    }
1481  }
1482}
1483
1484Bool TDecTop::xAllRefLayersInitilized()
1485{
1486  Bool allRefLayersInitilizedFlag = true; 
1487  TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); 
1488  for (Int i = 0; i < vps->getNumDirectRefLayers( getLayerId()  ); i++ )
1489  {
1490    Int refLayerId = vps->getRefLayerId( m_layerId, i ); 
1491    allRefLayersInitilizedFlag = allRefLayersInitilizedFlag && m_layerInitilizedFlag[ refLayerId ]; 
1492  }
1493
1494  return allRefLayersInitilizedFlag;
1495}
1496#endif
1497#endif
1498//! \}
Note: See TracBrowser for help on using the repository browser.