source: 3DVCSoftware/branches/0.2-poznan-univ/source/Lib/TLibDecoder/TDecTop.h

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

Poznan Tool disability bug fix

  • Property svn:eol-style set to native
File size: 9.5 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_CU_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_CU_SKIP || POZNAN_CU_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};
123
124#if POZNAN_CU_SKIP || POZNAN_CU_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION)
125  template <class T>
126Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
127{
128  if( rpt )
129  {
130    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
131    {
132      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
133      {
134        for( UInt uiM = 0; uiM < uiSize3; uiM++ )
135        {
136          delete[] rpt[ uiK ][ uiL ][ uiM ];
137        }
138        delete[] rpt[ uiK ][ uiL ];
139      }
140      delete[] rpt[ uiK ];
141    }
142    delete[] rpt;
143  }
144  rpt = NULL;
145};
146
147
148template <class T>
149Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 )
150{
151  if( rpt )
152  {
153    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
154    {
155      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
156      {
157        delete[] rpt[ uiK ][ uiL ];
158      }
159      delete[] rpt[ uiK ];
160    }
161    delete[] rpt;
162  }
163  rpt = NULL;
164};
165
166
167template <class T>
168Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize )
169{
170  if( rpt )
171  {
172    for( UInt uiK = 0; uiK < uiSize; uiK++ )
173    {
174      delete[] rpt[ uiK ];
175    }
176    delete[] rpt;
177  }
178  rpt = NULL;
179};
180#endif
181
182
183/// decoder class
184class TDecTop
185{
186private:
187  Int                     m_iGopSize;
188  Bool                    m_bGopSizeSet;
189  int                     m_iMaxRefPicNum;
190
191#if DCM_DECODING_REFRESH
192  Bool                    m_bRefreshPending;    ///< refresh pending flag
193  UInt                    m_uiPOCCDR;           ///< temporal reference of the CDR picture
194#if DCM_SKIP_DECODING_FRAMES
195  UInt                    m_uiPOCRA;            ///< temporal reference of the random access point
196#endif
197#endif
198
199  UInt                    m_uiValidPS;
200  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
201  TComSPS                 m_cSPS;
202  TComPPS                 m_cPPS;
203  TComSlice*              m_apcSlicePilot;
204
205  SEImessages *m_SEIs; ///< "all" SEI messages.  If not NULL, we own the object.
206
207  // functional classes
208  TComPrediction          m_cPrediction;
209  TComTrQuant             m_cTrQuant;
210  TDecGop                 m_cGopDecoder;
211  TDecSlice               m_cSliceDecoder;
212  TDecCu                  m_cCuDecoder;
213  TDecEntropy             m_cEntropyDecoder;
214  TDecCavlc               m_cCavlcDecoder;
215  TDecSbac                m_cSbacDecoder;
216  TDecBinCABAC            m_cBinCABAC;
217  TComLoopFilter          m_cLoopFilter;
218  TComAdaptiveLoopFilter  m_cAdaptiveLoopFilter;
219#if MTK_SAO
220  TComSampleAdaptiveOffset m_cSAO;
221#endif
222#if DEPTH_MAP_GENERATION
223  TComDepthMapGenerator   m_cDepthMapGenerator;
224#endif
225#if HHI_INTER_VIEW_RESIDUAL_PRED
226  TComResidualGenerator   m_cResidualGenerator;
227#endif
228
229#if POZNAN_MP
230  TComMP*                                 m_pcMP;
231#endif
232
233  Bool                    m_bIsDepth;
234  Int                     m_iViewIdx;
235  TAppDecTop*             m_pcTAppDecTop;
236  CamParsCollector*       m_pcCamParsCollector;
237
238#if DCM_SKIP_DECODING_FRAMES
239  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
240#endif
241  TComPic*                m_pcPic;
242  UInt                    m_uiSliceIdx;
243  UInt                    m_uiLastSliceIdx;
244  UInt                    m_uiPrevPOC;
245  Bool                    m_bFirstSliceInPicture;
246  Bool                    m_bFirstSliceInSequence;
247
248public:
249  TDecTop();
250  virtual ~TDecTop();
251
252  Void  create  ();
253  Void  destroy ();
254
255  void setPictureDigestEnabled(bool enabled) { m_cGopDecoder.setPictureDigestEnabled(enabled); }
256
257  Void  init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance = true );
258#if DCM_SKIP_DECODING_FRAMES
259  Bool  decode (Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS, Int& iSkipFrame, Int& iPOCLastDisplay);
260#else
261  Void  decode ( Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS );
262#endif
263
264  TComSPS *getSPS() { return (m_uiValidPS & 1) ? &m_cSPS : NULL; }
265
266  Void  deletePicBuffer();
267
268  Void  deleteExtraPicBuffers( Int iPoc );
269#if AMVP_BUFFERCOMPRESS
270  Void  compressMotion       ( Int iPoc );
271#endif
272
273  Void setViewIdx(Int i)                                        { m_iViewIdx = i ;}
274  Int  getViewIdx()                                                             { return m_iViewIdx ; }
275
276  Void setToDepth(Bool b)         { m_bIsDepth = b ;}
277  Bool getIsDepth()               { return m_bIsDepth ;}
278
279  Void setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
280
281  TComList<TComPic*>*     getListPic            () { return  &m_cListPic;             }
282  TAppDecTop*             getDecTop           ( ){ return  m_pcTAppDecTop ;};
283
284  Void                    setSPS                (TComSPS cSPS );
285
286  UInt                    getCodedPictureBufferSize() { return m_cSPS.getCodedPictureBufferSize() ; }
287
288  Void executeDeblockAndAlf(Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame,  Int& iPOCLastDisplay);
289
290protected:
291  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
292
293};// END CLASS DEFINITION TDecTop
294
295
296#endif // __TDECTOP__
297
Note: See TracBrowser for help on using the repository browser.