[208] | 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 |
---|
[1246] | 4 | * granted under this license. |
---|
[208] | 5 | * |
---|
[1259] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[208] | 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 TComDataCU.cpp |
---|
| 35 | \brief CU data structure |
---|
| 36 | \todo not all entities are documented |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #include "TComDataCU.h" |
---|
[1029] | 40 | #include "TComTU.h" |
---|
[208] | 41 | #include "TComPic.h" |
---|
| 42 | |
---|
| 43 | //! \ingroup TLibCommon |
---|
| 44 | //! \{ |
---|
| 45 | |
---|
| 46 | // ==================================================================================================================== |
---|
| 47 | // Constructor / destructor / create / destroy |
---|
| 48 | // ==================================================================================================================== |
---|
| 49 | |
---|
| 50 | TComDataCU::TComDataCU() |
---|
| 51 | { |
---|
| 52 | m_pcPic = NULL; |
---|
| 53 | m_pcSlice = NULL; |
---|
| 54 | m_puhDepth = NULL; |
---|
[1029] | 55 | |
---|
[208] | 56 | m_skipFlag = NULL; |
---|
| 57 | |
---|
| 58 | m_pePartSize = NULL; |
---|
| 59 | m_pePredMode = NULL; |
---|
| 60 | m_CUTransquantBypass = NULL; |
---|
| 61 | m_puhWidth = NULL; |
---|
| 62 | m_puhHeight = NULL; |
---|
| 63 | m_phQP = NULL; |
---|
[1029] | 64 | m_ChromaQpAdj = NULL; |
---|
[208] | 65 | m_pbMergeFlag = NULL; |
---|
| 66 | m_puhMergeIndex = NULL; |
---|
[1029] | 67 | for(UInt i=0; i<MAX_NUM_CHANNEL_TYPE; i++) |
---|
| 68 | { |
---|
| 69 | m_puhIntraDir[i] = NULL; |
---|
| 70 | } |
---|
[208] | 71 | m_puhInterDir = NULL; |
---|
| 72 | m_puhTrIdx = NULL; |
---|
[1029] | 73 | |
---|
| 74 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
| 75 | { |
---|
| 76 | m_puhCbf[comp] = NULL; |
---|
| 77 | m_crossComponentPredictionAlpha[comp] = NULL; |
---|
| 78 | m_puhTransformSkip[comp] = NULL; |
---|
| 79 | m_pcTrCoeff[comp] = NULL; |
---|
| 80 | #if ADAPTIVE_QP_SELECTION |
---|
| 81 | m_pcArlCoeff[comp] = NULL; |
---|
| 82 | #endif |
---|
| 83 | m_pcIPCMSample[comp] = NULL; |
---|
| 84 | m_explicitRdpcmMode[comp] = NULL; |
---|
| 85 | } |
---|
| 86 | #if ADAPTIVE_QP_SELECTION |
---|
[208] | 87 | m_ArlCoeffIsAliasedAllocation = false; |
---|
| 88 | #endif |
---|
| 89 | m_pbIPCMFlag = NULL; |
---|
| 90 | |
---|
[1029] | 91 | m_pCtuAboveLeft = NULL; |
---|
| 92 | m_pCtuAboveRight = NULL; |
---|
| 93 | m_pCtuAbove = NULL; |
---|
| 94 | m_pCtuLeft = NULL; |
---|
[208] | 95 | |
---|
[1029] | 96 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 97 | { |
---|
| 98 | m_apcCUColocated[i] = NULL; |
---|
| 99 | m_apiMVPIdx[i] = NULL; |
---|
| 100 | m_apiMVPNum[i] = NULL; |
---|
| 101 | } |
---|
| 102 | |
---|
[208] | 103 | m_bDecSubCu = false; |
---|
[1418] | 104 | |
---|
| 105 | #if FAST_INTRA_SHVC |
---|
| 106 | ::memset( m_reducedSetIntraModes, 0, sizeof(m_reducedSetIntraModes) ); |
---|
| 107 | #endif |
---|
[208] | 108 | } |
---|
| 109 | |
---|
| 110 | TComDataCU::~TComDataCU() |
---|
| 111 | { |
---|
| 112 | } |
---|
| 113 | |
---|
[1029] | 114 | Void TComDataCU::create( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
[208] | 115 | #if ADAPTIVE_QP_SELECTION |
---|
[1296] | 116 | , TCoeff *pParentARLBuffer |
---|
[1029] | 117 | #endif |
---|
[208] | 118 | ) |
---|
| 119 | { |
---|
| 120 | m_bDecSubCu = bDecSubCu; |
---|
[1029] | 121 | |
---|
[208] | 122 | m_pcPic = NULL; |
---|
| 123 | m_pcSlice = NULL; |
---|
| 124 | m_uiNumPartition = uiNumPartition; |
---|
| 125 | m_unitSize = unitSize; |
---|
[1029] | 126 | |
---|
[208] | 127 | if ( !bDecSubCu ) |
---|
| 128 | { |
---|
[1442] | 129 | m_phQP = (SChar* )xMalloc(SChar, uiNumPartition); |
---|
[208] | 130 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 131 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 132 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 133 | |
---|
[1029] | 134 | m_ChromaQpAdj = new UChar[ uiNumPartition ]; |
---|
[208] | 135 | m_skipFlag = new Bool[ uiNumPartition ]; |
---|
[1442] | 136 | m_pePartSize = new SChar[ uiNumPartition ]; |
---|
[1029] | 137 | memset( m_pePartSize, NUMBER_OF_PART_SIZES,uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
[1442] | 138 | m_pePredMode = new SChar[ uiNumPartition ]; |
---|
[208] | 139 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
---|
[1029] | 140 | |
---|
[208] | 141 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
| 142 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
[1029] | 143 | |
---|
| 144 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 145 | { |
---|
| 146 | m_puhIntraDir[ch] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 147 | } |
---|
[208] | 148 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
[1029] | 149 | |
---|
[208] | 150 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 151 | |
---|
[1029] | 152 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 153 | { |
---|
| 154 | const RefPicList rpl=RefPicList(i); |
---|
[1442] | 155 | m_apiMVPIdx[rpl] = new SChar[ uiNumPartition ]; |
---|
| 156 | m_apiMVPNum[rpl] = new SChar[ uiNumPartition ]; |
---|
| 157 | memset( m_apiMVPIdx[rpl], -1,uiNumPartition * sizeof( SChar ) ); |
---|
[1029] | 158 | } |
---|
| 159 | |
---|
| 160 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
| 161 | { |
---|
| 162 | const ComponentID compID = ComponentID(comp); |
---|
| 163 | const UInt chromaShift = getComponentScaleX(compID, chromaFormatIDC) + getComponentScaleY(compID, chromaFormatIDC); |
---|
| 164 | const UInt totalSize = (uiWidth * uiHeight) >> chromaShift; |
---|
| 165 | |
---|
[1442] | 166 | m_crossComponentPredictionAlpha[compID] = (SChar* )xMalloc(SChar, uiNumPartition); |
---|
[1029] | 167 | m_puhTransformSkip[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 168 | m_explicitRdpcmMode[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 169 | m_puhCbf[compID] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 170 | m_pcTrCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); |
---|
| 171 | memset( m_pcTrCoeff[compID], 0, (totalSize * sizeof( TCoeff )) ); |
---|
| 172 | |
---|
[713] | 173 | #if ADAPTIVE_QP_SELECTION |
---|
[1296] | 174 | if( pParentARLBuffer != 0 ) |
---|
[208] | 175 | { |
---|
[1296] | 176 | m_pcArlCoeff[compID] = pParentARLBuffer; |
---|
[1029] | 177 | m_ArlCoeffIsAliasedAllocation = true; |
---|
[1296] | 178 | pParentARLBuffer += totalSize; |
---|
[208] | 179 | } |
---|
[1029] | 180 | else |
---|
| 181 | { |
---|
[1246] | 182 | m_pcArlCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); |
---|
[1296] | 183 | m_ArlCoeffIsAliasedAllocation = false; |
---|
[1029] | 184 | } |
---|
| 185 | #endif |
---|
| 186 | m_pcIPCMSample[compID] = (Pel* )xMalloc(Pel , totalSize); |
---|
[208] | 187 | } |
---|
[1029] | 188 | |
---|
| 189 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
| 190 | |
---|
| 191 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[208] | 192 | { |
---|
[1029] | 193 | m_acCUMvField[i].create( uiNumPartition ); |
---|
[208] | 194 | } |
---|
| 195 | |
---|
| 196 | } |
---|
| 197 | else |
---|
| 198 | { |
---|
[1029] | 199 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 200 | { |
---|
| 201 | m_acCUMvField[i].setNumPartition(uiNumPartition ); |
---|
| 202 | } |
---|
[208] | 203 | } |
---|
[1029] | 204 | |
---|
[208] | 205 | // create motion vector fields |
---|
[1029] | 206 | |
---|
| 207 | m_pCtuAboveLeft = NULL; |
---|
| 208 | m_pCtuAboveRight = NULL; |
---|
| 209 | m_pCtuAbove = NULL; |
---|
| 210 | m_pCtuLeft = NULL; |
---|
| 211 | |
---|
| 212 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 213 | { |
---|
| 214 | m_apcCUColocated[i] = NULL; |
---|
| 215 | } |
---|
[208] | 216 | } |
---|
| 217 | |
---|
| 218 | Void TComDataCU::destroy() |
---|
| 219 | { |
---|
| 220 | // encoder-side buffer free |
---|
| 221 | if ( !m_bDecSubCu ) |
---|
| 222 | { |
---|
[1246] | 223 | if ( m_phQP ) |
---|
| 224 | { |
---|
| 225 | xFree(m_phQP); |
---|
| 226 | m_phQP = NULL; |
---|
| 227 | } |
---|
| 228 | if ( m_puhDepth ) |
---|
| 229 | { |
---|
| 230 | xFree(m_puhDepth); |
---|
| 231 | m_puhDepth = NULL; |
---|
| 232 | } |
---|
| 233 | if ( m_puhWidth ) |
---|
| 234 | { |
---|
| 235 | xFree(m_puhWidth); |
---|
| 236 | m_puhWidth = NULL; |
---|
| 237 | } |
---|
| 238 | if ( m_puhHeight ) |
---|
| 239 | { |
---|
| 240 | xFree(m_puhHeight); |
---|
| 241 | m_puhHeight = NULL; |
---|
| 242 | } |
---|
[208] | 243 | |
---|
[1246] | 244 | if ( m_skipFlag ) |
---|
| 245 | { |
---|
| 246 | delete[] m_skipFlag; |
---|
| 247 | m_skipFlag = NULL; |
---|
| 248 | } |
---|
[208] | 249 | |
---|
[1246] | 250 | if ( m_pePartSize ) |
---|
| 251 | { |
---|
| 252 | delete[] m_pePartSize; |
---|
| 253 | m_pePartSize = NULL; |
---|
| 254 | } |
---|
| 255 | if ( m_pePredMode ) |
---|
| 256 | { |
---|
| 257 | delete[] m_pePredMode; |
---|
| 258 | m_pePredMode = NULL; |
---|
| 259 | } |
---|
| 260 | if ( m_ChromaQpAdj ) |
---|
| 261 | { |
---|
| 262 | delete[] m_ChromaQpAdj; |
---|
| 263 | m_ChromaQpAdj = NULL; |
---|
| 264 | } |
---|
| 265 | if ( m_CUTransquantBypass ) |
---|
| 266 | { |
---|
| 267 | delete[] m_CUTransquantBypass; |
---|
| 268 | m_CUTransquantBypass = NULL; |
---|
| 269 | } |
---|
| 270 | if ( m_puhInterDir ) |
---|
| 271 | { |
---|
| 272 | xFree(m_puhInterDir); |
---|
| 273 | m_puhInterDir = NULL; |
---|
| 274 | } |
---|
| 275 | if ( m_pbMergeFlag ) |
---|
| 276 | { |
---|
| 277 | xFree(m_pbMergeFlag); |
---|
| 278 | m_pbMergeFlag = NULL; |
---|
| 279 | } |
---|
| 280 | if ( m_puhMergeIndex ) |
---|
| 281 | { |
---|
| 282 | xFree(m_puhMergeIndex); |
---|
| 283 | m_puhMergeIndex = NULL; |
---|
| 284 | } |
---|
[1029] | 285 | |
---|
| 286 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 287 | { |
---|
| 288 | xFree(m_puhIntraDir[ch]); |
---|
| 289 | m_puhIntraDir[ch] = NULL; |
---|
| 290 | } |
---|
| 291 | |
---|
[1246] | 292 | if ( m_puhTrIdx ) |
---|
| 293 | { |
---|
| 294 | xFree(m_puhTrIdx); |
---|
| 295 | m_puhTrIdx = NULL; |
---|
| 296 | } |
---|
[1029] | 297 | |
---|
| 298 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
| 299 | { |
---|
[1246] | 300 | if ( m_crossComponentPredictionAlpha[comp] ) |
---|
| 301 | { |
---|
| 302 | xFree(m_crossComponentPredictionAlpha[comp]); |
---|
| 303 | m_crossComponentPredictionAlpha[comp] = NULL; |
---|
| 304 | } |
---|
| 305 | if ( m_puhTransformSkip[comp] ) |
---|
| 306 | { |
---|
| 307 | xFree(m_puhTransformSkip[comp]); |
---|
| 308 | m_puhTransformSkip[comp] = NULL; |
---|
| 309 | } |
---|
| 310 | if ( m_puhCbf[comp] ) |
---|
| 311 | { |
---|
| 312 | xFree(m_puhCbf[comp]); |
---|
| 313 | m_puhCbf[comp] = NULL; |
---|
| 314 | } |
---|
| 315 | if ( m_pcTrCoeff[comp] ) |
---|
| 316 | { |
---|
| 317 | xFree(m_pcTrCoeff[comp]); |
---|
| 318 | m_pcTrCoeff[comp] = NULL; |
---|
| 319 | } |
---|
| 320 | if ( m_explicitRdpcmMode[comp] ) |
---|
| 321 | { |
---|
| 322 | xFree(m_explicitRdpcmMode[comp]); |
---|
| 323 | m_explicitRdpcmMode[comp] = NULL; |
---|
| 324 | } |
---|
[1029] | 325 | |
---|
[208] | 326 | #if ADAPTIVE_QP_SELECTION |
---|
[1029] | 327 | if (!m_ArlCoeffIsAliasedAllocation) |
---|
| 328 | { |
---|
[1246] | 329 | if ( m_pcArlCoeff[comp] ) |
---|
| 330 | { |
---|
| 331 | xFree(m_pcArlCoeff[comp]); |
---|
| 332 | m_pcArlCoeff[comp] = NULL; |
---|
| 333 | } |
---|
[1029] | 334 | } |
---|
| 335 | #endif |
---|
| 336 | |
---|
[1246] | 337 | if ( m_pcIPCMSample[comp] ) |
---|
| 338 | { |
---|
| 339 | xFree(m_pcIPCMSample[comp]); |
---|
| 340 | m_pcIPCMSample[comp] = NULL; |
---|
| 341 | } |
---|
[1029] | 342 | } |
---|
[1246] | 343 | if ( m_pbIPCMFlag ) |
---|
| 344 | { |
---|
| 345 | xFree(m_pbIPCMFlag ); |
---|
| 346 | m_pbIPCMFlag = NULL; |
---|
| 347 | } |
---|
[1029] | 348 | |
---|
| 349 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[208] | 350 | { |
---|
[1029] | 351 | const RefPicList rpl=RefPicList(i); |
---|
[1246] | 352 | if ( m_apiMVPIdx[rpl] ) |
---|
| 353 | { |
---|
| 354 | delete[] m_apiMVPIdx[rpl]; |
---|
| 355 | m_apiMVPIdx[rpl] = NULL; |
---|
| 356 | } |
---|
| 357 | if ( m_apiMVPNum[rpl] ) |
---|
| 358 | { |
---|
| 359 | delete[] m_apiMVPNum[rpl]; |
---|
| 360 | m_apiMVPNum[rpl] = NULL; |
---|
| 361 | } |
---|
[208] | 362 | } |
---|
[1029] | 363 | |
---|
| 364 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 365 | { |
---|
| 366 | const RefPicList rpl=RefPicList(i); |
---|
| 367 | m_acCUMvField[rpl].destroy(); |
---|
| 368 | } |
---|
[208] | 369 | } |
---|
| 370 | |
---|
[1029] | 371 | m_pcPic = NULL; |
---|
| 372 | m_pcSlice = NULL; |
---|
| 373 | |
---|
| 374 | m_pCtuAboveLeft = NULL; |
---|
| 375 | m_pCtuAboveRight = NULL; |
---|
| 376 | m_pCtuAbove = NULL; |
---|
| 377 | m_pCtuLeft = NULL; |
---|
| 378 | |
---|
| 379 | |
---|
| 380 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[208] | 381 | { |
---|
[1029] | 382 | m_apcCUColocated[i] = NULL; |
---|
[208] | 383 | } |
---|
[1029] | 384 | |
---|
[208] | 385 | } |
---|
| 386 | |
---|
[1029] | 387 | Bool TComDataCU::CUIsFromSameTile ( const TComDataCU *pCU /* Can be NULL */) const |
---|
| 388 | { |
---|
| 389 | return pCU!=NULL && |
---|
| 390 | pCU->getSlice() != NULL && |
---|
| 391 | m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()); |
---|
| 392 | } |
---|
| 393 | |
---|
| 394 | Bool TComDataCU::CUIsFromSameSliceAndTile ( const TComDataCU *pCU /* Can be NULL */) const |
---|
| 395 | { |
---|
| 396 | return pCU!=NULL && |
---|
| 397 | pCU->getSlice() != NULL && |
---|
| 398 | pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() && |
---|
| 399 | m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()) |
---|
| 400 | ; |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | Bool TComDataCU::CUIsFromSameSliceTileAndWavefrontRow( const TComDataCU *pCU /* Can be NULL */) const |
---|
| 404 | { |
---|
| 405 | return CUIsFromSameSliceAndTile(pCU) |
---|
| 406 | && (!getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() || getPic()->getCtu(getCtuRsAddr())->getCUPelY() == getPic()->getCtu(pCU->getCtuRsAddr())->getCUPelY()); |
---|
| 407 | } |
---|
| 408 | |
---|
[1465] | 409 | Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx) const |
---|
[1029] | 410 | { |
---|
[1289] | 411 | const TComSPS &sps=*(getSlice()->getSPS()); |
---|
[1029] | 412 | |
---|
[1289] | 413 | const UInt picWidth = sps.getPicWidthInLumaSamples(); |
---|
| 414 | const UInt picHeight = sps.getPicHeightInLumaSamples(); |
---|
| 415 | const UInt granularityWidth = sps.getMaxCUWidth(); |
---|
[1029] | 416 | |
---|
| 417 | const UInt cuPosX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[absPartIdx] ]; |
---|
| 418 | const UInt cuPosY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[absPartIdx] ]; |
---|
| 419 | |
---|
| 420 | return (((cuPosX+getWidth( absPartIdx))%granularityWidth==0||(cuPosX+getWidth( absPartIdx)==picWidth )) |
---|
| 421 | && ((cuPosY+getHeight(absPartIdx))%granularityWidth==0||(cuPosY+getHeight(absPartIdx)==picHeight))); |
---|
| 422 | } |
---|
| 423 | |
---|
[208] | 424 | // ==================================================================================================================== |
---|
| 425 | // Public member functions |
---|
| 426 | // ==================================================================================================================== |
---|
| 427 | |
---|
| 428 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 429 | // Initialization |
---|
| 430 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 431 | |
---|
| 432 | /** |
---|
[1258] | 433 | Initialize top-level CU: create internal buffers and set initial values before encoding the CTU. |
---|
| 434 | |
---|
| 435 | \param pcPic picture (TComPic) class pointer |
---|
| 436 | \param ctuRsAddr CTU address in raster scan order |
---|
[208] | 437 | */ |
---|
[1029] | 438 | Void TComDataCU::initCtu( TComPic* pcPic, UInt ctuRsAddr ) |
---|
[208] | 439 | { |
---|
| 440 | |
---|
[1289] | 441 | const UInt maxCUWidth = pcPic->getPicSym()->getSPS().getMaxCUWidth(); |
---|
| 442 | const UInt maxCUHeight= pcPic->getPicSym()->getSPS().getMaxCUHeight(); |
---|
[208] | 443 | m_pcPic = pcPic; |
---|
| 444 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
[1029] | 445 | m_ctuRsAddr = ctuRsAddr; |
---|
[1289] | 446 | m_uiCUPelX = ( ctuRsAddr % pcPic->getFrameWidthInCtus() ) * maxCUWidth; |
---|
| 447 | m_uiCUPelY = ( ctuRsAddr / pcPic->getFrameWidthInCtus() ) * maxCUHeight; |
---|
[1029] | 448 | m_absZIdxInCtu = 0; |
---|
[208] | 449 | m_dTotalCost = MAX_DOUBLE; |
---|
| 450 | m_uiTotalDistortion = 0; |
---|
| 451 | m_uiTotalBits = 0; |
---|
| 452 | m_uiTotalBins = 0; |
---|
[1029] | 453 | m_uiNumPartition = pcPic->getNumPartitionsInCtu(); |
---|
[208] | 454 | |
---|
[1029] | 455 | memset( m_skipFlag , false, m_uiNumPartition * sizeof( *m_skipFlag ) ); |
---|
| 456 | memset( m_pePartSize , NUMBER_OF_PART_SIZES, m_uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
| 457 | memset( m_pePredMode , NUMBER_OF_PREDICTION_MODES, m_uiNumPartition * sizeof( *m_pePredMode ) ); |
---|
| 458 | memset( m_CUTransquantBypass, false, m_uiNumPartition * sizeof( *m_CUTransquantBypass) ); |
---|
| 459 | memset( m_puhDepth , 0, m_uiNumPartition * sizeof( *m_puhDepth ) ); |
---|
| 460 | memset( m_puhTrIdx , 0, m_uiNumPartition * sizeof( *m_puhTrIdx ) ); |
---|
[1289] | 461 | memset( m_puhWidth , maxCUWidth, m_uiNumPartition * sizeof( *m_puhWidth ) ); |
---|
| 462 | memset( m_puhHeight , maxCUHeight, m_uiNumPartition * sizeof( *m_puhHeight ) ); |
---|
[1029] | 463 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[208] | 464 | { |
---|
[1029] | 465 | const RefPicList rpl=RefPicList(i); |
---|
| 466 | memset( m_apiMVPIdx[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPIdx[rpl] ) ); |
---|
| 467 | memset( m_apiMVPNum[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPNum[rpl] ) ); |
---|
[208] | 468 | } |
---|
[1029] | 469 | memset( m_phQP , getSlice()->getSliceQp(), m_uiNumPartition * sizeof( *m_phQP ) ); |
---|
| 470 | memset( m_ChromaQpAdj , 0, m_uiNumPartition * sizeof( *m_ChromaQpAdj ) ); |
---|
| 471 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
[208] | 472 | { |
---|
[1029] | 473 | memset( m_crossComponentPredictionAlpha[comp] , 0, m_uiNumPartition * sizeof( *m_crossComponentPredictionAlpha[comp] ) ); |
---|
| 474 | memset( m_puhTransformSkip[comp] , 0, m_uiNumPartition * sizeof( *m_puhTransformSkip[comp]) ); |
---|
| 475 | memset( m_puhCbf[comp] , 0, m_uiNumPartition * sizeof( *m_puhCbf[comp] ) ); |
---|
| 476 | memset( m_explicitRdpcmMode[comp] , NUMBER_OF_RDPCM_MODES, m_uiNumPartition * sizeof( *m_explicitRdpcmMode[comp] ) ); |
---|
[208] | 477 | } |
---|
[1029] | 478 | memset( m_pbMergeFlag , false, m_uiNumPartition * sizeof( *m_pbMergeFlag ) ); |
---|
| 479 | memset( m_puhMergeIndex , 0, m_uiNumPartition * sizeof( *m_puhMergeIndex ) ); |
---|
| 480 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
[208] | 481 | { |
---|
[1029] | 482 | memset( m_puhIntraDir[ch] , ((ch==0) ? DC_IDX : 0), m_uiNumPartition * sizeof( *(m_puhIntraDir[ch]) ) ); |
---|
[208] | 483 | } |
---|
[1029] | 484 | memset( m_puhInterDir , 0, m_uiNumPartition * sizeof( *m_puhInterDir ) ); |
---|
| 485 | memset( m_pbIPCMFlag , false, m_uiNumPartition * sizeof( *m_pbIPCMFlag ) ); |
---|
[208] | 486 | |
---|
[1289] | 487 | const UInt numCoeffY = maxCUWidth*maxCUHeight; |
---|
[1029] | 488 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
[208] | 489 | { |
---|
[1029] | 490 | const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(comp)) + m_pcPic->getComponentScaleY(ComponentID(comp)); |
---|
| 491 | memset( m_pcTrCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); |
---|
[208] | 492 | #if ADAPTIVE_QP_SELECTION |
---|
[1029] | 493 | memset( m_pcArlCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); |
---|
[208] | 494 | #endif |
---|
| 495 | } |
---|
[1029] | 496 | |
---|
| 497 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[208] | 498 | { |
---|
[1029] | 499 | m_acCUMvField[i].clearMvField(); |
---|
[208] | 500 | } |
---|
| 501 | |
---|
| 502 | // Setting neighbor CU |
---|
[1029] | 503 | m_pCtuLeft = NULL; |
---|
| 504 | m_pCtuAbove = NULL; |
---|
| 505 | m_pCtuAboveLeft = NULL; |
---|
| 506 | m_pCtuAboveRight = NULL; |
---|
[208] | 507 | |
---|
| 508 | |
---|
[1029] | 509 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[208] | 510 | { |
---|
[1029] | 511 | m_apcCUColocated[i] = NULL; |
---|
[208] | 512 | } |
---|
| 513 | |
---|
[1029] | 514 | UInt frameWidthInCtus = pcPic->getFrameWidthInCtus(); |
---|
| 515 | if ( m_ctuRsAddr % frameWidthInCtus ) |
---|
[208] | 516 | { |
---|
[1029] | 517 | m_pCtuLeft = pcPic->getCtu( m_ctuRsAddr - 1 ); |
---|
[208] | 518 | } |
---|
| 519 | |
---|
[1029] | 520 | if ( m_ctuRsAddr / frameWidthInCtus ) |
---|
[208] | 521 | { |
---|
[1029] | 522 | m_pCtuAbove = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus ); |
---|
[208] | 523 | } |
---|
| 524 | |
---|
[1029] | 525 | if ( m_pCtuLeft && m_pCtuAbove ) |
---|
[208] | 526 | { |
---|
[1029] | 527 | m_pCtuAboveLeft = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus - 1 ); |
---|
[208] | 528 | } |
---|
| 529 | |
---|
[1029] | 530 | if ( m_pCtuAbove && ( (m_ctuRsAddr%frameWidthInCtus) < (frameWidthInCtus-1) ) ) |
---|
[208] | 531 | { |
---|
[1029] | 532 | m_pCtuAboveRight = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus + 1 ); |
---|
[208] | 533 | } |
---|
| 534 | |
---|
[1029] | 535 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[208] | 536 | { |
---|
[1029] | 537 | const RefPicList rpl=RefPicList(i); |
---|
| 538 | if ( getSlice()->getNumRefIdx( rpl ) > 0 ) |
---|
| 539 | { |
---|
| 540 | m_apcCUColocated[rpl] = getSlice()->getRefPic( rpl, 0)->getCtu( m_ctuRsAddr ); |
---|
| 541 | } |
---|
[208] | 542 | } |
---|
| 543 | } |
---|
| 544 | |
---|
[1029] | 545 | |
---|
[1258] | 546 | /** Initialize prediction data with enabling sub-CTU-level delta QP. |
---|
| 547 | * - set CU width and CU height according to depth |
---|
| 548 | * - set qp value according to input qp |
---|
| 549 | * - set last-coded qp value according to input last-coded qp |
---|
| 550 | * |
---|
| 551 | * \param uiDepth depth of the current CU |
---|
| 552 | * \param qp qp for the current CU |
---|
| 553 | * \param bTransquantBypass true for transquant bypass |
---|
[208] | 554 | */ |
---|
[1029] | 555 | Void TComDataCU::initEstData( const UInt uiDepth, const Int qp, const Bool bTransquantBypass ) |
---|
[208] | 556 | { |
---|
| 557 | m_dTotalCost = MAX_DOUBLE; |
---|
| 558 | m_uiTotalDistortion = 0; |
---|
| 559 | m_uiTotalBits = 0; |
---|
| 560 | m_uiTotalBins = 0; |
---|
| 561 | |
---|
[1289] | 562 | const UChar uhWidth = getSlice()->getSPS()->getMaxCUWidth() >> uiDepth; |
---|
| 563 | const UChar uhHeight = getSlice()->getSPS()->getMaxCUHeight() >> uiDepth; |
---|
[208] | 564 | |
---|
| 565 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
| 566 | { |
---|
[1029] | 567 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[208] | 568 | { |
---|
[1029] | 569 | const RefPicList rpl=RefPicList(i); |
---|
| 570 | m_apiMVPIdx[rpl][ui] = -1; |
---|
| 571 | m_apiMVPNum[rpl][ui] = -1; |
---|
[208] | 572 | } |
---|
[1029] | 573 | m_puhDepth [ui] = uiDepth; |
---|
| 574 | m_puhWidth [ui] = uhWidth; |
---|
| 575 | m_puhHeight [ui] = uhHeight; |
---|
| 576 | m_puhTrIdx [ui] = 0; |
---|
| 577 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
| 578 | { |
---|
| 579 | m_crossComponentPredictionAlpha[comp][ui] = 0; |
---|
| 580 | m_puhTransformSkip [comp][ui] = 0; |
---|
| 581 | m_explicitRdpcmMode [comp][ui] = NUMBER_OF_RDPCM_MODES; |
---|
| 582 | } |
---|
| 583 | m_skipFlag[ui] = false; |
---|
| 584 | m_pePartSize[ui] = NUMBER_OF_PART_SIZES; |
---|
| 585 | m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; |
---|
| 586 | m_CUTransquantBypass[ui] = bTransquantBypass; |
---|
| 587 | m_pbIPCMFlag[ui] = 0; |
---|
| 588 | m_phQP[ui] = qp; |
---|
| 589 | m_ChromaQpAdj[ui] = 0; |
---|
| 590 | m_pbMergeFlag[ui] = 0; |
---|
| 591 | m_puhMergeIndex[ui] = 0; |
---|
| 592 | |
---|
| 593 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 594 | { |
---|
| 595 | m_puhIntraDir[ch][ui] = ((ch==0) ? DC_IDX : 0); |
---|
| 596 | } |
---|
| 597 | |
---|
| 598 | m_puhInterDir[ui] = 0; |
---|
| 599 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
| 600 | { |
---|
| 601 | m_puhCbf[comp][ui] = 0; |
---|
| 602 | } |
---|
[208] | 603 | } |
---|
| 604 | |
---|
[1029] | 605 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[208] | 606 | { |
---|
[1029] | 607 | m_acCUMvField[i].clearMvField(); |
---|
| 608 | } |
---|
| 609 | |
---|
| 610 | const UInt numCoeffY = uhWidth*uhHeight; |
---|
| 611 | |
---|
| 612 | for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
| 613 | { |
---|
| 614 | const ComponentID component = ComponentID(comp); |
---|
| 615 | const UInt numCoeff = numCoeffY >> (getPic()->getComponentScaleX(component) + getPic()->getComponentScaleY(component)); |
---|
| 616 | memset( m_pcTrCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); |
---|
[208] | 617 | #if ADAPTIVE_QP_SELECTION |
---|
[1029] | 618 | memset( m_pcArlCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); |
---|
[208] | 619 | #endif |
---|
[1029] | 620 | memset( m_pcIPCMSample[comp], 0, numCoeff * sizeof( Pel) ); |
---|
[208] | 621 | } |
---|
| 622 | } |
---|
| 623 | |
---|
| 624 | |
---|
| 625 | // initialize Sub partition |
---|
| 626 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
---|
| 627 | { |
---|
| 628 | assert( uiPartUnitIdx<4 ); |
---|
| 629 | |
---|
| 630 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
| 631 | |
---|
| 632 | m_pcPic = pcCU->getPic(); |
---|
[1289] | 633 | m_pcSlice = pcCU->getSlice(); |
---|
[1029] | 634 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
| 635 | m_absZIdxInCtu = pcCU->getZorderIdxInCtu() + uiPartOffset; |
---|
[208] | 636 | |
---|
[1289] | 637 | const UChar uhWidth = getSlice()->getSPS()->getMaxCUWidth() >> uiDepth; |
---|
| 638 | const UChar uhHeight = getSlice()->getSPS()->getMaxCUHeight() >> uiDepth; |
---|
[208] | 639 | |
---|
[1289] | 640 | m_uiCUPelX = pcCU->getCUPelX() + ( uhWidth )*( uiPartUnitIdx & 1 ); |
---|
| 641 | m_uiCUPelY = pcCU->getCUPelY() + ( uhHeight)*( uiPartUnitIdx >> 1 ); |
---|
| 642 | |
---|
[208] | 643 | m_dTotalCost = MAX_DOUBLE; |
---|
| 644 | m_uiTotalDistortion = 0; |
---|
| 645 | m_uiTotalBits = 0; |
---|
| 646 | m_uiTotalBins = 0; |
---|
| 647 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
| 648 | |
---|
| 649 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
| 650 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
[1442] | 651 | Int sizeInChar = sizeof( SChar ) * m_uiNumPartition; |
---|
[208] | 652 | |
---|
| 653 | memset( m_phQP, qp, sizeInChar ); |
---|
| 654 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
| 655 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
[1029] | 656 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 657 | { |
---|
| 658 | memset( m_puhIntraDir[ch], ((ch==0) ? DC_IDX : 0), iSizeInUchar ); |
---|
| 659 | } |
---|
| 660 | |
---|
[208] | 661 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
| 662 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
[1029] | 663 | |
---|
| 664 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
| 665 | { |
---|
| 666 | memset( m_crossComponentPredictionAlpha[comp], 0, iSizeInUchar ); |
---|
| 667 | memset( m_puhTransformSkip[comp], 0, iSizeInUchar ); |
---|
| 668 | memset( m_puhCbf[comp], 0, iSizeInUchar ); |
---|
| 669 | memset( m_explicitRdpcmMode[comp], NUMBER_OF_RDPCM_MODES, iSizeInUchar ); |
---|
| 670 | } |
---|
| 671 | |
---|
[208] | 672 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
| 673 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
| 674 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
| 675 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
---|
| 676 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
| 677 | { |
---|
| 678 | m_skipFlag[ui] = false; |
---|
[1029] | 679 | m_pePartSize[ui] = NUMBER_OF_PART_SIZES; |
---|
| 680 | m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; |
---|
[208] | 681 | m_CUTransquantBypass[ui] = false; |
---|
[1029] | 682 | m_ChromaQpAdj[ui] = 0; |
---|
| 683 | |
---|
| 684 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[208] | 685 | { |
---|
[1029] | 686 | const RefPicList rpl=RefPicList(i); |
---|
| 687 | m_apiMVPIdx[rpl][ui] = -1; |
---|
| 688 | m_apiMVPNum[rpl][ui] = -1; |
---|
[208] | 689 | } |
---|
| 690 | } |
---|
| 691 | |
---|
[1029] | 692 | const UInt numCoeffY = uhWidth*uhHeight; |
---|
| 693 | for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
[208] | 694 | { |
---|
[1029] | 695 | const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(ch)) + m_pcPic->getComponentScaleY(ComponentID(ch)); |
---|
| 696 | memset( m_pcTrCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
[208] | 697 | #if ADAPTIVE_QP_SELECTION |
---|
[1029] | 698 | memset( m_pcArlCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
[208] | 699 | #endif |
---|
[1029] | 700 | memset( m_pcIPCMSample[ch], 0, sizeof(Pel)* (numCoeffY>>componentShift) ); |
---|
[208] | 701 | } |
---|
| 702 | |
---|
[1029] | 703 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 704 | { |
---|
| 705 | m_acCUMvField[i].clearMvField(); |
---|
| 706 | } |
---|
[208] | 707 | |
---|
[1029] | 708 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
| 709 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
| 710 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
| 711 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
| 712 | |
---|
| 713 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 714 | { |
---|
| 715 | m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); |
---|
| 716 | } |
---|
[208] | 717 | } |
---|
| 718 | |
---|
| 719 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 720 | { |
---|
[1289] | 721 | const UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
---|
| 722 | const UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
| 723 | const TComSPS &sps = *(getSlice()->getSPS()); |
---|
| 724 | const UChar uhWidth = sps.getMaxCUWidth() >> uiDepth; |
---|
| 725 | const UChar uhHeight = sps.getMaxCUHeight() >> uiDepth; |
---|
[208] | 726 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
---|
| 727 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
---|
| 728 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
---|
| 729 | } |
---|
| 730 | |
---|
| 731 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 732 | // Copy |
---|
| 733 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 734 | |
---|
[1307] | 735 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[208] | 736 | { |
---|
| 737 | UInt uiPart = uiAbsPartIdx; |
---|
[1029] | 738 | |
---|
[208] | 739 | m_pcPic = pcCU->getPic(); |
---|
| 740 | m_pcSlice = pcCU->getSlice(); |
---|
[1029] | 741 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
| 742 | m_absZIdxInCtu = uiAbsPartIdx; |
---|
| 743 | |
---|
[208] | 744 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 745 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
[1029] | 746 | |
---|
[208] | 747 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
---|
| 748 | |
---|
| 749 | m_phQP=pcCU->getQP() + uiPart; |
---|
[1029] | 750 | m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiPart; |
---|
[208] | 751 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
---|
| 752 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
| 753 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
---|
[1029] | 754 | |
---|
[208] | 755 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
| 756 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
| 757 | |
---|
[1029] | 758 | for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 759 | { |
---|
| 760 | m_puhIntraDir[ch] = pcCU->getIntraDir(ChannelType(ch)) + uiPart; |
---|
| 761 | } |
---|
| 762 | |
---|
[208] | 763 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
| 764 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
| 765 | |
---|
[1029] | 766 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
| 767 | { |
---|
| 768 | m_crossComponentPredictionAlpha[comp] = pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)) + uiPart; |
---|
| 769 | m_puhTransformSkip[comp] = pcCU->getTransformSkip(ComponentID(comp)) + uiPart; |
---|
| 770 | m_puhCbf[comp] = pcCU->getCbf(ComponentID(comp)) + uiPart; |
---|
| 771 | m_explicitRdpcmMode[comp] = pcCU->getExplicitRdpcmMode(ComponentID(comp)) + uiPart; |
---|
| 772 | } |
---|
| 773 | |
---|
[208] | 774 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
| 775 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
| 776 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
[1029] | 777 | |
---|
[208] | 778 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
---|
| 779 | |
---|
[1029] | 780 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
| 781 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
| 782 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
| 783 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
| 784 | |
---|
| 785 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 786 | { |
---|
| 787 | const RefPicList rpl=RefPicList(i); |
---|
| 788 | m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); |
---|
| 789 | m_apiMVPIdx[rpl]=pcCU->getMVPIdx(rpl) + uiPart; |
---|
| 790 | m_apiMVPNum[rpl]=pcCU->getMVPNum(rpl) + uiPart; |
---|
| 791 | } |
---|
| 792 | |
---|
| 793 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 794 | { |
---|
| 795 | const RefPicList rpl=RefPicList(i); |
---|
| 796 | m_acCUMvField[rpl].linkToWithOffset( pcCU->getCUMvField(rpl), uiPart ); |
---|
| 797 | } |
---|
| 798 | |
---|
[208] | 799 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
| 800 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
[1029] | 801 | |
---|
| 802 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartitionsInCtu(); |
---|
| 803 | |
---|
| 804 | for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) |
---|
| 805 | { |
---|
| 806 | const ComponentID component = ComponentID(ch); |
---|
| 807 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
| 808 | const UInt offset = uiCoffOffset >> componentShift; |
---|
| 809 | m_pcTrCoeff[ch] = pcCU->getCoeff(component) + offset; |
---|
[208] | 810 | #if ADAPTIVE_QP_SELECTION |
---|
[1029] | 811 | m_pcArlCoeff[ch] = pcCU->getArlCoeff(component) + offset; |
---|
[208] | 812 | #endif |
---|
[1029] | 813 | m_pcIPCMSample[ch] = pcCU->getPCMSample(component) + offset; |
---|
| 814 | } |
---|
[208] | 815 | } |
---|
| 816 | |
---|
| 817 | // Copy inter prediction info from the biggest CU |
---|
| 818 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ) |
---|
| 819 | { |
---|
| 820 | m_pcPic = pcCU->getPic(); |
---|
| 821 | m_pcSlice = pcCU->getSlice(); |
---|
[1029] | 822 | m_ctuRsAddr = pcCU->getCtuRsAddr(); |
---|
| 823 | m_absZIdxInCtu = uiAbsPartIdx; |
---|
| 824 | |
---|
[208] | 825 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
[1029] | 826 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInCtuWidth() ); |
---|
| 827 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInCtuWidth() ); |
---|
| 828 | |
---|
| 829 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
| 830 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
| 831 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
| 832 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
| 833 | |
---|
| 834 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 835 | { |
---|
| 836 | m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); |
---|
| 837 | } |
---|
| 838 | |
---|
[208] | 839 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
---|
| 840 | |
---|
| 841 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
| 842 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
[1029] | 843 | m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiAbsPartIdx; |
---|
[208] | 844 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
---|
| 845 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
[1029] | 846 | |
---|
[208] | 847 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
| 848 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
| 849 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
[1029] | 850 | |
---|
[208] | 851 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
| 852 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
| 853 | |
---|
| 854 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
| 855 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
[1029] | 856 | |
---|
[208] | 857 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
---|
| 858 | } |
---|
| 859 | |
---|
| 860 | // Copy small CU to bigger CU. |
---|
| 861 | // One of quarter parts overwritten by predicted sub part. |
---|
| 862 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
| 863 | { |
---|
| 864 | assert( uiPartUnitIdx<4 ); |
---|
[1029] | 865 | |
---|
[208] | 866 | m_dTotalCost += pcCU->getTotalCost(); |
---|
| 867 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
| 868 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
[1029] | 869 | |
---|
[208] | 870 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
[1029] | 871 | const UInt numValidComp=pcCU->getPic()->getNumberValidComponents(); |
---|
| 872 | const UInt numValidChan=pcCU->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; |
---|
| 873 | |
---|
[208] | 874 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
| 875 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
| 876 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
[1029] | 877 | |
---|
[1442] | 878 | Int sizeInChar = sizeof( SChar ) * uiNumPartition; |
---|
[208] | 879 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
---|
| 880 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
---|
| 881 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
---|
| 882 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
---|
[1029] | 883 | memcpy( m_ChromaQpAdj + uiOffset, pcCU->getChromaQpAdj(), sizeof( *m_ChromaQpAdj ) * uiNumPartition ); |
---|
[208] | 884 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
---|
| 885 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
| 886 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
[1029] | 887 | |
---|
| 888 | for (UInt ch=0; ch<numValidChan; ch++) |
---|
| 889 | { |
---|
| 890 | memcpy( m_puhIntraDir[ch] + uiOffset, pcCU->getIntraDir(ChannelType(ch)), iSizeInUchar ); |
---|
| 891 | } |
---|
| 892 | |
---|
[208] | 893 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
| 894 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
| 895 | |
---|
[1029] | 896 | for(UInt comp=0; comp<numValidComp; comp++) |
---|
| 897 | { |
---|
| 898 | memcpy( m_crossComponentPredictionAlpha[comp] + uiOffset, pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)), iSizeInUchar ); |
---|
| 899 | memcpy( m_puhTransformSkip[comp] + uiOffset, pcCU->getTransformSkip(ComponentID(comp)) , iSizeInUchar ); |
---|
| 900 | memcpy( m_puhCbf[comp] + uiOffset, pcCU->getCbf(ComponentID(comp)) , iSizeInUchar ); |
---|
| 901 | memcpy( m_explicitRdpcmMode[comp] + uiOffset, pcCU->getExplicitRdpcmMode(ComponentID(comp)) , iSizeInUchar ); |
---|
| 902 | } |
---|
| 903 | |
---|
[208] | 904 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
| 905 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
| 906 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
[1029] | 907 | |
---|
[208] | 908 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
---|
| 909 | |
---|
[1029] | 910 | m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); |
---|
| 911 | m_pCtuAboveRight = pcCU->getCtuAboveRight(); |
---|
| 912 | m_pCtuAbove = pcCU->getCtuAbove(); |
---|
| 913 | m_pCtuLeft = pcCU->getCtuLeft(); |
---|
| 914 | |
---|
| 915 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 916 | { |
---|
| 917 | const RefPicList rpl=RefPicList(i); |
---|
| 918 | memcpy( m_apiMVPIdx[rpl] + uiOffset, pcCU->getMVPIdx(rpl), iSizeInUchar ); |
---|
| 919 | memcpy( m_apiMVPNum[rpl] + uiOffset, pcCU->getMVPNum(rpl), iSizeInUchar ); |
---|
| 920 | m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); |
---|
| 921 | } |
---|
| 922 | |
---|
| 923 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 924 | { |
---|
| 925 | const RefPicList rpl=RefPicList(i); |
---|
| 926 | m_acCUMvField[rpl].copyFrom( pcCU->getCUMvField( rpl ), pcCU->getTotalNumPart(), uiOffset ); |
---|
| 927 | } |
---|
| 928 | |
---|
[1289] | 929 | const UInt numCoeffY = (pcCU->getSlice()->getSPS()->getMaxCUWidth()*pcCU->getSlice()->getSPS()->getMaxCUHeight()) >> (uiDepth<<1); |
---|
[1029] | 930 | const UInt offsetY = uiPartUnitIdx*numCoeffY; |
---|
| 931 | for (UInt ch=0; ch<numValidComp; ch++) |
---|
| 932 | { |
---|
| 933 | const ComponentID component = ComponentID(ch); |
---|
| 934 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
| 935 | const UInt offset = offsetY>>componentShift; |
---|
| 936 | memcpy( m_pcTrCoeff [ch] + offset, pcCU->getCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
[208] | 937 | #if ADAPTIVE_QP_SELECTION |
---|
[1029] | 938 | memcpy( m_pcArlCoeff[ch] + offset, pcCU->getArlCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
[208] | 939 | #endif |
---|
[1029] | 940 | memcpy( m_pcIPCMSample[ch] + offset, pcCU->getPCMSample(component), sizeof(Pel)*(numCoeffY>>componentShift) ); |
---|
| 941 | } |
---|
[208] | 942 | |
---|
| 943 | m_uiTotalBins += pcCU->getTotalBins(); |
---|
| 944 | } |
---|
| 945 | |
---|
| 946 | // Copy current predicted part to a CU in picture. |
---|
| 947 | // It is used to predict for next part |
---|
| 948 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
| 949 | { |
---|
[1029] | 950 | TComDataCU* pCtu = m_pcPic->getCtu( m_ctuRsAddr ); |
---|
| 951 | const UInt numValidComp=pCtu->getPic()->getNumberValidComponents(); |
---|
| 952 | const UInt numValidChan=pCtu->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; |
---|
| 953 | |
---|
| 954 | pCtu->getTotalCost() = m_dTotalCost; |
---|
| 955 | pCtu->getTotalDistortion() = m_uiTotalDistortion; |
---|
| 956 | pCtu->getTotalBits() = m_uiTotalBits; |
---|
| 957 | |
---|
[208] | 958 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
| 959 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
[1442] | 960 | Int sizeInChar = sizeof( SChar ) * m_uiNumPartition; |
---|
[208] | 961 | |
---|
[1029] | 962 | memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
---|
[208] | 963 | |
---|
[1029] | 964 | memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar ); |
---|
[208] | 965 | |
---|
[1029] | 966 | memcpy( pCtu->getPartitionSize() + m_absZIdxInCtu, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
---|
| 967 | memcpy( pCtu->getPredictionMode() + m_absZIdxInCtu, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
---|
| 968 | memcpy( pCtu->getChromaQpAdj() + m_absZIdxInCtu, m_ChromaQpAdj, sizeof( *m_ChromaQpAdj ) * m_uiNumPartition ); |
---|
| 969 | memcpy( pCtu->getCUTransquantBypass()+ m_absZIdxInCtu, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
---|
| 970 | memcpy( pCtu->getMergeFlag() + m_absZIdxInCtu, m_pbMergeFlag, iSizeInBool ); |
---|
| 971 | memcpy( pCtu->getMergeIndex() + m_absZIdxInCtu, m_puhMergeIndex, iSizeInUchar ); |
---|
| 972 | for (UInt ch=0; ch<numValidChan; ch++) |
---|
| 973 | { |
---|
| 974 | memcpy( pCtu->getIntraDir(ChannelType(ch)) + m_absZIdxInCtu, m_puhIntraDir[ch], iSizeInUchar); |
---|
| 975 | } |
---|
[208] | 976 | |
---|
[1029] | 977 | memcpy( pCtu->getInterDir() + m_absZIdxInCtu, m_puhInterDir, iSizeInUchar ); |
---|
| 978 | memcpy( pCtu->getTransformIdx() + m_absZIdxInCtu, m_puhTrIdx, iSizeInUchar ); |
---|
[208] | 979 | |
---|
[1029] | 980 | for(UInt comp=0; comp<numValidComp; comp++) |
---|
| 981 | { |
---|
| 982 | memcpy( pCtu->getCrossComponentPredictionAlpha(ComponentID(comp)) + m_absZIdxInCtu, m_crossComponentPredictionAlpha[comp], iSizeInUchar ); |
---|
| 983 | memcpy( pCtu->getTransformSkip(ComponentID(comp)) + m_absZIdxInCtu, m_puhTransformSkip[comp], iSizeInUchar ); |
---|
| 984 | memcpy( pCtu->getCbf(ComponentID(comp)) + m_absZIdxInCtu, m_puhCbf[comp], iSizeInUchar ); |
---|
| 985 | memcpy( pCtu->getExplicitRdpcmMode(ComponentID(comp)) + m_absZIdxInCtu, m_explicitRdpcmMode[comp], iSizeInUchar ); |
---|
| 986 | } |
---|
[208] | 987 | |
---|
[1029] | 988 | memcpy( pCtu->getDepth() + m_absZIdxInCtu, m_puhDepth, iSizeInUchar ); |
---|
| 989 | memcpy( pCtu->getWidth() + m_absZIdxInCtu, m_puhWidth, iSizeInUchar ); |
---|
| 990 | memcpy( pCtu->getHeight() + m_absZIdxInCtu, m_puhHeight, iSizeInUchar ); |
---|
| 991 | |
---|
| 992 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 993 | { |
---|
| 994 | const RefPicList rpl=RefPicList(i); |
---|
| 995 | memcpy( pCtu->getMVPIdx(rpl) + m_absZIdxInCtu, m_apiMVPIdx[rpl], iSizeInUchar ); |
---|
| 996 | memcpy( pCtu->getMVPNum(rpl) + m_absZIdxInCtu, m_apiMVPNum[rpl], iSizeInUchar ); |
---|
| 997 | } |
---|
| 998 | |
---|
| 999 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 1000 | { |
---|
| 1001 | const RefPicList rpl=RefPicList(i); |
---|
| 1002 | m_acCUMvField[rpl].copyTo( pCtu->getCUMvField( rpl ), m_absZIdxInCtu ); |
---|
| 1003 | } |
---|
| 1004 | |
---|
| 1005 | memcpy( pCtu->getIPCMFlag() + m_absZIdxInCtu, m_pbIPCMFlag, iSizeInBool ); |
---|
| 1006 | |
---|
[1289] | 1007 | const UInt numCoeffY = (pCtu->getSlice()->getSPS()->getMaxCUWidth()*pCtu->getSlice()->getSPS()->getMaxCUHeight())>>(uhDepth<<1); |
---|
[1029] | 1008 | const UInt offsetY = m_absZIdxInCtu*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
| 1009 | for (UInt comp=0; comp<numValidComp; comp++) |
---|
| 1010 | { |
---|
| 1011 | const ComponentID component = ComponentID(comp); |
---|
| 1012 | const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); |
---|
| 1013 | memcpy( pCtu->getCoeff(component) + (offsetY>>componentShift), m_pcTrCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
[208] | 1014 | #if ADAPTIVE_QP_SELECTION |
---|
[1029] | 1015 | memcpy( pCtu->getArlCoeff(component) + (offsetY>>componentShift), m_pcArlCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); |
---|
[208] | 1016 | #endif |
---|
[1029] | 1017 | memcpy( pCtu->getPCMSample(component) + (offsetY>>componentShift), m_pcIPCMSample[component], sizeof(Pel)*(numCoeffY>>componentShift) ); |
---|
| 1018 | } |
---|
| 1019 | |
---|
| 1020 | pCtu->getTotalBins() = m_uiTotalBins; |
---|
[208] | 1021 | } |
---|
| 1022 | |
---|
| 1023 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 1024 | // Other public functions |
---|
| 1025 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 1026 | |
---|
[1465] | 1027 | const TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
---|
| 1028 | UInt uiCurrPartUnitIdx, |
---|
| 1029 | Bool bEnforceSliceRestriction, |
---|
| 1030 | Bool bEnforceTileRestriction ) const |
---|
[208] | 1031 | { |
---|
| 1032 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
[1029] | 1033 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
| 1034 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
| 1035 | |
---|
| 1036 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
[208] | 1037 | { |
---|
| 1038 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
[1029] | 1039 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
[208] | 1040 | { |
---|
[1029] | 1041 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
[208] | 1042 | } |
---|
| 1043 | else |
---|
| 1044 | { |
---|
[1029] | 1045 | uiLPartUnitIdx -= m_absZIdxInCtu; |
---|
[208] | 1046 | return this; |
---|
| 1047 | } |
---|
| 1048 | } |
---|
| 1049 | |
---|
[1029] | 1050 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth - 1 ]; |
---|
| 1051 | if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuLeft)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuLeft)) ) |
---|
[208] | 1052 | { |
---|
| 1053 | return NULL; |
---|
| 1054 | } |
---|
[1029] | 1055 | return m_pCtuLeft; |
---|
[208] | 1056 | } |
---|
| 1057 | |
---|
[1029] | 1058 | |
---|
[1465] | 1059 | const TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
---|
| 1060 | UInt uiCurrPartUnitIdx, |
---|
| 1061 | Bool bEnforceSliceRestriction, |
---|
| 1062 | Bool planarAtCtuBoundary, |
---|
| 1063 | Bool bEnforceTileRestriction ) const |
---|
[208] | 1064 | { |
---|
| 1065 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
[1029] | 1066 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
| 1067 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
| 1068 | |
---|
| 1069 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
[208] | 1070 | { |
---|
[1029] | 1071 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth ]; |
---|
| 1072 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
[208] | 1073 | { |
---|
[1029] | 1074 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
[208] | 1075 | } |
---|
| 1076 | else |
---|
| 1077 | { |
---|
[1029] | 1078 | uiAPartUnitIdx -= m_absZIdxInCtu; |
---|
[208] | 1079 | return this; |
---|
| 1080 | } |
---|
| 1081 | } |
---|
| 1082 | |
---|
[1029] | 1083 | if(planarAtCtuBoundary) |
---|
[208] | 1084 | { |
---|
| 1085 | return NULL; |
---|
| 1086 | } |
---|
| 1087 | |
---|
[1029] | 1088 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth ]; |
---|
| 1089 | |
---|
| 1090 | if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuAbove)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuAbove)) ) |
---|
[208] | 1091 | { |
---|
| 1092 | return NULL; |
---|
| 1093 | } |
---|
[1029] | 1094 | return m_pCtuAbove; |
---|
[208] | 1095 | } |
---|
| 1096 | |
---|
[1465] | 1097 | const TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) const |
---|
[208] | 1098 | { |
---|
| 1099 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
[1029] | 1100 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; |
---|
| 1101 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
| 1102 | |
---|
| 1103 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
[208] | 1104 | { |
---|
[1029] | 1105 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
[208] | 1106 | { |
---|
[1029] | 1107 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth - 1 ]; |
---|
| 1108 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
[208] | 1109 | { |
---|
[1029] | 1110 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
[208] | 1111 | } |
---|
| 1112 | else |
---|
| 1113 | { |
---|
[1029] | 1114 | uiALPartUnitIdx -= m_absZIdxInCtu; |
---|
[208] | 1115 | return this; |
---|
| 1116 | } |
---|
| 1117 | } |
---|
[1029] | 1118 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartitionsInCtu() - numPartInCtuWidth - 1 ]; |
---|
| 1119 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) |
---|
[208] | 1120 | { |
---|
| 1121 | return NULL; |
---|
| 1122 | } |
---|
[1029] | 1123 | return m_pCtuAbove; |
---|
[208] | 1124 | } |
---|
[1029] | 1125 | |
---|
| 1126 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) |
---|
[208] | 1127 | { |
---|
| 1128 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
[1029] | 1129 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) |
---|
[208] | 1130 | { |
---|
| 1131 | return NULL; |
---|
| 1132 | } |
---|
[1029] | 1133 | return m_pCtuLeft; |
---|
[208] | 1134 | } |
---|
[1029] | 1135 | |
---|
| 1136 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - 1 ]; |
---|
| 1137 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveLeft) ) |
---|
[208] | 1138 | { |
---|
| 1139 | return NULL; |
---|
| 1140 | } |
---|
[1029] | 1141 | return m_pCtuAboveLeft; |
---|
[208] | 1142 | } |
---|
| 1143 | |
---|
[1465] | 1144 | const TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) const |
---|
[208] | 1145 | { |
---|
| 1146 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
[1029] | 1147 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
| 1148 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_absZIdxInCtu ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*numPartInCtuWidth; |
---|
[1442] | 1149 | |
---|
[1029] | 1150 | if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
---|
[208] | 1151 | { |
---|
| 1152 | uiBLPartUnitIdx = MAX_UINT; |
---|
| 1153 | return NULL; |
---|
| 1154 | } |
---|
[1029] | 1155 | |
---|
| 1156 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInCtuHeight() - uiPartUnitOffset, numPartInCtuWidth ) ) |
---|
[208] | 1157 | { |
---|
[1029] | 1158 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, numPartInCtuWidth ) ) |
---|
[208] | 1159 | { |
---|
[1029] | 1160 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ] ) |
---|
[208] | 1161 | { |
---|
[1029] | 1162 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ]; |
---|
| 1163 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, numPartInCtuWidth ) ) |
---|
[208] | 1164 | { |
---|
[1029] | 1165 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
[208] | 1166 | } |
---|
| 1167 | else |
---|
| 1168 | { |
---|
[1029] | 1169 | uiBLPartUnitIdx -= m_absZIdxInCtu; |
---|
[208] | 1170 | return this; |
---|
| 1171 | } |
---|
| 1172 | } |
---|
| 1173 | uiBLPartUnitIdx = MAX_UINT; |
---|
| 1174 | return NULL; |
---|
| 1175 | } |
---|
[1029] | 1176 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * numPartInCtuWidth - 1 ]; |
---|
| 1177 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) |
---|
[208] | 1178 | { |
---|
| 1179 | return NULL; |
---|
| 1180 | } |
---|
[1029] | 1181 | return m_pCtuLeft; |
---|
[208] | 1182 | } |
---|
[1029] | 1183 | |
---|
[208] | 1184 | uiBLPartUnitIdx = MAX_UINT; |
---|
| 1185 | return NULL; |
---|
| 1186 | } |
---|
| 1187 | |
---|
[1465] | 1188 | const TComDataCU* TComDataCU::getPUAboveRight(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) const |
---|
[208] | 1189 | { |
---|
| 1190 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
[1029] | 1191 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_absZIdxInCtu ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
| 1192 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
[1442] | 1193 | |
---|
[1029] | 1194 | if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
[208] | 1195 | { |
---|
| 1196 | uiARPartUnitIdx = MAX_UINT; |
---|
| 1197 | return NULL; |
---|
| 1198 | } |
---|
[1029] | 1199 | |
---|
| 1200 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, numPartInCtuWidth - uiPartUnitOffset, numPartInCtuWidth ) ) |
---|
[208] | 1201 | { |
---|
[1029] | 1202 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) |
---|
[208] | 1203 | { |
---|
[1029] | 1204 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ] ) |
---|
[208] | 1205 | { |
---|
[1029] | 1206 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ]; |
---|
| 1207 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, numPartInCtuWidth ) ) |
---|
[208] | 1208 | { |
---|
[1029] | 1209 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
[208] | 1210 | } |
---|
| 1211 | else |
---|
| 1212 | { |
---|
[1029] | 1213 | uiARPartUnitIdx -= m_absZIdxInCtu; |
---|
[208] | 1214 | return this; |
---|
| 1215 | } |
---|
| 1216 | } |
---|
| 1217 | uiARPartUnitIdx = MAX_UINT; |
---|
| 1218 | return NULL; |
---|
| 1219 | } |
---|
[1029] | 1220 | |
---|
| 1221 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset ]; |
---|
| 1222 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) |
---|
[208] | 1223 | { |
---|
| 1224 | return NULL; |
---|
| 1225 | } |
---|
[1029] | 1226 | return m_pCtuAbove; |
---|
[208] | 1227 | } |
---|
[1029] | 1228 | |
---|
| 1229 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) |
---|
[208] | 1230 | { |
---|
| 1231 | uiARPartUnitIdx = MAX_UINT; |
---|
| 1232 | return NULL; |
---|
| 1233 | } |
---|
[1029] | 1234 | |
---|
| 1235 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset-1 ]; |
---|
| 1236 | if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveRight) ) |
---|
[208] | 1237 | { |
---|
| 1238 | return NULL; |
---|
| 1239 | } |
---|
[1029] | 1240 | return m_pCtuAboveRight; |
---|
[208] | 1241 | } |
---|
| 1242 | |
---|
| 1243 | /** Get left QpMinCu |
---|
| 1244 | *\param uiLPartUnitIdx |
---|
[1029] | 1245 | *\param uiCurrAbsIdxInCtu |
---|
[208] | 1246 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
---|
| 1247 | */ |
---|
[1465] | 1248 | const TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu ) const |
---|
[208] | 1249 | { |
---|
[1029] | 1250 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
[1290] | 1251 | const UInt maxCUDepth = getSlice()->getSPS()->getMaxTotalCUDepth(); |
---|
| 1252 | const UInt maxCuDQPDepth = getSlice()->getPPS()->getMaxCuDQPDepth(); |
---|
| 1253 | const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); |
---|
| 1254 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>doubleDepthDifference)<<doubleDepthDifference; |
---|
[208] | 1255 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
| 1256 | |
---|
[1029] | 1257 | // check for left CTU boundary |
---|
| 1258 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCtuWidth) ) |
---|
[208] | 1259 | { |
---|
| 1260 | return NULL; |
---|
| 1261 | } |
---|
| 1262 | |
---|
| 1263 | // get index of left-CU relative to top-left corner of current quantization group |
---|
| 1264 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
---|
| 1265 | |
---|
[1029] | 1266 | // return pointer to current CTU |
---|
| 1267 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
[208] | 1268 | } |
---|
| 1269 | |
---|
| 1270 | /** Get Above QpMinCu |
---|
[1029] | 1271 | *\param uiAPartUnitIdx |
---|
| 1272 | *\param uiCurrAbsIdxInCtu |
---|
[208] | 1273 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
---|
| 1274 | */ |
---|
[1465] | 1275 | const TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu ) const |
---|
[208] | 1276 | { |
---|
[1029] | 1277 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
[1290] | 1278 | const UInt maxCUDepth = getSlice()->getSPS()->getMaxTotalCUDepth(); |
---|
| 1279 | const UInt maxCuDQPDepth = getSlice()->getPPS()->getMaxCuDQPDepth(); |
---|
| 1280 | const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); |
---|
| 1281 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>doubleDepthDifference)<<doubleDepthDifference; |
---|
[208] | 1282 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
| 1283 | |
---|
[1029] | 1284 | // check for top CTU boundary |
---|
| 1285 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCtuWidth) ) |
---|
[208] | 1286 | { |
---|
| 1287 | return NULL; |
---|
| 1288 | } |
---|
| 1289 | |
---|
| 1290 | // get index of top-CU relative to top-left corner of current quantization group |
---|
[1029] | 1291 | uiAPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCtuWidth]; |
---|
[208] | 1292 | |
---|
[1029] | 1293 | // return pointer to current CTU |
---|
| 1294 | return m_pcPic->getCtu( getCtuRsAddr() ); |
---|
[208] | 1295 | } |
---|
| 1296 | |
---|
[1029] | 1297 | |
---|
| 1298 | |
---|
[208] | 1299 | /** Get reference QP from left QpMinCu or latest coded QP |
---|
[1029] | 1300 | *\param uiCurrAbsIdxInCtu |
---|
[1442] | 1301 | *\returns SChar reference QP value |
---|
[208] | 1302 | */ |
---|
[1465] | 1303 | SChar TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu ) const |
---|
[208] | 1304 | { |
---|
[1029] | 1305 | UInt lPartIdx = MAX_UINT; |
---|
| 1306 | UInt aPartIdx = MAX_UINT; |
---|
[1465] | 1307 | const TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); |
---|
| 1308 | const TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); |
---|
[1029] | 1309 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + 1) >> 1); |
---|
[208] | 1310 | } |
---|
| 1311 | |
---|
[1465] | 1312 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) const |
---|
[208] | 1313 | { |
---|
| 1314 | Int iLastValidPartIdx = iAbsPartIdx-1; |
---|
| 1315 | while ( iLastValidPartIdx >= 0 |
---|
[1029] | 1316 | && getPredictionMode( iLastValidPartIdx ) == NUMBER_OF_PREDICTION_MODES ) |
---|
[208] | 1317 | { |
---|
| 1318 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
---|
| 1319 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
---|
| 1320 | } |
---|
| 1321 | return iLastValidPartIdx; |
---|
| 1322 | } |
---|
| 1323 | |
---|
[1465] | 1324 | SChar TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) const |
---|
[208] | 1325 | { |
---|
[1290] | 1326 | UInt uiQUPartIdxMask = ~((1<<((getSlice()->getSPS()->getMaxTotalCUDepth() - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
---|
[1029] | 1327 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); // A idx will be invalid if it is off the right or bottom edge of the picture. |
---|
| 1328 | // If this CU is in the first CTU of the slice and there is no valid part before this one, use slice QP |
---|
| 1329 | if ( getPic()->getPicSym()->getCtuTsToRsAddrMap(getSlice()->getSliceCurStartCtuTsAddr()) == getCtuRsAddr() && Int(getZorderIdxInCtu())+iLastValidPartIdx<0) |
---|
[208] | 1330 | { |
---|
| 1331 | return getSlice()->getSliceQp(); |
---|
| 1332 | } |
---|
[310] | 1333 | else if ( iLastValidPartIdx >= 0 ) |
---|
[208] | 1334 | { |
---|
[1029] | 1335 | // If there is a valid part within the current Sub-CU, use it |
---|
[208] | 1336 | return getQP( iLastValidPartIdx ); |
---|
| 1337 | } |
---|
| 1338 | else |
---|
| 1339 | { |
---|
[1029] | 1340 | if ( getZorderIdxInCtu() > 0 ) |
---|
[208] | 1341 | { |
---|
[1029] | 1342 | // If this wasn't the first sub-cu within the Ctu, explore the CTU itself. |
---|
| 1343 | return getPic()->getCtu( getCtuRsAddr() )->getLastCodedQP( getZorderIdxInCtu() ); // TODO - remove this recursion |
---|
[208] | 1344 | } |
---|
[1029] | 1345 | else if ( getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr()) > 0 |
---|
| 1346 | && CUIsFromSameSliceTileAndWavefrontRow(getPic()->getCtu(getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1))) ) |
---|
[208] | 1347 | { |
---|
[1029] | 1348 | // If this isn't the first Ctu (how can it be due to the first 'if'?), and the previous Ctu is from the same tile, examine the previous Ctu. |
---|
| 1349 | return getPic()->getCtu( getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1) )->getLastCodedQP( getPic()->getNumPartitionsInCtu() ); // TODO - remove this recursion |
---|
[208] | 1350 | } |
---|
| 1351 | else |
---|
| 1352 | { |
---|
[1029] | 1353 | // No other options available - use the slice-level QP. |
---|
[208] | 1354 | return getSlice()->getSliceQp(); |
---|
| 1355 | } |
---|
| 1356 | } |
---|
| 1357 | } |
---|
[1029] | 1358 | |
---|
| 1359 | |
---|
[1258] | 1360 | /** Check whether the CU is coded in lossless coding mode. |
---|
| 1361 | * \param absPartIdx |
---|
[1029] | 1362 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
---|
[208] | 1363 | */ |
---|
[1465] | 1364 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) const |
---|
[208] | 1365 | { |
---|
| 1366 | return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); |
---|
| 1367 | } |
---|
| 1368 | |
---|
[1029] | 1369 | |
---|
[208] | 1370 | /** Get allowed chroma intra modes |
---|
[1258] | 1371 | * - fills uiModeList with chroma intra modes |
---|
| 1372 | * |
---|
| 1373 | *\param [in] uiAbsPartIdx |
---|
| 1374 | *\param [out] uiModeList pointer to chroma intra modes array |
---|
[208] | 1375 | */ |
---|
[1465] | 1376 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] ) const |
---|
[208] | 1377 | { |
---|
| 1378 | uiModeList[0] = PLANAR_IDX; |
---|
| 1379 | uiModeList[1] = VER_IDX; |
---|
| 1380 | uiModeList[2] = HOR_IDX; |
---|
| 1381 | uiModeList[3] = DC_IDX; |
---|
| 1382 | uiModeList[4] = DM_CHROMA_IDX; |
---|
[1029] | 1383 | assert(4<NUM_CHROMA_MODE); |
---|
[208] | 1384 | |
---|
[1029] | 1385 | UInt uiLumaMode = getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); |
---|
[208] | 1386 | |
---|
| 1387 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
---|
| 1388 | { |
---|
| 1389 | if( uiLumaMode == uiModeList[i] ) |
---|
| 1390 | { |
---|
| 1391 | uiModeList[i] = 34; // VER+8 mode |
---|
| 1392 | break; |
---|
| 1393 | } |
---|
| 1394 | } |
---|
| 1395 | } |
---|
| 1396 | |
---|
| 1397 | /** Get most probable intra modes |
---|
[1258] | 1398 | *\param uiAbsPartIdx partition index |
---|
[208] | 1399 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
[1260] | 1400 | *\param compID colour component ID |
---|
[208] | 1401 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
---|
| 1402 | *\returns Number of MPM |
---|
| 1403 | */ |
---|
[1465] | 1404 | Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode ) const |
---|
[208] | 1405 | { |
---|
[1029] | 1406 | UInt LeftPartIdx = MAX_UINT; |
---|
| 1407 | UInt AbovePartIdx = MAX_UINT; |
---|
[208] | 1408 | Int iLeftIntraDir, iAboveIntraDir; |
---|
[1290] | 1409 | const TComSPS *sps=getSlice()->getSPS(); |
---|
| 1410 | const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize())); |
---|
[310] | 1411 | |
---|
[1029] | 1412 | const ChannelType chType = toChannelType(compID); |
---|
| 1413 | const ChromaFormat chForm = getPic()->getChromaFormat(); |
---|
[208] | 1414 | // Get intra direction of left PU |
---|
[1465] | 1415 | const TComDataCU *pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
[1029] | 1416 | |
---|
[1246] | 1417 | if (isChroma(compID)) |
---|
| 1418 | { |
---|
[1290] | 1419 | LeftPartIdx = getChromasCorrespondingPULumaIdx(LeftPartIdx, chForm, partsPerMinCU); |
---|
[1246] | 1420 | } |
---|
[1029] | 1421 | iLeftIntraDir = pcCULeft ? ( pcCULeft->isIntra( LeftPartIdx ) ? pcCULeft->getIntraDir( chType, LeftPartIdx ) : DC_IDX ) : DC_IDX; |
---|
| 1422 | |
---|
[208] | 1423 | // Get intra direction of above PU |
---|
[1465] | 1424 | const TComDataCU *pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true ); |
---|
[1029] | 1425 | |
---|
[1246] | 1426 | if (isChroma(compID)) |
---|
| 1427 | { |
---|
[1290] | 1428 | AbovePartIdx = getChromasCorrespondingPULumaIdx(AbovePartIdx, chForm, partsPerMinCU); |
---|
[1246] | 1429 | } |
---|
[1029] | 1430 | iAboveIntraDir = pcCUAbove ? ( pcCUAbove->isIntra( AbovePartIdx ) ? pcCUAbove->getIntraDir( chType, AbovePartIdx ) : DC_IDX ) : DC_IDX; |
---|
| 1431 | |
---|
| 1432 | if (isChroma(chType)) |
---|
| 1433 | { |
---|
[1246] | 1434 | if (iLeftIntraDir == DM_CHROMA_IDX) |
---|
| 1435 | { |
---|
| 1436 | iLeftIntraDir = pcCULeft-> getIntraDir( CHANNEL_TYPE_LUMA, LeftPartIdx ); |
---|
| 1437 | } |
---|
| 1438 | if (iAboveIntraDir == DM_CHROMA_IDX) |
---|
| 1439 | { |
---|
| 1440 | iAboveIntraDir = pcCUAbove->getIntraDir( CHANNEL_TYPE_LUMA, AbovePartIdx ); |
---|
| 1441 | } |
---|
[1029] | 1442 | } |
---|
| 1443 | |
---|
| 1444 | assert (2<NUM_MOST_PROBABLE_MODES); |
---|
[208] | 1445 | if(iLeftIntraDir == iAboveIntraDir) |
---|
| 1446 | { |
---|
| 1447 | if( piMode ) |
---|
| 1448 | { |
---|
| 1449 | *piMode = 1; |
---|
| 1450 | } |
---|
[1029] | 1451 | |
---|
[208] | 1452 | if (iLeftIntraDir > 1) // angular modes |
---|
| 1453 | { |
---|
| 1454 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
| 1455 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
---|
| 1456 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
---|
| 1457 | } |
---|
| 1458 | else //non-angular |
---|
| 1459 | { |
---|
| 1460 | uiIntraDirPred[0] = PLANAR_IDX; |
---|
| 1461 | uiIntraDirPred[1] = DC_IDX; |
---|
[1029] | 1462 | uiIntraDirPred[2] = VER_IDX; |
---|
[208] | 1463 | } |
---|
| 1464 | } |
---|
| 1465 | else |
---|
| 1466 | { |
---|
| 1467 | if( piMode ) |
---|
| 1468 | { |
---|
| 1469 | *piMode = 2; |
---|
| 1470 | } |
---|
| 1471 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
| 1472 | uiIntraDirPred[1] = iAboveIntraDir; |
---|
[1029] | 1473 | |
---|
[208] | 1474 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
---|
| 1475 | { |
---|
| 1476 | uiIntraDirPred[2] = PLANAR_IDX; |
---|
| 1477 | } |
---|
| 1478 | else |
---|
| 1479 | { |
---|
| 1480 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
---|
| 1481 | } |
---|
| 1482 | } |
---|
[1244] | 1483 | for (UInt i=0; i<NUM_MOST_PROBABLE_MODES; i++) |
---|
[1246] | 1484 | { |
---|
[1029] | 1485 | assert(uiIntraDirPred[i] < 35); |
---|
[1246] | 1486 | } |
---|
[208] | 1487 | } |
---|
| 1488 | |
---|
[1465] | 1489 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) const |
---|
[208] | 1490 | { |
---|
[1465] | 1491 | const TComDataCU* pcTempCU; |
---|
| 1492 | UInt uiTempPartIdx; |
---|
| 1493 | UInt uiCtx; |
---|
[208] | 1494 | // Get left split flag |
---|
[1029] | 1495 | pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
[208] | 1496 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
[1029] | 1497 | |
---|
[208] | 1498 | // Get above split flag |
---|
[1029] | 1499 | pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
[208] | 1500 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
[1029] | 1501 | |
---|
[208] | 1502 | return uiCtx; |
---|
| 1503 | } |
---|
| 1504 | |
---|
[1465] | 1505 | UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType ) const |
---|
[208] | 1506 | { |
---|
[1029] | 1507 | const UInt transformDepth = rTu.GetTransformDepthRel(); |
---|
| 1508 | |
---|
| 1509 | if (isChroma(chType)) |
---|
[208] | 1510 | { |
---|
[1029] | 1511 | return transformDepth; |
---|
[208] | 1512 | } |
---|
| 1513 | else |
---|
| 1514 | { |
---|
[1029] | 1515 | const UInt uiCtx = ( transformDepth == 0 ? 1 : 0 ); |
---|
[208] | 1516 | return uiCtx; |
---|
| 1517 | } |
---|
| 1518 | } |
---|
| 1519 | |
---|
[1465] | 1520 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) const |
---|
[208] | 1521 | { |
---|
| 1522 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
---|
| 1523 | PartSize partSize = getPartitionSize( absPartIdx ); |
---|
[1029] | 1524 | UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
| 1525 | Int intraSplitFlag = ( isIntra( absPartIdx ) && partSize == SIZE_NxN ) ? 1 : 0; |
---|
| 1526 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && isInter( absPartIdx ) && (partSize != SIZE_2Nx2N) ); |
---|
| 1527 | |
---|
[208] | 1528 | UInt log2MinTUSizeInCU = 0; |
---|
[1029] | 1529 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
---|
[208] | 1530 | { |
---|
| 1531 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
---|
| 1532 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
| 1533 | } |
---|
| 1534 | else |
---|
| 1535 | { |
---|
| 1536 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
---|
| 1537 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
---|
| 1538 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
| 1539 | { |
---|
| 1540 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
---|
| 1541 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
[1029] | 1542 | } |
---|
[208] | 1543 | } |
---|
| 1544 | return log2MinTUSizeInCU; |
---|
| 1545 | } |
---|
| 1546 | |
---|
[1465] | 1547 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) const |
---|
[208] | 1548 | { |
---|
[1465] | 1549 | const TComDataCU* pcTempCU; |
---|
| 1550 | UInt uiTempPartIdx; |
---|
| 1551 | UInt uiCtx = 0; |
---|
[1029] | 1552 | |
---|
[208] | 1553 | // Get BCBP of left PU |
---|
[1029] | 1554 | pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
[208] | 1555 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
[1029] | 1556 | |
---|
[208] | 1557 | // Get BCBP of above PU |
---|
[1029] | 1558 | pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); |
---|
[208] | 1559 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
[1029] | 1560 | |
---|
[208] | 1561 | return uiCtx; |
---|
| 1562 | } |
---|
| 1563 | |
---|
[1465] | 1564 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) const |
---|
[208] | 1565 | { |
---|
| 1566 | return getDepth( uiAbsPartIdx ); |
---|
| 1567 | } |
---|
| 1568 | |
---|
[1029] | 1569 | |
---|
[1465] | 1570 | UChar TComDataCU::getQtRootCbf( UInt uiIdx ) const |
---|
[208] | 1571 | { |
---|
[1029] | 1572 | const UInt numberValidComponents = getPic()->getNumberValidComponents(); |
---|
| 1573 | return getCbf( uiIdx, COMPONENT_Y, 0 ) |
---|
| 1574 | || ((numberValidComponents > COMPONENT_Cb) && getCbf( uiIdx, COMPONENT_Cb, 0 )) |
---|
| 1575 | || ((numberValidComponents > COMPONENT_Cr) && getCbf( uiIdx, COMPONENT_Cr, 0 )); |
---|
[208] | 1576 | } |
---|
| 1577 | |
---|
[1029] | 1578 | Void TComDataCU::setCbfSubParts( const UInt uiCbf[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[208] | 1579 | { |
---|
[1029] | 1580 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
| 1581 | for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) |
---|
| 1582 | { |
---|
| 1583 | memset( m_puhCbf[comp] + uiAbsPartIdx, uiCbf[comp], sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1584 | } |
---|
[208] | 1585 | } |
---|
| 1586 | |
---|
[1029] | 1587 | Void TComDataCU::setCbfSubParts( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1588 | { |
---|
| 1589 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
| 1590 | memset( m_puhCbf[compID] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1591 | } |
---|
| 1592 | |
---|
[208] | 1593 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
[1260] | 1594 | * \param uiCbf The value of the coded block flag to be set |
---|
| 1595 | * \param compID |
---|
[208] | 1596 | * \param uiAbsPartIdx |
---|
| 1597 | * \param uiPartIdx |
---|
| 1598 | * \param uiDepth |
---|
| 1599 | */ |
---|
[1029] | 1600 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
[208] | 1601 | { |
---|
[1029] | 1602 | setSubPart<UChar>( uiCbf, m_puhCbf[compID], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[208] | 1603 | } |
---|
| 1604 | |
---|
[1029] | 1605 | Void TComDataCU::setCbfPartRange ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
| 1606 | { |
---|
| 1607 | memset((m_puhCbf[compID] + uiAbsPartIdx), uiCbf, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
| 1608 | } |
---|
| 1609 | |
---|
| 1610 | Void TComDataCU::bitwiseOrCbfPartRange( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
| 1611 | { |
---|
| 1612 | const UInt stopAbsPartIdx = uiAbsPartIdx + uiCoveredPartIdxes; |
---|
| 1613 | |
---|
| 1614 | for (UInt subPartIdx = uiAbsPartIdx; subPartIdx < stopAbsPartIdx; subPartIdx++) |
---|
| 1615 | { |
---|
| 1616 | m_puhCbf[compID][subPartIdx] |= uiCbf; |
---|
| 1617 | } |
---|
| 1618 | } |
---|
| 1619 | |
---|
[208] | 1620 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
| 1621 | { |
---|
[1029] | 1622 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
[208] | 1623 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 1624 | } |
---|
| 1625 | |
---|
[1465] | 1626 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) const |
---|
[208] | 1627 | { |
---|
[1029] | 1628 | UInt uiPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
| 1629 | return (((m_absZIdxInCtu + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
[208] | 1630 | } |
---|
| 1631 | |
---|
| 1632 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1633 | { |
---|
| 1634 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
[1029] | 1635 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
[208] | 1636 | } |
---|
| 1637 | |
---|
| 1638 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1639 | { |
---|
[1029] | 1640 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
[208] | 1641 | } |
---|
| 1642 | |
---|
| 1643 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
| 1644 | { |
---|
| 1645 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
[1029] | 1646 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); |
---|
[208] | 1647 | } |
---|
| 1648 | |
---|
| 1649 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1650 | { |
---|
| 1651 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
[1029] | 1652 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); |
---|
[208] | 1653 | } |
---|
| 1654 | |
---|
[1029] | 1655 | Void TComDataCU::setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth ) |
---|
[208] | 1656 | { |
---|
[1029] | 1657 | assert( sizeof(*m_ChromaQpAdj) == 1 ); |
---|
| 1658 | memset( m_ChromaQpAdj + absPartIdx, val, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); |
---|
| 1659 | } |
---|
| 1660 | |
---|
| 1661 | Void TComDataCU::setQPSubCUs( Int qp, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
| 1662 | { |
---|
| 1663 | UInt currPartNumb = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); |
---|
[208] | 1664 | UInt currPartNumQ = currPartNumb >> 2; |
---|
[1029] | 1665 | const UInt numValidComp = m_pcPic->getNumberValidComponents(); |
---|
[208] | 1666 | |
---|
| 1667 | if(!foundNonZeroCbf) |
---|
| 1668 | { |
---|
[1029] | 1669 | if(getDepth(absPartIdx) > depth) |
---|
[208] | 1670 | { |
---|
| 1671 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
| 1672 | { |
---|
[1029] | 1673 | setQPSubCUs( qp, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
[208] | 1674 | } |
---|
| 1675 | } |
---|
| 1676 | else |
---|
| 1677 | { |
---|
[1029] | 1678 | if(getCbf( absPartIdx, COMPONENT_Y ) || (numValidComp>COMPONENT_Cb && getCbf( absPartIdx, COMPONENT_Cb )) || (numValidComp>COMPONENT_Cr && getCbf( absPartIdx, COMPONENT_Cr) ) ) |
---|
[208] | 1679 | { |
---|
| 1680 | foundNonZeroCbf = true; |
---|
| 1681 | } |
---|
| 1682 | else |
---|
| 1683 | { |
---|
| 1684 | setQPSubParts(qp, absPartIdx, depth); |
---|
| 1685 | } |
---|
| 1686 | } |
---|
| 1687 | } |
---|
| 1688 | } |
---|
| 1689 | |
---|
| 1690 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1691 | { |
---|
[1029] | 1692 | const UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
| 1693 | memset(m_phQP+uiAbsPartIdx, qp, numPart); |
---|
[208] | 1694 | } |
---|
| 1695 | |
---|
[1029] | 1696 | Void TComDataCU::setIntraDirSubParts( const ChannelType channelType, const UInt dir, const UInt absPartIdx, const UInt depth ) |
---|
[208] | 1697 | { |
---|
[1029] | 1698 | UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); |
---|
| 1699 | memset( m_puhIntraDir[channelType] + absPartIdx, dir,sizeof(UChar)*numPart ); |
---|
[208] | 1700 | } |
---|
| 1701 | |
---|
| 1702 | template<typename T> |
---|
[1029] | 1703 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
[208] | 1704 | { |
---|
| 1705 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
[1029] | 1706 | |
---|
| 1707 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2; |
---|
[208] | 1708 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
| 1709 | { |
---|
| 1710 | case SIZE_2Nx2N: |
---|
[1029] | 1711 | memset( puhBaseCtu + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
[208] | 1712 | break; |
---|
| 1713 | case SIZE_2NxN: |
---|
[1029] | 1714 | memset( puhBaseCtu + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
[208] | 1715 | break; |
---|
| 1716 | case SIZE_Nx2N: |
---|
[1029] | 1717 | memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
| 1718 | memset( puhBaseCtu + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
[208] | 1719 | break; |
---|
| 1720 | case SIZE_NxN: |
---|
[1029] | 1721 | memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
[208] | 1722 | break; |
---|
| 1723 | case SIZE_2NxnU: |
---|
| 1724 | if ( uiPUIdx == 0 ) |
---|
| 1725 | { |
---|
[1029] | 1726 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 1727 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
[208] | 1728 | } |
---|
| 1729 | else if ( uiPUIdx == 1 ) |
---|
| 1730 | { |
---|
[1029] | 1731 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 1732 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
[208] | 1733 | } |
---|
| 1734 | else |
---|
| 1735 | { |
---|
| 1736 | assert(0); |
---|
| 1737 | } |
---|
| 1738 | break; |
---|
| 1739 | case SIZE_2NxnD: |
---|
| 1740 | if ( uiPUIdx == 0 ) |
---|
| 1741 | { |
---|
[1029] | 1742 | memset( puhBaseCtu + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
| 1743 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
[208] | 1744 | } |
---|
| 1745 | else if ( uiPUIdx == 1 ) |
---|
| 1746 | { |
---|
[1029] | 1747 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 1748 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
[208] | 1749 | } |
---|
| 1750 | else |
---|
| 1751 | { |
---|
| 1752 | assert(0); |
---|
| 1753 | } |
---|
| 1754 | break; |
---|
| 1755 | case SIZE_nLx2N: |
---|
| 1756 | if ( uiPUIdx == 0 ) |
---|
| 1757 | { |
---|
[1029] | 1758 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 1759 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 1760 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 1761 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
[208] | 1762 | } |
---|
| 1763 | else if ( uiPUIdx == 1 ) |
---|
| 1764 | { |
---|
[1029] | 1765 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 1766 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 1767 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 1768 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
[208] | 1769 | } |
---|
| 1770 | else |
---|
| 1771 | { |
---|
| 1772 | assert(0); |
---|
| 1773 | } |
---|
| 1774 | break; |
---|
| 1775 | case SIZE_nRx2N: |
---|
| 1776 | if ( uiPUIdx == 0 ) |
---|
[1029] | 1777 | { |
---|
| 1778 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 1779 | memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 1780 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 1781 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
[208] | 1782 | } |
---|
| 1783 | else if ( uiPUIdx == 1 ) |
---|
| 1784 | { |
---|
[1029] | 1785 | memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 1786 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 1787 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 1788 | memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
[208] | 1789 | } |
---|
| 1790 | else |
---|
| 1791 | { |
---|
| 1792 | assert(0); |
---|
| 1793 | } |
---|
| 1794 | break; |
---|
| 1795 | default: |
---|
| 1796 | assert( 0 ); |
---|
[1029] | 1797 | break; |
---|
[208] | 1798 | } |
---|
| 1799 | } |
---|
| 1800 | |
---|
| 1801 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 1802 | { |
---|
| 1803 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 1804 | } |
---|
| 1805 | |
---|
| 1806 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 1807 | { |
---|
| 1808 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 1809 | } |
---|
| 1810 | |
---|
| 1811 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 1812 | { |
---|
| 1813 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 1814 | } |
---|
| 1815 | |
---|
| 1816 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 1817 | { |
---|
[1442] | 1818 | setSubPart<SChar>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[208] | 1819 | } |
---|
| 1820 | |
---|
| 1821 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 1822 | { |
---|
[1442] | 1823 | setSubPart<SChar>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[208] | 1824 | } |
---|
| 1825 | |
---|
| 1826 | |
---|
| 1827 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1828 | { |
---|
[1029] | 1829 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
| 1830 | |
---|
[208] | 1831 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 1832 | } |
---|
| 1833 | |
---|
[1029] | 1834 | Void TComDataCU::setTransformSkipSubParts( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[208] | 1835 | { |
---|
[1029] | 1836 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
[208] | 1837 | |
---|
[1029] | 1838 | for(UInt i=0; i<MAX_NUM_COMPONENT; i++) |
---|
| 1839 | { |
---|
| 1840 | memset( m_puhTransformSkip[i] + uiAbsPartIdx, useTransformSkip[i], sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1841 | } |
---|
[208] | 1842 | } |
---|
| 1843 | |
---|
[1029] | 1844 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth) |
---|
[208] | 1845 | { |
---|
[1029] | 1846 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
[208] | 1847 | |
---|
[1029] | 1848 | memset( m_puhTransformSkip[compID] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
[208] | 1849 | } |
---|
| 1850 | |
---|
[1029] | 1851 | Void TComDataCU::setTransformSkipPartRange ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
| 1852 | { |
---|
| 1853 | memset((m_puhTransformSkip[compID] + uiAbsPartIdx), useTransformSkip, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
| 1854 | } |
---|
| 1855 | |
---|
[1442] | 1856 | Void TComDataCU::setCrossComponentPredictionAlphaPartRange( SChar alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
[1029] | 1857 | { |
---|
[1442] | 1858 | memset((m_crossComponentPredictionAlpha[compID] + uiAbsPartIdx), alphaValue, (sizeof(SChar) * uiCoveredPartIdxes)); |
---|
[1029] | 1859 | } |
---|
| 1860 | |
---|
| 1861 | Void TComDataCU::setExplicitRdpcmModePartRange ( UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) |
---|
| 1862 | { |
---|
| 1863 | memset((m_explicitRdpcmMode[compID] + uiAbsPartIdx), rdpcmMode, (sizeof(UChar) * uiCoveredPartIdxes)); |
---|
| 1864 | } |
---|
| 1865 | |
---|
[208] | 1866 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1867 | { |
---|
[1029] | 1868 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
| 1869 | |
---|
[208] | 1870 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 1871 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 1872 | } |
---|
| 1873 | |
---|
[1465] | 1874 | UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx) const |
---|
[208] | 1875 | { |
---|
| 1876 | UChar iNumPart = 0; |
---|
[1029] | 1877 | |
---|
| 1878 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
[208] | 1879 | { |
---|
| 1880 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
| 1881 | case SIZE_2NxN: iNumPart = 2; break; |
---|
| 1882 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
| 1883 | case SIZE_NxN: iNumPart = 4; break; |
---|
| 1884 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
| 1885 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
| 1886 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
| 1887 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
| 1888 | default: assert (0); break; |
---|
| 1889 | } |
---|
[1029] | 1890 | |
---|
[208] | 1891 | return iNumPart; |
---|
| 1892 | } |
---|
| 1893 | |
---|
[1236] | 1894 | // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx |
---|
[1465] | 1895 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) const |
---|
[208] | 1896 | { |
---|
| 1897 | switch ( m_pePartSize[0] ) |
---|
| 1898 | { |
---|
| 1899 | case SIZE_2NxN: |
---|
| 1900 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 1901 | break; |
---|
| 1902 | case SIZE_Nx2N: |
---|
| 1903 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
| 1904 | break; |
---|
| 1905 | case SIZE_NxN: |
---|
| 1906 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
| 1907 | break; |
---|
| 1908 | case SIZE_2NxnU: |
---|
| 1909 | riWidth = getWidth(0); |
---|
| 1910 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
| 1911 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
| 1912 | break; |
---|
| 1913 | case SIZE_2NxnD: |
---|
| 1914 | riWidth = getWidth(0); |
---|
| 1915 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
| 1916 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
| 1917 | break; |
---|
| 1918 | case SIZE_nLx2N: |
---|
| 1919 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
| 1920 | riHeight = getHeight(0); |
---|
| 1921 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
| 1922 | break; |
---|
| 1923 | case SIZE_nRx2N: |
---|
| 1924 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
| 1925 | riHeight = getHeight(0); |
---|
| 1926 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
| 1927 | break; |
---|
| 1928 | default: |
---|
| 1929 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
| 1930 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
| 1931 | break; |
---|
| 1932 | } |
---|
| 1933 | } |
---|
| 1934 | |
---|
[1465] | 1935 | // static member function |
---|
| 1936 | Void TComDataCU::getMvField ( const TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
[208] | 1937 | { |
---|
| 1938 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
| 1939 | { |
---|
| 1940 | TComMv cZeroMv; |
---|
| 1941 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
| 1942 | return; |
---|
| 1943 | } |
---|
[1029] | 1944 | |
---|
[1465] | 1945 | const TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
[208] | 1946 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
| 1947 | } |
---|
| 1948 | |
---|
[1465] | 1949 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const |
---|
[208] | 1950 | { |
---|
[1029] | 1951 | ruiPartIdxLT = m_absZIdxInCtu + uiAbsPartIdx; |
---|
[208] | 1952 | UInt uiPUWidth = 0; |
---|
[1029] | 1953 | |
---|
[208] | 1954 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
| 1955 | { |
---|
| 1956 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 1957 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 1958 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
| 1959 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
| 1960 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 1961 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
[1029] | 1962 | case SIZE_nLx2N: |
---|
[208] | 1963 | if ( uiPartIdx == 0 ) |
---|
| 1964 | { |
---|
[1029] | 1965 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
[208] | 1966 | } |
---|
| 1967 | else if ( uiPartIdx == 1 ) |
---|
| 1968 | { |
---|
[1029] | 1969 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
[208] | 1970 | } |
---|
| 1971 | else |
---|
| 1972 | { |
---|
| 1973 | assert(0); |
---|
| 1974 | } |
---|
| 1975 | break; |
---|
[1029] | 1976 | case SIZE_nRx2N: |
---|
[208] | 1977 | if ( uiPartIdx == 0 ) |
---|
| 1978 | { |
---|
[1029] | 1979 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
[208] | 1980 | } |
---|
| 1981 | else if ( uiPartIdx == 1 ) |
---|
| 1982 | { |
---|
[1029] | 1983 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
[208] | 1984 | } |
---|
| 1985 | else |
---|
| 1986 | { |
---|
| 1987 | assert(0); |
---|
| 1988 | } |
---|
| 1989 | break; |
---|
| 1990 | default: |
---|
| 1991 | assert (0); |
---|
| 1992 | break; |
---|
| 1993 | } |
---|
[1029] | 1994 | |
---|
[208] | 1995 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
| 1996 | } |
---|
| 1997 | |
---|
[1465] | 1998 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) const |
---|
[208] | 1999 | { |
---|
| 2000 | UInt uiPUHeight = 0; |
---|
| 2001 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
| 2002 | { |
---|
| 2003 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2004 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
| 2005 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2006 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
[1029] | 2007 | case SIZE_2NxnU: |
---|
[208] | 2008 | if ( uiPartIdx == 0 ) |
---|
| 2009 | { |
---|
[1029] | 2010 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
[208] | 2011 | } |
---|
| 2012 | else if ( uiPartIdx == 1 ) |
---|
| 2013 | { |
---|
[1029] | 2014 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
[208] | 2015 | } |
---|
| 2016 | else |
---|
| 2017 | { |
---|
| 2018 | assert(0); |
---|
| 2019 | } |
---|
| 2020 | break; |
---|
[1029] | 2021 | case SIZE_2NxnD: |
---|
[208] | 2022 | if ( uiPartIdx == 0 ) |
---|
| 2023 | { |
---|
[1029] | 2024 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
[208] | 2025 | } |
---|
| 2026 | else if ( uiPartIdx == 1 ) |
---|
| 2027 | { |
---|
[1029] | 2028 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
[208] | 2029 | } |
---|
| 2030 | else |
---|
| 2031 | { |
---|
| 2032 | assert(0); |
---|
| 2033 | } |
---|
| 2034 | break; |
---|
| 2035 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2036 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2037 | default: |
---|
| 2038 | assert (0); |
---|
| 2039 | break; |
---|
| 2040 | } |
---|
[1029] | 2041 | |
---|
| 2042 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInCtuWidth()]; |
---|
[208] | 2043 | } |
---|
| 2044 | |
---|
[1465] | 2045 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const |
---|
[208] | 2046 | { |
---|
[1029] | 2047 | ruiPartIdxLT = m_absZIdxInCtu; |
---|
[208] | 2048 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
[1029] | 2049 | |
---|
[208] | 2050 | switch ( m_pePartSize[0] ) |
---|
| 2051 | { |
---|
| 2052 | case SIZE_2Nx2N: break; |
---|
| 2053 | case SIZE_2NxN: |
---|
| 2054 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 2055 | break; |
---|
| 2056 | case SIZE_Nx2N: |
---|
| 2057 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
| 2058 | break; |
---|
| 2059 | case SIZE_NxN: |
---|
| 2060 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
| 2061 | break; |
---|
| 2062 | case SIZE_2NxnU: |
---|
| 2063 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
| 2064 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
| 2065 | break; |
---|
| 2066 | case SIZE_2NxnD: |
---|
| 2067 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
| 2068 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
| 2069 | break; |
---|
| 2070 | case SIZE_nLx2N: |
---|
| 2071 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
| 2072 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
| 2073 | break; |
---|
| 2074 | case SIZE_nRx2N: |
---|
| 2075 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
| 2076 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
| 2077 | break; |
---|
| 2078 | default: |
---|
| 2079 | assert (0); |
---|
| 2080 | break; |
---|
| 2081 | } |
---|
[1029] | 2082 | |
---|
[208] | 2083 | } |
---|
| 2084 | |
---|
[1465] | 2085 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) const |
---|
[208] | 2086 | { |
---|
[1029] | 2087 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth()]; |
---|
| 2088 | |
---|
[208] | 2089 | switch ( m_pePartSize[0] ) |
---|
| 2090 | { |
---|
| 2091 | case SIZE_2Nx2N: |
---|
| 2092 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
| 2093 | break; |
---|
| 2094 | case SIZE_2NxN: |
---|
| 2095 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 2096 | break; |
---|
| 2097 | case SIZE_Nx2N: |
---|
| 2098 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
| 2099 | break; |
---|
| 2100 | case SIZE_NxN: |
---|
| 2101 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
| 2102 | break; |
---|
| 2103 | case SIZE_2NxnU: |
---|
| 2104 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
| 2105 | break; |
---|
| 2106 | case SIZE_2NxnD: |
---|
| 2107 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
| 2108 | break; |
---|
| 2109 | case SIZE_nLx2N: |
---|
| 2110 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
| 2111 | break; |
---|
| 2112 | case SIZE_nRx2N: |
---|
| 2113 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
| 2114 | break; |
---|
| 2115 | default: |
---|
| 2116 | assert (0); |
---|
| 2117 | break; |
---|
| 2118 | } |
---|
| 2119 | } |
---|
| 2120 | |
---|
[1258] | 2121 | /** Derive the partition index of neighbouring bottom right block |
---|
| 2122 | * \param [in] uiPartIdx current partition index |
---|
| 2123 | * \param [out] ruiPartIdxRB partition index of neighbouring bottom right block |
---|
[208] | 2124 | */ |
---|
[1465] | 2125 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB ) const |
---|
[208] | 2126 | { |
---|
[1029] | 2127 | ruiPartIdxRB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth() + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1]; |
---|
[208] | 2128 | |
---|
| 2129 | switch ( m_pePartSize[0] ) |
---|
| 2130 | { |
---|
[1029] | 2131 | case SIZE_2Nx2N: |
---|
| 2132 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
[208] | 2133 | break; |
---|
[1029] | 2134 | case SIZE_2NxN: |
---|
| 2135 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
[208] | 2136 | break; |
---|
[1029] | 2137 | case SIZE_Nx2N: |
---|
| 2138 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
[208] | 2139 | break; |
---|
[1029] | 2140 | case SIZE_NxN: |
---|
| 2141 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
[208] | 2142 | break; |
---|
| 2143 | case SIZE_2NxnU: |
---|
| 2144 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
| 2145 | break; |
---|
| 2146 | case SIZE_2NxnD: |
---|
| 2147 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
| 2148 | break; |
---|
| 2149 | case SIZE_nLx2N: |
---|
| 2150 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
| 2151 | break; |
---|
| 2152 | case SIZE_nRx2N: |
---|
| 2153 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
| 2154 | break; |
---|
| 2155 | default: |
---|
| 2156 | assert (0); |
---|
| 2157 | break; |
---|
| 2158 | } |
---|
| 2159 | } |
---|
| 2160 | |
---|
[1465] | 2161 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, const TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) const |
---|
[208] | 2162 | { |
---|
| 2163 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
| 2164 | { |
---|
| 2165 | return false; |
---|
| 2166 | } |
---|
| 2167 | |
---|
| 2168 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 2169 | { |
---|
| 2170 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
| 2171 | { |
---|
[1029] | 2172 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
[208] | 2173 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
| 2174 | { |
---|
| 2175 | return false; |
---|
| 2176 | } |
---|
| 2177 | } |
---|
| 2178 | } |
---|
| 2179 | |
---|
| 2180 | return true; |
---|
| 2181 | } |
---|
| 2182 | |
---|
[1258] | 2183 | //! Construct a list of merging candidates |
---|
[1465] | 2184 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) const |
---|
[208] | 2185 | { |
---|
[1029] | 2186 | UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx; |
---|
[208] | 2187 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
| 2188 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
| 2189 | { |
---|
| 2190 | abCandIsInter[ui] = false; |
---|
| 2191 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
| 2192 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
| 2193 | } |
---|
| 2194 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
| 2195 | // compute the location of the current PU |
---|
| 2196 | Int xP, yP, nPSW, nPSH; |
---|
| 2197 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
| 2198 | |
---|
| 2199 | Int iCount = 0; |
---|
| 2200 | |
---|
| 2201 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
| 2202 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
| 2203 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
[1029] | 2204 | deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
[208] | 2205 | |
---|
| 2206 | //left |
---|
| 2207 | UInt uiLeftPartIdx = 0; |
---|
[1465] | 2208 | const TComDataCU *pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
[1029] | 2209 | |
---|
[208] | 2210 | Bool isAvailableA1 = pcCULeft && |
---|
[1029] | 2211 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
| 2212 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
| 2213 | pcCULeft->isInter( uiLeftPartIdx ) ; |
---|
| 2214 | |
---|
[208] | 2215 | if ( isAvailableA1 ) |
---|
| 2216 | { |
---|
| 2217 | abCandIsInter[iCount] = true; |
---|
| 2218 | // get Inter Dir |
---|
| 2219 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
| 2220 | // get Mv from Left |
---|
[1465] | 2221 | TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
[208] | 2222 | if ( getSlice()->isInterB() ) |
---|
| 2223 | { |
---|
[1465] | 2224 | TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
[208] | 2225 | } |
---|
| 2226 | if ( mrgCandIdx == iCount ) |
---|
| 2227 | { |
---|
| 2228 | return; |
---|
| 2229 | } |
---|
| 2230 | iCount ++; |
---|
| 2231 | } |
---|
[1029] | 2232 | |
---|
[208] | 2233 | // early termination |
---|
[1029] | 2234 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
[208] | 2235 | { |
---|
| 2236 | return; |
---|
| 2237 | } |
---|
| 2238 | // above |
---|
| 2239 | UInt uiAbovePartIdx = 0; |
---|
[1465] | 2240 | const TComDataCU *pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
[1029] | 2241 | |
---|
[208] | 2242 | Bool isAvailableB1 = pcCUAbove && |
---|
[1029] | 2243 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
| 2244 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
| 2245 | pcCUAbove->isInter( uiAbovePartIdx ); |
---|
| 2246 | |
---|
[208] | 2247 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
| 2248 | { |
---|
| 2249 | abCandIsInter[iCount] = true; |
---|
| 2250 | // get Inter Dir |
---|
| 2251 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
| 2252 | // get Mv from Left |
---|
[1465] | 2253 | TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
[208] | 2254 | if ( getSlice()->isInterB() ) |
---|
| 2255 | { |
---|
[1465] | 2256 | TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
[208] | 2257 | } |
---|
| 2258 | if ( mrgCandIdx == iCount ) |
---|
| 2259 | { |
---|
| 2260 | return; |
---|
| 2261 | } |
---|
| 2262 | iCount ++; |
---|
| 2263 | } |
---|
| 2264 | // early termination |
---|
[1029] | 2265 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
[208] | 2266 | { |
---|
| 2267 | return; |
---|
| 2268 | } |
---|
| 2269 | |
---|
| 2270 | // above right |
---|
| 2271 | UInt uiAboveRightPartIdx = 0; |
---|
[1465] | 2272 | const TComDataCU *pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
[1029] | 2273 | |
---|
[208] | 2274 | Bool isAvailableB0 = pcCUAboveRight && |
---|
[1029] | 2275 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
| 2276 | pcCUAboveRight->isInter( uiAboveRightPartIdx ); |
---|
| 2277 | |
---|
[208] | 2278 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
| 2279 | { |
---|
| 2280 | abCandIsInter[iCount] = true; |
---|
| 2281 | // get Inter Dir |
---|
| 2282 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
| 2283 | // get Mv from Left |
---|
[1465] | 2284 | TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
[208] | 2285 | if ( getSlice()->isInterB() ) |
---|
| 2286 | { |
---|
[1465] | 2287 | TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
[208] | 2288 | } |
---|
| 2289 | if ( mrgCandIdx == iCount ) |
---|
| 2290 | { |
---|
| 2291 | return; |
---|
| 2292 | } |
---|
| 2293 | iCount ++; |
---|
| 2294 | } |
---|
| 2295 | // early termination |
---|
[1029] | 2296 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
[208] | 2297 | { |
---|
| 2298 | return; |
---|
| 2299 | } |
---|
| 2300 | |
---|
| 2301 | //left bottom |
---|
| 2302 | UInt uiLeftBottomPartIdx = 0; |
---|
[1465] | 2303 | const TComDataCU *pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
[1029] | 2304 | |
---|
[208] | 2305 | Bool isAvailableA0 = pcCULeftBottom && |
---|
[1029] | 2306 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
| 2307 | pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ; |
---|
| 2308 | |
---|
[208] | 2309 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
| 2310 | { |
---|
| 2311 | abCandIsInter[iCount] = true; |
---|
| 2312 | // get Inter Dir |
---|
| 2313 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
| 2314 | // get Mv from Left |
---|
[1465] | 2315 | TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
[208] | 2316 | if ( getSlice()->isInterB() ) |
---|
| 2317 | { |
---|
[1465] | 2318 | TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
[208] | 2319 | } |
---|
| 2320 | if ( mrgCandIdx == iCount ) |
---|
| 2321 | { |
---|
| 2322 | return; |
---|
| 2323 | } |
---|
| 2324 | iCount ++; |
---|
| 2325 | } |
---|
| 2326 | // early termination |
---|
[1029] | 2327 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
[208] | 2328 | { |
---|
| 2329 | return; |
---|
| 2330 | } |
---|
[1029] | 2331 | |
---|
| 2332 | // above left |
---|
[208] | 2333 | if( iCount < 4 ) |
---|
| 2334 | { |
---|
| 2335 | UInt uiAboveLeftPartIdx = 0; |
---|
[1465] | 2336 | const TComDataCU *pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
[1029] | 2337 | |
---|
[208] | 2338 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
[1029] | 2339 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
| 2340 | pcCUAboveLeft->isInter( uiAboveLeftPartIdx ); |
---|
| 2341 | |
---|
[208] | 2342 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
| 2343 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
| 2344 | { |
---|
| 2345 | abCandIsInter[iCount] = true; |
---|
| 2346 | // get Inter Dir |
---|
| 2347 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
| 2348 | // get Mv from Left |
---|
[1465] | 2349 | TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
[208] | 2350 | if ( getSlice()->isInterB() ) |
---|
| 2351 | { |
---|
[1465] | 2352 | TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
[208] | 2353 | } |
---|
| 2354 | if ( mrgCandIdx == iCount ) |
---|
| 2355 | { |
---|
| 2356 | return; |
---|
| 2357 | } |
---|
| 2358 | iCount ++; |
---|
| 2359 | } |
---|
| 2360 | } |
---|
| 2361 | // early termination |
---|
[1029] | 2362 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
[208] | 2363 | { |
---|
| 2364 | return; |
---|
| 2365 | } |
---|
[1029] | 2366 | |
---|
| 2367 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
[208] | 2368 | { |
---|
| 2369 | //>> MTK colocated-RightBottom |
---|
| 2370 | UInt uiPartIdxRB; |
---|
| 2371 | |
---|
[1029] | 2372 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
[208] | 2373 | |
---|
| 2374 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
[1029] | 2375 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
| 2376 | const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); |
---|
[208] | 2377 | |
---|
| 2378 | TComMv cColMv; |
---|
| 2379 | Int iRefIdx; |
---|
[1029] | 2380 | Int ctuRsAddr = -1; |
---|
[208] | 2381 | |
---|
[1029] | 2382 | if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check |
---|
| 2383 | && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[208] | 2384 | { |
---|
[1029] | 2385 | if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU |
---|
| 2386 | ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU |
---|
[208] | 2387 | { |
---|
[1029] | 2388 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ]; |
---|
| 2389 | ctuRsAddr = getCtuRsAddr(); |
---|
[208] | 2390 | } |
---|
[1029] | 2391 | else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU |
---|
[208] | 2392 | { |
---|
[1029] | 2393 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; |
---|
[208] | 2394 | } |
---|
[1029] | 2395 | else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU |
---|
[208] | 2396 | { |
---|
| 2397 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
[1029] | 2398 | ctuRsAddr = getCtuRsAddr() + 1; |
---|
[208] | 2399 | } |
---|
[1029] | 2400 | else //is the right bottom corner of CTU |
---|
[208] | 2401 | { |
---|
| 2402 | uiAbsPartAddr = 0; |
---|
| 2403 | } |
---|
| 2404 | } |
---|
[1029] | 2405 | |
---|
[208] | 2406 | iRefIdx = 0; |
---|
[1029] | 2407 | |
---|
[208] | 2408 | Bool bExistMV = false; |
---|
| 2409 | UInt uiPartIdxCenter; |
---|
| 2410 | Int dir = 0; |
---|
| 2411 | UInt uiArrayAddr = iCount; |
---|
| 2412 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
[1029] | 2413 | bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
[208] | 2414 | if( bExistMV == false ) |
---|
| 2415 | { |
---|
[1029] | 2416 | bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); |
---|
[208] | 2417 | } |
---|
| 2418 | if( bExistMV ) |
---|
| 2419 | { |
---|
| 2420 | dir |= 1; |
---|
| 2421 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
| 2422 | } |
---|
[1029] | 2423 | |
---|
[208] | 2424 | if ( getSlice()->isInterB() ) |
---|
| 2425 | { |
---|
[1029] | 2426 | bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx); |
---|
[208] | 2427 | if( bExistMV == false ) |
---|
| 2428 | { |
---|
[1029] | 2429 | bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); |
---|
[208] | 2430 | } |
---|
| 2431 | if( bExistMV ) |
---|
| 2432 | { |
---|
| 2433 | dir |= 2; |
---|
| 2434 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
| 2435 | } |
---|
| 2436 | } |
---|
[1029] | 2437 | |
---|
[208] | 2438 | if (dir != 0) |
---|
| 2439 | { |
---|
| 2440 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
| 2441 | abCandIsInter[uiArrayAddr] = true; |
---|
| 2442 | |
---|
| 2443 | if ( mrgCandIdx == iCount ) |
---|
| 2444 | { |
---|
| 2445 | return; |
---|
| 2446 | } |
---|
| 2447 | iCount++; |
---|
| 2448 | } |
---|
| 2449 | } |
---|
| 2450 | // early termination |
---|
[1029] | 2451 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
[208] | 2452 | { |
---|
| 2453 | return; |
---|
| 2454 | } |
---|
[1029] | 2455 | |
---|
[208] | 2456 | UInt uiArrayAddr = iCount; |
---|
| 2457 | UInt uiCutoff = uiArrayAddr; |
---|
[1029] | 2458 | |
---|
| 2459 | if ( getSlice()->isInterB() ) |
---|
[208] | 2460 | { |
---|
[1029] | 2461 | static const UInt NUM_PRIORITY_LIST=12; |
---|
| 2462 | static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
| 2463 | static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
[208] | 2464 | |
---|
| 2465 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
| 2466 | { |
---|
[1029] | 2467 | assert(idx<NUM_PRIORITY_LIST); |
---|
| 2468 | Int i = uiPriorityList0[idx]; |
---|
| 2469 | Int j = uiPriorityList1[idx]; |
---|
[208] | 2470 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
| 2471 | { |
---|
| 2472 | abCandIsInter[uiArrayAddr] = true; |
---|
| 2473 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
| 2474 | |
---|
| 2475 | // get Mv from cand[i] and cand[j] |
---|
| 2476 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
| 2477 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
| 2478 | |
---|
| 2479 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
| 2480 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
| 2481 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
| 2482 | { |
---|
| 2483 | abCandIsInter[uiArrayAddr] = false; |
---|
| 2484 | } |
---|
| 2485 | else |
---|
| 2486 | { |
---|
| 2487 | uiArrayAddr++; |
---|
| 2488 | } |
---|
| 2489 | } |
---|
| 2490 | } |
---|
| 2491 | } |
---|
| 2492 | // early termination |
---|
[1029] | 2493 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
[208] | 2494 | { |
---|
| 2495 | return; |
---|
| 2496 | } |
---|
[1029] | 2497 | |
---|
[208] | 2498 | Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
[1029] | 2499 | |
---|
[208] | 2500 | Int r = 0; |
---|
| 2501 | Int refcnt = 0; |
---|
| 2502 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
| 2503 | { |
---|
| 2504 | abCandIsInter[uiArrayAddr] = true; |
---|
| 2505 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
| 2506 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
| 2507 | |
---|
| 2508 | if ( getSlice()->isInterB() ) |
---|
| 2509 | { |
---|
| 2510 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
| 2511 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
| 2512 | } |
---|
| 2513 | uiArrayAddr++; |
---|
[1029] | 2514 | |
---|
[208] | 2515 | if ( refcnt == iNumRefIdx - 1 ) |
---|
| 2516 | { |
---|
| 2517 | r = 0; |
---|
| 2518 | } |
---|
| 2519 | else |
---|
| 2520 | { |
---|
| 2521 | ++r; |
---|
| 2522 | ++refcnt; |
---|
| 2523 | } |
---|
| 2524 | } |
---|
| 2525 | numValidMergeCand = uiArrayAddr; |
---|
| 2526 | } |
---|
| 2527 | |
---|
| 2528 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
[1258] | 2529 | * \param xN, yN location of the upper-left corner pixel of a neighboring PU |
---|
[208] | 2530 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
| 2531 | */ |
---|
[1465] | 2532 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) const |
---|
[208] | 2533 | { |
---|
| 2534 | |
---|
| 2535 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
| 2536 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
| 2537 | { |
---|
| 2538 | return true; |
---|
| 2539 | } |
---|
| 2540 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
| 2541 | { |
---|
| 2542 | return true; |
---|
| 2543 | } |
---|
| 2544 | return false; |
---|
| 2545 | } |
---|
[1029] | 2546 | |
---|
[1258] | 2547 | /** Calculate the location of upper-left corner pixel and size of the current PU. |
---|
| 2548 | * \param partIdx PU index within a CU |
---|
| 2549 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
| 2550 | * \param nPSW, nPSH size of the current PU |
---|
[208] | 2551 | */ |
---|
[1465] | 2552 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) const |
---|
[208] | 2553 | { |
---|
| 2554 | UInt col = m_uiCUPelX; |
---|
| 2555 | UInt row = m_uiCUPelY; |
---|
| 2556 | |
---|
| 2557 | switch ( m_pePartSize[0] ) |
---|
| 2558 | { |
---|
| 2559 | case SIZE_2NxN: |
---|
[1029] | 2560 | nPSW = getWidth(0); |
---|
| 2561 | nPSH = getHeight(0) >> 1; |
---|
[208] | 2562 | xP = col; |
---|
| 2563 | yP = (partIdx ==0)? row: row + nPSH; |
---|
| 2564 | break; |
---|
| 2565 | case SIZE_Nx2N: |
---|
[1029] | 2566 | nPSW = getWidth(0) >> 1; |
---|
| 2567 | nPSH = getHeight(0); |
---|
[208] | 2568 | xP = (partIdx ==0)? col: col + nPSW; |
---|
| 2569 | yP = row; |
---|
| 2570 | break; |
---|
| 2571 | case SIZE_NxN: |
---|
[1029] | 2572 | nPSW = getWidth(0) >> 1; |
---|
| 2573 | nPSH = getHeight(0) >> 1; |
---|
[208] | 2574 | xP = col + (partIdx&0x1)*nPSW; |
---|
| 2575 | yP = row + (partIdx>>1)*nPSH; |
---|
| 2576 | break; |
---|
| 2577 | case SIZE_2NxnU: |
---|
| 2578 | nPSW = getWidth(0); |
---|
| 2579 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
| 2580 | xP = col; |
---|
| 2581 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
| 2582 | |
---|
| 2583 | break; |
---|
| 2584 | case SIZE_2NxnD: |
---|
| 2585 | nPSW = getWidth(0); |
---|
| 2586 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
| 2587 | xP = col; |
---|
| 2588 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
| 2589 | break; |
---|
| 2590 | case SIZE_nLx2N: |
---|
| 2591 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
| 2592 | nPSH = getHeight(0); |
---|
| 2593 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
| 2594 | yP = row; |
---|
| 2595 | break; |
---|
| 2596 | case SIZE_nRx2N: |
---|
| 2597 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
| 2598 | nPSH = getHeight(0); |
---|
| 2599 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
| 2600 | yP = row; |
---|
| 2601 | break; |
---|
| 2602 | default: |
---|
| 2603 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
[1029] | 2604 | nPSW = getWidth(0); |
---|
| 2605 | nPSH = getHeight(0); |
---|
[208] | 2606 | xP = col ; |
---|
| 2607 | yP = row ; |
---|
| 2608 | |
---|
| 2609 | break; |
---|
| 2610 | } |
---|
| 2611 | } |
---|
| 2612 | |
---|
[1465] | 2613 | /** Constructs a list of candidates for AMVP (See specification, section "Derivation process for motion vector predictor candidates") |
---|
[208] | 2614 | * \param uiPartIdx |
---|
[1029] | 2615 | * \param uiPartAddr |
---|
[208] | 2616 | * \param eRefPicList |
---|
| 2617 | * \param iRefIdx |
---|
| 2618 | * \param pInfo |
---|
| 2619 | */ |
---|
[1465] | 2620 | Void TComDataCU::fillMvpCand ( const UInt partIdx, const UInt partAddr, const RefPicList eRefPicList, const Int refIdx, AMVPInfo* pInfo ) const |
---|
[208] | 2621 | { |
---|
[1029] | 2622 | pInfo->iN = 0; |
---|
[1465] | 2623 | if (refIdx < 0) |
---|
[208] | 2624 | { |
---|
| 2625 | return; |
---|
| 2626 | } |
---|
[1029] | 2627 | |
---|
[208] | 2628 | //-- Get Spatial MV |
---|
[1465] | 2629 | UInt partIdxLT, partIdxRT, partIdxLB; |
---|
| 2630 | deriveLeftRightTopIdx( partIdx, partIdxLT, partIdxRT ); |
---|
| 2631 | deriveLeftBottomIdx( partIdx, partIdxLB ); |
---|
[1029] | 2632 | |
---|
[1465] | 2633 | Bool isScaledFlagLX = false; /// variable name from specification; true when the PUs below left or left are available (availableA0 || availableA1). |
---|
[208] | 2634 | { |
---|
[1465] | 2635 | UInt idx; |
---|
| 2636 | const TComDataCU* tmpCU = getPUBelowLeft(idx, partIdxLB); |
---|
| 2637 | isScaledFlagLX = (tmpCU != NULL) && (tmpCU->isInter(idx)); |
---|
| 2638 | if (!isScaledFlagLX) |
---|
| 2639 | { |
---|
| 2640 | tmpCU = getPULeft(idx, partIdxLB); |
---|
| 2641 | isScaledFlagLX = (tmpCU != NULL) && (tmpCU->isInter(idx)); |
---|
| 2642 | } |
---|
[208] | 2643 | } |
---|
| 2644 | |
---|
| 2645 | // Left predictor search |
---|
[1465] | 2646 | if (isScaledFlagLX) |
---|
[208] | 2647 | { |
---|
[1465] | 2648 | Bool bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLB, MD_BELOW_LEFT); |
---|
[1029] | 2649 | if (!bAdded) |
---|
[208] | 2650 | { |
---|
[1465] | 2651 | bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLB, MD_LEFT ); |
---|
| 2652 | if(!bAdded) |
---|
| 2653 | { |
---|
| 2654 | bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLB, MD_BELOW_LEFT); |
---|
| 2655 | if (!bAdded) |
---|
| 2656 | { |
---|
| 2657 | xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLB, MD_LEFT ); |
---|
| 2658 | } |
---|
| 2659 | } |
---|
[208] | 2660 | } |
---|
| 2661 | } |
---|
[1029] | 2662 | |
---|
[208] | 2663 | // Above predictor search |
---|
| 2664 | { |
---|
[1465] | 2665 | Bool bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE_RIGHT); |
---|
| 2666 | if (!bAdded) |
---|
| 2667 | { |
---|
| 2668 | bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE); |
---|
| 2669 | if(!bAdded) |
---|
| 2670 | { |
---|
| 2671 | xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLT, MD_ABOVE_LEFT); |
---|
| 2672 | } |
---|
| 2673 | } |
---|
[208] | 2674 | } |
---|
| 2675 | |
---|
[1465] | 2676 | if(!isScaledFlagLX) |
---|
[208] | 2677 | { |
---|
[1465] | 2678 | Bool bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE_RIGHT); |
---|
[1029] | 2679 | if (!bAdded) |
---|
[208] | 2680 | { |
---|
[1465] | 2681 | bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE); |
---|
| 2682 | if(!bAdded) |
---|
| 2683 | { |
---|
| 2684 | xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLT, MD_ABOVE_LEFT); |
---|
| 2685 | } |
---|
[208] | 2686 | } |
---|
| 2687 | } |
---|
[1029] | 2688 | |
---|
[208] | 2689 | if ( pInfo->iN == 2 ) |
---|
| 2690 | { |
---|
| 2691 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
| 2692 | { |
---|
| 2693 | pInfo->iN = 1; |
---|
| 2694 | } |
---|
| 2695 | } |
---|
| 2696 | |
---|
[1465] | 2697 | if (pInfo->iN < AMVP_MAX_NUM_CANDS && getSlice()->getEnableTMVPFlag() ) |
---|
[208] | 2698 | { |
---|
| 2699 | // Get Temporal Motion Predictor |
---|
[1465] | 2700 | const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); |
---|
| 2701 | const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); |
---|
| 2702 | const Int refIdx_Col = refIdx; |
---|
[208] | 2703 | TComMv cColMv; |
---|
[1465] | 2704 | UInt partIdxRB; |
---|
| 2705 | UInt absPartIdx; |
---|
[208] | 2706 | |
---|
[1465] | 2707 | deriveRightBottomIdx( partIdx, partIdxRB ); |
---|
| 2708 | UInt absPartAddr = m_absZIdxInCtu + partAddr; |
---|
[208] | 2709 | |
---|
| 2710 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
[1465] | 2711 | absPartIdx = g_auiZscanToRaster[partIdxRB]; |
---|
[1029] | 2712 | Int ctuRsAddr = -1; |
---|
[1203] | 2713 | |
---|
[1465] | 2714 | if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[absPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check |
---|
| 2715 | && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[absPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[208] | 2716 | { |
---|
[1465] | 2717 | if ( ( absPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU |
---|
| 2718 | ( absPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU |
---|
[208] | 2719 | { |
---|
[1465] | 2720 | absPartAddr = g_auiRasterToZscan[ absPartIdx + numPartInCtuWidth + 1 ]; |
---|
[1029] | 2721 | ctuRsAddr = getCtuRsAddr(); |
---|
[208] | 2722 | } |
---|
[1465] | 2723 | else if ( absPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU |
---|
[208] | 2724 | { |
---|
[1465] | 2725 | absPartAddr = g_auiRasterToZscan[ (absPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; |
---|
[208] | 2726 | } |
---|
[1465] | 2727 | else if ( absPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU |
---|
[208] | 2728 | { |
---|
[1465] | 2729 | absPartAddr = g_auiRasterToZscan[ absPartIdx + 1 ]; |
---|
[1029] | 2730 | ctuRsAddr = getCtuRsAddr() + 1; |
---|
[208] | 2731 | } |
---|
[1029] | 2732 | else //is the right bottom corner of CTU |
---|
[208] | 2733 | { |
---|
[1465] | 2734 | absPartAddr = 0; |
---|
[208] | 2735 | } |
---|
| 2736 | } |
---|
[1465] | 2737 | if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, absPartAddr, cColMv, refIdx_Col ) ) |
---|
[208] | 2738 | { |
---|
| 2739 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
| 2740 | } |
---|
[1029] | 2741 | else |
---|
[208] | 2742 | { |
---|
| 2743 | UInt uiPartIdxCenter; |
---|
[1465] | 2744 | xDeriveCenterIdx( partIdx, uiPartIdxCenter ); |
---|
| 2745 | if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter, cColMv, refIdx_Col )) |
---|
[208] | 2746 | { |
---|
| 2747 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
| 2748 | } |
---|
| 2749 | } |
---|
| 2750 | //---- co-located RightBottom Temporal Predictor ---// |
---|
| 2751 | } |
---|
| 2752 | |
---|
| 2753 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
| 2754 | { |
---|
[1029] | 2755 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
| 2756 | pInfo->iN++; |
---|
[208] | 2757 | } |
---|
| 2758 | return ; |
---|
| 2759 | } |
---|
| 2760 | |
---|
[1029] | 2761 | |
---|
[1465] | 2762 | Bool TComDataCU::isBipredRestriction(UInt puIdx) const |
---|
[208] | 2763 | { |
---|
| 2764 | Int width = 0; |
---|
| 2765 | Int height = 0; |
---|
| 2766 | UInt partAddr; |
---|
| 2767 | |
---|
| 2768 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
| 2769 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
| 2770 | { |
---|
| 2771 | return true; |
---|
| 2772 | } |
---|
| 2773 | return false; |
---|
| 2774 | } |
---|
| 2775 | |
---|
[1029] | 2776 | |
---|
[1395] | 2777 | Void TComDataCU::clipMv (TComMv& rcMv) const |
---|
[208] | 2778 | { |
---|
[1289] | 2779 | const TComSPS &sps=*(m_pcSlice->getSPS()); |
---|
[208] | 2780 | Int iMvShift = 2; |
---|
| 2781 | Int iOffset = 8; |
---|
[1289] | 2782 | Int iHorMax = ( sps.getPicWidthInLumaSamples() + iOffset - (Int)m_uiCUPelX - 1 ) << iMvShift; |
---|
| 2783 | Int iHorMin = ( -(Int)sps.getMaxCUWidth() - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
[1465] | 2784 | |
---|
[1289] | 2785 | Int iVerMax = ( sps.getPicHeightInLumaSamples() + iOffset - (Int)m_uiCUPelY - 1 ) << iMvShift; |
---|
| 2786 | Int iVerMin = ( -(Int)sps.getMaxCUHeight() - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
[1029] | 2787 | |
---|
[208] | 2788 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
| 2789 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
| 2790 | } |
---|
| 2791 | |
---|
[1029] | 2792 | |
---|
[1465] | 2793 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) const |
---|
[208] | 2794 | { |
---|
[310] | 2795 | UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
[1029] | 2796 | |
---|
[208] | 2797 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
| 2798 | UInt uiCnt = 0; |
---|
| 2799 | while( uiWidth ) |
---|
| 2800 | { |
---|
| 2801 | uiCnt++; |
---|
| 2802 | uiWidth>>=1; |
---|
| 2803 | } |
---|
| 2804 | uiCnt-=2; |
---|
| 2805 | return uiCnt > 6 ? 6 : uiCnt; |
---|
| 2806 | } |
---|
| 2807 | |
---|
[1029] | 2808 | Void TComDataCU::clearCbf( UInt uiIdx, ComponentID compID, UInt uiNumParts ) |
---|
[208] | 2809 | { |
---|
[1029] | 2810 | memset( &m_puhCbf[compID][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
[208] | 2811 | } |
---|
| 2812 | |
---|
| 2813 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
| 2814 | * \param bIpcmFlag I_PCM flag |
---|
| 2815 | * \param uiAbsPartIdx patition index |
---|
| 2816 | * \param uiDepth CU depth |
---|
| 2817 | * \returns Void |
---|
| 2818 | */ |
---|
| 2819 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
| 2820 | { |
---|
[1029] | 2821 | UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); |
---|
[208] | 2822 | |
---|
| 2823 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
| 2824 | } |
---|
| 2825 | |
---|
[1258] | 2826 | /** Test whether the block at uiPartIdx is skipped. |
---|
| 2827 | * \param uiPartIdx Partition index |
---|
| 2828 | * \returns true if the current the block is skipped |
---|
[208] | 2829 | */ |
---|
[1465] | 2830 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) const |
---|
[208] | 2831 | { |
---|
| 2832 | return ( getSkipFlag( uiPartIdx ) ); |
---|
| 2833 | } |
---|
| 2834 | |
---|
| 2835 | // ==================================================================================================================== |
---|
| 2836 | // Protected member functions |
---|
| 2837 | // ==================================================================================================================== |
---|
| 2838 | |
---|
[1465] | 2839 | Bool TComDataCU::xAddMVPCandUnscaled( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const |
---|
[208] | 2840 | { |
---|
[1465] | 2841 | const TComDataCU* neibCU = NULL; |
---|
| 2842 | UInt neibPUPartIdx; |
---|
[208] | 2843 | switch( eDir ) |
---|
| 2844 | { |
---|
| 2845 | case MD_LEFT: |
---|
| 2846 | { |
---|
[1465] | 2847 | neibCU = getPULeft(neibPUPartIdx, uiPartUnitIdx); |
---|
[208] | 2848 | break; |
---|
| 2849 | } |
---|
| 2850 | case MD_ABOVE: |
---|
| 2851 | { |
---|
[1465] | 2852 | neibCU = getPUAbove(neibPUPartIdx, uiPartUnitIdx); |
---|
[208] | 2853 | break; |
---|
| 2854 | } |
---|
| 2855 | case MD_ABOVE_RIGHT: |
---|
| 2856 | { |
---|
[1465] | 2857 | neibCU = getPUAboveRight(neibPUPartIdx, uiPartUnitIdx); |
---|
[208] | 2858 | break; |
---|
| 2859 | } |
---|
| 2860 | case MD_BELOW_LEFT: |
---|
| 2861 | { |
---|
[1465] | 2862 | neibCU = getPUBelowLeft(neibPUPartIdx, uiPartUnitIdx); |
---|
[208] | 2863 | break; |
---|
| 2864 | } |
---|
| 2865 | case MD_ABOVE_LEFT: |
---|
| 2866 | { |
---|
[1465] | 2867 | neibCU = getPUAboveLeft(neibPUPartIdx, uiPartUnitIdx); |
---|
[208] | 2868 | break; |
---|
| 2869 | } |
---|
| 2870 | default: |
---|
| 2871 | { |
---|
| 2872 | break; |
---|
| 2873 | } |
---|
| 2874 | } |
---|
| 2875 | |
---|
[1465] | 2876 | if ( neibCU == NULL ) |
---|
[208] | 2877 | { |
---|
| 2878 | return false; |
---|
| 2879 | } |
---|
[1029] | 2880 | |
---|
[1465] | 2881 | const Int currRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
| 2882 | const RefPicList eRefPicList2nd = (eRefPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
[1029] | 2883 | |
---|
[1465] | 2884 | for(Int predictorSource=0; predictorSource<2; predictorSource++) // examine the indicated reference picture list, then if not available, examine the other list. |
---|
[208] | 2885 | { |
---|
[1465] | 2886 | const RefPicList eRefPicListIndex = (predictorSource==0) ? eRefPicList : eRefPicList2nd; |
---|
| 2887 | const Int neibRefIdx = neibCU->getCUMvField(eRefPicListIndex)->getRefIdx(neibPUPartIdx); |
---|
[208] | 2888 | |
---|
[1465] | 2889 | if ( neibRefIdx >= 0 && currRefPOC == neibCU->getSlice()->getRefPOC( eRefPicListIndex, neibRefIdx )) |
---|
[208] | 2890 | { |
---|
[1465] | 2891 | info.m_acMvCand[info.iN++] = neibCU->getCUMvField(eRefPicListIndex)->getMv(neibPUPartIdx); |
---|
[208] | 2892 | return true; |
---|
| 2893 | } |
---|
| 2894 | } |
---|
[1465] | 2895 | |
---|
[208] | 2896 | return false; |
---|
| 2897 | } |
---|
| 2898 | |
---|
[1029] | 2899 | /** |
---|
[208] | 2900 | * \param pInfo |
---|
[1029] | 2901 | * \param eRefPicList |
---|
[208] | 2902 | * \param iRefIdx |
---|
| 2903 | * \param uiPartUnitIdx |
---|
| 2904 | * \param eDir |
---|
| 2905 | * \returns Bool |
---|
| 2906 | */ |
---|
[1465] | 2907 | Bool TComDataCU::xAddMVPCandWithScaling( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const |
---|
[208] | 2908 | { |
---|
[1465] | 2909 | const TComDataCU* neibCU = NULL; |
---|
| 2910 | UInt neibPUPartIdx; |
---|
[208] | 2911 | switch( eDir ) |
---|
| 2912 | { |
---|
| 2913 | case MD_LEFT: |
---|
| 2914 | { |
---|
[1465] | 2915 | neibCU = getPULeft(neibPUPartIdx, uiPartUnitIdx); |
---|
[208] | 2916 | break; |
---|
| 2917 | } |
---|
| 2918 | case MD_ABOVE: |
---|
| 2919 | { |
---|
[1465] | 2920 | neibCU = getPUAbove(neibPUPartIdx, uiPartUnitIdx); |
---|
[208] | 2921 | break; |
---|
| 2922 | } |
---|
| 2923 | case MD_ABOVE_RIGHT: |
---|
| 2924 | { |
---|
[1465] | 2925 | neibCU = getPUAboveRight(neibPUPartIdx, uiPartUnitIdx); |
---|
[208] | 2926 | break; |
---|
| 2927 | } |
---|
| 2928 | case MD_BELOW_LEFT: |
---|
| 2929 | { |
---|
[1465] | 2930 | neibCU = getPUBelowLeft(neibPUPartIdx, uiPartUnitIdx); |
---|
[208] | 2931 | break; |
---|
| 2932 | } |
---|
| 2933 | case MD_ABOVE_LEFT: |
---|
| 2934 | { |
---|
[1465] | 2935 | neibCU = getPUAboveLeft(neibPUPartIdx, uiPartUnitIdx); |
---|
[208] | 2936 | break; |
---|
| 2937 | } |
---|
| 2938 | default: |
---|
| 2939 | { |
---|
| 2940 | break; |
---|
| 2941 | } |
---|
| 2942 | } |
---|
| 2943 | |
---|
[1465] | 2944 | if ( neibCU == NULL ) |
---|
[208] | 2945 | { |
---|
| 2946 | return false; |
---|
| 2947 | } |
---|
[1029] | 2948 | |
---|
[1465] | 2949 | const RefPicList eRefPicList2nd = (eRefPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
[208] | 2950 | |
---|
[1465] | 2951 | const Int currPOC = m_pcSlice->getPOC(); |
---|
| 2952 | const Int currRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
| 2953 | const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
| 2954 | const Int neibPOC = currPOC; |
---|
[1029] | 2955 | |
---|
[1465] | 2956 | for(Int predictorSource=0; predictorSource<2; predictorSource++) // examine the indicated reference picture list, then if not available, examine the other list. |
---|
[208] | 2957 | { |
---|
[1465] | 2958 | const RefPicList eRefPicListIndex = (predictorSource==0) ? eRefPicList : eRefPicList2nd; |
---|
| 2959 | const Int neibRefIdx = neibCU->getCUMvField(eRefPicListIndex)->getRefIdx(neibPUPartIdx); |
---|
| 2960 | if( neibRefIdx >= 0) |
---|
| 2961 | { |
---|
| 2962 | const Bool bIsNeibRefLongTerm = neibCU->getSlice()->getRefPic( eRefPicListIndex, neibRefIdx )->getIsLongTerm(); |
---|
[208] | 2963 | |
---|
[1465] | 2964 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
[208] | 2965 | { |
---|
[1465] | 2966 | const TComMv &cMvPred = neibCU->getCUMvField(eRefPicListIndex)->getMv(neibPUPartIdx); |
---|
| 2967 | TComMv rcMv; |
---|
| 2968 | if ( bIsCurrRefLongTerm /* || bIsNeibRefLongTerm*/ ) |
---|
[1029] | 2969 | { |
---|
| 2970 | rcMv = cMvPred; |
---|
| 2971 | } |
---|
| 2972 | else |
---|
| 2973 | { |
---|
[1465] | 2974 | const Int neibRefPOC = neibCU->getSlice()->getRefPOC( eRefPicListIndex, neibRefIdx ); |
---|
| 2975 | const Int scale = xGetDistScaleFactor( currPOC, currRefPOC, neibPOC, neibRefPOC ); |
---|
| 2976 | if ( scale == 4096 ) |
---|
| 2977 | { |
---|
| 2978 | rcMv = cMvPred; |
---|
| 2979 | } |
---|
| 2980 | else |
---|
| 2981 | { |
---|
| 2982 | rcMv = cMvPred.scaleMv( scale ); |
---|
| 2983 | } |
---|
[1029] | 2984 | } |
---|
| 2985 | |
---|
[1465] | 2986 | info.m_acMvCand[info.iN++] = rcMv; |
---|
| 2987 | return true; |
---|
[208] | 2988 | } |
---|
| 2989 | } |
---|
| 2990 | } |
---|
| 2991 | return false; |
---|
| 2992 | } |
---|
| 2993 | |
---|
[1465] | 2994 | Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, const Int refIdx ) const |
---|
[208] | 2995 | { |
---|
[1465] | 2996 | const UInt absPartAddr = partUnitIdx; |
---|
[208] | 2997 | |
---|
| 2998 | // use coldir. |
---|
[1465] | 2999 | const TComPic * const pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
| 3000 | const TComDataCU * const pColCtu = pColPic->getCtu( ctuRsAddr ); |
---|
| 3001 | if(pColCtu->getPic()==0 || pColCtu->getPartitionSize(partUnitIdx)==NUMBER_OF_PART_SIZES) |
---|
[208] | 3002 | { |
---|
| 3003 | return false; |
---|
| 3004 | } |
---|
| 3005 | |
---|
[1465] | 3006 | if (!pColCtu->isInter(absPartAddr)) |
---|
[208] | 3007 | { |
---|
| 3008 | return false; |
---|
| 3009 | } |
---|
[1029] | 3010 | |
---|
[1465] | 3011 | RefPicList eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
---|
| 3012 | Int iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr); |
---|
[208] | 3013 | |
---|
| 3014 | if (iColRefIdx < 0 ) |
---|
| 3015 | { |
---|
| 3016 | eColRefPicList = RefPicList(1 - eColRefPicList); |
---|
[1465] | 3017 | iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr); |
---|
[208] | 3018 | |
---|
| 3019 | if (iColRefIdx < 0 ) |
---|
| 3020 | { |
---|
| 3021 | return false; |
---|
| 3022 | } |
---|
| 3023 | } |
---|
| 3024 | |
---|
[1465] | 3025 | const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm(); |
---|
| 3026 | const Bool bIsColRefLongTerm = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
---|
[208] | 3027 | |
---|
[1029] | 3028 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
[208] | 3029 | { |
---|
| 3030 | return false; |
---|
| 3031 | } |
---|
| 3032 | |
---|
[1465] | 3033 | // Scale the vector. |
---|
| 3034 | const TComMv &cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr); |
---|
| 3035 | if ( bIsCurrRefLongTerm /*|| bIsColRefLongTerm*/ ) |
---|
[208] | 3036 | { |
---|
| 3037 | rcMv = cColMv; |
---|
| 3038 | } |
---|
| 3039 | else |
---|
| 3040 | { |
---|
[1465] | 3041 | const Int currPOC = m_pcSlice->getPOC(); |
---|
| 3042 | const Int colPOC = pColCtu->getSlice()->getPOC(); |
---|
| 3043 | const Int colRefPOC = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
---|
| 3044 | const Int currRefPOC = m_pcSlice->getRefPic(eRefPicList, refIdx)->getPOC(); |
---|
| 3045 | const Int scale = xGetDistScaleFactor(currPOC, currRefPOC, colPOC, colRefPOC); |
---|
| 3046 | if ( scale == 4096 ) |
---|
[208] | 3047 | { |
---|
| 3048 | rcMv = cColMv; |
---|
| 3049 | } |
---|
| 3050 | else |
---|
| 3051 | { |
---|
[1465] | 3052 | rcMv = cColMv.scaleMv( scale ); |
---|
[208] | 3053 | } |
---|
| 3054 | } |
---|
[1029] | 3055 | |
---|
[208] | 3056 | return true; |
---|
| 3057 | } |
---|
| 3058 | |
---|
[1465] | 3059 | // Static member |
---|
[208] | 3060 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
| 3061 | { |
---|
| 3062 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
| 3063 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
[1029] | 3064 | |
---|
[208] | 3065 | if( iDiffPocD == iDiffPocB ) |
---|
| 3066 | { |
---|
| 3067 | return 4096; |
---|
| 3068 | } |
---|
| 3069 | else |
---|
| 3070 | { |
---|
| 3071 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
| 3072 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
| 3073 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
| 3074 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
---|
| 3075 | return iScale; |
---|
| 3076 | } |
---|
| 3077 | } |
---|
| 3078 | |
---|
[1465] | 3079 | Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) const |
---|
[208] | 3080 | { |
---|
| 3081 | UInt uiPartAddr; |
---|
| 3082 | Int iPartWidth; |
---|
| 3083 | Int iPartHeight; |
---|
| 3084 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
[1029] | 3085 | |
---|
| 3086 | ruiPartIdxCenter = m_absZIdxInCtu+uiPartAddr; // partition origin. |
---|
[208] | 3087 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
[1029] | 3088 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInCtuWidth() |
---|
[208] | 3089 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
---|
| 3090 | } |
---|
| 3091 | |
---|
| 3092 | Void TComDataCU::compressMV() |
---|
| 3093 | { |
---|
| 3094 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
| 3095 | if (scaleFactor > 0) |
---|
| 3096 | { |
---|
[1029] | 3097 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 3098 | { |
---|
| 3099 | m_acCUMvField[i].compress(m_pePredMode, scaleFactor); |
---|
| 3100 | } |
---|
[208] | 3101 | } |
---|
| 3102 | } |
---|
| 3103 | |
---|
[1029] | 3104 | UInt TComDataCU::getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const |
---|
[208] | 3105 | { |
---|
[1029] | 3106 | //------------------------------------------------ |
---|
[208] | 3107 | |
---|
[1029] | 3108 | //this mechanism is available for intra only |
---|
[208] | 3109 | |
---|
[1246] | 3110 | if (!isIntra(uiAbsPartIdx)) |
---|
| 3111 | { |
---|
| 3112 | return SCAN_DIAG; |
---|
| 3113 | } |
---|
[1029] | 3114 | |
---|
| 3115 | //------------------------------------------------ |
---|
| 3116 | |
---|
| 3117 | //check that MDCS can be used for this TU |
---|
| 3118 | |
---|
| 3119 | const ChromaFormat format = getPic()->getChromaFormat(); |
---|
| 3120 | |
---|
| 3121 | const UInt maximumWidth = MDCS_MAXIMUM_WIDTH >> getComponentScaleX(compID, format); |
---|
| 3122 | const UInt maximumHeight = MDCS_MAXIMUM_HEIGHT >> getComponentScaleY(compID, format); |
---|
| 3123 | |
---|
[1246] | 3124 | if ((uiWidth > maximumWidth) || (uiHeight > maximumHeight)) |
---|
| 3125 | { |
---|
| 3126 | return SCAN_DIAG; |
---|
| 3127 | } |
---|
[1029] | 3128 | |
---|
| 3129 | //------------------------------------------------ |
---|
| 3130 | |
---|
| 3131 | //otherwise, select the appropriate mode |
---|
| 3132 | |
---|
| 3133 | UInt uiDirMode = getIntraDir(toChannelType(compID), uiAbsPartIdx); |
---|
| 3134 | |
---|
| 3135 | if (uiDirMode==DM_CHROMA_IDX) |
---|
[208] | 3136 | { |
---|
[1290] | 3137 | const TComSPS *sps=getSlice()->getSPS(); |
---|
| 3138 | const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize())); |
---|
| 3139 | uiDirMode = getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, getPic()->getChromaFormat(), partsPerMinCU)); |
---|
[208] | 3140 | } |
---|
| 3141 | |
---|
[1029] | 3142 | if (isChroma(compID) && (format == CHROMA_422)) |
---|
[208] | 3143 | { |
---|
[1029] | 3144 | uiDirMode = g_chroma422IntraAngleMappingTable[uiDirMode]; |
---|
[208] | 3145 | } |
---|
| 3146 | |
---|
[1029] | 3147 | //------------------ |
---|
[208] | 3148 | |
---|
[1246] | 3149 | if (abs((Int)uiDirMode - VER_IDX) <= MDCS_ANGLE_LIMIT) |
---|
| 3150 | { |
---|
| 3151 | return SCAN_HOR; |
---|
| 3152 | } |
---|
| 3153 | else if (abs((Int)uiDirMode - HOR_IDX) <= MDCS_ANGLE_LIMIT) |
---|
| 3154 | { |
---|
| 3155 | return SCAN_VER; |
---|
| 3156 | } |
---|
| 3157 | else |
---|
| 3158 | { |
---|
| 3159 | return SCAN_DIAG; |
---|
| 3160 | } |
---|
[208] | 3161 | } |
---|
| 3162 | |
---|
[442] | 3163 | #if SVC_EXTENSION |
---|
[1419] | 3164 | TComDataCU* TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int** petPosScalingFactor, Bool motionMapping ) |
---|
[208] | 3165 | { |
---|
| 3166 | UInt uiPelX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiCuAbsPartIdx] ]; |
---|
| 3167 | UInt uiPelY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiCuAbsPartIdx] ]; |
---|
| 3168 | |
---|
[1419] | 3169 | return getBaseColCU( refLayerIdc, uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase, petPosScalingFactor, motionMapping ); |
---|
[208] | 3170 | } |
---|
| 3171 | |
---|
[1419] | 3172 | TComDataCU* TComDataCU::getBaseColCU( UInt refLayerIdc, UInt pelX, UInt pelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int** posScalingFactor, Bool motionMapping ) |
---|
[208] | 3173 | { |
---|
[713] | 3174 | TComPic* baseColPic = m_pcSlice->getBaseColPic(refLayerIdc); |
---|
[208] | 3175 | |
---|
[1074] | 3176 | Int iPelX = Clip3<Int>(0, m_pcPic->getPicYuvRec()->getWidth(COMPONENT_Y) - 1, pelX); |
---|
| 3177 | Int iPelY = Clip3<Int>(0, m_pcPic->getPicYuvRec()->getHeight(COMPONENT_Y) - 1, pelY); |
---|
[208] | 3178 | |
---|
[827] | 3179 | // centre of the collocated 16x16 block for motion mapping |
---|
| 3180 | if( motionMapping ) |
---|
| 3181 | { |
---|
[1074] | 3182 | iPelX = pelX + 8; |
---|
| 3183 | iPelY = pelY + 8; |
---|
[827] | 3184 | } |
---|
| 3185 | |
---|
[1030] | 3186 | Int leftStartL = m_pcSlice->getPPS()->getScaledRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowLeftOffset(); |
---|
| 3187 | Int topStartL = m_pcSlice->getPPS()->getScaledRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowTopOffset(); |
---|
[713] | 3188 | |
---|
[1038] | 3189 | const Window &windowRL = m_pcSlice->getPPS()->getRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)); |
---|
[1419] | 3190 | Int iBX = (((iPelX - leftStartL) * posScalingFactor[0][refLayerIdc] + (1<<15)) >> 16) + windowRL.getWindowLeftOffset(); |
---|
| 3191 | Int iBY = (((iPelY - topStartL ) * posScalingFactor[1][refLayerIdc] + (1<<15)) >> 16) + windowRL.getWindowTopOffset(); |
---|
[208] | 3192 | |
---|
[815] | 3193 | // offset for collocated block in the motion mapping |
---|
[822] | 3194 | if( motionMapping ) |
---|
[442] | 3195 | { |
---|
[901] | 3196 | if( m_pcPic->equalPictureSizeAndOffsetFlag(refLayerIdc) ) |
---|
[815] | 3197 | { |
---|
[901] | 3198 | // copy motion field from the same sample position for the case of 1x scaling ratio and same offset value between the current and reference layers |
---|
| 3199 | iBX = pelX; |
---|
| 3200 | iBY = pelY; |
---|
[815] | 3201 | } |
---|
| 3202 | else |
---|
| 3203 | { |
---|
[901] | 3204 | // actually, motion field compression is performed in the Void TComPic::compressMotion() function, but with (+4) the rounding may have effect on the picture boundary check. |
---|
| 3205 | iBX = ( ( iBX + 4 ) >> 4 ) << 4; |
---|
| 3206 | iBY = ( ( iBY + 4 ) >> 4 ) << 4; |
---|
[815] | 3207 | } |
---|
[442] | 3208 | } |
---|
[345] | 3209 | |
---|
[1029] | 3210 | if ( iBX < 0 || iBX >= baseColPic->getPicYuvRec()->getWidth(COMPONENT_Y) || iBY < 0 || iBY >= baseColPic->getPicYuvRec()->getHeight(COMPONENT_Y) ) |
---|
[208] | 3211 | { |
---|
| 3212 | return NULL; |
---|
| 3213 | } |
---|
| 3214 | |
---|
[1289] | 3215 | UInt baseMaxCUHeight = baseColPic->getSlice(0)->getSPS()->getMaxCUHeight(); |
---|
| 3216 | UInt baseMaxCUWidth = baseColPic->getSlice(0)->getSPS()->getMaxCUWidth(); |
---|
[713] | 3217 | UInt baseMinUnitSize = baseColPic->getMinCUWidth(); |
---|
[494] | 3218 | |
---|
[1029] | 3219 | uiCUAddrBase = ( iBY / baseMaxCUHeight ) * baseColPic->getFrameWidthInCtus() + ( iBX / baseMaxCUWidth ); |
---|
[208] | 3220 | |
---|
[1029] | 3221 | assert(uiCUAddrBase < baseColPic->getNumberOfCtusInFrame()); |
---|
[208] | 3222 | |
---|
[1289] | 3223 | UInt uiRasterAddrBase = ( iBY - (iBY/baseMaxCUHeight)*baseMaxCUHeight ) / baseMinUnitSize * baseColPic->getNumPartInCtuWidth() + ( iBX - (iBX/baseMaxCUWidth)*baseMaxCUWidth ) / baseMinUnitSize; |
---|
| 3224 | |
---|
[494] | 3225 | #if LAYER_CTB |
---|
[713] | 3226 | uiAbsPartIdxBase = g_auiLayerRasterToZscan[baseColPic->getLayerId()][uiRasterAddrBase]; |
---|
[494] | 3227 | #else |
---|
[208] | 3228 | uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase]; |
---|
[494] | 3229 | #endif |
---|
[208] | 3230 | |
---|
[1029] | 3231 | return baseColPic->getCtu(uiCUAddrBase); |
---|
[208] | 3232 | } |
---|
| 3233 | |
---|
[1419] | 3234 | Void TComDataCU::scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase, Int** mvScalingFactor ) |
---|
[208] | 3235 | { |
---|
| 3236 | TComMvField cMvFieldBase; |
---|
| 3237 | TComMv cMv; |
---|
[442] | 3238 | |
---|
[1419] | 3239 | cMv = rcMvFieldBase.getMv().scaleMv( mvScalingFactor[0][refLayerIdc], mvScalingFactor[1][refLayerIdc] ); |
---|
[208] | 3240 | |
---|
| 3241 | rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() ); |
---|
| 3242 | } |
---|
[713] | 3243 | |
---|
| 3244 | #if FAST_INTRA_SHVC |
---|
| 3245 | /** generate limited set of remaining modes |
---|
| 3246 | *\param uiAbsPartIdx |
---|
| 3247 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
| 3248 | *\returns Number of intra coding modes (nb of remaining modes + 3 MPMs) |
---|
| 3249 | */ |
---|
[1421] | 3250 | Int TComDataCU::reduceSetOfIntraModes( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int** posScalingFactor, Int &fullSetOfModes ) |
---|
[713] | 3251 | { |
---|
| 3252 | // check BL mode |
---|
[822] | 3253 | UInt uiCUAddrBase = 0, uiAbsPartAddrBase = 0; |
---|
[713] | 3254 | // the right reference layerIdc should be specified, currently it is set to m_layerId-1 |
---|
[1483] | 3255 | TComDataCU* pcTempCU = getBaseColCU(m_pcPic->getLayerId() - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase, posScalingFactor, false ); |
---|
[713] | 3256 | |
---|
| 3257 | if( pcTempCU->getPredictionMode( uiAbsPartAddrBase ) != MODE_INTRA ) |
---|
| 3258 | { |
---|
| 3259 | return( NUM_INTRA_MODE-1 ); |
---|
[1418] | 3260 | } |
---|
[713] | 3261 | |
---|
[1418] | 3262 | // compute set of enabled modes m_reducedSetIntraModes[...] |
---|
[713] | 3263 | Int authorizedMode[NUM_INTRA_MODE-1]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; |
---|
| 3264 | Int nbModes; |
---|
| 3265 | for (nbModes=0; nbModes<3; nbModes++) // add 3 MPMs 1st |
---|
| 3266 | { |
---|
[1418] | 3267 | m_reducedSetIntraModes[nbModes] = uiIntraDirPred[nbModes]; |
---|
[713] | 3268 | authorizedMode[ uiIntraDirPred[nbModes] ] = 0; |
---|
| 3269 | } |
---|
| 3270 | |
---|
[1029] | 3271 | Int iColBaseDir = pcTempCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartAddrBase ); |
---|
[713] | 3272 | if ( authorizedMode[iColBaseDir] ) //possibly add BL mode |
---|
| 3273 | { |
---|
[1418] | 3274 | m_reducedSetIntraModes[nbModes++] = iColBaseDir; |
---|
[713] | 3275 | authorizedMode[ iColBaseDir ] = 0; |
---|
| 3276 | } |
---|
| 3277 | |
---|
| 3278 | Int iRefMode = ( iColBaseDir > 1 ) ? iColBaseDir : uiIntraDirPred[0]; |
---|
| 3279 | if ( iRefMode > 1 ) //add neighboring modes of refMode |
---|
| 3280 | { |
---|
[1418] | 3281 | UInt left = iRefMode; |
---|
| 3282 | UInt right = iRefMode; |
---|
[713] | 3283 | while ( nbModes < NB_REMAIN_MODES+3 ) |
---|
| 3284 | { |
---|
[1418] | 3285 | left = ((left + 29) % 32) + 2; |
---|
| 3286 | right = ((right - 1 ) % 32) + 2; |
---|
| 3287 | if( authorizedMode[left] ) |
---|
| 3288 | { |
---|
| 3289 | m_reducedSetIntraModes[nbModes++] = left; |
---|
| 3290 | } |
---|
| 3291 | if( authorizedMode[right] ) |
---|
| 3292 | { |
---|
| 3293 | m_reducedSetIntraModes[nbModes++] = right; |
---|
| 3294 | } |
---|
[713] | 3295 | } |
---|
| 3296 | } |
---|
| 3297 | else //add pre-defined modes |
---|
| 3298 | { |
---|
[1418] | 3299 | const UChar predefSetIntraModes[NUM_INTRA_MODE-1] = {26,10,18,34,2,22,14,30,6,24,12,28,8,20,16,32,4,17,19,15,21,13,23,11,25,9,27,7,29,5,31,3,33,0,2}; |
---|
| 3300 | |
---|
[713] | 3301 | Int idx = 0; |
---|
[1418] | 3302 | while( nbModes < NB_REMAIN_MODES+3 ) |
---|
[713] | 3303 | { |
---|
[1418] | 3304 | UInt mode = predefSetIntraModes[idx++]; |
---|
| 3305 | if( authorizedMode[mode] ) |
---|
| 3306 | { |
---|
| 3307 | m_reducedSetIntraModes[nbModes++] = mode; |
---|
| 3308 | } |
---|
[713] | 3309 | } |
---|
| 3310 | } |
---|
| 3311 | |
---|
| 3312 | fullSetOfModes = 0; |
---|
[1418] | 3313 | |
---|
| 3314 | return nbModes; |
---|
[713] | 3315 | } |
---|
| 3316 | #endif |
---|
| 3317 | |
---|
| 3318 | #if REF_IDX_ME_ZEROMV |
---|
| 3319 | Bool TComDataCU::xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1) |
---|
| 3320 | { |
---|
| 3321 | Bool checkZeroMVILR = true; |
---|
| 3322 | |
---|
| 3323 | if(uhInterDir&0x1) //list0 |
---|
| 3324 | { |
---|
| 3325 | Int refIdxL0 = cMvFieldL0.getRefIdx(); |
---|
[815] | 3326 | TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_0, refIdxL0); |
---|
| 3327 | |
---|
[1483] | 3328 | if(refPic->isILR(m_pcPic->getLayerId())) |
---|
[713] | 3329 | { |
---|
| 3330 | checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0); |
---|
[815] | 3331 | |
---|
| 3332 | // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, |
---|
| 3333 | // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture |
---|
[1483] | 3334 | checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_pcPic->getLayerIdx(), refPic->getLayerIdx() ); |
---|
[713] | 3335 | } |
---|
| 3336 | } |
---|
| 3337 | if(uhInterDir&0x2) //list1 |
---|
| 3338 | { |
---|
| 3339 | Int refIdxL1 = cMvFieldL1.getRefIdx(); |
---|
[815] | 3340 | TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_1, refIdxL1); |
---|
| 3341 | |
---|
[1483] | 3342 | if(refPic->isILR(m_pcPic->getLayerId())) |
---|
[713] | 3343 | { |
---|
| 3344 | checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0); |
---|
[815] | 3345 | |
---|
| 3346 | // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, |
---|
| 3347 | // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture |
---|
[1483] | 3348 | checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_pcPic->getLayerIdx(), refPic->getLayerIdx() ); |
---|
[713] | 3349 | } |
---|
| 3350 | } |
---|
| 3351 | |
---|
| 3352 | return checkZeroMVILR; |
---|
| 3353 | } |
---|
| 3354 | |
---|
| 3355 | Bool TComDataCU::xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx) |
---|
| 3356 | { |
---|
| 3357 | RefPicList eRefPicList = iRefList > 0? REF_PIC_LIST_1: REF_PIC_LIST_0; |
---|
| 3358 | assert(eRefPicList == REF_PIC_LIST_1); |
---|
| 3359 | |
---|
| 3360 | Bool checkZeroMVILR = true; |
---|
| 3361 | |
---|
[1483] | 3362 | if(getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(m_pcPic->getLayerId())) |
---|
[713] | 3363 | { |
---|
| 3364 | AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
| 3365 | TComMv cMv = pcAMVPInfo->m_acMvCand[MvpIdx]; |
---|
| 3366 | checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0); |
---|
| 3367 | } |
---|
| 3368 | |
---|
| 3369 | return checkZeroMVILR; |
---|
| 3370 | } |
---|
| 3371 | #endif |
---|
| 3372 | |
---|
| 3373 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
[1465] | 3374 | Bool TComDataCU::isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1) const |
---|
[713] | 3375 | { |
---|
| 3376 | Bool checkILR = false; |
---|
| 3377 | |
---|
| 3378 | if(uhInterDir&0x1) //list0 |
---|
| 3379 | { |
---|
| 3380 | Int refIdxL0 = cMvFieldL0.getRefIdx(); |
---|
[1483] | 3381 | checkILR = getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_pcPic->getLayerId()); |
---|
[713] | 3382 | } |
---|
| 3383 | if(uhInterDir&0x2) //list1 |
---|
| 3384 | { |
---|
| 3385 | Int refIdxL1 = cMvFieldL1.getRefIdx(); |
---|
[1483] | 3386 | checkILR = checkILR || getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_pcPic->getLayerId()); |
---|
[713] | 3387 | } |
---|
| 3388 | |
---|
| 3389 | return checkILR; |
---|
| 3390 | } |
---|
| 3391 | #endif |
---|
| 3392 | |
---|
[595] | 3393 | #endif //SVC_EXTENSION |
---|
[208] | 3394 | //! \} |
---|