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