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

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

Added Ericsson Extraction Tool

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