source: 3DVCSoftware/branches/HTM-14.1-update-dev0/source/Lib/TLibDecoder/TDecTop.h @ 1199

Last change on this file since 1199 was 1196, checked in by tech, 9 years ago

Merged 14.0-dev0@1187.

  • Property svn:eol-style set to native
File size: 11.6 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-2015, 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_lastPoc; 
100  Int      m_firstReceivedPoc; 
101
102 
103  Bool    m_bCamParsVaryOverTime;
104
105  UInt    m_uiBitDepthForLUT;
106  UInt    m_iLog2Precision;
107  UInt    m_uiInputBitDepth;
108
109  // look-up tables
110  Double****   m_adBaseViewShiftLUT;       ///< Disparity LUT
111  Int****      m_aiBaseViewShiftLUT;       ///< Disparity LUT
112  Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT);
113  Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT);
114  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 );
115  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize1, UInt uiSize2 );
116  template<class T> Void  xDeleteArray  ( T*& rpt, UInt uiSize );
117
118};
119
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 //H_3D
177/// decoder class
178class TDecTop
179{
180private:
181  Int                     m_iMaxRefPicNum;
182 
183  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
184  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
185  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
186
187  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
188#if H_MV
189  Bool*                    m_layerInitilizedFlag; // initialization Layers
190  static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
191  Int                      m_targetOptLayerSetIdx; 
192#else
193  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
194#endif
195  TComSlice*              m_apcSlicePilot;
196 
197  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices
198
199  // functional classes
200  TComPrediction          m_cPrediction;
201  TComTrQuant             m_cTrQuant;
202  TDecGop                 m_cGopDecoder;
203  TDecSlice               m_cSliceDecoder;
204  TDecCu                  m_cCuDecoder;
205  TDecEntropy             m_cEntropyDecoder;
206  TDecCavlc               m_cCavlcDecoder;
207  TDecSbac                m_cSbacDecoder;
208  TDecBinCABAC            m_cBinCABAC;
209  SEIReader               m_seiReader;
210  TComLoopFilter          m_cLoopFilter;
211  TComSampleAdaptiveOffset m_cSAO;
212
213  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
214  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
215  TComPic*                m_pcPic;
216  UInt                    m_uiSliceIdx;
217  Int                     m_prevPOC;
218  Bool                    m_bFirstSliceInPicture;
219  Bool                    m_bFirstSliceInSequence;
220  Bool                    m_prevSliceSkipped;
221  Int                     m_skippedPOC;
222#if SETTING_NO_OUT_PIC_PRIOR 
223  Bool                    m_bFirstSliceInBitstream;
224  Int                     m_lastPOCNoOutputPriorPics;
225  Bool                    m_isNoOutputPriorPics;
226  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
227#endif
228#if H_MV
229  Bool                    m_isLastNALWasEos;
230#endif
231
232#if H_MV
233  // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer 
234  Int                     m_layerId;
235  Int                     m_viewId;
236  TComPicLists*           m_ivPicLists;
237  std::vector<TComPic*>   m_refPicSetInterLayer0; 
238  std::vector<TComPic*>   m_refPicSetInterLayer1; 
239#if H_3D
240  Int                     m_viewIndex; 
241  Bool                    m_isDepth;
242  CamParsCollector*       m_pcCamParsCollector;
243  Int                     m_profileIdc;
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
303  Void                    setProfileIdc();
304  Bool                    decProcAnnexI()           { assert( m_profileIdc != -1 ); return ( m_profileIdc == 8); }   
305#endif
306#endif
307protected:
308  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
309  Void  xCreateLostPicture (Int iLostPOC);
310
311  Void      xActivateParameterSets();
312#if H_MV 
313  TComPic*  xGetPic( Int layerId, Int poc ); 
314  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ); 
315  Void      xResetPocInPicBuffer();
316  Void      xCeckNoClrasOutput();
317
318  Bool      xAllRefLayersInitilized();
319#else
320  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
321#endif
322  Void      xDecodeVPS();
323  Void      xDecodeSPS();
324  Void      xDecodePPS();
325  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
326
327};// END CLASS DEFINITION TDecTop
328
329
330//! \}
331
332#endif // __TDECTOP__
333
Note: See TracBrowser for help on using the repository browser.