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