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