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-2013, 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 | |
---|
48 | #include "TDecGop.h" |
---|
49 | #include "TDecEntropy.h" |
---|
50 | #include "TDecSbac.h" |
---|
51 | #include "TDecCAVLC.h" |
---|
52 | #include "SEIread.h" |
---|
53 | |
---|
54 | struct InputNALUnit; |
---|
55 | |
---|
56 | //! \ingroup TLibDecoder |
---|
57 | //! \{ |
---|
58 | |
---|
59 | // ==================================================================================================================== |
---|
60 | // Class definition |
---|
61 | // ==================================================================================================================== |
---|
62 | |
---|
63 | /// decoder class |
---|
64 | class TDecTop |
---|
65 | { |
---|
66 | private: |
---|
67 | Int m_iMaxRefPicNum; |
---|
68 | |
---|
69 | Int m_pocCRA; ///< POC number of the latest CRA picture |
---|
70 | Bool m_prevRAPisBLA; ///< true if the previous RAP (CRA/CRANT/BLA/BLANT/IDR) picture is a BLA/BLANT picture |
---|
71 | Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) |
---|
72 | |
---|
73 | TComList<TComPic*> m_cListPic; // Dynamic buffer |
---|
74 | #if SVC_EXTENSION |
---|
75 | ParameterSetManagerDecoder m_parameterSetManagerDecoder[MAX_LAYERS]; // storage for parameter sets |
---|
76 | #else |
---|
77 | ParameterSetManagerDecoder m_parameterSetManagerDecoder; // storage for parameter sets |
---|
78 | #endif |
---|
79 | |
---|
80 | TComSlice* m_apcSlicePilot; |
---|
81 | |
---|
82 | SEIMessages m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices |
---|
83 | |
---|
84 | // functional classes |
---|
85 | TComPrediction m_cPrediction; |
---|
86 | TComTrQuant m_cTrQuant; |
---|
87 | TDecGop m_cGopDecoder; |
---|
88 | TDecSlice m_cSliceDecoder; |
---|
89 | TDecCu m_cCuDecoder; |
---|
90 | TDecEntropy m_cEntropyDecoder; |
---|
91 | TDecCavlc m_cCavlcDecoder; |
---|
92 | TDecSbac m_cSbacDecoder; |
---|
93 | TDecBinCABAC m_cBinCABAC; |
---|
94 | SEIReader m_seiReader; |
---|
95 | TComLoopFilter m_cLoopFilter; |
---|
96 | TComSampleAdaptiveOffset m_cSAO; |
---|
97 | |
---|
98 | Bool isSkipPictureForBLA(Int& iPOCLastDisplay); |
---|
99 | Bool isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
100 | TComPic* m_pcPic; |
---|
101 | UInt m_uiSliceIdx; |
---|
102 | #if !SVC_EXTENSION |
---|
103 | Int m_prevPOC; |
---|
104 | #endif |
---|
105 | Bool m_bFirstSliceInPicture; |
---|
106 | #if !SVC_EXTENSION |
---|
107 | Bool m_bFirstSliceInSequence; |
---|
108 | #endif |
---|
109 | #if HM12_RANDOM_ACCESS |
---|
110 | Bool m_prevSliceSkipped; |
---|
111 | Int m_skippedPOC; |
---|
112 | #endif |
---|
113 | |
---|
114 | #if SVC_EXTENSION |
---|
115 | static UInt m_prevPOC; // POC of the previous slice |
---|
116 | static UInt m_uiPrevLayerId; // LayerId of the previous slice |
---|
117 | static Bool m_bFirstSliceInSequence; |
---|
118 | UInt m_layerId; |
---|
119 | UInt m_numLayer; |
---|
120 | TDecTop** m_ppcTDecTop; |
---|
121 | #if AVC_BASE |
---|
122 | fstream* m_pBLReconFile; |
---|
123 | Int m_iBLSourceWidth; |
---|
124 | Int m_iBLSourceHeight; |
---|
125 | #endif |
---|
126 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
127 | Int m_numDirectRefLayers; |
---|
128 | Int m_refLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
129 | Int m_numSamplePredRefLayers; |
---|
130 | Int m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
131 | Int m_numMotionPredRefLayers; |
---|
132 | Int m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; |
---|
133 | Bool m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; |
---|
134 | Bool m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; |
---|
135 | #endif |
---|
136 | TComPic* m_cIlpPic[MAX_NUM_REF]; ///< Inter layer Prediction picture = upsampled picture |
---|
137 | #endif |
---|
138 | #if AVC_SYNTAX || SYNTAX_OUTPUT |
---|
139 | fstream* m_pBLSyntaxFile; |
---|
140 | #endif |
---|
141 | |
---|
142 | public: |
---|
143 | TDecTop(); |
---|
144 | virtual ~TDecTop(); |
---|
145 | |
---|
146 | Void create (); |
---|
147 | Void destroy (); |
---|
148 | |
---|
149 | void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
150 | |
---|
151 | Void init(); |
---|
152 | #if SVC_EXTENSION |
---|
153 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
154 | #else |
---|
155 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
156 | #endif |
---|
157 | |
---|
158 | Void deletePicBuffer(); |
---|
159 | |
---|
160 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
161 | #if EARLY_REF_PIC_MARKING |
---|
162 | Void earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdList); |
---|
163 | #endif |
---|
164 | |
---|
165 | #if SVC_EXTENSION |
---|
166 | UInt getLayerId () { return m_layerId; } |
---|
167 | Void setLayerId (UInt layer) { m_layerId = layer; } |
---|
168 | UInt getNumLayer () { return m_numLayer; } |
---|
169 | Void setNumLayer (UInt uiNum) { m_numLayer = uiNum; } |
---|
170 | TComList<TComPic*>* getListPic() { return &m_cListPic; } |
---|
171 | Void setLayerDec(TDecTop **p) { m_ppcTDecTop = p; } |
---|
172 | TDecTop* getLayerDec(UInt layer) { return m_ppcTDecTop[layer]; } |
---|
173 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
174 | TDecTop* getRefLayerDec(UInt refLayerIdc); |
---|
175 | #if M0457_PREDICTION_INDICATIONS |
---|
176 | Int getNumDirectRefLayers () { return m_numDirectRefLayers; } |
---|
177 | Void setNumDirectRefLayers (Int num) { m_numDirectRefLayers = num; } |
---|
178 | |
---|
179 | Int getRefLayerId (Int i) { return m_refLayerId[i]; } |
---|
180 | Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } |
---|
181 | |
---|
182 | Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; } |
---|
183 | Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; } |
---|
184 | |
---|
185 | Int getSamplePredRefLayerId (Int i) { return m_samplePredRefLayerId[i]; } |
---|
186 | Void setSamplePredRefLayerId (Int i, Int refLayerId) { m_samplePredRefLayerId[i] = refLayerId; } |
---|
187 | |
---|
188 | Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; } |
---|
189 | Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; } |
---|
190 | |
---|
191 | Int getMotionPredRefLayerId (Int i) { return m_motionPredRefLayerId[i]; } |
---|
192 | Void setMotionPredRefLayerId (Int i, Int refLayerId) { m_motionPredRefLayerId[i] = refLayerId; } |
---|
193 | |
---|
194 | Bool getSamplePredEnabledFlag (Int i) { return m_samplePredEnabledFlag[i]; } |
---|
195 | Void setSamplePredEnabledFlag (Int i,Bool flag) { m_samplePredEnabledFlag[i] = flag; } |
---|
196 | |
---|
197 | Bool getMotionPredEnabledFlag (Int i) { return m_motionPredEnabledFlag[i]; } |
---|
198 | Void setMotionPredEnabledFlag (Int i,Bool flag) { m_motionPredEnabledFlag[i] = flag; } |
---|
199 | |
---|
200 | TDecTop* getSamplePredRefLayerDec ( UInt layerId ); |
---|
201 | TDecTop* getMotionPredRefLayerDec ( UInt layerId ); |
---|
202 | |
---|
203 | Void setRefLayerParams( TComVPS* vps ); |
---|
204 | #endif |
---|
205 | #endif |
---|
206 | #if AVC_BASE |
---|
207 | Void setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; } |
---|
208 | fstream* getBLReconFile() { return m_pBLReconFile; } |
---|
209 | Void setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; } |
---|
210 | Int getBLWidth() { return m_iBLSourceWidth; } |
---|
211 | Int getBLHeight() { return m_iBLSourceHeight; } |
---|
212 | #endif |
---|
213 | #if REPN_FORMAT_IN_VPS |
---|
214 | Void xInitILRP(TComSlice *slice); |
---|
215 | #else |
---|
216 | Void xInitILRP(TComSPS *pcSPS); |
---|
217 | #endif |
---|
218 | Void setILRPic(TComPic *pcPic); |
---|
219 | #endif |
---|
220 | #if AVC_SYNTAX || SYNTAX_OUTPUT |
---|
221 | Void setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; } |
---|
222 | fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; } |
---|
223 | #endif |
---|
224 | |
---|
225 | protected: |
---|
226 | Void xGetNewPicBuffer (TComSlice* pcSlice, TComPic*& rpcPic); |
---|
227 | Void xCreateLostPicture (Int iLostPOC); |
---|
228 | |
---|
229 | Void xActivateParameterSets(); |
---|
230 | #if SVC_EXTENSION |
---|
231 | #if POC_RESET_FLAG |
---|
232 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
233 | #else |
---|
234 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC); |
---|
235 | #endif |
---|
236 | #else |
---|
237 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
238 | #endif |
---|
239 | Void xDecodeVPS(); |
---|
240 | Void xDecodeSPS(); |
---|
241 | Void xDecodePPS(); |
---|
242 | Void xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ); |
---|
243 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
244 | TComPic* getMotionPredIlp(TComSlice* pcSlice); |
---|
245 | #endif |
---|
246 | |
---|
247 | };// END CLASS DEFINITION TDecTop |
---|
248 | |
---|
249 | |
---|
250 | //! \} |
---|
251 | |
---|
252 | #endif // __TDECTOP__ |
---|
253 | |
---|