[210] | 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; |
---|
[212] | 1649 | |
---|
[210] | 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 | |
---|
[212] | 1741 | |
---|
| 1742 | #if FAST_INTRA_SHVC |
---|
| 1743 | /** generate limited set of remaining modes |
---|
| 1744 | *\param uiAbsPartIdx |
---|
| 1745 | *\param uiIntraDirPred pointer to the array for MPM storage |
---|
| 1746 | *\returns Number of intra coding modes (nb of remaining modes + 3 MPMs) |
---|
| 1747 | */ |
---|
| 1748 | Int TComDataCU::reduceSetOfIntraModes( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int &fullSetOfModes ) |
---|
| 1749 | { |
---|
| 1750 | // check BL mode |
---|
| 1751 | UInt uiCUAddrBase, uiAbsPartAddrBase; |
---|
[262] | 1752 | // the right reference layerIdc should be specified, currently it is set to m_layerId-1 |
---|
| 1753 | TComDataCU* pcTempCU = getBaseColCU(m_layerId - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase ); |
---|
[212] | 1754 | |
---|
| 1755 | if( pcTempCU->getPredictionMode( uiAbsPartAddrBase ) != MODE_INTRA ) |
---|
[253] | 1756 | { |
---|
[212] | 1757 | return( NUM_INTRA_MODE-1 ); |
---|
[253] | 1758 | } |
---|
[212] | 1759 | |
---|
| 1760 | // compute set of enabled modes g_reducedSetIntraModes[...] |
---|
| 1761 | Int authorizedMode[NUM_INTRA_MODE-1]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; |
---|
| 1762 | Int nbModes; |
---|
| 1763 | for (nbModes=0; nbModes<3; nbModes++) // add 3 MPMs 1st |
---|
| 1764 | { |
---|
| 1765 | g_reducedSetIntraModes[nbModes] = uiIntraDirPred[nbModes]; |
---|
| 1766 | authorizedMode[ uiIntraDirPred[nbModes] ] = 0; |
---|
| 1767 | } |
---|
| 1768 | |
---|
| 1769 | Int iColBaseDir = pcTempCU->getLumaIntraDir( uiAbsPartAddrBase ); |
---|
| 1770 | if ( authorizedMode[iColBaseDir] ) //possibly add BL mode |
---|
| 1771 | { |
---|
| 1772 | g_reducedSetIntraModes[nbModes++] = iColBaseDir; |
---|
| 1773 | authorizedMode[ iColBaseDir ] = 0; |
---|
| 1774 | } |
---|
| 1775 | |
---|
| 1776 | Int iRefMode = ( iColBaseDir > 1 ) ? iColBaseDir : uiIntraDirPred[0]; |
---|
| 1777 | if ( iRefMode > 1 ) //add neighboring modes of refMode |
---|
| 1778 | { |
---|
| 1779 | UInt Left = iRefMode; |
---|
| 1780 | UInt Right = iRefMode; |
---|
| 1781 | while ( nbModes < NB_REMAIN_MODES+3 ) |
---|
| 1782 | { |
---|
| 1783 | Left = ((Left + 29) % 32) + 2; |
---|
| 1784 | Right = ((Right - 1 ) % 32) + 2; |
---|
| 1785 | if ( authorizedMode[Left] ) g_reducedSetIntraModes[nbModes++] = Left; |
---|
| 1786 | if ( authorizedMode[Right] ) g_reducedSetIntraModes[nbModes++] = Right; |
---|
| 1787 | } |
---|
| 1788 | } |
---|
| 1789 | else //add pre-defined modes |
---|
| 1790 | { |
---|
| 1791 | Int idx = 0; |
---|
| 1792 | while ( nbModes < NB_REMAIN_MODES+3 ) |
---|
| 1793 | { |
---|
| 1794 | UInt mode = g_predefSetIntraModes[idx++]; |
---|
| 1795 | if ( authorizedMode[mode] ) g_reducedSetIntraModes[nbModes++] = mode; |
---|
| 1796 | } |
---|
| 1797 | } |
---|
| 1798 | |
---|
| 1799 | fullSetOfModes = 0; |
---|
| 1800 | return ( nbModes ); |
---|
| 1801 | } |
---|
| 1802 | #endif |
---|
| 1803 | |
---|
| 1804 | |
---|
[210] | 1805 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1806 | { |
---|
| 1807 | TComDataCU* pcTempCU; |
---|
| 1808 | UInt uiTempPartIdx; |
---|
| 1809 | UInt uiCtx; |
---|
| 1810 | // Get left split flag |
---|
| 1811 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1812 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
| 1813 | |
---|
| 1814 | // Get above split flag |
---|
| 1815 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1816 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
---|
| 1817 | |
---|
| 1818 | return uiCtx; |
---|
| 1819 | } |
---|
| 1820 | |
---|
| 1821 | UInt TComDataCU::getCtxQtCbf( TextType eType, UInt uiTrDepth ) |
---|
| 1822 | { |
---|
| 1823 | if( eType ) |
---|
| 1824 | { |
---|
| 1825 | return uiTrDepth; |
---|
| 1826 | } |
---|
| 1827 | else |
---|
| 1828 | { |
---|
| 1829 | const UInt uiCtx = ( uiTrDepth == 0 ? 1 : 0 ); |
---|
| 1830 | return uiCtx; |
---|
| 1831 | } |
---|
| 1832 | } |
---|
| 1833 | |
---|
| 1834 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) |
---|
| 1835 | { |
---|
| 1836 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
---|
| 1837 | PartSize partSize = getPartitionSize( absPartIdx ); |
---|
| 1838 | #if INTRA_BL |
---|
| 1839 | UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
| 1840 | #else |
---|
| 1841 | UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
---|
| 1842 | #endif |
---|
| 1843 | Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0; |
---|
| 1844 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) ); |
---|
| 1845 | |
---|
| 1846 | UInt log2MinTUSizeInCU = 0; |
---|
| 1847 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
---|
| 1848 | { |
---|
| 1849 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
---|
| 1850 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
---|
| 1851 | } |
---|
| 1852 | else |
---|
| 1853 | { |
---|
| 1854 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
---|
| 1855 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
---|
| 1856 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
---|
| 1857 | { |
---|
| 1858 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
---|
| 1859 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
| 1860 | } |
---|
| 1861 | } |
---|
| 1862 | return log2MinTUSizeInCU; |
---|
| 1863 | } |
---|
| 1864 | |
---|
| 1865 | #if INTRA_BL |
---|
| 1866 | UInt TComDataCU::getCtxIntraBLFlag( UInt uiAbsPartIdx ) |
---|
| 1867 | { |
---|
| 1868 | #if INTRA_BL_CTX_CHANGE |
---|
| 1869 | Int cuDepth = getDepth(uiAbsPartIdx); |
---|
| 1870 | Int maxCuDepth = g_uiMaxCUDepth - g_uiAddCUDepth; |
---|
| 1871 | UInt uiCtx = (maxCuDepth==3 && cuDepth > 0) ? (cuDepth - 1) : cuDepth; |
---|
| 1872 | return uiCtx; |
---|
| 1873 | #else |
---|
| 1874 | TComDataCU* pcTempCU; |
---|
| 1875 | UInt uiTempPartIdx; |
---|
| 1876 | UInt uiCtx = 0; |
---|
| 1877 | |
---|
| 1878 | // Get BCBP of left PU |
---|
| 1879 | #if DEPENDENT_SLICES |
---|
| 1880 | Bool bDepSliceRestriction = ( !m_pcSlice->getPPS()->getDependentSliceEnabledFlag()); |
---|
| 1881 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
| 1882 | #else |
---|
| 1883 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1884 | #endif |
---|
| 1885 | uiCtx = ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0; |
---|
| 1886 | |
---|
| 1887 | // Get BCBP of above PU |
---|
| 1888 | #if DEPENDENT_SLICES |
---|
| 1889 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction ); |
---|
| 1890 | #else |
---|
| 1891 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1892 | #endif |
---|
| 1893 | uiCtx += ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0; |
---|
| 1894 | |
---|
| 1895 | return uiCtx; |
---|
| 1896 | #endif |
---|
| 1897 | } |
---|
| 1898 | #endif |
---|
| 1899 | |
---|
| 1900 | #if REF_IDX_ME_ZEROMV |
---|
| 1901 | Bool TComDataCU::xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1) |
---|
| 1902 | { |
---|
| 1903 | Bool checkZeroMVILR = true; |
---|
| 1904 | |
---|
| 1905 | if(uhInterDir&0x1) //list0 |
---|
| 1906 | { |
---|
| 1907 | Int refIdxL0 = cMvFieldL0.getRefIdx(); |
---|
| 1908 | if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_layerId)) |
---|
| 1909 | { |
---|
| 1910 | checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0); |
---|
| 1911 | } |
---|
| 1912 | } |
---|
| 1913 | if(uhInterDir&0x2) //list1 |
---|
| 1914 | { |
---|
| 1915 | Int refIdxL1 = cMvFieldL1.getRefIdx(); |
---|
| 1916 | if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_layerId)) |
---|
| 1917 | { |
---|
| 1918 | checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0); |
---|
| 1919 | } |
---|
| 1920 | } |
---|
| 1921 | |
---|
| 1922 | return checkZeroMVILR; |
---|
| 1923 | } |
---|
| 1924 | |
---|
| 1925 | Bool TComDataCU::xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx) |
---|
| 1926 | { |
---|
| 1927 | RefPicList eRefPicList = iRefList > 0? REF_PIC_LIST_1: REF_PIC_LIST_0; |
---|
| 1928 | assert(eRefPicList == REF_PIC_LIST_1); |
---|
| 1929 | |
---|
| 1930 | Bool checkZeroMVILR = true; |
---|
| 1931 | |
---|
| 1932 | if(getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(m_layerId)) |
---|
| 1933 | { |
---|
| 1934 | AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo(); |
---|
| 1935 | TComMv cMv = pcAMVPInfo->m_acMvCand[MvpIdx]; |
---|
| 1936 | checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0); |
---|
| 1937 | } |
---|
| 1938 | |
---|
| 1939 | return checkZeroMVILR; |
---|
| 1940 | } |
---|
| 1941 | #endif |
---|
| 1942 | |
---|
| 1943 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
---|
| 1944 | { |
---|
| 1945 | TComDataCU* pcTempCU; |
---|
| 1946 | UInt uiTempPartIdx; |
---|
| 1947 | UInt uiCtx = 0; |
---|
| 1948 | |
---|
| 1949 | // Get BCBP of left PU |
---|
| 1950 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1951 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
| 1952 | |
---|
| 1953 | // Get BCBP of above PU |
---|
| 1954 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
---|
| 1955 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
---|
| 1956 | |
---|
| 1957 | return uiCtx; |
---|
| 1958 | } |
---|
| 1959 | |
---|
| 1960 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
---|
| 1961 | { |
---|
| 1962 | return getDepth( uiAbsPartIdx ); |
---|
| 1963 | } |
---|
| 1964 | |
---|
| 1965 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1966 | { |
---|
| 1967 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1968 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1969 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1970 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1971 | } |
---|
| 1972 | |
---|
| 1973 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1974 | { |
---|
| 1975 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1976 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 1977 | } |
---|
| 1978 | |
---|
| 1979 | /** Sets a coded block flag for all sub-partitions of a partition |
---|
| 1980 | * \param uiCbf The value of the coded block flag to be set |
---|
| 1981 | * \param eTType |
---|
| 1982 | * \param uiAbsPartIdx |
---|
| 1983 | * \param uiPartIdx |
---|
| 1984 | * \param uiDepth |
---|
| 1985 | * \returns Void |
---|
| 1986 | */ |
---|
| 1987 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 1988 | { |
---|
| 1989 | setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 1990 | } |
---|
| 1991 | |
---|
| 1992 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
---|
| 1993 | { |
---|
| 1994 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 1995 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 1996 | } |
---|
| 1997 | |
---|
| 1998 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
---|
| 1999 | { |
---|
| 2000 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2001 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
---|
| 2002 | } |
---|
| 2003 | |
---|
| 2004 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2005 | { |
---|
| 2006 | assert( sizeof( *m_pePartSize) == 1 ); |
---|
| 2007 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
| 2008 | } |
---|
| 2009 | |
---|
| 2010 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2011 | { |
---|
| 2012 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
| 2013 | } |
---|
| 2014 | |
---|
| 2015 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
---|
| 2016 | { |
---|
| 2017 | assert( sizeof( *m_skipFlag) == 1 ); |
---|
| 2018 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); |
---|
| 2019 | } |
---|
| 2020 | |
---|
| 2021 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2022 | { |
---|
| 2023 | assert( sizeof( *m_pePredMode) == 1 ); |
---|
| 2024 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
---|
| 2025 | } |
---|
| 2026 | |
---|
| 2027 | Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
---|
| 2028 | { |
---|
| 2029 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
---|
| 2030 | UInt currPartNumQ = currPartNumb >> 2; |
---|
| 2031 | |
---|
| 2032 | if(!foundNonZeroCbf) |
---|
| 2033 | { |
---|
| 2034 | if(pcCU->getDepth(absPartIdx) > depth) |
---|
| 2035 | { |
---|
| 2036 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
---|
| 2037 | { |
---|
| 2038 | pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
---|
| 2039 | } |
---|
| 2040 | } |
---|
| 2041 | else |
---|
| 2042 | { |
---|
| 2043 | if(pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V ) ) |
---|
| 2044 | { |
---|
| 2045 | foundNonZeroCbf = true; |
---|
| 2046 | } |
---|
| 2047 | else |
---|
| 2048 | { |
---|
| 2049 | setQPSubParts(qp, absPartIdx, depth); |
---|
| 2050 | } |
---|
| 2051 | } |
---|
| 2052 | } |
---|
| 2053 | } |
---|
| 2054 | |
---|
| 2055 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2056 | { |
---|
| 2057 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2058 | TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); |
---|
| 2059 | |
---|
| 2060 | for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) |
---|
| 2061 | { |
---|
| 2062 | if( m_pcPic->getCU( getAddr() )->getSliceSegmentStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr() ) |
---|
| 2063 | { |
---|
| 2064 | m_phQP[uiSCUIdx] = qp; |
---|
| 2065 | } |
---|
| 2066 | } |
---|
| 2067 | } |
---|
| 2068 | |
---|
| 2069 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2070 | { |
---|
| 2071 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2072 | |
---|
| 2073 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 2074 | } |
---|
| 2075 | |
---|
| 2076 | template<typename T> |
---|
| 2077 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
---|
| 2078 | { |
---|
| 2079 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
---|
| 2080 | |
---|
| 2081 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
---|
| 2082 | switch ( m_pePartSize[ uiCUAddr ] ) |
---|
| 2083 | { |
---|
| 2084 | case SIZE_2Nx2N: |
---|
| 2085 | memset( puhBaseLCU + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
---|
| 2086 | break; |
---|
| 2087 | case SIZE_2NxN: |
---|
| 2088 | memset( puhBaseLCU + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
---|
| 2089 | break; |
---|
| 2090 | case SIZE_Nx2N: |
---|
| 2091 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
| 2092 | memset( puhBaseLCU + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
---|
| 2093 | break; |
---|
| 2094 | case SIZE_NxN: |
---|
| 2095 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
---|
| 2096 | break; |
---|
| 2097 | case SIZE_2NxnU: |
---|
| 2098 | if ( uiPUIdx == 0 ) |
---|
| 2099 | { |
---|
| 2100 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2101 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2102 | } |
---|
| 2103 | else if ( uiPUIdx == 1 ) |
---|
| 2104 | { |
---|
| 2105 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2106 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
---|
| 2107 | } |
---|
| 2108 | else |
---|
| 2109 | { |
---|
| 2110 | assert(0); |
---|
| 2111 | } |
---|
| 2112 | break; |
---|
| 2113 | case SIZE_2NxnD: |
---|
| 2114 | if ( uiPUIdx == 0 ) |
---|
| 2115 | { |
---|
| 2116 | memset( puhBaseLCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
---|
| 2117 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2118 | } |
---|
| 2119 | else if ( uiPUIdx == 1 ) |
---|
| 2120 | { |
---|
| 2121 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2122 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
---|
| 2123 | } |
---|
| 2124 | else |
---|
| 2125 | { |
---|
| 2126 | assert(0); |
---|
| 2127 | } |
---|
| 2128 | break; |
---|
| 2129 | case SIZE_nLx2N: |
---|
| 2130 | if ( uiPUIdx == 0 ) |
---|
| 2131 | { |
---|
| 2132 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2133 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2134 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2135 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2136 | } |
---|
| 2137 | else if ( uiPUIdx == 1 ) |
---|
| 2138 | { |
---|
| 2139 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2140 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 2141 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2142 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 2143 | } |
---|
| 2144 | else |
---|
| 2145 | { |
---|
| 2146 | assert(0); |
---|
| 2147 | } |
---|
| 2148 | break; |
---|
| 2149 | case SIZE_nRx2N: |
---|
| 2150 | if ( uiPUIdx == 0 ) |
---|
| 2151 | { |
---|
| 2152 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 2153 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2154 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
---|
| 2155 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2156 | } |
---|
| 2157 | else if ( uiPUIdx == 1 ) |
---|
| 2158 | { |
---|
| 2159 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2160 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2161 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2162 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
---|
| 2163 | } |
---|
| 2164 | else |
---|
| 2165 | { |
---|
| 2166 | assert(0); |
---|
| 2167 | } |
---|
| 2168 | break; |
---|
| 2169 | default: |
---|
| 2170 | assert( 0 ); |
---|
| 2171 | } |
---|
| 2172 | } |
---|
| 2173 | |
---|
| 2174 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2175 | { |
---|
| 2176 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 2177 | } |
---|
| 2178 | |
---|
| 2179 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2180 | { |
---|
| 2181 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 2182 | } |
---|
| 2183 | |
---|
| 2184 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2185 | { |
---|
| 2186 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2187 | |
---|
| 2188 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 2189 | } |
---|
| 2190 | |
---|
| 2191 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2192 | { |
---|
| 2193 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 2194 | } |
---|
| 2195 | |
---|
| 2196 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2197 | { |
---|
| 2198 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 2199 | } |
---|
| 2200 | |
---|
| 2201 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2202 | { |
---|
| 2203 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
| 2204 | } |
---|
| 2205 | |
---|
| 2206 | |
---|
| 2207 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2208 | { |
---|
| 2209 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2210 | |
---|
| 2211 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 2212 | } |
---|
| 2213 | |
---|
| 2214 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2215 | { |
---|
| 2216 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2217 | |
---|
| 2218 | memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 2219 | memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 2220 | memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 2221 | } |
---|
| 2222 | |
---|
| 2223 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) |
---|
| 2224 | { |
---|
| 2225 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2226 | |
---|
| 2227 | memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
---|
| 2228 | } |
---|
| 2229 | |
---|
| 2230 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2231 | { |
---|
| 2232 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 2233 | |
---|
| 2234 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 2235 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
---|
| 2236 | } |
---|
| 2237 | |
---|
| 2238 | UChar TComDataCU::getNumPartInter() |
---|
| 2239 | { |
---|
| 2240 | UChar iNumPart = 0; |
---|
| 2241 | |
---|
| 2242 | switch ( m_pePartSize[0] ) |
---|
| 2243 | { |
---|
| 2244 | case SIZE_2Nx2N: iNumPart = 1; break; |
---|
| 2245 | case SIZE_2NxN: iNumPart = 2; break; |
---|
| 2246 | case SIZE_Nx2N: iNumPart = 2; break; |
---|
| 2247 | case SIZE_NxN: iNumPart = 4; break; |
---|
| 2248 | case SIZE_2NxnU: iNumPart = 2; break; |
---|
| 2249 | case SIZE_2NxnD: iNumPart = 2; break; |
---|
| 2250 | case SIZE_nLx2N: iNumPart = 2; break; |
---|
| 2251 | case SIZE_nRx2N: iNumPart = 2; break; |
---|
| 2252 | default: assert (0); break; |
---|
| 2253 | } |
---|
| 2254 | |
---|
| 2255 | return iNumPart; |
---|
| 2256 | } |
---|
| 2257 | |
---|
| 2258 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
---|
| 2259 | { |
---|
| 2260 | switch ( m_pePartSize[0] ) |
---|
| 2261 | { |
---|
| 2262 | case SIZE_2NxN: |
---|
| 2263 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 2264 | break; |
---|
| 2265 | case SIZE_Nx2N: |
---|
| 2266 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
---|
| 2267 | break; |
---|
| 2268 | case SIZE_NxN: |
---|
| 2269 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
| 2270 | break; |
---|
| 2271 | case SIZE_2NxnU: |
---|
| 2272 | riWidth = getWidth(0); |
---|
| 2273 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
| 2274 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
---|
| 2275 | break; |
---|
| 2276 | case SIZE_2NxnD: |
---|
| 2277 | riWidth = getWidth(0); |
---|
| 2278 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
| 2279 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
---|
| 2280 | break; |
---|
| 2281 | case SIZE_nLx2N: |
---|
| 2282 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
| 2283 | riHeight = getHeight(0); |
---|
| 2284 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
---|
| 2285 | break; |
---|
| 2286 | case SIZE_nRx2N: |
---|
| 2287 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
| 2288 | riHeight = getHeight(0); |
---|
| 2289 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
| 2290 | break; |
---|
| 2291 | default: |
---|
| 2292 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
| 2293 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
---|
| 2294 | break; |
---|
| 2295 | } |
---|
| 2296 | } |
---|
| 2297 | |
---|
| 2298 | |
---|
| 2299 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
---|
| 2300 | { |
---|
| 2301 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
---|
| 2302 | { |
---|
| 2303 | TComMv cZeroMv; |
---|
| 2304 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
---|
| 2305 | return; |
---|
| 2306 | } |
---|
| 2307 | |
---|
| 2308 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
---|
| 2309 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
---|
| 2310 | } |
---|
| 2311 | |
---|
| 2312 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
| 2313 | { |
---|
| 2314 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
| 2315 | UInt uiPUWidth = 0; |
---|
| 2316 | |
---|
| 2317 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
| 2318 | { |
---|
| 2319 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 2320 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 2321 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
| 2322 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
---|
| 2323 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 2324 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
---|
| 2325 | case SIZE_nLx2N: |
---|
| 2326 | if ( uiPartIdx == 0 ) |
---|
| 2327 | { |
---|
| 2328 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
| 2329 | } |
---|
| 2330 | else if ( uiPartIdx == 1 ) |
---|
| 2331 | { |
---|
| 2332 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
| 2333 | } |
---|
| 2334 | else |
---|
| 2335 | { |
---|
| 2336 | assert(0); |
---|
| 2337 | } |
---|
| 2338 | break; |
---|
| 2339 | case SIZE_nRx2N: |
---|
| 2340 | if ( uiPartIdx == 0 ) |
---|
| 2341 | { |
---|
| 2342 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
---|
| 2343 | } |
---|
| 2344 | else if ( uiPartIdx == 1 ) |
---|
| 2345 | { |
---|
| 2346 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
---|
| 2347 | } |
---|
| 2348 | else |
---|
| 2349 | { |
---|
| 2350 | assert(0); |
---|
| 2351 | } |
---|
| 2352 | break; |
---|
| 2353 | default: |
---|
| 2354 | assert (0); |
---|
| 2355 | break; |
---|
| 2356 | } |
---|
| 2357 | |
---|
| 2358 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
---|
| 2359 | } |
---|
| 2360 | |
---|
| 2361 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
| 2362 | { |
---|
| 2363 | UInt uiPUHeight = 0; |
---|
| 2364 | switch ( m_pePartSize[uiAbsPartIdx] ) |
---|
| 2365 | { |
---|
| 2366 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2367 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
| 2368 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2369 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
---|
| 2370 | case SIZE_2NxnU: |
---|
| 2371 | if ( uiPartIdx == 0 ) |
---|
| 2372 | { |
---|
| 2373 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
| 2374 | } |
---|
| 2375 | else if ( uiPartIdx == 1 ) |
---|
| 2376 | { |
---|
| 2377 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
| 2378 | } |
---|
| 2379 | else |
---|
| 2380 | { |
---|
| 2381 | assert(0); |
---|
| 2382 | } |
---|
| 2383 | break; |
---|
| 2384 | case SIZE_2NxnD: |
---|
| 2385 | if ( uiPartIdx == 0 ) |
---|
| 2386 | { |
---|
| 2387 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
---|
| 2388 | } |
---|
| 2389 | else if ( uiPartIdx == 1 ) |
---|
| 2390 | { |
---|
| 2391 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
---|
| 2392 | } |
---|
| 2393 | else |
---|
| 2394 | { |
---|
| 2395 | assert(0); |
---|
| 2396 | } |
---|
| 2397 | break; |
---|
| 2398 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2399 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
---|
| 2400 | default: |
---|
| 2401 | assert (0); |
---|
| 2402 | break; |
---|
| 2403 | } |
---|
| 2404 | |
---|
| 2405 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
| 2406 | } |
---|
| 2407 | |
---|
| 2408 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
---|
| 2409 | { |
---|
| 2410 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
---|
| 2411 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
---|
| 2412 | |
---|
| 2413 | switch ( m_pePartSize[0] ) |
---|
| 2414 | { |
---|
| 2415 | case SIZE_2Nx2N: break; |
---|
| 2416 | case SIZE_2NxN: |
---|
| 2417 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 2418 | break; |
---|
| 2419 | case SIZE_Nx2N: |
---|
| 2420 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
---|
| 2421 | break; |
---|
| 2422 | case SIZE_NxN: |
---|
| 2423 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
| 2424 | break; |
---|
| 2425 | case SIZE_2NxnU: |
---|
| 2426 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
| 2427 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
---|
| 2428 | break; |
---|
| 2429 | case SIZE_2NxnD: |
---|
| 2430 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
| 2431 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
---|
| 2432 | break; |
---|
| 2433 | case SIZE_nLx2N: |
---|
| 2434 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
---|
| 2435 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
| 2436 | break; |
---|
| 2437 | case SIZE_nRx2N: |
---|
| 2438 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
---|
| 2439 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
---|
| 2440 | break; |
---|
| 2441 | default: |
---|
| 2442 | assert (0); |
---|
| 2443 | break; |
---|
| 2444 | } |
---|
| 2445 | |
---|
| 2446 | } |
---|
| 2447 | |
---|
| 2448 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) |
---|
| 2449 | { |
---|
| 2450 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
---|
| 2451 | |
---|
| 2452 | switch ( m_pePartSize[0] ) |
---|
| 2453 | { |
---|
| 2454 | case SIZE_2Nx2N: |
---|
| 2455 | ruiPartIdxLB += m_uiNumPartition >> 1; |
---|
| 2456 | break; |
---|
| 2457 | case SIZE_2NxN: |
---|
| 2458 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 2459 | break; |
---|
| 2460 | case SIZE_Nx2N: |
---|
| 2461 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
---|
| 2462 | break; |
---|
| 2463 | case SIZE_NxN: |
---|
| 2464 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
---|
| 2465 | break; |
---|
| 2466 | case SIZE_2NxnU: |
---|
| 2467 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
| 2468 | break; |
---|
| 2469 | case SIZE_2NxnD: |
---|
| 2470 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
| 2471 | break; |
---|
| 2472 | case SIZE_nLx2N: |
---|
| 2473 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
---|
| 2474 | break; |
---|
| 2475 | case SIZE_nRx2N: |
---|
| 2476 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
---|
| 2477 | break; |
---|
| 2478 | default: |
---|
| 2479 | assert (0); |
---|
| 2480 | break; |
---|
| 2481 | } |
---|
| 2482 | } |
---|
| 2483 | |
---|
| 2484 | /** Derives the partition index of neighbouring bottom right block |
---|
| 2485 | * \param [in] eCUMode |
---|
| 2486 | * \param [in] uiPartIdx |
---|
| 2487 | * \param [out] ruiPartIdxRB |
---|
| 2488 | */ |
---|
| 2489 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxRB ) |
---|
| 2490 | { |
---|
| 2491 | 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]; |
---|
| 2492 | |
---|
| 2493 | switch ( m_pePartSize[0] ) |
---|
| 2494 | { |
---|
| 2495 | case SIZE_2Nx2N: |
---|
| 2496 | ruiPartIdxRB += m_uiNumPartition >> 1; |
---|
| 2497 | break; |
---|
| 2498 | case SIZE_2NxN: |
---|
| 2499 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
---|
| 2500 | break; |
---|
| 2501 | case SIZE_Nx2N: |
---|
| 2502 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
---|
| 2503 | break; |
---|
| 2504 | case SIZE_NxN: |
---|
| 2505 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
---|
| 2506 | break; |
---|
| 2507 | case SIZE_2NxnU: |
---|
| 2508 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
---|
| 2509 | break; |
---|
| 2510 | case SIZE_2NxnD: |
---|
| 2511 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
---|
| 2512 | break; |
---|
| 2513 | case SIZE_nLx2N: |
---|
| 2514 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
---|
| 2515 | break; |
---|
| 2516 | case SIZE_nRx2N: |
---|
| 2517 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
---|
| 2518 | break; |
---|
| 2519 | default: |
---|
| 2520 | assert (0); |
---|
| 2521 | break; |
---|
| 2522 | } |
---|
| 2523 | } |
---|
| 2524 | |
---|
| 2525 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
---|
| 2526 | { |
---|
| 2527 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
---|
| 2528 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
---|
| 2529 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
---|
| 2530 | } |
---|
| 2531 | |
---|
| 2532 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
---|
| 2533 | { |
---|
| 2534 | UInt uiAbsIdx; |
---|
| 2535 | UInt uiMinCuWidth, uiWidthInMinCus; |
---|
| 2536 | |
---|
| 2537 | uiMinCuWidth = getPic()->getMinCUWidth(); |
---|
| 2538 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
---|
| 2539 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
---|
| 2540 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
---|
| 2541 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
---|
| 2542 | } |
---|
| 2543 | |
---|
| 2544 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
---|
| 2545 | { |
---|
| 2546 | |
---|
| 2547 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
---|
| 2548 | { |
---|
| 2549 | return false; |
---|
| 2550 | } |
---|
| 2551 | |
---|
| 2552 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 2553 | { |
---|
| 2554 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
| 2555 | { |
---|
| 2556 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
---|
| 2557 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
---|
| 2558 | { |
---|
| 2559 | return false; |
---|
| 2560 | } |
---|
| 2561 | } |
---|
| 2562 | } |
---|
| 2563 | |
---|
| 2564 | return true; |
---|
| 2565 | } |
---|
| 2566 | |
---|
| 2567 | /** Constructs a list of merging candidates |
---|
| 2568 | * \param uiAbsPartIdx |
---|
| 2569 | * \param uiPUIdx |
---|
| 2570 | * \param uiDepth |
---|
| 2571 | * \param pcMvFieldNeighbours |
---|
| 2572 | * \param puhInterDirNeighbours |
---|
| 2573 | * \param numValidMergeCand |
---|
| 2574 | */ |
---|
| 2575 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) |
---|
| 2576 | { |
---|
| 2577 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
---|
| 2578 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
---|
| 2579 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
| 2580 | { |
---|
| 2581 | abCandIsInter[ui] = false; |
---|
| 2582 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
---|
| 2583 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
---|
| 2584 | } |
---|
| 2585 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
---|
| 2586 | // compute the location of the current PU |
---|
| 2587 | Int xP, yP, nPSW, nPSH; |
---|
| 2588 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
---|
| 2589 | |
---|
| 2590 | Int iCount = 0; |
---|
| 2591 | |
---|
| 2592 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
| 2593 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
---|
| 2594 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
| 2595 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
---|
| 2596 | #if SVC_MVP |
---|
| 2597 | // BL collocated |
---|
| 2598 | TComDataCU *pcColCU = NULL; |
---|
| 2599 | UInt uiCUAddrBase = 0, uiAbsPartAddrBase = 0; |
---|
| 2600 | #if AVC_BASE |
---|
| 2601 | if( !this->getSlice()->getVPS()->getAvcBaseLayerFlag() || AVC_SYNTAX ) |
---|
| 2602 | #endif |
---|
| 2603 | { |
---|
| 2604 | TComMvField cMvFieldBaseColCU[2]; |
---|
| 2605 | if(m_layerId) |
---|
| 2606 | { |
---|
| 2607 | pcColCU = getBaseColCU( xP + nPSW/2, yP + nPSH/2, uiCUAddrBase, uiAbsPartAddrBase ); |
---|
| 2608 | |
---|
| 2609 | #if INTRA_BL |
---|
| 2610 | if( pcColCU && pcColCU->isIntraBL( uiAbsPartAddrBase ) ) |
---|
| 2611 | { |
---|
| 2612 | pcColCU = NULL; |
---|
| 2613 | } |
---|
| 2614 | #endif |
---|
| 2615 | |
---|
| 2616 | if(pcColCU && !pcColCU->isIntra( uiAbsPartAddrBase ) ) |
---|
| 2617 | { |
---|
| 2618 | abCandIsInter[iCount] = true; |
---|
| 2619 | |
---|
| 2620 | // get interDir |
---|
| 2621 | puhInterDirNeighbours[iCount] = pcColCU->getInterDir( uiAbsPartAddrBase ); |
---|
| 2622 | |
---|
| 2623 | pcMvFieldNeighbours[(iCount << 1)].setMvField( TComMv(0,0), -1); |
---|
| 2624 | pcMvFieldNeighbours[(iCount << 1) + 1].setMvField( TComMv(0,0), -1); |
---|
| 2625 | |
---|
| 2626 | if( puhInterDirNeighbours[iCount] & 1 ) |
---|
| 2627 | { |
---|
| 2628 | pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_0, cMvFieldBaseColCU[0]); |
---|
| 2629 | scaleBaseMV( pcMvFieldNeighbours[iCount<<1], cMvFieldBaseColCU[0] ); |
---|
| 2630 | } |
---|
| 2631 | |
---|
| 2632 | if ( getSlice()->isInterB() && puhInterDirNeighbours[iCount] & 2 ) |
---|
| 2633 | { |
---|
| 2634 | pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_1, cMvFieldBaseColCU[1] ); |
---|
| 2635 | scaleBaseMV( pcMvFieldNeighbours[(iCount<<1)+1], cMvFieldBaseColCU[1] ); |
---|
| 2636 | } |
---|
| 2637 | |
---|
| 2638 | if( puhInterDirNeighbours[iCount] > 0 ) |
---|
| 2639 | { |
---|
| 2640 | if ( mrgCandIdx == iCount ) |
---|
| 2641 | { |
---|
| 2642 | return; |
---|
| 2643 | } |
---|
| 2644 | iCount ++; |
---|
| 2645 | } |
---|
| 2646 | } |
---|
| 2647 | } |
---|
| 2648 | } |
---|
| 2649 | #endif |
---|
| 2650 | |
---|
| 2651 | //left |
---|
| 2652 | UInt uiLeftPartIdx = 0; |
---|
| 2653 | TComDataCU* pcCULeft = 0; |
---|
| 2654 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
---|
| 2655 | #if INTRA_BL |
---|
| 2656 | if( pcCULeft && pcCULeft->isIntraBL( uiLeftPartIdx ) ) |
---|
| 2657 | { |
---|
| 2658 | pcCULeft = NULL; |
---|
| 2659 | } |
---|
| 2660 | #endif |
---|
| 2661 | Bool isAvailableA1 = pcCULeft && |
---|
| 2662 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
---|
| 2663 | #if SVC_MVP |
---|
| 2664 | ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) && |
---|
| 2665 | #endif |
---|
| 2666 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
---|
| 2667 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
---|
| 2668 | if ( isAvailableA1 ) |
---|
| 2669 | { |
---|
| 2670 | abCandIsInter[iCount] = true; |
---|
| 2671 | // get Inter Dir |
---|
| 2672 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
---|
| 2673 | // get Mv from Left |
---|
| 2674 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
| 2675 | if ( getSlice()->isInterB() ) |
---|
| 2676 | { |
---|
| 2677 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
| 2678 | } |
---|
| 2679 | if ( mrgCandIdx == iCount ) |
---|
| 2680 | { |
---|
| 2681 | return; |
---|
| 2682 | } |
---|
| 2683 | iCount ++; |
---|
| 2684 | } |
---|
| 2685 | |
---|
| 2686 | // early termination |
---|
| 2687 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2688 | { |
---|
| 2689 | return; |
---|
| 2690 | } |
---|
| 2691 | // above |
---|
| 2692 | UInt uiAbovePartIdx = 0; |
---|
| 2693 | TComDataCU* pcCUAbove = 0; |
---|
| 2694 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
---|
| 2695 | #if INTRA_BL |
---|
| 2696 | if( pcCUAbove && pcCUAbove->isIntraBL( uiAbovePartIdx ) ) |
---|
| 2697 | { |
---|
| 2698 | pcCUAbove = NULL; |
---|
| 2699 | } |
---|
| 2700 | #endif |
---|
| 2701 | Bool isAvailableB1 = pcCUAbove && |
---|
| 2702 | #if SVC_MVP |
---|
| 2703 | ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) && |
---|
| 2704 | #endif |
---|
| 2705 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
---|
| 2706 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
---|
| 2707 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
---|
| 2708 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
---|
| 2709 | { |
---|
| 2710 | abCandIsInter[iCount] = true; |
---|
| 2711 | // get Inter Dir |
---|
| 2712 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
---|
| 2713 | // get Mv from Left |
---|
| 2714 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
| 2715 | if ( getSlice()->isInterB() ) |
---|
| 2716 | { |
---|
| 2717 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
| 2718 | } |
---|
| 2719 | if ( mrgCandIdx == iCount ) |
---|
| 2720 | { |
---|
| 2721 | return; |
---|
| 2722 | } |
---|
| 2723 | iCount ++; |
---|
| 2724 | } |
---|
| 2725 | // early termination |
---|
| 2726 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2727 | { |
---|
| 2728 | return; |
---|
| 2729 | } |
---|
| 2730 | |
---|
| 2731 | // above right |
---|
| 2732 | UInt uiAboveRightPartIdx = 0; |
---|
| 2733 | TComDataCU* pcCUAboveRight = 0; |
---|
| 2734 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
---|
| 2735 | #if INTRA_BL |
---|
| 2736 | if( pcCUAboveRight && pcCUAboveRight->isIntraBL( uiAboveRightPartIdx ) ) |
---|
| 2737 | { |
---|
| 2738 | pcCUAboveRight = NULL; |
---|
| 2739 | } |
---|
| 2740 | #endif |
---|
| 2741 | Bool isAvailableB0 = pcCUAboveRight && |
---|
| 2742 | #if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING |
---|
| 2743 | ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveRight->hasEqualMotion( uiAboveRightPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) && |
---|
| 2744 | #endif |
---|
| 2745 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
---|
| 2746 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
---|
| 2747 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
---|
| 2748 | { |
---|
| 2749 | abCandIsInter[iCount] = true; |
---|
| 2750 | // get Inter Dir |
---|
| 2751 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
---|
| 2752 | // get Mv from Left |
---|
| 2753 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
| 2754 | if ( getSlice()->isInterB() ) |
---|
| 2755 | { |
---|
| 2756 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
| 2757 | } |
---|
| 2758 | if ( mrgCandIdx == iCount ) |
---|
| 2759 | { |
---|
| 2760 | return; |
---|
| 2761 | } |
---|
| 2762 | iCount ++; |
---|
| 2763 | } |
---|
| 2764 | // early termination |
---|
| 2765 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2766 | { |
---|
| 2767 | return; |
---|
| 2768 | } |
---|
| 2769 | |
---|
| 2770 | //left bottom |
---|
| 2771 | #if SVC_MVP |
---|
| 2772 | if( iCount < 4 ) |
---|
| 2773 | { |
---|
| 2774 | #endif |
---|
| 2775 | UInt uiLeftBottomPartIdx = 0; |
---|
| 2776 | TComDataCU* pcCULeftBottom = 0; |
---|
| 2777 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
---|
| 2778 | #if INTRA_BL |
---|
| 2779 | if( pcCULeftBottom && pcCULeftBottom->isIntraBL( uiLeftBottomPartIdx ) ) |
---|
| 2780 | { |
---|
| 2781 | pcCULeftBottom = NULL; |
---|
| 2782 | } |
---|
| 2783 | #endif |
---|
| 2784 | Bool isAvailableA0 = pcCULeftBottom && |
---|
| 2785 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
---|
| 2786 | #if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING |
---|
| 2787 | ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeftBottom->hasEqualMotion( uiLeftBottomPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) && |
---|
| 2788 | #endif |
---|
| 2789 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
---|
| 2790 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
---|
| 2791 | { |
---|
| 2792 | abCandIsInter[iCount] = true; |
---|
| 2793 | // get Inter Dir |
---|
| 2794 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
---|
| 2795 | // get Mv from Left |
---|
| 2796 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
| 2797 | if ( getSlice()->isInterB() ) |
---|
| 2798 | { |
---|
| 2799 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
| 2800 | } |
---|
| 2801 | if ( mrgCandIdx == iCount ) |
---|
| 2802 | { |
---|
| 2803 | return; |
---|
| 2804 | } |
---|
| 2805 | iCount ++; |
---|
| 2806 | } |
---|
| 2807 | // early termination |
---|
| 2808 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2809 | { |
---|
| 2810 | return; |
---|
| 2811 | } |
---|
| 2812 | #if SVC_MVP |
---|
| 2813 | } |
---|
| 2814 | #endif |
---|
| 2815 | |
---|
| 2816 | // above left |
---|
| 2817 | if( iCount < 4 ) |
---|
| 2818 | { |
---|
| 2819 | UInt uiAboveLeftPartIdx = 0; |
---|
| 2820 | TComDataCU* pcCUAboveLeft = 0; |
---|
| 2821 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
---|
| 2822 | #if INTRA_BL |
---|
| 2823 | if( pcCUAboveLeft && pcCUAboveLeft->isIntraBL( uiAboveLeftPartIdx ) ) |
---|
| 2824 | { |
---|
| 2825 | pcCUAboveLeft = NULL; |
---|
| 2826 | } |
---|
| 2827 | #endif |
---|
| 2828 | Bool isAvailableB2 = pcCUAboveLeft && |
---|
| 2829 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
---|
| 2830 | #if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING |
---|
| 2831 | ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveLeft->hasEqualMotion( uiAboveLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) && |
---|
| 2832 | #endif |
---|
| 2833 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
---|
| 2834 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
---|
| 2835 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
---|
| 2836 | { |
---|
| 2837 | abCandIsInter[iCount] = true; |
---|
| 2838 | // get Inter Dir |
---|
| 2839 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
---|
| 2840 | // get Mv from Left |
---|
| 2841 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
---|
| 2842 | if ( getSlice()->isInterB() ) |
---|
| 2843 | { |
---|
| 2844 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
---|
| 2845 | } |
---|
| 2846 | if ( mrgCandIdx == iCount ) |
---|
| 2847 | { |
---|
| 2848 | return; |
---|
| 2849 | } |
---|
| 2850 | iCount ++; |
---|
| 2851 | } |
---|
| 2852 | } |
---|
| 2853 | // early termination |
---|
| 2854 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2855 | { |
---|
| 2856 | return; |
---|
| 2857 | } |
---|
| 2858 | if ( getSlice()->getEnableTMVPFlag()) |
---|
| 2859 | { |
---|
| 2860 | //>> MTK colocated-RightBottom |
---|
| 2861 | UInt uiPartIdxRB; |
---|
| 2862 | Int uiLCUIdx = getAddr(); |
---|
| 2863 | |
---|
| 2864 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
---|
| 2865 | |
---|
| 2866 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
---|
| 2867 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 2868 | |
---|
| 2869 | TComMv cColMv; |
---|
| 2870 | Int iRefIdx; |
---|
| 2871 | |
---|
| 2872 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
| 2873 | { |
---|
| 2874 | uiLCUIdx = -1; |
---|
| 2875 | } |
---|
| 2876 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
| 2877 | { |
---|
| 2878 | uiLCUIdx = -1; |
---|
| 2879 | } |
---|
| 2880 | else |
---|
| 2881 | { |
---|
| 2882 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
| 2883 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
| 2884 | { |
---|
| 2885 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
---|
| 2886 | uiLCUIdx = getAddr(); |
---|
| 2887 | } |
---|
| 2888 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
| 2889 | { |
---|
| 2890 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
| 2891 | uiLCUIdx = -1 ; |
---|
| 2892 | } |
---|
| 2893 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
| 2894 | { |
---|
| 2895 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
---|
| 2896 | uiLCUIdx = getAddr() + 1; |
---|
| 2897 | } |
---|
| 2898 | else //is the right bottom corner of LCU |
---|
| 2899 | { |
---|
| 2900 | uiAbsPartAddr = 0; |
---|
| 2901 | uiLCUIdx = -1 ; |
---|
| 2902 | } |
---|
| 2903 | } |
---|
| 2904 | |
---|
| 2905 | |
---|
| 2906 | iRefIdx = 0; |
---|
| 2907 | Bool bExistMV = false; |
---|
| 2908 | UInt uiPartIdxCenter; |
---|
| 2909 | UInt uiCurLCUIdx = getAddr(); |
---|
| 2910 | Int dir = 0; |
---|
| 2911 | UInt uiArrayAddr = iCount; |
---|
| 2912 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
---|
| 2913 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
---|
| 2914 | if( bExistMV == false ) |
---|
| 2915 | { |
---|
| 2916 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
| 2917 | } |
---|
| 2918 | if( bExistMV ) |
---|
| 2919 | { |
---|
| 2920 | dir |= 1; |
---|
| 2921 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
---|
| 2922 | } |
---|
| 2923 | |
---|
| 2924 | if ( getSlice()->isInterB() ) |
---|
| 2925 | { |
---|
| 2926 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
---|
| 2927 | if( bExistMV == false ) |
---|
| 2928 | { |
---|
| 2929 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
---|
| 2930 | } |
---|
| 2931 | if( bExistMV ) |
---|
| 2932 | { |
---|
| 2933 | dir |= 2; |
---|
| 2934 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
---|
| 2935 | } |
---|
| 2936 | } |
---|
| 2937 | |
---|
| 2938 | if (dir != 0) |
---|
| 2939 | { |
---|
| 2940 | puhInterDirNeighbours[uiArrayAddr] = dir; |
---|
| 2941 | abCandIsInter[uiArrayAddr] = true; |
---|
| 2942 | |
---|
| 2943 | if ( mrgCandIdx == iCount ) |
---|
| 2944 | { |
---|
| 2945 | return; |
---|
| 2946 | } |
---|
| 2947 | iCount++; |
---|
| 2948 | } |
---|
| 2949 | } |
---|
| 2950 | // early termination |
---|
| 2951 | if (iCount == getSlice()->getMaxNumMergeCand()) |
---|
| 2952 | { |
---|
| 2953 | return; |
---|
| 2954 | } |
---|
| 2955 | UInt uiArrayAddr = iCount; |
---|
| 2956 | UInt uiCutoff = uiArrayAddr; |
---|
| 2957 | |
---|
| 2958 | if ( getSlice()->isInterB()) |
---|
| 2959 | { |
---|
| 2960 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
---|
| 2961 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
---|
| 2962 | |
---|
| 2963 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
---|
| 2964 | { |
---|
| 2965 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
---|
| 2966 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
---|
| 2967 | { |
---|
| 2968 | abCandIsInter[uiArrayAddr] = true; |
---|
| 2969 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
| 2970 | |
---|
| 2971 | // get Mv from cand[i] and cand[j] |
---|
| 2972 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
---|
| 2973 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
---|
| 2974 | |
---|
| 2975 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
---|
| 2976 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
---|
| 2977 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
---|
| 2978 | { |
---|
| 2979 | abCandIsInter[uiArrayAddr] = false; |
---|
| 2980 | } |
---|
| 2981 | else |
---|
| 2982 | { |
---|
| 2983 | uiArrayAddr++; |
---|
| 2984 | } |
---|
| 2985 | } |
---|
| 2986 | } |
---|
| 2987 | } |
---|
| 2988 | // early termination |
---|
| 2989 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
---|
| 2990 | { |
---|
| 2991 | return; |
---|
| 2992 | } |
---|
| 2993 | 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); |
---|
| 2994 | Int r = 0; |
---|
| 2995 | Int refcnt = 0; |
---|
| 2996 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
---|
| 2997 | { |
---|
| 2998 | abCandIsInter[uiArrayAddr] = true; |
---|
| 2999 | puhInterDirNeighbours[uiArrayAddr] = 1; |
---|
| 3000 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
---|
| 3001 | |
---|
| 3002 | if ( getSlice()->isInterB() ) |
---|
| 3003 | { |
---|
| 3004 | puhInterDirNeighbours[uiArrayAddr] = 3; |
---|
| 3005 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
---|
| 3006 | } |
---|
| 3007 | uiArrayAddr++; |
---|
| 3008 | if ( refcnt == iNumRefIdx - 1 ) |
---|
| 3009 | { |
---|
| 3010 | r = 0; |
---|
| 3011 | } |
---|
| 3012 | else |
---|
| 3013 | { |
---|
| 3014 | ++r; |
---|
| 3015 | ++refcnt; |
---|
| 3016 | } |
---|
| 3017 | } |
---|
| 3018 | |
---|
| 3019 | numValidMergeCand = uiArrayAddr; |
---|
| 3020 | } |
---|
| 3021 | |
---|
| 3022 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
---|
| 3023 | * \param xN, xN location of the upper-left corner pixel of a neighboring PU |
---|
| 3024 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
| 3025 | * \returns Bool |
---|
| 3026 | */ |
---|
| 3027 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
---|
| 3028 | { |
---|
| 3029 | |
---|
| 3030 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
---|
| 3031 | if ((xN>>plevel)!= (xP>>plevel)) |
---|
| 3032 | { |
---|
| 3033 | return true; |
---|
| 3034 | } |
---|
| 3035 | if ((yN>>plevel)!= (yP>>plevel)) |
---|
| 3036 | { |
---|
| 3037 | return true; |
---|
| 3038 | } |
---|
| 3039 | return false; |
---|
| 3040 | } |
---|
| 3041 | /** calculate the location of upper-left corner pixel and size of the current PU. |
---|
| 3042 | * \param partIdx PU index within a CU |
---|
| 3043 | * \param xP, yP location of the upper-left corner pixel of the current PU |
---|
| 3044 | * \param PSW, nPSH size of the curren PU |
---|
| 3045 | * \returns Void |
---|
| 3046 | */ |
---|
| 3047 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
---|
| 3048 | { |
---|
| 3049 | UInt col = m_uiCUPelX; |
---|
| 3050 | UInt row = m_uiCUPelY; |
---|
| 3051 | |
---|
| 3052 | switch ( m_pePartSize[0] ) |
---|
| 3053 | { |
---|
| 3054 | case SIZE_2NxN: |
---|
| 3055 | nPSW = getWidth(0); |
---|
| 3056 | nPSH = getHeight(0) >> 1; |
---|
| 3057 | xP = col; |
---|
| 3058 | yP = (partIdx ==0)? row: row + nPSH; |
---|
| 3059 | break; |
---|
| 3060 | case SIZE_Nx2N: |
---|
| 3061 | nPSW = getWidth(0) >> 1; |
---|
| 3062 | nPSH = getHeight(0); |
---|
| 3063 | xP = (partIdx ==0)? col: col + nPSW; |
---|
| 3064 | yP = row; |
---|
| 3065 | break; |
---|
| 3066 | case SIZE_NxN: |
---|
| 3067 | nPSW = getWidth(0) >> 1; |
---|
| 3068 | nPSH = getHeight(0) >> 1; |
---|
| 3069 | xP = col + (partIdx&0x1)*nPSW; |
---|
| 3070 | yP = row + (partIdx>>1)*nPSH; |
---|
| 3071 | break; |
---|
| 3072 | case SIZE_2NxnU: |
---|
| 3073 | nPSW = getWidth(0); |
---|
| 3074 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
---|
| 3075 | xP = col; |
---|
| 3076 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
| 3077 | |
---|
| 3078 | break; |
---|
| 3079 | case SIZE_2NxnD: |
---|
| 3080 | nPSW = getWidth(0); |
---|
| 3081 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
---|
| 3082 | xP = col; |
---|
| 3083 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
---|
| 3084 | break; |
---|
| 3085 | case SIZE_nLx2N: |
---|
| 3086 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
---|
| 3087 | nPSH = getHeight(0); |
---|
| 3088 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
| 3089 | yP = row; |
---|
| 3090 | break; |
---|
| 3091 | case SIZE_nRx2N: |
---|
| 3092 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
---|
| 3093 | nPSH = getHeight(0); |
---|
| 3094 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
---|
| 3095 | yP = row; |
---|
| 3096 | break; |
---|
| 3097 | default: |
---|
| 3098 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
---|
| 3099 | nPSW = getWidth(0); |
---|
| 3100 | nPSH = getHeight(0); |
---|
| 3101 | xP = col ; |
---|
| 3102 | yP = row ; |
---|
| 3103 | |
---|
| 3104 | break; |
---|
| 3105 | } |
---|
| 3106 | } |
---|
| 3107 | |
---|
| 3108 | /** Constructs a list of candidates for AMVP |
---|
| 3109 | * \param uiPartIdx |
---|
| 3110 | * \param uiPartAddr |
---|
| 3111 | * \param eRefPicList |
---|
| 3112 | * \param iRefIdx |
---|
| 3113 | * \param pInfo |
---|
| 3114 | */ |
---|
| 3115 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
---|
| 3116 | { |
---|
| 3117 | TComMv cMvPred; |
---|
| 3118 | Bool bAddedSmvp = false; |
---|
| 3119 | |
---|
| 3120 | pInfo->iN = 0; |
---|
| 3121 | if (iRefIdx < 0) |
---|
| 3122 | { |
---|
| 3123 | return; |
---|
| 3124 | } |
---|
| 3125 | |
---|
| 3126 | //-- Get Spatial MV |
---|
| 3127 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
| 3128 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 3129 | Bool bAdded = false; |
---|
| 3130 | |
---|
| 3131 | deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
---|
| 3132 | deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); |
---|
| 3133 | |
---|
| 3134 | TComDataCU* tmpCU = NULL; |
---|
| 3135 | UInt idx; |
---|
| 3136 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB); |
---|
| 3137 | #if INTRA_BL |
---|
| 3138 | bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx)); |
---|
| 3139 | #else |
---|
| 3140 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
| 3141 | #endif |
---|
| 3142 | |
---|
| 3143 | if (!bAddedSmvp) |
---|
| 3144 | { |
---|
| 3145 | tmpCU = getPULeft(idx, uiPartIdxLB); |
---|
| 3146 | #if INTRA_BL |
---|
| 3147 | bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx)); |
---|
| 3148 | #else |
---|
| 3149 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
---|
| 3150 | #endif |
---|
| 3151 | } |
---|
| 3152 | |
---|
| 3153 | // Left predictor search |
---|
| 3154 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
| 3155 | if (!bAdded) |
---|
| 3156 | { |
---|
| 3157 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
| 3158 | } |
---|
| 3159 | |
---|
| 3160 | if(!bAdded) |
---|
| 3161 | { |
---|
| 3162 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
---|
| 3163 | if (!bAdded) |
---|
| 3164 | { |
---|
| 3165 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
---|
| 3166 | } |
---|
| 3167 | } |
---|
| 3168 | // Above predictor search |
---|
| 3169 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
| 3170 | |
---|
| 3171 | if (!bAdded) |
---|
| 3172 | { |
---|
| 3173 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
| 3174 | } |
---|
| 3175 | |
---|
| 3176 | if(!bAdded) |
---|
| 3177 | { |
---|
| 3178 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
| 3179 | } |
---|
| 3180 | bAdded = bAddedSmvp; |
---|
| 3181 | if (pInfo->iN==2) bAdded = true; |
---|
| 3182 | |
---|
| 3183 | if(!bAdded) |
---|
| 3184 | { |
---|
| 3185 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
---|
| 3186 | if (!bAdded) |
---|
| 3187 | { |
---|
| 3188 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
---|
| 3189 | } |
---|
| 3190 | |
---|
| 3191 | if(!bAdded) |
---|
| 3192 | { |
---|
| 3193 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
---|
| 3194 | } |
---|
| 3195 | } |
---|
| 3196 | |
---|
| 3197 | if ( pInfo->iN == 2 ) |
---|
| 3198 | { |
---|
| 3199 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
---|
| 3200 | { |
---|
| 3201 | pInfo->iN = 1; |
---|
| 3202 | } |
---|
| 3203 | } |
---|
| 3204 | |
---|
| 3205 | if ( getSlice()->getEnableTMVPFlag() ) |
---|
| 3206 | { |
---|
| 3207 | // Get Temporal Motion Predictor |
---|
| 3208 | Int iRefIdx_Col = iRefIdx; |
---|
| 3209 | TComMv cColMv; |
---|
| 3210 | UInt uiPartIdxRB; |
---|
| 3211 | UInt uiAbsPartIdx; |
---|
| 3212 | UInt uiAbsPartAddr; |
---|
| 3213 | Int uiLCUIdx = getAddr(); |
---|
| 3214 | |
---|
| 3215 | deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); |
---|
| 3216 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
---|
| 3217 | |
---|
| 3218 | //---- co-located RightBottom Temporal Predictor (H) ---// |
---|
| 3219 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
---|
| 3220 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
---|
| 3221 | { |
---|
| 3222 | uiLCUIdx = -1; |
---|
| 3223 | } |
---|
| 3224 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
| 3225 | { |
---|
| 3226 | uiLCUIdx = -1; |
---|
| 3227 | } |
---|
| 3228 | else |
---|
| 3229 | { |
---|
| 3230 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
---|
| 3231 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
---|
| 3232 | { |
---|
| 3233 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
---|
| 3234 | uiLCUIdx = getAddr(); |
---|
| 3235 | } |
---|
| 3236 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
---|
| 3237 | { |
---|
| 3238 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
---|
| 3239 | uiLCUIdx = -1 ; |
---|
| 3240 | } |
---|
| 3241 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
---|
| 3242 | { |
---|
| 3243 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
---|
| 3244 | uiLCUIdx = getAddr() + 1; |
---|
| 3245 | } |
---|
| 3246 | else //is the right bottom corner of LCU |
---|
| 3247 | { |
---|
| 3248 | uiAbsPartAddr = 0; |
---|
| 3249 | uiLCUIdx = -1 ; |
---|
| 3250 | } |
---|
| 3251 | } |
---|
| 3252 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col ) ) |
---|
| 3253 | { |
---|
| 3254 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
| 3255 | } |
---|
| 3256 | else |
---|
| 3257 | { |
---|
| 3258 | UInt uiPartIdxCenter; |
---|
| 3259 | UInt uiCurLCUIdx = getAddr(); |
---|
| 3260 | xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); |
---|
| 3261 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col )) |
---|
| 3262 | { |
---|
| 3263 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
---|
| 3264 | } |
---|
| 3265 | } |
---|
| 3266 | //---- co-located RightBottom Temporal Predictor ---// |
---|
| 3267 | } |
---|
| 3268 | |
---|
| 3269 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
---|
| 3270 | { |
---|
| 3271 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
---|
| 3272 | } |
---|
| 3273 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
---|
| 3274 | { |
---|
| 3275 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
---|
| 3276 | pInfo->iN++; |
---|
| 3277 | } |
---|
| 3278 | return ; |
---|
| 3279 | } |
---|
| 3280 | |
---|
| 3281 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
---|
| 3282 | { |
---|
| 3283 | Int width = 0; |
---|
| 3284 | Int height = 0; |
---|
| 3285 | UInt partAddr; |
---|
| 3286 | |
---|
| 3287 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
---|
| 3288 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
---|
| 3289 | { |
---|
| 3290 | return true; |
---|
| 3291 | } |
---|
| 3292 | return false; |
---|
| 3293 | } |
---|
| 3294 | |
---|
| 3295 | Void TComDataCU::clipMv (TComMv& rcMv) |
---|
| 3296 | { |
---|
| 3297 | Int iMvShift = 2; |
---|
| 3298 | Int iOffset = 8; |
---|
| 3299 | Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset - m_uiCUPelX - 1 ) << iMvShift; |
---|
| 3300 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
---|
| 3301 | |
---|
| 3302 | Int iVerMax = ( m_pcSlice->getSPS()->getPicHeightInLumaSamples() + iOffset - m_uiCUPelY - 1 ) << iMvShift; |
---|
| 3303 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
---|
| 3304 | |
---|
| 3305 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
---|
| 3306 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
---|
| 3307 | } |
---|
| 3308 | |
---|
| 3309 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
---|
| 3310 | { |
---|
| 3311 | UInt uiShift = ( (m_puhTrIdx[uiAbsPartIdx]==0) && (m_pePartSize[uiAbsPartIdx]==SIZE_NxN) ) ? m_puhTrIdx[uiAbsPartIdx]+1 : m_puhTrIdx[uiAbsPartIdx]; |
---|
| 3312 | uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
---|
| 3313 | |
---|
| 3314 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
---|
| 3315 | UInt uiCnt = 0; |
---|
| 3316 | while( uiWidth ) |
---|
| 3317 | { |
---|
| 3318 | uiCnt++; |
---|
| 3319 | uiWidth>>=1; |
---|
| 3320 | } |
---|
| 3321 | uiCnt-=2; |
---|
| 3322 | return uiCnt > 6 ? 6 : uiCnt; |
---|
| 3323 | } |
---|
| 3324 | |
---|
| 3325 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
---|
| 3326 | { |
---|
| 3327 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
---|
| 3328 | } |
---|
| 3329 | |
---|
| 3330 | /** Set a I_PCM flag for all sub-partitions of a partition. |
---|
| 3331 | * \param bIpcmFlag I_PCM flag |
---|
| 3332 | * \param uiAbsPartIdx patition index |
---|
| 3333 | * \param uiDepth CU depth |
---|
| 3334 | * \returns Void |
---|
| 3335 | */ |
---|
| 3336 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
---|
| 3337 | { |
---|
| 3338 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
---|
| 3339 | |
---|
| 3340 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
---|
| 3341 | } |
---|
| 3342 | |
---|
| 3343 | /** Test whether the current block is skipped |
---|
| 3344 | * \param uiPartIdx Block index |
---|
| 3345 | * \returns Flag indicating whether the block is skipped |
---|
| 3346 | */ |
---|
| 3347 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
---|
| 3348 | { |
---|
| 3349 | return ( getSkipFlag( uiPartIdx ) ); |
---|
| 3350 | } |
---|
| 3351 | |
---|
| 3352 | // ==================================================================================================================== |
---|
| 3353 | // Protected member functions |
---|
| 3354 | // ==================================================================================================================== |
---|
| 3355 | |
---|
| 3356 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
| 3357 | { |
---|
| 3358 | TComDataCU* pcTmpCU = NULL; |
---|
| 3359 | UInt uiIdx; |
---|
| 3360 | switch( eDir ) |
---|
| 3361 | { |
---|
| 3362 | case MD_LEFT: |
---|
| 3363 | { |
---|
| 3364 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
| 3365 | break; |
---|
| 3366 | } |
---|
| 3367 | case MD_ABOVE: |
---|
| 3368 | { |
---|
| 3369 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx ); |
---|
| 3370 | break; |
---|
| 3371 | } |
---|
| 3372 | case MD_ABOVE_RIGHT: |
---|
| 3373 | { |
---|
| 3374 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
| 3375 | break; |
---|
| 3376 | } |
---|
| 3377 | case MD_BELOW_LEFT: |
---|
| 3378 | { |
---|
| 3379 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
| 3380 | break; |
---|
| 3381 | } |
---|
| 3382 | case MD_ABOVE_LEFT: |
---|
| 3383 | { |
---|
| 3384 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
| 3385 | break; |
---|
| 3386 | } |
---|
| 3387 | default: |
---|
| 3388 | { |
---|
| 3389 | break; |
---|
| 3390 | } |
---|
| 3391 | } |
---|
| 3392 | |
---|
| 3393 | if ( pcTmpCU == NULL ) |
---|
| 3394 | { |
---|
| 3395 | return false; |
---|
| 3396 | } |
---|
| 3397 | |
---|
| 3398 | #if L0363_MVP_POC |
---|
| 3399 | if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) |
---|
| 3400 | #else |
---|
| 3401 | if ( m_pcSlice->isEqualRef(eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx), iRefIdx) ) |
---|
| 3402 | #endif |
---|
| 3403 | { |
---|
| 3404 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
| 3405 | |
---|
| 3406 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
| 3407 | return true; |
---|
| 3408 | } |
---|
| 3409 | |
---|
| 3410 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
| 3411 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
| 3412 | { |
---|
| 3413 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
| 3414 | } |
---|
| 3415 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
| 3416 | { |
---|
| 3417 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
| 3418 | } |
---|
| 3419 | |
---|
| 3420 | |
---|
| 3421 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
| 3422 | Int iNeibRefPOC; |
---|
| 3423 | |
---|
| 3424 | |
---|
| 3425 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
---|
| 3426 | { |
---|
| 3427 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
| 3428 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
---|
| 3429 | { |
---|
| 3430 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
| 3431 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
---|
| 3432 | return true; |
---|
| 3433 | } |
---|
| 3434 | } |
---|
| 3435 | return false; |
---|
| 3436 | } |
---|
| 3437 | |
---|
| 3438 | /** |
---|
| 3439 | * \param pInfo |
---|
| 3440 | * \param eRefPicList |
---|
| 3441 | * \param iRefIdx |
---|
| 3442 | * \param uiPartUnitIdx |
---|
| 3443 | * \param eDir |
---|
| 3444 | * \returns Bool |
---|
| 3445 | */ |
---|
| 3446 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
---|
| 3447 | { |
---|
| 3448 | TComDataCU* pcTmpCU = NULL; |
---|
| 3449 | UInt uiIdx; |
---|
| 3450 | switch( eDir ) |
---|
| 3451 | { |
---|
| 3452 | case MD_LEFT: |
---|
| 3453 | { |
---|
| 3454 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
---|
| 3455 | break; |
---|
| 3456 | } |
---|
| 3457 | case MD_ABOVE: |
---|
| 3458 | { |
---|
| 3459 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
---|
| 3460 | break; |
---|
| 3461 | } |
---|
| 3462 | case MD_ABOVE_RIGHT: |
---|
| 3463 | { |
---|
| 3464 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
---|
| 3465 | break; |
---|
| 3466 | } |
---|
| 3467 | case MD_BELOW_LEFT: |
---|
| 3468 | { |
---|
| 3469 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
---|
| 3470 | break; |
---|
| 3471 | } |
---|
| 3472 | case MD_ABOVE_LEFT: |
---|
| 3473 | { |
---|
| 3474 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
---|
| 3475 | break; |
---|
| 3476 | } |
---|
| 3477 | default: |
---|
| 3478 | { |
---|
| 3479 | break; |
---|
| 3480 | } |
---|
| 3481 | } |
---|
| 3482 | |
---|
| 3483 | if ( pcTmpCU == NULL ) |
---|
| 3484 | { |
---|
| 3485 | return false; |
---|
| 3486 | } |
---|
| 3487 | |
---|
| 3488 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
---|
| 3489 | if( eRefPicList == REF_PIC_LIST_0 ) |
---|
| 3490 | { |
---|
| 3491 | eRefPicList2nd = REF_PIC_LIST_1; |
---|
| 3492 | } |
---|
| 3493 | else if ( eRefPicList == REF_PIC_LIST_1) |
---|
| 3494 | { |
---|
| 3495 | eRefPicList2nd = REF_PIC_LIST_0; |
---|
| 3496 | } |
---|
| 3497 | |
---|
| 3498 | Int iCurrPOC = m_pcSlice->getPOC(); |
---|
| 3499 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
---|
| 3500 | Int iNeibPOC = iCurrPOC; |
---|
| 3501 | Int iNeibRefPOC; |
---|
| 3502 | |
---|
| 3503 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
---|
| 3504 | Bool bIsNeibRefLongTerm = false; |
---|
| 3505 | //--------------- V1 (END) ------------------// |
---|
| 3506 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
---|
| 3507 | { |
---|
| 3508 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
---|
| 3509 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
---|
| 3510 | TComMv rcMv; |
---|
| 3511 | |
---|
| 3512 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
| 3513 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
| 3514 | { |
---|
| 3515 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
| 3516 | { |
---|
| 3517 | rcMv = cMvPred; |
---|
| 3518 | } |
---|
| 3519 | else |
---|
| 3520 | { |
---|
| 3521 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
| 3522 | if ( iScale == 4096 ) |
---|
| 3523 | { |
---|
| 3524 | rcMv = cMvPred; |
---|
| 3525 | } |
---|
| 3526 | else |
---|
| 3527 | { |
---|
| 3528 | rcMv = cMvPred.scaleMv( iScale ); |
---|
| 3529 | } |
---|
| 3530 | } |
---|
| 3531 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
| 3532 | return true; |
---|
| 3533 | } |
---|
| 3534 | } |
---|
| 3535 | //---------------------- V2(END) --------------------// |
---|
| 3536 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
---|
| 3537 | { |
---|
| 3538 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
---|
| 3539 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
---|
| 3540 | TComMv rcMv; |
---|
| 3541 | |
---|
| 3542 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); |
---|
| 3543 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
---|
| 3544 | { |
---|
| 3545 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
---|
| 3546 | { |
---|
| 3547 | rcMv = cMvPred; |
---|
| 3548 | } |
---|
| 3549 | else |
---|
| 3550 | { |
---|
| 3551 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
---|
| 3552 | if ( iScale == 4096 ) |
---|
| 3553 | { |
---|
| 3554 | rcMv = cMvPred; |
---|
| 3555 | } |
---|
| 3556 | else |
---|
| 3557 | { |
---|
| 3558 | rcMv = cMvPred.scaleMv( iScale ); |
---|
| 3559 | } |
---|
| 3560 | } |
---|
| 3561 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
---|
| 3562 | return true; |
---|
| 3563 | } |
---|
| 3564 | } |
---|
| 3565 | //---------------------- V3(END) --------------------// |
---|
| 3566 | return false; |
---|
| 3567 | } |
---|
| 3568 | |
---|
| 3569 | /** |
---|
| 3570 | * \param eRefPicList |
---|
| 3571 | * \param uiCUAddr |
---|
| 3572 | * \param uiPartUnitIdx |
---|
| 3573 | * \param riRefIdx |
---|
| 3574 | * \returns Bool |
---|
| 3575 | */ |
---|
| 3576 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ) |
---|
| 3577 | { |
---|
| 3578 | UInt uiAbsPartAddr = uiPartUnitIdx; |
---|
| 3579 | |
---|
| 3580 | RefPicList eColRefPicList; |
---|
| 3581 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
---|
| 3582 | TComMv cColMv; |
---|
| 3583 | |
---|
| 3584 | // use coldir. |
---|
| 3585 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
---|
| 3586 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
---|
| 3587 | if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE) |
---|
| 3588 | { |
---|
| 3589 | return false; |
---|
| 3590 | } |
---|
| 3591 | iCurrPOC = m_pcSlice->getPOC(); |
---|
| 3592 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
| 3593 | iColPOC = pColCU->getSlice()->getPOC(); |
---|
| 3594 | |
---|
| 3595 | if (pColCU->isIntra(uiAbsPartAddr)) |
---|
| 3596 | { |
---|
| 3597 | return false; |
---|
| 3598 | } |
---|
| 3599 | eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
---|
| 3600 | |
---|
| 3601 | Int iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
| 3602 | |
---|
| 3603 | if (iColRefIdx < 0 ) |
---|
| 3604 | { |
---|
| 3605 | eColRefPicList = RefPicList(1 - eColRefPicList); |
---|
| 3606 | iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
---|
| 3607 | |
---|
| 3608 | if (iColRefIdx < 0 ) |
---|
| 3609 | { |
---|
| 3610 | return false; |
---|
| 3611 | } |
---|
| 3612 | } |
---|
| 3613 | |
---|
| 3614 | // Scale the vector. |
---|
| 3615 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
---|
| 3616 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
---|
| 3617 | |
---|
| 3618 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
---|
| 3619 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
---|
| 3620 | Bool bIsColRefLongTerm = pColCU->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
---|
| 3621 | |
---|
| 3622 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
---|
| 3623 | { |
---|
| 3624 | return false; |
---|
| 3625 | } |
---|
| 3626 | |
---|
| 3627 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
---|
| 3628 | { |
---|
| 3629 | rcMv = cColMv; |
---|
| 3630 | } |
---|
| 3631 | else |
---|
| 3632 | { |
---|
| 3633 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
---|
| 3634 | if ( iScale == 4096 ) |
---|
| 3635 | { |
---|
| 3636 | rcMv = cColMv; |
---|
| 3637 | } |
---|
| 3638 | else |
---|
| 3639 | { |
---|
| 3640 | rcMv = cColMv.scaleMv( iScale ); |
---|
| 3641 | } |
---|
| 3642 | } |
---|
| 3643 | return true; |
---|
| 3644 | } |
---|
| 3645 | |
---|
| 3646 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
---|
| 3647 | { |
---|
| 3648 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
---|
| 3649 | } |
---|
| 3650 | |
---|
| 3651 | UInt TComDataCU::xGetComponentBits(Int iVal) |
---|
| 3652 | { |
---|
| 3653 | UInt uiLength = 1; |
---|
| 3654 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
| 3655 | |
---|
| 3656 | assert ( uiTemp ); |
---|
| 3657 | |
---|
| 3658 | while ( 1 != uiTemp ) |
---|
| 3659 | { |
---|
| 3660 | uiTemp >>= 1; |
---|
| 3661 | uiLength += 2; |
---|
| 3662 | } |
---|
| 3663 | |
---|
| 3664 | return uiLength; |
---|
| 3665 | } |
---|
| 3666 | |
---|
| 3667 | |
---|
| 3668 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
---|
| 3669 | { |
---|
| 3670 | Int iDiffPocD = iColPOC - iColRefPOC; |
---|
| 3671 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
---|
| 3672 | |
---|
| 3673 | if( iDiffPocD == iDiffPocB ) |
---|
| 3674 | { |
---|
| 3675 | return 4096; |
---|
| 3676 | } |
---|
| 3677 | else |
---|
| 3678 | { |
---|
| 3679 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
---|
| 3680 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
---|
| 3681 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
---|
| 3682 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
---|
| 3683 | return iScale; |
---|
| 3684 | } |
---|
| 3685 | } |
---|
| 3686 | |
---|
| 3687 | /** |
---|
| 3688 | * \param eCUMode |
---|
| 3689 | * \param uiPartIdx |
---|
| 3690 | * \param ruiPartIdxCenter |
---|
| 3691 | * \returns Void |
---|
| 3692 | */ |
---|
| 3693 | Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
---|
| 3694 | { |
---|
| 3695 | UInt uiPartAddr; |
---|
| 3696 | Int iPartWidth; |
---|
| 3697 | Int iPartHeight; |
---|
| 3698 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
---|
| 3699 | |
---|
| 3700 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
---|
| 3701 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
---|
| 3702 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInWidth() |
---|
| 3703 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
---|
| 3704 | } |
---|
| 3705 | |
---|
| 3706 | Void TComDataCU::compressMV() |
---|
| 3707 | { |
---|
| 3708 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
---|
| 3709 | if (scaleFactor > 0) |
---|
| 3710 | { |
---|
| 3711 | #if SVC_MVP |
---|
| 3712 | m_acCUMvField[0].compress(m_pePredMode, m_puhInterDir, scaleFactor); |
---|
| 3713 | m_acCUMvField[1].compress(m_pePredMode, m_puhInterDir, scaleFactor); |
---|
| 3714 | #else |
---|
| 3715 | m_acCUMvField[0].compress(m_pePredMode, scaleFactor); |
---|
| 3716 | m_acCUMvField[1].compress(m_pePredMode, scaleFactor); |
---|
| 3717 | #endif |
---|
| 3718 | } |
---|
| 3719 | } |
---|
| 3720 | |
---|
| 3721 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
---|
| 3722 | { |
---|
| 3723 | UInt uiCTXIdx; |
---|
| 3724 | UInt uiScanIdx; |
---|
| 3725 | UInt uiDirMode; |
---|
| 3726 | |
---|
| 3727 | if ( !bIsIntra ) |
---|
| 3728 | { |
---|
| 3729 | uiScanIdx = SCAN_DIAG; |
---|
| 3730 | return uiScanIdx; |
---|
| 3731 | } |
---|
| 3732 | |
---|
| 3733 | switch(uiWidth) |
---|
| 3734 | { |
---|
| 3735 | case 2: uiCTXIdx = 6; break; |
---|
| 3736 | case 4: uiCTXIdx = 5; break; |
---|
| 3737 | case 8: uiCTXIdx = 4; break; |
---|
| 3738 | case 16: uiCTXIdx = 3; break; |
---|
| 3739 | case 32: uiCTXIdx = 2; break; |
---|
| 3740 | case 64: uiCTXIdx = 1; break; |
---|
| 3741 | default: uiCTXIdx = 0; break; |
---|
| 3742 | } |
---|
| 3743 | |
---|
| 3744 | if ( bIsLuma ) |
---|
| 3745 | { |
---|
| 3746 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
---|
| 3747 | uiScanIdx = SCAN_DIAG; |
---|
| 3748 | if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size |
---|
| 3749 | { |
---|
| 3750 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
---|
| 3751 | } |
---|
| 3752 | } |
---|
| 3753 | else |
---|
| 3754 | { |
---|
| 3755 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
---|
| 3756 | if( uiDirMode == DM_CHROMA_IDX ) |
---|
| 3757 | { |
---|
| 3758 | // get number of partitions in current CU |
---|
| 3759 | UInt depth = getDepth(uiAbsPartIdx); |
---|
| 3760 | UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); |
---|
| 3761 | |
---|
| 3762 | // get luma mode from upper-left corner of current CU |
---|
| 3763 | uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); |
---|
| 3764 | } |
---|
| 3765 | uiScanIdx = SCAN_DIAG; |
---|
| 3766 | if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size |
---|
| 3767 | { |
---|
| 3768 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
---|
| 3769 | } |
---|
| 3770 | } |
---|
| 3771 | |
---|
| 3772 | return uiScanIdx; |
---|
| 3773 | } |
---|
| 3774 | |
---|
| 3775 | UInt TComDataCU::getSCUAddr() |
---|
| 3776 | { |
---|
| 3777 | return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; |
---|
| 3778 | } |
---|
| 3779 | |
---|
| 3780 | /** Set neighboring blocks availabilities for non-deblocked filtering |
---|
| 3781 | * \param numLCUInPicWidth number of LCUs in picture width |
---|
| 3782 | * \param numLCUInPicHeight number of LCUs in picture height |
---|
| 3783 | * \param numSUInLCUWidth number of SUs in LCU width |
---|
| 3784 | * \param numSUInLCUHeight number of SUs in LCU height |
---|
| 3785 | * \param picWidth picture width |
---|
| 3786 | * \param picHeight picture height |
---|
| 3787 | * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled |
---|
| 3788 | * \param bTopTileBoundary true means that top boundary coincides tile boundary |
---|
| 3789 | * \param bDownTileBoundary true means that bottom boundary coincides tile boundary |
---|
| 3790 | * \param bLeftTileBoundary true means that left boundary coincides tile boundary |
---|
| 3791 | * \param bRightTileBoundary true means that right boundary coincides tile boundary |
---|
| 3792 | * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled |
---|
| 3793 | */ |
---|
| 3794 | Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt /*numLCUInPicHeight*/, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight |
---|
| 3795 | ,std::vector<Bool>& LFCrossSliceBoundary |
---|
| 3796 | ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary |
---|
| 3797 | ,Bool bIndependentTileBoundaryEnabled) |
---|
| 3798 | { |
---|
| 3799 | UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight; |
---|
| 3800 | Int* pSliceIDMapLCU = m_piSliceSUMap; |
---|
| 3801 | Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1); |
---|
| 3802 | UInt uiLPelX, uiTPelY; |
---|
| 3803 | UInt width, height; |
---|
| 3804 | Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary; |
---|
| 3805 | Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false; |
---|
| 3806 | Bool* pbAvailBorder; |
---|
| 3807 | Bool* pbAvail; |
---|
| 3808 | UInt rTLSU, rBRSU, widthSU, heightSU; |
---|
| 3809 | UInt zRefSU; |
---|
| 3810 | Int* pRefID; |
---|
| 3811 | Int* pRefMapLCU; |
---|
| 3812 | UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0; |
---|
| 3813 | Int* pRRefMapLCU= NULL; |
---|
| 3814 | Int* pLRefMapLCU= NULL; |
---|
| 3815 | Int* pTRefMapLCU= NULL; |
---|
| 3816 | Int* pBRefMapLCU= NULL; |
---|
| 3817 | Int sliceID; |
---|
| 3818 | UInt numSGU = (UInt)m_vNDFBlock.size(); |
---|
| 3819 | |
---|
| 3820 | for(Int i=0; i< numSGU; i++) |
---|
| 3821 | { |
---|
| 3822 | NDBFBlockInfo& rSGU = m_vNDFBlock[i]; |
---|
| 3823 | |
---|
| 3824 | sliceID = rSGU.sliceID; |
---|
| 3825 | uiLPelX = rSGU.posX; |
---|
| 3826 | uiTPelY = rSGU.posY; |
---|
| 3827 | width = rSGU.width; |
---|
| 3828 | height = rSGU.height; |
---|
| 3829 | rTLSU = g_auiZscanToRaster[ rSGU.startSU ]; |
---|
| 3830 | rBRSU = g_auiZscanToRaster[ rSGU.endSU ]; |
---|
| 3831 | widthSU = rSGU.widthSU; |
---|
| 3832 | heightSU = rSGU.heightSU; |
---|
| 3833 | |
---|
| 3834 | pbAvailBorder = rSGU.isBorderAvailable; |
---|
| 3835 | |
---|
| 3836 | bPicTBoundary= (uiTPelY == 0 )?(true):(false); |
---|
| 3837 | bPicLBoundary= (uiLPelX == 0 )?(true):(false); |
---|
| 3838 | bPicRBoundary= (!(uiLPelX+ width < picWidth ) )?(true):(false); |
---|
| 3839 | bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false); |
---|
| 3840 | |
---|
| 3841 | bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false); |
---|
| 3842 | bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false); |
---|
| 3843 | bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false); |
---|
| 3844 | bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false); |
---|
| 3845 | |
---|
| 3846 | // SGU_L |
---|
| 3847 | pbAvail = &(pbAvailBorder[SGU_L]); |
---|
| 3848 | if(bPicLBoundary) |
---|
| 3849 | { |
---|
| 3850 | *pbAvail = false; |
---|
| 3851 | } |
---|
| 3852 | else if (onlyOneSliceInPic) |
---|
| 3853 | { |
---|
| 3854 | *pbAvail = true; |
---|
| 3855 | } |
---|
| 3856 | else |
---|
| 3857 | { |
---|
| 3858 | // bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
| 3859 | if(bLCULBoundary) |
---|
| 3860 | { |
---|
| 3861 | rLRefSU = rTLSU + numSUInLCUWidth -1; |
---|
| 3862 | zRefSU = g_auiRasterToZscan[rLRefSU]; |
---|
| 3863 | pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU); |
---|
| 3864 | } |
---|
| 3865 | else |
---|
| 3866 | { |
---|
| 3867 | zRefSU = g_auiRasterToZscan[rTLSU - 1]; |
---|
| 3868 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3869 | } |
---|
| 3870 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3871 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3872 | } |
---|
| 3873 | |
---|
| 3874 | // SGU_R |
---|
| 3875 | pbAvail = &(pbAvailBorder[SGU_R]); |
---|
| 3876 | if(bPicRBoundary) |
---|
| 3877 | { |
---|
| 3878 | *pbAvail = false; |
---|
| 3879 | } |
---|
| 3880 | else if (onlyOneSliceInPic) |
---|
| 3881 | { |
---|
| 3882 | *pbAvail = true; |
---|
| 3883 | } |
---|
| 3884 | else |
---|
| 3885 | { |
---|
| 3886 | // bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false); |
---|
| 3887 | if(bLCURBoundary) |
---|
| 3888 | { |
---|
| 3889 | rRRefSU = rTLSU + widthSU - numSUInLCUWidth; |
---|
| 3890 | zRefSU = g_auiRasterToZscan[rRRefSU]; |
---|
| 3891 | pRefMapLCU = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU); |
---|
| 3892 | } |
---|
| 3893 | else |
---|
| 3894 | { |
---|
| 3895 | zRefSU = g_auiRasterToZscan[rTLSU + widthSU]; |
---|
| 3896 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3897 | } |
---|
| 3898 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3899 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3900 | } |
---|
| 3901 | |
---|
| 3902 | // SGU_T |
---|
| 3903 | pbAvail = &(pbAvailBorder[SGU_T]); |
---|
| 3904 | if(bPicTBoundary) |
---|
| 3905 | { |
---|
| 3906 | *pbAvail = false; |
---|
| 3907 | } |
---|
| 3908 | else if (onlyOneSliceInPic) |
---|
| 3909 | { |
---|
| 3910 | *pbAvail = true; |
---|
| 3911 | } |
---|
| 3912 | else |
---|
| 3913 | { |
---|
| 3914 | // bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false); |
---|
| 3915 | if(bLCUTBoundary) |
---|
| 3916 | { |
---|
| 3917 | rTRefSU = numSUInLCU - (numSUInLCUWidth - rTLSU); |
---|
| 3918 | zRefSU = g_auiRasterToZscan[rTRefSU]; |
---|
| 3919 | pRefMapLCU = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU)); |
---|
| 3920 | } |
---|
| 3921 | else |
---|
| 3922 | { |
---|
| 3923 | zRefSU = g_auiRasterToZscan[rTLSU - numSUInLCUWidth]; |
---|
| 3924 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3925 | } |
---|
| 3926 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3927 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3928 | } |
---|
| 3929 | |
---|
| 3930 | // SGU_B |
---|
| 3931 | pbAvail = &(pbAvailBorder[SGU_B]); |
---|
| 3932 | if(bPicBBoundary) |
---|
| 3933 | { |
---|
| 3934 | *pbAvail = false; |
---|
| 3935 | } |
---|
| 3936 | else if (onlyOneSliceInPic) |
---|
| 3937 | { |
---|
| 3938 | *pbAvail = true; |
---|
| 3939 | } |
---|
| 3940 | else |
---|
| 3941 | { |
---|
| 3942 | // bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false); |
---|
| 3943 | if(bLCUBBoundary) |
---|
| 3944 | { |
---|
| 3945 | rBRefSU = rTLSU % numSUInLCUWidth; |
---|
| 3946 | zRefSU = g_auiRasterToZscan[rBRefSU]; |
---|
| 3947 | pRefMapLCU = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU)); |
---|
| 3948 | } |
---|
| 3949 | else |
---|
| 3950 | { |
---|
| 3951 | zRefSU = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)]; |
---|
| 3952 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3953 | } |
---|
| 3954 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3955 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3956 | } |
---|
| 3957 | |
---|
| 3958 | // SGU_TL |
---|
| 3959 | pbAvail = &(pbAvailBorder[SGU_TL]); |
---|
| 3960 | if(bPicTBoundary || bPicLBoundary) |
---|
| 3961 | { |
---|
| 3962 | *pbAvail = false; |
---|
| 3963 | } |
---|
| 3964 | else if (onlyOneSliceInPic) |
---|
| 3965 | { |
---|
| 3966 | *pbAvail = true; |
---|
| 3967 | } |
---|
| 3968 | else |
---|
| 3969 | { |
---|
| 3970 | if(bLCUTBoundary && bLCULBoundary) |
---|
| 3971 | { |
---|
| 3972 | zRefSU = numSUInLCU -1; |
---|
| 3973 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
| 3974 | } |
---|
| 3975 | else if(bLCUTBoundary) |
---|
| 3976 | { |
---|
| 3977 | zRefSU = g_auiRasterToZscan[ rTRefSU- 1]; |
---|
| 3978 | pRefMapLCU = pTRefMapLCU; |
---|
| 3979 | } |
---|
| 3980 | else if(bLCULBoundary) |
---|
| 3981 | { |
---|
| 3982 | zRefSU = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ]; |
---|
| 3983 | pRefMapLCU = pLRefMapLCU; |
---|
| 3984 | } |
---|
| 3985 | else //inside LCU |
---|
| 3986 | { |
---|
| 3987 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1]; |
---|
| 3988 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 3989 | } |
---|
| 3990 | pRefID = pRefMapLCU + zRefSU; |
---|
| 3991 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 3992 | } |
---|
| 3993 | |
---|
| 3994 | // SGU_TR |
---|
| 3995 | pbAvail = &(pbAvailBorder[SGU_TR]); |
---|
| 3996 | if(bPicTBoundary || bPicRBoundary) |
---|
| 3997 | { |
---|
| 3998 | *pbAvail = false; |
---|
| 3999 | } |
---|
| 4000 | else if (onlyOneSliceInPic) |
---|
| 4001 | { |
---|
| 4002 | *pbAvail = true; |
---|
| 4003 | } |
---|
| 4004 | else |
---|
| 4005 | { |
---|
| 4006 | if(bLCUTBoundary && bLCURBoundary) |
---|
| 4007 | { |
---|
| 4008 | zRefSU = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth]; |
---|
| 4009 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
| 4010 | } |
---|
| 4011 | else if(bLCUTBoundary) |
---|
| 4012 | { |
---|
| 4013 | zRefSU = g_auiRasterToZscan[ rTRefSU+ widthSU]; |
---|
| 4014 | pRefMapLCU = pTRefMapLCU; |
---|
| 4015 | } |
---|
| 4016 | else if(bLCURBoundary) |
---|
| 4017 | { |
---|
| 4018 | zRefSU = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ]; |
---|
| 4019 | pRefMapLCU = pRRefMapLCU; |
---|
| 4020 | } |
---|
| 4021 | else //inside LCU |
---|
| 4022 | { |
---|
| 4023 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU]; |
---|
| 4024 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 4025 | } |
---|
| 4026 | pRefID = pRefMapLCU + zRefSU; |
---|
| 4027 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 4028 | } |
---|
| 4029 | |
---|
| 4030 | // SGU_BL |
---|
| 4031 | pbAvail = &(pbAvailBorder[SGU_BL]); |
---|
| 4032 | if(bPicBBoundary || bPicLBoundary) |
---|
| 4033 | { |
---|
| 4034 | *pbAvail = false; |
---|
| 4035 | } |
---|
| 4036 | else if (onlyOneSliceInPic) |
---|
| 4037 | { |
---|
| 4038 | *pbAvail = true; |
---|
| 4039 | } |
---|
| 4040 | else |
---|
| 4041 | { |
---|
| 4042 | if(bLCUBBoundary && bLCULBoundary) |
---|
| 4043 | { |
---|
| 4044 | zRefSU = g_auiRasterToZscan[numSUInLCUWidth - 1]; |
---|
| 4045 | pRefMapLCU = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU); |
---|
| 4046 | } |
---|
| 4047 | else if(bLCUBBoundary) |
---|
| 4048 | { |
---|
| 4049 | zRefSU = g_auiRasterToZscan[ rBRefSU - 1]; |
---|
| 4050 | pRefMapLCU = pBRefMapLCU; |
---|
| 4051 | } |
---|
| 4052 | else if(bLCULBoundary) |
---|
| 4053 | { |
---|
| 4054 | zRefSU = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ]; |
---|
| 4055 | pRefMapLCU = pLRefMapLCU; |
---|
| 4056 | } |
---|
| 4057 | else //inside LCU |
---|
| 4058 | { |
---|
| 4059 | zRefSU = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1]; |
---|
| 4060 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 4061 | } |
---|
| 4062 | pRefID = pRefMapLCU + zRefSU; |
---|
| 4063 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 4064 | } |
---|
| 4065 | |
---|
| 4066 | // SGU_BR |
---|
| 4067 | pbAvail = &(pbAvailBorder[SGU_BR]); |
---|
| 4068 | if(bPicBBoundary || bPicRBoundary) |
---|
| 4069 | { |
---|
| 4070 | *pbAvail = false; |
---|
| 4071 | } |
---|
| 4072 | else if (onlyOneSliceInPic) |
---|
| 4073 | { |
---|
| 4074 | *pbAvail = true; |
---|
| 4075 | } |
---|
| 4076 | else |
---|
| 4077 | { |
---|
| 4078 | if(bLCUBBoundary && bLCURBoundary) |
---|
| 4079 | { |
---|
| 4080 | zRefSU = 0; |
---|
| 4081 | pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU); |
---|
| 4082 | } |
---|
| 4083 | else if(bLCUBBoundary) |
---|
| 4084 | { |
---|
| 4085 | zRefSU = g_auiRasterToZscan[ rBRefSU + widthSU]; |
---|
| 4086 | pRefMapLCU = pBRefMapLCU; |
---|
| 4087 | } |
---|
| 4088 | else if(bLCURBoundary) |
---|
| 4089 | { |
---|
| 4090 | zRefSU = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)]; |
---|
| 4091 | pRefMapLCU = pRRefMapLCU; |
---|
| 4092 | } |
---|
| 4093 | else //inside LCU |
---|
| 4094 | { |
---|
| 4095 | zRefSU = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU]; |
---|
| 4096 | pRefMapLCU = pSliceIDMapLCU; |
---|
| 4097 | } |
---|
| 4098 | pRefID = pRefMapLCU + zRefSU; |
---|
| 4099 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
---|
| 4100 | } |
---|
| 4101 | |
---|
| 4102 | if(bIndependentTileBoundaryEnabled) |
---|
| 4103 | { |
---|
| 4104 | //left LCU boundary |
---|
| 4105 | if(!bPicLBoundary && bLCULBoundary) |
---|
| 4106 | { |
---|
| 4107 | if(bLeftTileBoundary) |
---|
| 4108 | { |
---|
| 4109 | pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false; |
---|
| 4110 | } |
---|
| 4111 | } |
---|
| 4112 | //right LCU boundary |
---|
| 4113 | if(!bPicRBoundary && bLCURBoundary) |
---|
| 4114 | { |
---|
| 4115 | if(bRightTileBoundary) |
---|
| 4116 | { |
---|
| 4117 | pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false; |
---|
| 4118 | } |
---|
| 4119 | } |
---|
| 4120 | //top LCU boundary |
---|
| 4121 | if(!bPicTBoundary && bLCUTBoundary) |
---|
| 4122 | { |
---|
| 4123 | if(bTopTileBoundary) |
---|
| 4124 | { |
---|
| 4125 | pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false; |
---|
| 4126 | } |
---|
| 4127 | } |
---|
| 4128 | //down LCU boundary |
---|
| 4129 | if(!bPicBBoundary && bLCUBBoundary) |
---|
| 4130 | { |
---|
| 4131 | if(bDownTileBoundary) |
---|
| 4132 | { |
---|
| 4133 | pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false; |
---|
| 4134 | } |
---|
| 4135 | } |
---|
| 4136 | } |
---|
| 4137 | rSGU.allBordersAvailable = true; |
---|
| 4138 | for(Int b=0; b< NUM_SGU_BORDER; b++) |
---|
| 4139 | { |
---|
| 4140 | if(pbAvailBorder[b] == false) |
---|
| 4141 | { |
---|
| 4142 | rSGU.allBordersAvailable = false; |
---|
| 4143 | break; |
---|
| 4144 | } |
---|
| 4145 | } |
---|
| 4146 | } |
---|
| 4147 | } |
---|
| 4148 | |
---|
| 4149 | #if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED |
---|
| 4150 | Void TComDataCU::getBaseLumaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride ) |
---|
| 4151 | { |
---|
| 4152 | TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec(); |
---|
| 4153 | UInt uiStrideBase = pcBaseRec->getStride(); |
---|
| 4154 | Pel* piBase = pcBaseRec->getLumaAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 4155 | |
---|
| 4156 | for ( UInt y = 0; y < uiHeight; y ++ ) |
---|
| 4157 | { |
---|
| 4158 | memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) ); |
---|
| 4159 | } |
---|
| 4160 | } |
---|
| 4161 | |
---|
| 4162 | Void TComDataCU::getBaseChromaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, UInt uiChromaId ) |
---|
| 4163 | { |
---|
| 4164 | TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec(); |
---|
| 4165 | |
---|
| 4166 | UInt uiStrideBase = pcBaseRec->getCStride(); |
---|
| 4167 | Pel* piBase; |
---|
| 4168 | |
---|
| 4169 | if( uiChromaId == 0 ) |
---|
| 4170 | { |
---|
| 4171 | piBase = pcBaseRec->getCbAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 4172 | } |
---|
| 4173 | else |
---|
| 4174 | { |
---|
| 4175 | piBase = pcBaseRec->getCrAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx ); |
---|
| 4176 | } |
---|
| 4177 | |
---|
| 4178 | for ( UInt y = 0; y < uiHeight; y ++ ) |
---|
| 4179 | { |
---|
| 4180 | memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) ); |
---|
| 4181 | } |
---|
| 4182 | } |
---|
| 4183 | |
---|
| 4184 | #endif |
---|
| 4185 | |
---|
| 4186 | #if SVC_COL_BLK |
---|
[253] | 4187 | TComDataCU* TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase ) |
---|
[210] | 4188 | { |
---|
| 4189 | #if 1 // it should provide identical resutls |
---|
| 4190 | UInt uiPelX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiCuAbsPartIdx] ]; |
---|
| 4191 | UInt uiPelY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiCuAbsPartIdx] ]; |
---|
| 4192 | |
---|
[253] | 4193 | return getBaseColCU( refLayerIdc, uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase ); |
---|
[210] | 4194 | #else |
---|
| 4195 | TComPic* cBaseColPic = m_pcSlice->getBaseColPic(); |
---|
| 4196 | |
---|
| 4197 | #if SVC_UPSAMPLING |
---|
| 4198 | Int widthBL = cBaseColPic->getPicYuvRec()->getWidth () - cBaseColPic->getPicYuvRec()->getPicCropLeftOffset() - cBaseColPic->getPicYuvRec()->getPicCropRightOffset(); |
---|
| 4199 | Int heightBL = cBaseColPic->getPicYuvRec()->getHeight() - cBaseColPic->getPicYuvRec()->getPicCropTopOffset() - cBaseColPic->getPicYuvRec()->getPicCropBottomOffset(); |
---|
| 4200 | |
---|
| 4201 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth() - m_pcPic->getPicYuvRec()->getPicCropLeftOffset() - m_pcPic->getPicYuvRec()->getPicCropRightOffset(); |
---|
| 4202 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight() - m_pcPic->getPicYuvRec()->getPicCropTopOffset() - m_pcPic->getPicYuvRec()->getPicCropBottomOffset(); |
---|
| 4203 | #else |
---|
| 4204 | Int widthBL = cBaseColPic->getPicYuvRec()->getWidth(); |
---|
| 4205 | Int heightBL = cBaseColPic->getPicYuvRec()->getHeight(); |
---|
| 4206 | |
---|
| 4207 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth(); |
---|
| 4208 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight(); |
---|
| 4209 | #endif |
---|
| 4210 | |
---|
| 4211 | if (widthBL == widthEL && heightEL == heightBL) |
---|
| 4212 | { |
---|
| 4213 | uiAbsPartIdxBase = uiCuAbsPartIdx + m_uiAbsIdxInLCU; |
---|
| 4214 | uiCUAddrBase = m_uiCUAddr; |
---|
| 4215 | } |
---|
| 4216 | else |
---|
| 4217 | { |
---|
| 4218 | UInt uiMinUnitSize = m_pcPic->getMinCUWidth(); |
---|
| 4219 | UInt uiRasterAddr = g_auiZscanToRaster[uiCuAbsPartIdx]; |
---|
| 4220 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
---|
| 4221 | |
---|
| 4222 | Int iEX = m_uiCUPelX + uiMinUnitSize*(uiRasterAddr%uiNumPartInCUWidth); |
---|
| 4223 | Int iEY = m_uiCUPelY + uiMinUnitSize*(uiRasterAddr/uiNumPartInCUWidth); |
---|
| 4224 | |
---|
| 4225 | Int iBX = (iEX*widthBL + widthEL/2)/widthEL; |
---|
| 4226 | Int iBY = (iEY*heightBL+ heightEL/2)/heightEL; |
---|
| 4227 | |
---|
| 4228 | uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth); |
---|
| 4229 | |
---|
| 4230 | assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame()); |
---|
| 4231 | |
---|
| 4232 | UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth() |
---|
| 4233 | + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize; |
---|
| 4234 | |
---|
| 4235 | uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase]; |
---|
| 4236 | } |
---|
| 4237 | |
---|
| 4238 | return cBaseColPic->getCU(uiCUAddrBase); |
---|
| 4239 | #endif |
---|
| 4240 | } |
---|
| 4241 | |
---|
[253] | 4242 | TComDataCU* TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase ) |
---|
[210] | 4243 | { |
---|
[253] | 4244 | TComPic* cBaseColPic = m_pcSlice->getBaseColPic(refLayerIdc); |
---|
[210] | 4245 | |
---|
| 4246 | #if !SIMPLIFIED_MV_POS_SCALING |
---|
| 4247 | #if SVC_UPSAMPLING && !ILP_DECODED_PICTURE |
---|
| 4248 | const Window &confBL = cBaseColPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 4249 | const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 4250 | |
---|
| 4251 | Int widthBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
| 4252 | Int heightBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
| 4253 | |
---|
| 4254 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); |
---|
| 4255 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); |
---|
| 4256 | #else |
---|
| 4257 | Int widthBL = cBaseColPic->getPicYuvRec()->getWidth(); |
---|
| 4258 | Int heightBL = cBaseColPic->getPicYuvRec()->getHeight(); |
---|
| 4259 | |
---|
| 4260 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth(); |
---|
| 4261 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight(); |
---|
| 4262 | #endif |
---|
| 4263 | #endif |
---|
| 4264 | |
---|
| 4265 | uiPelX = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getWidth() - 1, uiPelX); |
---|
| 4266 | uiPelY = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getHeight() - 1, uiPelY); |
---|
| 4267 | |
---|
| 4268 | UInt uiMinUnitSize = m_pcPic->getMinCUWidth(); |
---|
| 4269 | |
---|
| 4270 | #if SIMPLIFIED_MV_POS_SCALING |
---|
| 4271 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 4272 | Int leftStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowLeftOffset(); |
---|
| 4273 | Int topStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowTopOffset(); |
---|
[253] | 4274 | Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16; |
---|
| 4275 | Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16; |
---|
[210] | 4276 | #else |
---|
[253] | 4277 | Int iBX = (uiPelX*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16; |
---|
| 4278 | Int iBY = (uiPelY*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16; |
---|
[210] | 4279 | #endif |
---|
| 4280 | #else |
---|
| 4281 | Int iBX = (uiPelX*widthBL + widthEL/2)/widthEL; |
---|
| 4282 | Int iBY = (uiPelY*heightBL+ heightEL/2)/heightEL; |
---|
| 4283 | #endif |
---|
| 4284 | |
---|
| 4285 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 4286 | if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight() || |
---|
| 4287 | iBX < 0 || iBY < 0 ) |
---|
| 4288 | #else |
---|
| 4289 | if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight()) |
---|
| 4290 | #endif |
---|
| 4291 | { |
---|
| 4292 | return NULL; |
---|
| 4293 | } |
---|
| 4294 | |
---|
| 4295 | #if AVC_SYNTAX && !ILP_DECODED_PICTURE |
---|
| 4296 | #if !ILP_DECODED_PICTURE |
---|
| 4297 | const Window &confBL = cBaseColPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 4298 | const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 4299 | |
---|
[253] | 4300 | Int widthBL = m_pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
| 4301 | Int heightBL = m_pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
[210] | 4302 | #endif |
---|
| 4303 | if( iBX >= widthBL || iBY >= heightBL ) //outside of the reference layer cropped picture |
---|
| 4304 | { |
---|
| 4305 | return NULL; |
---|
| 4306 | } |
---|
| 4307 | #endif |
---|
| 4308 | |
---|
| 4309 | uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth); |
---|
| 4310 | |
---|
| 4311 | assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame()); |
---|
| 4312 | |
---|
| 4313 | UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth() |
---|
| 4314 | + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize; |
---|
| 4315 | |
---|
| 4316 | uiAbsPartIdxBase = g_auiRasterToZscan[uiRasterAddrBase]; |
---|
| 4317 | |
---|
| 4318 | return cBaseColPic->getCU(uiCUAddrBase); |
---|
| 4319 | } |
---|
| 4320 | |
---|
[254] | 4321 | Void TComDataCU::scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase ) |
---|
[210] | 4322 | { |
---|
| 4323 | TComMvField cMvFieldBase; |
---|
| 4324 | TComMv cMv; |
---|
| 4325 | #if SIMPLIFIED_MV_POS_SCALING |
---|
[254] | 4326 | cMv = rcMvFieldBase.getMv().scaleMv( g_mvScalingFactor[refLayerIdc][0], g_mvScalingFactor[refLayerIdc][1] ); |
---|
[210] | 4327 | #else |
---|
| 4328 | const Window &confBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow(); |
---|
| 4329 | const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 4330 | |
---|
| 4331 | Int widthBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
| 4332 | Int heightBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
| 4333 | |
---|
| 4334 | Int widthEL = m_pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); |
---|
| 4335 | Int heightEL = m_pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); |
---|
| 4336 | |
---|
| 4337 | Int iMvX = (rcMvFieldBase.getHor()*widthEL + (widthBL/2 -1) * (rcMvFieldBase.getHor() > 0 ? 1: -1) )/widthBL; |
---|
| 4338 | Int iMvY = (rcMvFieldBase.getVer()*heightEL + (heightBL/2 -1) * (rcMvFieldBase.getVer() > 0 ? 1: -1) )/heightBL; |
---|
| 4339 | |
---|
| 4340 | cMv.set(iMvX, iMvY); |
---|
| 4341 | #endif |
---|
| 4342 | |
---|
| 4343 | rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() ); |
---|
| 4344 | } |
---|
| 4345 | #endif |
---|
| 4346 | |
---|
| 4347 | #if SVC_MVP |
---|
| 4348 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, UChar uchInterDir, TComMvField* pcMvField ) |
---|
| 4349 | { |
---|
| 4350 | if ( getInterDir( uiAbsPartIdx ) != uchInterDir ) |
---|
| 4351 | { |
---|
| 4352 | return false; |
---|
| 4353 | } |
---|
| 4354 | |
---|
| 4355 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 4356 | { |
---|
| 4357 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
---|
| 4358 | { |
---|
| 4359 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getMv() || |
---|
| 4360 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getRefIdx() ) |
---|
| 4361 | { |
---|
| 4362 | return false; |
---|
| 4363 | } |
---|
| 4364 | } |
---|
| 4365 | } |
---|
| 4366 | |
---|
| 4367 | return true; |
---|
| 4368 | } |
---|
| 4369 | #endif |
---|
| 4370 | |
---|
| 4371 | //! \} |
---|