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

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

some bug fix on high level syntax
fixed some compiler warning issues under windows and linux

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