source: 3DVCSoftware/branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibDecoder/TDecTop.cpp @ 1417

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

A final release, as planned

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