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

Last change on this file since 693 was 677, checked in by qualcomm, 11 years ago

Integration of JCTVC-Q0048 Asymmetric 3D LUT based CGS

  • Property svn:eol-style set to native
File size: 12.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
120#if SVC_EXTENSION
121  static UInt             m_prevPOC;        // POC of the previous slice
122  static UInt             m_uiPrevLayerId;  // LayerId of the previous slice
123  static Bool             m_bFirstSliceInSequence;
124  UInt                    m_layerId;     
125  UInt                    m_numLayer;
126  TDecTop**               m_ppcTDecTop;
127#if AVC_BASE
128  fstream*                m_pBLReconFile;
129  Int                     m_iBLSourceWidth;
130  Int                     m_iBLSourceHeight; 
131#endif
132#if VPS_EXTN_DIRECT_REF_LAYERS
133  Int                     m_numDirectRefLayers;
134  Int                     m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
135  Int                     m_numSamplePredRefLayers;
136  Int                     m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
137  Int                     m_numMotionPredRefLayers;
138  Int                     m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
139  Bool                    m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
140  Bool                    m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
141#endif
142  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
143#endif
144#if OUTPUT_LAYER_SET_INDEX
145  CommonDecoderParams*    m_commonDecoderParams;
146#endif
147#if AVC_SYNTAX || SYNTAX_OUTPUT
148  fstream*               m_pBLSyntaxFile;
149#endif
150
151#if NO_CLRAS_OUTPUT_FLAG 
152  Bool                    m_noClrasOutputFlag;
153  Bool                    m_layerInitializedFlag;
154  Bool                    m_firstPicInLayerDecodedFlag;
155#endif
156#if RESOLUTION_BASED_DPB
157  Int                     m_subDpbIdx;     // Index to the sub-DPB that the layer belongs to.
158                                           // When new VPS is activated, this should be re-initialized to -1
159#endif
160public:
161  TDecTop();
162  virtual ~TDecTop();
163 
164  Void  create  ();
165  Void  destroy ();
166
167  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
168
169  Void  init();
170#if SVC_EXTENSION
171  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
172#else
173  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
174#endif
175 
176  Void  deletePicBuffer();
177
178 
179  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); }
180
181
182  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
183#if SETTING_NO_OUT_PIC_PRIOR 
184  Void  checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic);
185  Bool  getNoOutputPriorPicsFlag ()         { return m_isNoOutputPriorPics; }
186  Void  setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; }
187#endif
188
189#if SVC_EXTENSION
190#if EARLY_REF_PIC_MARKING
191  Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList);
192#endif
193  UInt      getLayerId            () { return m_layerId;              }
194  Void      setLayerId            (UInt layer) { m_layerId = layer; }
195  UInt      getNumLayer           () { return m_numLayer;             }
196  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
197  TComList<TComPic*>*      getListPic() { return &m_cListPic; }
198  Void      setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
199  TDecTop*  getLayerDec(UInt layer)     { return m_ppcTDecTop[layer]; }
200#if VPS_EXTN_DIRECT_REF_LAYERS
201  TDecTop*  getRefLayerDec(UInt refLayerIdc);
202  Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
203  Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
204
205  Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
206  Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
207
208  Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
209  Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
210
211  Int       getSamplePredRefLayerId         (Int i)                         { return m_samplePredRefLayerId[i];       }
212  Void      setSamplePredRefLayerId         (Int i, Int refLayerId)         { m_samplePredRefLayerId[i] = refLayerId; }
213
214  Int       getNumMotionPredRefLayers       ()                              { return m_numMotionPredRefLayers;  }
215  Void      setNumMotionPredRefLayers       (Int num)                       { m_numMotionPredRefLayers = num;   }
216
217  Int       getMotionPredRefLayerId         (Int i)                         { return m_motionPredRefLayerId[i];       }
218  Void      setMotionPredRefLayerId         (Int i, Int refLayerId)         { m_motionPredRefLayerId[i] = refLayerId; }
219
220  Bool      getSamplePredEnabledFlag        (Int i)                         { return m_samplePredEnabledFlag[i];  }
221  Void      setSamplePredEnabledFlag        (Int i,Bool flag)               { m_samplePredEnabledFlag[i] = flag;  }
222
223  Bool      getMotionPredEnabledFlag        (Int i)                         { return m_motionPredEnabledFlag[i];  }
224  Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
225
226  TDecTop*  getSamplePredRefLayerDec        ( UInt layerId );
227  TDecTop*  getMotionPredRefLayerDec        ( UInt layerId );
228
229  Void      setRefLayerParams( TComVPS* vps );
230#endif
231#if AVC_BASE
232  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
233  fstream*  getBLReconFile() { return m_pBLReconFile; }
234  Void      setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; }
235  Int       getBLWidth() { return  m_iBLSourceWidth; }
236  Int       getBLHeight() { return  m_iBLSourceHeight; }
237#endif
238#if REPN_FORMAT_IN_VPS
239  Void      xInitILRP(TComSlice *slice);
240#else
241  Void      xInitILRP(TComSPS *pcSPS);
242#endif
243#if OUTPUT_LAYER_SET_INDEX
244  CommonDecoderParams*    getCommonDecoderParams() { return m_commonDecoderParams; }
245  Void                    setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }
246  Void      checkValueOfTargetOutputLayerSetIdx(TComVPS *vps);
247#endif
248#if SCALINGLIST_INFERRING
249  ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; }
250#endif
251#if RESOLUTION_BASED_DPB
252  Void setSubDpbIdx(Int idx)    { m_subDpbIdx = idx; }
253  Int  getSubDpbIdx()           { return m_subDpbIdx; }
254  Void assignSubDpbs(TComVPS *vps);
255#endif
256#endif //SVC_EXTENSION
257#if AVC_SYNTAX || SYNTAX_OUTPUT
258  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
259  fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
260#endif
261protected:
262  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
263  Void  xCreateLostPicture (Int iLostPOC);
264
265  Void      xActivateParameterSets();
266#if SVC_EXTENSION
267#if POC_RESET_FLAG
268  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
269#else
270  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
271#endif
272#else
273  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
274#endif
275  Void      xDecodeVPS();
276  Void      xDecodeSPS();
277  Void      xDecodePPS(
278#if Q0048_CGS_3D_ASYMLUT
279    TCom3DAsymLUT * pc3DAsymLUT
280#endif
281    );
282  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
283
284#if NO_CLRAS_OUTPUT_FLAG
285  Int  getNoClrasOutputFlag()                { return m_noClrasOutputFlag;}
286  Void setNoClrasOutputFlag(Bool x)          { m_noClrasOutputFlag = x;   }
287  Int  getLayerInitializedFlag()             { return m_layerInitializedFlag;}
288  Void setLayerInitializedFlag(Bool x)       { m_layerInitializedFlag = x;   }
289  Int  getFirstPicInLayerDecodedFlag()       { return m_firstPicInLayerDecodedFlag;}
290  Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x;   }
291#endif
292#if Q0048_CGS_3D_ASYMLUT
293  Void initAsymLut(TComSlice *pcSlice);
294#endif
295};// END CLASS DEFINITION TDecTop
296
297
298//! \}
299
300#endif // __TDECTOP__
301
Note: See TracBrowser for help on using the repository browser.