source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h @ 1512

Last change on this file since 1512 was 1512, checked in by seregin, 8 years ago

rename isSpatialEnhLayer to requireResampling for clarity since the difference may be in bitdepth only

  • Property svn:eol-style set to native
File size: 14.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-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/TComPrediction.h"
47#include "TLibCommon/SEI.h"
48#if CGS_3D_ASYMLUT
49#include "TLibCommon/TCom3DAsymLUT.h"
50#endif
51
52#include "TDecGop.h"
53#include "TDecEntropy.h"
54#include "TDecSbac.h"
55#include "TDecCAVLC.h"
56#include "SEIread.h"
57
58class InputNALUnit;
59
60//! \ingroup TLibDecoder
61//! \{
62
63// ====================================================================================================================
64// Class definition
65// ====================================================================================================================
66
67/// decoder class
68class TDecTop
69{
70private:
71  Int                     m_iMaxRefPicNum;
72
73  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
74  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
75  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
76
77  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
78  ParameterSetManager     m_parameterSetManager;  // storage for parameter sets
79  TComSlice*              m_apcSlicePilot;
80
81  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices, excluding prefix SEIs...
82
83  // functional classes
84  TComPrediction          m_cPrediction;
85#if CGS_3D_ASYMLUT
86  TCom3DAsymLUT           m_c3DAsymLUTPPS;
87  TComPicYuv*             m_pColorMappedPic;
88#endif
89  TComTrQuant             m_cTrQuant;
90  TDecGop                 m_cGopDecoder;
91  TDecSlice               m_cSliceDecoder;
92  TDecCu                  m_cCuDecoder;
93  TDecEntropy             m_cEntropyDecoder;
94  TDecCavlc               m_cCavlcDecoder;
95  TDecSbac                m_cSbacDecoder;
96  TDecBinCABAC            m_cBinCABAC;
97  SEIReader               m_seiReader;
98  TComLoopFilter          m_cLoopFilter;
99  TComSampleAdaptiveOffset m_cSAO;
100
101  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
102  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
103  TComPic*                m_pcPic;
104  UInt                    m_uiSliceIdx;
105#if !SVC_EXTENSION
106  Int                     m_prevPOC;
107#endif
108  Int                     m_prevTid0POC;
109  Bool                    m_bFirstSliceInPicture;
110#if !SVC_EXTENSION
111  Bool                    m_bFirstSliceInSequence;
112#endif
113  Bool                    m_prevSliceSkipped;
114  Int                     m_skippedPOC;
115  Bool                    m_bFirstSliceInBitstream;
116  Int                     m_lastPOCNoOutputPriorPics;
117  Bool                    m_isNoOutputPriorPics;
118  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
119#if O0043_BEST_EFFORT_DECODING
120  UInt                    m_forceDecodeBitDepth;
121#endif
122  std::ostream           *m_pDecodedSEIOutputStream;
123
124  Bool                    m_warningMessageSkipPicture;
125
126  std::list<InputNALUnit*> m_prefixSEINALUs; /// Buffered up prefix SEI NAL Units.
127
128#if SVC_EXTENSION
129  Bool                    m_isLastNALWasEos;
130  Bool                    m_lastPicHasEos;
131  static UInt             m_prevPOC;        // POC of the previous slice
132  static UInt             m_uiPrevLayerId;  // LayerId of the previous slice
133  static Bool             m_bFirstSliceInSequence;
134  UInt                    m_layerId;     
135  UInt                    m_numLayer;
136  TDecTop**               m_ppcTDecTop;
137  UInt                    m_smallestLayerId;
138  Bool                    m_pocResettingFlag;
139  Bool                    m_pocDecrementedInDPBFlag;
140#if AVC_BASE
141  fstream*                m_pBLReconFile;
142  TComPic*                m_blPic;
143#endif
144
145  Int                     m_numDirectRefLayers;
146  Int                     m_refLayerId[MAX_VPS_LAYER_IDX_PLUS1];
147  Int                     m_numSamplePredRefLayers;
148  Int                     m_numMotionPredRefLayers;
149
150  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
151  CommonDecoderParams*    m_commonDecoderParams;
152#if NO_CLRAS_OUTPUT_FLAG 
153  Bool                    m_noClrasOutputFlag;
154  Bool                    m_layerInitializedFlag;
155  Bool                    m_firstPicInLayerDecodedFlag;
156#endif
157  Int                     m_parseIdc;
158  Int                     m_lastPocPeriodId;
159  Int                     m_prevPicOrderCnt;
160#if CONFORMANCE_BITSTREAM_MODE
161  Bool                    m_confModeFlag;
162  std::vector<TComPic>    m_confListPic;         //  Dynamic buffer for storing pictures for conformance purposes
163#endif
164  Bool                    m_isOutputLayerFlag;
165  static std::vector<UInt> m_targetDecLayerIdList; // list of layers to be decoded according to the OLS index
166#endif //SVC_EXTENSION
167
168public:
169#if SVC_EXTENSION
170  static Bool             m_checkPocRestrictionsForCurrAu;
171  static Int              m_pocResetIdcOrCurrAu;
172  static Bool             m_baseLayerIdrFlag;
173  static Bool             m_baseLayerPicPresentFlag;
174  static Bool             m_baseLayerIrapFlag;
175  static Bool             m_nonBaseIdrPresentFlag;
176  static Int              m_nonBaseIdrType;
177  static Bool             m_picNonIdrWithRadlPresentFlag;
178  static Bool             m_picNonIdrNoLpPresentFlag;
179  static Int              m_crossLayerPocResetPeriodId;
180  static Int              m_crossLayerPocResetIdc;
181#endif //SVC_EXTENSION
182
183  TDecTop();
184  virtual ~TDecTop();
185
186  Void  create  ();
187  Void  destroy ();
188
189  Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
190
191  Void  init();
192#if SVC_EXTENSION
193  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
194#else
195  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
196#endif
197 
198  Void  deletePicBuffer();
199
200 
201  Void  executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
202  Void  checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic);
203
204  Bool  getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; }
205  Void  setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; }
206  Void  setFirstSliceInPicture (bool val)  { m_bFirstSliceInPicture = val; }
207  Bool  getFirstSliceInSequence ()         { return m_bFirstSliceInSequence; }
208  Void  setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; }
209#if O0043_BEST_EFFORT_DECODING
210  Void  setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; }
211#endif
212  Void  setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; }
213  UInt  getNumberOfChecksumErrorsDetected() const { return m_cGopDecoder.getNumberOfChecksumErrorsDetected(); }
214
215#if SVC_EXTENSION
216  Int       getParseIdc                     ()                              { return m_parseIdc;               }
217  Void      setParseIdc                     (Int x)                         { m_parseIdc = x;                  }
218  Void      markAllPicsAsNoCurrAu           ( const TComVPS *vps );
219
220  Int       getLastPocPeriodId              ()                              { return m_lastPocPeriodId;        }
221  Void      setLastPocPeriodId              (Int x)                         { m_lastPocPeriodId = x;           }
222
223  Int       getPrevPicOrderCnt              ()                              { return m_prevPicOrderCnt;        }
224  Void      setPrevPicOrderCnt              (Int const x)                   { m_prevPicOrderCnt = x;           }
225
226  UInt      getLayerId                      ()                              { return m_layerId;                }
227  Void      setLayerId                      (UInt layer)                    { m_layerId = layer;               }
228  UInt      getNumLayer                     ()                              { return m_numLayer;               }
229  Void      setNumLayer                     (UInt uiNum)                    { m_numLayer = uiNum;              }
230  TComList<TComPic*>*  getListPic           ()                              { return &m_cListPic;              }
231  Void      setLayerDec                     (TDecTop **p)                   { m_ppcTDecTop = p;                }
232  TDecTop*  getLayerDec                     (UInt layerId)                  { return m_ppcTDecTop[layerId];    }
233  Void      xDeriveSmallestLayerId(TComVPS* vps);
234
235  TDecTop*  getRefLayerDec                  (UInt refLayerIdx);
236  Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
237  Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
238
239  Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
240  Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
241
242  Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
243  Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
244
245  Int       getNumMotionPredRefLayers       ()                              { return m_numMotionPredRefLayers;  }
246  Void      setNumMotionPredRefLayers       (Int num)                       { m_numMotionPredRefLayers = num;   }
247
248  Void      setRefLayerParams( const TComVPS* vps );
249
250#if AVC_BASE
251  Void      setBLReconFile( fstream* pFile )                                { m_pBLReconFile = pFile; }
252  fstream*  getBLReconFile()                                                { return m_pBLReconFile;  }
253  Void      setBlPic( TComPic* pic )                                        { m_blPic = pic;          }
254  TComPic*  getBlPic()                                                      { return m_blPic;         }
255#endif
256  Void      xInitILRP(const TComSPS *sps, const TComPPS *pps);
257  CommonDecoderParams*    getCommonDecoderParams()                          { return m_commonDecoderParams; }
258  Void                    setCommonDecoderParams(CommonDecoderParams* x)    { m_commonDecoderParams = x;    }
259  Void      checkValueOfTargetOutputLayerSetIdx(TComVPS *vps);
260
261  ParameterSetManager* getParameterSetManager()                             { return &m_parameterSetManager; }
262
263#if CONFORMANCE_BITSTREAM_MODE
264  std::vector<TComPic>* getConfListPic()                                    { return &m_confListPic; }
265  Bool      getConfModeFlag() const                                         { return m_confModeFlag; }
266  Void      setConfModeFlag(Bool x)                                         { m_confModeFlag = x;    }
267#endif
268#endif //SVC_EXTENSION
269
270protected:
271#if SVC_EXTENSION
272  Void  xGetNewPicBuffer  ( const TComVPS &vps, const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer);
273#else
274  Void  xGetNewPicBuffer  (const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer);
275#endif
276  Void  xCreateLostPicture (Int iLostPOC);
277
278  Void      xActivateParameterSets();
279#if SVC_EXTENSION
280  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
281  Void      xSetRequireResamplingFlag( const TComVPS &vps, const TComSPS &sps, const TComPPS &pps, TComPic* pic );
282#else
283  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
284#endif
285  Void      xDecodeVPS(const std::vector<UChar> &naluData);
286  Void      xDecodeSPS(const std::vector<UChar> &naluData); 
287#if CGS_3D_ASYMLUT
288  Void      xDecodePPS(const std::vector<UChar> &naluData, TCom3DAsymLUT *pc3DAsymLUT);
289#else
290  Void      xDecodePPS(const std::vector<UChar> &naluData);
291#endif
292  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
293  Void      xUpdatePreviousTid0POC( TComSlice *pSlice ) { if ((pSlice->getTLayer()==0) && (pSlice->isReferenceNalu() && (pSlice->getNalUnitType()!=NAL_UNIT_CODED_SLICE_RASL_R)&& (pSlice->getNalUnitType()!=NAL_UNIT_CODED_SLICE_RADL_R))) { m_prevTid0POC=pSlice->getPOC(); } }
294  Void      xParsePrefixSEImessages();
295  Void      xParsePrefixSEIsForUnknownVCLNal();
296
297
298#if SVC_EXTENSION
299#if NO_CLRAS_OUTPUT_FLAG
300  Int       getNoClrasOutputFlag()                { return m_noClrasOutputFlag;}
301  Void      setNoClrasOutputFlag(Bool x)          { m_noClrasOutputFlag = x;   }
302  Int       getLayerInitializedFlag()             { return m_layerInitializedFlag;}
303  Void      setLayerInitializedFlag(Bool x)       { m_layerInitializedFlag = x;   }
304  Int       getFirstPicInLayerDecodedFlag()       { return m_firstPicInLayerDecodedFlag;}
305  Void      setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x;   }
306#endif
307#if CGS_3D_ASYMLUT
308  Void     initAsymLut(TComSlice *pcSlice);
309#endif
310  Void     resetPocRestrictionCheckParameters();
311  Void     xCheckLayerReset();
312  Void     xSetNoRaslOutputFlag();
313  Void     xSetLayerInitializedFlag();
314#endif
315};// END CLASS DEFINITION TDecTop
316
317
318//! \}
319
320#endif // __TDECTOP__
321
Note: See TracBrowser for help on using the repository browser.