source: 3DVCSoftware/trunk/source/Lib/TLibDecoder/TDecTop.h @ 622

Last change on this file since 622 was 622, checked in by tech, 11 years ago

Merged 8.0-dev0@621 (MV-HEVC 5 HLS).

  • Property svn:eol-style set to native
File size: 9.7 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-2013, 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/SEI.h"
47
48#include "TDecGop.h"
49#include "TDecEntropy.h"
50#include "TDecSbac.h"
51#include "TDecCAVLC.h"
52#include "SEIread.h"
53
54struct InputNALUnit;
55
56//! \ingroup TLibDecoder
57//! \{
58
59// ====================================================================================================================
60// Class definition
61// ====================================================================================================================
62
63#if H_MV
64class TAppDecTop;
65#endif
66#if H_3D
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  Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
79
80private:
81  Bool  xIsComplete ();
82  Void  xOutput     ( Int iPOC );
83
84private:
85  Bool    m_bInitialized;
86  FILE*   m_pCodedScaleOffsetFile;
87
88  Int**   m_aaiCodedOffset;
89  Int**   m_aaiCodedScale;
90  Int*    m_aiViewId; 
91
92  Bool*   m_bViewReceived;
93  UInt    m_uiCamParsCodedPrecision;
94  Bool    m_bCamParsVaryOverTime;
95  Int     m_iLastViewIndex;
96  Int     m_iLastPOC;
97  UInt    m_uiMaxViewIndex;
98
99
100  UInt    m_uiBitDepthForLUT;
101  UInt    m_iLog2Precision;
102  UInt    m_uiInputBitDepth;
103
104  // look-up tables
105  Double****   m_adBaseViewShiftLUT;       ///< Disparity LUT
106  Int****      m_aiBaseViewShiftLUT;       ///< Disparity LUT
107  Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT);
108  Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT);
109  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 );
110  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2 );
111  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize );
112
113};
114
115template <class T>
116Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
117{
118  if( rpt )
119  {
120    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
121    {
122      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
123      {
124        for( UInt uiM = 0; uiM < uiSize3; uiM++ )
125        {
126          delete[] rpt[ uiK ][ uiL ][ uiM ];
127        }
128        delete[] rpt[ uiK ][ uiL ];
129      }
130      delete[] rpt[ uiK ];
131    }
132    delete[] rpt;
133  }
134  rpt = NULL;
135};
136
137
138template <class T>
139Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 )
140{
141  if( rpt )
142  {
143    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
144    {
145      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
146      {
147        delete[] rpt[ uiK ][ uiL ];
148      }
149      delete[] rpt[ uiK ];
150    }
151    delete[] rpt;
152  }
153  rpt = NULL;
154};
155
156
157template <class T>
158Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize )
159{
160  if( rpt )
161  {
162    for( UInt uiK = 0; uiK < uiSize; uiK++ )
163    {
164      delete[] rpt[ uiK ];
165    }
166    delete[] rpt;
167  }
168  rpt = NULL;
169};
170
171#endif //H_3D
172/// decoder class
173class TDecTop
174{
175private:
176  Int                     m_iMaxRefPicNum;
177 
178  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
179  Bool                    m_prevRAPisBLA;      ///< true if the previous RAP (CRA/CRANT/BLA/BLANT/IDR) picture is a BLA/BLANT picture
180  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
181
182  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
183#if H_MV
184  static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
185#else
186  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
187#endif
188  TComSlice*              m_apcSlicePilot;
189 
190  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices
191
192  // functional classes
193  TComPrediction          m_cPrediction;
194  TComTrQuant             m_cTrQuant;
195  TDecGop                 m_cGopDecoder;
196  TDecSlice               m_cSliceDecoder;
197  TDecCu                  m_cCuDecoder;
198  TDecEntropy             m_cEntropyDecoder;
199  TDecCavlc               m_cCavlcDecoder;
200  TDecSbac                m_cSbacDecoder;
201  TDecBinCABAC            m_cBinCABAC;
202  SEIReader               m_seiReader;
203  TComLoopFilter          m_cLoopFilter;
204  TComSampleAdaptiveOffset m_cSAO;
205
206  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
207  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
208  TComPic*                m_pcPic;
209  UInt                    m_uiSliceIdx;
210  Int                     m_prevPOC;
211  Bool                    m_bFirstSliceInPicture;
212  Bool                    m_bFirstSliceInSequence;
213#if H_MV
214  // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
215  Int                     m_layerId;
216  Int                     m_viewId;
217  TComPicLists*           m_ivPicLists;
218#if H_MV5
219  std::vector<TComPic*>   m_refPicSetInterLayer0; 
220  std::vector<TComPic*>   m_refPicSetInterLayer1; 
221#else
222  std::vector<TComPic*>   m_refPicSetInterLayer; 
223#endif
224#if H_3D
225  Int                     m_viewIndex; 
226  Bool                    m_isDepth;
227  CamParsCollector*       m_pcCamParsCollector;
228#endif
229#endif
230
231public:
232  TDecTop();
233  virtual ~TDecTop();
234 
235  Void  create  ();
236  Void  destroy ();
237
238  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
239
240  Void  init();
241#if H_MV 
242  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
243#else 
244  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
245#endif
246 
247  Void  deletePicBuffer();
248
249#if H_MV
250  Void endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic,  std::vector<Int>& targetDecLayerIdSet); 
251#else
252  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
253#endif
254 
255#if H_MV   
256  TComPic*                getPic                ( Int poc );
257  TComList<TComPic*>*     getListPic            ()               { return &m_cListPic;  } 
258  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
259 
260  Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
261  Void                    setLayerId            ( Int layer)     { m_layerId = layer;   }
262  Int                     getLayerId            ()               { return m_layerId;    }
263  Void                    setViewId             ( Int viewId  )  { m_viewId  = viewId;  }
264  Int                     getViewId             ()               { return m_viewId;     } 
265#if H_3D   
266  Void                    setViewIndex          ( Int viewIndex  )  { m_viewIndex  = viewIndex;  }
267  Int                     getViewIndex          ()               { return m_viewIndex;     } 
268  Void                    setIsDepth            ( Bool isDepth ) { m_isDepth = isDepth; }
269  Bool                    getIsDepth            ()               { return m_isDepth;    }
270  Void                    setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
271#endif
272#endif
273protected:
274  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
275  Void  xCreateLostPicture (Int iLostPOC);
276
277  Void      xActivateParameterSets();
278#if H_MV 
279  TComPic*  xGetPic( Int layerId, Int poc ); 
280  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag ); 
281#if H_MV5
282  Void      xResetPocInPicBuffer();
283#endif
284#else
285  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
286#endif
287  Void      xDecodeVPS();
288  Void      xDecodeSPS();
289  Void      xDecodePPS();
290  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
291
292};// END CLASS DEFINITION TDecTop
293
294
295//! \}
296
297#endif // __TDECTOP__
298
Note: See TracBrowser for help on using the repository browser.