source: 3DVCSoftware/branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibDecoder/TDecTop.h @ 166

Last change on this file since 166 was 166, checked in by mitsubishi-htm, 12 years ago

Initial integration of VSP into HTM 4.0.1. The version used for JCT3V-B0102 at Shanghai meeting.

  • VC9 project/solution files updated. Other Visual C++ project/solution files are not updated.
  • Linux make file updated.

TODO

  • A second release is expected to include some bug fix and improvements on the interface, e.g. to move switches from macro definition to the configuration file.
  • A third release is expected after being integrated within HTM 5.x, which is to be used for CE1.h anchor.
  • Property svn:eol-style set to native
File size: 10.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-2012, ITU/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 ITU/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.h
35    \brief    decoder class (header)
36*/
37
38#ifndef __TDECTOP__
39#define __TDECTOP__
40
41#include "TLibCommon/CommonDef.h"
42#include "TLibCommon/TComList.h"
43#include "TLibCommon/TComPicYuv.h"
44#include "TLibCommon/TComPic.h"
45#include "TLibCommon/TComTrQuant.h"
46#include "TLibCommon/TComDepthMapGenerator.h"
47#include "TLibCommon/SEI.h"
48
49#include "TDecGop.h"
50#include "TDecEntropy.h"
51#include "TDecSbac.h"
52#include "TDecCAVLC.h"
53
54struct InputNALUnit;
55
56//! \ingroup TLibDecoder
57//! \{
58
59#define APS_RESERVED_BUFFER_SIZE 2 //!< must be equal to or larger than 2 to handle bitstream parsing
60
61// ====================================================================================================================
62// Class definition
63// ====================================================================================================================
64
65class TAppDecTop;
66
67class CamParsCollector
68{
69public:
70  CamParsCollector  ();
71  ~CamParsCollector ();
72
73  Void  init        ( FILE* pCodedScaleOffsetFile );
74  Void  uninit      ();
75  Void  setSlice    ( TComSlice* pcSlice );
76
77  Bool  isInitialized() const { return m_bInitialized; }
78
79#if VSP_N
80  Double****          getBaseViewShiftLUTD      ()  { return m_adBaseViewShiftLUT;   }
81  Int****             getBaseViewShiftLUTI      ()  { return m_aiBaseViewShiftLUT;   }
82  Int**               getBaseViewOffsetI        ()  { return m_aaiCodedOffset;   }
83  Int**               getBaseViewScaleI         ()  { return m_aaiCodedScale;   }
84  Bool                getNearestBaseView        ( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft);
85#if NTT_SUBPEL
86  Int****             getBaseViewIPelLUT        ()  { return m_aiBaseViewShiftLUT_ipel;   }
87  Int****             getBaseViewFPosLUT        ()  { return m_aiBaseViewShiftLUT_fpos;   }
88#endif
89#endif
90
91private:
92  Bool  xIsComplete ();
93  Void  xOutput     ( Int iPOC );
94
95private:
96  Bool    m_bInitialized;
97  FILE*   m_pCodedScaleOffsetFile;
98
99  Int**   m_aaiCodedOffset;
100  Int**   m_aaiCodedScale;
101  Int*    m_aiViewOrderIndex;
102  Int*    m_aiViewReceived;
103  UInt    m_uiCamParsCodedPrecision;
104  Bool    m_bCamParsVaryOverTime;
105  Int     m_iLastViewId;
106  Int     m_iLastPOC;
107  UInt    m_uiMaxViewId;
108
109#if VSP_N
110  UInt    m_uiBitDepthForLUT;
111  UInt    m_iLog2Precision;
112  UInt    m_uiInputBitDepth;
113  // look-up tables
114  Double****          m_adBaseViewShiftLUT;                    ///< Disparity LUT
115  Int****             m_aiBaseViewShiftLUT;                    ///< Disparity LUT
116  Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT);
117  Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT);
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
122#if NTT_SUBPEL
123  Int****             m_aiBaseViewShiftLUT_ipel;              ///< Disparity LUT
124  Int****             m_aiBaseViewShiftLUT_fpos;              ///< Disparity LUT
125  Void xCreateLUTs_Subpel ( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Int****& raiLUT0, Int****& raiLUT1 );
126  Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Int****& raiLUT_ipel, Int****& raiLUT_fpos);
127#endif
128#endif
129};
130
131#if VSP_N
132template <class T>
133Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
134{
135  if( rpt )
136  {
137    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
138    {
139      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
140      {
141        for( UInt uiM = 0; uiM < uiSize3; uiM++ )
142        {
143          delete[] rpt[ uiK ][ uiL ][ uiM ];
144        }
145        delete[] rpt[ uiK ][ uiL ];
146      }
147      delete[] rpt[ uiK ];
148    }
149    delete[] rpt;
150  }
151  rpt = NULL;
152};
153
154
155template <class T>
156Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 )
157{
158  if( rpt )
159  {
160    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
161    {
162      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
163      {
164        delete[] rpt[ uiK ][ uiL ];
165      }
166      delete[] rpt[ uiK ];
167    }
168    delete[] rpt;
169  }
170  rpt = NULL;
171};
172
173
174template <class T>
175Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize )
176{
177  if( rpt )
178  {
179    for( UInt uiK = 0; uiK < uiSize; uiK++ )
180    {
181      delete[] rpt[ uiK ];
182    }
183    delete[] rpt;
184  }
185  rpt = NULL;
186};
187#endif
188
189/// decoder class
190class TDecTop
191{
192private:
193  Int                     m_iGopSize;
194  Bool                    m_bGopSizeSet;
195  int                     m_iMaxRefPicNum;
196 
197  Bool                    m_bRefreshPending;    ///< refresh pending flag
198  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
199  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
200
201  UInt                    m_uiValidPS;
202  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
203  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
204  TComRPSList             m_RPSList;
205  TComSlice*              m_apcSlicePilot;
206 
207  SEImessages *m_SEIs; ///< "all" SEI messages.  If not NULL, we own the object.
208
209#if SONY_COLPIC_AVAILABILITY
210  Int                     m_iViewOrderIdx;
211#endif
212
213  // functional classes
214  TComPrediction          m_cPrediction;
215  TComTrQuant             m_cTrQuant;
216  TDecGop                 m_cGopDecoder;
217  TDecSlice               m_cSliceDecoder;
218  TDecCu                  m_cCuDecoder;
219  TDecEntropy             m_cEntropyDecoder;
220  TDecCavlc               m_cCavlcDecoder;
221  TDecSbac                m_cSbacDecoder;
222  TDecBinCABAC            m_cBinCABAC;
223  TComLoopFilter          m_cLoopFilter;
224  TComAdaptiveLoopFilter  m_cAdaptiveLoopFilter;
225  TComSampleAdaptiveOffset m_cSAO;
226
227#if DEPTH_MAP_GENERATION
228  TComDepthMapGenerator   m_cDepthMapGenerator;
229#endif
230#if HHI_INTER_VIEW_RESIDUAL_PRED
231  TComResidualGenerator   m_cResidualGenerator;
232#endif
233
234  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
235  TComPic*                m_pcPic;
236  UInt                    m_uiSliceIdx;
237  UInt                    m_uiLastSliceIdx;
238  Int                     m_prevPOC;
239  Bool                    m_bFirstSliceInPicture;
240  Bool                    m_bFirstSliceInSequence;
241
242  Int                     m_viewId;
243  Bool                    m_isDepth;
244  TAppDecTop*             m_tAppDecTop;
245  CamParsCollector*       m_pcCamParsCollector;
246  NalUnitType             m_nalUnitTypeBaseView; 
247
248#if VSP_N
249  TComPic*                m_pcPicVSP; //view synthesis prediction buffer for current POC to be coded
250  TComPic*                m_pcPicAvail;
251#endif
252
253public:
254  TDecTop();
255  virtual ~TDecTop();
256 
257  Void  create  ();
258  Void  destroy ();
259
260  void setPictureDigestEnabled(bool enabled) { m_cGopDecoder.setPictureDigestEnabled(enabled); }
261 
262  Void  init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance );
263  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
264 
265  Void  deletePicBuffer();
266
267#if HHI_INTER_VIEW_RESIDUAL_PRED
268  Void      deleteExtraPicBuffers   ( Int iPoc );
269#endif
270  Void  compressMotion       ( Int iPoc );
271
272  Void executeDeblockAndAlf(UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame,  Int& iPOCLastDisplay);
273
274  Void setViewId(Int viewId)      { m_viewId = viewId;}
275  Int  getViewId()                { return m_viewId  ;}
276  Void setIsDepth( Bool isDepth ) { m_isDepth = isDepth; }
277
278#if SONY_COLPIC_AVAILABILITY
279  Void setViewOrderIdx(Int i)     { m_iViewOrderIdx = i ;}
280  Int  getViewOrderIdx()          { return m_iViewOrderIdx ; }
281#endif
282
283#if DEPTH_MAP_GENERATION
284  TComDepthMapGenerator*  getDepthMapGenerator  () { return &m_cDepthMapGenerator; }
285#endif
286
287  Void setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
288
289  TComList<TComPic*>* getListPic()                              { return &m_cListPic; }
290  Void                setTAppDecTop( TAppDecTop* pcTAppDecTop ) { m_tAppDecTop = pcTAppDecTop; }
291  TAppDecTop*         getTAppDecTop()                           { return  m_tAppDecTop; }
292  NalUnitType         getNalUnitTypeBaseView()                  { return m_nalUnitTypeBaseView; }
293
294#if VSP_N
295  TComPic*            getVSPBuf()                               { return m_pcPicVSP; }
296#endif
297
298protected:
299  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
300  Void  xUpdateGopSize    (TComSlice* pcSlice);
301  Void  xCreateLostPicture (Int iLostPOC);
302
303  Void      decodeAPS( TComAPS* cAPS) { m_cEntropyDecoder.decodeAPS(cAPS); };
304  Void      xActivateParameterSets();
305#if SKIPFRAME_BUGFIX
306  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
307#else
308  Bool      xDecodeSlice(InputNALUnit &nalu, Int iSkipFrame, Int iPOCLastDisplay);
309#endif
310#if VIDYO_VPS_INTEGRATION
311  Void      xDecodeVPS();
312#endif
313  Void      xDecodeSPS();
314  Void      xDecodePPS();
315  Void      xDecodeAPS();
316  Void      xDecodeSEI();
317
318  Void      allocAPS (TComAPS* pAPS); //!< memory allocation for APS
319};// END CLASS DEFINITION TDecTop
320
321
322//! \}
323
324#endif // __TDECTOP__
325
Note: See TracBrowser for help on using the repository browser.