source: 3DVCSoftware/branches/HTM-9.2-dev0/source/Lib/TLibDecoder/TDecTop.cpp @ 765

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

Cleanup part 2

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