source: 3DVCSoftware/branches/0.3-poznan-univ/source/Lib/TLibDecoder/TDecTop.cpp @ 41

Last change on this file since 41 was 41, checked in by poznan-univ, 13 years ago

Adjustment for FlexCO, and high-level syntax improvement.

  • Property svn:eol-style set to native
File size: 36.7 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-2011, 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 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 "../../App/TAppDecoder/TAppDecTop.h"
39#include "TDecTop.h"
40
41
42
43CamParsCollector::CamParsCollector()
44: m_bInitialized( false )
45{
46  m_aaiCodedOffset         = new Int* [ MAX_NUMBER_VIEWS ];
47  m_aaiCodedScale          = new Int* [ MAX_NUMBER_VIEWS ];
48  m_aiViewOrderIndex       = new Int  [ MAX_NUMBER_VIEWS ];
49  m_aiViewReceived         = new Int  [ MAX_NUMBER_VIEWS ];
50  for( UInt uiId = 0; uiId < MAX_NUMBER_VIEWS; uiId++ )
51  {
52    m_aaiCodedOffset      [ uiId ] = new Int [ MAX_NUMBER_VIEWS ];
53    m_aaiCodedScale       [ uiId ] = new Int [ MAX_NUMBER_VIEWS ];
54  }
55#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
56  xCreateLUTs   ( (UInt)MAX_NUMBER_VIEWS, (UInt)MAX_NUMBER_VIEWS,  m_adBaseViewShiftLUT,  m_aiBaseViewShiftLUT);
57
58  m_iLog2Precision   = LOG2_DISP_PREC_LUT;
59  m_uiBitDepthForLUT = 8; //fixed
60#endif
61}
62
63CamParsCollector::~CamParsCollector()
64{
65  for( UInt uiId = 0; uiId < MAX_NUMBER_VIEWS; uiId++ )
66  {
67    delete [] m_aaiCodedOffset      [ uiId ];
68    delete [] m_aaiCodedScale       [ uiId ];
69  }
70  delete [] m_aaiCodedOffset;
71  delete [] m_aaiCodedScale;
72  delete [] m_aiViewOrderIndex;
73  delete [] m_aiViewReceived;
74
75#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
76  xDeleteArray( m_adBaseViewShiftLUT,        MAX_NUMBER_VIEWS, MAX_NUMBER_VIEWS,  2 );
77  xDeleteArray( m_aiBaseViewShiftLUT,        MAX_NUMBER_VIEWS, MAX_NUMBER_VIEWS,  2 );
78#endif
79}
80
81Void
82CamParsCollector::init( FILE* pCodedScaleOffsetFile )
83{
84  m_bInitialized            = true;
85  m_pCodedScaleOffsetFile   = pCodedScaleOffsetFile;
86  m_uiCamParsCodedPrecision = 0;
87  m_bCamParsVaryOverTime    = false;
88  m_iLastViewId             = -1;
89  m_iLastPOC                = -1;
90  m_uiMaxViewId             = 0;
91#if POZNAN_NONLINEAR_DEPTH
92  m_cNonlinearDepthModel.Clear();
93  m_bUseNonlinearDepth      = false;
94#endif
95}
96
97#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
98Void
99CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT)
100{
101  //AOF( m_uiBitDepthForLUT == 8 );
102  //AOF(radLUT == NULL && raiLUT == NULL );
103
104  uiNumberSourceViews = Max( 1, uiNumberSourceViews );
105  uiNumberTargetViews = Max( 1, uiNumberTargetViews );
106
107  radLUT         = new Double***[ uiNumberSourceViews ];
108  raiLUT         = new Int   ***[ uiNumberSourceViews ];
109
110  for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ )
111  {
112    radLUT        [ uiSourceView ] = new Double**[ uiNumberTargetViews ];
113    raiLUT        [ uiSourceView ] = new Int   **[ uiNumberTargetViews ];
114
115    for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ )
116    {
117      radLUT        [ uiSourceView ][ uiTargetView ]      = new Double*[ 2 ];
118      radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ];
119      radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ];
120
121      raiLUT        [ uiSourceView ][ uiTargetView ]      = new Int*   [ 2 ];
122      raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ 257 ];
123      raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ 257 ];
124    }
125  }
126}
127
128Void
129CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT)
130{
131  Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_uiCamParsCodedPrecision + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
132  Int     iLog2DivChroma = iLog2DivLuma + 1;
133
134  iOffset <<= m_uiBitDepthForLUT;
135
136  Double dScale  = (Double) iScale  / (( Double ) ( 1 << iLog2DivLuma ));
137  Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma ));
138
139  // offsets including rounding offsets
140  Int64 iOffsetLuma   = iOffset + ( ( 1 << iLog2DivLuma   ) >> 1 );
141  Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 );
142
143
144  for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ )
145  {
146
147    // real-valued look-up tables
148#if POZNAN_NONLINEAR_DEPTH
149    Double  dShiftLuma;
150    if( m_bUseNonlinearDepth )
151      dShiftLuma      = ( m_cNonlinearDepthModel.BackwardD( (Double)uiDepthValue, dScale) + dOffset ) * Double( 1 << m_iLog2Precision );
152    else
153      dShiftLuma      = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
154#else
155    Double  dShiftLuma      = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
156#endif
157    Double  dShiftChroma    = dShiftLuma / 2;
158    radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma;
159    radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma;
160
161    // integer-valued look-up tables
162#if POZNAN_NONLINEAR_DEPTH
163    Int64   iTempScale;
164    if( m_bUseNonlinearDepth )
165      iTempScale      = (Int64)m_cNonlinearDepthModel.BackwardI(uiDepthValue, iScale);
166    else
167      iTempScale      = (Int64)uiDepthValue * iScale;
168#else
169    Int64   iTempScale      = (Int64)uiDepthValue * iScale;
170#endif
171    Int64   iTestScale      = ( iTempScale + iOffset       );   // for checking accuracy of camera parameters
172    Int64   iShiftLuma      = ( iTempScale + iOffsetLuma   ) >> iLog2DivLuma;
173    Int64   iShiftChroma    = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma;
174    raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma;
175    raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma;
176
177    // maximum deviation
178    //dMaxDispDev     = Max( dMaxDispDev,    fabs( Double( (Int) iTestScale   ) - dShiftLuma * Double( 1 << iLog2DivLuma ) ) / Double( 1 << iLog2DivLuma ) );
179    //dMaxRndDispDvL  = Max( dMaxRndDispDvL, fabs( Double( (Int) iShiftLuma   ) - dShiftLuma   ) );
180    //dMaxRndDispDvC  = Max( dMaxRndDispDvC, fabs( Double( (Int) iShiftChroma ) - dShiftChroma ) );
181  }
182
183  radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
184  radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
185  raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
186  raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
187}
188
189Bool
190CamParsCollector::getNearestBaseView( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft)
191{
192  /*
193  riNearestViewIdx = 0;
194
195  Bool bDecencdingVN = ( m_aiSortedBaseViews.size() >= 2 && m_aiSortedBaseViews[ 0 ] > m_aiSortedBaseViews[ 1 ] );
196  Int  iFactor       = ( bDecencdingVN ? -1 : 1 );
197
198  if( ( m_aiBaseId2SortedId[iSynthViewIdx] - m_aiBaseId2SortedId[riNearestViewIdx] ) * iFactor  <= 0 )
199  {
200    rbRenderFromLeft = true;
201  }
202  else
203  {
204    rbRenderFromLeft = false;
205  }
206
207  riRelDistToLeft = 128; //Not used for now;
208//*/
209  return true;
210}
211
212#endif
213
214Void
215CamParsCollector::uninit()
216{
217  m_bInitialized = false;
218}
219
220Void
221CamParsCollector::setSlice( TComSlice* pcSlice )
222{
223  if( pcSlice == 0 )
224  {
225    AOF( xIsComplete() );
226    if( m_bCamParsVaryOverTime || m_iLastPOC == 0 )
227    {
228      xOutput( m_iLastPOC );
229    }
230    return;
231  }
232
233  AOF( pcSlice->getSPS()->getViewId() < MAX_NUMBER_VIEWS );
234  if ( pcSlice->getSPS()->isDepth  () )
235  {
236#if POZNAN_NONLINEAR_DEPTH
237    m_bUseNonlinearDepth = pcSlice->getSPS()->getUseNonlinearDepth();
238    m_cNonlinearDepthModel = pcSlice->getSPS()->getNonlinearDepthModel();   
239#endif
240    return;
241  }
242  else
243  {
244#if POZNAN_NONLINEAR_DEPTH
245    pcSlice->getSPS()->setUseNonlinearDepth(m_bUseNonlinearDepth);
246    pcSlice->getSPS()->setNonlinearDepthModel(m_cNonlinearDepthModel); // OLGIERD: ToDo - QP-Tex should not use getDepthPower() from texture SPS.
247#endif
248  }
249  Bool  bFirstAU          = ( pcSlice->getPOC()               == 0 );
250  Bool  bFirstSliceInAU   = ( pcSlice->getPOC()               != Int ( m_iLastPOC ) );
251  Bool  bFirstSliceInView = ( pcSlice->getSPS()->getViewId()  != UInt( m_iLastViewId ) || bFirstSliceInAU );
252  AOT(  bFirstSliceInAU  &&   pcSlice->getSPS()->getViewId()  != 0 );
253  AOT( !bFirstSliceInAU  &&   pcSlice->getSPS()->getViewId()   < UInt( m_iLastViewId ) );
254  AOT( !bFirstSliceInAU  &&   pcSlice->getSPS()->getViewId()   > UInt( m_iLastViewId + 1 ) );
255  AOT( !bFirstAU         &&   pcSlice->getSPS()->getViewId()   > m_uiMaxViewId );
256  if ( !bFirstSliceInView )
257  {
258    if( m_bCamParsVaryOverTime ) // check consistency of slice parameters here
259    {
260      UInt uiViewId = pcSlice->getSPS()->getViewId();
261      for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ )
262      {
263        AOF( m_aaiCodedScale [ uiBaseId ][ uiViewId ] == pcSlice->getCodedScale    () [ uiBaseId ] );
264        AOF( m_aaiCodedOffset[ uiBaseId ][ uiViewId ] == pcSlice->getCodedOffset   () [ uiBaseId ] );
265        AOF( m_aaiCodedScale [ uiViewId ][ uiBaseId ] == pcSlice->getInvCodedScale () [ uiBaseId ] );
266        AOF( m_aaiCodedOffset[ uiViewId ][ uiBaseId ] == pcSlice->getInvCodedOffset() [ uiBaseId ] );
267      }
268    }
269    return;
270  }
271
272  if( bFirstSliceInAU )
273  {
274    if( !bFirstAU )
275    {
276      AOF( xIsComplete() );
277      xOutput( m_iLastPOC );
278    }
279    ::memset( m_aiViewReceived, 0x00, MAX_NUMBER_VIEWS * sizeof( Int ) );
280  }
281
282  UInt uiViewId                 = pcSlice->getSPS()->getViewId();
283  m_aiViewReceived[ uiViewId ]  = 1;
284  if( bFirstAU )
285  {
286    m_uiMaxViewId                     = Max( m_uiMaxViewId, uiViewId );
287    m_aiViewOrderIndex[ uiViewId ]    = pcSlice->getSPS()->getViewOrderIdx();
288    if( uiViewId == 1 )
289    {
290      m_uiCamParsCodedPrecision       = pcSlice->getSPS()->getCamParPrecision     ();
291      m_bCamParsVaryOverTime          = pcSlice->getSPS()->hasCamParInSliceHeader ();
292    }
293    else if( uiViewId > 1 )
294    {
295      AOF( m_uiCamParsCodedPrecision == pcSlice->getSPS()->getCamParPrecision     () );
296      AOF( m_bCamParsVaryOverTime    == pcSlice->getSPS()->hasCamParInSliceHeader () );
297    }
298    for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ )
299    {
300      if( m_bCamParsVaryOverTime )
301      {
302        m_aaiCodedScale [ uiBaseId ][ uiViewId ]  = pcSlice->getCodedScale    () [ uiBaseId ];
303        m_aaiCodedOffset[ uiBaseId ][ uiViewId ]  = pcSlice->getCodedOffset   () [ uiBaseId ];
304        m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedScale () [ uiBaseId ];
305        m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedOffset() [ uiBaseId ];
306#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
307        xInitLUTs(uiBaseId,uiViewId,m_aaiCodedScale [ uiBaseId ][ uiViewId ],m_aaiCodedOffset[ uiBaseId ][ uiViewId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
308        xInitLUTs(uiViewId,uiBaseId,m_aaiCodedScale [ uiViewId ][ uiBaseId ],m_aaiCodedOffset[ uiViewId ][ uiBaseId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
309#endif
310      }
311      else
312      {
313        m_aaiCodedScale [ uiBaseId ][ uiViewId ]  = pcSlice->getSPS()->getCodedScale    () [ uiBaseId ];
314        m_aaiCodedOffset[ uiBaseId ][ uiViewId ]  = pcSlice->getSPS()->getCodedOffset   () [ uiBaseId ];
315        m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getSPS()->getInvCodedScale () [ uiBaseId ];
316        m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getSPS()->getInvCodedOffset() [ uiBaseId ];
317#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
318        xInitLUTs(uiBaseId,uiViewId,m_aaiCodedScale [ uiBaseId ][ uiViewId ],m_aaiCodedOffset[ uiBaseId ][ uiViewId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
319        xInitLUTs(uiViewId,uiBaseId,m_aaiCodedScale [ uiViewId ][ uiBaseId ],m_aaiCodedOffset[ uiViewId ][ uiBaseId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
320#endif
321      }
322    }
323  }
324  else
325  {
326    AOF( m_aiViewOrderIndex[ uiViewId ] == pcSlice->getSPS()->getViewOrderIdx() );
327    if( m_bCamParsVaryOverTime )
328    {
329      for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ )
330      {
331        m_aaiCodedScale [ uiBaseId ][ uiViewId ]  = pcSlice->getCodedScale    () [ uiBaseId ];
332        m_aaiCodedOffset[ uiBaseId ][ uiViewId ]  = pcSlice->getCodedOffset   () [ uiBaseId ];
333        m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedScale () [ uiBaseId ];
334        m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedOffset() [ uiBaseId ];
335#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
336        xInitLUTs(uiBaseId,uiViewId,m_aaiCodedScale [ uiBaseId ][ uiViewId ],m_aaiCodedOffset[ uiBaseId ][ uiViewId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
337        xInitLUTs(uiViewId,uiBaseId,m_aaiCodedScale [ uiViewId ][ uiBaseId ],m_aaiCodedOffset[ uiViewId ][ uiBaseId ],m_adBaseViewShiftLUT,m_aiBaseViewShiftLUT);
338#endif
339      }
340    }
341  }
342  m_iLastViewId = (Int)pcSlice->getSPS()->getViewId();
343  m_iLastPOC    = (Int)pcSlice->getPOC();
344}
345
346Bool
347CamParsCollector::xIsComplete()
348{
349  for( UInt uiView = 0; uiView <= m_uiMaxViewId; uiView++ )
350  {
351    if( m_aiViewReceived[ uiView ] == 0 )
352    {
353      return false;
354    }
355  }
356  return true;
357}
358
359Void
360CamParsCollector::xOutput( Int iPOC )
361{
362  if( m_pCodedScaleOffsetFile )
363  {
364    if( iPOC == 0 )
365    {
366      fprintf( m_pCodedScaleOffsetFile, "#     ViewId ViewOrderIdx\n" );
367      fprintf( m_pCodedScaleOffsetFile, "#----------- ------------\n" );
368      for( UInt uiViewId = 0; uiViewId <= m_uiMaxViewId; uiViewId++ )
369      {
370        fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewId, m_aiViewOrderIndex[ uiViewId ] );
371      }
372      fprintf( m_pCodedScaleOffsetFile, "\n\n");
373      fprintf( m_pCodedScaleOffsetFile, "# StartFrame     EndFrame   TargetView     BaseView   CodedScale  CodedOffset    Precision\n" );
374      fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" );
375    }
376    if( iPOC == 0 || m_bCamParsVaryOverTime )
377    {
378      Int iS = iPOC;
379      Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) );
380      for( UInt uiViewId = 0; uiViewId <= m_uiMaxViewId; uiViewId++ )
381      {
382        for( UInt uiBaseId = 0; uiBaseId <= m_uiMaxViewId; uiBaseId++ )
383        {
384          if( uiViewId != uiBaseId )
385          {
386            fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n",
387                     iS, iE, uiViewId, uiBaseId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_uiCamParsCodedPrecision );
388          }
389        }
390      }
391    }
392  }
393}
394
395
396
397
398TDecTop::TDecTop()
399: m_SEIs(0)
400{
401  m_iGopSize      = 0;
402  m_bGopSizeSet   = false;
403  m_iMaxRefPicNum = 0;
404  m_uiValidPS = 0;
405  m_bIsDepth = false ;
406  m_iViewIdx = 0 ;
407#if SONY_COLPIC_AVAILABILITY
408  m_iViewOrderIdx = 0;
409#endif
410#if ENC_DEC_TRACE
411  g_hTrace = fopen( "TraceDec.txt", "wb" );
412  g_bJustDoIt = g_bEncDecTraceDisable;
413  g_nSymbolCounter = 0;
414#endif
415#if DCM_DECODING_REFRESH
416  m_bRefreshPending = 0;
417  m_uiPOCCDR = 0;
418#if DCM_SKIP_DECODING_FRAMES
419  m_uiPOCRA = MAX_UINT;
420#endif
421#endif
422  m_uiPrevPOC               = UInt(-1);
423  m_bFirstSliceInPicture    = true;
424  m_bFirstSliceInSequence   = true;
425  m_pcCamParsCollector = 0;
426#if POZNAN_MP
427  m_pcMP = NULL;
428#endif
429}
430
431TDecTop::~TDecTop()
432{
433#if ENC_DEC_TRACE
434  fclose( g_hTrace );
435#endif
436}
437
438Void TDecTop::create()
439{
440  m_cGopDecoder.create();
441  m_apcSlicePilot = new TComSlice;
442  m_uiSliceIdx = m_uiLastSliceIdx = 0;
443}
444
445Void TDecTop::destroy()
446{
447  m_cGopDecoder.destroy();
448
449  delete m_apcSlicePilot;
450  m_apcSlicePilot = NULL;
451
452  m_cSliceDecoder.destroy();
453
454#if DEPTH_MAP_GENERATION
455  m_cDepthMapGenerator.destroy();
456#endif
457#if HHI_INTER_VIEW_RESIDUAL_PRED
458  m_cResidualGenerator.destroy();
459#endif
460
461#if POZNAN_MP
462  m_pcMP = NULL;
463#endif
464}
465
466Void TDecTop::init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance )
467{
468  // initialize ROM
469  if( bFirstInstance )
470    initROM();
471#if MTK_SAO
472  m_cGopDecoder.  init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cAdaptiveLoopFilter, &m_cSAO
473#if DEPTH_MAP_GENERATION
474                      , &m_cDepthMapGenerator
475#endif
476#if HHI_INTER_VIEW_RESIDUAL_PRED
477                      , &m_cResidualGenerator
478#endif
479                      );
480#else
481  m_cGopDecoder.  init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cAdaptiveLoopFilter
482#if DEPTH_MAP_GENERATION
483                      , &m_cDepthMapGenerator
484#endif
485#if HHI_INTER_VIEW_RESIDUAL_PRED
486                      , &m_cResidualGenerator
487#endif
488                      );
489#endif
490  m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder );
491  m_cEntropyDecoder.init(&m_cPrediction);
492
493  m_pcTAppDecTop = pcTAppDecTop;
494#if DEPTH_MAP_GENERATION
495  m_cDepthMapGenerator.init( &m_cPrediction, m_pcTAppDecTop->getSPSAccess(), m_pcTAppDecTop->getAUPicAccess() );
496#endif
497#if HHI_INTER_VIEW_RESIDUAL_PRED
498  m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator );
499#endif
500
501#if POZNAN_MP
502  m_pcMP = pcTAppDecTop->getMP();
503#endif
504}
505
506Void TDecTop::setSPS(TComSPS cSPS)
507{
508  m_cSPS = cSPS ;
509      if ( !m_cAdaptiveLoopFilter.isCreated())
510      {
511  m_cAdaptiveLoopFilter.create( m_cSPS.getWidth(), m_cSPS.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
512#if MTK_SAO
513  m_cSAO.create( m_cSPS.getWidth(), m_cSPS.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
514#endif
515  m_cLoopFilter.        create( g_uiMaxCUDepth );
516      }
517  m_uiValidPS |= 1;
518}
519
520Void TDecTop::deletePicBuffer ( )
521{
522  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
523  Int iSize = Int( m_cListPic.size() );
524
525  for (Int i = 0; i < iSize; i++ )
526  {
527    TComPic* pcPic = *(iterPic++);
528    pcPic->destroy();
529
530    delete pcPic;
531    pcPic = NULL;
532  }
533
534  // destroy ALF temporary buffers
535  m_cAdaptiveLoopFilter.destroy();
536
537#if MTK_SAO
538  m_cSAO.destroy();
539#endif
540
541  m_cLoopFilter.        destroy();
542
543  // destroy ROM
544  if( m_iViewIdx <= 0 && !m_bIsDepth)
545    destroyROM();
546}
547
548Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic )
549{
550  m_iMaxRefPicNum = getCodedPictureBufferSize( );
551
552#if DEPTH_MAP_GENERATION
553  UInt uiPdm                  = ( pcSlice->getSPS()->getViewId() ? pcSlice->getSPS()->getPredDepthMapGeneration() : m_pcTAppDecTop->getSPSAccess()->getPdm() );
554  Bool bNeedPrdDepthMapBuffer = ( !pcSlice->getSPS()->isDepth() && uiPdm > 0 );
555#endif
556
557  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
558  {
559    rpcPic = new TComPic;
560    rpcPic->create ( pcSlice->getSPS()->getWidth(), pcSlice->getSPS()->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
561#if DEPTH_MAP_GENERATION
562    if( bNeedPrdDepthMapBuffer )
563    {
564      rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
565    }
566#endif
567    m_cListPic.pushBack( rpcPic );
568
569    return;
570  }
571
572  Bool bBufferIsAvailable = false;
573  TComList<TComPic*>::iterator  iterPic   = m_cListPic.begin();
574  while (iterPic != m_cListPic.end())
575  {
576    rpcPic = *(iterPic++);
577    if ( rpcPic->getReconMark() == false )
578    {
579      bBufferIsAvailable = true;
580      break;
581    }
582  }
583
584  if ( !bBufferIsAvailable )
585  {
586    pcSlice->sortPicList(m_cListPic);
587    iterPic = m_cListPic.begin();
588    rpcPic = *(iterPic);
589    rpcPic->setReconMark(false);
590
591    // mark it should be extended
592  }
593  rpcPic->getPicYuvRec()->setBorderExtension(false);
594
595#if DEPTH_MAP_GENERATION
596  if( bNeedPrdDepthMapBuffer && !rpcPic->getPredDepthMap() )
597  {
598    rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
599  }
600#endif
601}
602
603
604Void
605TDecTop::deleteExtraPicBuffers( Int iPoc )
606{
607  TComPic*                      pcPic = 0;
608  TComList<TComPic*>::iterator  cIter = m_cListPic.begin();
609  TComList<TComPic*>::iterator  cEnd  = m_cListPic.end  ();
610  for( ; cIter != cEnd; cIter++ )
611  {
612    if( (*cIter)->getPOC() == iPoc )
613    {
614      pcPic = *cIter;
615      break;
616    }
617  }
618  AOF( pcPic );
619  if ( pcPic )
620  {
621    pcPic->removeOriginalBuffer   ();
622#if HHI_INTER_VIEW_MOTION_PRED
623    pcPic->removeOrgDepthMapBuffer();
624#endif
625#if HHI_INTER_VIEW_RESIDUAL_PRED
626    pcPic->removeResidualBuffer   ();
627#endif
628#if HHI_INTERVIEW_SKIP
629    pcPic->removeUsedPelsMapBuffer();
630#endif
631#if POZNAN_AVAIL_MAP
632    pcPic->removeAvailabilityBuffer();
633#endif
634#if POZNAN_SYNTH_VIEW
635    pcPic->removeSynthesisBuffer();
636#endif
637#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
638    pcPic->removeSynthesisDepthBuffer();
639#endif
640  }
641}
642
643#if AMVP_BUFFERCOMPRESS
644Void
645TDecTop::compressMotion( Int iPoc )
646{
647  TComPic*                      pcPic = 0;
648  TComList<TComPic*>::iterator  cIter = m_cListPic.begin();
649  TComList<TComPic*>::iterator  cEnd  = m_cListPic.end  ();
650  for( ; cIter != cEnd; cIter++ )
651  {
652    if( (*cIter)->getPOC() == iPoc )
653    {
654      pcPic = *cIter;
655      break;
656    }
657  }
658  AOF( pcPic );
659  if ( pcPic )
660  {
661    pcPic->compressMotion();
662  }
663}
664#endif
665
666
667Void TDecTop::executeDeblockAndAlf(Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame,  Int& iPOCLastDisplay)
668{
669  TComPic*&   pcPic         = m_pcPic;
670
671  // Execute Deblock and ALF only + Cleanup
672  TComSlice* pcSlice  = pcPic->getPicSym()->getSlice( m_uiSliceIdx                  );
673  m_cGopDecoder.decompressGop ( bEos, pcBitstream, pcPic, true);
674
675  if( m_pcCamParsCollector && bEos )
676  {
677    m_pcCamParsCollector->setSlice( 0 );
678  }
679
680  pcSlice->sortPicList        ( m_cListPic );       //  sorting for application output
681  ruiPOC              = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
682  rpcListPic          = &m_cListPic;
683  m_cCuDecoder.destroy();
684  m_bFirstSliceInPicture  = true;
685
686  return;
687}
688
689#if DCM_SKIP_DECODING_FRAMES
690#if FLEX_CODING_ORDER
691Bool TDecTop::decode (Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS, Int& iSkipFrame,  Int& iPOCLastDisplay, Bool& bNewPictureType)
692#else
693Bool TDecTop::decode (Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS, Int& iSkipFrame,  Int& iPOCLastDisplay)
694#endif
695#else
696Void TDecTop::decode (Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS )
697#endif
698{
699  if (m_bFirstSliceInPicture)
700  {
701    rpcListPic = NULL;
702  }
703  TComPic*&   pcPic         = m_pcPic;
704
705  // Initialize entropy decoder
706  m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder);
707  m_cEntropyDecoder.setBitstream      (pcBitstream);
708
709  NalUnitType eNalUnitType;
710  UInt        TemporalId;
711  Bool        OutputFlag;
712
713  m_cEntropyDecoder.decodeNalUnitHeader(eNalUnitType, TemporalId, OutputFlag);
714  reNalUnitType = eNalUnitType;
715
716  switch (eNalUnitType)
717  {
718    case NAL_UNIT_SPS:
719    {
720      TComSPS cTempSPS;
721      m_cEntropyDecoder.decodeSPS( &cTempSPS );
722#if FLEX_CODING_ORDER
723      m_cNewSPS = cTempSPS;
724#endif
725
726      if( (m_iViewIdx == cTempSPS.getViewId()) && ( m_bIsDepth == cTempSPS.isDepth() ) )
727      {
728        m_cSPS = cTempSPS;
729        cComSPS = m_cSPS;
730      }
731      else
732      {
733#if POZNAN_NONLINEAR_DEPTH
734        // For texture complete depth power information. Depth power is sended, for example, for base view depth map and it should be available prior non-base texture decoding
735        if(!cTempSPS.isDepth() && cTempSPS.getViewId())
736        {
737          cTempSPS.setUseNonlinearDepth(getDecTop()->getPicFromView( 0, pcPic->getPOC(), true )->getSPS()->getUseNonlinearDepth());
738          cTempSPS.setNonlinearDepthModel(getDecTop()->getPicFromView( 0, pcPic->getPOC(), true )->getSPS()->getNonlinearDepthModel());
739        }
740#endif
741        cComSPS = cTempSPS;
742        return false;
743      }
744
745      // create ALF temporary buffer
746      if ( !m_cAdaptiveLoopFilter.isCreated())
747      {
748      m_cAdaptiveLoopFilter.create( m_cSPS.getWidth(), m_cSPS.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
749#if MTK_SAO
750      m_cSAO.create( m_cSPS.getWidth(), m_cSPS.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
751#endif
752      m_cLoopFilter.        create( g_uiMaxCUDepth );
753      }
754      m_uiValidPS |= 1;
755
756#if POZNAN_MP
757#if POZNAN_MP_USE_DEPTH_MAP_GENERATION
758      m_pcMP->init( m_cSPS.getHeight(), m_cSPS.getWidth() );
759#else
760      m_pcMP->init( m_cSPS.getHeight(), m_cSPS.getWidth(), m_pcCamParsCollector->getBaseViewShiftLUTI());
761#endif
762#endif
763
764      return false;
765    }
766
767    case NAL_UNIT_PPS:
768      m_cEntropyDecoder.decodePPS( &m_cPPS );
769      assert( m_cPPS.getSPSId() == m_cSPS.getSPSId() );
770      m_uiValidPS |= 2;
771      return false;
772
773    case NAL_UNIT_SEI:
774      m_SEIs = new SEImessages;
775      m_cEntropyDecoder.decodeSEI(*m_SEIs);
776      return false;
777
778    case NAL_UNIT_CODED_SLICE:
779    case NAL_UNIT_CODED_SLICE_IDR:
780    case NAL_UNIT_CODED_SLICE_CDR:
781    {
782      // make sure we already received both parameter sets
783      assert( 3 == m_uiValidPS );
784      if (m_bFirstSliceInPicture)
785      {
786        m_apcSlicePilot->initSlice();
787        m_uiSliceIdx     = 0;
788        m_uiLastSliceIdx = 0;
789      }
790      m_apcSlicePilot->setSliceIdx(m_uiSliceIdx);
791
792      //  Read slice header
793      m_apcSlicePilot->setSPS( &m_cSPS );
794      m_apcSlicePilot->setPPS( &m_cPPS );
795      m_apcSlicePilot->setSliceIdx(m_uiSliceIdx);
796      m_apcSlicePilot->setViewIdx( m_cSPS.getViewId() );
797#if SONY_COLPIC_AVAILABILITY
798      m_apcSlicePilot->setViewOrderIdx( m_cSPS.getViewOrderIdx());
799#endif
800      if (!m_bFirstSliceInPicture)
801      {
802        memcpy(m_apcSlicePilot, pcPic->getPicSym()->getSlice(m_uiSliceIdx-1), sizeof(TComSlice));
803      }
804
805#if DCM_DECODING_REFRESH
806      m_apcSlicePilot->setNalUnitType        (eNalUnitType);
807#endif
808      m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot);
809
810//      if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_uiPrevPOC && !m_bFirstSliceInSequence)
811//      if (m_apcSlicePilot->isNextSlice() && ( m_apcSlicePilot->getPOC()!=m_uiPrevPOC || m_apcSlicePilot->getPPSId() != m_cPPS.getPPSId() ) && !m_bFirstSliceInSequence)
812      if (m_apcSlicePilot->isNextSlice() && ( m_apcSlicePilot->getPOC()!=m_uiPrevPOC || m_apcSlicePilot->getPPSId() != m_cPPS.getPPSId() ) && !m_bFirstSliceInPicture)
813      {
814        m_uiPrevPOC = m_apcSlicePilot->getPOC();
815#if FLEX_CODING_ORDER
816        bNewPictureType = m_cNewSPS.isDepth();
817#endif
818        return true;
819      }
820      if (m_apcSlicePilot->isNextSlice())
821        m_uiPrevPOC = m_apcSlicePilot->getPOC();
822      m_bFirstSliceInSequence = false;
823      if (m_apcSlicePilot->isNextSlice())
824      {
825#if DCM_SKIP_DECODING_FRAMES
826        // Skip pictures due to random access
827        if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
828        {
829          return false;
830        }
831#endif
832      }
833
834      if (m_bFirstSliceInPicture)
835      {
836        // Buffer initialize for prediction.
837        m_cPrediction.initTempBuff();
838        //  Get a new picture buffer
839        xGetNewPicBuffer (m_apcSlicePilot, pcPic);
840
841        pcPic->setViewIdx( m_cSPS.getViewId() );
842
843#if SONY_COLPIC_AVAILABILITY
844        pcPic->setViewOrderIdx( m_cSPS.getViewOrderIdx() );
845#endif
846
847        /* transfer any SEI messages that have been received to the picture */
848        pcPic->setSEIs(m_SEIs);
849        m_SEIs = NULL;
850
851        // Recursive structure
852        m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );
853        m_cCuDecoder.init   ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction );
854        m_cTrQuant.init     ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize());
855
856        m_cSliceDecoder.create( m_apcSlicePilot, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
857
858#if DEPTH_MAP_GENERATION
859        UInt uiPdm = ( m_cSPS.getViewId() ? m_cSPS.getPredDepthMapGeneration() : getDecTop()->getSPSAccess()->getPdm() );
860        m_cDepthMapGenerator.create( true, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
861        TComDepthMapGenerator* pcDMG0 = getDecTop()->getDecTop0()->getDepthMapGenerator();
862        if( m_cSPS.getViewId() == 1 && ( pcDMG0->getSubSampExpX() != PDM_SUB_SAMP_EXP_X(uiPdm) || pcDMG0->getSubSampExpY() != PDM_SUB_SAMP_EXP_Y(uiPdm) ) )
863        {
864          pcDMG0->create( true, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
865        }
866#endif
867#if HHI_INTER_VIEW_RESIDUAL_PRED
868        m_cResidualGenerator.create( true, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement );
869#endif
870      }
871
872      //  Set picture slice pointer
873      TComSlice*  pcSlice = m_apcSlicePilot;
874      Bool bNextSlice     = pcSlice->isNextSlice();
875      if (m_bFirstSliceInPicture)
876      {
877        if(pcPic->getNumAllocatedSlice() != 1)
878        {
879          pcPic->clearSliceBuffer();
880        }
881      }
882      else
883      {
884        pcPic->allocateNewSlice();
885      }
886      assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));
887      m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx);
888      pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);
889
890#if POZNAN_MP
891          pcSlice->setMP(m_pcMP);
892#endif
893
894      if (bNextSlice)
895      {
896#if DCM_DECODING_REFRESH
897        // Do decoding refresh marking if any
898        pcSlice->decodingRefreshMarking(m_uiPOCCDR, m_bRefreshPending, m_cListPic);
899#endif
900
901        // Set reference list
902        std::vector<TComPic*> apcSpatRefPics = getDecTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), m_cSPS.isDepth() );
903        TComPic * const pcTexturePic = ( m_cSPS.isDepth()) ? getDecTop()->getPicFromView( pcPic->getViewIdx(), pcSlice->getPOC(), false ) : NULL;
904        TComPic * const pcDepthPic   = (!m_cSPS.isDepth()) ? getDecTop()->getPicFromView( pcPic->getViewIdx(), pcSlice->getPOC(), true  ) : NULL; 
905#if FLEX_CODING_ORDER
906        if (pcTexturePic != NULL)
907        {
908          assert( ! m_cSPS.isDepth() || pcTexturePic != NULL );
909          pcSlice->setTexturePic( pcTexturePic );
910        }
911        if (pcDepthPic != NULL)
912        {
913          assert(   m_cSPS.isDepth() || pcDepthPic != NULL );
914          pcSlice->setDepthPic( pcDepthPic );
915        }
916#else
917        assert( ! m_cSPS.isDepth() || pcTexturePic != NULL );
918        pcSlice->setTexturePic( pcTexturePic );
919        pcSlice->setDepthPic( pcDepthPic );
920        pcSlice->setViewIdx( pcPic->getViewIdx() );
921#endif
922#if SONY_COLPIC_AVAILABILITY
923        pcSlice->setViewOrderIdx( pcPic->getViewOrderIdx() );
924#endif
925        pcSlice->setRefPicListExplicitlyDecoderSided(m_cListPic, apcSpatRefPics) ;// temporary solution
926
927#if DCM_COMB_LIST
928        if(!pcSlice->getRefPicListModificationFlagLC())
929        {
930          pcSlice->generateCombinedList();
931        }
932#endif
933
934        pcSlice->setNoBackPredFlag( false );
935#if DCM_COMB_LIST
936        if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag())
937#else
938          if ( pcSlice->getSliceType() == B_SLICE )
939#endif
940          {
941            if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) )
942            {
943              pcSlice->setNoBackPredFlag( true );
944              int i;
945              for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ )
946              {
947                if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) )
948                {
949                  pcSlice->setNoBackPredFlag( false );
950                  break;
951                }
952              }
953            }
954          }
955      }
956
957      pcPic->setCurrSliceIdx(m_uiSliceIdx);
958
959#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
960    if ( m_cSPS.getUseDMM() && g_aacWedgeLists.empty() && m_bIsDepth )
961      {
962        initWedgeLists();
963      }
964#endif
965
966#if POZNAN_SYNTH
967      if( m_pcCamParsCollector)
968      {
969        m_pcCamParsCollector->setSlice( pcSlice );
970      }
971      //if(!getIsDepth())
972      if(pcSlice->getSPS()->getUseCUSkip())
973      {
974        getDecTop()->storeSynthPicsInBuffer(pcSlice->getViewIdx(),pcSlice->getSPS()->getViewOrderIdx(),pcSlice->getPOC(),getIsDepth());
975      }
976#endif
977
978      //*
979#if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH
980#if FLEX_CODING_ORDER
981      Bool bHaveReconDepth = (pcSlice->getDepthPic() != NULL) && (pcSlice->getDepthPic()->getReconMark());
982      if(!getIsDepth() && pcSlice->getSPS()->getUseTexDqpAccordingToDepth() && !bHaveReconDepth )
983#else
984      if(!getIsDepth() && pcSlice->getSPS()->getUseTexDqpAccordingToDepth())
985#endif
986      {
987        getDecTop()->storeDepthSynthPicsInBuffer(pcSlice->getViewIdx(),pcSlice->getSPS()->getViewOrderIdx(),pcSlice->getPOC());
988      }
989#endif
990      //*/
991
992#if POZNAN_MP
993        std::vector<TComPic*> apcSpatDataRefPics = getDecTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), m_cSPS.isDepth() );
994        pcSlice->getMP()->setRefPicsList(&apcSpatDataRefPics); 
995#if !POZNAN_MP_USE_DEPTH_MAP_GENERATION
996        std::vector<TComPic*> apcSpatDepthRefPics = getDecTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), true );
997        pcSlice->getMP()->setDepthRefPicsList(&apcSpatDepthRefPics);
998#endif
999#endif
1000
1001      //  Decode a picture
1002      m_cGopDecoder.decompressGop ( bEos, pcBitstream, pcPic, false );
1003
1004#if POZNAN_MP
1005          //pcSlice->getMP()->disable();
1006#endif
1007
1008      if( m_pcCamParsCollector )
1009      {
1010        m_pcCamParsCollector->setSlice( pcSlice );
1011      }
1012
1013      m_bFirstSliceInPicture = false;
1014      m_uiSliceIdx++;
1015    }
1016      break;
1017    default:
1018      assert (1);
1019  }
1020
1021  return false;
1022}
1023
1024#if DCM_SKIP_DECODING_FRAMES
1025/** Function for checking if picture should be skipped because of random access
1026 * \param iSkipFrame skip frame counter
1027 * \param iPOCLastDisplay POC of last picture displayed
1028 * \returns true if the picture shold be skipped in the random access.
1029 * This function checks the skipping of pictures in the case of -s option random access.
1030 * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped.
1031 * It also checks the type of Nal unit type at the random access point.
1032 * If the random access point is CDR, pictures with POC equal to or greater than the CDR POC are decoded.
1033 * If the random access point is IDR all pictures after the random access point are decoded.
1034 * If the random access point is not IDR or CDR, a warning is issues, and decoding of pictures with POC
1035 * equal to or greater than the random access point POC is attempted. For non IDR/CDR random
1036 * access point there is no guarantee that the decoder will not crash.
1037 */
1038Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay)
1039{
1040  if (iSkipFrame)
1041  {
1042    iSkipFrame--;   // decrement the counter
1043    return true;
1044  }
1045  else if (m_uiPOCRA == MAX_UINT) // start of random access point, m_uiPOCRA has not been set yet.
1046  {
1047    if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CDR)
1048    {
1049      m_uiPOCRA = m_apcSlicePilot->getPOC(); // set the POC random access since we need to skip the reordered pictures in CDR.
1050    }
1051    else if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR)
1052    {
1053      m_uiPOCRA = 0; // no need to skip the reordered pictures in IDR, they are decodable.
1054    }
1055    else
1056    {
1057      printf("\nUnsafe random access point. Decoder may crash.");
1058      m_uiPOCRA = m_apcSlicePilot->getPOC(); // set the POC random access skip the reordered pictures and try to decode if possible.  This increases the chances of avoiding a decoder crash.
1059      //m_uiPOCRA = 0;
1060    }
1061  }
1062  else if (m_apcSlicePilot->getPOC() < m_uiPOCRA)  // skip the reordered pictures if necessary
1063  {
1064    iPOCLastDisplay++;
1065    return true;
1066  }
1067  // if we reach here, then the picture is not skipped.
1068  return false;
1069}
1070#endif
1071
Note: See TracBrowser for help on using the repository browser.