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