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