source: 3DVCSoftware/trunk/source/Lib/TLibDecoder/TDecTop.cpp @ 758

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

Merged HTM-9.1-dev0-MediaTek@757. (3D-HEVC HLS)

  • Property svn:eol-style set to native
File size: 51.3 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 QC_DEPTH_IV_MRG_F0125
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#if SHARP_ARP_REF_CHECK_F0105
1010    pcSlice->setARPStepNum(m_ivPicLists);
1011#else
1012    pcSlice->setARPStepNum();
1013#endif
1014    if( pcSlice->getARPStepNum() > 1 )
1015    {
1016      // GT: This seems to be broken, not all nuh_layer_ids are necessarily present
1017      for(Int iLayerId = 0; iLayerId < nalu.m_layerId; iLayerId ++ )
1018      {
1019        Int  iViewIdx =   pcSlice->getVPS()->getViewIndex(iLayerId);
1020        Bool bIsDepth = ( pcSlice->getVPS()->getDepthId  ( iLayerId ) == 1 );
1021        if( iViewIdx<getViewIndex() && !bIsDepth )
1022        {
1023          pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );
1024        }
1025      }
1026    }
1027#endif
1028#else
1029#if FIX1071
1030    pcSlice->setRefPicList( m_cListPic, true );
1031#else
1032    pcSlice->setRefPicList( m_cListPic );
1033#endif
1034
1035#endif
1036
1037#if H_3D
1038    pcSlice->setIvPicLists( m_ivPicLists );         
1039#if H_3D_IV_MERGE
1040#if H_3D_FCO
1041    //assert( !getIsDepth() );
1042#else
1043    assert( !getIsDepth() || ( pcSlice->getTexturePic() != 0 ) );
1044#endif
1045#endif   
1046#endif
1047    // For generalized B
1048    // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
1049    if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0)
1050    {
1051      Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0);
1052      pcSlice->setNumRefIdx        ( REF_PIC_LIST_1, iNumRefIdx );
1053
1054      for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++)
1055      {
1056        pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx);
1057      }
1058    }
1059    if (!pcSlice->isIntra())
1060    {
1061      Bool bLowDelay = true;
1062      Int  iCurrPOC  = pcSlice->getPOC();
1063      Int iRefIdx = 0;
1064
1065      for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++)
1066      {
1067        if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC )
1068        {
1069          bLowDelay = false;
1070        }
1071      }
1072      if (pcSlice->isInterB())
1073      {
1074        for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
1075        {
1076          if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
1077          {
1078            bLowDelay = false;
1079          }
1080        }       
1081      }
1082
1083      pcSlice->setCheckLDC(bLowDelay);           
1084    }
1085
1086    //---------------
1087    pcSlice->setRefPOCList();
1088#if  H_3D_TMVP
1089    if(pcSlice->getLayerId())
1090      pcSlice->generateAlterRefforTMVP();
1091#endif
1092  }
1093
1094  pcPic->setCurrSliceIdx(m_uiSliceIdx);
1095  if(pcSlice->getSPS()->getScalingListFlag())
1096  {
1097    pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList()  );
1098    if(pcSlice->getPPS()->getScalingListPresentFlag())
1099    {
1100      pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList()  );
1101    }
1102    if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag())
1103    {
1104      pcSlice->setDefaultScalingList();
1105    }
1106    m_cTrQuant.setScalingListDec(pcSlice->getScalingList());
1107    m_cTrQuant.setUseScalingList(true);
1108  }
1109  else
1110  {
1111    m_cTrQuant.setFlatScalingList();
1112    m_cTrQuant.setUseScalingList(false);
1113  }
1114
1115#if QC_DEPTH_IV_MRG_F0125
1116  if( pcSlice->getIsDepth() && m_pcCamParsCollector )
1117  {
1118    m_pcCamParsCollector->copyCamParamForSlice( pcSlice );
1119  }
1120#endif
1121
1122  //  Decode a picture
1123  m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic);
1124#if H_3D
1125  if( m_pcCamParsCollector )
1126  {
1127    m_pcCamParsCollector->setSlice( pcSlice );
1128  }
1129#if QC_DEPTH_IV_MRG_F0125
1130  if( pcSlice->getIsDepth() )
1131  {
1132#if !CAM_HLS_F0136_F0045_F0082
1133    pcSlice->getSPS()->setHasCamParInSliceHeader( false );
1134#endif
1135  }
1136#endif
1137#endif
1138  m_bFirstSliceInPicture = false;
1139  m_uiSliceIdx++;
1140
1141  return false;
1142}
1143
1144Void TDecTop::xDecodeVPS()
1145{
1146  TComVPS* vps = new TComVPS();
1147 
1148  m_cEntropyDecoder.decodeVPS( vps );
1149  m_parameterSetManagerDecoder.storePrefetchedVPS(vps); 
1150}
1151
1152Void TDecTop::xDecodeSPS()
1153{
1154  TComSPS* sps = new TComSPS();
1155#if H_MV
1156  sps->setLayerId( getLayerId() ); 
1157#endif
1158#if H_3D
1159  // Preliminary fix. assuming that all sps refer to the same SPS.
1160  // Parsing dependency should be resolved!
1161  TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); 
1162  assert( vps != 0 ); 
1163  m_cEntropyDecoder.decodeSPS( sps, vps->getViewIndex( m_layerId ), ( vps->getDepthId( m_layerId ) == 1 ) );
1164#else
1165  m_cEntropyDecoder.decodeSPS( sps );
1166#endif
1167  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
1168}
1169
1170Void TDecTop::xDecodePPS()
1171{
1172  TComPPS* pps = new TComPPS();
1173#if H_MV
1174  pps->setLayerId( getLayerId() ); 
1175#endif
1176#if DLT_DIFF_CODING_IN_PPS
1177  // Assuming that all PPS indirectly refer to the same VPS via different SPS
1178  // There is no parsing dependency in decoding DLT in PPS.
1179  // The VPS information passed to decodePPS() is used to arrange the decoded DLT tables to their corresponding layers.
1180  // This is equivalent to the process of
1181  //   Step 1) decoding DLT tables based on the number of depth layers, and
1182  //   Step 2) mapping DLT tables to the depth layers
1183  // as descripted in the 3D-HEVC WD.
1184  TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 );
1185  m_cEntropyDecoder.decodePPS( pps, vps );
1186#else
1187  m_cEntropyDecoder.decodePPS( pps );
1188#endif
1189  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
1190}
1191
1192Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType )
1193{
1194  if(nalUnitType == NAL_UNIT_SUFFIX_SEI)
1195  {
1196#if H_MV
1197    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) );
1198#else
1199    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
1200#endif
1201  }
1202  else
1203  {
1204#if H_MV
1205    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) );
1206#else
1207    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
1208#endif
1209    SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
1210    if (activeParamSets.size()>0)
1211    {
1212      SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
1213      m_parameterSetManagerDecoder.applyPrefetchedPS();
1214      assert(seiAps->activeSeqParamSetId.size()>0);
1215#if H_MV
1216      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0], m_layerId ))
1217#else
1218      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))
1219#endif
1220      {
1221        printf ("Warning SPS activation with Active parameter set SEI failed");
1222      }
1223    }
1224  }
1225}
1226
1227#if H_MV
1228#if H_MV_FIX_SKIP_PICTURES
1229Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag )
1230#else
1231Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag)
1232#endif
1233#else
1234Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
1235#endif
1236{
1237  // Initialize entropy decoder
1238  m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder);
1239  m_cEntropyDecoder.setBitstream      (nalu.m_Bitstream);
1240
1241  switch (nalu.m_nalUnitType)
1242  {
1243    case NAL_UNIT_VPS:
1244      xDecodeVPS();
1245      return false;
1246     
1247    case NAL_UNIT_SPS:
1248      xDecodeSPS();
1249      return false;
1250
1251    case NAL_UNIT_PPS:
1252      xDecodePPS();
1253      return false;
1254     
1255    case NAL_UNIT_PREFIX_SEI:
1256    case NAL_UNIT_SUFFIX_SEI:
1257      xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
1258      return false;
1259
1260    case NAL_UNIT_CODED_SLICE_TRAIL_R:
1261    case NAL_UNIT_CODED_SLICE_TRAIL_N:
1262    case NAL_UNIT_CODED_SLICE_TLA_R:
1263    case NAL_UNIT_CODED_SLICE_TSA_N:
1264    case NAL_UNIT_CODED_SLICE_STSA_R:
1265    case NAL_UNIT_CODED_SLICE_STSA_N:
1266    case NAL_UNIT_CODED_SLICE_BLA_W_LP:
1267    case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
1268    case NAL_UNIT_CODED_SLICE_BLA_N_LP:
1269    case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
1270    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
1271    case NAL_UNIT_CODED_SLICE_CRA:
1272    case NAL_UNIT_CODED_SLICE_RADL_N:
1273    case NAL_UNIT_CODED_SLICE_RADL_R:
1274    case NAL_UNIT_CODED_SLICE_RASL_N:
1275    case NAL_UNIT_CODED_SLICE_RASL_R:
1276#if H_MV
1277#if H_MV_FIX_SKIP_PICTURES
1278      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag );
1279#else
1280      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag);
1281#endif
1282#else
1283      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
1284#endif
1285      break;
1286    default:
1287      assert (1);
1288  }
1289
1290  return false;
1291}
1292
1293/** Function for checking if picture should be skipped because of association with a previous BLA picture
1294 * \param iPOCLastDisplay POC of last picture displayed
1295 * \returns true if the picture should be skipped
1296 * This function skips all TFD pictures that follow a BLA picture
1297 * in decoding order and precede it in output order.
1298 */
1299Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
1300{
1301  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) && 
1302       m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
1303  {
1304    iPOCLastDisplay++;
1305    return true;
1306  }
1307  return false;
1308}
1309
1310/** Function for checking if picture should be skipped because of random access
1311 * \param iSkipFrame skip frame counter
1312 * \param iPOCLastDisplay POC of last picture displayed
1313 * \returns true if the picture shold be skipped in the random access.
1314 * This function checks the skipping of pictures in the case of -s option random access.
1315 * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped.
1316 * It also checks the type of Nal unit type at the random access point.
1317 * 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.
1318 * If the random access point is IDR all pictures after the random access point are decoded.
1319 * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC
1320 * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random
1321 * access point there is no guarantee that the decoder will not crash.
1322 */
1323Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay)
1324{
1325  if (iSkipFrame) 
1326  {
1327    iSkipFrame--;   // decrement the counter
1328    return true;
1329  }
1330#if H_MV_LAYER_WISE_STARTUP
1331  else if ( !m_layerInitilizedFlag[ m_layerId ] ) // start of random access point, m_pocRandomAccess has not been set yet.
1332#else
1333  else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet.
1334#endif
1335  {
1336    if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
1337        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
1338        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
1339        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL )
1340    {
1341
1342#if H_MV_LAYER_WISE_STARTUP
1343      if ( xAllRefLayersInitilized() )
1344      {
1345        m_layerInitilizedFlag[ m_layerId ] = true; 
1346        m_pocRandomAccess = m_apcSlicePilot->getPOC();
1347      }
1348      else
1349      {
1350        return true; 
1351      }
1352#else
1353      // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
1354      m_pocRandomAccess = m_apcSlicePilot->getPOC();
1355#endif
1356    }
1357    else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
1358    {
1359#if H_MV_LAYER_WISE_STARTUP
1360      if ( xAllRefLayersInitilized() )
1361      {
1362        m_layerInitilizedFlag[ m_layerId ] = true; 
1363      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
1364    }
1365    else 
1366    {
1367        return true; 
1368      }
1369#else
1370      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
1371#endif
1372    }
1373    else 
1374    {
1375#if H_MV_FIX_SKIP_PICTURES
1376      static Bool warningMessage[MAX_NUM_LAYERS];
1377      static Bool warningInitFlag = false;
1378     
1379      if (!warningInitFlag)
1380      {
1381        for ( Int i = 0; i < MAX_NUM_LAYERS; i++)
1382        {
1383          warningMessage[i] = true; 
1384        }
1385        warningInitFlag = true; 
1386      }
1387
1388      if ( warningMessage[getLayerId()] )
1389      {
1390        printf("\nLayer%3d   No valid random access point. VCL NAL units of this layer are discarded until next layer initialization picture. ", getLayerId() ); 
1391        warningMessage[m_layerId] = false; 
1392      }
1393#else
1394      static Bool warningMessage = false;
1395      if(!warningMessage)
1396      {
1397        printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture");
1398        warningMessage = true;
1399      }
1400#endif
1401      return true;
1402    }
1403  }
1404  // skip the reordered pictures, if necessary
1405  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))
1406  {
1407    iPOCLastDisplay++;
1408    return true;
1409  }
1410#if H_MV_LAYER_WISE_STARTUP
1411  return !m_layerInitilizedFlag[ getLayerId() ]; 
1412#else
1413  // if we reach here, then the picture is not skipped.
1414  return false; 
1415#endif
1416}
1417
1418#if H_MV
1419TComPic* TDecTop::getPic( Int poc )
1420{
1421  xGetPic( m_layerId, poc ); 
1422  TComList<TComPic*>* listPic = getListPic();
1423  TComPic* pcPic = NULL;
1424  for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++)
1425  {
1426    if( (*it)->getPOC() == poc )
1427    {
1428      pcPic = *it ;
1429      break ;
1430    }
1431  }
1432  return pcPic;
1433}
1434
1435TComPic* TDecTop::xGetPic( Int layerId, Int poc )
1436{ 
1437  return m_ivPicLists->getPic( layerId, poc ) ;
1438}
1439
1440Void TDecTop::xResetPocInPicBuffer()
1441{
1442  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
1443  while (iterPic != m_cListPic.end())
1444  {
1445    TComPic* pic = *(iterPic++);
1446    if ( pic->getReconMark() )
1447    {
1448      for( Int i = 0; i < pic->getNumAllocatedSlice(); i++)
1449      {
1450        TComSlice* slice = pic->getSlice( i ); 
1451        slice->setPOC ( slice->getPOC() - m_apcSlicePilot->getPocBeforeReset() );           
1452      }         
1453    }     
1454  }
1455}
1456
1457#if H_MV_LAYER_WISE_STARTUP
1458Void TDecTop::xCeckNoClrasOutput()
1459{
1460  // This part needs further testing!
1461  if ( getLayerId() == 0 )
1462  {   
1463    NalUnitType nut = m_apcSlicePilot->getNalUnitType(); 
1464
1465    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 ); 
1466    Bool isIDR  = ( nut == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) || ( nut == NAL_UNIT_CODED_SLICE_IDR_N_LP ); 
1467    Bool noClrasOutputFlag  = isBLA || ( isIDR  &&  m_apcSlicePilot->getCrossLayerBlaFlag() ); 
1468
1469    if ( noClrasOutputFlag ) 
1470    {
1471      for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
1472      {
1473        m_layerInitilizedFlag[i] = false; 
1474      } 
1475    }
1476  }
1477}
1478
1479Bool TDecTop::xAllRefLayersInitilized()
1480{
1481  Bool allRefLayersInitilizedFlag = true; 
1482  TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); 
1483  for (Int i = 0; i < vps->getNumDirectRefLayers( getLayerId()  ); i++ )
1484  {
1485    Int refLayerId = vps->getRefLayerId( m_layerId, i ); 
1486    allRefLayersInitilizedFlag = allRefLayersInitilizedFlag && m_layerInitilizedFlag[ refLayerId ]; 
1487  }
1488
1489  return allRefLayersInitilizedFlag;
1490}
1491#endif
1492#endif
1493//! \}
Note: See TracBrowser for help on using the repository browser.