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 TComPic.cpp |
---|
37 | \brief picture class |
---|
38 | */ |
---|
39 | |
---|
40 | #include "TComPic.h" |
---|
41 | #include "SEI.h" |
---|
42 | |
---|
43 | // ==================================================================================================================== |
---|
44 | // Constructor / destructor / create / destroy |
---|
45 | // ==================================================================================================================== |
---|
46 | |
---|
47 | TComPic::TComPic() |
---|
48 | { |
---|
49 | m_apcPicSym = NULL; |
---|
50 | m_apcPicYuv[0] = NULL; |
---|
51 | m_apcPicYuv[1] = NULL; |
---|
52 | #if DEPTH_MAP_GENERATION |
---|
53 | m_pcPredDepthMap = NULL; |
---|
54 | #endif |
---|
55 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
56 | m_pcOrgDepthMap = NULL; |
---|
57 | #endif |
---|
58 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
59 | m_pcResidual = NULL; |
---|
60 | #endif |
---|
61 | m_pcPicYuvPred = NULL; |
---|
62 | m_pcPicYuvResi = NULL; |
---|
63 | #if HHI_INTERVIEW_SKIP |
---|
64 | m_pcUsedPelsMap = NULL; |
---|
65 | #endif |
---|
66 | |
---|
67 | #if PARALLEL_MERGED_DEBLK |
---|
68 | m_pcPicYuvDeblkBuf = NULL; |
---|
69 | #endif |
---|
70 | |
---|
71 | m_bReconstructed = false; |
---|
72 | |
---|
73 | m_aiNumRefIdx[0] = 0; |
---|
74 | m_aiNumRefIdx[1] = 0; |
---|
75 | #if SONY_COLPIC_AVAILABILITY |
---|
76 | m_iViewOrderIdx = 0; |
---|
77 | #endif |
---|
78 | m_iViewIdx = 0; |
---|
79 | m_aaiCodedScale = 0; |
---|
80 | m_aaiCodedOffset = 0; |
---|
81 | } |
---|
82 | |
---|
83 | TComPic::~TComPic() |
---|
84 | { |
---|
85 | } |
---|
86 | |
---|
87 | Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth ) |
---|
88 | { |
---|
89 | m_apcPicSym = new TComPicSym; m_apcPicSym ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); |
---|
90 | m_apcPicYuv[1] = new TComPicYuv; m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); |
---|
91 | |
---|
92 | /* there are no SEI messages associated with this picture initially */ |
---|
93 | m_SEIs = NULL; |
---|
94 | |
---|
95 | return; |
---|
96 | } |
---|
97 | |
---|
98 | Void TComPic::destroy() |
---|
99 | { |
---|
100 | if (m_apcPicSym) |
---|
101 | { |
---|
102 | m_apcPicSym->destroy(); |
---|
103 | delete m_apcPicSym; |
---|
104 | m_apcPicSym = NULL; |
---|
105 | } |
---|
106 | |
---|
107 | if (m_apcPicYuv[0]) |
---|
108 | { |
---|
109 | m_apcPicYuv[0]->destroy(); |
---|
110 | delete m_apcPicYuv[0]; |
---|
111 | m_apcPicYuv[0] = NULL; |
---|
112 | } |
---|
113 | |
---|
114 | if (m_apcPicYuv[1]) |
---|
115 | { |
---|
116 | m_apcPicYuv[1]->destroy(); |
---|
117 | delete m_apcPicYuv[1]; |
---|
118 | m_apcPicYuv[1] = NULL; |
---|
119 | } |
---|
120 | |
---|
121 | #if DEPTH_MAP_GENERATION |
---|
122 | if( m_pcPredDepthMap ) |
---|
123 | { |
---|
124 | m_pcPredDepthMap->destroy(); |
---|
125 | delete m_pcPredDepthMap; |
---|
126 | m_pcPredDepthMap = NULL; |
---|
127 | } |
---|
128 | #endif |
---|
129 | |
---|
130 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
131 | if( m_pcOrgDepthMap ) |
---|
132 | { |
---|
133 | m_pcOrgDepthMap->destroy(); |
---|
134 | delete m_pcOrgDepthMap; |
---|
135 | m_pcOrgDepthMap = NULL; |
---|
136 | } |
---|
137 | #endif |
---|
138 | |
---|
139 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
140 | if( m_pcResidual ) |
---|
141 | { |
---|
142 | m_pcResidual->destroy(); |
---|
143 | delete m_pcResidual; |
---|
144 | m_pcResidual = NULL; |
---|
145 | } |
---|
146 | #endif |
---|
147 | |
---|
148 | #if HHI_INTERVIEW_SKIP |
---|
149 | if( m_pcUsedPelsMap ) |
---|
150 | { |
---|
151 | m_pcUsedPelsMap->destroy(); |
---|
152 | delete m_pcUsedPelsMap; |
---|
153 | m_pcUsedPelsMap = NULL; |
---|
154 | } |
---|
155 | #endif |
---|
156 | |
---|
157 | #if PARALLEL_MERGED_DEBLK |
---|
158 | if (m_pcPicYuvDeblkBuf) |
---|
159 | { |
---|
160 | m_pcPicYuvDeblkBuf->destroy(); |
---|
161 | delete m_pcPicYuvDeblkBuf; |
---|
162 | m_pcPicYuvDeblkBuf = NULL; |
---|
163 | } |
---|
164 | #endif |
---|
165 | |
---|
166 | delete m_SEIs; |
---|
167 | } |
---|
168 | |
---|
169 | #if AMVP_BUFFERCOMPRESS |
---|
170 | Void TComPic::compressMotion() |
---|
171 | { |
---|
172 | TComPicSym* pPicSym = getPicSym(); |
---|
173 | for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getFrameHeightInCU()*pPicSym->getFrameWidthInCU(); uiCUAddr++ ) |
---|
174 | { |
---|
175 | TComDataCU* pcCU = pPicSym->getCU(uiCUAddr); |
---|
176 | pcCU->compressMV(); |
---|
177 | } |
---|
178 | } |
---|
179 | #endif |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | Void |
---|
184 | TComPic::addOriginalBuffer() |
---|
185 | { |
---|
186 | AOT( m_apcPicYuv[0] ); |
---|
187 | AOF( m_apcPicYuv[1] ); |
---|
188 | Int iWidth = m_apcPicYuv[1]->getWidth (); |
---|
189 | Int iHeight = m_apcPicYuv[1]->getHeight (); |
---|
190 | UInt uiMaxCuWidth = m_apcPicYuv[1]->getMaxCuWidth (); |
---|
191 | UInt uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight(); |
---|
192 | UInt uiMaxCuDepth = m_apcPicYuv[1]->getMaxCuDepth (); |
---|
193 | m_apcPicYuv[0] = new TComPicYuv; |
---|
194 | m_apcPicYuv[0] ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth ); |
---|
195 | } |
---|
196 | |
---|
197 | #if PARALLEL_MERGED_DEBLK |
---|
198 | Void |
---|
199 | TComPic::addDeblockBuffer() |
---|
200 | { |
---|
201 | AOT( m_pcPicYuvDeblkBuf ); |
---|
202 | AOF( m_apcPicYuv[1] ); |
---|
203 | Int iWidth = m_apcPicYuv[1]->getWidth (); |
---|
204 | Int iHeight = m_apcPicYuv[1]->getHeight (); |
---|
205 | UInt uiMaxCuWidth = m_apcPicYuv[1]->getMaxCuWidth (); |
---|
206 | UInt uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight(); |
---|
207 | UInt uiMaxCuDepth = m_apcPicYuv[1]->getMaxCuDepth (); |
---|
208 | m_pcPicYuvDeblkBuf = new TComPicYuv; |
---|
209 | m_pcPicYuvDeblkBuf ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth ); |
---|
210 | } |
---|
211 | #endif |
---|
212 | |
---|
213 | #if DEPTH_MAP_GENERATION |
---|
214 | Void |
---|
215 | TComPic::addPrdDepthMapBuffer( UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
216 | { |
---|
217 | AOT( m_pcPredDepthMap ); |
---|
218 | AOF( m_apcPicYuv[1] ); |
---|
219 | Int iWidth = m_apcPicYuv[1]->getWidth (); |
---|
220 | Int iHeight = m_apcPicYuv[1]->getHeight (); |
---|
221 | UInt uiMaxCuWidth = m_apcPicYuv[1]->getMaxCuWidth (); |
---|
222 | UInt uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight(); |
---|
223 | UInt uiMaxCuDepth = m_apcPicYuv[1]->getMaxCuDepth (); |
---|
224 | m_pcPredDepthMap = new TComPicYuv; |
---|
225 | m_pcPredDepthMap ->create( iWidth >> uiSubSampExpX, iHeight >> uiSubSampExpY, uiMaxCuWidth >> uiSubSampExpX, uiMaxCuHeight >> uiSubSampExpY, uiMaxCuDepth ); |
---|
226 | } |
---|
227 | #endif |
---|
228 | |
---|
229 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
230 | Void |
---|
231 | TComPic::addOrgDepthMapBuffer() |
---|
232 | { |
---|
233 | AOT( m_pcOrgDepthMap ); |
---|
234 | AOF( m_apcPicYuv[1] ); |
---|
235 | Int iWidth = m_apcPicYuv[1]->getWidth (); |
---|
236 | Int iHeight = m_apcPicYuv[1]->getHeight (); |
---|
237 | UInt uiMaxCuWidth = m_apcPicYuv[1]->getMaxCuWidth (); |
---|
238 | UInt uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight(); |
---|
239 | UInt uiMaxCuDepth = m_apcPicYuv[1]->getMaxCuDepth (); |
---|
240 | m_pcOrgDepthMap = new TComPicYuv; |
---|
241 | m_pcOrgDepthMap ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth ); |
---|
242 | } |
---|
243 | #endif |
---|
244 | |
---|
245 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
246 | Void |
---|
247 | TComPic::addResidualBuffer() |
---|
248 | { |
---|
249 | AOT( m_pcResidual ); |
---|
250 | AOF( m_apcPicYuv[1] ); |
---|
251 | Int iWidth = m_apcPicYuv[1]->getWidth (); |
---|
252 | Int iHeight = m_apcPicYuv[1]->getHeight (); |
---|
253 | UInt uiMaxCuWidth = m_apcPicYuv[1]->getMaxCuWidth (); |
---|
254 | UInt uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight(); |
---|
255 | UInt uiMaxCuDepth = m_apcPicYuv[1]->getMaxCuDepth (); |
---|
256 | m_pcResidual = new TComPicYuv; |
---|
257 | m_pcResidual ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth ); |
---|
258 | } |
---|
259 | #endif |
---|
260 | |
---|
261 | #if HHI_INTERVIEW_SKIP |
---|
262 | Void |
---|
263 | TComPic::addUsedPelsMapBuffer() |
---|
264 | { |
---|
265 | AOT( m_pcUsedPelsMap ); |
---|
266 | AOF( m_apcPicYuv[1] ); |
---|
267 | Int iWidth = m_apcPicYuv[1]->getWidth (); |
---|
268 | Int iHeight = m_apcPicYuv[1]->getHeight (); |
---|
269 | UInt uiMaxCuWidth = m_apcPicYuv[1]->getMaxCuWidth (); |
---|
270 | UInt uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight(); |
---|
271 | UInt uiMaxCuDepth = m_apcPicYuv[1]->getMaxCuDepth (); |
---|
272 | m_pcUsedPelsMap = new TComPicYuv; |
---|
273 | m_pcUsedPelsMap ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth ); |
---|
274 | } |
---|
275 | #endif |
---|
276 | |
---|
277 | Void |
---|
278 | TComPic::removeOriginalBuffer() |
---|
279 | { |
---|
280 | if( m_apcPicYuv[0] ) |
---|
281 | { |
---|
282 | m_apcPicYuv[0]->destroy(); |
---|
283 | delete m_apcPicYuv[0]; |
---|
284 | m_apcPicYuv[0] = NULL; |
---|
285 | } |
---|
286 | } |
---|
287 | |
---|
288 | #if PARALLEL_MERGED_DEBLK |
---|
289 | Void |
---|
290 | TComPic::removeDeblockBuffer() |
---|
291 | { |
---|
292 | if( m_pcPicYuvDeblkBuf ) |
---|
293 | { |
---|
294 | m_pcPicYuvDeblkBuf->destroy(); |
---|
295 | delete m_pcPicYuvDeblkBuf; |
---|
296 | m_pcPicYuvDeblkBuf = NULL; |
---|
297 | } |
---|
298 | } |
---|
299 | #endif |
---|
300 | |
---|
301 | #if DEPTH_MAP_GENERATION |
---|
302 | Void |
---|
303 | TComPic::removePrdDepthMapBuffer() |
---|
304 | { |
---|
305 | if( m_pcPredDepthMap ) |
---|
306 | { |
---|
307 | m_pcPredDepthMap->destroy(); |
---|
308 | delete m_pcPredDepthMap; |
---|
309 | m_pcPredDepthMap = NULL; |
---|
310 | } |
---|
311 | } |
---|
312 | #endif |
---|
313 | |
---|
314 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
315 | Void |
---|
316 | TComPic::removeOrgDepthMapBuffer() |
---|
317 | { |
---|
318 | if( m_pcOrgDepthMap ) |
---|
319 | { |
---|
320 | m_pcOrgDepthMap->destroy(); |
---|
321 | delete m_pcOrgDepthMap; |
---|
322 | m_pcOrgDepthMap = NULL; |
---|
323 | } |
---|
324 | } |
---|
325 | #endif |
---|
326 | |
---|
327 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
328 | Void |
---|
329 | TComPic::removeResidualBuffer() |
---|
330 | { |
---|
331 | if( m_pcResidual ) |
---|
332 | { |
---|
333 | m_pcResidual->destroy(); |
---|
334 | delete m_pcResidual; |
---|
335 | m_pcResidual = NULL; |
---|
336 | } |
---|
337 | } |
---|
338 | #endif |
---|
339 | |
---|
340 | #if HHI_INTERVIEW_SKIP |
---|
341 | Void |
---|
342 | TComPic::removeUsedPelsMapBuffer() |
---|
343 | { |
---|
344 | if( m_pcUsedPelsMap ) |
---|
345 | { |
---|
346 | m_pcUsedPelsMap->destroy(); |
---|
347 | delete m_pcUsedPelsMap; |
---|
348 | m_pcUsedPelsMap = NULL; |
---|
349 | } |
---|
350 | } |
---|
351 | #endif |
---|
352 | |
---|