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 TComPic.cpp |
---|
35 | \brief picture class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TComPic.h" |
---|
39 | #include "SEI.h" |
---|
40 | |
---|
41 | //! \ingroup TLibCommon |
---|
42 | //! \{ |
---|
43 | |
---|
44 | // ==================================================================================================================== |
---|
45 | // Constructor / destructor / create / destroy |
---|
46 | // ==================================================================================================================== |
---|
47 | |
---|
48 | TComPic::TComPic() |
---|
49 | { |
---|
50 | m_uiTLayer = 0; |
---|
51 | |
---|
52 | m_apcPicSym = NULL; |
---|
53 | m_apcPicYuv[0] = NULL; |
---|
54 | m_apcPicYuv[1] = NULL; |
---|
55 | #if DEPTH_MAP_GENERATION |
---|
56 | m_pcPredDepthMap = NULL; |
---|
57 | #endif |
---|
58 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
59 | m_pcOrgDepthMap = NULL; |
---|
60 | #endif |
---|
61 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
62 | m_pcResidual = NULL; |
---|
63 | #endif |
---|
64 | m_pcPicYuvPred = NULL; |
---|
65 | m_pcPicYuvResi = NULL; |
---|
66 | m_bIsLongTerm = false; |
---|
67 | m_bReconstructed = false; |
---|
68 | m_usedForTMVP = true; |
---|
69 | m_bNeededForOutput = false; |
---|
70 | m_pSliceSUMap = NULL; |
---|
71 | m_uiCurrSliceIdx = 0; |
---|
72 | #if HHI_INTERVIEW_SKIP |
---|
73 | m_pcUsedPelsMap = NULL; |
---|
74 | #endif |
---|
75 | #if SONY_COLPIC_AVAILABILITY |
---|
76 | m_iViewOrderIdx = 0; |
---|
77 | #endif |
---|
78 | m_aaiCodedScale = 0; |
---|
79 | m_aaiCodedOffset = 0; |
---|
80 | } |
---|
81 | |
---|
82 | TComPic::~TComPic() |
---|
83 | { |
---|
84 | } |
---|
85 | |
---|
86 | Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Bool bIsVirtual ) |
---|
87 | { |
---|
88 | m_apcPicSym = new TComPicSym; m_apcPicSym ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); |
---|
89 | if (!bIsVirtual) |
---|
90 | { |
---|
91 | m_apcPicYuv[0] = new TComPicYuv; m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); |
---|
92 | } |
---|
93 | m_apcPicYuv[1] = new TComPicYuv; m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); |
---|
94 | |
---|
95 | /* there are no SEI messages associated with this picture initially */ |
---|
96 | m_SEIs = NULL; |
---|
97 | m_bUsedByCurr = false; |
---|
98 | return; |
---|
99 | } |
---|
100 | |
---|
101 | Void TComPic::destroy() |
---|
102 | { |
---|
103 | if (m_apcPicSym) |
---|
104 | { |
---|
105 | m_apcPicSym->destroy(); |
---|
106 | delete m_apcPicSym; |
---|
107 | m_apcPicSym = NULL; |
---|
108 | } |
---|
109 | |
---|
110 | if (m_apcPicYuv[0]) |
---|
111 | { |
---|
112 | m_apcPicYuv[0]->destroy(); |
---|
113 | delete m_apcPicYuv[0]; |
---|
114 | m_apcPicYuv[0] = NULL; |
---|
115 | } |
---|
116 | |
---|
117 | if (m_apcPicYuv[1]) |
---|
118 | { |
---|
119 | m_apcPicYuv[1]->destroy(); |
---|
120 | delete m_apcPicYuv[1]; |
---|
121 | m_apcPicYuv[1] = NULL; |
---|
122 | } |
---|
123 | #if HHI_INTERVIEW_SKIP |
---|
124 | if( m_pcUsedPelsMap ) |
---|
125 | { |
---|
126 | m_pcUsedPelsMap->destroy(); |
---|
127 | delete m_pcUsedPelsMap; |
---|
128 | m_pcUsedPelsMap = NULL; |
---|
129 | } |
---|
130 | #endif |
---|
131 | #if DEPTH_MAP_GENERATION |
---|
132 | if( m_pcPredDepthMap ) |
---|
133 | { |
---|
134 | m_pcPredDepthMap->destroy(); |
---|
135 | delete m_pcPredDepthMap; |
---|
136 | m_pcPredDepthMap = NULL; |
---|
137 | } |
---|
138 | #endif |
---|
139 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
140 | if( m_pcOrgDepthMap ) |
---|
141 | { |
---|
142 | m_pcOrgDepthMap->destroy(); |
---|
143 | delete m_pcOrgDepthMap; |
---|
144 | m_pcOrgDepthMap = NULL; |
---|
145 | } |
---|
146 | #endif |
---|
147 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
148 | if( m_pcResidual ) |
---|
149 | { |
---|
150 | m_pcResidual->destroy(); |
---|
151 | delete m_pcResidual; |
---|
152 | m_pcResidual = NULL; |
---|
153 | } |
---|
154 | #endif |
---|
155 | delete m_SEIs; |
---|
156 | } |
---|
157 | |
---|
158 | Void TComPic::compressMotion() |
---|
159 | { |
---|
160 | TComPicSym* pPicSym = getPicSym(); |
---|
161 | for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getFrameHeightInCU()*pPicSym->getFrameWidthInCU(); uiCUAddr++ ) |
---|
162 | { |
---|
163 | TComDataCU* pcCU = pPicSym->getCU(uiCUAddr); |
---|
164 | pcCU->compressMV(); |
---|
165 | } |
---|
166 | } |
---|
167 | |
---|
168 | #if DEPTH_MAP_GENERATION |
---|
169 | Void |
---|
170 | TComPic::addPrdDepthMapBuffer( UInt uiSubSampExpX, UInt uiSubSampExpY ) |
---|
171 | { |
---|
172 | AOT( m_pcPredDepthMap ); |
---|
173 | AOF( m_apcPicYuv[1] ); |
---|
174 | Int iWidth = m_apcPicYuv[1]->getWidth (); |
---|
175 | Int iHeight = m_apcPicYuv[1]->getHeight (); |
---|
176 | UInt uiMaxCuWidth = m_apcPicYuv[1]->getMaxCuWidth (); |
---|
177 | UInt uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight(); |
---|
178 | UInt uiMaxCuDepth = m_apcPicYuv[1]->getMaxCuDepth (); |
---|
179 | m_pcPredDepthMap = new TComPicYuv; |
---|
180 | m_pcPredDepthMap ->create( iWidth >> uiSubSampExpX, iHeight >> uiSubSampExpY, uiMaxCuWidth >> uiSubSampExpX, uiMaxCuHeight >> uiSubSampExpY, uiMaxCuDepth ); |
---|
181 | } |
---|
182 | #endif |
---|
183 | |
---|
184 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
185 | Void |
---|
186 | TComPic::addOrgDepthMapBuffer() |
---|
187 | { |
---|
188 | AOT( m_pcOrgDepthMap ); |
---|
189 | AOF( m_apcPicYuv[1] ); |
---|
190 | Int iWidth = m_apcPicYuv[1]->getWidth (); |
---|
191 | Int iHeight = m_apcPicYuv[1]->getHeight (); |
---|
192 | UInt uiMaxCuWidth = m_apcPicYuv[1]->getMaxCuWidth (); |
---|
193 | UInt uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight(); |
---|
194 | UInt uiMaxCuDepth = m_apcPicYuv[1]->getMaxCuDepth (); |
---|
195 | m_pcOrgDepthMap = new TComPicYuv; |
---|
196 | m_pcOrgDepthMap ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth ); |
---|
197 | } |
---|
198 | #endif |
---|
199 | |
---|
200 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
201 | Void |
---|
202 | TComPic::addResidualBuffer() |
---|
203 | { |
---|
204 | AOT( m_pcResidual ); |
---|
205 | AOF( m_apcPicYuv[1] ); |
---|
206 | Int iWidth = m_apcPicYuv[1]->getWidth (); |
---|
207 | Int iHeight = m_apcPicYuv[1]->getHeight (); |
---|
208 | UInt uiMaxCuWidth = m_apcPicYuv[1]->getMaxCuWidth (); |
---|
209 | UInt uiMaxCuHeight = m_apcPicYuv[1]->getMaxCuHeight(); |
---|
210 | UInt uiMaxCuDepth = m_apcPicYuv[1]->getMaxCuDepth (); |
---|
211 | m_pcResidual = new TComPicYuv; |
---|
212 | m_pcResidual ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth ); |
---|
213 | } |
---|
214 | #endif |
---|
215 | |
---|
216 | #if DEPTH_MAP_GENERATION |
---|
217 | Void |
---|
218 | TComPic::removePrdDepthMapBuffer() |
---|
219 | { |
---|
220 | if( m_pcPredDepthMap ) |
---|
221 | { |
---|
222 | m_pcPredDepthMap->destroy(); |
---|
223 | delete m_pcPredDepthMap; |
---|
224 | m_pcPredDepthMap = NULL; |
---|
225 | } |
---|
226 | } |
---|
227 | #endif |
---|
228 | |
---|
229 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
230 | Void |
---|
231 | TComPic::removeOrgDepthMapBuffer() |
---|
232 | { |
---|
233 | if( m_pcOrgDepthMap ) |
---|
234 | { |
---|
235 | m_pcOrgDepthMap->destroy(); |
---|
236 | delete m_pcOrgDepthMap; |
---|
237 | m_pcOrgDepthMap = NULL; |
---|
238 | } |
---|
239 | } |
---|
240 | #endif |
---|
241 | |
---|
242 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
243 | Void |
---|
244 | TComPic::removeResidualBuffer() |
---|
245 | { |
---|
246 | if( m_pcResidual ) |
---|
247 | { |
---|
248 | m_pcResidual->destroy(); |
---|
249 | delete m_pcResidual; |
---|
250 | m_pcResidual = NULL; |
---|
251 | } |
---|
252 | } |
---|
253 | #endif |
---|
254 | |
---|
255 | /** Create non-deblocked filter information |
---|
256 | * \param pSliceStartAddress array for storing slice start addresses |
---|
257 | * \param numSlices number of slices in picture |
---|
258 | * \param sliceGranularityDepth slice granularity |
---|
259 | * \param bNDBFilterCrossSliceBoundary cross-slice-boundary in-loop filtering; true for "cross". |
---|
260 | * \param numTiles number of tiles in picture |
---|
261 | * \param bNDBFilterCrossTileBoundary cross-tile-boundary in-loop filtering; true for "cross". |
---|
262 | */ |
---|
263 | Void TComPic::createNonDBFilterInfo(UInt* pSliceStartAddress, Int numSlices, Int sliceGranularityDepth |
---|
264 | ,Bool bNDBFilterCrossSliceBoundary |
---|
265 | ,Int numTiles |
---|
266 | ,Bool bNDBFilterCrossTileBoundary) |
---|
267 | { |
---|
268 | UInt maxNumSUInLCU = getNumPartInCU(); |
---|
269 | UInt numLCUInPic = getNumCUsInFrame(); |
---|
270 | UInt picWidth = getSlice(0)->getSPS()->getPicWidthInLumaSamples(); |
---|
271 | UInt picHeight = getSlice(0)->getSPS()->getPicHeightInLumaSamples(); |
---|
272 | Int numLCUsInPicWidth = getFrameWidthInCU(); |
---|
273 | Int numLCUsInPicHeight= getFrameHeightInCU(); |
---|
274 | UInt maxNumSUInLCUWidth = getNumPartInWidth(); |
---|
275 | UInt maxNumSUInLCUHeight= getNumPartInHeight(); |
---|
276 | |
---|
277 | m_bIndependentSliceBoundaryForNDBFilter = (bNDBFilterCrossSliceBoundary)?(false):((numSlices > 1)?(true):(false)) ; |
---|
278 | m_sliceGranularityForNDBFilter = sliceGranularityDepth; |
---|
279 | m_bIndependentTileBoundaryForNDBFilter = (bNDBFilterCrossTileBoundary)?(false) :((numTiles > 1)?(true):(false)); |
---|
280 | |
---|
281 | m_pbValidSlice = new Bool[numSlices]; |
---|
282 | for(Int s=0; s< numSlices; s++) |
---|
283 | { |
---|
284 | m_pbValidSlice[s] = true; |
---|
285 | } |
---|
286 | #if !LCU_SYNTAX_ALF |
---|
287 | if( pSliceStartAddress == NULL || (numSlices == 1 && numTiles == 1) ) |
---|
288 | { |
---|
289 | return; |
---|
290 | } |
---|
291 | #endif |
---|
292 | m_pSliceSUMap = new Int[maxNumSUInLCU * numLCUInPic]; |
---|
293 | |
---|
294 | //initialization |
---|
295 | for(UInt i=0; i< (maxNumSUInLCU * numLCUInPic); i++ ) |
---|
296 | { |
---|
297 | m_pSliceSUMap[i] = -1; |
---|
298 | } |
---|
299 | for( UInt CUAddr = 0; CUAddr < numLCUInPic ; CUAddr++ ) |
---|
300 | { |
---|
301 | TComDataCU* pcCU = getCU( CUAddr ); |
---|
302 | pcCU->setSliceSUMap(m_pSliceSUMap + (CUAddr* maxNumSUInLCU)); |
---|
303 | pcCU->getNDBFilterBlocks()->clear(); |
---|
304 | } |
---|
305 | m_vSliceCUDataLink.clear(); |
---|
306 | |
---|
307 | m_vSliceCUDataLink.resize(numSlices); |
---|
308 | |
---|
309 | UInt startAddr, endAddr, firstCUInStartLCU, startLCU, endLCU, lastCUInEndLCU, uiAddr; |
---|
310 | UInt LPelX, TPelY, LCUX, LCUY; |
---|
311 | UInt currSU; |
---|
312 | UInt startSU, endSU; |
---|
313 | |
---|
314 | for(Int s=0; s< numSlices; s++) |
---|
315 | { |
---|
316 | //1st step: decide the real start address |
---|
317 | startAddr = pSliceStartAddress[s]; |
---|
318 | endAddr = pSliceStartAddress[s+1] -1; |
---|
319 | |
---|
320 | startLCU = startAddr / maxNumSUInLCU; |
---|
321 | firstCUInStartLCU = startAddr % maxNumSUInLCU; |
---|
322 | |
---|
323 | endLCU = endAddr / maxNumSUInLCU; |
---|
324 | lastCUInEndLCU = endAddr % maxNumSUInLCU; |
---|
325 | |
---|
326 | uiAddr = m_apcPicSym->getCUOrderMap(startLCU); |
---|
327 | |
---|
328 | LCUX = getCU(uiAddr)->getCUPelX(); |
---|
329 | LCUY = getCU(uiAddr)->getCUPelY(); |
---|
330 | LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[firstCUInStartLCU] ]; |
---|
331 | TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[firstCUInStartLCU] ]; |
---|
332 | currSU = firstCUInStartLCU; |
---|
333 | |
---|
334 | Bool bMoveToNextLCU = false; |
---|
335 | Bool bSliceInOneLCU = (startLCU == endLCU); |
---|
336 | |
---|
337 | while(!( LPelX < picWidth ) || !( TPelY < picHeight )) |
---|
338 | { |
---|
339 | currSU ++; |
---|
340 | |
---|
341 | if(bSliceInOneLCU) |
---|
342 | { |
---|
343 | if(currSU > lastCUInEndLCU) |
---|
344 | { |
---|
345 | m_pbValidSlice[s] = false; |
---|
346 | break; |
---|
347 | } |
---|
348 | } |
---|
349 | |
---|
350 | if(currSU >= maxNumSUInLCU ) |
---|
351 | { |
---|
352 | bMoveToNextLCU = true; |
---|
353 | break; |
---|
354 | } |
---|
355 | |
---|
356 | LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ]; |
---|
357 | TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ]; |
---|
358 | |
---|
359 | } |
---|
360 | |
---|
361 | |
---|
362 | if(!m_pbValidSlice[s]) |
---|
363 | { |
---|
364 | continue; |
---|
365 | } |
---|
366 | |
---|
367 | if(currSU != firstCUInStartLCU) |
---|
368 | { |
---|
369 | if(!bMoveToNextLCU) |
---|
370 | { |
---|
371 | firstCUInStartLCU = currSU; |
---|
372 | } |
---|
373 | else |
---|
374 | { |
---|
375 | startLCU++; |
---|
376 | firstCUInStartLCU = 0; |
---|
377 | assert( startLCU < getNumCUsInFrame()); |
---|
378 | } |
---|
379 | assert(startLCU*maxNumSUInLCU + firstCUInStartLCU < endAddr); |
---|
380 | } |
---|
381 | |
---|
382 | |
---|
383 | //2nd step: assign NonDBFilterInfo to each processing block |
---|
384 | for(UInt i= startLCU; i <= endLCU; i++) |
---|
385 | { |
---|
386 | startSU = (i == startLCU)?(firstCUInStartLCU):(0); |
---|
387 | endSU = (i == endLCU )?(lastCUInEndLCU ):(maxNumSUInLCU -1); |
---|
388 | |
---|
389 | uiAddr = m_apcPicSym->getCUOrderMap(i); |
---|
390 | Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr); |
---|
391 | |
---|
392 | TComDataCU* pcCU = getCU(uiAddr); |
---|
393 | m_vSliceCUDataLink[s].push_back(pcCU); |
---|
394 | |
---|
395 | createNonDBFilterInfoLCU(iTileID, s, pcCU, startSU, endSU, m_sliceGranularityForNDBFilter, picWidth, picHeight); |
---|
396 | } |
---|
397 | } |
---|
398 | |
---|
399 | //step 3: border availability |
---|
400 | for(Int s=0; s< numSlices; s++) |
---|
401 | { |
---|
402 | if(!m_pbValidSlice[s]) |
---|
403 | { |
---|
404 | continue; |
---|
405 | } |
---|
406 | |
---|
407 | for(Int i=0; i< m_vSliceCUDataLink[s].size(); i++) |
---|
408 | { |
---|
409 | TComDataCU* pcCU = m_vSliceCUDataLink[s][i]; |
---|
410 | uiAddr = pcCU->getAddr(); |
---|
411 | |
---|
412 | if(pcCU->getPic()==0) |
---|
413 | { |
---|
414 | continue; |
---|
415 | } |
---|
416 | Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr); |
---|
417 | Bool bTopTileBoundary = false, bDownTileBoundary= false, bLeftTileBoundary= false, bRightTileBoundary= false; |
---|
418 | |
---|
419 | if(m_bIndependentTileBoundaryForNDBFilter) |
---|
420 | { |
---|
421 | //left |
---|
422 | if( uiAddr % numLCUsInPicWidth != 0) |
---|
423 | { |
---|
424 | bLeftTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr -1) != iTileID )?true:false; |
---|
425 | } |
---|
426 | //right |
---|
427 | if( (uiAddr % numLCUsInPicWidth) != (numLCUsInPicWidth -1) ) |
---|
428 | { |
---|
429 | bRightTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr +1) != iTileID)?true:false; |
---|
430 | } |
---|
431 | //top |
---|
432 | if( uiAddr >= numLCUsInPicWidth) |
---|
433 | { |
---|
434 | bTopTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr - numLCUsInPicWidth) != iTileID )?true:false; |
---|
435 | } |
---|
436 | //down |
---|
437 | if( uiAddr + numLCUsInPicWidth < numLCUInPic ) |
---|
438 | { |
---|
439 | bDownTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr + numLCUsInPicWidth) != iTileID)?true:false; |
---|
440 | } |
---|
441 | |
---|
442 | } |
---|
443 | |
---|
444 | pcCU->setNDBFilterBlockBorderAvailability(numLCUsInPicWidth, numLCUsInPicHeight, maxNumSUInLCUWidth, maxNumSUInLCUHeight,picWidth, picHeight |
---|
445 | ,m_bIndependentSliceBoundaryForNDBFilter |
---|
446 | ,bTopTileBoundary, bDownTileBoundary, bLeftTileBoundary, bRightTileBoundary |
---|
447 | ,m_bIndependentTileBoundaryForNDBFilter); |
---|
448 | |
---|
449 | } |
---|
450 | |
---|
451 | } |
---|
452 | |
---|
453 | if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter) |
---|
454 | { |
---|
455 | m_pNDBFilterYuvTmp = new TComPicYuv(); |
---|
456 | m_pNDBFilterYuvTmp->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); |
---|
457 | } |
---|
458 | } |
---|
459 | |
---|
460 | #if HHI_INTERVIEW_SKIP |
---|
461 | Void TComPic::addUsedPelsMapBuffer() |
---|
462 | { |
---|
463 | AOT( m_pcUsedPelsMap ); |
---|
464 | AOF( m_apcPicYuv[1] ); |
---|
465 | Int iWidth = m_apcPicYuv[1]->getWidth (); |
---|
466 | Int iHeight = m_apcPicYuv[1]->getHeight (); |
---|
467 | UInt uiMaxCuWidth = m_apcPicSym->getMaxCUWidth(); |
---|
468 | UInt uiMaxCuHeight = m_apcPicSym->getMaxCUHeight(); |
---|
469 | UInt uiMaxCuDepth = m_apcPicSym->getMaxCUDepth (); |
---|
470 | m_pcUsedPelsMap = new TComPicYuv; |
---|
471 | m_pcUsedPelsMap ->create( iWidth, iHeight, uiMaxCuWidth, uiMaxCuHeight, uiMaxCuDepth ); |
---|
472 | |
---|
473 | } |
---|
474 | Void |
---|
475 | TComPic::removeUsedPelsMapBuffer() |
---|
476 | { |
---|
477 | if( m_pcUsedPelsMap ) |
---|
478 | { |
---|
479 | m_pcUsedPelsMap->destroy(); |
---|
480 | delete m_pcUsedPelsMap; |
---|
481 | m_pcUsedPelsMap = NULL; |
---|
482 | } |
---|
483 | } |
---|
484 | #endif |
---|
485 | |
---|
486 | /** Create non-deblocked filter information for LCU |
---|
487 | * \param tileID tile index |
---|
488 | * \param sliceID slice index |
---|
489 | * \param pcCU CU data pointer |
---|
490 | * \param startSU start SU index in LCU |
---|
491 | * \param endSU end SU index in LCU |
---|
492 | * \param sliceGranularyDepth slice granularity |
---|
493 | * \param picWidth picture width |
---|
494 | * \param picHeight picture height |
---|
495 | */ |
---|
496 | Void TComPic::createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight) |
---|
497 | { |
---|
498 | UInt LCUX = pcCU->getCUPelX(); |
---|
499 | UInt LCUY = pcCU->getCUPelY(); |
---|
500 | Int* pCUSliceMap = pcCU->getSliceSUMap(); |
---|
501 | UInt maxNumSUInLCU = getNumPartInCU(); |
---|
502 | UInt maxNumSUInSGU = maxNumSUInLCU >> (sliceGranularyDepth << 1); |
---|
503 | UInt maxNumSUInLCUWidth = getNumPartInWidth(); |
---|
504 | UInt LPelX, TPelY; |
---|
505 | UInt currSU; |
---|
506 | |
---|
507 | |
---|
508 | //get the number of valid NBFilterBLock |
---|
509 | currSU = startSU; |
---|
510 | while(currSU <= endSU) |
---|
511 | { |
---|
512 | LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ]; |
---|
513 | TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ]; |
---|
514 | |
---|
515 | while(!( LPelX < picWidth ) || !( TPelY < picHeight )) |
---|
516 | { |
---|
517 | currSU += maxNumSUInSGU; |
---|
518 | if(currSU >= maxNumSUInLCU || currSU > endSU) |
---|
519 | { |
---|
520 | break; |
---|
521 | } |
---|
522 | LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ]; |
---|
523 | TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ]; |
---|
524 | } |
---|
525 | |
---|
526 | if(currSU >= maxNumSUInLCU || currSU > endSU) |
---|
527 | { |
---|
528 | break; |
---|
529 | } |
---|
530 | |
---|
531 | NDBFBlockInfo NDBFBlock; |
---|
532 | |
---|
533 | NDBFBlock.tileID = tileID; |
---|
534 | NDBFBlock.sliceID = sliceID; |
---|
535 | NDBFBlock.posY = TPelY; |
---|
536 | NDBFBlock.posX = LPelX; |
---|
537 | NDBFBlock.startSU = currSU; |
---|
538 | |
---|
539 | UInt uiLastValidSU = currSU; |
---|
540 | UInt uiIdx, uiLPelX_su, uiTPelY_su; |
---|
541 | for(uiIdx = currSU; uiIdx < currSU + maxNumSUInSGU; uiIdx++) |
---|
542 | { |
---|
543 | if(uiIdx > endSU) |
---|
544 | { |
---|
545 | break; |
---|
546 | } |
---|
547 | uiLPelX_su = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
548 | uiTPelY_su = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
549 | if( !(uiLPelX_su < picWidth ) || !( uiTPelY_su < picHeight )) |
---|
550 | { |
---|
551 | continue; |
---|
552 | } |
---|
553 | pCUSliceMap[uiIdx] = sliceID; |
---|
554 | uiLastValidSU = uiIdx; |
---|
555 | } |
---|
556 | NDBFBlock.endSU = uiLastValidSU; |
---|
557 | |
---|
558 | UInt rTLSU = g_auiZscanToRaster[ NDBFBlock.startSU ]; |
---|
559 | UInt rBRSU = g_auiZscanToRaster[ NDBFBlock.endSU ]; |
---|
560 | NDBFBlock.widthSU = (rBRSU % maxNumSUInLCUWidth) - (rTLSU % maxNumSUInLCUWidth)+ 1; |
---|
561 | NDBFBlock.heightSU = (UInt)(rBRSU / maxNumSUInLCUWidth) - (UInt)(rTLSU / maxNumSUInLCUWidth)+ 1; |
---|
562 | NDBFBlock.width = NDBFBlock.widthSU * getMinCUWidth(); |
---|
563 | NDBFBlock.height = NDBFBlock.heightSU * getMinCUHeight(); |
---|
564 | |
---|
565 | pcCU->getNDBFilterBlocks()->push_back(NDBFBlock); |
---|
566 | |
---|
567 | currSU += maxNumSUInSGU; |
---|
568 | } |
---|
569 | |
---|
570 | } |
---|
571 | |
---|
572 | /** destroy non-deblocked filter information for LCU |
---|
573 | */ |
---|
574 | Void TComPic::destroyNonDBFilterInfo() |
---|
575 | { |
---|
576 | if(m_pbValidSlice != NULL) |
---|
577 | { |
---|
578 | delete[] m_pbValidSlice; |
---|
579 | m_pbValidSlice = NULL; |
---|
580 | } |
---|
581 | |
---|
582 | if(m_pSliceSUMap != NULL) |
---|
583 | { |
---|
584 | delete[] m_pSliceSUMap; |
---|
585 | m_pSliceSUMap = NULL; |
---|
586 | } |
---|
587 | for( UInt CUAddr = 0; CUAddr < getNumCUsInFrame() ; CUAddr++ ) |
---|
588 | { |
---|
589 | TComDataCU* pcCU = getCU( CUAddr ); |
---|
590 | pcCU->getNDBFilterBlocks()->clear(); |
---|
591 | } |
---|
592 | |
---|
593 | if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter) |
---|
594 | { |
---|
595 | m_pNDBFilterYuvTmp->destroy(); |
---|
596 | delete m_pNDBFilterYuvTmp; |
---|
597 | m_pNDBFilterYuvTmp = NULL; |
---|
598 | } |
---|
599 | |
---|
600 | } |
---|
601 | |
---|
602 | |
---|
603 | //! \} |
---|