source: 3DVCSoftware/branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecTop.cpp @ 15

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

Poznan Tools

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