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