source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2a/source/Lib/TLibDecoder/TDecTop.h @ 464

Last change on this file since 464 was 464, checked in by zhang, 11 years ago

Implementation of ARP from QC

  • 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-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  Int*    m_aiLayerIdx;
92
93  Bool*   m_bViewReceived;
94  UInt    m_uiCamParsCodedPrecision;
95  Bool    m_bCamParsVaryOverTime;
96  Int     m_iLastViewIndex;
97  Int     m_iLastPOC;
98  UInt    m_uiMaxViewIndex;
99
100
101  UInt    m_uiBitDepthForLUT;
102  UInt    m_iLog2Precision;
103  UInt    m_uiInputBitDepth;
104
105  // look-up tables
106  Double****   m_adBaseViewShiftLUT;       ///< Disparity LUT
107  Int****      m_aiBaseViewShiftLUT;       ///< Disparity LUT
108  Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT);
109  Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT);
110  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 );
111  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2 );
112  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize );
113
114};
115
116template <class T>
117Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
118{
119  if( rpt )
120  {
121    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
122    {
123      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
124      {
125        for( UInt uiM = 0; uiM < uiSize3; uiM++ )
126        {
127          delete[] rpt[ uiK ][ uiL ][ uiM ];
128        }
129        delete[] rpt[ uiK ][ uiL ];
130      }
131      delete[] rpt[ uiK ];
132    }
133    delete[] rpt;
134  }
135  rpt = NULL;
136};
137
138
139template <class T>
140Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 )
141{
142  if( rpt )
143  {
144    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
145    {
146      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
147      {
148        delete[] rpt[ uiK ][ uiL ];
149      }
150      delete[] rpt[ uiK ];
151    }
152    delete[] rpt;
153  }
154  rpt = NULL;
155};
156
157
158template <class T>
159Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize )
160{
161  if( rpt )
162  {
163    for( UInt uiK = 0; uiK < uiSize; uiK++ )
164    {
165      delete[] rpt[ uiK ];
166    }
167    delete[] rpt;
168  }
169  rpt = NULL;
170};
171
172#endif //H_3D
173/// decoder class
174class TDecTop
175{
176private:
177  Int                     m_iMaxRefPicNum;
178 
179  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
180  Bool                    m_prevRAPisBLA;      ///< true if the previous RAP (CRA/CRANT/BLA/BLANT/IDR) picture is a BLA/BLANT picture
181  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
182
183  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
184#if H_MV
185  static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
186#else
187  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
188#endif
189  TComSlice*              m_apcSlicePilot;
190 
191  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices
192
193  // functional classes
194  TComPrediction          m_cPrediction;
195  TComTrQuant             m_cTrQuant;
196  TDecGop                 m_cGopDecoder;
197  TDecSlice               m_cSliceDecoder;
198  TDecCu                  m_cCuDecoder;
199  TDecEntropy             m_cEntropyDecoder;
200  TDecCavlc               m_cCavlcDecoder;
201  TDecSbac                m_cSbacDecoder;
202  TDecBinCABAC            m_cBinCABAC;
203  SEIReader               m_seiReader;
204  TComLoopFilter          m_cLoopFilter;
205  TComSampleAdaptiveOffset m_cSAO;
206
207  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
208  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
209  TComPic*                m_pcPic;
210  UInt                    m_uiSliceIdx;
211  Int                     m_prevPOC;
212  Bool                    m_bFirstSliceInPicture;
213  Bool                    m_bFirstSliceInSequence;
214#if H_MV
215  // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
216  Int                     m_layerId;
217  Int                     m_viewId;
218  TComPicLists*           m_ivPicLists;
219  std::vector<TComPic*>   m_refPicSetInterLayer; 
220#if H_3D
221  Int                     m_viewIndex; 
222  Bool                    m_isDepth;
223  CamParsCollector*       m_pcCamParsCollector;
224#endif
225#endif
226
227#if H_3D_ARP
228  TAppDecTop*             m_tAppDecTop;
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
272#if H_3D_ARP
273  Void                    setTAppDecTop( TAppDecTop* pcTAppDecTop ) { m_tAppDecTop = pcTAppDecTop; }
274  TAppDecTop*             getTAppDecTop()                           { return  m_tAppDecTop; }
275#endif
276#endif
277#endif
278protected:
279  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
280  Void  xCreateLostPicture (Int iLostPOC);
281
282  Void      xActivateParameterSets();
283#if H_MV 
284  TComPic*  xGetPic( Int layerId, Int poc ); 
285  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag ); 
286#else
287  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
288#endif
289  Void      xDecodeVPS();
290  Void      xDecodeSPS();
291  Void      xDecodePPS();
292  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
293
294};// END CLASS DEFINITION TDecTop
295
296
297//! \}
298
299#endif // __TDECTOP__
300
Note: See TracBrowser for help on using the repository browser.