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