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