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

Last change on this file since 569 was 532, checked in by seregin, 11 years ago

update to HM-12.1 base

  • 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-2013, 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/// decoder class
64class TDecTop
65{
66private:
67  Int                     m_iMaxRefPicNum;
68 
69  NalUnitType             m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture
70  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
71  Int                     m_pocRandomAccess;   ///< POC number of the random access point (the first IDR or CRA picture)
72
73  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
74  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
75  TComSlice*              m_apcSlicePilot;
76
77  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices
78
79  // functional classes
80  TComPrediction          m_cPrediction;
81  TComTrQuant             m_cTrQuant;
82  TDecGop                 m_cGopDecoder;
83  TDecSlice               m_cSliceDecoder;
84  TDecCu                  m_cCuDecoder;
85  TDecEntropy             m_cEntropyDecoder;
86  TDecCavlc               m_cCavlcDecoder;
87  TDecSbac                m_cSbacDecoder;
88  TDecBinCABAC            m_cBinCABAC;
89  SEIReader               m_seiReader;
90  TComLoopFilter          m_cLoopFilter;
91  TComSampleAdaptiveOffset m_cSAO;
92
93  Bool isSkipPictureForBLA(Int& iPOCLastDisplay);
94  Bool isRandomAccessSkipPicture(Int& iSkipFrame,  Int& iPOCLastDisplay);
95  TComPic*                m_pcPic;
96  UInt                    m_uiSliceIdx;
97#if !SVC_EXTENSION
98  Int                     m_prevPOC;
99#endif
100  Bool                    m_bFirstSliceInPicture;
101#if !SVC_EXTENSION
102  Bool                    m_bFirstSliceInSequence;
103#endif
104  Bool                    m_prevSliceSkipped;
105  Int                     m_skippedPOC;
106
107#if SVC_EXTENSION
108  static UInt             m_prevPOC;        // POC of the previous slice
109  static UInt             m_uiPrevLayerId;  // LayerId of the previous slice
110  static Bool             m_bFirstSliceInSequence;
111  UInt                    m_layerId;     
112  UInt                    m_numLayer;
113  TDecTop**               m_ppcTDecTop;
114#if AVC_BASE
115  fstream*                m_pBLReconFile;
116  Int                     m_iBLSourceWidth;
117  Int                     m_iBLSourceHeight; 
118#endif
119#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
120  Int                     m_numDirectRefLayers;
121  Int                     m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
122  Int                     m_numSamplePredRefLayers;
123  Int                     m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
124  Int                     m_numMotionPredRefLayers;
125  Int                     m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
126  Bool                    m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
127  Bool                    m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
128#endif
129  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
130#endif
131#if OUTPUT_LAYER_SET_INDEX
132  CommonDecoderParams*    m_commonDecoderParams;
133#endif
134#if AVC_SYNTAX || SYNTAX_OUTPUT
135  fstream*               m_pBLSyntaxFile;
136#endif
137
138#if NO_CLRAS_OUTPUT_FLAG
139  Bool                    m_noClrasOutputFlag;
140  Bool                    m_layerInitializedFlag;
141  Bool                    m_firstPicInLayerDecodedFlag;
142  Bool                    m_noOutputOfPriorPicsFlags;
143
144  Bool                   m_bRefreshPending;
145#endif
146
147public:
148  TDecTop();
149  virtual ~TDecTop();
150 
151  Void  create  ();
152  Void  destroy ();
153
154  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
155
156  Void  init();
157#if SVC_EXTENSION
158  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
159#else
160  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay);
161#endif
162 
163  Void  deletePicBuffer();
164
165  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
166#if SVC_EXTENSION
167#if EARLY_REF_PIC_MARKING
168  Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList);
169#endif
170  UInt      getLayerId            () { return m_layerId;              }
171  Void      setLayerId            (UInt layer) { m_layerId = layer; }
172  UInt      getNumLayer           () { return m_numLayer;             }
173  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
174  TComList<TComPic*>*      getListPic() { return &m_cListPic; }
175  Void      setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
176  TDecTop*  getLayerDec(UInt layer)     { return m_ppcTDecTop[layer]; }
177#if VPS_EXTN_DIRECT_REF_LAYERS
178  TDecTop*  getRefLayerDec(UInt refLayerIdc);
179#if M0457_PREDICTION_INDICATIONS
180  Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
181  Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
182
183  Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
184  Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
185
186  Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
187  Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
188
189  Int       getSamplePredRefLayerId         (Int i)                         { return m_samplePredRefLayerId[i];       }
190  Void      setSamplePredRefLayerId         (Int i, Int refLayerId)         { m_samplePredRefLayerId[i] = refLayerId; }
191
192  Int       getNumMotionPredRefLayers       ()                              { return m_numMotionPredRefLayers;  }
193  Void      setNumMotionPredRefLayers       (Int num)                       { m_numMotionPredRefLayers = num;   }
194
195  Int       getMotionPredRefLayerId         (Int i)                         { return m_motionPredRefLayerId[i];       }
196  Void      setMotionPredRefLayerId         (Int i, Int refLayerId)         { m_motionPredRefLayerId[i] = refLayerId; }
197
198  Bool      getSamplePredEnabledFlag        (Int i)                         { return m_samplePredEnabledFlag[i];  }
199  Void      setSamplePredEnabledFlag        (Int i,Bool flag)               { m_samplePredEnabledFlag[i] = flag;  }
200
201  Bool      getMotionPredEnabledFlag        (Int i)                         { return m_motionPredEnabledFlag[i];  }
202  Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
203
204  TDecTop*  getSamplePredRefLayerDec        ( UInt layerId );
205  TDecTop*  getMotionPredRefLayerDec        ( UInt layerId );
206
207  Void      setRefLayerParams( TComVPS* vps );
208#endif
209#endif
210#if AVC_BASE
211  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
212  fstream*  getBLReconFile() { return m_pBLReconFile; }
213  Void      setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; }
214  Int       getBLWidth() { return  m_iBLSourceWidth; }
215  Int       getBLHeight() { return  m_iBLSourceHeight; }
216#endif
217#if REPN_FORMAT_IN_VPS
218  Void      xInitILRP(TComSlice *slice);
219#else
220  Void      xInitILRP(TComSPS *pcSPS);
221#endif
222#endif
223#if AVC_SYNTAX || SYNTAX_OUTPUT
224  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
225  fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
226#endif
227
228protected:
229  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
230  Void  xCreateLostPicture (Int iLostPOC);
231
232  Void      xActivateParameterSets();
233#if SVC_EXTENSION
234#if POC_RESET_FLAG
235  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
236#else
237  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC);
238#endif
239#else
240  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
241#endif
242  Void      xDecodeVPS();
243  Void      xDecodeSPS();
244  Void      xDecodePPS();
245  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
246#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
247  TComPic*  getMotionPredIlp(TComSlice* pcSlice);
248#endif
249
250#if NO_CLRAS_OUTPUT_FLAG
251  Int  getNoClrasOutputFlag()                { return m_noClrasOutputFlag;}
252  Void setNoClrasOutputFlag(Bool x)          { m_noClrasOutputFlag = x;   }
253  Int  getLayerInitializedFlag()             { return m_layerInitializedFlag;}
254  Void setLayerInitializedFlag(Bool x)       { m_layerInitializedFlag = x;   }
255  Int  getFirstPicInLayerDecodedFlag()       { return m_firstPicInLayerDecodedFlag;}
256  Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x;   }
257  Int  getNoOutputOfPriorPicsFlags()         { return m_noOutputOfPriorPicsFlags;}
258  Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
259#endif
260public:
261#if OUTPUT_LAYER_SET_INDEX
262  CommonDecoderParams*    getCommonDecoderParams() { return m_commonDecoderParams; }
263  Void                    setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }
264  Void      checkValueOfOutputLayerSetIdx(TComVPS *vps);
265#endif
266#if SCALINGLIST_INFERRING
267  ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; }
268#endif
269};// END CLASS DEFINITION TDecTop
270
271
272//! \}
273
274#endif // __TDECTOP__
275
Note: See TracBrowser for help on using the repository browser.