Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComDataCU.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComDataCU.cpp
r1196 r1313 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 38 38 39 39 #include "TComDataCU.h" 40 #include "TComTU.h" 40 41 #include "TComPic.h" 41 42 42 43 //! \ingroup TLibCommon 43 44 //! \{ 44 45 #if ADAPTIVE_QP_SELECTION46 Int * TComDataCU::m_pcGlbArlCoeffY = NULL;47 Int * TComDataCU::m_pcGlbArlCoeffCb = NULL;48 Int * TComDataCU::m_pcGlbArlCoeffCr = NULL;49 #endif50 45 51 46 // ==================================================================================================================== … … 58 53 m_pcSlice = NULL; 59 54 m_puhDepth = NULL; 60 55 61 56 m_skipFlag = NULL; 62 #if H_3D57 #if NH_3D_DIS 63 58 m_bDISFlag = NULL; 64 m_u iDISType = NULL;59 m_ucDISType = NULL; 65 60 #endif 66 61 m_pePartSize = NULL; … … 70 65 m_puhHeight = NULL; 71 66 m_phQP = NULL; 67 m_ChromaQpAdj = NULL; 72 68 m_pbMergeFlag = NULL; 73 69 m_puhMergeIndex = NULL; 74 m_puhLumaIntraDir = NULL; 75 m_puhChromaIntraDir = NULL; 70 for(UInt i=0; i<MAX_NUM_CHANNEL_TYPE; i++) 71 { 72 m_puhIntraDir[i] = NULL; 73 } 76 74 m_puhInterDir = NULL; 77 75 m_puhTrIdx = NULL; 78 m_puhTransformSkip[0] = NULL; 79 m_puhTransformSkip[1] = NULL; 80 m_puhTransformSkip[2] = NULL; 81 m_puhCbf[0] = NULL; 82 m_puhCbf[1] = NULL; 83 m_puhCbf[2] = NULL; 84 m_pcTrCoeffY = NULL; 85 m_pcTrCoeffCb = NULL; 86 m_pcTrCoeffCr = NULL; 87 #if ADAPTIVE_QP_SELECTION 76 77 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 78 { 79 m_puhCbf[comp] = NULL; 80 m_crossComponentPredictionAlpha[comp] = NULL; 81 m_puhTransformSkip[comp] = NULL; 82 m_pcTrCoeff[comp] = NULL; 83 #if ADAPTIVE_QP_SELECTION 84 m_pcArlCoeff[comp] = NULL; 85 #endif 86 m_pcIPCMSample[comp] = NULL; 87 m_explicitRdpcmMode[comp] = NULL; 88 } 89 #if ADAPTIVE_QP_SELECTION 88 90 m_ArlCoeffIsAliasedAllocation = false; 89 m_pcArlCoeffY = NULL; 90 m_pcArlCoeffCb = NULL; 91 m_pcArlCoeffCr = NULL; 92 #endif 93 91 #endif 94 92 m_pbIPCMFlag = NULL; 95 m_pcIPCMSampleY = NULL; 96 m_pcIPCMSampleCb = NULL; 97 m_pcIPCMSampleCr = NULL; 98 99 m_pcPattern = NULL; 100 101 m_pcCUAboveLeft = NULL; 102 m_pcCUAboveRight = NULL; 103 m_pcCUAbove = NULL; 104 m_pcCULeft = NULL; 105 106 m_apcCUColocated[0] = NULL; 107 m_apcCUColocated[1] = NULL; 108 109 m_apiMVPIdx[0] = NULL; 110 m_apiMVPIdx[1] = NULL; 111 m_apiMVPNum[0] = NULL; 112 m_apiMVPNum[1] = NULL; 113 114 #if H_3D_DIM 115 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 116 { 117 m_dimDeltaDC[i][0] = NULL; 118 m_dimDeltaDC[i][1] = NULL; 119 } 120 #if H_3D_DIM_DMM 121 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 122 { 123 m_dmmWedgeTabIdx[i] = NULL; 124 } 125 #endif 126 #if H_3D_DIM_SDC 93 94 m_pCtuAboveLeft = NULL; 95 m_pCtuAboveRight = NULL; 96 m_pCtuAbove = NULL; 97 m_pCtuLeft = NULL; 98 99 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 100 { 101 m_apcCUColocated[i] = NULL; 102 m_apiMVPIdx[i] = NULL; 103 m_apiMVPNum[i] = NULL; 104 } 105 106 #if NH_3D_DMM 107 for( Int i = 0; i < NUM_DMM; i++ ) 108 { 109 m_dmmDeltaDC[i][0] = NULL; 110 m_dmmDeltaDC[i][1] = NULL; 111 } 112 m_dmm1WedgeTabIdx = NULL; 113 #endif 114 #if NH_3D_SDC_INTRA 127 115 m_pbSDCFlag = NULL; 128 116 m_apSegmentDCOffset[0] = NULL; 129 117 m_apSegmentDCOffset[1] = NULL; 130 118 #endif 131 #endif 119 132 120 m_bDecSubCu = false; 133 m_sliceStartCU = 0; 134 m_sliceSegmentStartCU = 0; 135 #if H_3D_NBDV 121 122 #if NH_3D_NBDV 136 123 m_pDvInfo = NULL; 137 124 #endif 138 #if H_3D_VSP125 #if NH_3D_VSP 139 126 m_piVSPFlag = NULL; 140 127 #endif 141 #if H_3D_SPIVMP128 #if NH_3D_SPIVMP 142 129 m_pbSPIVMPFlag = NULL; 143 130 #endif 144 #if H_3D_ARP131 #if NH_3D_ARP 145 132 m_puhARPW = NULL; 146 133 #endif 147 #if H_3D_IC134 #if NH_3D_IC 148 135 m_pbICFlag = NULL; 149 136 #endif 150 #if H_3D_INTER_SDC 151 #endif 152 #if H_3D_DBBP 137 #if NH_3D_DBBP 153 138 m_pbDBBPFlag = NULL; 154 139 #endif 140 155 141 } 156 142 … … 159 145 } 160 146 161 Void TComDataCU::create( UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize147 Void TComDataCU::create( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize 162 148 #if ADAPTIVE_QP_SELECTION 163 , Bool bGlobalRMARLBuffer164 #endif 149 , TCoeff *pParentARLBuffer 150 #endif 165 151 ) 166 152 { 167 153 m_bDecSubCu = bDecSubCu; 168 154 169 155 m_pcPic = NULL; 170 156 m_pcSlice = NULL; 171 157 m_uiNumPartition = uiNumPartition; 172 158 m_unitSize = unitSize; 173 159 174 160 if ( !bDecSubCu ) 175 161 { … … 179 165 m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); 180 166 167 m_ChromaQpAdj = new UChar[ uiNumPartition ]; 181 168 m_skipFlag = new Bool[ uiNumPartition ]; 182 #if H_3D169 #if NH_3D_DIS 183 170 m_bDISFlag = new Bool[ uiNumPartition ]; 184 m_u iDISType = (UInt*)xMalloc(UInt, uiNumPartition);171 m_ucDISType = (UChar*)xMalloc(UChar, uiNumPartition); 185 172 #endif 186 173 m_pePartSize = new Char[ uiNumPartition ]; 187 memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) );174 memset( m_pePartSize, NUMBER_OF_PART_SIZES,uiNumPartition * sizeof( *m_pePartSize ) ); 188 175 m_pePredMode = new Char[ uiNumPartition ]; 189 176 m_CUTransquantBypass = new Bool[ uiNumPartition ]; 177 190 178 m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); 191 179 m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); 192 #if H_3D_VSP180 #if NH_3D_VSP 193 181 m_piVSPFlag = (Char* )xMalloc(Char, uiNumPartition); 194 182 #endif 195 #if H_3D_SPIVMP183 #if NH_3D_SPIVMP 196 184 m_pbSPIVMPFlag = (Bool* )xMalloc(Bool, uiNumPartition); 197 185 #endif 198 m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); 199 m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); 186 187 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 188 { 189 m_puhIntraDir[ch] = (UChar* )xMalloc(UChar, uiNumPartition); 190 } 200 191 m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); 201 192 202 193 m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); 203 m_puhTransformSkip[0] = (UChar* )xMalloc(UChar, uiNumPartition); 204 m_puhTransformSkip[1] = (UChar* )xMalloc(UChar, uiNumPartition); 205 m_puhTransformSkip[2] = (UChar* )xMalloc(UChar, uiNumPartition); 206 207 m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); 208 m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); 209 m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); 210 211 m_apiMVPIdx[0] = new Char[ uiNumPartition ]; 212 m_apiMVPIdx[1] = new Char[ uiNumPartition ]; 213 m_apiMVPNum[0] = new Char[ uiNumPartition ]; 214 m_apiMVPNum[1] = new Char[ uiNumPartition ]; 215 memset( m_apiMVPIdx[0], -1,uiNumPartition * sizeof( Char ) ); 216 memset( m_apiMVPIdx[1], -1,uiNumPartition * sizeof( Char ) ); 217 218 m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); 219 m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); 220 m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); 221 #if H_3D_NBDV 194 195 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 196 { 197 const RefPicList rpl=RefPicList(i); 198 m_apiMVPIdx[rpl] = new Char[ uiNumPartition ]; 199 m_apiMVPNum[rpl] = new Char[ uiNumPartition ]; 200 memset( m_apiMVPIdx[rpl], -1,uiNumPartition * sizeof( Char ) ); 201 } 202 203 #if NH_3D_NBDV 222 204 m_pDvInfo = (DisInfo* )xMalloc(DisInfo, uiNumPartition); 223 205 #endif 224 memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) ); 225 memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); 226 memset( m_pcTrCoeffCr, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); 227 #if ADAPTIVE_QP_SELECTION 228 if( bGlobalRMARLBuffer ) 229 { 230 if( m_pcGlbArlCoeffY == NULL ) 231 { 232 m_pcGlbArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); 233 m_pcGlbArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); 234 m_pcGlbArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); 235 } 236 m_pcArlCoeffY = m_pcGlbArlCoeffY; 237 m_pcArlCoeffCb = m_pcGlbArlCoeffCb; 238 m_pcArlCoeffCr = m_pcGlbArlCoeffCr; 239 m_ArlCoeffIsAliasedAllocation = true; 240 } 241 else 242 { 243 m_pcArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); 244 m_pcArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); 245 m_pcArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); 246 } 247 #endif 248 206 207 208 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 209 { 210 const ComponentID compID = ComponentID(comp); 211 const UInt chromaShift = getComponentScaleX(compID, chromaFormatIDC) + getComponentScaleY(compID, chromaFormatIDC); 212 const UInt totalSize = (uiWidth * uiHeight) >> chromaShift; 213 214 m_crossComponentPredictionAlpha[compID] = (Char* )xMalloc(Char, uiNumPartition); 215 m_puhTransformSkip[compID] = (UChar* )xMalloc(UChar, uiNumPartition); 216 m_explicitRdpcmMode[compID] = (UChar* )xMalloc(UChar, uiNumPartition); 217 m_puhCbf[compID] = (UChar* )xMalloc(UChar, uiNumPartition); 218 m_pcTrCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); 219 memset( m_pcTrCoeff[compID], 0, (totalSize * sizeof( TCoeff )) ); 220 221 #if ADAPTIVE_QP_SELECTION 222 if( pParentARLBuffer != 0 ) 223 { 224 m_pcArlCoeff[compID] = pParentARLBuffer; 225 m_ArlCoeffIsAliasedAllocation = true; 226 pParentARLBuffer += totalSize; 227 } 228 else 229 { 230 m_pcArlCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); 231 m_ArlCoeffIsAliasedAllocation = false; 232 } 233 #endif 234 m_pcIPCMSample[compID] = (Pel* )xMalloc(Pel , totalSize); 235 } 236 249 237 m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); 250 m_pcIPCMSampleY = (Pel* )xMalloc(Pel , uiWidth*uiHeight); 251 m_pcIPCMSampleCb = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); 252 m_pcIPCMSampleCr = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); 253 254 m_acCUMvField[0].create( uiNumPartition ); 255 m_acCUMvField[1].create( uiNumPartition ); 256 257 #if H_3D_ARP 258 m_puhARPW = new UChar[ uiNumPartition]; 259 #endif 260 #if H_3D_IC 238 239 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 240 { 241 m_acCUMvField[i].create( uiNumPartition ); 242 } 243 244 #if NH_3D_ARP 245 m_puhARPW = (UChar* )xMalloc(UChar, uiNumPartition); 246 #endif 247 #if NH_3D_IC 261 248 m_pbICFlag = (Bool* )xMalloc(Bool, uiNumPartition); 262 249 #endif 263 #if H_3D_DIM 264 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 265 { 266 m_dimDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition); 267 m_dimDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition); 268 } 269 #if H_3D_DIM_DMM 270 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 271 { 272 m_dmmWedgeTabIdx[i] = (UInt*)xMalloc(UInt, uiNumPartition); 273 } 274 #endif 275 #if H_3D_DIM_SDC 250 #if NH_3D_DMM 251 for( Int i = 0; i < NUM_DMM; i++ ) 252 { 253 m_dmmDeltaDC[i][0] = (Pel* )xMalloc(Pel, uiNumPartition); 254 m_dmmDeltaDC[i][1] = (Pel* )xMalloc(Pel, uiNumPartition); 255 } 256 m_dmm1WedgeTabIdx = (UInt*)xMalloc(UInt, uiNumPartition); 257 #endif 258 #if NH_3D_SDC_INTRA 276 259 m_pbSDCFlag = (Bool*)xMalloc(Bool, uiNumPartition); 277 260 m_apSegmentDCOffset[0] = (Pel*)xMalloc(Pel, uiNumPartition); 278 261 m_apSegmentDCOffset[1] = (Pel*)xMalloc(Pel, uiNumPartition); 279 262 #endif 280 #endif 281 #if H_3D_DBBP 263 #if NH_3D_DBBP 282 264 m_pbDBBPFlag = (Bool* )xMalloc(Bool, uiNumPartition); 283 265 #endif 266 284 267 } 285 268 else 286 269 { 287 m_acCUMvField[0].setNumPartition(uiNumPartition ); 288 m_acCUMvField[1].setNumPartition(uiNumPartition ); 289 } 290 m_sliceStartCU = (UInt* )xMalloc(UInt, uiNumPartition); 291 m_sliceSegmentStartCU = (UInt* )xMalloc(UInt, uiNumPartition); 292 293 // create pattern memory 294 m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); 295 270 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 271 { 272 m_acCUMvField[i].setNumPartition(uiNumPartition ); 273 } 274 } 296 275 297 276 // create motion vector fields 298 299 m_pcCUAboveLeft = NULL; 300 m_pcCUAboveRight = NULL; 301 m_pcCUAbove = NULL; 302 m_pcCULeft = NULL; 303 304 m_apcCUColocated[0] = NULL; 305 m_apcCUColocated[1] = NULL; 277 278 m_pCtuAboveLeft = NULL; 279 m_pCtuAboveRight = NULL; 280 m_pCtuAbove = NULL; 281 m_pCtuLeft = NULL; 282 283 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 284 { 285 m_apcCUColocated[i] = NULL; 286 } 306 287 } 307 288 308 289 Void TComDataCU::destroy() 309 290 { 310 m_pcPic = NULL;311 m_pcSlice = NULL;312 313 if ( m_pcPattern )314 {315 xFree(m_pcPattern);316 m_pcPattern = NULL;317 }318 319 291 // encoder-side buffer free 320 292 if ( !m_bDecSubCu ) 321 293 { 322 if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } 323 if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } 324 if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } 325 if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } 326 327 if ( m_skipFlag ) { delete[] m_skipFlag; m_skipFlag = NULL; } 328 #if H_3D 294 if ( m_phQP ) 295 { 296 xFree(m_phQP); 297 m_phQP = NULL; 298 } 299 if ( m_puhDepth ) 300 { 301 xFree(m_puhDepth); 302 m_puhDepth = NULL; 303 } 304 if ( m_puhWidth ) 305 { 306 xFree(m_puhWidth); 307 m_puhWidth = NULL; 308 } 309 if ( m_puhHeight ) 310 { 311 xFree(m_puhHeight); 312 m_puhHeight = NULL; 313 } 314 315 if ( m_skipFlag ) 316 { 317 delete[] m_skipFlag; 318 m_skipFlag = NULL; 319 } 320 321 #if NH_3D_DIS 329 322 if ( m_bDISFlag ) { delete[] m_bDISFlag; m_bDISFlag = NULL; } 330 if ( m_uiDISType ) { xFree(m_uiDISType); m_uiDISType = NULL; } 331 #endif 332 if ( m_pePartSize ) { delete[] m_pePartSize; m_pePartSize = NULL; } 333 if ( m_pePredMode ) { delete[] m_pePredMode; m_pePredMode = NULL; } 334 if ( m_CUTransquantBypass ) { delete[] m_CUTransquantBypass;m_CUTransquantBypass = NULL; } 335 if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } 336 if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } 337 if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } 338 if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } 339 if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } 340 if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } 341 #if H_3D_VSP 342 if ( m_piVSPFlag ) { xFree(m_piVSPFlag); m_piVSPFlag = NULL; } 343 #endif 344 #if H_3D_SPIVMP 323 if ( m_ucDISType ) { xFree(m_ucDISType); m_ucDISType = NULL; } 324 #endif 325 326 if ( m_pePartSize ) 327 { 328 delete[] m_pePartSize; 329 m_pePartSize = NULL; 330 } 331 if ( m_pePredMode ) 332 { 333 delete[] m_pePredMode; 334 m_pePredMode = NULL; 335 } 336 if ( m_ChromaQpAdj ) 337 { 338 delete[] m_ChromaQpAdj; 339 m_ChromaQpAdj = NULL; 340 } 341 if ( m_CUTransquantBypass ) 342 { 343 delete[] m_CUTransquantBypass; 344 m_CUTransquantBypass = NULL; 345 } 346 if ( m_puhInterDir ) 347 { 348 xFree(m_puhInterDir); 349 m_puhInterDir = NULL; 350 } 351 if ( m_pbMergeFlag ) 352 { 353 xFree(m_pbMergeFlag); 354 m_pbMergeFlag = NULL; 355 } 356 if ( m_puhMergeIndex ) 357 { 358 xFree(m_puhMergeIndex); 359 m_puhMergeIndex = NULL; 360 } 361 362 #if NH_3D_VSP 363 if ( m_piVSPFlag ) 364 { 365 xFree(m_piVSPFlag); 366 m_piVSPFlag = NULL; 367 } 368 #endif 369 #if NH_3D_SPIVMP 345 370 if ( m_pbSPIVMPFlag ) { xFree(m_pbSPIVMPFlag); m_pbSPIVMPFlag = NULL; } 346 371 #endif 347 if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } 348 if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } 349 if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } 350 if ( m_puhTransformSkip[0]) { xFree(m_puhTransformSkip[0]); m_puhTransformSkip[0] = NULL; } 351 if ( m_puhTransformSkip[1]) { xFree(m_puhTransformSkip[1]); m_puhTransformSkip[1] = NULL; } 352 if ( m_puhTransformSkip[2]) { xFree(m_puhTransformSkip[2]); m_puhTransformSkip[2] = NULL; } 353 if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } 354 if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } 355 if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } 372 373 374 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 375 { 376 xFree(m_puhIntraDir[ch]); 377 m_puhIntraDir[ch] = NULL; 378 } 379 380 if ( m_puhTrIdx ) 381 { 382 xFree(m_puhTrIdx); 383 m_puhTrIdx = NULL; 384 } 385 386 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 387 { 388 if ( m_crossComponentPredictionAlpha[comp] ) 389 { 390 xFree(m_crossComponentPredictionAlpha[comp]); 391 m_crossComponentPredictionAlpha[comp] = NULL; 392 } 393 if ( m_puhTransformSkip[comp] ) 394 { 395 xFree(m_puhTransformSkip[comp]); 396 m_puhTransformSkip[comp] = NULL; 397 } 398 if ( m_puhCbf[comp] ) 399 { 400 xFree(m_puhCbf[comp]); 401 m_puhCbf[comp] = NULL; 402 } 403 if ( m_pcTrCoeff[comp] ) 404 { 405 xFree(m_pcTrCoeff[comp]); 406 m_pcTrCoeff[comp] = NULL; 407 } 408 if ( m_explicitRdpcmMode[comp] ) 409 { 410 xFree(m_explicitRdpcmMode[comp]); 411 m_explicitRdpcmMode[comp] = NULL; 412 } 413 356 414 #if ADAPTIVE_QP_SELECTION 357 if (!m_ArlCoeffIsAliasedAllocation) 358 { 359 xFree(m_pcArlCoeffY); m_pcArlCoeffY = 0; 360 xFree(m_pcArlCoeffCb); m_pcArlCoeffCb = 0; 361 xFree(m_pcArlCoeffCr); m_pcArlCoeffCr = 0; 362 } 363 if ( m_pcGlbArlCoeffY ) { xFree(m_pcGlbArlCoeffY); m_pcGlbArlCoeffY = NULL; } 364 if ( m_pcGlbArlCoeffCb ) { xFree(m_pcGlbArlCoeffCb); m_pcGlbArlCoeffCb = NULL; } 365 if ( m_pcGlbArlCoeffCr ) { xFree(m_pcGlbArlCoeffCr); m_pcGlbArlCoeffCr = NULL; } 366 #endif 367 if ( m_pbIPCMFlag ) { xFree(m_pbIPCMFlag ); m_pbIPCMFlag = NULL; } 368 if ( m_pcIPCMSampleY ) { xFree(m_pcIPCMSampleY); m_pcIPCMSampleY = NULL; } 369 if ( m_pcIPCMSampleCb ) { xFree(m_pcIPCMSampleCb); m_pcIPCMSampleCb = NULL; } 370 if ( m_pcIPCMSampleCr ) { xFree(m_pcIPCMSampleCr); m_pcIPCMSampleCr = NULL; } 371 if ( m_apiMVPIdx[0] ) { delete[] m_apiMVPIdx[0]; m_apiMVPIdx[0] = NULL; } 372 if ( m_apiMVPIdx[1] ) { delete[] m_apiMVPIdx[1]; m_apiMVPIdx[1] = NULL; } 373 if ( m_apiMVPNum[0] ) { delete[] m_apiMVPNum[0]; m_apiMVPNum[0] = NULL; } 374 if ( m_apiMVPNum[1] ) { delete[] m_apiMVPNum[1]; m_apiMVPNum[1] = NULL; } 375 #if H_3D_NBDV 415 if (!m_ArlCoeffIsAliasedAllocation) 416 { 417 if ( m_pcArlCoeff[comp] ) 418 { 419 xFree(m_pcArlCoeff[comp]); 420 m_pcArlCoeff[comp] = NULL; 421 } 422 } 423 #endif 424 425 if ( m_pcIPCMSample[comp] ) 426 { 427 xFree(m_pcIPCMSample[comp]); 428 m_pcIPCMSample[comp] = NULL; 429 } 430 } 431 if ( m_pbIPCMFlag ) 432 { 433 xFree(m_pbIPCMFlag ); 434 m_pbIPCMFlag = NULL; 435 } 436 437 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 438 { 439 const RefPicList rpl=RefPicList(i); 440 if ( m_apiMVPIdx[rpl] ) 441 { 442 delete[] m_apiMVPIdx[rpl]; 443 m_apiMVPIdx[rpl] = NULL; 444 } 445 if ( m_apiMVPNum[rpl] ) 446 { 447 delete[] m_apiMVPNum[rpl]; 448 m_apiMVPNum[rpl] = NULL; 449 } 450 } 451 452 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 453 { 454 const RefPicList rpl=RefPicList(i); 455 m_acCUMvField[rpl].destroy(); 456 } 457 #if NH_3D_NBDV 376 458 if ( m_pDvInfo ) { xFree(m_pDvInfo); m_pDvInfo = NULL; } 377 459 #endif 378 460 379 461 380 #if H_3D_ARP381 if ( m_puhARPW ) { delete[] m_puhARPW;m_puhARPW = NULL; }382 #endif 383 #if H_3D_IC462 #if NH_3D_ARP 463 if ( m_puhARPW ) { xFree(m_puhARPW); m_puhARPW = NULL; } 464 #endif 465 #if NH_3D_IC 384 466 if ( m_pbICFlag ) { xFree(m_pbICFlag); m_pbICFlag = NULL; } 385 467 #endif 386 m_acCUMvField[0].destroy(); 387 m_acCUMvField[1].destroy(); 388 389 #if H_3D_DIM 390 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 391 { 392 if ( m_dimDeltaDC[i][0] ) { xFree( m_dimDeltaDC[i][0] ); m_dimDeltaDC[i][0] = NULL; } 393 if ( m_dimDeltaDC[i][1] ) { xFree( m_dimDeltaDC[i][1] ); m_dimDeltaDC[i][1] = NULL; } 394 } 395 #if H_3D_DIM_DMM 396 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 397 { 398 if ( m_dmmWedgeTabIdx[i] ) { xFree( m_dmmWedgeTabIdx[i] ); m_dmmWedgeTabIdx[i] = NULL; } 399 } 400 #endif 401 #if H_3D_DIM_SDC 468 469 #if NH_3D_DMM 470 for( Int i = 0; i < NUM_DMM; i++ ) 471 { 472 if ( m_dmmDeltaDC[i][0] ) { xFree( m_dmmDeltaDC[i][0] ); m_dmmDeltaDC[i][0] = NULL; } 473 if ( m_dmmDeltaDC[i][1] ) { xFree( m_dmmDeltaDC[i][1] ); m_dmmDeltaDC[i][1] = NULL; } 474 } 475 if ( m_dmm1WedgeTabIdx ) { xFree( m_dmm1WedgeTabIdx ); m_dmm1WedgeTabIdx = NULL; } 476 #endif 477 #if NH_3D_SDC_INTRA 402 478 if ( m_pbSDCFlag ) { xFree(m_pbSDCFlag); m_pbSDCFlag = NULL; } 403 479 if ( m_apSegmentDCOffset[0] ) { xFree(m_apSegmentDCOffset[0]); m_apSegmentDCOffset[0] = NULL; } 404 480 if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]); m_apSegmentDCOffset[1] = NULL; } 405 481 #endif 406 #endif 407 #if H_3D_DBBP 482 #if NH_3D_DBBP 408 483 if ( m_pbDBBPFlag ) { xFree(m_pbDBBPFlag); m_pbDBBPFlag = NULL; } 409 484 #endif 410 } 411 m_pcCUAboveLeft = NULL; 412 m_pcCUAboveRight = NULL; 413 m_pcCUAbove = NULL; 414 m_pcCULeft = NULL; 415 416 m_apcCUColocated[0] = NULL; 417 m_apcCUColocated[1] = NULL; 418 419 if( m_sliceStartCU ) 420 { 421 xFree(m_sliceStartCU); 422 m_sliceStartCU=NULL; 423 } 424 if(m_sliceSegmentStartCU ) 425 { 426 xFree(m_sliceSegmentStartCU); 427 m_sliceSegmentStartCU=NULL; 428 } 485 486 } 487 488 m_pcPic = NULL; 489 m_pcSlice = NULL; 490 491 m_pCtuAboveLeft = NULL; 492 m_pCtuAboveRight = NULL; 493 m_pCtuAbove = NULL; 494 m_pCtuLeft = NULL; 495 496 497 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 498 { 499 m_apcCUColocated[i] = NULL; 500 } 501 502 } 503 504 Bool TComDataCU::CUIsFromSameTile ( const TComDataCU *pCU /* Can be NULL */) const 505 { 506 return pCU!=NULL && 507 pCU->getSlice() != NULL && 508 m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()); 509 } 510 511 Bool TComDataCU::CUIsFromSameSliceAndTile ( const TComDataCU *pCU /* Can be NULL */) const 512 { 513 return pCU!=NULL && 514 pCU->getSlice() != NULL && 515 pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() && 516 m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()) 517 ; 518 } 519 520 Bool TComDataCU::CUIsFromSameSliceTileAndWavefrontRow( const TComDataCU *pCU /* Can be NULL */) const 521 { 522 return CUIsFromSameSliceAndTile(pCU) 523 && (!getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() || getPic()->getCtu(getCtuRsAddr())->getCUPelY() == getPic()->getCtu(pCU->getCtuRsAddr())->getCUPelY()); 524 } 525 526 Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx) 527 { 528 const TComSPS &sps=*(getSlice()->getSPS()); 529 530 const UInt picWidth = sps.getPicWidthInLumaSamples(); 531 const UInt picHeight = sps.getPicHeightInLumaSamples(); 532 const UInt granularityWidth = sps.getMaxCUWidth(); 533 534 const UInt cuPosX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[absPartIdx] ]; 535 const UInt cuPosY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[absPartIdx] ]; 536 537 return (((cuPosX+getWidth( absPartIdx))%granularityWidth==0||(cuPosX+getWidth( absPartIdx)==picWidth )) 538 && ((cuPosY+getHeight(absPartIdx))%granularityWidth==0||(cuPosY+getHeight(absPartIdx)==picHeight))); 429 539 } 430 540 … … 438 548 439 549 /** 440 - initialize top-level CU 441 - internal buffers are already created 442 - set values before encoding a CU 443 . 444 \param pcPic picture (TComPic) class pointer 445 \param iCUAddr CU address 550 Initialize top-level CU: create internal buffers and set initial values before encoding the CTU. 551 552 \param pcPic picture (TComPic) class pointer 553 \param ctuRsAddr CTU address in raster scan order 446 554 */ 447 Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr ) 448 { 449 555 Void TComDataCU::initCtu( TComPic* pcPic, UInt ctuRsAddr ) 556 { 557 558 const UInt maxCUWidth = pcPic->getPicSym()->getSPS().getMaxCUWidth(); 559 const UInt maxCUHeight= pcPic->getPicSym()->getSPS().getMaxCUHeight(); 450 560 m_pcPic = pcPic; 451 561 m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); 452 m_ uiCUAddr = iCUAddr;453 m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth;454 m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight;455 m_ uiAbsIdxInLCU= 0;562 m_ctuRsAddr = ctuRsAddr; 563 m_uiCUPelX = ( ctuRsAddr % pcPic->getFrameWidthInCtus() ) * maxCUWidth; 564 m_uiCUPelY = ( ctuRsAddr / pcPic->getFrameWidthInCtus() ) * maxCUHeight; 565 m_absZIdxInCtu = 0; 456 566 m_dTotalCost = MAX_DOUBLE; 457 567 m_uiTotalDistortion = 0; 458 568 m_uiTotalBits = 0; 459 569 m_uiTotalBins = 0; 460 m_uiNumPartition = pcPic->getNumPartInCU(); 461 462 for(Int i=0; i<pcPic->getNumPartInCU(); i++) 463 { 464 if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceCurStartCUAddr()) 465 { 466 m_sliceStartCU[i]=getSlice()->getSliceCurStartCUAddr(); 467 } 468 else 469 { 470 m_sliceStartCU[i]=pcPic->getCU(getAddr())->m_sliceStartCU[i]; 471 } 472 } 473 for(Int i=0; i<pcPic->getNumPartInCU(); i++) 474 { 475 if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceSegmentCurStartCUAddr()) 476 { 477 m_sliceSegmentStartCU[i]=getSlice()->getSliceSegmentCurStartCUAddr(); 478 } 479 else 480 { 481 m_sliceSegmentStartCU[i]=pcPic->getCU(getAddr())->m_sliceSegmentStartCU[i]; 482 } 483 } 484 485 Int partStartIdx = getSlice()->getSliceSegmentCurStartCUAddr() - pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr) * pcPic->getNumPartInCU(); 486 487 Int numElements = min<Int>( partStartIdx, m_uiNumPartition ); 488 for ( Int ui = 0; ui < numElements; ui++ ) 489 { 490 TComDataCU * pcFrom = pcPic->getCU(getAddr()); 491 m_skipFlag[ui] = pcFrom->getSkipFlag(ui); 492 #if H_3D 493 m_bDISFlag[ui] = pcFrom->getDISFlag(ui); 494 m_uiDISType[ui] = pcFrom->getDISType(ui); 495 #endif 496 m_pePartSize[ui] = pcFrom->getPartitionSize(ui); 497 m_pePredMode[ui] = pcFrom->getPredictionMode(ui); 498 m_CUTransquantBypass[ui] = pcFrom->getCUTransquantBypass(ui); 499 m_puhDepth[ui] = pcFrom->getDepth(ui); 500 #if H_3D_ARP 501 m_puhARPW [ui] = pcFrom->getARPW( ui ); 502 #endif 503 #if H_3D_IC 504 m_pbICFlag[ui] = pcFrom->m_pbICFlag[ui]; 505 #endif 506 507 m_puhWidth [ui] = pcFrom->getWidth(ui); 508 m_puhHeight [ui] = pcFrom->getHeight(ui); 509 m_puhTrIdx [ui] = pcFrom->getTransformIdx(ui); 510 m_puhTransformSkip[0][ui] = pcFrom->getTransformSkip(ui,TEXT_LUMA); 511 m_puhTransformSkip[1][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_U); 512 m_puhTransformSkip[2][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_V); 513 m_apiMVPIdx[0][ui] = pcFrom->m_apiMVPIdx[0][ui];; 514 m_apiMVPIdx[1][ui] = pcFrom->m_apiMVPIdx[1][ui]; 515 m_apiMVPNum[0][ui] = pcFrom->m_apiMVPNum[0][ui]; 516 m_apiMVPNum[1][ui] = pcFrom->m_apiMVPNum[1][ui]; 517 m_phQP[ui]=pcFrom->m_phQP[ui]; 518 m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui]; 519 m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui]; 520 #if H_3D_VSP 521 m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui]; 522 #endif 523 #if H_3D_SPIVMP 524 m_pbSPIVMPFlag[ui] = pcFrom->m_pbSPIVMPFlag[ui]; 525 #endif 526 m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui]; 527 m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui]; 528 m_puhInterDir[ui]=pcFrom->m_puhInterDir[ui]; 529 m_puhCbf[0][ui]=pcFrom->m_puhCbf[0][ui]; 530 m_puhCbf[1][ui]=pcFrom->m_puhCbf[1][ui]; 531 m_puhCbf[2][ui]=pcFrom->m_puhCbf[2][ui]; 532 m_pbIPCMFlag[ui] = pcFrom->m_pbIPCMFlag[ui]; 533 #if H_3D_DIM_SDC 534 m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui]; 535 #endif 536 #if H_3D_DBBP 537 m_pbDBBPFlag[ui] = pcFrom->m_pbDBBPFlag[ui]; 538 #endif 539 } 540 541 Int firstElement = max<Int>( partStartIdx, 0 ); 542 numElements = m_uiNumPartition - firstElement; 543 544 if ( numElements > 0 ) 545 { 546 memset( m_skipFlag + firstElement, false, numElements * sizeof( *m_skipFlag ) ); 547 #if H_3D 548 memset( m_bDISFlag + firstElement, false, numElements * sizeof( *m_bDISFlag ) ); 549 memset( m_uiDISType + firstElement, 0, numElements * sizeof( *m_uiDISType) ); 550 #endif 551 memset( m_pePartSize + firstElement, SIZE_NONE, numElements * sizeof( *m_pePartSize ) ); 552 memset( m_pePredMode + firstElement, MODE_NONE, numElements * sizeof( *m_pePredMode ) ); 553 memset( m_CUTransquantBypass+ firstElement, false, numElements * sizeof( *m_CUTransquantBypass) ); 554 memset( m_puhDepth + firstElement, 0, numElements * sizeof( *m_puhDepth ) ); 555 memset( m_puhTrIdx + firstElement, 0, numElements * sizeof( *m_puhTrIdx ) ); 556 memset( m_puhTransformSkip[0] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[0]) ); 557 memset( m_puhTransformSkip[1] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[1]) ); 558 memset( m_puhTransformSkip[2] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[2]) ); 559 memset( m_puhWidth + firstElement, g_uiMaxCUWidth, numElements * sizeof( *m_puhWidth ) ); 560 memset( m_puhHeight + firstElement, g_uiMaxCUHeight, numElements * sizeof( *m_puhHeight ) ); 561 memset( m_apiMVPIdx[0] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[0] ) ); 562 memset( m_apiMVPIdx[1] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[1] ) ); 563 memset( m_apiMVPNum[0] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[0] ) ); 564 memset( m_apiMVPNum[1] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[1] ) ); 565 memset( m_phQP + firstElement, getSlice()->getSliceQp(), numElements * sizeof( *m_phQP ) ); 566 memset( m_pbMergeFlag + firstElement, false, numElements * sizeof( *m_pbMergeFlag ) ); 567 memset( m_puhMergeIndex + firstElement, 0, numElements * sizeof( *m_puhMergeIndex ) ); 568 #if H_3D_VSP 569 memset( m_piVSPFlag + firstElement, 0, numElements * sizeof( *m_piVSPFlag ) ); 570 #endif 571 #if H_3D_SPIVMP 572 memset( m_pbSPIVMPFlag + firstElement, 0, numElements * sizeof( *m_pbSPIVMPFlag ) ); 573 #endif 574 memset( m_puhLumaIntraDir + firstElement, DC_IDX, numElements * sizeof( *m_puhLumaIntraDir ) ); 575 memset( m_puhChromaIntraDir + firstElement, 0, numElements * sizeof( *m_puhChromaIntraDir ) ); 576 memset( m_puhInterDir + firstElement, 0, numElements * sizeof( *m_puhInterDir ) ); 577 memset( m_puhCbf[0] + firstElement, 0, numElements * sizeof( *m_puhCbf[0] ) ); 578 memset( m_puhCbf[1] + firstElement, 0, numElements * sizeof( *m_puhCbf[1] ) ); 579 memset( m_puhCbf[2] + firstElement, 0, numElements * sizeof( *m_puhCbf[2] ) ); 580 memset( m_pbIPCMFlag + firstElement, false, numElements * sizeof( *m_pbIPCMFlag ) ); 581 #if H_3D_ARP 582 memset( m_puhARPW + firstElement, 0, numElements * sizeof( UChar ) ); 583 #endif 584 #if H_3D_IC 585 memset( m_pbICFlag + firstElement, false, numElements * sizeof( *m_pbICFlag ) ); 586 #endif 587 588 589 #if H_3D_DIM 590 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 591 { 592 memset( m_dimDeltaDC[i][0] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][0] ) ); 593 memset( m_dimDeltaDC[i][1] + firstElement, 0, numElements * sizeof( *m_dimDeltaDC[i][1] ) ); 594 } 595 #if H_3D_DIM_DMM 596 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 597 { 598 memset( m_dmmWedgeTabIdx[i] + firstElement, 0, numElements * sizeof( *m_dmmWedgeTabIdx[i] ) ); 599 } 600 #endif 601 #if H_3D_DIM_SDC 602 memset( m_pbSDCFlag + firstElement, 0, numElements * sizeof( *m_pbSDCFlag ) ); 603 memset( m_apSegmentDCOffset[0] + firstElement, 0, numElements * sizeof( *m_apSegmentDCOffset[0] ) ); 604 memset( m_apSegmentDCOffset[1] + firstElement, 0, numElements * sizeof( *m_apSegmentDCOffset[1] ) ); 605 #endif 606 m_apDmmPredictor[0] = 0; 607 m_apDmmPredictor[1] = 0; 608 #endif 609 #if H_3D_DBBP 610 memset( m_pbDBBPFlag + firstElement, false, numElements * sizeof( *m_pbDBBPFlag ) ); 611 #endif 612 } 613 614 UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight; 615 if ( 0 >= partStartIdx ) 616 { 617 m_acCUMvField[0].clearMvField(); 618 m_acCUMvField[1].clearMvField(); 619 memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); 570 m_uiNumPartition = pcPic->getNumPartitionsInCtu(); 571 572 memset( m_skipFlag , false, m_uiNumPartition * sizeof( *m_skipFlag ) ); 573 574 #if NH_3D_DIS 575 memset( m_bDISFlag , false, m_uiNumPartition * sizeof( *m_bDISFlag ) ); 576 memset( m_ucDISType , false, m_uiNumPartition * sizeof( *m_ucDISType ) ); 577 #endif 578 579 memset( m_pePartSize , NUMBER_OF_PART_SIZES, m_uiNumPartition * sizeof( *m_pePartSize ) ); 580 memset( m_pePredMode , NUMBER_OF_PREDICTION_MODES, m_uiNumPartition * sizeof( *m_pePredMode ) ); 581 memset( m_CUTransquantBypass, false, m_uiNumPartition * sizeof( *m_CUTransquantBypass) ); 582 memset( m_puhDepth , 0, m_uiNumPartition * sizeof( *m_puhDepth ) ); 583 memset( m_puhTrIdx , 0, m_uiNumPartition * sizeof( *m_puhTrIdx ) ); 584 memset( m_puhWidth , maxCUWidth, m_uiNumPartition * sizeof( *m_puhWidth ) ); 585 memset( m_puhHeight , maxCUHeight, m_uiNumPartition * sizeof( *m_puhHeight ) ); 586 587 #if NH_3D_IC 588 memset( m_pbICFlag , false, m_uiNumPartition * sizeof( *m_pbICFlag ) ); 589 #endif 590 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 591 { 592 const RefPicList rpl=RefPicList(i); 593 memset( m_apiMVPIdx[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPIdx[rpl] ) ); 594 memset( m_apiMVPNum[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPNum[rpl] ) ); 595 } 596 memset( m_phQP , getSlice()->getSliceQp(), m_uiNumPartition * sizeof( *m_phQP ) ); 597 memset( m_ChromaQpAdj , 0, m_uiNumPartition * sizeof( *m_ChromaQpAdj ) ); 598 for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 599 { 600 memset( m_crossComponentPredictionAlpha[comp] , 0, m_uiNumPartition * sizeof( *m_crossComponentPredictionAlpha[comp] ) ); 601 memset( m_puhTransformSkip[comp] , 0, m_uiNumPartition * sizeof( *m_puhTransformSkip[comp]) ); 602 memset( m_puhCbf[comp] , 0, m_uiNumPartition * sizeof( *m_puhCbf[comp] ) ); 603 memset( m_explicitRdpcmMode[comp] , NUMBER_OF_RDPCM_MODES, m_uiNumPartition * sizeof( *m_explicitRdpcmMode[comp] ) ); 604 } 605 memset( m_pbMergeFlag , false, m_uiNumPartition * sizeof( *m_pbMergeFlag ) ); 606 memset( m_puhMergeIndex , 0, m_uiNumPartition * sizeof( *m_puhMergeIndex ) ); 607 608 #if NH_3D_VSP 609 memset( m_piVSPFlag , 0, m_uiNumPartition * sizeof( *m_piVSPFlag ) ); 610 #endif 611 #if NH_3D_SPIVMP 612 memset( m_pbSPIVMPFlag , 0, m_uiNumPartition * sizeof( *m_pbSPIVMPFlag ) ); 613 #endif 614 #if NH_3D_SDC_INTRA 615 memset( m_pbSDCFlag, false, m_uiNumPartition * sizeof( *m_pbSDCFlag ) ); 616 #endif 617 #if NH_3D_DBBP 618 memset( m_pbDBBPFlag , false, m_uiNumPartition * sizeof( *m_pbDBBPFlag )); 619 #endif 620 621 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 622 { 623 memset( m_puhIntraDir[ch] , ((ch==0) ? DC_IDX : 0), m_uiNumPartition * sizeof( *(m_puhIntraDir[ch]) ) ); 624 } 625 626 #if NH_3D_ARP 627 memset( m_puhARPW , 0, m_uiNumPartition * sizeof( *m_puhARPW ) ); 628 #endif 629 630 631 #if NH_3D_DMM 632 for( Int i = 0; i < NUM_DMM; i++ ) 633 { 634 memset( m_dmmDeltaDC[i][0], 0, m_uiNumPartition * sizeof( *m_dmmDeltaDC[i][0] ) ); 635 memset( m_dmmDeltaDC[i][1], 0, m_uiNumPartition * sizeof( *m_dmmDeltaDC[i][1] ) ); 636 } 637 memset( m_dmm1WedgeTabIdx, 0, m_uiNumPartition * sizeof( *m_dmm1WedgeTabIdx ) ); 638 #endif 639 #if NH_3D_SDC_INTRA 640 memset( m_pbSDCFlag, false, m_uiNumPartition * sizeof( *m_pbSDCFlag ) ); 641 memset( m_apSegmentDCOffset[0], 0, m_uiNumPartition * sizeof( *m_apSegmentDCOffset[0] ) ); 642 memset( m_apSegmentDCOffset[1], 0, m_uiNumPartition * sizeof( *m_apSegmentDCOffset[1] ) ); 643 #endif 644 645 memset( m_puhInterDir , 0, m_uiNumPartition * sizeof( *m_puhInterDir ) ); 646 memset( m_pbIPCMFlag , false, m_uiNumPartition * sizeof( *m_pbIPCMFlag ) ); 647 648 const UInt numCoeffY = maxCUWidth*maxCUHeight; 649 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 650 { 651 const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(comp)) + m_pcPic->getComponentScaleY(ComponentID(comp)); 652 memset( m_pcTrCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); 620 653 #if ADAPTIVE_QP_SELECTION 621 memset( m_pcArlCoeffY , 0, sizeof( Int ) * uiTmp ); 622 #endif 623 memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); 624 uiTmp >>= 2; 625 memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); 626 memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); 627 #if ADAPTIVE_QP_SELECTION 628 memset( m_pcArlCoeffCb, 0, sizeof( Int ) * uiTmp ); 629 memset( m_pcArlCoeffCr, 0, sizeof( Int ) * uiTmp ); 630 #endif 631 memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); 632 memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); 633 } 634 else 635 { 636 TComDataCU * pcFrom = pcPic->getCU(getAddr()); 637 m_acCUMvField[0].copyFrom(&pcFrom->m_acCUMvField[0],m_uiNumPartition,0); 638 m_acCUMvField[1].copyFrom(&pcFrom->m_acCUMvField[1],m_uiNumPartition,0); 639 for(Int i=0; i<uiTmp; i++) 640 { 641 m_pcTrCoeffY[i]=pcFrom->m_pcTrCoeffY[i]; 642 #if ADAPTIVE_QP_SELECTION 643 m_pcArlCoeffY[i]=pcFrom->m_pcArlCoeffY[i]; 644 #endif 645 m_pcIPCMSampleY[i]=pcFrom->m_pcIPCMSampleY[i]; 646 } 647 for(Int i=0; i<(uiTmp>>2); i++) 648 { 649 m_pcTrCoeffCb[i]=pcFrom->m_pcTrCoeffCb[i]; 650 m_pcTrCoeffCr[i]=pcFrom->m_pcTrCoeffCr[i]; 651 #if ADAPTIVE_QP_SELECTION 652 m_pcArlCoeffCb[i]=pcFrom->m_pcArlCoeffCb[i]; 653 m_pcArlCoeffCr[i]=pcFrom->m_pcArlCoeffCr[i]; 654 #endif 655 m_pcIPCMSampleCb[i]=pcFrom->m_pcIPCMSampleCb[i]; 656 m_pcIPCMSampleCr[i]=pcFrom->m_pcIPCMSampleCr[i]; 657 } 654 memset( m_pcArlCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); 655 #endif 656 } 657 658 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 659 { 660 m_acCUMvField[i].clearMvField(); 658 661 } 659 662 660 663 // Setting neighbor CU 661 m_pcCULeft = NULL; 662 m_pcCUAbove = NULL; 663 m_pcCUAboveLeft = NULL; 664 m_pcCUAboveRight = NULL; 665 666 m_apcCUColocated[0] = NULL; 667 m_apcCUColocated[1] = NULL; 668 669 UInt uiWidthInCU = pcPic->getFrameWidthInCU(); 670 if ( m_uiCUAddr % uiWidthInCU ) 671 { 672 m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); 673 } 674 675 if ( m_uiCUAddr / uiWidthInCU ) 676 { 677 m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); 678 } 679 680 if ( m_pcCULeft && m_pcCUAbove ) 681 { 682 m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); 683 } 684 685 if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) 686 { 687 m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); 688 } 689 690 if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) 691 { 692 m_apcCUColocated[0] = getSlice()->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); 693 } 694 695 if ( getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) 696 { 697 m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); 698 } 699 } 700 701 /** initialize prediction data with enabling sub-LCU-level delta QP 702 *\param uiDepth depth of the current CU 703 *\param qp qp for the current CU 704 *- set CU width and CU height according to depth 705 *- set qp value according to input qp 706 *- set last-coded qp value according to input last-coded qp 664 m_pCtuLeft = NULL; 665 m_pCtuAbove = NULL; 666 m_pCtuAboveLeft = NULL; 667 m_pCtuAboveRight = NULL; 668 669 670 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 671 { 672 m_apcCUColocated[i] = NULL; 673 } 674 675 UInt frameWidthInCtus = pcPic->getFrameWidthInCtus(); 676 if ( m_ctuRsAddr % frameWidthInCtus ) 677 { 678 m_pCtuLeft = pcPic->getCtu( m_ctuRsAddr - 1 ); 679 } 680 681 if ( m_ctuRsAddr / frameWidthInCtus ) 682 { 683 m_pCtuAbove = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus ); 684 } 685 686 if ( m_pCtuLeft && m_pCtuAbove ) 687 { 688 m_pCtuAboveLeft = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus - 1 ); 689 } 690 691 if ( m_pCtuAbove && ( (m_ctuRsAddr%frameWidthInCtus) < (frameWidthInCtus-1) ) ) 692 { 693 m_pCtuAboveRight = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus + 1 ); 694 } 695 696 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 697 { 698 const RefPicList rpl=RefPicList(i); 699 if ( getSlice()->getNumRefIdx( rpl ) > 0 ) 700 { 701 m_apcCUColocated[rpl] = getSlice()->getRefPic( rpl, 0)->getCtu( m_ctuRsAddr ); 702 } 703 } 704 } 705 706 707 /** Initialize prediction data with enabling sub-CTU-level delta QP. 708 * - set CU width and CU height according to depth 709 * - set qp value according to input qp 710 * - set last-coded qp value according to input last-coded qp 711 * 712 * \param uiDepth depth of the current CU 713 * \param qp qp for the current CU 714 * \param bTransquantBypass true for transquant bypass 707 715 */ 708 Void TComDataCU::initEstData( UInt uiDepth, Int qp,Bool bTransquantBypass )716 Void TComDataCU::initEstData( const UInt uiDepth, const Int qp, const Bool bTransquantBypass ) 709 717 { 710 718 m_dTotalCost = MAX_DOUBLE; … … 713 721 m_uiTotalBins = 0; 714 722 715 UChar uhWidth = g_uiMaxCUWidth>> uiDepth;716 UChar uhHeight = g_uiMaxCUHeight>> uiDepth;723 const UChar uhWidth = getSlice()->getSPS()->getMaxCUWidth() >> uiDepth; 724 const UChar uhHeight = getSlice()->getSPS()->getMaxCUHeight() >> uiDepth; 717 725 718 726 for (UInt ui = 0; ui < m_uiNumPartition; ui++) 719 727 { 720 if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui >= getSlice()->getSliceSegmentCurStartCUAddr()) 721 { 722 m_apiMVPIdx[0][ui] = -1; 723 m_apiMVPIdx[1][ui] = -1; 724 m_apiMVPNum[0][ui] = -1; 725 m_apiMVPNum[1][ui] = -1; 726 m_puhDepth [ui] = uiDepth; 727 m_puhWidth [ui] = uhWidth; 728 m_puhHeight [ui] = uhHeight; 729 m_puhTrIdx [ui] = 0; 730 m_puhTransformSkip[0][ui] = 0; 731 m_puhTransformSkip[1][ui] = 0; 732 m_puhTransformSkip[2][ui] = 0; 733 m_skipFlag[ui] = false; 734 #if H_3D 735 m_bDISFlag[ui] = false; 736 m_uiDISType[ui] = 0; 737 #endif 738 m_pePartSize[ui] = SIZE_NONE; 739 m_pePredMode[ui] = MODE_NONE; 740 m_CUTransquantBypass[ui] = bTransquantBypass; 741 m_pbIPCMFlag[ui] = 0; 742 m_phQP[ui] = qp; 743 m_pbMergeFlag[ui] = 0; 744 m_puhMergeIndex[ui] = 0; 745 #if H_3D_VSP 746 m_piVSPFlag[ui] = 0; 747 #endif 748 #if H_3D_SPIVMP 749 m_pbSPIVMPFlag[ui] = 0; 750 #endif 751 m_puhLumaIntraDir[ui] = DC_IDX; 752 m_puhChromaIntraDir[ui] = 0; 753 m_puhInterDir[ui] = 0; 754 m_puhCbf[0][ui] = 0; 755 m_puhCbf[1][ui] = 0; 756 m_puhCbf[2][ui] = 0; 757 #if H_3D_ARP 728 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 729 { 730 const RefPicList rpl=RefPicList(i); 731 m_apiMVPIdx[rpl][ui] = -1; 732 m_apiMVPNum[rpl][ui] = -1; 733 } 734 m_puhDepth [ui] = uiDepth; 735 m_puhWidth [ui] = uhWidth; 736 m_puhHeight [ui] = uhHeight; 737 m_puhTrIdx [ui] = 0; 738 for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 739 { 740 m_crossComponentPredictionAlpha[comp][ui] = 0; 741 m_puhTransformSkip [comp][ui] = 0; 742 m_explicitRdpcmMode [comp][ui] = NUMBER_OF_RDPCM_MODES; 743 } 744 m_skipFlag[ui] = false; 745 #if NH_3D_DIS 746 m_bDISFlag[ui] = false; 747 m_ucDISType[ui] = 0; 748 #endif 749 m_pePartSize[ui] = NUMBER_OF_PART_SIZES; 750 m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; 751 m_CUTransquantBypass[ui] = bTransquantBypass; 752 m_pbIPCMFlag[ui] = 0; 753 m_phQP[ui] = qp; 754 m_ChromaQpAdj[ui] = 0; 755 m_pbMergeFlag[ui] = 0; 756 m_puhMergeIndex[ui] = 0; 757 #if NH_3D_VSP 758 m_piVSPFlag[ui] = 0; 759 #endif 760 #if NH_3D_SPIVMP 761 m_pbSPIVMPFlag[ui] = 0; 762 #endif 763 764 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 765 { 766 m_puhIntraDir[ch][ui] = ((ch==0) ? DC_IDX : 0); 767 } 768 769 m_puhInterDir[ui] = 0; 770 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 771 { 772 m_puhCbf[comp][ui] = 0; 773 } 774 #if NH_3D_ARP 758 775 m_puhARPW[ui] = 0; 759 776 #endif 760 #if H_3D_IC777 #if NH_3D_IC 761 778 m_pbICFlag[ui] = false; 762 779 #endif 763 780 764 781 765 #if H_3D_DIM 766 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 767 { 768 m_dimDeltaDC[i][0] [ui] = 0; 769 m_dimDeltaDC[i][1] [ui] = 0; 770 } 771 #if H_3D_DIM_DMM 772 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 773 { 774 m_dmmWedgeTabIdx[i] [ui] = 0; 775 } 776 #endif 777 #if H_3D_DIM_SDC 782 #if NH_3D_DMM 783 for( Int i = 0; i < NUM_DMM; i++ ) 784 { 785 m_dmmDeltaDC[i][0] [ui] = 0; 786 m_dmmDeltaDC[i][1] [ui] = 0; 787 } 788 m_dmm1WedgeTabIdx [ui] = 0; 789 #endif 790 #if NH_3D_SDC_INTRA 778 791 m_pbSDCFlag [ui] = false; 779 792 m_apSegmentDCOffset[0][ui] = 0; 780 793 m_apSegmentDCOffset[1][ui] = 0; 781 794 #endif 782 m_apDmmPredictor[0] = 0; 783 m_apDmmPredictor[1] = 0; 784 #endif 785 #if H_3D_DBBP 795 #if NH_3D_DBBP 786 796 m_pbDBBPFlag[ui] = false; 787 797 #endif 788 } 789 } 790 791 if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU >= getSlice()->getSliceSegmentCurStartCUAddr()) 792 { 793 m_acCUMvField[0].clearMvField(); 794 m_acCUMvField[1].clearMvField(); 795 UInt uiTmp = uhWidth*uhHeight; 796 797 memset( m_pcTrCoeffY, 0, uiTmp * sizeof( *m_pcTrCoeffY ) ); 798 } 799 800 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 801 { 802 m_acCUMvField[i].clearMvField(); 803 } 804 805 const UInt numCoeffY = uhWidth*uhHeight; 806 807 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 808 { 809 const ComponentID component = ComponentID(comp); 810 const UInt numCoeff = numCoeffY >> (getPic()->getComponentScaleX(component) + getPic()->getComponentScaleY(component)); 811 memset( m_pcTrCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); 798 812 #if ADAPTIVE_QP_SELECTION 799 memset( m_pcArlCoeffY , 0, uiTmp * sizeof( *m_pcArlCoeffY ) ); 800 #endif 801 memset( m_pcIPCMSampleY, 0, uiTmp * sizeof( *m_pcIPCMSampleY ) ); 802 803 uiTmp>>=2; 804 memset( m_pcTrCoeffCb, 0, uiTmp * sizeof( *m_pcTrCoeffCb ) ); 805 memset( m_pcTrCoeffCr, 0, uiTmp * sizeof( *m_pcTrCoeffCr ) ); 806 #if ADAPTIVE_QP_SELECTION 807 memset( m_pcArlCoeffCb, 0, uiTmp * sizeof( *m_pcArlCoeffCb ) ); 808 memset( m_pcArlCoeffCr, 0, uiTmp * sizeof( *m_pcArlCoeffCr ) ); 809 #endif 810 memset( m_pcIPCMSampleCb, 0, uiTmp * sizeof( *m_pcIPCMSampleCb ) ); 811 memset( m_pcIPCMSampleCr, 0, uiTmp * sizeof( *m_pcIPCMSampleCr ) ); 813 memset( m_pcArlCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); 814 #endif 815 memset( m_pcIPCMSample[comp], 0, numCoeff * sizeof( Pel) ); 812 816 } 813 817 } … … 822 826 823 827 m_pcPic = pcCU->getPic(); 824 m_pcSlice = m_pcPic->getSlice(m_pcPic->getCurrSliceIdx()); 825 m_uiCUAddr = pcCU->getAddr(); 826 m_uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset; 827 828 m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth>>uiDepth )*( uiPartUnitIdx & 1 ); 829 m_uiCUPelY = pcCU->getCUPelY() + ( g_uiMaxCUHeight>>uiDepth )*( uiPartUnitIdx >> 1 ); 828 m_pcSlice = pcCU->getSlice(); 829 m_ctuRsAddr = pcCU->getCtuRsAddr(); 830 m_absZIdxInCtu = pcCU->getZorderIdxInCtu() + uiPartOffset; 831 832 const UChar uhWidth = getSlice()->getSPS()->getMaxCUWidth() >> uiDepth; 833 const UChar uhHeight = getSlice()->getSPS()->getMaxCUHeight() >> uiDepth; 834 835 m_uiCUPelX = pcCU->getCUPelX() + ( uhWidth )*( uiPartUnitIdx & 1 ); 836 m_uiCUPelY = pcCU->getCUPelY() + ( uhHeight)*( uiPartUnitIdx >> 1 ); 830 837 831 838 m_dTotalCost = MAX_DOUBLE; … … 837 844 Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; 838 845 Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; 839 840 846 Int sizeInChar = sizeof( Char ) * m_uiNumPartition; 847 841 848 memset( m_phQP, qp, sizeInChar ); 842 843 849 memset( m_pbMergeFlag, 0, iSizeInBool ); 844 850 memset( m_puhMergeIndex, 0, iSizeInUchar ); 845 #if H_3D_VSP851 #if NH_3D_VSP 846 852 memset( m_piVSPFlag, 0, sizeof( Char ) * m_uiNumPartition ); 847 853 #endif 848 #if H_3D_SPIVMP854 #if NH_3D_SPIVMP 849 855 memset( m_pbSPIVMPFlag, 0, sizeof( Bool ) * m_uiNumPartition ); 850 856 #endif 851 memset( m_puhLumaIntraDir, DC_IDX, iSizeInUchar ); 852 memset( m_puhChromaIntraDir, 0, iSizeInUchar ); 857 858 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 859 { 860 memset( m_puhIntraDir[ch], ((ch==0) ? DC_IDX : 0), iSizeInUchar ); 861 } 862 853 863 memset( m_puhInterDir, 0, iSizeInUchar ); 854 864 memset( m_puhTrIdx, 0, iSizeInUchar ); 855 memset( m_puhTransformSkip[0], 0, iSizeInUchar ); 856 memset( m_puhTransformSkip[1], 0, iSizeInUchar ); 857 memset( m_puhTransformSkip[2], 0, iSizeInUchar ); 858 memset( m_puhCbf[0], 0, iSizeInUchar ); 859 memset( m_puhCbf[1], 0, iSizeInUchar ); 860 memset( m_puhCbf[2], 0, iSizeInUchar ); 865 866 for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 867 { 868 memset( m_crossComponentPredictionAlpha[comp], 0, iSizeInUchar ); 869 memset( m_puhTransformSkip[comp], 0, iSizeInUchar ); 870 memset( m_puhCbf[comp], 0, iSizeInUchar ); 871 memset( m_explicitRdpcmMode[comp], NUMBER_OF_RDPCM_MODES, iSizeInUchar ); 872 } 873 861 874 memset( m_puhDepth, uiDepth, iSizeInUchar ); 862 #if H_3D_ARP863 memset( m_puhARPW, 0, iSizeInUchar );864 #endif865 866 867 UChar uhWidth = g_uiMaxCUWidth >> uiDepth;868 UChar uhHeight = g_uiMaxCUHeight >> uiDepth;869 875 memset( m_puhWidth, uhWidth, iSizeInUchar ); 870 876 memset( m_puhHeight, uhHeight, iSizeInUchar ); 871 877 memset( m_pbIPCMFlag, 0, iSizeInBool ); 872 #if H_3D_IC 878 #if NH_3D_ARP 879 memset( m_puhARPW, 0, iSizeInUchar ); 880 #endif 881 #if NH_3D_IC 873 882 memset( m_pbICFlag, 0, iSizeInBool ); 874 883 #endif 875 #if H_3D_DIM 876 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 877 { 878 memset( m_dimDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition ); 879 memset( m_dimDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition ); 880 } 881 #if H_3D_DIM_DMM 882 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 883 { 884 memset( m_dmmWedgeTabIdx[i], 0, sizeof(UInt) * m_uiNumPartition ); 885 } 886 #endif 887 #if H_3D_DIM_SDC 884 #if NH_3D_DMM 885 for( Int i = 0; i < NUM_DMM; i++ ) 886 { 887 memset( m_dmmDeltaDC[i][0], 0, sizeof(Pel ) * m_uiNumPartition ); 888 memset( m_dmmDeltaDC[i][1], 0, sizeof(Pel ) * m_uiNumPartition ); 889 } 890 memset( m_dmm1WedgeTabIdx, 0, sizeof(UInt) * m_uiNumPartition ); 891 #endif 892 #if NH_3D_SDC_INTRA 888 893 memset( m_pbSDCFlag, 0, sizeof(Bool) * m_uiNumPartition ); 889 894 memset( m_apSegmentDCOffset[0], 0, sizeof(Pel) * m_uiNumPartition ); 890 895 memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition ); 891 896 #endif 892 m_apDmmPredictor[0] = 0; 893 m_apDmmPredictor[1] = 0; 894 #endif 895 #if H_3D_DBBP 896 memset( m_pbDBBPFlag, 0, iSizeInBool ); 897 #if NH_3D_DBBP 898 memset( m_pbDBBPFlag, 0, sizeof(Bool) * m_uiNumPartition ); 897 899 #endif 898 900 … … 900 902 { 901 903 m_skipFlag[ui] = false; 902 #if H_3D904 #if NH_3D_DIS 903 905 m_bDISFlag[ui] = false; 904 m_uiDISType[ui] = 0; 905 #endif 906 m_pePartSize[ui] = SIZE_NONE; 907 m_pePredMode[ui] = MODE_NONE; 906 m_ucDISType[ui] = 0; 907 #endif 908 909 m_pePartSize[ui] = NUMBER_OF_PART_SIZES; 910 m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; 908 911 m_CUTransquantBypass[ui] = false; 909 m_apiMVPIdx[0][ui] = -1; 910 m_apiMVPIdx[1][ui] = -1; 911 m_apiMVPNum[0][ui] = -1; 912 m_apiMVPNum[1][ui] = -1; 913 if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui<getSlice()->getSliceSegmentCurStartCUAddr()) 914 { 915 m_apiMVPIdx[0][ui] = pcCU->m_apiMVPIdx[0][uiPartOffset+ui]; 916 m_apiMVPIdx[1][ui] = pcCU->m_apiMVPIdx[1][uiPartOffset+ui];; 917 m_apiMVPNum[0][ui] = pcCU->m_apiMVPNum[0][uiPartOffset+ui];; 918 m_apiMVPNum[1][ui] = pcCU->m_apiMVPNum[1][uiPartOffset+ui];; 919 m_puhDepth [ui] = pcCU->getDepth(uiPartOffset+ui); 920 m_puhWidth [ui] = pcCU->getWidth(uiPartOffset+ui); 921 m_puhHeight [ui] = pcCU->getHeight(uiPartOffset+ui); 922 m_puhTrIdx [ui] = pcCU->getTransformIdx(uiPartOffset+ui); 923 m_puhTransformSkip[0][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_LUMA); 924 m_puhTransformSkip[1][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_U); 925 m_puhTransformSkip[2][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_V); 926 m_skipFlag[ui] = pcCU->getSkipFlag(uiPartOffset+ui); 927 #if H_3D 912 m_ChromaQpAdj[ui] = 0; 913 914 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 915 { 916 const RefPicList rpl=RefPicList(i); 917 m_apiMVPIdx[rpl][ui] = -1; 918 m_apiMVPNum[rpl][ui] = -1; 919 } 920 #if NH_3D_DIS 928 921 m_bDISFlag[ui] = pcCU->getDISFlag(uiPartOffset+ui); 929 m_uiDISType[ui] = pcCU->getDISType(uiPartOffset+ui); 930 #endif 931 m_pePartSize[ui] = pcCU->getPartitionSize(uiPartOffset+ui); 932 m_pePredMode[ui] = pcCU->getPredictionMode(uiPartOffset+ui); 933 m_CUTransquantBypass[ui] = pcCU->getCUTransquantBypass(uiPartOffset+ui); 934 m_pbIPCMFlag[ui]=pcCU->m_pbIPCMFlag[uiPartOffset+ui]; 935 m_phQP[ui] = pcCU->m_phQP[uiPartOffset+ui]; 936 m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui]; 937 m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui]; 938 #if H_3D_VSP 939 m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui]; 940 m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui]; 941 #endif 942 #if H_3D_SPIVMP 943 m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui]; 944 #endif 945 m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui]; 946 m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui]; 947 m_puhInterDir[ui]=pcCU->m_puhInterDir[uiPartOffset+ui]; 948 m_puhCbf[0][ui]=pcCU->m_puhCbf[0][uiPartOffset+ui]; 949 m_puhCbf[1][ui]=pcCU->m_puhCbf[1][uiPartOffset+ui]; 950 m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui]; 951 952 #if H_3D_ARP 922 m_ucDISType[ui] = pcCU->getDISType(uiPartOffset+ui); 923 #endif 924 #if NH_3D_VSP 925 m_piVSPFlag[ui] = pcCU->m_piVSPFlag[uiPartOffset+ui]; 926 m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui]; 927 #endif 928 #if NH_3D_SPIVMP 929 m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui]; 930 #endif 931 #if NH_3D_ARP 953 932 m_puhARPW [ui] = pcCU->getARPW( uiPartOffset+ui ); 954 933 #endif 955 #if H_3D_IC934 #if NH_3D_IC 956 935 m_pbICFlag [ui] = pcCU->m_pbICFlag[uiPartOffset+ui]; 957 936 #endif 958 #if H_3D_DIM 959 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 960 { 961 m_dimDeltaDC[i][0] [ui] = pcCU->m_dimDeltaDC[i][0] [uiPartOffset+ui]; 962 m_dimDeltaDC[i][1] [ui] = pcCU->m_dimDeltaDC[i][1] [uiPartOffset+ui]; 963 } 964 #if H_3D_DIM_DMM 965 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 966 { 967 m_dmmWedgeTabIdx[i] [ui] = pcCU->m_dmmWedgeTabIdx[i] [uiPartOffset+ui]; 968 } 969 #endif 970 #if H_3D_DIM_SDC 971 m_pbSDCFlag [ui] = pcCU->m_pbSDCFlag [ uiPartOffset + ui ]; 972 m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ]; 973 m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ]; 974 #endif 975 #endif 976 #if H_3D_DBBP 937 #if NH_3D_DMM 938 for( Int i = 0; i < NUM_DMM; i++ ) 939 { 940 m_dmmDeltaDC[i][0] [ui] = pcCU->m_dmmDeltaDC[i][0] [uiPartOffset+ui]; 941 m_dmmDeltaDC[i][1] [ui] = pcCU->m_dmmDeltaDC[i][1] [uiPartOffset+ui]; 942 } 943 m_dmm1WedgeTabIdx [ui] = pcCU->m_dmm1WedgeTabIdx [uiPartOffset+ui]; 944 #endif 945 #if NH_3D_SDC_INTRA 946 m_pbSDCFlag [ui] = pcCU->m_pbSDCFlag [ uiPartOffset + ui ]; 947 m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ]; 948 m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ]; 949 #endif 950 #if NH_3D_DBBP 977 951 m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui]; 978 952 #endif 979 } 980 } 981 UInt uiTmp = uhWidth*uhHeight; 982 memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); 983 #if ADAPTIVE_QP_SELECTION 984 memset( m_pcArlCoeffY , 0, sizeof(Int)*uiTmp ); 985 #endif 986 memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); 987 uiTmp >>= 2; 988 memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); 989 memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); 953 } 954 955 const UInt numCoeffY = uhWidth*uhHeight; 956 for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) 957 { 958 const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(ch)) + m_pcPic->getComponentScaleY(ComponentID(ch)); 959 memset( m_pcTrCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); 990 960 #if ADAPTIVE_QP_SELECTION 991 memset( m_pcArlCoeffCb, 0, sizeof(Int)*uiTmp ); 992 memset( m_pcArlCoeffCr, 0, sizeof(Int)*uiTmp ); 993 #endif 994 memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); 995 memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); 996 m_acCUMvField[0].clearMvField(); 997 m_acCUMvField[1].clearMvField(); 998 999 if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU<getSlice()->getSliceSegmentCurStartCUAddr()) 1000 { 1001 // Part of this CU contains data from an older slice. Now copy in that data. 1002 UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); 1003 UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); 1004 TComDataCU * bigCU = getPic()->getCU(getAddr()); 1005 Int minui = uiPartOffset; 1006 minui = -minui; 1007 pcCU->m_acCUMvField[0].copyTo(&m_acCUMvField[0],minui,uiPartOffset,m_uiNumPartition); 1008 pcCU->m_acCUMvField[1].copyTo(&m_acCUMvField[1],minui,uiPartOffset,m_uiNumPartition); 1009 UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*m_uiAbsIdxInLCU/pcCU->getPic()->getNumPartInCU(); 1010 uiTmp = uhWidth*uhHeight; 1011 for(Int i=0; i<uiTmp; i++) 1012 { 1013 m_pcTrCoeffY[i]=bigCU->m_pcTrCoeffY[uiCoffOffset+i]; 1014 #if ADAPTIVE_QP_SELECTION 1015 m_pcArlCoeffY[i]=bigCU->m_pcArlCoeffY[uiCoffOffset+i]; 1016 #endif 1017 m_pcIPCMSampleY[i]=bigCU->m_pcIPCMSampleY[uiCoffOffset+i]; 1018 } 1019 uiTmp>>=2; 1020 uiCoffOffset>>=2; 1021 for(Int i=0; i<uiTmp; i++) 1022 { 1023 m_pcTrCoeffCr[i]=bigCU->m_pcTrCoeffCr[uiCoffOffset+i]; 1024 m_pcTrCoeffCb[i]=bigCU->m_pcTrCoeffCb[uiCoffOffset+i]; 1025 #if ADAPTIVE_QP_SELECTION 1026 m_pcArlCoeffCr[i]=bigCU->m_pcArlCoeffCr[uiCoffOffset+i]; 1027 m_pcArlCoeffCb[i]=bigCU->m_pcArlCoeffCb[uiCoffOffset+i]; 1028 #endif 1029 m_pcIPCMSampleCb[i]=bigCU->m_pcIPCMSampleCb[uiCoffOffset+i]; 1030 m_pcIPCMSampleCr[i]=bigCU->m_pcIPCMSampleCr[uiCoffOffset+i]; 1031 } 1032 } 1033 1034 m_pcCULeft = pcCU->getCULeft(); 1035 m_pcCUAbove = pcCU->getCUAbove(); 1036 m_pcCUAboveLeft = pcCU->getCUAboveLeft(); 1037 m_pcCUAboveRight = pcCU->getCUAboveRight(); 1038 1039 m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); 1040 m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); 1041 memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); 1042 memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); 961 memset( m_pcArlCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); 962 #endif 963 memset( m_pcIPCMSample[ch], 0, sizeof(Pel)* (numCoeffY>>componentShift) ); 964 } 965 966 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 967 { 968 m_acCUMvField[i].clearMvField(); 969 } 970 971 m_pCtuLeft = pcCU->getCtuLeft(); 972 m_pCtuAbove = pcCU->getCtuAbove(); 973 m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); 974 m_pCtuAboveRight = pcCU->getCtuAboveRight(); 975 976 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 977 { 978 m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); 979 } 1043 980 } 1044 981 1045 982 Void TComDataCU::setOutsideCUPart( UInt uiAbsPartIdx, UInt uiDepth ) 1046 983 { 1047 UIntuiNumPartition = m_uiNumPartition >> (uiDepth << 1);1048 UInt uiSizeInUchar= sizeof( UChar ) * uiNumPartition;1049 1050 UChar uhWidth = g_uiMaxCUWidth>> uiDepth;1051 UChar uhHeight = g_uiMaxCUHeight>> uiDepth;984 const UInt uiNumPartition = m_uiNumPartition >> (uiDepth << 1); 985 const UInt uiSizeInUchar = sizeof( UChar ) * uiNumPartition; 986 const TComSPS &sps = *(getSlice()->getSPS()); 987 const UChar uhWidth = sps.getMaxCUWidth() >> uiDepth; 988 const UChar uhHeight = sps.getMaxCUHeight() >> uiDepth; 1052 989 memset( m_puhDepth + uiAbsPartIdx, uiDepth, uiSizeInUchar ); 1053 990 memset( m_puhWidth + uiAbsPartIdx, uhWidth, uiSizeInUchar ); … … 1059 996 // -------------------------------------------------------------------------------------------------------------------- 1060 997 1061 Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx , UInt uiDepth)998 Void TComDataCU::copySubCU( TComDataCU* pcCU, UInt uiAbsPartIdx ) 1062 999 { 1063 1000 UInt uiPart = uiAbsPartIdx; 1064 1001 1065 1002 m_pcPic = pcCU->getPic(); 1066 1003 m_pcSlice = pcCU->getSlice(); 1067 m_ uiCUAddr = pcCU->getAddr();1068 m_ uiAbsIdxInLCU= uiAbsPartIdx;1069 1004 m_ctuRsAddr = pcCU->getCtuRsAddr(); 1005 m_absZIdxInCtu = uiAbsPartIdx; 1006 1070 1007 m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1071 1008 m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1072 1009 1073 1010 m_skipFlag=pcCU->getSkipFlag() + uiPart; 1074 #if H_3D1011 #if NH_3D_DIS 1075 1012 m_bDISFlag = pcCU->getDISFlag() + uiPart; 1076 m_uiDISType = pcCU->getDISType() + uiPart; 1077 #endif 1013 m_ucDISType = pcCU->getDISType() + uiPart; 1014 #endif 1015 1078 1016 m_phQP=pcCU->getQP() + uiPart; 1017 m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiPart; 1079 1018 m_pePartSize = pcCU->getPartitionSize() + uiPart; 1080 1019 m_pePredMode=pcCU->getPredictionMode() + uiPart; 1081 1020 m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; 1082 1083 #if H_3D_NBDV 1021 #if NH_3D_NBDV 1084 1022 m_pDvInfo = pcCU->getDvInfo() + uiPart; 1085 1023 #endif 1024 1086 1025 m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; 1087 1026 m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; 1088 #if H_3D_VSP1027 #if NH_3D_VSP 1089 1028 m_piVSPFlag = pcCU->getVSPFlag() + uiPart; 1090 1029 #endif 1091 #if H_3D_SPIVMP1030 #if NH_3D_SPIVMP 1092 1031 m_pbSPIVMPFlag = pcCU->getSPIVMPFlag() + uiPart; 1093 1032 #endif 1094 #if H_3D_ARP1033 #if NH_3D_ARP 1095 1034 m_puhARPW = pcCU->getARPW() + uiPart; 1096 1035 #endif 1097 #if H_3D_IC1036 #if NH_3D_IC 1098 1037 m_pbICFlag = pcCU->getICFlag() + uiPart; 1099 1038 #endif 1100 m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; 1101 m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; 1039 1040 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 1041 { 1042 m_puhIntraDir[ch] = pcCU->getIntraDir(ChannelType(ch)) + uiPart; 1043 } 1044 1102 1045 m_puhInterDir = pcCU->getInterDir() + uiPart; 1103 1046 m_puhTrIdx = pcCU->getTransformIdx() + uiPart; 1104 m_puhTransformSkip[0] = pcCU->getTransformSkip(TEXT_LUMA) + uiPart; 1105 m_puhTransformSkip[1] = pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPart; 1106 m_puhTransformSkip[2] = pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPart; 1107 1108 m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; 1109 m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; 1110 m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; 1111 #if H_3D_DIM 1112 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 1113 { 1114 m_dimDeltaDC[i][0] = pcCU->getDimDeltaDC( i, 0 ) + uiPart; 1115 m_dimDeltaDC[i][1] = pcCU->getDimDeltaDC( i, 1 ) + uiPart; 1116 } 1117 #if H_3D_DIM_DMM 1118 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 1119 { 1120 m_dmmWedgeTabIdx[i] = pcCU->getDmmWedgeTabIdx( i ) + uiPart; 1121 } 1122 #endif 1123 #if H_3D_DIM_SDC 1047 1048 for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 1049 { 1050 m_crossComponentPredictionAlpha[comp] = pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)) + uiPart; 1051 m_puhTransformSkip[comp] = pcCU->getTransformSkip(ComponentID(comp)) + uiPart; 1052 m_puhCbf[comp] = pcCU->getCbf(ComponentID(comp)) + uiPart; 1053 m_explicitRdpcmMode[comp] = pcCU->getExplicitRdpcmMode(ComponentID(comp)) + uiPart; 1054 } 1055 #if NH_3D_DMM 1056 for( Int i = 0; i < NUM_DMM; i++ ) 1057 { 1058 m_dmmDeltaDC[i][0] = pcCU->getDmmDeltaDC( (DmmID)i, 0 ) + uiPart; 1059 m_dmmDeltaDC[i][1] = pcCU->getDmmDeltaDC( (DmmID)i, 1 ) + uiPart; 1060 } 1061 m_dmm1WedgeTabIdx = pcCU->getDmm1WedgeTabIdx() + uiPart; 1062 #endif 1063 #if NH_3D_SDC_INTRA 1124 1064 m_pbSDCFlag = pcCU->getSDCFlag() + uiPart; 1125 1065 m_apSegmentDCOffset[0] = pcCU->getSDCSegmentDCOffset(0) + uiPart; 1126 1066 m_apSegmentDCOffset[1] = pcCU->getSDCSegmentDCOffset(1) + uiPart; 1127 1067 #endif 1128 #endif 1129 #if H_3D_DBBP 1068 #if NH_3D_DBBP 1130 1069 m_pbDBBPFlag = pcCU->getDBBPFlag() + uiPart; 1131 1070 #endif 1071 1132 1072 m_puhDepth=pcCU->getDepth() + uiPart; 1133 1073 m_puhWidth=pcCU->getWidth() + uiPart; 1134 1074 m_puhHeight=pcCU->getHeight() + uiPart; 1135 1136 m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; 1137 m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; 1138 m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; 1139 m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; 1140 1075 1141 1076 m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; 1142 1077 1143 m_pcCUAboveLeft = pcCU->getCUAboveLeft(); 1144 m_pcCUAboveRight = pcCU->getCUAboveRight(); 1145 m_pcCUAbove = pcCU->getCUAbove(); 1146 m_pcCULeft = pcCU->getCULeft(); 1147 1148 m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); 1149 m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); 1150 1078 m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); 1079 m_pCtuAboveRight = pcCU->getCtuAboveRight(); 1080 m_pCtuAbove = pcCU->getCtuAbove(); 1081 m_pCtuLeft = pcCU->getCtuLeft(); 1082 1083 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 1084 { 1085 const RefPicList rpl=RefPicList(i); 1086 m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); 1087 m_apiMVPIdx[rpl]=pcCU->getMVPIdx(rpl) + uiPart; 1088 m_apiMVPNum[rpl]=pcCU->getMVPNum(rpl) + uiPart; 1089 } 1090 1091 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 1092 { 1093 const RefPicList rpl=RefPicList(i); 1094 m_acCUMvField[rpl].linkToWithOffset( pcCU->getCUMvField(rpl), uiPart ); 1095 } 1096 1151 1097 UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); 1152 1098 UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); 1153 1154 UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); 1155 1156 m_pcTrCoeffY = pcCU->getCoeffY() + uiCoffOffset; 1099 1100 UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartitionsInCtu(); 1101 1102 for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) 1103 { 1104 const ComponentID component = ComponentID(ch); 1105 const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); 1106 const UInt offset = uiCoffOffset >> componentShift; 1107 m_pcTrCoeff[ch] = pcCU->getCoeff(component) + offset; 1157 1108 #if ADAPTIVE_QP_SELECTION 1158 m_pcArlCoeffY= pcCU->getArlCoeffY() + uiCoffOffset; 1159 #endif 1160 m_pcIPCMSampleY = pcCU->getPCMSampleY() + uiCoffOffset; 1161 1162 uiCoffOffset >>=2; 1163 m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; 1164 m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; 1165 #if ADAPTIVE_QP_SELECTION 1166 m_pcArlCoeffCb=pcCU->getArlCoeffCb() + uiCoffOffset; 1167 m_pcArlCoeffCr=pcCU->getArlCoeffCr() + uiCoffOffset; 1168 #endif 1169 m_pcIPCMSampleCb = pcCU->getPCMSampleCb() + uiCoffOffset; 1170 m_pcIPCMSampleCr = pcCU->getPCMSampleCr() + uiCoffOffset; 1171 1172 m_acCUMvField[0].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_0), uiPart ); 1173 m_acCUMvField[1].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_1), uiPart ); 1174 memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); 1175 memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); 1176 } 1177 #if H_3D_NBDV 1109 m_pcArlCoeff[ch] = pcCU->getArlCoeff(component) + offset; 1110 #endif 1111 m_pcIPCMSample[ch] = pcCU->getPCMSample(component) + offset; 1112 } 1113 } 1114 1115 #if NH_3D_NBDV 1178 1116 Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx) 1179 1117 { … … 1181 1119 } 1182 1120 #endif 1121 1183 1122 // Copy inter prediction info from the biggest CU 1184 1123 Void TComDataCU::copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList 1185 #if H_3D_NBDV1124 #if NH_3D_NBDV 1186 1125 , Bool bNBDV 1187 1126 #endif 1188 1127 ) 1189 1128 { 1190 1129 m_pcPic = pcCU->getPic(); 1191 1130 m_pcSlice = pcCU->getSlice(); 1192 m_ uiCUAddr = pcCU->getAddr();1193 m_ uiAbsIdxInLCU= uiAbsPartIdx;1194 1131 m_ctuRsAddr = pcCU->getCtuRsAddr(); 1132 m_absZIdxInCtu = uiAbsPartIdx; 1133 1195 1134 Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; 1196 m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); 1197 m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); 1198 1199 m_pcCUAboveLeft = pcCU->getCUAboveLeft(); 1200 m_pcCUAboveRight = pcCU->getCUAboveRight(); 1201 m_pcCUAbove = pcCU->getCUAbove(); 1202 m_pcCULeft = pcCU->getCULeft(); 1203 1204 m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); 1205 m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); 1206 1135 m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInCtuWidth() ); 1136 m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInCtuWidth() ); 1137 1138 m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); 1139 m_pCtuAboveRight = pcCU->getCtuAboveRight(); 1140 m_pCtuAbove = pcCU->getCtuAbove(); 1141 m_pCtuLeft = pcCU->getCtuLeft(); 1142 1143 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 1144 { 1145 m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); 1146 } 1147 1207 1148 m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; 1208 #if H_3D1149 #if NH_3D_DIS 1209 1150 m_bDISFlag = pcCU->getDISFlag () + uiAbsPartIdx; 1210 m_uiDISType = pcCU->getDISType() + uiAbsPartIdx; 1211 #endif 1151 m_ucDISType = pcCU->getDISType() + uiAbsPartIdx; 1152 #endif 1153 1212 1154 m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; 1213 #if H_3D_NBDV1155 #if NH_3D_NBDV 1214 1156 if(bNBDV == true) 1215 1157 { … … 1222 1164 #endif 1223 1165 m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; 1166 m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiAbsPartIdx; 1224 1167 m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; 1225 1168 m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; 1226 1169 1227 1170 m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; 1228 1171 m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; 1229 1172 m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; 1230 1173 1231 1174 m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; 1232 1175 m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; 1233 #if H_3D_VSP1176 #if NH_3D_VSP 1234 1177 m_piVSPFlag = pcCU->getVSPFlag() + uiAbsPartIdx; 1235 1178 m_pDvInfo = pcCU->getDvInfo() + uiAbsPartIdx; 1236 1179 #endif 1237 #if H_3D_SPIVMP1180 #if NH_3D_SPIVMP 1238 1181 m_pbSPIVMPFlag = pcCU->getSPIVMPFlag() + uiAbsPartIdx; 1239 1182 #endif 1183 1240 1184 m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; 1241 m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; 1242 #if H_3D_ARP1185 m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; 1186 #if NH_3D_ARP 1243 1187 m_puhARPW = pcCU->getARPW() + uiAbsPartIdx; 1244 1188 #endif 1245 #if H_3D_DBBP1189 #if NH_3D_DBBP 1246 1190 m_pbDBBPFlag = pcCU->getDBBPFlag() + uiAbsPartIdx; 1247 1191 #endif 1248 1192 1249 1193 m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); 1250 1251 memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); 1252 memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition); 1253 #if H_3D_NBDV 1254 } 1255 #endif 1256 #if H_3D_IC 1194 #if NH_3D_NBDV 1195 } 1196 #endif 1197 #if NH_3D_IC 1257 1198 m_pbICFlag = pcCU->getICFlag() + uiAbsPartIdx; 1258 1199 #endif 1200 1259 1201 } 1260 1202 … … 1264 1206 { 1265 1207 assert( uiPartUnitIdx<4 ); 1266 1208 1267 1209 m_dTotalCost += pcCU->getTotalCost(); 1268 1210 m_uiTotalDistortion += pcCU->getTotalDistortion(); 1269 1211 m_uiTotalBits += pcCU->getTotalBits(); 1270 1212 1271 1213 UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; 1272 1214 const UInt numValidComp=pcCU->getPic()->getNumberValidComponents(); 1215 const UInt numValidChan=pcCU->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; 1216 1273 1217 UInt uiNumPartition = pcCU->getTotalNumPart(); 1274 1218 Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; 1275 1219 Int iSizeInBool = sizeof( Bool ) * uiNumPartition; 1276 1220 1277 1221 Int sizeInChar = sizeof( Char ) * uiNumPartition; 1278 1222 memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); 1279 #if H_3D1280 memcpy( m_bDISFlag + uiOffset, pcCU->getDISFlag(), sizeof( *m_bDISFlag ) * uiNumPartition );1281 memcpy( m_u iDISType + uiOffset, pcCU->getDISType(), sizeof( *m_uiDISType ) * uiNumPartition);1223 #if NH_3D_DIS 1224 memcpy( m_bDISFlag + uiOffset, pcCU->getDISFlag(), sizeof( *m_bDISFlag ) * uiNumPartition ); 1225 memcpy( m_ucDISType + uiOffset, pcCU->getDISType(), sizeof( *m_ucDISType ) * uiNumPartition); 1282 1226 #endif 1283 1227 memcpy( m_phQP + uiOffset, pcCU->getQP(), sizeInChar ); 1284 1228 memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); 1285 1229 memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); 1230 memcpy( m_ChromaQpAdj + uiOffset, pcCU->getChromaQpAdj(), sizeof( *m_ChromaQpAdj ) * uiNumPartition ); 1286 1231 memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); 1287 1232 memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); 1288 1233 memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); 1289 #if H_3D_VSP1234 #if NH_3D_VSP 1290 1235 memcpy( m_piVSPFlag + uiOffset, pcCU->getVSPFlag(), sizeof( Char ) * uiNumPartition ); 1291 1236 memcpy( m_pDvInfo + uiOffset, pcCU->getDvInfo(), sizeof( *m_pDvInfo ) * uiNumPartition ); 1292 1237 #endif 1293 #if H_3D_SPIVMP1238 #if NH_3D_SPIVMP || NH_3D_DBBP 1294 1239 memcpy( m_pbSPIVMPFlag + uiOffset, pcCU->getSPIVMPFlag(), sizeof( Bool ) * uiNumPartition ); 1295 1240 #endif 1296 memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); 1297 memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); 1241 1242 for (UInt ch=0; ch<numValidChan; ch++) 1243 { 1244 memcpy( m_puhIntraDir[ch] + uiOffset, pcCU->getIntraDir(ChannelType(ch)), iSizeInUchar ); 1245 } 1246 1298 1247 memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); 1299 1248 memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); 1300 memcpy( m_puhTransformSkip[0] + uiOffset, pcCU->getTransformSkip(TEXT_LUMA), iSizeInUchar ); 1301 memcpy( m_puhTransformSkip[1] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_U), iSizeInUchar ); 1302 memcpy( m_puhTransformSkip[2] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_V), iSizeInUchar ); 1303 1304 memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); 1305 memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); 1306 memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); 1307 #if H_3D_DIM 1308 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 1309 { 1310 memcpy( m_dimDeltaDC[i][0] + uiOffset, pcCU->getDimDeltaDC( i, 0 ), sizeof(Pel ) * uiNumPartition ); 1311 memcpy( m_dimDeltaDC[i][1] + uiOffset, pcCU->getDimDeltaDC( i, 1 ), sizeof(Pel ) * uiNumPartition ); 1312 } 1313 #if H_3D_DIM_DMM 1314 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 1315 { 1316 memcpy( m_dmmWedgeTabIdx[i] + uiOffset, pcCU->getDmmWedgeTabIdx( i ), sizeof(UInt) * uiNumPartition ); 1317 } 1318 #endif 1319 #if H_3D_DIM_SDC 1320 memcpy( m_pbSDCFlag + uiOffset, pcCU->getSDCFlag(), iSizeInBool ); 1249 1250 for(UInt comp=0; comp<numValidComp; comp++) 1251 { 1252 memcpy( m_crossComponentPredictionAlpha[comp] + uiOffset, pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)), iSizeInUchar ); 1253 memcpy( m_puhTransformSkip[comp] + uiOffset, pcCU->getTransformSkip(ComponentID(comp)) , iSizeInUchar ); 1254 memcpy( m_puhCbf[comp] + uiOffset, pcCU->getCbf(ComponentID(comp)) , iSizeInUchar ); 1255 memcpy( m_explicitRdpcmMode[comp] + uiOffset, pcCU->getExplicitRdpcmMode(ComponentID(comp)) , iSizeInUchar ); 1256 } 1257 #if NH_3D_DMM 1258 for( Int i = 0; i < NUM_DMM; i++ ) 1259 { 1260 memcpy( m_dmmDeltaDC[i][0] + uiOffset, pcCU->getDmmDeltaDC( (DmmID)i, 0 ), sizeof(Pel ) * uiNumPartition ); 1261 memcpy( m_dmmDeltaDC[i][1] + uiOffset, pcCU->getDmmDeltaDC( (DmmID)i, 1 ), sizeof(Pel ) * uiNumPartition ); 1262 } 1263 memcpy( m_dmm1WedgeTabIdx + uiOffset, pcCU->getDmm1WedgeTabIdx(), sizeof(UInt) * uiNumPartition ); 1264 #endif 1265 #if NH_3D_SDC_INTRA 1266 memcpy( m_pbSDCFlag + uiOffset, pcCU->getSDCFlag(), sizeof( *m_pbSDCFlag ) * uiNumPartition ); 1321 1267 memcpy( m_apSegmentDCOffset[0] + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition); 1322 1268 memcpy( m_apSegmentDCOffset[1] + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition); 1323 1269 #endif 1324 #endif 1325 #if H_3D_DBBP 1270 #if NH_3D_DBBP 1326 1271 memcpy( m_pbDBBPFlag + uiOffset, pcCU->getDBBPFlag(), iSizeInBool ); 1272 #endif 1273 #if NH_3D_ARP 1274 memcpy( m_puhARPW + uiOffset, pcCU->getARPW(), iSizeInUchar ); 1327 1275 #endif 1328 1276 … … 1330 1278 memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); 1331 1279 memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); 1332 1333 memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInUchar ); 1334 memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInUchar ); 1335 memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInUchar ); 1336 memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInUchar ); 1337 1280 1338 1281 memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); 1339 1282 1340 m_pcCUAboveLeft = pcCU->getCUAboveLeft(); 1341 m_pcCUAboveRight = pcCU->getCUAboveRight(); 1342 m_pcCUAbove = pcCU->getCUAbove(); 1343 m_pcCULeft = pcCU->getCULeft(); 1344 1345 m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); 1346 m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); 1347 1348 m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); 1349 m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); 1350 1351 UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); 1352 UInt uiTmp2 = uiPartUnitIdx*uiTmp; 1353 memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); 1283 m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); 1284 m_pCtuAboveRight = pcCU->getCtuAboveRight(); 1285 m_pCtuAbove = pcCU->getCtuAbove(); 1286 m_pCtuLeft = pcCU->getCtuLeft(); 1287 1288 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 1289 { 1290 const RefPicList rpl=RefPicList(i); 1291 memcpy( m_apiMVPIdx[rpl] + uiOffset, pcCU->getMVPIdx(rpl), iSizeInUchar ); 1292 memcpy( m_apiMVPNum[rpl] + uiOffset, pcCU->getMVPNum(rpl), iSizeInUchar ); 1293 m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); 1294 } 1295 1296 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 1297 { 1298 const RefPicList rpl=RefPicList(i); 1299 m_acCUMvField[rpl].copyFrom( pcCU->getCUMvField( rpl ), pcCU->getTotalNumPart(), uiOffset ); 1300 } 1301 1302 const UInt numCoeffY = (pcCU->getSlice()->getSPS()->getMaxCUWidth()*pcCU->getSlice()->getSPS()->getMaxCUHeight()) >> (uiDepth<<1); 1303 const UInt offsetY = uiPartUnitIdx*numCoeffY; 1304 for (UInt ch=0; ch<numValidComp; ch++) 1305 { 1306 const ComponentID component = ComponentID(ch); 1307 const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); 1308 const UInt offset = offsetY>>componentShift; 1309 memcpy( m_pcTrCoeff [ch] + offset, pcCU->getCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); 1354 1310 #if ADAPTIVE_QP_SELECTION 1355 memcpy( m_pcArlCoeffY + uiTmp2, pcCU->getArlCoeffY(), sizeof(Int)*uiTmp ); 1356 #endif 1357 memcpy( m_pcIPCMSampleY + uiTmp2 , pcCU->getPCMSampleY(), sizeof(Pel) * uiTmp ); 1358 1359 uiTmp >>= 2; uiTmp2>>= 2; 1360 memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); 1361 memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); 1362 #if ADAPTIVE_QP_SELECTION 1363 memcpy( m_pcArlCoeffCb + uiTmp2, pcCU->getArlCoeffCb(), sizeof(Int)*uiTmp ); 1364 memcpy( m_pcArlCoeffCr + uiTmp2, pcCU->getArlCoeffCr(), sizeof(Int)*uiTmp ); 1365 #endif 1366 memcpy( m_pcIPCMSampleCb + uiTmp2 , pcCU->getPCMSampleCb(), sizeof(Pel) * uiTmp ); 1367 memcpy( m_pcIPCMSampleCr + uiTmp2 , pcCU->getPCMSampleCr(), sizeof(Pel) * uiTmp ); 1311 memcpy( m_pcArlCoeff[ch] + offset, pcCU->getArlCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); 1312 #endif 1313 memcpy( m_pcIPCMSample[ch] + offset, pcCU->getPCMSample(component), sizeof(Pel)*(numCoeffY>>componentShift) ); 1314 } 1315 1316 #if NH_3D_IC 1317 memcpy( m_pbICFlag + uiOffset, pcCU->getICFlag(), iSizeInBool ); 1318 #endif 1319 1368 1320 m_uiTotalBins += pcCU->getTotalBins(); 1369 memcpy( m_sliceStartCU + uiOffset, pcCU->m_sliceStartCU, sizeof( UInt ) * uiNumPartition );1370 memcpy( m_sliceSegmentStartCU + uiOffset, pcCU->m_sliceSegmentStartCU, sizeof( UInt ) * uiNumPartition );1371 #if H_3D_ARP1372 memcpy( m_puhARPW + uiOffset, pcCU->getARPW(), iSizeInUchar );1373 #endif1374 #if H_3D_IC1375 memcpy( m_pbICFlag + uiOffset, pcCU->getICFlag(), iSizeInBool );1376 #endif1377 1321 } 1378 1322 … … 1381 1325 Void TComDataCU::copyToPic( UChar uhDepth ) 1382 1326 { 1383 TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); 1384 1385 rpcCU->getTotalCost() = m_dTotalCost; 1386 rpcCU->getTotalDistortion() = m_uiTotalDistortion; 1387 rpcCU->getTotalBits() = m_uiTotalBits; 1388 1327 TComDataCU* pCtu = m_pcPic->getCtu( m_ctuRsAddr ); 1328 const UInt numValidComp=pCtu->getPic()->getNumberValidComponents(); 1329 const UInt numValidChan=pCtu->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; 1330 1331 pCtu->getTotalCost() = m_dTotalCost; 1332 pCtu->getTotalDistortion() = m_uiTotalDistortion; 1333 pCtu->getTotalBits() = m_uiTotalBits; 1334 1389 1335 Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; 1390 1336 Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; 1391 1392 1337 Int sizeInChar = sizeof( Char ) * m_uiNumPartition; 1393 1338 1394 memcpy( rpcCU->getSkipFlag() + m_uiAbsIdxInLCU, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); 1395 #if H_3D 1396 memcpy( rpcCU->getDISFlag() + m_uiAbsIdxInLCU, m_bDISFlag, sizeof( *m_bDISFlag ) * m_uiNumPartition ); 1397 memcpy( rpcCU->getDISType() + m_uiAbsIdxInLCU, m_uiDISType, sizeof( *m_uiDISType ) * m_uiNumPartition ); 1398 #endif 1399 memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar ); 1400 #if H_3D_NBDV 1401 memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition ); 1402 #endif 1403 memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); 1404 memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); 1405 memcpy( rpcCU->getCUTransquantBypass()+ m_uiAbsIdxInLCU, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); 1406 memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); 1407 memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); 1408 #if H_3D_VSP 1409 memcpy( rpcCU->getVSPFlag() + m_uiAbsIdxInLCU, m_piVSPFlag, sizeof( Char ) * m_uiNumPartition ); 1410 memcpy( rpcCU->getDvInfo() + m_uiAbsIdxInLCU, m_pDvInfo, sizeof( *m_pDvInfo ) * m_uiNumPartition ); 1411 #endif 1412 #if H_3D_SPIVMP 1413 memcpy( rpcCU->getSPIVMPFlag() + m_uiAbsIdxInLCU, m_pbSPIVMPFlag, sizeof( Bool ) * m_uiNumPartition ); 1414 #endif 1415 memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); 1416 memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); 1417 memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); 1418 memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); 1419 memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhTransformSkip[0], iSizeInUchar ); 1420 memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhTransformSkip[1], iSizeInUchar ); 1421 memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhTransformSkip[2], iSizeInUchar ); 1422 1423 memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); 1424 memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); 1425 memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); 1426 1427 #if H_3D_DIM 1428 for( Int i = 0; i < DIM_NUM_TYPE; i++ ) 1429 { 1430 memcpy( rpcCU->getDimDeltaDC( i, 0 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition ); 1431 memcpy( rpcCU->getDimDeltaDC( i, 1 ) + m_uiAbsIdxInLCU, m_dimDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition ); 1432 } 1433 #if H_3D_DIM_DMM 1434 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 1435 { 1436 memcpy( rpcCU->getDmmWedgeTabIdx( i ) + m_uiAbsIdxInLCU, m_dmmWedgeTabIdx[i], sizeof(UInt) * m_uiNumPartition ); 1437 } 1438 #endif 1439 #if H_3D_DIM_SDC 1440 memcpy( rpcCU->getSDCFlag() + m_uiAbsIdxInLCU, m_pbSDCFlag, iSizeInBool ); 1441 memcpy( rpcCU->getSDCSegmentDCOffset(0) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition); 1442 memcpy( rpcCU->getSDCSegmentDCOffset(1) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition); 1443 #endif 1444 #endif 1445 #if H_3D_DBBP 1446 memcpy( rpcCU->getDBBPFlag() + m_uiAbsIdxInLCU, m_pbDBBPFlag, iSizeInBool ); 1447 #endif 1448 1449 memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); 1450 memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); 1451 memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); 1452 1453 memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInUchar ); 1454 memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInUchar ); 1455 memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInUchar ); 1456 memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInUchar ); 1457 1458 m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); 1459 m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); 1460 1461 memcpy( rpcCU->getIPCMFlag() + m_uiAbsIdxInLCU, m_pbIPCMFlag, iSizeInBool ); 1462 1463 UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); 1464 UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); 1465 memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); 1466 #if ADAPTIVE_QP_SELECTION 1467 memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); 1468 #endif 1469 memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof(Pel)*uiTmp ); 1470 1471 uiTmp >>= 2; uiTmp2 >>= 2; 1472 memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); 1473 memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); 1339 memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); 1340 #if NH_3D_DIS 1341 memcpy( pCtu->getDISFlag() + m_absZIdxInCtu, m_bDISFlag, sizeof( *m_bDISFlag ) * m_uiNumPartition ); 1342 memcpy( pCtu->getDISType() + m_absZIdxInCtu, m_ucDISType, sizeof( *m_ucDISType ) * m_uiNumPartition ); 1343 #endif 1344 1345 memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar ); 1346 #if NH_3D_NBDV 1347 memcpy( pCtu->getDvInfo() + m_absZIdxInCtu, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition ); 1348 #endif 1349 1350 memcpy( pCtu->getPartitionSize() + m_absZIdxInCtu, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); 1351 memcpy( pCtu->getPredictionMode() + m_absZIdxInCtu, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); 1352 memcpy( pCtu->getChromaQpAdj() + m_absZIdxInCtu, m_ChromaQpAdj, sizeof( *m_ChromaQpAdj ) * m_uiNumPartition ); 1353 memcpy( pCtu->getCUTransquantBypass()+ m_absZIdxInCtu, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); 1354 memcpy( pCtu->getMergeFlag() + m_absZIdxInCtu, m_pbMergeFlag, iSizeInBool ); 1355 memcpy( pCtu->getMergeIndex() + m_absZIdxInCtu, m_puhMergeIndex, iSizeInUchar ); 1356 #if NH_3D_VSP 1357 memcpy( pCtu->getVSPFlag() + m_absZIdxInCtu, m_piVSPFlag, sizeof( Char ) * m_uiNumPartition ); 1358 #endif 1359 #if NH_3D_DBBP 1360 memcpy( pCtu->getDvInfo() + m_absZIdxInCtu, m_pDvInfo, sizeof( *m_pDvInfo ) * m_uiNumPartition ); 1361 #endif 1362 #if NH_3D_SPIVMP 1363 memcpy( pCtu->getSPIVMPFlag() + m_absZIdxInCtu, m_pbSPIVMPFlag, sizeof( Bool ) * m_uiNumPartition ); 1364 #endif 1365 1366 for (UInt ch=0; ch<numValidChan; ch++) 1367 { 1368 memcpy( pCtu->getIntraDir(ChannelType(ch)) + m_absZIdxInCtu, m_puhIntraDir[ch], iSizeInUchar); 1369 } 1370 1371 memcpy( pCtu->getInterDir() + m_absZIdxInCtu, m_puhInterDir, iSizeInUchar ); 1372 memcpy( pCtu->getTransformIdx() + m_absZIdxInCtu, m_puhTrIdx, iSizeInUchar ); 1373 1374 for(UInt comp=0; comp<numValidComp; comp++) 1375 { 1376 memcpy( pCtu->getCrossComponentPredictionAlpha(ComponentID(comp)) + m_absZIdxInCtu, m_crossComponentPredictionAlpha[comp], iSizeInUchar ); 1377 memcpy( pCtu->getTransformSkip(ComponentID(comp)) + m_absZIdxInCtu, m_puhTransformSkip[comp], iSizeInUchar ); 1378 memcpy( pCtu->getCbf(ComponentID(comp)) + m_absZIdxInCtu, m_puhCbf[comp], iSizeInUchar ); 1379 memcpy( pCtu->getExplicitRdpcmMode(ComponentID(comp)) + m_absZIdxInCtu, m_explicitRdpcmMode[comp], iSizeInUchar ); 1380 } 1381 1382 #if NH_3D_DMM 1383 for( Int i = 0; i < NUM_DMM; i++ ) 1384 { 1385 memcpy( pCtu->getDmmDeltaDC( (DmmID)i, 0 ) + m_absZIdxInCtu, m_dmmDeltaDC[i][0], sizeof(Pel ) * m_uiNumPartition ); 1386 memcpy( pCtu->getDmmDeltaDC( (DmmID)i, 1 ) + m_absZIdxInCtu, m_dmmDeltaDC[i][1], sizeof(Pel ) * m_uiNumPartition ); 1387 } 1388 memcpy( pCtu->getDmm1WedgeTabIdx() + m_absZIdxInCtu, m_dmm1WedgeTabIdx, sizeof(UInt) * m_uiNumPartition ); 1389 #endif 1390 #if NH_3D_SDC_INTRA 1391 memcpy( pCtu->getSDCFlag() + m_absZIdxInCtu, m_pbSDCFlag, sizeof(Bool) * m_uiNumPartition ); 1392 memcpy( pCtu->getSDCSegmentDCOffset(0) + m_absZIdxInCtu, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition); 1393 memcpy( pCtu->getSDCSegmentDCOffset(1) + m_absZIdxInCtu, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition); 1394 #endif 1395 #if NH_3D_DBBP 1396 memcpy( pCtu->getDBBPFlag() + m_absZIdxInCtu, m_pbDBBPFlag, iSizeInBool ); 1397 #endif 1398 #if NH_3D_ARP 1399 memcpy( pCtu->getARPW() + m_absZIdxInCtu, m_puhARPW, iSizeInUchar ); 1400 #endif 1401 1402 memcpy( pCtu->getDepth() + m_absZIdxInCtu, m_puhDepth, iSizeInUchar ); 1403 memcpy( pCtu->getWidth() + m_absZIdxInCtu, m_puhWidth, iSizeInUchar ); 1404 memcpy( pCtu->getHeight() + m_absZIdxInCtu, m_puhHeight, iSizeInUchar ); 1405 1406 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 1407 { 1408 const RefPicList rpl=RefPicList(i); 1409 memcpy( pCtu->getMVPIdx(rpl) + m_absZIdxInCtu, m_apiMVPIdx[rpl], iSizeInUchar ); 1410 memcpy( pCtu->getMVPNum(rpl) + m_absZIdxInCtu, m_apiMVPNum[rpl], iSizeInUchar ); 1411 } 1412 1413 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 1414 { 1415 const RefPicList rpl=RefPicList(i); 1416 m_acCUMvField[rpl].copyTo( pCtu->getCUMvField( rpl ), m_absZIdxInCtu ); 1417 } 1418 1419 memcpy( pCtu->getIPCMFlag() + m_absZIdxInCtu, m_pbIPCMFlag, iSizeInBool ); 1420 1421 const UInt numCoeffY = (pCtu->getSlice()->getSPS()->getMaxCUWidth()*pCtu->getSlice()->getSPS()->getMaxCUHeight())>>(uhDepth<<1); 1422 const UInt offsetY = m_absZIdxInCtu*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); 1423 for (UInt comp=0; comp<numValidComp; comp++) 1424 { 1425 const ComponentID component = ComponentID(comp); 1426 const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); 1427 memcpy( pCtu->getCoeff(component) + (offsetY>>componentShift), m_pcTrCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); 1474 1428 #if ADAPTIVE_QP_SELECTION 1475 memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); 1476 memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); 1477 #endif 1478 memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); 1479 memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); 1480 rpcCU->getTotalBins() = m_uiTotalBins; 1481 memcpy( rpcCU->m_sliceStartCU + m_uiAbsIdxInLCU, m_sliceStartCU, sizeof( UInt ) * m_uiNumPartition ); 1482 memcpy( rpcCU->m_sliceSegmentStartCU + m_uiAbsIdxInLCU, m_sliceSegmentStartCU, sizeof( UInt ) * m_uiNumPartition ); 1483 #if H_3D_ARP 1484 memcpy( rpcCU->getARPW() + m_uiAbsIdxInLCU, m_puhARPW, iSizeInUchar ); 1485 #endif 1486 #if H_3D_IC 1487 memcpy( rpcCU->getICFlag() + m_uiAbsIdxInLCU, m_pbICFlag, iSizeInBool ); 1488 #endif 1489 } 1490 1491 Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) 1492 { 1493 TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); 1494 UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); 1495 1496 UInt uiPartStart = uiPartIdx*uiQNumPart; 1497 UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; 1498 1499 rpcCU->getTotalCost() = m_dTotalCost; 1500 rpcCU->getTotalDistortion() = m_uiTotalDistortion; 1501 rpcCU->getTotalBits() = m_uiTotalBits; 1502 1503 Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; 1504 Int iSizeInBool = sizeof( Bool ) * uiQNumPart; 1505 1506 Int sizeInChar = sizeof( Char ) * uiQNumPart; 1507 memcpy( rpcCU->getSkipFlag() + uiPartOffset, m_skipFlag, sizeof( *m_skipFlag ) * uiQNumPart ); 1508 #if H_3D 1509 memcpy( rpcCU->getDISFlag() + uiPartOffset, m_bDISFlag, sizeof( *m_bDISFlag ) * uiQNumPart ); 1510 memcpy( rpcCU->getDISType() + uiPartOffset, m_uiDISType, sizeof( *m_uiDISType ) * uiQNumPart ); 1511 #endif 1512 memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, sizeInChar ); 1513 memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart ); 1514 memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( *m_pePredMode ) * uiQNumPart ); 1515 memcpy( rpcCU->getCUTransquantBypass()+ uiPartOffset, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * uiQNumPart ); 1516 memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); 1517 memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); 1518 #if H_3D_VSP 1519 memcpy( rpcCU->getVSPFlag() + uiPartOffset, m_piVSPFlag, sizeof(Char) * uiQNumPart ); 1520 #endif 1429 memcpy( pCtu->getArlCoeff(component) + (offsetY>>componentShift), m_pcArlCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); 1430 #endif 1431 memcpy( pCtu->getPCMSample(component) + (offsetY>>componentShift), m_pcIPCMSample[component], sizeof(Pel)*(numCoeffY>>componentShift) ); 1432 } 1433 1434 #if NH_3D_IC 1435 memcpy( pCtu->getICFlag() + m_absZIdxInCtu, m_pbICFlag, sizeof( *m_pbICFlag ) * m_uiNumPartition ); 1436 #endif 1437 pCtu->getTotalBins() = m_uiTotalBins; 1438 } 1521 1439 #if H_3D_SPIVMP 1522 1440 memcpy( rpcCU->getSPIVMPFlag() + uiPartOffset, m_pbSPIVMPFlag, sizeof(Bool) * uiQNumPart ); 1523 1441 #endif 1524 memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); 1525 memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); 1526 memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); 1527 memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); 1528 memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + uiPartOffset, m_puhTransformSkip[0], iSizeInUchar ); 1529 memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhTransformSkip[1], iSizeInUchar ); 1530 memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhTransformSkip[2], iSizeInUchar ); 1531 memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); 1532 memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); 1533 memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); 1534 #if H_3D_DIM 1535 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 1536 { 1537 memcpy( rpcCU->getDimDeltaDC( i, 0 ) + uiPartOffset, m_dimDeltaDC[i][0], sizeof(Pel ) * uiQNumPart ); 1538 memcpy( rpcCU->getDimDeltaDC( i, 1 ) + uiPartOffset, m_dimDeltaDC[i][1], sizeof(Pel ) * uiQNumPart ); 1539 } 1540 #if H_3D_DIM_DMM 1541 for( Int i = 0; i < DMM_NUM_TYPE; i++ ) 1542 { 1543 memcpy( rpcCU->getDmmWedgeTabIdx( i ) + uiPartOffset, m_dmmWedgeTabIdx[i], sizeof(UInt) * uiQNumPart ); 1544 } 1545 #endif 1546 #if H_3D_DIM_SDC 1547 memcpy( rpcCU->getSDCFlag() + uiPartOffset, m_pbSDCFlag, iSizeInBool ); 1548 memcpy( rpcCU->getSDCSegmentDCOffset(0) + uiPartOffset, m_apSegmentDCOffset[0], sizeof( Pel ) * uiQNumPart); 1549 memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart); 1550 #endif 1551 #endif 1552 #if H_3D_DBBP 1553 memcpy( rpcCU->getDBBPFlag() + uiPartOffset, m_pbDBBPFlag, iSizeInBool ); 1554 #endif 1555 1556 memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); 1557 memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); 1558 memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); 1559 1560 memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInUchar ); 1561 memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInUchar ); 1562 memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInUchar ); 1563 memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInUchar ); 1564 m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); 1565 m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); 1566 1567 memcpy( rpcCU->getIPCMFlag() + uiPartOffset, m_pbIPCMFlag, iSizeInBool ); 1568 1569 UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); 1570 UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); 1571 memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); 1572 #if ADAPTIVE_QP_SELECTION 1573 memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); 1574 #endif 1575 1576 memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof( Pel ) * uiTmp ); 1577 1578 uiTmp >>= 2; uiTmp2 >>= 2; 1579 memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); 1580 memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); 1581 #if ADAPTIVE_QP_SELECTION 1582 memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); 1583 memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); 1584 #endif 1585 1586 memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); 1587 memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); 1588 rpcCU->getTotalBins() = m_uiTotalBins; 1589 memcpy( rpcCU->m_sliceStartCU + uiPartOffset, m_sliceStartCU, sizeof( UInt ) * uiQNumPart ); 1590 memcpy( rpcCU->m_sliceSegmentStartCU + uiPartOffset, m_sliceSegmentStartCU, sizeof( UInt ) * uiQNumPart ); 1591 #if H_3D_ARP 1592 memcpy( rpcCU->getARPW() + uiPartOffset, m_puhARPW, iSizeInUchar ); 1593 #endif 1594 #if H_3D_IC 1595 memcpy( rpcCU->getICFlag() + uiPartOffset, m_pbICFlag, iSizeInBool ); 1596 #endif 1597 } 1442 1598 1443 1599 1444 … … 1602 1447 // -------------------------------------------------------------------------------------------------------------------- 1603 1448 1604 TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, 1605 UInt uiCurrPartUnitIdx, 1606 Bool bEnforceSliceRestriction, 1449 TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, 1450 UInt uiCurrPartUnitIdx, 1451 Bool bEnforceSliceRestriction, 1607 1452 Bool bEnforceTileRestriction ) 1608 1453 { 1609 1454 UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1610 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_ uiAbsIdxInLCU];1611 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();1612 1613 if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) )1455 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; 1456 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1457 1458 if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) 1614 1459 { 1615 1460 uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; 1616 if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) )1617 { 1618 return m_pcPic->getC U( getAddr() );1461 if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) 1462 { 1463 return m_pcPic->getCtu( getCtuRsAddr() ); 1619 1464 } 1620 1465 else 1621 1466 { 1622 uiLPartUnitIdx -= m_ uiAbsIdxInLCU;1467 uiLPartUnitIdx -= m_absZIdxInCtu; 1623 1468 return this; 1624 1469 } 1625 1470 } 1626 1627 uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; 1628 1629 1630 if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) 1631 || 1632 (bEnforceTileRestriction && ( m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) ) ) 1633 ) 1471 1472 uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth - 1 ]; 1473 if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuLeft)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuLeft)) ) 1634 1474 { 1635 1475 return NULL; 1636 1476 } 1637 return m_pcCULeft; 1638 } 1477 return m_pCtuLeft; 1478 } 1479 1639 1480 1640 1481 TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, 1641 UInt uiCurrPartUnitIdx, 1642 Bool bEnforceSliceRestriction, 1643 Bool planarAt LCUBoundary,1482 UInt uiCurrPartUnitIdx, 1483 Bool bEnforceSliceRestriction, 1484 Bool planarAtCtuBoundary, 1644 1485 Bool bEnforceTileRestriction ) 1645 1486 { 1646 1487 UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1647 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_ uiAbsIdxInLCU];1648 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();1649 1650 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) )1651 { 1652 uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ];1653 if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) )1654 { 1655 return m_pcPic->getC U( getAddr() );1488 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; 1489 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1490 1491 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) 1492 { 1493 uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth ]; 1494 if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) 1495 { 1496 return m_pcPic->getCtu( getCtuRsAddr() ); 1656 1497 } 1657 1498 else 1658 1499 { 1659 uiAPartUnitIdx -= m_ uiAbsIdxInLCU;1500 uiAPartUnitIdx -= m_absZIdxInCtu; 1660 1501 return this; 1661 1502 } 1662 1503 } 1663 1504 1664 if(planarAt LCUBoundary)1505 if(planarAtCtuBoundary) 1665 1506 { 1666 1507 return NULL; 1667 1508 } 1668 1669 uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; 1670 1671 if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) 1672 || 1673 (bEnforceTileRestriction &&(m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())))) 1674 ) 1509 1510 uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth ]; 1511 1512 if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuAbove)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuAbove)) ) 1675 1513 { 1676 1514 return NULL; 1677 1515 } 1678 return m_p cCUAbove;1516 return m_pCtuAbove; 1679 1517 } 1680 1518 … … 1682 1520 { 1683 1521 UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1684 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_ uiAbsIdxInLCU];1685 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();1686 1687 if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) )1688 { 1689 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) )1690 { 1691 uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ];1692 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) )1693 { 1694 return m_pcPic->getC U( getAddr() );1522 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; 1523 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1524 1525 if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) 1526 { 1527 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) 1528 { 1529 uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth - 1 ]; 1530 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) 1531 { 1532 return m_pcPic->getCtu( getCtuRsAddr() ); 1695 1533 } 1696 1534 else 1697 1535 { 1698 uiALPartUnitIdx -= m_ uiAbsIdxInLCU;1536 uiALPartUnitIdx -= m_absZIdxInCtu; 1699 1537 return this; 1700 1538 } 1701 1539 } 1702 uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; 1703 if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || 1704 m_pcCUAbove->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1705 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1706 )) 1707 ) 1540 uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartitionsInCtu() - numPartInCtuWidth - 1 ]; 1541 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) 1708 1542 { 1709 1543 return NULL; 1710 1544 } 1711 return m_p cCUAbove;1712 } 1713 1714 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) )1545 return m_pCtuAbove; 1546 } 1547 1548 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) 1715 1549 { 1716 1550 uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; 1717 if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || 1718 m_pcCULeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1719 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1720 )) 1721 ) 1551 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) 1722 1552 { 1723 1553 return NULL; 1724 1554 } 1725 return m_pcCULeft; 1726 } 1727 1728 uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; 1729 if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || 1730 m_pcCUAboveLeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1731 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveLeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1732 )) 1733 ) 1555 return m_pCtuLeft; 1556 } 1557 1558 uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - 1 ]; 1559 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveLeft) ) 1734 1560 { 1735 1561 return NULL; 1736 1562 } 1737 return m_p cCUAboveLeft;1738 } 1739 1740 TComDataCU* TComDataCU::getPU AboveRight( UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction)1741 { 1742 UInt uiAbsPartIdx RT= g_auiZscanToRaster[uiCurrPartUnitIdx];1743 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1;1744 UInt ui NumPartInCUWidth = m_pcPic->getNumPartInWidth();1745 1746 if( ( m_pcPic->getC U(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples())1747 { 1748 ui ARPartUnitIdx = MAX_UINT;1563 return m_pCtuAboveLeft; 1564 } 1565 1566 TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) 1567 { 1568 UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1569 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1570 UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_absZIdxInCtu ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*numPartInCtuWidth; 1571 1572 if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) 1573 { 1574 uiBLPartUnitIdx = MAX_UINT; 1749 1575 return NULL; 1750 1576 } 1751 1752 if ( RasterAddress::lessThan Col( uiAbsPartIdxRT, uiNumPartInCUWidth - 1, uiNumPartInCUWidth ) )1753 { 1754 if ( !RasterAddress::isZero Row( uiAbsPartIdxRT, uiNumPartInCUWidth ) )1755 { 1756 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdx RT - uiNumPartInCUWidth +1 ] )1757 { 1758 ui ARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth +1 ];1759 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx RT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) )1577 1578 if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInCtuHeight() - uiPartUnitOffset, numPartInCtuWidth ) ) 1579 { 1580 if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, numPartInCtuWidth ) ) 1581 { 1582 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ] ) 1583 { 1584 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ]; 1585 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, numPartInCtuWidth ) ) 1760 1586 { 1761 return m_pcPic->getC U( getAddr() );1587 return m_pcPic->getCtu( getCtuRsAddr() ); 1762 1588 } 1763 1589 else 1764 1590 { 1765 ui ARPartUnitIdx -= m_uiAbsIdxInLCU;1591 uiBLPartUnitIdx -= m_absZIdxInCtu; 1766 1592 return this; 1767 1593 } 1768 1594 } 1769 ui ARPartUnitIdx = MAX_UINT;1595 uiBLPartUnitIdx = MAX_UINT; 1770 1596 return NULL; 1771 1597 } 1772 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; 1773 if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || 1774 m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1775 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1776 )) 1777 ) 1598 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * numPartInCtuWidth - 1 ]; 1599 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) 1778 1600 { 1779 1601 return NULL; 1780 1602 } 1781 return m_pcCUAbove; 1782 } 1783 1784 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) 1603 return m_pCtuLeft; 1604 } 1605 1606 uiBLPartUnitIdx = MAX_UINT; 1607 return NULL; 1608 } 1609 1610 TComDataCU* TComDataCU::getPUAboveRight(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) 1611 { 1612 UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1613 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_absZIdxInCtu ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; 1614 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1615 1616 if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) 1785 1617 { 1786 1618 uiARPartUnitIdx = MAX_UINT; 1787 1619 return NULL; 1788 1620 } 1789 1790 uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; 1791 if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || 1792 m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || 1793 m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1794 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1795 )) 1796 ) 1797 { 1798 return NULL; 1799 } 1800 return m_pcCUAboveRight; 1801 } 1802 1803 TComDataCU* TComDataCU::getPUBelowLeft( UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) 1804 { 1805 UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1806 UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth(); 1807 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 1808 1809 if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 1810 { 1811 uiBLPartUnitIdx = MAX_UINT; 1812 return NULL; 1813 } 1814 1815 if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - 1, uiNumPartInCUWidth ) ) 1816 { 1817 if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) 1818 { 1819 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] ) 1820 { 1821 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ]; 1822 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) 1621 1622 if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, numPartInCtuWidth - uiPartUnitOffset, numPartInCtuWidth ) ) 1623 { 1624 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) 1625 { 1626 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ] ) 1627 { 1628 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ]; 1629 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, numPartInCtuWidth ) ) 1823 1630 { 1824 return m_pcPic->getC U( getAddr() );1631 return m_pcPic->getCtu( getCtuRsAddr() ); 1825 1632 } 1826 1633 else 1827 1634 { 1828 ui BLPartUnitIdx -= m_uiAbsIdxInLCU;1635 uiARPartUnitIdx -= m_absZIdxInCtu; 1829 1636 return this; 1830 1637 } 1831 1638 } 1832 ui BLPartUnitIdx = MAX_UINT;1639 uiARPartUnitIdx = MAX_UINT; 1833 1640 return NULL; 1834 1641 } 1835 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; 1836 if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || 1837 m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1838 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1839 )) 1840 ) 1642 1643 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset ]; 1644 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) 1841 1645 { 1842 1646 return NULL; 1843 1647 } 1844 return m_pcCULeft; 1845 } 1846 1847 uiBLPartUnitIdx = MAX_UINT; 1848 return NULL; 1849 } 1850 1851 TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) 1852 { 1853 UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1854 UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth(); 1855 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 1856 1857 if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) 1858 { 1859 uiBLPartUnitIdx = MAX_UINT; 1860 return NULL; 1861 } 1862 1863 if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInHeight() - uiPartUnitOffset, uiNumPartInCUWidth ) ) 1864 { 1865 if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) ) 1866 { 1867 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] ) 1868 { 1869 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ]; 1870 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) ) 1871 { 1872 return m_pcPic->getCU( getAddr() ); 1873 } 1874 else 1875 { 1876 uiBLPartUnitIdx -= m_uiAbsIdxInLCU; 1877 return this; 1878 } 1879 } 1880 uiBLPartUnitIdx = MAX_UINT; 1881 return NULL; 1882 } 1883 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; 1884 if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || 1885 m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1886 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1887 )) 1888 ) 1889 { 1890 return NULL; 1891 } 1892 return m_pcCULeft; 1893 } 1894 1895 uiBLPartUnitIdx = MAX_UINT; 1896 return NULL; 1897 } 1898 1899 TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction ) 1900 { 1901 UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1902 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; 1903 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 1904 1905 if( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) 1648 return m_pCtuAbove; 1649 } 1650 1651 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) 1906 1652 { 1907 1653 uiARPartUnitIdx = MAX_UINT; 1908 1654 return NULL; 1909 1655 } 1910 1911 if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - uiPartUnitOffset, uiNumPartInCUWidth ) ) 1912 { 1913 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) 1914 { 1915 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] ) 1916 { 1917 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ]; 1918 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) ) 1919 { 1920 return m_pcPic->getCU( getAddr() ); 1921 } 1922 else 1923 { 1924 uiARPartUnitIdx -= m_uiAbsIdxInLCU; 1925 return this; 1926 } 1927 } 1928 uiARPartUnitIdx = MAX_UINT; 1929 return NULL; 1930 } 1931 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; 1932 if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || 1933 m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1934 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1935 )) 1936 ) 1937 { 1938 return NULL; 1939 } 1940 return m_pcCUAbove; 1941 } 1942 1943 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) ) 1944 { 1945 uiARPartUnitIdx = MAX_UINT; 1656 1657 uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset-1 ]; 1658 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveRight) ) 1659 { 1946 1660 return NULL; 1947 1661 } 1948 1949 uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; 1950 if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || 1951 m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || 1952 m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1953 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1954 )) 1955 ) 1956 { 1957 return NULL; 1958 } 1959 return m_pcCUAboveRight; 1662 return m_pCtuAboveRight; 1960 1663 } 1961 1664 1962 1665 /** Get left QpMinCu 1963 1666 *\param uiLPartUnitIdx 1964 *\param uiCurrAbsIdxIn LCU1667 *\param uiCurrAbsIdxInCtu 1965 1668 *\returns TComDataCU* point of TComDataCU of left QpMinCu 1966 1669 */ 1967 TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInLCU) 1968 { 1969 UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); 1970 UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth -getSlice()->getPPS()->getMaxCuDQPDepth())<<1); 1670 TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu ) 1671 { 1672 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1673 const UInt maxCUDepth = getSlice()->getSPS()->getMaxTotalCUDepth(); 1674 const UInt maxCuDQPDepth = getSlice()->getPPS()->getMaxCuDQPDepth(); 1675 const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); 1676 UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>doubleDepthDifference)<<doubleDepthDifference; 1971 1677 UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; 1972 1678 1973 // check for left LCU boundary1974 if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInC UWidth) )1679 // check for left CTU boundary 1680 if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCtuWidth) ) 1975 1681 { 1976 1682 return NULL; … … 1980 1686 uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; 1981 1687 1982 // return pointer to current LCU1983 return m_pcPic->getC U( getAddr() );1688 // return pointer to current CTU 1689 return m_pcPic->getCtu( getCtuRsAddr() ); 1984 1690 } 1985 1691 1986 1692 /** Get Above QpMinCu 1987 *\param aPartUnitIdx1988 *\param currAbsIdxInLCU1693 *\param uiAPartUnitIdx 1694 *\param uiCurrAbsIdxInCtu 1989 1695 *\returns TComDataCU* point of TComDataCU of above QpMinCu 1990 1696 */ 1991 TComDataCU* TComDataCU::getQpMinCuAbove( UInt& aPartUnitIdx, UInt currAbsIdxInLCU ) 1992 { 1993 UInt numPartInCUWidth = m_pcPic->getNumPartInWidth(); 1994 UInt absZorderQpMinCUIdx = (currAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1); 1697 TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu ) 1698 { 1699 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1700 const UInt maxCUDepth = getSlice()->getSPS()->getMaxTotalCUDepth(); 1701 const UInt maxCuDQPDepth = getSlice()->getPPS()->getMaxCuDQPDepth(); 1702 const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); 1703 UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>doubleDepthDifference)<<doubleDepthDifference; 1995 1704 UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; 1996 1705 1997 // check for top LCU boundary1998 if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInC UWidth) )1706 // check for top CTU boundary 1707 if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCtuWidth) ) 1999 1708 { 2000 1709 return NULL; … … 2002 1711 2003 1712 // get index of top-CU relative to top-left corner of current quantization group 2004 aPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCUWidth]; 2005 2006 // return pointer to current LCU 2007 return m_pcPic->getCU( getAddr() ); 2008 } 1713 uiAPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCtuWidth]; 1714 1715 // return pointer to current CTU 1716 return m_pcPic->getCtu( getCtuRsAddr() ); 1717 } 1718 1719 2009 1720 2010 1721 /** Get reference QP from left QpMinCu or latest coded QP 2011 *\param uiCurrAbsIdxIn LCU1722 *\param uiCurrAbsIdxInCtu 2012 1723 *\returns Char reference QP value 2013 1724 */ 2014 Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInLCU ) 2015 { 2016 UInt lPartIdx = 0, aPartIdx = 0; 2017 TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); 2018 TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); 2019 return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + 1) >> 1); 1725 Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu ) 1726 { 1727 UInt lPartIdx = MAX_UINT; 1728 UInt aPartIdx = MAX_UINT; 1729 TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); 1730 TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); 1731 return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + 1) >> 1); 2020 1732 } 2021 1733 … … 2024 1736 Int iLastValidPartIdx = iAbsPartIdx-1; 2025 1737 while ( iLastValidPartIdx >= 0 2026 && getPredictionMode( iLastValidPartIdx ) == MODE_NONE)1738 && getPredictionMode( iLastValidPartIdx ) == NUMBER_OF_PREDICTION_MODES ) 2027 1739 { 2028 1740 UInt uiDepth = getDepth( iLastValidPartIdx ); … … 2034 1746 Char TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) 2035 1747 { 2036 UInt uiQUPartIdxMask = ~((1<<((g _uiMaxCUDepth- getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1);2037 Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); 2038 if ( uiAbsPartIdx < m_uiNumPartition2039 && (getSCUAddr()+iLastValidPartIdx < getSliceStartCU(m_uiAbsIdxInLCU+uiAbsPartIdx)))1748 UInt uiQUPartIdxMask = ~((1<<((getSlice()->getSPS()->getMaxTotalCUDepth() - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); 1749 Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); // A idx will be invalid if it is off the right or bottom edge of the picture. 1750 // If this CU is in the first CTU of the slice and there is no valid part before this one, use slice QP 1751 if ( getPic()->getPicSym()->getCtuTsToRsAddrMap(getSlice()->getSliceCurStartCtuTsAddr()) == getCtuRsAddr() && Int(getZorderIdxInCtu())+iLastValidPartIdx<0) 2040 1752 { 2041 1753 return getSlice()->getSliceQp(); … … 2043 1755 else if ( iLastValidPartIdx >= 0 ) 2044 1756 { 1757 // If there is a valid part within the current Sub-CU, use it 2045 1758 return getQP( iLastValidPartIdx ); 2046 1759 } 2047 1760 else 2048 1761 { 2049 if ( getZorderIdxInCU() > 0 ) 2050 { 2051 return getPic()->getCU( getAddr() )->getLastCodedQP( getZorderIdxInCU() ); 2052 } 2053 else if ( getPic()->getPicSym()->getInverseCUOrderMap(getAddr()) > 0 2054 && getPic()->getPicSym()->getTileIdxMap(getAddr()) == getPic()->getPicSym()->getTileIdxMap(getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1)) 2055 && !( getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() && getAddr() % getPic()->getFrameWidthInCU() == 0 ) ) 2056 { 2057 return getPic()->getCU( getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1) )->getLastCodedQP( getPic()->getNumPartInCU() ); 1762 if ( getZorderIdxInCtu() > 0 ) 1763 { 1764 // If this wasn't the first sub-cu within the Ctu, explore the CTU itself. 1765 return getPic()->getCtu( getCtuRsAddr() )->getLastCodedQP( getZorderIdxInCtu() ); // TODO - remove this recursion 1766 } 1767 else if ( getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr()) > 0 1768 && CUIsFromSameSliceTileAndWavefrontRow(getPic()->getCtu(getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1))) ) 1769 { 1770 // If this isn't the first Ctu (how can it be due to the first 'if'?), and the previous Ctu is from the same tile, examine the previous Ctu. 1771 return getPic()->getCtu( getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1) )->getLastCodedQP( getPic()->getNumPartitionsInCtu() ); // TODO - remove this recursion 2058 1772 } 2059 1773 else 2060 1774 { 1775 // No other options available - use the slice-level QP. 2061 1776 return getSlice()->getSliceQp(); 2062 1777 } 2063 1778 } 2064 1779 } 2065 /** Check whether the CU is coded in lossless coding mode 2066 * \param uiAbsPartIdx 2067 * \returns true if the CU is coded in lossless coding mode; false if otherwise 1780 1781 1782 /** Check whether the CU is coded in lossless coding mode. 1783 * \param absPartIdx 1784 * \returns true if the CU is coded in lossless coding mode; false if otherwise 2068 1785 */ 2069 1786 Bool TComDataCU::isLosslessCoded(UInt absPartIdx) … … 2072 1789 } 2073 1790 1791 2074 1792 /** Get allowed chroma intra modes 2075 * \param uiAbsPartIdx2076 * \param uiModeList pointer to chroma intra modes array2077 *\ returns2078 * - fill uiModeList with chroma intra modes1793 * - fills uiModeList with chroma intra modes 1794 * 1795 *\param [in] uiAbsPartIdx 1796 *\param [out] uiModeList pointer to chroma intra modes array 2079 1797 */ 2080 Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt * uiModeList)1798 Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] ) 2081 1799 { 2082 1800 uiModeList[0] = PLANAR_IDX; … … 2085 1803 uiModeList[3] = DC_IDX; 2086 1804 uiModeList[4] = DM_CHROMA_IDX; 2087 2088 UInt uiLumaMode = getLumaIntraDir( uiAbsPartIdx ); 1805 assert(4<NUM_CHROMA_MODE); 1806 1807 UInt uiLumaMode = getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); 2089 1808 2090 1809 for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) … … 2099 1818 2100 1819 /** Get most probable intra modes 2101 *\param uiAbsPartIdx 1820 *\param uiAbsPartIdx partition index 2102 1821 *\param uiIntraDirPred pointer to the array for MPM storage 1822 *\param compID colour component ID 2103 1823 *\param piMode it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side. 2104 1824 *\returns Number of MPM 2105 1825 */ 2106 Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode ) 2107 { 2108 TComDataCU* pcTempCU; 2109 UInt uiTempPartIdx; 1826 Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode ) 1827 { 1828 TComDataCU* pcCULeft, *pcCUAbove; 1829 UInt LeftPartIdx = MAX_UINT; 1830 UInt AbovePartIdx = MAX_UINT; 2110 1831 Int iLeftIntraDir, iAboveIntraDir; 2111 Int uiPredNum = 0; 2112 1832 const TComSPS *sps=getSlice()->getSPS(); 1833 const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize())); 1834 1835 const ChannelType chType = toChannelType(compID); 1836 const ChromaFormat chForm = getPic()->getChromaFormat(); 2113 1837 // Get intra direction of left PU 2114 pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); 2115 2116 iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; 2117 #if H_3D_DIM 2118 mapDepthModeToIntraDir( iLeftIntraDir ); 2119 #endif 2120 1838 pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 1839 1840 if (isChroma(compID)) 1841 { 1842 LeftPartIdx = getChromasCorrespondingPULumaIdx(LeftPartIdx, chForm, partsPerMinCU); 1843 } 1844 iLeftIntraDir = pcCULeft ? ( pcCULeft->isIntra( LeftPartIdx ) ? pcCULeft->getIntraDir( chType, LeftPartIdx ) : DC_IDX ) : DC_IDX; 1845 #if NH_3D_DMM 1846 mapDmmToIntraDir( iLeftIntraDir ); 1847 #endif 1848 2121 1849 // Get intra direction of above PU 2122 pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true ); 2123 2124 iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; 2125 #if H_3D_DIM 2126 mapDepthModeToIntraDir( iAboveIntraDir ); 2127 #endif 2128 2129 uiPredNum = 3; 1850 pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true ); 1851 1852 if (isChroma(compID)) 1853 { 1854 AbovePartIdx = getChromasCorrespondingPULumaIdx(AbovePartIdx, chForm, partsPerMinCU); 1855 } 1856 iAboveIntraDir = pcCUAbove ? ( pcCUAbove->isIntra( AbovePartIdx ) ? pcCUAbove->getIntraDir( chType, AbovePartIdx ) : DC_IDX ) : DC_IDX; 1857 #if NH_3D_DMM 1858 mapDmmToIntraDir( iAboveIntraDir ); 1859 #endif 1860 1861 1862 if (isChroma(chType)) 1863 { 1864 if (iLeftIntraDir == DM_CHROMA_IDX) 1865 { 1866 iLeftIntraDir = pcCULeft-> getIntraDir( CHANNEL_TYPE_LUMA, LeftPartIdx ); 1867 } 1868 if (iAboveIntraDir == DM_CHROMA_IDX) 1869 { 1870 iAboveIntraDir = pcCUAbove->getIntraDir( CHANNEL_TYPE_LUMA, AbovePartIdx ); 1871 } 1872 } 1873 1874 assert (2<NUM_MOST_PROBABLE_MODES); 2130 1875 if(iLeftIntraDir == iAboveIntraDir) 2131 1876 { … … 2134 1879 *piMode = 1; 2135 1880 } 2136 1881 2137 1882 if (iLeftIntraDir > 1) // angular modes 2138 1883 { … … 2145 1890 uiIntraDirPred[0] = PLANAR_IDX; 2146 1891 uiIntraDirPred[1] = DC_IDX; 2147 uiIntraDirPred[2] = VER_IDX; 1892 uiIntraDirPred[2] = VER_IDX; 2148 1893 } 2149 1894 } … … 2156 1901 uiIntraDirPred[0] = iLeftIntraDir; 2157 1902 uiIntraDirPred[1] = iAboveIntraDir; 2158 1903 2159 1904 if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar 2160 1905 { … … 2166 1911 } 2167 1912 } 2168 2169 return uiPredNum; 1913 for (UInt i=0; i<NUM_MOST_PROBABLE_MODES; i++) 1914 { 1915 assert(uiIntraDirPred[i] < 35); 1916 } 2170 1917 } 2171 1918 … … 2176 1923 UInt uiCtx; 2177 1924 // Get left split flag 2178 pcTempCU = getPULeft( uiTempPartIdx, m_ uiAbsIdxInLCU+ uiAbsPartIdx );1925 pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 2179 1926 uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; 2180 1927 2181 1928 // Get above split flag 2182 pcTempCU = getPUAbove( uiTempPartIdx, m_ uiAbsIdxInLCU+ uiAbsPartIdx );1929 pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 2183 1930 uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; 2184 1931 2185 1932 return uiCtx; 2186 1933 } 2187 1934 2188 UInt TComDataCU::getCtxQtCbf( TextType eType, UInt uiTrDepth ) 2189 { 2190 if( eType ) 2191 { 2192 return uiTrDepth; 1935 UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType ) 1936 { 1937 const UInt transformDepth = rTu.GetTransformDepthRel(); 1938 1939 if (isChroma(chType)) 1940 { 1941 return transformDepth; 2193 1942 } 2194 1943 else 2195 1944 { 2196 const UInt uiCtx = ( uiTrDepth == 0 ? 1 : 0 );1945 const UInt uiCtx = ( transformDepth == 0 ? 1 : 0 ); 2197 1946 return uiCtx; 2198 1947 } … … 2203 1952 UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; 2204 1953 PartSize partSize = getPartitionSize( absPartIdx ); 2205 UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter();2206 Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA&& partSize == SIZE_NxN ) ? 1 : 0;2207 Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) );2208 1954 UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); 1955 Int intraSplitFlag = ( isIntra( absPartIdx ) && partSize == SIZE_NxN ) ? 1 : 0; 1956 Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && isInter( absPartIdx ) && (partSize != SIZE_2Nx2N) ); 1957 2209 1958 UInt log2MinTUSizeInCU = 0; 2210 if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) 1959 if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) 2211 1960 { 2212 1961 // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize … … 2221 1970 // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize 2222 1971 log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); 2223 } 1972 } 2224 1973 } 2225 1974 return log2MinTUSizeInCU; … … 2227 1976 2228 1977 UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) 1978 { 1979 TComDataCU* pcTempCU; 1980 UInt uiTempPartIdx; 1981 UInt uiCtx = 0; 1982 1983 // Get BCBP of left PU 1984 pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 1985 uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; 1986 1987 // Get BCBP of above PU 1988 pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 1989 uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; 1990 1991 return uiCtx; 1992 } 1993 #if NH_3D_ARP 1994 UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx ) 2229 1995 { 2230 1996 TComDataCU* pcTempCU; … … 2232 1998 UInt uiCtx = 0; 2233 1999 2234 // Get BCBP of left PU 2235 pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); 2236 uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; 2237 2238 // Get BCBP of above PU 2239 pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); 2240 uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; 2241 2242 return uiCtx; 2243 } 2244 2245 #if H_3D_ARP 2246 UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx ) 2247 { 2248 TComDataCU* pcTempCU; 2249 UInt uiTempPartIdx; 2250 UInt uiCtx = 0; 2251 2252 pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); 2000 pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 2253 2001 uiCtx = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0; 2254 2002 return uiCtx; 2255 2003 } 2256 2004 #endif 2257 #if H_3D_DBBP2005 #if NH_3D_DBBP 2258 2006 Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride) 2259 2007 { 2008 const TComSPS* sps = getSlice()->getSPS(); 2009 UInt uiMaxCUWidth = sps->getMaxCUWidth(); 2010 UInt uiMaxCUHeight = sps->getMaxCUHeight(); 2011 2260 2012 // get coded and reconstructed depth view 2261 2013 TComPicYuv* depthPicYuv = NULL; … … 2263 2015 2264 2016 // DBBP is a texture coding tool 2265 if( getSlice()->getIsDepth() ) 2266 { 2267 return NULL; 2268 } 2017 assert( !getSlice()->getIsDepth() ); 2018 2269 2019 #if H_3D_FCO 2270 2020 TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() ); … … 2293 2043 depthPicYuv = baseDepthPic->getPicYuvRec(); 2294 2044 depthPicYuv->extendPicBorder(); 2295 uiDepthStride = depthPicYuv->getStride( );2045 uiDepthStride = depthPicYuv->getStride(COMPONENT_Y); 2296 2046 2297 Int iBlkX = ( get Addr() % baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];2298 Int iBlkY = ( get Addr() / baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];2047 Int iBlkX = ( getCtuRsAddr() % baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ]; 2048 Int iBlkY = ( getCtuRsAddr() / baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ]; 2299 2049 2300 Int iPictureWidth = depthPicYuv->getWidth( );2301 Int iPictureHeight = depthPicYuv->getHeight( );2050 Int iPictureWidth = depthPicYuv->getWidth(COMPONENT_Y); 2051 Int iPictureHeight = depthPicYuv->getHeight(COMPONENT_Y); 2302 2052 2303 2053 2304 2054 Bool depthRefineFlag = false; 2305 #if H_3D_NBDV_REF2306 depthRefineFlag = m_pcSlice->getDepthRefinementFlag( 2307 #endif // H_3D_NBDV_REF2055 #if NH_3D_NBDV_REF 2056 depthRefineFlag = m_pcSlice->getDepthRefinementFlag(); 2057 #endif // NH_3D_NBDV_REF 2308 2058 2309 2059 TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV; … … 2316 2066 Int depthPosY = Clip3(0, iPictureHeight - 1, iBlkY + ((cDv.getVer()+2)>>2)); 2317 2067 2318 pDepthPels = depthPicYuv->get LumaAddr() + depthPosX + depthPosY * uiDepthStride;2068 pDepthPels = depthPicYuv->getAddr(COMPONENT_Y) + depthPosX + depthPosY * uiDepthStride; 2319 2069 } 2320 2070 #endif … … 2328 2078 #endif 2329 2079 2330 #if H_3D_DBBP2080 #if NH_3D_DBBP 2331 2081 Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 2332 2082 { … … 2335 2085 #endif 2336 2086 2337 #if H_3D_DIM_SDC2338 UInt TComDataCU::getCtxSDCFlag( UInt uiAbsPartIdx )2339 {2340 return 0;2341 }2342 2343 #endif2344 2087 2345 2088 UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) … … 2348 2091 } 2349 2092 2350 Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) 2351 { 2352 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 2353 memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); 2354 memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); 2355 memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); 2356 } 2357 2358 Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) 2359 { 2360 2361 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 2362 memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); 2093 2094 UChar TComDataCU::getQtRootCbf( UInt uiIdx ) 2095 { 2096 const UInt numberValidComponents = getPic()->getNumberValidComponents(); 2097 return getCbf( uiIdx, COMPONENT_Y, 0 ) 2098 || ((numberValidComponents > COMPONENT_Cb) && getCbf( uiIdx, COMPONENT_Cb, 0 )) 2099 || ((numberValidComponents > COMPONENT_Cr) && getCbf( uiIdx, COMPONENT_Cr, 0 )); 2100 } 2101 2102 Void TComDataCU::setCbfSubParts( const UInt uiCbf[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) 2103 { 2104 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 2105 for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 2106 { 2107 memset( m_puhCbf[comp] + uiAbsPartIdx, uiCbf[comp], sizeof( UChar ) * uiCurrPartNumb ); 2108 } 2109 } 2110 2111 Void TComDataCU::setCbfSubParts( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth ) 2112 { 2113 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 2114 memset( m_puhCbf[compID] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); 2363 2115 } 2364 2116 2365 2117 /** Sets a coded block flag for all sub-partitions of a partition 2366 * \param uiCbf The value of the coded block flag to be set2367 * \param eTType2118 * \param uiCbf The value of the coded block flag to be set 2119 * \param compID 2368 2120 * \param uiAbsPartIdx 2369 2121 * \param uiPartIdx 2370 2122 * \param uiDepth 2371 * \returns Void2372 2123 */ 2373 Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 2374 { 2375 setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); 2124 Void TComDataCU::setCbfSubParts ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 2125 { 2126 setSubPart<UChar>( uiCbf, m_puhCbf[compID], uiAbsPartIdx, uiDepth, uiPartIdx ); 2127 } 2128 2129 Void TComDataCU::setCbfPartRange ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) 2130 { 2131 memset((m_puhCbf[compID] + uiAbsPartIdx), uiCbf, (sizeof(UChar) * uiCoveredPartIdxes)); 2132 } 2133 2134 Void TComDataCU::bitwiseOrCbfPartRange( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) 2135 { 2136 const UInt stopAbsPartIdx = uiAbsPartIdx + uiCoveredPartIdxes; 2137 2138 for (UInt subPartIdx = uiAbsPartIdx; subPartIdx < stopAbsPartIdx; subPartIdx++) 2139 { 2140 m_puhCbf[compID][subPartIdx] |= uiCbf; 2141 } 2376 2142 } 2377 2143 2378 2144 Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) 2379 2145 { 2380 UInt uiCurrPartNumb = m_pcPic->getNumPart InCU() >> (uiDepth << 1);2146 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 2381 2147 memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); 2382 2148 } … … 2384 2150 Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) 2385 2151 { 2386 UInt uiPartNumb = m_pcPic->getNumPart InCU() >> (uiDepth << 1);2387 return (((m_ uiAbsIdxInLCU+ uiAbsPartIdx)% uiPartNumb) == 0);2152 UInt uiPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 2153 return (((m_absZIdxInCtu + uiAbsPartIdx)% uiPartNumb) == 0); 2388 2154 } 2389 2155 … … 2391 2157 { 2392 2158 assert( sizeof( *m_pePartSize) == 1 ); 2393 memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPart InCU() >> ( 2 * uiDepth ) );2159 memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); 2394 2160 } 2395 2161 2396 2162 Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) 2397 2163 { 2398 memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPart InCU() >> ( 2 * uiDepth ) );2164 memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); 2399 2165 } 2400 2166 … … 2402 2168 { 2403 2169 assert( sizeof( *m_skipFlag) == 1 ); 2404 memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); 2405 } 2406 #if H_3D 2407 Void TComDataCU::setDISFlagSubParts( Bool bDIS, UInt absPartIdx, UInt depth ) 2170 memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); 2171 } 2172 2173 #if NH_3D_DIS 2174 Void TComDataCU::setDISFlagSubParts( Bool bDIS, UInt uiAbsPartIdx, UInt uiDepth ) 2408 2175 { 2409 2176 assert( sizeof( *m_bDISFlag) == 1 ); 2410 memset( m_bDISFlag + absPartIdx, bDIS, m_pcPic->getNumPartInCU() >> ( 2 * depth ) ); 2411 } 2412 2413 Void TComDataCU::setDISTypeSubParts(UInt uiDISType, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth ) 2414 { 2415 setSubPartT( uiDISType, m_uiDISType, uiAbsPartIdx, uiDepth, uiPUIdx ); 2177 memset( m_bDISFlag + uiAbsPartIdx, bDIS, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); 2178 } 2179 2180 Void TComDataCU::setDISTypeSubParts(UChar ucDISType, UInt uiAbsPartIdx, UInt uiDepth ) 2181 { 2182 assert( sizeof( *m_ucDISType) == 1 ); 2183 memset( m_ucDISType + uiAbsPartIdx, ucDISType, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); 2416 2184 } 2417 2185 #endif … … 2420 2188 { 2421 2189 assert( sizeof( *m_pePredMode) == 1 ); 2422 memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); 2423 } 2424 2425 Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) 2426 { 2427 UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); 2190 memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); 2191 } 2192 2193 Void TComDataCU::setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth ) 2194 { 2195 assert( sizeof(*m_ChromaQpAdj) == 1 ); 2196 memset( m_ChromaQpAdj + absPartIdx, val, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); 2197 } 2198 2199 Void TComDataCU::setQPSubCUs( Int qp, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) 2200 { 2201 UInt currPartNumb = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); 2428 2202 UInt currPartNumQ = currPartNumb >> 2; 2203 const UInt numValidComp = m_pcPic->getNumberValidComponents(); 2429 2204 2430 2205 if(!foundNonZeroCbf) 2431 2206 { 2432 if( pcCU->getDepth(absPartIdx) > depth)2207 if(getDepth(absPartIdx) > depth) 2433 2208 { 2434 2209 for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) 2435 2210 { 2436 pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf );2211 setQPSubCUs( qp, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); 2437 2212 } 2438 2213 } 2439 2214 else 2440 2215 { 2441 if( pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V) )2216 if(getCbf( absPartIdx, COMPONENT_Y ) || (numValidComp>COMPONENT_Cb && getCbf( absPartIdx, COMPONENT_Cb )) || (numValidComp>COMPONENT_Cr && getCbf( absPartIdx, COMPONENT_Cr) ) ) 2442 2217 { 2443 2218 foundNonZeroCbf = true; … … 2453 2228 Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) 2454 2229 { 2455 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 2456 TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); 2457 2458 for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) 2459 { 2460 if( m_pcPic->getCU( getAddr() )->getSliceSegmentStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr() ) 2461 { 2462 m_phQP[uiSCUIdx] = qp; 2463 } 2464 } 2465 } 2466 2467 Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) 2468 { 2469 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 2470 2471 memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); 2230 const UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 2231 memset(m_phQP+uiAbsPartIdx, qp, numPart); 2232 } 2233 2234 Void TComDataCU::setIntraDirSubParts( const ChannelType channelType, const UInt dir, const UInt absPartIdx, const UInt depth ) 2235 { 2236 UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); 2237 memset( m_puhIntraDir[channelType] + absPartIdx, dir,sizeof(UChar)*numPart ); 2472 2238 } 2473 2239 2474 2240 template<typename T> 2475 Void TComDataCU::setSubPart( T uiParameter, T* puhBase LCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx )2241 Void TComDataCU::setSubPart( T uiParameter, T* puhBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) 2476 2242 { 2477 2243 assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 2478 2479 UInt uiCurrPartNumQ = (m_pcPic->getNumPart InCU() >> (2 * uiCUDepth)) >> 2;2244 2245 UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2; 2480 2246 switch ( m_pePartSize[ uiCUAddr ] ) 2481 2247 { 2482 2248 case SIZE_2Nx2N: 2483 memset( puhBase LCU+ uiCUAddr, uiParameter, 4 * uiCurrPartNumQ );2249 memset( puhBaseCtu + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); 2484 2250 break; 2485 2251 case SIZE_2NxN: 2486 memset( puhBase LCU+ uiCUAddr, uiParameter, 2 * uiCurrPartNumQ );2252 memset( puhBaseCtu + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); 2487 2253 break; 2488 2254 case SIZE_Nx2N: 2489 memset( puhBase LCU+ uiCUAddr, uiParameter, uiCurrPartNumQ );2490 memset( puhBase LCU+ uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ );2255 memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); 2256 memset( puhBaseCtu + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); 2491 2257 break; 2492 2258 case SIZE_NxN: 2493 memset( puhBase LCU + uiCUAddr, uiParameter, uiCurrPartNumQ );2259 memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); 2494 2260 break; 2495 2261 case SIZE_2NxnU: 2496 2262 if ( uiPUIdx == 0 ) 2497 2263 { 2498 memset( puhBase LCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) );2499 memset( puhBase LCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) );2264 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); 2265 memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); 2500 2266 } 2501 2267 else if ( uiPUIdx == 1 ) 2502 2268 { 2503 memset( puhBase LCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) );2504 memset( puhBase LCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) );2269 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); 2270 memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); 2505 2271 } 2506 2272 else … … 2512 2278 if ( uiPUIdx == 0 ) 2513 2279 { 2514 memset( puhBase LCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) );2515 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) );2280 memset( puhBaseCtu + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); 2281 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); 2516 2282 } 2517 2283 else if ( uiPUIdx == 1 ) 2518 2284 { 2519 memset( puhBase LCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) );2520 memset( puhBase LCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) );2285 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); 2286 memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); 2521 2287 } 2522 2288 else … … 2528 2294 if ( uiPUIdx == 0 ) 2529 2295 { 2530 memset( puhBase LCU+ uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) );2531 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );2532 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) );2533 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );2296 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); 2297 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 2298 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); 2299 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 2534 2300 } 2535 2301 else if ( uiPUIdx == 1 ) 2536 2302 { 2537 memset( puhBase LCU+ uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) );2538 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) );2539 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) );2540 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) );2303 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); 2304 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); 2305 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); 2306 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); 2541 2307 } 2542 2308 else … … 2547 2313 case SIZE_nRx2N: 2548 2314 if ( uiPUIdx == 0 ) 2549 { 2550 memset( puhBase LCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) );2551 memset( puhBase LCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );2552 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) );2553 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );2315 { 2316 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); 2317 memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 2318 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); 2319 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 2554 2320 } 2555 2321 else if ( uiPUIdx == 1 ) 2556 2322 { 2557 memset( puhBase LCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) );2558 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );2559 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) );2560 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );2323 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); 2324 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 2325 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); 2326 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 2561 2327 } 2562 2328 else … … 2567 2333 default: 2568 2334 assert( 0 ); 2569 } 2570 } 2571 2572 #if H_3D_DIM_SDC 2573 Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiDepth ) 2335 break; 2336 } 2337 } 2338 2339 #if NH_3D_SDC_INTRA 2340 Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt absPartIdx, UInt depth ) 2574 2341 { 2575 2342 assert( sizeof( *m_pbSDCFlag) == 1 ); 2576 memset( m_pbSDCFlag + uiAbsPartIdx, bSDCFlag, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) );2343 memset( m_pbSDCFlag + absPartIdx, bSDCFlag, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); 2577 2344 } 2578 2345 2579 2346 Bool TComDataCU::getSDCAvailable( UInt uiAbsPartIdx ) 2580 2347 { 2581 // check general CU information 2582 if( !getSlice()->getIsDepth() || !isIntra(uiAbsPartIdx) || getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) 2583 { 2584 return false; 2585 } 2586 2587 if( isDimMode( getLumaIntraDir( uiAbsPartIdx ) ) ) 2588 { 2589 return true; 2590 } 2591 2592 if( getLumaIntraDir( uiAbsPartIdx ) < NUM_INTRA_MODE ) 2593 { 2594 return true; 2595 } 2596 2348 if( getSlice()->getIsDepth() && isIntra(uiAbsPartIdx) && getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ) 2349 { 2350 UInt lumaPredMode = getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); 2351 if( lumaPredMode < NUM_INTRA_MODE ) { return true; } 2352 #if NH_3D_DMM 2353 if( isDmmMode( lumaPredMode ) ) { return true; } 2354 #endif 2355 } 2597 2356 return false; 2598 // check prediction mode 2599 UInt uiLumaPredMode = getLumaIntraDir( uiAbsPartIdx ); 2600 if( uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX ) ) 2601 return true; 2602 2603 // else 2604 return false; 2605 } 2606 #endif 2357 } 2358 #endif 2359 2607 2360 Void TComDataCU::setMergeFlagSubParts ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 2608 2361 { … … 2615 2368 } 2616 2369 2617 #if H_3D_SPIVMP2370 #if NH_3D_SPIVMP 2618 2371 Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 2619 2372 { … … 2622 2375 #endif 2623 2376 2624 #if H_3D_VSP2377 #if NH_3D_VSP 2625 2378 Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 2626 2379 { 2627 2380 setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx ); 2628 2381 } 2629 #if H_3D_VSP2630 2382 template<typename T> 2631 2383 Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) 2632 2384 { 2633 UInt uiCurrPartNumQ = (m_pcPic->getNumPart InCU() >> (2 * uiCUDepth)) >> 2;2385 UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2; 2634 2386 switch ( m_pePartSize[ uiCUAddr ] ) 2635 2387 { … … 2763 2515 } 2764 2516 #endif 2765 #endif2766 Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth )2767 {2768 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1);2769 2770 memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb );2771 }2772 2517 2773 2518 Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) … … 2789 2534 Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) 2790 2535 { 2791 UInt uiCurrPartNumb = m_pcPic->getNumPart InCU() >> (uiDepth << 1);2792 2536 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 2537 2793 2538 memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); 2794 2539 } 2795 2540 2796 Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) 2797 { 2798 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 2799 2800 memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); 2801 memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); 2802 memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); 2803 } 2804 2805 Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) 2806 { 2807 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 2808 2809 memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); 2541 Void TComDataCU::setTransformSkipSubParts( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) 2542 { 2543 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 2544 2545 for(UInt i=0; i<MAX_NUM_COMPONENT; i++) 2546 { 2547 memset( m_puhTransformSkip[i] + uiAbsPartIdx, useTransformSkip[i], sizeof( UChar ) * uiCurrPartNumb ); 2548 } 2549 } 2550 2551 Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth) 2552 { 2553 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 2554 2555 memset( m_puhTransformSkip[compID] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); 2556 } 2557 2558 Void TComDataCU::setTransformSkipPartRange ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) 2559 { 2560 memset((m_puhTransformSkip[compID] + uiAbsPartIdx), useTransformSkip, (sizeof(UChar) * uiCoveredPartIdxes)); 2561 } 2562 2563 Void TComDataCU::setCrossComponentPredictionAlphaPartRange( Char alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) 2564 { 2565 memset((m_crossComponentPredictionAlpha[compID] + uiAbsPartIdx), alphaValue, (sizeof(Char) * uiCoveredPartIdxes)); 2566 } 2567 2568 Void TComDataCU::setExplicitRdpcmModePartRange ( UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) 2569 { 2570 memset((m_explicitRdpcmMode[compID] + uiAbsPartIdx), rdpcmMode, (sizeof(UChar) * uiCoveredPartIdxes)); 2810 2571 } 2811 2572 2812 2573 Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) 2813 2574 { 2814 UInt uiCurrPartNumb = m_pcPic->getNumPart InCU() >> (uiDepth << 1);2815 2575 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 2576 2816 2577 memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); 2817 2578 memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); 2818 2579 } 2819 2580 2820 UChar TComDataCU::getNumPartitions( )2581 UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx) 2821 2582 { 2822 2583 UChar iNumPart = 0; 2823 2824 switch ( m_pePartSize[ 0] )2584 2585 switch ( m_pePartSize[uiAbsPartIdx] ) 2825 2586 { 2826 2587 case SIZE_2Nx2N: iNumPart = 1; break; … … 2834 2595 default: assert (0); break; 2835 2596 } 2836 2597 2837 2598 return iNumPart; 2838 2599 } 2839 2600 2840 #if H_3D_IC 2601 // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx 2602 #if NH_3D_IC || NH_3D_VSP 2841 2603 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU) 2842 2604 { … … 2882 2644 } 2883 2645 #else 2646 2884 2647 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) 2885 2648 { … … 2932 2695 return; 2933 2696 } 2934 2697 2935 2698 TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); 2936 2699 rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); … … 2939 2702 Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) 2940 2703 { 2941 ruiPartIdxLT = m_ uiAbsIdxInLCU+ uiAbsPartIdx;2704 ruiPartIdxLT = m_absZIdxInCtu + uiAbsPartIdx; 2942 2705 UInt uiPUWidth = 0; 2943 2706 2944 2707 switch ( m_pePartSize[uiAbsPartIdx] ) 2945 2708 { … … 2950 2713 case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; 2951 2714 case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; 2952 case SIZE_nLx2N: 2715 case SIZE_nLx2N: 2953 2716 if ( uiPartIdx == 0 ) 2954 2717 { 2955 uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; 2718 uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; 2956 2719 } 2957 2720 else if ( uiPartIdx == 1 ) 2958 2721 { 2959 uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); 2722 uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); 2960 2723 } 2961 2724 else … … 2964 2727 } 2965 2728 break; 2966 case SIZE_nRx2N: 2729 case SIZE_nRx2N: 2967 2730 if ( uiPartIdx == 0 ) 2968 2731 { 2969 uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); 2732 uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); 2970 2733 } 2971 2734 else if ( uiPartIdx == 1 ) 2972 2735 { 2973 uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; 2736 uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; 2974 2737 } 2975 2738 else … … 2982 2745 break; 2983 2746 } 2984 2747 2985 2748 ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; 2986 2749 } … … 2995 2758 case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; 2996 2759 case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; 2997 case SIZE_2NxnU: 2760 case SIZE_2NxnU: 2998 2761 if ( uiPartIdx == 0 ) 2999 2762 { 3000 uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; 2763 uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; 3001 2764 } 3002 2765 else if ( uiPartIdx == 1 ) 3003 2766 { 3004 uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); 2767 uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); 3005 2768 } 3006 2769 else … … 3009 2772 } 3010 2773 break; 3011 case SIZE_2NxnD: 2774 case SIZE_2NxnD: 3012 2775 if ( uiPartIdx == 0 ) 3013 2776 { 3014 uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); 2777 uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); 3015 2778 } 3016 2779 else if ( uiPartIdx == 1 ) 3017 2780 { 3018 uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; 2781 uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; 3019 2782 } 3020 2783 else … … 3029 2792 break; 3030 2793 } 3031 3032 ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_ uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()];2794 2795 ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInCtuWidth()]; 3033 2796 } 3034 2797 3035 2798 Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) 3036 2799 { 3037 ruiPartIdxLT = m_ uiAbsIdxInLCU;2800 ruiPartIdxLT = m_absZIdxInCtu; 3038 2801 ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; 3039 2802 3040 2803 switch ( m_pePartSize[0] ) 3041 2804 { … … 3070 2833 break; 3071 2834 } 3072 2835 3073 2836 } 3074 2837 3075 2838 Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) 3076 2839 { 3077 ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_ uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()];3078 2840 ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth()]; 2841 3079 2842 switch ( m_pePartSize[0] ) 3080 2843 { … … 3109 2872 } 3110 2873 3111 /** Derives the partition index of neighbouring bottom right block 3112 * \param [in] eCUMode 3113 * \param [in] uiPartIdx 3114 * \param [out] ruiPartIdxRB 2874 /** Derive the partition index of neighbouring bottom right block 2875 * \param [in] uiPartIdx current partition index 2876 * \param [out] ruiPartIdxRB partition index of neighbouring bottom right block 3115 2877 */ 3116 Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt&ruiPartIdxRB )3117 { 3118 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];2878 Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB ) 2879 { 2880 ruiPartIdxRB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth() + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1]; 3119 2881 3120 2882 switch ( m_pePartSize[0] ) 3121 2883 { 3122 case SIZE_2Nx2N: 3123 ruiPartIdxRB += m_uiNumPartition >> 1; 3124 break; 3125 case SIZE_2NxN: 3126 ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; 3127 break; 3128 case SIZE_Nx2N: 3129 ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); 3130 break; 3131 case SIZE_NxN: 3132 ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); 2884 case SIZE_2Nx2N: 2885 ruiPartIdxRB += m_uiNumPartition >> 1; 2886 break; 2887 case SIZE_2NxN: 2888 ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; 2889 break; 2890 case SIZE_Nx2N: 2891 ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); 2892 break; 2893 case SIZE_NxN: 2894 ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); 3133 2895 break; 3134 2896 case SIZE_2NxnU: … … 3150 2912 } 3151 2913 3152 Void TComDataCU::deriveLeftRightTopIdxAdi ( UInt& ruiPartIdxLT, UInt& ruiPartIdxRT, UInt uiPartOffset, UInt uiPartDepth )3153 {3154 UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth;3155 ruiPartIdxLT = m_uiAbsIdxInLCU + uiPartOffset;3156 ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ];3157 }3158 3159 Void TComDataCU::deriveLeftBottomIdxAdi( UInt& ruiPartIdxLB, UInt uiPartOffset, UInt uiPartDepth )3160 {3161 UInt uiAbsIdx;3162 UInt uiMinCuWidth, uiWidthInMinCus;3163 3164 uiMinCuWidth = getPic()->getMinCUWidth();3165 uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth;3166 uiAbsIdx = getZorderIdxInCU()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1;3167 uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1);3168 ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx];3169 }3170 3171 2914 Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) 3172 2915 { 3173 3174 2916 if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) 3175 2917 { … … 3181 2923 if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) 3182 2924 { 3183 if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || 2925 if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || 3184 2926 getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) 3185 2927 { … … 3192 2934 } 3193 2935 3194 #if H_3D_VSP 3195 2936 #if NH_3D_FIX_PRUNING 2937 Bool TComDataCU::hasEqualMotion( Int dirA, const TComMvField* mvFieldA, Int dirB, const TComMvField* mvFieldB ) 2938 { 2939 return ( dirA == dirB && 2940 ( ( dirA & 1 ) == 0 || mvFieldA[0] == mvFieldB[0] ) && 2941 ( ( dirA & 2 ) == 0 || mvFieldA[1] == mvFieldB[1] ) 2942 ); 2943 } 2944 #endif 2945 2946 #if NH_3D_VSP 3196 2947 /** Add a VSP merging candidate 3197 2948 * \Inputs … … 3247 2998 predFlag[iRefListIdX] = 1; 3248 2999 mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i ); 3249 #if H_3D_NBDV3000 #if NH_3D_NBDV 3250 3001 mvVSP[0+iRefListIdX].getMv().setIDVFlag (false); 3251 3002 #endif … … 3255 3006 3256 3007 dirVSP = (predFlag[0] | (predFlag[1] << 1)); 3257 m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true, false); 3008 m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true 3009 #if NH_3D_SPIVMP 3010 , false 3011 #endif 3012 ); 3258 3013 if ( mrgCandIdx == iCount ) 3259 3014 { … … 3265 3020 return false; 3266 3021 } 3267 3268 #endif 3269 3270 #if H_3D_IV_MERGE 3022 #endif 3023 3024 #if NH_3D_IV_MERGE 3271 3025 inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx ) 3272 3026 { … … 3292 3046 if( !iLoop && ivCandDir[0] > 0) 3293 3047 { 3048 #if NH_3D_FIX_PRUNING 3049 if( hasEqualMotion(tmpDir, tmpMV, m_mergCands[MRG_IVMC].m_uDir, m_mergCands[MRG_IVMC].m_cMvField )) 3050 #else 3294 3051 if(tmpDir == m_mergCands[MRG_IVMC].m_uDir && m_mergCands[MRG_IVMC].m_cMvField[0]==tmpMV[0] && m_mergCands[MRG_IVMC].m_cMvField[1]==tmpMV[1]) 3052 #endif 3295 3053 { 3296 3054 bRemove = true; … … 3299 3057 if(!bRemove) 3300 3058 { 3301 #if H_3D_NBDV3059 #if NH_3D_NBDV 3302 3060 if(iLoop) // For IvMcShift candidate 3303 3061 { … … 3320 3078 3321 3079 #endif 3322 3323 #if H_3D 3080 #if NH_3D_MLC 3081 /** Construct a extended list of merging candidates 3082 * \param pcMvFieldNeighbours 3083 * \param puhInterDirNeighbours 3084 * \param vspFlag 3085 * \param pbSPIVMPFlag 3086 * \param numValidMergeCand 3087 */ 3324 3088 Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours 3325 #if H_3D_VSP3089 #if NH_3D_VSP 3326 3090 , Int* vspFlag 3327 3091 #endif 3328 #if H_3D_SPIVMP3092 #if NH_3D_SPIVMP 3329 3093 , Bool* pbSPIVMPFlag 3330 3094 #endif … … 3332 3096 ) 3333 3097 { 3334 if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) // for only dependent texture3098 if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) 3335 3099 { 3336 3100 return; … … 3348 3112 extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID); 3349 3113 extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID); 3114 #if NH_3D_VSP 3350 3115 vspFlag[ui] = 0; 3351 } 3352 3353 // add candidates to temporal list 3354 // insert MPI ... IvShift candidate 3116 #endif 3117 } 3118 3119 // insert MPI ... IvShift candidate to extMergeCandList 3355 3120 for (Int i=0; i<=MRG_IVSHIFT; i++) 3356 3121 { 3357 3122 if (m_mergCands[i].m_bAvailable) 3358 3123 { 3359 m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt, vspFlag, pbSPIVMPFlag); 3124 m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt 3125 #if NH_3D_VSP 3126 , vspFlag 3127 #endif 3128 #if NH_3D_SPIVMP 3129 , pbSPIVMPFlag 3130 #endif 3131 ); 3360 3132 iCount++; 3361 3133 if (iCount >= getSlice()->getMaxNumMergeCand()) … … 3364 3136 } 3365 3137 3366 // insert remaining base candidates 3367 while (iCount < getSlice()->getMaxNumMergeCand() && m_baseListidc < getSlice()->getMaxNumMergeCand()) 3368 { 3369 uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[m_baseListidc]; 3370 extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[m_baseListidc<<1].getMv(), pcMvFieldNeighbours[m_baseListidc<<1].getRefIdx()); 3138 Int iCountBase = m_numSpatialCands; 3139 // insert remaining base candidates to extMergeCandList 3140 while (iCount < getSlice()->getMaxNumMergeCand() && iCountBase < getSlice()->getMaxNumMergeCand()) 3141 { 3142 uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[iCountBase]; 3143 extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[iCountBase<<1].getMv(), pcMvFieldNeighbours[iCountBase<<1].getRefIdx()); 3371 3144 if ( getSlice()->isInterB() ) 3372 3145 { 3373 extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[( m_baseListidc<<1)+1].getMv(), pcMvFieldNeighbours[(m_baseListidc<<1)+1].getRefIdx());3374 } 3375 m_baseListidc++;3146 extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(iCountBase<<1)+1].getMv(), pcMvFieldNeighbours[(iCountBase<<1)+1].getRefIdx()); 3147 } 3148 iCountBase++; 3376 3149 iCount++; 3377 3150 } … … 3395 3168 } 3396 3169 3397 /** Constructs a list of merging candidates 3170 3171 3172 /** Derive 3D merge candidates 3398 3173 * \param uiAbsPartIdx 3399 3174 * \param uiPUIdx 3400 * \param uiDepth3401 3175 * \param pcMvFieldNeighbours 3176 * \param puhInterDirNeighbours 3177 * \param pcMvFieldSP 3402 3178 * \param puhInterDirNeighbours 3403 3179 * \param numValidMergeCand 3404 3180 */ 3405 // HM 12.0 based merge candidate list construction 3406 3407 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) 3408 { 3409 3410 UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; 3411 Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ]; 3181 Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours 3182 #if NH_3D_SPIVMP 3183 , TComMvField* pcMvFieldSP, UChar* puhInterDirSP 3184 #endif 3185 , Int& numValidMergeCand, Int mrgCandIdx 3186 ) 3187 { 3188 #if NH_3D_IV_MERGE 3412 3189 TComMv cZeroMv; 3413 for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) 3414 { 3415 abCandIsInter[ui] = false; 3416 pcMvFieldNeighbours[ ( ui << 1 ) ].setMvField(cZeroMv, NOT_VALID); 3417 pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID); 3190 TComMvField tmpMV[2]; 3191 #endif 3192 3193 ////////////////////////////////// 3194 //////// GET DISPARITIES //////// 3195 ////////////////////////////////// 3196 #if NH_3D_IV_MERGE 3197 DisInfo cDisInfo = getDvInfo(uiAbsPartIdx); 3198 m_cDefaultDisInfo = cDisInfo; 3199 #elif NH_3D_VSP 3200 // for xAddVspCand() 3201 DisInfo cDisInfo = getDvInfo(uiAbsPartIdx); 3202 #endif 3203 3204 if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) 3205 { 3206 return; 3418 3207 } 3419 3208 numValidMergeCand = getSlice()->getMaxNumMergeCand(); 3209 ////////////////////////////////// 3210 //////// DERIVE LOCATIONS //////// 3211 ////////////////////////////////// 3420 3212 // compute the location of the current PU 3421 3213 Int xP, yP, nPSW, nPSH; … … 3423 3215 3424 3216 Int iCount = 0; 3425 3426 3217 UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 3427 PartSize cCurPS = getPartitionSize( uiAbsPartIdx );3428 3218 deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); 3429 3219 deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); 3430 3431 //left 3432 UInt uiLeftPartIdx = 0; 3433 TComDataCU* pcCULeft = 0; 3434 pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); 3435 Bool isAvailableA1 = pcCULeft && 3436 pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && 3437 !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && 3438 !pcCULeft->isIntra( uiLeftPartIdx ) ; 3439 if ( isAvailableA1 ) 3440 { 3441 m_bAvailableFlagA1 = 1; 3442 abCandIsInter[iCount] = true; 3443 // get Inter Dir 3444 puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); 3445 // get Mv from Left 3446 pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); 3447 if ( getSlice()->isInterB() ) 3448 { 3449 pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 3450 } 3451 3452 iCount ++; 3453 } 3454 3455 // early termination 3456 if (iCount == getSlice()->getMaxNumMergeCand()) 3457 { 3458 return; 3459 } 3460 // above 3461 UInt uiAbovePartIdx = 0; 3462 TComDataCU* pcCUAbove = 0; 3463 pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); 3464 Bool isAvailableB1 = pcCUAbove && 3465 pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && 3466 !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && 3467 !pcCUAbove->isIntra( uiAbovePartIdx ); 3468 if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) 3469 { 3470 m_bAvailableFlagB1 = 1; 3471 abCandIsInter[iCount] = true; 3472 // get Inter Dir 3473 puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); 3474 // get Mv from Left 3475 pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); 3476 if ( getSlice()->isInterB() ) 3477 { 3478 pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 3479 } 3480 if ( mrgCandIdx == iCount ) 3481 { 3482 return; 3483 } 3484 iCount ++; 3485 } 3486 // early termination 3487 if (iCount == getSlice()->getMaxNumMergeCand()) 3488 { 3489 return; 3490 } 3491 3492 // above right 3493 UInt uiAboveRightPartIdx = 0; 3494 TComDataCU* pcCUAboveRight = 0; 3495 pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); 3496 Bool isAvailableB0 = pcCUAboveRight && 3497 pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && 3498 !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); 3499 if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) 3500 { 3501 m_bAvailableFlagB0 = 1; 3502 abCandIsInter[iCount] = true; 3503 // get Inter Dir 3504 puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); 3505 // get Mv from Left 3506 pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); 3507 if ( getSlice()->isInterB() ) 3508 { 3509 pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 3510 } 3511 if ( mrgCandIdx == iCount ) 3512 { 3513 return; 3514 } 3515 iCount ++; 3516 } 3517 // early termination 3518 if (iCount == getSlice()->getMaxNumMergeCand()) 3519 { 3520 return; 3521 } 3522 3523 //left bottom 3524 UInt uiLeftBottomPartIdx = 0; 3525 TComDataCU* pcCULeftBottom = 0; 3526 pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); 3527 Bool isAvailableA0 = pcCULeftBottom && 3528 pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && 3529 !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; 3530 if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) 3531 { 3532 m_bAvailableFlagA0 = 1; 3533 abCandIsInter[iCount] = true; 3534 // get Inter Dir 3535 puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); 3536 // get Mv from Left 3537 pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); 3538 if ( getSlice()->isInterB() ) 3539 { 3540 pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 3541 } 3542 if ( mrgCandIdx == iCount ) 3543 { 3544 return; 3545 } 3546 iCount ++; 3547 } 3548 // early termination 3549 if (iCount == getSlice()->getMaxNumMergeCand()) 3550 { 3551 return; 3552 } 3553 // above left 3554 if( iCount < 4 ) 3555 { 3556 UInt uiAboveLeftPartIdx = 0; 3557 TComDataCU* pcCUAboveLeft = 0; 3558 pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); 3559 Bool isAvailableB2 = pcCUAboveLeft && 3560 pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && 3561 !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); 3562 if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) 3563 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) 3564 { 3565 m_bAvailableFlagB2 = 1; 3566 abCandIsInter[iCount] = true; 3567 // get Inter Dir 3568 puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); 3569 // get Mv from Left 3570 pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); 3571 if ( getSlice()->isInterB() ) 3572 { 3573 pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 3574 } 3575 if ( mrgCandIdx == iCount ) 3576 { 3577 return; 3578 } 3579 iCount ++; 3580 } 3581 } 3582 // early termination 3583 if (iCount == getSlice()->getMaxNumMergeCand()) 3584 { 3585 return; 3586 } 3587 if ( getSlice()->getEnableTMVPFlag()) 3588 { 3589 //>> MTK colocated-RightBottom 3590 UInt uiPartIdxRB; 3591 3592 deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 3593 3594 UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; 3595 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 3596 3597 TComMv cColMv; 3598 Int iRefIdx; 3599 Int uiLCUIdx = -1; 3600 3601 if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check 3602 { 3603 } 3604 else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 3605 { 3606 } 3607 else 3608 { 3609 if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU 3610 ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU 3611 { 3612 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; 3613 uiLCUIdx = getAddr(); 3614 } 3615 else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU 3616 { 3617 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; 3618 } 3619 else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU 3620 { 3621 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; 3622 uiLCUIdx = getAddr() + 1; 3623 } 3624 else //is the right bottom corner of LCU 3625 { 3626 uiAbsPartAddr = 0; 3627 } 3628 } 3629 3630 iRefIdx = 0; 3631 Bool bExistMV = false; 3632 UInt uiPartIdxCenter; 3633 UInt uiCurLCUIdx = getAddr(); 3634 Int dir = 0; 3635 UInt uiArrayAddr = iCount; 3636 xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); 3637 bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); 3638 if( bExistMV == false ) 3639 { 3640 bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); 3641 } 3642 if( bExistMV ) 3643 { 3644 dir |= 1; 3645 pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); 3646 } 3647 3648 if ( getSlice()->isInterB() ) 3649 { 3650 #if H_3D_TMVP 3651 iRefIdx = 0; 3652 #endif 3653 bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); 3654 if( bExistMV == false ) 3655 { 3656 bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); 3657 } 3658 if( bExistMV ) 3659 { 3660 dir |= 2; 3661 pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); 3662 } 3663 } 3664 3665 if (dir != 0) 3666 { 3667 puhInterDirNeighbours[uiArrayAddr] = dir; 3668 abCandIsInter[uiArrayAddr] = true; 3669 #if H_3D_NBDV 3670 pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); 3671 pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); 3672 #endif 3673 if ( mrgCandIdx == iCount ) 3674 { 3675 return; 3676 } 3677 iCount++; 3678 } 3679 } 3680 // early termination 3681 if (iCount == getSlice()->getMaxNumMergeCand()) 3682 { 3683 return; 3684 } 3685 UInt uiArrayAddr = iCount; 3686 UInt uiCutoff = uiArrayAddr; 3687 3688 if ( getSlice()->isInterB() && iCount<5) // JCT3V-F0129 by Qualcomm 3689 { 3690 UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; 3691 UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; 3692 3693 for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) 3694 { 3695 Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; 3696 if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) 3697 { 3698 abCandIsInter[uiArrayAddr] = true; 3699 puhInterDirNeighbours[uiArrayAddr] = 3; 3700 3701 // get Mv from cand[i] and cand[j] 3702 pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); 3703 pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); 3704 3705 Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); 3706 Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); 3707 if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) 3708 { 3709 abCandIsInter[uiArrayAddr] = false; 3710 } 3711 else 3712 { 3713 uiArrayAddr++; 3714 } 3715 } 3716 } 3717 } 3718 // early termination 3719 if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 3720 { 3721 return; 3722 } 3723 3724 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); 3725 Int r = 0; 3726 Int refcnt = 0; 3727 while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) 3728 { 3729 abCandIsInter[uiArrayAddr] = true; 3730 puhInterDirNeighbours[uiArrayAddr] = 1; 3731 pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); 3732 3733 if ( getSlice()->isInterB() ) 3734 { 3735 puhInterDirNeighbours[uiArrayAddr] = 3; 3736 pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); 3737 } 3738 uiArrayAddr++; 3739 if ( refcnt == iNumRefIdx - 1 ) 3740 { 3741 r = 0; 3742 } 3743 else 3744 { 3745 ++r; 3746 ++refcnt; 3747 } 3748 } 3749 3750 numValidMergeCand = uiArrayAddr; 3751 } 3752 3753 3754 3755 /** Constructs a list of merging candidates 3756 * \param uiAbsPartIdx 3757 * \param uiPUIdx 3758 * \param uiDepth 3759 * \param pcMvFieldNeighbours 3760 * \param puhInterDirNeighbours 3761 * \param numValidMergeCand 3762 */ 3763 #if H_3D 3764 Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours 3765 #else 3766 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours 3767 #endif 3768 #if H_3D_SPIVMP 3769 , TComMvField* pcMvFieldSP, UChar* puhInterDirSP 3770 #endif 3771 , Int& numValidMergeCand, Int mrgCandIdx 3772 ) 3773 { 3774 #if H_3D_IV_MERGE 3775 //////////////////////////// 3776 //////// INIT LISTS //////// 3777 //////////////////////////// 3778 TComMv cZeroMv; 3779 #else 3780 Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; 3781 #endif 3782 #if H_3D 3783 TComMvField tmpMV[2]; 3784 UChar tmpDir; 3785 3786 3787 ////////////////////////////////// 3788 //////// GET DISPARITIES //////// 3789 ////////////////////////////////// 3790 DisInfo cDisInfo = getDvInfo(uiAbsPartIdx); 3791 m_cDefaultDisInfo = cDisInfo; 3792 3793 if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0)) // current slice is not both dependent view or depth 3794 { 3795 return; 3796 } 3797 #else 3798 for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) 3799 { 3800 abCandIsInter[ui] = false; 3801 pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); 3802 pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); 3803 } 3804 #endif 3805 3806 numValidMergeCand = getSlice()->getMaxNumMergeCand(); 3807 #if H_3D 3808 ////////////////////////////////// 3809 //////// DERIVE LOCATIONS //////// 3810 ////////////////////////////////// 3811 #endif 3812 // compute the location of the current PU 3813 Int xP, yP, nPSW, nPSH; 3814 this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); 3815 3816 Int iCount = 0; 3817 3818 UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 3819 #if !H_3D 3820 PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); 3821 #endif 3822 deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); 3823 deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); 3824 #if H_3D 3220 #if NH_3D_TEXT_MERGE 3825 3221 Bool bMPIFlag = getSlice()->getMpiFlag(); 3222 Int tmpDir; 3223 #endif 3224 #if NH_3D_IV_MERGE || NH_3D_TEXT_MERGE 3826 3225 Bool bIsDepth = getSlice()->getIsDepth(); 3827 #endif 3828 3829 #if H_3D_IC3226 #endif 3227 3228 #if NH_3D_IC 3830 3229 Bool bICFlag = getICFlag(uiAbsPartIdx); 3831 3230 #endif 3832 #if H_3D_ARP3231 #if NH_3D_ARP 3833 3232 Bool bARPFlag = getARPW(uiAbsPartIdx) > 0; 3834 3233 #endif 3835 #if H_3D_DBBP3234 #if NH_3D_DBBP 3836 3235 Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx); 3837 3236 assert(bDBBPFlag == getDBBPFlag(0)); 3838 3237 #endif 3839 3238 3840 #if H_3D 3841 #if H_3D_NBDV 3239 #if NH_3D_NBDV 3842 3240 for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++) 3843 3241 { 3844 pcMvFieldNeighbours[i<<1 ].getMv().setIDVFlag (false); 3845 pcMvFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false); 3846 } 3847 #endif 3848 // Clean version for MCL construction align with WD 3849 // init mergCands list 3242 pcMFieldNeighbours[i<<1 ].getMv().setIDVFlag (false); 3243 pcMFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false); 3244 } 3245 #endif 3246 // init containers 3850 3247 for (Int i = 0; i<MRG_IVSHIFT+1; i++) 3851 {3852 3248 m_mergCands[i].init(); 3853 } 3854 3855 m_baseListidc = 0; 3856 3249 3250 m_numSpatialCands = 0; 3251 3252 ////////////////////////////////// 3253 ///////// GET VSP FLAGS ////////// 3254 ////////////////////////////////// 3857 3255 //left 3858 3256 UInt uiLeftPartIdx = 0; … … 3862 3260 if (getAvailableFlagA1()) 3863 3261 { 3864 m_mergCands[MRG_A1].setCand( &pcM vFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]3865 #if H_3D_VSP3262 m_mergCands[MRG_A1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands] 3263 #if NH_3D_VSP 3866 3264 , (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0 3867 #if H_3D_IC3265 #if NH_3D_IC 3868 3266 && !bICFlag 3869 3267 #endif 3870 #if H_3D_ARP3268 #if NH_3D_ARP 3871 3269 && !bARPFlag 3872 3270 #endif 3873 #if H_3D_DBBP3271 #if NH_3D_DBBP 3874 3272 && !bDBBPFlag 3875 3273 #endif 3876 3274 ) 3877 3275 #endif 3276 #if NH_3D_SPIVMP 3878 3277 , false 3278 #endif 3879 3279 ); 3880 m_ baseListidc++;3280 m_numSpatialCands++; 3881 3281 } 3882 3282 3883 3283 // above 3884 3885 3284 if (getAvailableFlagB1()) 3886 3285 { 3887 m_mergCands[MRG_B1].setCand( &pcM vFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]3888 #if H_3D_VSP3286 m_mergCands[MRG_B1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands] 3287 #if NH_3D_VSP 3889 3288 , false 3890 3289 #endif 3290 #if NH_3D_SPIVMP 3891 3291 , false 3292 #endif 3892 3293 ); 3893 m_ baseListidc++;3294 m_numSpatialCands++; 3894 3295 } 3895 3296 3896 3297 // above right 3897 3898 3298 if (getAvailableFlagB0()) 3899 3299 { 3900 m_mergCands[MRG_B0].setCand( &pcM vFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]3901 #if H_3D_VSP3902 , 3903 false 3904 # endif3300 m_mergCands[MRG_B0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands] 3301 #if NH_3D_VSP 3302 , false 3303 #endif 3304 #if NH_3D_SPIVMP 3905 3305 , false 3306 #endif 3906 3307 ); 3907 m_ baseListidc++;3308 m_numSpatialCands++; 3908 3309 } 3909 3310 3910 3311 // left bottom 3911 3912 3312 if (getAvailableFlagA0()) 3913 3313 { 3914 m_mergCands[MRG_A0].setCand( &pcM vFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]3915 #if H_3D_VSP3314 m_mergCands[MRG_A0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands] 3315 #if NH_3D_VSP 3916 3316 , false 3917 3317 #endif 3318 #if NH_3D_SPIVMP 3918 3319 , false 3320 #endif 3919 3321 ); 3920 m_ baseListidc++;3322 m_numSpatialCands++; 3921 3323 } 3922 3324 3923 3325 // above left 3924 3925 3326 if (getAvailableFlagB2()) 3926 3327 { 3927 m_mergCands[MRG_B2].setCand( &pcM vFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]3928 #if H_3D_VSP3328 m_mergCands[MRG_B2].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands] 3329 #if NH_3D_VSP 3929 3330 , false 3930 3331 #endif 3332 #if NH_3D_SPIVMP 3931 3333 , false 3334 #endif 3932 3335 ); 3933 m_baseListidc++; 3934 } 3935 3936 #endif 3937 3938 3939 #if H_3D_IV_MERGE 3336 m_numSpatialCands++; 3337 } 3338 3339 3340 #if NH_3D_TEXT_MERGE 3940 3341 3941 3342 ///////////////////////////////////////////// … … 3963 3364 3964 3365 this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight ); 3965 pcTexRec->getTopLeftSamplePos( this->get Addr(), this->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );3366 pcTexRec->getTopLeftSamplePos( this->getCtuRsAddr(), this->getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY ); 3966 3367 3967 3368 Int iPUWidth, iPUHeight, iNumPart, iNumPartLine; … … 3988 3389 3989 3390 Int iTexPosX, iTexPosY; 3391 #if NH_3D_INTEGER_MV_DEPTH 3990 3392 const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) ); 3991 3393 #endif 3992 3394 Int iCenterPosX = iCurrPosX + ( ( iWidth / iPUWidth ) >> 1 ) * iPUWidth + ( iPUWidth >> 1 ); 3993 3395 Int iCenterPosY = iCurrPosY + ( ( iHeight / iPUHeight ) >> 1 ) * iPUHeight + (iPUHeight >> 1); … … 4003 3405 4004 3406 pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx ); 4005 TComDataCU* pcDefaultCU = pcTexPic->getC U( iTexCenterCUAddr );3407 TComDataCU* pcDefaultCU = pcTexPic->getCtu( iTexCenterCUAddr ); 4006 3408 4007 3409 if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA ) … … 4022 3424 { 4023 3425 bSPIVMPFlag = true; 3426 #if NH_3D_INTEGER_MV_DEPTH 4024 3427 TComMv cMv = cDefaultMvField.getMv() + cMvRounding; 4025 3428 cMv >>= 2; 3429 #else 3430 TComMv cMv = cDefaultMvField.getMv(); 3431 #endif 4026 3432 cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ; 4027 3433 break; … … 4048 3454 iTexPosY = i + iOffsetY; 4049 3455 pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx ); 4050 pcTexCU = pcTexPic->getC U( iTexCUAddr );3456 pcTexCU = pcTexPic->getCtu( iTexCUAddr ); 4051 3457 4052 3458 if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) ) … … 4060 3466 if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) ) 4061 3467 { 3468 #if NH_3D_INTEGER_MV_DEPTH 4062 3469 TComMv cMv = cTexMvField.getMv() + cMvRounding; 4063 3470 cMv >>=2; 3471 #else 3472 TComMv cMv = cTexMvField.getMv(); 3473 #endif 4064 3474 pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef); 4065 3475 } … … 4080 3490 } 4081 3491 } 4082 #if H_3D 4083 } 4084 #endif 3492 } 4085 3493 #if H_3D_FCO 4086 3494 } … … 4091 3499 for(iCnloop = 0; iCnloop < 2; iCnloop ++) 4092 3500 { 4093 if ( !m_mergCands[MRG_A1+iCnloop].m_bAvailable ) // prun ning to A1, B13501 if ( !m_mergCands[MRG_A1+iCnloop].m_bAvailable ) // pruning to A1, B1 4094 3502 { 4095 3503 continue; 4096 3504 } 3505 #if NH_3D_FIX_PRUNING 3506 if (hasEqualMotion( tmpDir, tmpMV, m_mergCands[MRG_A1+iCnloop].m_uDir, m_mergCands[MRG_A1+iCnloop].m_cMvField ) ) 3507 #else 4097 3508 if (tmpDir == m_mergCands[MRG_A1+iCnloop].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+iCnloop].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+iCnloop].m_cMvField[1]) 3509 #endif 4098 3510 { 4099 3511 m_mergCands[MRG_A1+iCnloop].m_bAvailable = false; … … 4110 3522 } 4111 3523 } 3524 #endif 3525 3526 #if NH_3D_IV_MERGE 4112 3527 ///////////////////////////////////////////////////////////////// 4113 3528 //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC Candidates ///// … … 4127 3542 if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1) 4128 3543 { 3544 #if NH_3D_IC 4129 3545 getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag ); 3546 #else 3547 getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, false ); 3548 #endif 4130 3549 } 4131 3550 … … 4158 3577 for(Int i = 0; i < 2; i ++) 4159 3578 { 4160 if ( !m_mergCands[MRG_A1 + i].m_bAvailable ) // prun ning to A1, B13579 if ( !m_mergCands[MRG_A1 + i].m_bAvailable ) // pruning to A1, B1 4161 3580 { 4162 3581 continue; 4163 3582 } 3583 #if NH_3D_FIX_PRUNING 3584 if (hasEqualMotion(ivCandDir[0], tmpMV, m_mergCands[MRG_A1+i].m_uDir, m_mergCands[MRG_A1+i].m_cMvField) ) 3585 #else 4164 3586 if (ivCandDir[0] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1]) 3587 #endif 4165 3588 { 4166 3589 m_mergCands[MRG_A1+i].m_bAvailable = false; … … 4169 3592 } 4170 3593 } 4171 if (bIsDepth) 4172 { 3594 else 3595 { 3596 #if NH_3D_FIX_PRUNING 3597 if( hasEqualMotion( ivCandDir[0], tmpMV, m_mergCands[MRG_T].m_uDir, m_mergCands[MRG_T].m_cMvField ) ) 3598 #else 4173 3599 if (m_mergCands[MRG_T].m_bAvailable && ivCandDir[0] == m_mergCands[MRG_T].m_uDir && tmpMV[0]==m_mergCands[MRG_T].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_T].m_cMvField[1]) 3600 #endif 4174 3601 { 4175 3602 bRemoveSpa = true; … … 4183 3610 spiMvpFlag = true; 4184 3611 } 4185 #if H_3D_DBBP3612 #if NH_3D_DBBP 4186 3613 spiMvpFlag &= !bDBBPFlag; 4187 3614 #endif … … 4204 3631 #endif 4205 3632 4206 #if H_3D4207 3633 iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable; 3634 3635 #if NH_3D_VSP 3636 ///////////////////////////////////////////////// 3637 //////// VIEW SYNTHESIS PREDICTION (VSP) //////// 3638 ///////////////////////////////////////////////// 3639 if (iCount<getSlice()->getMaxNumMergeCand()) 3640 { 3641 if ( 3642 (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) && 3643 #if NH_3D_IC 3644 !bICFlag && 3645 #endif 3646 #if NH_3D_ARP 3647 !bARPFlag && 3648 #endif 3649 #if H_3D || NH_3D_FIX_VSP 3650 (nPSW + nPSH > 12) && 3651 #endif 3652 #if NH_3D_DBBP 3653 !bDBBPFlag && 3654 #endif 3655 xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) ) 3656 { 3657 return; 3658 } 3659 3660 // early termination 3661 if (iCount == getSlice()->getMaxNumMergeCand()) 3662 { 3663 return; 3664 } 3665 } 3666 #endif 3667 3668 iCount += m_mergCands[MRG_B0].m_bAvailable; 3669 3670 #if NH_3D_IV_MERGE 3671 ///////////////////////////////////////////// 3672 //////// INTER VIEW DISP COMP (IvDC) //////// 3673 ///////////////////////////////////////////// 3674 if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 3675 { 3676 assert(iCount < getSlice()->getMaxNumMergeCand()); 3677 3678 tmpMV[0].setMvField( cZeroMv, NOT_VALID ); 3679 tmpMV[1].setMvField( cZeroMv, NOT_VALID ); 3680 if( ( ivCandDir[1] & 1 ) == 1 ) 3681 { 3682 tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] ); 3683 } 3684 if( ( ivCandDir[1] & 2 ) == 2 ) 3685 { 3686 tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] ); 3687 } 3688 3689 Bool bRemoveSpa = false; //pruning to A1, B1 3690 for(Int i = 0; i < 2; i ++) 3691 { 3692 if ( !m_mergCands[MRG_A1+i].m_bAvailable ) 3693 { 3694 continue; 3695 } 3696 #if NH_3D_FIX_PRUNING 3697 if ( hasEqualMotion(ivCandDir[1], tmpMV, m_mergCands[MRG_A1+i].m_uDir, m_mergCands[MRG_A1+i].m_cMvField) ) 4208 3698 #else 3699 if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1]) 3700 #endif 3701 { 3702 bRemoveSpa = true; 3703 break; 3704 } 3705 } 3706 if(!bRemoveSpa) 3707 { 3708 #if NH_3D_NBDV 3709 tmpMV[0].getMv().setIDVFlag (false); 3710 tmpMV[1].getMv().setIDVFlag (false); 3711 #endif 3712 m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false); 3713 3714 if ( mrgCandIdx == iCount ) 3715 return; 3716 iCount ++; 3717 3718 // early termination 3719 if (iCount == getSlice()->getMaxNumMergeCand()) 3720 { 3721 return; 3722 } 3723 } 3724 } 3725 #endif // H_3D_IV_MERGE 3726 3727 iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable; 3728 3729 #if NH_3D_IV_MERGE 3730 //////////////////////////////////////////////////// 3731 //////// SHIFTED IV (IvMCShift + IvDCShift) //////// 3732 //////////////////////////////////////////////////// 3733 if( ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 3734 { 3735 if(xAddIvMRGCand( mrgCandIdx, iCount, ivCandDir, ivCandMv, ivCandRefIdx ) ) 3736 { 3737 return; 3738 } 3739 //early termination 3740 if (iCount == getSlice()->getMaxNumMergeCand()) 3741 { 3742 return; 3743 } 3744 } 3745 #endif 3746 } 3747 #endif 3748 3749 //! Construct a list of merging candidates 3750 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) 3751 { 3752 UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx; 3753 #if NH_3D_MLC 3754 Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ]; 3755 #else 3756 Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; 3757 #endif 3758 for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) 3759 { 3760 abCandIsInter[ui] = false; 3761 pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); 3762 pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); 3763 } 3764 numValidMergeCand = getSlice()->getMaxNumMergeCand(); 3765 // compute the location of the current PU 3766 Int xP, yP, nPSW, nPSH; 3767 this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); 3768 3769 Int iCount = 0; 3770 3771 UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 3772 PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); 3773 deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); 3774 deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); 3775 4209 3776 //left 4210 3777 UInt uiLeftPartIdx = 0; 4211 3778 TComDataCU* pcCULeft = 0; 4212 3779 pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); 3780 4213 3781 Bool isAvailableA1 = pcCULeft && 4214 pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && 4215 !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && 4216 !pcCULeft->isIntra( uiLeftPartIdx ) ; 3782 pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && 3783 !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && 3784 pcCULeft->isInter( uiLeftPartIdx ) ; 3785 4217 3786 if ( isAvailableA1 ) 4218 3787 { 3788 #if NH_3D_MLC 3789 m_bAvailableFlagA1 = 1; 3790 #endif 4219 3791 abCandIsInter[iCount] = true; 4220 3792 // get Inter Dir … … 4226 3798 pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 4227 3799 } 4228 4229 3800 if ( mrgCandIdx == iCount ) 4230 3801 { … … 4235 3806 4236 3807 // early termination 4237 if (iCount == getSlice()->getMaxNumMergeCand()) 3808 if (iCount == getSlice()->getMaxNumMergeCand()) 4238 3809 { 4239 3810 return; 4240 3811 } 4241 4242 3812 // above 4243 3813 UInt uiAbovePartIdx = 0; 4244 3814 TComDataCU* pcCUAbove = 0; 4245 3815 pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); 3816 4246 3817 Bool isAvailableB1 = pcCUAbove && 4247 pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && 4248 !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && 4249 !pcCUAbove->isIntra( uiAbovePartIdx ); 3818 pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && 3819 !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && 3820 pcCUAbove->isInter( uiAbovePartIdx ); 3821 4250 3822 if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) 4251 3823 { 3824 #if NH_3D_MLC 3825 m_bAvailableFlagB1 = 1; 3826 #endif 4252 3827 abCandIsInter[iCount] = true; 4253 3828 // get Inter Dir … … 4259 3834 pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 4260 3835 } 4261 4262 3836 if ( mrgCandIdx == iCount ) 4263 3837 { … … 4267 3841 } 4268 3842 // early termination 4269 if (iCount == getSlice()->getMaxNumMergeCand()) 3843 if (iCount == getSlice()->getMaxNumMergeCand()) 4270 3844 { 4271 3845 return; … … 4276 3850 TComDataCU* pcCUAboveRight = 0; 4277 3851 pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); 3852 4278 3853 Bool isAvailableB0 = pcCUAboveRight && 4279 pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && 4280 !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); 3854 pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && 3855 pcCUAboveRight->isInter( uiAboveRightPartIdx ); 3856 4281 3857 if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) 4282 3858 { 3859 #if NH_3D_MLC 3860 m_bAvailableFlagB0 = 1; 3861 #endif 4283 3862 abCandIsInter[iCount] = true; 4284 3863 // get Inter Dir … … 4290 3869 pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 4291 3870 } 4292 4293 3871 if ( mrgCandIdx == iCount ) 4294 3872 { … … 4298 3876 } 4299 3877 // early termination 4300 if (iCount == getSlice()->getMaxNumMergeCand()) 3878 if (iCount == getSlice()->getMaxNumMergeCand()) 4301 3879 { 4302 3880 return; 4303 3881 } 4304 #endif 4305 4306 4307 #if H_3D_VSP 4308 ///////////////////////////////////////////////// 4309 //////// VIEW SYNTHESIS PREDICTION (VSP) //////// 4310 ///////////////////////////////////////////////// 4311 if (iCount<getSlice()->getMaxNumMergeCand()) 4312 { 4313 if ( 4314 (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) && 4315 #if H_3D_IC 4316 !bICFlag && 4317 #endif 4318 #if H_3D_ARP 4319 !bARPFlag && 4320 #endif 4321 #if H_3D 4322 (nPSW + nPSH > 12) && 4323 #endif 4324 #if H_3D_DBBP 4325 !bDBBPFlag && 4326 #endif 4327 xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) ) 4328 { 4329 return; 4330 } 4331 4332 // early termination 4333 if (iCount == getSlice()->getMaxNumMergeCand()) 4334 { 4335 return; 4336 } 4337 #endif 4338 #if H_3D_VSP 4339 } 4340 #endif 4341 4342 #if H_3D 4343 iCount += m_mergCands[MRG_B0].m_bAvailable; 4344 #endif 4345 4346 4347 #if H_3D_IV_MERGE 4348 ///////////////////////////////////////////// 4349 //////// INTER VIEW DISP COMP (IvDC) //////// 4350 ///////////////////////////////////////////// 4351 if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 4352 { 4353 assert(iCount < getSlice()->getMaxNumMergeCand()); 4354 4355 tmpMV[0].setMvField( cZeroMv, NOT_VALID ); 4356 tmpMV[1].setMvField( cZeroMv, NOT_VALID ); 4357 if( ( ivCandDir[1] & 1 ) == 1 ) 4358 { 4359 tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] ); 4360 } 4361 if( ( ivCandDir[1] & 2 ) == 2 ) 4362 { 4363 tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] ); 4364 } 4365 4366 Bool bRemoveSpa = false; //pruning to A1, B1 4367 for(Int i = 0; i < 2; i ++) 4368 { 4369 if ( !m_mergCands[MRG_A1+i].m_bAvailable ) 4370 { 4371 continue; 4372 } 4373 if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1]) 4374 { 4375 bRemoveSpa = true; 4376 break; 4377 } 4378 } 4379 if(!bRemoveSpa) 4380 { 4381 #if H_3D_NBDV 4382 tmpMV[0].getMv().setIDVFlag (false); 4383 tmpMV[1].getMv().setIDVFlag (false); 4384 #endif 4385 m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false); 4386 4387 if ( mrgCandIdx == iCount ) 4388 return; 4389 iCount ++; 4390 4391 // early termination 4392 if (iCount == getSlice()->getMaxNumMergeCand()) 4393 { 4394 return; 4395 } 4396 } 4397 } 4398 #endif // H_3D_IV_MERGE 4399 4400 4401 #if H_3D 4402 iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable; 4403 #else 3882 4404 3883 //left bottom 4405 3884 UInt uiLeftBottomPartIdx = 0; 4406 3885 TComDataCU* pcCULeftBottom = 0; 4407 3886 pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); 3887 4408 3888 Bool isAvailableA0 = pcCULeftBottom && 4409 pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && 4410 !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; 3889 pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && 3890 pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ; 3891 4411 3892 if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) 4412 3893 { 3894 #if NH_3D_MLC 3895 m_bAvailableFlagA0 = 1; 3896 #endif 4413 3897 abCandIsInter[iCount] = true; 4414 3898 // get Inter Dir … … 4427 3911 } 4428 3912 // early termination 4429 if (iCount == getSlice()->getMaxNumMergeCand()) 3913 if (iCount == getSlice()->getMaxNumMergeCand()) 4430 3914 { 4431 3915 return; 4432 3916 } 4433 3917 4434 // above left 3918 // above left 4435 3919 if( iCount < 4 ) 4436 3920 { … … 4438 3922 TComDataCU* pcCUAboveLeft = 0; 4439 3923 pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); 3924 4440 3925 Bool isAvailableB2 = pcCUAboveLeft && 4441 pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && 4442 !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); 3926 pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && 3927 pcCUAboveLeft->isInter( uiAboveLeftPartIdx ); 3928 4443 3929 if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) 4444 3930 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) 4445 3931 { 3932 #if NH_3D_MLC 3933 m_bAvailableFlagB2 = 1; 3934 #endif 4446 3935 abCandIsInter[iCount] = true; 4447 3936 // get Inter Dir … … 4461 3950 } 4462 3951 // early termination 4463 if (iCount == getSlice()->getMaxNumMergeCand()) 3952 if (iCount == getSlice()->getMaxNumMergeCand()) 4464 3953 { 4465 3954 return; 4466 3955 } 4467 #endif 4468 4469 4470 #if H_3D_IV_MERGE 4471 //////////////////////////////////////////////////// 4472 //////// SHIFTED IV (IvMCShift + IvDCShift) //////// 4473 //////////////////////////////////////////////////// 4474 if( ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 4475 { 4476 if(xAddIvMRGCand( mrgCandIdx, iCount, ivCandDir, ivCandMv, ivCandRefIdx ) ) 4477 { 4478 return; 4479 } 4480 //early termination 4481 if (iCount == getSlice()->getMaxNumMergeCand()) 4482 { 4483 return; 4484 } 4485 } 4486 #endif 4487 #if !H_3D 4488 if ( getSlice()->getEnableTMVPFlag()) 3956 3957 if ( getSlice()->getEnableTMVPFlag() ) 4489 3958 { 4490 3959 //>> MTK colocated-RightBottom 4491 3960 UInt uiPartIdxRB; 4492 3961 4493 deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 3962 deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 4494 3963 4495 3964 UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; 4496 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 3965 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 3966 const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); 4497 3967 4498 3968 TComMv cColMv; 4499 3969 Int iRefIdx; 4500 Int uiLCUIdx = -1; 4501 4502 if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check 4503 { 4504 } 4505 else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 4506 { 4507 } 4508 else 4509 { 4510 if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU 4511 ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU 4512 { 4513 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; 4514 uiLCUIdx = getAddr(); 4515 } 4516 else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU 4517 { 4518 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; 4519 } 4520 else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU 3970 Int ctuRsAddr = -1; 3971 3972 if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check 3973 && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 3974 { 3975 if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU 3976 ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU 3977 { 3978 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ]; 3979 ctuRsAddr = getCtuRsAddr(); 3980 } 3981 else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU 3982 { 3983 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; 3984 } 3985 else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU 4521 3986 { 4522 3987 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; 4523 uiLCUIdx = getAddr() + 1;4524 } 4525 else //is the right bottom corner of LCU3988 ctuRsAddr = getCtuRsAddr() + 1; 3989 } 3990 else //is the right bottom corner of CTU 4526 3991 { 4527 3992 uiAbsPartAddr = 0; 4528 3993 } 4529 3994 } 4530 4531 3995 4532 3996 iRefIdx = 0; 3997 4533 3998 Bool bExistMV = false; 4534 3999 UInt uiPartIdxCenter; 4535 UInt uiCurLCUIdx = getAddr();4536 4000 Int dir = 0; 4537 4001 UInt uiArrayAddr = iCount; 4538 4002 xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); 4539 bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );4003 bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx ); 4540 4004 if( bExistMV == false ) 4541 4005 { 4542 bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter,cColMv, iRefIdx );4006 bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); 4543 4007 } 4544 4008 if( bExistMV ) … … 4550 4014 if ( getSlice()->isInterB() ) 4551 4015 { 4552 bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); 4016 #if NH_3D_TMVP 4017 iRefIdx = 0; 4018 #endif 4019 bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx); 4553 4020 if( bExistMV == false ) 4554 4021 { 4555 bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );4022 bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); 4556 4023 } 4557 4024 if( bExistMV ) … … 4561 4028 } 4562 4029 } 4563 4030 4564 4031 if (dir != 0) 4565 4032 { 4566 4033 puhInterDirNeighbours[uiArrayAddr] = dir; 4567 4034 abCandIsInter[uiArrayAddr] = true; 4035 #if NH_3D_NBDV 4036 pcMvFieldNeighbours[iCount<<1 ].getMv().setIDVFlag (false); 4037 pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false); 4038 #endif 4039 4568 4040 if ( mrgCandIdx == iCount ) 4569 4041 { … … 4573 4045 } 4574 4046 } 4575 // early termination 4576 if (iCount == getSlice()->getMaxNumMergeCand()) 4047 // early termination 4048 if (iCount == getSlice()->getMaxNumMergeCand()) 4577 4049 { 4578 4050 return; 4579 4051 } 4052 4580 4053 UInt uiArrayAddr = iCount; 4581 4054 UInt uiCutoff = uiArrayAddr; 4582 4583 if ( getSlice()->isInterB()) 4584 { 4585 UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; 4586 UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; 4055 4056 #if NH_3D_MLC 4057 if ( getSlice()->isInterB() && iCount<5) 4058 #else 4059 if ( getSlice()->isInterB() ) 4060 #endif 4061 { 4062 static const UInt NUM_PRIORITY_LIST=12; 4063 static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; 4064 static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; 4587 4065 4588 4066 for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) 4589 4067 { 4590 Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; 4068 assert(idx<NUM_PRIORITY_LIST); 4069 Int i = uiPriorityList0[idx]; 4070 Int j = uiPriorityList1[idx]; 4591 4071 if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) 4592 4072 { … … 4612 4092 } 4613 4093 // early termination 4614 if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 4094 if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 4615 4095 { 4616 4096 return; 4617 4097 } 4098 4618 4099 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); 4100 4619 4101 Int r = 0; 4620 4102 Int refcnt = 0; … … 4631 4113 } 4632 4114 uiArrayAddr++; 4115 4633 4116 if ( refcnt == iNumRefIdx - 1 ) 4634 4117 { … … 4641 4124 } 4642 4125 } 4643 4644 4126 numValidMergeCand = uiArrayAddr; 4645 #endif 4646 } 4647 #else 4648 4649 /** Constructs a list of merging candidates 4650 * \param uiAbsPartIdx 4651 * \param uiPUIdx 4652 * \param uiDepth 4653 * \param pcMvFieldNeighbours 4654 * \param puhInterDirNeighbours 4655 * \param numValidMergeCand 4656 */ 4657 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours 4658 , Int& numValidMergeCand, Int mrgCandIdx 4659 ) 4660 { 4661 UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx; 4662 Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; 4663 for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) 4664 { 4665 abCandIsInter[ui] = false; 4666 pcMvFieldNeighbours[ ( ui << 1 ) ].setRefIdx(NOT_VALID); 4667 pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID); 4668 } 4669 numValidMergeCand = getSlice()->getMaxNumMergeCand(); 4670 // compute the location of the current PU 4671 Int xP, yP, nPSW, nPSH; 4672 this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH); 4673 4674 Int iCount = 0; 4675 4676 UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 4677 PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); 4678 deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); 4679 deriveLeftBottomIdxGeneral ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); 4680 4681 //left 4682 UInt uiLeftPartIdx = 0; 4683 TComDataCU* pcCULeft = 0; 4684 pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); 4685 Bool isAvailableA1 = pcCULeft && 4686 pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && 4687 !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && 4688 !pcCULeft->isIntra( uiLeftPartIdx ) ; 4689 if ( isAvailableA1 ) 4690 { 4691 abCandIsInter[iCount] = true; 4692 // get Inter Dir 4693 puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx ); 4694 // get Mv from Left 4695 pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); 4696 if ( getSlice()->isInterB() ) 4697 { 4698 pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 4699 } 4700 if ( mrgCandIdx == iCount ) 4701 { 4702 return; 4703 } 4704 iCount ++; 4705 } 4706 4707 // early termination 4708 if (iCount == getSlice()->getMaxNumMergeCand()) 4709 { 4710 return; 4711 } 4712 4713 // above 4714 UInt uiAbovePartIdx = 0; 4715 TComDataCU* pcCUAbove = 0; 4716 pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); 4717 Bool isAvailableB1 = pcCUAbove && 4718 pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && 4719 !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && 4720 !pcCUAbove->isIntra( uiAbovePartIdx ); 4721 if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) 4722 { 4723 abCandIsInter[iCount] = true; 4724 // get Inter Dir 4725 puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx ); 4726 // get Mv from Left 4727 pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); 4728 if ( getSlice()->isInterB() ) 4729 { 4730 pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 4731 } 4732 4733 if ( mrgCandIdx == iCount ) 4734 { 4735 return; 4736 } 4737 iCount ++; 4738 } 4739 // early termination 4740 if (iCount == getSlice()->getMaxNumMergeCand()) 4741 { 4742 return; 4743 } 4744 4745 4746 // above right 4747 UInt uiAboveRightPartIdx = 0; 4748 TComDataCU* pcCUAboveRight = 0; 4749 pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); 4750 Bool isAvailableB0 = pcCUAboveRight && 4751 pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && 4752 !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); 4753 if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) 4754 { 4755 abCandIsInter[iCount] = true; 4756 // get Inter Dir 4757 puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx ); 4758 // get Mv from Left 4759 pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); 4760 if ( getSlice()->isInterB() ) 4761 { 4762 pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 4763 } 4764 if ( mrgCandIdx == iCount ) 4765 { 4766 return; 4767 } 4768 iCount ++; 4769 } 4770 // early termination 4771 if (iCount == getSlice()->getMaxNumMergeCand()) 4772 { 4773 return; 4774 } 4775 4776 //left bottom 4777 UInt uiLeftBottomPartIdx = 0; 4778 TComDataCU* pcCULeftBottom = 0; 4779 pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); 4780 Bool isAvailableA0 = pcCULeftBottom && 4781 pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && 4782 !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; 4783 if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) 4784 { 4785 abCandIsInter[iCount] = true; 4786 // get Inter Dir 4787 puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx ); 4788 // get Mv from Left 4789 pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); 4790 if ( getSlice()->isInterB() ) 4791 { 4792 pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 4793 } 4794 4795 if ( mrgCandIdx == iCount ) 4796 { 4797 return; 4798 } 4799 iCount ++; 4800 } 4801 // early termination 4802 if (iCount == getSlice()->getMaxNumMergeCand()) 4803 { 4804 return; 4805 } 4806 4807 // above left 4808 if( iCount < 4 ) 4809 { 4810 UInt uiAboveLeftPartIdx = 0; 4811 TComDataCU* pcCUAboveLeft = 0; 4812 pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); 4813 Bool isAvailableB2 = pcCUAboveLeft && 4814 pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && 4815 !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); 4816 if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) 4817 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) 4818 { 4819 abCandIsInter[iCount] = true; 4820 // get Inter Dir 4821 puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx ); 4822 // get Mv from Left 4823 pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] ); 4824 if ( getSlice()->isInterB() ) 4825 { 4826 pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 4827 } 4828 if ( mrgCandIdx == iCount ) 4829 { 4830 return; 4831 } 4832 iCount ++; 4833 } 4834 } 4835 // early termination 4836 if (iCount == getSlice()->getMaxNumMergeCand()) 4837 { 4838 return; 4839 } 4840 4841 if ( getSlice()->getEnableTMVPFlag()) 4842 { 4843 //>> MTK colocated-RightBottom 4844 UInt uiPartIdxRB; 4845 4846 deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 4847 4848 UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; 4849 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 4850 4851 TComMv cColMv; 4852 Int iRefIdx; 4853 Int uiLCUIdx = -1; 4854 4855 if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check 4856 { 4857 } 4858 else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 4859 { 4860 } 4861 else 4862 { 4863 if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU 4864 ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU 4865 { 4866 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; 4867 uiLCUIdx = getAddr(); 4868 } 4869 else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU 4870 { 4871 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; 4872 } 4873 else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU 4874 { 4875 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; 4876 uiLCUIdx = getAddr() + 1; 4877 } 4878 else //is the right bottom corner of LCU 4879 { 4880 uiAbsPartAddr = 0; 4881 } 4882 } 4883 4884 4885 iRefIdx = 0; 4886 Bool bExistMV = false; 4887 UInt uiPartIdxCenter; 4888 UInt uiCurLCUIdx = getAddr(); 4889 Int dir = 0; 4890 UInt uiArrayAddr = iCount; 4891 xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); 4892 bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx ); 4893 if( bExistMV == false ) 4894 { 4895 bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); 4896 } 4897 if( bExistMV ) 4898 { 4899 dir |= 1; 4900 pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); 4901 } 4902 4903 if ( getSlice()->isInterB() ) 4904 { 4905 bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx); 4906 if( bExistMV == false ) 4907 { 4908 bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx ); 4909 } 4910 if( bExistMV ) 4911 { 4912 dir |= 2; 4913 pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx ); 4914 } 4915 } 4916 4917 if (dir != 0) 4918 { 4919 puhInterDirNeighbours[uiArrayAddr] = dir; 4920 abCandIsInter[uiArrayAddr] = true; 4921 if ( mrgCandIdx == iCount ) 4922 { 4923 return; 4924 } 4925 iCount++; 4926 } 4927 } 4928 // early termination 4929 if (iCount == getSlice()->getMaxNumMergeCand()) 4930 { 4931 return; 4932 } 4933 UInt uiArrayAddr = iCount; 4934 UInt uiCutoff = uiArrayAddr; 4935 4936 if ( getSlice()->isInterB()) 4937 { 4938 UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; 4939 UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; 4940 4941 for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) 4942 { 4943 Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; 4944 if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) 4945 { 4946 abCandIsInter[uiArrayAddr] = true; 4947 puhInterDirNeighbours[uiArrayAddr] = 3; 4948 4949 // get Mv from cand[i] and cand[j] 4950 pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx()); 4951 pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx()); 4952 4953 Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() ); 4954 Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() ); 4955 if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv()) 4956 { 4957 abCandIsInter[uiArrayAddr] = false; 4958 } 4959 else 4960 { 4961 uiArrayAddr++; 4962 } 4963 } 4964 } 4965 } 4966 // early termination 4967 if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 4968 { 4969 return; 4970 } 4971 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); 4972 Int r = 0; 4973 Int refcnt = 0; 4974 while (uiArrayAddr < getSlice()->getMaxNumMergeCand()) 4975 { 4976 abCandIsInter[uiArrayAddr] = true; 4977 puhInterDirNeighbours[uiArrayAddr] = 1; 4978 pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r); 4979 4980 if ( getSlice()->isInterB() ) 4981 { 4982 puhInterDirNeighbours[uiArrayAddr] = 3; 4983 pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r); 4984 } 4985 uiArrayAddr++; 4986 if ( refcnt == iNumRefIdx - 1 ) 4987 { 4988 r = 0; 4989 } 4990 else 4991 { 4992 ++r; 4993 ++refcnt; 4994 } 4995 } 4996 4997 numValidMergeCand = uiArrayAddr; 4998 } 4999 #endif 4127 } 5000 4128 5001 4129 /** Check whether the current PU and a spatial neighboring PU are in a same ME region. 5002 * \param xN, xN location of the upper-left corner pixel of a neighboring PU4130 * \param xN, yN location of the upper-left corner pixel of a neighboring PU 5003 4131 * \param xP, yP location of the upper-left corner pixel of the current PU 5004 * \returns Bool5005 4132 */ 5006 4133 Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) … … 5018 4145 return false; 5019 4146 } 5020 /** calculate the location of upper-left corner pixel and size of the current PU. 5021 * \param partIdx PU index within a CU 5022 * \param xP, yP location of the upper-left corner pixel of the current PU5023 * \param PSW, nPSH size of the currenPU5024 * \ returns Void4147 4148 /** Calculate the location of upper-left corner pixel and size of the current PU. 4149 * \param partIdx PU index within a CU 4150 * \param xP, yP location of the upper-left corner pixel of the current PU 4151 * \param nPSW, nPSH size of the current PU 5025 4152 */ 5026 4153 Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) … … 5032 4159 { 5033 4160 case SIZE_2NxN: 5034 nPSW = getWidth(0); 5035 nPSH = getHeight(0) >> 1; 4161 nPSW = getWidth(0); 4162 nPSH = getHeight(0) >> 1; 5036 4163 xP = col; 5037 4164 yP = (partIdx ==0)? row: row + nPSH; 5038 4165 break; 5039 4166 case SIZE_Nx2N: 5040 nPSW = getWidth(0) >> 1; 5041 nPSH = getHeight(0); 4167 nPSW = getWidth(0) >> 1; 4168 nPSH = getHeight(0); 5042 4169 xP = (partIdx ==0)? col: col + nPSW; 5043 4170 yP = row; 5044 4171 break; 5045 4172 case SIZE_NxN: 5046 nPSW = getWidth(0) >> 1; 5047 nPSH = getHeight(0) >> 1; 4173 nPSW = getWidth(0) >> 1; 4174 nPSH = getHeight(0) >> 1; 5048 4175 xP = col + (partIdx&0x1)*nPSW; 5049 4176 yP = row + (partIdx>>1)*nPSH; … … 5076 4203 default: 5077 4204 assert ( m_pePartSize[0] == SIZE_2Nx2N ); 5078 nPSW = getWidth(0); 5079 nPSH = getHeight(0); 4205 nPSW = getWidth(0); 4206 nPSH = getHeight(0); 5080 4207 xP = col ; 5081 4208 yP = row ; … … 5087 4214 /** Constructs a list of candidates for AMVP 5088 4215 * \param uiPartIdx 5089 * \param uiPartAddr 4216 * \param uiPartAddr 5090 4217 * \param eRefPicList 5091 4218 * \param iRefIdx … … 5097 4224 Bool bAddedSmvp = false; 5098 4225 5099 pInfo->iN = 0; 4226 pInfo->iN = 0; 5100 4227 if (iRefIdx < 0) 5101 4228 { 5102 4229 return; 5103 4230 } 5104 4231 5105 4232 //-- Get Spatial MV 5106 4233 UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 5107 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 4234 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 4235 const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); 5108 4236 Bool bAdded = false; 5109 4237 5110 4238 deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); 5111 4239 deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); 5112 4240 5113 4241 TComDataCU* tmpCU = NULL; 5114 4242 UInt idx; 5115 4243 tmpCU = getPUBelowLeft(idx, uiPartIdxLB); 5116 bAddedSmvp = (tmpCU != NULL) && (tmpCU-> getPredictionMode(idx) != MODE_INTRA);4244 bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx)); 5117 4245 5118 4246 if (!bAddedSmvp) 5119 4247 { 5120 4248 tmpCU = getPULeft(idx, uiPartIdxLB); 5121 bAddedSmvp = (tmpCU != NULL) && (tmpCU-> getPredictionMode(idx) != MODE_INTRA);4249 bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx)); 5122 4250 } 5123 4251 5124 4252 // Left predictor search 5125 4253 bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); 5126 if (!bAdded) 4254 if (!bAdded) 5127 4255 { 5128 4256 bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); 5129 4257 } 5130 4258 5131 4259 if(!bAdded) 5132 4260 { 5133 4261 bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); 5134 if (!bAdded) 4262 if (!bAdded) 5135 4263 { 5136 4264 xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); 5137 4265 } 5138 4266 } 4267 5139 4268 // Above predictor search 5140 4269 bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); 5141 4270 5142 if (!bAdded) 4271 if (!bAdded) 5143 4272 { 5144 4273 bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); … … 5150 4279 } 5151 4280 5152 if 4281 if(!bAddedSmvp) 5153 4282 { 5154 4283 bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); 5155 if (!bAdded) 4284 if (!bAdded) 5156 4285 { 5157 4286 bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); … … 5163 4292 } 5164 4293 } 5165 4294 5166 4295 if ( pInfo->iN == 2 ) 5167 4296 { … … 5178 4307 TComMv cColMv; 5179 4308 UInt uiPartIdxRB; 5180 UInt uiAbsPartIdx; 4309 UInt uiAbsPartIdx; 5181 4310 UInt uiAbsPartAddr; 5182 4311 5183 4312 deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); 5184 uiAbsPartAddr = m_ uiAbsIdxInLCU+ uiPartAddr;4313 uiAbsPartAddr = m_absZIdxInCtu + uiPartAddr; 5185 4314 5186 4315 //---- co-located RightBottom Temporal Predictor (H) ---// 5187 4316 uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; 5188 Int uiLCUIdx = -1; 5189 if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check 5190 { 5191 } 5192 else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 5193 { 4317 Int ctuRsAddr = -1; 4318 if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check 4319 && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 4320 { 4321 if ( ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU 4322 ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU 4323 { 4324 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth + 1 ]; 4325 ctuRsAddr = getCtuRsAddr(); 4326 } 4327 else if ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU 4328 { 4329 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; 4330 } 4331 else if ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU 4332 { 4333 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; 4334 ctuRsAddr = getCtuRsAddr() + 1; 4335 } 4336 else //is the right bottom corner of CTU 4337 { 4338 uiAbsPartAddr = 0; 4339 } 4340 } 4341 if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx_Col 4342 #if NH_3D_TMVP 4343 , 0 4344 #endif 4345 ) ) 4346 { 4347 pInfo->m_acMvCand[pInfo->iN++] = cColMv; 5194 4348 } 5195 4349 else 5196 4350 { 5197 if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU 5198 ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU 5199 { 5200 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ]; 5201 uiLCUIdx = getAddr(); 5202 } 5203 else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU 5204 { 5205 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; 5206 } 5207 else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU 5208 { 5209 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; 5210 uiLCUIdx = getAddr() + 1; 5211 } 5212 else //is the right bottom corner of LCU 5213 { 5214 uiAbsPartAddr = 0; 5215 } 5216 } 5217 if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col 5218 #if H_3D_TMVP 4351 UInt uiPartIdxCenter; 4352 xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); 4353 if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx_Col 4354 #if NH_3D_TMVP 5219 4355 , 0 5220 4356 #endif 5221 ) ) 5222 { 5223 pInfo->m_acMvCand[pInfo->iN++] = cColMv; 5224 } 5225 else 5226 { 5227 UInt uiPartIdxCenter; 5228 UInt uiCurLCUIdx = getAddr(); 5229 xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); 5230 if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col 5231 #if H_3D_TMVP 5232 , 0 5233 #endif 5234 )) 4357 )) 5235 4358 { 5236 4359 pInfo->m_acMvCand[pInfo->iN++] = cColMv; … … 5244 4367 pInfo->iN = AMVP_MAX_NUM_CANDS; 5245 4368 } 4369 5246 4370 while (pInfo->iN < AMVP_MAX_NUM_CANDS) 5247 4371 { 5248 5249 4372 pInfo->m_acMvCand[pInfo->iN].set(0,0); 4373 pInfo->iN++; 5250 4374 } 5251 4375 return ; 5252 4376 } 4377 5253 4378 5254 4379 Bool TComDataCU::isBipredRestriction(UInt puIdx) … … 5257 4382 Int height = 0; 5258 4383 UInt partAddr; 5259 5260 #if H_3D_DBBP4384 4385 #if NH_3D_DBBP 5261 4386 if( getDBBPFlag(0) ) 5262 4387 { … … 5273 4398 } 5274 4399 4400 5275 4401 Void TComDataCU::clipMv (TComMv& rcMv) 5276 4402 { 4403 const TComSPS &sps=*(m_pcSlice->getSPS()); 5277 4404 Int iMvShift = 2; 5278 #if H_3D_IC4405 #if NH_3D_INTEGER_MV_DEPTH 5279 4406 if( getSlice()->getIsDepth() ) 5280 4407 iMvShift = 0; 5281 4408 #endif 4409 5282 4410 Int iOffset = 8; 5283 Int iHorMax = ( m_pcSlice->getSPS()->getPicWidthInLumaSamples() + iOffset -m_uiCUPelX - 1 ) << iMvShift;5284 Int iHorMin = ( -(Int)g_uiMaxCUWidth- iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift;5285 5286 Int iVerMax = ( m_pcSlice->getSPS()->getPicHeightInLumaSamples() + iOffset -m_uiCUPelY - 1 ) << iMvShift;5287 Int iVerMin = ( -(Int)g_uiMaxCUHeight- iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift;5288 4411 Int iHorMax = ( sps.getPicWidthInLumaSamples() + iOffset - (Int)m_uiCUPelX - 1 ) << iMvShift; 4412 Int iHorMin = ( -(Int)sps.getMaxCUWidth() - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift; 4413 4414 Int iVerMax = ( sps.getPicHeightInLumaSamples() + iOffset - (Int)m_uiCUPelY - 1 ) << iMvShift; 4415 Int iVerMin = ( -(Int)sps.getMaxCUHeight() - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; 4416 5289 4417 rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); 5290 4418 rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); 5291 4419 } 5292 4420 5293 #if H_MV4421 #if NH_MV 5294 4422 Void TComDataCU::checkMvVertRest (TComMv& rcMv, RefPicList eRefPicList, int iRefIdx ) 5295 4423 { … … 5310 4438 { 5311 4439 UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); 5312 4440 5313 4441 UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; 5314 4442 UInt uiCnt = 0; … … 5322 4450 } 5323 4451 5324 Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts )5325 { 5326 ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts);4452 Void TComDataCU::clearCbf( UInt uiIdx, ComponentID compID, UInt uiNumParts ) 4453 { 4454 memset( &m_puhCbf[compID][uiIdx], 0, sizeof(UChar)*uiNumParts); 5327 4455 } 5328 4456 … … 5335 4463 Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) 5336 4464 { 5337 UInt uiCurrPartNumb = m_pcPic->getNumPart InCU() >> (uiDepth << 1);4465 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 5338 4466 5339 4467 memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); 5340 4468 } 5341 4469 5342 /** Test whether the current block is skipped5343 * \param uiPartIdx Blockindex5344 * \returns Flag indicating whetherthe block is skipped4470 /** Test whether the block at uiPartIdx is skipped. 4471 * \param uiPartIdx Partition index 4472 * \returns true if the current the block is skipped 5345 4473 */ 5346 4474 Bool TComDataCU::isSkipped( UInt uiPartIdx ) … … 5348 4476 return ( getSkipFlag( uiPartIdx ) ); 5349 4477 } 5350 5351 #if H_3D_IC5352 Bool TComDataCU::isIC( UInt uiPartIdx )5353 {5354 if ( m_pcSlice->isIntra () )5355 {5356 return false;5357 }5358 return ( ( getSkipFlag(uiPartIdx) || getPredictionMode(uiPartIdx) == MODE_INTER) && getICFlag( uiPartIdx ) && isICFlagRequired( uiPartIdx ) );5359 }5360 #endif5361 4478 5362 4479 // ==================================================================================================================== … … 5377 4494 case MD_ABOVE: 5378 4495 { 5379 pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx 4496 pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); 5380 4497 break; 5381 4498 } … … 5405 4522 return false; 5406 4523 } 5407 4524 5408 4525 if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) 5409 4526 { 5410 4527 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 5411 4528 5412 4529 pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; 5413 4530 return true; … … 5442 4559 } 5443 4560 5444 /** 4561 /** 5445 4562 * \param pInfo 5446 * \param eRefPicList 4563 * \param eRefPicList 5447 4564 * \param iRefIdx 5448 4565 * \param uiPartUnitIdx … … 5487 4604 } 5488 4605 5489 if ( pcTmpCU == NULL ) 4606 if ( pcTmpCU == NULL ) 5490 4607 { 5491 4608 return false; 5492 4609 } 5493 4610 5494 4611 RefPicList eRefPicList2nd = REF_PIC_LIST_0; 5495 4612 if( eRefPicList == REF_PIC_LIST_0 ) … … 5506 4623 Int iNeibPOC = iCurrPOC; 5507 4624 Int iNeibRefPOC; 5508 5509 4625 Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); 5510 4626 Bool bIsNeibRefLongTerm = false; 4627 5511 4628 //--------------- V1 (END) ------------------// 5512 4629 if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) … … 5517 4634 5518 4635 bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); 5519 if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) 5520 { 5521 if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) 5522 { 5523 rcMv = cMvPred; 5524 } 5525 else 5526 { 5527 Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); 5528 if ( iScale == 4096 ) 4636 if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) 4637 { 4638 if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) 5529 4639 { 5530 4640 rcMv = cMvPred; … … 5532 4642 else 5533 4643 { 5534 rcMv = cMvPred.scaleMv( iScale ); 5535 } 5536 } 5537 pInfo->m_acMvCand[ pInfo->iN++] = rcMv; 5538 return true; 4644 Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); 4645 if ( iScale == 4096 ) 4646 { 4647 rcMv = cMvPred; 4648 } 4649 else 4650 { 4651 rcMv = cMvPred.scaleMv( iScale ); 4652 } 4653 } 4654 4655 pInfo->m_acMvCand[ pInfo->iN++] = rcMv; 4656 return true; 5539 4657 } 5540 4658 } … … 5547 4665 5548 4666 bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); 5549 if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) 5550 { 5551 if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) 5552 { 5553 rcMv = cMvPred; 5554 } 5555 else 5556 { 5557 Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); 5558 if ( iScale == 4096 ) 4667 if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) 4668 { 4669 if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) 5559 4670 { 5560 4671 rcMv = cMvPred; … … 5562 4673 else 5563 4674 { 5564 rcMv = cMvPred.scaleMv( iScale ); 5565 } 5566 } 5567 pInfo->m_acMvCand[ pInfo->iN++] = rcMv; 5568 return true; 4675 Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); 4676 if ( iScale == 4096 ) 4677 { 4678 rcMv = cMvPred; 4679 } 4680 else 4681 { 4682 rcMv = cMvPred.scaleMv( iScale ); 4683 } 4684 } 4685 4686 pInfo->m_acMvCand[ pInfo->iN++] = rcMv; 4687 return true; 5569 4688 } 5570 4689 } … … 5573 4692 } 5574 4693 5575 /** 5576 * \param eRefPicList 5577 * \param uiCUAddr 5578 * \param uiPartUnitIdx 5579 * \param riRefIdx 5580 * \returns Bool 5581 */ 5582 Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx 5583 #if H_3D_TMVP 4694 Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx 4695 #if NH_3D_TMVP 5584 4696 , Bool bMRG 5585 4697 #endif 5586 4698 ) 5587 4699 { 5588 4700 UInt uiAbsPartAddr = uiPartUnitIdx; … … 5594 4706 // use coldir. 5595 4707 TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); 5596 TComDataCU *pColC U = pColPic->getCU( uiCUAddr );5597 if(pColC U->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE)4708 TComDataCU *pColCtu = pColPic->getCtu( ctuRsAddr ); 4709 if(pColCtu->getPic()==0||pColCtu->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES) 5598 4710 { 5599 4711 return false; 5600 4712 } 5601 iCurrPOC = m_pcSlice->getPOC(); 5602 iColPOC = pColC U->getSlice()->getPOC();5603 5604 if ( pColCU->isIntra(uiAbsPartAddr))4713 iCurrPOC = m_pcSlice->getPOC(); 4714 iColPOC = pColCtu->getSlice()->getPOC(); 4715 4716 if (!pColCtu->isInter(uiAbsPartAddr)) 5605 4717 { 5606 4718 return false; 5607 4719 } 4720 5608 4721 eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); 5609 4722 5610 Int iColRefIdx = pColC U->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr);4723 Int iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); 5611 4724 5612 4725 if (iColRefIdx < 0 ) 5613 4726 { 5614 4727 eColRefPicList = RefPicList(1 - eColRefPicList); 5615 iColRefIdx = pColC U->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr);4728 iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); 5616 4729 5617 4730 if (iColRefIdx < 0 ) … … 5622 4735 5623 4736 // Scale the vector. 5624 iColRefPOC = pColC U->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);5625 cColMv = pColC U->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);4737 iColRefPOC = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); 4738 cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); 5626 4739 5627 4740 iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); 4741 5628 4742 Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); 5629 Bool bIsColRefLongTerm = pColC U->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);5630 5631 if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) 5632 { 5633 #if H_3D_TMVP4743 Bool bIsColRefLongTerm = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); 4744 4745 if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) 4746 { 4747 #if NH_3D_TMVP 5634 4748 Int iAlterRefIdx = m_pcSlice->getAlterRefIdx(eRefPicList); 5635 4749 if(bMRG && iAlterRefIdx > 0) … … 5643 4757 { 5644 4758 #endif 5645 5646 #if H_3D_TMVP4759 return false; 4760 #if NH_3D_TMVP 5647 4761 } 5648 4762 #endif … … 5651 4765 if ( bIsCurrRefLongTerm || bIsColRefLongTerm ) 5652 4766 { 5653 #if H_3D_TMVP4767 #if NH_3D_TMVP 5654 4768 Int iCurrViewId = m_pcSlice->getViewId (); 5655 4769 Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewId (); 5656 Int iColViewId = pColC U->getSlice()->getViewId();5657 Int iColRefViewId = pColC U->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewId();4770 Int iColViewId = pColCtu->getSlice()->getViewId(); 4771 Int iColRefViewId = pColCtu->getSlice()->getRefPic( eColRefPicList, pColCtu->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewId(); 5658 4772 iScale = 4096; 5659 4773 if ( iCurrRefViewId != iCurrViewId && iColViewId != iColRefViewId ) … … 5668 4782 { 5669 4783 #endif 5670 5671 #if H_3D_TMVP4784 rcMv = cColMv; 4785 #if NH_3D_TMVP 5672 4786 } 5673 4787 #endif … … 5685 4799 } 5686 4800 } 4801 5687 4802 return true; 5688 4803 } 5689 5690 UInt TComDataCU::xGetMvdBits(TComMv cMvd)5691 {5692 return ( xGetComponentBits(cMvd.getHor()) + xGetComponentBits(cMvd.getVer()) );5693 }5694 5695 UInt TComDataCU::xGetComponentBits(Int iVal)5696 {5697 UInt uiLength = 1;5698 UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1);5699 5700 assert ( uiTemp );5701 5702 while ( 1 != uiTemp )5703 {5704 uiTemp >>= 1;5705 uiLength += 2;5706 }5707 5708 return uiLength;5709 }5710 5711 4804 5712 4805 Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC) … … 5714 4807 Int iDiffPocD = iColPOC - iColRefPOC; 5715 4808 Int iDiffPocB = iCurrPOC - iCurrRefPOC; 5716 4809 5717 4810 if( iDiffPocD == iDiffPocB ) 5718 4811 { … … 5729 4822 } 5730 4823 5731 /**5732 * \param eCUMode5733 * \param uiPartIdx5734 * \param ruiPartIdxCenter5735 * \returns Void5736 */5737 4824 Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) 5738 4825 { … … 5741 4828 Int iPartHeight; 5742 4829 getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); 5743 5744 ruiPartIdxCenter = m_ uiAbsIdxInLCU+uiPartAddr; // partition origin.4830 4831 ruiPartIdxCenter = m_absZIdxInCtu+uiPartAddr; // partition origin. 5745 4832 ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] 5746 + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartIn Width()4833 + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInCtuWidth() 5747 4834 + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; 5748 4835 } 5749 #if H_3D 4836 4837 #if NH_3D 5750 4838 Void TComDataCU::compressMV(Int scale) 4839 { 4840 Int scaleFactor = (4 / scale ) * AMVP_DECIMATION_FACTOR / m_unitSize; 5751 4841 #else 5752 4842 Void TComDataCU::compressMV() 5753 #endif 5754 { 5755 #if H_3D 5756 Int scaleFactor = (4 / scale ) * AMVP_DECIMATION_FACTOR / m_unitSize; 5757 #else 4843 { 5758 4844 Int scaleFactor = 4 * AMVP_DECIMATION_FACTOR / m_unitSize; 5759 4845 #endif 5760 4846 if (scaleFactor > 0) 5761 4847 { 5762 m_acCUMvField[0].compress(m_pePredMode, scaleFactor); 5763 m_acCUMvField[1].compress(m_pePredMode, scaleFactor); 5764 } 5765 } 5766 5767 UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) 5768 { 5769 UInt uiCTXIdx; 5770 UInt uiScanIdx; 5771 UInt uiDirMode; 5772 5773 if ( !bIsIntra ) 5774 { 5775 uiScanIdx = SCAN_DIAG; 5776 return uiScanIdx; 5777 } 5778 5779 switch(uiWidth) 5780 { 5781 case 2: uiCTXIdx = 6; break; 5782 case 4: uiCTXIdx = 5; break; 5783 case 8: uiCTXIdx = 4; break; 5784 case 16: uiCTXIdx = 3; break; 5785 case 32: uiCTXIdx = 2; break; 5786 case 64: uiCTXIdx = 1; break; 5787 default: uiCTXIdx = 0; break; 5788 } 5789 5790 if ( bIsLuma ) 5791 { 5792 uiDirMode = getLumaIntraDir(uiAbsPartIdx); 5793 #if H_3D_DIM 5794 mapDepthModeToIntraDir( uiDirMode ); 5795 #endif 5796 uiScanIdx = SCAN_DIAG; 5797 if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size 5798 { 5799 uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); 5800 } 4848 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 4849 { 4850 m_acCUMvField[i].compress(m_pePredMode, scaleFactor); 4851 } 4852 } 4853 } 4854 4855 UInt TComDataCU::getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const 4856 { 4857 //------------------------------------------------ 4858 4859 //this mechanism is available for intra only 4860 4861 if (!isIntra(uiAbsPartIdx)) 4862 { 4863 return SCAN_DIAG; 4864 } 4865 4866 //------------------------------------------------ 4867 4868 //check that MDCS can be used for this TU 4869 4870 const ChromaFormat format = getPic()->getChromaFormat(); 4871 4872 const UInt maximumWidth = MDCS_MAXIMUM_WIDTH >> getComponentScaleX(compID, format); 4873 const UInt maximumHeight = MDCS_MAXIMUM_HEIGHT >> getComponentScaleY(compID, format); 4874 4875 if ((uiWidth > maximumWidth) || (uiHeight > maximumHeight)) 4876 { 4877 return SCAN_DIAG; 4878 } 4879 4880 //------------------------------------------------ 4881 4882 //otherwise, select the appropriate mode 4883 4884 UInt uiDirMode = getIntraDir(toChannelType(compID), uiAbsPartIdx); 4885 #if NH_3D_DMM 4886 mapDmmToIntraDir( uiDirMode ); 4887 #endif 4888 4889 if (uiDirMode==DM_CHROMA_IDX) 4890 { 4891 const TComSPS *sps=getSlice()->getSPS(); 4892 const UInt partsPerMinCU = 1<<(2*(sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize())); 4893 uiDirMode = getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, getPic()->getChromaFormat(), partsPerMinCU)); 4894 #if NH_3D_DMM 4895 mapDmmToIntraDir( uiDirMode ); 4896 #endif 4897 } 4898 4899 if (isChroma(compID) && (format == CHROMA_422)) 4900 { 4901 uiDirMode = g_chroma422IntraAngleMappingTable[uiDirMode]; 4902 } 4903 4904 //------------------ 4905 4906 if (abs((Int)uiDirMode - VER_IDX) <= MDCS_ANGLE_LIMIT) 4907 { 4908 return SCAN_HOR; 4909 } 4910 else if (abs((Int)uiDirMode - HOR_IDX) <= MDCS_ANGLE_LIMIT) 4911 { 4912 return SCAN_VER; 5801 4913 } 5802 4914 else 5803 4915 { 5804 uiDirMode = getChromaIntraDir(uiAbsPartIdx); 5805 if( uiDirMode == DM_CHROMA_IDX ) 5806 { 5807 // get number of partitions in current CU 5808 UInt depth = getDepth(uiAbsPartIdx); 5809 UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); 5810 5811 // get luma mode from upper-left corner of current CU 5812 uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); 5813 #if H_3D_DIM 5814 mapDepthModeToIntraDir( uiDirMode ); 5815 #endif 5816 } 5817 uiScanIdx = SCAN_DIAG; 5818 if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size 5819 { 5820 uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); 5821 } 5822 } 5823 5824 return uiScanIdx; 5825 } 5826 5827 UInt TComDataCU::getSCUAddr() 5828 { 5829 return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; 5830 } 5831 5832 #if H_3D 5833 Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) 4916 return SCAN_DIAG; 4917 } 4918 } 4919 4920 #if NH_3D_VSO 4921 Void TComDataCU::getPosInPic( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) const 5834 4922 { 5835 4923 riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX(); … … 5838 4926 #endif 5839 4927 5840 #if H_3D_IV_MERGE4928 #if NH_3D_IV_MERGE 5841 4929 Void TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp) 5842 4930 { … … 5848 4936 Int iViewIdx = getSlice()->getDefaultRefViewIdx(); 5849 4937 pDisp->m_aVIdxCan = iViewIdx; 5850 Int iDisp = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepth Y() - 1 )) ];4938 Int iDisp = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 )) ]; 5851 4939 5852 4940 cMv.setHor(iDisp); … … 5858 4946 #endif 5859 4947 5860 #if H_3D4948 #if NH_3D_DIS 5861 4949 Bool TComDataCU::getNeighDepth ( UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index ) 5862 4950 { 5863 UInt uiPartIdxLT, uiPartIdxRT; 5864 this->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, 0, 0 ); 4951 assert(uiPartIdx==0); 4952 const UInt uiPartIdxLT = getZorderIdxInCtu() + uiPartAddr; 4953 const Int iPartIdxStride = getPic()->getNumPartInCtuWidth(); 4954 5865 4955 UInt uiMidPart, uiPartNeighbor; 5866 4956 TComDataCU* pcCUNeighbor; 5867 4957 Bool bDepAvail = false; 5868 Pel *pDepth = this->getPic()->getPicYuvRec()->get LumaAddr();5869 Int iDepStride = this->getPic()->getPicYuvRec()->getStride( );4958 Pel *pDepth = this->getPic()->getPicYuvRec()->getAddr(COMPONENT_Y); 4959 Int iDepStride = this->getPic()->getPicYuvRec()->getStride(COMPONENT_Y); 5870 4960 5871 4961 Int xP, yP, nPSW, nPSH; … … 5875 4965 { 5876 4966 case 0: // Mid Left 5877 uiMidPart = g_auiZscanToRaster[uiPartIdxLT] + (nPSH>>1) / this->getPic()->getMinCUHeight() * this->getPic()->getNumPartInWidth();4967 uiMidPart = g_auiZscanToRaster[uiPartIdxLT] + (nPSH>>1) / this->getPic()->getMinCUHeight() * iPartIdxStride; 5878 4968 pcCUNeighbor = this->getPULeft( uiPartNeighbor, g_auiRasterToZscan[uiMidPart] ); 5879 4969 if ( pcCUNeighbor ) … … 5915 5005 } 5916 5006 #endif 5917 #if H_3D_NBDV5007 #if NH_3D_NBDV 5918 5008 //Notes from QC: 5919 //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 done5009 //TBD#1: DoNBDV related contributions are just partially integrated under the marco of NH_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done 5920 5010 //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 5921 5011 //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 5922 5012 Void TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo 5923 #if H_3D_NBDV_REF5013 #if NH_3D_NBDV_REF 5924 5014 , Bool bDepthRefine 5925 5015 #endif … … 5944 5034 } 5945 5035 } 5946 #if H_3D_NBDV_REF5036 #if NH_3D_NBDV_REF 5947 5037 if( !m_pcSlice->getDepthRefinementFlag( ) ) 5948 5038 { … … 5967 5057 ///*** Derive center position *** 5968 5058 UInt uiPartIdxCenter; 5969 Int uiLCUIdx = getAddr();5059 Int uiLCUIdx = getCtuRsAddr(); 5970 5060 xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter ); 5971 5061 … … 5994 5084 pDInfo->m_aVIdxCan = iTargetViewIdx; 5995 5085 5996 #if H_3D_NBDV_REF5086 #if NH_3D_NBDV_REF 5997 5087 TComPic* picDepth = NULL; 5998 5088 #if H_3D_FCO_VSP_DONBDV_E0163 … … 6016 5106 } 6017 5107 pDInfo->m_acDoNBDV = cColMv; 6018 #endif // H_3D_NBDV_REF5108 #endif //NH_3D_NBDV_REF 6019 5109 return; 6020 5110 } … … 6030 5120 bCheckMcpDv = true; 6031 5121 if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT 6032 #if H_3D_NBDV_REF5122 #if NH_3D_NBDV_REF 6033 5123 , bDepthRefine 6034 5124 #endif … … 6040 5130 if(pcTmpCU != NULL ) 6041 5131 { 6042 bCheckMcpDv = ( ( get Addr() - pcTmpCU->getAddr() ) == 0);5132 bCheckMcpDv = ( ( getCtuRsAddr() - pcTmpCU->getCtuRsAddr() ) == 0); 6043 5133 if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE 6044 #if H_3D_NBDV_REF5134 #if NH_3D_NBDV_REF 6045 5135 , bDepthRefine 6046 5136 #endif … … 6061 5151 pDInfo->m_acNBDV = cDispVec; 6062 5152 pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ]; 6063 #if H_3D_NBDV_REF5153 #if NH_3D_NBDV_REF 6064 5154 #if H_3D_FCO_VSP_DONBDV_E0163 6065 5155 TComPic* picDepth = NULL; … … 6099 5189 pDInfo->m_aVIdxCan = getSlice()->getDefaultRefViewIdx(); 6100 5190 6101 #if H_3D_NBDV_REF5191 #if NH_3D_NBDV_REF 6102 5192 TComPic* picDepth = NULL; 6103 5193 #if H_3D_FCO_VSP_DONBDV_E0163 … … 6125 5215 } 6126 5216 6127 #if H_3D_NBDV_REF5217 #if NH_3D_NBDV_REF 6128 5218 Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT ) 6129 5219 { 6130 Int iPictureWidth = pcBaseViewDepthPicYuv->getWidth( );6131 Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight( );6132 5220 Int iPictureWidth = pcBaseViewDepthPicYuv->getWidth(COMPONENT_Y); 5221 Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(COMPONENT_Y); 5222 6133 5223 Int depthStartPosX = Clip3(0, iPictureWidth - 1, iBlkX + ((mv->getHor()+2)>>2)); 6134 5224 Int depthStartPosY = Clip3(0, iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2)); … … 6136 5226 Int depthEndPosY = Clip3(0, iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2)); 6137 5227 6138 Pel* depthTL = pcBaseViewDepthPicYuv->get LumaAddr();6139 Int depStride = pcBaseViewDepthPicYuv->getStride( );5228 Pel* depthTL = pcBaseViewDepthPicYuv->getAddr(COMPONENT_Y); 5229 Int depStride = pcBaseViewDepthPicYuv->getStride(COMPONENT_Y); 6140 5230 6141 5231 Pel maxDepthVal = 0; … … 6152 5242 if (picDepth) 6153 5243 { 6154 UInt uiAbsPartAddrCurrCU = m_ uiAbsIdxInLCU+ uiPartAddr;5244 UInt uiAbsPartAddrCurrCU = m_absZIdxInCtu + uiPartAddr; 6155 5245 Int iWidth, iHeight; 6156 5246 getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more 6157 5247 6158 5248 TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec(); 6159 Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; 6160 Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; 5249 const TComSPS &sps =*(getSlice()->getSPS()); 5250 Int iBlkX = ( getCtuRsAddr() % picDepth->getFrameWidthInCtus() ) * sps.getMaxCUWidth() + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; 5251 Int iBlkY = ( getCtuRsAddr() / picDepth->getFrameWidthInCtus() ) * sps.getMaxCUHeight() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ]; 6161 5252 6162 5253 Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx ); … … 6166 5257 } 6167 5258 } 6168 #endif // H_3D_NBDV_REF5259 #endif //NH_3D_NBDV_REF 6169 5260 6170 5261 6171 5262 Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos 6172 #if H_3D_NBDV_REF5263 #if NH_3D_NBDV_REF 6173 5264 , Bool bDepthRefine 6174 5265 #endif … … 6191 5282 pNbDvInfo->m_acNBDV = cMvPred; 6192 5283 pNbDvInfo->m_aVIdxCan = refViewIdx; 6193 #if H_3D_NBDV_REF5284 #if NH_3D_NBDV_REF 6194 5285 TComPic* picDepth = NULL; 6195 5286 assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC()); … … 6237 5328 { 6238 5329 UInt uiPartIdx = 0; 6239 UInt uiNumPartInCUWidth = m_pcPic->getNumPartIn Width();6240 Int uiLCUIdx = get Addr();5330 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInCtuWidth(); 5331 Int uiLCUIdx = getCtuRsAddr(); 6241 5332 6242 5333 UInt uiPartIdxRB; … … 6244 5335 UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; 6245 5336 6246 if (( m_pcPic->getC U(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )5337 if (( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) 6247 5338 { 6248 5339 riLCUIdxRBNb = -1; 6249 5340 riPartIdxRBNb = -1; 6250 5341 } 6251 else if(( m_pcPic->getC U(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )5342 else if(( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 6252 5343 { 6253 5344 riLCUIdxRBNb = -1; … … 6257 5348 { 6258 5349 if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU 6259 ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartIn Height() - 1 ) ) // is not at the last row of LCU5350 ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) ) // is not at the last row of LCU 6260 5351 { 6261 5352 riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; … … 6267 5358 riLCUIdxRBNb = -1; 6268 5359 } 6269 else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartIn Height() - 1 ) // is not at the last row of LCU But is last column of LCU5360 else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) // is not at the last row of LCU But is last column of LCU 6270 5361 { 6271 5362 riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; … … 6283 5374 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth ) 6284 5375 { 6285 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 5376 #if NH_3D_VSP // bug fix 5377 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 5378 assert(m_pcPic->getNumPartitionsInCtu() ==m_pcPic->getNumPartInCtuWidth()*m_pcPic->getNumPartInCtuHeight()); 5379 5380 #else 5381 UInt uiCurrPartNumb = m_pcPic->getNumPartInCtuWidth() >> (uiDepth << 1); 5382 #endif 6286 5383 for (UInt ui = 0; ui < uiCurrPartNumb; ui++ ) 6287 5384 { … … 6289 5386 } 6290 5387 } 6291 #if H_3D_VSP5388 #if NH_3D_VSP || NH_3D_DBBP 6292 5389 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth ) 6293 5390 { … … 6302 5399 Int iColViewIdx, iColRefViewIdx; 6303 5400 TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx); 6304 TComDataCU *pColCU = pColPic->getC U( uiCUAddr );5401 TComDataCU *pColCU = pColPic->getCtu( uiCUAddr ); 6305 5402 iColViewIdx = pColCU->getSlice()->getViewIndex(); 6306 if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)== SIZE_NONE||pColCU->isIntra(uiPartUnitIdx))5403 if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES||pColCU->isIntra(uiPartUnitIdx)) 6307 5404 { 6308 5405 return false; … … 6344 5441 } 6345 5442 #endif 6346 #if H_3D_FAST_TEXTURE_ENCODING5443 #if NH_3D_FAST_TEXTURE_ENCODING 6347 5444 Void 6348 5445 TComDataCU::getIVNStatus ( UInt uiPartIdx, DisInfo* pDInfo, Bool& bIVFMerge, Int& iIVFMaxD) … … 6360 5457 6361 5458 Int iCurrPosX, iCurrPosY; 6362 pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );5459 pcBaseRec->getTopLeftSamplePos( this->getCtuRsAddr(), this->getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY ); 6363 5460 6364 5461 iCurrPosX += ( ( iWidth - 1 ) >> 1 ); … … 6366 5463 6367 5464 Bool depthRefineFlag = false; 6368 #if H_3D_NBDV_REF5465 #if NH_3D_NBDV_REF 6369 5466 depthRefineFlag = m_pcSlice->getDepthRefinementFlag( ); 6370 #endif // H_3D_NBDV_REF5467 #endif // NH_3D_NBDV_REF 6371 5468 6372 5469 TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; … … 6376 5473 } 6377 5474 6378 Int iBasePosX = Clip3( 0, pcBaseRec->getWidth ( ) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );6379 Int iBasePosY = Clip3( 0, pcBaseRec->getHeight( ) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 ));6380 Int iBaseLPosX = Clip3( 0, pcBaseRec->getWidth ( ) - 1, iCurrPosX - (iWidth >> 1) + ( (cDv.getHor() + 2 ) >> 2 ) );6381 Int iBaseLPosY = Clip3( 0, pcBaseRec->getHeight( ) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 ));6382 Int iBaseRPosX = Clip3( 0, pcBaseRec->getWidth ( ) - 1, iCurrPosX + (iWidth >> 1) + 1 + ( (cDv.getHor() + 2 ) >> 2 ) );6383 Int iBaseRPosY = Clip3( 0, pcBaseRec->getHeight( ) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 ));6384 Int iBaseUPosX = Clip3( 0, pcBaseRec->getWidth ( ) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );6385 Int iBaseUPosY = Clip3( 0, pcBaseRec->getHeight( ) - 1, iCurrPosY - (iHeight >> 1) + ( (cDv.getVer() + 2 ) >> 2 ));6386 Int iBaseDPosX = Clip3( 0, pcBaseRec->getWidth ( ) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );6387 Int iBaseDPosY = Clip3( 0, pcBaseRec->getHeight( ) - 1, iCurrPosY + (iHeight >> 1) + 1 + ( (cDv.getVer() + 2 ) >> 2 ));5475 Int iBasePosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); 5476 Int iBasePosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); 5477 Int iBaseLPosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX - (iWidth >> 1) + ( (cDv.getHor() + 2 ) >> 2 ) ); 5478 Int iBaseLPosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); 5479 Int iBaseRPosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + (iWidth >> 1) + 1 + ( (cDv.getHor() + 2 ) >> 2 ) ); 5480 Int iBaseRPosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 )); 5481 Int iBaseUPosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); 5482 Int iBaseUPosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY - (iHeight >> 1) + ( (cDv.getVer() + 2 ) >> 2 )); 5483 Int iBaseDPosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); 5484 Int iBaseDPosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + (iHeight >> 1) + 1 + ( (cDv.getVer() + 2 ) >> 2 )); 6388 5485 6389 5486 Int iBaseCUAddr; … … 6402 5499 pcBaseRec->getCUAddrAndPartIdx( iBaseUPosX , iBaseUPosY , iBaseUCUAddr, iBaseUAbsPartIdx ); 6403 5500 pcBaseRec->getCUAddrAndPartIdx( iBaseDPosX , iBaseDPosY , iBaseDCUAddr, iBaseDAbsPartIdx ); 6404 TComDataCU* pcBaseCU = pcBasePic->getCU( iBaseCUAddr );6405 TComDataCU* pcBaseLCU = pcBasePic->getC U( iBaseLCUAddr );6406 TComDataCU* pcBaseRCU = pcBasePic->getC U( iBaseRCUAddr );6407 TComDataCU* pcBaseUCU = pcBasePic->getC U( iBaseUCUAddr );6408 TComDataCU* pcBaseDCU = pcBasePic->getC U( iBaseDCUAddr );5501 TComDataCU* pcBaseCU = pcBasePic->getCtu( iBaseCUAddr ); 5502 TComDataCU* pcBaseLCU = pcBasePic->getCtu( iBaseLCUAddr ); 5503 TComDataCU* pcBaseRCU = pcBasePic->getCtu( iBaseRCUAddr ); 5504 TComDataCU* pcBaseUCU = pcBasePic->getCtu( iBaseUCUAddr ); 5505 TComDataCU* pcBaseDCU = pcBasePic->getCtu( iBaseDCUAddr ); 6409 5506 bIVFMerge = pcBaseLCU->getMergeFlag( iBaseLAbsPartIdx ) && pcBaseCU->getMergeFlag( iBaseAbsPartIdx ) && pcBaseRCU->getMergeFlag( iBaseRAbsPartIdx ) && pcBaseUCU->getMergeFlag( iBaseUAbsPartIdx ) && pcBaseDCU->getMergeFlag( iBaseDAbsPartIdx ); 6410 5507 Int aiDepthL[5]; //depth level … … 6422 5519 #endif 6423 5520 6424 #if H_3D_SPIVMP5521 #if NH_3D_SPIVMP 6425 5522 Void TComDataCU::getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight) 6426 5523 { … … 6439 5536 Void TComDataCU::getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr ) 6440 5537 { 6441 uiBaseAbsPartIdx += m_ uiAbsIdxInLCU;5538 uiBaseAbsPartIdx += m_absZIdxInCtu; 6442 5539 Int iBasePelX = g_auiRasterToPelX[g_auiZscanToRaster[uiBaseAbsPartIdx]]; 6443 5540 Int iBasePelY = g_auiRasterToPelY[g_auiZscanToRaster[uiBaseAbsPartIdx]]; 6444 5541 Int iCurrPelX = iBasePelX + iPartIdx%iNumPartLine * iWidth; 6445 5542 Int iCurrPelY = iBasePelY + iPartIdx/iNumPartLine * iHeight; 6446 Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartIn Width() + iCurrPelX/getPic()->getMinCUWidth();5543 Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + iCurrPelX/getPic()->getMinCUWidth(); 6447 5544 ruiPartAddr = g_auiRasterToZscan[iCurrRaster]; 6448 ruiPartAddr -= m_ uiAbsIdxInLCU;5545 ruiPartAddr -= m_absZIdxInCtu; 6449 5546 } 6450 5547 6451 5548 Void TComDataCU::setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight ) 6452 5549 { 6453 uiAbsPartIdx += getZorderIdxInC U();5550 uiAbsPartIdx += getZorderIdxInCtu(); 6454 5551 Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]]; 6455 5552 Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]]; … … 6463 5560 for (Int j=iStartPelX; j < iEndPelX; j += getPic()->getMinCUWidth()) 6464 5561 { 6465 iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartIn Width() + j/getPic()->getMinCUWidth();5562 iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + j/getPic()->getMinCUWidth(); 6466 5563 uiPartAddr = g_auiRasterToZscan[iCurrRaster]; 6467 uiPartAddr -= getZorderIdxInC U();5564 uiPartAddr -= getZorderIdxInCtu(); 6468 5565 6469 5566 m_puhInterDir[uiPartAddr] = uiDir; … … 6473 5570 #endif 6474 5571 6475 #if H_3D_IV_MERGE5572 #if NH_3D_IV_MERGE 6476 5573 Bool 6477 5574 TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc , Bool bIsDepth 6478 #if H_3D_SPIVMP5575 #if NH_3D_SPIVMP 6479 5576 , TComMvField* pcMvFieldSP, UChar* puhInterDirSP 6480 5577 #endif … … 6495 5592 6496 5593 Int iCurrPosX, iCurrPosY; 6497 pcBaseRec->getTopLeftSamplePos( get Addr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );6498 6499 #if ! H_3D_SPIVMP5594 pcBaseRec->getTopLeftSamplePos( getCtuRsAddr(), getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY ); 5595 5596 #if !NH_3D_SPIVMP 6500 5597 iCurrPosX += ( iWidth >> 1 ); 6501 5598 iCurrPosY += ( iHeight >> 1 ); … … 6503 5600 6504 5601 Bool depthRefineFlag = false; 6505 #if H_3D_NBDV_REF5602 #if NH_3D_NBDV_REF 6506 5603 depthRefineFlag = m_pcSlice->getDepthRefinementFlag( ); 6507 #endif // H_3D_NBDV_REF5604 #endif // NH_3D_NBDV_REF 6508 5605 6509 5606 TComMv cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; … … 6514 5611 6515 5612 Bool abPdmAvailable[8] = {false, false, false, false, false, false, false, false}; 6516 #if H_3D_NBDV5613 #if NH_3D_NBDV 6517 5614 for( Int i = 0; i < 8; i++) 6518 5615 { … … 6524 5621 { 6525 5622 6526 #if H_3D_SPIVMP5623 #if NH_3D_SPIVMP 6527 5624 //////////////////////////////// 6528 5625 //////////sub-PU IvMC/////////// … … 6530 5627 if(!m_pcSlice->getIsDepth()) 6531 5628 { 5629 #if H_3D_DBBP || NH_3D_ALIGN_SPIVMP_DBBP 6532 5630 if (!getDBBPFlag(0)) 5631 #else 5632 if (1) 5633 #endif 6533 5634 { 6534 5635 Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; … … 6562 5663 } 6563 5664 6564 Int iRefCenterPosX = Clip3( 0, pcBaseRec->getWidth ( ) - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );6565 Int iRefCenterPosY = Clip3( 0, pcBaseRec->getHeight( ) - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) );5665 Int iRefCenterPosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) ); 5666 Int iRefCenterPosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) ); 6566 5667 6567 5668 pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx ); 6568 TComDataCU* pcDefaultCU = pcBasePic->getC U( iRefCenterCUAddr );5669 TComDataCU* pcDefaultCU = pcBasePic->getCtu( iRefCenterCUAddr ); 6569 5670 if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA )) 6570 5671 { … … 6590 5691 abPdmAvailable[ uiCurrRefListId ] = true; 6591 5692 TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer()); 6592 #if H_3D_NBDV6593 #if H_3D_IV_MERGE5693 #if NH_3D_NBDV 5694 #if NH_3D_IV_MERGE 6594 5695 if( !bIsDepth ) 6595 5696 { … … 6599 5700 cMv.setIDVVer (cDv.getVer()); 6600 5701 cMv.setIDVVId (iViewIndex); 6601 #if H_3D_IV_MERGE5702 #if NH_3D_IV_MERGE 6602 5703 } 6603 5704 #endif … … 6624 5725 for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth) 6625 5726 { 6626 iBasePosX = Clip3( 0, pcBaseRec->getWidth ( ) - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));6627 iBasePosY = Clip3( 0, pcBaseRec->getHeight( ) - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 ));5727 iBasePosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 )); 5728 iBasePosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 )); 6628 5729 6629 5730 pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx ); 6630 pcBaseCU = pcBasePic->getC U( iBaseCUAddr );5731 pcBaseCU = pcBasePic->getCtu( iBaseCUAddr ); 6631 5732 if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) 6632 5733 { … … 6696 5797 //////////////////////////////// 6697 5798 6698 #if H_3D_SPIVMP5799 #if NH_3D_SPIVMP 6699 5800 if(m_pcSlice->getIsDepth()) 6700 5801 { … … 6702 5803 iCurrPosY += ( iHeight >> 1 ); 6703 5804 } 5805 #if H_3D_DBBP || NH_3D_ALIGN_SPIVMP_DBBP 6704 5806 for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 6705 5807 #else 5808 for(Int iLoopCan = ( m_pcSlice->getIsDepth() ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 5809 #endif 5810 #else 6706 5811 for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) 6707 5812 #endif … … 6713 5818 Int iBaseAbsPartIdx; 6714 5819 6715 Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth * 2 6716 Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2 6717 6718 Int iBasePosX = Clip3( 0, pcBaseRec->getWidth ( ) - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );6719 Int iBasePosY = Clip3( 0, pcBaseRec->getHeight( ) - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) );5820 Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth * 2); 5821 Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2); 5822 5823 Int iBasePosX = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) ); 5824 Int iBasePosY = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); 6720 5825 pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx ); 6721 5826 6722 TComDataCU* pcBaseCU = pcBasePic->getC U( iBaseCUAddr );5827 TComDataCU* pcBaseCU = pcBasePic->getCtu( iBaseCUAddr ); 6723 5828 if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA )) 6724 5829 { … … 6747 5852 abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true; 6748 5853 TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer()); 6749 #if H_3D_NBDV6750 #if H_3D_IV_MERGE5854 #if NH_3D_NBDV 5855 #if NH_3D_IV_MERGE 6751 5856 if( !bIsDepth ) 6752 5857 { … … 6756 5861 cMv.setIDVVer (cDv.getVer()); 6757 5862 cMv.setIDVVId (iViewIndex); 6758 #if H_3D_IV_MERGE5863 #if NH_3D_IV_MERGE 6759 5864 } 6760 5865 #endif … … 6772 5877 } 6773 5878 } 6774 #if H_3D_SPIVMP 5879 #if NH_3D_SPIVMP 5880 #if H_3D_DBBP || NH_3D_ALIGN_SPIVMP_DBBP 6775 5881 for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 5882 #else 5883 for(Int iLoopCan = ( m_pcSlice->getIsDepth() ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 5884 #endif 6776 5885 #else 6777 5886 for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) … … 6802 5911 abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true; 6803 5912 paiPdmRefIdx [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx; 6804 #if H_3D_NBDV_REF5913 #if NH_3D_NBDV_REF 6805 5914 TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; 6806 5915 #endif 6807 5916 cMv.setHor( cMv.getHor() + ioffsetDV ); 6808 #if H_3D_IV_MERGE5917 #if NH_3D_IV_MERGE 6809 5918 if( bIsDepth ) 6810 5919 { … … 6827 5936 } 6828 5937 #endif 6829 #if H_3D_ARP5938 #if NH_3D_ARP 6830 5939 Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth ) 6831 5940 { 6832 assert( sizeof( *m_puhARPW) == 1 ); 6833 memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); 6834 } 6835 #endif 6836 6837 #if H_3D_IC 5941 setSubPart<UChar>( w, m_puhARPW, uiAbsPartIdx, uiDepth, 0 ); 5942 } 5943 #endif 5944 5945 #if NH_3D_IC 6838 5946 Void TComDataCU::setICFlagSubParts( Bool bICFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 6839 5947 { 6840 memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPart InCU() >> ( 2 * uiDepth ))*sizeof(Bool) );5948 memset( m_pbICFlag + uiAbsPartIdx, bICFlag, (m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ))*sizeof(Bool) ); 6841 5949 } 6842 5950 … … 6889 5997 } 6890 5998 #endif 6891 #if H_3D_DIM_DMM 6892 Void TComDataCU::setDmmWedgeTabIdxSubParts( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth ) 6893 { 6894 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 6895 for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) 6896 { 6897 m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; 6898 } 6899 } 6900 #endif 6901 6902 #if H_3D_VSP 5999 #if NH_3D_DMM 6000 Void TComDataCU::setDmm1WedgeTabIdxSubParts( UInt tabIdx, UInt uiAbsPartIdx, UInt uiDepth ) 6001 { 6002 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 6003 for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm1WedgeTabIdx[uiAbsPartIdx+ui] = tabIdx; } 6004 } 6005 #endif 6006 6007 #if NH_3D_VSP 6903 6008 Void TComDataCU::setMvFieldPUForVSP( TComDataCU* pcCU, UInt partAddr, Int width, Int height, RefPicList eRefPicList, Int iRefIdx, Int &vspSize ) 6904 6009 { … … 6956 6061 TComCUMvField *cuMvField = cu->getCUMvField( refPicList ); 6957 6062 Int partAddrRasterSubPULine = g_auiZscanToRaster[ partAddr ]; 6958 Int numPartsLine = cu->getPic()->getNumPartIn Width();6063 Int numPartsLine = cu->getPic()->getNumPartInCtuWidth(); 6959 6064 6960 6065 Int nTxtPerMvInfoX = 4; // cu->getPic()->getMinCUWidth(); 6961 6066 Int nTxtPerMvInfoY = 4; // cu->getPic()->getMinCUHeight(); 6962 6067 6963 Int refDepStride = picRefDepth->getStride( );6068 Int refDepStride = picRefDepth->getStride( COMPONENT_Y ); 6964 6069 6965 6070 TComMv tmpMv(0, 0); … … 6967 6072 6968 6073 Int refDepOffset = ( (dv->getHor()+2) >> 2 ) + ( (dv->getVer()+2) >> 2 ) * refDepStride; 6969 Pel *refDepth = picRefDepth->get LumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refDepOffset;6074 Pel *refDepth = picRefDepth->getAddr( COMPONENT_Y, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refDepOffset; 6970 6075 6971 6076 if ((height % 8))
Note: See TracChangeset for help on using the changeset viewer.