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