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

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

Adjustment for FlexCO, and high-level syntax improvement.

  • Property svn:eol-style set to native
File size: 10.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
35
36/** \file     TDecTop.h
37    \brief    decoder class (header)
38*/
39
40#ifndef __TDECTOP__
41#define __TDECTOP__
42
43#include "../TLibCommon/CommonDef.h"
44#include "../TLibCommon/TComList.h"
45#include "../TLibCommon/TComPicYuv.h"
46#include "../TLibCommon/TComPic.h"
47#include "../TLibCommon/TComTrQuant.h"
48#include "../TLibCommon/TComDepthMapGenerator.h"
49#include "../TLibCommon/TComResidualGenerator.h"
50#include "../TLibCommon/SEI.h"
51
52#include "TDecGop.h"
53#include "TDecEntropy.h"
54#include "TDecSbac.h"
55#include "TDecCAVLC.h"
56
57#if POZNAN_MP
58#include "../TLibCommon/TComMP.h"
59#endif
60
61// ====================================================================================================================
62// Class definition
63// ====================================================================================================================
64
65class TAppDecTop ;
66
67
68class CamParsCollector
69{
70public:
71  CamParsCollector  ();
72  ~CamParsCollector ();
73
74  Void  init        ( FILE* pCodedScaleOffsetFile );
75  Void  uninit      ();
76  Void  setSlice    ( TComSlice* pcSlice );
77#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
78  Double****          getBaseViewShiftLUTD      ()  { return m_adBaseViewShiftLUT;   }
79  Int****             getBaseViewShiftLUTI      ()  { return m_aiBaseViewShiftLUT;   }
80
81  Int**               getBaseViewOffsetI        ()  { return m_aaiCodedOffset;   }
82  Int**               getBaseViewScaleI         ()  { return m_aaiCodedScale;   }
83
84  Bool                getNearestBaseView        ( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft);
85#endif
86
87private:
88  Bool  xIsComplete ();
89  Void  xOutput     ( Int iPOC );
90
91private:
92  Bool    m_bInitialized;
93  FILE*   m_pCodedScaleOffsetFile;
94
95  Int**   m_aaiCodedOffset;
96  Int**   m_aaiCodedScale;
97  Int*    m_aiViewOrderIndex;
98  Int*    m_aiViewReceived;
99  UInt    m_uiCamParsCodedPrecision;
100  Bool    m_bCamParsVaryOverTime;
101  Int     m_iLastViewId;
102  Int     m_iLastPOC;
103  UInt    m_uiMaxViewId;
104
105#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
106
107  UInt    m_uiBitDepthForLUT;
108  UInt    m_iLog2Precision;
109  UInt    m_uiInputBitDepth;
110
111  // look-up tables
112  Double****          m_adBaseViewShiftLUT;                                                                             ///< Disparity LUT
113  Int****             m_aiBaseViewShiftLUT;                                                                       ///< Disparity LUT
114
115  Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT);
116  Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT);
117
118  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 );
119  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2 );
120  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize );
121#endif
122#if POZNAN_NONLINEAR_DEPTH
123  TComNonlinearDepthModel m_cNonlinearDepthModel; 
124  Bool m_bUseNonlinearDepth;
125#endif
126
127
128};
129
130#if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
131  template <class T>
132Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
133{
134  if( rpt )
135  {
136    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
137    {
138      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
139      {
140        for( UInt uiM = 0; uiM < uiSize3; uiM++ )
141        {
142          delete[] rpt[ uiK ][ uiL ][ uiM ];
143        }
144        delete[] rpt[ uiK ][ uiL ];
145      }
146      delete[] rpt[ uiK ];
147    }
148    delete[] rpt;
149  }
150  rpt = NULL;
151};
152
153
154template <class T>
155Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 )
156{
157  if( rpt )
158  {
159    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
160    {
161      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
162      {
163        delete[] rpt[ uiK ][ uiL ];
164      }
165      delete[] rpt[ uiK ];
166    }
167    delete[] rpt;
168  }
169  rpt = NULL;
170};
171
172
173template <class T>
174Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize )
175{
176  if( rpt )
177  {
178    for( UInt uiK = 0; uiK < uiSize; uiK++ )
179    {
180      delete[] rpt[ uiK ];
181    }
182    delete[] rpt;
183  }
184  rpt = NULL;
185};
186#endif
187
188
189/// decoder class
190class TDecTop
191{
192private:
193  Int                     m_iGopSize;
194  Bool                    m_bGopSizeSet;
195  int                     m_iMaxRefPicNum;
196
197#if DCM_DECODING_REFRESH
198  Bool                    m_bRefreshPending;    ///< refresh pending flag
199  UInt                    m_uiPOCCDR;           ///< temporal reference of the CDR picture
200#if DCM_SKIP_DECODING_FRAMES
201  UInt                    m_uiPOCRA;            ///< temporal reference of the random access point
202#endif
203#endif
204
205  UInt                    m_uiValidPS;
206  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
207  TComSPS                 m_cSPS;
208#if FLEX_CODING_ORDER
209  TComSPS                 m_cNewSPS;
210#endif
211  TComPPS                 m_cPPS;
212  TComSlice*              m_apcSlicePilot;
213
214  SEImessages *m_SEIs; ///< "all" SEI messages.  If not NULL, we own the object.
215
216  // functional classes
217  TComPrediction          m_cPrediction;
218  TComTrQuant             m_cTrQuant;
219  TDecGop                 m_cGopDecoder;
220  TDecSlice               m_cSliceDecoder;
221  TDecCu                  m_cCuDecoder;
222  TDecEntropy             m_cEntropyDecoder;
223  TDecCavlc               m_cCavlcDecoder;
224  TDecSbac                m_cSbacDecoder;
225  TDecBinCABAC            m_cBinCABAC;
226  TComLoopFilter          m_cLoopFilter;
227  TComAdaptiveLoopFilter  m_cAdaptiveLoopFilter;
228#if MTK_SAO
229  TComSampleAdaptiveOffset m_cSAO;
230#endif
231#if DEPTH_MAP_GENERATION
232  TComDepthMapGenerator   m_cDepthMapGenerator;
233#endif
234#if HHI_INTER_VIEW_RESIDUAL_PRED
235  TComResidualGenerator   m_cResidualGenerator;
236#endif
237
238#if POZNAN_MP
239  TComMP*                                 m_pcMP;
240#endif
241
242  Bool                    m_bIsDepth;
243  Int                     m_iViewIdx;
244#if SONY_COLPIC_AVAILABILITY
245  Int                     m_iViewOrderIdx;
246#endif
247  TAppDecTop*             m_pcTAppDecTop;
248  CamParsCollector*       m_pcCamParsCollector;
249
250#if DCM_SKIP_DECODING_FRAMES
251  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
252#endif
253  TComPic*                m_pcPic;
254  UInt                    m_uiSliceIdx;
255  UInt                    m_uiLastSliceIdx;
256  UInt                    m_uiPrevPOC;
257  Bool                    m_bFirstSliceInPicture;
258  Bool                    m_bFirstSliceInSequence;
259
260public:
261  TDecTop();
262  virtual ~TDecTop();
263
264  Void  create  ();
265  Void  destroy ();
266
267  void setPictureDigestEnabled(bool enabled) { m_cGopDecoder.setPictureDigestEnabled(enabled); }
268
269  Void  init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance = true );
270#if DCM_SKIP_DECODING_FRAMES
271#if FLEX_CODING_ORDER
272  Bool  decode (Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS, Int& iSkipFrame, Int& iPOCLastDisplay, Bool& bNewPictureType);
273#else
274  Bool  decode (Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS, Int& iSkipFrame, Int& iPOCLastDisplay);
275#endif
276#else
277  Void  decode ( Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS );
278#endif
279
280  TComSPS *getSPS() { return (m_uiValidPS & 1) ? &m_cSPS : NULL; }
281
282  Void  deletePicBuffer();
283
284  Void  deleteExtraPicBuffers( Int iPoc );
285#if AMVP_BUFFERCOMPRESS
286  Void  compressMotion       ( Int iPoc );
287#endif
288
289  Void setViewIdx(Int i)                                        { m_iViewIdx = i ;}
290  Int  getViewIdx()                                                             { return m_iViewIdx ; }
291#if SONY_COLPIC_AVAILABILITY
292  Void setViewOrderIdx(Int i)                                   { m_iViewOrderIdx = i ;}
293  Int  getViewOrderIdx()                                                        { return m_iViewOrderIdx ; }
294#endif
295
296  Void setToDepth(Bool b)         { m_bIsDepth = b ;}
297  Bool getIsDepth()               { return m_bIsDepth ;}
298
299  Void setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
300
301  TComList<TComPic*>*     getListPic            () { return  &m_cListPic;             }
302  TAppDecTop*             getDecTop           ( ){ return  m_pcTAppDecTop ;}
303#if DEPTH_MAP_GENERATION
304  TComDepthMapGenerator*  getDepthMapGenerator  () { return &m_cDepthMapGenerator; }
305#endif
306
307  Void                    setSPS                (TComSPS cSPS );
308
309  UInt                    getCodedPictureBufferSize() { return m_cSPS.getCodedPictureBufferSize() ; }
310
311  Void executeDeblockAndAlf(Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame,  Int& iPOCLastDisplay);
312
313protected:
314  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
315
316};// END CLASS DEFINITION TDecTop
317
318
319#endif // __TDECTOP__
320
Note: See TracBrowser for help on using the repository browser.