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 | |
---|
57 | struct InputNALUnit; |
---|
58 | |
---|
59 | //! \ingroup TLibDecoder |
---|
60 | //! \{ |
---|
61 | |
---|
62 | // ==================================================================================================================== |
---|
63 | // Class definition |
---|
64 | // ==================================================================================================================== |
---|
65 | |
---|
66 | /// decoder class |
---|
67 | class TDecTop |
---|
68 | { |
---|
69 | private: |
---|
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 | Bool m_bFirstSliceInBitstream; |
---|
114 | Int m_lastPOCNoOutputPriorPics; |
---|
115 | Bool m_isNoOutputPriorPics; |
---|
116 | Bool m_craNoRaslOutputFlag; //value of variable NoRaslOutputFlag of the last CRA pic |
---|
117 | #if O0043_BEST_EFFORT_DECODING |
---|
118 | UInt m_forceDecodeBitDepth; |
---|
119 | #endif |
---|
120 | std::ostream *m_pDecodedSEIOutputStream; |
---|
121 | |
---|
122 | #if SVC_EXTENSION |
---|
123 | #if Q0177_EOS_CHECKS |
---|
124 | Bool m_isLastNALWasEos; |
---|
125 | #endif |
---|
126 | #if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS |
---|
127 | Bool m_lastPicHasEos; |
---|
128 | #endif |
---|
129 | static UInt m_prevPOC; // POC of the previous slice |
---|
130 | static UInt m_uiPrevLayerId; // LayerId of the previous slice |
---|
131 | static Bool m_bFirstSliceInSequence; |
---|
132 | UInt m_layerId; |
---|
133 | UInt m_numLayer; |
---|
134 | TDecTop** m_ppcTDecTop; |
---|
135 | #if R0235_SMALLEST_LAYER_ID |
---|
136 | UInt m_smallestLayerId; |
---|
137 | #endif |
---|
138 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
139 | Bool m_pocResettingFlag; |
---|
140 | Bool m_pocDecrementedInDPBFlag; |
---|
141 | #endif |
---|
142 | #if AVC_BASE |
---|
143 | fstream* m_pBLReconFile; |
---|
144 | #if !REPN_FORMAT_IN_VPS |
---|
145 | Int m_iBLSourceWidth; |
---|
146 | Int m_iBLSourceHeight; |
---|
147 | #endif |
---|
148 | #endif |
---|
149 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
150 | Int m_numDirectRefLayers; |
---|
151 | Int m_refLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
152 | Int m_numSamplePredRefLayers; |
---|
153 | Int m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
154 | Int m_numMotionPredRefLayers; |
---|
155 | Int m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
156 | Bool m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; |
---|
157 | Bool m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; |
---|
158 | #endif |
---|
159 | TComPic* m_cIlpPic[MAX_NUM_REF]; ///< Inter layer Prediction picture = upsampled picture |
---|
160 | #endif |
---|
161 | #if OUTPUT_LAYER_SET_INDEX |
---|
162 | CommonDecoderParams* m_commonDecoderParams; |
---|
163 | #endif |
---|
164 | #if NO_CLRAS_OUTPUT_FLAG |
---|
165 | Bool m_noClrasOutputFlag; |
---|
166 | Bool m_layerInitializedFlag; |
---|
167 | Bool m_firstPicInLayerDecodedFlag; |
---|
168 | #endif |
---|
169 | #if POC_RESET_IDC_DECODER |
---|
170 | Int m_parseIdc; |
---|
171 | Int m_lastPocPeriodId; |
---|
172 | Int m_prevPicOrderCnt; |
---|
173 | #endif |
---|
174 | #if RESOLUTION_BASED_DPB |
---|
175 | Int m_subDpbIdx; // Index to the sub-DPB that the layer belongs to. |
---|
176 | // When new VPS is activated, this should be re-initialized to -1 |
---|
177 | #endif |
---|
178 | #if CONFORMANCE_BITSTREAM_MODE |
---|
179 | Bool m_confModeFlag; |
---|
180 | std::vector<TComPic> m_confListPic; // Dynamic buffer for storing pictures for conformance purposes |
---|
181 | #endif |
---|
182 | #if FIX_NON_OUTPUT_LAYER |
---|
183 | Bool m_isOutputLayerFlag; |
---|
184 | #endif |
---|
185 | public: |
---|
186 | #if POC_RESET_RESTRICTIONS |
---|
187 | static Bool m_checkPocRestrictionsForCurrAu; |
---|
188 | static Int m_pocResetIdcOrCurrAu; |
---|
189 | static Bool m_baseLayerIdrFlag; |
---|
190 | static Bool m_baseLayerPicPresentFlag; |
---|
191 | static Bool m_baseLayerIrapFlag; |
---|
192 | static Bool m_nonBaseIdrPresentFlag; |
---|
193 | static Int m_nonBaseIdrType; |
---|
194 | static Bool m_picNonIdrWithRadlPresentFlag; |
---|
195 | static Bool m_picNonIdrNoLpPresentFlag; |
---|
196 | #endif |
---|
197 | #if POC_RESET_VALUE_RESTRICTION |
---|
198 | static Int m_crossLayerPocResetPeriodId; |
---|
199 | static Int m_crossLayerPocResetIdc; |
---|
200 | #endif |
---|
201 | |
---|
202 | TDecTop(); |
---|
203 | virtual ~TDecTop(); |
---|
204 | |
---|
205 | Void create (); |
---|
206 | Void destroy (); |
---|
207 | |
---|
208 | Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
209 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
210 | void setColourRemappingInfoSEIEnabled(Bool enabled) { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); } |
---|
211 | #endif |
---|
212 | |
---|
213 | Void init(); |
---|
214 | #if SVC_EXTENSION |
---|
215 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
216 | #else |
---|
217 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
218 | #endif |
---|
219 | |
---|
220 | Void deletePicBuffer(); |
---|
221 | |
---|
222 | |
---|
223 | TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); } |
---|
224 | |
---|
225 | |
---|
226 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
227 | Void checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic); |
---|
228 | |
---|
229 | Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; } |
---|
230 | Void setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; } |
---|
231 | Void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; } |
---|
232 | Bool getFirstSliceInSequence () { return m_bFirstSliceInSequence; } |
---|
233 | Void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; } |
---|
234 | #if O0043_BEST_EFFORT_DECODING |
---|
235 | Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; } |
---|
236 | #endif |
---|
237 | Void setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; } |
---|
238 | |
---|
239 | #if SVC_EXTENSION |
---|
240 | #if EARLY_REF_PIC_MARKING |
---|
241 | Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList); |
---|
242 | #endif |
---|
243 | #if POC_RESET_IDC_DECODER |
---|
244 | Int getParseIdc() { return m_parseIdc;} |
---|
245 | Void setParseIdc(Int x) { m_parseIdc = x;} |
---|
246 | Void markAllPicsAsNoCurrAu(); |
---|
247 | |
---|
248 | Int getLastPocPeriodId() { return m_lastPocPeriodId; } |
---|
249 | Void setLastPocPeriodId(Int x) { m_lastPocPeriodId = x; } |
---|
250 | |
---|
251 | Int getPrevPicOrderCnt() { return m_prevPicOrderCnt; } |
---|
252 | Void setPrevPicOrderCnt(Int const x) { m_prevPicOrderCnt = x; } |
---|
253 | #endif |
---|
254 | UInt getLayerId () { return m_layerId; } |
---|
255 | Void setLayerId (UInt layer) { m_layerId = layer; } |
---|
256 | UInt getNumLayer () { return m_numLayer; } |
---|
257 | Void setNumLayer (UInt uiNum) { m_numLayer = uiNum; } |
---|
258 | TComList<TComPic*>* getListPic() { return &m_cListPic; } |
---|
259 | Void setLayerDec(TDecTop **p) { m_ppcTDecTop = p; } |
---|
260 | TDecTop* getLayerDec(UInt layer) { return m_ppcTDecTop[layer]; } |
---|
261 | #if R0235_SMALLEST_LAYER_ID |
---|
262 | Void xDeriveSmallestLayerId(TComVPS* vps); |
---|
263 | #endif |
---|
264 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
265 | TDecTop* getRefLayerDec(UInt refLayerIdc); |
---|
266 | Int getNumDirectRefLayers () { return m_numDirectRefLayers; } |
---|
267 | Void setNumDirectRefLayers (Int num) { m_numDirectRefLayers = num; } |
---|
268 | |
---|
269 | Int getRefLayerId (Int i) { return m_refLayerId[i]; } |
---|
270 | Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } |
---|
271 | |
---|
272 | Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; } |
---|
273 | Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; } |
---|
274 | |
---|
275 | Int getSamplePredRefLayerId (Int i) { return m_samplePredRefLayerId[i]; } |
---|
276 | Void setSamplePredRefLayerId (Int i, Int refLayerId) { m_samplePredRefLayerId[i] = refLayerId; } |
---|
277 | |
---|
278 | Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; } |
---|
279 | Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; } |
---|
280 | |
---|
281 | Int getMotionPredRefLayerId (Int i) { return m_motionPredRefLayerId[i]; } |
---|
282 | Void setMotionPredRefLayerId (Int i, Int refLayerId) { m_motionPredRefLayerId[i] = refLayerId; } |
---|
283 | |
---|
284 | Bool getSamplePredEnabledFlag (Int i) { return m_samplePredEnabledFlag[i]; } |
---|
285 | Void setSamplePredEnabledFlag (Int i,Bool flag) { m_samplePredEnabledFlag[i] = flag; } |
---|
286 | |
---|
287 | Bool getMotionPredEnabledFlag (Int i) { return m_motionPredEnabledFlag[i]; } |
---|
288 | Void setMotionPredEnabledFlag (Int i,Bool flag) { m_motionPredEnabledFlag[i] = flag; } |
---|
289 | |
---|
290 | TDecTop* getSamplePredRefLayerDec ( UInt layerId ); |
---|
291 | TDecTop* getMotionPredRefLayerDec ( UInt layerId ); |
---|
292 | |
---|
293 | Void setRefLayerParams( TComVPS* vps ); |
---|
294 | #endif |
---|
295 | #if AVC_BASE |
---|
296 | Void setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; } |
---|
297 | fstream* getBLReconFile() { return m_pBLReconFile; } |
---|
298 | #if !REPN_FORMAT_IN_VPS |
---|
299 | Void setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; } |
---|
300 | Int getBLWidth() { return m_iBLSourceWidth; } |
---|
301 | Int getBLHeight() { return m_iBLSourceHeight; } |
---|
302 | #endif |
---|
303 | #endif |
---|
304 | #if REPN_FORMAT_IN_VPS |
---|
305 | Void xInitILRP(TComSlice *slice); |
---|
306 | #else |
---|
307 | Void xInitILRP(TComSPS *pcSPS); |
---|
308 | #endif |
---|
309 | #if OUTPUT_LAYER_SET_INDEX |
---|
310 | CommonDecoderParams* getCommonDecoderParams() { return m_commonDecoderParams; } |
---|
311 | Void setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; } |
---|
312 | Void checkValueOfTargetOutputLayerSetIdx(TComVPS *vps); |
---|
313 | #endif |
---|
314 | #if SCALINGLIST_INFERRING |
---|
315 | ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; } |
---|
316 | #endif |
---|
317 | #if RESOLUTION_BASED_DPB |
---|
318 | Void setSubDpbIdx(Int idx) { m_subDpbIdx = idx; } |
---|
319 | Int getSubDpbIdx() { return m_subDpbIdx; } |
---|
320 | Void assignSubDpbs(TComVPS *vps); |
---|
321 | #endif |
---|
322 | #if CONFORMANCE_BITSTREAM_MODE |
---|
323 | std::vector<TComPic>* getConfListPic() {return &m_confListPic; } |
---|
324 | // std::string const getDecodedYuvLayerFileName(Int layerId) { return m_decodedYuvLayerFileName[layerId]; } |
---|
325 | Bool const getConfModeFlag() { return m_confModeFlag; } |
---|
326 | Void setConfModeFlag(Bool x) { m_confModeFlag = x; } |
---|
327 | #endif |
---|
328 | #endif //SVC_EXTENSION |
---|
329 | |
---|
330 | protected: |
---|
331 | Void xGetNewPicBuffer (TComSlice* pcSlice, TComPic*& rpcPic); |
---|
332 | Void xCreateLostPicture (Int iLostPOC); |
---|
333 | |
---|
334 | Void xActivateParameterSets(); |
---|
335 | #if SVC_EXTENSION |
---|
336 | #if POC_RESET_FLAG |
---|
337 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
338 | #else |
---|
339 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
340 | #endif |
---|
341 | #else |
---|
342 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
343 | #endif |
---|
344 | Void xDecodeVPS(); |
---|
345 | Void xDecodeSPS(); |
---|
346 | Void xDecodePPS( |
---|
347 | #if Q0048_CGS_3D_ASYMLUT |
---|
348 | TCom3DAsymLUT * pc3DAsymLUT |
---|
349 | #endif |
---|
350 | ); |
---|
351 | Void xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ); |
---|
352 | |
---|
353 | #if NO_CLRAS_OUTPUT_FLAG |
---|
354 | Int getNoClrasOutputFlag() { return m_noClrasOutputFlag;} |
---|
355 | Void setNoClrasOutputFlag(Bool x) { m_noClrasOutputFlag = x; } |
---|
356 | Int getLayerInitializedFlag() { return m_layerInitializedFlag;} |
---|
357 | Void setLayerInitializedFlag(Bool x) { m_layerInitializedFlag = x; } |
---|
358 | Int getFirstPicInLayerDecodedFlag() { return m_firstPicInLayerDecodedFlag;} |
---|
359 | Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x; } |
---|
360 | #endif |
---|
361 | #if Q0048_CGS_3D_ASYMLUT |
---|
362 | Void initAsymLut(TComSlice *pcSlice); |
---|
363 | #endif |
---|
364 | #if POC_RESET_RESTRICTIONS |
---|
365 | Void resetPocRestrictionCheckParameters(); |
---|
366 | #endif |
---|
367 | #if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS |
---|
368 | Void xCheckLayerReset(); |
---|
369 | Void xSetNoRaslOutputFlag(); |
---|
370 | Void xSetLayerInitializedFlag(); |
---|
371 | #endif |
---|
372 | };// END CLASS DEFINITION TDecTop |
---|
373 | |
---|
374 | |
---|
375 | //! \} |
---|
376 | |
---|
377 | #endif // __TDECTOP__ |
---|
378 | |
---|