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