source: 3DVCSoftware/branches/HTM-8.2-dev1-Sharp/source/Lib/TLibDecoder/TDecTop.h @ 686

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

Merged 8.1-Cleanup@654

  • 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  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
179  Int                     m_pocCRA;            ///< POC number of the latest CRA 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  Bool                    m_prevSliceSkipped;
214  Int                     m_skippedPOC;
215
216#if H_MV
217  // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
218  Int                     m_layerId;
219  Int                     m_viewId;
220  TComPicLists*           m_ivPicLists;
221  std::vector<TComPic*>   m_refPicSetInterLayer0; 
222  std::vector<TComPic*>   m_refPicSetInterLayer1; 
223#if H_3D
224  Int                     m_viewIndex; 
225  Bool                    m_isDepth;
226  CamParsCollector*       m_pcCamParsCollector;
227#endif
228#endif
229
230public:
231  TDecTop();
232  virtual ~TDecTop();
233 
234  Void  create  ();
235  Void  destroy ();
236
237  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
238
239  Void  init();
240#if H_MV 
241  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
242#else 
243  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
244#endif
245 
246  Void  deletePicBuffer();
247
248#if H_MV
249  Void endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic,  std::vector<Int>& targetDecLayerIdSet); 
250#else
251  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
252#endif
253 
254#if H_MV   
255  TComPic*                getPic                ( Int poc );
256  TComList<TComPic*>*     getListPic            ()               { return &m_cListPic;  } 
257  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
258 
259  Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
260  Void                    setLayerId            ( Int layer)     { m_layerId = layer;   }
261  Int                     getLayerId            ()               { return m_layerId;    }
262  Void                    setViewId             ( Int viewId  )  { m_viewId  = viewId;  }
263  Int                     getViewId             ()               { return m_viewId;     } 
264#if H_3D   
265  Void                    setViewIndex          ( Int viewIndex  )  { m_viewIndex  = viewIndex;  }
266  Int                     getViewIndex          ()               { return m_viewIndex;     } 
267  Void                    setIsDepth            ( Bool isDepth ) { m_isDepth = isDepth; }
268  Bool                    getIsDepth            ()               { return m_isDepth;    }
269  Void                    setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
270#endif
271#endif
272protected:
273  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
274  Void  xCreateLostPicture (Int iLostPOC);
275
276  Void      xActivateParameterSets();
277#if H_MV 
278  TComPic*  xGetPic( Int layerId, Int poc ); 
279  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag ); 
280  Void      xResetPocInPicBuffer();
281#else
282  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
283#endif
284  Void      xDecodeVPS();
285  Void      xDecodeSPS();
286  Void      xDecodePPS();
287  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
288
289};// END CLASS DEFINITION TDecTop
290
291
292//! \}
293
294#endif // __TDECTOP__
295
Note: See TracBrowser for help on using the repository browser.