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-2011, 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 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 | |
---|
35 | |
---|
36 | /** \file TDecTop.h |
---|
37 | \brief decoder class (header) |
---|
38 | */ |
---|
39 | |
---|
40 | #ifndef __TDECTOP__ |
---|
41 | #define __TDECTOP__ |
---|
42 | |
---|
43 | #include "../TLibCommon/CommonDef.h" |
---|
44 | #include "../TLibCommon/TComList.h" |
---|
45 | #include "../TLibCommon/TComPicYuv.h" |
---|
46 | #include "../TLibCommon/TComPic.h" |
---|
47 | #include "../TLibCommon/TComTrQuant.h" |
---|
48 | #include "../TLibCommon/TComDepthMapGenerator.h" |
---|
49 | #include "../TLibCommon/TComResidualGenerator.h" |
---|
50 | #include "../TLibCommon/SEI.h" |
---|
51 | |
---|
52 | #include "TDecGop.h" |
---|
53 | #include "TDecEntropy.h" |
---|
54 | #include "TDecSbac.h" |
---|
55 | #include "TDecCAVLC.h" |
---|
56 | |
---|
57 | #if POZNAN_MP |
---|
58 | #include "../TLibCommon/TComMP.h" |
---|
59 | #endif |
---|
60 | |
---|
61 | // ==================================================================================================================== |
---|
62 | // Class definition |
---|
63 | // ==================================================================================================================== |
---|
64 | |
---|
65 | class TAppDecTop ; |
---|
66 | |
---|
67 | |
---|
68 | class CamParsCollector |
---|
69 | { |
---|
70 | public: |
---|
71 | CamParsCollector (); |
---|
72 | ~CamParsCollector (); |
---|
73 | |
---|
74 | Void init ( FILE* pCodedScaleOffsetFile ); |
---|
75 | Void uninit (); |
---|
76 | Void setSlice ( TComSlice* pcSlice ); |
---|
77 | #if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION) |
---|
78 | Double**** getBaseViewShiftLUTD () { return m_adBaseViewShiftLUT; } |
---|
79 | Int**** getBaseViewShiftLUTI () { return m_aiBaseViewShiftLUT; } |
---|
80 | |
---|
81 | Int** getBaseViewOffsetI () { return m_aaiCodedOffset; } |
---|
82 | Int** getBaseViewScaleI () { return m_aaiCodedScale; } |
---|
83 | |
---|
84 | Bool getNearestBaseView ( Int iSynthViewIdx, Int &riNearestViewIdx, Int &riRelDistToLeft, Bool& rbRenderFromLeft); |
---|
85 | #endif |
---|
86 | |
---|
87 | private: |
---|
88 | Bool xIsComplete (); |
---|
89 | Void xOutput ( Int iPOC ); |
---|
90 | |
---|
91 | private: |
---|
92 | Bool m_bInitialized; |
---|
93 | FILE* m_pCodedScaleOffsetFile; |
---|
94 | |
---|
95 | Int** m_aaiCodedOffset; |
---|
96 | Int** m_aaiCodedScale; |
---|
97 | Int* m_aiViewOrderIndex; |
---|
98 | Int* m_aiViewReceived; |
---|
99 | UInt m_uiCamParsCodedPrecision; |
---|
100 | Bool m_bCamParsVaryOverTime; |
---|
101 | Int m_iLastViewId; |
---|
102 | Int m_iLastPOC; |
---|
103 | UInt m_uiMaxViewId; |
---|
104 | |
---|
105 | #if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION) |
---|
106 | |
---|
107 | UInt m_uiBitDepthForLUT; |
---|
108 | UInt m_iLog2Precision; |
---|
109 | UInt m_uiInputBitDepth; |
---|
110 | |
---|
111 | // look-up tables |
---|
112 | Double**** m_adBaseViewShiftLUT; ///< Disparity LUT |
---|
113 | Int**** m_aiBaseViewShiftLUT; ///< Disparity LUT |
---|
114 | |
---|
115 | Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT); |
---|
116 | Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT); |
---|
117 | |
---|
118 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 ); |
---|
119 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize1, UInt uiSize2 ); |
---|
120 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize ); |
---|
121 | #endif |
---|
122 | #if POZNAN_NONLINEAR_DEPTH |
---|
123 | Float m_fDepthPower; |
---|
124 | #endif |
---|
125 | |
---|
126 | |
---|
127 | }; |
---|
128 | |
---|
129 | #if POZNAN_SYNTH || (POZNAN_MP && !POZNAN_MP_USE_DEPTH_MAP_GENERATION) |
---|
130 | template <class T> |
---|
131 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 ) |
---|
132 | { |
---|
133 | if( rpt ) |
---|
134 | { |
---|
135 | for( UInt uiK = 0; uiK < uiSize1; uiK++ ) |
---|
136 | { |
---|
137 | for( UInt uiL = 0; uiL < uiSize2; uiL++ ) |
---|
138 | { |
---|
139 | for( UInt uiM = 0; uiM < uiSize3; uiM++ ) |
---|
140 | { |
---|
141 | delete[] rpt[ uiK ][ uiL ][ uiM ]; |
---|
142 | } |
---|
143 | delete[] rpt[ uiK ][ uiL ]; |
---|
144 | } |
---|
145 | delete[] rpt[ uiK ]; |
---|
146 | } |
---|
147 | delete[] rpt; |
---|
148 | } |
---|
149 | rpt = NULL; |
---|
150 | }; |
---|
151 | |
---|
152 | |
---|
153 | template <class T> |
---|
154 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 ) |
---|
155 | { |
---|
156 | if( rpt ) |
---|
157 | { |
---|
158 | for( UInt uiK = 0; uiK < uiSize1; uiK++ ) |
---|
159 | { |
---|
160 | for( UInt uiL = 0; uiL < uiSize2; uiL++ ) |
---|
161 | { |
---|
162 | delete[] rpt[ uiK ][ uiL ]; |
---|
163 | } |
---|
164 | delete[] rpt[ uiK ]; |
---|
165 | } |
---|
166 | delete[] rpt; |
---|
167 | } |
---|
168 | rpt = NULL; |
---|
169 | }; |
---|
170 | |
---|
171 | |
---|
172 | template <class T> |
---|
173 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize ) |
---|
174 | { |
---|
175 | if( rpt ) |
---|
176 | { |
---|
177 | for( UInt uiK = 0; uiK < uiSize; uiK++ ) |
---|
178 | { |
---|
179 | delete[] rpt[ uiK ]; |
---|
180 | } |
---|
181 | delete[] rpt; |
---|
182 | } |
---|
183 | rpt = NULL; |
---|
184 | }; |
---|
185 | #endif |
---|
186 | |
---|
187 | |
---|
188 | /// decoder class |
---|
189 | class TDecTop |
---|
190 | { |
---|
191 | private: |
---|
192 | Int m_iGopSize; |
---|
193 | Bool m_bGopSizeSet; |
---|
194 | int m_iMaxRefPicNum; |
---|
195 | |
---|
196 | #if DCM_DECODING_REFRESH |
---|
197 | Bool m_bRefreshPending; ///< refresh pending flag |
---|
198 | UInt m_uiPOCCDR; ///< temporal reference of the CDR picture |
---|
199 | #if DCM_SKIP_DECODING_FRAMES |
---|
200 | UInt m_uiPOCRA; ///< temporal reference of the random access point |
---|
201 | #endif |
---|
202 | #endif |
---|
203 | |
---|
204 | UInt m_uiValidPS; |
---|
205 | TComList<TComPic*> m_cListPic; // Dynamic buffer |
---|
206 | TComSPS m_cSPS; |
---|
207 | TComPPS m_cPPS; |
---|
208 | TComSlice* m_apcSlicePilot; |
---|
209 | |
---|
210 | SEImessages *m_SEIs; ///< "all" SEI messages. If not NULL, we own the object. |
---|
211 | |
---|
212 | // functional classes |
---|
213 | TComPrediction m_cPrediction; |
---|
214 | TComTrQuant m_cTrQuant; |
---|
215 | TDecGop m_cGopDecoder; |
---|
216 | TDecSlice m_cSliceDecoder; |
---|
217 | TDecCu m_cCuDecoder; |
---|
218 | TDecEntropy m_cEntropyDecoder; |
---|
219 | TDecCavlc m_cCavlcDecoder; |
---|
220 | TDecSbac m_cSbacDecoder; |
---|
221 | TDecBinCABAC m_cBinCABAC; |
---|
222 | TComLoopFilter m_cLoopFilter; |
---|
223 | TComAdaptiveLoopFilter m_cAdaptiveLoopFilter; |
---|
224 | #if MTK_SAO |
---|
225 | TComSampleAdaptiveOffset m_cSAO; |
---|
226 | #endif |
---|
227 | #if DEPTH_MAP_GENERATION |
---|
228 | TComDepthMapGenerator m_cDepthMapGenerator; |
---|
229 | #endif |
---|
230 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
231 | TComResidualGenerator m_cResidualGenerator; |
---|
232 | #endif |
---|
233 | |
---|
234 | #if POZNAN_MP |
---|
235 | TComMP* m_pcMP; |
---|
236 | #endif |
---|
237 | |
---|
238 | Bool m_bIsDepth; |
---|
239 | Int m_iViewIdx; |
---|
240 | #if SONY_COLPIC_AVAILABILITY |
---|
241 | Int m_iViewOrderIdx; |
---|
242 | #endif |
---|
243 | TAppDecTop* m_pcTAppDecTop; |
---|
244 | CamParsCollector* m_pcCamParsCollector; |
---|
245 | |
---|
246 | #if DCM_SKIP_DECODING_FRAMES |
---|
247 | Bool isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
248 | #endif |
---|
249 | TComPic* m_pcPic; |
---|
250 | UInt m_uiSliceIdx; |
---|
251 | UInt m_uiLastSliceIdx; |
---|
252 | UInt m_uiPrevPOC; |
---|
253 | Bool m_bFirstSliceInPicture; |
---|
254 | Bool m_bFirstSliceInSequence; |
---|
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 = true ); |
---|
266 | #if DCM_SKIP_DECODING_FRAMES |
---|
267 | Bool decode (Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
268 | #else |
---|
269 | Void decode ( Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS ); |
---|
270 | #endif |
---|
271 | |
---|
272 | TComSPS *getSPS() { return (m_uiValidPS & 1) ? &m_cSPS : NULL; } |
---|
273 | |
---|
274 | Void deletePicBuffer(); |
---|
275 | |
---|
276 | Void deleteExtraPicBuffers( Int iPoc ); |
---|
277 | #if AMVP_BUFFERCOMPRESS |
---|
278 | Void compressMotion ( Int iPoc ); |
---|
279 | #endif |
---|
280 | |
---|
281 | Void setViewIdx(Int i) { m_iViewIdx = i ;} |
---|
282 | Int getViewIdx() { return m_iViewIdx ; } |
---|
283 | #if SONY_COLPIC_AVAILABILITY |
---|
284 | Void setViewOrderIdx(Int i) { m_iViewOrderIdx = i ;} |
---|
285 | Int getViewOrderIdx() { return m_iViewOrderIdx ; } |
---|
286 | #endif |
---|
287 | |
---|
288 | Void setToDepth(Bool b) { m_bIsDepth = b ;} |
---|
289 | Bool getIsDepth() { return m_bIsDepth ;} |
---|
290 | |
---|
291 | Void setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; } |
---|
292 | |
---|
293 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
294 | TAppDecTop* getDecTop ( ){ return m_pcTAppDecTop ;} |
---|
295 | #if DEPTH_MAP_GENERATION |
---|
296 | TComDepthMapGenerator* getDepthMapGenerator () { return &m_cDepthMapGenerator; } |
---|
297 | #endif |
---|
298 | |
---|
299 | Void setSPS (TComSPS cSPS ); |
---|
300 | |
---|
301 | UInt getCodedPictureBufferSize() { return m_cSPS.getCodedPictureBufferSize() ; } |
---|
302 | |
---|
303 | Void executeDeblockAndAlf(Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
304 | |
---|
305 | protected: |
---|
306 | Void xGetNewPicBuffer (TComSlice* pcSlice, TComPic*& rpcPic); |
---|
307 | |
---|
308 | };// END CLASS DEFINITION TDecTop |
---|
309 | |
---|
310 | |
---|
311 | #endif // __TDECTOP__ |
---|
312 | |
---|