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 | |
---|
49 | #include "TDecGop.h" |
---|
50 | #include "TDecEntropy.h" |
---|
51 | #include "TDecSbac.h" |
---|
52 | #include "TDecCAVLC.h" |
---|
53 | #include "SEIread.h" |
---|
54 | |
---|
55 | class InputNALUnit; |
---|
56 | |
---|
57 | //! \ingroup TLibDecoder |
---|
58 | //! \{ |
---|
59 | |
---|
60 | // ==================================================================================================================== |
---|
61 | // Class definition |
---|
62 | // ==================================================================================================================== |
---|
63 | |
---|
64 | #if NH_MV |
---|
65 | class TAppDecTop; |
---|
66 | #endif |
---|
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 | #if !NH_MV |
---|
75 | Int m_pocCRA; ///< POC number of the latest CRA picture |
---|
76 | Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) |
---|
77 | |
---|
78 | TComList<TComPic*> m_cListPic; // Dynamic buffer |
---|
79 | ParameterSetManager m_parameterSetManager; // storage for parameter sets |
---|
80 | #endif |
---|
81 | |
---|
82 | TComSlice* m_apcSlicePilot; |
---|
83 | |
---|
84 | SEIMessages m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices, excluding prefix SEIs... |
---|
85 | |
---|
86 | // functional classes |
---|
87 | TComPrediction m_cPrediction; |
---|
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 | #if !NH_MV |
---|
102 | Bool isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
103 | #endif |
---|
104 | |
---|
105 | TComPic* m_pcPic; |
---|
106 | UInt m_uiSliceIdx; |
---|
107 | #if !NH_MV |
---|
108 | Int m_prevPOC; |
---|
109 | Int m_prevTid0POC; |
---|
110 | Bool m_bFirstSliceInPicture; |
---|
111 | Bool m_bFirstSliceInSequence; |
---|
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 | #endif |
---|
119 | |
---|
120 | #if O0043_BEST_EFFORT_DECODING |
---|
121 | UInt m_forceDecodeBitDepth; |
---|
122 | #endif |
---|
123 | |
---|
124 | |
---|
125 | std::ostream *m_pDecodedSEIOutputStream; |
---|
126 | |
---|
127 | #if !NH_MV |
---|
128 | Bool m_warningMessageSkipPicture; |
---|
129 | #endif |
---|
130 | |
---|
131 | #if NH_MV |
---|
132 | // Class interface |
---|
133 | static ParameterSetManager m_parameterSetManager; // storage for parameter sets |
---|
134 | TComPicLists* m_dpb; |
---|
135 | |
---|
136 | // Layer identification |
---|
137 | Int m_layerId; |
---|
138 | Int m_viewId; |
---|
139 | |
---|
140 | // Layer set |
---|
141 | Int m_targetOlsIdx; |
---|
142 | Int m_smallestLayerId; |
---|
143 | Bool m_isInOwnTargetDecLayerIdList; |
---|
144 | |
---|
145 | // Decoding processes |
---|
146 | DecodingProcess m_decodingProcess; |
---|
147 | DecodingProcess m_decProcPocAndRps; |
---|
148 | |
---|
149 | // Decoding state |
---|
150 | Bool* m_firstPicInLayerDecodedFlag; |
---|
151 | |
---|
152 | Int m_prevPicOrderCnt; |
---|
153 | Int m_prevTid0PicPicOrderCntMsb; |
---|
154 | Int m_prevTid0PicSlicePicOrderCntLsb; |
---|
155 | |
---|
156 | Int* m_lastPresentPocResetIdc; |
---|
157 | Bool* m_pocDecrementedInDpbFlag; |
---|
158 | |
---|
159 | Int m_prevIrapPoc; |
---|
160 | Int64 m_prevIrapDecodingOrder; |
---|
161 | Int64 m_prevStsaDecOrder; |
---|
162 | Int m_prevStsaTemporalId; |
---|
163 | #endif |
---|
164 | |
---|
165 | std::list<InputNALUnit*> m_prefixSEINALUs; /// Buffered up prefix SEI NAL Units. |
---|
166 | public: |
---|
167 | TDecTop(); |
---|
168 | virtual ~TDecTop(); |
---|
169 | |
---|
170 | Void create (); |
---|
171 | Void destroy (); |
---|
172 | |
---|
173 | Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
174 | |
---|
175 | Void init(); |
---|
176 | #if !NH_MV |
---|
177 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
178 | Void deletePicBuffer(); |
---|
179 | |
---|
180 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
181 | Void checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic); |
---|
182 | |
---|
183 | Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; } |
---|
184 | Void setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; } |
---|
185 | |
---|
186 | Void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; } |
---|
187 | |
---|
188 | Bool getFirstSliceInSequence () { return m_bFirstSliceInSequence; } |
---|
189 | Void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; } |
---|
190 | #endif |
---|
191 | |
---|
192 | #if O0043_BEST_EFFORT_DECODING |
---|
193 | Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; } |
---|
194 | #endif |
---|
195 | |
---|
196 | Void setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; } |
---|
197 | UInt getNumberOfChecksumErrorsDetected() const { return m_cGopDecoder.getNumberOfChecksumErrorsDetected(); } |
---|
198 | |
---|
199 | #if NH_MV |
---|
200 | |
---|
201 | ///////////////////////// |
---|
202 | // For access from TAppDecTop |
---|
203 | ///////////////////////// |
---|
204 | |
---|
205 | // Non VCL decoding |
---|
206 | Bool decodeNonVclNalu ( InputNALUnit& nalu ); |
---|
207 | |
---|
208 | // Start picture decoding |
---|
209 | Int preDecodePoc ( Bool firstPicInLayerDecodedFlag, Bool isFstPicOfAllLayOfPocResetPer, Bool isPocResettingPicture ); |
---|
210 | Void inferPocResetPeriodId ( ); |
---|
211 | Void decodeSliceHeader ( InputNALUnit &nalu ); |
---|
212 | |
---|
213 | // Picture decoding |
---|
214 | Void activatePSsAndInitPicOrSlice( TComPic* newPic ); |
---|
215 | Void decodePocAndRps ( ); |
---|
216 | Void genUnavailableRefPics ( ); |
---|
217 | Void decodeSliceSegment ( InputNALUnit &nalu ); |
---|
218 | |
---|
219 | // End Picture decoding |
---|
220 | Void executeLoopFilters ( ); |
---|
221 | Void finalizePic( ); |
---|
222 | |
---|
223 | ////////////////////////// |
---|
224 | // For access from slice |
---|
225 | ///////////////////////// |
---|
226 | Void initFromActiveVps ( const TComVPS* vps ); |
---|
227 | |
---|
228 | ////////////////////////// |
---|
229 | // General access |
---|
230 | ///////////////////////// |
---|
231 | |
---|
232 | // Picture identification |
---|
233 | Void setLayerId ( Int layer ) { m_layerId = layer; } |
---|
234 | Int getLayerId ( ) { return m_layerId; } |
---|
235 | Void setViewId ( Int viewId ) { m_viewId = viewId; } |
---|
236 | Int getViewId ( ) { return m_viewId; } |
---|
237 | |
---|
238 | // Classes |
---|
239 | Void setDpb ( TComPicLists* picLists) { m_dpb = picLists; } |
---|
240 | |
---|
241 | // Slice pilot access |
---|
242 | TComSlice* getSlicePilot ( ) { return m_apcSlicePilot; } |
---|
243 | |
---|
244 | // Decoding state |
---|
245 | Bool getFirstSliceSegementInPicFlag( ); |
---|
246 | Void setFirstPicInLayerDecodedFlag(Bool* val ) { m_firstPicInLayerDecodedFlag = val; } |
---|
247 | Void setPocDecrementedInDPBFlag (Bool* val ) { m_pocDecrementedInDpbFlag = val; } |
---|
248 | Void setLastPresentPocResetIdc (Int* val ) { m_lastPresentPocResetIdc = val; } |
---|
249 | |
---|
250 | // Layer sets |
---|
251 | Void setTargetOlsIdx ( Int targetOlsIdx ) { m_targetOlsIdx = targetOlsIdx; } |
---|
252 | Int getTargetOlsIdx ( ) { return m_targetOlsIdx; } |
---|
253 | Int getSmallestLayerId ( ) { return m_smallestLayerId; } |
---|
254 | Bool getIsInOwnTargetDecLayerIdList() { return m_isInOwnTargetDecLayerIdList; } |
---|
255 | |
---|
256 | // Decoding processes identification |
---|
257 | Bool decProcClause8( ) { return ( m_decodingProcess == CLAUSE_8 ); } |
---|
258 | Bool decProcAnnexF ( ) { return ( decProcAnnexG() || decProcAnnexH() || decProcAnnexI() ); } |
---|
259 | Bool decProcAnnexG ( ) { return ( m_decodingProcess == ANNEX_G || decProcAnnexI() ); } |
---|
260 | Bool decProcAnnexH ( ) { return ( m_decodingProcess == ANNEX_H ); } |
---|
261 | Bool decProcAnnexI ( ) { return ( m_decodingProcess == ANNEX_I ); } |
---|
262 | |
---|
263 | DecodingProcess getDecodingProcess ( ) const { return m_decodingProcess; } |
---|
264 | Void setDecProcPocAndRps( DecodingProcess decProc ) { m_decProcPocAndRps = decProc; } |
---|
265 | #endif |
---|
266 | |
---|
267 | protected: |
---|
268 | |
---|
269 | #if !NH_MV |
---|
270 | Void xGetNewPicBuffer (const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer); |
---|
271 | Void xCreateLostPicture (Int iLostPOC); |
---|
272 | Void xActivateParameterSets(); |
---|
273 | Bool xDecodeSlice (InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
274 | #endif |
---|
275 | |
---|
276 | Void xDecodeVPS(const std::vector<UChar> &naluData); |
---|
277 | Void xDecodeSPS(const std::vector<UChar> &naluData); |
---|
278 | Void xDecodePPS(const std::vector<UChar> &naluData); |
---|
279 | #if !NH_MV |
---|
280 | 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(); } } |
---|
281 | #endif |
---|
282 | |
---|
283 | Void xParsePrefixSEImessages(); |
---|
284 | Void xParsePrefixSEIsForUnknownVCLNal(); |
---|
285 | |
---|
286 | #if NH_MV |
---|
287 | // POC |
---|
288 | Void x831DecProcForPicOrderCount ( ); |
---|
289 | Void xF831DecProcForPicOrderCount ( ); |
---|
290 | Int xGetCurrMsb ( Int cl, Int pl, Int pm, Int ml ); |
---|
291 | |
---|
292 | //RPS |
---|
293 | Void x832DecProcForRefPicSet ( Bool annexFModifications ); |
---|
294 | Void xF832DecProcForRefPicSet ( ); |
---|
295 | Void xG813DecProcForInterLayerRefPicSet ( ); |
---|
296 | |
---|
297 | // Unavailable Pics |
---|
298 | Void x8331GenDecProcForGenUnavilRefPics ( ); |
---|
299 | TComPic* x8332GenOfOneUnavailPic ( Bool calledFromCl8331 ); |
---|
300 | Void xF817DecProcForGenUnavRefPicForPicsFrstInDecOrderInLay(); |
---|
301 | Void xF833DecProcForGenUnavRefPics ( ); |
---|
302 | Void xCheckUnavailableRefPics ( ); |
---|
303 | #endif |
---|
304 | |
---|
305 | };// END CLASS DEFINITION TDecTop |
---|
306 | |
---|
307 | |
---|
308 | //! \} |
---|
309 | #endif // __TDECTOP__ |
---|
310 | |
---|