[125] | 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 | * |
---|
| 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
| 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" |
---|
| 40 | #include "TComPic.h" |
---|
| 41 | |
---|
| 42 | //! \ingroup TLibCommon |
---|
| 43 | //! \{ |
---|
| 44 | |
---|
| 45 | #if ADAPTIVE_QP_SELECTION |
---|
| 46 | Int * TComDataCU::m_pcGlbArlCoeffY = NULL; |
---|
| 47 | Int * TComDataCU::m_pcGlbArlCoeffCb = NULL; |
---|
| 48 | Int * TComDataCU::m_pcGlbArlCoeffCr = NULL; |
---|
| 49 | #endif |
---|
| 50 | |
---|
| 51 | // ==================================================================================================================== |
---|
| 52 | // Constructor / destructor / create / destroy |
---|
| 53 | // ==================================================================================================================== |
---|
| 54 | |
---|
| 55 | TComDataCU::TComDataCU() |
---|
| 56 | { |
---|
| 57 | m_pcPic = NULL; |
---|
| 58 | m_pcSlice = NULL; |
---|
| 59 | m_puhDepth = NULL; |
---|
| 60 | |
---|
| 61 | m_skipFlag = NULL; |
---|
| 62 | |
---|
| 63 | m_pePartSize = NULL; |
---|
| 64 | m_pePredMode = NULL; |
---|
| 65 | m_CUTransquantBypass = NULL; |
---|
| 66 | m_puhWidth = NULL; |
---|
| 67 | m_puhHeight = NULL; |
---|
| 68 | m_phQP = NULL; |
---|
| 69 | m_pbMergeFlag = NULL; |
---|
| 70 | m_puhMergeIndex = NULL; |
---|
| 71 | m_puhLumaIntraDir = NULL; |
---|
| 72 | m_puhChromaIntraDir = NULL; |
---|
| 73 | m_puhInterDir = NULL; |
---|
| 74 | m_puhTrIdx = NULL; |
---|
| 75 | m_puhTransformSkip[0] = NULL; |
---|
| 76 | m_puhTransformSkip[1] = NULL; |
---|
| 77 | m_puhTransformSkip[2] = NULL; |
---|
| 78 | m_puhCbf[0] = NULL; |
---|
| 79 | m_puhCbf[1] = NULL; |
---|
| 80 | m_puhCbf[2] = NULL; |
---|
| 81 | m_pcTrCoeffY = NULL; |
---|
| 82 | m_pcTrCoeffCb = NULL; |
---|
| 83 | m_pcTrCoeffCr = NULL; |
---|
| 84 | #if ADAPTIVE_QP_SELECTION |
---|
| 85 | m_ArlCoeffIsAliasedAllocation = false; |
---|
| 86 | m_pcArlCoeffY = NULL; |
---|
| 87 | m_pcArlCoeffCb = NULL; |
---|
| 88 | m_pcArlCoeffCr = NULL; |
---|
| 89 | #endif |
---|
| 90 | |
---|
| 91 | m_pbIPCMFlag = NULL; |
---|
| 92 | m_pcIPCMSampleY = NULL; |
---|
| 93 | m_pcIPCMSampleCb = NULL; |
---|
| 94 | m_pcIPCMSampleCr = NULL; |
---|
| 95 | |
---|
| 96 | m_pcPattern = NULL; |
---|
| 97 | |
---|
| 98 | m_pcCUAboveLeft = NULL; |
---|
| 99 | m_pcCUAboveRight = NULL; |
---|
| 100 | m_pcCUAbove = NULL; |
---|
| 101 | m_pcCULeft = NULL; |
---|
| 102 | |
---|
| 103 | m_apcCUColocated[0] = NULL; |
---|
| 104 | m_apcCUColocated[1] = NULL; |
---|
| 105 | |
---|
| 106 | m_apiMVPIdx[0] = NULL; |
---|
| 107 | m_apiMVPIdx[1] = NULL; |
---|
| 108 | m_apiMVPNum[0] = NULL; |
---|
| 109 | m_apiMVPNum[1] = NULL; |
---|
| 110 | |
---|
| 111 | m_bDecSubCu = false; |
---|
| 112 | m_sliceStartCU = 0; |
---|
| 113 | m_sliceSegmentStartCU = 0; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | TComDataCU::~TComDataCU() |
---|
| 117 | { |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | Void TComDataCU::create(UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
---|
| 121 | #if ADAPTIVE_QP_SELECTION |
---|
| 122 | , Bool bGlobalRMARLBuffer |
---|
| 123 | #endif |
---|
| 124 | ) |
---|
| 125 | { |
---|
| 126 | m_bDecSubCu = bDecSubCu; |
---|
| 127 | |
---|
| 128 | m_pcPic = NULL; |
---|
| 129 | m_pcSlice = NULL; |
---|
| 130 | m_uiNumPartition = uiNumPartition; |
---|
| 131 | m_unitSize = unitSize; |
---|
| 132 | |
---|
| 133 | if ( !bDecSubCu ) |
---|
| 134 | { |
---|
| 135 | m_phQP = (Char* )xMalloc(Char, uiNumPartition); |
---|
| 136 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 137 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 138 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 139 | |
---|
| 140 | m_skipFlag = new Bool[ uiNumPartition ]; |
---|
| 141 | |
---|
| 142 | m_pePartSize = new Char[ uiNumPartition ]; |
---|
| 143 | memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) ); |
---|
| 144 | m_pePredMode = new Char[ uiNumPartition ]; |
---|
| 145 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
---|
| 146 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
| 147 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 148 | m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 149 | m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 150 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 151 | |
---|
| 152 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 153 | m_puhTransformSkip[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 154 | m_puhTransformSkip[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 155 | m_puhTransformSkip[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 156 | |
---|
| 157 | m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 158 | m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 159 | m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
---|
| 160 | |
---|
| 161 | m_apiMVPIdx[0] = new Char[ uiNumPartition ]; |
---|
| 162 | m_apiMVPIdx[1] = new Char[ uiNumPartition ]; |
---|
| 163 | m_apiMVPNum[0] = new Char[ uiNumPartition ]; |
---|
| 164 | m_apiMVPNum[1] = new Char[ uiNumPartition ]; |
---|
| 165 | memset( m_apiMVPIdx[0], -1,uiNumPartition * sizeof( Char ) ); |
---|
| 166 | memset( m_apiMVPIdx[1], -1,uiNumPartition * sizeof( Char ) ); |
---|
| 167 | |
---|
| 168 | m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); |
---|
| 169 | m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
| 170 | m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
---|
| 171 | memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) ); |
---|
| 172 | memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
---|
| 173 | memset( m_pcTrCoeffCr, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
---|
| 174 | #if ADAPTIVE_QP_SELECTION |
---|
| 175 | if( bGlobalRMARLBuffer ) |
---|
| 176 | { |
---|
| 177 | if( m_pcGlbArlCoeffY == NULL ) |
---|
| 178 | { |
---|
| 179 | m_pcGlbArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
---|
| 180 | m_pcGlbArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
| 181 | m_pcGlbArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
| 182 | } |
---|
| 183 | m_pcArlCoeffY = m_pcGlbArlCoeffY; |
---|
| 184 | m_pcArlCoeffCb = m_pcGlbArlCoeffCb; |
---|
| 185 | m_pcArlCoeffCr = m_pcGlbArlCoeffCr; |
---|
| 186 | m_ArlCoeffIsAliasedAllocation = true; |
---|
| 187 | } |
---|
| 188 | else |
---|
| 189 | { |
---|
| 190 | m_pcArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
---|
| 191 | m_pcArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
| 192 | m_pcArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
---|
| 193 | } |
---|
| 194 | #endif |
---|
| 195 | |
---|
| 196 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
---|
| 197 | m_pcIPCMSampleY = (Pel* )xMalloc(Pel , uiWidth*uiHeight); |
---|
| 198 | m_pcIPCMSampleCb = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
---|
| 199 | m_pcIPCMSampleCr = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
---|
| 200 | |
---|
| 201 | m_acCUMvField[0].create( uiNumPartition ); |
---|
| 202 | m_acCUMvField[1].create( uiNumPartition ); |
---|
| 203 | |
---|
| 204 | } |
---|
| 205 | else |
---|
| 206 | { |
---|
| 207 | m_acCUMvField[0].setNumPartition(uiNumPartition ); |
---|
| 208 | m_acCUMvField[1].setNumPartition(uiNumPartition ); |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | m_sliceStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
| 212 | m_sliceSegmentStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
---|
| 213 | |
---|
| 214 | // create pattern memory |
---|
| 215 | m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); |
---|
| 216 | |
---|
| 217 | // create motion vector fields |
---|
| 218 | |
---|
| 219 | m_pcCUAboveLeft = NULL; |
---|
| 220 | m_pcCUAboveRight = NULL; |
---|
| 221 | m_pcCUAbove = NULL; |
---|
| 222 | m_pcCULeft = NULL; |
---|
| 223 | |
---|
| 224 | m_apcCUColocated[0] = NULL; |
---|
| 225 | m_apcCUColocated[1] = NULL; |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | Void TComDataCU::destroy() |
---|
| 229 | { |
---|
| 230 | m_pcPic = NULL; |
---|
| 231 | m_pcSlice = NULL; |
---|
| 232 | |
---|
| 233 | if ( m_pcPattern ) |
---|
| 234 | { |
---|
| 235 | xFree(m_pcPattern); |
---|
| 236 | m_pcPattern = NULL; |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | // encoder-side buffer free |
---|
| 240 | if ( !m_bDecSubCu ) |
---|
| 241 | { |
---|
| 242 | if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } |
---|
| 243 | if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } |
---|
| 244 | if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } |
---|
| 245 | if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } |
---|
| 246 | |
---|
| 247 | if ( m_skipFlag ) { delete[] m_skipFlag; m_skipFlag = NULL; } |
---|
| 248 | |
---|
| 249 | if ( m_pePartSize ) { delete[] m_pePartSize; m_pePartSize = NULL; } |
---|
| 250 | if ( m_pePredMode ) { delete[] m_pePredMode; m_pePredMode = NULL; } |
---|
| 251 | if ( m_CUTransquantBypass ) { delete[] m_CUTransquantBypass;m_CUTransquantBypass = NULL; } |
---|
| 252 | if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } |
---|
| 253 | if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } |
---|
| 254 | if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } |
---|
| 255 | if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } |
---|
| 256 | if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } |
---|
| 257 | if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } |
---|
| 258 | if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } |
---|
| 259 | if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } |
---|
| 260 | if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } |
---|
| 261 | if ( m_puhTransformSkip[0]) { xFree(m_puhTransformSkip[0]); m_puhTransformSkip[0] = NULL; } |
---|
| 262 | if ( m_puhTransformSkip[1]) { xFree(m_puhTransformSkip[1]); m_puhTransformSkip[1] = NULL; } |
---|
| 263 | if ( m_puhTransformSkip[2]) { xFree(m_puhTransformSkip[2]); m_puhTransformSkip[2] = NULL; } |
---|
| 264 | if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } |
---|
| 265 | if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } |
---|
| 266 | if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } |
---|
| 267 | #if ADAPTIVE_QP_SELECTION |
---|
| 268 | if (!m_ArlCoeffIsAliasedAllocation) |
---|
| 269 | { |
---|
| 270 | xFree(m_pcArlCoeffY); m_pcArlCoeffY = 0; |
---|
| 271 | xFree(m_pcArlCoeffCb); m_pcArlCoeffCb = 0; |
---|
| 272 | xFree(m_pcArlCoeffCr); m_pcArlCoeffCr = 0; |
---|
| 273 | } |
---|
| 274 | if ( m_pcGlbArlCoeffY ) { xFree(m_pcGlbArlCoeffY); m_pcGlbArlCoeffY = NULL; } |
---|
| 275 | if ( m_pcGlbArlCoeffCb ) { xFree(m_pcGlbArlCoeffCb); m_pcGlbArlCoeffCb = NULL; } |
---|
| 276 | if ( m_pcGlbArlCoeffCr ) { xFree(m_pcGlbArlCoeffCr); m_pcGlbArlCoeffCr = NULL; } |
---|
| 277 | #endif |
---|
| 278 | if ( m_pbIPCMFlag ) { xFree(m_pbIPCMFlag ); m_pbIPCMFlag = NULL; } |
---|
| 279 | if ( m_pcIPCMSampleY ) { xFree(m_pcIPCMSampleY); m_pcIPCMSampleY = NULL; } |
---|
| 280 | if ( m_pcIPCMSampleCb ) { xFree(m_pcIPCMSampleCb); m_pcIPCMSampleCb = NULL; } |
---|
| 281 | if ( m_pcIPCMSampleCr ) { xFree(m_pcIPCMSampleCr); m_pcIPCMSampleCr = NULL; } |
---|
| 282 | if ( m_apiMVPIdx[0] ) { delete[] m_apiMVPIdx[0]; m_apiMVPIdx[0] = NULL; } |
---|
| 283 | if ( m_apiMVPIdx[1] ) { delete[] m_apiMVPIdx[1]; m_apiMVPIdx[1] = NULL; } |
---|
| 284 | if ( m_apiMVPNum[0] ) { delete[] m_apiMVPNum[0]; m_apiMVPNum[0] = NULL; } |
---|
| 285 | if ( m_apiMVPNum[1] ) { delete[] m_apiMVPNum[1]; m_apiMVPNum[1] = NULL; } |
---|
| 286 | |
---|
| 287 | m_acCUMvField[0].destroy(); |
---|
| 288 | m_acCUMvField[1].destroy(); |
---|
| 289 | |
---|
| 290 | } |
---|
| 291 | |
---|
| 292 | m_pcCUAboveLeft = NULL; |
---|
| 293 | m_pcCUAboveRight = NULL; |
---|
| 294 | m_pcCUAbove = NULL; |
---|
| 295 | m_pcCULeft = NULL; |
---|
| 296 | |
---|
| 297 | m_apcCUColocated[0] = NULL; |
---|
| 298 | m_apcCUColocated[1] = NULL; |
---|
| 299 | |
---|
| 300 | if( m_sliceStartCU ) |
---|
| 301 | { |
---|
| 302 | xFree(m_sliceStartCU); |
---|
| 303 | m_sliceStartCU=NULL; |
---|
| 304 | } |
---|
| 305 | if(m_sliceSegmentStartCU ) |
---|
| 306 | { |
---|
| 307 | xFree(m_sliceSegmentStartCU); |
---|
| 308 | m_sliceSegmentStartCU=NULL; |
---|
| 309 | } |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | const NDBFBlockInfo& NDBFBlockInfo::operator= (const NDBFBlockInfo& src) |
---|
| 313 | { |
---|
| 314 | this->tileID = src.tileID; |
---|
| 315 | this->sliceID= src.sliceID; |
---|
| 316 | this->startSU= src.startSU; |
---|
| 317 | this->endSU = src.endSU; |
---|
| 318 | this->widthSU= src.widthSU; |
---|
| 319 | this->heightSU=src.heightSU; |
---|
| 320 | this->posX = src.posX; |
---|
| 321 | this->posY = src.posY; |
---|
| 322 | this->width = src.width; |
---|
| 323 | this->height = src.height; |
---|
| 324 | ::memcpy(this->isBorderAvailable, src.isBorderAvailable, sizeof(Bool)*((Int)NUM_SGU_BORDER)); |
---|
| 325 | this->allBordersAvailable = src.allBordersAvailable; |
---|
| 326 | |
---|
| 327 | return *this; |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | |
---|
| 331 | // ==================================================================================================================== |
---|
| 332 | // Public member functions |
---|
| 333 | // ==================================================================================================================== |
---|
| 334 | |
---|
| 335 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 336 | // Initialization |
---|
| 337 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 338 | |
---|
| 339 | /** |
---|
| 340 | - initialize top-level CU |
---|
| 341 | - internal buffers are already created |
---|
| 342 | - set values before encoding a CU |
---|
| 343 | . |
---|
| 344 | \param pcPic picture (TComPic) class pointer |
---|
| 345 | \param iCUAddr CU address |
---|
| 346 | */ |
---|
| 347 | Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr ) |
---|
| 348 | { |
---|
| 349 | |
---|
| 350 | m_pcPic = pcPic; |
---|
| 351 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
| 352 | m_uiCUAddr = iCUAddr; |
---|
| 353 | m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth; |
---|
| 354 | m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight; |
---|
| 355 | m_uiAbsIdxInLCU = 0; |
---|
| 356 | m_dTotalCost = MAX_DOUBLE; |
---|
| 357 | m_uiTotalDistortion = 0; |
---|
| 358 | m_uiTotalBits = 0; |
---|
| 359 | m_uiTotalBins = 0; |
---|
| 360 | m_uiNumPartition = pcPic->getNumPartInCU(); |
---|
| 361 | |
---|
| 362 | #if SVC_EXTENSION |
---|
| 363 | m_layerId = pcPic->getLayerId(); |
---|
| 364 | #endif |
---|
| 365 | |
---|
| 366 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
---|
| 367 | { |
---|
| 368 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceCurStartCUAddr()) |
---|
| 369 | { |
---|
| 370 | m_sliceStartCU[i]=getSlice()->getSliceCurStartCUAddr(); |
---|
| 371 | } |
---|
| 372 | else |
---|
| 373 | { |
---|
| 374 | m_sliceStartCU[i]=pcPic->getCU(getAddr())->m_sliceStartCU[i]; |
---|
| 375 | } |
---|
| 376 | } |
---|
| 377 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
---|
| 378 | { |
---|
| 379 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
| 380 | { |
---|
| 381 | m_sliceSegmentStartCU[i]=getSlice()->getSliceSegmentCurStartCUAddr(); |
---|
| 382 | } |
---|
| 383 | else |
---|
| 384 | { |
---|
| 385 | m_sliceSegmentStartCU[i]=pcPic->getCU(getAddr())->m_sliceSegmentStartCU[i]; |
---|
| 386 | } |
---|
| 387 | } |
---|
| 388 | |
---|
| 389 | Int partStartIdx = getSlice()->getSliceSegmentCurStartCUAddr() - pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr) * pcPic->getNumPartInCU(); |
---|
| 390 | |
---|
| 391 | Int numElements = min<Int>( partStartIdx, m_uiNumPartition ); |
---|
| 392 | for ( Int ui = 0; ui < numElements; ui++ ) |
---|
| 393 | { |
---|
| 394 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
---|
| 395 | m_skipFlag[ui] = pcFrom->getSkipFlag(ui); |
---|
| 396 | m_pePartSize[ui] = pcFrom->getPartitionSize(ui); |
---|
| 397 | m_pePredMode[ui] = pcFrom->getPredictionMode(ui); |
---|
| 398 | m_CUTransquantBypass[ui] = pcFrom->getCUTransquantBypass(ui); |
---|
| 399 | m_puhDepth[ui] = pcFrom->getDepth(ui); |
---|
| 400 | m_puhWidth [ui] = pcFrom->getWidth(ui); |
---|
| 401 | m_puhHeight [ui] = pcFrom->getHeight(ui); |
---|
| 402 | m_puhTrIdx [ui] = pcFrom->getTransformIdx(ui); |
---|
| 403 | m_puhTransformSkip[0][ui] = pcFrom->getTransformSkip(ui,TEXT_LUMA); |
---|
| 404 | m_puhTransformSkip[1][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_U); |
---|
| 405 | m_puhTransformSkip[2][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_V); |
---|
| 406 | m_apiMVPIdx[0][ui] = pcFrom->m_apiMVPIdx[0][ui];; |
---|
| 407 | m_apiMVPIdx[1][ui] = pcFrom->m_apiMVPIdx[1][ui]; |
---|
| 408 | m_apiMVPNum[0][ui] = pcFrom->m_apiMVPNum[0][ui]; |
---|
| 409 | m_apiMVPNum[1][ui] = pcFrom->m_apiMVPNum[1][ui]; |
---|
| 410 | m_phQP[ui]=pcFrom->m_phQP[ui]; |
---|
| 411 | m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui]; |
---|
| 412 | m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui]; |
---|
| 413 | m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui]; |
---|
| 414 | m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui]; |
---|
| 415 | m_puhInterDir[ui]=pcFrom->m_puhInterDir[ui]; |
---|
| 416 | m_puhCbf[0][ui]=pcFrom->m_puhCbf[0][ui]; |
---|
| 417 | m_puhCbf[1][ui]=pcFrom->m_puhCbf[1][ui]; |
---|
| 418 | m_puhCbf[2][ui]=pcFrom->m_puhCbf[2][ui]; |
---|
| 419 | m_pbIPCMFlag[ui] = pcFrom->m_pbIPCMFlag[ui]; |
---|
| 420 | } |
---|
| 421 | |
---|
| 422 | Int firstElement = max<Int>( partStartIdx, 0 ); |
---|
| 423 | numElements = m_uiNumPartition - firstElement; |
---|
| 424 | |
---|
| 425 | if ( numElements > 0 ) |
---|
| 426 | { |
---|
| 427 | memset( m_skipFlag + firstElement, false, numElements * sizeof( *m_skipFlag ) ); |
---|
| 428 | |
---|
| 429 | memset( m_pePartSize + firstElement, SIZE_NONE, numElements * sizeof( *m_pePartSize ) ); |
---|
| 430 | memset( m_pePredMode + firstElement, MODE_NONE, numElements * sizeof( *m_pePredMode ) ); |
---|
| 431 | memset( m_CUTransquantBypass+ firstElement, false, numElements * sizeof( *m_CUTransquantBypass) ); |
---|
| 432 | memset( m_puhDepth + firstElement, 0, numElements * sizeof( *m_puhDepth ) ); |
---|
| 433 | memset( m_puhTrIdx + firstElement, 0, numElements * sizeof( *m_puhTrIdx ) ); |
---|
| 434 | memset( m_puhTransformSkip[0] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[0]) ); |
---|
| 435 | memset( m_puhTransformSkip[1] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[1]) ); |
---|
| 436 | memset( m_puhTransformSkip[2] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[2]) ); |
---|
| 437 | memset( m_puhWidth + firstElement, g_uiMaxCUWidth, numElements * sizeof( *m_puhWidth ) ); |
---|
| 438 | memset( m_puhHeight + firstElement, g_uiMaxCUHeight, numElements * sizeof( *m_puhHeight ) ); |
---|
| 439 | memset( m_apiMVPIdx[0] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[0] ) ); |
---|
| 440 | memset( m_apiMVPIdx[1] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[1] ) ); |
---|
| 441 | memset( m_apiMVPNum[0] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[0] ) ); |
---|
| 442 | memset( m_apiMVPNum[1] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[1] ) ); |
---|
| 443 | memset( m_phQP + firstElement, getSlice()->getSliceQp(), numElements * sizeof( *m_phQP ) ); |
---|
| 444 | memset( m_pbMergeFlag + firstElement, false, numElements * sizeof( *m_pbMergeFlag ) ); |
---|
| 445 | memset( m_puhMergeIndex + firstElement, 0, numElements * sizeof( *m_puhMergeIndex ) ); |
---|
| 446 | memset( m_puhLumaIntraDir + firstElement, DC_IDX, numElements * sizeof( *m_puhLumaIntraDir ) ); |
---|
| 447 | memset( m_puhChromaIntraDir + firstElement, 0, numElements * sizeof( *m_puhChromaIntraDir ) ); |
---|
| 448 | memset( m_puhInterDir + firstElement, 0, numElements * sizeof( *m_puhInterDir ) ); |
---|
| 449 | memset( m_puhCbf[0] + firstElement, 0, numElements * sizeof( *m_puhCbf[0] ) ); |
---|
| 450 | memset( m_puhCbf[1] + firstElement, 0, numElements * sizeof( *m_puhCbf[1] ) ); |
---|
| 451 | memset( m_puhCbf[2] + firstElement, 0, numElements * sizeof( *m_puhCbf[2] ) ); |
---|
| 452 | memset( m_pbIPCMFlag + firstElement, false, numElements * sizeof( *m_pbIPCMFlag ) ); |
---|
| 453 | } |
---|
| 454 | |
---|
| 455 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight; |
---|
| 456 | if ( 0 >= partStartIdx ) |
---|
| 457 | { |
---|
| 458 | m_acCUMvField[0].clearMvField(); |
---|
| 459 | m_acCUMvField[1].clearMvField(); |
---|
| 460 | memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); |
---|
| 461 | #if ADAPTIVE_QP_SELECTION |
---|
| 462 | memset( m_pcArlCoeffY , 0, sizeof( Int ) * uiTmp ); |
---|
| 463 | #endif |
---|
| 464 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
---|
| 465 | uiTmp >>= 2; |
---|
| 466 | memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); |
---|
| 467 | memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); |
---|
| 468 | #if ADAPTIVE_QP_SELECTION |
---|
| 469 | memset( m_pcArlCoeffCb, 0, sizeof( Int ) * uiTmp ); |
---|
| 470 | memset( m_pcArlCoeffCr, 0, sizeof( Int ) * uiTmp ); |
---|
| 471 | #endif |
---|
| 472 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
---|
| 473 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
---|
| 474 | } |
---|
| 475 | else |
---|
| 476 | { |
---|
| 477 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
---|
| 478 | m_acCUMvField[0].copyFrom(&pcFrom->m_acCUMvField[0],m_uiNumPartition,0); |
---|
| 479 | m_acCUMvField[1].copyFrom(&pcFrom->m_acCUMvField[1],m_uiNumPartition,0); |
---|
| 480 | for(Int i=0; i<uiTmp; i++) |
---|
| 481 | { |
---|
| 482 | m_pcTrCoeffY[i]=pcFrom->m_pcTrCoeffY[i]; |
---|
| 483 | #if ADAPTIVE_QP_SELECTION |
---|
| 484 | m_pcArlCoeffY[i]=pcFrom->m_pcArlCoeffY[i]; |
---|
| 485 | #endif |
---|
| 486 | m_pcIPCMSampleY[i]=pcFrom->m_pcIPCMSampleY[i]; |
---|
| 487 | } |
---|
| 488 | for(Int i=0; i<(uiTmp>>2); i++) |
---|
| 489 | { |
---|
| 490 | m_pcTrCoeffCb[i]=pcFrom->m_pcTrCoeffCb[i]; |
---|
| 491 | m_pcTrCoeffCr[i]=pcFrom->m_pcTrCoeffCr[i]; |
---|
| 492 | #if ADAPTIVE_QP_SELECTION |
---|
| 493 | m_pcArlCoeffCb[i]=pcFrom->m_pcArlCoeffCb[i]; |
---|
| 494 | m_pcArlCoeffCr[i]=pcFrom->m_pcArlCoeffCr[i]; |
---|
| 495 | #endif |
---|
| 496 | m_pcIPCMSampleCb[i]=pcFrom->m_pcIPCMSampleCb[i]; |
---|
| 497 | m_pcIPCMSampleCr[i]=pcFrom->m_pcIPCMSampleCr[i]; |
---|
| 498 | } |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | // Setting neighbor CU |
---|
| 502 | m_pcCULeft = NULL; |
---|
| 503 | m_pcCUAbove = NULL; |
---|
| 504 | m_pcCUAboveLeft = NULL; |
---|
| 505 | m_pcCUAboveRight = NULL; |
---|
| 506 | |
---|
| 507 | m_apcCUColocated[0] = NULL; |
---|
| 508 | m_apcCUColocated[1] = NULL; |
---|
| 509 | |
---|
| 510 | UInt uiWidthInCU = pcPic->getFrameWidthInCU(); |
---|
| 511 | if ( m_uiCUAddr % uiWidthInCU ) |
---|
| 512 | { |
---|
| 513 | m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | if ( m_uiCUAddr / uiWidthInCU ) |
---|
| 517 | { |
---|
| 518 | m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); |
---|
| 519 | } |
---|
| 520 | |
---|
| 521 | if ( m_pcCULeft && m_pcCUAbove ) |
---|
| 522 | { |
---|
| 523 | m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); |
---|
| 524 | } |
---|
| 525 | |
---|
| 526 | if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) |
---|
| 527 | { |
---|
| 528 | m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); |
---|
| 529 | } |
---|
| 530 | |
---|
| 531 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
---|
| 532 | { |
---|
| 533 | m_apcCUColocated[0] = getSlice()->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); |
---|
| 534 | } |
---|
| 535 | |
---|
| 536 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
---|
| 537 | { |
---|
| 538 | m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); |
---|
| 539 | } |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | /** initialize prediction data with enabling sub-LCU-level delta QP |
---|
| 543 | *\param uiDepth depth of the current CU |
---|
| 544 | *\param qp qp for the current CU |
---|
| 545 | *- set CU width and CU height according to depth |
---|
| 546 | *- set qp value according to input qp |
---|
| 547 | *- set last-coded qp value according to input last-coded qp |
---|
| 548 | */ |
---|
| 549 | Void TComDataCU::initEstData( UInt uiDepth, Int qp ) |
---|
| 550 | { |
---|
| 551 | m_dTotalCost = MAX_DOUBLE; |
---|
| 552 | m_uiTotalDistortion = 0; |
---|
| 553 | m_uiTotalBits = 0; |
---|
| 554 | m_uiTotalBins = 0; |
---|
| 555 | |
---|
| 556 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
| 557 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
| 558 | |
---|
| 559 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
| 560 | { |
---|
| 561 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui >= getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
| 562 | { |
---|
| 563 | m_apiMVPIdx[0][ui] = -1; |
---|
| 564 | m_apiMVPIdx[1][ui] = -1; |
---|
| 565 | m_apiMVPNum[0][ui] = -1; |
---|
| 566 | m_apiMVPNum[1][ui] = -1; |
---|
| 567 | m_puhDepth [ui] = uiDepth; |
---|
| 568 | m_puhWidth [ui] = uhWidth; |
---|
| 569 | m_puhHeight [ui] = uhHeight; |
---|
| 570 | m_puhTrIdx [ui] = 0; |
---|
| 571 | m_puhTransformSkip[0][ui] = 0; |
---|
| 572 | m_puhTransformSkip[1][ui] = 0; |
---|
| 573 | m_puhTransformSkip[2][ui] = 0; |
---|
| 574 | m_skipFlag[ui] = false; |
---|
| 575 | m_pePartSize[ui] = SIZE_NONE; |
---|
| 576 | m_pePredMode[ui] = MODE_NONE; |
---|
| 577 | m_CUTransquantBypass[ui] = false; |
---|
| 578 | m_pbIPCMFlag[ui] = 0; |
---|
| 579 | m_phQP[ui] = qp; |
---|
| 580 | m_pbMergeFlag[ui] = 0; |
---|
| 581 | m_puhMergeIndex[ui] = 0; |
---|
| 582 | m_puhLumaIntraDir[ui] = DC_IDX; |
---|
| 583 | m_puhChromaIntraDir[ui] = 0; |
---|
| 584 | m_puhInterDir[ui] = 0; |
---|
| 585 | m_puhCbf[0][ui] = 0; |
---|
| 586 | m_puhCbf[1][ui] = 0; |
---|
| 587 | m_puhCbf[2][ui] = 0; |
---|
| 588 | } |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | UInt uiTmp = uhWidth*uhHeight; |
---|
| 592 | |
---|
| 593 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU >= getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
| 594 | { |
---|
| 595 | m_acCUMvField[0].clearMvField(); |
---|
| 596 | m_acCUMvField[1].clearMvField(); |
---|
| 597 | uiTmp = uhWidth*uhHeight; |
---|
| 598 | |
---|
| 599 | memset( m_pcTrCoeffY, 0, uiTmp * sizeof( *m_pcTrCoeffY ) ); |
---|
| 600 | #if ADAPTIVE_QP_SELECTION |
---|
| 601 | memset( m_pcArlCoeffY , 0, uiTmp * sizeof( *m_pcArlCoeffY ) ); |
---|
| 602 | #endif |
---|
| 603 | memset( m_pcIPCMSampleY, 0, uiTmp * sizeof( *m_pcIPCMSampleY ) ); |
---|
| 604 | |
---|
| 605 | uiTmp>>=2; |
---|
| 606 | memset( m_pcTrCoeffCb, 0, uiTmp * sizeof( *m_pcTrCoeffCb ) ); |
---|
| 607 | memset( m_pcTrCoeffCr, 0, uiTmp * sizeof( *m_pcTrCoeffCr ) ); |
---|
| 608 | #if ADAPTIVE_QP_SELECTION |
---|
| 609 | memset( m_pcArlCoeffCb, 0, uiTmp * sizeof( *m_pcArlCoeffCb ) ); |
---|
| 610 | memset( m_pcArlCoeffCr, 0, uiTmp * sizeof( *m_pcArlCoeffCr ) ); |
---|
| 611 | #endif |
---|
| 612 | memset( m_pcIPCMSampleCb, 0, uiTmp * sizeof( *m_pcIPCMSampleCb ) ); |
---|
| 613 | memset( m_pcIPCMSampleCr, 0, uiTmp * sizeof( *m_pcIPCMSampleCr ) ); |
---|
| 614 | } |
---|
| 615 | } |
---|
| 616 | |
---|
| 617 | |
---|
| 618 | // initialize Sub partition |
---|
| 619 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
---|
| 620 | { |
---|
| 621 | assert( uiPartUnitIdx<4 ); |
---|
| 622 | |
---|
| 623 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
---|
| 624 | |
---|
| 625 | m_pcPic = pcCU->getPic(); |
---|
| 626 | m_pcSlice = m_pcPic->getSlice(m_pcPic->getCurrSliceIdx()); |
---|
| 627 | m_uiCUAddr = pcCU->getAddr(); |
---|
| 628 | m_uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset; |
---|
| 629 | |
---|
| 630 | m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth>>uiDepth )*( uiPartUnitIdx & 1 ); |
---|
| 631 | m_uiCUPelY = pcCU->getCUPelY() + ( g_uiMaxCUHeight>>uiDepth )*( uiPartUnitIdx >> 1 ); |
---|
| 632 | |
---|
| 633 | m_dTotalCost = MAX_DOUBLE; |
---|
| 634 | m_uiTotalDistortion = 0; |
---|
| 635 | m_uiTotalBits = 0; |
---|
| 636 | m_uiTotalBins = 0; |
---|
| 637 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
---|
| 638 | |
---|
| 639 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
| 640 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
| 641 | |
---|
| 642 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
| 643 | memset( m_phQP, qp, sizeInChar ); |
---|
| 644 | |
---|
| 645 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
---|
| 646 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
---|
| 647 | memset( m_puhLumaIntraDir, DC_IDX, iSizeInUchar ); |
---|
| 648 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
---|
| 649 | memset( m_puhInterDir, 0, iSizeInUchar ); |
---|
| 650 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
---|
| 651 | memset( m_puhTransformSkip[0], 0, iSizeInUchar ); |
---|
| 652 | memset( m_puhTransformSkip[1], 0, iSizeInUchar ); |
---|
| 653 | memset( m_puhTransformSkip[2], 0, iSizeInUchar ); |
---|
| 654 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
---|
| 655 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
---|
| 656 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
---|
| 657 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
---|
| 658 | |
---|
| 659 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
| 660 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
| 661 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
---|
| 662 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
---|
| 663 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
---|
| 664 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
---|
| 665 | { |
---|
| 666 | m_skipFlag[ui] = false; |
---|
| 667 | m_pePartSize[ui] = SIZE_NONE; |
---|
| 668 | m_pePredMode[ui] = MODE_NONE; |
---|
| 669 | m_CUTransquantBypass[ui] = false; |
---|
| 670 | m_apiMVPIdx[0][ui] = -1; |
---|
| 671 | m_apiMVPIdx[1][ui] = -1; |
---|
| 672 | m_apiMVPNum[0][ui] = -1; |
---|
| 673 | m_apiMVPNum[1][ui] = -1; |
---|
| 674 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui<getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
| 675 | { |
---|
| 676 | m_apiMVPIdx[0][ui] = pcCU->m_apiMVPIdx[0][uiPartOffset+ui]; |
---|
| 677 | m_apiMVPIdx[1][ui] = pcCU->m_apiMVPIdx[1][uiPartOffset+ui];; |
---|
| 678 | m_apiMVPNum[0][ui] = pcCU->m_apiMVPNum[0][uiPartOffset+ui];; |
---|
| 679 | m_apiMVPNum[1][ui] = pcCU->m_apiMVPNum[1][uiPartOffset+ui];; |
---|
| 680 | m_puhDepth [ui] = pcCU->getDepth(uiPartOffset+ui); |
---|
| 681 | m_puhWidth [ui] = pcCU->getWidth(uiPartOffset+ui); |
---|
| 682 | m_puhHeight [ui] = pcCU->getHeight(uiPartOffset+ui); |
---|
| 683 | m_puhTrIdx [ui] = pcCU->getTransformIdx(uiPartOffset+ui); |
---|
| 684 | m_puhTransformSkip[0][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_LUMA); |
---|
| 685 | m_puhTransformSkip[1][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_U); |
---|
| 686 | m_puhTransformSkip[2][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_V); |
---|
| 687 | m_skipFlag[ui] = pcCU->getSkipFlag(uiPartOffset+ui); |
---|
| 688 | m_pePartSize[ui] = pcCU->getPartitionSize(uiPartOffset+ui); |
---|
| 689 | m_pePredMode[ui] = pcCU->getPredictionMode(uiPartOffset+ui); |
---|
| 690 | m_CUTransquantBypass[ui] = pcCU->getCUTransquantBypass(uiPartOffset+ui); |
---|
| 691 | m_pbIPCMFlag[ui]=pcCU->m_pbIPCMFlag[uiPartOffset+ui]; |
---|
| 692 | m_phQP[ui] = pcCU->m_phQP[uiPartOffset+ui]; |
---|
| 693 | m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui]; |
---|
| 694 | m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui]; |
---|
| 695 | m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui]; |
---|
| 696 | m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui]; |
---|
| 697 | m_puhInterDir[ui]=pcCU->m_puhInterDir[uiPartOffset+ui]; |
---|
| 698 | m_puhCbf[0][ui]=pcCU->m_puhCbf[0][uiPartOffset+ui]; |
---|
| 699 | m_puhCbf[1][ui]=pcCU->m_puhCbf[1][uiPartOffset+ui]; |
---|
| 700 | m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui]; |
---|
| 701 | |
---|
| 702 | } |
---|
| 703 | } |
---|
| 704 | UInt uiTmp = uhWidth*uhHeight; |
---|
| 705 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
---|
| 706 | #if ADAPTIVE_QP_SELECTION |
---|
| 707 | memset( m_pcArlCoeffY , 0, sizeof(Int)*uiTmp ); |
---|
| 708 | #endif |
---|
| 709 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
---|
| 710 | uiTmp >>= 2; |
---|
| 711 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
---|
| 712 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
---|
| 713 | #if ADAPTIVE_QP_SELECTION |
---|
| 714 | memset( m_pcArlCoeffCb, 0, sizeof(Int)*uiTmp ); |
---|
| 715 | memset( m_pcArlCoeffCr, 0, sizeof(Int)*uiTmp ); |
---|
| 716 | #endif |
---|
| 717 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
---|
| 718 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
---|
| 719 | m_acCUMvField[0].clearMvField(); |
---|
| 720 | m_acCUMvField[1].clearMvField(); |
---|
| 721 | |
---|
| 722 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU<getSlice()->getSliceSegmentCurStartCUAddr()) |
---|
| 723 | { |
---|
| 724 | // Part of this CU contains data from an older slice. Now copy in that data. |
---|
| 725 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
| 726 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
| 727 | TComDataCU * bigCU = getPic()->getCU(getAddr()); |
---|
| 728 | Int minui = uiPartOffset; |
---|
| 729 | minui = -minui; |
---|
| 730 | pcCU->m_acCUMvField[0].copyTo(&m_acCUMvField[0],minui,uiPartOffset,m_uiNumPartition); |
---|
| 731 | pcCU->m_acCUMvField[1].copyTo(&m_acCUMvField[1],minui,uiPartOffset,m_uiNumPartition); |
---|
| 732 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*m_uiAbsIdxInLCU/pcCU->getPic()->getNumPartInCU(); |
---|
| 733 | uiTmp = uhWidth*uhHeight; |
---|
| 734 | for(Int i=0; i<uiTmp; i++) |
---|
| 735 | { |
---|
| 736 | m_pcTrCoeffY[i]=bigCU->m_pcTrCoeffY[uiCoffOffset+i]; |
---|
| 737 | #if ADAPTIVE_QP_SELECTION |
---|
| 738 | m_pcArlCoeffY[i]=bigCU->m_pcArlCoeffY[uiCoffOffset+i]; |
---|
| 739 | #endif |
---|
| 740 | m_pcIPCMSampleY[i]=bigCU->m_pcIPCMSampleY[uiCoffOffset+i]; |
---|
| 741 | } |
---|
| 742 | uiTmp>>=2; |
---|
| 743 | uiCoffOffset>>=2; |
---|
| 744 | for(Int i=0; i<uiTmp; i++) |
---|
| 745 | { |
---|
| 746 | m_pcTrCoeffCr[i]=bigCU->m_pcTrCoeffCr[uiCoffOffset+i]; |
---|
| 747 | m_pcTrCoeffCb[i]=bigCU->m_pcTrCoeffCb[uiCoffOffset+i]; |
---|
| 748 | #if ADAPTIVE_QP_SELECTION |
---|
| 749 | m_pcArlCoeffCr[i]=bigCU->m_pcArlCoeffCr[uiCoffOffset+i]; |
---|
| 750 | m_pcArlCoeffCb[i]=bigCU->m_pcArlCoeffCb[uiCoffOffset+i]; |
---|
| 751 | #endif |
---|
| 752 | m_pcIPCMSampleCb[i]=bigCU->m_pcIPCMSampleCb[uiCoffOffset+i]; |
---|
| 753 | m_pcIPCMSampleCr[i]=bigCU->m_pcIPCMSampleCr[uiCoffOffset+i]; |
---|
| 754 | } |
---|
| 755 | } |
---|
| 756 | |
---|
| 757 | m_pcCULeft = pcCU->getCULeft(); |
---|
| 758 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
| 759 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
| 760 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
| 761 | |
---|
| 762 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
| 763 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
| 764 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
---|
| 765 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
---|
| 766 | } |
---|
| 767 | |
---|
| 768 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 769 | { |
---|
| 770 | UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
---|
| 771 | UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
| 772 | |
---|
| 773 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
---|
| 774 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
---|
| 775 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
---|
| 776 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
---|
| 777 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
---|
| 778 | } |
---|
| 779 | |
---|
| 780 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 781 | // Copy |
---|
| 782 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 783 | |
---|
| 784 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 785 | { |
---|
| 786 | UInt uiPart = uiAbsPartIdx; |
---|
| 787 | |
---|
| 788 | m_pcPic = pcCU->getPic(); |
---|
| 789 | m_pcSlice = pcCU->getSlice(); |
---|
| 790 | m_uiCUAddr = pcCU->getAddr(); |
---|
| 791 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
| 792 | |
---|
| 793 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 794 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 795 | |
---|
| 796 | UInt uiWidth = g_uiMaxCUWidth >> uiDepth; |
---|
| 797 | UInt uiHeight = g_uiMaxCUHeight >> uiDepth; |
---|
| 798 | |
---|
| 799 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
---|
| 800 | |
---|
| 801 | m_phQP=pcCU->getQP() + uiPart; |
---|
| 802 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
---|
| 803 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
---|
| 804 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
---|
| 805 | |
---|
| 806 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
---|
| 807 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
---|
| 808 | |
---|
| 809 | m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; |
---|
| 810 | m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; |
---|
| 811 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
---|
| 812 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
---|
| 813 | m_puhTransformSkip[0] = pcCU->getTransformSkip(TEXT_LUMA) + uiPart; |
---|
| 814 | m_puhTransformSkip[1] = pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPart; |
---|
| 815 | m_puhTransformSkip[2] = pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPart; |
---|
| 816 | |
---|
| 817 | m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; |
---|
| 818 | m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; |
---|
| 819 | m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; |
---|
| 820 | |
---|
| 821 | m_puhDepth=pcCU->getDepth() + uiPart; |
---|
| 822 | m_puhWidth=pcCU->getWidth() + uiPart; |
---|
| 823 | m_puhHeight=pcCU->getHeight() + uiPart; |
---|
| 824 | |
---|
| 825 | m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; |
---|
| 826 | m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; |
---|
| 827 | m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; |
---|
| 828 | m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; |
---|
| 829 | |
---|
| 830 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
---|
| 831 | |
---|
| 832 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
| 833 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
| 834 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
| 835 | m_pcCULeft = pcCU->getCULeft(); |
---|
| 836 | |
---|
| 837 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
| 838 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
| 839 | |
---|
| 840 | UInt uiTmp = uiWidth*uiHeight; |
---|
| 841 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
| 842 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
| 843 | |
---|
| 844 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); |
---|
| 845 | |
---|
| 846 | m_pcTrCoeffY = pcCU->getCoeffY() + uiCoffOffset; |
---|
| 847 | #if ADAPTIVE_QP_SELECTION |
---|
| 848 | m_pcArlCoeffY= pcCU->getArlCoeffY() + uiCoffOffset; |
---|
| 849 | #endif |
---|
| 850 | m_pcIPCMSampleY = pcCU->getPCMSampleY() + uiCoffOffset; |
---|
| 851 | |
---|
| 852 | uiTmp >>= 2; |
---|
| 853 | uiCoffOffset >>=2; |
---|
| 854 | m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; |
---|
| 855 | m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; |
---|
| 856 | #if ADAPTIVE_QP_SELECTION |
---|
| 857 | m_pcArlCoeffCb=pcCU->getArlCoeffCb() + uiCoffOffset; |
---|
| 858 | m_pcArlCoeffCr=pcCU->getArlCoeffCr() + uiCoffOffset; |
---|
| 859 | #endif |
---|
| 860 | m_pcIPCMSampleCb = pcCU->getPCMSampleCb() + uiCoffOffset; |
---|
| 861 | m_pcIPCMSampleCr = pcCU->getPCMSampleCr() + uiCoffOffset; |
---|
| 862 | |
---|
| 863 | m_acCUMvField[0].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_0), uiPart ); |
---|
| 864 | m_acCUMvField[1].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_1), uiPart ); |
---|
| 865 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
---|
| 866 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
---|
| 867 | } |
---|
| 868 | |
---|
| 869 | // Copy inter prediction info from the biggest CU |
---|
| 870 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList ) |
---|
| 871 | { |
---|
| 872 | m_pcPic = pcCU->getPic(); |
---|
| 873 | m_pcSlice = pcCU->getSlice(); |
---|
| 874 | m_uiCUAddr = pcCU->getAddr(); |
---|
| 875 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
---|
| 876 | |
---|
| 877 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
---|
| 878 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); |
---|
| 879 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); |
---|
| 880 | |
---|
| 881 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
| 882 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
| 883 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
| 884 | m_pcCULeft = pcCU->getCULeft(); |
---|
| 885 | |
---|
| 886 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
| 887 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
| 888 | |
---|
| 889 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
---|
| 890 | |
---|
| 891 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
---|
| 892 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
---|
| 893 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
---|
| 894 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
---|
| 895 | |
---|
| 896 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
---|
| 897 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
---|
| 898 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
---|
| 899 | |
---|
| 900 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
---|
| 901 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
---|
| 902 | |
---|
| 903 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
---|
| 904 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
---|
| 905 | |
---|
| 906 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
---|
| 907 | |
---|
| 908 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
---|
| 909 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
---|
| 910 | } |
---|
| 911 | |
---|
| 912 | // Copy small CU to bigger CU. |
---|
| 913 | // One of quarter parts overwritten by predicted sub part. |
---|
| 914 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
---|
| 915 | { |
---|
| 916 | assert( uiPartUnitIdx<4 ); |
---|
| 917 | |
---|
| 918 | m_dTotalCost += pcCU->getTotalCost(); |
---|
| 919 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
---|
| 920 | m_uiTotalBits += pcCU->getTotalBits(); |
---|
| 921 | |
---|
| 922 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
---|
| 923 | |
---|
| 924 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
---|
| 925 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
---|
| 926 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
---|
| 927 | |
---|
| 928 | Int sizeInChar = sizeof( Char ) * uiNumPartition; |
---|
| 929 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
---|
| 930 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
---|
| 931 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
---|
| 932 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
---|
| 933 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
---|
| 934 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
---|
| 935 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
---|
| 936 | memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); |
---|
| 937 | memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); |
---|
| 938 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
---|
| 939 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
---|
| 940 | memcpy( m_puhTransformSkip[0] + uiOffset, pcCU->getTransformSkip(TEXT_LUMA), iSizeInUchar ); |
---|
| 941 | memcpy( m_puhTransformSkip[1] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_U), iSizeInUchar ); |
---|
| 942 | memcpy( m_puhTransformSkip[2] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_V), iSizeInUchar ); |
---|
| 943 | |
---|
| 944 | memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); |
---|
| 945 | memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); |
---|
| 946 | memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); |
---|
| 947 | |
---|
| 948 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
---|
| 949 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
---|
| 950 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
---|
| 951 | |
---|
| 952 | memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInUchar ); |
---|
| 953 | memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInUchar ); |
---|
| 954 | memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInUchar ); |
---|
| 955 | memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInUchar ); |
---|
| 956 | |
---|
| 957 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
---|
| 958 | |
---|
| 959 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
---|
| 960 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
---|
| 961 | m_pcCUAbove = pcCU->getCUAbove(); |
---|
| 962 | m_pcCULeft = pcCU->getCULeft(); |
---|
| 963 | |
---|
| 964 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
---|
| 965 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
---|
| 966 | |
---|
| 967 | m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
| 968 | m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); |
---|
| 969 | |
---|
| 970 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); |
---|
| 971 | UInt uiTmp2 = uiPartUnitIdx*uiTmp; |
---|
| 972 | memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); |
---|
| 973 | #if ADAPTIVE_QP_SELECTION |
---|
| 974 | memcpy( m_pcArlCoeffY + uiTmp2, pcCU->getArlCoeffY(), sizeof(Int)*uiTmp ); |
---|
| 975 | #endif |
---|
| 976 | memcpy( m_pcIPCMSampleY + uiTmp2 , pcCU->getPCMSampleY(), sizeof(Pel) * uiTmp ); |
---|
| 977 | |
---|
| 978 | uiTmp >>= 2; uiTmp2>>= 2; |
---|
| 979 | memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); |
---|
| 980 | memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); |
---|
| 981 | #if ADAPTIVE_QP_SELECTION |
---|
| 982 | memcpy( m_pcArlCoeffCb + uiTmp2, pcCU->getArlCoeffCb(), sizeof(Int)*uiTmp ); |
---|
| 983 | memcpy( m_pcArlCoeffCr + uiTmp2, pcCU->getArlCoeffCr(), sizeof(Int)*uiTmp ); |
---|
| 984 | #endif |
---|
| 985 | memcpy( m_pcIPCMSampleCb + uiTmp2 , pcCU->getPCMSampleCb(), sizeof(Pel) * uiTmp ); |
---|
| 986 | memcpy( m_pcIPCMSampleCr + uiTmp2 , pcCU->getPCMSampleCr(), sizeof(Pel) * uiTmp ); |
---|
| 987 | m_uiTotalBins += pcCU->getTotalBins(); |
---|
| 988 | memcpy( m_sliceStartCU + uiOffset, pcCU->m_sliceStartCU, sizeof( UInt ) * uiNumPartition ); |
---|
| 989 | memcpy( m_sliceSegmentStartCU + uiOffset, pcCU->m_sliceSegmentStartCU, sizeof( UInt ) * uiNumPartition ); |
---|
| 990 | } |
---|
| 991 | |
---|
| 992 | // Copy current predicted part to a CU in picture. |
---|
| 993 | // It is used to predict for next part |
---|
| 994 | Void TComDataCU::copyToPic( UChar uhDepth ) |
---|
| 995 | { |
---|
| 996 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
| 997 | |
---|
| 998 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
| 999 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
| 1000 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
| 1001 | |
---|
| 1002 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
---|
| 1003 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
---|
| 1004 | |
---|
| 1005 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
---|
| 1006 | |
---|
| 1007 | memcpy( rpcCU->getSkipFlag() + m_uiAbsIdxInLCU, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
---|
| 1008 | |
---|
| 1009 | memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar ); |
---|
| 1010 | |
---|
| 1011 | memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
---|
| 1012 | memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
---|
| 1013 | memcpy( rpcCU->getCUTransquantBypass()+ m_uiAbsIdxInLCU, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
---|
| 1014 | memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); |
---|
| 1015 | memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); |
---|
| 1016 | memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); |
---|
| 1017 | memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); |
---|
| 1018 | memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); |
---|
| 1019 | memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); |
---|
| 1020 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhTransformSkip[0], iSizeInUchar ); |
---|
| 1021 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhTransformSkip[1], iSizeInUchar ); |
---|
| 1022 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhTransformSkip[2], iSizeInUchar ); |
---|
| 1023 | |
---|
| 1024 | memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); |
---|
| 1025 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); |
---|
| 1026 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); |
---|
| 1027 | |
---|
| 1028 | memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); |
---|
| 1029 | memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); |
---|
| 1030 | memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); |
---|
| 1031 | |
---|
| 1032 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInUchar ); |
---|
| 1033 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInUchar ); |
---|
| 1034 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInUchar ); |
---|
| 1035 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInUchar ); |
---|
| 1036 | |
---|
| 1037 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); |
---|
| 1038 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); |
---|
| 1039 | |
---|
| 1040 | memcpy( rpcCU->getIPCMFlag() + m_uiAbsIdxInLCU, m_pbIPCMFlag, iSizeInBool ); |
---|
| 1041 | |
---|
| 1042 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); |
---|
| 1043 | UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
| 1044 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
| 1045 | #if ADAPTIVE_QP_SELECTION |
---|
| 1046 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
---|
| 1047 | #endif |
---|
| 1048 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof(Pel)*uiTmp ); |
---|
| 1049 | |
---|
| 1050 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
| 1051 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
| 1052 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
| 1053 | #if ADAPTIVE_QP_SELECTION |
---|
| 1054 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
---|
| 1055 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
---|
| 1056 | #endif |
---|
| 1057 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
---|
| 1058 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
---|
| 1059 | rpcCU->getTotalBins() = m_uiTotalBins; |
---|
| 1060 | memcpy( rpcCU->m_sliceStartCU + m_uiAbsIdxInLCU, m_sliceStartCU, sizeof( UInt ) * m_uiNumPartition ); |
---|
| 1061 | memcpy( rpcCU->m_sliceSegmentStartCU + m_uiAbsIdxInLCU, m_sliceSegmentStartCU, sizeof( UInt ) * m_uiNumPartition ); |
---|
| 1062 | } |
---|
| 1063 | |
---|
| 1064 | Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) |
---|
| 1065 | { |
---|
| 1066 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
---|
| 1067 | UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); |
---|
| 1068 | |
---|
| 1069 | UInt uiPartStart = uiPartIdx*uiQNumPart; |
---|
| 1070 | UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; |
---|
| 1071 | |
---|
| 1072 | rpcCU->getTotalCost() = m_dTotalCost; |
---|
| 1073 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
---|
| 1074 | rpcCU->getTotalBits() = m_uiTotalBits; |
---|
| 1075 | |
---|
| 1076 | Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; |
---|
| 1077 | Int iSizeInBool = sizeof( Bool ) * uiQNumPart; |
---|
| 1078 | |
---|
| 1079 | Int sizeInChar = sizeof( Char ) * uiQNumPart; |
---|
| 1080 | memcpy( rpcCU->getSkipFlag() + uiPartOffset, m_skipFlag, sizeof( *m_skipFlag ) * uiQNumPart ); |
---|
| 1081 | |
---|
| 1082 | memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, sizeInChar ); |
---|
| 1083 | memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart ); |
---|
| 1084 | memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( *m_pePredMode ) * uiQNumPart ); |
---|
| 1085 | memcpy( rpcCU->getCUTransquantBypass()+ uiPartOffset, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * uiQNumPart ); |
---|
| 1086 | memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); |
---|
| 1087 | memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); |
---|
| 1088 | memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); |
---|
| 1089 | memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); |
---|
| 1090 | memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); |
---|
| 1091 | memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); |
---|
| 1092 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + uiPartOffset, m_puhTransformSkip[0], iSizeInUchar ); |
---|
| 1093 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhTransformSkip[1], iSizeInUchar ); |
---|
| 1094 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhTransformSkip[2], iSizeInUchar ); |
---|
| 1095 | memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); |
---|
| 1096 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); |
---|
| 1097 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); |
---|
| 1098 | |
---|
| 1099 | memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); |
---|
| 1100 | memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); |
---|
| 1101 | memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); |
---|
| 1102 | |
---|
| 1103 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInUchar ); |
---|
| 1104 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInUchar ); |
---|
| 1105 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInUchar ); |
---|
| 1106 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInUchar ); |
---|
| 1107 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
| 1108 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
---|
| 1109 | |
---|
| 1110 | memcpy( rpcCU->getIPCMFlag() + uiPartOffset, m_pbIPCMFlag, iSizeInBool ); |
---|
| 1111 | |
---|
| 1112 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); |
---|
| 1113 | UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
---|
| 1114 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
---|
| 1115 | #if ADAPTIVE_QP_SELECTION |
---|
| 1116 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
---|
| 1117 | #endif |
---|
| 1118 | |
---|
| 1119 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof( Pel ) * uiTmp ); |
---|
| 1120 | |
---|
| 1121 | uiTmp >>= 2; uiTmp2 >>= 2; |
---|
| 1122 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
---|
| 1123 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
---|
| 1124 | #if ADAPTIVE_QP_SELECTION |
---|
| 1125 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
---|
| 1126 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
---|
| 1127 | #endif |
---|
| 1128 | |
---|
| 1129 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
---|
| 1130 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
---|
| 1131 | rpcCU->getTotalBins() = m_uiTotalBins; |
---|
| 1132 | memcpy( rpcCU->m_sliceStartCU + uiPartOffset, m_sliceStartCU, sizeof( UInt ) * uiQNumPart ); |
---|
| 1133 | memcpy( rpcCU->m_sliceSegmentStartCU + uiPartOffset, m_sliceSegmentStartCU, sizeof( UInt ) * uiQNumPart ); |
---|
| 1134 | } |
---|
| 1135 | |
---|
| 1136 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 1137 | // Other public functions |
---|
| 1138 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 1139 | |
---|
| 1140 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
---|
| 1141 | UInt uiCurrPartUnitIdx, |
---|
| 1142 | Bool bEnforceSliceRestriction, |
---|
| 1143 | Bool bEnforceTileRestriction ) |
---|
| 1144 | { |
---|
| 1145 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
| 1146 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
| 1147 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 1148 | |
---|
| 1149 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
| 1150 | { |
---|
| 1151 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
| 1152 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
| 1153 | { |
---|
| 1154 | return m_pcPic->getCU( getAddr() ); |
---|
| 1155 | } |
---|
| 1156 | else |
---|
| 1157 | { |
---|
| 1158 | uiLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
| 1159 | return this; |
---|
| 1160 | } |
---|
| 1161 | } |
---|
| 1162 | |
---|
| 1163 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; |
---|
| 1164 | |
---|
| 1165 | |
---|
| 1166 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
| 1167 | || |
---|
| 1168 | (bEnforceTileRestriction && ( m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) ) ) |
---|
| 1169 | ) |
---|
| 1170 | { |
---|
| 1171 | return NULL; |
---|
| 1172 | } |
---|
| 1173 | return m_pcCULeft; |
---|
| 1174 | } |
---|
| 1175 | |
---|
| 1176 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
---|
| 1177 | UInt uiCurrPartUnitIdx, |
---|
| 1178 | Bool bEnforceSliceRestriction, |
---|
| 1179 | Bool planarAtLCUBoundary , |
---|
| 1180 | Bool bEnforceTileRestriction ) |
---|
| 1181 | { |
---|
| 1182 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
| 1183 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
| 1184 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 1185 | |
---|
| 1186 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
| 1187 | { |
---|
| 1188 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ]; |
---|
| 1189 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
| 1190 | { |
---|
| 1191 | return m_pcPic->getCU( getAddr() ); |
---|
| 1192 | } |
---|
| 1193 | else |
---|
| 1194 | { |
---|
| 1195 | uiAPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
| 1196 | return this; |
---|
| 1197 | } |
---|
| 1198 | } |
---|
| 1199 | |
---|
| 1200 | if(planarAtLCUBoundary) |
---|
| 1201 | { |
---|
| 1202 | return NULL; |
---|
| 1203 | } |
---|
| 1204 | |
---|
| 1205 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
| 1206 | |
---|
| 1207 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
---|
| 1208 | || |
---|
| 1209 | (bEnforceTileRestriction &&(m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())))) |
---|
| 1210 | ) |
---|
| 1211 | { |
---|
| 1212 | return NULL; |
---|
| 1213 | } |
---|
| 1214 | return m_pcCUAbove; |
---|
| 1215 | } |
---|
| 1216 | |
---|
| 1217 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
| 1218 | { |
---|
| 1219 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
| 1220 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
---|
| 1221 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 1222 | |
---|
| 1223 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
| 1224 | { |
---|
| 1225 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
| 1226 | { |
---|
| 1227 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ]; |
---|
| 1228 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
| 1229 | { |
---|
| 1230 | return m_pcPic->getCU( getAddr() ); |
---|
| 1231 | } |
---|
| 1232 | else |
---|
| 1233 | { |
---|
| 1234 | uiALPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
| 1235 | return this; |
---|
| 1236 | } |
---|
| 1237 | } |
---|
| 1238 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; |
---|
| 1239 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
| 1240 | m_pcCUAbove->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
| 1241 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
| 1242 | )) |
---|
| 1243 | ) |
---|
| 1244 | { |
---|
| 1245 | return NULL; |
---|
| 1246 | } |
---|
| 1247 | return m_pcCUAbove; |
---|
| 1248 | } |
---|
| 1249 | |
---|
| 1250 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
---|
| 1251 | { |
---|
| 1252 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
---|
| 1253 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
| 1254 | m_pcCULeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
| 1255 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
| 1256 | )) |
---|
| 1257 | ) |
---|
| 1258 | { |
---|
| 1259 | return NULL; |
---|
| 1260 | } |
---|
| 1261 | return m_pcCULeft; |
---|
| 1262 | } |
---|
| 1263 | |
---|
| 1264 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; |
---|
| 1265 | if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || |
---|
| 1266 | m_pcCUAboveLeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
| 1267 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveLeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
| 1268 | )) |
---|
| 1269 | ) |
---|
| 1270 | { |
---|
| 1271 | return NULL; |
---|
| 1272 | } |
---|
| 1273 | return m_pcCUAboveLeft; |
---|
| 1274 | } |
---|
| 1275 | |
---|
| 1276 | TComDataCU* TComDataCU::getPUAboveRight( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
| 1277 | { |
---|
| 1278 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
| 1279 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1; |
---|
| 1280 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 1281 | |
---|
| 1282 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
| 1283 | { |
---|
| 1284 | uiARPartUnitIdx = MAX_UINT; |
---|
| 1285 | return NULL; |
---|
| 1286 | } |
---|
| 1287 | |
---|
| 1288 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - 1, uiNumPartInCUWidth ) ) |
---|
| 1289 | { |
---|
| 1290 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
| 1291 | { |
---|
| 1292 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
---|
| 1293 | { |
---|
| 1294 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
---|
| 1295 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
| 1296 | { |
---|
| 1297 | return m_pcPic->getCU( getAddr() ); |
---|
| 1298 | } |
---|
| 1299 | else |
---|
| 1300 | { |
---|
| 1301 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
| 1302 | return this; |
---|
| 1303 | } |
---|
| 1304 | } |
---|
| 1305 | uiARPartUnitIdx = MAX_UINT; |
---|
| 1306 | return NULL; |
---|
| 1307 | } |
---|
| 1308 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
---|
| 1309 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
| 1310 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
| 1311 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
| 1312 | )) |
---|
| 1313 | ) |
---|
| 1314 | { |
---|
| 1315 | return NULL; |
---|
| 1316 | } |
---|
| 1317 | return m_pcCUAbove; |
---|
| 1318 | } |
---|
| 1319 | |
---|
| 1320 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
| 1321 | { |
---|
| 1322 | uiARPartUnitIdx = MAX_UINT; |
---|
| 1323 | return NULL; |
---|
| 1324 | } |
---|
| 1325 | |
---|
| 1326 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
---|
| 1327 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
| 1328 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
| 1329 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
| 1330 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
| 1331 | )) |
---|
| 1332 | ) |
---|
| 1333 | { |
---|
| 1334 | return NULL; |
---|
| 1335 | } |
---|
| 1336 | return m_pcCUAboveRight; |
---|
| 1337 | } |
---|
| 1338 | |
---|
| 1339 | TComDataCU* TComDataCU::getPUBelowLeft( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
---|
| 1340 | { |
---|
| 1341 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
| 1342 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth(); |
---|
| 1343 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 1344 | |
---|
| 1345 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
| 1346 | { |
---|
| 1347 | uiBLPartUnitIdx = MAX_UINT; |
---|
| 1348 | return NULL; |
---|
| 1349 | } |
---|
| 1350 | |
---|
| 1351 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - 1, uiNumPartInCUWidth ) ) |
---|
| 1352 | { |
---|
| 1353 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
---|
| 1354 | { |
---|
| 1355 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
---|
| 1356 | { |
---|
| 1357 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
---|
| 1358 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
---|
| 1359 | { |
---|
| 1360 | return m_pcPic->getCU( getAddr() ); |
---|
| 1361 | } |
---|
| 1362 | else |
---|
| 1363 | { |
---|
| 1364 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
| 1365 | return this; |
---|
| 1366 | } |
---|
| 1367 | } |
---|
| 1368 | uiBLPartUnitIdx = MAX_UINT; |
---|
| 1369 | return NULL; |
---|
| 1370 | } |
---|
| 1371 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
---|
| 1372 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
| 1373 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
| 1374 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
| 1375 | )) |
---|
| 1376 | ) |
---|
| 1377 | { |
---|
| 1378 | return NULL; |
---|
| 1379 | } |
---|
| 1380 | return m_pcCULeft; |
---|
| 1381 | } |
---|
| 1382 | |
---|
| 1383 | uiBLPartUnitIdx = MAX_UINT; |
---|
| 1384 | return NULL; |
---|
| 1385 | } |
---|
| 1386 | |
---|
| 1387 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
---|
| 1388 | { |
---|
| 1389 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
| 1390 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth(); |
---|
| 1391 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 1392 | |
---|
| 1393 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
---|
| 1394 | { |
---|
| 1395 | uiBLPartUnitIdx = MAX_UINT; |
---|
| 1396 | return NULL; |
---|
| 1397 | } |
---|
| 1398 | |
---|
| 1399 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
---|
| 1400 | { |
---|
| 1401 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
---|
| 1402 | { |
---|
| 1403 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] ) |
---|
| 1404 | { |
---|
| 1405 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ]; |
---|
| 1406 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
---|
| 1407 | { |
---|
| 1408 | return m_pcPic->getCU( getAddr() ); |
---|
| 1409 | } |
---|
| 1410 | else |
---|
| 1411 | { |
---|
| 1412 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
| 1413 | return this; |
---|
| 1414 | } |
---|
| 1415 | } |
---|
| 1416 | uiBLPartUnitIdx = MAX_UINT; |
---|
| 1417 | return NULL; |
---|
| 1418 | } |
---|
| 1419 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; |
---|
| 1420 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
---|
| 1421 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
| 1422 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
| 1423 | )) |
---|
| 1424 | ) |
---|
| 1425 | { |
---|
| 1426 | return NULL; |
---|
| 1427 | } |
---|
| 1428 | return m_pcCULeft; |
---|
| 1429 | } |
---|
| 1430 | |
---|
| 1431 | uiBLPartUnitIdx = MAX_UINT; |
---|
| 1432 | return NULL; |
---|
| 1433 | } |
---|
| 1434 | |
---|
| 1435 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
---|
| 1436 | { |
---|
| 1437 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
---|
| 1438 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
---|
| 1439 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 1440 | |
---|
| 1441 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
---|
| 1442 | { |
---|
| 1443 | uiARPartUnitIdx = MAX_UINT; |
---|
| 1444 | return NULL; |
---|
| 1445 | } |
---|
| 1446 | |
---|
| 1447 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
---|
| 1448 | { |
---|
| 1449 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
| 1450 | { |
---|
| 1451 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] ) |
---|
| 1452 | { |
---|
| 1453 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
| 1454 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
---|
| 1455 | { |
---|
| 1456 | return m_pcPic->getCU( getAddr() ); |
---|
| 1457 | } |
---|
| 1458 | else |
---|
| 1459 | { |
---|
| 1460 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
---|
| 1461 | return this; |
---|
| 1462 | } |
---|
| 1463 | } |
---|
| 1464 | uiARPartUnitIdx = MAX_UINT; |
---|
| 1465 | return NULL; |
---|
| 1466 | } |
---|
| 1467 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; |
---|
| 1468 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
---|
| 1469 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
| 1470 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
| 1471 | )) |
---|
| 1472 | ) |
---|
| 1473 | { |
---|
| 1474 | return NULL; |
---|
| 1475 | } |
---|
| 1476 | return m_pcCUAbove; |
---|
| 1477 | } |
---|
| 1478 | |
---|
| 1479 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
---|
| 1480 | { |
---|
| 1481 | uiARPartUnitIdx = MAX_UINT; |
---|
| 1482 | return NULL; |
---|
| 1483 | } |
---|
| 1484 | |
---|
| 1485 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; |
---|
| 1486 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
---|
| 1487 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
---|
| 1488 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
---|
| 1489 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
---|
| 1490 | )) |
---|
| 1491 | ) |
---|
| 1492 | { |
---|
| 1493 | return NULL; |
---|
| 1494 | } |
---|
| 1495 | return m_pcCUAboveRight; |
---|
| 1496 | } |
---|
| 1497 | |
---|
| 1498 | /** Get left QpMinCu |
---|
| 1499 | *\param uiLPartUnitIdx |
---|
| 1500 | *\param uiCurrAbsIdxInLCU |
---|
| 1501 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
---|
| 1502 | */ |
---|
| 1503 | TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInLCU) |
---|
| 1504 | { |
---|
| 1505 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 1506 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth -getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
---|
| 1507 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
| 1508 | |
---|
| 1509 | // check for left LCU boundary |
---|
| 1510 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCUWidth) ) |
---|
| 1511 | { |
---|
| 1512 | return NULL; |
---|
| 1513 | } |
---|
| 1514 | |
---|
| 1515 | // get index of left-CU relative to top-left corner of current quantization group |
---|
| 1516 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
---|
| 1517 | |
---|
| 1518 | // return pointer to current LCU |
---|
| 1519 | return m_pcPic->getCU( getAddr() ); |
---|
| 1520 | } |
---|
| 1521 | |
---|
| 1522 | /** Get Above QpMinCu |
---|
| 1523 | *\param aPartUnitIdx |
---|
| 1524 | *\param currAbsIdxInLCU |
---|
| 1525 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
---|
| 1526 | */ |
---|
| 1527 | TComDataCU* TComDataCU::getQpMinCuAbove( UInt& aPartUnitIdx, UInt currAbsIdxInLCU ) |
---|
| 1528 | { |
---|
| 1529 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 1530 | UInt absZorderQpMinCUIdx = (currAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
---|
| 1531 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
---|
| 1532 | |
---|
| 1533 | // check for top LCU boundary |
---|
| 1534 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCUWidth) ) |
---|
| 1535 | { |
---|
| 1536 | return NULL; |
---|
| 1537 | } |
---|
| 1538 | |
---|
| 1539 | // get index of top-CU relative to top-left corner of current quantization group |
---|
| 1540 | aPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCUWidth]; |
---|
| 1541 | |
---|
| 1542 | // return pointer to current LCU |
---|
| 1543 | return m_pcPic->getCU( getAddr() ); |
---|
| 1544 | } |
---|
| 1545 | |
---|
| 1546 | /** Get reference QP from left QpMinCu or latest coded QP |
---|
| 1547 | *\param uiCurrAbsIdxInLCU |
---|
| 1548 | *\returns Char reference QP value |
---|
| 1549 | */ |
---|
| 1550 | Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInLCU ) |
---|
| 1551 | { |
---|
| 1552 | UInt lPartIdx = 0, aPartIdx = 0; |
---|
| 1553 | TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
---|
| 1554 | TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
---|
| 1555 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + 1) >> 1); |
---|
| 1556 | } |
---|
| 1557 | |
---|
| 1558 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) |
---|
| 1559 | { |
---|
| 1560 | Int iLastValidPartIdx = iAbsPartIdx-1; |
---|
| 1561 | while ( iLastValidPartIdx >= 0 |
---|
| 1562 | && getPredictionMode( iLastValidPartIdx ) == MODE_NONE ) |
---|
| 1563 | { |
---|
| 1564 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
---|
| 1565 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
---|
| 1566 | } |
---|
| 1567 | return iLastValidPartIdx; |
---|
| 1568 | } |
---|
| 1569 | |
---|
| 1570 | Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) |
---|
| 1571 | { |
---|
| 1572 | UInt uiQUPartIdxMask = ~((1<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
---|
| 1573 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); |
---|
| 1574 | if ( uiAbsPartIdx < m_uiNumPartition |
---|
| 1575 | && (getSCUAddr()+iLastValidPartIdx < getSliceStartCU(m_uiAbsIdxInLCU+uiAbsPartIdx))) |
---|
| 1576 | { |
---|
| 1577 | return getSlice()->getSliceQp(); |
---|
| 1578 | } |
---|
| 1579 | else |
---|
| 1580 | if ( iLastValidPartIdx >= 0 ) |
---|
| 1581 | { |
---|
| 1582 | return getQP( iLastValidPartIdx ); |
---|
| 1583 | } |
---|
| 1584 | else |
---|
| 1585 | { |
---|
| 1586 | if ( getZorderIdxInCU() > 0 ) |
---|
| 1587 | { |
---|
| 1588 | return getPic()->getCU( getAddr() )->getLastCodedQP( getZorderIdxInCU() ); |
---|
| 1589 | } |
---|
| 1590 | else if ( getPic()->getPicSym()->getInverseCUOrderMap(getAddr()) > 0 |
---|
| 1591 | && getPic()->getPicSym()->getTileIdxMap(getAddr()) == getPic()->getPicSym()->getTileIdxMap(getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1)) |
---|
| 1592 | && !( getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() && getAddr() % getPic()->getFrameWidthInCU() == 0 ) ) |
---|
| 1593 | { |
---|
| 1594 | return getPic()->getCU( getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1) )->getLastCodedQP( getPic()->getNumPartInCU() ); |
---|
| 1595 | } |
---|
| 1596 | else |
---|
| 1597 | { |
---|
| 1598 | return getSlice()->getSliceQp(); |
---|
| 1599 | } |
---|
| 1600 | } |
---|
| 1601 | } |
---|
| 1602 | /** Check whether the CU is coded in lossless coding mode |
---|
| 1603 | * \param uiAbsPartIdx |
---|
| 1604 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
---|
| 1605 | */ |
---|
| 1606 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) |
---|
| 1607 | { |
---|
| 1608 | return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); |
---|
| 1609 | } |
---|
| 1610 | |
---|
| 1611 | /** Get allowed chroma intra modes |
---|
| 1612 | *\param uiAbsPartIdx |
---|
| 1613 | *\param uiModeList pointer to chroma intra modes array |
---|
| 1614 | *\returns |
---|
| 1615 | *- fill uiModeList with chroma intra modes |
---|
| 1616 | */ |
---|
| 1617 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt* uiModeList ) |
---|
| 1618 | { |
---|
| 1619 | uiModeList[0] = PLANAR_IDX; |
---|
| 1620 | uiModeList[1] = VER_IDX; |
---|
| 1621 | uiModeList[2] = HOR_IDX; |
---|
| 1622 | uiModeList[3] = DC_IDX; |
---|
| 1623 | uiModeList[4] = DM_CHROMA_IDX; |
---|
| 1624 | |
---|
| 1625 | UInt uiLumaMode = getLumaIntraDir( uiAbsPartIdx ); |
---|
| 1626 | |
---|
| 1627 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
---|
| 1628 | { |
---|
| 1629 | if( uiLumaMode == uiModeList[i] ) |
---|
| 1630 | { |
---|
| 1631 | uiModeList[i] = 34; // VER+8 mode |
---|
| 1632 | break; |
---|
| 1633 | } |
---|
| 1634 | } |
---|
| 1635 | } |
---|
| 1636 | |
---|
| 1637 | /** Get most probable intra modes |
---|
| 1638 | *\param uiAbsPartIdx |
---|
| 1639 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
| 1640 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
---|
| 1641 | *\returns Number of MPM |
---|
| 1642 | */ |
---|
| 1643 | Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode ) |
---|
| 1644 | { |
---|
| 1645 | TComDataCU* pcTempCU; |
---|
| 1646 | UInt uiTempPartIdx; |
---|
| 1647 | Int iLeftIntraDir, iAboveIntraDir; |
---|
| 1648 | Int uiPredNum = 0; |
---|
| 1649 | |
---|
| 1650 | // Get intra direction of left PU |
---|
| 1651 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1652 | |
---|
| 1653 | #if INTRA_BL |
---|
| 1654 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) && ( !pcTempCU->isIntraBL( uiTempPartIdx ) ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
| 1655 | #else |
---|
| 1656 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
| 1657 | #endif |
---|
| 1658 | |
---|
| 1659 | // Get intra direction of above PU |
---|
| 1660 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true ); |
---|
| 1661 | |
---|
| 1662 | #if INTRA_BL |
---|
| 1663 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) && ( !pcTempCU->isIntraBL( uiTempPartIdx ) ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
| 1664 | #else |
---|
| 1665 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
---|
| 1666 | #endif |
---|
| 1667 | |
---|
| 1668 | #if SVC_BL_CAND_INTRA |
---|
| 1669 | if(m_layerId > 0) |
---|
| 1670 | { |
---|
| 1671 | UInt uiCUAddrBase, uiAbsPartAddrBase; |
---|
| 1672 | pcTempCU = getBaseColCU( uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase ); |
---|
| 1673 | |
---|
| 1674 | if(pcTempCU->getPredictionMode( uiAbsPartAddrBase ) == MODE_INTRA ) |
---|
| 1675 | { |
---|
| 1676 | Int iColBaseDir = pcTempCU->getLumaIntraDir( uiAbsPartAddrBase ); |
---|
| 1677 | if( iColBaseDir != iAboveIntraDir && iColBaseDir != iLeftIntraDir && iAboveIntraDir != iLeftIntraDir) |
---|
| 1678 | { |
---|
| 1679 | uiIntraDirPred[0] = iColBaseDir; |
---|
| 1680 | uiIntraDirPred[1] = iLeftIntraDir; |
---|
| 1681 | uiIntraDirPred[2] = iAboveIntraDir; |
---|
| 1682 | if( piMode ) |
---|
| 1683 | { |
---|
| 1684 | *piMode = 2; |
---|
| 1685 | } |
---|
| 1686 | uiPredNum = 3; |
---|
| 1687 | return uiPredNum; |
---|
| 1688 | } |
---|
| 1689 | else |
---|
| 1690 | { |
---|
| 1691 | iAboveIntraDir = (iColBaseDir == iLeftIntraDir) ? iAboveIntraDir : iLeftIntraDir; |
---|
| 1692 | iLeftIntraDir = iColBaseDir; |
---|
| 1693 | } |
---|
| 1694 | } |
---|
| 1695 | } |
---|
| 1696 | #endif |
---|
| 1697 | |
---|
| 1698 | uiPredNum = 3; |
---|
| 1699 | if(iLeftIntraDir == iAboveIntraDir) |
---|
| 1700 | { |
---|
| 1701 | if( piMode ) |
---|
| 1702 | { |
---|
| 1703 | *piMode = 1; |
---|
| 1704 | } |
---|
| 1705 | |
---|
| 1706 | if (iLeftIntraDir > 1) // angular modes |
---|
| 1707 | { |
---|
| 1708 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
| 1709 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
---|
| 1710 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
---|
| 1711 | } |
---|
| 1712 | else //non-angular |
---|
| 1713 | { |
---|
| 1714 | uiIntraDirPred[0] = PLANAR_IDX; |
---|
| 1715 | uiIntraDirPred[1] = DC_IDX; |
---|
| 1716 | uiIntraDirPred[2] = VER_IDX; |
---|
| 1717 | } |
---|
| 1718 | } |
---|
| 1719 | else |
---|
| 1720 | { |
---|
| 1721 | if( piMode ) |
---|
| 1722 | { |
---|
| 1723 | *piMode = 2; |
---|
| 1724 | } |
---|
| 1725 | uiIntraDirPred[0] = iLeftIntraDir; |
---|
| 1726 | uiIntraDirPred[1] = iAboveIntraDir; |
---|
| 1727 | |
---|
| 1728 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
---|
| 1729 | { |
---|
| 1730 | uiIntraDirPred[2] = PLANAR_IDX; |
---|
| 1731 | } |
---|
| 1732 | else |
---|
| 1733 | { |
---|
| 1734 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
---|
| 1735 | } |
---|
| 1736 | } |
---|
| 1737 | |
---|
| 1738 | return uiPredNum; |
---|
| 1739 | } |
---|
| 1740 | |
---|
| 1741 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1742 | { |
---|
| 1743 | TComDataCU* pcTempCU; |
---|
| 1744 | UInt uiTempPartIdx; |
---|
| 1745 | UInt uiCtx; |
---|
| 1746 | // Get left split flag |
---|
| 1747 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1748 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
| 1749 | |
---|
| 1750 | // Get above split flag |
---|
| 1751 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1752 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
| 1753 | |
---|
| 1754 | return uiCtx; |
---|
| 1755 | } |
---|
| 1756 | |
---|
| 1757 | UInt TComDataCU::getCtxQtCbf( TextType eType, UInt uiTrDepth ) |
---|
| 1758 | { |
---|
| 1759 | if( eType ) |
---|
| 1760 | { |
---|
| 1761 | return uiTrDepth; |
---|
| 1762 | } |
---|
| 1763 | else |
---|
| 1764 | { |
---|
| 1765 | const UInt uiCtx = ( uiTrDepth == 0 ? 1 : 0 ); |
---|
| 1766 | return uiCtx; |
---|
| 1767 | } |
---|
| 1768 | } |
---|
| 1769 | |
---|
| 1770 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) |
---|
| 1771 | { |
---|
| 1772 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
---|
| 1773 | PartSize partSize = getPartitionSize( absPartIdx ); |
---|
| 1774 | #if INTRA_BL |
---|
| 1775 | UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
| 1776 | #else |
---|
| 1777 | UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
| 1778 | #endif |
---|
| 1779 | Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0; |
---|
| 1780 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) ); |
---|
| 1781 | |
---|
| 1782 | UInt log2MinTUSizeInCU = 0; |
---|
| 1783 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
---|
| 1784 | { |
---|
| 1785 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
---|
| 1786 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
| 1787 | } |
---|
| 1788 | else |
---|
| 1789 | { |
---|
| 1790 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
---|
| 1791 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
---|
| 1792 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
| 1793 | { |
---|
| 1794 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
---|
| 1795 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
| 1796 | } |
---|
| 1797 | } |
---|
| 1798 | return log2MinTUSizeInCU; |
---|
| 1799 | } |
---|
| 1800 | |
---|
| 1801 | #if INTRA_BL |
---|
| 1802 | UInt TComDataCU::getCtxIntraBLFlag( UInt uiAbsPartIdx ) |
---|
| 1803 | { |
---|
[139] | 1804 | #if INTRA_BL_CTX_CHANGE |
---|
| 1805 | Int cuDepth = getDepth(uiAbsPartIdx); |
---|
| 1806 | Int maxCuDepth = g_uiMaxCUDepth - g_uiAddCUDepth; |
---|
| 1807 | UInt uiCtx = (maxCuDepth==3 && cuDepth > 0) ? (cuDepth - 1) : cuDepth; |
---|
| 1808 | return uiCtx; |
---|
| 1809 | #else |
---|
[125] | 1810 | TComDataCU* pcTempCU; |
---|
| 1811 | UInt uiTempPartIdx; |
---|
| 1812 | UInt uiCtx = 0; |
---|
| 1813 | |
---|
| 1814 | // Get BCBP of left PU |
---|
| 1815 | #if DEPENDENT_SLICES |
---|
| 1816 | Bool bDepSliceRestriction = ( !m_pcSlice->getPPS()->getDependentSliceEnabledFlag()); |
---|
| 1817 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
| 1818 | #else |
---|
| 1819 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1820 | #endif |
---|
| 1821 | uiCtx = ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0; |
---|
| 1822 | |
---|
| 1823 | // Get BCBP of above PU |
---|
| 1824 | #if DEPENDENT_SLICES |
---|
| 1825 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
| 1826 | #else |
---|
| 1827 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1828 | #endif |
---|
| 1829 | uiCtx += ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0; |
---|
| 1830 | |
---|
| 1831 | return uiCtx; |
---|
[139] | 1832 | #endif |
---|
[125] | 1833 | } |
---|
| 1834 | #endif |
---|
| 1835 | |
---|
| 1836 | #if REF_IDX_ME_ZEROMV |
---|
| 1837 | Bool TComDataCU::xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1) |
---|
| 1838 | { |
---|
| 1839 | Bool checkZeroMVILR = true; |
---|
| 1840 | |
---|
| 1841 | if(uhInterDir&0x1) //list0 |
---|
| 1842 | { |
---|
| 1843 | Int refIdxL0 = cMvFieldL0.getRefIdx(); |
---|
[134] | 1844 | if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_layerId)) |
---|
[125] | 1845 | { |
---|
| 1846 | checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0); |
---|
| 1847 | } |
---|
| 1848 | } |
---|
| 1849 | if(uhInterDir&0x2) //list1 |
---|
| 1850 | { |
---|
| 1851 | Int refIdxL1 = cMvFieldL1.getRefIdx(); |
---|
[134] | 1852 | if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_layerId)) |
---|
[125] | 1853 | { |
---|
| 1854 | checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0); |
---|
| 1855 | } |
---|
| 1856 | } |
---|
| 1857 | |
---|
| 1858 | return checkZeroMVILR; |
---|
| 1859 | } |
---|
| 1860 | |
---|
| 1861 | Bool TComDataCU::xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx) |
---|
| 1862 | { |
---|
| 1863 | RefPicList eRefPicList = iRefList > 0? REF_PIC_LIST_1: REF_PIC_LIST_0; |
---|
| 1864 | assert(eRefPicList == REF_PIC_LIST_1); |
---|
| 1865 | |
---|
| 1866 | Bool checkZeroMVILR = true; |
---|
| 1867 | |
---|
[134] | 1868 | if(getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(m_layerId)) |
---|
[125] | 1869 | { |
---|
| 1870 | AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
| 1871 | TComMv cMv = pcAMVPInfo->m_acMvCand[MvpIdx]; |
---|
| 1872 | checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0); |
---|
| 1873 | } |
---|
| 1874 | |
---|
| 1875 | return checkZeroMVILR; |
---|
| 1876 | } |
---|
| 1877 | #endif |
---|
| 1878 | |
---|
| 1879 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
| 1880 | { |
---|
| 1881 | TComDataCU* pcTempCU; |
---|
| 1882 | UInt uiTempPartIdx; |
---|
| 1883 | UInt uiCtx = 0; |
---|
| 1884 | |
---|
| 1885 | // Get BCBP of left PU |
---|
| 1886 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1887 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
| 1888 | |
---|
| 1889 | // Get BCBP of above PU |
---|
| 1890 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1891 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
| 1892 | |
---|
| 1893 | return uiCtx; |
---|
| 1894 | } |
---|
| 1895 | |
---|
| 1896 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
| 1897 | { |
---|
| 1898 | return getDepth( uiAbsPartIdx ); |
---|
| 1899 | } |
---|
| 1900 | |
---|
| 1901 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1902 | { |
---|
| 1903 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1904 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1905 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1906 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1907 | } |
---|
| 1908 | |
---|
| 1909 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1910 | { |
---|
| 1911 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1912 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1913 | } |
---|
| 1914 | |
---|
| 1915 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
| 1916 | * \param uiCbf The value of the coded block flag to be set |
---|
| 1917 | * \param eTType |
---|
| 1918 | * \param uiAbsPartIdx |
---|
| 1919 | * \param uiPartIdx |
---|
| 1920 | * \param uiDepth |
---|
| 1921 | * \returns Void |
---|
| 1922 | */ |
---|
| 1923 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 1924 | { |
---|
| 1925 | setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 1926 | } |
---|
| 1927 | |
---|
| 1928 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
| 1929 | { |
---|
| 1930 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1931 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 1932 | } |
---|
| 1933 | |
---|
| 1934 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
| 1935 | { |
---|
| 1936 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1937 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
| 1938 | } |
---|
| 1939 | |
---|
| 1940 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1941 | { |
---|
| 1942 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
| 1943 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
| 1944 | } |
---|
| 1945 | |
---|
| 1946 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1947 | { |
---|
| 1948 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
| 1949 | } |
---|
| 1950 | |
---|
| 1951 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
| 1952 | { |
---|
| 1953 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
| 1954 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); |
---|
| 1955 | } |
---|
| 1956 | |
---|
| 1957 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1958 | { |
---|
| 1959 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
| 1960 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
| 1961 | } |
---|
| 1962 | |
---|
| 1963 | Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
| 1964 | { |
---|
| 1965 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
---|
| 1966 | UInt currPartNumQ = currPartNumb >> 2; |
---|
| 1967 | |
---|
| 1968 | if(!foundNonZeroCbf) |
---|
| 1969 | { |
---|
| 1970 | if(pcCU->getDepth(absPartIdx) > depth) |
---|
| 1971 | { |
---|
| 1972 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
| 1973 | { |
---|
| 1974 | pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
| 1975 | } |
---|
| 1976 | } |
---|
| 1977 | else |
---|
| 1978 | { |
---|
| 1979 | if(pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V ) ) |
---|
| 1980 | { |
---|
| 1981 | foundNonZeroCbf = true; |
---|
| 1982 | } |
---|
| 1983 | else |
---|
| 1984 | { |
---|
| 1985 | setQPSubParts(qp, absPartIdx, depth); |
---|
| 1986 | } |
---|
| 1987 | } |
---|
| 1988 | } |
---|
| 1989 | } |
---|
| 1990 | |
---|
| 1991 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1992 | { |
---|
| 1993 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1994 | TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); |
---|
| 1995 | |
---|
| 1996 | for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) |
---|
| 1997 | { |
---|
| 1998 | if( m_pcPic->getCU( getAddr() )->getSliceSegmentStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr() ) |
---|
| 1999 | { |
---|
| 2000 | m_phQP[uiSCUIdx] = qp; |
---|
| 2001 | } |
---|
| 2002 | } |
---|
| 2003 | } |
---|
| 2004 | |
---|
| 2005 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2006 | { |
---|
| 2007 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2008 | |
---|
| 2009 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 2010 | } |
---|
| 2011 | |
---|
| 2012 | template<typename T> |
---|
| 2013 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
| 2014 | { |
---|
| 2015 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
| 2016 | |
---|
| 2017 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
| 2018 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
| 2019 | { |
---|
| 2020 | case SIZE_2Nx2N: |
---|
| 2021 | memset( puhBaseLCU + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
| 2022 | break; |
---|
| 2023 | case SIZE_2NxN: |
---|
| 2024 | memset( puhBaseLCU + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
| 2025 | break; |
---|
| 2026 | case SIZE_Nx2N: |
---|
| 2027 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
| 2028 | memset( puhBaseLCU + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
| 2029 | break; |
---|
| 2030 | case SIZE_NxN: |
---|
| 2031 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
| 2032 | break; |
---|
| 2033 | case SIZE_2NxnU: |
---|
| 2034 | if ( uiPUIdx == 0 ) |
---|
| 2035 | { |
---|
| 2036 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2037 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2038 | } |
---|
| 2039 | else if ( uiPUIdx == 1 ) |
---|
| 2040 | { |
---|
| 2041 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2042 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
| 2043 | } |
---|
| 2044 | else |
---|
| 2045 | { |
---|
| 2046 | assert(0); |
---|
| 2047 | } |
---|
| 2048 | break; |
---|
| 2049 | case SIZE_2NxnD: |
---|
| 2050 | if ( uiPUIdx == 0 ) |
---|
| 2051 | { |
---|
| 2052 | memset( puhBaseLCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
| 2053 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2054 | } |
---|
| 2055 | else if ( uiPUIdx == 1 ) |
---|
| 2056 | { |
---|
| 2057 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2058 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2059 | } |
---|
| 2060 | else |
---|
| 2061 | { |
---|
| 2062 | assert(0); |
---|
| 2063 | } |
---|
| 2064 | break; |
---|
| 2065 | case SIZE_nLx2N: |
---|
| 2066 | if ( uiPUIdx == 0 ) |
---|
| 2067 | { |
---|
| 2068 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2069 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2070 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2071 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2072 | } |
---|
| 2073 | else if ( uiPUIdx == 1 ) |
---|
| 2074 | { |
---|
| 2075 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2076 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 2077 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2078 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 2079 | } |
---|
| 2080 | else |
---|
| 2081 | { |
---|
| 2082 | assert(0); |
---|
| 2083 | } |
---|
| 2084 | break; |
---|
| 2085 | case SIZE_nRx2N: |
---|
| 2086 | if ( uiPUIdx == 0 ) |
---|
| 2087 | { |
---|
| 2088 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 2089 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2090 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 2091 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2092 | } |
---|
| 2093 | else if ( uiPUIdx == 1 ) |
---|
| 2094 | { |
---|
| 2095 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2096 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2097 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2098 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2099 | } |
---|
| 2100 | else |
---|
| 2101 | { |
---|
| 2102 | assert(0); |
---|
| 2103 | } |
---|
| 2104 | break; |
---|
| 2105 | default: |
---|
| 2106 | assert( 0 ); |
---|
| 2107 | } |
---|
| 2108 | } |
---|
| 2109 | |
---|
| 2110 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2111 | { |
---|
| 2112 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 2113 | } |
---|
| 2114 | |
---|
| 2115 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2116 | { |
---|
| 2117 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 2118 | } |
---|
| 2119 | |
---|
| 2120 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2121 | { |
---|
| 2122 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2123 | |
---|
| 2124 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 2125 | } |
---|
| 2126 | |
---|
| 2127 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2128 | { |
---|
| 2129 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 2130 | } |
---|
| 2131 | |
---|
| 2132 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2133 | { |
---|
| 2134 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 2135 | } |
---|
| 2136 | |
---|
| 2137 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2138 | { |
---|
| 2139 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 2140 | } |
---|
| 2141 | |
---|
| 2142 | |
---|
| 2143 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2144 | { |
---|
| 2145 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2146 | |
---|
| 2147 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 2148 | } |
---|
| 2149 | |
---|
| 2150 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2151 | { |
---|
| 2152 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2153 | |
---|
| 2154 | memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 2155 | memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 2156 | memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 2157 | } |
---|
| 2158 | |
---|
| 2159 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) |
---|
| 2160 | { |
---|
| 2161 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2162 | |
---|
| 2163 | memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 2164 | } |
---|
| 2165 | |
---|
| 2166 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2167 | { |
---|
| 2168 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2169 | |
---|
| 2170 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 2171 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 2172 | } |
---|
| 2173 | |
---|
| 2174 | UChar TComDataCU::getNumPartInter() |
---|
| 2175 | { |
---|
| 2176 | UChar iNumPart = 0; |
---|
| 2177 | |
---|
| 2178 | switch ( m_pePartSize[0] ) |
---|
| 2179 | { |
---|
| 2180 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
| 2181 | case SIZE_2NxN: iNumPart = 2; break; |
---|
| 2182 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
| 2183 | case SIZE_NxN: iNumPart = 4; break; |
---|
| 2184 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
| 2185 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
| 2186 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
| 2187 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
| 2188 | default: assert (0); break; |
---|
| 2189 | } |
---|
| 2190 | |
---|
| 2191 | return iNumPart; |
---|
| 2192 | } |
---|
| 2193 | |
---|
| 2194 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
| 2195 | { |
---|
| 2196 | switch ( m_pePartSize[0] ) |
---|
| 2197 | { |
---|
| 2198 | case SIZE_2NxN: |
---|
| 2199 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 2200 | break; |
---|
| 2201 | case SIZE_Nx2N: |
---|
| 2202 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
| 2203 | break; |
---|
| 2204 | case SIZE_NxN: |
---|
| 2205 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
| 2206 | break; |
---|
| 2207 | case SIZE_2NxnU: |
---|
| 2208 | riWidth = getWidth(0); |
---|
| 2209 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
| 2210 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
| 2211 | break; |
---|
| 2212 | case SIZE_2NxnD: |
---|
| 2213 | riWidth = getWidth(0); |
---|
| 2214 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
| 2215 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
| 2216 | break; |
---|
| 2217 | case SIZE_nLx2N: |
---|
| 2218 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
| 2219 | riHeight = getHeight(0); |
---|
| 2220 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
| 2221 | break; |
---|
| 2222 | case SIZE_nRx2N: |
---|
| 2223 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
| 2224 | riHeight = getHeight(0); |
---|
| 2225 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
| 2226 | break; |
---|
| 2227 | default: |
---|
| 2228 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
| 2229 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
| 2230 | break; |
---|
| 2231 | } |
---|
| 2232 | } |
---|
| 2233 | |
---|
| 2234 | |
---|
| 2235 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
| 2236 | { |
---|
| 2237 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
| 2238 | { |
---|
| 2239 | TComMv cZeroMv; |
---|
| 2240 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
| 2241 | return; |
---|
| 2242 | } |
---|
| 2243 | |
---|
| 2244 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
| 2245 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
| 2246 | } |
---|
| 2247 | |
---|
| 2248 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
| 2249 | { |
---|
| 2250 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
| 2251 | UInt uiPUWidth = 0; |
---|
| 2252 | |
---|
| 2253 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
| 2254 | { |
---|
| 2255 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 2256 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 2257 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
| 2258 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
| 2259 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 2260 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 2261 | case SIZE_nLx2N: |
---|
| 2262 | if ( uiPartIdx == 0 ) |
---|
| 2263 | { |
---|
| 2264 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
| 2265 | } |
---|
| 2266 | else if ( uiPartIdx == 1 ) |
---|
| 2267 | { |
---|
| 2268 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
| 2269 | } |
---|
| 2270 | else |
---|
| 2271 | { |
---|
| 2272 | assert(0); |
---|
| 2273 | } |
---|
| 2274 | break; |
---|
| 2275 | case SIZE_nRx2N: |
---|
| 2276 | if ( uiPartIdx == 0 ) |
---|
| 2277 | { |
---|
| 2278 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
| 2279 | } |
---|
| 2280 | else if ( uiPartIdx == 1 ) |
---|
| 2281 | { |
---|
| 2282 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
| 2283 | } |
---|
| 2284 | else |
---|
| 2285 | { |
---|
| 2286 | assert(0); |
---|
| 2287 | } |
---|
| 2288 | break; |
---|
| 2289 | default: |
---|
| 2290 | assert (0); |
---|
| 2291 | break; |
---|
| 2292 | } |
---|
| 2293 | |
---|
| 2294 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
| 2295 | } |
---|
| 2296 | |
---|
| 2297 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
| 2298 | { |
---|
| 2299 | UInt uiPUHeight = 0; |
---|
| 2300 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
| 2301 | { |
---|
| 2302 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2303 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
| 2304 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2305 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
| 2306 | case SIZE_2NxnU: |
---|
| 2307 | if ( uiPartIdx == 0 ) |
---|
| 2308 | { |
---|
| 2309 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
| 2310 | } |
---|
| 2311 | else if ( uiPartIdx == 1 ) |
---|
| 2312 | { |
---|
| 2313 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
| 2314 | } |
---|
| 2315 | else |
---|
| 2316 | { |
---|
| 2317 | assert(0); |
---|
| 2318 | } |
---|
| 2319 | break; |
---|
| 2320 | case SIZE_2NxnD: |
---|
| 2321 | if ( uiPartIdx == 0 ) |
---|
| 2322 | { |
---|
| 2323 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
| 2324 | } |
---|
| 2325 | else if ( uiPartIdx == 1 ) |
---|
| 2326 | { |
---|
| 2327 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
| 2328 | } |
---|
| 2329 | else |
---|
| 2330 | { |
---|
| 2331 | assert(0); |
---|
| 2332 | } |
---|
| 2333 | break; |
---|
| 2334 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2335 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2336 | default: |
---|
| 2337 | assert (0); |
---|
| 2338 | break; |
---|
| 2339 | } |
---|
| 2340 | |
---|
| 2341 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
| 2342 | } |
---|
| 2343 | |
---|
| 2344 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
| 2345 | { |
---|
| 2346 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
---|
| 2347 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
| 2348 | |
---|
| 2349 | switch ( m_pePartSize[0] ) |
---|
| 2350 | { |
---|
| 2351 | case SIZE_2Nx2N: break; |
---|
| 2352 | case SIZE_2NxN: |
---|
| 2353 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 2354 | break; |
---|
| 2355 | case SIZE_Nx2N: |
---|
| 2356 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
| 2357 | break; |
---|
| 2358 | case SIZE_NxN: |
---|
| 2359 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
| 2360 | break; |
---|
| 2361 | case SIZE_2NxnU: |
---|
| 2362 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
| 2363 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
| 2364 | break; |
---|
| 2365 | case SIZE_2NxnD: |
---|
| 2366 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
| 2367 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
| 2368 | break; |
---|
| 2369 | case SIZE_nLx2N: |
---|
| 2370 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
| 2371 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
| 2372 | break; |
---|
| 2373 | case SIZE_nRx2N: |
---|
| 2374 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
| 2375 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
| 2376 | break; |
---|
| 2377 | default: |
---|
| 2378 | assert (0); |
---|
| 2379 | break; |
---|
| 2380 | } |
---|
| 2381 | |
---|
| 2382 | } |
---|
| 2383 | |
---|
| 2384 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
| 2385 | { |
---|
| 2386 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
| 2387 | |
---|
| 2388 | switch ( m_pePartSize[0] ) |
---|
| 2389 | { |
---|
| 2390 | case SIZE_2Nx2N: |
---|
| 2391 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
| 2392 | break; |
---|
| 2393 | case SIZE_2NxN: |
---|
| 2394 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 2395 | break; |
---|
| 2396 | case SIZE_Nx2N: |
---|
| 2397 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
| 2398 | break; |
---|
| 2399 | case SIZE_NxN: |
---|
| 2400 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
| 2401 | break; |
---|
| 2402 | case SIZE_2NxnU: |
---|
| 2403 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
| 2404 | break; |
---|
| 2405 | case SIZE_2NxnD: |
---|
| 2406 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
| 2407 | break; |
---|
| 2408 | case SIZE_nLx2N: |
---|
| 2409 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
| 2410 | break; |
---|
| 2411 | case SIZE_nRx2N: |
---|
| 2412 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
| 2413 | break; |
---|
| 2414 | default: |
---|
| 2415 | assert (0); |
---|
| 2416 | break; |
---|
| 2417 | } |
---|
| 2418 | } |
---|
| 2419 | |
---|
| 2420 | /** Derives the partition index of neighbouring bottom right block |
---|
| 2421 | * \param [in] eCUMode |
---|
| 2422 | * \param [in] uiPartIdx |
---|
| 2423 | * \param [out] ruiPartIdxRB |
---|
| 2424 | */ |
---|
| 2425 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxRB ) |
---|
| 2426 | { |
---|
| 2427 | ruiPartIdxRB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth() + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1]; |
---|
| 2428 | |
---|
| 2429 | switch ( m_pePartSize[0] ) |
---|
| 2430 | { |
---|
| 2431 | case SIZE_2Nx2N: |
---|
| 2432 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
| 2433 | break; |
---|
| 2434 | case SIZE_2NxN: |
---|
| 2435 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 2436 | break; |
---|
| 2437 | case SIZE_Nx2N: |
---|
| 2438 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
| 2439 | break; |
---|
| 2440 | case SIZE_NxN: |
---|
| 2441 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
| 2442 | break; |
---|
| 2443 | case SIZE_2NxnU: |
---|
| 2444 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
| 2445 | break; |
---|
| 2446 | case SIZE_2NxnD: |
---|
| 2447 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
| 2448 | break; |
---|
| 2449 | case SIZE_nLx2N: |
---|
| 2450 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
| 2451 | break; |
---|
| 2452 | case SIZE_nRx2N: |
---|
| 2453 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
| 2454 | break; |
---|
| 2455 | default: |
---|
| 2456 | assert (0); |
---|
| 2457 | break; |
---|
| 2458 | } |
---|
| 2459 | } |
---|
| 2460 | |
---|
| 2461 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
---|
| 2462 | { |
---|
| 2463 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
---|
| 2464 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
---|
| 2465 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
---|
| 2466 | } |
---|
| 2467 | |
---|
| 2468 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
---|
| 2469 | { |
---|
| 2470 | UInt uiAbsIdx; |
---|
| 2471 | UInt uiMinCuWidth, uiWidthInMinCus; |
---|
| 2472 | |
---|
| 2473 | uiMinCuWidth = getPic()->getMinCUWidth(); |
---|
| 2474 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
---|
| 2475 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
---|
| 2476 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
---|
| 2477 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
---|
| 2478 | } |
---|
| 2479 | |
---|
| 2480 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
| 2481 | { |
---|
| 2482 | |
---|
| 2483 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
| 2484 | { |
---|
| 2485 | return false; |
---|
| 2486 | } |
---|
| 2487 | |
---|
| 2488 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 2489 | { |
---|
| 2490 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
| 2491 | { |
---|
| 2492 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
| 2493 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
| 2494 | { |
---|
| 2495 | return false; |
---|
| 2496 | } |
---|
| 2497 | } |
---|
| 2498 | } |
---|
| 2499 | |
---|
| 2500 | return true; |
---|
| 2501 | } |
---|
| 2502 | |
---|
| 2503 | /** Constructs a list of merging candidates |
---|
| 2504 | * \param uiAbsPartIdx |
---|
| 2505 | * \param uiPUIdx |
---|
| 2506 | * \param uiDepth |
---|
| 2507 | * \param pcMvFieldNeighbours |
---|
| 2508 | * \param puhInterDirNeighbours |
---|
| 2509 | * \param numValidMergeCand |
---|
| 2510 | */ |
---|
| 2511 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) |
---|
| 2512 | { |
---|
| 2513 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
| 2514 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
| 2515 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
| 2516 | { |
---|
| 2517 | abCandIsInter[ui] = false; |
---|
| 2518 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
| 2519 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
| 2520 | } |
---|
| 2521 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
| 2522 | // compute the location of the current PU |
---|
| 2523 | Int xP, yP, nPSW, nPSH; |
---|
| 2524 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
| 2525 | |
---|
| 2526 | Int iCount = 0; |
---|
| 2527 | |
---|
| 2528 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
| 2529 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
| 2530 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
| 2531 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
| 2532 | #if SVC_MVP |
---|
| 2533 | // BL collocated |
---|
[207] | 2534 | TComDataCU *pcColCU = NULL; |
---|
| 2535 | UInt uiCUAddrBase = 0, uiAbsPartAddrBase = 0; |
---|
| 2536 | #if AVC_BASE |
---|
| 2537 | if( !this->getSlice()->getVPS()->getAvcBaseLayerFlag() || AVC_SYNTAX ) |
---|
| 2538 | #endif |
---|
[125] | 2539 | { |
---|
[207] | 2540 | TComMvField cMvFieldBaseColCU[2]; |
---|
| 2541 | if(m_layerId) |
---|
[125] | 2542 | { |
---|
[207] | 2543 | pcColCU = getBaseColCU( xP + nPSW/2, yP + nPSH/2, uiCUAddrBase, uiAbsPartAddrBase ); |
---|
[125] | 2544 | |
---|
[207] | 2545 | #if INTRA_BL |
---|
| 2546 | if( pcColCU && pcColCU->isIntraBL( uiAbsPartAddrBase ) ) |
---|
[125] | 2547 | { |
---|
[207] | 2548 | pcColCU = NULL; |
---|
[125] | 2549 | } |
---|
[207] | 2550 | #endif |
---|
[125] | 2551 | |
---|
[207] | 2552 | if(pcColCU && !pcColCU->isIntra( uiAbsPartAddrBase ) ) |
---|
[125] | 2553 | { |
---|
[207] | 2554 | abCandIsInter[iCount] = true; |
---|
[125] | 2555 | |
---|
[207] | 2556 | // get interDir |
---|
| 2557 | puhInterDirNeighbours[iCount] = pcColCU->getInterDir( uiAbsPartAddrBase ); |
---|
| 2558 | |
---|
| 2559 | pcMvFieldNeighbours[(iCount << 1)].setMvField( TComMv(0,0), -1); |
---|
| 2560 | pcMvFieldNeighbours[(iCount << 1) + 1].setMvField( TComMv(0,0), -1); |
---|
| 2561 | |
---|
| 2562 | if( puhInterDirNeighbours[iCount] & 1 ) |
---|
[125] | 2563 | { |
---|
[207] | 2564 | pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_0, cMvFieldBaseColCU[0]); |
---|
| 2565 | scaleBaseMV( pcMvFieldNeighbours[iCount<<1], cMvFieldBaseColCU[0] ); |
---|
[125] | 2566 | } |
---|
[207] | 2567 | |
---|
| 2568 | if ( getSlice()->isInterB() && puhInterDirNeighbours[iCount] & 2 ) |
---|
| 2569 | { |
---|
| 2570 | pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_1, cMvFieldBaseColCU[1] ); |
---|
| 2571 | scaleBaseMV( pcMvFieldNeighbours[(iCount<<1)+1], cMvFieldBaseColCU[1] ); |
---|
| 2572 | } |
---|
| 2573 | |
---|
| 2574 | if( puhInterDirNeighbours[iCount] > 0 ) |
---|
| 2575 | { |
---|
| 2576 | if ( mrgCandIdx == iCount ) |
---|
| 2577 | { |
---|
| 2578 | return; |
---|
| 2579 | } |
---|
| 2580 | iCount ++; |
---|
| 2581 | } |
---|
[125] | 2582 | } |
---|
| 2583 | } |
---|
| 2584 | } |
---|
| 2585 | #endif |
---|
| 2586 | |
---|
| 2587 | //left |
---|
| 2588 | UInt uiLeftPartIdx = 0; |
---|
| 2589 | TComDataCU* pcCULeft = 0; |
---|
| 2590 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
| 2591 | #if INTRA_BL |
---|
| 2592 | if( pcCULeft && pcCULeft->isIntraBL( uiLeftPartIdx ) ) |
---|
| 2593 | { |
---|
| 2594 | pcCULeft = NULL; |
---|
| 2595 | } |
---|
| 2596 | #endif |
---|
| 2597 | Bool isAvailableA1 = pcCULeft && |
---|
| 2598 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
| 2599 | #if SVC_MVP |
---|
| 2600 | ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) && |
---|
| 2601 | #endif |
---|
| 2602 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
| 2603 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
| 2604 | if ( isAvailableA1 ) |
---|
| 2605 | { |
---|
| 2606 | abCandIsInter[iCount] = true; |
---|
| 2607 | // get Inter Dir |
---|
| 2608 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
| 2609 | // get Mv from Left |
---|
| 2610 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
| 2611 | if ( getSlice()->isInterB() ) |
---|
| 2612 | { |
---|
| 2613 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
| 2614 | } |
---|
| 2615 | if ( mrgCandIdx == iCount ) |
---|
| 2616 | { |
---|
| 2617 | return; |
---|
| 2618 | } |
---|
| 2619 | iCount ++; |
---|
| 2620 | } |
---|
| 2621 | |
---|
| 2622 | // early termination |
---|
| 2623 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2624 | { |
---|
| 2625 | return; |
---|
| 2626 | } |
---|
| 2627 | // above |
---|
| 2628 | UInt uiAbovePartIdx = 0; |
---|
| 2629 | TComDataCU* pcCUAbove = 0; |
---|
| 2630 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
| 2631 | #if INTRA_BL |
---|
| 2632 | if( pcCUAbove && pcCUAbove->isIntraBL( uiAbovePartIdx ) ) |
---|
| 2633 | { |
---|
| 2634 | pcCUAbove = NULL; |
---|
| 2635 | } |
---|
| 2636 | #endif |
---|
| 2637 | Bool isAvailableB1 = pcCUAbove && |
---|
| 2638 | #if SVC_MVP |
---|
| 2639 | ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) && |
---|
| 2640 | #endif |
---|
| 2641 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
| 2642 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
| 2643 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
| 2644 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
| 2645 | { |
---|
| 2646 | abCandIsInter[iCount] = true; |
---|
| 2647 | // get Inter Dir |
---|
| 2648 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
| 2649 | // get Mv from Left |
---|
| 2650 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
| 2651 | if ( getSlice()->isInterB() ) |
---|
| 2652 | { |
---|
| 2653 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
| 2654 | } |
---|
| 2655 | if ( mrgCandIdx == iCount ) |
---|
| 2656 | { |
---|
| 2657 | return; |
---|
| 2658 | } |
---|
| 2659 | iCount ++; |
---|
| 2660 | } |
---|
| 2661 | // early termination |
---|
| 2662 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2663 | { |
---|
| 2664 | return; |
---|
| 2665 | } |
---|
| 2666 | |
---|
| 2667 | // above right |
---|
| 2668 | UInt uiAboveRightPartIdx = 0; |
---|
| 2669 | TComDataCU* pcCUAboveRight = 0; |
---|
| 2670 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
| 2671 | #if INTRA_BL |
---|
| 2672 | if( pcCUAboveRight && pcCUAboveRight->isIntraBL( uiAboveRightPartIdx ) ) |
---|
| 2673 | { |
---|
| 2674 | pcCUAboveRight = NULL; |
---|
| 2675 | } |
---|
| 2676 | #endif |
---|
| 2677 | Bool isAvailableB0 = pcCUAboveRight && |
---|
[136] | 2678 | #if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING |
---|
[125] | 2679 | ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveRight->hasEqualMotion( uiAboveRightPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) && |
---|
| 2680 | #endif |
---|
| 2681 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
| 2682 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
| 2683 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
| 2684 | { |
---|
| 2685 | abCandIsInter[iCount] = true; |
---|
| 2686 | // get Inter Dir |
---|
| 2687 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
| 2688 | // get Mv from Left |
---|
| 2689 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
| 2690 | if ( getSlice()->isInterB() ) |
---|
| 2691 | { |
---|
| 2692 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
| 2693 | } |
---|
| 2694 | if ( mrgCandIdx == iCount ) |
---|
| 2695 | { |
---|
| 2696 | return; |
---|
| 2697 | } |
---|
| 2698 | iCount ++; |
---|
| 2699 | } |
---|
| 2700 | // early termination |
---|
| 2701 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2702 | { |
---|
| 2703 | return; |
---|
| 2704 | } |
---|
| 2705 | |
---|
| 2706 | //left bottom |
---|
| 2707 | #if SVC_MVP |
---|
| 2708 | if( iCount < 4 ) |
---|
| 2709 | { |
---|
| 2710 | #endif |
---|
| 2711 | UInt uiLeftBottomPartIdx = 0; |
---|
| 2712 | TComDataCU* pcCULeftBottom = 0; |
---|
| 2713 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
| 2714 | #if INTRA_BL |
---|
| 2715 | if( pcCULeftBottom && pcCULeftBottom->isIntraBL( uiLeftBottomPartIdx ) ) |
---|
| 2716 | { |
---|
| 2717 | pcCULeftBottom = NULL; |
---|
| 2718 | } |
---|
| 2719 | #endif |
---|
| 2720 | Bool isAvailableA0 = pcCULeftBottom && |
---|
| 2721 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
[136] | 2722 | #if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING |
---|
[125] | 2723 | ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeftBottom->hasEqualMotion( uiLeftBottomPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) && |
---|
| 2724 | #endif |
---|
| 2725 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
| 2726 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
| 2727 | { |
---|
| 2728 | abCandIsInter[iCount] = true; |
---|
| 2729 | // get Inter Dir |
---|
| 2730 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
| 2731 | // get Mv from Left |
---|
| 2732 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
| 2733 | if ( getSlice()->isInterB() ) |
---|
| 2734 | { |
---|
| 2735 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
| 2736 | } |
---|
| 2737 | if ( mrgCandIdx == iCount ) |
---|
| 2738 | { |
---|
| 2739 | return; |
---|
| 2740 | } |
---|
| 2741 | iCount ++; |
---|
| 2742 | } |
---|
| 2743 | // early termination |
---|
| 2744 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2745 | { |
---|
| 2746 | return; |
---|
| 2747 | } |
---|
| 2748 | #if SVC_MVP |
---|
| 2749 | } |
---|
| 2750 | #endif |
---|
| 2751 | |
---|
| 2752 | // above left |
---|
| 2753 | if( iCount < 4 ) |
---|
| 2754 | { |
---|
| 2755 | UInt uiAboveLeftPartIdx = 0; |
---|
| 2756 | TComDataCU* pcCUAboveLeft = 0; |
---|
| 2757 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
| 2758 | #if INTRA_BL |
---|
| 2759 | if( pcCUAboveLeft && pcCUAboveLeft->isIntraBL( uiAboveLeftPartIdx ) ) |
---|
| 2760 | { |
---|
| 2761 | pcCUAboveLeft = NULL; |
---|
| 2762 | } |
---|
| 2763 | #endif |
---|
| 2764 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
| 2765 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
[136] | 2766 | #if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING |
---|
[125] | 2767 | ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveLeft->hasEqualMotion( uiAboveLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) && |
---|
| 2768 | #endif |
---|
| 2769 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
| 2770 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
| 2771 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
| 2772 | { |
---|
| 2773 | abCandIsInter[iCount] = true; |
---|
| 2774 | // get Inter Dir |
---|
| 2775 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
| 2776 | // get Mv from Left |
---|
| 2777 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
| 2778 | if ( getSlice()->isInterB() ) |
---|
| 2779 | { |
---|
| 2780 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
| 2781 | } |
---|
| 2782 | if ( mrgCandIdx == iCount ) |
---|
| 2783 | { |
---|
| 2784 | return; |
---|
| 2785 | } |
---|
| 2786 | iCount ++; |
---|
| 2787 | } |
---|
| 2788 | } |
---|
| 2789 | // early termination |
---|
| 2790 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2791 | { |
---|
| 2792 | return; |
---|
| 2793 | } |
---|
| 2794 | if ( getSlice()->getEnableTMVPFlag()) |
---|
| 2795 | { |
---|
| 2796 | //>> MTK colocated-RightBottom |
---|
| 2797 | UInt uiPartIdxRB; |
---|
| 2798 | Int uiLCUIdx = getAddr(); |
---|
| 2799 | |
---|
| 2800 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
| 2801 | |
---|
| 2802 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
| 2803 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 2804 | |
---|
| 2805 | TComMv cColMv; |
---|
| 2806 | Int iRefIdx; |
---|
| 2807 | |
---|
| 2808 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
| 2809 | { |
---|
| 2810 | uiLCUIdx = -1; |
---|
| 2811 | } |
---|
| 2812 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
| 2813 | { |
---|
| 2814 | uiLCUIdx = -1; |
---|
| 2815 | } |
---|
| 2816 | else |
---|
| 2817 | { |
---|
| 2818 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
| 2819 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
| 2820 | { |
---|
| 2821 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
| 2822 | uiLCUIdx = getAddr(); |
---|
| 2823 | } |
---|
| 2824 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
| 2825 | { |
---|
| 2826 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
| 2827 | uiLCUIdx = -1 ; |
---|
| 2828 | } |
---|
| 2829 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
| 2830 | { |
---|
| 2831 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
| 2832 | uiLCUIdx = getAddr() + 1; |
---|
| 2833 | } |
---|
| 2834 | else //is the right bottom corner of LCU |
---|
| 2835 | { |
---|
| 2836 | uiAbsPartAddr = 0; |
---|
| 2837 | uiLCUIdx = -1 ; |
---|
| 2838 | } |
---|
| 2839 | } |
---|
| 2840 | |
---|
| 2841 | |
---|
| 2842 | iRefIdx = 0; |
---|
| 2843 | Bool bExistMV = false; |
---|
| 2844 | UInt uiPartIdxCenter; |
---|
| 2845 | UInt uiCurLCUIdx = getAddr(); |
---|
| 2846 | Int dir = 0; |
---|
| 2847 | UInt uiArrayAddr = iCount; |
---|
| 2848 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
| 2849 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
| 2850 | if( bExistMV == false ) |
---|
| 2851 | { |
---|
| 2852 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
| 2853 | } |
---|
| 2854 | if( bExistMV ) |
---|
| 2855 | { |
---|
| 2856 | dir |= 1; |
---|
| 2857 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
| 2858 | } |
---|
| 2859 | |
---|
| 2860 | if ( getSlice()->isInterB() ) |
---|
| 2861 | { |
---|
| 2862 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
| 2863 | if( bExistMV == false ) |
---|
| 2864 | { |
---|
| 2865 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
| 2866 | } |
---|
| 2867 | if( bExistMV ) |
---|
| 2868 | { |
---|
| 2869 | dir |= 2; |
---|
| 2870 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
| 2871 | } |
---|
| 2872 | } |
---|
| 2873 | |
---|
| 2874 | if (dir != 0) |
---|
| 2875 | { |
---|
| 2876 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
| 2877 | abCandIsInter[uiArrayAddr] = true; |
---|
| 2878 | |
---|
| 2879 | if ( mrgCandIdx == iCount ) |
---|
| 2880 | { |
---|
| 2881 | return; |
---|
| 2882 | } |
---|
| 2883 | iCount++; |
---|
| 2884 | } |
---|
| 2885 | } |
---|
| 2886 | // early termination |
---|
| 2887 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2888 | { |
---|
| 2889 | return; |
---|
| 2890 | } |
---|
| 2891 | UInt uiArrayAddr = iCount; |
---|
| 2892 | UInt uiCutoff = uiArrayAddr; |
---|
| 2893 | |
---|
| 2894 | if ( getSlice()->isInterB()) |
---|
| 2895 | { |
---|
| 2896 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
| 2897 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
| 2898 | |
---|
| 2899 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
| 2900 | { |
---|
| 2901 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
| 2902 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
| 2903 | { |
---|
| 2904 | abCandIsInter[uiArrayAddr] = true; |
---|
| 2905 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
| 2906 | |
---|
| 2907 | // get Mv from cand[i] and cand[j] |
---|
| 2908 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
| 2909 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
| 2910 | |
---|
| 2911 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
| 2912 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
| 2913 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
| 2914 | { |
---|
| 2915 | abCandIsInter[uiArrayAddr] = false; |
---|
| 2916 | } |
---|
| 2917 | else |
---|
| 2918 | { |
---|
| 2919 | uiArrayAddr++; |
---|
| 2920 | } |
---|
| 2921 | } |
---|
| 2922 | } |
---|
| 2923 | } |
---|
| 2924 | // early termination |
---|
| 2925 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
| 2926 | { |
---|
| 2927 | return; |
---|
| 2928 | } |
---|
| 2929 | 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); |
---|
| 2930 | Int r = 0; |
---|
| 2931 | Int refcnt = 0; |
---|
| 2932 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
| 2933 | { |
---|
| 2934 | abCandIsInter[uiArrayAddr] = true; |
---|
| 2935 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
| 2936 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
| 2937 | |
---|
| 2938 | if ( getSlice()->isInterB() ) |
---|
| 2939 | { |
---|
| 2940 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
| 2941 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
| 2942 | } |
---|
| 2943 | uiArrayAddr++; |
---|
| 2944 | if ( refcnt == iNumRefIdx - 1 ) |
---|
| 2945 | { |
---|
| 2946 | r = 0; |
---|
| 2947 | } |
---|
| 2948 | else |
---|
| 2949 | { |
---|
| 2950 | ++r; |
---|
| 2951 | ++refcnt; |
---|
| 2952 | } |
---|
| 2953 | } |
---|
| 2954 | |
---|
| 2955 | numValidMergeCand = uiArrayAddr; |
---|
| 2956 | } |
---|
| 2957 | |
---|
| 2958 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
| 2959 | * \param xN, xN location of the upper-left corner pixel of a neighboring PU |
---|
| 2960 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
| 2961 | * \returns Bool |
---|
| 2962 | */ |
---|
| 2963 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
---|
| 2964 | { |
---|
| 2965 | |
---|
| 2966 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
| 2967 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
| 2968 | { |
---|
| 2969 | return true; |
---|
| 2970 | } |
---|
| 2971 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
| 2972 | { |
---|
| 2973 | return true; |
---|
| 2974 | } |
---|
| 2975 | return false; |
---|
| 2976 | } |
---|
| 2977 | /** calculate the location of upper-left corner pixel and size of the current PU. |
---|
| 2978 | * \param partIdx PU index within a CU |
---|
| 2979 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
| 2980 | * \param PSW, nPSH size of the curren PU |
---|
| 2981 | * \returns Void |
---|
| 2982 | */ |
---|
| 2983 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
---|
| 2984 | { |
---|
| 2985 | UInt col = m_uiCUPelX; |
---|
| 2986 | UInt row = m_uiCUPelY; |
---|
| 2987 | |
---|
| 2988 | switch ( m_pePartSize[0] ) |
---|
| 2989 | { |
---|
| 2990 | case SIZE_2NxN: |
---|
| 2991 | nPSW = getWidth(0); |
---|
| 2992 | nPSH = getHeight(0) >> 1; |
---|
| 2993 | xP = col; |
---|
| 2994 | yP = (partIdx ==0)? row: row + nPSH; |
---|
| 2995 | break; |
---|
| 2996 | case SIZE_Nx2N: |
---|
| 2997 | nPSW = getWidth(0) >> 1; |
---|
| 2998 | nPSH = getHeight(0); |
---|
| 2999 | xP = (partIdx ==0)? col: col + nPSW; |
---|
| 3000 | yP = row; |
---|
| 3001 | break; |
---|
| 3002 | case SIZE_NxN: |
---|
| 3003 | nPSW = getWidth(0) >> 1; |
---|
| 3004 | nPSH = getHeight(0) >> 1; |
---|
| 3005 | xP = col + (partIdx&0x1)*nPSW; |
---|
| 3006 | yP = row + (partIdx>>1)*nPSH; |
---|
| 3007 | break; |
---|
| 3008 | case SIZE_2NxnU: |
---|
| 3009 | nPSW = getWidth(0); |
---|
| 3010 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
| 3011 | xP = col; |
---|
| 3012 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
| 3013 | |
---|
| 3014 | break; |
---|
| 3015 | case SIZE_2NxnD: |
---|
| 3016 | nPSW = getWidth(0); |
---|
| 3017 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
| 3018 | xP = col; |
---|
| 3019 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
| 3020 | break; |
---|
| 3021 | case SIZE_nLx2N: |
---|
| 3022 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
| 3023 | nPSH = getHeight(0); |
---|
| 3024 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
| 3025 | yP = row; |
---|
| 3026 | break; |
---|
| 3027 | case SIZE_nRx2N: |
---|
| 3028 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
| 3029 | nPSH = getHeight(0); |
---|
| 3030 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
| 3031 | yP = row; |
---|
| 3032 | break; |
---|
| 3033 | default: |
---|
| 3034 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
| 3035 | nPSW = getWidth(0); |
---|
| 3036 | nPSH = getHeight(0); |
---|
| 3037 | xP = col ; |
---|
| 3038 | yP = row ; |
---|
| 3039 | |
---|
| 3040 | break; |
---|
| 3041 | } |
---|
| 3042 | } |
---|
| 3043 | |
---|
| 3044 | /** Constructs a list of candidates for AMVP |
---|
| 3045 | * \param uiPartIdx |
---|
| 3046 | * \param uiPartAddr |
---|
| 3047 | * \param eRefPicList |
---|
| 3048 | * \param iRefIdx |
---|
| 3049 | * \param pInfo |
---|
| 3050 | */ |
---|
| 3051 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
| 3052 | { |
---|
| 3053 | TComMv cMvPred; |
---|
| 3054 | Bool bAddedSmvp = false; |
---|
| 3055 | |
---|
| 3056 | pInfo->iN = 0; |
---|
| 3057 | if (iRefIdx < 0) |
---|
| 3058 | { |
---|
| 3059 | return; |
---|
| 3060 | } |
---|
| 3061 | |
---|
| 3062 | //-- Get Spatial MV |
---|
| 3063 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
| 3064 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 3065 | Bool bAdded = false; |
---|
| 3066 | |
---|
| 3067 | deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
| 3068 | deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); |
---|
| 3069 | |
---|
| 3070 | TComDataCU* tmpCU = NULL; |
---|
| 3071 | UInt idx; |
---|
| 3072 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB); |
---|
| 3073 | #if INTRA_BL |
---|
| 3074 | bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx)); |
---|
| 3075 | #else |
---|
| 3076 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
| 3077 | #endif |
---|
| 3078 | |
---|
| 3079 | if (!bAddedSmvp) |
---|
| 3080 | { |
---|
| 3081 | tmpCU = getPULeft(idx, uiPartIdxLB); |
---|
| 3082 | #if INTRA_BL |
---|
| 3083 | bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx)); |
---|
| 3084 | #else |
---|
| 3085 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
| 3086 | #endif |
---|
| 3087 | } |
---|
| 3088 | |
---|
| 3089 | // Left predictor search |
---|
| 3090 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
| 3091 | if (!bAdded) |
---|
| 3092 | { |
---|
| 3093 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
| 3094 | } |
---|
| 3095 | |
---|
| 3096 | if(!bAdded) |
---|
| 3097 | { |
---|
| 3098 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
| 3099 | if (!bAdded) |
---|
| 3100 | { |
---|
| 3101 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
| 3102 | } |
---|
| 3103 | } |
---|
| 3104 | // Above predictor search |
---|
| 3105 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
| 3106 | |
---|
| 3107 | if (!bAdded) |
---|
| 3108 | { |
---|
| 3109 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
| 3110 | } |
---|
| 3111 | |
---|
| 3112 | if(!bAdded) |
---|
| 3113 | { |
---|
| 3114 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
| 3115 | } |
---|
| 3116 | bAdded = bAddedSmvp; |
---|
| 3117 | if (pInfo->iN==2) bAdded = true; |
---|
| 3118 | |
---|
| 3119 | if(!bAdded) |
---|
| 3120 | { |
---|
| 3121 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
| 3122 | if (!bAdded) |
---|
| 3123 | { |
---|
| 3124 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
| 3125 | } |
---|
| 3126 | |
---|
| 3127 | if(!bAdded) |
---|
| 3128 | { |
---|
| 3129 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
| 3130 | } |
---|
| 3131 | } |
---|
| 3132 | |
---|
| 3133 | if ( pInfo->iN == 2 ) |
---|
| 3134 | { |
---|
| 3135 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
| 3136 | { |
---|
| 3137 | pInfo->iN = 1; |
---|
| 3138 | } |
---|
| 3139 | } |
---|
| 3140 | |
---|
| 3141 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
| 3142 | { |
---|
| 3143 | // Get Temporal Motion Predictor |
---|
| 3144 | Int iRefIdx_Col = iRefIdx; |
---|
| 3145 | TComMv cColMv; |
---|
| 3146 | UInt uiPartIdxRB; |
---|
| 3147 | UInt uiAbsPartIdx; |
---|
| 3148 | UInt uiAbsPartAddr; |
---|
| 3149 | Int uiLCUIdx = getAddr(); |
---|
| 3150 | |
---|
| 3151 | deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); |
---|
| 3152 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
| 3153 | |
---|
| 3154 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
| 3155 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
| 3156 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
| 3157 | { |
---|
| 3158 | uiLCUIdx = -1; |
---|
| 3159 | } |
---|
| 3160 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
| 3161 | { |
---|
| 3162 | uiLCUIdx = -1; |
---|
| 3163 | } |
---|
| 3164 | else |
---|
| 3165 | { |
---|
| 3166 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
| 3167 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
| 3168 | { |
---|
| 3169 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
---|
| 3170 | uiLCUIdx = getAddr(); |
---|
| 3171 | } |
---|
| 3172 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
| 3173 | { |
---|
| 3174 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
| 3175 | uiLCUIdx = -1 ; |
---|
| 3176 | } |
---|
| 3177 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
| 3178 | { |
---|
| 3179 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
| 3180 | uiLCUIdx = getAddr() + 1; |
---|
| 3181 | } |
---|
| 3182 | else //is the right bottom corner of LCU |
---|
| 3183 | { |
---|
| 3184 | uiAbsPartAddr = 0; |
---|
| 3185 | uiLCUIdx = -1 ; |
---|
| 3186 | } |
---|
| 3187 | } |
---|
| 3188 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col ) ) |
---|
| 3189 | { |
---|
| 3190 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
| 3191 | } |
---|
| 3192 | else |
---|
| 3193 | { |
---|
| 3194 | UInt uiPartIdxCenter; |
---|
| 3195 | UInt uiCurLCUIdx = getAddr(); |
---|
| 3196 | xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); |
---|
| 3197 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col )) |
---|
| 3198 | { |
---|
| 3199 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
| 3200 | } |
---|
| 3201 | } |
---|
| 3202 | //---- co-located RightBottom Temporal Predictor ---// |
---|
| 3203 | } |
---|
| 3204 | |
---|
| 3205 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
---|
| 3206 | { |
---|
| 3207 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
---|
| 3208 | } |
---|
| 3209 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
| 3210 | { |
---|
| 3211 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
| 3212 | pInfo->iN++; |
---|
| 3213 | } |
---|
| 3214 | return ; |
---|
| 3215 | } |
---|
| 3216 | |
---|
| 3217 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
---|
| 3218 | { |
---|
| 3219 | Int width = 0; |
---|
| 3220 | Int height = 0; |
---|
| 3221 | UInt partAddr; |
---|
| 3222 | |
---|
| 3223 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
| 3224 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
| 3225 | { |
---|
| 3226 | return true; |
---|
| 3227 | } |
---|
| 3228 | return false; |
---|
| 3229 | } |
---|
| 3230 | |
---|
| 3231 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
| 3232 | { |
---|
| 3233 | Int iMvShift = 2; |
---|
| 3234 | Int iOffset = 8; |
---|
| 3235 | Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset - m_uiCUPelX - 1 ) << iMvShift; |
---|
| 3236 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
| 3237 | |
---|
| 3238 | Int iVerMax = ( m_pcSlice->getSPS()->getPicHeightInLumaSamples() + iOffset - m_uiCUPelY - 1 ) << iMvShift; |
---|
| 3239 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
| 3240 | |
---|
| 3241 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
| 3242 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
| 3243 | } |
---|
| 3244 | |
---|
| 3245 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
| 3246 | { |
---|
| 3247 | UInt uiShift = ( (m_puhTrIdx[uiAbsPartIdx]==0) && (m_pePartSize[uiAbsPartIdx]==SIZE_NxN) ) ? m_puhTrIdx[uiAbsPartIdx]+1 : m_puhTrIdx[uiAbsPartIdx]; |
---|
| 3248 | uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
| 3249 | |
---|
| 3250 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
| 3251 | UInt uiCnt = 0; |
---|
| 3252 | while( uiWidth ) |
---|
| 3253 | { |
---|
| 3254 | uiCnt++; |
---|
| 3255 | uiWidth>>=1; |
---|
| 3256 | } |
---|
| 3257 | uiCnt-=2; |
---|
| 3258 | return uiCnt > 6 ? 6 : uiCnt; |
---|
| 3259 | } |
---|
| 3260 | |
---|
| 3261 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
---|
| 3262 | { |
---|
| 3263 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
| 3264 | } |
---|
| 3265 | |
---|
| 3266 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
| 3267 | * \param bIpcmFlag I_PCM flag |
---|
| 3268 | * \param uiAbsPartIdx patition index |
---|
| 3269 | * \param uiDepth CU depth |
---|
| 3270 | * \returns Void |
---|
| 3271 | */ |
---|
| 3272 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
| 3273 | { |
---|
| 3274 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 3275 | |
---|
| 3276 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
| 3277 | } |
---|
| 3278 | |
---|
| 3279 | /** Test whether the current block is skipped |
---|
| 3280 | * \param uiPartIdx Block index |
---|
| 3281 | * \returns Flag indicating whether the block is skipped |
---|
| 3282 | */ |
---|
| 3283 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
| 3284 | { |
---|
| 3285 | return ( getSkipFlag( uiPartIdx ) ); |
---|
| 3286 | } |
---|
| 3287 | |
---|
| 3288 | // ==================================================================================================================== |
---|
| 3289 | // Protected member functions |
---|
| 3290 | // ==================================================================================================================== |
---|
| 3291 | |
---|
| 3292 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
| 3293 | { |
---|
| 3294 | TComDataCU* pcTmpCU = NULL; |
---|
| 3295 | UInt uiIdx; |
---|
| 3296 | switch( eDir ) |
---|
| 3297 | { |
---|
| 3298 | case MD_LEFT: |
---|
| 3299 | { |
---|
| 3300 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
| 3301 | break; |
---|
| 3302 | } |
---|
| 3303 | case MD_ABOVE: |
---|
| 3304 | { |
---|
| 3305 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx ); |
---|
| 3306 | break; |
---|
| 3307 | } |
---|
| 3308 | case MD_ABOVE_RIGHT: |
---|
| 3309 | { |
---|
| 3310 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
| 3311 | break; |
---|
| 3312 | } |
---|
| 3313 | case MD_BELOW_LEFT: |
---|
| 3314 | { |
---|
| 3315 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
| 3316 | break; |
---|
| 3317 | } |
---|
| 3318 | case MD_ABOVE_LEFT: |
---|
| 3319 | { |
---|
| 3320 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
| 3321 | break; |
---|
| 3322 | } |
---|
| 3323 | default: |
---|
| 3324 | { |
---|
| 3325 | break; |
---|
| 3326 | } |
---|
| 3327 | } |
---|
| 3328 | |
---|
| 3329 | if ( pcTmpCU == NULL ) |
---|
| 3330 | { |
---|
| 3331 | return false; |
---|
| 3332 | } |
---|
| 3333 | |
---|
| 3334 | #if L0363_MVP_POC |
---|
| 3335 | if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) |
---|
| 3336 | #else |
---|
| 3337 | if ( m_pcSlice->isEqualRef(eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx), iRefIdx) ) |
---|
| 3338 | #endif |
---|
| 3339 | { |
---|
| 3340 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
| 3341 | |
---|
| 3342 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
| 3343 | return true; |
---|
| 3344 | } |
---|
| 3345 | |
---|
| 3346 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
| 3347 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
| 3348 | { |
---|
| 3349 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
| 3350 | } |
---|
| 3351 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
| 3352 | { |
---|
| 3353 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
| 3354 | } |
---|
| 3355 | |
---|
| 3356 | |
---|
| 3357 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
| 3358 | Int iNeibRefPOC; |
---|
| 3359 | |
---|
| 3360 | |
---|
| 3361 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
| 3362 | { |
---|
| 3363 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
| 3364 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
| 3365 | { |
---|
| 3366 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
| 3367 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
| 3368 | return true; |
---|
| 3369 | } |
---|
| 3370 | } |
---|
| 3371 | return false; |
---|
| 3372 | } |
---|
| 3373 | |
---|
| 3374 | /** |
---|
| 3375 | * \param pInfo |
---|
| 3376 | * \param eRefPicList |
---|
| 3377 | * \param iRefIdx |
---|
| 3378 | * \param uiPartUnitIdx |
---|
| 3379 | * \param eDir |
---|
| 3380 | * \returns Bool |
---|
| 3381 | */ |
---|
| 3382 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
| 3383 | { |
---|
| 3384 | TComDataCU* pcTmpCU = NULL; |
---|
| 3385 | UInt uiIdx; |
---|
| 3386 | switch( eDir ) |
---|
| 3387 | { |
---|
| 3388 | case MD_LEFT: |
---|
| 3389 | { |
---|
| 3390 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
| 3391 | break; |
---|
| 3392 | } |
---|
| 3393 | case MD_ABOVE: |
---|
| 3394 | { |
---|
| 3395 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
| 3396 | break; |
---|
| 3397 | } |
---|
| 3398 | case MD_ABOVE_RIGHT: |
---|
| 3399 | { |
---|
| 3400 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
| 3401 | break; |
---|
| 3402 | } |
---|
| 3403 | case MD_BELOW_LEFT: |
---|
| 3404 | { |
---|
| 3405 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
| 3406 | break; |
---|
| 3407 | } |
---|
| 3408 | case MD_ABOVE_LEFT: |
---|
| 3409 | { |
---|
| 3410 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
| 3411 | break; |
---|
| 3412 | } |
---|
| 3413 | default: |
---|
| 3414 | { |
---|
| 3415 | break; |
---|
| 3416 | } |
---|
| 3417 | } |
---|
| 3418 | |
---|
| 3419 | if ( pcTmpCU == NULL ) |
---|
| 3420 | { |
---|
| 3421 | return false; |
---|
| 3422 | } |
---|
| 3423 | |
---|
| 3424 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
| 3425 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
| 3426 | { |
---|
| 3427 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
| 3428 | } |
---|
| 3429 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
| 3430 | { |
---|
| 3431 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
| 3432 | } |
---|
| 3433 | |
---|
| 3434 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
| 3435 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
| 3436 | Int iNeibPOC = iCurrPOC; |
---|
| 3437 | Int iNeibRefPOC; |
---|
| 3438 | |
---|
| 3439 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
| 3440 | Bool bIsNeibRefLongTerm = false; |
---|
| 3441 | //--------------- V1 (END) ------------------// |
---|
| 3442 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
| 3443 | { |
---|
| 3444 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
| 3445 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
| 3446 | TComMv rcMv; |
---|
| 3447 | |
---|
| 3448 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
| 3449 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
| 3450 | { |
---|
| 3451 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
| 3452 | { |
---|
| 3453 | rcMv = cMvPred; |
---|
| 3454 | } |
---|
| 3455 | else |
---|
| 3456 | { |
---|
| 3457 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
| 3458 | if ( iScale == 4096 ) |
---|
| 3459 | { |
---|
| 3460 | rcMv = cMvPred; |
---|
| 3461 | } |
---|
| 3462 | else |
---|
| 3463 | { |
---|
| 3464 | rcMv = cMvPred.scaleMv( iScale ); |
---|
| 3465 | } |
---|
| 3466 | } |
---|
| 3467 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
| 3468 | return true; |
---|
| 3469 | } |
---|
| 3470 | } |
---|
| 3471 | //---------------------- V2(END) --------------------// |
---|
| 3472 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
| 3473 | { |
---|
| 3474 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
| 3475 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
| 3476 | TComMv rcMv; |
---|
| 3477 | |
---|
| 3478 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
| 3479 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
| 3480 | { |
---|
| 3481 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
| 3482 | { |
---|
| 3483 | rcMv = cMvPred; |
---|
| 3484 | } |
---|
| 3485 | else |
---|
| 3486 | { |
---|
| 3487 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
| 3488 | if ( iScale == 4096 ) |
---|
| 3489 | { |
---|
| 3490 | rcMv = cMvPred; |
---|
| 3491 | } |
---|
| 3492 | else |
---|
| 3493 | { |
---|
| 3494 | rcMv = cMvPred.scaleMv( iScale ); |
---|
| 3495 | } |
---|
| 3496 | } |
---|
| 3497 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
| 3498 | return true; |
---|
| 3499 | } |
---|
| 3500 | } |
---|
| 3501 | //---------------------- V3(END) --------------------// |
---|
| 3502 | return false; |
---|
| 3503 | } |
---|
| 3504 | |
---|
| 3505 | /** |
---|
| 3506 | * \param eRefPicList |
---|
| 3507 | * \param uiCUAddr |
---|
| 3508 | * \param uiPartUnitIdx |
---|
| 3509 | * \param riRefIdx |
---|
| 3510 | * \returns Bool |
---|
| 3511 | */ |
---|
| 3512 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ) |
---|
| 3513 | { |
---|
| 3514 | UInt uiAbsPartAddr = uiPartUnitIdx; |
---|
| 3515 | |
---|
| 3516 | RefPicList eColRefPicList; |
---|
| 3517 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
---|
| 3518 | TComMv cColMv; |
---|
| 3519 | |
---|
| 3520 | // use coldir. |
---|
| 3521 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
| 3522 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
| 3523 | if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE) |
---|
| 3524 | { |
---|
| 3525 | return false; |
---|
| 3526 | } |
---|
| 3527 | iCurrPOC = m_pcSlice->getPOC(); |
---|
| 3528 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
| 3529 | iColPOC = pColCU->getSlice()->getPOC(); |
---|
| 3530 | |
---|
| 3531 | if (pColCU->isIntra(uiAbsPartAddr)) |
---|
| 3532 | { |
---|
| 3533 | return false; |
---|
| 3534 | } |
---|
| 3535 | eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
---|
| 3536 | |
---|
| 3537 | Int iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
| 3538 | |
---|
| 3539 | if (iColRefIdx < 0 ) |
---|
| 3540 | { |
---|
| 3541 | eColRefPicList = RefPicList(1 - eColRefPicList); |
---|
| 3542 | iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
| 3543 | |
---|
| 3544 | if (iColRefIdx < 0 ) |
---|
| 3545 | { |
---|
| 3546 | return false; |
---|
| 3547 | } |
---|
| 3548 | } |
---|
| 3549 | |
---|
| 3550 | // Scale the vector. |
---|
| 3551 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
---|
| 3552 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
| 3553 | |
---|
| 3554 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
| 3555 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
| 3556 | Bool bIsColRefLongTerm = pColCU->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
---|
| 3557 | |
---|
| 3558 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
| 3559 | { |
---|
| 3560 | return false; |
---|
| 3561 | } |
---|
| 3562 | |
---|
| 3563 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
---|
| 3564 | { |
---|
| 3565 | rcMv = cColMv; |
---|
| 3566 | } |
---|
| 3567 | else |
---|
| 3568 | { |
---|
| 3569 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
| 3570 | if ( iScale == 4096 ) |
---|
| 3571 | { |
---|
| 3572 | rcMv = cColMv; |
---|
| 3573 | } |
---|
| 3574 | else |
---|
| 3575 | { |
---|
| 3576 | rcMv = cColMv.scaleMv( iScale ); |
---|
| 3577 | } |
---|
| 3578 | } |
---|
| 3579 | return true; |
---|
| 3580 | } |
---|
| 3581 | |
---|
| 3582 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
---|
| 3583 | { |
---|
| 3584 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
---|
| 3585 | } |
---|
| 3586 | |
---|
| 3587 | UInt TComDataCU::xGetComponentBits(Int iVal) |
---|
| 3588 | { |
---|
| 3589 | UInt uiLength = 1; |
---|
| 3590 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
| 3591 | |
---|
| 3592 | assert ( uiTemp ); |
---|
| 3593 | |
---|
| 3594 | while ( 1 != uiTemp ) |
---|
| 3595 | { |
---|
| 3596 | uiTemp >>= 1; |
---|
| 3597 | uiLength += 2; |
---|
| 3598 | } |
---|
| 3599 | |
---|
| 3600 | return uiLength; |
---|
| 3601 | } |
---|
| 3602 | |
---|
| 3603 | |
---|
| 3604 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
| 3605 | { |
---|
| 3606 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
| 3607 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
| 3608 | |
---|
| 3609 | if( iDiffPocD == iDiffPocB ) |
---|
| 3610 | { |
---|
| 3611 | return 4096; |
---|
| 3612 | } |
---|
| 3613 | else |
---|
| 3614 | { |
---|
| 3615 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
| 3616 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
| 3617 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
| 3618 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
---|
| 3619 | return iScale; |
---|
| 3620 | } |
---|
| 3621 | } |
---|
| 3622 | |
---|
| 3623 | /** |
---|
| 3624 | * \param eCUMode |
---|
| 3625 | * \param uiPartIdx |
---|
| 3626 | * \param ruiPartIdxCenter |
---|
| 3627 | * \returns Void |
---|
| 3628 | */ |
---|
| 3629 | Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
---|
| 3630 | { |
---|
| 3631 | UInt uiPartAddr; |
---|
| 3632 | Int iPartWidth; |
---|
| 3633 | Int iPartHeight; |
---|
| 3634 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
| 3635 | |
---|
| 3636 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
---|
| 3637 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
| 3638 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInWidth() |
---|
| 3639 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
---|
| 3640 | } |
---|
| 3641 | |
---|
| 3642 | Void TComDataCU::compressMV() |
---|
| 3643 | { |
---|
| 3644 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
| 3645 | if (scaleFactor > 0) |
---|
| 3646 | { |
---|
| 3647 | #if SVC_MVP |
---|
| 3648 | m_acCUMvField[0].compress(m_pePredMode, m_puhInterDir, scaleFactor); |
---|
| 3649 | m_acCUMvField[1].compress(m_pePredMode, m_puhInterDir, scaleFactor); |
---|
| 3650 | #else |
---|
| 3651 | m_acCUMvField[0].compress(m_pePredMode, scaleFactor); |
---|
| 3652 | m_acCUMvField[1].compress(m_pePredMode, scaleFactor); |
---|
| 3653 | #endif |
---|
| 3654 | } |
---|
| 3655 | } |
---|
| 3656 | |
---|
| 3657 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
---|
| 3658 | { |
---|
| 3659 | UInt uiCTXIdx; |
---|
| 3660 | UInt uiScanIdx; |
---|
| 3661 | UInt uiDirMode; |
---|
| 3662 | |
---|
| 3663 | if ( !bIsIntra ) |
---|
| 3664 | { |
---|
| 3665 | uiScanIdx = SCAN_DIAG; |
---|
| 3666 | return uiScanIdx; |
---|
| 3667 | } |
---|
| 3668 | |
---|
| 3669 | switch(uiWidth) |
---|
| 3670 | { |
---|
| 3671 | case 2: uiCTXIdx = 6; break; |
---|
| 3672 | case 4: uiCTXIdx = 5; break; |
---|
| 3673 | case 8: uiCTXIdx = 4; break; |
---|
| 3674 | case 16: uiCTXIdx = 3; break; |
---|
| 3675 | case 32: uiCTXIdx = 2; break; |
---|
| 3676 | case 64: uiCTXIdx = 1; break; |
---|
| 3677 | default: uiCTXIdx = 0; break; |
---|
| 3678 | } |
---|
| 3679 | |
---|
| 3680 | if ( bIsLuma ) |
---|
| 3681 | { |
---|
| 3682 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
| 3683 | uiScanIdx = SCAN_DIAG; |
---|
| 3684 | if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size |
---|
| 3685 | { |
---|
| 3686 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
---|
| 3687 | } |
---|
| 3688 | } |
---|
| 3689 | else |
---|
| 3690 | { |
---|
| 3691 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
---|
| 3692 | if( uiDirMode == DM_CHROMA_IDX ) |
---|
| 3693 | { |
---|
| 3694 | // get number of partitions in current CU |
---|
| 3695 | UInt depth = getDepth(uiAbsPartIdx); |
---|
| 3696 | UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); |
---|
| 3697 | |
---|
| 3698 | // get luma mode from upper-left corner of current CU |
---|
| 3699 | uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); |
---|
| 3700 | } |
---|
| 3701 | uiScanIdx = SCAN_DIAG; |
---|
| 3702 | if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size |
---|
| 3703 | { |
---|
| 3704 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
---|
| 3705 | } |
---|
| 3706 | } |
---|
| 3707 | |
---|
| 3708 | return uiScanIdx; |
---|
| 3709 | } |
---|
| 3710 | |
---|
| 3711 | UInt TComDataCU::getSCUAddr() |
---|
| 3712 | { |
---|
| 3713 | return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; |
---|
| 3714 | } |
---|
| 3715 | |
---|
| 3716 | /** Set neighboring blocks availabilities for non-deblocked filtering |
---|
| 3717 | * \param numLCUInPicWidth number of LCUs in picture width |
---|
| 3718 | * \param numLCUInPicHeight number of LCUs in picture height |
---|
| 3719 | * \param numSUInLCUWidth number of SUs in LCU width |
---|
| 3720 | * \param numSUInLCUHeight number of SUs in LCU height |
---|
| 3721 | * \param picWidth picture width |
---|
| 3722 | * \param picHeight picture height |
---|
| 3723 | * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled |
---|
| 3724 | * \param bTopTileBoundary true means that top boundary coincides tile boundary |
---|
| 3725 | * \param bDownTileBoundary true means that bottom boundary coincides tile boundary |
---|
| 3726 | * \param bLeftTileBoundary true means that left boundary coincides tile boundary |
---|
| 3727 | * \param bRightTileBoundary true means that right boundary coincides tile boundary |
---|
| 3728 | * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled |
---|
| 3729 | */ |
---|
| 3730 | Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt /*numLCUInPicHeight*/, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight |
---|
| 3731 | ,std::vector<Bool>& LFCrossSliceBoundary |
---|
| 3732 | ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary |
---|
| 3733 | ,Bool bIndependentTileBoundaryEnabled) |
---|
| 3734 | { |
---|
| 3735 | UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight; |
---|
| 3736 | Int* pSliceIDMapLCU = m_piSliceSUMap; |
---|
| 3737 | Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1); |
---|
| 3738 | UInt uiLPelX, uiTPelY; |
---|
| 3739 | UInt width, height; |
---|
| 3740 | Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary; |
---|
| 3741 | Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false; |
---|
| 3742 | Bool* pbAvailBorder; |
---|
| 3743 | Bool* pbAvail; |
---|
| 3744 | UInt rTLSU, rBRSU, widthSU, heightSU; |
---|
| 3745 | UInt zRefSU; |
---|
| 3746 | Int* pRefID; |
---|
| 3747 | Int* pRefMapLCU; |
---|
| 3748 | UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0; |
---|
| 3749 | Int* pRRefMapLCU= NULL; |
---|
| 3750 | Int* pLRefMapLCU= NULL; |
---|
| 3751 | Int* pTRefMapLCU= NULL; |
---|
| 3752 | Int* pBRefMapLCU= NULL; |
---|
| 3753 | Int sliceID; |
---|
| 3754 | UInt numSGU = (UInt)m_vNDFBlock.size(); |
---|
| 3755 | |
---|
| 3756 | for(Int i=0; i< numSGU; i++) |
---|
| 3757 | { |
---|
| 3758 | NDBFBlockInfo& rSGU = m_vNDFBlock[i]; |
---|
| 3759 | |
---|
| 3760 | sliceID = rSGU.sliceID; |
---|
| 3761 | uiLPelX = rSGU.posX; |
---|
| 3762 | uiTPelY = rSGU.posY; |
---|
| 3763 | width = rSGU.width; |
---|
| 3764 | height = rSGU.height; |
---|
| 3765 | rTLSU = g_auiZscanToRaster[ rSGU.startSU ]; |
---|
| 3766 | rBRSU = g_auiZscanToRaster[ rSGU.endSU ]; |
---|
| 3767 | widthSU = rSGU.widthSU; |
---|
| 3768 | heightSU = rSGU.heightSU; |
---|
| 3769 | |
---|
| 3770 | pbAvailBorder = rSGU.isBorderAvailable; |
---|
| 3771 | |
---|
| 3772 | bPicTBoundary= (uiTPelY == 0 )?(true):(false); |
---|
| 3773 | bPicLBoundary= (uiLPelX == 0 )?(true):(false); |
---|
| 3774 | bPicRBoundary= (!(uiLPelX+ width < picWidth ) )?(true):(false); |
---|
| 3775 | bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false); |
---|
| 3776 | |
---|
| 3777 | bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false); |
---|
| 3778 | bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false); |
---|
| 3779 | bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false); |
---|
| 3780 | bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false); |
---|
| 3781 | |
---|
| 3782 | // SGU_L |
---|
| 3783 | pbAvail = &(pbAvailBorder[SGU_L]); |
---|
| 3784 | if(bPicLBoundary) |
---|
| 3785 | { |
---|
| 3786 | *pbAvail = false; |
---|
| 3787 | } |
---|
| 3788 | else if (onlyOneSliceInPic) |
---|
| 3789 | { |
---|
| 3790 | *pbAvail = true; |
---|
| 3791 | } |
---|
| 3792 | else |
---|
| 3793 | { |
---|
| 3794 | // bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
| 3795 | if(bLCULBoundary) |
---|
| 3796 | { |
---|
| 3797 | rLRefSU = rTLSU + numSUInLCUWidth -1; |
---|
| 3798 | zRefSU = g_auiRasterToZscan[rLRefSU]; |
---|
| 3799 | pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU); |
---|
| 3800 | } |
---|
| 3801 | else |
---|
| 3802 | { |
---|
| 3803 | zRefSU = g_auiRasterToZscan[rTLSU - 1]; |
---|
| 3804 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3805 | } |
---|
| 3806 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3807 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3808 | } |
---|
| 3809 | |
---|
| 3810 | // SGU_R |
---|
| 3811 | pbAvail = &(pbAvailBorder[SGU_R]); |
---|
| 3812 | if(bPicRBoundary) |
---|
| 3813 | { |
---|
| 3814 | *pbAvail = false; |
---|
| 3815 | } |
---|
| 3816 | else if (onlyOneSliceInPic) |
---|
| 3817 | { |
---|
| 3818 | *pbAvail = true; |
---|
| 3819 | } |
---|
| 3820 | else |
---|
| 3821 | { |
---|
| 3822 | // bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
| 3823 | if(bLCURBoundary) |
---|
| 3824 | { |
---|
| 3825 | rRRefSU = rTLSU + widthSU - numSUInLCUWidth; |
---|
| 3826 | zRefSU = g_auiRasterToZscan[rRRefSU]; |
---|
| 3827 | pRefMapLCU = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU); |
---|
| 3828 | } |
---|
| 3829 | else |
---|
| 3830 | { |
---|
| 3831 | zRefSU = g_auiRasterToZscan[rTLSU + widthSU]; |
---|
| 3832 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3833 | } |
---|
| 3834 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3835 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3836 | } |
---|
| 3837 | |
---|
| 3838 | // SGU_T |
---|
| 3839 | pbAvail = &(pbAvailBorder[SGU_T]); |
---|
| 3840 | if(bPicTBoundary) |
---|
| 3841 | { |
---|
| 3842 | *pbAvail = false; |
---|
| 3843 | } |
---|
| 3844 | else if (onlyOneSliceInPic) |
---|
| 3845 | { |
---|
| 3846 | *pbAvail = true; |
---|
| 3847 | } |
---|
| 3848 | else |
---|
| 3849 | { |
---|
| 3850 | // bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false); |
---|
| 3851 | if(bLCUTBoundary) |
---|
| 3852 | { |
---|
| 3853 | rTRefSU = numSUInLCU - (numSUInLCUWidth - rTLSU); |
---|
| 3854 | zRefSU = g_auiRasterToZscan[rTRefSU]; |
---|
| 3855 | pRefMapLCU = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU)); |
---|
| 3856 | } |
---|
| 3857 | else |
---|
| 3858 | { |
---|
| 3859 | zRefSU = g_auiRasterToZscan[rTLSU - numSUInLCUWidth]; |
---|
| 3860 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3861 | } |
---|
| 3862 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3863 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3864 | } |
---|
| 3865 | |
---|
| 3866 | // SGU_B |
---|
| 3867 | pbAvail = &(pbAvailBorder[SGU_B]); |
---|
| 3868 | if(bPicBBoundary) |
---|
| 3869 | { |
---|
| 3870 | *pbAvail = false; |
---|
| 3871 | } |
---|
| 3872 | else if (onlyOneSliceInPic) |
---|
| 3873 | { |
---|
| 3874 | *pbAvail = true; |
---|
| 3875 | } |
---|
| 3876 | else |
---|
| 3877 | { |
---|
| 3878 | // bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false); |
---|
| 3879 | if(bLCUBBoundary) |
---|
| 3880 | { |
---|
| 3881 | rBRefSU = rTLSU % numSUInLCUWidth; |
---|
| 3882 | zRefSU = g_auiRasterToZscan[rBRefSU]; |
---|
| 3883 | pRefMapLCU = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU)); |
---|
| 3884 | } |
---|
| 3885 | else |
---|
| 3886 | { |
---|
| 3887 | zRefSU = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)]; |
---|
| 3888 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3889 | } |
---|
| 3890 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3891 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3892 | } |
---|
| 3893 | |
---|
| 3894 | // SGU_TL |
---|
| 3895 | pbAvail = &(pbAvailBorder[SGU_TL]); |
---|
| 3896 | if(bPicTBoundary || bPicLBoundary) |
---|
| 3897 | { |
---|
| 3898 | *pbAvail = false; |
---|
| 3899 | } |
---|
| 3900 | else if (onlyOneSliceInPic) |
---|
| 3901 | { |
---|
| 3902 | *pbAvail = true; |
---|
| 3903 | } |
---|
| 3904 | else |
---|
| 3905 | { |
---|
| 3906 | if(bLCUTBoundary && bLCULBoundary) |
---|
| 3907 | { |
---|
| 3908 | zRefSU = numSUInLCU -1; |
---|
| 3909 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
| 3910 | } |
---|
| 3911 | else if(bLCUTBoundary) |
---|
| 3912 | { |
---|
| 3913 | zRefSU = g_auiRasterToZscan[ rTRefSU- 1]; |
---|
| 3914 | pRefMapLCU = pTRefMapLCU; |
---|
| 3915 | } |
---|
| 3916 | else if(bLCULBoundary) |
---|
| 3917 | { |
---|
| 3918 | zRefSU = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ]; |
---|
| 3919 | pRefMapLCU = pLRefMapLCU; |
---|
| 3920 | } |
---|
| 3921 | else //inside LCU |
---|
| 3922 | { |
---|
| 3923 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1]; |
---|
| 3924 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3925 | } |
---|
| 3926 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3927 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3928 | } |
---|
| 3929 | |
---|
| 3930 | // SGU_TR |
---|
| 3931 | pbAvail = &(pbAvailBorder[SGU_TR]); |
---|
| 3932 | if(bPicTBoundary || bPicRBoundary) |
---|
| 3933 | { |
---|
| 3934 | *pbAvail = false; |
---|
| 3935 | } |
---|
| 3936 | else if (onlyOneSliceInPic) |
---|
| 3937 | { |
---|
| 3938 | *pbAvail = true; |
---|
| 3939 | } |
---|
| 3940 | else |
---|
| 3941 | { |
---|
| 3942 | if(bLCUTBoundary && bLCURBoundary) |
---|
| 3943 | { |
---|
| 3944 | zRefSU = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth]; |
---|
| 3945 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
| 3946 | } |
---|
| 3947 | else if(bLCUTBoundary) |
---|
| 3948 | { |
---|
| 3949 | zRefSU = g_auiRasterToZscan[ rTRefSU+ widthSU]; |
---|
| 3950 | pRefMapLCU = pTRefMapLCU; |
---|
| 3951 | } |
---|
| 3952 | else if(bLCURBoundary) |
---|
| 3953 | { |
---|
| 3954 | zRefSU = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ]; |
---|
| 3955 | pRefMapLCU = pRRefMapLCU; |
---|
| 3956 | } |
---|
| 3957 | else //inside LCU |
---|
| 3958 | { |
---|
| 3959 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU]; |
---|
| 3960 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3961 | } |
---|
| 3962 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3963 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3964 | } |
---|
| 3965 | |
---|
| 3966 | // SGU_BL |
---|
| 3967 | pbAvail = &(pbAvailBorder[SGU_BL]); |
---|
| 3968 | if(bPicBBoundary || bPicLBoundary) |
---|
| 3969 | { |
---|
| 3970 | *pbAvail = false; |
---|
| 3971 | } |
---|
| 3972 | else if (onlyOneSliceInPic) |
---|
| 3973 | { |
---|
| 3974 | *pbAvail = true; |
---|
| 3975 | } |
---|
| 3976 | else |
---|
| 3977 | { |
---|
| 3978 | if(bLCUBBoundary && bLCULBoundary) |
---|
| 3979 | { |
---|
| 3980 | zRefSU = g_auiRasterToZscan[numSUInLCUWidth - 1]; |
---|
| 3981 | pRefMapLCU = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
| 3982 | } |
---|
| 3983 | else if(bLCUBBoundary) |
---|
| 3984 | { |
---|
| 3985 | zRefSU = g_auiRasterToZscan[ rBRefSU - 1]; |
---|
| 3986 | pRefMapLCU = pBRefMapLCU; |
---|
| 3987 | } |
---|
| 3988 | else if(bLCULBoundary) |
---|
| 3989 | { |
---|
| 3990 | zRefSU = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ]; |
---|
| 3991 | pRefMapLCU = pLRefMapLCU; |
---|
| 3992 | } |
---|
| 3993 | else //inside LCU |
---|
| 3994 | { |
---|
| 3995 | zRefSU = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1]; |
---|
| 3996 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3997 | } |
---|
| 3998 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3999 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 4000 | } |
---|
| 4001 | |
---|
| 4002 | // SGU_BR |
---|
| 4003 | pbAvail = &(pbAvailBorder[SGU_BR]); |
---|
| 4004 | if(bPicBBoundary || bPicRBoundary) |
---|
| 4005 | { |
---|
| 4006 | *pbAvail = false; |
---|
| 4007 | } |
---|
| 4008 | else if (onlyOneSliceInPic) |
---|
| 4009 | { |
---|
| 4010 | *pbAvail = true; |
---|
| 4011 | } |
---|
| 4012 | else |
---|
| 4013 | { |
---|
| 4014 | if(bLCUBBoundary && bLCURBoundary) |
---|
| 4015 | { |
---|
| 4016 | zRefSU = 0; |
---|
| 4017 | pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
| 4018 | } |
---|
| 4019 | else if(bLCUBBoundary) |
---|
| 4020 | { |
---|
| 4021 | zRefSU = g_auiRasterToZscan[ rBRefSU + widthSU]; |
---|
| 4022 | pRefMapLCU = pBRefMapLCU; |
---|
| 4023 | } |
---|
| 4024 | else if(bLCURBoundary) |
---|
| 4025 | { |
---|
| 4026 | zRefSU = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)]; |
---|
| 4027 | pRefMapLCU = pRRefMapLCU; |
---|
| 4028 | } |
---|
| 4029 | else //inside LCU |
---|
| 4030 | { |
---|
| 4031 | zRefSU = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU]; |
---|
| 4032 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 4033 | } |
---|
| 4034 | pRefID = pRefMapLCU + zRefSU; |
---|
| 4035 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 4036 | } |
---|
| 4037 | |
---|
| 4038 | if(bIndependentTileBoundaryEnabled) |
---|
| 4039 | { |
---|
| 4040 | //left LCU boundary |
---|
| 4041 | if(!bPicLBoundary && bLCULBoundary) |
---|
| 4042 | { |
---|
| 4043 | if(bLeftTileBoundary) |
---|
| 4044 | { |
---|
| 4045 | pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false; |
---|
| 4046 | } |
---|
| 4047 | } |
---|
| 4048 | //right LCU boundary |
---|
| 4049 | if(!bPicRBoundary && bLCURBoundary) |
---|
| 4050 | { |
---|
| 4051 | if(bRightTileBoundary) |
---|
| 4052 | { |
---|
| 4053 | pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false; |
---|
| 4054 | } |
---|
| 4055 | } |
---|
| 4056 | //top LCU boundary |
---|
| 4057 | if(!bPicTBoundary && bLCUTBoundary) |
---|
| 4058 | { |
---|
| 4059 | if(bTopTileBoundary) |
---|
| 4060 | { |
---|
| 4061 | pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false; |
---|
| 4062 | } |
---|
| 4063 | } |
---|
| 4064 | //down LCU boundary |
---|
| 4065 | if(!bPicBBoundary && bLCUBBoundary) |
---|
| 4066 | { |
---|
| 4067 | if(bDownTileBoundary) |
---|
| 4068 | { |
---|
| 4069 | pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false; |
---|
| 4070 | } |
---|
| 4071 | } |
---|
| 4072 | } |
---|
| 4073 | rSGU.allBordersAvailable = true; |
---|
| 4074 | for(Int b=0; b< NUM_SGU_BORDER; b++) |
---|
| 4075 | { |
---|
| 4076 | if(pbAvailBorder[b] == false) |
---|
| 4077 | { |
---|
| 4078 | rSGU.allBordersAvailable = false; |
---|
| 4079 | break; |
---|
| 4080 | } |
---|
| 4081 | } |
---|
| 4082 | } |
---|
| 4083 | } |
---|
| 4084 | |
---|
| 4085 | #if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED |
---|
| 4086 | Void TComDataCU::getBaseLumaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride ) |
---|
| 4087 | { |
---|
| 4088 | TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec(); |
---|
| 4089 | UInt uiStrideBase = pcBaseRec->getStride(); |
---|
| 4090 | Pel* piBase = pcBaseRec->getLumaAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 4091 | |
---|
| 4092 | for ( UInt y = 0; y < uiHeight; y ++ ) |
---|
| 4093 | { |
---|
| 4094 | memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) ); |
---|
| 4095 | } |
---|
| 4096 | } |
---|
| 4097 | |
---|
| 4098 | Void TComDataCU::getBaseChromaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, UInt uiChromaId ) |
---|
| 4099 | { |
---|
| 4100 | TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec(); |
---|
| 4101 | |
---|
| 4102 | UInt uiStrideBase = pcBaseRec->getCStride(); |
---|
| 4103 | Pel* piBase; |
---|
| 4104 | |
---|
| 4105 | if( uiChromaId == 0 ) |
---|
| 4106 | { |
---|
| 4107 | piBase = pcBaseRec->getCbAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 4108 | } |
---|
| 4109 | else |
---|
| 4110 | { |
---|
| 4111 | piBase = pcBaseRec->getCrAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 4112 | } |
---|
| 4113 | |
---|
| 4114 | for ( UInt y = 0; y < uiHeight; y ++ ) |
---|
| 4115 | { |
---|
| 4116 | memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) ); |
---|
| 4117 | } |
---|
| 4118 | } |
---|
| 4119 | |
---|
| 4120 | #endif |
---|
| 4121 | |
---|
| 4122 | #if SVC_COL_BLK |
---|
| 4123 | TComDataCU* TComDataCU::getBaseColCU( UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase ) |
---|
| 4124 | { |
---|
| 4125 | #if 1 // it should provide identical resutls |
---|
| 4126 | UInt uiPelX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiCuAbsPartIdx] ]; |
---|
| 4127 | UInt uiPelY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiCuAbsPartIdx] ]; |
---|
| 4128 | |
---|
| 4129 | return getBaseColCU( uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase ); |
---|
| 4130 | #else |
---|
| 4131 | TComPic* cBaseColPic = m_pcSlice->getBaseColPic(); |
---|
| 4132 | |
---|
| 4133 | #if SVC_UPSAMPLING |
---|
| 4134 | Int widthBL = cBaseColPic->getPicYuvRec()->getWidth () - cBaseColPic->getPicYuvRec()->getPicCropLeftOffset() - cBaseColPic->getPicYuvRec()->getPicCropRightOffset(); |
---|
| 4135 | Int heightBL = cBaseColPic->getPicYuvRec()->getHeight() - cBaseColPic->getPicYuvRec()->getPicCropTopOffset() - cBaseColPic->getPicYuvRec()->getPicCropBottomOffset(); |
---|
| 4136 | |
---|
| 4137 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth() - m_pcPic->getPicYuvRec()->getPicCropLeftOffset() - m_pcPic->getPicYuvRec()->getPicCropRightOffset(); |
---|
| 4138 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight() - m_pcPic->getPicYuvRec()->getPicCropTopOffset() - m_pcPic->getPicYuvRec()->getPicCropBottomOffset(); |
---|
| 4139 | #else |
---|
| 4140 | Int widthBL = cBaseColPic->getPicYuvRec()->getWidth(); |
---|
| 4141 | Int heightBL = cBaseColPic->getPicYuvRec()->getHeight(); |
---|
| 4142 | |
---|
| 4143 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth(); |
---|
| 4144 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight(); |
---|
| 4145 | #endif |
---|
| 4146 | |
---|
| 4147 | if (widthBL == widthEL && heightEL == heightBL) |
---|
| 4148 | { |
---|
| 4149 | uiAbsPartIdxBase = uiCuAbsPartIdx + m_uiAbsIdxInLCU; |
---|
| 4150 | uiCUAddrBase = m_uiCUAddr; |
---|
| 4151 | } |
---|
| 4152 | else |
---|
| 4153 | { |
---|
| 4154 | UInt uiMinUnitSize = m_pcPic->getMinCUWidth(); |
---|
| 4155 | UInt uiRasterAddr = g_auiZscanToRaster[uiCuAbsPartIdx]; |
---|
| 4156 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 4157 | |
---|
| 4158 | Int iEX = m_uiCUPelX + uiMinUnitSize*(uiRasterAddr%uiNumPartInCUWidth); |
---|
| 4159 | Int iEY = m_uiCUPelY + uiMinUnitSize*(uiRasterAddr/uiNumPartInCUWidth); |
---|
| 4160 | |
---|
| 4161 | Int iBX = (iEX*widthBL + widthEL/2)/widthEL; |
---|
| 4162 | Int iBY = (iEY*heightBL+ heightEL/2)/heightEL; |
---|
| 4163 | |
---|
| 4164 | uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth); |
---|
| 4165 | |
---|
| 4166 | assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame()); |
---|
| 4167 | |
---|
| 4168 | UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth() |
---|
| 4169 | + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize; |
---|
| 4170 | |
---|
| 4171 | uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase]; |
---|
| 4172 | } |
---|
| 4173 | |
---|
| 4174 | return cBaseColPic->getCU(uiCUAddrBase); |
---|
| 4175 | #endif |
---|
| 4176 | } |
---|
| 4177 | |
---|
| 4178 | TComDataCU* TComDataCU::getBaseColCU( UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase ) |
---|
| 4179 | { |
---|
| 4180 | TComPic* cBaseColPic = m_pcSlice->getBaseColPic(); |
---|
| 4181 | |
---|
[137] | 4182 | #if !SIMPLIFIED_MV_POS_SCALING |
---|
[144] | 4183 | #if SVC_UPSAMPLING && !ILP_DECODED_PICTURE |
---|
[125] | 4184 | const Window &confBL = cBaseColPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 4185 | const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 4186 | |
---|
| 4187 | Int widthBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
| 4188 | Int heightBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
| 4189 | |
---|
| 4190 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); |
---|
| 4191 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); |
---|
| 4192 | #else |
---|
| 4193 | Int widthBL = cBaseColPic->getPicYuvRec()->getWidth(); |
---|
| 4194 | Int heightBL = cBaseColPic->getPicYuvRec()->getHeight(); |
---|
| 4195 | |
---|
| 4196 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth(); |
---|
| 4197 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight(); |
---|
| 4198 | #endif |
---|
[137] | 4199 | #endif |
---|
[125] | 4200 | |
---|
| 4201 | uiPelX = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getWidth() - 1, uiPelX); |
---|
| 4202 | uiPelY = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getHeight() - 1, uiPelY); |
---|
| 4203 | |
---|
| 4204 | UInt uiMinUnitSize = m_pcPic->getMinCUWidth(); |
---|
| 4205 | |
---|
[137] | 4206 | #if SIMPLIFIED_MV_POS_SCALING |
---|
[175] | 4207 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 4208 | Int leftStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowLeftOffset(); |
---|
| 4209 | Int topStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowTopOffset(); |
---|
| 4210 | Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16; |
---|
| 4211 | Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16; |
---|
| 4212 | #else |
---|
[137] | 4213 | Int iBX = (uiPelX*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16; |
---|
| 4214 | Int iBY = (uiPelY*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16; |
---|
[175] | 4215 | #endif |
---|
[137] | 4216 | #else |
---|
[125] | 4217 | Int iBX = (uiPelX*widthBL + widthEL/2)/widthEL; |
---|
| 4218 | Int iBY = (uiPelY*heightBL+ heightEL/2)/heightEL; |
---|
[137] | 4219 | #endif |
---|
[125] | 4220 | |
---|
[175] | 4221 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 4222 | if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight() || |
---|
| 4223 | iBX < 0 || iBY < 0 ) |
---|
| 4224 | #else |
---|
[125] | 4225 | if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight()) |
---|
[175] | 4226 | #endif |
---|
[125] | 4227 | { |
---|
| 4228 | return NULL; |
---|
| 4229 | } |
---|
| 4230 | |
---|
[144] | 4231 | #if AVC_SYNTAX && !ILP_DECODED_PICTURE |
---|
[150] | 4232 | #if !ILP_DECODED_PICTURE |
---|
| 4233 | const Window &confBL = cBaseColPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 4234 | const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 4235 | |
---|
| 4236 | Int widthBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
| 4237 | Int heightBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
| 4238 | #endif |
---|
[125] | 4239 | if( iBX >= widthBL || iBY >= heightBL ) //outside of the reference layer cropped picture |
---|
| 4240 | { |
---|
| 4241 | return NULL; |
---|
| 4242 | } |
---|
| 4243 | #endif |
---|
| 4244 | |
---|
| 4245 | uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth); |
---|
| 4246 | |
---|
| 4247 | assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame()); |
---|
| 4248 | |
---|
| 4249 | UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth() |
---|
| 4250 | + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize; |
---|
| 4251 | |
---|
| 4252 | uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase]; |
---|
| 4253 | |
---|
| 4254 | return cBaseColPic->getCU(uiCUAddrBase); |
---|
| 4255 | } |
---|
| 4256 | |
---|
| 4257 | Void TComDataCU::scaleBaseMV( TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase ) |
---|
| 4258 | { |
---|
| 4259 | TComMvField cMvFieldBase; |
---|
| 4260 | TComMv cMv; |
---|
[137] | 4261 | #if SIMPLIFIED_MV_POS_SCALING |
---|
| 4262 | cMv = rcMvFieldBase.getMv().scaleMv( g_mvScalingFactor[m_layerId][0], g_mvScalingFactor[m_layerId][1] ); |
---|
| 4263 | #else |
---|
[125] | 4264 | const Window &confBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow(); |
---|
| 4265 | const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 4266 | |
---|
| 4267 | Int widthBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
| 4268 | Int heightBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
| 4269 | |
---|
| 4270 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); |
---|
| 4271 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); |
---|
| 4272 | |
---|
| 4273 | Int iMvX = (rcMvFieldBase.getHor()*widthEL + (widthBL/2 -1) * (rcMvFieldBase.getHor() > 0 ? 1: -1) )/widthBL; |
---|
| 4274 | Int iMvY = (rcMvFieldBase.getVer()*heightEL + (heightBL/2 -1) * (rcMvFieldBase.getVer() > 0 ? 1: -1) )/heightBL; |
---|
| 4275 | |
---|
| 4276 | cMv.set(iMvX, iMvY); |
---|
[137] | 4277 | #endif |
---|
[125] | 4278 | |
---|
| 4279 | rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() ); |
---|
| 4280 | } |
---|
| 4281 | #endif |
---|
| 4282 | |
---|
| 4283 | #if SVC_MVP |
---|
| 4284 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, UChar uchInterDir, TComMvField* pcMvField ) |
---|
| 4285 | { |
---|
| 4286 | if ( getInterDir( uiAbsPartIdx ) != uchInterDir ) |
---|
| 4287 | { |
---|
| 4288 | return false; |
---|
| 4289 | } |
---|
| 4290 | |
---|
| 4291 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 4292 | { |
---|
| 4293 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
| 4294 | { |
---|
| 4295 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getMv() || |
---|
| 4296 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getRefIdx() ) |
---|
| 4297 | { |
---|
| 4298 | return false; |
---|
| 4299 | } |
---|
| 4300 | } |
---|
| 4301 | } |
---|
| 4302 | |
---|
| 4303 | return true; |
---|
| 4304 | } |
---|
| 4305 | #endif |
---|
| 4306 | |
---|
| 4307 | //! \} |
---|