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