[313] | 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 |
---|
[916] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[313] | 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 TComPicSym.cpp |
---|
| 35 | \brief picture symbol class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TComPicSym.h" |
---|
| 39 | #include "TComSampleAdaptiveOffset.h" |
---|
[823] | 40 | #include "TComSlice.h" |
---|
[313] | 41 | |
---|
| 42 | //! \ingroup TLibCommon |
---|
| 43 | //! \{ |
---|
| 44 | |
---|
| 45 | // ==================================================================================================================== |
---|
| 46 | // Constructor / destructor / create / destroy |
---|
| 47 | // ==================================================================================================================== |
---|
| 48 | |
---|
| 49 | TComPicSym::TComPicSym() |
---|
[916] | 50 | :m_frameWidthInCtus(0) |
---|
| 51 | ,m_frameHeightInCtus(0) |
---|
[313] | 52 | ,m_uiMaxCUWidth(0) |
---|
| 53 | ,m_uiMaxCUHeight(0) |
---|
| 54 | ,m_uiMinCUWidth(0) |
---|
| 55 | ,m_uiMinCUHeight(0) |
---|
| 56 | ,m_uhTotalDepth(0) |
---|
[916] | 57 | ,m_numPartitionsInCtu(0) |
---|
| 58 | ,m_numPartInCtuWidth(0) |
---|
| 59 | ,m_numPartInCtuHeight(0) |
---|
| 60 | ,m_numCtusInFrame(0) |
---|
[313] | 61 | ,m_apcTComSlice(NULL) |
---|
[916] | 62 | ,m_uiNumAllocatedSlice(0) |
---|
| 63 | ,m_pictureCtuArray(NULL) |
---|
| 64 | ,m_numTileColumnsMinus1(0) |
---|
| 65 | ,m_numTileRowsMinus1(0) |
---|
| 66 | ,m_ctuTsToRsAddrMap(NULL) |
---|
[313] | 67 | ,m_puiTileIdxMap(NULL) |
---|
[916] | 68 | ,m_ctuRsToTsAddrMap(NULL) |
---|
[540] | 69 | ,m_saoBlkParams(NULL) |
---|
[916] | 70 | {} |
---|
[313] | 71 | |
---|
| 72 | |
---|
[916] | 73 | Void TComPicSym::create ( ChromaFormat chromaFormatIDC, Int iPicWidth, Int iPicHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth ) |
---|
[313] | 74 | { |
---|
| 75 | UInt i; |
---|
| 76 | |
---|
[916] | 77 | m_uhTotalDepth = uiMaxDepth; |
---|
| 78 | m_numPartitionsInCtu = 1<<(m_uhTotalDepth<<1); |
---|
| 79 | |
---|
| 80 | m_uiMaxCUWidth = uiMaxWidth; |
---|
| 81 | m_uiMaxCUHeight = uiMaxHeight; |
---|
| 82 | |
---|
| 83 | m_uiMinCUWidth = uiMaxWidth >> m_uhTotalDepth; |
---|
| 84 | m_uiMinCUHeight = uiMaxHeight >> m_uhTotalDepth; |
---|
| 85 | |
---|
| 86 | m_numPartInCtuWidth = m_uiMaxCUWidth / m_uiMinCUWidth; // equivalent to 1<<m_uhTotalDepth |
---|
| 87 | m_numPartInCtuHeight = m_uiMaxCUHeight / m_uiMinCUHeight; // equivalent to 1<<m_uhTotalDepth |
---|
| 88 | |
---|
| 89 | m_frameWidthInCtus = ( iPicWidth %m_uiMaxCUWidth ) ? iPicWidth /m_uiMaxCUWidth + 1 : iPicWidth /m_uiMaxCUWidth; |
---|
| 90 | m_frameHeightInCtus = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight; |
---|
| 91 | |
---|
| 92 | m_numCtusInFrame = m_frameWidthInCtus * m_frameHeightInCtus; |
---|
| 93 | m_pictureCtuArray = new TComDataCU*[m_numCtusInFrame]; |
---|
| 94 | |
---|
[313] | 95 | if (m_uiNumAllocatedSlice>0) |
---|
| 96 | { |
---|
| 97 | for ( i=0; i<m_uiNumAllocatedSlice ; i++ ) |
---|
| 98 | { |
---|
| 99 | delete m_apcTComSlice[i]; |
---|
| 100 | } |
---|
| 101 | delete [] m_apcTComSlice; |
---|
| 102 | } |
---|
[916] | 103 | m_apcTComSlice = new TComSlice*[m_numCtusInFrame]; |
---|
[313] | 104 | m_apcTComSlice[0] = new TComSlice; |
---|
| 105 | m_uiNumAllocatedSlice = 1; |
---|
[916] | 106 | for ( i=0; i<m_numCtusInFrame ; i++ ) |
---|
[313] | 107 | { |
---|
[916] | 108 | m_pictureCtuArray[i] = new TComDataCU; |
---|
| 109 | m_pictureCtuArray[i]->create( chromaFormatIDC, m_numPartitionsInCtu, m_uiMaxCUWidth, m_uiMaxCUHeight, false, m_uiMaxCUWidth >> m_uhTotalDepth |
---|
[313] | 110 | #if ADAPTIVE_QP_SELECTION |
---|
| 111 | , true |
---|
[916] | 112 | #endif |
---|
[313] | 113 | ); |
---|
| 114 | } |
---|
| 115 | |
---|
[916] | 116 | m_ctuTsToRsAddrMap = new UInt[m_numCtusInFrame+1]; |
---|
| 117 | m_puiTileIdxMap = new UInt[m_numCtusInFrame]; |
---|
| 118 | m_ctuRsToTsAddrMap = new UInt[m_numCtusInFrame+1]; |
---|
| 119 | |
---|
[442] | 120 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
[916] | 121 | m_piTileSetIdxMap = new Int[m_numCtusInFrame]; |
---|
| 122 | m_pucTileSetType = new UChar[m_numCtusInFrame]; |
---|
| 123 | m_pbSkippedTileSetFlag = new Bool[m_numCtusInFrame]; |
---|
| 124 | #endif |
---|
[313] | 125 | |
---|
[916] | 126 | for( i=0; i<m_numCtusInFrame; i++ ) |
---|
[313] | 127 | { |
---|
[916] | 128 | m_ctuTsToRsAddrMap[i] = i; |
---|
| 129 | m_ctuRsToTsAddrMap[i] = i; |
---|
[313] | 130 | } |
---|
[540] | 131 | |
---|
[916] | 132 | m_saoBlkParams = new SAOBlkParam[m_numCtusInFrame]; |
---|
[313] | 133 | } |
---|
| 134 | |
---|
| 135 | Void TComPicSym::destroy() |
---|
| 136 | { |
---|
| 137 | if (m_uiNumAllocatedSlice>0) |
---|
| 138 | { |
---|
| 139 | for (Int i = 0; i<m_uiNumAllocatedSlice ; i++ ) |
---|
| 140 | { |
---|
| 141 | delete m_apcTComSlice[i]; |
---|
| 142 | } |
---|
| 143 | delete [] m_apcTComSlice; |
---|
| 144 | } |
---|
| 145 | m_apcTComSlice = NULL; |
---|
[916] | 146 | |
---|
| 147 | for (Int i = 0; i < m_numCtusInFrame; i++) |
---|
[313] | 148 | { |
---|
[916] | 149 | m_pictureCtuArray[i]->destroy(); |
---|
| 150 | delete m_pictureCtuArray[i]; |
---|
| 151 | m_pictureCtuArray[i] = NULL; |
---|
[313] | 152 | } |
---|
[916] | 153 | delete [] m_pictureCtuArray; |
---|
| 154 | m_pictureCtuArray = NULL; |
---|
[313] | 155 | |
---|
[916] | 156 | delete [] m_ctuTsToRsAddrMap; |
---|
| 157 | m_ctuTsToRsAddrMap = NULL; |
---|
[313] | 158 | |
---|
| 159 | delete [] m_puiTileIdxMap; |
---|
| 160 | m_puiTileIdxMap = NULL; |
---|
[442] | 161 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
| 162 | delete [] m_piTileSetIdxMap; |
---|
| 163 | m_piTileSetIdxMap = NULL; |
---|
| 164 | delete [] m_pucTileSetType; |
---|
| 165 | m_pucTileSetType = NULL; |
---|
| 166 | delete [] m_pbSkippedTileSetFlag; |
---|
| 167 | m_pbSkippedTileSetFlag = NULL; |
---|
| 168 | #endif |
---|
[313] | 169 | |
---|
[916] | 170 | delete [] m_ctuRsToTsAddrMap; |
---|
| 171 | m_ctuRsToTsAddrMap = NULL; |
---|
| 172 | |
---|
[540] | 173 | if(m_saoBlkParams) |
---|
| 174 | { |
---|
| 175 | delete[] m_saoBlkParams; m_saoBlkParams = NULL; |
---|
| 176 | } |
---|
[313] | 177 | } |
---|
| 178 | |
---|
| 179 | Void TComPicSym::allocateNewSlice() |
---|
| 180 | { |
---|
[916] | 181 | assert ((m_uiNumAllocatedSlice + 1) <= m_numCtusInFrame); |
---|
[313] | 182 | m_apcTComSlice[m_uiNumAllocatedSlice ++] = new TComSlice; |
---|
| 183 | if (m_uiNumAllocatedSlice>=2) |
---|
| 184 | { |
---|
| 185 | m_apcTComSlice[m_uiNumAllocatedSlice-1]->copySliceInfo( m_apcTComSlice[m_uiNumAllocatedSlice-2] ); |
---|
| 186 | #if SVC_EXTENSION |
---|
| 187 | m_apcTComSlice[m_uiNumAllocatedSlice-1]->initSlice( m_apcTComSlice[m_uiNumAllocatedSlice-1]->getLayerId() ); |
---|
| 188 | #else |
---|
| 189 | m_apcTComSlice[m_uiNumAllocatedSlice-1]->initSlice(); |
---|
| 190 | #endif |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | Void TComPicSym::clearSliceBuffer() |
---|
| 195 | { |
---|
| 196 | UInt i; |
---|
| 197 | for (i = 1; i < m_uiNumAllocatedSlice; i++) |
---|
| 198 | { |
---|
| 199 | delete m_apcTComSlice[i]; |
---|
| 200 | } |
---|
| 201 | m_uiNumAllocatedSlice = 1; |
---|
| 202 | } |
---|
| 203 | |
---|
[916] | 204 | Void TComPicSym::initCtuTsRsAddrMaps() |
---|
[313] | 205 | { |
---|
[916] | 206 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
| 207 | for(Int ctuTsAddr=0, ctuRsAddr=0; ctuTsAddr<getNumberOfCtusInFrame(); ctuTsAddr++, ctuRsAddr = xCalculateNextCtuRSAddr(ctuRsAddr)) |
---|
| 208 | { |
---|
| 209 | setCtuTsToRsAddrMap(ctuTsAddr, ctuRsAddr); |
---|
| 210 | setCtuRsToTsAddrMap(ctuRsAddr, ctuTsAddr); |
---|
| 211 | } |
---|
| 212 | setCtuTsToRsAddrMap(getNumberOfCtusInFrame(), getNumberOfCtusInFrame()); |
---|
| 213 | setCtuRsToTsAddrMap(getNumberOfCtusInFrame(), getNumberOfCtusInFrame()); |
---|
[313] | 214 | } |
---|
| 215 | |
---|
[823] | 216 | Void TComPicSym::initTiles(TComPPS *pps) |
---|
[313] | 217 | { |
---|
[823] | 218 | //set NumColumnsMinus1 and NumRowsMinus1 |
---|
[916] | 219 | setNumTileColumnsMinus1( pps->getNumTileColumnsMinus1() ); |
---|
| 220 | setNumTileRowsMinus1( pps->getNumTileRowsMinus1() ); |
---|
[823] | 221 | |
---|
| 222 | const Int numCols = pps->getNumTileColumnsMinus1() + 1; |
---|
[916] | 223 | const Int numRows = pps->getNumTileRowsMinus1() + 1; |
---|
[823] | 224 | const Int numTiles = numRows * numCols; |
---|
| 225 | |
---|
| 226 | // allocate memory for tile parameters |
---|
| 227 | m_tileParameters.resize(numTiles); |
---|
| 228 | |
---|
| 229 | if( pps->getTileUniformSpacingFlag() ) |
---|
[313] | 230 | { |
---|
[823] | 231 | //set width and height for each (uniform) tile |
---|
| 232 | for(Int row=0; row < numRows; row++) |
---|
[916] | 233 | { |
---|
[823] | 234 | for(Int col=0; col < numCols; col++) |
---|
| 235 | { |
---|
| 236 | const Int tileIdx = row * numCols + col; |
---|
[916] | 237 | m_tileParameters[tileIdx].setTileWidthInCtus( (col+1)*getFrameWidthInCtus( )/numCols - (col*getFrameWidthInCtus( ))/numCols ); |
---|
| 238 | m_tileParameters[tileIdx].setTileHeightInCtus( (row+1)*getFrameHeightInCtus()/numRows - (row*getFrameHeightInCtus())/numRows ); |
---|
[823] | 239 | } |
---|
| 240 | } |
---|
[313] | 241 | } |
---|
[823] | 242 | else |
---|
| 243 | { |
---|
| 244 | //set the width for each tile |
---|
| 245 | for(Int row=0; row < numRows; row++) |
---|
| 246 | { |
---|
| 247 | Int cumulativeTileWidth = 0; |
---|
[916] | 248 | for(Int col=0; col < getNumTileColumnsMinus1(); col++) |
---|
[823] | 249 | { |
---|
[916] | 250 | m_tileParameters[row * numCols + col].setTileWidthInCtus( pps->getTileColumnWidth(col) ); |
---|
[823] | 251 | cumulativeTileWidth += pps->getTileColumnWidth(col); |
---|
| 252 | } |
---|
[916] | 253 | m_tileParameters[row * numCols + getNumTileColumnsMinus1()].setTileWidthInCtus( getFrameWidthInCtus()-cumulativeTileWidth ); |
---|
| 254 | } |
---|
[313] | 255 | |
---|
[823] | 256 | //set the height for each tile |
---|
| 257 | for(Int col=0; col < numCols; col++) |
---|
| 258 | { |
---|
| 259 | Int cumulativeTileHeight = 0; |
---|
[916] | 260 | for(Int row=0; row < getNumTileRowsMinus1(); row++) |
---|
[823] | 261 | { |
---|
[916] | 262 | m_tileParameters[row * numCols + col].setTileHeightInCtus( pps->getTileRowHeight(row) ); |
---|
[823] | 263 | cumulativeTileHeight += pps->getTileRowHeight(row); |
---|
| 264 | } |
---|
[916] | 265 | m_tileParameters[getNumTileRowsMinus1() * numCols + col].setTileHeightInCtus( getFrameHeightInCtus()-cumulativeTileHeight ); |
---|
[823] | 266 | } |
---|
| 267 | } |
---|
[313] | 268 | |
---|
[823] | 269 | #if TILE_SIZE_CHECK |
---|
| 270 | Int minWidth = 1; |
---|
| 271 | Int minHeight = 1; |
---|
| 272 | const Int profileIdc = pps->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc(); |
---|
[916] | 273 | if ( profileIdc == Profile::MAIN || profileIdc == Profile::MAIN10) //TODO: add more profiles to the tile-size check... |
---|
[823] | 274 | { |
---|
| 275 | if (pps->getTilesEnabledFlag()) |
---|
| 276 | { |
---|
| 277 | minHeight = 64 / g_uiMaxCUHeight; |
---|
| 278 | minWidth = 256 / g_uiMaxCUWidth; |
---|
| 279 | } |
---|
| 280 | } |
---|
| 281 | for(Int row=0; row < numRows; row++) |
---|
| 282 | { |
---|
| 283 | for(Int col=0; col < numCols; col++) |
---|
| 284 | { |
---|
| 285 | const Int tileIdx = row * numCols + col; |
---|
[916] | 286 | assert (m_tileParameters[tileIdx].getTileWidthInCtus() >= minWidth); |
---|
| 287 | assert (m_tileParameters[tileIdx].getTileHeightInCtus() >= minHeight); |
---|
[823] | 288 | } |
---|
| 289 | } |
---|
| 290 | #endif |
---|
| 291 | |
---|
[313] | 292 | //initialize each tile of the current picture |
---|
[823] | 293 | for( Int row=0; row < numRows; row++ ) |
---|
[313] | 294 | { |
---|
[823] | 295 | for( Int col=0; col < numCols; col++ ) |
---|
[313] | 296 | { |
---|
[823] | 297 | const Int tileIdx = row * numCols + col; |
---|
[313] | 298 | |
---|
| 299 | //initialize the RightEdgePosInCU for each tile |
---|
[823] | 300 | Int rightEdgePosInCTU = 0; |
---|
| 301 | for( Int i=0; i <= col; i++ ) |
---|
[313] | 302 | { |
---|
[916] | 303 | rightEdgePosInCTU += m_tileParameters[row * numCols + i].getTileWidthInCtus(); |
---|
[313] | 304 | } |
---|
[916] | 305 | m_tileParameters[tileIdx].setRightEdgePosInCtus(rightEdgePosInCTU-1); |
---|
[313] | 306 | |
---|
| 307 | //initialize the BottomEdgePosInCU for each tile |
---|
[823] | 308 | Int bottomEdgePosInCTU = 0; |
---|
| 309 | for( Int i=0; i <= row; i++ ) |
---|
[313] | 310 | { |
---|
[916] | 311 | bottomEdgePosInCTU += m_tileParameters[i * numCols + col].getTileHeightInCtus(); |
---|
[313] | 312 | } |
---|
[916] | 313 | m_tileParameters[tileIdx].setBottomEdgePosInCtus(bottomEdgePosInCTU-1); |
---|
[313] | 314 | |
---|
| 315 | //initialize the FirstCUAddr for each tile |
---|
[916] | 316 | m_tileParameters[tileIdx].setFirstCtuRsAddr( (m_tileParameters[tileIdx].getBottomEdgePosInCtus() - m_tileParameters[tileIdx].getTileHeightInCtus() + 1) * getFrameWidthInCtus() + |
---|
| 317 | m_tileParameters[tileIdx].getRightEdgePosInCtus() - m_tileParameters[tileIdx].getTileWidthInCtus() + 1); |
---|
[313] | 318 | } |
---|
| 319 | } |
---|
| 320 | |
---|
[823] | 321 | Int columnIdx = 0; |
---|
| 322 | Int rowIdx = 0; |
---|
| 323 | |
---|
[313] | 324 | //initialize the TileIdxMap |
---|
[916] | 325 | for( Int i=0; i<m_numCtusInFrame; i++) |
---|
[313] | 326 | { |
---|
[823] | 327 | for( Int col=0; col < numCols; col++) |
---|
[313] | 328 | { |
---|
[916] | 329 | if(i % getFrameWidthInCtus() <= m_tileParameters[col].getRightEdgePosInCtus()) |
---|
[313] | 330 | { |
---|
[823] | 331 | columnIdx = col; |
---|
| 332 | break; |
---|
[313] | 333 | } |
---|
| 334 | } |
---|
[823] | 335 | for(Int row=0; row < numRows; row++) |
---|
[313] | 336 | { |
---|
[916] | 337 | if(i / getFrameWidthInCtus() <= m_tileParameters[row*numCols].getBottomEdgePosInCtus()) |
---|
[313] | 338 | { |
---|
[823] | 339 | rowIdx = row; |
---|
| 340 | break; |
---|
[313] | 341 | } |
---|
| 342 | } |
---|
[823] | 343 | m_puiTileIdxMap[i] = rowIdx * numCols + columnIdx; |
---|
[313] | 344 | } |
---|
| 345 | } |
---|
[916] | 346 | UInt TComPicSym::xCalculateNextCtuRSAddr( UInt currCtuRsAddr ) |
---|
[313] | 347 | { |
---|
[916] | 348 | UInt nextCtuRsAddr; |
---|
[313] | 349 | |
---|
[916] | 350 | //get the tile index for the current CTU |
---|
| 351 | const UInt uiTileIdx = getTileIdxMap(currCtuRsAddr); |
---|
| 352 | |
---|
| 353 | //get the raster scan address for the next CTU |
---|
| 354 | if( currCtuRsAddr % m_frameWidthInCtus == getTComTile(uiTileIdx)->getRightEdgePosInCtus() && currCtuRsAddr / m_frameWidthInCtus == getTComTile(uiTileIdx)->getBottomEdgePosInCtus() ) |
---|
| 355 | //the current CTU is the last CTU of the tile |
---|
[313] | 356 | { |
---|
[916] | 357 | if(uiTileIdx+1 == getNumTiles()) |
---|
[313] | 358 | { |
---|
[916] | 359 | nextCtuRsAddr = m_numCtusInFrame; |
---|
[313] | 360 | } |
---|
| 361 | else |
---|
| 362 | { |
---|
[916] | 363 | nextCtuRsAddr = getTComTile(uiTileIdx+1)->getFirstCtuRsAddr(); |
---|
[313] | 364 | } |
---|
[916] | 365 | } |
---|
| 366 | else //the current CTU is not the last CTU of the tile |
---|
[313] | 367 | { |
---|
[916] | 368 | if( currCtuRsAddr % m_frameWidthInCtus == getTComTile(uiTileIdx)->getRightEdgePosInCtus() ) //the current CTU is on the rightmost edge of the tile |
---|
[313] | 369 | { |
---|
[916] | 370 | nextCtuRsAddr = currCtuRsAddr + m_frameWidthInCtus - getTComTile(uiTileIdx)->getTileWidthInCtus() + 1; |
---|
[313] | 371 | } |
---|
| 372 | else |
---|
| 373 | { |
---|
[916] | 374 | nextCtuRsAddr = currCtuRsAddr + 1; |
---|
[313] | 375 | } |
---|
| 376 | } |
---|
| 377 | |
---|
[916] | 378 | return nextCtuRsAddr; |
---|
[313] | 379 | } |
---|
| 380 | |
---|
[916] | 381 | Void TComPicSym::deriveLoopFilterBoundaryAvailibility(Int ctuRsAddr, |
---|
[540] | 382 | Bool& isLeftAvail, |
---|
| 383 | Bool& isRightAvail, |
---|
| 384 | Bool& isAboveAvail, |
---|
| 385 | Bool& isBelowAvail, |
---|
| 386 | Bool& isAboveLeftAvail, |
---|
| 387 | Bool& isAboveRightAvail, |
---|
| 388 | Bool& isBelowLeftAvail, |
---|
| 389 | Bool& isBelowRightAvail |
---|
| 390 | ) |
---|
| 391 | { |
---|
| 392 | |
---|
[916] | 393 | isLeftAvail = (ctuRsAddr % m_frameWidthInCtus != 0); |
---|
| 394 | isRightAvail = (ctuRsAddr % m_frameWidthInCtus != m_frameWidthInCtus-1); |
---|
| 395 | isAboveAvail = (ctuRsAddr >= m_frameWidthInCtus ); |
---|
| 396 | isBelowAvail = (ctuRsAddr < m_numCtusInFrame - m_frameWidthInCtus); |
---|
[540] | 397 | isAboveLeftAvail = (isAboveAvail && isLeftAvail); |
---|
| 398 | isAboveRightAvail= (isAboveAvail && isRightAvail); |
---|
| 399 | isBelowLeftAvail = (isBelowAvail && isLeftAvail); |
---|
| 400 | isBelowRightAvail= (isBelowAvail && isRightAvail); |
---|
| 401 | |
---|
[916] | 402 | Bool isLoopFiltAcrossTilePPS = getCtu(ctuRsAddr)->getSlice()->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); |
---|
[540] | 403 | |
---|
| 404 | { |
---|
[916] | 405 | TComDataCU* ctuCurr = getCtu(ctuRsAddr); |
---|
| 406 | TComDataCU* ctuLeft = isLeftAvail ?getCtu(ctuRsAddr-1):NULL; |
---|
| 407 | TComDataCU* ctuRight = isRightAvail?getCtu(ctuRsAddr+1):NULL; |
---|
| 408 | TComDataCU* ctuAbove = isAboveAvail?getCtu(ctuRsAddr-m_frameWidthInCtus):NULL; |
---|
| 409 | TComDataCU* ctuBelow = isBelowAvail?getCtu(ctuRsAddr+m_frameWidthInCtus):NULL; |
---|
| 410 | TComDataCU* ctuAboveLeft = isAboveLeftAvail ? getCtu(ctuRsAddr-m_frameWidthInCtus-1):NULL; |
---|
| 411 | TComDataCU* ctuAboveRight = isAboveRightAvail? getCtu(ctuRsAddr-m_frameWidthInCtus+1):NULL; |
---|
| 412 | TComDataCU* ctuBelowLeft = isBelowLeftAvail ? getCtu(ctuRsAddr+m_frameWidthInCtus-1):NULL; |
---|
| 413 | TComDataCU* ctuBelowRight = isBelowRightAvail? getCtu(ctuRsAddr+m_frameWidthInCtus+1):NULL; |
---|
[540] | 414 | |
---|
| 415 | { |
---|
| 416 | //left |
---|
| 417 | if(ctuLeft != NULL) |
---|
| 418 | { |
---|
[916] | 419 | isLeftAvail = (ctuCurr->getSlice()->getSliceCurStartCtuTsAddr() != ctuLeft->getSlice()->getSliceCurStartCtuTsAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true; |
---|
[540] | 420 | } |
---|
| 421 | //above |
---|
| 422 | if(ctuAbove != NULL) |
---|
| 423 | { |
---|
[916] | 424 | isAboveAvail = (ctuCurr->getSlice()->getSliceCurStartCtuTsAddr() != ctuAbove->getSlice()->getSliceCurStartCtuTsAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true; |
---|
[540] | 425 | } |
---|
| 426 | //right |
---|
| 427 | if(ctuRight != NULL) |
---|
| 428 | { |
---|
[916] | 429 | isRightAvail = (ctuCurr->getSlice()->getSliceCurStartCtuTsAddr() != ctuRight->getSlice()->getSliceCurStartCtuTsAddr())?ctuRight->getSlice()->getLFCrossSliceBoundaryFlag():true; |
---|
[540] | 430 | } |
---|
| 431 | //below |
---|
| 432 | if(ctuBelow != NULL) |
---|
| 433 | { |
---|
[916] | 434 | isBelowAvail = (ctuCurr->getSlice()->getSliceCurStartCtuTsAddr() != ctuBelow->getSlice()->getSliceCurStartCtuTsAddr())?ctuBelow->getSlice()->getLFCrossSliceBoundaryFlag():true; |
---|
[540] | 435 | } |
---|
| 436 | //above-left |
---|
| 437 | if(ctuAboveLeft != NULL) |
---|
| 438 | { |
---|
[916] | 439 | isAboveLeftAvail = (ctuCurr->getSlice()->getSliceCurStartCtuTsAddr() != ctuAboveLeft->getSlice()->getSliceCurStartCtuTsAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true; |
---|
[540] | 440 | } |
---|
| 441 | //below-right |
---|
| 442 | if(ctuBelowRight != NULL) |
---|
| 443 | { |
---|
[916] | 444 | isBelowRightAvail = (ctuCurr->getSlice()->getSliceCurStartCtuTsAddr() != ctuBelowRight->getSlice()->getSliceCurStartCtuTsAddr())?ctuBelowRight->getSlice()->getLFCrossSliceBoundaryFlag():true; |
---|
[540] | 445 | } |
---|
| 446 | |
---|
| 447 | //above-right |
---|
[916] | 448 | if(ctuAboveRight != NULL) |
---|
[540] | 449 | { |
---|
[916] | 450 | Int curSliceStartTsAddr = ctuCurr->getSlice()->getSliceCurStartCtuTsAddr(); |
---|
| 451 | Int aboveRightSliceStartTsAddr = ctuAboveRight->getSlice()->getSliceCurStartCtuTsAddr(); |
---|
[540] | 452 | |
---|
[916] | 453 | isAboveRightAvail = (curSliceStartTsAddr == aboveRightSliceStartTsAddr)?(true): |
---|
[540] | 454 | ( |
---|
[916] | 455 | (curSliceStartTsAddr > aboveRightSliceStartTsAddr)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag()) |
---|
| 456 | :(ctuAboveRight->getSlice()->getLFCrossSliceBoundaryFlag()) |
---|
| 457 | ); |
---|
[540] | 458 | } |
---|
| 459 | //below-left |
---|
| 460 | if(ctuBelowLeft != NULL) |
---|
| 461 | { |
---|
[916] | 462 | Int curSliceStartTsAddr = ctuCurr->getSlice()->getSliceCurStartCtuTsAddr(); |
---|
| 463 | Int belowLeftSliceStartTsAddr = ctuBelowLeft->getSlice()->getSliceCurStartCtuTsAddr(); |
---|
[540] | 464 | |
---|
[916] | 465 | isBelowLeftAvail = (curSliceStartTsAddr == belowLeftSliceStartTsAddr)?(true): |
---|
[540] | 466 | ( |
---|
[916] | 467 | (curSliceStartTsAddr > belowLeftSliceStartTsAddr)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag()) |
---|
[540] | 468 | :(ctuBelowLeft->getSlice()->getLFCrossSliceBoundaryFlag()) |
---|
| 469 | ); |
---|
[916] | 470 | } |
---|
[540] | 471 | } |
---|
| 472 | |
---|
| 473 | if(!isLoopFiltAcrossTilePPS) |
---|
[916] | 474 | { |
---|
| 475 | isLeftAvail = (!isLeftAvail ) ?false:(getTileIdxMap( ctuLeft->getCtuRsAddr() ) == getTileIdxMap( ctuRsAddr )); |
---|
| 476 | isAboveAvail = (!isAboveAvail ) ?false:(getTileIdxMap( ctuAbove->getCtuRsAddr() ) == getTileIdxMap( ctuRsAddr )); |
---|
| 477 | isRightAvail = (!isRightAvail ) ?false:(getTileIdxMap( ctuRight->getCtuRsAddr() ) == getTileIdxMap( ctuRsAddr )); |
---|
| 478 | isBelowAvail = (!isBelowAvail ) ?false:(getTileIdxMap( ctuBelow->getCtuRsAddr() ) == getTileIdxMap( ctuRsAddr )); |
---|
| 479 | isAboveLeftAvail = (!isAboveLeftAvail ) ?false:(getTileIdxMap( ctuAboveLeft->getCtuRsAddr() ) == getTileIdxMap( ctuRsAddr )); |
---|
| 480 | isAboveRightAvail= (!isAboveRightAvail) ?false:(getTileIdxMap( ctuAboveRight->getCtuRsAddr() ) == getTileIdxMap( ctuRsAddr )); |
---|
| 481 | isBelowLeftAvail = (!isBelowLeftAvail ) ?false:(getTileIdxMap( ctuBelowLeft->getCtuRsAddr() ) == getTileIdxMap( ctuRsAddr )); |
---|
| 482 | isBelowRightAvail= (!isBelowRightAvail) ?false:(getTileIdxMap( ctuBelowRight->getCtuRsAddr() ) == getTileIdxMap( ctuRsAddr )); |
---|
[540] | 483 | } |
---|
| 484 | } |
---|
| 485 | |
---|
| 486 | } |
---|
[313] | 487 | |
---|
[916] | 488 | |
---|
[313] | 489 | TComTile::TComTile() |
---|
[916] | 490 | : m_tileWidthInCtus (0) |
---|
| 491 | , m_tileHeightInCtus (0) |
---|
| 492 | , m_rightEdgePosInCtus (0) |
---|
| 493 | , m_bottomEdgePosInCtus (0) |
---|
| 494 | , m_firstCtuRsAddr (0) |
---|
[313] | 495 | { |
---|
| 496 | } |
---|
| 497 | |
---|
| 498 | TComTile::~TComTile() |
---|
| 499 | { |
---|
| 500 | } |
---|
| 501 | //! \} |
---|