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