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-2012, 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/TComDepthMapGenerator.h" |
---|
47 | #include "TLibCommon/SEI.h" |
---|
48 | |
---|
49 | #include "TDecGop.h" |
---|
50 | #include "TDecEntropy.h" |
---|
51 | #include "TDecSbac.h" |
---|
52 | #include "TDecCAVLC.h" |
---|
53 | |
---|
54 | struct InputNALUnit; |
---|
55 | |
---|
56 | //! \ingroup TLibDecoder |
---|
57 | //! \{ |
---|
58 | |
---|
59 | #define APS_RESERVED_BUFFER_SIZE 2 //!< must be equal to or larger than 2 to handle bitstream parsing |
---|
60 | |
---|
61 | // ==================================================================================================================== |
---|
62 | // Class definition |
---|
63 | // ==================================================================================================================== |
---|
64 | |
---|
65 | class TAppDecTop; |
---|
66 | |
---|
67 | class CamParsCollector |
---|
68 | { |
---|
69 | public: |
---|
70 | CamParsCollector (); |
---|
71 | ~CamParsCollector (); |
---|
72 | |
---|
73 | Void init ( FILE* pCodedScaleOffsetFile ); |
---|
74 | Void uninit (); |
---|
75 | Void setSlice ( TComSlice* pcSlice ); |
---|
76 | |
---|
77 | Bool isInitialized() const { return m_bInitialized; } |
---|
78 | |
---|
79 | #if VSP_N |
---|
80 | Double**** getBaseViewShiftLUTD () { return m_adBaseViewShiftLUT; } |
---|
81 | Int**** getBaseViewShiftLUTI () { return m_aiBaseViewShiftLUT; } |
---|
82 | Int** getBaseViewOffsetI () { return m_aaiCodedOffset; } |
---|
83 | Int** getBaseViewScaleI () { return m_aaiCodedScale; } |
---|
84 | Bool getNearestBaseView ( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft); |
---|
85 | #if NTT_SUBPEL |
---|
86 | Int**** getBaseViewIPelLUT () { return m_aiBaseViewShiftLUT_ipel; } |
---|
87 | Int**** getBaseViewFPosLUT () { return m_aiBaseViewShiftLUT_fpos; } |
---|
88 | #endif |
---|
89 | #endif |
---|
90 | |
---|
91 | private: |
---|
92 | Bool xIsComplete (); |
---|
93 | Void xOutput ( Int iPOC ); |
---|
94 | |
---|
95 | private: |
---|
96 | Bool m_bInitialized; |
---|
97 | FILE* m_pCodedScaleOffsetFile; |
---|
98 | |
---|
99 | Int** m_aaiCodedOffset; |
---|
100 | Int** m_aaiCodedScale; |
---|
101 | Int* m_aiViewOrderIndex; |
---|
102 | #if QC_MVHEVC_B0046 |
---|
103 | Int* m_aiViewId; |
---|
104 | #endif |
---|
105 | Int* m_aiViewReceived; |
---|
106 | UInt m_uiCamParsCodedPrecision; |
---|
107 | Bool m_bCamParsVaryOverTime; |
---|
108 | Int m_iLastViewId; |
---|
109 | Int m_iLastPOC; |
---|
110 | UInt m_uiMaxViewId; |
---|
111 | |
---|
112 | #if VSP_N |
---|
113 | UInt m_uiBitDepthForLUT; |
---|
114 | UInt m_iLog2Precision; |
---|
115 | UInt m_uiInputBitDepth; |
---|
116 | // look-up tables |
---|
117 | Double**** m_adBaseViewShiftLUT; ///< Disparity LUT |
---|
118 | Int**** m_aiBaseViewShiftLUT; ///< Disparity LUT |
---|
119 | Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT); |
---|
120 | Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT); |
---|
121 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 ); |
---|
122 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize1, UInt uiSize2 ); |
---|
123 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize ); |
---|
124 | |
---|
125 | #if NTT_SUBPEL |
---|
126 | Int**** m_aiBaseViewShiftLUT_ipel; ///< Disparity LUT |
---|
127 | Int**** m_aiBaseViewShiftLUT_fpos; ///< Disparity LUT |
---|
128 | Void xCreateLUTs_Subpel ( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Int****& raiLUT0, Int****& raiLUT1 ); |
---|
129 | Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Int****& raiLUT_ipel, Int****& raiLUT_fpos); |
---|
130 | #endif |
---|
131 | #endif |
---|
132 | }; |
---|
133 | |
---|
134 | #if VSP_N |
---|
135 | template <class T> |
---|
136 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 ) |
---|
137 | { |
---|
138 | if( rpt ) |
---|
139 | { |
---|
140 | for( UInt uiK = 0; uiK < uiSize1; uiK++ ) |
---|
141 | { |
---|
142 | for( UInt uiL = 0; uiL < uiSize2; uiL++ ) |
---|
143 | { |
---|
144 | for( UInt uiM = 0; uiM < uiSize3; uiM++ ) |
---|
145 | { |
---|
146 | delete[] rpt[ uiK ][ uiL ][ uiM ]; |
---|
147 | } |
---|
148 | delete[] rpt[ uiK ][ uiL ]; |
---|
149 | } |
---|
150 | delete[] rpt[ uiK ]; |
---|
151 | } |
---|
152 | delete[] rpt; |
---|
153 | } |
---|
154 | rpt = NULL; |
---|
155 | }; |
---|
156 | |
---|
157 | |
---|
158 | template <class T> |
---|
159 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 ) |
---|
160 | { |
---|
161 | if( rpt ) |
---|
162 | { |
---|
163 | for( UInt uiK = 0; uiK < uiSize1; uiK++ ) |
---|
164 | { |
---|
165 | for( UInt uiL = 0; uiL < uiSize2; uiL++ ) |
---|
166 | { |
---|
167 | delete[] rpt[ uiK ][ uiL ]; |
---|
168 | } |
---|
169 | delete[] rpt[ uiK ]; |
---|
170 | } |
---|
171 | delete[] rpt; |
---|
172 | } |
---|
173 | rpt = NULL; |
---|
174 | }; |
---|
175 | |
---|
176 | |
---|
177 | template <class T> |
---|
178 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize ) |
---|
179 | { |
---|
180 | if( rpt ) |
---|
181 | { |
---|
182 | for( UInt uiK = 0; uiK < uiSize; uiK++ ) |
---|
183 | { |
---|
184 | delete[] rpt[ uiK ]; |
---|
185 | } |
---|
186 | delete[] rpt; |
---|
187 | } |
---|
188 | rpt = NULL; |
---|
189 | }; |
---|
190 | #endif |
---|
191 | |
---|
192 | /// decoder class |
---|
193 | class TDecTop |
---|
194 | { |
---|
195 | private: |
---|
196 | Int m_iGopSize; |
---|
197 | Bool m_bGopSizeSet; |
---|
198 | int m_iMaxRefPicNum; |
---|
199 | |
---|
200 | Bool m_bRefreshPending; ///< refresh pending flag |
---|
201 | Int m_pocCRA; ///< POC number of the latest CRA picture |
---|
202 | Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) |
---|
203 | |
---|
204 | UInt m_uiValidPS; |
---|
205 | TComList<TComPic*> m_cListPic; // Dynamic buffer |
---|
206 | ParameterSetManagerDecoder m_parameterSetManagerDecoder; // storage for parameter sets |
---|
207 | TComRPSList m_RPSList; |
---|
208 | TComSlice* m_apcSlicePilot; |
---|
209 | |
---|
210 | SEImessages *m_SEIs; ///< "all" SEI messages. If not NULL, we own the object. |
---|
211 | |
---|
212 | #if SONY_COLPIC_AVAILABILITY |
---|
213 | Int m_iViewOrderIdx; |
---|
214 | #endif |
---|
215 | |
---|
216 | // functional classes |
---|
217 | TComPrediction m_cPrediction; |
---|
218 | TComTrQuant m_cTrQuant; |
---|
219 | TDecGop m_cGopDecoder; |
---|
220 | TDecSlice m_cSliceDecoder; |
---|
221 | TDecCu m_cCuDecoder; |
---|
222 | TDecEntropy m_cEntropyDecoder; |
---|
223 | TDecCavlc m_cCavlcDecoder; |
---|
224 | TDecSbac m_cSbacDecoder; |
---|
225 | TDecBinCABAC m_cBinCABAC; |
---|
226 | TComLoopFilter m_cLoopFilter; |
---|
227 | TComAdaptiveLoopFilter m_cAdaptiveLoopFilter; |
---|
228 | TComSampleAdaptiveOffset m_cSAO; |
---|
229 | |
---|
230 | #if DEPTH_MAP_GENERATION |
---|
231 | TComDepthMapGenerator m_cDepthMapGenerator; |
---|
232 | #endif |
---|
233 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
234 | TComResidualGenerator m_cResidualGenerator; |
---|
235 | #endif |
---|
236 | |
---|
237 | Bool isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
238 | TComPic* m_pcPic; |
---|
239 | UInt m_uiSliceIdx; |
---|
240 | UInt m_uiLastSliceIdx; |
---|
241 | Int m_prevPOC; |
---|
242 | Bool m_bFirstSliceInPicture; |
---|
243 | Bool m_bFirstSliceInSequence; |
---|
244 | |
---|
245 | Int m_viewId; |
---|
246 | Bool m_isDepth; |
---|
247 | TAppDecTop* m_tAppDecTop; |
---|
248 | CamParsCollector* m_pcCamParsCollector; |
---|
249 | NalUnitType m_nalUnitTypeBaseView; |
---|
250 | |
---|
251 | #if VSP_N |
---|
252 | TComPic* m_pcPicVSP; //view synthesis prediction buffer for current POC to be coded |
---|
253 | TComPic* m_pcPicAvail; |
---|
254 | #endif |
---|
255 | |
---|
256 | public: |
---|
257 | TDecTop(); |
---|
258 | virtual ~TDecTop(); |
---|
259 | |
---|
260 | Void create (); |
---|
261 | Void destroy (); |
---|
262 | |
---|
263 | void setPictureDigestEnabled(bool enabled) { m_cGopDecoder.setPictureDigestEnabled(enabled); } |
---|
264 | |
---|
265 | Void init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance ); |
---|
266 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
267 | |
---|
268 | Void deletePicBuffer(); |
---|
269 | #if QC_MVHEVC_B0046 |
---|
270 | Void xCopySPS( TComSPS* pSPSV0); |
---|
271 | Void xCopyPPS( TComPPS* pPPSV0); |
---|
272 | Void xCopyVPS( TComVPS* pVPSV0); |
---|
273 | #endif |
---|
274 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
275 | Void deleteExtraPicBuffers ( Int iPoc ); |
---|
276 | #endif |
---|
277 | Void compressMotion ( Int iPoc ); |
---|
278 | |
---|
279 | Void executeDeblockAndAlf(UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
280 | |
---|
281 | Void setViewId(Int viewId) { m_viewId = viewId;} |
---|
282 | Int getViewId() { return m_viewId ;} |
---|
283 | Void setIsDepth( Bool isDepth ) { m_isDepth = isDepth; } |
---|
284 | Bool getIsDepth() { return m_isDepth; } |
---|
285 | |
---|
286 | #if SONY_COLPIC_AVAILABILITY |
---|
287 | Void setViewOrderIdx(Int i) { m_iViewOrderIdx = i ;} |
---|
288 | Int getViewOrderIdx() { return m_iViewOrderIdx ; } |
---|
289 | #endif |
---|
290 | |
---|
291 | #if DEPTH_MAP_GENERATION |
---|
292 | TComDepthMapGenerator* getDepthMapGenerator () { return &m_cDepthMapGenerator; } |
---|
293 | #endif |
---|
294 | |
---|
295 | Void setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; } |
---|
296 | |
---|
297 | TComList<TComPic*>* getListPic() { return &m_cListPic; } |
---|
298 | Void setTAppDecTop( TAppDecTop* pcTAppDecTop ) { m_tAppDecTop = pcTAppDecTop; } |
---|
299 | TAppDecTop* getTAppDecTop() { return m_tAppDecTop; } |
---|
300 | NalUnitType getNalUnitTypeBaseView() { return m_nalUnitTypeBaseView; } |
---|
301 | #if QC_MVHEVC_B0046 |
---|
302 | bool m_bFirstNal; //used to copy SPS, PPS, VPS |
---|
303 | ParameterSetManagerDecoder* xGetParaSetDec () {return &m_parameterSetManagerDecoder;} |
---|
304 | #endif |
---|
305 | |
---|
306 | #if VSP_N |
---|
307 | TComPic* getVSPBuf() { return m_pcPicVSP; } |
---|
308 | #endif |
---|
309 | |
---|
310 | protected: |
---|
311 | Void xGetNewPicBuffer (TComSlice* pcSlice, TComPic*& rpcPic); |
---|
312 | Void xUpdateGopSize (TComSlice* pcSlice); |
---|
313 | Void xCreateLostPicture (Int iLostPOC); |
---|
314 | |
---|
315 | Void decodeAPS( TComAPS* cAPS) { m_cEntropyDecoder.decodeAPS(cAPS); }; |
---|
316 | Void xActivateParameterSets(); |
---|
317 | #if SKIPFRAME_BUGFIX |
---|
318 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
319 | #else |
---|
320 | Bool xDecodeSlice(InputNALUnit &nalu, Int iSkipFrame, Int iPOCLastDisplay); |
---|
321 | #endif |
---|
322 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
323 | Void xDecodeVPS(); |
---|
324 | #endif |
---|
325 | Void xDecodeSPS(); |
---|
326 | Void xDecodePPS(); |
---|
327 | Void xDecodeAPS(); |
---|
328 | Void xDecodeSEI(); |
---|
329 | |
---|
330 | Void allocAPS (TComAPS* pAPS); //!< memory allocation for APS |
---|
331 | };// END CLASS DEFINITION TDecTop |
---|
332 | |
---|
333 | |
---|
334 | //! \} |
---|
335 | |
---|
336 | #endif // __TDECTOP__ |
---|
337 | |
---|