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

Last change on this file since 930 was 924, checked in by seregin, 11 years ago

in order to generate the metadata related to conformance bitstreams, patch was provided by Ramasubramonian, Adarsh Krishnan <aramasub@…>

  • Property svn:eol-style set to native
File size: 14.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-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#if Q0048_CGS_3D_ASYMLUT
48#include "TLibCommon/TCom3DAsymLUT.h"
49#endif
50
51#include "TDecGop.h"
52#include "TDecEntropy.h"
53#include "TDecSbac.h"
54#include "TDecCAVLC.h"
55#include "SEIread.h"
56
57struct InputNALUnit;
58
59//! \ingroup TLibDecoder
60//! \{
61
62// ====================================================================================================================
63// Class definition
64// ====================================================================================================================
65
66/// decoder class
67class TDecTop
68{
69private:
70  Int                     m_iMaxRefPicNum;
71 
72  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
73  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
74  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
75
76  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
77  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
78  TComSlice*              m_apcSlicePilot;
79
80  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices
81
82  // functional classes
83  TComPrediction          m_cPrediction;
84#if Q0048_CGS_3D_ASYMLUT
85  TCom3DAsymLUT           m_c3DAsymLUTPPS;
86  TComPicYuv*             m_pColorMappedPic;
87#endif
88  TComTrQuant             m_cTrQuant;
89  TDecGop                 m_cGopDecoder;
90  TDecSlice               m_cSliceDecoder;
91  TDecCu                  m_cCuDecoder;
92  TDecEntropy             m_cEntropyDecoder;
93  TDecCavlc               m_cCavlcDecoder;
94  TDecSbac                m_cSbacDecoder;
95  TDecBinCABAC            m_cBinCABAC;
96  SEIReader               m_seiReader;
97  TComLoopFilter          m_cLoopFilter;
98  TComSampleAdaptiveOffset m_cSAO;
99
100  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
101  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
102  TComPic*                m_pcPic;
103  UInt                    m_uiSliceIdx;
104#if !SVC_EXTENSION
105  Int                     m_prevPOC;
106#endif
107  Bool                    m_bFirstSliceInPicture;
108#if !SVC_EXTENSION
109  Bool                    m_bFirstSliceInSequence;
110#endif
111  Bool                    m_prevSliceSkipped;
112  Int                     m_skippedPOC;
113#if SETTING_NO_OUT_PIC_PRIOR 
114  Bool                    m_bFirstSliceInBitstream;
115  Int                     m_lastPOCNoOutputPriorPics;
116  Bool                    m_isNoOutputPriorPics;
117  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
118#endif
119#if Q0177_EOS_CHECKS
120  Bool                    m_isLastNALWasEos;
121#endif
122#if SVC_EXTENSION
123  static UInt             m_prevPOC;        // POC of the previous slice
124  static UInt             m_uiPrevLayerId;  // LayerId of the previous slice
125  static Bool             m_bFirstSliceInSequence;
126  UInt                    m_layerId;     
127  UInt                    m_numLayer;
128  TDecTop**               m_ppcTDecTop;
129#if P0297_VPS_POC_LSB_ALIGNED_FLAG
130  Bool                    m_pocResettingFlag;
131  Bool                    m_pocDecrementedInDPBFlag;
132#endif
133#if AVC_BASE
134  fstream*                m_pBLReconFile;
135#if !REPN_FORMAT_IN_VPS
136  Int                     m_iBLSourceWidth;
137  Int                     m_iBLSourceHeight;
138#endif
139#endif
140#if VPS_EXTN_DIRECT_REF_LAYERS
141  Int                     m_numDirectRefLayers;
142  Int                     m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
143  Int                     m_numSamplePredRefLayers;
144  Int                     m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
145  Int                     m_numMotionPredRefLayers;
146  Int                     m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
147  Bool                    m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
148  Bool                    m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
149#endif
150  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
151#endif
152#if OUTPUT_LAYER_SET_INDEX
153  CommonDecoderParams*    m_commonDecoderParams;
154#endif
155#if NO_CLRAS_OUTPUT_FLAG 
156  Bool                    m_noClrasOutputFlag;
157  Bool                    m_layerInitializedFlag;
158  Bool                    m_firstPicInLayerDecodedFlag;
159#endif
160#if POC_RESET_IDC_DECODER
161  Int                     m_parseIdc;
162  Int                     m_lastPocPeriodId;
163  Int                     m_prevPicOrderCnt;
164#endif
165#if RESOLUTION_BASED_DPB
166  Int                     m_subDpbIdx;     // Index to the sub-DPB that the layer belongs to.
167                                           // When new VPS is activated, this should be re-initialized to -1
168#endif
169#if CONFORMANCE_BITSTREAM_MODE
170  Bool m_confModeFlag;
171  std::vector<TComPic>   m_confListPic;         //  Dynamic buffer for storing pictures for conformance purposes
172#endif
173public:
174#if POC_RESET_RESTRICTIONS
175  static Bool                    m_checkPocRestrictionsForCurrAu;
176  static Int                     m_pocResetIdcOrCurrAu;
177  static Bool                    m_baseLayerIdrFlag;
178  static Bool                    m_baseLayerPicPresentFlag;
179  static Bool                    m_baseLayerIrapFlag;
180  static Bool                    m_nonBaseIdrPresentFlag;
181  static Int                     m_nonBaseIdrType;
182  static Bool                    m_picNonIdrWithRadlPresentFlag;
183  static Bool                    m_picNonIdrNoLpPresentFlag;
184#endif
185#if POC_RESET_VALUE_RESTRICTION
186  static Int                     m_crossLayerPocResetPeriodId;
187  static Int                     m_crossLayerPocResetIdc;
188#endif
189
190  TDecTop();
191  virtual ~TDecTop();
192 
193  Void  create  ();
194  Void  destroy ();
195
196  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
197#if Q0074_COLOUR_REMAPPING_SEI
198  void setColourRemappingInfoSEIEnabled(Bool enabled)  { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); }
199#endif
200
201  Void  init();
202#if SVC_EXTENSION
203  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
204#else
205  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
206#endif
207 
208  Void  deletePicBuffer();
209
210 
211  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); }
212
213
214  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
215#if SETTING_NO_OUT_PIC_PRIOR 
216  Void  checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic);
217  Bool  getNoOutputPriorPicsFlag ()         { return m_isNoOutputPriorPics; }
218  Void  setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; }
219#endif
220
221#if SVC_EXTENSION
222#if EARLY_REF_PIC_MARKING
223  Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList);
224#endif
225#if POC_RESET_IDC_DECODER
226  Int getParseIdc() { return m_parseIdc;}
227  Void        setParseIdc(Int x) { m_parseIdc = x;}
228  Void        markAllPicsAsNoCurrAu();
229
230  Int   getLastPocPeriodId() { return m_lastPocPeriodId; }
231  Void  setLastPocPeriodId(Int x)    { m_lastPocPeriodId = x; }
232
233  Int   getPrevPicOrderCnt() { return m_prevPicOrderCnt; }
234  Void  setPrevPicOrderCnt(Int const x) { m_prevPicOrderCnt = x; }
235#endif
236  UInt      getLayerId            () { return m_layerId;              }
237  Void      setLayerId            (UInt layer) { m_layerId = layer; }
238  UInt      getNumLayer           () { return m_numLayer;             }
239  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
240  TComList<TComPic*>*      getListPic() { return &m_cListPic; }
241  Void      setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
242  TDecTop*  getLayerDec(UInt layer)     { return m_ppcTDecTop[layer]; }
243#if VPS_EXTN_DIRECT_REF_LAYERS
244  TDecTop*  getRefLayerDec(UInt refLayerIdc);
245  Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
246  Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
247
248  Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
249  Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
250
251  Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
252  Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
253
254  Int       getSamplePredRefLayerId         (Int i)                         { return m_samplePredRefLayerId[i];       }
255  Void      setSamplePredRefLayerId         (Int i, Int refLayerId)         { m_samplePredRefLayerId[i] = refLayerId; }
256
257  Int       getNumMotionPredRefLayers       ()                              { return m_numMotionPredRefLayers;  }
258  Void      setNumMotionPredRefLayers       (Int num)                       { m_numMotionPredRefLayers = num;   }
259
260  Int       getMotionPredRefLayerId         (Int i)                         { return m_motionPredRefLayerId[i];       }
261  Void      setMotionPredRefLayerId         (Int i, Int refLayerId)         { m_motionPredRefLayerId[i] = refLayerId; }
262
263  Bool      getSamplePredEnabledFlag        (Int i)                         { return m_samplePredEnabledFlag[i];  }
264  Void      setSamplePredEnabledFlag        (Int i,Bool flag)               { m_samplePredEnabledFlag[i] = flag;  }
265
266  Bool      getMotionPredEnabledFlag        (Int i)                         { return m_motionPredEnabledFlag[i];  }
267  Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
268
269  TDecTop*  getSamplePredRefLayerDec        ( UInt layerId );
270  TDecTop*  getMotionPredRefLayerDec        ( UInt layerId );
271
272  Void      setRefLayerParams( TComVPS* vps );
273#endif
274#if AVC_BASE
275  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
276  fstream*  getBLReconFile() { return m_pBLReconFile; }
277#if !REPN_FORMAT_IN_VPS
278  Void      setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; }
279  Int       getBLWidth() { return  m_iBLSourceWidth; }
280  Int       getBLHeight() { return  m_iBLSourceHeight; }
281#endif
282#endif
283#if REPN_FORMAT_IN_VPS
284  Void      xInitILRP(TComSlice *slice);
285#else
286  Void      xInitILRP(TComSPS *pcSPS);
287#endif
288#if OUTPUT_LAYER_SET_INDEX
289  CommonDecoderParams*    getCommonDecoderParams() { return m_commonDecoderParams; }
290  Void                    setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }
291  Void      checkValueOfTargetOutputLayerSetIdx(TComVPS *vps);
292#endif
293#if SCALINGLIST_INFERRING
294  ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; }
295#endif
296#if RESOLUTION_BASED_DPB
297  Void setSubDpbIdx(Int idx)    { m_subDpbIdx = idx; }
298  Int  getSubDpbIdx()           { return m_subDpbIdx; }
299  Void assignSubDpbs(TComVPS *vps);
300#endif
301#if CONFORMANCE_BITSTREAM_MODE
302  std::vector<TComPic>* getConfListPic() {return &m_confListPic; }
303  // std::string const getDecodedYuvLayerFileName(Int layerId) { return m_decodedYuvLayerFileName[layerId]; }
304#endif
305#endif //SVC_EXTENSION
306
307protected:
308  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
309  Void  xCreateLostPicture (Int iLostPOC);
310
311  Void      xActivateParameterSets();
312#if SVC_EXTENSION
313#if POC_RESET_FLAG
314  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
315#else
316  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
317#endif
318#else
319  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
320#endif
321  Void      xDecodeVPS();
322  Void      xDecodeSPS();
323  Void      xDecodePPS(
324#if Q0048_CGS_3D_ASYMLUT
325    TCom3DAsymLUT * pc3DAsymLUT
326#endif
327    );
328  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
329
330#if NO_CLRAS_OUTPUT_FLAG
331  Int  getNoClrasOutputFlag()                { return m_noClrasOutputFlag;}
332  Void setNoClrasOutputFlag(Bool x)          { m_noClrasOutputFlag = x;   }
333  Int  getLayerInitializedFlag()             { return m_layerInitializedFlag;}
334  Void setLayerInitializedFlag(Bool x)       { m_layerInitializedFlag = x;   }
335  Int  getFirstPicInLayerDecodedFlag()       { return m_firstPicInLayerDecodedFlag;}
336  Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x;   }
337#endif
338#if Q0048_CGS_3D_ASYMLUT
339  Void initAsymLut(TComSlice *pcSlice);
340#endif
341#if POC_RESET_RESTRICTIONS
342  Void resetPocRestrictionCheckParameters();
343#endif
344  public:
345#if CONFORMANCE_BITSTREAM_MODE
346  Bool const getConfModeFlag() { return m_confModeFlag; }
347  Void setConfModeFlag(Bool x) { m_confModeFlag = x; }
348#endif
349};// END CLASS DEFINITION TDecTop
350
351
352
353//! \}
354
355#endif // __TDECTOP__
356
Note: See TracBrowser for help on using the repository browser.