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

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

Poznan disocclusion coding - CU Skip

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