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