| 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 | #if H_3D_DIM |
|---|
| 112 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
|---|
| 113 | { |
|---|
| 114 | m_dimDeltaDC[i][0] = NULL; |
|---|
| 115 | m_dimDeltaDC[i][1] = NULL; |
|---|
| 116 | } |
|---|
| 117 | #if H_3D_DIM_DMM |
|---|
| 118 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 119 | { |
|---|
| 120 | m_dmmWedgeTabIdx[i] = NULL; |
|---|
| 121 | } |
|---|
| 122 | #if !SEC_DMM2_E0146 |
|---|
| 123 | m_dmm2DeltaEnd = NULL; |
|---|
| 124 | #endif |
|---|
| 125 | m_dmm3IntraTabIdx = NULL; |
|---|
| 126 | #endif |
|---|
| 127 | #if H_3D_DIM_RBC |
|---|
| 128 | m_pucEdgeCode = NULL; |
|---|
| 129 | m_pucEdgeNumber = NULL; |
|---|
| 130 | m_pucEdgeStartPos = NULL; |
|---|
| 131 | m_pbEdgeLeftFirst = NULL; |
|---|
| 132 | m_pbEdgePartition = NULL; |
|---|
| 133 | #endif |
|---|
| 134 | #if H_3D_DIM_SDC |
|---|
| 135 | m_pbSDCFlag = NULL; |
|---|
| 136 | m_apSegmentDCOffset[0] = NULL; |
|---|
| 137 | m_apSegmentDCOffset[1] = NULL; |
|---|
| 138 | #endif |
|---|
| 139 | #endif |
|---|
| 140 | m_bDecSubCu = false; |
|---|
| 141 | m_sliceStartCU = 0; |
|---|
| 142 | m_sliceSegmentStartCU = 0; |
|---|
| 143 | #if H_3D_NBDV |
|---|
| 144 | m_pDvInfo = NULL; |
|---|
| 145 | #endif |
|---|
| 146 | #if H_3D_VSP |
|---|
| 147 | m_piVSPFlag = NULL; |
|---|
| 148 | #if MTK_VSP_FIX_E0172 |
|---|
| 149 | m_piVSPDir = NULL; |
|---|
| 150 | #endif |
|---|
| 151 | #endif |
|---|
| 152 | #if H_3D_ARP |
|---|
| 153 | m_puhARPW = NULL; |
|---|
| 154 | #endif |
|---|
| 155 | #if H_3D_IC |
|---|
| 156 | m_pbICFlag = NULL; |
|---|
| 157 | #endif |
|---|
| 158 | #if LGE_INTER_SDC_E0156 |
|---|
| 159 | m_pbInterSDCFlag = NULL; |
|---|
| 160 | for( Int i = 0; i < 4; i++ ) |
|---|
| 161 | { |
|---|
| 162 | m_apSegmentInterDCOffset[i] = NULL; |
|---|
| 163 | } |
|---|
| 164 | m_pucInterSDCMask = NULL; |
|---|
| 165 | #endif |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | TComDataCU::~TComDataCU() |
|---|
| 169 | { |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | Void TComDataCU::create(UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize |
|---|
| 173 | #if ADAPTIVE_QP_SELECTION |
|---|
| 174 | , Bool bGlobalRMARLBuffer |
|---|
| 175 | #endif |
|---|
| 176 | ) |
|---|
| 177 | { |
|---|
| 178 | m_bDecSubCu = bDecSubCu; |
|---|
| 179 | |
|---|
| 180 | m_pcPic = NULL; |
|---|
| 181 | m_pcSlice = NULL; |
|---|
| 182 | m_uiNumPartition = uiNumPartition; |
|---|
| 183 | m_unitSize = unitSize; |
|---|
| 184 | |
|---|
| 185 | if ( !bDecSubCu ) |
|---|
| 186 | { |
|---|
| 187 | m_phQP = (Char* )xMalloc(Char, uiNumPartition); |
|---|
| 188 | m_puhDepth = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 189 | m_puhWidth = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 190 | m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 191 | |
|---|
| 192 | m_skipFlag = new Bool[ uiNumPartition ]; |
|---|
| 193 | |
|---|
| 194 | m_pePartSize = new Char[ uiNumPartition ]; |
|---|
| 195 | memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) ); |
|---|
| 196 | m_pePredMode = new Char[ uiNumPartition ]; |
|---|
| 197 | m_CUTransquantBypass = new Bool[ uiNumPartition ]; |
|---|
| 198 | m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
|---|
| 199 | m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 200 | #if H_3D_VSP |
|---|
| 201 | m_piVSPFlag = (Char* )xMalloc(Char, uiNumPartition); |
|---|
| 202 | #if MTK_VSP_FIX_E0172 |
|---|
| 203 | m_piVSPDir = (Char* )xMalloc(Char, uiNumPartition); |
|---|
| 204 | #endif |
|---|
| 205 | #endif |
|---|
| 206 | m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 207 | m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 208 | m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 209 | |
|---|
| 210 | m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 211 | m_puhTransformSkip[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 212 | m_puhTransformSkip[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 213 | m_puhTransformSkip[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 214 | |
|---|
| 215 | m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 216 | m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 217 | m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); |
|---|
| 218 | |
|---|
| 219 | m_apiMVPIdx[0] = new Char[ uiNumPartition ]; |
|---|
| 220 | m_apiMVPIdx[1] = new Char[ uiNumPartition ]; |
|---|
| 221 | m_apiMVPNum[0] = new Char[ uiNumPartition ]; |
|---|
| 222 | m_apiMVPNum[1] = new Char[ uiNumPartition ]; |
|---|
| 223 | memset( m_apiMVPIdx[0], -1,uiNumPartition * sizeof( Char ) ); |
|---|
| 224 | memset( m_apiMVPIdx[1], -1,uiNumPartition * sizeof( Char ) ); |
|---|
| 225 | |
|---|
| 226 | m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); |
|---|
| 227 | m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
|---|
| 228 | m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); |
|---|
| 229 | #if H_3D_NBDV |
|---|
| 230 | m_pDvInfo = (DisInfo* )xMalloc(DisInfo, uiNumPartition); |
|---|
| 231 | #endif |
|---|
| 232 | memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) ); |
|---|
| 233 | memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
|---|
| 234 | memset( m_pcTrCoeffCr, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); |
|---|
| 235 | #if ADAPTIVE_QP_SELECTION |
|---|
| 236 | if( bGlobalRMARLBuffer ) |
|---|
| 237 | { |
|---|
| 238 | if( m_pcGlbArlCoeffY == NULL ) |
|---|
| 239 | { |
|---|
| 240 | m_pcGlbArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
|---|
| 241 | m_pcGlbArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
|---|
| 242 | m_pcGlbArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
|---|
| 243 | } |
|---|
| 244 | m_pcArlCoeffY = m_pcGlbArlCoeffY; |
|---|
| 245 | m_pcArlCoeffCb = m_pcGlbArlCoeffCb; |
|---|
| 246 | m_pcArlCoeffCr = m_pcGlbArlCoeffCr; |
|---|
| 247 | m_ArlCoeffIsAliasedAllocation = true; |
|---|
| 248 | } |
|---|
| 249 | else |
|---|
| 250 | { |
|---|
| 251 | m_pcArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); |
|---|
| 252 | m_pcArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
|---|
| 253 | m_pcArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); |
|---|
| 254 | } |
|---|
| 255 | #endif |
|---|
| 256 | |
|---|
| 257 | m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
|---|
| 258 | m_pcIPCMSampleY = (Pel* )xMalloc(Pel , uiWidth*uiHeight); |
|---|
| 259 | m_pcIPCMSampleCb = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
|---|
| 260 | m_pcIPCMSampleCr = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); |
|---|
| 261 | |
|---|
| 262 | m_acCUMvField[0].create( uiNumPartition ); |
|---|
| 263 | m_acCUMvField[1].create( uiNumPartition ); |
|---|
| 264 | |
|---|
| 265 | #if H_3D_ARP |
|---|
| 266 | m_puhARPW = new UChar[ uiNumPartition]; |
|---|
| 267 | #endif |
|---|
| 268 | #if H_3D_IC |
|---|
| 269 | m_pbICFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
|---|
| 270 | #endif |
|---|
| 271 | #if H_3D_DIM |
|---|
| 272 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
|---|
| 273 | { |
|---|
| 274 | m_dimDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition); |
|---|
| 275 | m_dimDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition); |
|---|
| 276 | } |
|---|
| 277 | #if H_3D_DIM_DMM |
|---|
| 278 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 279 | { |
|---|
| 280 | m_dmmWedgeTabIdx[i] = (UInt*)xMalloc(UInt, uiNumPartition); |
|---|
| 281 | } |
|---|
| 282 | #if !SEC_DMM2_E0146 |
|---|
| 283 | m_dmm2DeltaEnd = (Int* )xMalloc(Int, uiNumPartition); |
|---|
| 284 | #endif |
|---|
| 285 | m_dmm3IntraTabIdx = (UInt*)xMalloc(UInt, uiNumPartition); |
|---|
| 286 | #endif |
|---|
| 287 | #if H_3D_DIM_RBC |
|---|
| 288 | m_pucEdgeCode = (UChar*)xMalloc(UChar, uiNumPartition * RBC_MAX_EDGE_NUM_PER_4x4); |
|---|
| 289 | m_pucEdgeNumber = (UChar*)xMalloc(UChar, uiNumPartition); |
|---|
| 290 | m_pucEdgeStartPos = (UChar*)xMalloc(UChar, uiNumPartition); |
|---|
| 291 | m_pbEdgeLeftFirst = (Bool*)xMalloc(Bool, uiNumPartition); |
|---|
| 292 | m_pbEdgePartition = (Bool*)xMalloc(Bool, uiNumPartition * 16); |
|---|
| 293 | #endif |
|---|
| 294 | #if H_3D_DIM_SDC |
|---|
| 295 | m_pbSDCFlag = (Bool*)xMalloc(Bool, uiNumPartition); |
|---|
| 296 | m_apSegmentDCOffset[0] = (Pel*)xMalloc(Pel, uiNumPartition); |
|---|
| 297 | m_apSegmentDCOffset[1] = (Pel*)xMalloc(Pel, uiNumPartition); |
|---|
| 298 | #endif |
|---|
| 299 | #endif |
|---|
| 300 | #if LGE_INTER_SDC_E0156 |
|---|
| 301 | m_pbInterSDCFlag = (Bool* )xMalloc(Bool, uiNumPartition); |
|---|
| 302 | for( Int i = 0; i < 4; i++ ) |
|---|
| 303 | { |
|---|
| 304 | m_apSegmentInterDCOffset[i] = (Int*)xMalloc(Int, uiNumPartition); |
|---|
| 305 | } |
|---|
| 306 | #endif |
|---|
| 307 | } |
|---|
| 308 | else |
|---|
| 309 | { |
|---|
| 310 | m_acCUMvField[0].setNumPartition(uiNumPartition ); |
|---|
| 311 | m_acCUMvField[1].setNumPartition(uiNumPartition ); |
|---|
| 312 | } |
|---|
| 313 | #if LGE_INTER_SDC_E0156 |
|---|
| 314 | m_pucInterSDCMask = (UChar* )xMalloc(UChar, g_uiMaxCUHeight*g_uiMaxCUWidth); |
|---|
| 315 | #endif |
|---|
| 316 | m_sliceStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
|---|
| 317 | m_sliceSegmentStartCU = (UInt* )xMalloc(UInt, uiNumPartition); |
|---|
| 318 | |
|---|
| 319 | // create pattern memory |
|---|
| 320 | m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); |
|---|
| 321 | |
|---|
| 322 | // create motion vector fields |
|---|
| 323 | |
|---|
| 324 | m_pcCUAboveLeft = NULL; |
|---|
| 325 | m_pcCUAboveRight = NULL; |
|---|
| 326 | m_pcCUAbove = NULL; |
|---|
| 327 | m_pcCULeft = NULL; |
|---|
| 328 | |
|---|
| 329 | m_apcCUColocated[0] = NULL; |
|---|
| 330 | m_apcCUColocated[1] = NULL; |
|---|
| 331 | } |
|---|
| 332 | |
|---|
| 333 | Void TComDataCU::destroy() |
|---|
| 334 | { |
|---|
| 335 | m_pcPic = NULL; |
|---|
| 336 | m_pcSlice = NULL; |
|---|
| 337 | |
|---|
| 338 | if ( m_pcPattern ) |
|---|
| 339 | { |
|---|
| 340 | xFree(m_pcPattern); |
|---|
| 341 | m_pcPattern = NULL; |
|---|
| 342 | } |
|---|
| 343 | |
|---|
| 344 | // encoder-side buffer free |
|---|
| 345 | if ( !m_bDecSubCu ) |
|---|
| 346 | { |
|---|
| 347 | if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } |
|---|
| 348 | if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } |
|---|
| 349 | if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } |
|---|
| 350 | if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } |
|---|
| 351 | |
|---|
| 352 | if ( m_skipFlag ) { delete[] m_skipFlag; m_skipFlag = NULL; } |
|---|
| 353 | |
|---|
| 354 | if ( m_pePartSize ) { delete[] m_pePartSize; m_pePartSize = NULL; } |
|---|
| 355 | if ( m_pePredMode ) { delete[] m_pePredMode; m_pePredMode = NULL; } |
|---|
| 356 | if ( m_CUTransquantBypass ) { delete[] m_CUTransquantBypass;m_CUTransquantBypass = NULL; } |
|---|
| 357 | if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } |
|---|
| 358 | if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } |
|---|
| 359 | if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } |
|---|
| 360 | if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } |
|---|
| 361 | if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } |
|---|
| 362 | if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } |
|---|
| 363 | #if H_3D_VSP |
|---|
| 364 | if ( m_piVSPFlag ) { xFree(m_piVSPFlag); m_piVSPFlag = NULL; } |
|---|
| 365 | #if MTK_VSP_FIX_E0172 |
|---|
| 366 | if ( m_piVSPDir ) { xFree(m_piVSPDir ); m_piVSPDir = NULL; } |
|---|
| 367 | #endif |
|---|
| 368 | #endif |
|---|
| 369 | if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } |
|---|
| 370 | if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } |
|---|
| 371 | if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } |
|---|
| 372 | if ( m_puhTransformSkip[0]) { xFree(m_puhTransformSkip[0]); m_puhTransformSkip[0] = NULL; } |
|---|
| 373 | if ( m_puhTransformSkip[1]) { xFree(m_puhTransformSkip[1]); m_puhTransformSkip[1] = NULL; } |
|---|
| 374 | if ( m_puhTransformSkip[2]) { xFree(m_puhTransformSkip[2]); m_puhTransformSkip[2] = NULL; } |
|---|
| 375 | if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } |
|---|
| 376 | if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } |
|---|
| 377 | if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } |
|---|
| 378 | #if ADAPTIVE_QP_SELECTION |
|---|
| 379 | if (!m_ArlCoeffIsAliasedAllocation) |
|---|
| 380 | { |
|---|
| 381 | xFree(m_pcArlCoeffY); m_pcArlCoeffY = 0; |
|---|
| 382 | xFree(m_pcArlCoeffCb); m_pcArlCoeffCb = 0; |
|---|
| 383 | xFree(m_pcArlCoeffCr); m_pcArlCoeffCr = 0; |
|---|
| 384 | } |
|---|
| 385 | if ( m_pcGlbArlCoeffY ) { xFree(m_pcGlbArlCoeffY); m_pcGlbArlCoeffY = NULL; } |
|---|
| 386 | if ( m_pcGlbArlCoeffCb ) { xFree(m_pcGlbArlCoeffCb); m_pcGlbArlCoeffCb = NULL; } |
|---|
| 387 | if ( m_pcGlbArlCoeffCr ) { xFree(m_pcGlbArlCoeffCr); m_pcGlbArlCoeffCr = NULL; } |
|---|
| 388 | #endif |
|---|
| 389 | if ( m_pbIPCMFlag ) { xFree(m_pbIPCMFlag ); m_pbIPCMFlag = NULL; } |
|---|
| 390 | if ( m_pcIPCMSampleY ) { xFree(m_pcIPCMSampleY); m_pcIPCMSampleY = NULL; } |
|---|
| 391 | if ( m_pcIPCMSampleCb ) { xFree(m_pcIPCMSampleCb); m_pcIPCMSampleCb = NULL; } |
|---|
| 392 | if ( m_pcIPCMSampleCr ) { xFree(m_pcIPCMSampleCr); m_pcIPCMSampleCr = NULL; } |
|---|
| 393 | if ( m_apiMVPIdx[0] ) { delete[] m_apiMVPIdx[0]; m_apiMVPIdx[0] = NULL; } |
|---|
| 394 | if ( m_apiMVPIdx[1] ) { delete[] m_apiMVPIdx[1]; m_apiMVPIdx[1] = NULL; } |
|---|
| 395 | if ( m_apiMVPNum[0] ) { delete[] m_apiMVPNum[0]; m_apiMVPNum[0] = NULL; } |
|---|
| 396 | if ( m_apiMVPNum[1] ) { delete[] m_apiMVPNum[1]; m_apiMVPNum[1] = NULL; } |
|---|
| 397 | #if H_3D_NBDV |
|---|
| 398 | if ( m_pDvInfo ) { xFree(m_pDvInfo); m_pDvInfo = NULL; } |
|---|
| 399 | #endif |
|---|
| 400 | |
|---|
| 401 | #if H_3D_ARP |
|---|
| 402 | if ( m_puhARPW ) { delete[] m_puhARPW; m_puhARPW = NULL; } |
|---|
| 403 | #endif |
|---|
| 404 | #if H_3D_IC |
|---|
| 405 | if ( m_pbICFlag ) { xFree(m_pbICFlag); m_pbICFlag = NULL; } |
|---|
| 406 | #endif |
|---|
| 407 | m_acCUMvField[0].destroy(); |
|---|
| 408 | m_acCUMvField[1].destroy(); |
|---|
| 409 | |
|---|
| 410 | #if H_3D_DIM |
|---|
| 411 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
|---|
| 412 | { |
|---|
| 413 | if ( m_dimDeltaDC[i][0] ) { xFree( m_dimDeltaDC[i][0] ); m_dimDeltaDC[i][0] = NULL; } |
|---|
| 414 | if ( m_dimDeltaDC[i][1] ) { xFree( m_dimDeltaDC[i][1] ); m_dimDeltaDC[i][1] = NULL; } |
|---|
| 415 | } |
|---|
| 416 | #if H_3D_DIM_DMM |
|---|
| 417 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 418 | { |
|---|
| 419 | if ( m_dmmWedgeTabIdx[i] ) { xFree( m_dmmWedgeTabIdx[i] ); m_dmmWedgeTabIdx[i] = NULL; } |
|---|
| 420 | } |
|---|
| 421 | #if !SEC_DMM2_E0146 |
|---|
| 422 | if ( m_dmm2DeltaEnd ) { xFree( m_dmm2DeltaEnd ); m_dmm2DeltaEnd = NULL; } |
|---|
| 423 | #endif |
|---|
| 424 | if ( m_dmm3IntraTabIdx ) { xFree( m_dmm3IntraTabIdx ); m_dmm3IntraTabIdx = NULL; } |
|---|
| 425 | #endif |
|---|
| 426 | #if H_3D_DIM_RBC |
|---|
| 427 | if ( m_pbEdgeLeftFirst ) { xFree( m_pbEdgeLeftFirst ); m_pbEdgeLeftFirst = NULL; } |
|---|
| 428 | if ( m_pucEdgeStartPos ) { xFree( m_pucEdgeStartPos ); m_pucEdgeStartPos = NULL; } |
|---|
| 429 | if ( m_pucEdgeNumber ) { xFree( m_pucEdgeNumber ); m_pucEdgeNumber = NULL; } |
|---|
| 430 | if ( m_pucEdgeCode ) { xFree( m_pucEdgeCode ); m_pucEdgeCode = NULL; } |
|---|
| 431 | if ( m_pbEdgePartition ) { xFree( m_pbEdgePartition ); m_pbEdgePartition = NULL; } |
|---|
| 432 | #endif |
|---|
| 433 | #if H_3D_DIM_SDC |
|---|
| 434 | if ( m_pbSDCFlag ) { xFree(m_pbSDCFlag); m_pbSDCFlag = NULL; } |
|---|
| 435 | if ( m_apSegmentDCOffset[0] ) { xFree(m_apSegmentDCOffset[0]); m_apSegmentDCOffset[0] = NULL; } |
|---|
| 436 | if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]); m_apSegmentDCOffset[1] = NULL; } |
|---|
| 437 | #endif |
|---|
| 438 | #endif |
|---|
| 439 | #if LGE_INTER_SDC_E0156 |
|---|
| 440 | if ( m_pbInterSDCFlag ) { xFree(m_pbInterSDCFlag); m_pbInterSDCFlag = NULL; } |
|---|
| 441 | for(Int i = 0; i < 4; i++ ) |
|---|
| 442 | { |
|---|
| 443 | if ( m_apSegmentInterDCOffset[i] ) { xFree( m_apSegmentInterDCOffset[i] ); m_apSegmentInterDCOffset[i] = NULL; } |
|---|
| 444 | } |
|---|
| 445 | #endif |
|---|
| 446 | } |
|---|
| 447 | #if LGE_INTER_SDC_E0156 |
|---|
| 448 | if ( m_pucInterSDCMask ) { xFree(m_pucInterSDCMask); m_pucInterSDCMask = NULL; } |
|---|
| 449 | #endif |
|---|
| 450 | m_pcCUAboveLeft = NULL; |
|---|
| 451 | m_pcCUAboveRight = NULL; |
|---|
| 452 | m_pcCUAbove = NULL; |
|---|
| 453 | m_pcCULeft = NULL; |
|---|
| 454 | |
|---|
| 455 | m_apcCUColocated[0] = NULL; |
|---|
| 456 | m_apcCUColocated[1] = NULL; |
|---|
| 457 | |
|---|
| 458 | if( m_sliceStartCU ) |
|---|
| 459 | { |
|---|
| 460 | xFree(m_sliceStartCU); |
|---|
| 461 | m_sliceStartCU=NULL; |
|---|
| 462 | } |
|---|
| 463 | if(m_sliceSegmentStartCU ) |
|---|
| 464 | { |
|---|
| 465 | xFree(m_sliceSegmentStartCU); |
|---|
| 466 | m_sliceSegmentStartCU=NULL; |
|---|
| 467 | } |
|---|
| 468 | } |
|---|
| 469 | |
|---|
| 470 | const NDBFBlockInfo& NDBFBlockInfo::operator= (const NDBFBlockInfo& src) |
|---|
| 471 | { |
|---|
| 472 | this->tileID = src.tileID; |
|---|
| 473 | this->sliceID= src.sliceID; |
|---|
| 474 | this->startSU= src.startSU; |
|---|
| 475 | this->endSU = src.endSU; |
|---|
| 476 | this->widthSU= src.widthSU; |
|---|
| 477 | this->heightSU=src.heightSU; |
|---|
| 478 | this->posX = src.posX; |
|---|
| 479 | this->posY = src.posY; |
|---|
| 480 | this->width = src.width; |
|---|
| 481 | this->height = src.height; |
|---|
| 482 | ::memcpy(this->isBorderAvailable, src.isBorderAvailable, sizeof(Bool)*((Int)NUM_SGU_BORDER)); |
|---|
| 483 | this->allBordersAvailable = src.allBordersAvailable; |
|---|
| 484 | |
|---|
| 485 | return *this; |
|---|
| 486 | } |
|---|
| 487 | |
|---|
| 488 | |
|---|
| 489 | // ==================================================================================================================== |
|---|
| 490 | // Public member functions |
|---|
| 491 | // ==================================================================================================================== |
|---|
| 492 | |
|---|
| 493 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 494 | // Initialization |
|---|
| 495 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 496 | |
|---|
| 497 | /** |
|---|
| 498 | - initialize top-level CU |
|---|
| 499 | - internal buffers are already created |
|---|
| 500 | - set values before encoding a CU |
|---|
| 501 | . |
|---|
| 502 | \param pcPic picture (TComPic) class pointer |
|---|
| 503 | \param iCUAddr CU address |
|---|
| 504 | */ |
|---|
| 505 | Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr ) |
|---|
| 506 | { |
|---|
| 507 | |
|---|
| 508 | m_pcPic = pcPic; |
|---|
| 509 | m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
|---|
| 510 | m_uiCUAddr = iCUAddr; |
|---|
| 511 | m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth; |
|---|
| 512 | m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight; |
|---|
| 513 | m_uiAbsIdxInLCU = 0; |
|---|
| 514 | m_dTotalCost = MAX_DOUBLE; |
|---|
| 515 | m_uiTotalDistortion = 0; |
|---|
| 516 | m_uiTotalBits = 0; |
|---|
| 517 | m_uiTotalBins = 0; |
|---|
| 518 | m_uiNumPartition = pcPic->getNumPartInCU(); |
|---|
| 519 | |
|---|
| 520 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
|---|
| 521 | { |
|---|
| 522 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceCurStartCUAddr()) |
|---|
| 523 | { |
|---|
| 524 | m_sliceStartCU[i]=getSlice()->getSliceCurStartCUAddr(); |
|---|
| 525 | } |
|---|
| 526 | else |
|---|
| 527 | { |
|---|
| 528 | m_sliceStartCU[i]=pcPic->getCU(getAddr())->m_sliceStartCU[i]; |
|---|
| 529 | } |
|---|
| 530 | } |
|---|
| 531 | for(Int i=0; i<pcPic->getNumPartInCU(); i++) |
|---|
| 532 | { |
|---|
| 533 | if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceSegmentCurStartCUAddr()) |
|---|
| 534 | { |
|---|
| 535 | m_sliceSegmentStartCU[i]=getSlice()->getSliceSegmentCurStartCUAddr(); |
|---|
| 536 | } |
|---|
| 537 | else |
|---|
| 538 | { |
|---|
| 539 | m_sliceSegmentStartCU[i]=pcPic->getCU(getAddr())->m_sliceSegmentStartCU[i]; |
|---|
| 540 | } |
|---|
| 541 | } |
|---|
| 542 | |
|---|
| 543 | Int partStartIdx = getSlice()->getSliceSegmentCurStartCUAddr() - pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr) * pcPic->getNumPartInCU(); |
|---|
| 544 | |
|---|
| 545 | Int numElements = min<Int>( partStartIdx, m_uiNumPartition ); |
|---|
| 546 | for ( Int ui = 0; ui < numElements; ui++ ) |
|---|
| 547 | { |
|---|
| 548 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
|---|
| 549 | m_skipFlag[ui] = pcFrom->getSkipFlag(ui); |
|---|
| 550 | m_pePartSize[ui] = pcFrom->getPartitionSize(ui); |
|---|
| 551 | m_pePredMode[ui] = pcFrom->getPredictionMode(ui); |
|---|
| 552 | m_CUTransquantBypass[ui] = pcFrom->getCUTransquantBypass(ui); |
|---|
| 553 | m_puhDepth[ui] = pcFrom->getDepth(ui); |
|---|
| 554 | #if H_3D_ARP |
|---|
| 555 | m_puhARPW [ui] = pcFrom->getARPW( ui ); |
|---|
| 556 | #endif |
|---|
| 557 | #if H_3D_IC |
|---|
| 558 | m_pbICFlag[ui] = pcFrom->m_pbICFlag[ui]; |
|---|
| 559 | #endif |
|---|
| 560 | m_puhWidth [ui] = pcFrom->getWidth(ui); |
|---|
| 561 | m_puhHeight [ui] = pcFrom->getHeight(ui); |
|---|
| 562 | m_puhTrIdx [ui] = pcFrom->getTransformIdx(ui); |
|---|
| 563 | m_puhTransformSkip[0][ui] = pcFrom->getTransformSkip(ui,TEXT_LUMA); |
|---|
| 564 | m_puhTransformSkip[1][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_U); |
|---|
| 565 | m_puhTransformSkip[2][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_V); |
|---|
| 566 | m_apiMVPIdx[0][ui] = pcFrom->m_apiMVPIdx[0][ui];; |
|---|
| 567 | m_apiMVPIdx[1][ui] = pcFrom->m_apiMVPIdx[1][ui]; |
|---|
| 568 | m_apiMVPNum[0][ui] = pcFrom->m_apiMVPNum[0][ui]; |
|---|
| 569 | m_apiMVPNum[1][ui] = pcFrom->m_apiMVPNum[1][ui]; |
|---|
| 570 | m_phQP[ui]=pcFrom->m_phQP[ui]; |
|---|
| 571 | m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui]; |
|---|
| 572 | m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui]; |
|---|
| 573 | #if H_3D_VSP |
|---|
| 574 | m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui]; |
|---|
| 575 | #if MTK_VSP_FIX_E0172 |
|---|
| 576 | m_piVSPDir [ui] = pcFrom->m_piVSPDir[ui]; |
|---|
| 577 | #endif |
|---|
| 578 | #endif |
|---|
| 579 | m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui]; |
|---|
| 580 | m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui]; |
|---|
| 581 | m_puhInterDir[ui]=pcFrom->m_puhInterDir[ui]; |
|---|
| 582 | m_puhCbf[0][ui]=pcFrom->m_puhCbf[0][ui]; |
|---|
| 583 | m_puhCbf[1][ui]=pcFrom->m_puhCbf[1][ui]; |
|---|
| 584 | m_puhCbf[2][ui]=pcFrom->m_puhCbf[2][ui]; |
|---|
| 585 | m_pbIPCMFlag[ui] = pcFrom->m_pbIPCMFlag[ui]; |
|---|
| 586 | #if H_3D_DIM_SDC |
|---|
| 587 | m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui]; |
|---|
| 588 | #endif |
|---|
| 589 | #if LGE_INTER_SDC_E0156 |
|---|
| 590 | m_pbInterSDCFlag[ui] = pcFrom->m_pbInterSDCFlag[ui]; |
|---|
| 591 | #endif |
|---|
| 592 | } |
|---|
| 593 | |
|---|
| 594 | Int firstElement = max<Int>( partStartIdx, 0 ); |
|---|
| 595 | numElements = m_uiNumPartition - firstElement; |
|---|
| 596 | |
|---|
| 597 | if ( numElements > 0 ) |
|---|
| 598 | { |
|---|
| 599 | memset( m_skipFlag + firstElement, false, numElements * sizeof( *m_skipFlag ) ); |
|---|
| 600 | |
|---|
| 601 | memset( m_pePartSize + firstElement, SIZE_NONE, numElements * sizeof( *m_pePartSize ) ); |
|---|
| 602 | memset( m_pePredMode + firstElement, MODE_NONE, numElements * sizeof( *m_pePredMode ) ); |
|---|
| 603 | memset( m_CUTransquantBypass+ firstElement, false, numElements * sizeof( *m_CUTransquantBypass) ); |
|---|
| 604 | memset( m_puhDepth + firstElement, 0, numElements * sizeof( *m_puhDepth ) ); |
|---|
| 605 | memset( m_puhTrIdx + firstElement, 0, numElements * sizeof( *m_puhTrIdx ) ); |
|---|
| 606 | memset( m_puhTransformSkip[0] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[0]) ); |
|---|
| 607 | memset( m_puhTransformSkip[1] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[1]) ); |
|---|
| 608 | memset( m_puhTransformSkip[2] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[2]) ); |
|---|
| 609 | memset( m_puhWidth + firstElement, g_uiMaxCUWidth, numElements * sizeof( *m_puhWidth ) ); |
|---|
| 610 | memset( m_puhHeight + firstElement, g_uiMaxCUHeight, numElements * sizeof( *m_puhHeight ) ); |
|---|
| 611 | memset( m_apiMVPIdx[0] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[0] ) ); |
|---|
| 612 | memset( m_apiMVPIdx[1] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[1] ) ); |
|---|
| 613 | memset( m_apiMVPNum[0] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[0] ) ); |
|---|
| 614 | memset( m_apiMVPNum[1] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[1] ) ); |
|---|
| 615 | memset( m_phQP + firstElement, getSlice()->getSliceQp(), numElements * sizeof( *m_phQP ) ); |
|---|
| 616 | memset( m_pbMergeFlag + firstElement, false, numElements * sizeof( *m_pbMergeFlag ) ); |
|---|
| 617 | memset( m_puhMergeIndex + firstElement, 0, numElements * sizeof( *m_puhMergeIndex ) ); |
|---|
| 618 | #if H_3D_VSP |
|---|
| 619 | memset( m_piVSPFlag + firstElement, 0, numElements * sizeof( *m_piVSPFlag ) ); |
|---|
| 620 | #if MTK_VSP_FIX_E0172 |
|---|
| 621 | memset( m_piVSPDir + firstElement, 0, numElements * sizeof( *m_piVSPDir ) ); |
|---|
| 622 | #endif |
|---|
| 623 | #endif |
|---|
| 624 | memset( m_puhLumaIntraDir + firstElement, DC_IDX, numElements * sizeof( *m_puhLumaIntraDir ) ); |
|---|
| 625 | memset( m_puhChromaIntraDir + firstElement, 0, numElements * sizeof( *m_puhChromaIntraDir ) ); |
|---|
| 626 | memset( m_puhInterDir + firstElement, 0, numElements * sizeof( *m_puhInterDir ) ); |
|---|
| 627 | memset( m_puhCbf[0] + firstElement, 0, numElements * sizeof( *m_puhCbf[0] ) ); |
|---|
| 628 | memset( m_puhCbf[1] + firstElement, 0, numElements * sizeof( *m_puhCbf[1] ) ); |
|---|
| 629 | memset( m_puhCbf[2] + firstElement, 0, numElements * sizeof( *m_puhCbf[2] ) ); |
|---|
| 630 | memset( m_pbIPCMFlag + firstElement, false, numElements * sizeof( *m_pbIPCMFlag ) ); |
|---|
| 631 | #if H_3D_ARP |
|---|
| 632 | memset( m_puhARPW + firstElement, 0, numElements * sizeof( UChar ) ); |
|---|
| 633 | #endif |
|---|
| 634 | #if H_3D_IC |
|---|
| 635 | memset( m_pbICFlag + firstElement, false, numElements * sizeof( *m_pbICFlag ) ); |
|---|
| 636 | #endif |
|---|
| 637 | #if H_3D_DIM |
|---|
| 638 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
|---|
| 639 | { |
|---|
| 640 | memset( m_dimDeltaDC[i][0] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][0] ) ); |
|---|
| 641 | memset( m_dimDeltaDC[i][1] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][1] ) ); |
|---|
| 642 | } |
|---|
| 643 | #if H_3D_DIM_DMM |
|---|
| 644 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 645 | { |
|---|
| 646 | memset( m_dmmWedgeTabIdx[i] + firstElement, 0, numElements * sizeof( *m_dmmWedgeTabIdx[i] ) ); |
|---|
| 647 | } |
|---|
| 648 | #if !SEC_DMM2_E0146 |
|---|
| 649 | memset( m_dmm2DeltaEnd + firstElement, 0, numElements * sizeof( *m_dmm2DeltaEnd ) ); |
|---|
| 650 | #endif |
|---|
| 651 | memset( m_dmm3IntraTabIdx + firstElement, 0, numElements * sizeof( *m_dmm3IntraTabIdx ) ); |
|---|
| 652 | #endif |
|---|
| 653 | #if H_3D_DIM_RBC |
|---|
| 654 | memset( m_pucEdgeCode + firstElement, 0, numElements * sizeof( *m_pucEdgeCode ) * RBC_MAX_EDGE_NUM_PER_4x4 ); |
|---|
| 655 | memset( m_pucEdgeNumber + firstElement, 0, numElements * sizeof( *m_pucEdgeNumber ) ); |
|---|
| 656 | memset( m_pucEdgeStartPos + firstElement, 0, numElements * sizeof( *m_pucEdgeStartPos ) ); |
|---|
| 657 | memset( m_pbEdgeLeftFirst + firstElement, false, numElements * sizeof( *m_pbEdgeLeftFirst ) ); |
|---|
| 658 | memset( m_pbEdgePartition + firstElement, false, numElements * sizeof( *m_pbEdgePartition ) * 16 ); |
|---|
| 659 | #endif |
|---|
| 660 | #if H_3D_DIM_SDC |
|---|
| 661 | memset( m_pbSDCFlag + firstElement, 0, numElements * sizeof( *m_pbSDCFlag ) ); |
|---|
| 662 | memset( m_apSegmentDCOffset[0] + firstElement, 0, numElements * sizeof( *m_apSegmentDCOffset[0] ) ); |
|---|
| 663 | memset( m_apSegmentDCOffset[1] + firstElement, 0, numElements * sizeof( *m_apSegmentDCOffset[1] ) ); |
|---|
| 664 | #endif |
|---|
| 665 | #endif |
|---|
| 666 | #if LGE_INTER_SDC_E0156 |
|---|
| 667 | memset( m_pbInterSDCFlag + firstElement, 0, numElements * sizeof( *m_pbInterSDCFlag ) ); |
|---|
| 668 | for( Int i = 0; i < 4; i++ ) |
|---|
| 669 | { |
|---|
| 670 | memset( m_apSegmentInterDCOffset[i] + firstElement, 0, numElements * sizeof( *m_apSegmentInterDCOffset[i] ) ); |
|---|
| 671 | } |
|---|
| 672 | #endif |
|---|
| 673 | } |
|---|
| 674 | |
|---|
| 675 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight; |
|---|
| 676 | if ( 0 >= partStartIdx ) |
|---|
| 677 | { |
|---|
| 678 | m_acCUMvField[0].clearMvField(); |
|---|
| 679 | m_acCUMvField[1].clearMvField(); |
|---|
| 680 | memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); |
|---|
| 681 | #if ADAPTIVE_QP_SELECTION |
|---|
| 682 | memset( m_pcArlCoeffY , 0, sizeof( Int ) * uiTmp ); |
|---|
| 683 | #endif |
|---|
| 684 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 685 | uiTmp >>= 2; |
|---|
| 686 | memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); |
|---|
| 687 | memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); |
|---|
| 688 | #if ADAPTIVE_QP_SELECTION |
|---|
| 689 | memset( m_pcArlCoeffCb, 0, sizeof( Int ) * uiTmp ); |
|---|
| 690 | memset( m_pcArlCoeffCr, 0, sizeof( Int ) * uiTmp ); |
|---|
| 691 | #endif |
|---|
| 692 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 693 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 694 | } |
|---|
| 695 | else |
|---|
| 696 | { |
|---|
| 697 | TComDataCU * pcFrom = pcPic->getCU(getAddr()); |
|---|
| 698 | m_acCUMvField[0].copyFrom(&pcFrom->m_acCUMvField[0],m_uiNumPartition,0); |
|---|
| 699 | m_acCUMvField[1].copyFrom(&pcFrom->m_acCUMvField[1],m_uiNumPartition,0); |
|---|
| 700 | for(Int i=0; i<uiTmp; i++) |
|---|
| 701 | { |
|---|
| 702 | m_pcTrCoeffY[i]=pcFrom->m_pcTrCoeffY[i]; |
|---|
| 703 | #if ADAPTIVE_QP_SELECTION |
|---|
| 704 | m_pcArlCoeffY[i]=pcFrom->m_pcArlCoeffY[i]; |
|---|
| 705 | #endif |
|---|
| 706 | m_pcIPCMSampleY[i]=pcFrom->m_pcIPCMSampleY[i]; |
|---|
| 707 | } |
|---|
| 708 | for(Int i=0; i<(uiTmp>>2); i++) |
|---|
| 709 | { |
|---|
| 710 | m_pcTrCoeffCb[i]=pcFrom->m_pcTrCoeffCb[i]; |
|---|
| 711 | m_pcTrCoeffCr[i]=pcFrom->m_pcTrCoeffCr[i]; |
|---|
| 712 | #if ADAPTIVE_QP_SELECTION |
|---|
| 713 | m_pcArlCoeffCb[i]=pcFrom->m_pcArlCoeffCb[i]; |
|---|
| 714 | m_pcArlCoeffCr[i]=pcFrom->m_pcArlCoeffCr[i]; |
|---|
| 715 | #endif |
|---|
| 716 | m_pcIPCMSampleCb[i]=pcFrom->m_pcIPCMSampleCb[i]; |
|---|
| 717 | m_pcIPCMSampleCr[i]=pcFrom->m_pcIPCMSampleCr[i]; |
|---|
| 718 | } |
|---|
| 719 | } |
|---|
| 720 | |
|---|
| 721 | // Setting neighbor CU |
|---|
| 722 | m_pcCULeft = NULL; |
|---|
| 723 | m_pcCUAbove = NULL; |
|---|
| 724 | m_pcCUAboveLeft = NULL; |
|---|
| 725 | m_pcCUAboveRight = NULL; |
|---|
| 726 | |
|---|
| 727 | m_apcCUColocated[0] = NULL; |
|---|
| 728 | m_apcCUColocated[1] = NULL; |
|---|
| 729 | |
|---|
| 730 | UInt uiWidthInCU = pcPic->getFrameWidthInCU(); |
|---|
| 731 | if ( m_uiCUAddr % uiWidthInCU ) |
|---|
| 732 | { |
|---|
| 733 | m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); |
|---|
| 734 | } |
|---|
| 735 | |
|---|
| 736 | if ( m_uiCUAddr / uiWidthInCU ) |
|---|
| 737 | { |
|---|
| 738 | m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); |
|---|
| 739 | } |
|---|
| 740 | |
|---|
| 741 | if ( m_pcCULeft && m_pcCUAbove ) |
|---|
| 742 | { |
|---|
| 743 | m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); |
|---|
| 744 | } |
|---|
| 745 | |
|---|
| 746 | if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) |
|---|
| 747 | { |
|---|
| 748 | m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); |
|---|
| 749 | } |
|---|
| 750 | |
|---|
| 751 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
|---|
| 752 | { |
|---|
| 753 | m_apcCUColocated[0] = getSlice()->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); |
|---|
| 754 | } |
|---|
| 755 | |
|---|
| 756 | if ( getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
|---|
| 757 | { |
|---|
| 758 | m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); |
|---|
| 759 | } |
|---|
| 760 | } |
|---|
| 761 | |
|---|
| 762 | /** initialize prediction data with enabling sub-LCU-level delta QP |
|---|
| 763 | *\param uiDepth depth of the current CU |
|---|
| 764 | *\param qp qp for the current CU |
|---|
| 765 | *- set CU width and CU height according to depth |
|---|
| 766 | *- set qp value according to input qp |
|---|
| 767 | *- set last-coded qp value according to input last-coded qp |
|---|
| 768 | */ |
|---|
| 769 | Void TComDataCU::initEstData( UInt uiDepth, Int qp ) |
|---|
| 770 | { |
|---|
| 771 | m_dTotalCost = MAX_DOUBLE; |
|---|
| 772 | m_uiTotalDistortion = 0; |
|---|
| 773 | m_uiTotalBits = 0; |
|---|
| 774 | m_uiTotalBins = 0; |
|---|
| 775 | |
|---|
| 776 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
|---|
| 777 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
|---|
| 778 | |
|---|
| 779 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
|---|
| 780 | { |
|---|
| 781 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui >= getSlice()->getSliceSegmentCurStartCUAddr()) |
|---|
| 782 | { |
|---|
| 783 | m_apiMVPIdx[0][ui] = -1; |
|---|
| 784 | m_apiMVPIdx[1][ui] = -1; |
|---|
| 785 | m_apiMVPNum[0][ui] = -1; |
|---|
| 786 | m_apiMVPNum[1][ui] = -1; |
|---|
| 787 | m_puhDepth [ui] = uiDepth; |
|---|
| 788 | m_puhWidth [ui] = uhWidth; |
|---|
| 789 | m_puhHeight [ui] = uhHeight; |
|---|
| 790 | m_puhTrIdx [ui] = 0; |
|---|
| 791 | m_puhTransformSkip[0][ui] = 0; |
|---|
| 792 | m_puhTransformSkip[1][ui] = 0; |
|---|
| 793 | m_puhTransformSkip[2][ui] = 0; |
|---|
| 794 | m_skipFlag[ui] = false; |
|---|
| 795 | m_pePartSize[ui] = SIZE_NONE; |
|---|
| 796 | m_pePredMode[ui] = MODE_NONE; |
|---|
| 797 | m_CUTransquantBypass[ui] = false; |
|---|
| 798 | m_pbIPCMFlag[ui] = 0; |
|---|
| 799 | m_phQP[ui] = qp; |
|---|
| 800 | m_pbMergeFlag[ui] = 0; |
|---|
| 801 | m_puhMergeIndex[ui] = 0; |
|---|
| 802 | #if H_3D_VSP |
|---|
| 803 | m_piVSPFlag[ui] = 0; |
|---|
| 804 | #if MTK_VSP_FIX_E0172 |
|---|
| 805 | m_piVSPDir [ui] = 0; |
|---|
| 806 | #endif |
|---|
| 807 | #endif |
|---|
| 808 | m_puhLumaIntraDir[ui] = DC_IDX; |
|---|
| 809 | m_puhChromaIntraDir[ui] = 0; |
|---|
| 810 | m_puhInterDir[ui] = 0; |
|---|
| 811 | m_puhCbf[0][ui] = 0; |
|---|
| 812 | m_puhCbf[1][ui] = 0; |
|---|
| 813 | m_puhCbf[2][ui] = 0; |
|---|
| 814 | #if H_3D_ARP |
|---|
| 815 | m_puhARPW[ui] = 0; |
|---|
| 816 | #endif |
|---|
| 817 | #if H_3D_IC |
|---|
| 818 | m_pbICFlag[ui] = false; |
|---|
| 819 | #endif |
|---|
| 820 | #if H_3D_DIM |
|---|
| 821 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
|---|
| 822 | { |
|---|
| 823 | m_dimDeltaDC[i][0] [ui] = 0; |
|---|
| 824 | m_dimDeltaDC[i][1] [ui] = 0; |
|---|
| 825 | } |
|---|
| 826 | #if H_3D_DIM_DMM |
|---|
| 827 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 828 | { |
|---|
| 829 | m_dmmWedgeTabIdx[i] [ui] = 0; |
|---|
| 830 | } |
|---|
| 831 | #if !SEC_DMM2_E0146 |
|---|
| 832 | m_dmm2DeltaEnd [ui] = 0; |
|---|
| 833 | #endif |
|---|
| 834 | m_dmm3IntraTabIdx [ui] = 0; |
|---|
| 835 | #endif |
|---|
| 836 | #if H_3D_DIM_SDC |
|---|
| 837 | m_pbSDCFlag [ui] = false; |
|---|
| 838 | m_apSegmentDCOffset[0][ui] = 0; |
|---|
| 839 | m_apSegmentDCOffset[1][ui] = 0; |
|---|
| 840 | #endif |
|---|
| 841 | #endif |
|---|
| 842 | #if LGE_INTER_SDC_E0156 |
|---|
| 843 | m_pbInterSDCFlag[ui] = false; |
|---|
| 844 | for( Int i = 0; i < 4; i++ ) |
|---|
| 845 | { |
|---|
| 846 | m_apSegmentInterDCOffset[i][ui] = 0; |
|---|
| 847 | } |
|---|
| 848 | #endif |
|---|
| 849 | } |
|---|
| 850 | } |
|---|
| 851 | |
|---|
| 852 | if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU >= getSlice()->getSliceSegmentCurStartCUAddr()) |
|---|
| 853 | { |
|---|
| 854 | m_acCUMvField[0].clearMvField(); |
|---|
| 855 | m_acCUMvField[1].clearMvField(); |
|---|
| 856 | UInt uiTmp = uhWidth*uhHeight; |
|---|
| 857 | |
|---|
| 858 | memset( m_pcTrCoeffY, 0, uiTmp * sizeof( *m_pcTrCoeffY ) ); |
|---|
| 859 | #if ADAPTIVE_QP_SELECTION |
|---|
| 860 | memset( m_pcArlCoeffY , 0, uiTmp * sizeof( *m_pcArlCoeffY ) ); |
|---|
| 861 | #endif |
|---|
| 862 | memset( m_pcIPCMSampleY, 0, uiTmp * sizeof( *m_pcIPCMSampleY ) ); |
|---|
| 863 | |
|---|
| 864 | uiTmp>>=2; |
|---|
| 865 | memset( m_pcTrCoeffCb, 0, uiTmp * sizeof( *m_pcTrCoeffCb ) ); |
|---|
| 866 | memset( m_pcTrCoeffCr, 0, uiTmp * sizeof( *m_pcTrCoeffCr ) ); |
|---|
| 867 | #if ADAPTIVE_QP_SELECTION |
|---|
| 868 | memset( m_pcArlCoeffCb, 0, uiTmp * sizeof( *m_pcArlCoeffCb ) ); |
|---|
| 869 | memset( m_pcArlCoeffCr, 0, uiTmp * sizeof( *m_pcArlCoeffCr ) ); |
|---|
| 870 | #endif |
|---|
| 871 | memset( m_pcIPCMSampleCb, 0, uiTmp * sizeof( *m_pcIPCMSampleCb ) ); |
|---|
| 872 | memset( m_pcIPCMSampleCr, 0, uiTmp * sizeof( *m_pcIPCMSampleCr ) ); |
|---|
| 873 | } |
|---|
| 874 | } |
|---|
| 875 | |
|---|
| 876 | |
|---|
| 877 | // initialize Sub partition |
|---|
| 878 | Void TComDataCU::initSubCU( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp ) |
|---|
| 879 | { |
|---|
| 880 | assert( uiPartUnitIdx<4 ); |
|---|
| 881 | |
|---|
| 882 | UInt uiPartOffset = ( pcCU->getTotalNumPart()>>2 )*uiPartUnitIdx; |
|---|
| 883 | |
|---|
| 884 | m_pcPic = pcCU->getPic(); |
|---|
| 885 | m_pcSlice = m_pcPic->getSlice(m_pcPic->getCurrSliceIdx()); |
|---|
| 886 | m_uiCUAddr = pcCU->getAddr(); |
|---|
| 887 | m_uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset; |
|---|
| 888 | |
|---|
| 889 | m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth>>uiDepth )*( uiPartUnitIdx & 1 ); |
|---|
| 890 | m_uiCUPelY = pcCU->getCUPelY() + ( g_uiMaxCUHeight>>uiDepth )*( uiPartUnitIdx >> 1 ); |
|---|
| 891 | |
|---|
| 892 | m_dTotalCost = MAX_DOUBLE; |
|---|
| 893 | m_uiTotalDistortion = 0; |
|---|
| 894 | m_uiTotalBits = 0; |
|---|
| 895 | m_uiTotalBins = 0; |
|---|
| 896 | m_uiNumPartition = pcCU->getTotalNumPart() >> 2; |
|---|
| 897 | |
|---|
| 898 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
|---|
| 899 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
|---|
| 900 | |
|---|
| 901 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
|---|
| 902 | memset( m_phQP, qp, sizeInChar ); |
|---|
| 903 | |
|---|
| 904 | memset( m_pbMergeFlag, 0, iSizeInBool ); |
|---|
| 905 | memset( m_puhMergeIndex, 0, iSizeInUchar ); |
|---|
| 906 | #if H_3D_VSP |
|---|
| 907 | memset( m_piVSPFlag, 0, sizeof( Char ) * m_uiNumPartition ); |
|---|
| 908 | #if MTK_VSP_FIX_E0172 |
|---|
| 909 | memset( m_piVSPDir , 0, sizeInChar ); |
|---|
| 910 | #endif |
|---|
| 911 | #endif |
|---|
| 912 | memset( m_puhLumaIntraDir, DC_IDX, iSizeInUchar ); |
|---|
| 913 | memset( m_puhChromaIntraDir, 0, iSizeInUchar ); |
|---|
| 914 | memset( m_puhInterDir, 0, iSizeInUchar ); |
|---|
| 915 | memset( m_puhTrIdx, 0, iSizeInUchar ); |
|---|
| 916 | memset( m_puhTransformSkip[0], 0, iSizeInUchar ); |
|---|
| 917 | memset( m_puhTransformSkip[1], 0, iSizeInUchar ); |
|---|
| 918 | memset( m_puhTransformSkip[2], 0, iSizeInUchar ); |
|---|
| 919 | memset( m_puhCbf[0], 0, iSizeInUchar ); |
|---|
| 920 | memset( m_puhCbf[1], 0, iSizeInUchar ); |
|---|
| 921 | memset( m_puhCbf[2], 0, iSizeInUchar ); |
|---|
| 922 | memset( m_puhDepth, uiDepth, iSizeInUchar ); |
|---|
| 923 | #if H_3D_NBDV |
|---|
| 924 | m_pDvInfo->bDV = false; |
|---|
| 925 | #endif |
|---|
| 926 | #if H_3D_ARP |
|---|
| 927 | memset( m_puhARPW, 0, iSizeInUchar ); |
|---|
| 928 | #endif |
|---|
| 929 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
|---|
| 930 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
|---|
| 931 | memset( m_puhWidth, uhWidth, iSizeInUchar ); |
|---|
| 932 | memset( m_puhHeight, uhHeight, iSizeInUchar ); |
|---|
| 933 | memset( m_pbIPCMFlag, 0, iSizeInBool ); |
|---|
| 934 | #if H_3D_IC |
|---|
| 935 | memset( m_pbICFlag, 0, iSizeInBool ); |
|---|
| 936 | #endif |
|---|
| 937 | #if H_3D_DIM |
|---|
| 938 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
|---|
| 939 | { |
|---|
| 940 | memset( m_dimDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition ); |
|---|
| 941 | memset( m_dimDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition ); |
|---|
| 942 | } |
|---|
| 943 | #if H_3D_DIM_DMM |
|---|
| 944 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 945 | { |
|---|
| 946 | memset( m_dmmWedgeTabIdx[i], 0, sizeof(UInt) * m_uiNumPartition ); |
|---|
| 947 | } |
|---|
| 948 | #if !SEC_DMM2_E0146 |
|---|
| 949 | memset( m_dmm2DeltaEnd , 0, sizeof(Int ) * m_uiNumPartition ); |
|---|
| 950 | #endif |
|---|
| 951 | memset( m_dmm3IntraTabIdx, 0, sizeof(UInt) * m_uiNumPartition ); |
|---|
| 952 | #endif |
|---|
| 953 | #if H_3D_DIM_RBC |
|---|
| 954 | memset( m_pucEdgeCode , 0, iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); |
|---|
| 955 | memset( m_pucEdgeNumber , 0, iSizeInUchar ); |
|---|
| 956 | memset( m_pucEdgeStartPos, 0, iSizeInUchar ); |
|---|
| 957 | memset( m_pbEdgeLeftFirst, 0, iSizeInBool ); |
|---|
| 958 | memset( m_pbEdgePartition, 0, iSizeInBool * 16 ); |
|---|
| 959 | #endif |
|---|
| 960 | #if H_3D_DIM_SDC |
|---|
| 961 | memset( m_pbSDCFlag, 0, sizeof(Bool) * m_uiNumPartition ); |
|---|
| 962 | memset( m_apSegmentDCOffset[0], 0, sizeof(Pel) * m_uiNumPartition ); |
|---|
| 963 | memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition ); |
|---|
| 964 | #endif |
|---|
| 965 | #endif |
|---|
| 966 | #if LGE_INTER_SDC_E0156 |
|---|
| 967 | memset( m_pbInterSDCFlag, 0, sizeof( Bool ) * m_uiNumPartition ); |
|---|
| 968 | for( Int i = 0; i < 4; i++ ) |
|---|
| 969 | { |
|---|
| 970 | memset( m_apSegmentInterDCOffset[i], 0, sizeof( Int ) * m_uiNumPartition ); |
|---|
| 971 | } |
|---|
| 972 | #endif |
|---|
| 973 | |
|---|
| 974 | for (UInt ui = 0; ui < m_uiNumPartition; ui++) |
|---|
| 975 | { |
|---|
| 976 | m_skipFlag[ui] = false; |
|---|
| 977 | m_pePartSize[ui] = SIZE_NONE; |
|---|
| 978 | m_pePredMode[ui] = MODE_NONE; |
|---|
| 979 | m_CUTransquantBypass[ui] = false; |
|---|
| 980 | m_apiMVPIdx[0][ui] = -1; |
|---|
| 981 | m_apiMVPIdx[1][ui] = -1; |
|---|
| 982 | m_apiMVPNum[0][ui] = -1; |
|---|
| 983 | m_apiMVPNum[1][ui] = -1; |
|---|
| 984 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui<getSlice()->getSliceSegmentCurStartCUAddr()) |
|---|
| 985 | { |
|---|
| 986 | m_apiMVPIdx[0][ui] = pcCU->m_apiMVPIdx[0][uiPartOffset+ui]; |
|---|
| 987 | m_apiMVPIdx[1][ui] = pcCU->m_apiMVPIdx[1][uiPartOffset+ui];; |
|---|
| 988 | m_apiMVPNum[0][ui] = pcCU->m_apiMVPNum[0][uiPartOffset+ui];; |
|---|
| 989 | m_apiMVPNum[1][ui] = pcCU->m_apiMVPNum[1][uiPartOffset+ui];; |
|---|
| 990 | m_puhDepth [ui] = pcCU->getDepth(uiPartOffset+ui); |
|---|
| 991 | m_puhWidth [ui] = pcCU->getWidth(uiPartOffset+ui); |
|---|
| 992 | m_puhHeight [ui] = pcCU->getHeight(uiPartOffset+ui); |
|---|
| 993 | m_puhTrIdx [ui] = pcCU->getTransformIdx(uiPartOffset+ui); |
|---|
| 994 | m_puhTransformSkip[0][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_LUMA); |
|---|
| 995 | m_puhTransformSkip[1][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_U); |
|---|
| 996 | m_puhTransformSkip[2][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_V); |
|---|
| 997 | m_skipFlag[ui] = pcCU->getSkipFlag(uiPartOffset+ui); |
|---|
| 998 | m_pePartSize[ui] = pcCU->getPartitionSize(uiPartOffset+ui); |
|---|
| 999 | m_pePredMode[ui] = pcCU->getPredictionMode(uiPartOffset+ui); |
|---|
| 1000 | m_CUTransquantBypass[ui] = pcCU->getCUTransquantBypass(uiPartOffset+ui); |
|---|
| 1001 | m_pbIPCMFlag[ui]=pcCU->m_pbIPCMFlag[uiPartOffset+ui]; |
|---|
| 1002 | m_phQP[ui] = pcCU->m_phQP[uiPartOffset+ui]; |
|---|
| 1003 | m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui]; |
|---|
| 1004 | m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui]; |
|---|
| 1005 | #if H_3D_VSP |
|---|
| 1006 | m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui]; |
|---|
| 1007 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 1008 | m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui]; |
|---|
| 1009 | #endif |
|---|
| 1010 | #if MTK_VSP_FIX_E0172 |
|---|
| 1011 | m_piVSPDir[ui]=pcCU->m_piVSPDir[uiPartOffset+ui]; |
|---|
| 1012 | #endif |
|---|
| 1013 | #endif |
|---|
| 1014 | m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui]; |
|---|
| 1015 | m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui]; |
|---|
| 1016 | m_puhInterDir[ui]=pcCU->m_puhInterDir[uiPartOffset+ui]; |
|---|
| 1017 | m_puhCbf[0][ui]=pcCU->m_puhCbf[0][uiPartOffset+ui]; |
|---|
| 1018 | m_puhCbf[1][ui]=pcCU->m_puhCbf[1][uiPartOffset+ui]; |
|---|
| 1019 | m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui]; |
|---|
| 1020 | |
|---|
| 1021 | #if H_3D_ARP |
|---|
| 1022 | m_puhARPW [ui] = pcCU->getARPW( uiPartOffset+ui ); |
|---|
| 1023 | #endif |
|---|
| 1024 | #if H_3D_IC |
|---|
| 1025 | m_pbICFlag [ui] = pcCU->m_pbICFlag[uiPartOffset+ui]; |
|---|
| 1026 | #endif |
|---|
| 1027 | #if H_3D_DIM |
|---|
| 1028 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
|---|
| 1029 | { |
|---|
| 1030 | m_dimDeltaDC[i][0] [ui] = pcCU->m_dimDeltaDC[i][0] [uiPartOffset+ui]; |
|---|
| 1031 | m_dimDeltaDC[i][1] [ui] = pcCU->m_dimDeltaDC[i][1] [uiPartOffset+ui]; |
|---|
| 1032 | } |
|---|
| 1033 | #if H_3D_DIM_DMM |
|---|
| 1034 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 1035 | { |
|---|
| 1036 | m_dmmWedgeTabIdx[i] [ui] = pcCU->m_dmmWedgeTabIdx[i] [uiPartOffset+ui]; |
|---|
| 1037 | } |
|---|
| 1038 | #if !SEC_DMM2_E0146 |
|---|
| 1039 | m_dmm2DeltaEnd [ui] = pcCU->m_dmm2DeltaEnd [uiPartOffset+ui]; |
|---|
| 1040 | #endif |
|---|
| 1041 | m_dmm3IntraTabIdx [ui] = pcCU->m_dmm3IntraTabIdx[uiPartOffset+ui]; |
|---|
| 1042 | #endif |
|---|
| 1043 | #if H_3D_DIM_SDC |
|---|
| 1044 | m_pbSDCFlag [ui] = pcCU->m_pbSDCFlag [ uiPartOffset + ui ]; |
|---|
| 1045 | m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ]; |
|---|
| 1046 | m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ]; |
|---|
| 1047 | #endif |
|---|
| 1048 | #endif |
|---|
| 1049 | #if LGE_INTER_SDC_E0156 |
|---|
| 1050 | m_pbInterSDCFlag [ui] = pcCU->m_pbInterSDCFlag [ uiPartOffset + ui ]; |
|---|
| 1051 | for( Int i = 0; i < 4; i++ ) |
|---|
| 1052 | { |
|---|
| 1053 | m_apSegmentInterDCOffset[i][ui] = pcCU->m_apSegmentInterDCOffset[i][ uiPartOffset + ui ]; |
|---|
| 1054 | } |
|---|
| 1055 | #endif |
|---|
| 1056 | } |
|---|
| 1057 | } |
|---|
| 1058 | UInt uiTmp = uhWidth*uhHeight; |
|---|
| 1059 | memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); |
|---|
| 1060 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1061 | memset( m_pcArlCoeffY , 0, sizeof(Int)*uiTmp ); |
|---|
| 1062 | #endif |
|---|
| 1063 | memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 1064 | uiTmp >>= 2; |
|---|
| 1065 | memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); |
|---|
| 1066 | memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); |
|---|
| 1067 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1068 | memset( m_pcArlCoeffCb, 0, sizeof(Int)*uiTmp ); |
|---|
| 1069 | memset( m_pcArlCoeffCr, 0, sizeof(Int)*uiTmp ); |
|---|
| 1070 | #endif |
|---|
| 1071 | memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 1072 | memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); |
|---|
| 1073 | m_acCUMvField[0].clearMvField(); |
|---|
| 1074 | m_acCUMvField[1].clearMvField(); |
|---|
| 1075 | |
|---|
| 1076 | if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU<getSlice()->getSliceSegmentCurStartCUAddr()) |
|---|
| 1077 | { |
|---|
| 1078 | // Part of this CU contains data from an older slice. Now copy in that data. |
|---|
| 1079 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
|---|
| 1080 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
|---|
| 1081 | TComDataCU * bigCU = getPic()->getCU(getAddr()); |
|---|
| 1082 | Int minui = uiPartOffset; |
|---|
| 1083 | minui = -minui; |
|---|
| 1084 | pcCU->m_acCUMvField[0].copyTo(&m_acCUMvField[0],minui,uiPartOffset,m_uiNumPartition); |
|---|
| 1085 | pcCU->m_acCUMvField[1].copyTo(&m_acCUMvField[1],minui,uiPartOffset,m_uiNumPartition); |
|---|
| 1086 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*m_uiAbsIdxInLCU/pcCU->getPic()->getNumPartInCU(); |
|---|
| 1087 | uiTmp = uhWidth*uhHeight; |
|---|
| 1088 | for(Int i=0; i<uiTmp; i++) |
|---|
| 1089 | { |
|---|
| 1090 | m_pcTrCoeffY[i]=bigCU->m_pcTrCoeffY[uiCoffOffset+i]; |
|---|
| 1091 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1092 | m_pcArlCoeffY[i]=bigCU->m_pcArlCoeffY[uiCoffOffset+i]; |
|---|
| 1093 | #endif |
|---|
| 1094 | m_pcIPCMSampleY[i]=bigCU->m_pcIPCMSampleY[uiCoffOffset+i]; |
|---|
| 1095 | } |
|---|
| 1096 | uiTmp>>=2; |
|---|
| 1097 | uiCoffOffset>>=2; |
|---|
| 1098 | for(Int i=0; i<uiTmp; i++) |
|---|
| 1099 | { |
|---|
| 1100 | m_pcTrCoeffCr[i]=bigCU->m_pcTrCoeffCr[uiCoffOffset+i]; |
|---|
| 1101 | m_pcTrCoeffCb[i]=bigCU->m_pcTrCoeffCb[uiCoffOffset+i]; |
|---|
| 1102 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1103 | m_pcArlCoeffCr[i]=bigCU->m_pcArlCoeffCr[uiCoffOffset+i]; |
|---|
| 1104 | m_pcArlCoeffCb[i]=bigCU->m_pcArlCoeffCb[uiCoffOffset+i]; |
|---|
| 1105 | #endif |
|---|
| 1106 | m_pcIPCMSampleCb[i]=bigCU->m_pcIPCMSampleCb[uiCoffOffset+i]; |
|---|
| 1107 | m_pcIPCMSampleCr[i]=bigCU->m_pcIPCMSampleCr[uiCoffOffset+i]; |
|---|
| 1108 | } |
|---|
| 1109 | } |
|---|
| 1110 | |
|---|
| 1111 | m_pcCULeft = pcCU->getCULeft(); |
|---|
| 1112 | m_pcCUAbove = pcCU->getCUAbove(); |
|---|
| 1113 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
|---|
| 1114 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
|---|
| 1115 | |
|---|
| 1116 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
|---|
| 1117 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
|---|
| 1118 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
|---|
| 1119 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); |
|---|
| 1120 | } |
|---|
| 1121 | |
|---|
| 1122 | Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 1123 | { |
|---|
| 1124 | UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); |
|---|
| 1125 | UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; |
|---|
| 1126 | |
|---|
| 1127 | UChar uhWidth = g_uiMaxCUWidth >> uiDepth; |
|---|
| 1128 | UChar uhHeight = g_uiMaxCUHeight >> uiDepth; |
|---|
| 1129 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); |
|---|
| 1130 | memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); |
|---|
| 1131 | memset( m_puhHeight + uiAbsPartIdx, uhHeight, uiSizeInUchar ); |
|---|
| 1132 | } |
|---|
| 1133 | |
|---|
| 1134 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 1135 | // Copy |
|---|
| 1136 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 1137 | |
|---|
| 1138 | Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 1139 | { |
|---|
| 1140 | UInt uiPart = uiAbsPartIdx; |
|---|
| 1141 | |
|---|
| 1142 | m_pcPic = pcCU->getPic(); |
|---|
| 1143 | m_pcSlice = pcCU->getSlice(); |
|---|
| 1144 | m_uiCUAddr = pcCU->getAddr(); |
|---|
| 1145 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
|---|
| 1146 | |
|---|
| 1147 | m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 1148 | m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 1149 | |
|---|
| 1150 | m_skipFlag=pcCU->getSkipFlag() + uiPart; |
|---|
| 1151 | |
|---|
| 1152 | m_phQP=pcCU->getQP() + uiPart; |
|---|
| 1153 | m_pePartSize = pcCU->getPartitionSize() + uiPart; |
|---|
| 1154 | m_pePredMode=pcCU->getPredictionMode() + uiPart; |
|---|
| 1155 | m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; |
|---|
| 1156 | |
|---|
| 1157 | #if H_3D_NBDV |
|---|
| 1158 | m_pDvInfo = pcCU->getDvInfo() + uiPart; |
|---|
| 1159 | #endif |
|---|
| 1160 | m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; |
|---|
| 1161 | m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; |
|---|
| 1162 | #if H_3D_VSP |
|---|
| 1163 | m_piVSPFlag = pcCU->getVSPFlag() + uiPart; |
|---|
| 1164 | #if MTK_VSP_FIX_E0172 |
|---|
| 1165 | m_piVSPDir = pcCU->getVSPDir () + uiPart; |
|---|
| 1166 | #endif |
|---|
| 1167 | #endif |
|---|
| 1168 | |
|---|
| 1169 | #if H_3D_ARP |
|---|
| 1170 | m_puhARPW = pcCU->getARPW() + uiPart; |
|---|
| 1171 | #endif |
|---|
| 1172 | #if H_3D_IC |
|---|
| 1173 | m_pbICFlag = pcCU->getICFlag() + uiPart; |
|---|
| 1174 | #endif |
|---|
| 1175 | |
|---|
| 1176 | m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; |
|---|
| 1177 | m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; |
|---|
| 1178 | m_puhInterDir = pcCU->getInterDir() + uiPart; |
|---|
| 1179 | m_puhTrIdx = pcCU->getTransformIdx() + uiPart; |
|---|
| 1180 | m_puhTransformSkip[0] = pcCU->getTransformSkip(TEXT_LUMA) + uiPart; |
|---|
| 1181 | m_puhTransformSkip[1] = pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPart; |
|---|
| 1182 | m_puhTransformSkip[2] = pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPart; |
|---|
| 1183 | |
|---|
| 1184 | m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; |
|---|
| 1185 | m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; |
|---|
| 1186 | m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; |
|---|
| 1187 | #if H_3D_DIM |
|---|
| 1188 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
|---|
| 1189 | { |
|---|
| 1190 | m_dimDeltaDC[i][0] = pcCU->getDimDeltaDC( i, 0 ) + uiPart; |
|---|
| 1191 | m_dimDeltaDC[i][1] = pcCU->getDimDeltaDC( i, 1 ) + uiPart; |
|---|
| 1192 | } |
|---|
| 1193 | #if H_3D_DIM_DMM |
|---|
| 1194 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 1195 | { |
|---|
| 1196 | m_dmmWedgeTabIdx[i] = pcCU->getDmmWedgeTabIdx( i ) + uiPart; |
|---|
| 1197 | } |
|---|
| 1198 | #if !SEC_DMM2_E0146 |
|---|
| 1199 | m_dmm2DeltaEnd = pcCU->getDmm2DeltaEnd() + uiPart; |
|---|
| 1200 | #endif |
|---|
| 1201 | m_dmm3IntraTabIdx = pcCU->getDmm3IntraTabIdx() + uiPart; |
|---|
| 1202 | #endif |
|---|
| 1203 | #if H_3D_DIM_RBC |
|---|
| 1204 | m_pucEdgeCode = pcCU->getEdgeCode( uiPart ); |
|---|
| 1205 | m_pucEdgeNumber = pcCU->getEdgeNumber() + uiPart; |
|---|
| 1206 | m_pucEdgeStartPos = pcCU->getEdgeStartPos() + uiPart; |
|---|
| 1207 | m_pbEdgeLeftFirst = pcCU->getEdgeLeftFirst() + uiPart; |
|---|
| 1208 | m_pbEdgePartition = pcCU->getEdgePartition( uiPart ); |
|---|
| 1209 | #endif |
|---|
| 1210 | #if H_3D_DIM_SDC |
|---|
| 1211 | m_pbSDCFlag = pcCU->getSDCFlag() + uiPart; |
|---|
| 1212 | m_apSegmentDCOffset[0] = pcCU->getSDCSegmentDCOffset(0) + uiPart; |
|---|
| 1213 | m_apSegmentDCOffset[1] = pcCU->getSDCSegmentDCOffset(1) + uiPart; |
|---|
| 1214 | #endif |
|---|
| 1215 | #endif |
|---|
| 1216 | #if LGE_INTER_SDC_E0156 |
|---|
| 1217 | m_pbInterSDCFlag = pcCU->getInterSDCFlag() + uiPart; |
|---|
| 1218 | for( Int i = 0; i < 4; i++ ) |
|---|
| 1219 | { |
|---|
| 1220 | m_apSegmentInterDCOffset[i] = pcCU->getInterSDCSegmentDCOffset( i ) + uiPart; |
|---|
| 1221 | } |
|---|
| 1222 | #endif |
|---|
| 1223 | m_puhDepth=pcCU->getDepth() + uiPart; |
|---|
| 1224 | m_puhWidth=pcCU->getWidth() + uiPart; |
|---|
| 1225 | m_puhHeight=pcCU->getHeight() + uiPart; |
|---|
| 1226 | |
|---|
| 1227 | m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; |
|---|
| 1228 | m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; |
|---|
| 1229 | m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; |
|---|
| 1230 | m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; |
|---|
| 1231 | |
|---|
| 1232 | m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; |
|---|
| 1233 | |
|---|
| 1234 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
|---|
| 1235 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
|---|
| 1236 | m_pcCUAbove = pcCU->getCUAbove(); |
|---|
| 1237 | m_pcCULeft = pcCU->getCULeft(); |
|---|
| 1238 | |
|---|
| 1239 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
|---|
| 1240 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
|---|
| 1241 | |
|---|
| 1242 | UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
|---|
| 1243 | UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
|---|
| 1244 | |
|---|
| 1245 | UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); |
|---|
| 1246 | |
|---|
| 1247 | m_pcTrCoeffY = pcCU->getCoeffY() + uiCoffOffset; |
|---|
| 1248 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1249 | m_pcArlCoeffY= pcCU->getArlCoeffY() + uiCoffOffset; |
|---|
| 1250 | #endif |
|---|
| 1251 | m_pcIPCMSampleY = pcCU->getPCMSampleY() + uiCoffOffset; |
|---|
| 1252 | |
|---|
| 1253 | uiCoffOffset >>=2; |
|---|
| 1254 | m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; |
|---|
| 1255 | m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; |
|---|
| 1256 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1257 | m_pcArlCoeffCb=pcCU->getArlCoeffCb() + uiCoffOffset; |
|---|
| 1258 | m_pcArlCoeffCr=pcCU->getArlCoeffCr() + uiCoffOffset; |
|---|
| 1259 | #endif |
|---|
| 1260 | m_pcIPCMSampleCb = pcCU->getPCMSampleCb() + uiCoffOffset; |
|---|
| 1261 | m_pcIPCMSampleCr = pcCU->getPCMSampleCr() + uiCoffOffset; |
|---|
| 1262 | |
|---|
| 1263 | m_acCUMvField[0].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_0), uiPart ); |
|---|
| 1264 | m_acCUMvField[1].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_1), uiPart ); |
|---|
| 1265 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
|---|
| 1266 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); |
|---|
| 1267 | } |
|---|
| 1268 | #if H_3D_NBDV |
|---|
| 1269 | Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx) |
|---|
| 1270 | { |
|---|
| 1271 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
|---|
| 1272 | } |
|---|
| 1273 | #endif |
|---|
| 1274 | // Copy inter prediction info from the biggest CU |
|---|
| 1275 | Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList |
|---|
| 1276 | #if H_3D_NBDV |
|---|
| 1277 | , Bool bNBDV |
|---|
| 1278 | #endif |
|---|
| 1279 | ) |
|---|
| 1280 | { |
|---|
| 1281 | m_pcPic = pcCU->getPic(); |
|---|
| 1282 | m_pcSlice = pcCU->getSlice(); |
|---|
| 1283 | m_uiCUAddr = pcCU->getAddr(); |
|---|
| 1284 | m_uiAbsIdxInLCU = uiAbsPartIdx; |
|---|
| 1285 | |
|---|
| 1286 | Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; |
|---|
| 1287 | m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); |
|---|
| 1288 | m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); |
|---|
| 1289 | |
|---|
| 1290 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
|---|
| 1291 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
|---|
| 1292 | m_pcCUAbove = pcCU->getCUAbove(); |
|---|
| 1293 | m_pcCULeft = pcCU->getCULeft(); |
|---|
| 1294 | |
|---|
| 1295 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
|---|
| 1296 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
|---|
| 1297 | |
|---|
| 1298 | m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; |
|---|
| 1299 | |
|---|
| 1300 | m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; |
|---|
| 1301 | #if H_3D_NBDV |
|---|
| 1302 | if(bNBDV == true) |
|---|
| 1303 | { |
|---|
| 1304 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
|---|
| 1305 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
|---|
| 1306 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
|---|
| 1307 | } |
|---|
| 1308 | else |
|---|
| 1309 | { |
|---|
| 1310 | #endif |
|---|
| 1311 | m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; |
|---|
| 1312 | m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; |
|---|
| 1313 | m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; |
|---|
| 1314 | |
|---|
| 1315 | m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; |
|---|
| 1316 | m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; |
|---|
| 1317 | m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; |
|---|
| 1318 | |
|---|
| 1319 | m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; |
|---|
| 1320 | m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; |
|---|
| 1321 | #if H_3D_VSP |
|---|
| 1322 | m_piVSPFlag = pcCU->getVSPFlag() + uiAbsPartIdx; |
|---|
| 1323 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 1324 | m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; |
|---|
| 1325 | #endif |
|---|
| 1326 | #if MTK_VSP_FIX_E0172 |
|---|
| 1327 | m_piVSPDir = pcCU->getVSPDir () + uiAbsPartIdx; |
|---|
| 1328 | #endif |
|---|
| 1329 | #endif |
|---|
| 1330 | |
|---|
| 1331 | m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; |
|---|
| 1332 | m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; |
|---|
| 1333 | |
|---|
| 1334 | #if H_3D_ARP |
|---|
| 1335 | m_puhARPW = pcCU->getARPW() + uiAbsPartIdx; |
|---|
| 1336 | #endif |
|---|
| 1337 | |
|---|
| 1338 | m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); |
|---|
| 1339 | |
|---|
| 1340 | memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
|---|
| 1341 | memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); |
|---|
| 1342 | #if H_3D_NBDV |
|---|
| 1343 | } |
|---|
| 1344 | #endif |
|---|
| 1345 | #if H_3D_IC |
|---|
| 1346 | m_pbICFlag = pcCU->getICFlag() + uiAbsPartIdx; |
|---|
| 1347 | #endif |
|---|
| 1348 | } |
|---|
| 1349 | |
|---|
| 1350 | // Copy small CU to bigger CU. |
|---|
| 1351 | // One of quarter parts overwritten by predicted sub part. |
|---|
| 1352 | Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth ) |
|---|
| 1353 | { |
|---|
| 1354 | assert( uiPartUnitIdx<4 ); |
|---|
| 1355 | |
|---|
| 1356 | m_dTotalCost += pcCU->getTotalCost(); |
|---|
| 1357 | m_uiTotalDistortion += pcCU->getTotalDistortion(); |
|---|
| 1358 | m_uiTotalBits += pcCU->getTotalBits(); |
|---|
| 1359 | |
|---|
| 1360 | UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; |
|---|
| 1361 | |
|---|
| 1362 | UInt uiNumPartition = pcCU->getTotalNumPart(); |
|---|
| 1363 | Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; |
|---|
| 1364 | Int iSizeInBool = sizeof( Bool ) * uiNumPartition; |
|---|
| 1365 | |
|---|
| 1366 | Int sizeInChar = sizeof( Char ) * uiNumPartition; |
|---|
| 1367 | memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); |
|---|
| 1368 | memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); |
|---|
| 1369 | memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); |
|---|
| 1370 | memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); |
|---|
| 1371 | memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); |
|---|
| 1372 | memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); |
|---|
| 1373 | memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); |
|---|
| 1374 | #if H_3D_VSP |
|---|
| 1375 | memcpy( m_piVSPFlag + uiOffset, pcCU->getVSPFlag(), sizeof( Char ) * uiNumPartition ); |
|---|
| 1376 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 1377 | memcpy( m_pDvInfo + uiOffset, pcCU->getDvInfo(), sizeof( *m_pDvInfo ) * uiNumPartition ); |
|---|
| 1378 | #endif |
|---|
| 1379 | #if MTK_VSP_FIX_E0172 |
|---|
| 1380 | memcpy( m_piVSPDir + uiOffset, pcCU->getVSPDir (), sizeInChar ); |
|---|
| 1381 | #endif |
|---|
| 1382 | #endif |
|---|
| 1383 | memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); |
|---|
| 1384 | memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); |
|---|
| 1385 | memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); |
|---|
| 1386 | memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); |
|---|
| 1387 | memcpy( m_puhTransformSkip[0] + uiOffset, pcCU->getTransformSkip(TEXT_LUMA), iSizeInUchar ); |
|---|
| 1388 | memcpy( m_puhTransformSkip[1] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_U), iSizeInUchar ); |
|---|
| 1389 | memcpy( m_puhTransformSkip[2] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_V), iSizeInUchar ); |
|---|
| 1390 | |
|---|
| 1391 | memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); |
|---|
| 1392 | memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); |
|---|
| 1393 | memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); |
|---|
| 1394 | |
|---|
| 1395 | #if H_3D_DIM |
|---|
| 1396 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
|---|
| 1397 | { |
|---|
| 1398 | memcpy( m_dimDeltaDC[i][0] + uiOffset, pcCU->getDimDeltaDC( i, 0 ), sizeof(Pel ) * uiNumPartition ); |
|---|
| 1399 | memcpy( m_dimDeltaDC[i][1] + uiOffset, pcCU->getDimDeltaDC( i, 1 ), sizeof(Pel ) * uiNumPartition ); |
|---|
| 1400 | } |
|---|
| 1401 | #if H_3D_DIM_DMM |
|---|
| 1402 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 1403 | { |
|---|
| 1404 | memcpy( m_dmmWedgeTabIdx[i] + uiOffset, pcCU->getDmmWedgeTabIdx( i ), sizeof(UInt) * uiNumPartition ); |
|---|
| 1405 | } |
|---|
| 1406 | #if !SEC_DMM2_E0146 |
|---|
| 1407 | memcpy( m_dmm2DeltaEnd + uiOffset, pcCU->getDmm2DeltaEnd() , sizeof(Int ) * uiNumPartition ); |
|---|
| 1408 | #endif |
|---|
| 1409 | memcpy( m_dmm3IntraTabIdx + uiOffset, pcCU->getDmm3IntraTabIdx(), sizeof(UInt) * uiNumPartition ); |
|---|
| 1410 | #endif |
|---|
| 1411 | #if H_3D_DIM_RBC |
|---|
| 1412 | memcpy( getEdgeCode( uiOffset ), pcCU->getEdgeCode(0), iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); |
|---|
| 1413 | memcpy( getEdgeNumber() + uiOffset, pcCU->getEdgeNumber(), iSizeInUchar ); |
|---|
| 1414 | memcpy( getEdgeStartPos() + uiOffset, pcCU->getEdgeStartPos(), iSizeInUchar ); |
|---|
| 1415 | memcpy( getEdgeLeftFirst() + uiOffset, pcCU->getEdgeLeftFirst(), iSizeInBool ); |
|---|
| 1416 | memcpy( getEdgePartition( uiOffset ), pcCU->getEdgePartition(0), iSizeInBool * 16 ); |
|---|
| 1417 | #endif |
|---|
| 1418 | #if H_3D_DIM_SDC |
|---|
| 1419 | memcpy( m_pbSDCFlag + uiOffset, pcCU->getSDCFlag(), iSizeInBool ); |
|---|
| 1420 | memcpy( m_apSegmentDCOffset[0] + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition); |
|---|
| 1421 | memcpy( m_apSegmentDCOffset[1] + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition); |
|---|
| 1422 | #endif |
|---|
| 1423 | #endif |
|---|
| 1424 | #if LGE_INTER_SDC_E0156 |
|---|
| 1425 | memcpy( m_pbInterSDCFlag + uiOffset, pcCU->getInterSDCFlag(), iSizeInBool ); |
|---|
| 1426 | for( Int i = 0; i < 4; i++ ) |
|---|
| 1427 | { |
|---|
| 1428 | memcpy( m_apSegmentInterDCOffset[i] + uiOffset, pcCU->getInterSDCSegmentDCOffset( i ), sizeof( Int ) * uiNumPartition); |
|---|
| 1429 | } |
|---|
| 1430 | #endif |
|---|
| 1431 | |
|---|
| 1432 | memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); |
|---|
| 1433 | memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); |
|---|
| 1434 | memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); |
|---|
| 1435 | |
|---|
| 1436 | memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInUchar ); |
|---|
| 1437 | memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInUchar ); |
|---|
| 1438 | memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInUchar ); |
|---|
| 1439 | memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInUchar ); |
|---|
| 1440 | |
|---|
| 1441 | memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); |
|---|
| 1442 | |
|---|
| 1443 | m_pcCUAboveLeft = pcCU->getCUAboveLeft(); |
|---|
| 1444 | m_pcCUAboveRight = pcCU->getCUAboveRight(); |
|---|
| 1445 | m_pcCUAbove = pcCU->getCUAbove(); |
|---|
| 1446 | m_pcCULeft = pcCU->getCULeft(); |
|---|
| 1447 | |
|---|
| 1448 | m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); |
|---|
| 1449 | m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); |
|---|
| 1450 | |
|---|
| 1451 | m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); |
|---|
| 1452 | m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); |
|---|
| 1453 | |
|---|
| 1454 | UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); |
|---|
| 1455 | UInt uiTmp2 = uiPartUnitIdx*uiTmp; |
|---|
| 1456 | memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); |
|---|
| 1457 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1458 | memcpy( m_pcArlCoeffY + uiTmp2, pcCU->getArlCoeffY(), sizeof(Int)*uiTmp ); |
|---|
| 1459 | #endif |
|---|
| 1460 | memcpy( m_pcIPCMSampleY + uiTmp2 , pcCU->getPCMSampleY(), sizeof(Pel) * uiTmp ); |
|---|
| 1461 | |
|---|
| 1462 | uiTmp >>= 2; uiTmp2>>= 2; |
|---|
| 1463 | memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); |
|---|
| 1464 | memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); |
|---|
| 1465 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1466 | memcpy( m_pcArlCoeffCb + uiTmp2, pcCU->getArlCoeffCb(), sizeof(Int)*uiTmp ); |
|---|
| 1467 | memcpy( m_pcArlCoeffCr + uiTmp2, pcCU->getArlCoeffCr(), sizeof(Int)*uiTmp ); |
|---|
| 1468 | #endif |
|---|
| 1469 | memcpy( m_pcIPCMSampleCb + uiTmp2 , pcCU->getPCMSampleCb(), sizeof(Pel) * uiTmp ); |
|---|
| 1470 | memcpy( m_pcIPCMSampleCr + uiTmp2 , pcCU->getPCMSampleCr(), sizeof(Pel) * uiTmp ); |
|---|
| 1471 | m_uiTotalBins += pcCU->getTotalBins(); |
|---|
| 1472 | memcpy( m_sliceStartCU + uiOffset, pcCU->m_sliceStartCU, sizeof( UInt ) * uiNumPartition ); |
|---|
| 1473 | memcpy( m_sliceSegmentStartCU + uiOffset, pcCU->m_sliceSegmentStartCU, sizeof( UInt ) * uiNumPartition ); |
|---|
| 1474 | #if H_3D_ARP |
|---|
| 1475 | memcpy( m_puhARPW + uiOffset, pcCU->getARPW(), iSizeInUchar ); |
|---|
| 1476 | #endif |
|---|
| 1477 | #if H_3D_IC |
|---|
| 1478 | memcpy( m_pbICFlag + uiOffset, pcCU->getICFlag(), iSizeInBool ); |
|---|
| 1479 | #endif |
|---|
| 1480 | } |
|---|
| 1481 | |
|---|
| 1482 | // Copy current predicted part to a CU in picture. |
|---|
| 1483 | // It is used to predict for next part |
|---|
| 1484 | Void TComDataCU::copyToPic( UChar uhDepth ) |
|---|
| 1485 | { |
|---|
| 1486 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
|---|
| 1487 | |
|---|
| 1488 | rpcCU->getTotalCost() = m_dTotalCost; |
|---|
| 1489 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
|---|
| 1490 | rpcCU->getTotalBits() = m_uiTotalBits; |
|---|
| 1491 | |
|---|
| 1492 | Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; |
|---|
| 1493 | Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; |
|---|
| 1494 | |
|---|
| 1495 | Int sizeInChar = sizeof( Char ) * m_uiNumPartition; |
|---|
| 1496 | |
|---|
| 1497 | memcpy( rpcCU->getSkipFlag() + m_uiAbsIdxInLCU, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); |
|---|
| 1498 | |
|---|
| 1499 | memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar ); |
|---|
| 1500 | #if H_3D_NBDV |
|---|
| 1501 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition ); |
|---|
| 1502 | #endif |
|---|
| 1503 | |
|---|
| 1504 | memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); |
|---|
| 1505 | memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); |
|---|
| 1506 | memcpy( rpcCU->getCUTransquantBypass()+ m_uiAbsIdxInLCU, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); |
|---|
| 1507 | memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); |
|---|
| 1508 | memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); |
|---|
| 1509 | #if H_3D_VSP |
|---|
| 1510 | memcpy( rpcCU->getVSPFlag() + m_uiAbsIdxInLCU, m_piVSPFlag, sizeof( Char ) * m_uiNumPartition ); |
|---|
| 1511 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 1512 | memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof( *m_pDvInfo ) * m_uiNumPartition ); |
|---|
| 1513 | #endif |
|---|
| 1514 | #if MTK_VSP_FIX_E0172 |
|---|
| 1515 | memcpy( rpcCU->getVSPDir () + m_uiAbsIdxInLCU, m_piVSPDir , sizeInChar ); |
|---|
| 1516 | #endif |
|---|
| 1517 | #endif |
|---|
| 1518 | memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); |
|---|
| 1519 | memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); |
|---|
| 1520 | memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); |
|---|
| 1521 | memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); |
|---|
| 1522 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhTransformSkip[0], iSizeInUchar ); |
|---|
| 1523 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhTransformSkip[1], iSizeInUchar ); |
|---|
| 1524 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhTransformSkip[2], iSizeInUchar ); |
|---|
| 1525 | |
|---|
| 1526 | memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); |
|---|
| 1527 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); |
|---|
| 1528 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); |
|---|
| 1529 | |
|---|
| 1530 | #if H_3D_DIM |
|---|
| 1531 | for( Int i = 0; i < DIM_NUM_TYPE; i++ ) |
|---|
| 1532 | { |
|---|
| 1533 | memcpy( rpcCU->getDimDeltaDC( i, 0 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition ); |
|---|
| 1534 | memcpy( rpcCU->getDimDeltaDC( i, 1 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition ); |
|---|
| 1535 | } |
|---|
| 1536 | #if H_3D_DIM_DMM |
|---|
| 1537 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 1538 | { |
|---|
| 1539 | memcpy( rpcCU->getDmmWedgeTabIdx( i ) + m_uiAbsIdxInLCU, m_dmmWedgeTabIdx[i], sizeof(UInt) * m_uiNumPartition ); |
|---|
| 1540 | } |
|---|
| 1541 | #if !SEC_DMM2_E0146 |
|---|
| 1542 | memcpy( rpcCU->getDmm2DeltaEnd() + m_uiAbsIdxInLCU, m_dmm2DeltaEnd , sizeof(Int ) * m_uiNumPartition ); |
|---|
| 1543 | #endif |
|---|
| 1544 | memcpy( rpcCU->getDmm3IntraTabIdx() + m_uiAbsIdxInLCU, m_dmm3IntraTabIdx, sizeof(UInt) * m_uiNumPartition ); |
|---|
| 1545 | #endif |
|---|
| 1546 | #if H_3D_DIM_RBC |
|---|
| 1547 | memcpy( rpcCU->getEdgeCode( m_uiAbsIdxInLCU ), m_pucEdgeCode, iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); |
|---|
| 1548 | memcpy( rpcCU->getEdgeNumber() + m_uiAbsIdxInLCU, m_pucEdgeNumber, iSizeInUchar ); |
|---|
| 1549 | memcpy( rpcCU->getEdgeStartPos() + m_uiAbsIdxInLCU, m_pucEdgeStartPos, iSizeInUchar ); |
|---|
| 1550 | memcpy( rpcCU->getEdgeLeftFirst() + m_uiAbsIdxInLCU, m_pbEdgeLeftFirst, iSizeInBool ); |
|---|
| 1551 | memcpy( rpcCU->getEdgePartition( m_uiAbsIdxInLCU ), m_pbEdgePartition, iSizeInBool * 16 ); |
|---|
| 1552 | #endif |
|---|
| 1553 | #if H_3D_DIM_SDC |
|---|
| 1554 | memcpy( rpcCU->getSDCFlag() + m_uiAbsIdxInLCU, m_pbSDCFlag, iSizeInBool ); |
|---|
| 1555 | memcpy( rpcCU->getSDCSegmentDCOffset(0) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition); |
|---|
| 1556 | memcpy( rpcCU->getSDCSegmentDCOffset(1) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition); |
|---|
| 1557 | #endif |
|---|
| 1558 | #endif |
|---|
| 1559 | #if LGE_INTER_SDC_E0156 |
|---|
| 1560 | memcpy( rpcCU->getInterSDCFlag() + m_uiAbsIdxInLCU, m_pbInterSDCFlag, iSizeInBool ); |
|---|
| 1561 | for( Int i = 0;i < 4; i++ ) |
|---|
| 1562 | { |
|---|
| 1563 | memcpy( rpcCU->getInterSDCSegmentDCOffset( i ) + m_uiAbsIdxInLCU, m_apSegmentInterDCOffset[i], sizeof( Int ) * m_uiNumPartition); |
|---|
| 1564 | } |
|---|
| 1565 | #endif |
|---|
| 1566 | memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); |
|---|
| 1567 | memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); |
|---|
| 1568 | memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); |
|---|
| 1569 | |
|---|
| 1570 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInUchar ); |
|---|
| 1571 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInUchar ); |
|---|
| 1572 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInUchar ); |
|---|
| 1573 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInUchar ); |
|---|
| 1574 | |
|---|
| 1575 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); |
|---|
| 1576 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); |
|---|
| 1577 | |
|---|
| 1578 | memcpy( rpcCU->getIPCMFlag() + m_uiAbsIdxInLCU, m_pbIPCMFlag, iSizeInBool ); |
|---|
| 1579 | |
|---|
| 1580 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); |
|---|
| 1581 | UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
|---|
| 1582 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
|---|
| 1583 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1584 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
|---|
| 1585 | #endif |
|---|
| 1586 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof(Pel)*uiTmp ); |
|---|
| 1587 | |
|---|
| 1588 | uiTmp >>= 2; uiTmp2 >>= 2; |
|---|
| 1589 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
|---|
| 1590 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
|---|
| 1591 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1592 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
|---|
| 1593 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
|---|
| 1594 | #endif |
|---|
| 1595 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
|---|
| 1596 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
|---|
| 1597 | rpcCU->getTotalBins() = m_uiTotalBins; |
|---|
| 1598 | memcpy( rpcCU->m_sliceStartCU + m_uiAbsIdxInLCU, m_sliceStartCU, sizeof( UInt ) * m_uiNumPartition ); |
|---|
| 1599 | memcpy( rpcCU->m_sliceSegmentStartCU + m_uiAbsIdxInLCU, m_sliceSegmentStartCU, sizeof( UInt ) * m_uiNumPartition ); |
|---|
| 1600 | #if H_3D_ARP |
|---|
| 1601 | memcpy( rpcCU->getARPW() + m_uiAbsIdxInLCU, m_puhARPW, iSizeInUchar ); |
|---|
| 1602 | #endif |
|---|
| 1603 | #if H_3D_IC |
|---|
| 1604 | memcpy( rpcCU->getICFlag() + m_uiAbsIdxInLCU, m_pbICFlag, iSizeInBool ); |
|---|
| 1605 | #endif |
|---|
| 1606 | } |
|---|
| 1607 | |
|---|
| 1608 | Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) |
|---|
| 1609 | { |
|---|
| 1610 | TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); |
|---|
| 1611 | UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); |
|---|
| 1612 | |
|---|
| 1613 | UInt uiPartStart = uiPartIdx*uiQNumPart; |
|---|
| 1614 | UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; |
|---|
| 1615 | |
|---|
| 1616 | rpcCU->getTotalCost() = m_dTotalCost; |
|---|
| 1617 | rpcCU->getTotalDistortion() = m_uiTotalDistortion; |
|---|
| 1618 | rpcCU->getTotalBits() = m_uiTotalBits; |
|---|
| 1619 | |
|---|
| 1620 | Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; |
|---|
| 1621 | Int iSizeInBool = sizeof( Bool ) * uiQNumPart; |
|---|
| 1622 | |
|---|
| 1623 | Int sizeInChar = sizeof( Char ) * uiQNumPart; |
|---|
| 1624 | memcpy( rpcCU->getSkipFlag() + uiPartOffset, m_skipFlag, sizeof( *m_skipFlag ) * uiQNumPart ); |
|---|
| 1625 | |
|---|
| 1626 | memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, sizeInChar ); |
|---|
| 1627 | memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart ); |
|---|
| 1628 | memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( *m_pePredMode ) * uiQNumPart ); |
|---|
| 1629 | memcpy( rpcCU->getCUTransquantBypass()+ uiPartOffset, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * uiQNumPart ); |
|---|
| 1630 | memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); |
|---|
| 1631 | memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); |
|---|
| 1632 | #if H_3D_VSP |
|---|
| 1633 | memcpy( rpcCU->getVSPFlag() + uiPartOffset, m_piVSPFlag, sizeof(Char) * uiQNumPart ); |
|---|
| 1634 | #if MTK_VSP_FIX_E0172 |
|---|
| 1635 | memcpy( rpcCU->getVSPDir () + uiPartOffset, m_piVSPDir , sizeInChar ); |
|---|
| 1636 | #endif |
|---|
| 1637 | #endif |
|---|
| 1638 | memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); |
|---|
| 1639 | memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); |
|---|
| 1640 | memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); |
|---|
| 1641 | memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); |
|---|
| 1642 | memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + uiPartOffset, m_puhTransformSkip[0], iSizeInUchar ); |
|---|
| 1643 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhTransformSkip[1], iSizeInUchar ); |
|---|
| 1644 | memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhTransformSkip[2], iSizeInUchar ); |
|---|
| 1645 | memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); |
|---|
| 1646 | memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); |
|---|
| 1647 | memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); |
|---|
| 1648 | |
|---|
| 1649 | #if H_3D_DIM |
|---|
| 1650 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 1651 | { |
|---|
| 1652 | memcpy( rpcCU->getDimDeltaDC( i, 0 ) + uiPartOffset, m_dimDeltaDC[i][0], sizeof(Pel ) * uiQNumPart ); |
|---|
| 1653 | memcpy( rpcCU->getDimDeltaDC( i, 1 ) + uiPartOffset, m_dimDeltaDC[i][1], sizeof(Pel ) * uiQNumPart ); |
|---|
| 1654 | } |
|---|
| 1655 | #if H_3D_DIM_DMM |
|---|
| 1656 | for( Int i = 0; i < DMM_NUM_TYPE; i++ ) |
|---|
| 1657 | { |
|---|
| 1658 | memcpy( rpcCU->getDmmWedgeTabIdx( i ) + uiPartOffset, m_dmmWedgeTabIdx[i], sizeof(UInt) * uiQNumPart ); |
|---|
| 1659 | } |
|---|
| 1660 | #if !SEC_DMM2_E0146 |
|---|
| 1661 | memcpy( rpcCU->getDmm2DeltaEnd() + uiPartOffset, m_dmm2DeltaEnd , sizeof(Int ) * uiQNumPart ); |
|---|
| 1662 | #endif |
|---|
| 1663 | memcpy( rpcCU->getDmm3IntraTabIdx() + uiPartOffset, m_dmm3IntraTabIdx, sizeof(UInt) * uiQNumPart ); |
|---|
| 1664 | #endif |
|---|
| 1665 | #if H_3D_DIM_RBC |
|---|
| 1666 | memcpy( rpcCU->getEdgeCode( uiPartOffset ), m_pucEdgeCode, iSizeInUchar * RBC_MAX_EDGE_NUM_PER_4x4 ); |
|---|
| 1667 | memcpy( rpcCU->getEdgeNumber() + uiPartOffset, m_pucEdgeNumber, iSizeInUchar ); |
|---|
| 1668 | memcpy( rpcCU->getEdgeStartPos() + uiPartOffset, m_pucEdgeStartPos, iSizeInUchar ); |
|---|
| 1669 | memcpy( rpcCU->getEdgeLeftFirst() + uiPartOffset, m_pbEdgeLeftFirst, iSizeInBool ); |
|---|
| 1670 | memcpy( rpcCU->getEdgePartition( uiPartOffset ), m_pbEdgePartition, iSizeInBool * 16 ); |
|---|
| 1671 | #endif |
|---|
| 1672 | #if H_3D_DIM_SDC |
|---|
| 1673 | memcpy( rpcCU->getSDCFlag() + uiPartOffset, m_pbSDCFlag, iSizeInBool ); |
|---|
| 1674 | memcpy( rpcCU->getSDCSegmentDCOffset(0) + uiPartOffset, m_apSegmentDCOffset[0], sizeof( Pel ) * uiQNumPart); |
|---|
| 1675 | memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart); |
|---|
| 1676 | #endif |
|---|
| 1677 | #endif |
|---|
| 1678 | #if LGE_INTER_SDC_E0156 |
|---|
| 1679 | memcpy( rpcCU->getInterSDCFlag() + uiPartOffset, m_pbInterSDCFlag, iSizeInBool ); |
|---|
| 1680 | for( Int i = 0; i < 4; i++ ) |
|---|
| 1681 | { |
|---|
| 1682 | memcpy( rpcCU->getInterSDCSegmentDCOffset( i ) + uiPartOffset, m_apSegmentInterDCOffset[i], sizeof( Int ) * uiQNumPart); |
|---|
| 1683 | } |
|---|
| 1684 | #endif |
|---|
| 1685 | memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); |
|---|
| 1686 | memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); |
|---|
| 1687 | memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); |
|---|
| 1688 | |
|---|
| 1689 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInUchar ); |
|---|
| 1690 | memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInUchar ); |
|---|
| 1691 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInUchar ); |
|---|
| 1692 | memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInUchar ); |
|---|
| 1693 | m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
|---|
| 1694 | m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); |
|---|
| 1695 | |
|---|
| 1696 | memcpy( rpcCU->getIPCMFlag() + uiPartOffset, m_pbIPCMFlag, iSizeInBool ); |
|---|
| 1697 | |
|---|
| 1698 | UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); |
|---|
| 1699 | UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); |
|---|
| 1700 | memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); |
|---|
| 1701 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1702 | memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); |
|---|
| 1703 | #endif |
|---|
| 1704 | |
|---|
| 1705 | memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof( Pel ) * uiTmp ); |
|---|
| 1706 | |
|---|
| 1707 | uiTmp >>= 2; uiTmp2 >>= 2; |
|---|
| 1708 | memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); |
|---|
| 1709 | memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); |
|---|
| 1710 | #if ADAPTIVE_QP_SELECTION |
|---|
| 1711 | memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); |
|---|
| 1712 | memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); |
|---|
| 1713 | #endif |
|---|
| 1714 | |
|---|
| 1715 | memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); |
|---|
| 1716 | memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); |
|---|
| 1717 | rpcCU->getTotalBins() = m_uiTotalBins; |
|---|
| 1718 | memcpy( rpcCU->m_sliceStartCU + uiPartOffset, m_sliceStartCU, sizeof( UInt ) * uiQNumPart ); |
|---|
| 1719 | memcpy( rpcCU->m_sliceSegmentStartCU + uiPartOffset, m_sliceSegmentStartCU, sizeof( UInt ) * uiQNumPart ); |
|---|
| 1720 | #if H_3D_ARP |
|---|
| 1721 | memcpy( rpcCU->getARPW() + uiPartOffset, m_puhARPW, iSizeInUchar ); |
|---|
| 1722 | #endif |
|---|
| 1723 | #if H_3D_IC |
|---|
| 1724 | memcpy( rpcCU->getICFlag() + uiPartOffset, m_pbICFlag, iSizeInBool ); |
|---|
| 1725 | #endif |
|---|
| 1726 | } |
|---|
| 1727 | |
|---|
| 1728 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 1729 | // Other public functions |
|---|
| 1730 | // -------------------------------------------------------------------------------------------------------------------- |
|---|
| 1731 | |
|---|
| 1732 | TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, |
|---|
| 1733 | UInt uiCurrPartUnitIdx, |
|---|
| 1734 | Bool bEnforceSliceRestriction, |
|---|
| 1735 | Bool bEnforceTileRestriction ) |
|---|
| 1736 | { |
|---|
| 1737 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1738 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
|---|
| 1739 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1740 | |
|---|
| 1741 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
|---|
| 1742 | { |
|---|
| 1743 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
|---|
| 1744 | if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
|---|
| 1745 | { |
|---|
| 1746 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1747 | } |
|---|
| 1748 | else |
|---|
| 1749 | { |
|---|
| 1750 | uiLPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1751 | return this; |
|---|
| 1752 | } |
|---|
| 1753 | } |
|---|
| 1754 | |
|---|
| 1755 | uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; |
|---|
| 1756 | |
|---|
| 1757 | |
|---|
| 1758 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
|---|
| 1759 | || |
|---|
| 1760 | (bEnforceTileRestriction && ( m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) ) ) |
|---|
| 1761 | ) |
|---|
| 1762 | { |
|---|
| 1763 | return NULL; |
|---|
| 1764 | } |
|---|
| 1765 | return m_pcCULeft; |
|---|
| 1766 | } |
|---|
| 1767 | |
|---|
| 1768 | TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, |
|---|
| 1769 | UInt uiCurrPartUnitIdx, |
|---|
| 1770 | Bool bEnforceSliceRestriction, |
|---|
| 1771 | Bool planarAtLCUBoundary , |
|---|
| 1772 | Bool bEnforceTileRestriction ) |
|---|
| 1773 | { |
|---|
| 1774 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1775 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
|---|
| 1776 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1777 | |
|---|
| 1778 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
|---|
| 1779 | { |
|---|
| 1780 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ]; |
|---|
| 1781 | if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
|---|
| 1782 | { |
|---|
| 1783 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1784 | } |
|---|
| 1785 | else |
|---|
| 1786 | { |
|---|
| 1787 | uiAPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1788 | return this; |
|---|
| 1789 | } |
|---|
| 1790 | } |
|---|
| 1791 | |
|---|
| 1792 | if(planarAtLCUBoundary) |
|---|
| 1793 | { |
|---|
| 1794 | return NULL; |
|---|
| 1795 | } |
|---|
| 1796 | |
|---|
| 1797 | uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
|---|
| 1798 | |
|---|
| 1799 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) |
|---|
| 1800 | || |
|---|
| 1801 | (bEnforceTileRestriction &&(m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())))) |
|---|
| 1802 | ) |
|---|
| 1803 | { |
|---|
| 1804 | return NULL; |
|---|
| 1805 | } |
|---|
| 1806 | return m_pcCUAbove; |
|---|
| 1807 | } |
|---|
| 1808 | |
|---|
| 1809 | TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
|---|
| 1810 | { |
|---|
| 1811 | UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1812 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_uiAbsIdxInLCU]; |
|---|
| 1813 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1814 | |
|---|
| 1815 | if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
|---|
| 1816 | { |
|---|
| 1817 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
|---|
| 1818 | { |
|---|
| 1819 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ]; |
|---|
| 1820 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
|---|
| 1821 | { |
|---|
| 1822 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1823 | } |
|---|
| 1824 | else |
|---|
| 1825 | { |
|---|
| 1826 | uiALPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1827 | return this; |
|---|
| 1828 | } |
|---|
| 1829 | } |
|---|
| 1830 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; |
|---|
| 1831 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
|---|
| 1832 | m_pcCUAbove->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1833 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1834 | )) |
|---|
| 1835 | ) |
|---|
| 1836 | { |
|---|
| 1837 | return NULL; |
|---|
| 1838 | } |
|---|
| 1839 | return m_pcCUAbove; |
|---|
| 1840 | } |
|---|
| 1841 | |
|---|
| 1842 | if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) ) |
|---|
| 1843 | { |
|---|
| 1844 | uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; |
|---|
| 1845 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
|---|
| 1846 | m_pcCULeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1847 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1848 | )) |
|---|
| 1849 | ) |
|---|
| 1850 | { |
|---|
| 1851 | return NULL; |
|---|
| 1852 | } |
|---|
| 1853 | return m_pcCULeft; |
|---|
| 1854 | } |
|---|
| 1855 | |
|---|
| 1856 | uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; |
|---|
| 1857 | if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || |
|---|
| 1858 | m_pcCUAboveLeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1859 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveLeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1860 | )) |
|---|
| 1861 | ) |
|---|
| 1862 | { |
|---|
| 1863 | return NULL; |
|---|
| 1864 | } |
|---|
| 1865 | return m_pcCUAboveLeft; |
|---|
| 1866 | } |
|---|
| 1867 | |
|---|
| 1868 | TComDataCU* TComDataCU::getPUAboveRight( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
|---|
| 1869 | { |
|---|
| 1870 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1871 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1; |
|---|
| 1872 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1873 | |
|---|
| 1874 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
|---|
| 1875 | { |
|---|
| 1876 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 1877 | return NULL; |
|---|
| 1878 | } |
|---|
| 1879 | |
|---|
| 1880 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - 1, uiNumPartInCUWidth ) ) |
|---|
| 1881 | { |
|---|
| 1882 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
|---|
| 1883 | { |
|---|
| 1884 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] ) |
|---|
| 1885 | { |
|---|
| 1886 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ]; |
|---|
| 1887 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
|---|
| 1888 | { |
|---|
| 1889 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1890 | } |
|---|
| 1891 | else |
|---|
| 1892 | { |
|---|
| 1893 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1894 | return this; |
|---|
| 1895 | } |
|---|
| 1896 | } |
|---|
| 1897 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 1898 | return NULL; |
|---|
| 1899 | } |
|---|
| 1900 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; |
|---|
| 1901 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
|---|
| 1902 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1903 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1904 | )) |
|---|
| 1905 | ) |
|---|
| 1906 | { |
|---|
| 1907 | return NULL; |
|---|
| 1908 | } |
|---|
| 1909 | return m_pcCUAbove; |
|---|
| 1910 | } |
|---|
| 1911 | |
|---|
| 1912 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
|---|
| 1913 | { |
|---|
| 1914 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 1915 | return NULL; |
|---|
| 1916 | } |
|---|
| 1917 | |
|---|
| 1918 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; |
|---|
| 1919 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
|---|
| 1920 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
|---|
| 1921 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1922 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1923 | )) |
|---|
| 1924 | ) |
|---|
| 1925 | { |
|---|
| 1926 | return NULL; |
|---|
| 1927 | } |
|---|
| 1928 | return m_pcCUAboveRight; |
|---|
| 1929 | } |
|---|
| 1930 | |
|---|
| 1931 | TComDataCU* TComDataCU::getPUBelowLeft( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) |
|---|
| 1932 | { |
|---|
| 1933 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1934 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth(); |
|---|
| 1935 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1936 | |
|---|
| 1937 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
|---|
| 1938 | { |
|---|
| 1939 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 1940 | return NULL; |
|---|
| 1941 | } |
|---|
| 1942 | |
|---|
| 1943 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - 1, uiNumPartInCUWidth ) ) |
|---|
| 1944 | { |
|---|
| 1945 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
|---|
| 1946 | { |
|---|
| 1947 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) |
|---|
| 1948 | { |
|---|
| 1949 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; |
|---|
| 1950 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
|---|
| 1951 | { |
|---|
| 1952 | return m_pcPic->getCU( getAddr() ); |
|---|
| 1953 | } |
|---|
| 1954 | else |
|---|
| 1955 | { |
|---|
| 1956 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 1957 | return this; |
|---|
| 1958 | } |
|---|
| 1959 | } |
|---|
| 1960 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 1961 | return NULL; |
|---|
| 1962 | } |
|---|
| 1963 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; |
|---|
| 1964 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
|---|
| 1965 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 1966 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 1967 | )) |
|---|
| 1968 | ) |
|---|
| 1969 | { |
|---|
| 1970 | return NULL; |
|---|
| 1971 | } |
|---|
| 1972 | return m_pcCULeft; |
|---|
| 1973 | } |
|---|
| 1974 | |
|---|
| 1975 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 1976 | return NULL; |
|---|
| 1977 | } |
|---|
| 1978 | |
|---|
| 1979 | TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
|---|
| 1980 | { |
|---|
| 1981 | UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 1982 | UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth(); |
|---|
| 1983 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 1984 | |
|---|
| 1985 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) |
|---|
| 1986 | { |
|---|
| 1987 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 1988 | return NULL; |
|---|
| 1989 | } |
|---|
| 1990 | |
|---|
| 1991 | if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
|---|
| 1992 | { |
|---|
| 1993 | if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) |
|---|
| 1994 | { |
|---|
| 1995 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] ) |
|---|
| 1996 | { |
|---|
| 1997 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ]; |
|---|
| 1998 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) |
|---|
| 1999 | { |
|---|
| 2000 | return m_pcPic->getCU( getAddr() ); |
|---|
| 2001 | } |
|---|
| 2002 | else |
|---|
| 2003 | { |
|---|
| 2004 | uiBLPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 2005 | return this; |
|---|
| 2006 | } |
|---|
| 2007 | } |
|---|
| 2008 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 2009 | return NULL; |
|---|
| 2010 | } |
|---|
| 2011 | uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; |
|---|
| 2012 | if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || |
|---|
| 2013 | m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 2014 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 2015 | )) |
|---|
| 2016 | ) |
|---|
| 2017 | { |
|---|
| 2018 | return NULL; |
|---|
| 2019 | } |
|---|
| 2020 | return m_pcCULeft; |
|---|
| 2021 | } |
|---|
| 2022 | |
|---|
| 2023 | uiBLPartUnitIdx = MAX_UINT; |
|---|
| 2024 | return NULL; |
|---|
| 2025 | } |
|---|
| 2026 | |
|---|
| 2027 | TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) |
|---|
| 2028 | { |
|---|
| 2029 | UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; |
|---|
| 2030 | UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; |
|---|
| 2031 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 2032 | |
|---|
| 2033 | if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
|---|
| 2034 | { |
|---|
| 2035 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 2036 | return NULL; |
|---|
| 2037 | } |
|---|
| 2038 | |
|---|
| 2039 | if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - uiPartUnitOffset, uiNumPartInCUWidth ) ) |
|---|
| 2040 | { |
|---|
| 2041 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
|---|
| 2042 | { |
|---|
| 2043 | if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] ) |
|---|
| 2044 | { |
|---|
| 2045 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ]; |
|---|
| 2046 | if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) |
|---|
| 2047 | { |
|---|
| 2048 | return m_pcPic->getCU( getAddr() ); |
|---|
| 2049 | } |
|---|
| 2050 | else |
|---|
| 2051 | { |
|---|
| 2052 | uiARPartUnitIdx -= m_uiAbsIdxInLCU; |
|---|
| 2053 | return this; |
|---|
| 2054 | } |
|---|
| 2055 | } |
|---|
| 2056 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 2057 | return NULL; |
|---|
| 2058 | } |
|---|
| 2059 | uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; |
|---|
| 2060 | if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || |
|---|
| 2061 | m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 2062 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 2063 | )) |
|---|
| 2064 | ) |
|---|
| 2065 | { |
|---|
| 2066 | return NULL; |
|---|
| 2067 | } |
|---|
| 2068 | return m_pcCUAbove; |
|---|
| 2069 | } |
|---|
| 2070 | |
|---|
| 2071 | if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) |
|---|
| 2072 | { |
|---|
| 2073 | uiARPartUnitIdx = MAX_UINT; |
|---|
| 2074 | return NULL; |
|---|
| 2075 | } |
|---|
| 2076 | |
|---|
| 2077 | uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; |
|---|
| 2078 | if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || |
|---|
| 2079 | m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || |
|---|
| 2080 | m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| |
|---|
| 2081 | (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) |
|---|
| 2082 | )) |
|---|
| 2083 | ) |
|---|
| 2084 | { |
|---|
| 2085 | return NULL; |
|---|
| 2086 | } |
|---|
| 2087 | return m_pcCUAboveRight; |
|---|
| 2088 | } |
|---|
| 2089 | |
|---|
| 2090 | /** Get left QpMinCu |
|---|
| 2091 | *\param uiLPartUnitIdx |
|---|
| 2092 | *\param uiCurrAbsIdxInLCU |
|---|
| 2093 | *\returns TComDataCU* point of TComDataCU of left QpMinCu |
|---|
| 2094 | */ |
|---|
| 2095 | TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInLCU) |
|---|
| 2096 | { |
|---|
| 2097 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 2098 | UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth -getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
|---|
| 2099 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
|---|
| 2100 | |
|---|
| 2101 | // check for left LCU boundary |
|---|
| 2102 | if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCUWidth) ) |
|---|
| 2103 | { |
|---|
| 2104 | return NULL; |
|---|
| 2105 | } |
|---|
| 2106 | |
|---|
| 2107 | // get index of left-CU relative to top-left corner of current quantization group |
|---|
| 2108 | uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; |
|---|
| 2109 | |
|---|
| 2110 | // return pointer to current LCU |
|---|
| 2111 | return m_pcPic->getCU( getAddr() ); |
|---|
| 2112 | } |
|---|
| 2113 | |
|---|
| 2114 | /** Get Above QpMinCu |
|---|
| 2115 | *\param aPartUnitIdx |
|---|
| 2116 | *\param currAbsIdxInLCU |
|---|
| 2117 | *\returns TComDataCU* point of TComDataCU of above QpMinCu |
|---|
| 2118 | */ |
|---|
| 2119 | TComDataCU* TComDataCU::getQpMinCuAbove( UInt& aPartUnitIdx, UInt currAbsIdxInLCU ) |
|---|
| 2120 | { |
|---|
| 2121 | UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 2122 | UInt absZorderQpMinCUIdx = (currAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1); |
|---|
| 2123 | UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; |
|---|
| 2124 | |
|---|
| 2125 | // check for top LCU boundary |
|---|
| 2126 | if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCUWidth) ) |
|---|
| 2127 | { |
|---|
| 2128 | return NULL; |
|---|
| 2129 | } |
|---|
| 2130 | |
|---|
| 2131 | // get index of top-CU relative to top-left corner of current quantization group |
|---|
| 2132 | aPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCUWidth]; |
|---|
| 2133 | |
|---|
| 2134 | // return pointer to current LCU |
|---|
| 2135 | return m_pcPic->getCU( getAddr() ); |
|---|
| 2136 | } |
|---|
| 2137 | |
|---|
| 2138 | /** Get reference QP from left QpMinCu or latest coded QP |
|---|
| 2139 | *\param uiCurrAbsIdxInLCU |
|---|
| 2140 | *\returns Char reference QP value |
|---|
| 2141 | */ |
|---|
| 2142 | Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInLCU ) |
|---|
| 2143 | { |
|---|
| 2144 | UInt lPartIdx = 0, aPartIdx = 0; |
|---|
| 2145 | TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
|---|
| 2146 | TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); |
|---|
| 2147 | return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + 1) >> 1); |
|---|
| 2148 | } |
|---|
| 2149 | |
|---|
| 2150 | Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) |
|---|
| 2151 | { |
|---|
| 2152 | Int iLastValidPartIdx = iAbsPartIdx-1; |
|---|
| 2153 | while ( iLastValidPartIdx >= 0 |
|---|
| 2154 | && getPredictionMode( iLastValidPartIdx ) == MODE_NONE ) |
|---|
| 2155 | { |
|---|
| 2156 | UInt uiDepth = getDepth( iLastValidPartIdx ); |
|---|
| 2157 | iLastValidPartIdx -= m_uiNumPartition>>(uiDepth<<1); |
|---|
| 2158 | } |
|---|
| 2159 | return iLastValidPartIdx; |
|---|
| 2160 | } |
|---|
| 2161 | |
|---|
| 2162 | Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) |
|---|
| 2163 | { |
|---|
| 2164 | UInt uiQUPartIdxMask = ~((1<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); |
|---|
| 2165 | Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); |
|---|
| 2166 | if ( uiAbsPartIdx < m_uiNumPartition |
|---|
| 2167 | && (getSCUAddr()+iLastValidPartIdx < getSliceStartCU(m_uiAbsIdxInLCU+uiAbsPartIdx))) |
|---|
| 2168 | { |
|---|
| 2169 | return getSlice()->getSliceQp(); |
|---|
| 2170 | } |
|---|
| 2171 | else if ( iLastValidPartIdx >= 0 ) |
|---|
| 2172 | { |
|---|
| 2173 | return getQP( iLastValidPartIdx ); |
|---|
| 2174 | } |
|---|
| 2175 | else |
|---|
| 2176 | { |
|---|
| 2177 | if ( getZorderIdxInCU() > 0 ) |
|---|
| 2178 | { |
|---|
| 2179 | return getPic()->getCU( getAddr() )->getLastCodedQP( getZorderIdxInCU() ); |
|---|
| 2180 | } |
|---|
| 2181 | else if ( getPic()->getPicSym()->getInverseCUOrderMap(getAddr()) > 0 |
|---|
| 2182 | && getPic()->getPicSym()->getTileIdxMap(getAddr()) == getPic()->getPicSym()->getTileIdxMap(getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1)) |
|---|
| 2183 | && !( getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() && getAddr() % getPic()->getFrameWidthInCU() == 0 ) ) |
|---|
| 2184 | { |
|---|
| 2185 | return getPic()->getCU( getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1) )->getLastCodedQP( getPic()->getNumPartInCU() ); |
|---|
| 2186 | } |
|---|
| 2187 | else |
|---|
| 2188 | { |
|---|
| 2189 | return getSlice()->getSliceQp(); |
|---|
| 2190 | } |
|---|
| 2191 | } |
|---|
| 2192 | } |
|---|
| 2193 | /** Check whether the CU is coded in lossless coding mode |
|---|
| 2194 | * \param uiAbsPartIdx |
|---|
| 2195 | * \returns true if the CU is coded in lossless coding mode; false if otherwise |
|---|
| 2196 | */ |
|---|
| 2197 | Bool TComDataCU::isLosslessCoded(UInt absPartIdx) |
|---|
| 2198 | { |
|---|
| 2199 | return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); |
|---|
| 2200 | } |
|---|
| 2201 | |
|---|
| 2202 | /** Get allowed chroma intra modes |
|---|
| 2203 | *\param uiAbsPartIdx |
|---|
| 2204 | *\param uiModeList pointer to chroma intra modes array |
|---|
| 2205 | *\returns |
|---|
| 2206 | *- fill uiModeList with chroma intra modes |
|---|
| 2207 | */ |
|---|
| 2208 | Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt* uiModeList ) |
|---|
| 2209 | { |
|---|
| 2210 | uiModeList[0] = PLANAR_IDX; |
|---|
| 2211 | uiModeList[1] = VER_IDX; |
|---|
| 2212 | uiModeList[2] = HOR_IDX; |
|---|
| 2213 | uiModeList[3] = DC_IDX; |
|---|
| 2214 | uiModeList[4] = DM_CHROMA_IDX; |
|---|
| 2215 | |
|---|
| 2216 | UInt uiLumaMode = getLumaIntraDir( uiAbsPartIdx ); |
|---|
| 2217 | |
|---|
| 2218 | for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) |
|---|
| 2219 | { |
|---|
| 2220 | if( uiLumaMode == uiModeList[i] ) |
|---|
| 2221 | { |
|---|
| 2222 | uiModeList[i] = 34; // VER+8 mode |
|---|
| 2223 | break; |
|---|
| 2224 | } |
|---|
| 2225 | } |
|---|
| 2226 | } |
|---|
| 2227 | |
|---|
| 2228 | /** Get most probable intra modes |
|---|
| 2229 | *\param uiAbsPartIdx |
|---|
| 2230 | *\param uiIntraDirPred pointer to the array for MPM storage |
|---|
| 2231 | *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. |
|---|
| 2232 | *\returns Number of MPM |
|---|
| 2233 | */ |
|---|
| 2234 | Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode ) |
|---|
| 2235 | { |
|---|
| 2236 | TComDataCU* pcTempCU; |
|---|
| 2237 | UInt uiTempPartIdx; |
|---|
| 2238 | Int iLeftIntraDir, iAboveIntraDir; |
|---|
| 2239 | Int uiPredNum = 0; |
|---|
| 2240 | |
|---|
| 2241 | // Get intra direction of left PU |
|---|
| 2242 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 2243 | |
|---|
| 2244 | iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
|---|
| 2245 | #if H_3D_DIM |
|---|
| 2246 | mapDepthModeToIntraDir( iLeftIntraDir ); |
|---|
| 2247 | #endif |
|---|
| 2248 | |
|---|
| 2249 | // Get intra direction of above PU |
|---|
| 2250 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true ); |
|---|
| 2251 | |
|---|
| 2252 | iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; |
|---|
| 2253 | #if H_3D_DIM |
|---|
| 2254 | mapDepthModeToIntraDir( iAboveIntraDir ); |
|---|
| 2255 | #endif |
|---|
| 2256 | |
|---|
| 2257 | uiPredNum = 3; |
|---|
| 2258 | if(iLeftIntraDir == iAboveIntraDir) |
|---|
| 2259 | { |
|---|
| 2260 | if( piMode ) |
|---|
| 2261 | { |
|---|
| 2262 | *piMode = 1; |
|---|
| 2263 | } |
|---|
| 2264 | |
|---|
| 2265 | if (iLeftIntraDir > 1) // angular modes |
|---|
| 2266 | { |
|---|
| 2267 | uiIntraDirPred[0] = iLeftIntraDir; |
|---|
| 2268 | uiIntraDirPred[1] = ((iLeftIntraDir + 29) % 32) + 2; |
|---|
| 2269 | uiIntraDirPred[2] = ((iLeftIntraDir - 1 ) % 32) + 2; |
|---|
| 2270 | } |
|---|
| 2271 | else //non-angular |
|---|
| 2272 | { |
|---|
| 2273 | uiIntraDirPred[0] = PLANAR_IDX; |
|---|
| 2274 | uiIntraDirPred[1] = DC_IDX; |
|---|
| 2275 | uiIntraDirPred[2] = VER_IDX; |
|---|
| 2276 | } |
|---|
| 2277 | } |
|---|
| 2278 | else |
|---|
| 2279 | { |
|---|
| 2280 | if( piMode ) |
|---|
| 2281 | { |
|---|
| 2282 | *piMode = 2; |
|---|
| 2283 | } |
|---|
| 2284 | uiIntraDirPred[0] = iLeftIntraDir; |
|---|
| 2285 | uiIntraDirPred[1] = iAboveIntraDir; |
|---|
| 2286 | |
|---|
| 2287 | if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar |
|---|
| 2288 | { |
|---|
| 2289 | uiIntraDirPred[2] = PLANAR_IDX; |
|---|
| 2290 | } |
|---|
| 2291 | else |
|---|
| 2292 | { |
|---|
| 2293 | uiIntraDirPred[2] = (iLeftIntraDir+iAboveIntraDir)<2? VER_IDX : DC_IDX; |
|---|
| 2294 | } |
|---|
| 2295 | } |
|---|
| 2296 | |
|---|
| 2297 | return uiPredNum; |
|---|
| 2298 | } |
|---|
| 2299 | |
|---|
| 2300 | UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2301 | { |
|---|
| 2302 | TComDataCU* pcTempCU; |
|---|
| 2303 | UInt uiTempPartIdx; |
|---|
| 2304 | UInt uiCtx; |
|---|
| 2305 | // Get left split flag |
|---|
| 2306 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 2307 | uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
|---|
| 2308 | |
|---|
| 2309 | // Get above split flag |
|---|
| 2310 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 2311 | uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; |
|---|
| 2312 | |
|---|
| 2313 | return uiCtx; |
|---|
| 2314 | } |
|---|
| 2315 | |
|---|
| 2316 | UInt TComDataCU::getCtxQtCbf( TextType eType, UInt uiTrDepth ) |
|---|
| 2317 | { |
|---|
| 2318 | if( eType ) |
|---|
| 2319 | { |
|---|
| 2320 | return uiTrDepth; |
|---|
| 2321 | } |
|---|
| 2322 | else |
|---|
| 2323 | { |
|---|
| 2324 | const UInt uiCtx = ( uiTrDepth == 0 ? 1 : 0 ); |
|---|
| 2325 | return uiCtx; |
|---|
| 2326 | } |
|---|
| 2327 | } |
|---|
| 2328 | |
|---|
| 2329 | UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) |
|---|
| 2330 | { |
|---|
| 2331 | UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; |
|---|
| 2332 | PartSize partSize = getPartitionSize( absPartIdx ); |
|---|
| 2333 | UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); |
|---|
| 2334 | Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0; |
|---|
| 2335 | Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) ); |
|---|
| 2336 | |
|---|
| 2337 | UInt log2MinTUSizeInCU = 0; |
|---|
| 2338 | if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) |
|---|
| 2339 | { |
|---|
| 2340 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize |
|---|
| 2341 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MinSize(); |
|---|
| 2342 | } |
|---|
| 2343 | else |
|---|
| 2344 | { |
|---|
| 2345 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still >= QuadtreeTULog2MinSize |
|---|
| 2346 | log2MinTUSizeInCU = log2CbSize - ( quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag); // stop when trafoDepth == hierarchy_depth = splitFlag |
|---|
| 2347 | if ( log2MinTUSizeInCU > m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize()) |
|---|
| 2348 | { |
|---|
| 2349 | // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize |
|---|
| 2350 | log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); |
|---|
| 2351 | } |
|---|
| 2352 | } |
|---|
| 2353 | return log2MinTUSizeInCU; |
|---|
| 2354 | } |
|---|
| 2355 | |
|---|
| 2356 | UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) |
|---|
| 2357 | { |
|---|
| 2358 | TComDataCU* pcTempCU; |
|---|
| 2359 | UInt uiTempPartIdx; |
|---|
| 2360 | UInt uiCtx = 0; |
|---|
| 2361 | |
|---|
| 2362 | // Get BCBP of left PU |
|---|
| 2363 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 2364 | uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
|---|
| 2365 | |
|---|
| 2366 | // Get BCBP of above PU |
|---|
| 2367 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 2368 | uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; |
|---|
| 2369 | |
|---|
| 2370 | return uiCtx; |
|---|
| 2371 | } |
|---|
| 2372 | |
|---|
| 2373 | #if H_3D_ARP |
|---|
| 2374 | UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx ) |
|---|
| 2375 | { |
|---|
| 2376 | TComDataCU* pcTempCU; |
|---|
| 2377 | UInt uiTempPartIdx; |
|---|
| 2378 | UInt uiCtx = 0; |
|---|
| 2379 | |
|---|
| 2380 | pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 2381 | uiCtx = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0; |
|---|
| 2382 | |
|---|
| 2383 | pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); |
|---|
| 2384 | uiCtx += ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1): 0; |
|---|
| 2385 | |
|---|
| 2386 | return uiCtx; |
|---|
| 2387 | } |
|---|
| 2388 | #endif |
|---|
| 2389 | |
|---|
| 2390 | #if H_3D_IC |
|---|
| 2391 | UInt TComDataCU::getCtxICFlag( UInt uiAbsPartIdx ) |
|---|
| 2392 | { |
|---|
| 2393 | UInt uiCtx = 0; |
|---|
| 2394 | |
|---|
| 2395 | return uiCtx; |
|---|
| 2396 | } |
|---|
| 2397 | #endif |
|---|
| 2398 | |
|---|
| 2399 | #if LGE_INTER_SDC_E0156 |
|---|
| 2400 | Void TComDataCU::setInterSDCFlagSubParts ( Bool bInterSDCFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2401 | { |
|---|
| 2402 | setSubPart( bInterSDCFlag, m_pbInterSDCFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2403 | } |
|---|
| 2404 | |
|---|
| 2405 | UInt TComDataCU::getCtxInterSDCFlag( UInt uiAbsPartIdx ) |
|---|
| 2406 | { |
|---|
| 2407 | return 0; |
|---|
| 2408 | } |
|---|
| 2409 | |
|---|
| 2410 | Void TComDataCU::xSetInterSDCCUMask( TComDataCU *pcCU, UChar *pMask ) |
|---|
| 2411 | { |
|---|
| 2412 | UInt uiWidth = pcCU->getWidth ( 0 ); |
|---|
| 2413 | UInt uiHeight = pcCU->getHeight( 0 ); |
|---|
| 2414 | UInt uiPartitionSize = pcCU->getPartitionSize( 0 ); |
|---|
| 2415 | UInt uiXOffset = 0, uiYOffset = 0; |
|---|
| 2416 | |
|---|
| 2417 | switch( uiPartitionSize ) |
|---|
| 2418 | { |
|---|
| 2419 | case SIZE_2NxN: |
|---|
| 2420 | uiXOffset = uiWidth; uiYOffset = uiHeight >> 1; break; |
|---|
| 2421 | case SIZE_2NxnU: |
|---|
| 2422 | uiXOffset = uiWidth; uiYOffset = uiHeight >> 2; break; |
|---|
| 2423 | case SIZE_2NxnD: |
|---|
| 2424 | uiXOffset = uiWidth; uiYOffset = ( uiHeight >> 1 ) + ( uiHeight >> 2 ); break; |
|---|
| 2425 | case SIZE_Nx2N: |
|---|
| 2426 | uiXOffset = uiWidth >> 1; uiYOffset = uiHeight; break; |
|---|
| 2427 | case SIZE_nLx2N: |
|---|
| 2428 | uiXOffset = uiWidth >> 2; uiYOffset = uiHeight; break; |
|---|
| 2429 | case SIZE_nRx2N: |
|---|
| 2430 | uiXOffset = ( uiWidth >> 1 ) + ( uiWidth >> 2 ); uiYOffset = uiHeight; break; |
|---|
| 2431 | case SIZE_NxN: |
|---|
| 2432 | uiXOffset = uiWidth >> 1; uiYOffset = uiHeight >> 1; break; |
|---|
| 2433 | default: |
|---|
| 2434 | assert( uiPartitionSize == SIZE_2Nx2N ); |
|---|
| 2435 | uiXOffset = uiWidth; uiYOffset = uiHeight; break; |
|---|
| 2436 | } |
|---|
| 2437 | |
|---|
| 2438 | UInt uiPelX, uiPelY; |
|---|
| 2439 | |
|---|
| 2440 | memset( pMask, 0, uiWidth*uiHeight ); |
|---|
| 2441 | |
|---|
| 2442 | //mask |
|---|
| 2443 | if( uiPartitionSize == SIZE_2NxN || uiPartitionSize == SIZE_2NxnD || uiPartitionSize == SIZE_2NxnU ) |
|---|
| 2444 | { |
|---|
| 2445 | for( uiPelY = 0; uiPelY < uiYOffset; uiPelY++ ) |
|---|
| 2446 | { |
|---|
| 2447 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
|---|
| 2448 | { |
|---|
| 2449 | pMask[uiPelX + uiPelY*uiWidth] = 0; |
|---|
| 2450 | } |
|---|
| 2451 | } |
|---|
| 2452 | |
|---|
| 2453 | for( ; uiPelY < uiHeight; uiPelY++ ) |
|---|
| 2454 | { |
|---|
| 2455 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
|---|
| 2456 | { |
|---|
| 2457 | pMask[uiPelX + uiPelY*uiWidth] = 1; |
|---|
| 2458 | } |
|---|
| 2459 | } |
|---|
| 2460 | } |
|---|
| 2461 | else if( uiPartitionSize == SIZE_Nx2N || uiPartitionSize == SIZE_nLx2N || uiPartitionSize == SIZE_nRx2N ) |
|---|
| 2462 | { |
|---|
| 2463 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
|---|
| 2464 | { |
|---|
| 2465 | for( uiPelX = 0; uiPelX < uiXOffset; uiPelX++ ) |
|---|
| 2466 | { |
|---|
| 2467 | pMask[uiPelX + uiPelY*uiWidth] = 0; |
|---|
| 2468 | } |
|---|
| 2469 | |
|---|
| 2470 | for( ; uiPelX < uiWidth; uiPelX++ ) |
|---|
| 2471 | { |
|---|
| 2472 | pMask[uiPelX + uiPelY*uiWidth] = 1; |
|---|
| 2473 | } |
|---|
| 2474 | } |
|---|
| 2475 | } |
|---|
| 2476 | else if( uiPartitionSize == SIZE_NxN ) |
|---|
| 2477 | { |
|---|
| 2478 | for( uiPelY = 0; uiPelY < uiYOffset; uiPelY++ ) |
|---|
| 2479 | { |
|---|
| 2480 | for( uiPelX = 0; uiPelX < uiXOffset; uiPelX++ ) |
|---|
| 2481 | { |
|---|
| 2482 | pMask[uiPelX + uiPelY*uiWidth] = 0; |
|---|
| 2483 | } |
|---|
| 2484 | |
|---|
| 2485 | for( ; uiPelX < uiWidth; uiPelX++ ) |
|---|
| 2486 | { |
|---|
| 2487 | pMask[uiPelX + uiPelY*uiWidth] = 1; |
|---|
| 2488 | } |
|---|
| 2489 | } |
|---|
| 2490 | |
|---|
| 2491 | for( ; uiPelY < uiHeight; uiPelY++ ) |
|---|
| 2492 | { |
|---|
| 2493 | for( uiPelX = 0; uiPelX < uiXOffset; uiPelX++ ) |
|---|
| 2494 | { |
|---|
| 2495 | pMask[uiPelX + uiPelY*uiWidth] = 2; |
|---|
| 2496 | } |
|---|
| 2497 | |
|---|
| 2498 | for( ; uiPelX < uiWidth; uiPelX++ ) |
|---|
| 2499 | { |
|---|
| 2500 | pMask[uiPelX + uiPelY*uiWidth] = 3; |
|---|
| 2501 | } |
|---|
| 2502 | } |
|---|
| 2503 | } |
|---|
| 2504 | |
|---|
| 2505 | } |
|---|
| 2506 | #endif |
|---|
| 2507 | |
|---|
| 2508 | UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) |
|---|
| 2509 | { |
|---|
| 2510 | return getDepth( uiAbsPartIdx ); |
|---|
| 2511 | } |
|---|
| 2512 | |
|---|
| 2513 | Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2514 | { |
|---|
| 2515 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2516 | memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2517 | memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2518 | memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2519 | } |
|---|
| 2520 | |
|---|
| 2521 | Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2522 | { |
|---|
| 2523 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2524 | memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2525 | } |
|---|
| 2526 | |
|---|
| 2527 | /** Sets a coded block flag for all sub-partitions of a partition |
|---|
| 2528 | * \param uiCbf The value of the coded block flag to be set |
|---|
| 2529 | * \param eTType |
|---|
| 2530 | * \param uiAbsPartIdx |
|---|
| 2531 | * \param uiPartIdx |
|---|
| 2532 | * \param uiDepth |
|---|
| 2533 | * \returns Void |
|---|
| 2534 | */ |
|---|
| 2535 | Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2536 | { |
|---|
| 2537 | setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2538 | } |
|---|
| 2539 | |
|---|
| 2540 | Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) |
|---|
| 2541 | { |
|---|
| 2542 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2543 | memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2544 | } |
|---|
| 2545 | |
|---|
| 2546 | Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) |
|---|
| 2547 | { |
|---|
| 2548 | UInt uiPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2549 | return (((m_uiAbsIdxInLCU + uiAbsPartIdx)% uiPartNumb) == 0); |
|---|
| 2550 | } |
|---|
| 2551 | |
|---|
| 2552 | Void TComDataCU::setPartSizeSubParts( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2553 | { |
|---|
| 2554 | assert( sizeof( *m_pePartSize) == 1 ); |
|---|
| 2555 | memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
|---|
| 2556 | } |
|---|
| 2557 | |
|---|
| 2558 | Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2559 | { |
|---|
| 2560 | memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
|---|
| 2561 | } |
|---|
| 2562 | |
|---|
| 2563 | Void TComDataCU::setSkipFlagSubParts( Bool skip, UInt absPartIdx, UInt depth ) |
|---|
| 2564 | { |
|---|
| 2565 | assert( sizeof( *m_skipFlag) == 1 ); |
|---|
| 2566 | memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); |
|---|
| 2567 | } |
|---|
| 2568 | |
|---|
| 2569 | Void TComDataCU::setPredModeSubParts( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2570 | { |
|---|
| 2571 | assert( sizeof( *m_pePredMode) == 1 ); |
|---|
| 2572 | memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
|---|
| 2573 | } |
|---|
| 2574 | |
|---|
| 2575 | Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) |
|---|
| 2576 | { |
|---|
| 2577 | UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); |
|---|
| 2578 | UInt currPartNumQ = currPartNumb >> 2; |
|---|
| 2579 | |
|---|
| 2580 | if(!foundNonZeroCbf) |
|---|
| 2581 | { |
|---|
| 2582 | if(pcCU->getDepth(absPartIdx) > depth) |
|---|
| 2583 | { |
|---|
| 2584 | for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) |
|---|
| 2585 | { |
|---|
| 2586 | pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); |
|---|
| 2587 | } |
|---|
| 2588 | } |
|---|
| 2589 | else |
|---|
| 2590 | { |
|---|
| 2591 | if(pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V ) ) |
|---|
| 2592 | { |
|---|
| 2593 | foundNonZeroCbf = true; |
|---|
| 2594 | } |
|---|
| 2595 | else |
|---|
| 2596 | { |
|---|
| 2597 | setQPSubParts(qp, absPartIdx, depth); |
|---|
| 2598 | } |
|---|
| 2599 | } |
|---|
| 2600 | } |
|---|
| 2601 | } |
|---|
| 2602 | |
|---|
| 2603 | Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2604 | { |
|---|
| 2605 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2606 | TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); |
|---|
| 2607 | |
|---|
| 2608 | for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) |
|---|
| 2609 | { |
|---|
| 2610 | if( m_pcPic->getCU( getAddr() )->getSliceSegmentStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr() ) |
|---|
| 2611 | { |
|---|
| 2612 | m_phQP[uiSCUIdx] = qp; |
|---|
| 2613 | } |
|---|
| 2614 | } |
|---|
| 2615 | } |
|---|
| 2616 | |
|---|
| 2617 | Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2618 | { |
|---|
| 2619 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2620 | |
|---|
| 2621 | memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2622 | } |
|---|
| 2623 | |
|---|
| 2624 | template<typename T> |
|---|
| 2625 | Void TComDataCU::setSubPart( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
|---|
| 2626 | { |
|---|
| 2627 | assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 |
|---|
| 2628 | |
|---|
| 2629 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
|---|
| 2630 | switch ( m_pePartSize[ uiCUAddr ] ) |
|---|
| 2631 | { |
|---|
| 2632 | case SIZE_2Nx2N: |
|---|
| 2633 | memset( puhBaseLCU + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); |
|---|
| 2634 | break; |
|---|
| 2635 | case SIZE_2NxN: |
|---|
| 2636 | memset( puhBaseLCU + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); |
|---|
| 2637 | break; |
|---|
| 2638 | case SIZE_Nx2N: |
|---|
| 2639 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
|---|
| 2640 | memset( puhBaseLCU + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); |
|---|
| 2641 | break; |
|---|
| 2642 | case SIZE_NxN: |
|---|
| 2643 | memset( puhBaseLCU + uiCUAddr, uiParameter, uiCurrPartNumQ ); |
|---|
| 2644 | break; |
|---|
| 2645 | case SIZE_2NxnU: |
|---|
| 2646 | if ( uiPUIdx == 0 ) |
|---|
| 2647 | { |
|---|
| 2648 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2649 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2650 | } |
|---|
| 2651 | else if ( uiPUIdx == 1 ) |
|---|
| 2652 | { |
|---|
| 2653 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2654 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); |
|---|
| 2655 | } |
|---|
| 2656 | else |
|---|
| 2657 | { |
|---|
| 2658 | assert(0); |
|---|
| 2659 | } |
|---|
| 2660 | break; |
|---|
| 2661 | case SIZE_2NxnD: |
|---|
| 2662 | if ( uiPUIdx == 0 ) |
|---|
| 2663 | { |
|---|
| 2664 | memset( puhBaseLCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); |
|---|
| 2665 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2666 | } |
|---|
| 2667 | else if ( uiPUIdx == 1 ) |
|---|
| 2668 | { |
|---|
| 2669 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2670 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); |
|---|
| 2671 | } |
|---|
| 2672 | else |
|---|
| 2673 | { |
|---|
| 2674 | assert(0); |
|---|
| 2675 | } |
|---|
| 2676 | break; |
|---|
| 2677 | case SIZE_nLx2N: |
|---|
| 2678 | if ( uiPUIdx == 0 ) |
|---|
| 2679 | { |
|---|
| 2680 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2681 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2682 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2683 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2684 | } |
|---|
| 2685 | else if ( uiPUIdx == 1 ) |
|---|
| 2686 | { |
|---|
| 2687 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2688 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
|---|
| 2689 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2690 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
|---|
| 2691 | } |
|---|
| 2692 | else |
|---|
| 2693 | { |
|---|
| 2694 | assert(0); |
|---|
| 2695 | } |
|---|
| 2696 | break; |
|---|
| 2697 | case SIZE_nRx2N: |
|---|
| 2698 | if ( uiPUIdx == 0 ) |
|---|
| 2699 | { |
|---|
| 2700 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
|---|
| 2701 | memset( puhBaseLCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2702 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); |
|---|
| 2703 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2704 | } |
|---|
| 2705 | else if ( uiPUIdx == 1 ) |
|---|
| 2706 | { |
|---|
| 2707 | memset( puhBaseLCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2708 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2709 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2710 | memset( puhBaseLCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); |
|---|
| 2711 | } |
|---|
| 2712 | else |
|---|
| 2713 | { |
|---|
| 2714 | assert(0); |
|---|
| 2715 | } |
|---|
| 2716 | break; |
|---|
| 2717 | default: |
|---|
| 2718 | assert( 0 ); |
|---|
| 2719 | } |
|---|
| 2720 | } |
|---|
| 2721 | |
|---|
| 2722 | #if H_3D_DIM_SDC |
|---|
| 2723 | Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2724 | { |
|---|
| 2725 | assert( sizeof( *m_pbSDCFlag) == 1 ); |
|---|
| 2726 | memset( m_pbSDCFlag + uiAbsPartIdx, bSDCFlag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
|---|
| 2727 | } |
|---|
| 2728 | |
|---|
| 2729 | Bool TComDataCU::getSDCAvailable( UInt uiAbsPartIdx ) |
|---|
| 2730 | { |
|---|
| 2731 | // check general CU information |
|---|
| 2732 | if( !getSlice()->getIsDepth() || !isIntra(uiAbsPartIdx) || getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) |
|---|
| 2733 | return false; |
|---|
| 2734 | |
|---|
| 2735 | // check prediction mode |
|---|
| 2736 | UInt uiLumaPredMode = getLumaIntraDir( uiAbsPartIdx ); |
|---|
| 2737 | #if LGE_SDC_REMOVE_DC_E0158 |
|---|
| 2738 | if( uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX && !isDimDeltaDC( uiLumaPredMode ) ) ) |
|---|
| 2739 | #else |
|---|
| 2740 | if( uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX && !isDimDeltaDC( uiLumaPredMode ) ) ) |
|---|
| 2741 | #endif |
|---|
| 2742 | return true; |
|---|
| 2743 | |
|---|
| 2744 | // else |
|---|
| 2745 | return false; |
|---|
| 2746 | } |
|---|
| 2747 | #endif |
|---|
| 2748 | Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2749 | { |
|---|
| 2750 | setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2751 | } |
|---|
| 2752 | |
|---|
| 2753 | Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2754 | { |
|---|
| 2755 | setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2756 | } |
|---|
| 2757 | |
|---|
| 2758 | #if H_3D_VSP |
|---|
| 2759 | Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2760 | { |
|---|
| 2761 | setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2762 | } |
|---|
| 2763 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 2764 | template<typename T> |
|---|
| 2765 | Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) |
|---|
| 2766 | { |
|---|
| 2767 | UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2; |
|---|
| 2768 | switch ( m_pePartSize[ uiCUAddr ] ) |
|---|
| 2769 | { |
|---|
| 2770 | case SIZE_2Nx2N: |
|---|
| 2771 | for (UInt ui = 0; ui < 4 * uiCurrPartNumQ; ui++) |
|---|
| 2772 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2773 | |
|---|
| 2774 | break; |
|---|
| 2775 | case SIZE_2NxN: |
|---|
| 2776 | for (UInt ui = 0; ui < 2 * uiCurrPartNumQ; ui++) |
|---|
| 2777 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2778 | break; |
|---|
| 2779 | case SIZE_Nx2N: |
|---|
| 2780 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
|---|
| 2781 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2782 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
|---|
| 2783 | puhBaseLCU[uiCUAddr + 2 * uiCurrPartNumQ + ui] = uiParameter; |
|---|
| 2784 | break; |
|---|
| 2785 | case SIZE_NxN: |
|---|
| 2786 | for (UInt ui = 0; ui < uiCurrPartNumQ; ui++) |
|---|
| 2787 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2788 | break; |
|---|
| 2789 | case SIZE_2NxnU: |
|---|
| 2790 | if ( uiPUIdx == 0 ) |
|---|
| 2791 | { |
|---|
| 2792 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
|---|
| 2793 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2794 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
|---|
| 2795 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
|---|
| 2796 | |
|---|
| 2797 | } |
|---|
| 2798 | else if ( uiPUIdx == 1 ) |
|---|
| 2799 | { |
|---|
| 2800 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
|---|
| 2801 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2802 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1); ui++) |
|---|
| 2803 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
|---|
| 2804 | |
|---|
| 2805 | } |
|---|
| 2806 | else |
|---|
| 2807 | { |
|---|
| 2808 | assert(0); |
|---|
| 2809 | } |
|---|
| 2810 | break; |
|---|
| 2811 | case SIZE_2NxnD: |
|---|
| 2812 | if ( uiPUIdx == 0 ) |
|---|
| 2813 | { |
|---|
| 2814 | for (UInt ui = 0; ui < ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)); ui++) |
|---|
| 2815 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2816 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
|---|
| 2817 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + ui] = uiParameter; |
|---|
| 2818 | |
|---|
| 2819 | } |
|---|
| 2820 | else if ( uiPUIdx == 1 ) |
|---|
| 2821 | { |
|---|
| 2822 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
|---|
| 2823 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2824 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 1); ui++) |
|---|
| 2825 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + ui] = uiParameter; |
|---|
| 2826 | |
|---|
| 2827 | } |
|---|
| 2828 | else |
|---|
| 2829 | { |
|---|
| 2830 | assert(0); |
|---|
| 2831 | } |
|---|
| 2832 | break; |
|---|
| 2833 | case SIZE_nLx2N: |
|---|
| 2834 | if ( uiPUIdx == 0 ) |
|---|
| 2835 | { |
|---|
| 2836 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2837 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2838 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2839 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
|---|
| 2840 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2841 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
|---|
| 2842 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2843 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
|---|
| 2844 | |
|---|
| 2845 | } |
|---|
| 2846 | else if ( uiPUIdx == 1 ) |
|---|
| 2847 | { |
|---|
| 2848 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2849 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2850 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
|---|
| 2851 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
|---|
| 2852 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2853 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
|---|
| 2854 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
|---|
| 2855 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
|---|
| 2856 | |
|---|
| 2857 | } |
|---|
| 2858 | else |
|---|
| 2859 | { |
|---|
| 2860 | assert(0); |
|---|
| 2861 | } |
|---|
| 2862 | break; |
|---|
| 2863 | case SIZE_nRx2N: |
|---|
| 2864 | if ( uiPUIdx == 0 ) |
|---|
| 2865 | { |
|---|
| 2866 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
|---|
| 2867 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2868 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2869 | puhBaseLCU[uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
|---|
| 2870 | for (UInt ui = 0; ui < (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)); ui++) |
|---|
| 2871 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
|---|
| 2872 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2873 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
|---|
| 2874 | |
|---|
| 2875 | } |
|---|
| 2876 | else if ( uiPUIdx == 1 ) |
|---|
| 2877 | { |
|---|
| 2878 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2879 | puhBaseLCU[uiCUAddr + ui] = uiParameter; |
|---|
| 2880 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2881 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
|---|
| 2882 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2883 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + ui] = uiParameter; |
|---|
| 2884 | for (UInt ui = 0; ui < (uiCurrPartNumQ >> 2); ui++) |
|---|
| 2885 | puhBaseLCU[uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1) + ui] = uiParameter; |
|---|
| 2886 | |
|---|
| 2887 | } |
|---|
| 2888 | else |
|---|
| 2889 | { |
|---|
| 2890 | assert(0); |
|---|
| 2891 | } |
|---|
| 2892 | break; |
|---|
| 2893 | default: |
|---|
| 2894 | assert( 0 ); |
|---|
| 2895 | } |
|---|
| 2896 | |
|---|
| 2897 | } |
|---|
| 2898 | #endif |
|---|
| 2899 | #if MTK_VSP_FIX_E0172 |
|---|
| 2900 | Void TComDataCU::setVSPDirSubParts ( Char iVSPDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2901 | { |
|---|
| 2902 | setSubPart<Char>( iVSPDir, m_piVSPDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2903 | } |
|---|
| 2904 | #endif |
|---|
| 2905 | #endif |
|---|
| 2906 | Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2907 | { |
|---|
| 2908 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2909 | |
|---|
| 2910 | memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2911 | } |
|---|
| 2912 | |
|---|
| 2913 | Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2914 | { |
|---|
| 2915 | setSubPart<UChar>( uiDir, m_puhInterDir, uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2916 | } |
|---|
| 2917 | |
|---|
| 2918 | Void TComDataCU::setMVPIdxSubParts( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2919 | { |
|---|
| 2920 | setSubPart<Char>( iMVPIdx, m_apiMVPIdx[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2921 | } |
|---|
| 2922 | |
|---|
| 2923 | Void TComDataCU::setMVPNumSubParts( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 2924 | { |
|---|
| 2925 | setSubPart<Char>( iMVPNum, m_apiMVPNum[eRefPicList], uiAbsPartIdx, uiDepth, uiPartIdx ); |
|---|
| 2926 | } |
|---|
| 2927 | |
|---|
| 2928 | |
|---|
| 2929 | Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2930 | { |
|---|
| 2931 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2932 | |
|---|
| 2933 | memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2934 | } |
|---|
| 2935 | |
|---|
| 2936 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2937 | { |
|---|
| 2938 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2939 | |
|---|
| 2940 | memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2941 | memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2942 | memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2943 | } |
|---|
| 2944 | |
|---|
| 2945 | Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) |
|---|
| 2946 | { |
|---|
| 2947 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2948 | |
|---|
| 2949 | memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); |
|---|
| 2950 | } |
|---|
| 2951 | |
|---|
| 2952 | Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 2953 | { |
|---|
| 2954 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 2955 | |
|---|
| 2956 | memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2957 | memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); |
|---|
| 2958 | } |
|---|
| 2959 | |
|---|
| 2960 | UChar TComDataCU::getNumPartInter() |
|---|
| 2961 | { |
|---|
| 2962 | UChar iNumPart = 0; |
|---|
| 2963 | |
|---|
| 2964 | switch ( m_pePartSize[0] ) |
|---|
| 2965 | { |
|---|
| 2966 | case SIZE_2Nx2N: iNumPart = 1; break; |
|---|
| 2967 | case SIZE_2NxN: iNumPart = 2; break; |
|---|
| 2968 | case SIZE_Nx2N: iNumPart = 2; break; |
|---|
| 2969 | case SIZE_NxN: iNumPart = 4; break; |
|---|
| 2970 | case SIZE_2NxnU: iNumPart = 2; break; |
|---|
| 2971 | case SIZE_2NxnD: iNumPart = 2; break; |
|---|
| 2972 | case SIZE_nLx2N: iNumPart = 2; break; |
|---|
| 2973 | case SIZE_nRx2N: iNumPart = 2; break; |
|---|
| 2974 | default: assert (0); break; |
|---|
| 2975 | } |
|---|
| 2976 | |
|---|
| 2977 | return iNumPart; |
|---|
| 2978 | } |
|---|
| 2979 | |
|---|
| 2980 | #if H_3D_IC |
|---|
| 2981 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) |
|---|
| 2982 | { |
|---|
| 2983 | UInt uiNumPartition = bLCU ? (getWidth(uiAbsPartIdx)*getHeight(uiAbsPartIdx) >> 4) : m_uiNumPartition; |
|---|
| 2984 | UInt uiTmpAbsPartIdx = bLCU ? uiAbsPartIdx : 0; |
|---|
| 2985 | |
|---|
| 2986 | switch ( m_pePartSize[uiTmpAbsPartIdx] ) |
|---|
| 2987 | { |
|---|
| 2988 | case SIZE_2NxN: |
|---|
| 2989 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 1; |
|---|
| 2990 | break; |
|---|
| 2991 | case SIZE_Nx2N: |
|---|
| 2992 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = ( uiPartIdx == 0 )? 0 : uiNumPartition >> 2; |
|---|
| 2993 | break; |
|---|
| 2994 | case SIZE_NxN: |
|---|
| 2995 | riWidth = getWidth( uiTmpAbsPartIdx ) >> 1; riHeight = getHeight( uiTmpAbsPartIdx ) >> 1; ruiPartAddr = ( uiNumPartition >> 2 ) * uiPartIdx; |
|---|
| 2996 | break; |
|---|
| 2997 | case SIZE_2NxnU: |
|---|
| 2998 | riWidth = getWidth( uiTmpAbsPartIdx ); |
|---|
| 2999 | riHeight = ( uiPartIdx == 0 ) ? getHeight( uiTmpAbsPartIdx ) >> 2 : ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ); |
|---|
| 3000 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 3; |
|---|
| 3001 | break; |
|---|
| 3002 | case SIZE_2NxnD: |
|---|
| 3003 | riWidth = getWidth( uiTmpAbsPartIdx ); |
|---|
| 3004 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight( uiTmpAbsPartIdx ) >> 2 ) + ( getHeight( uiTmpAbsPartIdx ) >> 1 ) : getHeight( uiTmpAbsPartIdx ) >> 2; |
|---|
| 3005 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 1) + (uiNumPartition >> 3); |
|---|
| 3006 | break; |
|---|
| 3007 | case SIZE_nLx2N: |
|---|
| 3008 | riWidth = ( uiPartIdx == 0 ) ? getWidth( uiTmpAbsPartIdx ) >> 2 : ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ); |
|---|
| 3009 | riHeight = getHeight( uiTmpAbsPartIdx ); |
|---|
| 3010 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : uiNumPartition >> 4; |
|---|
| 3011 | break; |
|---|
| 3012 | case SIZE_nRx2N: |
|---|
| 3013 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth( uiTmpAbsPartIdx ) >> 2 ) + ( getWidth( uiTmpAbsPartIdx ) >> 1 ) : getWidth( uiTmpAbsPartIdx ) >> 2; |
|---|
| 3014 | riHeight = getHeight( uiTmpAbsPartIdx ); |
|---|
| 3015 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (uiNumPartition >> 2) + (uiNumPartition >> 4); |
|---|
| 3016 | break; |
|---|
| 3017 | default: |
|---|
| 3018 | assert ( m_pePartSize[uiTmpAbsPartIdx] == SIZE_2Nx2N ); |
|---|
| 3019 | riWidth = getWidth( uiTmpAbsPartIdx ); riHeight = getHeight( uiTmpAbsPartIdx ); ruiPartAddr = 0; |
|---|
| 3020 | break; |
|---|
| 3021 | } |
|---|
| 3022 | } |
|---|
| 3023 | #else |
|---|
| 3024 | Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) |
|---|
| 3025 | { |
|---|
| 3026 | switch ( m_pePartSize[0] ) |
|---|
| 3027 | { |
|---|
| 3028 | case SIZE_2NxN: |
|---|
| 3029 | riWidth = getWidth(0); riHeight = getHeight(0) >> 1; ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
|---|
| 3030 | break; |
|---|
| 3031 | case SIZE_Nx2N: |
|---|
| 3032 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0); ruiPartAddr = ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; |
|---|
| 3033 | break; |
|---|
| 3034 | case SIZE_NxN: |
|---|
| 3035 | riWidth = getWidth(0) >> 1; riHeight = getHeight(0) >> 1; ruiPartAddr = ( m_uiNumPartition >> 2 ) * uiPartIdx; |
|---|
| 3036 | break; |
|---|
| 3037 | case SIZE_2NxnU: |
|---|
| 3038 | riWidth = getWidth(0); |
|---|
| 3039 | riHeight = ( uiPartIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
|---|
| 3040 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 3; |
|---|
| 3041 | break; |
|---|
| 3042 | case SIZE_2NxnD: |
|---|
| 3043 | riWidth = getWidth(0); |
|---|
| 3044 | riHeight = ( uiPartIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
|---|
| 3045 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 3); |
|---|
| 3046 | break; |
|---|
| 3047 | case SIZE_nLx2N: |
|---|
| 3048 | riWidth = ( uiPartIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
|---|
| 3049 | riHeight = getHeight(0); |
|---|
| 3050 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : m_uiNumPartition >> 4; |
|---|
| 3051 | break; |
|---|
| 3052 | case SIZE_nRx2N: |
|---|
| 3053 | riWidth = ( uiPartIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
|---|
| 3054 | riHeight = getHeight(0); |
|---|
| 3055 | ruiPartAddr = ( uiPartIdx == 0 ) ? 0 : (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
|---|
| 3056 | break; |
|---|
| 3057 | default: |
|---|
| 3058 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
|---|
| 3059 | riWidth = getWidth(0); riHeight = getHeight(0); ruiPartAddr = 0; |
|---|
| 3060 | break; |
|---|
| 3061 | } |
|---|
| 3062 | } |
|---|
| 3063 | #endif |
|---|
| 3064 | |
|---|
| 3065 | |
|---|
| 3066 | Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField ) |
|---|
| 3067 | { |
|---|
| 3068 | if ( pcCU == NULL ) // OUT OF BOUNDARY |
|---|
| 3069 | { |
|---|
| 3070 | TComMv cZeroMv; |
|---|
| 3071 | rcMvField.setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3072 | return; |
|---|
| 3073 | } |
|---|
| 3074 | |
|---|
| 3075 | TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); |
|---|
| 3076 | rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); |
|---|
| 3077 | } |
|---|
| 3078 | |
|---|
| 3079 | Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
|---|
| 3080 | { |
|---|
| 3081 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiAbsPartIdx; |
|---|
| 3082 | UInt uiPUWidth = 0; |
|---|
| 3083 | |
|---|
| 3084 | switch ( m_pePartSize[uiAbsPartIdx] ) |
|---|
| 3085 | { |
|---|
| 3086 | case SIZE_2Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
|---|
| 3087 | case SIZE_2NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
|---|
| 3088 | case SIZE_Nx2N: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
|---|
| 3089 | case SIZE_NxN: uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 1; break; |
|---|
| 3090 | case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
|---|
| 3091 | case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; |
|---|
| 3092 | case SIZE_nLx2N: |
|---|
| 3093 | if ( uiPartIdx == 0 ) |
|---|
| 3094 | { |
|---|
| 3095 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
|---|
| 3096 | } |
|---|
| 3097 | else if ( uiPartIdx == 1 ) |
|---|
| 3098 | { |
|---|
| 3099 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
|---|
| 3100 | } |
|---|
| 3101 | else |
|---|
| 3102 | { |
|---|
| 3103 | assert(0); |
|---|
| 3104 | } |
|---|
| 3105 | break; |
|---|
| 3106 | case SIZE_nRx2N: |
|---|
| 3107 | if ( uiPartIdx == 0 ) |
|---|
| 3108 | { |
|---|
| 3109 | uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); |
|---|
| 3110 | } |
|---|
| 3111 | else if ( uiPartIdx == 1 ) |
|---|
| 3112 | { |
|---|
| 3113 | uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; |
|---|
| 3114 | } |
|---|
| 3115 | else |
|---|
| 3116 | { |
|---|
| 3117 | assert(0); |
|---|
| 3118 | } |
|---|
| 3119 | break; |
|---|
| 3120 | default: |
|---|
| 3121 | assert (0); |
|---|
| 3122 | break; |
|---|
| 3123 | } |
|---|
| 3124 | |
|---|
| 3125 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; |
|---|
| 3126 | } |
|---|
| 3127 | |
|---|
| 3128 | Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) |
|---|
| 3129 | { |
|---|
| 3130 | UInt uiPUHeight = 0; |
|---|
| 3131 | switch ( m_pePartSize[uiAbsPartIdx] ) |
|---|
| 3132 | { |
|---|
| 3133 | case SIZE_2Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
|---|
| 3134 | case SIZE_2NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
|---|
| 3135 | case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
|---|
| 3136 | case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; |
|---|
| 3137 | case SIZE_2NxnU: |
|---|
| 3138 | if ( uiPartIdx == 0 ) |
|---|
| 3139 | { |
|---|
| 3140 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
|---|
| 3141 | } |
|---|
| 3142 | else if ( uiPartIdx == 1 ) |
|---|
| 3143 | { |
|---|
| 3144 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
|---|
| 3145 | } |
|---|
| 3146 | else |
|---|
| 3147 | { |
|---|
| 3148 | assert(0); |
|---|
| 3149 | } |
|---|
| 3150 | break; |
|---|
| 3151 | case SIZE_2NxnD: |
|---|
| 3152 | if ( uiPartIdx == 0 ) |
|---|
| 3153 | { |
|---|
| 3154 | uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); |
|---|
| 3155 | } |
|---|
| 3156 | else if ( uiPartIdx == 1 ) |
|---|
| 3157 | { |
|---|
| 3158 | uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; |
|---|
| 3159 | } |
|---|
| 3160 | else |
|---|
| 3161 | { |
|---|
| 3162 | assert(0); |
|---|
| 3163 | } |
|---|
| 3164 | break; |
|---|
| 3165 | case SIZE_nLx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
|---|
| 3166 | case SIZE_nRx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; |
|---|
| 3167 | default: |
|---|
| 3168 | assert (0); |
|---|
| 3169 | break; |
|---|
| 3170 | } |
|---|
| 3171 | |
|---|
| 3172 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()]; |
|---|
| 3173 | } |
|---|
| 3174 | |
|---|
| 3175 | Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) |
|---|
| 3176 | { |
|---|
| 3177 | ruiPartIdxLT = m_uiAbsIdxInLCU; |
|---|
| 3178 | ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; |
|---|
| 3179 | |
|---|
| 3180 | switch ( m_pePartSize[0] ) |
|---|
| 3181 | { |
|---|
| 3182 | case SIZE_2Nx2N: break; |
|---|
| 3183 | case SIZE_2NxN: |
|---|
| 3184 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
|---|
| 3185 | break; |
|---|
| 3186 | case SIZE_Nx2N: |
|---|
| 3187 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 2; ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 2; |
|---|
| 3188 | break; |
|---|
| 3189 | case SIZE_NxN: |
|---|
| 3190 | ruiPartIdxLT += ( m_uiNumPartition >> 2 ) * uiPartIdx; ruiPartIdxRT += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
|---|
| 3191 | break; |
|---|
| 3192 | case SIZE_2NxnU: |
|---|
| 3193 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
|---|
| 3194 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 3; |
|---|
| 3195 | break; |
|---|
| 3196 | case SIZE_2NxnD: |
|---|
| 3197 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
|---|
| 3198 | ruiPartIdxRT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 1 ) + ( m_uiNumPartition >> 3 ); |
|---|
| 3199 | break; |
|---|
| 3200 | case SIZE_nLx2N: |
|---|
| 3201 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 4; |
|---|
| 3202 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
|---|
| 3203 | break; |
|---|
| 3204 | case SIZE_nRx2N: |
|---|
| 3205 | ruiPartIdxLT += ( uiPartIdx == 0 )? 0 : ( m_uiNumPartition >> 2 ) + ( m_uiNumPartition >> 4 ); |
|---|
| 3206 | ruiPartIdxRT -= ( uiPartIdx == 1 )? 0 : m_uiNumPartition >> 4; |
|---|
| 3207 | break; |
|---|
| 3208 | default: |
|---|
| 3209 | assert (0); |
|---|
| 3210 | break; |
|---|
| 3211 | } |
|---|
| 3212 | |
|---|
| 3213 | } |
|---|
| 3214 | |
|---|
| 3215 | Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) |
|---|
| 3216 | { |
|---|
| 3217 | ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()]; |
|---|
| 3218 | |
|---|
| 3219 | switch ( m_pePartSize[0] ) |
|---|
| 3220 | { |
|---|
| 3221 | case SIZE_2Nx2N: |
|---|
| 3222 | ruiPartIdxLB += m_uiNumPartition >> 1; |
|---|
| 3223 | break; |
|---|
| 3224 | case SIZE_2NxN: |
|---|
| 3225 | ruiPartIdxLB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
|---|
| 3226 | break; |
|---|
| 3227 | case SIZE_Nx2N: |
|---|
| 3228 | ruiPartIdxLB += ( uiPartIdx == 0 )? m_uiNumPartition >> 1 : (m_uiNumPartition >> 2)*3; |
|---|
| 3229 | break; |
|---|
| 3230 | case SIZE_NxN: |
|---|
| 3231 | ruiPartIdxLB += ( m_uiNumPartition >> 2 ) * uiPartIdx; |
|---|
| 3232 | break; |
|---|
| 3233 | case SIZE_2NxnU: |
|---|
| 3234 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
|---|
| 3235 | break; |
|---|
| 3236 | case SIZE_2NxnD: |
|---|
| 3237 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
|---|
| 3238 | break; |
|---|
| 3239 | case SIZE_nLx2N: |
|---|
| 3240 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 4); |
|---|
| 3241 | break; |
|---|
| 3242 | case SIZE_nRx2N: |
|---|
| 3243 | ruiPartIdxLB += ( uiPartIdx == 0 ) ? m_uiNumPartition >> 1 : (m_uiNumPartition >> 1) + (m_uiNumPartition >> 2) + (m_uiNumPartition >> 4); |
|---|
| 3244 | break; |
|---|
| 3245 | default: |
|---|
| 3246 | assert (0); |
|---|
| 3247 | break; |
|---|
| 3248 | } |
|---|
| 3249 | } |
|---|
| 3250 | |
|---|
| 3251 | /** Derives the partition index of neighbouring bottom right block |
|---|
| 3252 | * \param [in] eCUMode |
|---|
| 3253 | * \param [in] uiPartIdx |
|---|
| 3254 | * \param [out] ruiPartIdxRB |
|---|
| 3255 | */ |
|---|
| 3256 | Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxRB ) |
|---|
| 3257 | { |
|---|
| 3258 | 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]; |
|---|
| 3259 | |
|---|
| 3260 | switch ( m_pePartSize[0] ) |
|---|
| 3261 | { |
|---|
| 3262 | case SIZE_2Nx2N: |
|---|
| 3263 | ruiPartIdxRB += m_uiNumPartition >> 1; |
|---|
| 3264 | break; |
|---|
| 3265 | case SIZE_2NxN: |
|---|
| 3266 | ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; |
|---|
| 3267 | break; |
|---|
| 3268 | case SIZE_Nx2N: |
|---|
| 3269 | ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); |
|---|
| 3270 | break; |
|---|
| 3271 | case SIZE_NxN: |
|---|
| 3272 | ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); |
|---|
| 3273 | break; |
|---|
| 3274 | case SIZE_2NxnU: |
|---|
| 3275 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? -((Int)m_uiNumPartition >> 3) : m_uiNumPartition >> 1; |
|---|
| 3276 | break; |
|---|
| 3277 | case SIZE_2NxnD: |
|---|
| 3278 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3): m_uiNumPartition >> 1; |
|---|
| 3279 | break; |
|---|
| 3280 | case SIZE_nLx2N: |
|---|
| 3281 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4): m_uiNumPartition >> 1; |
|---|
| 3282 | break; |
|---|
| 3283 | case SIZE_nRx2N: |
|---|
| 3284 | ruiPartIdxRB += ( uiPartIdx == 0 ) ? (m_uiNumPartition >> 2) + (m_uiNumPartition >> 3) + (m_uiNumPartition >> 4) : m_uiNumPartition >> 1; |
|---|
| 3285 | break; |
|---|
| 3286 | default: |
|---|
| 3287 | assert (0); |
|---|
| 3288 | break; |
|---|
| 3289 | } |
|---|
| 3290 | } |
|---|
| 3291 | |
|---|
| 3292 | Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth ) |
|---|
| 3293 | { |
|---|
| 3294 | UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; |
|---|
| 3295 | ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset; |
|---|
| 3296 | ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; |
|---|
| 3297 | } |
|---|
| 3298 | |
|---|
| 3299 | Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth ) |
|---|
| 3300 | { |
|---|
| 3301 | UInt uiAbsIdx; |
|---|
| 3302 | UInt uiMinCuWidth, uiWidthInMinCus; |
|---|
| 3303 | |
|---|
| 3304 | uiMinCuWidth = getPic()->getMinCUWidth(); |
|---|
| 3305 | uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; |
|---|
| 3306 | uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; |
|---|
| 3307 | uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); |
|---|
| 3308 | ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; |
|---|
| 3309 | } |
|---|
| 3310 | |
|---|
| 3311 | Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) |
|---|
| 3312 | { |
|---|
| 3313 | |
|---|
| 3314 | if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) |
|---|
| 3315 | { |
|---|
| 3316 | return false; |
|---|
| 3317 | } |
|---|
| 3318 | |
|---|
| 3319 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 3320 | { |
|---|
| 3321 | if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) |
|---|
| 3322 | { |
|---|
| 3323 | if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || |
|---|
| 3324 | getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) |
|---|
| 3325 | { |
|---|
| 3326 | return false; |
|---|
| 3327 | } |
|---|
| 3328 | } |
|---|
| 3329 | } |
|---|
| 3330 | |
|---|
| 3331 | return true; |
|---|
| 3332 | } |
|---|
| 3333 | |
|---|
| 3334 | #if H_3D_VSP |
|---|
| 3335 | |
|---|
| 3336 | /** Add a VSP merging candidate |
|---|
| 3337 | * \Inputs |
|---|
| 3338 | * \param uiPUIdx: PU index within a CU |
|---|
| 3339 | * \param ucVspMergePos: Specify the VSP merge candidate position |
|---|
| 3340 | * \param mrgCandIdx: Target merge candidate index. At encoder, it is set equal to -1, such that the whole merge candidate list will be constructed. |
|---|
| 3341 | * \param pDinfo: The "disparity information" derived from neighboring blocks. Type 1 MV. |
|---|
| 3342 | * \param uiCount: The next position to add VSP merge candidate |
|---|
| 3343 | * |
|---|
| 3344 | * \Outputs |
|---|
| 3345 | * \param uiCount: The next position to add merge candidate. Will be updated if VSP is successfully added |
|---|
| 3346 | * \param abCandIsInter: abCandIsInter[iCount] tells that VSP candidate is an Inter candidate, if VSP is successfully added |
|---|
| 3347 | * \param pcMvFieldNeighbours: Return combined motion information, then stored to a global buffer |
|---|
| 3348 | * 1) the "disparity vector". Type 1 MV. To be used to fetch a depth block. |
|---|
| 3349 | * 2) the ref index /list. Type 2 reference picture pointer, typically for texture |
|---|
| 3350 | * \param puhInterDirNeighbours: Indicate the VSP prediction direction. |
|---|
| 3351 | * \param vspFlag: vspFlag[iCount] will be set (equal to 1), if VSP is successfully added. To be used to indicate the actual position of the VSP candidate |
|---|
| 3352 | * |
|---|
| 3353 | * \Return |
|---|
| 3354 | * true: if the VSP candidate is added at the target position |
|---|
| 3355 | * false: otherwise |
|---|
| 3356 | */ |
|---|
| 3357 | #if MTK_VSP_FIX_E0172 |
|---|
| 3358 | inline Bool TComDataCU::xAddVspCand( UChar ucVspMergePos, Int mrgCandIdx, DisInfo* pDInfo, Int& iCount, |
|---|
| 3359 | Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag, Int* vspDir ) |
|---|
| 3360 | #else |
|---|
| 3361 | inline Bool TComDataCU::xAddVspCand( UChar ucVspMergePos, Int mrgCandIdx, DisInfo* pDInfo, Int& iCount, |
|---|
| 3362 | Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag ) |
|---|
| 3363 | #endif |
|---|
| 3364 | { |
|---|
| 3365 | if ( ucVspMergePos != H_3D_VSP_POSITION || 0 == m_pcSlice->getViewIndex() || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() ) |
|---|
| 3366 | return false; |
|---|
| 3367 | |
|---|
| 3368 | Int refViewIdx = pDInfo->m_aVIdxCan; |
|---|
| 3369 | TComPic* picDepth = getSlice()->getIvPic( true, refViewIdx ); |
|---|
| 3370 | if( picDepth == NULL ) // No depth reference avail |
|---|
| 3371 | return false; |
|---|
| 3372 | |
|---|
| 3373 | Bool refViewAvailFlag = false; |
|---|
| 3374 | UChar predFlag[2] = {0, 0}; |
|---|
| 3375 | Int iRefListIdX = 0; |
|---|
| 3376 | Int iRefListIdY = 0; |
|---|
| 3377 | Int i; |
|---|
| 3378 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3379 | Int currViewId = m_pcSlice->getViewId(); |
|---|
| 3380 | Int derivedViewId = -1; |
|---|
| 3381 | Int otherViewId = -1; |
|---|
| 3382 | #endif |
|---|
| 3383 | #if MTK_VSP_FIX_E0172 |
|---|
| 3384 | Int currViewId = m_pcSlice->getViewId(); |
|---|
| 3385 | Int derivedViewId = -1; |
|---|
| 3386 | Int otherViewId = -1; |
|---|
| 3387 | #endif |
|---|
| 3388 | for( iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ ) |
|---|
| 3389 | { |
|---|
| 3390 | RefPicList eRefPicList = RefPicList( iRefListIdX ); |
|---|
| 3391 | for ( i = 0; i < m_pcSlice->getNumRefIdx(eRefPicList) && !refViewAvailFlag; i++ ) |
|---|
| 3392 | { |
|---|
| 3393 | Int viewIdxRefInList = m_pcSlice->getRefPic(eRefPicList, i)->getViewIndex(); |
|---|
| 3394 | if ( viewIdxRefInList == refViewIdx ) |
|---|
| 3395 | { |
|---|
| 3396 | refViewAvailFlag = true; |
|---|
| 3397 | predFlag[iRefListIdX] = 1; |
|---|
| 3398 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3399 | derivedViewId = m_pcSlice->getRefPic(eRefPicList, i)->getViewId(); |
|---|
| 3400 | #endif |
|---|
| 3401 | #if MTK_VSP_FIX_E0172 |
|---|
| 3402 | vspDir[iCount] = iRefListIdX; |
|---|
| 3403 | derivedViewId = m_pcSlice->getRefPic(eRefPicList, i)->getViewId(); |
|---|
| 3404 | #endif |
|---|
| 3405 | iRefListIdY = 1 - iRefListIdX; |
|---|
| 3406 | #if H_3D_FIX_BVSP |
|---|
| 3407 | pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acNBDV, i ); |
|---|
| 3408 | #else |
|---|
| 3409 | pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acDoNBDV, i ); |
|---|
| 3410 | #endif |
|---|
| 3411 | #if H_3D_NBDV |
|---|
| 3412 | pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].getMv().setIDVFlag (false); |
|---|
| 3413 | #endif |
|---|
| 3414 | } |
|---|
| 3415 | } |
|---|
| 3416 | } |
|---|
| 3417 | |
|---|
| 3418 | if (m_pcSlice->isInterB() && refViewAvailFlag) |
|---|
| 3419 | { |
|---|
| 3420 | RefPicList eRefPicList = RefPicList( iRefListIdY ); |
|---|
| 3421 | refViewAvailFlag = false; |
|---|
| 3422 | for ( i = 0; i < m_pcSlice->getNumRefIdx(eRefPicList) && !refViewAvailFlag; i++ ) |
|---|
| 3423 | { |
|---|
| 3424 | Int viewIdxRefInList = m_pcSlice->getRefPic(eRefPicList, i)->getViewIndex(); |
|---|
| 3425 | if ( viewIdxRefInList != refViewIdx && viewIdxRefInList != m_pcSlice->getViewIndex() ) |
|---|
| 3426 | { |
|---|
| 3427 | refViewAvailFlag = true; |
|---|
| 3428 | predFlag[iRefListIdY] = 1; |
|---|
| 3429 | #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3430 | #if H_3D_FIX_BVSP |
|---|
| 3431 | TComMv cMv = pDInfo->m_acNBDV; |
|---|
| 3432 | #else |
|---|
| 3433 | TComMv cMv = pDInfo->m_acDoNBDV; |
|---|
| 3434 | #endif |
|---|
| 3435 | otherViewId = m_pcSlice->getRefPic( eRefPicList, i)->getViewId(); |
|---|
| 3436 | Int iScale = xGetDistScaleFactor( currViewId, otherViewId, currViewId, derivedViewId ); |
|---|
| 3437 | if ( iScale != 4096 && m_pcSlice->getVPS()->getIvMvScalingFlag() ) |
|---|
| 3438 | { |
|---|
| 3439 | cMv = cMv.scaleMv( iScale ); |
|---|
| 3440 | } |
|---|
| 3441 | else |
|---|
| 3442 | { |
|---|
| 3443 | |
|---|
| 3444 | cMv = cMv; |
|---|
| 3445 | } |
|---|
| 3446 | clipMv( cMv ); |
|---|
| 3447 | pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].setMvField( cMv, i ); |
|---|
| 3448 | #else |
|---|
| 3449 | #if H_3D_FIX_BVSP |
|---|
| 3450 | pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].setMvField( pDInfo->m_acNBDV, i ); |
|---|
| 3451 | #else |
|---|
| 3452 | pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].setMvField( pDInfo->m_acDoNBDV, i ); |
|---|
| 3453 | #endif |
|---|
| 3454 | #endif |
|---|
| 3455 | #if H_3D_NBDV |
|---|
| 3456 | pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].getMv().setIDVFlag (false); |
|---|
| 3457 | #endif |
|---|
| 3458 | } |
|---|
| 3459 | } |
|---|
| 3460 | } |
|---|
| 3461 | |
|---|
| 3462 | // Set values to be returned |
|---|
| 3463 | abCandIsInter[iCount] = true; |
|---|
| 3464 | puhInterDirNeighbours[iCount] = (predFlag[0] | (predFlag[1] << 1)); |
|---|
| 3465 | vspFlag[iCount] = 1; |
|---|
| 3466 | |
|---|
| 3467 | if ( mrgCandIdx == iCount ) |
|---|
| 3468 | return true; |
|---|
| 3469 | |
|---|
| 3470 | iCount++; |
|---|
| 3471 | |
|---|
| 3472 | return false; |
|---|
| 3473 | } |
|---|
| 3474 | |
|---|
| 3475 | #endif |
|---|
| 3476 | |
|---|
| 3477 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 3478 | inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* iPdmDir, TComMv* acPdmMv, |
|---|
| 3479 | Int* aiPdmRefIdx, Int iPosDmv, Int* vspFlag ) |
|---|
| 3480 | { |
|---|
| 3481 | for(Int iLoop = 0; iLoop < 2; iLoop ++ ) |
|---|
| 3482 | { |
|---|
| 3483 | if( iLoop == 1 ) |
|---|
| 3484 | { |
|---|
| 3485 | Int iFirDispCand = -1; |
|---|
| 3486 | if (xFirstDmvAvai(iCount, pcMvFieldNeighbours, iPdmDir, iPosDmv, vspFlag, iFirDispCand)) |
|---|
| 3487 | { |
|---|
| 3488 | TComMv cMv; |
|---|
| 3489 | cMv = pcMvFieldNeighbours[(iFirDispCand<<1)].getMv(); |
|---|
| 3490 | cMv.setHor(cMv.getHor()+4); |
|---|
| 3491 | if(m_pcSlice->getVPS()->getViewSynthesisPredFlag(m_pcSlice->getLayerIdInVps())) |
|---|
| 3492 | { |
|---|
| 3493 | cMv.setVer(0); |
|---|
| 3494 | } |
|---|
| 3495 | clipMv( cMv ); |
|---|
| 3496 | abCandIsInter[ iCount ] = true; |
|---|
| 3497 | puhInterDirNeighbours[ iCount ] = puhInterDirNeighbours[iFirDispCand]; |
|---|
| 3498 | pcMvFieldNeighbours[ iCount<<1 ].setMvField(cMv, pcMvFieldNeighbours[( iFirDispCand << 1)].getRefIdx() ); |
|---|
| 3499 | pcMvFieldNeighbours[ (iCount<<1)+1 ].setMvField(pcMvFieldNeighbours[(iFirDispCand << 1) + 1].getMv(), pcMvFieldNeighbours[( iFirDispCand << 1) + 1].getRefIdx() ); |
|---|
| 3500 | if( mrgCandIdx == iCount ) |
|---|
| 3501 | { |
|---|
| 3502 | return true; |
|---|
| 3503 | } |
|---|
| 3504 | iCount++; |
|---|
| 3505 | break; |
|---|
| 3506 | } |
|---|
| 3507 | } |
|---|
| 3508 | if(iPdmDir[iLoop + 2]) |
|---|
| 3509 | { |
|---|
| 3510 | abCandIsInter[ iCount ] = true; |
|---|
| 3511 | puhInterDirNeighbours[ iCount ] = iPdmDir[iLoop + 2]; |
|---|
| 3512 | if( ( iPdmDir[iLoop + 2] & 1 ) == 1 ) |
|---|
| 3513 | { |
|---|
| 3514 | pcMvFieldNeighbours[ iCount<<1 ].setMvField( acPdmMv[ (iLoop<<1) + 4 ], aiPdmRefIdx[ (iLoop<<1) + 4 ] ); |
|---|
| 3515 | } |
|---|
| 3516 | if( ( iPdmDir[iLoop + 2] & 2 ) == 2 ) |
|---|
| 3517 | { |
|---|
| 3518 | pcMvFieldNeighbours[ (iCount<<1)+1 ].setMvField( acPdmMv[ (iLoop<<1) + 5 ], aiPdmRefIdx[ (iLoop<<1) + 5 ] ); |
|---|
| 3519 | } |
|---|
| 3520 | |
|---|
| 3521 | bool bRemove = false; |
|---|
| 3522 | if(!iLoop && iPdmDir[0] > 0) |
|---|
| 3523 | { |
|---|
| 3524 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[0] && pcMvFieldNeighbours[0]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
|---|
| 3525 | { |
|---|
| 3526 | bRemove = true; |
|---|
| 3527 | abCandIsInter [ iCount ] = false; |
|---|
| 3528 | puhInterDirNeighbours[iCount] = 0; |
|---|
| 3529 | TComMv cZeroMv; |
|---|
| 3530 | pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3531 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3532 | } |
|---|
| 3533 | } |
|---|
| 3534 | if(!bRemove) |
|---|
| 3535 | { |
|---|
| 3536 | #if H_3D_NBDV |
|---|
| 3537 | if(iLoop) |
|---|
| 3538 | { |
|---|
| 3539 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3540 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3541 | } |
|---|
| 3542 | #endif |
|---|
| 3543 | if( mrgCandIdx == iCount ) |
|---|
| 3544 | { |
|---|
| 3545 | return true; |
|---|
| 3546 | } |
|---|
| 3547 | iCount++; |
|---|
| 3548 | } |
|---|
| 3549 | break; |
|---|
| 3550 | } |
|---|
| 3551 | } |
|---|
| 3552 | return false; |
|---|
| 3553 | } |
|---|
| 3554 | |
|---|
| 3555 | inline Bool TComDataCU::xFirstDmvAvai( Int& iCount, TComMvField* pcMvFieldNeighbours, Int* iPdmDir, Int iPosDmv, Int* vspFlag, Int& iFirDispCand ) |
|---|
| 3556 | { |
|---|
| 3557 | for ( Int i = (iPdmDir[0] ? 1: 0); i < iCount; i++ ) |
|---|
| 3558 | { |
|---|
| 3559 | if ( ( i == iPosDmv ) || ( vspFlag[ i ] == 1 ) ) |
|---|
| 3560 | { |
|---|
| 3561 | continue; |
|---|
| 3562 | } |
|---|
| 3563 | else if((pcMvFieldNeighbours[i<<1].getRefIdx()!=-1) && (getSlice()->getViewIndex() != getSlice()->getRefPic(RefPicList(0), pcMvFieldNeighbours[i<<1].getRefIdx())->getViewIndex())) |
|---|
| 3564 | { |
|---|
| 3565 | iFirDispCand = i; |
|---|
| 3566 | return true; |
|---|
| 3567 | } |
|---|
| 3568 | } |
|---|
| 3569 | return false; |
|---|
| 3570 | } |
|---|
| 3571 | |
|---|
| 3572 | #endif |
|---|
| 3573 | /** Constructs a list of merging candidates |
|---|
| 3574 | * \param uiAbsPartIdx |
|---|
| 3575 | * \param uiPUIdx |
|---|
| 3576 | * \param uiDepth |
|---|
| 3577 | * \param pcMvFieldNeighbours |
|---|
| 3578 | * \param puhInterDirNeighbours |
|---|
| 3579 | * \param numValidMergeCand |
|---|
| 3580 | */ |
|---|
| 3581 | Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours |
|---|
| 3582 | #if H_3D_VSP |
|---|
| 3583 | , Int* vspFlag |
|---|
| 3584 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3585 | , InheritedVSPDisInfo* inheritedVSPDisInfo |
|---|
| 3586 | #endif |
|---|
| 3587 | #if MTK_VSP_FIX_E0172 |
|---|
| 3588 | , Int* vspDir |
|---|
| 3589 | #endif |
|---|
| 3590 | #endif |
|---|
| 3591 | , Int& numValidMergeCand, Int mrgCandIdx |
|---|
| 3592 | ) |
|---|
| 3593 | { |
|---|
| 3594 | UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; |
|---|
| 3595 | #if H_3D_IV_MERGE |
|---|
| 3596 | TComMv cZeroMv; |
|---|
| 3597 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ]; |
|---|
| 3598 | #else |
|---|
| 3599 | Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; |
|---|
| 3600 | #endif |
|---|
| 3601 | for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) |
|---|
| 3602 | { |
|---|
| 3603 | abCandIsInter[ui] = false; |
|---|
| 3604 | #if H_3D_IV_MERGE |
|---|
| 3605 | pcMvFieldNeighbours[ ( ui << 1 ) ].setMvField(cZeroMv, NOT_VALID); |
|---|
| 3606 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID); |
|---|
| 3607 | #else |
|---|
| 3608 | pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); |
|---|
| 3609 | pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); |
|---|
| 3610 | #endif |
|---|
| 3611 | } |
|---|
| 3612 | numValidMergeCand = getSlice()->getMaxNumMergeCand(); |
|---|
| 3613 | // compute the location of the current PU |
|---|
| 3614 | Int xP, yP, nPSW, nPSH; |
|---|
| 3615 | this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); |
|---|
| 3616 | |
|---|
| 3617 | Int iCount = 0; |
|---|
| 3618 | |
|---|
| 3619 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
|---|
| 3620 | PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); |
|---|
| 3621 | deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); |
|---|
| 3622 | deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); |
|---|
| 3623 | #if H_3D_IV_MERGE |
|---|
| 3624 | Bool ivMvPredFlag = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() ); |
|---|
| 3625 | |
|---|
| 3626 | //===== add merge with predicted depth maps ===== |
|---|
| 3627 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 3628 | TComMv acPdmMv [8]; |
|---|
| 3629 | Int aiPdmRefIdx [8] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
|---|
| 3630 | Int iPosDmv = -1; |
|---|
| 3631 | #else |
|---|
| 3632 | TComMv acPdmMv [4]; |
|---|
| 3633 | Int aiPdmRefIdx [4] = {-1, -1, -1, -1}; |
|---|
| 3634 | #endif |
|---|
| 3635 | Bool bLeftAvai = false; |
|---|
| 3636 | Int iPosLeftAbove[2] = {-1, -1}; |
|---|
| 3637 | |
|---|
| 3638 | |
|---|
| 3639 | DisInfo cDisInfo; |
|---|
| 3640 | |
|---|
| 3641 | cDisInfo.bDV = getDvInfo(uiAbsPartIdx).bDV; |
|---|
| 3642 | #if H_3D_NBDV_REF |
|---|
| 3643 | cDisInfo.m_acDoNBDV = getDvInfo(uiAbsPartIdx).m_acDoNBDV; |
|---|
| 3644 | #endif //H_3D_NBDV_REF |
|---|
| 3645 | cDisInfo.m_acNBDV = getDvInfo(uiAbsPartIdx).m_acNBDV; |
|---|
| 3646 | cDisInfo.m_aVIdxCan = getDvInfo(uiAbsPartIdx).m_aVIdxCan; |
|---|
| 3647 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3648 | for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) |
|---|
| 3649 | { |
|---|
| 3650 | inheritedVSPDisInfo[i].m_acDvInfo = cDisInfo; |
|---|
| 3651 | } |
|---|
| 3652 | #endif |
|---|
| 3653 | if( m_pcSlice->getIsDepth()) |
|---|
| 3654 | { |
|---|
| 3655 | UInt uiPartIdxCenter; |
|---|
| 3656 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
|---|
| 3657 | TComDataCU *pcTextureCU = m_pcSlice->getTexturePic()->getCU( getAddr() ); |
|---|
| 3658 | |
|---|
| 3659 | if ( pcTextureCU && !pcTextureCU->isIntra( uiPartIdxCenter ) ) |
|---|
| 3660 | { |
|---|
| 3661 | #if MTK_TEXTURE_MRGCAND_BUGFIX_E0182 |
|---|
| 3662 | pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 3663 | Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1].getRefIdx() ); |
|---|
| 3664 | if( (pcMvFieldNeighbours[iCount<<1].getRefIdx()>=0) && ( iValidDepRef >= 0 ) ) |
|---|
| 3665 | { |
|---|
| 3666 | TComMv cMvPred = pcMvFieldNeighbours[iCount<<1].getMv(); |
|---|
| 3667 | const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
|---|
| 3668 | cMvPred+=cAdd; |
|---|
| 3669 | cMvPred>>=2; |
|---|
| 3670 | clipMv(cMvPred); |
|---|
| 3671 | pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,iValidDepRef); |
|---|
| 3672 | } |
|---|
| 3673 | |
|---|
| 3674 | if ( getSlice()->isInterB() ) |
|---|
| 3675 | { |
|---|
| 3676 | pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 3677 | iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx() ); |
|---|
| 3678 | if( (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()>=0) && ( iValidDepRef >= 0) ) |
|---|
| 3679 | { |
|---|
| 3680 | TComMv cMvPred = pcMvFieldNeighbours[(iCount<<1)+1].getMv(); |
|---|
| 3681 | const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
|---|
| 3682 | cMvPred+=cAdd; |
|---|
| 3683 | cMvPred>>=2; |
|---|
| 3684 | clipMv(cMvPred); |
|---|
| 3685 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField(cMvPred,iValidDepRef); |
|---|
| 3686 | } |
|---|
| 3687 | } |
|---|
| 3688 | |
|---|
| 3689 | puhInterDirNeighbours[iCount] = (pcMvFieldNeighbours[iCount<<1].getRefIdx()>=0)?1:0; |
|---|
| 3690 | puhInterDirNeighbours[iCount] += (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()>=0)?2:0; |
|---|
| 3691 | |
|---|
| 3692 | if( puhInterDirNeighbours[iCount] != 0 ) |
|---|
| 3693 | { |
|---|
| 3694 | abCandIsInter[iCount] = true; |
|---|
| 3695 | if ( mrgCandIdx == iCount ) |
|---|
| 3696 | { |
|---|
| 3697 | return; |
|---|
| 3698 | } |
|---|
| 3699 | iCount ++; |
|---|
| 3700 | } |
|---|
| 3701 | #else |
|---|
| 3702 | abCandIsInter[iCount] = true; |
|---|
| 3703 | puhInterDirNeighbours[iCount] = pcTextureCU->getInterDir( uiPartIdxCenter ); |
|---|
| 3704 | #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 |
|---|
| 3705 | pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 3706 | if (pcMvFieldNeighbours[iCount<<1].getRefIdx()>=0) |
|---|
| 3707 | #else |
|---|
| 3708 | if( ( puhInterDirNeighbours[iCount] & 1 ) == 1 ) |
|---|
| 3709 | #endif |
|---|
| 3710 | { |
|---|
| 3711 | #if !MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 |
|---|
| 3712 | pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 3713 | #endif |
|---|
| 3714 | TComMv cMvPred = pcMvFieldNeighbours[iCount<<1].getMv(); |
|---|
| 3715 | |
|---|
| 3716 | #if H_3D_IC |
|---|
| 3717 | const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
|---|
| 3718 | cMvPred+=cAdd; |
|---|
| 3719 | cMvPred>>=2; |
|---|
| 3720 | clipMv(cMvPred); |
|---|
| 3721 | #endif |
|---|
| 3722 | //pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,pcMvFieldNeighbours[iCount<<1].getRefIdx()); |
|---|
| 3723 | #if H_3D //Notes from QC: for BVSP coded blocks, the reference index shall not be equal to -1 due to the adoption of JCT3V-D0191 |
|---|
| 3724 | pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,pcMvFieldNeighbours[iCount<<1].getRefIdx()); |
|---|
| 3725 | #endif |
|---|
| 3726 | } |
|---|
| 3727 | |
|---|
| 3728 | if ( getSlice()->isInterB() ) |
|---|
| 3729 | { |
|---|
| 3730 | #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 |
|---|
| 3731 | pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 3732 | if (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()>=0) |
|---|
| 3733 | #else |
|---|
| 3734 | if( ( puhInterDirNeighbours[iCount] & 2 ) == 2 ) |
|---|
| 3735 | #endif |
|---|
| 3736 | { |
|---|
| 3737 | #if !MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 |
|---|
| 3738 | pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 3739 | #endif |
|---|
| 3740 | TComMv cMvPred = pcMvFieldNeighbours[(iCount<<1)+1].getMv(); |
|---|
| 3741 | #if H_3D_IC |
|---|
| 3742 | const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); |
|---|
| 3743 | cMvPred+=cAdd; |
|---|
| 3744 | cMvPred>>=2; |
|---|
| 3745 | clipMv(cMvPred); |
|---|
| 3746 | #endif |
|---|
| 3747 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField(cMvPred,pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()); |
|---|
| 3748 | } |
|---|
| 3749 | } |
|---|
| 3750 | #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 |
|---|
| 3751 | puhInterDirNeighbours[iCount] = (pcMvFieldNeighbours[iCount<<1].getRefIdx()>=0)?1:0; |
|---|
| 3752 | puhInterDirNeighbours[iCount] += (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()>=0)?2:0; |
|---|
| 3753 | #endif |
|---|
| 3754 | #if H_3D_NBDV |
|---|
| 3755 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3756 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3757 | #endif |
|---|
| 3758 | if ( mrgCandIdx == iCount ) |
|---|
| 3759 | { |
|---|
| 3760 | return; |
|---|
| 3761 | } |
|---|
| 3762 | iCount ++; |
|---|
| 3763 | #endif//Bug fix |
|---|
| 3764 | } |
|---|
| 3765 | } |
|---|
| 3766 | |
|---|
| 3767 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 3768 | Int iPdmDir[4] = {0, 0, 0, 0}; |
|---|
| 3769 | #else |
|---|
| 3770 | Int iPdmDir[2] = {0, 0}; |
|---|
| 3771 | #endif |
|---|
| 3772 | |
|---|
| 3773 | if ( ivMvPredFlag ) |
|---|
| 3774 | { |
|---|
| 3775 | getInterViewMergeCands(uiPUIdx, aiPdmRefIdx, acPdmMv, &cDisInfo, iPdmDir ); |
|---|
| 3776 | } |
|---|
| 3777 | |
|---|
| 3778 | Int iPdmInterDir; |
|---|
| 3779 | |
|---|
| 3780 | if( iPdmDir[0] ) |
|---|
| 3781 | { |
|---|
| 3782 | abCandIsInter [ iCount ] = true; |
|---|
| 3783 | puhInterDirNeighbours[ iCount ] = iPdmDir[0]; |
|---|
| 3784 | iPdmInterDir = iPdmDir[0]; |
|---|
| 3785 | |
|---|
| 3786 | if( ( iPdmInterDir & 1 ) == 1 ) |
|---|
| 3787 | { |
|---|
| 3788 | pcMvFieldNeighbours[ iCount<<1 ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] ); |
|---|
| 3789 | } |
|---|
| 3790 | if( ( iPdmInterDir & 2 ) == 2 ) |
|---|
| 3791 | { |
|---|
| 3792 | pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 1 ], aiPdmRefIdx[ 1 ] ); |
|---|
| 3793 | } |
|---|
| 3794 | |
|---|
| 3795 | if ( mrgCandIdx == iCount ) |
|---|
| 3796 | { |
|---|
| 3797 | return; |
|---|
| 3798 | } |
|---|
| 3799 | iCount ++; |
|---|
| 3800 | } |
|---|
| 3801 | // early termination |
|---|
| 3802 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3803 | { |
|---|
| 3804 | return; |
|---|
| 3805 | } |
|---|
| 3806 | #endif |
|---|
| 3807 | |
|---|
| 3808 | //left |
|---|
| 3809 | UInt uiLeftPartIdx = 0; |
|---|
| 3810 | TComDataCU* pcCULeft = 0; |
|---|
| 3811 | pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); |
|---|
| 3812 | Bool isAvailableA1 = pcCULeft && |
|---|
| 3813 | pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && |
|---|
| 3814 | !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && |
|---|
| 3815 | !pcCULeft->isIntra( uiLeftPartIdx ) ; |
|---|
| 3816 | if ( isAvailableA1 ) |
|---|
| 3817 | { |
|---|
| 3818 | abCandIsInter[iCount] = true; |
|---|
| 3819 | // get Inter Dir |
|---|
| 3820 | puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); |
|---|
| 3821 | // get Mv from Left |
|---|
| 3822 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 3823 | if ( getSlice()->isInterB() ) |
|---|
| 3824 | { |
|---|
| 3825 | pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 3826 | } |
|---|
| 3827 | #if H_3D_IV_MERGE |
|---|
| 3828 | Bool bRemoveSpa = false; //pruning to inter-view candidates |
|---|
| 3829 | Int iCnloop = iCount - 1; |
|---|
| 3830 | for(; iCnloop >= 0; iCnloop --) |
|---|
| 3831 | { |
|---|
| 3832 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
|---|
| 3833 | { |
|---|
| 3834 | bRemoveSpa = true; |
|---|
| 3835 | abCandIsInter [ iCount ] = false; |
|---|
| 3836 | |
|---|
| 3837 | //reset to the default value for MC |
|---|
| 3838 | puhInterDirNeighbours[iCount] = 0; |
|---|
| 3839 | pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3840 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3841 | break; |
|---|
| 3842 | } |
|---|
| 3843 | } |
|---|
| 3844 | if(!bRemoveSpa) |
|---|
| 3845 | { |
|---|
| 3846 | bLeftAvai = true; |
|---|
| 3847 | iPosLeftAbove[0] = iCount; |
|---|
| 3848 | #if H_3D_NBDV |
|---|
| 3849 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3850 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3851 | #endif |
|---|
| 3852 | #if H_3D_VSP |
|---|
| 3853 | if (pcCULeft->getVSPFlag(uiLeftPartIdx) == 1) |
|---|
| 3854 | #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3855 | { |
|---|
| 3856 | #endif |
|---|
| 3857 | vspFlag[iCount] = 1; |
|---|
| 3858 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3859 | xInheritVSPDisInfo(pcCULeft,uiLeftPartIdx,iCount,inheritedVSPDisInfo); |
|---|
| 3860 | } |
|---|
| 3861 | #endif |
|---|
| 3862 | #if MTK_VSP_FIX_E0172 |
|---|
| 3863 | vspDir[iCount] = pcCULeft->getVSPDir( uiLeftPartIdx ); |
|---|
| 3864 | } |
|---|
| 3865 | #endif |
|---|
| 3866 | #endif |
|---|
| 3867 | if ( mrgCandIdx == iCount ) |
|---|
| 3868 | { |
|---|
| 3869 | return; |
|---|
| 3870 | } |
|---|
| 3871 | iCount ++; |
|---|
| 3872 | } |
|---|
| 3873 | #else |
|---|
| 3874 | if ( mrgCandIdx == iCount ) |
|---|
| 3875 | { |
|---|
| 3876 | return; |
|---|
| 3877 | } |
|---|
| 3878 | iCount ++; |
|---|
| 3879 | #endif |
|---|
| 3880 | } |
|---|
| 3881 | |
|---|
| 3882 | // early termination |
|---|
| 3883 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3884 | { |
|---|
| 3885 | return; |
|---|
| 3886 | } |
|---|
| 3887 | // above |
|---|
| 3888 | UInt uiAbovePartIdx = 0; |
|---|
| 3889 | TComDataCU* pcCUAbove = 0; |
|---|
| 3890 | pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); |
|---|
| 3891 | Bool isAvailableB1 = pcCUAbove && |
|---|
| 3892 | pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && |
|---|
| 3893 | !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && |
|---|
| 3894 | !pcCUAbove->isIntra( uiAbovePartIdx ); |
|---|
| 3895 | if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) |
|---|
| 3896 | { |
|---|
| 3897 | abCandIsInter[iCount] = true; |
|---|
| 3898 | // get Inter Dir |
|---|
| 3899 | puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); |
|---|
| 3900 | // get Mv from Left |
|---|
| 3901 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 3902 | if ( getSlice()->isInterB() ) |
|---|
| 3903 | { |
|---|
| 3904 | pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 3905 | } |
|---|
| 3906 | #if H_3D_IV_MERGE |
|---|
| 3907 | Bool bRemoveSpa = false; //pruning to inter-view candidates |
|---|
| 3908 | Int iCnloop = bLeftAvai? (iCount-2): (iCount-1); |
|---|
| 3909 | for(; iCnloop >= 0; iCnloop --) |
|---|
| 3910 | { |
|---|
| 3911 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
|---|
| 3912 | { |
|---|
| 3913 | bRemoveSpa = true; |
|---|
| 3914 | abCandIsInter [ iCount ] = false; |
|---|
| 3915 | |
|---|
| 3916 | //reset to the default value for MC |
|---|
| 3917 | puhInterDirNeighbours[iCount] = 0; |
|---|
| 3918 | |
|---|
| 3919 | pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3920 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 3921 | break; |
|---|
| 3922 | } |
|---|
| 3923 | } |
|---|
| 3924 | if(!bRemoveSpa) |
|---|
| 3925 | { |
|---|
| 3926 | iPosLeftAbove[1] = iCount; |
|---|
| 3927 | #if H_3D_NBDV |
|---|
| 3928 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3929 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3930 | #endif |
|---|
| 3931 | #if H_3D_VSP |
|---|
| 3932 | if (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1) |
|---|
| 3933 | #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3934 | { |
|---|
| 3935 | #endif |
|---|
| 3936 | vspFlag[iCount] = 1; |
|---|
| 3937 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3938 | xInheritVSPDisInfo(pcCUAbove,uiAbovePartIdx,iCount,inheritedVSPDisInfo); |
|---|
| 3939 | } |
|---|
| 3940 | #endif |
|---|
| 3941 | #if MTK_VSP_FIX_E0172 |
|---|
| 3942 | vspDir[iCount] = pcCUAbove->getVSPDir( uiAbovePartIdx ); |
|---|
| 3943 | } |
|---|
| 3944 | #endif |
|---|
| 3945 | #endif |
|---|
| 3946 | if ( mrgCandIdx == iCount ) |
|---|
| 3947 | { |
|---|
| 3948 | return; |
|---|
| 3949 | } |
|---|
| 3950 | iCount ++; |
|---|
| 3951 | } |
|---|
| 3952 | #else |
|---|
| 3953 | if ( mrgCandIdx == iCount ) |
|---|
| 3954 | { |
|---|
| 3955 | return; |
|---|
| 3956 | } |
|---|
| 3957 | iCount ++; |
|---|
| 3958 | #endif |
|---|
| 3959 | } |
|---|
| 3960 | // early termination |
|---|
| 3961 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 3962 | { |
|---|
| 3963 | return; |
|---|
| 3964 | } |
|---|
| 3965 | |
|---|
| 3966 | // above right |
|---|
| 3967 | UInt uiAboveRightPartIdx = 0; |
|---|
| 3968 | TComDataCU* pcCUAboveRight = 0; |
|---|
| 3969 | pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); |
|---|
| 3970 | Bool isAvailableB0 = pcCUAboveRight && |
|---|
| 3971 | pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && |
|---|
| 3972 | !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); |
|---|
| 3973 | if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) |
|---|
| 3974 | { |
|---|
| 3975 | abCandIsInter[iCount] = true; |
|---|
| 3976 | // get Inter Dir |
|---|
| 3977 | puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); |
|---|
| 3978 | // get Mv from Left |
|---|
| 3979 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 3980 | if ( getSlice()->isInterB() ) |
|---|
| 3981 | { |
|---|
| 3982 | pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 3983 | } |
|---|
| 3984 | #if H_3D_NBDV |
|---|
| 3985 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 3986 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 3987 | #endif |
|---|
| 3988 | #if H_3D_VSP |
|---|
| 3989 | if (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1) |
|---|
| 3990 | #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3991 | { |
|---|
| 3992 | #endif |
|---|
| 3993 | vspFlag[iCount] = 1; |
|---|
| 3994 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 3995 | xInheritVSPDisInfo(pcCUAboveRight,uiAboveRightPartIdx,iCount,inheritedVSPDisInfo); |
|---|
| 3996 | } |
|---|
| 3997 | #endif |
|---|
| 3998 | #if MTK_VSP_FIX_E0172 |
|---|
| 3999 | vspDir[iCount] = pcCUAboveRight->getVSPDir( uiAboveRightPartIdx); |
|---|
| 4000 | } |
|---|
| 4001 | #endif |
|---|
| 4002 | #endif |
|---|
| 4003 | if ( mrgCandIdx == iCount ) |
|---|
| 4004 | { |
|---|
| 4005 | return; |
|---|
| 4006 | } |
|---|
| 4007 | iCount ++; |
|---|
| 4008 | } |
|---|
| 4009 | // early termination |
|---|
| 4010 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 4011 | { |
|---|
| 4012 | return; |
|---|
| 4013 | } |
|---|
| 4014 | |
|---|
| 4015 | #if H_3D_IV_MERGE |
|---|
| 4016 | if( iPdmDir[1] ) |
|---|
| 4017 | { |
|---|
| 4018 | assert(iCount < getSlice()->getMaxNumMergeCand()); |
|---|
| 4019 | abCandIsInter [ iCount ] = true; |
|---|
| 4020 | puhInterDirNeighbours[ iCount ] = iPdmDir[1]; |
|---|
| 4021 | if( ( iPdmDir[1] & 1 ) == 1 ) |
|---|
| 4022 | { |
|---|
| 4023 | pcMvFieldNeighbours[ iCount<<1 ].setMvField( acPdmMv[ 2 ], aiPdmRefIdx[ 2 ] ); |
|---|
| 4024 | } |
|---|
| 4025 | if( ( iPdmDir[1] & 2 ) == 2 ) |
|---|
| 4026 | { |
|---|
| 4027 | pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 3 ], aiPdmRefIdx[ 3 ] ); |
|---|
| 4028 | } |
|---|
| 4029 | |
|---|
| 4030 | Bool bRemoveSpa = false; //pruning to A1, B1 |
|---|
| 4031 | for(Int i = 0; i < 2; i ++) |
|---|
| 4032 | { |
|---|
| 4033 | Int iCnloop = iPosLeftAbove[i]; |
|---|
| 4034 | if(iCnloop == -1) |
|---|
| 4035 | continue; |
|---|
| 4036 | if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1]) |
|---|
| 4037 | { |
|---|
| 4038 | bRemoveSpa = true; |
|---|
| 4039 | abCandIsInter [ iCount ] = false; |
|---|
| 4040 | //reset to the default value for MC |
|---|
| 4041 | puhInterDirNeighbours[iCount] = 0; |
|---|
| 4042 | pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 4043 | pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID ); |
|---|
| 4044 | break; |
|---|
| 4045 | } |
|---|
| 4046 | } |
|---|
| 4047 | if(!bRemoveSpa) |
|---|
| 4048 | { |
|---|
| 4049 | #if H_3D_NBDV |
|---|
| 4050 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 4051 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 4052 | #endif |
|---|
| 4053 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 4054 | iPosDmv = iCount; |
|---|
| 4055 | #endif |
|---|
| 4056 | if ( mrgCandIdx == iCount ) |
|---|
| 4057 | return; |
|---|
| 4058 | iCount ++; |
|---|
| 4059 | |
|---|
| 4060 | // early termination |
|---|
| 4061 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 4062 | { |
|---|
| 4063 | return; |
|---|
| 4064 | } |
|---|
| 4065 | } |
|---|
| 4066 | } |
|---|
| 4067 | #endif |
|---|
| 4068 | |
|---|
| 4069 | #if H_3D_VSP |
|---|
| 4070 | #if MTK_VSP_FIX_E0172 |
|---|
| 4071 | if ( xAddVspCand( H_3D_VSP_POSITION, mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, vspDir ) ) |
|---|
| 4072 | #else |
|---|
| 4073 | if ( xAddVspCand( H_3D_VSP_POSITION, mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag ) ) |
|---|
| 4074 | #endif |
|---|
| 4075 | return; |
|---|
| 4076 | // early termination |
|---|
| 4077 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 4078 | return; |
|---|
| 4079 | #endif |
|---|
| 4080 | |
|---|
| 4081 | //left bottom |
|---|
| 4082 | UInt uiLeftBottomPartIdx = 0; |
|---|
| 4083 | TComDataCU* pcCULeftBottom = 0; |
|---|
| 4084 | pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); |
|---|
| 4085 | Bool isAvailableA0 = pcCULeftBottom && |
|---|
| 4086 | pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && |
|---|
| 4087 | !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; |
|---|
| 4088 | if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) |
|---|
| 4089 | { |
|---|
| 4090 | abCandIsInter[iCount] = true; |
|---|
| 4091 | // get Inter Dir |
|---|
| 4092 | puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); |
|---|
| 4093 | // get Mv from Left |
|---|
| 4094 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 4095 | if ( getSlice()->isInterB() ) |
|---|
| 4096 | { |
|---|
| 4097 | pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 4098 | } |
|---|
| 4099 | #if H_3D_NBDV |
|---|
| 4100 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 4101 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 4102 | #endif |
|---|
| 4103 | #if H_3D_VSP |
|---|
| 4104 | if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) == 1) |
|---|
| 4105 | #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 4106 | { |
|---|
| 4107 | #endif |
|---|
| 4108 | vspFlag[iCount] = 1; |
|---|
| 4109 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 4110 | xInheritVSPDisInfo(pcCULeftBottom,uiLeftBottomPartIdx,iCount,inheritedVSPDisInfo); |
|---|
| 4111 | } |
|---|
| 4112 | #endif |
|---|
| 4113 | #if MTK_VSP_FIX_E0172 |
|---|
| 4114 | vspDir[iCount] = pcCULeftBottom->getVSPDir( uiLeftBottomPartIdx); |
|---|
| 4115 | } |
|---|
| 4116 | #endif |
|---|
| 4117 | #endif |
|---|
| 4118 | if ( mrgCandIdx == iCount ) |
|---|
| 4119 | { |
|---|
| 4120 | return; |
|---|
| 4121 | } |
|---|
| 4122 | iCount ++; |
|---|
| 4123 | } |
|---|
| 4124 | // early termination |
|---|
| 4125 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 4126 | { |
|---|
| 4127 | return; |
|---|
| 4128 | } |
|---|
| 4129 | // above left |
|---|
| 4130 | if( iCount < 4 ) |
|---|
| 4131 | { |
|---|
| 4132 | UInt uiAboveLeftPartIdx = 0; |
|---|
| 4133 | TComDataCU* pcCUAboveLeft = 0; |
|---|
| 4134 | pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); |
|---|
| 4135 | Bool isAvailableB2 = pcCUAboveLeft && |
|---|
| 4136 | pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && |
|---|
| 4137 | !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); |
|---|
| 4138 | if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) |
|---|
| 4139 | && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) |
|---|
| 4140 | { |
|---|
| 4141 | abCandIsInter[iCount] = true; |
|---|
| 4142 | // get Inter Dir |
|---|
| 4143 | puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); |
|---|
| 4144 | // get Mv from Left |
|---|
| 4145 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); |
|---|
| 4146 | if ( getSlice()->isInterB() ) |
|---|
| 4147 | { |
|---|
| 4148 | pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); |
|---|
| 4149 | } |
|---|
| 4150 | #if H_3D_NBDV |
|---|
| 4151 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 4152 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 4153 | #endif |
|---|
| 4154 | #if H_3D_VSP |
|---|
| 4155 | if (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1) |
|---|
| 4156 | #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 4157 | { |
|---|
| 4158 | #endif |
|---|
| 4159 | vspFlag[iCount] = 1; |
|---|
| 4160 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 4161 | xInheritVSPDisInfo(pcCUAboveLeft,uiAboveLeftPartIdx,iCount,inheritedVSPDisInfo); |
|---|
| 4162 | } |
|---|
| 4163 | #endif |
|---|
| 4164 | #if MTK_VSP_FIX_E0172 |
|---|
| 4165 | vspDir[iCount] = pcCUAboveLeft->getVSPDir( uiAboveLeftPartIdx); |
|---|
| 4166 | } |
|---|
| 4167 | #endif |
|---|
| 4168 | #endif |
|---|
| 4169 | if ( mrgCandIdx == iCount ) |
|---|
| 4170 | { |
|---|
| 4171 | return; |
|---|
| 4172 | } |
|---|
| 4173 | iCount ++; |
|---|
| 4174 | } |
|---|
| 4175 | } |
|---|
| 4176 | // early termination |
|---|
| 4177 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 4178 | { |
|---|
| 4179 | return; |
|---|
| 4180 | } |
|---|
| 4181 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 4182 | if( ivMvPredFlag ) |
|---|
| 4183 | { |
|---|
| 4184 | if(xAddIvMRGCand( mrgCandIdx, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, iPdmDir, acPdmMv, aiPdmRefIdx, iPosDmv, vspFlag)) |
|---|
| 4185 | { |
|---|
| 4186 | return; |
|---|
| 4187 | } |
|---|
| 4188 | //early termination |
|---|
| 4189 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 4190 | { |
|---|
| 4191 | return; |
|---|
| 4192 | } |
|---|
| 4193 | } |
|---|
| 4194 | #endif |
|---|
| 4195 | if ( getSlice()->getEnableTMVPFlag()) |
|---|
| 4196 | { |
|---|
| 4197 | //>> MTK colocated-RightBottom |
|---|
| 4198 | UInt uiPartIdxRB; |
|---|
| 4199 | |
|---|
| 4200 | deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); |
|---|
| 4201 | |
|---|
| 4202 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
|---|
| 4203 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 4204 | |
|---|
| 4205 | TComMv cColMv; |
|---|
| 4206 | Int iRefIdx; |
|---|
| 4207 | Int uiLCUIdx = -1; |
|---|
| 4208 | |
|---|
| 4209 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
|---|
| 4210 | { |
|---|
| 4211 | } |
|---|
| 4212 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
|---|
| 4213 | { |
|---|
| 4214 | } |
|---|
| 4215 | else |
|---|
| 4216 | { |
|---|
| 4217 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
|---|
| 4218 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
|---|
| 4219 | { |
|---|
| 4220 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
|---|
| 4221 | uiLCUIdx = getAddr(); |
|---|
| 4222 | } |
|---|
| 4223 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
|---|
| 4224 | { |
|---|
| 4225 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
|---|
| 4226 | } |
|---|
| 4227 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
|---|
| 4228 | { |
|---|
| 4229 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
|---|
| 4230 | uiLCUIdx = getAddr() + 1; |
|---|
| 4231 | } |
|---|
| 4232 | else //is the right bottom corner of LCU |
|---|
| 4233 | { |
|---|
| 4234 | uiAbsPartAddr = 0; |
|---|
| 4235 | } |
|---|
| 4236 | } |
|---|
| 4237 | |
|---|
| 4238 | |
|---|
| 4239 | iRefIdx = 0; |
|---|
| 4240 | Bool bExistMV = false; |
|---|
| 4241 | UInt uiPartIdxCenter; |
|---|
| 4242 | UInt uiCurLCUIdx = getAddr(); |
|---|
| 4243 | Int dir = 0; |
|---|
| 4244 | UInt uiArrayAddr = iCount; |
|---|
| 4245 | xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); |
|---|
| 4246 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); |
|---|
| 4247 | if( bExistMV == false ) |
|---|
| 4248 | { |
|---|
| 4249 | bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
|---|
| 4250 | } |
|---|
| 4251 | if( bExistMV ) |
|---|
| 4252 | { |
|---|
| 4253 | dir |= 1; |
|---|
| 4254 | pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); |
|---|
| 4255 | } |
|---|
| 4256 | |
|---|
| 4257 | if ( getSlice()->isInterB() ) |
|---|
| 4258 | { |
|---|
| 4259 | #if H_3D_TMVP |
|---|
| 4260 | iRefIdx = 0; |
|---|
| 4261 | #endif |
|---|
| 4262 | bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); |
|---|
| 4263 | if( bExistMV == false ) |
|---|
| 4264 | { |
|---|
| 4265 | bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); |
|---|
| 4266 | } |
|---|
| 4267 | if( bExistMV ) |
|---|
| 4268 | { |
|---|
| 4269 | dir |= 2; |
|---|
| 4270 | pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); |
|---|
| 4271 | } |
|---|
| 4272 | } |
|---|
| 4273 | |
|---|
| 4274 | if (dir != 0) |
|---|
| 4275 | { |
|---|
| 4276 | puhInterDirNeighbours[uiArrayAddr] = dir; |
|---|
| 4277 | abCandIsInter[uiArrayAddr] = true; |
|---|
| 4278 | #if H_3D_NBDV |
|---|
| 4279 | pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); |
|---|
| 4280 | pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); |
|---|
| 4281 | #endif |
|---|
| 4282 | if ( mrgCandIdx == iCount ) |
|---|
| 4283 | { |
|---|
| 4284 | return; |
|---|
| 4285 | } |
|---|
| 4286 | iCount++; |
|---|
| 4287 | } |
|---|
| 4288 | } |
|---|
| 4289 | // early termination |
|---|
| 4290 | if (iCount == getSlice()->getMaxNumMergeCand()) |
|---|
| 4291 | { |
|---|
| 4292 | return; |
|---|
| 4293 | } |
|---|
| 4294 | UInt uiArrayAddr = iCount; |
|---|
| 4295 | UInt uiCutoff = uiArrayAddr; |
|---|
| 4296 | |
|---|
| 4297 | if ( getSlice()->isInterB()) |
|---|
| 4298 | { |
|---|
| 4299 | #if H_3D_IV_MERGE |
|---|
| 4300 | UInt uiPriorityList0[20] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4, 2, 4, 3, 4 }; |
|---|
| 4301 | UInt uiPriorityList1[20] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2, 4, 0, 4, 1, 4, 2, 4, 3 }; |
|---|
| 4302 | #else |
|---|
| 4303 | UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; |
|---|
| 4304 | UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; |
|---|
| 4305 | #endif |
|---|
| 4306 | |
|---|
| 4307 | for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) |
|---|
| 4308 | { |
|---|
| 4309 | Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; |
|---|
| 4310 | #if H_3D_VSP |
|---|
| 4311 | Bool bValid = true; |
|---|
| 4312 | if ( vspFlag[i] == 1 || vspFlag[j] == 1 ) |
|---|
| 4313 | bValid = false; |
|---|
| 4314 | if( !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) ) |
|---|
| 4315 | assert(bValid == true); |
|---|
| 4316 | #endif |
|---|
| 4317 | #if H_3D_VSP |
|---|
| 4318 | if (abCandIsInter[i] && abCandIsInter[j] && (puhInterDirNeighbours[i]&0x1) && (puhInterDirNeighbours[j]&0x2) && bValid) |
|---|
| 4319 | #else |
|---|
| 4320 | if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) |
|---|
| 4321 | #endif |
|---|
| 4322 | { |
|---|
| 4323 | abCandIsInter[uiArrayAddr] = true; |
|---|
| 4324 | puhInterDirNeighbours[uiArrayAddr] = 3; |
|---|
| 4325 | |
|---|
| 4326 | // get Mv from cand[i] and cand[j] |
|---|
| 4327 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); |
|---|
| 4328 | pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); |
|---|
| 4329 | |
|---|
| 4330 | Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); |
|---|
| 4331 | Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); |
|---|
| 4332 | if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) |
|---|
| 4333 | { |
|---|
| 4334 | abCandIsInter[uiArrayAddr] = false; |
|---|
| 4335 | } |
|---|
| 4336 | else |
|---|
| 4337 | { |
|---|
| 4338 | uiArrayAddr++; |
|---|
| 4339 | } |
|---|
| 4340 | } |
|---|
| 4341 | } |
|---|
| 4342 | } |
|---|
| 4343 | // early termination |
|---|
| 4344 | if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) |
|---|
| 4345 | { |
|---|
| 4346 | return; |
|---|
| 4347 | } |
|---|
| 4348 | 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); |
|---|
| 4349 | Int r = 0; |
|---|
| 4350 | Int refcnt = 0; |
|---|
| 4351 | while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) |
|---|
| 4352 | { |
|---|
| 4353 | abCandIsInter[uiArrayAddr] = true; |
|---|
| 4354 | puhInterDirNeighbours[uiArrayAddr] = 1; |
|---|
| 4355 | pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); |
|---|
| 4356 | |
|---|
| 4357 | if ( getSlice()->isInterB() ) |
|---|
| 4358 | { |
|---|
| 4359 | puhInterDirNeighbours[uiArrayAddr] = 3; |
|---|
| 4360 | pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); |
|---|
| 4361 | } |
|---|
| 4362 | uiArrayAddr++; |
|---|
| 4363 | if ( refcnt == iNumRefIdx - 1 ) |
|---|
| 4364 | { |
|---|
| 4365 | r = 0; |
|---|
| 4366 | } |
|---|
| 4367 | else |
|---|
| 4368 | { |
|---|
| 4369 | ++r; |
|---|
| 4370 | ++refcnt; |
|---|
| 4371 | } |
|---|
| 4372 | } |
|---|
| 4373 | |
|---|
| 4374 | numValidMergeCand = uiArrayAddr; |
|---|
| 4375 | } |
|---|
| 4376 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 4377 | inline Void TComDataCU::xInheritVSPDisInfo(TComDataCU* pcCURef, UInt uiAbsPartIdx, Int iCount, InheritedVSPDisInfo* inheritedVSPDisInfo) |
|---|
| 4378 | { |
|---|
| 4379 | inheritedVSPDisInfo[iCount].m_acDvInfo.m_acNBDV = pcCURef->getDvInfo(uiAbsPartIdx).m_acNBDV; |
|---|
| 4380 | inheritedVSPDisInfo[iCount].m_acDvInfo.m_aVIdxCan = pcCURef->getDvInfo(uiAbsPartIdx).m_aVIdxCan; |
|---|
| 4381 | } |
|---|
| 4382 | #endif |
|---|
| 4383 | /** Check whether the current PU and a spatial neighboring PU are in a same ME region. |
|---|
| 4384 | * \param xN, xN location of the upper-left corner pixel of a neighboring PU |
|---|
| 4385 | * \param xP, yP location of the upper-left corner pixel of the current PU |
|---|
| 4386 | * \returns Bool |
|---|
| 4387 | */ |
|---|
| 4388 | Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) |
|---|
| 4389 | { |
|---|
| 4390 | |
|---|
| 4391 | UInt plevel = this->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() + 2; |
|---|
| 4392 | if ((xN>>plevel)!= (xP>>plevel)) |
|---|
| 4393 | { |
|---|
| 4394 | return true; |
|---|
| 4395 | } |
|---|
| 4396 | if ((yN>>plevel)!= (yP>>plevel)) |
|---|
| 4397 | { |
|---|
| 4398 | return true; |
|---|
| 4399 | } |
|---|
| 4400 | return false; |
|---|
| 4401 | } |
|---|
| 4402 | /** calculate the location of upper-left corner pixel and size of the current PU. |
|---|
| 4403 | * \param partIdx PU index within a CU |
|---|
| 4404 | * \param xP, yP location of the upper-left corner pixel of the current PU |
|---|
| 4405 | * \param PSW, nPSH size of the curren PU |
|---|
| 4406 | * \returns Void |
|---|
| 4407 | */ |
|---|
| 4408 | Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) |
|---|
| 4409 | { |
|---|
| 4410 | UInt col = m_uiCUPelX; |
|---|
| 4411 | UInt row = m_uiCUPelY; |
|---|
| 4412 | |
|---|
| 4413 | switch ( m_pePartSize[0] ) |
|---|
| 4414 | { |
|---|
| 4415 | case SIZE_2NxN: |
|---|
| 4416 | nPSW = getWidth(0); |
|---|
| 4417 | nPSH = getHeight(0) >> 1; |
|---|
| 4418 | xP = col; |
|---|
| 4419 | yP = (partIdx ==0)? row: row + nPSH; |
|---|
| 4420 | break; |
|---|
| 4421 | case SIZE_Nx2N: |
|---|
| 4422 | nPSW = getWidth(0) >> 1; |
|---|
| 4423 | nPSH = getHeight(0); |
|---|
| 4424 | xP = (partIdx ==0)? col: col + nPSW; |
|---|
| 4425 | yP = row; |
|---|
| 4426 | break; |
|---|
| 4427 | case SIZE_NxN: |
|---|
| 4428 | nPSW = getWidth(0) >> 1; |
|---|
| 4429 | nPSH = getHeight(0) >> 1; |
|---|
| 4430 | xP = col + (partIdx&0x1)*nPSW; |
|---|
| 4431 | yP = row + (partIdx>>1)*nPSH; |
|---|
| 4432 | break; |
|---|
| 4433 | case SIZE_2NxnU: |
|---|
| 4434 | nPSW = getWidth(0); |
|---|
| 4435 | nPSH = ( partIdx == 0 ) ? getHeight(0) >> 2 : ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ); |
|---|
| 4436 | xP = col; |
|---|
| 4437 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
|---|
| 4438 | |
|---|
| 4439 | break; |
|---|
| 4440 | case SIZE_2NxnD: |
|---|
| 4441 | nPSW = getWidth(0); |
|---|
| 4442 | nPSH = ( partIdx == 0 ) ? ( getHeight(0) >> 2 ) + ( getHeight(0) >> 1 ) : getHeight(0) >> 2; |
|---|
| 4443 | xP = col; |
|---|
| 4444 | yP = (partIdx ==0)? row: row + getHeight(0) - nPSH; |
|---|
| 4445 | break; |
|---|
| 4446 | case SIZE_nLx2N: |
|---|
| 4447 | nPSW = ( partIdx == 0 ) ? getWidth(0) >> 2 : ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ); |
|---|
| 4448 | nPSH = getHeight(0); |
|---|
| 4449 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
|---|
| 4450 | yP = row; |
|---|
| 4451 | break; |
|---|
| 4452 | case SIZE_nRx2N: |
|---|
| 4453 | nPSW = ( partIdx == 0 ) ? ( getWidth(0) >> 2 ) + ( getWidth(0) >> 1 ) : getWidth(0) >> 2; |
|---|
| 4454 | nPSH = getHeight(0); |
|---|
| 4455 | xP = (partIdx ==0)? col: col + getWidth(0) - nPSW; |
|---|
| 4456 | yP = row; |
|---|
| 4457 | break; |
|---|
| 4458 | default: |
|---|
| 4459 | assert ( m_pePartSize[0] == SIZE_2Nx2N ); |
|---|
| 4460 | nPSW = getWidth(0); |
|---|
| 4461 | nPSH = getHeight(0); |
|---|
| 4462 | xP = col ; |
|---|
| 4463 | yP = row ; |
|---|
| 4464 | |
|---|
| 4465 | break; |
|---|
| 4466 | } |
|---|
| 4467 | } |
|---|
| 4468 | |
|---|
| 4469 | /** Constructs a list of candidates for AMVP |
|---|
| 4470 | * \param uiPartIdx |
|---|
| 4471 | * \param uiPartAddr |
|---|
| 4472 | * \param eRefPicList |
|---|
| 4473 | * \param iRefIdx |
|---|
| 4474 | * \param pInfo |
|---|
| 4475 | */ |
|---|
| 4476 | Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo ) |
|---|
| 4477 | { |
|---|
| 4478 | TComMv cMvPred; |
|---|
| 4479 | Bool bAddedSmvp = false; |
|---|
| 4480 | |
|---|
| 4481 | pInfo->iN = 0; |
|---|
| 4482 | if (iRefIdx < 0) |
|---|
| 4483 | { |
|---|
| 4484 | return; |
|---|
| 4485 | } |
|---|
| 4486 | |
|---|
| 4487 | //-- Get Spatial MV |
|---|
| 4488 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
|---|
| 4489 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 4490 | Bool bAdded = false; |
|---|
| 4491 | |
|---|
| 4492 | deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
|---|
| 4493 | deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); |
|---|
| 4494 | |
|---|
| 4495 | TComDataCU* tmpCU = NULL; |
|---|
| 4496 | UInt idx; |
|---|
| 4497 | tmpCU = getPUBelowLeft(idx, uiPartIdxLB); |
|---|
| 4498 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
|---|
| 4499 | |
|---|
| 4500 | if (!bAddedSmvp) |
|---|
| 4501 | { |
|---|
| 4502 | tmpCU = getPULeft(idx, uiPartIdxLB); |
|---|
| 4503 | bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA); |
|---|
| 4504 | } |
|---|
| 4505 | |
|---|
| 4506 | // Left predictor search |
|---|
| 4507 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
|---|
| 4508 | if (!bAdded) |
|---|
| 4509 | { |
|---|
| 4510 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
|---|
| 4511 | } |
|---|
| 4512 | |
|---|
| 4513 | if(!bAdded) |
|---|
| 4514 | { |
|---|
| 4515 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); |
|---|
| 4516 | if (!bAdded) |
|---|
| 4517 | { |
|---|
| 4518 | xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); |
|---|
| 4519 | } |
|---|
| 4520 | } |
|---|
| 4521 | // Above predictor search |
|---|
| 4522 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
|---|
| 4523 | |
|---|
| 4524 | if (!bAdded) |
|---|
| 4525 | { |
|---|
| 4526 | bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
|---|
| 4527 | } |
|---|
| 4528 | |
|---|
| 4529 | if(!bAdded) |
|---|
| 4530 | { |
|---|
| 4531 | xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
|---|
| 4532 | } |
|---|
| 4533 | bAdded = bAddedSmvp; |
|---|
| 4534 | if (pInfo->iN==2) bAdded = true; |
|---|
| 4535 | |
|---|
| 4536 | if(!bAdded) |
|---|
| 4537 | { |
|---|
| 4538 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); |
|---|
| 4539 | if (!bAdded) |
|---|
| 4540 | { |
|---|
| 4541 | bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); |
|---|
| 4542 | } |
|---|
| 4543 | |
|---|
| 4544 | if(!bAdded) |
|---|
| 4545 | { |
|---|
| 4546 | xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT); |
|---|
| 4547 | } |
|---|
| 4548 | } |
|---|
| 4549 | |
|---|
| 4550 | if ( pInfo->iN == 2 ) |
|---|
| 4551 | { |
|---|
| 4552 | if ( pInfo->m_acMvCand[ 0 ] == pInfo->m_acMvCand[ 1 ] ) |
|---|
| 4553 | { |
|---|
| 4554 | pInfo->iN = 1; |
|---|
| 4555 | } |
|---|
| 4556 | } |
|---|
| 4557 | |
|---|
| 4558 | if ( getSlice()->getEnableTMVPFlag() ) |
|---|
| 4559 | { |
|---|
| 4560 | // Get Temporal Motion Predictor |
|---|
| 4561 | Int iRefIdx_Col = iRefIdx; |
|---|
| 4562 | TComMv cColMv; |
|---|
| 4563 | UInt uiPartIdxRB; |
|---|
| 4564 | UInt uiAbsPartIdx; |
|---|
| 4565 | UInt uiAbsPartAddr; |
|---|
| 4566 | |
|---|
| 4567 | deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); |
|---|
| 4568 | uiAbsPartAddr = m_uiAbsIdxInLCU + uiPartAddr; |
|---|
| 4569 | |
|---|
| 4570 | //---- co-located RightBottom Temporal Predictor (H) ---// |
|---|
| 4571 | uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; |
|---|
| 4572 | Int uiLCUIdx = -1; |
|---|
| 4573 | if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check |
|---|
| 4574 | { |
|---|
| 4575 | } |
|---|
| 4576 | else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
|---|
| 4577 | { |
|---|
| 4578 | } |
|---|
| 4579 | else |
|---|
| 4580 | { |
|---|
| 4581 | if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
|---|
| 4582 | ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
|---|
| 4583 | { |
|---|
| 4584 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; |
|---|
| 4585 | uiLCUIdx = getAddr(); |
|---|
| 4586 | } |
|---|
| 4587 | else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
|---|
| 4588 | { |
|---|
| 4589 | uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; |
|---|
| 4590 | } |
|---|
| 4591 | else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
|---|
| 4592 | { |
|---|
| 4593 | uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; |
|---|
| 4594 | uiLCUIdx = getAddr() + 1; |
|---|
| 4595 | } |
|---|
| 4596 | else //is the right bottom corner of LCU |
|---|
| 4597 | { |
|---|
| 4598 | uiAbsPartAddr = 0; |
|---|
| 4599 | } |
|---|
| 4600 | } |
|---|
| 4601 | if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col |
|---|
| 4602 | #if H_3D_TMVP |
|---|
| 4603 | , 0 |
|---|
| 4604 | #endif |
|---|
| 4605 | ) ) |
|---|
| 4606 | { |
|---|
| 4607 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
|---|
| 4608 | } |
|---|
| 4609 | else |
|---|
| 4610 | { |
|---|
| 4611 | UInt uiPartIdxCenter; |
|---|
| 4612 | UInt uiCurLCUIdx = getAddr(); |
|---|
| 4613 | xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); |
|---|
| 4614 | if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col |
|---|
| 4615 | #if H_3D_TMVP |
|---|
| 4616 | , 0 |
|---|
| 4617 | #endif |
|---|
| 4618 | )) |
|---|
| 4619 | { |
|---|
| 4620 | pInfo->m_acMvCand[pInfo->iN++] = cColMv; |
|---|
| 4621 | } |
|---|
| 4622 | } |
|---|
| 4623 | //---- co-located RightBottom Temporal Predictor ---// |
|---|
| 4624 | } |
|---|
| 4625 | |
|---|
| 4626 | if (pInfo->iN > AMVP_MAX_NUM_CANDS) |
|---|
| 4627 | { |
|---|
| 4628 | pInfo->iN = AMVP_MAX_NUM_CANDS; |
|---|
| 4629 | } |
|---|
| 4630 | while (pInfo->iN < AMVP_MAX_NUM_CANDS) |
|---|
| 4631 | { |
|---|
| 4632 | pInfo->m_acMvCand[pInfo->iN].set(0,0); |
|---|
| 4633 | pInfo->iN++; |
|---|
| 4634 | } |
|---|
| 4635 | return ; |
|---|
| 4636 | } |
|---|
| 4637 | |
|---|
| 4638 | Bool TComDataCU::isBipredRestriction(UInt puIdx) |
|---|
| 4639 | { |
|---|
| 4640 | Int width = 0; |
|---|
| 4641 | Int height = 0; |
|---|
| 4642 | UInt partAddr; |
|---|
| 4643 | |
|---|
| 4644 | getPartIndexAndSize( puIdx, partAddr, width, height ); |
|---|
| 4645 | if ( getWidth(0) == 8 && (width < 8 || height < 8) ) |
|---|
| 4646 | { |
|---|
| 4647 | return true; |
|---|
| 4648 | } |
|---|
| 4649 | return false; |
|---|
| 4650 | } |
|---|
| 4651 | |
|---|
| 4652 | Void TComDataCU::clipMv (TComMv& rcMv) |
|---|
| 4653 | { |
|---|
| 4654 | Int iMvShift = 2; |
|---|
| 4655 | #if H_3D_IC |
|---|
| 4656 | if( getSlice()->getIsDepth() ) |
|---|
| 4657 | iMvShift = 0; |
|---|
| 4658 | #endif |
|---|
| 4659 | Int iOffset = 8; |
|---|
| 4660 | Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset - m_uiCUPelX - 1 ) << iMvShift; |
|---|
| 4661 | Int iHorMin = ( -(Int)g_uiMaxCUWidth - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; |
|---|
| 4662 | |
|---|
| 4663 | Int iVerMax = ( m_pcSlice->getSPS()->getPicHeightInLumaSamples() + iOffset - m_uiCUPelY - 1 ) << iMvShift; |
|---|
| 4664 | Int iVerMin = ( -(Int)g_uiMaxCUHeight - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; |
|---|
| 4665 | |
|---|
| 4666 | rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); |
|---|
| 4667 | rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); |
|---|
| 4668 | } |
|---|
| 4669 | |
|---|
| 4670 | UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) |
|---|
| 4671 | { |
|---|
| 4672 | UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); |
|---|
| 4673 | |
|---|
| 4674 | UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; |
|---|
| 4675 | UInt uiCnt = 0; |
|---|
| 4676 | while( uiWidth ) |
|---|
| 4677 | { |
|---|
| 4678 | uiCnt++; |
|---|
| 4679 | uiWidth>>=1; |
|---|
| 4680 | } |
|---|
| 4681 | uiCnt-=2; |
|---|
| 4682 | return uiCnt > 6 ? 6 : uiCnt; |
|---|
| 4683 | } |
|---|
| 4684 | |
|---|
| 4685 | Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts ) |
|---|
| 4686 | { |
|---|
| 4687 | ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts); |
|---|
| 4688 | } |
|---|
| 4689 | |
|---|
| 4690 | /** Set a I_PCM flag for all sub-partitions of a partition. |
|---|
| 4691 | * \param bIpcmFlag I_PCM flag |
|---|
| 4692 | * \param uiAbsPartIdx patition index |
|---|
| 4693 | * \param uiDepth CU depth |
|---|
| 4694 | * \returns Void |
|---|
| 4695 | */ |
|---|
| 4696 | Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) |
|---|
| 4697 | { |
|---|
| 4698 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 4699 | |
|---|
| 4700 | memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); |
|---|
| 4701 | } |
|---|
| 4702 | |
|---|
| 4703 | /** Test whether the current block is skipped |
|---|
| 4704 | * \param uiPartIdx Block index |
|---|
| 4705 | * \returns Flag indicating whether the block is skipped |
|---|
| 4706 | */ |
|---|
| 4707 | Bool TComDataCU::isSkipped( UInt uiPartIdx ) |
|---|
| 4708 | { |
|---|
| 4709 | return ( getSkipFlag( uiPartIdx ) ); |
|---|
| 4710 | } |
|---|
| 4711 | |
|---|
| 4712 | // ==================================================================================================================== |
|---|
| 4713 | // Protected member functions |
|---|
| 4714 | // ==================================================================================================================== |
|---|
| 4715 | |
|---|
| 4716 | Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
|---|
| 4717 | { |
|---|
| 4718 | TComDataCU* pcTmpCU = NULL; |
|---|
| 4719 | UInt uiIdx; |
|---|
| 4720 | switch( eDir ) |
|---|
| 4721 | { |
|---|
| 4722 | case MD_LEFT: |
|---|
| 4723 | { |
|---|
| 4724 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
|---|
| 4725 | break; |
|---|
| 4726 | } |
|---|
| 4727 | case MD_ABOVE: |
|---|
| 4728 | { |
|---|
| 4729 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx ); |
|---|
| 4730 | break; |
|---|
| 4731 | } |
|---|
| 4732 | case MD_ABOVE_RIGHT: |
|---|
| 4733 | { |
|---|
| 4734 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
|---|
| 4735 | break; |
|---|
| 4736 | } |
|---|
| 4737 | case MD_BELOW_LEFT: |
|---|
| 4738 | { |
|---|
| 4739 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
|---|
| 4740 | break; |
|---|
| 4741 | } |
|---|
| 4742 | case MD_ABOVE_LEFT: |
|---|
| 4743 | { |
|---|
| 4744 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
|---|
| 4745 | break; |
|---|
| 4746 | } |
|---|
| 4747 | default: |
|---|
| 4748 | { |
|---|
| 4749 | break; |
|---|
| 4750 | } |
|---|
| 4751 | } |
|---|
| 4752 | |
|---|
| 4753 | if ( pcTmpCU == NULL ) |
|---|
| 4754 | { |
|---|
| 4755 | return false; |
|---|
| 4756 | } |
|---|
| 4757 | |
|---|
| 4758 | if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) |
|---|
| 4759 | { |
|---|
| 4760 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
|---|
| 4761 | |
|---|
| 4762 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
|---|
| 4763 | return true; |
|---|
| 4764 | } |
|---|
| 4765 | |
|---|
| 4766 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
|---|
| 4767 | if( eRefPicList == REF_PIC_LIST_0 ) |
|---|
| 4768 | { |
|---|
| 4769 | eRefPicList2nd = REF_PIC_LIST_1; |
|---|
| 4770 | } |
|---|
| 4771 | else if ( eRefPicList == REF_PIC_LIST_1) |
|---|
| 4772 | { |
|---|
| 4773 | eRefPicList2nd = REF_PIC_LIST_0; |
|---|
| 4774 | } |
|---|
| 4775 | |
|---|
| 4776 | |
|---|
| 4777 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
|---|
| 4778 | Int iNeibRefPOC; |
|---|
| 4779 | |
|---|
| 4780 | |
|---|
| 4781 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 ) |
|---|
| 4782 | { |
|---|
| 4783 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
|---|
| 4784 | if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List// |
|---|
| 4785 | { |
|---|
| 4786 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
|---|
| 4787 | pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; |
|---|
| 4788 | return true; |
|---|
| 4789 | } |
|---|
| 4790 | } |
|---|
| 4791 | return false; |
|---|
| 4792 | } |
|---|
| 4793 | |
|---|
| 4794 | /** |
|---|
| 4795 | * \param pInfo |
|---|
| 4796 | * \param eRefPicList |
|---|
| 4797 | * \param iRefIdx |
|---|
| 4798 | * \param uiPartUnitIdx |
|---|
| 4799 | * \param eDir |
|---|
| 4800 | * \returns Bool |
|---|
| 4801 | */ |
|---|
| 4802 | Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir ) |
|---|
| 4803 | { |
|---|
| 4804 | TComDataCU* pcTmpCU = NULL; |
|---|
| 4805 | UInt uiIdx; |
|---|
| 4806 | switch( eDir ) |
|---|
| 4807 | { |
|---|
| 4808 | case MD_LEFT: |
|---|
| 4809 | { |
|---|
| 4810 | pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx); |
|---|
| 4811 | break; |
|---|
| 4812 | } |
|---|
| 4813 | case MD_ABOVE: |
|---|
| 4814 | { |
|---|
| 4815 | pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); |
|---|
| 4816 | break; |
|---|
| 4817 | } |
|---|
| 4818 | case MD_ABOVE_RIGHT: |
|---|
| 4819 | { |
|---|
| 4820 | pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx); |
|---|
| 4821 | break; |
|---|
| 4822 | } |
|---|
| 4823 | case MD_BELOW_LEFT: |
|---|
| 4824 | { |
|---|
| 4825 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx); |
|---|
| 4826 | break; |
|---|
| 4827 | } |
|---|
| 4828 | case MD_ABOVE_LEFT: |
|---|
| 4829 | { |
|---|
| 4830 | pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx); |
|---|
| 4831 | break; |
|---|
| 4832 | } |
|---|
| 4833 | default: |
|---|
| 4834 | { |
|---|
| 4835 | break; |
|---|
| 4836 | } |
|---|
| 4837 | } |
|---|
| 4838 | |
|---|
| 4839 | if ( pcTmpCU == NULL ) |
|---|
| 4840 | { |
|---|
| 4841 | return false; |
|---|
| 4842 | } |
|---|
| 4843 | |
|---|
| 4844 | RefPicList eRefPicList2nd = REF_PIC_LIST_0; |
|---|
| 4845 | if( eRefPicList == REF_PIC_LIST_0 ) |
|---|
| 4846 | { |
|---|
| 4847 | eRefPicList2nd = REF_PIC_LIST_1; |
|---|
| 4848 | } |
|---|
| 4849 | else if ( eRefPicList == REF_PIC_LIST_1) |
|---|
| 4850 | { |
|---|
| 4851 | eRefPicList2nd = REF_PIC_LIST_0; |
|---|
| 4852 | } |
|---|
| 4853 | |
|---|
| 4854 | Int iCurrPOC = m_pcSlice->getPOC(); |
|---|
| 4855 | Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC(); |
|---|
| 4856 | Int iNeibPOC = iCurrPOC; |
|---|
| 4857 | Int iNeibRefPOC; |
|---|
| 4858 | |
|---|
| 4859 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); |
|---|
| 4860 | Bool bIsNeibRefLongTerm = false; |
|---|
| 4861 | //--------------- V1 (END) ------------------// |
|---|
| 4862 | if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) |
|---|
| 4863 | { |
|---|
| 4864 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ); |
|---|
| 4865 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
|---|
| 4866 | TComMv rcMv; |
|---|
| 4867 | |
|---|
| 4868 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); |
|---|
| 4869 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
|---|
| 4870 | { |
|---|
| 4871 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
|---|
| 4872 | { |
|---|
| 4873 | rcMv = cMvPred; |
|---|
| 4874 | } |
|---|
| 4875 | else |
|---|
| 4876 | { |
|---|
| 4877 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
|---|
| 4878 | if ( iScale == 4096 ) |
|---|
| 4879 | { |
|---|
| 4880 | rcMv = cMvPred; |
|---|
| 4881 | } |
|---|
| 4882 | else |
|---|
| 4883 | { |
|---|
| 4884 | rcMv = cMvPred.scaleMv( iScale ); |
|---|
| 4885 | } |
|---|
| 4886 | } |
|---|
| 4887 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
|---|
| 4888 | return true; |
|---|
| 4889 | } |
|---|
| 4890 | } |
|---|
| 4891 | //---------------------- V2(END) --------------------// |
|---|
| 4892 | if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0) |
|---|
| 4893 | { |
|---|
| 4894 | iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ); |
|---|
| 4895 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx); |
|---|
| 4896 | TComMv rcMv; |
|---|
| 4897 | |
|---|
| 4898 | bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); |
|---|
| 4899 | if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) |
|---|
| 4900 | { |
|---|
| 4901 | if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) |
|---|
| 4902 | { |
|---|
| 4903 | rcMv = cMvPred; |
|---|
| 4904 | } |
|---|
| 4905 | else |
|---|
| 4906 | { |
|---|
| 4907 | Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); |
|---|
| 4908 | if ( iScale == 4096 ) |
|---|
| 4909 | { |
|---|
| 4910 | rcMv = cMvPred; |
|---|
| 4911 | } |
|---|
| 4912 | else |
|---|
| 4913 | { |
|---|
| 4914 | rcMv = cMvPred.scaleMv( iScale ); |
|---|
| 4915 | } |
|---|
| 4916 | } |
|---|
| 4917 | pInfo->m_acMvCand[ pInfo->iN++] = rcMv; |
|---|
| 4918 | return true; |
|---|
| 4919 | } |
|---|
| 4920 | } |
|---|
| 4921 | //---------------------- V3(END) --------------------// |
|---|
| 4922 | return false; |
|---|
| 4923 | } |
|---|
| 4924 | |
|---|
| 4925 | /** |
|---|
| 4926 | * \param eRefPicList |
|---|
| 4927 | * \param uiCUAddr |
|---|
| 4928 | * \param uiPartUnitIdx |
|---|
| 4929 | * \param riRefIdx |
|---|
| 4930 | * \returns Bool |
|---|
| 4931 | */ |
|---|
| 4932 | Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx |
|---|
| 4933 | #if H_3D_TMVP |
|---|
| 4934 | , Bool bMRG |
|---|
| 4935 | #endif |
|---|
| 4936 | ) |
|---|
| 4937 | { |
|---|
| 4938 | UInt uiAbsPartAddr = uiPartUnitIdx; |
|---|
| 4939 | |
|---|
| 4940 | RefPicList eColRefPicList; |
|---|
| 4941 | Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale; |
|---|
| 4942 | TComMv cColMv; |
|---|
| 4943 | |
|---|
| 4944 | // use coldir. |
|---|
| 4945 | #if H_MV |
|---|
| 4946 | TComPic *pColPic; |
|---|
| 4947 | if (getSlice()->getAltCollocatedIndicationFlag() ) |
|---|
| 4948 | { |
|---|
| 4949 | pColPic = getSlice()->getPicFromRefPicSetInterLayer( getSlice()->getActiveMotionPredRefLayerId( getSlice()->getCollocatedRefLayerIdx() )); |
|---|
| 4950 | } |
|---|
| 4951 | else |
|---|
| 4952 | { |
|---|
| 4953 | pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
|---|
| 4954 | } |
|---|
| 4955 | #else |
|---|
| 4956 | TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); |
|---|
| 4957 | #endif |
|---|
| 4958 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
|---|
| 4959 | if(pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE) |
|---|
| 4960 | { |
|---|
| 4961 | return false; |
|---|
| 4962 | } |
|---|
| 4963 | iCurrPOC = m_pcSlice->getPOC(); |
|---|
| 4964 | iColPOC = pColCU->getSlice()->getPOC(); |
|---|
| 4965 | |
|---|
| 4966 | if (pColCU->isIntra(uiAbsPartAddr)) |
|---|
| 4967 | { |
|---|
| 4968 | return false; |
|---|
| 4969 | } |
|---|
| 4970 | eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); |
|---|
| 4971 | |
|---|
| 4972 | Int iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
|---|
| 4973 | |
|---|
| 4974 | if (iColRefIdx < 0 ) |
|---|
| 4975 | { |
|---|
| 4976 | eColRefPicList = RefPicList(1 - eColRefPicList); |
|---|
| 4977 | iColRefIdx = pColCU->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); |
|---|
| 4978 | |
|---|
| 4979 | if (iColRefIdx < 0 ) |
|---|
| 4980 | { |
|---|
| 4981 | return false; |
|---|
| 4982 | } |
|---|
| 4983 | } |
|---|
| 4984 | |
|---|
| 4985 | // Scale the vector. |
|---|
| 4986 | iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); |
|---|
| 4987 | cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); |
|---|
| 4988 | |
|---|
| 4989 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
|---|
| 4990 | Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
|---|
| 4991 | Bool bIsColRefLongTerm = pColCU->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); |
|---|
| 4992 | |
|---|
| 4993 | if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) |
|---|
| 4994 | { |
|---|
| 4995 | #if H_3D_TMVP |
|---|
| 4996 | Int iAlterRefIdx = m_pcSlice->getAlterRefIdx(eRefPicList); |
|---|
| 4997 | if(bMRG && iAlterRefIdx > 0) |
|---|
| 4998 | { |
|---|
| 4999 | riRefIdx = iAlterRefIdx; |
|---|
| 5000 | bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); |
|---|
| 5001 | iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); |
|---|
| 5002 | assert(bIsCurrRefLongTerm == bIsColRefLongTerm); |
|---|
| 5003 | } |
|---|
| 5004 | else |
|---|
| 5005 | { |
|---|
| 5006 | #endif |
|---|
| 5007 | return false; |
|---|
| 5008 | #if H_3D_TMVP |
|---|
| 5009 | } |
|---|
| 5010 | #endif |
|---|
| 5011 | } |
|---|
| 5012 | |
|---|
| 5013 | if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) |
|---|
| 5014 | { |
|---|
| 5015 | #if H_3D_TMVP |
|---|
| 5016 | Int iCurrViewId = m_pcSlice->getViewIndex (); |
|---|
| 5017 | Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewIndex (); |
|---|
| 5018 | Int iColViewId = pColCU->getSlice()->getViewIndex(); |
|---|
| 5019 | Int iColRefViewId = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewIndex(); |
|---|
| 5020 | iScale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId ); |
|---|
| 5021 | if ( iScale != 4096 && m_pcSlice->getVPS()->getIvMvScalingFlag() ) |
|---|
| 5022 | { |
|---|
| 5023 | rcMv = cColMv.scaleMv( iScale ); |
|---|
| 5024 | } |
|---|
| 5025 | else |
|---|
| 5026 | { |
|---|
| 5027 | #endif |
|---|
| 5028 | rcMv = cColMv; |
|---|
| 5029 | #if H_3D_TMVP |
|---|
| 5030 | } |
|---|
| 5031 | #endif |
|---|
| 5032 | } |
|---|
| 5033 | else |
|---|
| 5034 | { |
|---|
| 5035 | iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC); |
|---|
| 5036 | if ( iScale == 4096 ) |
|---|
| 5037 | { |
|---|
| 5038 | rcMv = cColMv; |
|---|
| 5039 | } |
|---|
| 5040 | else |
|---|
| 5041 | { |
|---|
| 5042 | rcMv = cColMv.scaleMv( iScale ); |
|---|
| 5043 | } |
|---|
| 5044 | } |
|---|
| 5045 | return true; |
|---|
| 5046 | } |
|---|
| 5047 | |
|---|
| 5048 | UInt TComDataCU::xGetMvdBits(TComMv cMvd) |
|---|
| 5049 | { |
|---|
| 5050 | return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) ); |
|---|
| 5051 | } |
|---|
| 5052 | |
|---|
| 5053 | UInt TComDataCU::xGetComponentBits(Int iVal) |
|---|
| 5054 | { |
|---|
| 5055 | UInt uiLength = 1; |
|---|
| 5056 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
|---|
| 5057 | |
|---|
| 5058 | assert ( uiTemp ); |
|---|
| 5059 | |
|---|
| 5060 | while ( 1 != uiTemp ) |
|---|
| 5061 | { |
|---|
| 5062 | uiTemp >>= 1; |
|---|
| 5063 | uiLength += 2; |
|---|
| 5064 | } |
|---|
| 5065 | |
|---|
| 5066 | return uiLength; |
|---|
| 5067 | } |
|---|
| 5068 | |
|---|
| 5069 | |
|---|
| 5070 | Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) |
|---|
| 5071 | { |
|---|
| 5072 | Int iDiffPocD = iColPOC - iColRefPOC; |
|---|
| 5073 | Int iDiffPocB = iCurrPOC - iCurrRefPOC; |
|---|
| 5074 | |
|---|
| 5075 | if( iDiffPocD == iDiffPocB ) |
|---|
| 5076 | { |
|---|
| 5077 | return 4096; |
|---|
| 5078 | } |
|---|
| 5079 | else |
|---|
| 5080 | { |
|---|
| 5081 | Int iTDB = Clip3( -128, 127, iDiffPocB ); |
|---|
| 5082 | Int iTDD = Clip3( -128, 127, iDiffPocD ); |
|---|
| 5083 | Int iX = (0x4000 + abs(iTDD/2)) / iTDD; |
|---|
| 5084 | Int iScale = Clip3( -4096, 4095, (iTDB * iX + 32) >> 6 ); |
|---|
| 5085 | return iScale; |
|---|
| 5086 | } |
|---|
| 5087 | } |
|---|
| 5088 | |
|---|
| 5089 | /** |
|---|
| 5090 | * \param eCUMode |
|---|
| 5091 | * \param uiPartIdx |
|---|
| 5092 | * \param ruiPartIdxCenter |
|---|
| 5093 | * \returns Void |
|---|
| 5094 | */ |
|---|
| 5095 | Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) |
|---|
| 5096 | { |
|---|
| 5097 | UInt uiPartAddr; |
|---|
| 5098 | Int iPartWidth; |
|---|
| 5099 | Int iPartHeight; |
|---|
| 5100 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); |
|---|
| 5101 | |
|---|
| 5102 | ruiPartIdxCenter = m_uiAbsIdxInLCU+uiPartAddr; // partition origin. |
|---|
| 5103 | ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] |
|---|
| 5104 | + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInWidth() |
|---|
| 5105 | + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; |
|---|
| 5106 | } |
|---|
| 5107 | #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 |
|---|
| 5108 | Void TComDataCU::compressMV(int scale) |
|---|
| 5109 | #else |
|---|
| 5110 | Void TComDataCU::compressMV() |
|---|
| 5111 | #endif |
|---|
| 5112 | { |
|---|
| 5113 | #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 |
|---|
| 5114 | Int scaleFactor = (4 / scale ) * AMVP_DECIMATION_FACTOR / m_unitSize; |
|---|
| 5115 | #else |
|---|
| 5116 | Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; |
|---|
| 5117 | #endif |
|---|
| 5118 | if (scaleFactor > 0) |
|---|
| 5119 | { |
|---|
| 5120 | m_acCUMvField[0].compress(m_pePredMode, scaleFactor); |
|---|
| 5121 | m_acCUMvField[1].compress(m_pePredMode, scaleFactor); |
|---|
| 5122 | } |
|---|
| 5123 | } |
|---|
| 5124 | |
|---|
| 5125 | UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) |
|---|
| 5126 | { |
|---|
| 5127 | UInt uiCTXIdx; |
|---|
| 5128 | UInt uiScanIdx; |
|---|
| 5129 | UInt uiDirMode; |
|---|
| 5130 | |
|---|
| 5131 | if ( !bIsIntra ) |
|---|
| 5132 | { |
|---|
| 5133 | uiScanIdx = SCAN_DIAG; |
|---|
| 5134 | return uiScanIdx; |
|---|
| 5135 | } |
|---|
| 5136 | |
|---|
| 5137 | switch(uiWidth) |
|---|
| 5138 | { |
|---|
| 5139 | case 2: uiCTXIdx = 6; break; |
|---|
| 5140 | case 4: uiCTXIdx = 5; break; |
|---|
| 5141 | case 8: uiCTXIdx = 4; break; |
|---|
| 5142 | case 16: uiCTXIdx = 3; break; |
|---|
| 5143 | case 32: uiCTXIdx = 2; break; |
|---|
| 5144 | case 64: uiCTXIdx = 1; break; |
|---|
| 5145 | default: uiCTXIdx = 0; break; |
|---|
| 5146 | } |
|---|
| 5147 | |
|---|
| 5148 | if ( bIsLuma ) |
|---|
| 5149 | { |
|---|
| 5150 | uiDirMode = getLumaIntraDir(uiAbsPartIdx); |
|---|
| 5151 | #if H_3D_DIM |
|---|
| 5152 | mapDepthModeToIntraDir( uiDirMode ); |
|---|
| 5153 | #endif |
|---|
| 5154 | uiScanIdx = SCAN_DIAG; |
|---|
| 5155 | if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size |
|---|
| 5156 | { |
|---|
| 5157 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
|---|
| 5158 | } |
|---|
| 5159 | } |
|---|
| 5160 | else |
|---|
| 5161 | { |
|---|
| 5162 | uiDirMode = getChromaIntraDir(uiAbsPartIdx); |
|---|
| 5163 | if( uiDirMode == DM_CHROMA_IDX ) |
|---|
| 5164 | { |
|---|
| 5165 | // get number of partitions in current CU |
|---|
| 5166 | UInt depth = getDepth(uiAbsPartIdx); |
|---|
| 5167 | UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); |
|---|
| 5168 | |
|---|
| 5169 | // get luma mode from upper-left corner of current CU |
|---|
| 5170 | uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); |
|---|
| 5171 | #if H_3D_DIM |
|---|
| 5172 | mapDepthModeToIntraDir( uiDirMode ); |
|---|
| 5173 | #endif |
|---|
| 5174 | } |
|---|
| 5175 | uiScanIdx = SCAN_DIAG; |
|---|
| 5176 | if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size |
|---|
| 5177 | { |
|---|
| 5178 | uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); |
|---|
| 5179 | } |
|---|
| 5180 | } |
|---|
| 5181 | |
|---|
| 5182 | return uiScanIdx; |
|---|
| 5183 | } |
|---|
| 5184 | |
|---|
| 5185 | UInt TComDataCU::getSCUAddr() |
|---|
| 5186 | { |
|---|
| 5187 | return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; |
|---|
| 5188 | } |
|---|
| 5189 | |
|---|
| 5190 | /** Set neighboring blocks availabilities for non-deblocked filtering |
|---|
| 5191 | * \param numLCUInPicWidth number of LCUs in picture width |
|---|
| 5192 | * \param numLCUInPicHeight number of LCUs in picture height |
|---|
| 5193 | * \param numSUInLCUWidth number of SUs in LCU width |
|---|
| 5194 | * \param numSUInLCUHeight number of SUs in LCU height |
|---|
| 5195 | * \param picWidth picture width |
|---|
| 5196 | * \param picHeight picture height |
|---|
| 5197 | * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled |
|---|
| 5198 | * \param bTopTileBoundary true means that top boundary coincides tile boundary |
|---|
| 5199 | * \param bDownTileBoundary true means that bottom boundary coincides tile boundary |
|---|
| 5200 | * \param bLeftTileBoundary true means that left boundary coincides tile boundary |
|---|
| 5201 | * \param bRightTileBoundary true means that right boundary coincides tile boundary |
|---|
| 5202 | * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled |
|---|
| 5203 | */ |
|---|
| 5204 | Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt /*numLCUInPicHeight*/, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight |
|---|
| 5205 | ,std::vector<Bool>& LFCrossSliceBoundary |
|---|
| 5206 | ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary |
|---|
| 5207 | ,Bool bIndependentTileBoundaryEnabled) |
|---|
| 5208 | { |
|---|
| 5209 | UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight; |
|---|
| 5210 | Int* pSliceIDMapLCU = m_piSliceSUMap; |
|---|
| 5211 | Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1); |
|---|
| 5212 | UInt uiLPelX, uiTPelY; |
|---|
| 5213 | UInt width, height; |
|---|
| 5214 | Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary; |
|---|
| 5215 | Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false; |
|---|
| 5216 | Bool* pbAvailBorder; |
|---|
| 5217 | Bool* pbAvail; |
|---|
| 5218 | UInt rTLSU, rBRSU, widthSU, heightSU; |
|---|
| 5219 | UInt zRefSU; |
|---|
| 5220 | Int* pRefID; |
|---|
| 5221 | Int* pRefMapLCU; |
|---|
| 5222 | UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0; |
|---|
| 5223 | Int* pRRefMapLCU= NULL; |
|---|
| 5224 | Int* pLRefMapLCU= NULL; |
|---|
| 5225 | Int* pTRefMapLCU= NULL; |
|---|
| 5226 | Int* pBRefMapLCU= NULL; |
|---|
| 5227 | Int sliceID; |
|---|
| 5228 | UInt numSGU = (UInt)m_vNDFBlock.size(); |
|---|
| 5229 | |
|---|
| 5230 | for(Int i=0; i< numSGU; i++) |
|---|
| 5231 | { |
|---|
| 5232 | NDBFBlockInfo& rSGU = m_vNDFBlock[i]; |
|---|
| 5233 | |
|---|
| 5234 | sliceID = rSGU.sliceID; |
|---|
| 5235 | uiLPelX = rSGU.posX; |
|---|
| 5236 | uiTPelY = rSGU.posY; |
|---|
| 5237 | width = rSGU.width; |
|---|
| 5238 | height = rSGU.height; |
|---|
| 5239 | rTLSU = g_auiZscanToRaster[ rSGU.startSU ]; |
|---|
| 5240 | rBRSU = g_auiZscanToRaster[ rSGU.endSU ]; |
|---|
| 5241 | widthSU = rSGU.widthSU; |
|---|
| 5242 | heightSU = rSGU.heightSU; |
|---|
| 5243 | |
|---|
| 5244 | pbAvailBorder = rSGU.isBorderAvailable; |
|---|
| 5245 | |
|---|
| 5246 | bPicTBoundary= (uiTPelY == 0 )?(true):(false); |
|---|
| 5247 | bPicLBoundary= (uiLPelX == 0 )?(true):(false); |
|---|
| 5248 | bPicRBoundary= (!(uiLPelX+ width < picWidth ) )?(true):(false); |
|---|
| 5249 | bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false); |
|---|
| 5250 | |
|---|
| 5251 | bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false); |
|---|
| 5252 | bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false); |
|---|
| 5253 | bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false); |
|---|
| 5254 | bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false); |
|---|
| 5255 | |
|---|
| 5256 | // SGU_L |
|---|
| 5257 | pbAvail = &(pbAvailBorder[SGU_L]); |
|---|
| 5258 | if(bPicLBoundary) |
|---|
| 5259 | { |
|---|
| 5260 | *pbAvail = false; |
|---|
| 5261 | } |
|---|
| 5262 | else if (onlyOneSliceInPic) |
|---|
| 5263 | { |
|---|
| 5264 | *pbAvail = true; |
|---|
| 5265 | } |
|---|
| 5266 | else |
|---|
| 5267 | { |
|---|
| 5268 | // bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false); |
|---|
| 5269 | if(bLCULBoundary) |
|---|
| 5270 | { |
|---|
| 5271 | rLRefSU = rTLSU + numSUInLCUWidth -1; |
|---|
| 5272 | zRefSU = g_auiRasterToZscan[rLRefSU]; |
|---|
| 5273 | pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU); |
|---|
| 5274 | } |
|---|
| 5275 | else |
|---|
| 5276 | { |
|---|
| 5277 | zRefSU = g_auiRasterToZscan[rTLSU - 1]; |
|---|
| 5278 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 5279 | } |
|---|
| 5280 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 5281 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 5282 | } |
|---|
| 5283 | |
|---|
| 5284 | // SGU_R |
|---|
| 5285 | pbAvail = &(pbAvailBorder[SGU_R]); |
|---|
| 5286 | if(bPicRBoundary) |
|---|
| 5287 | { |
|---|
| 5288 | *pbAvail = false; |
|---|
| 5289 | } |
|---|
| 5290 | else if (onlyOneSliceInPic) |
|---|
| 5291 | { |
|---|
| 5292 | *pbAvail = true; |
|---|
| 5293 | } |
|---|
| 5294 | else |
|---|
| 5295 | { |
|---|
| 5296 | // bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false); |
|---|
| 5297 | if(bLCURBoundary) |
|---|
| 5298 | { |
|---|
| 5299 | rRRefSU = rTLSU + widthSU - numSUInLCUWidth; |
|---|
| 5300 | zRefSU = g_auiRasterToZscan[rRRefSU]; |
|---|
| 5301 | pRefMapLCU = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU); |
|---|
| 5302 | } |
|---|
| 5303 | else |
|---|
| 5304 | { |
|---|
| 5305 | zRefSU = g_auiRasterToZscan[rTLSU + widthSU]; |
|---|
| 5306 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 5307 | } |
|---|
| 5308 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 5309 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 5310 | } |
|---|
| 5311 | |
|---|
| 5312 | // SGU_T |
|---|
| 5313 | pbAvail = &(pbAvailBorder[SGU_T]); |
|---|
| 5314 | if(bPicTBoundary) |
|---|
| 5315 | { |
|---|
| 5316 | *pbAvail = false; |
|---|
| 5317 | } |
|---|
| 5318 | else if (onlyOneSliceInPic) |
|---|
| 5319 | { |
|---|
| 5320 | *pbAvail = true; |
|---|
| 5321 | } |
|---|
| 5322 | else |
|---|
| 5323 | { |
|---|
| 5324 | // bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false); |
|---|
| 5325 | if(bLCUTBoundary) |
|---|
| 5326 | { |
|---|
| 5327 | rTRefSU = numSUInLCU - (numSUInLCUWidth - rTLSU); |
|---|
| 5328 | zRefSU = g_auiRasterToZscan[rTRefSU]; |
|---|
| 5329 | pRefMapLCU = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU)); |
|---|
| 5330 | } |
|---|
| 5331 | else |
|---|
| 5332 | { |
|---|
| 5333 | zRefSU = g_auiRasterToZscan[rTLSU - numSUInLCUWidth]; |
|---|
| 5334 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 5335 | } |
|---|
| 5336 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 5337 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 5338 | } |
|---|
| 5339 | |
|---|
| 5340 | // SGU_B |
|---|
| 5341 | pbAvail = &(pbAvailBorder[SGU_B]); |
|---|
| 5342 | if(bPicBBoundary) |
|---|
| 5343 | { |
|---|
| 5344 | *pbAvail = false; |
|---|
| 5345 | } |
|---|
| 5346 | else if (onlyOneSliceInPic) |
|---|
| 5347 | { |
|---|
| 5348 | *pbAvail = true; |
|---|
| 5349 | } |
|---|
| 5350 | else |
|---|
| 5351 | { |
|---|
| 5352 | // bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false); |
|---|
| 5353 | if(bLCUBBoundary) |
|---|
| 5354 | { |
|---|
| 5355 | rBRefSU = rTLSU % numSUInLCUWidth; |
|---|
| 5356 | zRefSU = g_auiRasterToZscan[rBRefSU]; |
|---|
| 5357 | pRefMapLCU = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU)); |
|---|
| 5358 | } |
|---|
| 5359 | else |
|---|
| 5360 | { |
|---|
| 5361 | zRefSU = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)]; |
|---|
| 5362 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 5363 | } |
|---|
| 5364 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 5365 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 5366 | } |
|---|
| 5367 | |
|---|
| 5368 | // SGU_TL |
|---|
| 5369 | pbAvail = &(pbAvailBorder[SGU_TL]); |
|---|
| 5370 | if(bPicTBoundary || bPicLBoundary) |
|---|
| 5371 | { |
|---|
| 5372 | *pbAvail = false; |
|---|
| 5373 | } |
|---|
| 5374 | else if (onlyOneSliceInPic) |
|---|
| 5375 | { |
|---|
| 5376 | *pbAvail = true; |
|---|
| 5377 | } |
|---|
| 5378 | else |
|---|
| 5379 | { |
|---|
| 5380 | if(bLCUTBoundary && bLCULBoundary) |
|---|
| 5381 | { |
|---|
| 5382 | zRefSU = numSUInLCU -1; |
|---|
| 5383 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU); |
|---|
| 5384 | } |
|---|
| 5385 | else if(bLCUTBoundary) |
|---|
| 5386 | { |
|---|
| 5387 | zRefSU = g_auiRasterToZscan[ rTRefSU- 1]; |
|---|
| 5388 | pRefMapLCU = pTRefMapLCU; |
|---|
| 5389 | } |
|---|
| 5390 | else if(bLCULBoundary) |
|---|
| 5391 | { |
|---|
| 5392 | zRefSU = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ]; |
|---|
| 5393 | pRefMapLCU = pLRefMapLCU; |
|---|
| 5394 | } |
|---|
| 5395 | else //inside LCU |
|---|
| 5396 | { |
|---|
| 5397 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1]; |
|---|
| 5398 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 5399 | } |
|---|
| 5400 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 5401 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 5402 | } |
|---|
| 5403 | |
|---|
| 5404 | // SGU_TR |
|---|
| 5405 | pbAvail = &(pbAvailBorder[SGU_TR]); |
|---|
| 5406 | if(bPicTBoundary || bPicRBoundary) |
|---|
| 5407 | { |
|---|
| 5408 | *pbAvail = false; |
|---|
| 5409 | } |
|---|
| 5410 | else if (onlyOneSliceInPic) |
|---|
| 5411 | { |
|---|
| 5412 | *pbAvail = true; |
|---|
| 5413 | } |
|---|
| 5414 | else |
|---|
| 5415 | { |
|---|
| 5416 | if(bLCUTBoundary && bLCURBoundary) |
|---|
| 5417 | { |
|---|
| 5418 | zRefSU = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth]; |
|---|
| 5419 | pRefMapLCU = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU); |
|---|
| 5420 | } |
|---|
| 5421 | else if(bLCUTBoundary) |
|---|
| 5422 | { |
|---|
| 5423 | zRefSU = g_auiRasterToZscan[ rTRefSU+ widthSU]; |
|---|
| 5424 | pRefMapLCU = pTRefMapLCU; |
|---|
| 5425 | } |
|---|
| 5426 | else if(bLCURBoundary) |
|---|
| 5427 | { |
|---|
| 5428 | zRefSU = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ]; |
|---|
| 5429 | pRefMapLCU = pRRefMapLCU; |
|---|
| 5430 | } |
|---|
| 5431 | else //inside LCU |
|---|
| 5432 | { |
|---|
| 5433 | zRefSU = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU]; |
|---|
| 5434 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 5435 | } |
|---|
| 5436 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 5437 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 5438 | } |
|---|
| 5439 | |
|---|
| 5440 | // SGU_BL |
|---|
| 5441 | pbAvail = &(pbAvailBorder[SGU_BL]); |
|---|
| 5442 | if(bPicBBoundary || bPicLBoundary) |
|---|
| 5443 | { |
|---|
| 5444 | *pbAvail = false; |
|---|
| 5445 | } |
|---|
| 5446 | else if (onlyOneSliceInPic) |
|---|
| 5447 | { |
|---|
| 5448 | *pbAvail = true; |
|---|
| 5449 | } |
|---|
| 5450 | else |
|---|
| 5451 | { |
|---|
| 5452 | if(bLCUBBoundary && bLCULBoundary) |
|---|
| 5453 | { |
|---|
| 5454 | zRefSU = g_auiRasterToZscan[numSUInLCUWidth - 1]; |
|---|
| 5455 | pRefMapLCU = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU); |
|---|
| 5456 | } |
|---|
| 5457 | else if(bLCUBBoundary) |
|---|
| 5458 | { |
|---|
| 5459 | zRefSU = g_auiRasterToZscan[ rBRefSU - 1]; |
|---|
| 5460 | pRefMapLCU = pBRefMapLCU; |
|---|
| 5461 | } |
|---|
| 5462 | else if(bLCULBoundary) |
|---|
| 5463 | { |
|---|
| 5464 | zRefSU = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ]; |
|---|
| 5465 | pRefMapLCU = pLRefMapLCU; |
|---|
| 5466 | } |
|---|
| 5467 | else //inside LCU |
|---|
| 5468 | { |
|---|
| 5469 | zRefSU = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1]; |
|---|
| 5470 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 5471 | } |
|---|
| 5472 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 5473 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 5474 | } |
|---|
| 5475 | |
|---|
| 5476 | // SGU_BR |
|---|
| 5477 | pbAvail = &(pbAvailBorder[SGU_BR]); |
|---|
| 5478 | if(bPicBBoundary || bPicRBoundary) |
|---|
| 5479 | { |
|---|
| 5480 | *pbAvail = false; |
|---|
| 5481 | } |
|---|
| 5482 | else if (onlyOneSliceInPic) |
|---|
| 5483 | { |
|---|
| 5484 | *pbAvail = true; |
|---|
| 5485 | } |
|---|
| 5486 | else |
|---|
| 5487 | { |
|---|
| 5488 | if(bLCUBBoundary && bLCURBoundary) |
|---|
| 5489 | { |
|---|
| 5490 | zRefSU = 0; |
|---|
| 5491 | pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU); |
|---|
| 5492 | } |
|---|
| 5493 | else if(bLCUBBoundary) |
|---|
| 5494 | { |
|---|
| 5495 | zRefSU = g_auiRasterToZscan[ rBRefSU + widthSU]; |
|---|
| 5496 | pRefMapLCU = pBRefMapLCU; |
|---|
| 5497 | } |
|---|
| 5498 | else if(bLCURBoundary) |
|---|
| 5499 | { |
|---|
| 5500 | zRefSU = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)]; |
|---|
| 5501 | pRefMapLCU = pRRefMapLCU; |
|---|
| 5502 | } |
|---|
| 5503 | else //inside LCU |
|---|
| 5504 | { |
|---|
| 5505 | zRefSU = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU]; |
|---|
| 5506 | pRefMapLCU = pSliceIDMapLCU; |
|---|
| 5507 | } |
|---|
| 5508 | pRefID = pRefMapLCU + zRefSU; |
|---|
| 5509 | *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID])); |
|---|
| 5510 | } |
|---|
| 5511 | |
|---|
| 5512 | if(bIndependentTileBoundaryEnabled) |
|---|
| 5513 | { |
|---|
| 5514 | //left LCU boundary |
|---|
| 5515 | if(!bPicLBoundary && bLCULBoundary) |
|---|
| 5516 | { |
|---|
| 5517 | if(bLeftTileBoundary) |
|---|
| 5518 | { |
|---|
| 5519 | pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false; |
|---|
| 5520 | } |
|---|
| 5521 | } |
|---|
| 5522 | //right LCU boundary |
|---|
| 5523 | if(!bPicRBoundary && bLCURBoundary) |
|---|
| 5524 | { |
|---|
| 5525 | if(bRightTileBoundary) |
|---|
| 5526 | { |
|---|
| 5527 | pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false; |
|---|
| 5528 | } |
|---|
| 5529 | } |
|---|
| 5530 | //top LCU boundary |
|---|
| 5531 | if(!bPicTBoundary && bLCUTBoundary) |
|---|
| 5532 | { |
|---|
| 5533 | if(bTopTileBoundary) |
|---|
| 5534 | { |
|---|
| 5535 | pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false; |
|---|
| 5536 | } |
|---|
| 5537 | } |
|---|
| 5538 | //down LCU boundary |
|---|
| 5539 | if(!bPicBBoundary && bLCUBBoundary) |
|---|
| 5540 | { |
|---|
| 5541 | if(bDownTileBoundary) |
|---|
| 5542 | { |
|---|
| 5543 | pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false; |
|---|
| 5544 | } |
|---|
| 5545 | } |
|---|
| 5546 | } |
|---|
| 5547 | rSGU.allBordersAvailable = true; |
|---|
| 5548 | for(Int b=0; b< NUM_SGU_BORDER; b++) |
|---|
| 5549 | { |
|---|
| 5550 | if(pbAvailBorder[b] == false) |
|---|
| 5551 | { |
|---|
| 5552 | rSGU.allBordersAvailable = false; |
|---|
| 5553 | break; |
|---|
| 5554 | } |
|---|
| 5555 | } |
|---|
| 5556 | } |
|---|
| 5557 | } |
|---|
| 5558 | |
|---|
| 5559 | #if H_3D |
|---|
| 5560 | Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) |
|---|
| 5561 | { |
|---|
| 5562 | riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX(); |
|---|
| 5563 | riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY(); |
|---|
| 5564 | } |
|---|
| 5565 | #endif |
|---|
| 5566 | #if H_3D_NBDV |
|---|
| 5567 | //Notes from QC: |
|---|
| 5568 | //TBD#1: DoNBDV related contributions are just partially integrated under the marco of H_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done |
|---|
| 5569 | //TBD#2: set of DvMCP values need to be done as part of inter-view motion prediction process. Remove this comment once merge related integration is done |
|---|
| 5570 | //To be checked: Parallel Merge features for NBDV, related to DV_DERIVATION_PARALLEL_B0096 and LGE_IVMP_PARALLEL_MERGE_B0136 are not integrated. The need of these features due to the adoption of CU-based NBDV is not clear. We need confirmation on this, especially by proponents |
|---|
| 5571 | Bool TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo |
|---|
| 5572 | #if H_3D_NBDV_REF |
|---|
| 5573 | , Bool bDepthRefine |
|---|
| 5574 | #endif |
|---|
| 5575 | ) |
|---|
| 5576 | { |
|---|
| 5577 | //// ******* Init variables ******* ///// |
|---|
| 5578 | // Init disparity struct for results |
|---|
| 5579 | pDInfo->bDV = false; |
|---|
| 5580 | // Init struct for disparities from MCP neighboring blocks |
|---|
| 5581 | IDVInfo cIDVInfo; |
|---|
| 5582 | cIDVInfo.m_bFound = false; |
|---|
| 5583 | UInt uiPartIdx = 0; |
|---|
| 5584 | UInt uiPartAddr = 0; |
|---|
| 5585 | for (UInt iCurDvMcpCand = 0; iCurDvMcpCand < IDV_CANDS; iCurDvMcpCand++) |
|---|
| 5586 | { |
|---|
| 5587 | for (UInt iList = 0; iList < 2; iList++) |
|---|
| 5588 | { |
|---|
| 5589 | cIDVInfo.m_acMvCand[iList][iCurDvMcpCand].setZero(); |
|---|
| 5590 | cIDVInfo.m_aVIdxCan[iList][iCurDvMcpCand] = 0; |
|---|
| 5591 | cIDVInfo.m_bAvailab[iList][iCurDvMcpCand] = false; |
|---|
| 5592 | } |
|---|
| 5593 | } |
|---|
| 5594 | #if H_3D_NBDV_REF |
|---|
| 5595 | if( !m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ) ) |
|---|
| 5596 | { |
|---|
| 5597 | bDepthRefine = false; |
|---|
| 5598 | } |
|---|
| 5599 | #endif |
|---|
| 5600 | // Get Positions |
|---|
| 5601 | PartSize eCUMode = getPartitionSize( uiPartAddr ); |
|---|
| 5602 | assert(eCUMode == SIZE_2Nx2N); |
|---|
| 5603 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
|---|
| 5604 | |
|---|
| 5605 | deriveLeftRightTopIdxGeneral(uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT ); |
|---|
| 5606 | deriveLeftBottomIdxGeneral (uiPartAddr, uiPartIdx, uiPartIdxLB ); |
|---|
| 5607 | |
|---|
| 5608 | //// ******* Get disparity from temporal neighboring blocks ******* ///// |
|---|
| 5609 | if ( getSlice()->getEnableTMVPFlag() ) |
|---|
| 5610 | { |
|---|
| 5611 | TComMv cColMv; |
|---|
| 5612 | Int iTargetViewIdx = 0; |
|---|
| 5613 | Int iTStartViewIdx = 0; |
|---|
| 5614 | |
|---|
| 5615 | ///*** Derive center position *** |
|---|
| 5616 | UInt uiPartIdxCenter; |
|---|
| 5617 | Int uiLCUIdx = getAddr(); |
|---|
| 5618 | xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter ); |
|---|
| 5619 | |
|---|
| 5620 | ///*** Derive bottom right neighbour position *** |
|---|
| 5621 | #if !SEC_SIMPLIFIED_NBDV_E0142 |
|---|
| 5622 | Int iLCUIdxRBNb = -1; |
|---|
| 5623 | Int iPartIdxRBNb = -1; |
|---|
| 5624 | xDeriveRightBottomNbIdx(iLCUIdxRBNb, iPartIdxRBNb ); |
|---|
| 5625 | #endif |
|---|
| 5626 | |
|---|
| 5627 | ///*** Search temporal candidate pictures for disparity vector *** |
|---|
| 5628 | const Int iNumCandPics = getPic()->getNumDdvCandPics(); |
|---|
| 5629 | for(Int curCandPic = 0; curCandPic < iNumCandPics; curCandPic++) |
|---|
| 5630 | { |
|---|
| 5631 | RefPicList eCurRefPicList = REF_PIC_LIST_0 ; |
|---|
| 5632 | Int curCandPicRefIdx = 0; |
|---|
| 5633 | if( curCandPic == 0 ) |
|---|
| 5634 | { |
|---|
| 5635 | eCurRefPicList = RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0); |
|---|
| 5636 | curCandPicRefIdx = getSlice()->getColRefIdx(); |
|---|
| 5637 | } |
|---|
| 5638 | else |
|---|
| 5639 | { |
|---|
| 5640 | eCurRefPicList = getPic()->getRapRefList(); |
|---|
| 5641 | curCandPicRefIdx = getPic()->getRapRefIdx(); |
|---|
| 5642 | } |
|---|
| 5643 | |
|---|
| 5644 | #if !SEC_SIMPLIFIED_NBDV_E0142 |
|---|
| 5645 | // Check BR and Center |
|---|
| 5646 | for(Int curPosition = 0; curPosition < 2; curPosition++) |
|---|
| 5647 | { |
|---|
| 5648 | #endif |
|---|
| 5649 | Bool bCheck = false; |
|---|
| 5650 | #if !SEC_SIMPLIFIED_NBDV_E0142 |
|---|
| 5651 | if ( curPosition == 0 && iLCUIdxRBNb >= 0 ) |
|---|
| 5652 | #if MTK_NBDV_TN_FIX_E0172 |
|---|
| 5653 | bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, iLCUIdxRBNb, iPartIdxRBNb, cColMv, iTargetViewIdx, iTStartViewIdx); |
|---|
| 5654 | #else |
|---|
| 5655 | bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, iLCUIdxRBNb, iPartIdxRBNb, cColMv, iTargetViewIdx, iTStartViewIdx); |
|---|
| 5656 | #endif |
|---|
| 5657 | |
|---|
| 5658 | if (curPosition == 1 ) |
|---|
| 5659 | #endif |
|---|
| 5660 | #if MTK_NBDV_TN_FIX_E0172 |
|---|
| 5661 | bCheck = xGetColDisMV( curCandPic, eCurRefPicList, curCandPicRefIdx, uiLCUIdx, uiPartIdxCenter, cColMv, iTargetViewIdx, iTStartViewIdx ); |
|---|
| 5662 | #else |
|---|
| 5663 | bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, uiLCUIdx, uiPartIdxCenter, cColMv, iTargetViewIdx, iTStartViewIdx ); |
|---|
| 5664 | #endif |
|---|
| 5665 | |
|---|
| 5666 | if( bCheck ) |
|---|
| 5667 | { |
|---|
| 5668 | clipMv(cColMv); |
|---|
| 5669 | pDInfo->m_acNBDV = cColMv; |
|---|
| 5670 | pDInfo->m_aVIdxCan = iTargetViewIdx; |
|---|
| 5671 | |
|---|
| 5672 | #if H_3D_NBDV_REF |
|---|
| 5673 | TComPic* picDepth = NULL; |
|---|
| 5674 | picDepth = getSlice()->getIvPic( true, iTargetViewIdx ); |
|---|
| 5675 | assert(picDepth != NULL); |
|---|
| 5676 | if (picDepth && bDepthRefine) |
|---|
| 5677 | estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv ); |
|---|
| 5678 | |
|---|
| 5679 | pDInfo->m_acDoNBDV = cColMv; |
|---|
| 5680 | #endif //H_3D_NBDV_REF |
|---|
| 5681 | return true; |
|---|
| 5682 | } |
|---|
| 5683 | #if !SEC_SIMPLIFIED_NBDV_E0142 |
|---|
| 5684 | } |
|---|
| 5685 | #endif |
|---|
| 5686 | } |
|---|
| 5687 | } |
|---|
| 5688 | |
|---|
| 5689 | UInt uiIdx = 0; |
|---|
| 5690 | Bool bCheckMcpDv = false; |
|---|
| 5691 | TComDataCU* pcTmpCU = NULL; |
|---|
| 5692 | |
|---|
| 5693 | //// ******* Get disparity from left block ******* ///// |
|---|
| 5694 | pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false); |
|---|
| 5695 | bCheckMcpDv = true; |
|---|
| 5696 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT |
|---|
| 5697 | #if H_3D_NBDV_REF |
|---|
| 5698 | , bDepthRefine |
|---|
| 5699 | #endif |
|---|
| 5700 | ) ) |
|---|
| 5701 | return true; |
|---|
| 5702 | |
|---|
| 5703 | //// ******* Get disparity from above block ******* ///// |
|---|
| 5704 | pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true); |
|---|
| 5705 | if(pcTmpCU != NULL ) |
|---|
| 5706 | { |
|---|
| 5707 | bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0); |
|---|
| 5708 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE |
|---|
| 5709 | #if H_3D_NBDV_REF |
|---|
| 5710 | , bDepthRefine |
|---|
| 5711 | #endif |
|---|
| 5712 | ) ) |
|---|
| 5713 | return true; |
|---|
| 5714 | } |
|---|
| 5715 | |
|---|
| 5716 | #if !SEC_SIMPLIFIED_NBDV_E0142 |
|---|
| 5717 | //// ******* Get disparity from above right block ******* ///// |
|---|
| 5718 | pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true); |
|---|
| 5719 | if(pcTmpCU != NULL ) |
|---|
| 5720 | { |
|---|
| 5721 | bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0); |
|---|
| 5722 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVERIGHT |
|---|
| 5723 | #if H_3D_NBDV_REF |
|---|
| 5724 | , bDepthRefine |
|---|
| 5725 | #endif |
|---|
| 5726 | ) ) |
|---|
| 5727 | return true; |
|---|
| 5728 | } |
|---|
| 5729 | |
|---|
| 5730 | //// ******* Get disparity from below left block ******* ///// |
|---|
| 5731 | pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true); |
|---|
| 5732 | if( pcTmpCU != NULL ) |
|---|
| 5733 | { |
|---|
| 5734 | bCheckMcpDv = true; |
|---|
| 5735 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFTBELOW |
|---|
| 5736 | #if H_3D_NBDV_REF |
|---|
| 5737 | , bDepthRefine |
|---|
| 5738 | #endif |
|---|
| 5739 | ) ) |
|---|
| 5740 | return true; |
|---|
| 5741 | } |
|---|
| 5742 | |
|---|
| 5743 | //// ******* Get disparity from above left block ******* ///// |
|---|
| 5744 | pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true); |
|---|
| 5745 | assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr)); |
|---|
| 5746 | |
|---|
| 5747 | if( pcTmpCU != NULL ) |
|---|
| 5748 | { |
|---|
| 5749 | bCheckMcpDv = (( getAddr() - pcTmpCU->getAddr() ) <= 1); |
|---|
| 5750 | if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVELEFT |
|---|
| 5751 | #if H_3D_NBDV_REF |
|---|
| 5752 | , bDepthRefine |
|---|
| 5753 | #endif |
|---|
| 5754 | ) ) |
|---|
| 5755 | return true; |
|---|
| 5756 | } |
|---|
| 5757 | #endif |
|---|
| 5758 | |
|---|
| 5759 | //// ******* Search MCP blocks ******* ///// |
|---|
| 5760 | if( cIDVInfo.m_bFound ) |
|---|
| 5761 | { |
|---|
| 5762 | for( Int curPos = 0 ; curPos < IDV_CANDS ; curPos++ ) |
|---|
| 5763 | { |
|---|
| 5764 | for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) |
|---|
| 5765 | { |
|---|
| 5766 | if( cIDVInfo.m_bAvailab[iList][curPos] ) |
|---|
| 5767 | { |
|---|
| 5768 | TComMv cDispVec = cIDVInfo.m_acMvCand[iList][ curPos ]; |
|---|
| 5769 | clipMv( cDispVec ); |
|---|
| 5770 | pDInfo->m_acNBDV = cDispVec; |
|---|
| 5771 | pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ]; |
|---|
| 5772 | #if !MTK_DVMCP_FIX_E0172 |
|---|
| 5773 | assert(pDInfo->m_aVIdxCan == 0); //Notes from QC: only works for CTC |
|---|
| 5774 | #endif |
|---|
| 5775 | #if H_3D_NBDV_REF |
|---|
| 5776 | TComPic* picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan ); |
|---|
| 5777 | assert(picDepth!=NULL); |
|---|
| 5778 | |
|---|
| 5779 | if (picDepth && bDepthRefine) |
|---|
| 5780 | { |
|---|
| 5781 | estimateDVFromDM (pDInfo->m_aVIdxCan, uiPartIdx, picDepth, uiPartAddr, &cDispVec); |
|---|
| 5782 | } |
|---|
| 5783 | pDInfo->m_acDoNBDV = cDispVec; |
|---|
| 5784 | #endif |
|---|
| 5785 | return true; |
|---|
| 5786 | } |
|---|
| 5787 | } |
|---|
| 5788 | } |
|---|
| 5789 | } |
|---|
| 5790 | |
|---|
| 5791 | TComMv defaultDV(0, 0); |
|---|
| 5792 | pDInfo->m_acNBDV = defaultDV; |
|---|
| 5793 | #if NBDV_DEFAULT_VIEWIDX_BUGFIX |
|---|
| 5794 | Int valid = 0; |
|---|
| 5795 | Int viewIndex = 0; |
|---|
| 5796 | for( UInt uiBId = 0; uiBId < getSlice()->getViewIndex() && valid==0; uiBId++ ) |
|---|
| 5797 | { |
|---|
| 5798 | UInt uiBaseId = uiBId; |
|---|
| 5799 | TComPic* pcBasePic = getSlice()->getIvPic( false, uiBaseId ); |
|---|
| 5800 | for( Int iRefListId = 0; ( iRefListId < (getSlice()->isInterB()? 2:1) ) && !getSlice()->isIntra() && valid==0; iRefListId++ ) |
|---|
| 5801 | { |
|---|
| 5802 | RefPicList eRefPicListTest = RefPicList( iRefListId ); |
|---|
| 5803 | Int iNumRefPics = getSlice()->getNumRefIdx( eRefPicListTest ) ; |
|---|
| 5804 | for( Int iRefIndex = 0; iRefIndex < iNumRefPics; iRefIndex++ ) |
|---|
| 5805 | { |
|---|
| 5806 | if(pcBasePic->getPOC() == getSlice()->getRefPic( eRefPicListTest, iRefIndex )->getPOC() |
|---|
| 5807 | && pcBasePic->getViewIndex() == getSlice()->getRefPic( eRefPicListTest, iRefIndex )->getViewIndex()) |
|---|
| 5808 | { |
|---|
| 5809 | valid=1; |
|---|
| 5810 | viewIndex = uiBaseId; |
|---|
| 5811 | break; |
|---|
| 5812 | } |
|---|
| 5813 | } |
|---|
| 5814 | } |
|---|
| 5815 | } |
|---|
| 5816 | if(valid) |
|---|
| 5817 | { |
|---|
| 5818 | pDInfo->m_aVIdxCan = viewIndex; |
|---|
| 5819 | #if H_3D_NBDV_REF |
|---|
| 5820 | TComPic* picDepth = NULL; |
|---|
| 5821 | picDepth = getSlice()->getIvPic( true, viewIndex ); |
|---|
| 5822 | assert(picDepth!=NULL); |
|---|
| 5823 | |
|---|
| 5824 | if (picDepth && bDepthRefine) |
|---|
| 5825 | { |
|---|
| 5826 | estimateDVFromDM(viewIndex, uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view |
|---|
| 5827 | } |
|---|
| 5828 | pDInfo->m_acDoNBDV = defaultDV; |
|---|
| 5829 | #endif |
|---|
| 5830 | } |
|---|
| 5831 | #else |
|---|
| 5832 | pDInfo->m_aVIdxCan = 0; |
|---|
| 5833 | #if H_3D_NBDV_REF |
|---|
| 5834 | TComPic* picDepth = NULL; |
|---|
| 5835 | picDepth = getSlice()->getIvPic( true, 0 ); |
|---|
| 5836 | assert(picDepth!=NULL); |
|---|
| 5837 | |
|---|
| 5838 | if (picDepth && bDepthRefine) |
|---|
| 5839 | { |
|---|
| 5840 | estimateDVFromDM(0, uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view |
|---|
| 5841 | } |
|---|
| 5842 | pDInfo->m_acDoNBDV = defaultDV; |
|---|
| 5843 | #endif |
|---|
| 5844 | #endif |
|---|
| 5845 | return false; |
|---|
| 5846 | } |
|---|
| 5847 | |
|---|
| 5848 | #if H_3D_NBDV_REF |
|---|
| 5849 | Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT ) |
|---|
| 5850 | { |
|---|
| 5851 | Int iPictureWidth = pcBaseViewDepthPicYuv->getWidth(); |
|---|
| 5852 | Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(); |
|---|
| 5853 | |
|---|
| 5854 | #if NTT_DoNBDV_VECTOR_CLIP_E0141 |
|---|
| 5855 | Int depthStartPosX = Clip3(0, iPictureWidth - 1, iBlkX + ((mv->getHor()+2)>>2)); |
|---|
| 5856 | Int depthStartPosY = Clip3(0, iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2)); |
|---|
| 5857 | Int depthEndPosX = Clip3(0, iPictureWidth - 1, iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2)); |
|---|
| 5858 | Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2)); |
|---|
| 5859 | #else |
|---|
| 5860 | Int depthStartPosX = Clip3(0, iPictureWidth - iBlkWidth, iBlkX + ((mv->getHor()+2)>>2)); |
|---|
| 5861 | Int depthStartPosY = Clip3(0, iPictureHeight- iBlkHeight, iBlkY + ((mv->getVer()+2)>>2)); |
|---|
| 5862 | Int depthEndPosX = Clip3(0, iPictureWidth - 1, iBlkX + iBlkWidth - 1 + ((mv->getHor()+2)>>2)); |
|---|
| 5863 | Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2)); |
|---|
| 5864 | #endif |
|---|
| 5865 | |
|---|
| 5866 | Pel* depthTL = pcBaseViewDepthPicYuv->getLumaAddr(); |
|---|
| 5867 | Int depStride = pcBaseViewDepthPicYuv->getStride(); |
|---|
| 5868 | |
|---|
| 5869 | Pel maxDepthVal = 0; |
|---|
| 5870 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthStartPosX ]); // Left Top |
|---|
| 5871 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthStartPosX ]); // Left Bottom |
|---|
| 5872 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthStartPosY) * depStride + depthEndPosX ]); // Right Top |
|---|
| 5873 | maxDepthVal = std::max( maxDepthVal, depthTL[ (depthEndPosY) * depStride + depthEndPosX ]); // Right Bottom |
|---|
| 5874 | |
|---|
| 5875 | return aiShiftLUT[ maxDepthVal ]; |
|---|
| 5876 | } |
|---|
| 5877 | |
|---|
| 5878 | Void TComDataCU::estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred ) |
|---|
| 5879 | { |
|---|
| 5880 | if (picDepth) |
|---|
| 5881 | { |
|---|
| 5882 | UInt uiAbsPartAddrCurrCU = m_uiAbsIdxInLCU + uiPartAddr; |
|---|
| 5883 | Int iWidth, iHeight; |
|---|
| 5884 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more |
|---|
| 5885 | |
|---|
| 5886 | TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec(); |
|---|
| 5887 | Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; |
|---|
| 5888 | Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; |
|---|
| 5889 | |
|---|
| 5890 | Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx ); |
|---|
| 5891 | |
|---|
| 5892 | Pel iDisp = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT ); |
|---|
| 5893 | cMvPred->setHor( iDisp ); |
|---|
| 5894 | clipMv(*cMvPred); |
|---|
| 5895 | } |
|---|
| 5896 | } |
|---|
| 5897 | #endif //H_3D_NBDV_REF |
|---|
| 5898 | |
|---|
| 5899 | |
|---|
| 5900 | Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos |
|---|
| 5901 | #if H_3D_NBDV_REF |
|---|
| 5902 | , Bool bDepthRefine |
|---|
| 5903 | #endif |
|---|
| 5904 | ) |
|---|
| 5905 | { |
|---|
| 5906 | if( pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) ) |
|---|
| 5907 | { |
|---|
| 5908 | Bool bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx ); |
|---|
| 5909 | for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++) |
|---|
| 5910 | { |
|---|
| 5911 | RefPicList eRefPicList = RefPicList(iList); |
|---|
| 5912 | Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ; |
|---|
| 5913 | TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); |
|---|
| 5914 | |
|---|
| 5915 | if( refId >= 0) |
|---|
| 5916 | { |
|---|
| 5917 | Int refViewIdx = pcTmpCU->getSlice()->getRefPic(eRefPicList, refId)->getViewIndex(); |
|---|
| 5918 | if (refViewIdx != m_pcSlice->getViewIndex()) |
|---|
| 5919 | { |
|---|
| 5920 | clipMv(cMvPred); |
|---|
| 5921 | pNbDvInfo->m_acNBDV = cMvPred; |
|---|
| 5922 | pNbDvInfo->m_aVIdxCan = refViewIdx; |
|---|
| 5923 | #if H_3D_NBDV_REF |
|---|
| 5924 | TComPic* picDepth = NULL; |
|---|
| 5925 | assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC()); |
|---|
| 5926 | picDepth = getSlice()->getIvPic (true, refViewIdx ); |
|---|
| 5927 | assert(picDepth != NULL); |
|---|
| 5928 | |
|---|
| 5929 | UInt uiPartIdx = 0; //Notes from MTK: Please confirm that using 0 as partition index and partition address is correct for CU-level DoNBDV |
|---|
| 5930 | UInt uiPartAddr = 0; //QC: confirmed |
|---|
| 5931 | |
|---|
| 5932 | if (picDepth && bDepthRefine) |
|---|
| 5933 | estimateDVFromDM(refViewIdx, uiPartIdx, picDepth, uiPartAddr, &cMvPred ); |
|---|
| 5934 | |
|---|
| 5935 | pNbDvInfo->m_acDoNBDV = cMvPred; |
|---|
| 5936 | #endif |
|---|
| 5937 | return true; |
|---|
| 5938 | } |
|---|
| 5939 | else if ( bSearchForMvpDv && cMvPred.getIDVFlag() && bTmpIsSkipped ) |
|---|
| 5940 | { |
|---|
| 5941 | assert( uiMvpDvPos < IDV_CANDS ); |
|---|
| 5942 | paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() ); |
|---|
| 5943 | //Notes from QC: DvMCP is implemented in a way that doesnE½t carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design. |
|---|
| 5944 | #if MTK_DVMCP_FIX_E0172 |
|---|
| 5945 | paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = cMvPred.getIDVVId(); |
|---|
| 5946 | #else |
|---|
| 5947 | paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = 0; |
|---|
| 5948 | #endif |
|---|
| 5949 | paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true; |
|---|
| 5950 | paIDVInfo->m_bFound = true; |
|---|
| 5951 | } |
|---|
| 5952 | } |
|---|
| 5953 | } |
|---|
| 5954 | } |
|---|
| 5955 | return false; |
|---|
| 5956 | } |
|---|
| 5957 | |
|---|
| 5958 | Void TComDataCU::xDeriveRightBottomNbIdx(Int &riLCUIdxRBNb, Int &riPartIdxRBNb ) |
|---|
| 5959 | { |
|---|
| 5960 | UInt uiPartIdx = 0; |
|---|
| 5961 | UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); |
|---|
| 5962 | Int uiLCUIdx = getAddr(); |
|---|
| 5963 | |
|---|
| 5964 | UInt uiPartIdxRB; |
|---|
| 5965 | deriveRightBottomIdx(uiPartIdx, uiPartIdxRB ); |
|---|
| 5966 | UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; |
|---|
| 5967 | |
|---|
| 5968 | if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) |
|---|
| 5969 | { |
|---|
| 5970 | riLCUIdxRBNb = -1; |
|---|
| 5971 | riPartIdxRBNb = -1; |
|---|
| 5972 | } |
|---|
| 5973 | else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
|---|
| 5974 | { |
|---|
| 5975 | riLCUIdxRBNb = -1; |
|---|
| 5976 | riPartIdxRBNb = -1; |
|---|
| 5977 | } |
|---|
| 5978 | else |
|---|
| 5979 | { |
|---|
| 5980 | if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU |
|---|
| 5981 | ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU |
|---|
| 5982 | { |
|---|
| 5983 | riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; |
|---|
| 5984 | riLCUIdxRBNb = uiLCUIdx; |
|---|
| 5985 | } |
|---|
| 5986 | else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU |
|---|
| 5987 | { |
|---|
| 5988 | riPartIdxRBNb = -1; |
|---|
| 5989 | riLCUIdxRBNb = -1; |
|---|
| 5990 | } |
|---|
| 5991 | else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU |
|---|
| 5992 | { |
|---|
| 5993 | riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; |
|---|
| 5994 | riLCUIdxRBNb = uiLCUIdx + 1; |
|---|
| 5995 | } |
|---|
| 5996 | else //is the right bottom corner of LCU |
|---|
| 5997 | { |
|---|
| 5998 | riPartIdxRBNb = -1; |
|---|
| 5999 | riLCUIdxRBNb = -1; |
|---|
| 6000 | } |
|---|
| 6001 | } |
|---|
| 6002 | } |
|---|
| 6003 | |
|---|
| 6004 | |
|---|
| 6005 | Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 6006 | { |
|---|
| 6007 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 6008 | for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
|---|
| 6009 | { |
|---|
| 6010 | m_pDvInfo[uiAbsPartIdx + ui] = cDvInfo; |
|---|
| 6011 | } |
|---|
| 6012 | } |
|---|
| 6013 | #if MTK_VSP_FIX_ALIGN_WD_E0172 |
|---|
| 6014 | Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth ) |
|---|
| 6015 | { |
|---|
| 6016 | setSubPartT<DisInfo>( cDvInfo, m_pDvInfo, uiAbsPartIdx, uiDepth, uiPUIdx ); |
|---|
| 6017 | } |
|---|
| 6018 | #endif |
|---|
| 6019 | #if MTK_NBDV_TN_FIX_E0172 |
|---|
| 6020 | Bool TComDataCU::xGetColDisMV( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx ) |
|---|
| 6021 | #else |
|---|
| 6022 | Bool TComDataCU::xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx ) |
|---|
| 6023 | #endif |
|---|
| 6024 | { |
|---|
| 6025 | |
|---|
| 6026 | RefPicList eColRefPicList = REF_PIC_LIST_0; |
|---|
| 6027 | Int iColViewIdx, iColRefViewIdx; |
|---|
| 6028 | TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx); |
|---|
| 6029 | TComDataCU *pColCU = pColPic->getCU( uiCUAddr ); |
|---|
| 6030 | iColViewIdx = pColCU->getSlice()->getViewIndex(); |
|---|
| 6031 | if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiPartUnitIdx)) |
|---|
| 6032 | { |
|---|
| 6033 | return false; |
|---|
| 6034 | } |
|---|
| 6035 | for (Int ilist = 0; ilist < (pColCU->getSlice()->isInterB()? 2:1); ilist++) |
|---|
| 6036 | { |
|---|
| 6037 | if(pColCU->getSlice()->isInterB()) |
|---|
| 6038 | { |
|---|
| 6039 | eColRefPicList = RefPicList(ilist); |
|---|
| 6040 | } |
|---|
| 6041 | |
|---|
| 6042 | Int iColRefIdx = pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiPartUnitIdx); |
|---|
| 6043 | |
|---|
| 6044 | if (iColRefIdx < 0) |
|---|
| 6045 | { |
|---|
| 6046 | continue; |
|---|
| 6047 | } |
|---|
| 6048 | |
|---|
| 6049 | iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewIndex(); |
|---|
| 6050 | |
|---|
| 6051 | if ( iColViewIdx == iColRefViewIdx ) // temporal vector |
|---|
| 6052 | { |
|---|
| 6053 | continue; |
|---|
| 6054 | } |
|---|
| 6055 | else |
|---|
| 6056 | { |
|---|
| 6057 | #if MTK_NBDV_TN_FIX_E0172 |
|---|
| 6058 | if(getPic()->isTempIVRefValid(currCandPic, ilist, iColRefIdx)) |
|---|
| 6059 | { |
|---|
| 6060 | #endif |
|---|
| 6061 | rcMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiPartUnitIdx); |
|---|
| 6062 | rcMv.setIDVFlag(0); |
|---|
| 6063 | iTargetViewIdx = iColRefViewIdx ; |
|---|
| 6064 | iStartViewIdx = iColViewIdx ; |
|---|
| 6065 | return true; |
|---|
| 6066 | #if MTK_NBDV_TN_FIX_E0172 |
|---|
| 6067 | } |
|---|
| 6068 | #endif |
|---|
| 6069 | } |
|---|
| 6070 | } |
|---|
| 6071 | |
|---|
| 6072 | return false; |
|---|
| 6073 | } |
|---|
| 6074 | #endif |
|---|
| 6075 | #if MTK_FAST_TEXTURE_ENCODING_E0173 |
|---|
| 6076 | Void |
|---|
| 6077 | TComDataCU::getIVNStatus ( UInt uiPartIdx, DisInfo* pDInfo, Bool& bIVFMerge, Int& iIVFMaxD) |
|---|
| 6078 | { |
|---|
| 6079 | TComSlice* pcSlice = getSlice (); |
|---|
| 6080 | Int iViewIndex = pDInfo->m_aVIdxCan; |
|---|
| 6081 | //--- get base CU/PU and check prediction mode --- |
|---|
| 6082 | TComPic* pcBasePic = pcSlice->getIvPic( false, iViewIndex ); |
|---|
| 6083 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
|---|
| 6084 | |
|---|
| 6085 | UInt uiPartAddr; |
|---|
| 6086 | Int iWidth; |
|---|
| 6087 | Int iHeight; |
|---|
| 6088 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
|---|
| 6089 | |
|---|
| 6090 | Int iCurrPosX, iCurrPosY; |
|---|
| 6091 | pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
|---|
| 6092 | |
|---|
| 6093 | iCurrPosX += ( ( iWidth - 1 ) >> 1 ); |
|---|
| 6094 | iCurrPosY += ( ( iHeight - 1 ) >> 1 ); |
|---|
| 6095 | |
|---|
| 6096 | Bool depthRefineFlag = false; |
|---|
| 6097 | #if H_3D_NBDV_REF |
|---|
| 6098 | depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ); |
|---|
| 6099 | #endif // H_3D_NBDV_REF |
|---|
| 6100 | |
|---|
| 6101 | TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
|---|
| 6102 | |
|---|
| 6103 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
|---|
| 6104 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
|---|
| 6105 | Int iBaseLPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX - (iWidth >> 1) + ( (cDv.getHor() + 2 ) >> 2 ) ); |
|---|
| 6106 | Int iBaseLPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
|---|
| 6107 | Int iBaseRPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + (iWidth >> 1) + 1 + ( (cDv.getHor() + 2 ) >> 2 ) ); |
|---|
| 6108 | Int iBaseRPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
|---|
| 6109 | Int iBaseUPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
|---|
| 6110 | Int iBaseUPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY - (iHeight >> 1) + ( (cDv.getVer() + 2 ) >> 2 )); |
|---|
| 6111 | Int iBaseDPosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
|---|
| 6112 | Int iBaseDPosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + (iHeight >> 1) + 1 + ( (cDv.getVer() + 2 ) >> 2 )); |
|---|
| 6113 | |
|---|
| 6114 | Int iBaseCUAddr; |
|---|
| 6115 | Int iBaseAbsPartIdx; |
|---|
| 6116 | Int iBaseLCUAddr; |
|---|
| 6117 | Int iBaseLAbsPartIdx; |
|---|
| 6118 | Int iBaseRCUAddr; |
|---|
| 6119 | Int iBaseRAbsPartIdx; |
|---|
| 6120 | Int iBaseUCUAddr; |
|---|
| 6121 | Int iBaseUAbsPartIdx; |
|---|
| 6122 | Int iBaseDCUAddr; |
|---|
| 6123 | Int iBaseDAbsPartIdx; |
|---|
| 6124 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
|---|
| 6125 | pcBaseRec->getCUAddrAndPartIdx( iBaseLPosX , iBaseLPosY , iBaseLCUAddr, iBaseLAbsPartIdx ); |
|---|
| 6126 | pcBaseRec->getCUAddrAndPartIdx( iBaseRPosX , iBaseRPosY , iBaseRCUAddr, iBaseRAbsPartIdx ); |
|---|
| 6127 | pcBaseRec->getCUAddrAndPartIdx( iBaseUPosX , iBaseUPosY , iBaseUCUAddr, iBaseUAbsPartIdx ); |
|---|
| 6128 | pcBaseRec->getCUAddrAndPartIdx( iBaseDPosX , iBaseDPosY , iBaseDCUAddr, iBaseDAbsPartIdx ); |
|---|
| 6129 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
|---|
| 6130 | TComDataCU* pcBaseLCU = pcBasePic->getCU( iBaseLCUAddr ); |
|---|
| 6131 | TComDataCU* pcBaseRCU = pcBasePic->getCU( iBaseRCUAddr ); |
|---|
| 6132 | TComDataCU* pcBaseUCU = pcBasePic->getCU( iBaseUCUAddr ); |
|---|
| 6133 | TComDataCU* pcBaseDCU = pcBasePic->getCU( iBaseDCUAddr ); |
|---|
| 6134 | bIVFMerge = pcBaseLCU->getMergeFlag( iBaseLAbsPartIdx ) && pcBaseCU->getMergeFlag( iBaseAbsPartIdx ) && pcBaseRCU->getMergeFlag( iBaseRAbsPartIdx ) && pcBaseUCU->getMergeFlag( iBaseUAbsPartIdx ) && pcBaseDCU->getMergeFlag( iBaseDAbsPartIdx ); |
|---|
| 6135 | Int aiDepthL[5]; //depth level |
|---|
| 6136 | aiDepthL[0] = pcBaseCU->getDepth(iBaseAbsPartIdx); |
|---|
| 6137 | aiDepthL[1] = pcBaseLCU->getDepth(iBaseLAbsPartIdx); |
|---|
| 6138 | aiDepthL[2] = pcBaseRCU->getDepth(iBaseRAbsPartIdx); |
|---|
| 6139 | aiDepthL[3] = pcBaseUCU->getDepth(iBaseUAbsPartIdx); |
|---|
| 6140 | aiDepthL[4] = pcBaseDCU->getDepth(iBaseDAbsPartIdx); |
|---|
| 6141 | for (Int i = 0; i < 5; i++) |
|---|
| 6142 | { |
|---|
| 6143 | if (iIVFMaxD < aiDepthL[i]) |
|---|
| 6144 | iIVFMaxD = aiDepthL[i]; |
|---|
| 6145 | } |
|---|
| 6146 | } |
|---|
| 6147 | #endif |
|---|
| 6148 | #if H_3D_IV_MERGE |
|---|
| 6149 | Bool |
|---|
| 6150 | TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc ) |
|---|
| 6151 | { |
|---|
| 6152 | TComSlice* pcSlice = getSlice (); |
|---|
| 6153 | Int iViewIndex = pDInfo->m_aVIdxCan; |
|---|
| 6154 | //--- get base CU/PU and check prediction mode --- |
|---|
| 6155 | TComPic* pcBasePic = pcSlice->getIvPic( false, iViewIndex ); |
|---|
| 6156 | TComPicYuv* pcBaseRec = pcBasePic->getPicYuvRec (); |
|---|
| 6157 | |
|---|
| 6158 | UInt uiPartAddr; |
|---|
| 6159 | Int iWidth; |
|---|
| 6160 | Int iHeight; |
|---|
| 6161 | getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); |
|---|
| 6162 | |
|---|
| 6163 | Int iCurrPosX, iCurrPosY; |
|---|
| 6164 | pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY ); |
|---|
| 6165 | |
|---|
| 6166 | iCurrPosX += ( ( iWidth - 1 ) >> 1 ); |
|---|
| 6167 | iCurrPosY += ( ( iHeight - 1 ) >> 1 ); |
|---|
| 6168 | |
|---|
| 6169 | Bool depthRefineFlag = false; |
|---|
| 6170 | #if H_3D_NBDV_REF |
|---|
| 6171 | depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() ); |
|---|
| 6172 | #endif // H_3D_NBDV_REF |
|---|
| 6173 | |
|---|
| 6174 | TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
|---|
| 6175 | |
|---|
| 6176 | #if !QC_INRIA_MTK_MRG_E0126 |
|---|
| 6177 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); |
|---|
| 6178 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); |
|---|
| 6179 | |
|---|
| 6180 | Int iBaseCUAddr; |
|---|
| 6181 | Int iBaseAbsPartIdx; |
|---|
| 6182 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
|---|
| 6183 | |
|---|
| 6184 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
|---|
| 6185 | #endif |
|---|
| 6186 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 6187 | Bool abPdmAvailable[8] = {false, false, false, false, false, false, false, false}; |
|---|
| 6188 | #else |
|---|
| 6189 | Bool abPdmAvailable[4] = {false, false, false, false}; |
|---|
| 6190 | #endif |
|---|
| 6191 | #if H_3D_NBDV |
|---|
| 6192 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 6193 | for( Int i = 0; i < 8; i++) |
|---|
| 6194 | #else |
|---|
| 6195 | for( Int i = 0; i < 4; i++) |
|---|
| 6196 | #endif |
|---|
| 6197 | { |
|---|
| 6198 | pacPdmMv[i].setIDVFlag (false); |
|---|
| 6199 | } |
|---|
| 6200 | #endif |
|---|
| 6201 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 6202 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
|---|
| 6203 | { |
|---|
| 6204 | Int iBaseCUAddr; |
|---|
| 6205 | Int iBaseAbsPartIdx; |
|---|
| 6206 | |
|---|
| 6207 | Int offsetW = (iLoopCan == 0) ? 0 : ( ((iWidth/2)*4) + 4 ); |
|---|
| 6208 | Int offsetH = (iLoopCan == 0) ? 0 : ( ((iHeight/2)*4) + 4 ); |
|---|
| 6209 | |
|---|
| 6210 | Int iBasePosX = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) ); |
|---|
| 6211 | Int iBasePosY = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); |
|---|
| 6212 | pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); |
|---|
| 6213 | |
|---|
| 6214 | TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr ); |
|---|
| 6215 | #endif |
|---|
| 6216 | if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) |
|---|
| 6217 | { |
|---|
| 6218 | for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ ) |
|---|
| 6219 | { |
|---|
| 6220 | RefPicList eCurrRefPicList = RefPicList( uiCurrRefListId ); |
|---|
| 6221 | |
|---|
| 6222 | Bool stopLoop = false; |
|---|
| 6223 | for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop) |
|---|
| 6224 | { |
|---|
| 6225 | RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 - uiCurrRefListId ) : RefPicList( uiCurrRefListId ); |
|---|
| 6226 | TComMvField cBaseMvField; |
|---|
| 6227 | pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField ); |
|---|
| 6228 | Int iBaseRefIdx = cBaseMvField.getRefIdx(); |
|---|
| 6229 | if (iBaseRefIdx >= 0) |
|---|
| 6230 | { |
|---|
| 6231 | Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx); |
|---|
| 6232 | if (iBaseRefPOC != pcSlice->getPOC()) |
|---|
| 6233 | { |
|---|
| 6234 | for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++) |
|---|
| 6235 | { |
|---|
| 6236 | if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx)) |
|---|
| 6237 | { |
|---|
| 6238 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 6239 | abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true; |
|---|
| 6240 | TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); |
|---|
| 6241 | #if H_3D_NBDV |
|---|
| 6242 | cMv.setIDVFlag (true); |
|---|
| 6243 | cMv.setIDVHor (cDv.getHor()); |
|---|
| 6244 | cMv.setIDVVer (cDv.getVer()); |
|---|
| 6245 | #if MTK_DVMCP_FIX_E0172 |
|---|
| 6246 | cMv.setIDVVId (iViewIndex); |
|---|
| 6247 | #endif |
|---|
| 6248 | #endif |
|---|
| 6249 | clipMv( cMv ); |
|---|
| 6250 | paiPdmRefIdx [ (uiCurrRefListId + (iLoopCan<<2)) ] = iPdmRefIdx; |
|---|
| 6251 | pacPdmMv [ (uiCurrRefListId + (iLoopCan<<2)) ] = cMv; |
|---|
| 6252 | #else |
|---|
| 6253 | abPdmAvailable[ uiCurrRefListId ] = true; |
|---|
| 6254 | TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); |
|---|
| 6255 | #if H_3D_NBDV |
|---|
| 6256 | cMv.setIDVFlag (true); |
|---|
| 6257 | cMv.setIDVHor (cDv.getHor()); |
|---|
| 6258 | cMv.setIDVVer (cDv.getVer()); |
|---|
| 6259 | #if MTK_DVMCP_FIX_E0172 |
|---|
| 6260 | cMv.setIDVVId (iViewIndex); |
|---|
| 6261 | #endif |
|---|
| 6262 | #endif |
|---|
| 6263 | clipMv( cMv ); |
|---|
| 6264 | paiPdmRefIdx [ uiCurrRefListId ] = iPdmRefIdx; |
|---|
| 6265 | pacPdmMv [ uiCurrRefListId ] = cMv; |
|---|
| 6266 | #endif |
|---|
| 6267 | stopLoop = true; |
|---|
| 6268 | break; |
|---|
| 6269 | } |
|---|
| 6270 | } |
|---|
| 6271 | } |
|---|
| 6272 | } |
|---|
| 6273 | } |
|---|
| 6274 | } |
|---|
| 6275 | } |
|---|
| 6276 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 6277 | } |
|---|
| 6278 | #endif |
|---|
| 6279 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 6280 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
|---|
| 6281 | { |
|---|
| 6282 | availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0); |
|---|
| 6283 | } |
|---|
| 6284 | #else |
|---|
| 6285 | availableMcDc[0] = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 ); |
|---|
| 6286 | #endif |
|---|
| 6287 | for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ ) |
|---|
| 6288 | { |
|---|
| 6289 | RefPicList eRefPicListDMV = RefPicList( iRefListId ); |
|---|
| 6290 | Int iNumRefPics = pcSlice->getNumRefIdx( eRefPicListDMV ); |
|---|
| 6291 | for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ ) |
|---|
| 6292 | { |
|---|
| 6293 | #if MTK_DIVMC_FIX_E0172 |
|---|
| 6294 | if(( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC()) && (pcSlice->getRefPic( eRefPicListDMV, iPdmRefIdx )->getViewIndex() == pDInfo->m_aVIdxCan)) |
|---|
| 6295 | #else |
|---|
| 6296 | if( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC()) |
|---|
| 6297 | #endif |
|---|
| 6298 | { |
|---|
| 6299 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 6300 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
|---|
| 6301 | { |
|---|
| 6302 | Int ioffsetDV = (iLoopCan == 0) ? 0 : 4; |
|---|
| 6303 | abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true; |
|---|
| 6304 | paiPdmRefIdx [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx; |
|---|
| 6305 | #if H_3D_NBDV_REF |
|---|
| 6306 | TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
|---|
| 6307 | #endif |
|---|
| 6308 | cMv.setHor( cMv.getHor() + ioffsetDV ); |
|---|
| 6309 | cMv.setVer( 0 ); |
|---|
| 6310 | clipMv( cMv ); |
|---|
| 6311 | pacPdmMv [iRefListId + 2 + (iLoopCan<<2)] = cMv; |
|---|
| 6312 | } |
|---|
| 6313 | break; |
|---|
| 6314 | #else |
|---|
| 6315 | abPdmAvailable[ iRefListId+2 ] = true; |
|---|
| 6316 | paiPdmRefIdx [ iRefListId+2 ] = iPdmRefIdx; |
|---|
| 6317 | |
|---|
| 6318 | #if H_3D_NBDV_REF |
|---|
| 6319 | TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; |
|---|
| 6320 | #endif // H_3D_NBDV_REF |
|---|
| 6321 | cMv.setVer(0); |
|---|
| 6322 | clipMv( cMv ); |
|---|
| 6323 | pacPdmMv [ iRefListId + 2] = cMv; |
|---|
| 6324 | break; |
|---|
| 6325 | #endif |
|---|
| 6326 | } |
|---|
| 6327 | } |
|---|
| 6328 | } |
|---|
| 6329 | #if QC_INRIA_MTK_MRG_E0126 |
|---|
| 6330 | for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) |
|---|
| 6331 | { |
|---|
| 6332 | availableMcDc[1 + (iLoopCan << 1)] = ( abPdmAvailable[2 + (iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[3 + (iLoopCan<<2)] ? 2 : 0 ); |
|---|
| 6333 | } |
|---|
| 6334 | #else |
|---|
| 6335 | availableMcDc[1] = ( abPdmAvailable[2] ? 1 : 0 ) + ( abPdmAvailable[3] ? 2 : 0 ); |
|---|
| 6336 | #endif |
|---|
| 6337 | return false; |
|---|
| 6338 | } |
|---|
| 6339 | #endif |
|---|
| 6340 | #if H_3D_ARP |
|---|
| 6341 | Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 6342 | { |
|---|
| 6343 | assert( sizeof( *m_puhARPW) == 1 ); |
|---|
| 6344 | memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); |
|---|
| 6345 | } |
|---|
| 6346 | #endif |
|---|
| 6347 | |
|---|
| 6348 | #if H_3D_IC |
|---|
| 6349 | Void TComDataCU::setICFlagSubParts( Bool bICFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
|---|
| 6350 | { |
|---|
| 6351 | memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ))*sizeof(Bool) ); |
|---|
| 6352 | } |
|---|
| 6353 | |
|---|
| 6354 | Bool TComDataCU::isICFlagRequired( UInt uiAbsPartIdx ) |
|---|
| 6355 | { |
|---|
| 6356 | UInt uiPartAddr; |
|---|
| 6357 | UInt iNumbPart; |
|---|
| 6358 | |
|---|
| 6359 | if( !( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ) |
|---|
| 6360 | { |
|---|
| 6361 | return false; |
|---|
| 6362 | } |
|---|
| 6363 | |
|---|
| 6364 | if( getSlice()->getIcSkipParseFlag() ) |
|---|
| 6365 | { |
|---|
| 6366 | if( getMergeFlag( uiAbsPartIdx ) && getMergeIndex( uiAbsPartIdx ) == 0 ) |
|---|
| 6367 | { |
|---|
| 6368 | return false; |
|---|
| 6369 | } |
|---|
| 6370 | } |
|---|
| 6371 | |
|---|
| 6372 | if( getMergeFlag( uiAbsPartIdx ) ) |
|---|
| 6373 | { |
|---|
| 6374 | return true; |
|---|
| 6375 | } |
|---|
| 6376 | |
|---|
| 6377 | |
|---|
| 6378 | Int iWidth, iHeight; |
|---|
| 6379 | |
|---|
| 6380 | iNumbPart = ( getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ? 1 : ( getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 ) ); |
|---|
| 6381 | |
|---|
| 6382 | for(UInt i = 0; i < iNumbPart; i++) |
|---|
| 6383 | { |
|---|
| 6384 | getPartIndexAndSize( i, uiPartAddr, iWidth, iHeight, uiAbsPartIdx, true ); |
|---|
| 6385 | uiPartAddr += uiAbsPartIdx; |
|---|
| 6386 | |
|---|
| 6387 | for(UInt uiRefIdx = 0; uiRefIdx < 2; uiRefIdx++) |
|---|
| 6388 | { |
|---|
| 6389 | RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
|---|
| 6390 | Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr); |
|---|
| 6391 | |
|---|
| 6392 | if( ( getInterDir( uiPartAddr ) & ( uiRefIdx+1 ) ) && iBestRefIdx >= 0 && getSlice()->getViewIndex() != getSlice()->getRefPic( eRefList, iBestRefIdx )->getViewIndex() ) |
|---|
| 6393 | { |
|---|
| 6394 | return true; |
|---|
| 6395 | } |
|---|
| 6396 | } |
|---|
| 6397 | } |
|---|
| 6398 | |
|---|
| 6399 | return false; |
|---|
| 6400 | } |
|---|
| 6401 | #endif |
|---|
| 6402 | #if H_3D_DIM_DMM |
|---|
| 6403 | Void TComDataCU::setDmmWedgeTabIdxSubParts( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 6404 | { |
|---|
| 6405 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 6406 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; } |
|---|
| 6407 | } |
|---|
| 6408 | #if !SEC_DMM2_E0146 |
|---|
| 6409 | Void TComDataCU::setDmm2DeltaEndSubParts( Int iDelta, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 6410 | { |
|---|
| 6411 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 6412 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm2DeltaEnd[uiAbsPartIdx+ui] = iDelta; } |
|---|
| 6413 | } |
|---|
| 6414 | #endif |
|---|
| 6415 | Void TComDataCU::setDmm3IntraTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 6416 | { |
|---|
| 6417 | UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); |
|---|
| 6418 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm3IntraTabIdx[uiAbsPartIdx+ui] = uiTIdx; } |
|---|
| 6419 | } |
|---|
| 6420 | #endif |
|---|
| 6421 | #if H_3D_DIM_RBC |
|---|
| 6422 | Void TComDataCU::reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion ) |
|---|
| 6423 | { |
|---|
| 6424 | Int iWidth; |
|---|
| 6425 | Int iHeight; |
|---|
| 6426 | if( uiDepth == 0 ) |
|---|
| 6427 | { |
|---|
| 6428 | iWidth = 64; |
|---|
| 6429 | iHeight = 64; |
|---|
| 6430 | } |
|---|
| 6431 | else if( uiDepth == 1 ) |
|---|
| 6432 | { |
|---|
| 6433 | iWidth = 32; |
|---|
| 6434 | iHeight = 32; |
|---|
| 6435 | } |
|---|
| 6436 | else if( uiDepth == 2 ) |
|---|
| 6437 | { |
|---|
| 6438 | iWidth = 16; |
|---|
| 6439 | iHeight = 16; |
|---|
| 6440 | } |
|---|
| 6441 | else if( uiDepth == 3 ) |
|---|
| 6442 | { |
|---|
| 6443 | iWidth = 8; |
|---|
| 6444 | iHeight = 8; |
|---|
| 6445 | } |
|---|
| 6446 | else // uiDepth == 4 |
|---|
| 6447 | { |
|---|
| 6448 | iWidth = 4; |
|---|
| 6449 | iHeight = 4; |
|---|
| 6450 | } |
|---|
| 6451 | |
|---|
| 6452 | Int iPtr = 0; |
|---|
| 6453 | Int iX, iY; |
|---|
| 6454 | Int iDir = -1; |
|---|
| 6455 | Int iDiffX = 0, iDiffY = 0; |
|---|
| 6456 | |
|---|
| 6457 | // 1. Edge Code -> Vert & Horz Edges |
|---|
| 6458 | Bool* pbEdge = (Bool*) xMalloc( Bool, 4 * iWidth * iHeight ); |
|---|
| 6459 | |
|---|
| 6460 | for( UInt ui = 0; ui < 4 * iWidth * iHeight; ui++ ) |
|---|
| 6461 | pbEdge [ ui ] = false; |
|---|
| 6462 | |
|---|
| 6463 | // Direction : left(0), right(1), top(2), bottom(3), left-top(4), right-top(5), left-bottom(6), right-bottom(7) |
|---|
| 6464 | // Code : 0deg(0), 45deg(1), -45deg(2), 90deg(3), -90deg(4), 135deg(5), -135deg(6) |
|---|
| 6465 | const UChar tableDir[8][7] = { { 0, 6, 4, 3, 2, 7, 5 }, |
|---|
| 6466 | { 1, 5, 7, 2, 3, 4, 6 }, |
|---|
| 6467 | { 2, 4, 5, 0, 1, 6, 7 }, |
|---|
| 6468 | { 3, 7, 6, 1, 0, 5, 4 }, |
|---|
| 6469 | { 4, 0, 2, 6, 5, 3, 1 }, |
|---|
| 6470 | { 5, 2, 1, 4, 7, 0, 3 }, |
|---|
| 6471 | { 6, 3, 0, 7, 4, 1, 2 }, |
|---|
| 6472 | { 7, 1, 3, 5, 6, 2, 0 }}; |
|---|
| 6473 | |
|---|
| 6474 | UChar ucCode = pucEdgeCode[iPtr++]; |
|---|
| 6475 | |
|---|
| 6476 | if( !bLeft ) |
|---|
| 6477 | { |
|---|
| 6478 | iX = ucStartPos; |
|---|
| 6479 | iY = 0; |
|---|
| 6480 | |
|---|
| 6481 | switch(ucCode) |
|---|
| 6482 | { |
|---|
| 6483 | case 0: // bottom |
|---|
| 6484 | iDir = 3; |
|---|
| 6485 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6486 | break; |
|---|
| 6487 | case 2: // left-bottom |
|---|
| 6488 | iDir = 6; |
|---|
| 6489 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6490 | break; |
|---|
| 6491 | case 1: // right-bottom |
|---|
| 6492 | iDir = 7; |
|---|
| 6493 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6494 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6495 | break; |
|---|
| 6496 | case 4: // left |
|---|
| 6497 | iDir = 0; |
|---|
| 6498 | assert(false); |
|---|
| 6499 | break; |
|---|
| 6500 | case 3: // right |
|---|
| 6501 | iDir = 1; |
|---|
| 6502 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6503 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6504 | break; |
|---|
| 6505 | } |
|---|
| 6506 | } |
|---|
| 6507 | else |
|---|
| 6508 | { |
|---|
| 6509 | iX = 0; |
|---|
| 6510 | iY = ucStartPos; |
|---|
| 6511 | |
|---|
| 6512 | switch(ucCode) |
|---|
| 6513 | { |
|---|
| 6514 | case 0: // right |
|---|
| 6515 | iDir = 1; |
|---|
| 6516 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6517 | break; |
|---|
| 6518 | case 1: // right-top |
|---|
| 6519 | iDir = 5; |
|---|
| 6520 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6521 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6522 | break; |
|---|
| 6523 | case 2: // right-bottom |
|---|
| 6524 | iDir = 7; |
|---|
| 6525 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6526 | break; |
|---|
| 6527 | case 3: // top |
|---|
| 6528 | iDir = 2; |
|---|
| 6529 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6530 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6531 | break; |
|---|
| 6532 | case 4: // bottom |
|---|
| 6533 | iDir = 3; |
|---|
| 6534 | assert(false); |
|---|
| 6535 | break; |
|---|
| 6536 | } |
|---|
| 6537 | } |
|---|
| 6538 | |
|---|
| 6539 | switch( iDir ) |
|---|
| 6540 | { |
|---|
| 6541 | case 0: // left |
|---|
| 6542 | iDiffX = -1; |
|---|
| 6543 | iDiffY = 0; |
|---|
| 6544 | break; |
|---|
| 6545 | case 1: // right |
|---|
| 6546 | iDiffX = +1; |
|---|
| 6547 | iDiffY = 0; |
|---|
| 6548 | break; |
|---|
| 6549 | case 2: // top |
|---|
| 6550 | iDiffX = 0; |
|---|
| 6551 | iDiffY = -1; |
|---|
| 6552 | break; |
|---|
| 6553 | case 3: // bottom |
|---|
| 6554 | iDiffX = 0; |
|---|
| 6555 | iDiffY = +1; |
|---|
| 6556 | break; |
|---|
| 6557 | case 4: // left-top |
|---|
| 6558 | iDiffX = -1; |
|---|
| 6559 | iDiffY = -1; |
|---|
| 6560 | break; |
|---|
| 6561 | case 5: // right-top |
|---|
| 6562 | iDiffX = +1; |
|---|
| 6563 | iDiffY = -1; |
|---|
| 6564 | break; |
|---|
| 6565 | case 6: // left-bottom |
|---|
| 6566 | iDiffX = -1; |
|---|
| 6567 | iDiffY = +1; |
|---|
| 6568 | break; |
|---|
| 6569 | case 7: // right-bottom |
|---|
| 6570 | iDiffX = +1; |
|---|
| 6571 | iDiffY = +1; |
|---|
| 6572 | break; |
|---|
| 6573 | } |
|---|
| 6574 | |
|---|
| 6575 | iX += iDiffX; |
|---|
| 6576 | iY += iDiffY; |
|---|
| 6577 | |
|---|
| 6578 | while( iPtr < ucNumEdge ) |
|---|
| 6579 | { |
|---|
| 6580 | ucCode = pucEdgeCode[iPtr++]; |
|---|
| 6581 | |
|---|
| 6582 | Int iNewDir = tableDir[iDir][ucCode]; |
|---|
| 6583 | |
|---|
| 6584 | switch( iNewDir ) |
|---|
| 6585 | { |
|---|
| 6586 | case 0: // left |
|---|
| 6587 | iDiffX = -1; |
|---|
| 6588 | iDiffY = 0; |
|---|
| 6589 | break; |
|---|
| 6590 | case 1: // right |
|---|
| 6591 | iDiffX = +1; |
|---|
| 6592 | iDiffY = 0; |
|---|
| 6593 | break; |
|---|
| 6594 | case 2: // top |
|---|
| 6595 | iDiffX = 0; |
|---|
| 6596 | iDiffY = -1; |
|---|
| 6597 | break; |
|---|
| 6598 | case 3: // bottom |
|---|
| 6599 | iDiffX = 0; |
|---|
| 6600 | iDiffY = +1; |
|---|
| 6601 | break; |
|---|
| 6602 | case 4: // left-top |
|---|
| 6603 | iDiffX = -1; |
|---|
| 6604 | iDiffY = -1; |
|---|
| 6605 | break; |
|---|
| 6606 | case 5: // right-top |
|---|
| 6607 | iDiffX = +1; |
|---|
| 6608 | iDiffY = -1; |
|---|
| 6609 | break; |
|---|
| 6610 | case 6: // left-bottom |
|---|
| 6611 | iDiffX = -1; |
|---|
| 6612 | iDiffY = +1; |
|---|
| 6613 | break; |
|---|
| 6614 | case 7: // right-bottom |
|---|
| 6615 | iDiffX = +1; |
|---|
| 6616 | iDiffY = +1; |
|---|
| 6617 | break; |
|---|
| 6618 | } |
|---|
| 6619 | |
|---|
| 6620 | switch( iDir ) |
|---|
| 6621 | { |
|---|
| 6622 | case 0: // left |
|---|
| 6623 | switch( ucCode ) |
|---|
| 6624 | { |
|---|
| 6625 | case 0: |
|---|
| 6626 | case 2: |
|---|
| 6627 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6628 | break; |
|---|
| 6629 | case 1: |
|---|
| 6630 | case 3: |
|---|
| 6631 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6632 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6633 | break; |
|---|
| 6634 | case 4: |
|---|
| 6635 | case 6: |
|---|
| 6636 | // no |
|---|
| 6637 | break; |
|---|
| 6638 | case 5: |
|---|
| 6639 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6640 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6641 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6642 | break; |
|---|
| 6643 | } |
|---|
| 6644 | break; |
|---|
| 6645 | case 1: // right |
|---|
| 6646 | switch( ucCode ) |
|---|
| 6647 | { |
|---|
| 6648 | case 0: |
|---|
| 6649 | case 2: |
|---|
| 6650 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6651 | break; |
|---|
| 6652 | case 1: |
|---|
| 6653 | case 3: |
|---|
| 6654 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6655 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6656 | break; |
|---|
| 6657 | case 4: |
|---|
| 6658 | case 6: |
|---|
| 6659 | // no |
|---|
| 6660 | break; |
|---|
| 6661 | case 5: |
|---|
| 6662 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6663 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6664 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6665 | break; |
|---|
| 6666 | } |
|---|
| 6667 | break; |
|---|
| 6668 | case 2: // top |
|---|
| 6669 | switch( ucCode ) |
|---|
| 6670 | { |
|---|
| 6671 | case 0: |
|---|
| 6672 | case 2: |
|---|
| 6673 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6674 | break; |
|---|
| 6675 | case 1: |
|---|
| 6676 | case 3: |
|---|
| 6677 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6678 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6679 | break; |
|---|
| 6680 | case 4: |
|---|
| 6681 | case 6: |
|---|
| 6682 | // no |
|---|
| 6683 | break; |
|---|
| 6684 | case 5: |
|---|
| 6685 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6686 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6687 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6688 | break; |
|---|
| 6689 | } |
|---|
| 6690 | break; |
|---|
| 6691 | case 3: // bottom |
|---|
| 6692 | switch( ucCode ) |
|---|
| 6693 | { |
|---|
| 6694 | case 0: |
|---|
| 6695 | case 2: |
|---|
| 6696 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6697 | break; |
|---|
| 6698 | case 1: |
|---|
| 6699 | case 3: |
|---|
| 6700 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6701 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6702 | break; |
|---|
| 6703 | case 4: |
|---|
| 6704 | case 6: |
|---|
| 6705 | // no |
|---|
| 6706 | break; |
|---|
| 6707 | case 5: |
|---|
| 6708 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6709 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6710 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6711 | break; |
|---|
| 6712 | } |
|---|
| 6713 | break; |
|---|
| 6714 | case 4: // left-top |
|---|
| 6715 | switch( ucCode ) |
|---|
| 6716 | { |
|---|
| 6717 | case 0: |
|---|
| 6718 | case 1: |
|---|
| 6719 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6720 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6721 | break; |
|---|
| 6722 | case 2: |
|---|
| 6723 | case 4: |
|---|
| 6724 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6725 | break; |
|---|
| 6726 | case 3: |
|---|
| 6727 | case 5: |
|---|
| 6728 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6729 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6730 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6731 | break; |
|---|
| 6732 | case 6: |
|---|
| 6733 | // no |
|---|
| 6734 | break; |
|---|
| 6735 | } |
|---|
| 6736 | break; |
|---|
| 6737 | case 5: // right-top |
|---|
| 6738 | switch( ucCode ) |
|---|
| 6739 | { |
|---|
| 6740 | case 0: |
|---|
| 6741 | case 1: |
|---|
| 6742 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6743 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6744 | break; |
|---|
| 6745 | case 2: |
|---|
| 6746 | case 4: |
|---|
| 6747 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6748 | break; |
|---|
| 6749 | case 3: |
|---|
| 6750 | case 5: |
|---|
| 6751 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6752 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6753 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6754 | break; |
|---|
| 6755 | case 6: |
|---|
| 6756 | // no |
|---|
| 6757 | break; |
|---|
| 6758 | } |
|---|
| 6759 | break; |
|---|
| 6760 | case 6: // left-bottom |
|---|
| 6761 | switch( ucCode ) |
|---|
| 6762 | { |
|---|
| 6763 | case 0: |
|---|
| 6764 | case 1: |
|---|
| 6765 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6766 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6767 | break; |
|---|
| 6768 | case 2: |
|---|
| 6769 | case 4: |
|---|
| 6770 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6771 | break; |
|---|
| 6772 | case 3: |
|---|
| 6773 | case 5: |
|---|
| 6774 | if(iY > 0) pbEdge[ 2 * iX + (2 * (iY - 1) + 1) * 2 * iWidth ] = true; |
|---|
| 6775 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6776 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6777 | break; |
|---|
| 6778 | case 6: |
|---|
| 6779 | // no |
|---|
| 6780 | break; |
|---|
| 6781 | } |
|---|
| 6782 | break; |
|---|
| 6783 | case 7: // right-bottom |
|---|
| 6784 | switch( ucCode ) |
|---|
| 6785 | { |
|---|
| 6786 | case 0: |
|---|
| 6787 | case 1: |
|---|
| 6788 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6789 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6790 | break; |
|---|
| 6791 | case 2: |
|---|
| 6792 | case 4: |
|---|
| 6793 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6794 | break; |
|---|
| 6795 | case 3: |
|---|
| 6796 | case 5: |
|---|
| 6797 | if(iX > 0) pbEdge[ 2 * (iX - 1) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6798 | if(iX < iWidth - 1) pbEdge[ 2 * (iX + 0) + 1 + iY * 4 * iWidth ] = true; |
|---|
| 6799 | if(iY < iHeight - 1) pbEdge[ 2 * iX + (2 * (iY + 0) + 1) * 2 * iWidth ] = true; |
|---|
| 6800 | break; |
|---|
| 6801 | case 6: |
|---|
| 6802 | // no |
|---|
| 6803 | break; |
|---|
| 6804 | } |
|---|
| 6805 | break; |
|---|
| 6806 | } |
|---|
| 6807 | |
|---|
| 6808 | assert( iX >= 0 && iX <= iWidth ); |
|---|
| 6809 | assert( iY >= 0 && iY <= iHeight ); |
|---|
| 6810 | |
|---|
| 6811 | iX += iDiffX; |
|---|
| 6812 | iY += iDiffY; |
|---|
| 6813 | iDir = iNewDir; |
|---|
| 6814 | } |
|---|
| 6815 | |
|---|
| 6816 | // finalize edge chain |
|---|
| 6817 | if( iX == iWidth-1 ) |
|---|
| 6818 | { |
|---|
| 6819 | if( iY == 0 ) |
|---|
| 6820 | { |
|---|
| 6821 | if( iDir == 1 ) |
|---|
| 6822 | { |
|---|
| 6823 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
|---|
| 6824 | } |
|---|
| 6825 | else if( iDir == 5 ) |
|---|
| 6826 | { |
|---|
| 6827 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
|---|
| 6828 | } |
|---|
| 6829 | else |
|---|
| 6830 | { |
|---|
| 6831 | assert(false); |
|---|
| 6832 | } |
|---|
| 6833 | } |
|---|
| 6834 | else if( iY == iHeight-1 ) |
|---|
| 6835 | { |
|---|
| 6836 | if( iDir == 3 ) |
|---|
| 6837 | { |
|---|
| 6838 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6839 | } |
|---|
| 6840 | else if( iDir == 7 ) |
|---|
| 6841 | { |
|---|
| 6842 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6843 | } |
|---|
| 6844 | else |
|---|
| 6845 | { |
|---|
| 6846 | assert(false); |
|---|
| 6847 | } |
|---|
| 6848 | } |
|---|
| 6849 | else |
|---|
| 6850 | { |
|---|
| 6851 | if( iDir == 1 ) |
|---|
| 6852 | { |
|---|
| 6853 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
|---|
| 6854 | } |
|---|
| 6855 | else if( iDir == 3 ) |
|---|
| 6856 | { |
|---|
| 6857 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6858 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
|---|
| 6859 | } |
|---|
| 6860 | else if( iDir == 5 ) |
|---|
| 6861 | { |
|---|
| 6862 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
|---|
| 6863 | } |
|---|
| 6864 | else if( iDir == 7 ) |
|---|
| 6865 | { |
|---|
| 6866 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6867 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
|---|
| 6868 | } |
|---|
| 6869 | else |
|---|
| 6870 | { |
|---|
| 6871 | assert(false); |
|---|
| 6872 | } |
|---|
| 6873 | } |
|---|
| 6874 | } |
|---|
| 6875 | else if( iX == 0 ) |
|---|
| 6876 | { |
|---|
| 6877 | if( iY == 0 ) |
|---|
| 6878 | { |
|---|
| 6879 | if( iDir == 2 ) |
|---|
| 6880 | { |
|---|
| 6881 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6882 | } |
|---|
| 6883 | else if( iDir == 4 ) |
|---|
| 6884 | { |
|---|
| 6885 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6886 | } |
|---|
| 6887 | else |
|---|
| 6888 | { |
|---|
| 6889 | assert(false); |
|---|
| 6890 | } |
|---|
| 6891 | } |
|---|
| 6892 | else if( iY == iHeight-1 ) |
|---|
| 6893 | { |
|---|
| 6894 | if( iDir == 0 ) |
|---|
| 6895 | { |
|---|
| 6896 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
|---|
| 6897 | } |
|---|
| 6898 | else if( iDir == 6 ) |
|---|
| 6899 | { |
|---|
| 6900 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
|---|
| 6901 | } |
|---|
| 6902 | else |
|---|
| 6903 | { |
|---|
| 6904 | assert(false); |
|---|
| 6905 | } |
|---|
| 6906 | } |
|---|
| 6907 | else |
|---|
| 6908 | { |
|---|
| 6909 | if( iDir == 0 ) |
|---|
| 6910 | { |
|---|
| 6911 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
|---|
| 6912 | } |
|---|
| 6913 | else if( iDir == 2 ) |
|---|
| 6914 | { |
|---|
| 6915 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6916 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
|---|
| 6917 | } |
|---|
| 6918 | else if( iDir == 4 ) |
|---|
| 6919 | { |
|---|
| 6920 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6921 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
|---|
| 6922 | } |
|---|
| 6923 | else if( iDir == 6 ) |
|---|
| 6924 | { |
|---|
| 6925 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
|---|
| 6926 | } |
|---|
| 6927 | else |
|---|
| 6928 | { |
|---|
| 6929 | assert(false); |
|---|
| 6930 | } |
|---|
| 6931 | } |
|---|
| 6932 | } |
|---|
| 6933 | else if( iY == 0 ) |
|---|
| 6934 | { |
|---|
| 6935 | if( iDir == 1 ) |
|---|
| 6936 | { |
|---|
| 6937 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
|---|
| 6938 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6939 | } |
|---|
| 6940 | else if( iDir == 2 ) |
|---|
| 6941 | { |
|---|
| 6942 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6943 | } |
|---|
| 6944 | else if( iDir == 4 ) |
|---|
| 6945 | { |
|---|
| 6946 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6947 | } |
|---|
| 6948 | else if( iDir == 5 ) |
|---|
| 6949 | { |
|---|
| 6950 | pbEdge[ 2 * iX + (2 * iY + 1) * 2 * iWidth ] = true; |
|---|
| 6951 | pbEdge[ 2 * iX + 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6952 | } |
|---|
| 6953 | else |
|---|
| 6954 | { |
|---|
| 6955 | assert(false); |
|---|
| 6956 | } |
|---|
| 6957 | } |
|---|
| 6958 | else if( iY == iHeight-1 ) |
|---|
| 6959 | { |
|---|
| 6960 | if( iDir == 0 ) |
|---|
| 6961 | { |
|---|
| 6962 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
|---|
| 6963 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6964 | } |
|---|
| 6965 | else if( iDir == 3 ) |
|---|
| 6966 | { |
|---|
| 6967 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6968 | } |
|---|
| 6969 | else if( iDir == 6 ) |
|---|
| 6970 | { |
|---|
| 6971 | pbEdge[ 2 * iX + (2 * iY - 1) * 2 * iWidth ] = true; |
|---|
| 6972 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6973 | } |
|---|
| 6974 | else if( iDir == 7 ) |
|---|
| 6975 | { |
|---|
| 6976 | pbEdge[ 2 * iX - 1 + 2 * iY * 2 * iWidth ] = true; |
|---|
| 6977 | } |
|---|
| 6978 | else |
|---|
| 6979 | { |
|---|
| 6980 | assert(false); |
|---|
| 6981 | } |
|---|
| 6982 | } |
|---|
| 6983 | else |
|---|
| 6984 | { |
|---|
| 6985 | printf("reconPartiton: wrong termination\n"); |
|---|
| 6986 | assert(false); |
|---|
| 6987 | } |
|---|
| 6988 | |
|---|
| 6989 | // Reconstruct Region from Chain Code |
|---|
| 6990 | Bool* pbVisit = (Bool*) xMalloc( Bool, iWidth * iHeight ); |
|---|
| 6991 | Int* piStack = (Int* ) xMalloc( Int, iWidth * iHeight ); |
|---|
| 6992 | |
|---|
| 6993 | for( UInt ui = 0; ui < iWidth * iHeight; ui++ ) |
|---|
| 6994 | { |
|---|
| 6995 | pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next) |
|---|
| 6996 | pbVisit [ ui ] = false; |
|---|
| 6997 | } |
|---|
| 6998 | |
|---|
| 6999 | iPtr = 0; |
|---|
| 7000 | piStack[iPtr++] = (0 << 8) | (0); |
|---|
| 7001 | pbRegion[ 0 ] = false; |
|---|
| 7002 | |
|---|
| 7003 | while(iPtr > 0) |
|---|
| 7004 | { |
|---|
| 7005 | Int iTmp = piStack[--iPtr]; |
|---|
| 7006 | Int iX1, iY1; |
|---|
| 7007 | iX1 = iTmp & 0xff; |
|---|
| 7008 | iY1 = (iTmp >> 8) & 0xff; |
|---|
| 7009 | |
|---|
| 7010 | pbVisit[ iX1 + iY1 * iWidth ] = true; |
|---|
| 7011 | |
|---|
| 7012 | assert( iX1 >= 0 && iX1 < iWidth ); |
|---|
| 7013 | assert( iY1 >= 0 && iY1 < iHeight ); |
|---|
| 7014 | |
|---|
| 7015 | if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] ) |
|---|
| 7016 | { |
|---|
| 7017 | piStack[iPtr++] = (iY1 << 8) | (iX1 - 1); |
|---|
| 7018 | pbRegion[ iX1 - 1 + iY1 * iWidth ] = false; |
|---|
| 7019 | } |
|---|
| 7020 | if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] ) |
|---|
| 7021 | { |
|---|
| 7022 | piStack[iPtr++] = (iY1 << 8) | (iX1 + 1); |
|---|
| 7023 | pbRegion[ iX1 + 1 + iY1 * iWidth ] = false; |
|---|
| 7024 | } |
|---|
| 7025 | if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] ) |
|---|
| 7026 | { |
|---|
| 7027 | piStack[iPtr++] = ((iY1 - 1) << 8) | iX1; |
|---|
| 7028 | pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false; |
|---|
| 7029 | } |
|---|
| 7030 | if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] ) |
|---|
| 7031 | { |
|---|
| 7032 | piStack[iPtr++] = ((iY1 + 1) << 8) | iX1; |
|---|
| 7033 | pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false; |
|---|
| 7034 | } |
|---|
| 7035 | } |
|---|
| 7036 | |
|---|
| 7037 | xFree( pbEdge ); |
|---|
| 7038 | xFree( pbVisit ); |
|---|
| 7039 | xFree( piStack ); |
|---|
| 7040 | } |
|---|
| 7041 | #endif |
|---|
| 7042 | |
|---|
| 7043 | |
|---|
| 7044 | //! \} |
|---|