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