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