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