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