source: 3DVCSoftware/branches/HTM-5.1-dev3-Mediatek/source/Lib/TLibDecoder/TDecTop.cpp @ 245

Last change on this file since 245 was 231, checked in by mitsubishi-htm, 12 years ago

-Integration of JCT3V-C0152 & JCT3V-C0131
-This check-in enable C0131 only

  • Property svn:eol-style set to native
File size: 50.8 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-2012, 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 "../../App/TAppDecoder/TAppDecTop.h"
40#include "TDecTop.h"
41
42//! \ingroup TLibDecoder
43//! \{
44
45
46CamParsCollector::CamParsCollector()
47: m_bInitialized( false )
48{
49  m_aaiCodedOffset         = new Int* [ MAX_VIEW_NUM ];
50  m_aaiCodedScale          = new Int* [ MAX_VIEW_NUM ];
51  m_aiViewOrderIndex       = new Int  [ MAX_VIEW_NUM ];
52#if QC_MVHEVC_B0046
53  m_aiViewId               = new Int  [ MAX_VIEW_NUM ];
54#endif
55  m_aiViewReceived         = new Int  [ MAX_VIEW_NUM ];
56  for( UInt uiId = 0; uiId < MAX_VIEW_NUM; uiId++ )
57  {
58    m_aaiCodedOffset      [ uiId ] = new Int [ MAX_VIEW_NUM ];
59    m_aaiCodedScale       [ uiId ] = new Int [ MAX_VIEW_NUM ];
60  }
61
62#if MERL_VSP_C0152
63  xCreateLUTs( (UInt)MAX_VIEW_NUM, (UInt)MAX_VIEW_NUM, m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
64  m_iLog2Precision   = LOG2_DISP_PREC_LUT;
65  m_uiBitDepthForLUT = 8; // fixed
66#endif
67}
68
69CamParsCollector::~CamParsCollector()
70{
71  for( UInt uiId = 0; uiId < MAX_VIEW_NUM; uiId++ )
72  {
73    delete [] m_aaiCodedOffset      [ uiId ];
74    delete [] m_aaiCodedScale       [ uiId ];
75  }
76  delete [] m_aaiCodedOffset;
77  delete [] m_aaiCodedScale;
78  delete [] m_aiViewOrderIndex;
79  delete [] m_aiViewReceived;
80
81#if MERL_VSP_C0152
82  xDeleteArray( m_adBaseViewShiftLUT, MAX_VIEW_NUM, MAX_VIEW_NUM, 2 );
83  xDeleteArray( m_aiBaseViewShiftLUT, MAX_VIEW_NUM, MAX_VIEW_NUM, 2 );
84#endif
85}
86
87Void
88CamParsCollector::init( FILE* pCodedScaleOffsetFile )
89{
90  m_bInitialized            = true;
91  m_pCodedScaleOffsetFile   = pCodedScaleOffsetFile;
92  m_uiCamParsCodedPrecision = 0;
93  m_bCamParsVaryOverTime    = false;
94  m_iLastViewId             = -1;
95  m_iLastPOC                = -1;
96  m_uiMaxViewId             = 0;
97}
98
99#if MERL_VSP_C0152
100Void
101CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT)
102{
103  //AOF( m_uiBitDepthForLUT == 8 );
104  //AOF(radLUT == NULL && raiLUT == NULL );
105
106  uiNumberSourceViews = Max( 1, uiNumberSourceViews );
107  uiNumberTargetViews = Max( 1, uiNumberTargetViews );
108
109  radLUT         = new Double***[ uiNumberSourceViews ];
110  raiLUT         = new Int   ***[ uiNumberSourceViews ];
111
112  for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ )
113  {
114    radLUT        [ uiSourceView ] = new Double**[ uiNumberTargetViews ];
115    raiLUT        [ uiSourceView ] = new Int   **[ uiNumberTargetViews ];
116
117    for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ )
118    {
119      radLUT        [ uiSourceView ][ uiTargetView ]      = new Double*[ 2 ];
120      radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ];
121      radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ];
122
123      raiLUT        [ uiSourceView ][ uiTargetView ]      = new Int*   [ 2 ];
124      raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ 257 ];
125      raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ 257 ];
126    }
127  }
128}
129
130Void
131  CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT)
132{
133  Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_uiCamParsCodedPrecision + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
134  Int     iLog2DivChroma = iLog2DivLuma + 1;
135
136  iOffset <<= m_uiBitDepthForLUT;
137
138  Double dScale  = (Double) iScale  / (( Double ) ( 1 << iLog2DivLuma ));
139  Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma ));
140
141  // offsets including rounding offsets
142  Int64 iOffsetLuma   = iOffset + ( ( 1 << iLog2DivLuma   ) >> 1 );
143  Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 );
144
145
146  for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ )
147  {
148
149    // real-valued look-up tables
150    Double  dShiftLuma      = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
151    Double  dShiftChroma    = dShiftLuma / 2;
152    radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma;
153    radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma;
154
155    // integer-valued look-up tables
156    Int64   iTempScale      = (Int64)uiDepthValue * iScale;
157    Int64   iShiftLuma      = ( iTempScale + iOffsetLuma   ) >> iLog2DivLuma;
158    Int64   iShiftChroma    = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma;
159    raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma;
160    raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma;
161
162    // maximum deviation
163    //dMaxDispDev     = Max( dMaxDispDev,    fabs( Double( (Int) iTestScale   ) - dShiftLuma * Double( 1 << iLog2DivLuma ) ) / Double( 1 << iLog2DivLuma ) );
164    //dMaxRndDispDvL  = Max( dMaxRndDispDvL, fabs( Double( (Int) iShiftLuma   ) - dShiftLuma   ) );
165    //dMaxRndDispDvC  = Max( dMaxRndDispDvC, fabs( Double( (Int) iShiftChroma ) - dShiftChroma ) );
166  }
167
168  radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
169  radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
170  raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
171  raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
172}
173#endif // end MERL_VSP_C0152
174
175Void
176CamParsCollector::uninit()
177{
178  m_bInitialized = false;
179}
180
181Void
182CamParsCollector::setSlice( TComSlice* pcSlice )
183{
184  if( pcSlice == 0 )
185  {
186    AOF( xIsComplete() );
187    if( m_bCamParsVaryOverTime || m_iLastPOC == 0 )
188    {
189      xOutput( m_iLastPOC );
190    }
191    return;
192  }
193
194  AOF( pcSlice->getSPS()->getViewId() < MAX_VIEW_NUM );
195  if ( pcSlice->getSPS()->isDepth  () )
196  {
197    return;
198  }
199  Bool  bFirstAU          = ( pcSlice->getPOC()               == 0 );
200  Bool  bFirstSliceInAU   = ( pcSlice->getPOC()               != Int ( m_iLastPOC ) );
201  Bool  bFirstSliceInView = ( pcSlice->getSPS()->getViewId()  != UInt( m_iLastViewId ) || bFirstSliceInAU );
202  AOT(  bFirstSliceInAU  &&   pcSlice->getSPS()->getViewId()  != 0 );
203  AOT( !bFirstSliceInAU  &&   pcSlice->getSPS()->getViewId()   < UInt( m_iLastViewId ) );
204  AOT( !bFirstSliceInAU  &&   pcSlice->getSPS()->getViewId()   > UInt( m_iLastViewId + 1 ) );
205  AOT( !bFirstAU         &&   pcSlice->getSPS()->getViewId()   > m_uiMaxViewId );
206  if ( !bFirstSliceInView )
207  {
208    if( m_bCamParsVaryOverTime ) // check consistency of slice parameters here
209    {
210      UInt uiViewId = pcSlice->getSPS()->getViewId();
211      for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ )
212      {
213        AOF( m_aaiCodedScale [ uiBaseId ][ uiViewId ] == pcSlice->getCodedScale    () [ uiBaseId ] );
214        AOF( m_aaiCodedOffset[ uiBaseId ][ uiViewId ] == pcSlice->getCodedOffset   () [ uiBaseId ] );
215        AOF( m_aaiCodedScale [ uiViewId ][ uiBaseId ] == pcSlice->getInvCodedScale () [ uiBaseId ] );
216        AOF( m_aaiCodedOffset[ uiViewId ][ uiBaseId ] == pcSlice->getInvCodedOffset() [ uiBaseId ] );
217      }
218    }
219    return;
220  }
221
222  if( bFirstSliceInAU )
223  {
224    if( !bFirstAU )
225    {
226      AOF( xIsComplete() );
227      xOutput( m_iLastPOC );
228    }
229    ::memset( m_aiViewReceived, 0x00, MAX_VIEW_NUM * sizeof( Int ) );
230  }
231
232  UInt uiViewId                 = pcSlice->getSPS()->getViewId();
233  m_aiViewReceived[ uiViewId ]  = 1;
234  if( bFirstAU )
235  {
236    m_uiMaxViewId                     = Max( m_uiMaxViewId, uiViewId );
237    m_aiViewOrderIndex[ uiViewId ]    = pcSlice->getSPS()->getViewOrderIdx();
238    if( uiViewId == 1 )
239    {
240      m_uiCamParsCodedPrecision       = pcSlice->getSPS()->getCamParPrecision     ();
241      m_bCamParsVaryOverTime          = pcSlice->getSPS()->hasCamParInSliceHeader ();
242    }
243    else if( uiViewId > 1 )
244    {
245      AOF( m_uiCamParsCodedPrecision == pcSlice->getSPS()->getCamParPrecision     () );
246      AOF( m_bCamParsVaryOverTime    == pcSlice->getSPS()->hasCamParInSliceHeader () );
247    }
248    for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ )
249    {
250      if( m_bCamParsVaryOverTime )
251      {
252        m_aaiCodedScale [ uiBaseId ][ uiViewId ]  = pcSlice->getCodedScale    () [ uiBaseId ];
253        m_aaiCodedOffset[ uiBaseId ][ uiViewId ]  = pcSlice->getCodedOffset   () [ uiBaseId ];
254        m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedScale () [ uiBaseId ];
255        m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedOffset() [ uiBaseId ];
256#if MERL_VSP_C0152
257        xInitLUTs( uiBaseId, uiViewId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
258        xInitLUTs( uiViewId, uiBaseId, m_aaiCodedScale[ uiViewId ][ uiBaseId ], m_aaiCodedOffset[ uiViewId ][ uiBaseId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
259#endif
260      }
261      else
262      {
263        m_aaiCodedScale [ uiBaseId ][ uiViewId ]  = pcSlice->getSPS()->getCodedScale    () [ uiBaseId ];
264        m_aaiCodedOffset[ uiBaseId ][ uiViewId ]  = pcSlice->getSPS()->getCodedOffset   () [ uiBaseId ];
265        m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getSPS()->getInvCodedScale () [ uiBaseId ];
266        m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getSPS()->getInvCodedOffset() [ uiBaseId ];
267#if MERL_VSP_C0152
268        xInitLUTs( uiBaseId, uiViewId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
269        xInitLUTs( uiViewId, uiBaseId, m_aaiCodedScale[ uiViewId ][ uiBaseId ], m_aaiCodedOffset[ uiViewId ][ uiBaseId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
270#endif
271      }
272    }
273  }
274  else
275  {
276    AOF( m_aiViewOrderIndex[ uiViewId ] == pcSlice->getSPS()->getViewOrderIdx() );
277    if( m_bCamParsVaryOverTime )
278    {
279      for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ )
280      {
281        m_aaiCodedScale [ uiBaseId ][ uiViewId ]  = pcSlice->getCodedScale    () [ uiBaseId ];
282        m_aaiCodedOffset[ uiBaseId ][ uiViewId ]  = pcSlice->getCodedOffset   () [ uiBaseId ];
283        m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedScale () [ uiBaseId ];
284        m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedOffset() [ uiBaseId ];
285#if MERL_VSP_C0152
286        xInitLUTs( uiBaseId, uiViewId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
287        xInitLUTs( uiViewId, uiBaseId, m_aaiCodedScale[ uiViewId ][ uiBaseId ], m_aaiCodedOffset[ uiViewId ][ uiBaseId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
288#endif
289      }
290    }
291  }
292  m_iLastViewId = (Int)pcSlice->getSPS()->getViewId();
293  m_iLastPOC    = (Int)pcSlice->getPOC();
294}
295
296Bool
297CamParsCollector::xIsComplete()
298{
299  for( UInt uiView = 0; uiView <= m_uiMaxViewId; uiView++ )
300  {
301    if( m_aiViewReceived[ uiView ] == 0 )
302    {
303      return false;
304    }
305  }
306  return true;
307}
308
309Void
310CamParsCollector::xOutput( Int iPOC )
311{
312  if( m_pCodedScaleOffsetFile )
313  {
314    if( iPOC == 0 )
315    {
316      fprintf( m_pCodedScaleOffsetFile, "#     ViewId ViewOrderIdx\n" );
317      fprintf( m_pCodedScaleOffsetFile, "#----------- ------------\n" );
318      for( UInt uiViewId = 0; uiViewId <= m_uiMaxViewId; uiViewId++ )
319      {
320        fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewId, m_aiViewOrderIndex[ uiViewId ] );
321      }
322      fprintf( m_pCodedScaleOffsetFile, "\n\n");
323      fprintf( m_pCodedScaleOffsetFile, "# StartFrame     EndFrame   TargetView     BaseView   CodedScale  CodedOffset    Precision\n" );
324      fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" );
325    }
326    if( iPOC == 0 || m_bCamParsVaryOverTime )
327    {
328      Int iS = iPOC;
329      Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) );
330      for( UInt uiViewId = 0; uiViewId <= m_uiMaxViewId; uiViewId++ )
331      {
332        for( UInt uiBaseId = 0; uiBaseId <= m_uiMaxViewId; uiBaseId++ )
333        {
334          if( uiViewId != uiBaseId )
335          {
336            fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n",
337              iS, iE, uiViewId, uiBaseId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_uiCamParsCodedPrecision );
338          }
339        }
340      }
341    }
342  }
343}
344
345TDecTop::TDecTop()
346: m_SEIs(0)
347, m_tAppDecTop( NULL )
348, m_nalUnitTypeBaseView( NAL_UNIT_INVALID )
349{
350  m_pcPic = 0;
351  m_iGopSize      = 0;
352  m_bGopSizeSet   = false;
353  m_iMaxRefPicNum = 0;
354  m_uiValidPS = 0;
355#if SONY_COLPIC_AVAILABILITY
356  m_iViewOrderIdx = 0;
357#endif
358#if ENC_DEC_TRACE
359  if(!g_hTrace) g_hTrace = fopen( "TraceDec.txt", "wb" );
360  g_bJustDoIt = g_bEncDecTraceDisable;
361  g_nSymbolCounter = 0;
362#endif
363  m_bRefreshPending = 0;
364  m_pocCRA = 0;
365  m_pocRandomAccess = MAX_INT;         
366  m_prevPOC                = MAX_INT;
367  m_bFirstSliceInPicture    = true;
368  m_bFirstSliceInSequence   = true;
369  m_pcCamParsCollector = 0;
370#if QC_MVHEVC_B0046
371  m_bFirstNal                  = false;
372#endif
373}
374
375TDecTop::~TDecTop()
376{
377#if ENC_DEC_TRACE
378  if(g_hTrace) fclose( g_hTrace );
379  g_hTrace=NULL;
380#endif
381}
382
383Void TDecTop::create()
384{
385  m_cGopDecoder.create();
386  m_apcSlicePilot = new TComSlice;
387  m_uiSliceIdx = m_uiLastSliceIdx = 0;
388}
389
390Void TDecTop::destroy()
391{
392  m_cGopDecoder.destroy();
393 
394  delete m_apcSlicePilot;
395  m_apcSlicePilot = NULL;
396 
397  m_cSliceDecoder.destroy();
398  m_tAppDecTop = NULL;
399
400#if DEPTH_MAP_GENERATION
401  m_cDepthMapGenerator.destroy();
402#endif
403#if HHI_INTER_VIEW_RESIDUAL_PRED
404  m_cResidualGenerator.destroy();
405#endif
406
407}
408
409Void TDecTop::init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance )
410{
411  // initialize ROM
412  if( bFirstInstance )
413  {
414  initROM();
415  }
416  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cAdaptiveLoopFilter, &m_cSAO
417#if DEPTH_MAP_GENERATION
418                    , &m_cDepthMapGenerator
419#endif
420#if HHI_INTER_VIEW_RESIDUAL_PRED
421                    , &m_cResidualGenerator
422#endif
423    );
424  m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder );
425  m_cEntropyDecoder.init(&m_cPrediction);
426  m_tAppDecTop = pcTAppDecTop;
427#if DEPTH_MAP_GENERATION
428#if VIDYO_VPS_INTEGRATION
429  m_cDepthMapGenerator.init( &m_cPrediction, m_tAppDecTop->getVPSAccess(), m_tAppDecTop->getSPSAccess(), m_tAppDecTop->getAUPicAccess() );
430#else
431  m_cDepthMapGenerator.init( &m_cPrediction, m_tAppDecTop->getSPSAccess(), m_tAppDecTop->getAUPicAccess() );
432#endif
433#endif
434#if HHI_INTER_VIEW_RESIDUAL_PRED
435  m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator );
436#endif
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    if( *iterPic )
447    {
448      TComPic* pcPic = *(iterPic++);
449      pcPic->destroy();
450   
451      delete pcPic;
452      pcPic = NULL;
453    }
454  }
455 
456  // destroy ALF temporary buffers
457  m_cAdaptiveLoopFilter.destroy();
458
459  m_cSAO.destroy();
460 
461  m_cLoopFilter.        destroy();
462 
463  // destroy ROM
464  if(m_viewId == 0 && m_isDepth == false)
465  {
466    destroyROM();
467  }
468}
469
470#if HHI_INTER_VIEW_RESIDUAL_PRED
471Void
472TDecTop::deleteExtraPicBuffers( Int iPoc )
473{
474  TComPic*                      pcPic = 0;
475  TComList<TComPic*>::iterator  cIter = m_cListPic.begin();
476  TComList<TComPic*>::iterator  cEnd  = m_cListPic.end  ();
477  for( ; cIter != cEnd; cIter++ )
478  {
479    if( (*cIter)->getPOC() == iPoc )
480    {
481      pcPic = *cIter;
482      break;
483    }
484  }
485  //AOF( pcPic );
486  if ( pcPic )
487  {
488    pcPic->removeResidualBuffer   ();
489  }
490}
491#endif
492
493
494Void
495TDecTop::compressMotion( Int iPoc )
496{
497  TComPic*                      pcPic = 0;
498  TComList<TComPic*>::iterator  cIter = m_cListPic.begin();
499  TComList<TComPic*>::iterator  cEnd  = m_cListPic.end  ();
500  for( ; cIter != cEnd; cIter++ )
501  {
502    if( (*cIter)->getPOC() == iPoc )
503    {
504      pcPic = *cIter;
505      break;
506    }
507  }
508//  AOF( pcPic );
509  if ( pcPic )
510  {
511    pcPic->compressMotion();
512  }
513}
514
515Void TDecTop::xUpdateGopSize (TComSlice* pcSlice)
516{
517  if ( !pcSlice->isIntra() && !m_bGopSizeSet)
518  {
519    m_iGopSize    = pcSlice->getPOC();
520    m_bGopSizeSet = true;
521   
522    m_cGopDecoder.setGopSize(m_iGopSize);
523  }
524}
525
526Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic )
527{
528  xUpdateGopSize(pcSlice);
529 
530#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
531  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded
532#else
533  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxNumberOfReferencePictures()+pcSlice->getSPS()->getNumReorderFrames() + 1; // +1 to have space for the picture currently being decoded
534#endif
535
536#if DEPTH_MAP_GENERATION
537  UInt uiPdm                  = ( pcSlice->getSPS()->getViewId() ? pcSlice->getSPS()->getPredDepthMapGeneration() : m_tAppDecTop->getSPSAccess()->getPdm() );
538  Bool bNeedPrdDepthMapBuffer = ( !pcSlice->getSPS()->isDepth() && uiPdm > 0 );
539#endif
540
541  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
542  {
543    rpcPic = new TComPic();
544   
545    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
546   
547#if DEPTH_MAP_GENERATION
548    if( bNeedPrdDepthMapBuffer )
549    {
550      rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
551    }
552#endif
553   
554    m_cListPic.pushBack( rpcPic );
555   
556    return;
557  }
558 
559  Bool bBufferIsAvailable = false;
560  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
561  while (iterPic != m_cListPic.end())
562  {
563    rpcPic = *(iterPic++);
564    if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false)
565    {
566      rpcPic->setOutputMark(false);
567      bBufferIsAvailable = true;
568      break;
569    }
570
571    if ( rpcPic->getSlice( 0 )->isReferenced() == false  && rpcPic->getOutputMark() == false)
572    {
573      rpcPic->setOutputMark(false);
574      rpcPic->setReconMark( false );
575      rpcPic->getPicYuvRec()->setBorderExtension( false );
576      bBufferIsAvailable = true;
577      break;
578    }
579  }
580 
581  if ( !bBufferIsAvailable )
582  {
583    //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer.
584    m_iMaxRefPicNum++;
585    rpcPic = new TComPic();
586    m_cListPic.pushBack( rpcPic );
587  }
588  rpcPic->destroy(); 
589  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
590#if DEPTH_MAP_GENERATION
591  if( bNeedPrdDepthMapBuffer && !rpcPic->getPredDepthMap() )
592  {
593    rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
594  }
595#endif
596}
597
598Void TDecTop::executeDeblockAndAlf(UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame, Int& iPOCLastDisplay)
599{
600  if (!m_pcPic)
601  {
602    /* nothing to deblock */
603    return;
604  }
605 
606  TComPic*&   pcPic         = m_pcPic;
607
608  // Execute Deblock and ALF only + Cleanup
609
610  m_cGopDecoder.decompressGop(NULL, pcPic, true);
611
612  TComSlice::sortPicList( m_cListPic ); // sorting for application output
613  ruiPOC              = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
614  rpcListPic          = &m_cListPic; 
615  m_cCuDecoder.destroy();       
616  m_bFirstSliceInPicture  = true;
617
618  return;
619}
620
621Void TDecTop::xCreateLostPicture(Int iLostPoc) 
622{
623  printf("\ninserting lost poc : %d\n",iLostPoc);
624  TComSlice cFillSlice;
625  cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
626  cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
627  cFillSlice.initSlice();
628  cFillSlice.initTiles();
629  TComPic *cFillPic;
630  xGetNewPicBuffer(&cFillSlice,cFillPic);
631  cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
632  cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
633  cFillPic->getSlice(0)->initSlice();
634  cFillPic->getSlice(0)->initTiles();
635
636 
637 
638  TComList<TComPic*>::iterator iterPic = m_cListPic.begin();
639  Int closestPoc = 1000000;
640  while ( iterPic != m_cListPic.end())
641  {
642    TComPic * rpcPic = *(iterPic++);
643    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())
644    {
645      closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc);
646    }
647  }
648  iterPic = m_cListPic.begin();
649  while ( iterPic != m_cListPic.end())
650  {
651    TComPic *rpcPic = *(iterPic++);
652    if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC())
653    {
654      printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC());
655      rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec());
656      break;
657    }
658  }
659  cFillPic->setCurrSliceIdx(0);
660  for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) 
661  {
662    cFillPic->getCU(i)->initCU(cFillPic,i);
663  }
664  cFillPic->getSlice(0)->setReferenced(true);
665  cFillPic->getSlice(0)->setPOC(iLostPoc);
666  cFillPic->setReconMark(true);
667  cFillPic->setOutputMark(true);
668  if(m_pocRandomAccess == MAX_INT)
669  {
670    m_pocRandomAccess = iLostPoc;
671  }
672}
673
674
675Void TDecTop::xActivateParameterSets()
676{
677  m_parameterSetManagerDecoder.applyPrefetchedPS();
678
679  TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId());
680  assert (pps != 0);
681
682  TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId());
683  assert (sps != 0);
684#if VIDYO_VPS_INTEGRATION
685  TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
686  assert (vps != 0);
687#if !QC_REM_IDV_B0046
688  if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA )
689#else
690  if( (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) && !sps->getViewId() )
691#endif
692    // VPS can only be activated on IDR or CRA...
693    getTAppDecTop()->getVPSAccess()->setActiveVPSId( sps->getVPSId() );
694#endif
695  m_apcSlicePilot->setPPS(pps);
696  m_apcSlicePilot->setSPS(sps);
697#if QC_MVHEVC_B0046
698  TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
699#endif
700#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
701  m_apcSlicePilot->setVPS(vps);
702#endif
703  pps->setSPS(sps);
704
705  if(sps->getUseSAO() || sps->getUseALF()|| sps->getScalingListFlag() || sps->getUseDF())
706  {
707    m_apcSlicePilot->setAPS( m_parameterSetManagerDecoder.getAPS(m_apcSlicePilot->getAPSId())  );
708  }
709  pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
710
711  for (Int i = 0; i < sps->getMaxCUDepth() - 1; i++)
712  {
713    sps->setAMPAcc( i, sps->getUseAMP() );
714  }
715
716  for (Int i = sps->getMaxCUDepth() - 1; i < sps->getMaxCUDepth(); i++)
717  {
718    sps->setAMPAcc( i, 0 );
719  }
720
721#if !LCU_SYNTAX_ALF
722  // create ALF temporary buffer
723  m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
724#endif
725  m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
726  m_cLoopFilter.        create( g_uiMaxCUDepth );
727}
728
729#if SKIPFRAME_BUGFIX
730Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
731#else
732Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int iSkipFrame, Int iPOCLastDisplay )
733#endif
734{
735  TComPic*&   pcPic         = m_pcPic;
736  m_apcSlicePilot->initSlice();
737
738  //!!!KS: DIRTY HACK
739  m_apcSlicePilot->setPPSId(0);
740  m_apcSlicePilot->setPPS(m_parameterSetManagerDecoder.getPrefetchedPPS(0));
741  m_apcSlicePilot->setSPS(m_parameterSetManagerDecoder.getPrefetchedSPS(0));
742#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
743#if QC_MVHEVC_B0046
744  m_apcSlicePilot->setIsDepth(false);
745#endif
746  m_apcSlicePilot->setVPS(m_parameterSetManagerDecoder.getPrefetchedVPS(0));
747#endif
748  m_apcSlicePilot->initTiles();
749#if QC_MVHEVC_B0046
750  m_apcSlicePilot->setViewId( nalu.m_layerId );
751  m_apcSlicePilot->setViewId( nalu.m_layerId );
752  m_apcSlicePilot->setViewOrderIdx(m_apcSlicePilot->getVPS()->getViewId(nalu.m_layerId), nalu.m_layerId);
753  Int iNumDirectRef = m_apcSlicePilot->getVPS()->getNumDirectRefLayer(nalu.m_layerId);
754  m_apcSlicePilot->getSPS()->setNumberOfUsableInterViewRefs(iNumDirectRef);
755  for(Int iNumIvRef = 0; iNumIvRef < iNumDirectRef; iNumIvRef ++)
756  {
757    Int iDeltaLayerId = m_apcSlicePilot->getVPS()->getDirectRefLayerId( nalu.m_layerId, iNumIvRef);
758    m_apcSlicePilot->getSPS()->setUsableInterViewRef(iNumIvRef, (iDeltaLayerId-nalu.m_layerId));
759  }
760#endif
761  if (m_bFirstSliceInPicture)
762  {
763    m_uiSliceIdx     = 0;
764    m_uiLastSliceIdx = 0;
765  }
766  m_apcSlicePilot->setSliceIdx(m_uiSliceIdx);
767  if (!m_bFirstSliceInPicture)
768  {
769    m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );
770  }
771
772  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
773  if( m_bFirstSliceInPicture )
774  {
775#if QC_MVHEVC_B0046
776    if( nalu.m_layerId == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; }
777    else                     { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, 0 )->getNalUnitTypeBaseView(); }
778#else
779#if VIDYO_VPS_INTEGRATION
780    if( m_apcSlicePilot->getVPS()->getViewId(nalu.m_layerId) == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; }
781    else { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, m_apcSlicePilot->getVPS()->getDepthFlag(nalu.m_layerId) )->getNalUnitTypeBaseView(); }
782#else
783    if( nalu.m_viewId == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; }
784    else                     { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, nalu.m_isDepth )->getNalUnitTypeBaseView(); }
785#endif
786#endif
787    m_apcSlicePilot->setNalUnitTypeBaseViewMvc( m_nalUnitTypeBaseView );
788  }
789
790#if SONY_COLPIC_AVAILABILITY
791  m_apcSlicePilot->setViewOrderIdx( m_apcSlicePilot->getSPS()->getViewOrderIdx());
792#endif
793
794#if NAL_REF_FLAG
795  m_apcSlicePilot->setReferenced(nalu.m_nalRefFlag);
796#else
797  m_apcSlicePilot->setReferenced(nalu.m_nalRefIDC != NAL_REF_IDC_PRIORITY_LOWEST);
798#endif
799  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
800
801  // ALF CU parameters should be part of the slice header -> needs to be fixed
802#if LCU_SYNTAX_ALF
803  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam(), m_cGopDecoder.getAlfParamSet());
804#else
805  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam() );
806#endif
807  // byte align
808  {
809    Int numBitsForByteAlignment = nalu.m_Bitstream->getNumBitsUntilByteAligned();
810    if ( numBitsForByteAlignment > 0 )
811    {
812      UInt bitsForByteAlignment;
813      nalu.m_Bitstream->read( numBitsForByteAlignment, bitsForByteAlignment );
814      assert( bitsForByteAlignment == ( ( 1 << numBitsForByteAlignment ) - 1 ) );
815    }
816  }
817
818  // exit when a new picture is found
819  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence)
820  {
821#if START_DECODING_AT_CRA
822    if (m_prevPOC >= m_pocRandomAccess)
823    {
824      m_prevPOC = m_apcSlicePilot->getPOC();
825      return true;
826    }
827    m_prevPOC = m_apcSlicePilot->getPOC();
828#else
829    m_prevPOC = m_apcSlicePilot->getPOC();
830    return true;
831#endif
832  }
833  // actual decoding starts here
834  xActivateParameterSets();
835  m_apcSlicePilot->initTiles();
836
837  if (m_apcSlicePilot->isNextSlice()) 
838  {
839    m_prevPOC = m_apcSlicePilot->getPOC();
840  }
841  m_bFirstSliceInSequence = false;
842  if (m_apcSlicePilot->isNextSlice())
843  {
844    // Skip pictures due to random access
845    if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
846    {
847      return false;
848    }
849  }
850  //detect lost reference picture and insert copy of earlier frame.
851#if START_DECODING_AT_CRA
852  while(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess) > 0)
853#else
854  while(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true) > 0)
855#endif
856  {
857    xCreateLostPicture(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), false)-1);
858  }
859  if (m_bFirstSliceInPicture)
860  {
861    // Buffer initialize for prediction.
862    m_cPrediction.initTempBuff();
863    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
864    //  Get a new picture buffer
865    xGetNewPicBuffer (m_apcSlicePilot, pcPic);
866
867#if SONY_COLPIC_AVAILABILITY
868    pcPic->setViewOrderIdx( m_apcSlicePilot->getSPS()->getViewOrderIdx() );
869#endif
870
871    /* transfer any SEI messages that have been received to the picture */
872    pcPic->setSEIs(m_SEIs);
873    m_SEIs = NULL;
874
875    // Recursive structure
876    m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
877    m_cCuDecoder.init   ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction );
878    m_cTrQuant.init     ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize());
879
880    m_cSliceDecoder.create( m_apcSlicePilot, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
881#if DEPTH_MAP_GENERATION
882    UInt uiPdm = ( m_apcSlicePilot->getSPS()->getViewId() ? m_apcSlicePilot->getSPS()->getPredDepthMapGeneration() : m_tAppDecTop->getSPSAccess()->getPdm() );
883    m_cDepthMapGenerator.create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
884    TComDepthMapGenerator* pcDMG0 = m_tAppDecTop->getDecTop0()->getDepthMapGenerator();
885    if( m_apcSlicePilot->getSPS()->getViewId() == 1 && ( pcDMG0->getSubSampExpX() != PDM_SUB_SAMP_EXP_X(uiPdm) || pcDMG0->getSubSampExpY() != PDM_SUB_SAMP_EXP_Y(uiPdm) ) )
886    {
887      pcDMG0->create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
888    }
889#endif
890#if HHI_INTER_VIEW_RESIDUAL_PRED
891    m_cResidualGenerator.create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement );
892#endif
893  }
894
895  //  Set picture slice pointer
896  TComSlice*  pcSlice = m_apcSlicePilot;
897  Bool bNextSlice     = pcSlice->isNextSlice();
898
899  UInt uiCummulativeTileWidth;
900  UInt uiCummulativeTileHeight;
901  UInt i, j, p;
902
903#if !REMOVE_TILE_DEPENDENCE
904  //set the TileBoundaryIndependenceIdr
905  if(pcSlice->getPPS()->getTileBehaviorControlPresentFlag() == 1)
906  {
907    pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getTileBoundaryIndependenceIdr() );
908  }
909  else
910  {
911    pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getSPS()->getTileBoundaryIndependenceIdr() );
912  }
913#endif
914
915  if( pcSlice->getPPS()->getColumnRowInfoPresent() == 1 )
916  {
917    //set NumColumnsMins1 and NumRowsMinus1
918    pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() );
919    pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() );
920
921    //create the TComTileArray
922    pcPic->getPicSym()->xCreateTComTileArray();
923
924    if( pcSlice->getPPS()->getUniformSpacingIdr() == 1)
925    {
926      //set the width for each tile
927      for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++)
928      {
929        for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++)
930        {
931          pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->
932            setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) 
933            - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) );
934        }
935      }
936
937      //set the height for each tile
938      for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++)
939      {
940        for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++)
941        {
942          pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->
943            setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) 
944            - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) );   
945        }
946      }
947    }
948    else
949    {
950      //set the width for each tile
951      for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++)
952      {
953        uiCummulativeTileWidth = 0;
954        for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++)
955        {
956          pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) );
957          uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i);
958        }
959        pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth );
960      }
961
962      //set the height for each tile
963      for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++)
964      {
965        uiCummulativeTileHeight = 0;
966        for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++)
967        { 
968          pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) );
969          uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i);
970        }
971        pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight );
972      }
973    }
974  }
975  else
976  {
977    //set NumColumnsMins1 and NumRowsMinus1
978    pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getSPS()->getNumColumnsMinus1() );
979    pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getSPS()->getNumRowsMinus1() );
980
981    //create the TComTileArray
982    pcPic->getPicSym()->xCreateTComTileArray();
983
984    //automatically set the column and row boundary if UniformSpacingIdr = 1
985    if( pcSlice->getSPS()->getUniformSpacingIdr() == 1 )
986    {
987      //set the width for each tile
988      for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++)
989      {
990        for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++)
991        {
992          pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->
993            setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) 
994            - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) );
995        }
996      }
997
998      //set the height for each tile
999      for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++)
1000      {
1001        for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++)
1002        {
1003          pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->
1004            setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) 
1005            - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) );   
1006        }
1007      }
1008    }
1009    else
1010    {
1011      //set the width for each tile
1012      for(j=0; j < pcSlice->getSPS()->getNumRowsMinus1()+1; j++)
1013      {
1014        uiCummulativeTileWidth = 0;
1015        for(i=0; i < pcSlice->getSPS()->getNumColumnsMinus1(); i++)
1016        {
1017          pcPic->getPicSym()->getTComTile(j * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getSPS()->getColumnWidth(i) );
1018          uiCummulativeTileWidth += pcSlice->getSPS()->getColumnWidth(i);
1019        }
1020        pcPic->getPicSym()->getTComTile(j * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth );
1021      }
1022
1023      //set the height for each tile
1024      for(j=0; j < pcSlice->getSPS()->getNumColumnsMinus1()+1; j++)
1025      {
1026        uiCummulativeTileHeight = 0;
1027        for(i=0; i < pcSlice->getSPS()->getNumRowsMinus1(); i++)
1028        { 
1029          pcPic->getPicSym()->getTComTile(i * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getSPS()->getRowHeight(i) );
1030          uiCummulativeTileHeight += pcSlice->getSPS()->getRowHeight(i);
1031        }
1032        pcPic->getPicSym()->getTComTile(i * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight );
1033      }
1034    }
1035  }
1036
1037  pcPic->getPicSym()->xInitTiles();
1038
1039  //generate the Coding Order Map and Inverse Coding Order Map
1040  UInt uiEncCUAddr;
1041  for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr))
1042  {
1043    pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr);
1044    pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i);
1045  }
1046  pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame());
1047  pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame());
1048
1049  //convert the start and end CU addresses of the slice and entropy slice into encoding order
1050  pcSlice->setEntropySliceCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getEntropySliceCurStartCUAddr()) );
1051  pcSlice->setEntropySliceCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getEntropySliceCurEndCUAddr()) );
1052  if(pcSlice->isNextSlice())
1053  {
1054    pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr()));
1055    pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr()));
1056  }
1057
1058  if (m_bFirstSliceInPicture) 
1059  {
1060    if(pcPic->getNumAllocatedSlice() != 1)
1061    {
1062      pcPic->clearSliceBuffer();
1063    }
1064  }
1065  else
1066  {
1067    pcPic->allocateNewSlice();
1068  }
1069  assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
1070  m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); 
1071  pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);
1072
1073  pcPic->setTLayer(nalu.m_temporalId);
1074
1075  if (bNextSlice)
1076  {
1077    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_cListPic); 
1078
1079    if ( !pcSlice->getPPS()->getEnableTMVPFlag() && pcPic->getTLayer() == 0 )
1080    {
1081      pcSlice->decodingMarkingForNoTMVP( m_cListPic, pcSlice->getPOC() );
1082    }
1083
1084    // Set reference list
1085#if !QC_MVHEVC_B0046
1086#if VIDYO_VPS_INTEGRATION
1087    pcSlice->setViewId( pcSlice->getVPS()->getViewId(nalu.m_layerId) );
1088    pcSlice->setIsDepth( pcSlice->getVPS()->getDepthFlag(nalu.m_layerId) );
1089#else
1090    pcSlice->setViewId(m_viewId);
1091    pcSlice->setIsDepth(m_isDepth);
1092#endif
1093#endif
1094
1095#if SONY_COLPIC_AVAILABILITY
1096#if VIDYO_VPS_INTEGRATION
1097    pcSlice->setViewOrderIdx( pcSlice->getVPS()->getViewOrderIdx(nalu.m_layerId) );
1098#else
1099    pcSlice->setViewOrderIdx( pcPic->getViewOrderIdx() );
1100#endif
1101#endif
1102
1103    assert( m_tAppDecTop != NULL );
1104    TComPic * const pcTexturePic = m_isDepth ? m_tAppDecTop->getPicFromView(  m_viewId, pcSlice->getPOC(), false ) : NULL;
1105
1106#if FLEX_CODING_ORDER_M23723
1107    if (pcTexturePic != NULL)
1108    {
1109      assert( !m_isDepth || pcTexturePic != NULL );
1110      pcSlice->setTexturePic( pcTexturePic );
1111    }
1112#else
1113    assert( !m_isDepth || pcTexturePic != NULL );
1114    pcSlice->setTexturePic( pcTexturePic );
1115#endif
1116
1117
1118    std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() );
1119    pcSlice->setRefPicListMvc( m_cListPic, apcInterViewRefPics );
1120
1121    // For generalized B
1122    // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
1123    if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0)
1124    {
1125      Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0);
1126      pcSlice->setNumRefIdx        ( REF_PIC_LIST_1, iNumRefIdx );
1127
1128      for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++)
1129      {
1130        pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx);
1131      }
1132    }
1133    if (pcSlice->isInterB())
1134    {
1135      Bool bLowDelay = true;
1136      Int  iCurrPOC  = pcSlice->getPOC();
1137      Int iRefIdx = 0;
1138
1139      for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++)
1140      {
1141        if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC )
1142        {
1143          bLowDelay = false;
1144        }
1145      }
1146      for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
1147      {
1148        if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
1149        {
1150          bLowDelay = false;
1151        }
1152      }
1153
1154      pcSlice->setCheckLDC(bLowDelay);           
1155    }
1156
1157    //---------------
1158    pcSlice->setRefPOCnViewListsMvc();
1159
1160    if(!pcSlice->getRefPicListModificationFlagLC())
1161    {
1162      pcSlice->generateCombinedList();
1163    }
1164
1165    if( pcSlice->getRefPicListCombinationFlag() && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getSliceType()==B_SLICE )
1166    {
1167      pcSlice->setWpParamforLC();
1168    }
1169    pcSlice->setNoBackPredFlag( false );
1170    if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag())
1171    {
1172      if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) )
1173      {
1174        pcSlice->setNoBackPredFlag( true );
1175        for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ )
1176        {
1177          if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) ) 
1178          {
1179            pcSlice->setNoBackPredFlag( false );
1180            break;
1181          }
1182        }
1183      }
1184    }
1185  }
1186
1187  pcPic->setCurrSliceIdx(m_uiSliceIdx);
1188  if(pcSlice->getSPS()->getScalingListFlag())
1189  {
1190    if(pcSlice->getAPS()->getScalingListEnabled())
1191    {
1192      pcSlice->setScalingList ( pcSlice->getAPS()->getScalingList()  );
1193      if(pcSlice->getScalingList()->getScalingListPresentFlag())
1194      {
1195        pcSlice->setDefaultScalingList();
1196      }
1197      m_cTrQuant.setScalingListDec(pcSlice->getScalingList());
1198    }
1199    m_cTrQuant.setUseScalingList(true);
1200  }
1201  else
1202  {
1203    m_cTrQuant.setFlatScalingList();
1204    m_cTrQuant.setUseScalingList(false);
1205  }
1206
1207#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
1208  if( m_parameterSetManagerDecoder.getPrefetchedSPS(0)->getUseDMM() && g_aacWedgeLists.empty() )
1209  {
1210    initWedgeLists();
1211  }
1212#endif
1213
1214#if MERL_VSP_C0152 // set BW LUT
1215  if( m_pcCamParsCollector ) // Initialize the LUT elements
1216  {
1217    m_pcCamParsCollector->setSlice( pcSlice );
1218  }
1219  if( pcSlice->getViewId() !=0 )
1220  {
1221    TComPic* pcBaseTxtPic = m_tAppDecTop->getPicFromView(  0, pcSlice->getPOC(), false );  // get base view reconstructed texture
1222    TComPic* pcBaseDepthPic = m_tAppDecTop->getPicFromView(  0, pcSlice->getPOC(), true ); // get base view reconstructed depth
1223     pcSlice->setRefPicBaseTxt(pcBaseTxtPic);
1224     pcSlice->setRefPicBaseDepth(pcBaseDepthPic);
1225  }
1226  getTAppDecTop()->setBWVSPLUT( pcSlice, pcSlice->getViewId(),  pcSlice->getPOC() ); // get the LUT for backward warping
1227#endif
1228
1229  //  Decode a picture
1230  m_cGopDecoder.decompressGop(nalu.m_Bitstream, pcPic, false);
1231
1232#if QC_IV_AS_LT_B0046
1233  std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() );
1234  for( Int k = 0; k < apcInterViewRefPics.size(); k++ )
1235  {
1236    TComPic*  pcPicIv = apcInterViewRefPics[k];
1237    pcPicIv->setIsLongTerm( 0 );
1238  }
1239#endif
1240  if( m_pcCamParsCollector )
1241  {
1242    m_pcCamParsCollector->setSlice( pcSlice );
1243  }
1244
1245  m_bFirstSliceInPicture = false;
1246  m_uiSliceIdx++;
1247
1248  return false;
1249}
1250
1251#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
1252Void TDecTop::xDecodeVPS()
1253{
1254  TComVPS* vps = new TComVPS();
1255 
1256  m_cEntropyDecoder.decodeVPS( vps );
1257  m_parameterSetManagerDecoder.storePrefetchedVPS(vps); 
1258#if !QC_MVHEVC_B0046
1259  getTAppDecTop()->getVPSAccess()->addVPS( vps );
1260#endif
1261}
1262#endif
1263
1264Void TDecTop::xDecodeSPS()
1265{
1266  TComSPS* sps = new TComSPS();
1267#if RPS_IN_SPS
1268  TComRPSList* rps = new TComRPSList();
1269  sps->setRPSList(rps);
1270#endif
1271#if HHI_MPI
1272  m_cEntropyDecoder.decodeSPS( sps, m_isDepth );
1273#else
1274  m_cEntropyDecoder.decodeSPS( sps );
1275#endif
1276  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
1277#if LCU_SYNTAX_ALF
1278  m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
1279#endif
1280}
1281
1282Void TDecTop::xDecodePPS()
1283{
1284#if !RPS_IN_SPS
1285  TComRPSList* rps = new TComRPSList();
1286#endif
1287  TComPPS* pps = new TComPPS();
1288#if !RPS_IN_SPS
1289  pps->setRPSList(rps);
1290#endif
1291#if TILES_OR_ENTROPY_SYNC_IDC
1292  m_cEntropyDecoder.decodePPS( pps, &m_parameterSetManagerDecoder );
1293#else
1294  m_cEntropyDecoder.decodePPS( pps );
1295#endif
1296  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
1297
1298  //!!!KS: Activate parameter sets for parsing APS (unless dependency is resolved)
1299  m_apcSlicePilot->setPPSId(pps->getPPSId());
1300  xActivateParameterSets();
1301  m_apcSlicePilot->initTiles();
1302}
1303
1304Void TDecTop::xDecodeAPS()
1305{
1306  TComAPS  *aps = new TComAPS();
1307  allocAPS (aps);
1308  decodeAPS(aps);
1309  m_parameterSetManagerDecoder.storePrefetchedAPS(aps);
1310}
1311
1312Void TDecTop::xDecodeSEI()
1313{
1314  m_SEIs = new SEImessages;
1315  m_cEntropyDecoder.decodeSEI(*m_SEIs);
1316}
1317
1318Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
1319{
1320  // Initialize entropy decoder
1321  m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder);
1322  m_cEntropyDecoder.setBitstream      (nalu.m_Bitstream);
1323
1324  switch (nalu.m_nalUnitType)
1325  {
1326#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
1327    case NAL_UNIT_VPS:
1328      xDecodeVPS();
1329      return false;
1330#endif
1331    case NAL_UNIT_SPS:
1332      xDecodeSPS();
1333      return false;
1334
1335    case NAL_UNIT_PPS:
1336      xDecodePPS();
1337      return false;
1338    case NAL_UNIT_APS:
1339      xDecodeAPS();
1340      return false;
1341
1342    case NAL_UNIT_SEI:
1343      xDecodeSEI();
1344      return false;
1345
1346    case NAL_UNIT_CODED_SLICE:
1347    case NAL_UNIT_CODED_SLICE_IDR:
1348#if H0566_TLA
1349#if !QC_REM_IDV_B0046
1350    case NAL_UNIT_CODED_SLICE_IDV:
1351#endif
1352    case NAL_UNIT_CODED_SLICE_CRA:
1353    case NAL_UNIT_CODED_SLICE_TLA:
1354#else
1355    case NAL_UNIT_CODED_SLICE_CDR:
1356#endif
1357      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
1358      break;
1359    default:
1360      assert (1);
1361  }
1362
1363  return false;
1364}
1365
1366#if QC_MVHEVC_B0046
1367Void TDecTop::xCopyVPS( TComVPS* pVPSV0 )
1368{
1369  m_parameterSetManagerDecoder.storePrefetchedVPS(pVPSV0); 
1370}
1371
1372Void TDecTop::xCopySPS( TComSPS* pSPSV0 )
1373{
1374  TComSPS* sps = new TComSPS();
1375  sps = pSPSV0;
1376  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
1377#if LCU_SYNTAX_ALF
1378  m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
1379#endif
1380}
1381
1382Void TDecTop::xCopyPPS(TComPPS* pPPSV0 )
1383{
1384  m_parameterSetManagerDecoder.storePrefetchedPPS( pPPSV0 );
1385
1386  //!!!KS: Activate parameter sets for parsing APS (unless dependency is resolved)
1387  m_apcSlicePilot->setPPSId(pPPSV0->getPPSId());
1388  xActivateParameterSets();
1389  m_apcSlicePilot->initTiles();
1390}
1391#endif
1392/** Function for checking if picture should be skipped because of random access
1393 * \param iSkipFrame skip frame counter
1394 * \param iPOCLastDisplay POC of last picture displayed
1395 * \returns true if the picture shold be skipped in the random access.
1396 * This function checks the skipping of pictures in the case of -s option random access.
1397 * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped.
1398 * It also checks the type of Nal unit type at the random access point.
1399 * If the random access point is CRA, pictures with POC equal to or greater than the CRA POC are decoded.
1400 * If the random access point is IDR all pictures after the random access point are decoded.
1401 * If the random access point is not IDR or CRA, a warning is issues, and decoding of pictures with POC
1402 * equal to or greater than the random access point POC is attempted. For non IDR/CRA random
1403 * access point there is no guarantee that the decoder will not crash.
1404 */
1405Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay)
1406{
1407  if (iSkipFrame) 
1408  {
1409    iSkipFrame--;   // decrement the counter
1410    return true;
1411  }
1412  else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet.
1413  {
1414#if H0566_TLA
1415    if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CRA )
1416#else
1417    if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CDR )
1418#endif
1419    {
1420      m_pocRandomAccess = m_apcSlicePilot->getPOC(); // set the POC random access since we need to skip the reordered pictures in CRA.
1421    }
1422    else if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_IDR )
1423    {
1424      m_pocRandomAccess = 0; // no need to skip the reordered pictures in IDR, they are decodable.
1425    }
1426    else 
1427    {
1428#if START_DECODING_AT_CRA
1429      static bool warningMessage = false;
1430      if(!warningMessage)
1431      {
1432        printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture");
1433        warningMessage = true;
1434      }
1435      return true;
1436#else
1437      printf("\nUnsafe random access point. Decoder may crash.");
1438      m_pocRandomAccess = 0;
1439#endif
1440    }
1441  }
1442  else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess)  // skip the reordered pictures if necessary
1443  {
1444    iPOCLastDisplay++;
1445    return true;
1446  }
1447  // if we reach here, then the picture is not skipped.
1448  return false; 
1449}
1450
1451Void TDecTop::allocAPS (TComAPS* pAPS)
1452{
1453  // we don't know the SPS before it has been activated. These fields could exist
1454  // depending on the corresponding flags in the APS, but SAO/ALF allocation functions will
1455  // have to be moved for that
1456  pAPS->createScalingList();
1457  pAPS->createSaoParam();
1458  m_cSAO.allocSaoParam(pAPS->getSaoParam());
1459  pAPS->createAlfParam();
1460#if !LCU_SYNTAX_ALF
1461  m_cAdaptiveLoopFilter.allocALFParam(pAPS->getAlfParam());
1462#endif
1463}
1464
1465//! \}
Note: See TracBrowser for help on using the repository browser.