source: 3DVCSoftware/branches/HTM-13.1-dev2-HiSilicon/source/Lib/TLibDecoder/TDecTop.h @ 1417

Last change on this file since 1417 was 1133, checked in by tech, 10 years ago

Merged 13.0-dev0@1132

  • Cleanup
  • TICKET083_IVPFLAG_FIX
  • Property svn:eol-style set to native
File size: 11.4 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-2014, 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, TComVPS* vps );
74
75  Void  uninit      ();
76  Void  setSlice    ( TComSlice* pcSlice );
77
78  Bool  isInitialized() const     { return m_bInitialized; }
79  Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
80
81#if H_3D_IV_MERGE
82  Void  copyCamParamForSlice( TComSlice* pcSlice );
83#endif
84
85
86private:
87  Void xResetReceivedIdc( Bool overWriteFlag ); 
88  Void  xOutput     ( Int iPOC );
89
90private:
91  Bool    m_bInitialized;
92  FILE*   m_pCodedScaleOffsetFile;
93
94  Int**   m_aaiCodedOffset;
95  Int**   m_aaiCodedScale;
96 
97  TComVPS* m_vps; 
98  Int**    m_receivedIdc; 
99  Int      m_uiMaxViewIndex; 
100  Int      m_lastPoc; 
101  Int      m_firstReceivedPoc; 
102
103 
104  Bool    m_bCamParsVaryOverTime;
105
106  UInt    m_uiBitDepthForLUT;
107  UInt    m_iLog2Precision;
108  UInt    m_uiInputBitDepth;
109
110  // look-up tables
111  Double****   m_adBaseViewShiftLUT;       ///< Disparity LUT
112  Int****      m_aiBaseViewShiftLUT;       ///< Disparity LUT
113  Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT);
114  Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT);
115  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 );
116  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2 );
117  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize );
118
119};
120
121template <class T>
122Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 )
123{
124  if( rpt )
125  {
126    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
127    {
128      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
129      {
130        for( UInt uiM = 0; uiM < uiSize3; uiM++ )
131        {
132          delete[] rpt[ uiK ][ uiL ][ uiM ];
133        }
134        delete[] rpt[ uiK ][ uiL ];
135      }
136      delete[] rpt[ uiK ];
137    }
138    delete[] rpt;
139  }
140  rpt = NULL;
141};
142
143
144template <class T>
145Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 )
146{
147  if( rpt )
148  {
149    for( UInt uiK = 0; uiK < uiSize1; uiK++ )
150    {
151      for( UInt uiL = 0; uiL < uiSize2; uiL++ )
152      {
153        delete[] rpt[ uiK ][ uiL ];
154      }
155      delete[] rpt[ uiK ];
156    }
157    delete[] rpt;
158  }
159  rpt = NULL;
160};
161
162
163template <class T>
164Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize )
165{
166  if( rpt )
167  {
168    for( UInt uiK = 0; uiK < uiSize; uiK++ )
169    {
170      delete[] rpt[ uiK ];
171    }
172    delete[] rpt;
173  }
174  rpt = NULL;
175};
176
177#endif //H_3D
178/// decoder class
179class TDecTop
180{
181private:
182  Int                     m_iMaxRefPicNum;
183 
184  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
185  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
186  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
187
188  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
189#if H_MV
190  Bool*                    m_layerInitilizedFlag; // initialization Layers
191  static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
192  Int                      m_targetOptLayerSetIdx; 
193#else
194  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
195#endif
196  TComSlice*              m_apcSlicePilot;
197 
198  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices
199
200  // functional classes
201  TComPrediction          m_cPrediction;
202  TComTrQuant             m_cTrQuant;
203  TDecGop                 m_cGopDecoder;
204  TDecSlice               m_cSliceDecoder;
205  TDecCu                  m_cCuDecoder;
206  TDecEntropy             m_cEntropyDecoder;
207  TDecCavlc               m_cCavlcDecoder;
208  TDecSbac                m_cSbacDecoder;
209  TDecBinCABAC            m_cBinCABAC;
210  SEIReader               m_seiReader;
211  TComLoopFilter          m_cLoopFilter;
212  TComSampleAdaptiveOffset m_cSAO;
213
214  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
215  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
216  TComPic*                m_pcPic;
217  UInt                    m_uiSliceIdx;
218  Int                     m_prevPOC;
219  Bool                    m_bFirstSliceInPicture;
220  Bool                    m_bFirstSliceInSequence;
221  Bool                    m_prevSliceSkipped;
222  Int                     m_skippedPOC;
223#if SETTING_NO_OUT_PIC_PRIOR 
224  Bool                    m_bFirstSliceInBitstream;
225  Int                     m_lastPOCNoOutputPriorPics;
226  Bool                    m_isNoOutputPriorPics;
227  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
228#endif
229#if H_MV
230  Bool                    m_isLastNALWasEos;
231#endif
232
233#if H_MV
234  // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
235  Int                     m_layerId;
236  Int                     m_viewId;
237  TComPicLists*           m_ivPicLists;
238  std::vector<TComPic*>   m_refPicSetInterLayer0; 
239  std::vector<TComPic*>   m_refPicSetInterLayer1; 
240#if H_3D
241  Int                     m_viewIndex; 
242  Bool                    m_isDepth;
243  CamParsCollector*       m_pcCamParsCollector;
244#endif
245#endif
246
247public:
248  TDecTop();
249  virtual ~TDecTop();
250 
251  Void  create  ();
252  Void  destroy ();
253
254  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
255
256  Void  init();
257#if H_MV 
258  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer, Bool& sliceSkippedFlag );
259  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
260#else 
261  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
262#endif
263 
264  Void  deletePicBuffer();
265#if H_MV
266  TComVPS* getActiveVPS() { return m_parameterSetManagerDecoder.getActiveVPS( ); }
267  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS( m_layerId ); }
268#else
269  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); }
270#endif
271
272#if H_MV
273  Void endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic,  std::vector<Int>& targetDecLayerIdSet); 
274#else
275  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
276#endif
277 
278#if SETTING_NO_OUT_PIC_PRIOR 
279  Void  checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic);
280
281  Bool  getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; }
282  Void  setNoOutputPriorPicsFlag (bool val) { m_isNoOutputPriorPics = val; }
283#endif
284#if H_MV   
285  TComPic*                getPic                ( Int poc );
286  TComList<TComPic*>*     getListPic            ()               { return &m_cListPic;  } 
287  Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
288  Void                    setLayerInitilizedFlags( Bool* val )    { m_layerInitilizedFlag = val; }
289  Void                    setTargetOptLayerSetIdx( Int targetOptLayerSetIdx ) { m_targetOptLayerSetIdx = targetOptLayerSetIdx; }   
290  TComVPS*                getPrefetchedVPS      ()               { return m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); }; //Assuming that currently only one VPS is present.
291  Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
292  Void                    setLayerId            ( Int layer)     { m_layerId = layer;   }
293  Int                     getLayerId            ()               { return m_layerId;    }
294  Void                    setViewId             ( Int viewId  )  { m_viewId  = viewId;  }
295  Int                     getViewId             ()               { return m_viewId;     } 
296#if H_3D   
297  Void                    setViewIndex          ( Int viewIndex  )  { m_viewIndex  = viewIndex;  }
298  Int                     getViewIndex          ()               { return m_viewIndex;     } 
299  Void                    setIsDepth            ( Bool isDepth ) { m_isDepth = isDepth; }
300  Bool                    getIsDepth            ()               { return m_isDepth;    }
301  Void                    setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
302#endif
303#endif
304protected:
305  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
306  Void  xCreateLostPicture (Int iLostPOC);
307
308  Void      xActivateParameterSets();
309#if H_MV 
310  TComPic*  xGetPic( Int layerId, Int poc ); 
311  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ); 
312  Void      xResetPocInPicBuffer();
313  Void      xCeckNoClrasOutput();
314
315  Bool      xAllRefLayersInitilized();
316#else
317  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
318#endif
319  Void      xDecodeVPS();
320  Void      xDecodeSPS();
321  Void      xDecodePPS();
322  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
323
324};// END CLASS DEFINITION TDecTop
325
326
327//! \}
328
329#endif // __TDECTOP__
330
Note: See TracBrowser for help on using the repository browser.