source: 3DVCSoftware/branches/HTM-5.1-dev3-MERL/source/Lib/TLibDecoder/TDecTop.h @ 231

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

-Integration of JCT3V-C0152 & JCT3V-C0131
-This check-in enable C0131 only

  • Property svn:eol-style set to native
File size: 9.9 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 MERL_VSP_C0152
80  Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
81#endif
82private:
83  Bool  xIsComplete ();
84  Void  xOutput     ( Int iPOC );
85
86private:
87  Bool    m_bInitialized;
88  FILE*   m_pCodedScaleOffsetFile;
89
90  Int**   m_aaiCodedOffset;
91  Int**   m_aaiCodedScale;
92  Int*    m_aiViewOrderIndex;
93#if QC_MVHEVC_B0046
94  Int*    m_aiViewId;
95#endif
96  Int*    m_aiViewReceived;
97  UInt    m_uiCamParsCodedPrecision;
98  Bool    m_bCamParsVaryOverTime;
99  Int     m_iLastViewId;
100  Int     m_iLastPOC;
101  UInt    m_uiMaxViewId;
102
103#if MERL_VSP_C0152
104  UInt    m_uiBitDepthForLUT;
105  UInt    m_iLog2Precision;
106  UInt    m_uiInputBitDepth;
107  // look-up tables
108  Double****   m_adBaseViewShiftLUT;       ///< Disparity LUT
109  Int****      m_aiBaseViewShiftLUT;       ///< Disparity LUT
110  Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT);
111  Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT);
112  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 );
113  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2 );
114  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize );
115#endif
116
117};
118
119#if MERL_VSP_C0152
120template <class T>
121Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
122{
123  if( rpt )
124  {
125    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
126    {
127      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
128      {
129        for( UInt uiM = 0; uiM < uiSize3; uiM++ )
130        {
131          delete[] rpt[ uiK ][ uiL ][ uiM ];
132        }
133        delete[] rpt[ uiK ][ uiL ];
134      }
135      delete[] rpt[ uiK ];
136    }
137    delete[] rpt;
138  }
139  rpt = NULL;
140};
141
142
143template <class T>
144Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 )
145{
146  if( rpt )
147  {
148    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
149    {
150      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
151      {
152        delete[] rpt[ uiK ][ uiL ];
153      }
154      delete[] rpt[ uiK ];
155    }
156    delete[] rpt;
157  }
158  rpt = NULL;
159};
160
161
162template <class T>
163Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize )
164{
165  if( rpt )
166  {
167    for( UInt uiK = 0; uiK < uiSize; uiK++ )
168    {
169      delete[] rpt[ uiK ];
170    }
171    delete[] rpt;
172  }
173  rpt = NULL;
174};
175
176#endif
177
178/// decoder class
179class TDecTop
180{
181private:
182  Int                     m_iGopSize;
183  Bool                    m_bGopSizeSet;
184  int                     m_iMaxRefPicNum;
185 
186  Bool                    m_bRefreshPending;    ///< refresh pending flag
187  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
188  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
189
190  UInt                    m_uiValidPS;
191  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
192  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
193  TComRPSList             m_RPSList;
194  TComSlice*              m_apcSlicePilot;
195 
196  SEImessages *m_SEIs; ///< "all" SEI messages.  If not NULL, we own the object.
197
198#if SONY_COLPIC_AVAILABILITY
199  Int                     m_iViewOrderIdx;
200#endif
201
202  // functional classes
203  TComPrediction          m_cPrediction;
204  TComTrQuant             m_cTrQuant;
205  TDecGop                 m_cGopDecoder;
206  TDecSlice               m_cSliceDecoder;
207  TDecCu                  m_cCuDecoder;
208  TDecEntropy             m_cEntropyDecoder;
209  TDecCavlc               m_cCavlcDecoder;
210  TDecSbac                m_cSbacDecoder;
211  TDecBinCABAC            m_cBinCABAC;
212  TComLoopFilter          m_cLoopFilter;
213  TComAdaptiveLoopFilter  m_cAdaptiveLoopFilter;
214  TComSampleAdaptiveOffset m_cSAO;
215
216#if DEPTH_MAP_GENERATION
217  TComDepthMapGenerator   m_cDepthMapGenerator;
218#endif
219#if HHI_INTER_VIEW_RESIDUAL_PRED
220  TComResidualGenerator   m_cResidualGenerator;
221#endif
222
223  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
224  TComPic*                m_pcPic;
225  UInt                    m_uiSliceIdx;
226  UInt                    m_uiLastSliceIdx;
227  Int                     m_prevPOC;
228  Bool                    m_bFirstSliceInPicture;
229  Bool                    m_bFirstSliceInSequence;
230
231  Int                     m_viewId;
232  Bool                    m_isDepth;
233  TAppDecTop*             m_tAppDecTop;
234  CamParsCollector*       m_pcCamParsCollector;
235  NalUnitType             m_nalUnitTypeBaseView; 
236
237public:
238  TDecTop();
239  virtual ~TDecTop();
240 
241  Void  create  ();
242  Void  destroy ();
243
244  void setPictureDigestEnabled(bool enabled) { m_cGopDecoder.setPictureDigestEnabled(enabled); }
245 
246  Void  init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance );
247  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
248 
249  Void  deletePicBuffer();
250#if QC_MVHEVC_B0046
251  Void      xCopySPS( TComSPS* pSPSV0);
252  Void      xCopyPPS( TComPPS* pPPSV0);
253  Void      xCopyVPS( TComVPS* pVPSV0);
254#endif
255#if HHI_INTER_VIEW_RESIDUAL_PRED
256  Void      deleteExtraPicBuffers   ( Int iPoc );
257#endif
258  Void  compressMotion       ( Int iPoc );
259
260  Void executeDeblockAndAlf(UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame,  Int& iPOCLastDisplay);
261
262  Void setViewId(Int viewId)      { m_viewId = viewId;}
263  Int  getViewId()                { return m_viewId  ;}
264  Void setIsDepth( Bool isDepth ) { m_isDepth = isDepth; }
265
266#if SONY_COLPIC_AVAILABILITY
267  Void setViewOrderIdx(Int i)     { m_iViewOrderIdx = i ;}
268  Int  getViewOrderIdx()          { return m_iViewOrderIdx ; }
269#endif
270
271#if DEPTH_MAP_GENERATION
272  TComDepthMapGenerator*  getDepthMapGenerator  () { return &m_cDepthMapGenerator; }
273#endif
274
275  Void setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
276
277  TComList<TComPic*>* getListPic()                              { return &m_cListPic; }
278  Void                setTAppDecTop( TAppDecTop* pcTAppDecTop ) { m_tAppDecTop = pcTAppDecTop; }
279  TAppDecTop*         getTAppDecTop()                           { return  m_tAppDecTop; }
280  NalUnitType         getNalUnitTypeBaseView()                  { return m_nalUnitTypeBaseView; }
281#if QC_MVHEVC_B0046
282  bool                m_bFirstNal; //used to copy SPS, PPS, VPS
283  ParameterSetManagerDecoder* xGetParaSetDec ()        {return  &m_parameterSetManagerDecoder;}
284#endif
285
286protected:
287  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
288  Void  xUpdateGopSize    (TComSlice* pcSlice);
289  Void  xCreateLostPicture (Int iLostPOC);
290
291  Void      decodeAPS( TComAPS* cAPS) { m_cEntropyDecoder.decodeAPS(cAPS); };
292  Void      xActivateParameterSets();
293#if SKIPFRAME_BUGFIX
294  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
295#else
296  Bool      xDecodeSlice(InputNALUnit &nalu, Int iSkipFrame, Int iPOCLastDisplay);
297#endif
298#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
299  Void      xDecodeVPS();
300#endif
301  Void      xDecodeSPS();
302  Void      xDecodePPS();
303  Void      xDecodeAPS();
304  Void      xDecodeSEI();
305
306  Void      allocAPS (TComAPS* pAPS); //!< memory allocation for APS
307};// END CLASS DEFINITION TDecTop
308
309
310//! \}
311
312#endif // __TDECTOP__
313
Note: See TracBrowser for help on using the repository browser.