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