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 | |
---|
58 | struct InputNALUnit; |
---|
59 | |
---|
60 | //! \ingroup TLibDecoder |
---|
61 | //! \{ |
---|
62 | |
---|
63 | // ==================================================================================================================== |
---|
64 | // Class definition |
---|
65 | // ==================================================================================================================== |
---|
66 | |
---|
67 | /// decoder class |
---|
68 | class TDecTop |
---|
69 | { |
---|
70 | private: |
---|
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 |
---|
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 | Bool m_bFirstSliceInPicture; |
---|
109 | #if !SVC_EXTENSION |
---|
110 | Bool m_bFirstSliceInSequence; |
---|
111 | #endif |
---|
112 | Bool m_prevSliceSkipped; |
---|
113 | Int m_skippedPOC; |
---|
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 | #if O0043_BEST_EFFORT_DECODING |
---|
119 | UInt m_forceDecodeBitDepth; |
---|
120 | #endif |
---|
121 | std::ostream *m_pDecodedSEIOutputStream; |
---|
122 | |
---|
123 | #if SVC_EXTENSION |
---|
124 | Bool m_isLastNALWasEos; |
---|
125 | Bool m_lastPicHasEos; |
---|
126 | static UInt m_prevPOC; // POC of the previous slice |
---|
127 | static UInt m_uiPrevLayerId; // LayerId of the previous slice |
---|
128 | static Bool m_bFirstSliceInSequence; |
---|
129 | UInt m_layerId; |
---|
130 | UInt m_numLayer; |
---|
131 | TDecTop** m_ppcTDecTop; |
---|
132 | UInt m_smallestLayerId; |
---|
133 | Bool m_pocResettingFlag; |
---|
134 | Bool m_pocDecrementedInDPBFlag; |
---|
135 | #if AVC_BASE |
---|
136 | fstream* m_pBLReconFile; |
---|
137 | #endif |
---|
138 | |
---|
139 | Int m_numDirectRefLayers; |
---|
140 | Int m_refLayerId[MAX_VPS_LAYER_IDX_PLUS1]; |
---|
141 | Int m_numSamplePredRefLayers; |
---|
142 | Int m_numMotionPredRefLayers; |
---|
143 | |
---|
144 | TComPic* m_cIlpPic[MAX_NUM_REF]; ///< Inter layer Prediction picture = upsampled picture |
---|
145 | CommonDecoderParams* m_commonDecoderParams; |
---|
146 | #if NO_CLRAS_OUTPUT_FLAG |
---|
147 | Bool m_noClrasOutputFlag; |
---|
148 | Bool m_layerInitializedFlag; |
---|
149 | Bool m_firstPicInLayerDecodedFlag; |
---|
150 | #endif |
---|
151 | Int m_parseIdc; |
---|
152 | Int m_lastPocPeriodId; |
---|
153 | Int m_prevPicOrderCnt; |
---|
154 | #if CONFORMANCE_BITSTREAM_MODE |
---|
155 | Bool m_confModeFlag; |
---|
156 | std::vector<TComPic> m_confListPic; // Dynamic buffer for storing pictures for conformance purposes |
---|
157 | #endif |
---|
158 | Bool m_isOutputLayerFlag; |
---|
159 | #endif //SVC_EXTENSION |
---|
160 | |
---|
161 | public: |
---|
162 | #if SVC_EXTENSION |
---|
163 | static Bool m_checkPocRestrictionsForCurrAu; |
---|
164 | static Int m_pocResetIdcOrCurrAu; |
---|
165 | static Bool m_baseLayerIdrFlag; |
---|
166 | static Bool m_baseLayerPicPresentFlag; |
---|
167 | static Bool m_baseLayerIrapFlag; |
---|
168 | static Bool m_nonBaseIdrPresentFlag; |
---|
169 | static Int m_nonBaseIdrType; |
---|
170 | static Bool m_picNonIdrWithRadlPresentFlag; |
---|
171 | static Bool m_picNonIdrNoLpPresentFlag; |
---|
172 | static Int m_crossLayerPocResetPeriodId; |
---|
173 | static Int m_crossLayerPocResetIdc; |
---|
174 | #endif //SVC_EXTENSION |
---|
175 | |
---|
176 | TDecTop(); |
---|
177 | virtual ~TDecTop(); |
---|
178 | |
---|
179 | Void create (); |
---|
180 | Void destroy (); |
---|
181 | |
---|
182 | Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
183 | |
---|
184 | Void init(); |
---|
185 | #if SVC_EXTENSION |
---|
186 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
187 | #else |
---|
188 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
189 | #endif |
---|
190 | |
---|
191 | Void deletePicBuffer(); |
---|
192 | |
---|
193 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
194 | Void checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic); |
---|
195 | |
---|
196 | Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; } |
---|
197 | Void setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; } |
---|
198 | Void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; } |
---|
199 | Bool getFirstSliceInSequence () { return m_bFirstSliceInSequence; } |
---|
200 | Void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; } |
---|
201 | #if O0043_BEST_EFFORT_DECODING |
---|
202 | Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; } |
---|
203 | #endif |
---|
204 | Void setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; } |
---|
205 | |
---|
206 | #if SVC_EXTENSION |
---|
207 | Int getParseIdc () { return m_parseIdc; } |
---|
208 | Void setParseIdc (Int x) { m_parseIdc = x; } |
---|
209 | Void markAllPicsAsNoCurrAu ( const TComVPS *vps ); |
---|
210 | |
---|
211 | Int getLastPocPeriodId () { return m_lastPocPeriodId; } |
---|
212 | Void setLastPocPeriodId (Int x) { m_lastPocPeriodId = x; } |
---|
213 | |
---|
214 | Int getPrevPicOrderCnt () { return m_prevPicOrderCnt; } |
---|
215 | Void setPrevPicOrderCnt (Int const x) { m_prevPicOrderCnt = x; } |
---|
216 | |
---|
217 | UInt getLayerId () { return m_layerId; } |
---|
218 | Void setLayerId (UInt layer) { m_layerId = layer; } |
---|
219 | UInt getNumLayer () { return m_numLayer; } |
---|
220 | Void setNumLayer (UInt uiNum) { m_numLayer = uiNum; } |
---|
221 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
222 | Void setLayerDec (TDecTop **p) { m_ppcTDecTop = p; } |
---|
223 | TDecTop* getLayerDec (UInt layerId) { return m_ppcTDecTop[layerId]; } |
---|
224 | Void xDeriveSmallestLayerId(TComVPS* vps); |
---|
225 | |
---|
226 | TDecTop* getRefLayerDec (UInt refLayerIdx); |
---|
227 | Int getNumDirectRefLayers () { return m_numDirectRefLayers; } |
---|
228 | Void setNumDirectRefLayers (Int num) { m_numDirectRefLayers = num; } |
---|
229 | |
---|
230 | Int getRefLayerId (Int i) { return m_refLayerId[i]; } |
---|
231 | Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } |
---|
232 | |
---|
233 | Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; } |
---|
234 | Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; } |
---|
235 | |
---|
236 | Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; } |
---|
237 | Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; } |
---|
238 | |
---|
239 | Void setRefLayerParams( const TComVPS* vps ); |
---|
240 | |
---|
241 | #if AVC_BASE |
---|
242 | Void setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; } |
---|
243 | fstream* getBLReconFile() { return m_pBLReconFile; } |
---|
244 | #endif |
---|
245 | Void xInitILRP(TComSlice *slice); |
---|
246 | CommonDecoderParams* getCommonDecoderParams() { return m_commonDecoderParams; } |
---|
247 | Void setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; } |
---|
248 | Void checkValueOfTargetOutputLayerSetIdx(TComVPS *vps); |
---|
249 | |
---|
250 | ParameterSetManager* getParameterSetManager() { return &m_parameterSetManager; } |
---|
251 | |
---|
252 | #if CONFORMANCE_BITSTREAM_MODE |
---|
253 | std::vector<TComPic>* getConfListPic() {return &m_confListPic; } |
---|
254 | Bool const getConfModeFlag() { return m_confModeFlag; } |
---|
255 | Void setConfModeFlag(Bool x) { m_confModeFlag = x; } |
---|
256 | #endif |
---|
257 | #endif //SVC_EXTENSION |
---|
258 | |
---|
259 | protected: |
---|
260 | #if SVC_EXTENSION |
---|
261 | Void xGetNewPicBuffer ( const TComVPS &vps, const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer); |
---|
262 | #else |
---|
263 | Void xGetNewPicBuffer (const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer); |
---|
264 | #endif |
---|
265 | Void xCreateLostPicture (Int iLostPOC); |
---|
266 | |
---|
267 | Void xActivateParameterSets(); |
---|
268 | #if SVC_EXTENSION |
---|
269 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
270 | Void xSetSpatialEnhLayerFlag( const TComVPS &vps, const TComSPS &sps, const TComPPS &pps, TComPic* pic ); |
---|
271 | #else |
---|
272 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
273 | #endif |
---|
274 | Void xDecodeVPS(const std::vector<UChar> *pNaluData); |
---|
275 | Void xDecodeSPS(const std::vector<UChar> *pNaluData); |
---|
276 | #if CGS_3D_ASYMLUT |
---|
277 | Void xDecodePPS(const std::vector<UChar> *pNaluData, TCom3DAsymLUT *pc3DAsymLUT); |
---|
278 | #else |
---|
279 | Void xDecodePPS(const std::vector<UChar> *pNaluData); |
---|
280 | #endif |
---|
281 | Void xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ); |
---|
282 | |
---|
283 | #if SVC_EXTENSION |
---|
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 CGS_3D_ASYMLUT |
---|
293 | Void initAsymLut(TComSlice *pcSlice); |
---|
294 | #endif |
---|
295 | Void resetPocRestrictionCheckParameters(); |
---|
296 | Void xCheckLayerReset(); |
---|
297 | Void xSetNoRaslOutputFlag(); |
---|
298 | Void xSetLayerInitializedFlag(); |
---|
299 | #endif |
---|
300 | };// END CLASS DEFINITION TDecTop |
---|
301 | |
---|
302 | |
---|
303 | //! \} |
---|
304 | |
---|
305 | #endif // __TDECTOP__ |
---|
306 | |
---|