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

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

Poznan Tools

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