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