Changeset 916 in SHVCSoftware for branches/SHM-upgrade/source/Lib/TLibCommon/TComDataCU.cpp
- Timestamp:
- 12 Nov 2014, 08:09:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-upgrade/source/Lib/TLibCommon/TComDataCU.cpp
r901 r916 38 38 39 39 #include "TComDataCU.h" 40 #include "TComTU.h" 40 41 #include "TComPic.h" 41 42 … … 44 45 45 46 #if ADAPTIVE_QP_SELECTION 46 Int * TComDataCU::m_pcGlbArlCoeffY = NULL; 47 Int * TComDataCU::m_pcGlbArlCoeffCb = NULL; 48 Int * TComDataCU::m_pcGlbArlCoeffCr = NULL; 47 TCoeff * TComDataCU::m_pcGlbArlCoeff[MAX_NUM_COMPONENT] = { NULL, NULL, NULL }; 49 48 #endif 50 49 … … 58 57 m_pcSlice = NULL; 59 58 m_puhDepth = NULL; 60 59 61 60 m_skipFlag = NULL; 62 61 … … 67 66 m_puhHeight = NULL; 68 67 m_phQP = NULL; 68 m_ChromaQpAdj = NULL; 69 69 m_pbMergeFlag = NULL; 70 70 m_puhMergeIndex = NULL; 71 m_puhLumaIntraDir = NULL; 72 m_puhChromaIntraDir = NULL; 71 for(UInt i=0; i<MAX_NUM_CHANNEL_TYPE; i++) 72 { 73 m_puhIntraDir[i] = NULL; 74 } 73 75 m_puhInterDir = NULL; 74 76 m_puhTrIdx = NULL; 75 m_puhTransformSkip[0] = NULL; 76 m_puhTransformSkip[1] = NULL; 77 m_puhTransformSkip[2] = NULL; 78 m_puhCbf[0] = NULL; 79 m_puhCbf[1] = NULL; 80 m_puhCbf[2] = NULL; 81 m_pcTrCoeffY = NULL; 82 m_pcTrCoeffCb = NULL; 83 m_pcTrCoeffCr = NULL; 84 #if ADAPTIVE_QP_SELECTION 77 78 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 79 { 80 m_puhCbf[comp] = NULL; 81 m_crossComponentPredictionAlpha[comp] = NULL; 82 m_puhTransformSkip[comp] = NULL; 83 m_pcTrCoeff[comp] = NULL; 84 #if ADAPTIVE_QP_SELECTION 85 m_pcArlCoeff[comp] = NULL; 86 #endif 87 m_pcIPCMSample[comp] = NULL; 88 m_explicitRdpcmMode[comp] = NULL; 89 } 90 #if ADAPTIVE_QP_SELECTION 85 91 m_ArlCoeffIsAliasedAllocation = false; 86 m_pcArlCoeffY = NULL;87 m_pcArlCoeffCb = NULL;88 m_pcArlCoeffCr = NULL;89 92 #endif 90 91 93 m_pbIPCMFlag = NULL; 92 m_pcIPCMSampleY = NULL; 93 m_pcIPCMSampleCb = NULL; 94 m_pcIPCMSampleCr = NULL; 95 96 m_pcPattern = NULL; 97 98 m_pcCUAboveLeft = NULL; 99 m_pcCUAboveRight = NULL; 100 m_pcCUAbove = NULL; 101 m_pcCULeft = NULL; 102 103 m_apcCUColocated[0] = NULL; 104 m_apcCUColocated[1] = NULL; 105 106 m_apiMVPIdx[0] = NULL; 107 m_apiMVPIdx[1] = NULL; 108 m_apiMVPNum[0] = NULL; 109 m_apiMVPNum[1] = NULL; 94 95 m_pCtuAboveLeft = NULL; 96 m_pCtuAboveRight = NULL; 97 m_pCtuAbove = NULL; 98 m_pCtuLeft = NULL; 99 100 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 101 { 102 m_apcCUColocated[i] = NULL; 103 m_apiMVPIdx[i] = NULL; 104 m_apiMVPNum[i] = NULL; 105 } 110 106 111 107 m_bDecSubCu = false; 112 m_sliceStartCU = 0;113 m_sliceSegmentStartCU = 0;114 108 } 115 109 … … 118 112 } 119 113 120 Void TComDataCU::create( UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize114 Void TComDataCU::create( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize 121 115 #if ADAPTIVE_QP_SELECTION 122 116 , Bool bGlobalRMARLBuffer 123 #endif 117 #endif 124 118 ) 125 119 { 126 120 m_bDecSubCu = bDecSubCu; 127 121 128 122 m_pcPic = NULL; 129 123 m_pcSlice = NULL; 130 124 m_uiNumPartition = uiNumPartition; 131 125 m_unitSize = unitSize; 132 126 133 127 if ( !bDecSubCu ) 134 128 { … … 138 132 m_puhHeight = (UChar* )xMalloc(UChar, uiNumPartition); 139 133 134 m_ChromaQpAdj = new UChar[ uiNumPartition ]; 140 135 m_skipFlag = new Bool[ uiNumPartition ]; 141 142 136 m_pePartSize = new Char[ uiNumPartition ]; 143 memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) );137 memset( m_pePartSize, NUMBER_OF_PART_SIZES,uiNumPartition * sizeof( *m_pePartSize ) ); 144 138 m_pePredMode = new Char[ uiNumPartition ]; 145 139 m_CUTransquantBypass = new Bool[ uiNumPartition ]; 140 146 141 m_pbMergeFlag = (Bool* )xMalloc(Bool, uiNumPartition); 147 142 m_puhMergeIndex = (UChar* )xMalloc(UChar, uiNumPartition); 148 m_puhLumaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); 149 m_puhChromaIntraDir = (UChar* )xMalloc(UChar, uiNumPartition); 143 144 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 145 { 146 m_puhIntraDir[ch] = (UChar* )xMalloc(UChar, uiNumPartition); 147 } 150 148 m_puhInterDir = (UChar* )xMalloc(UChar, uiNumPartition); 151 149 152 150 m_puhTrIdx = (UChar* )xMalloc(UChar, uiNumPartition); 153 m_puhTransformSkip[0] = (UChar* )xMalloc(UChar, uiNumPartition); 154 m_puhTransformSkip[1] = (UChar* )xMalloc(UChar, uiNumPartition); 155 m_puhTransformSkip[2] = (UChar* )xMalloc(UChar, uiNumPartition); 156 157 m_puhCbf[0] = (UChar* )xMalloc(UChar, uiNumPartition); 158 m_puhCbf[1] = (UChar* )xMalloc(UChar, uiNumPartition); 159 m_puhCbf[2] = (UChar* )xMalloc(UChar, uiNumPartition); 160 161 m_apiMVPIdx[0] = new Char[ uiNumPartition ]; 162 m_apiMVPIdx[1] = new Char[ uiNumPartition ]; 163 m_apiMVPNum[0] = new Char[ uiNumPartition ]; 164 m_apiMVPNum[1] = new Char[ uiNumPartition ]; 165 memset( m_apiMVPIdx[0], -1,uiNumPartition * sizeof( Char ) ); 166 memset( m_apiMVPIdx[1], -1,uiNumPartition * sizeof( Char ) ); 167 168 m_pcTrCoeffY = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight); 169 m_pcTrCoeffCb = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); 170 m_pcTrCoeffCr = (TCoeff*)xMalloc(TCoeff, uiWidth*uiHeight/4); 171 memset( m_pcTrCoeffY, 0,uiWidth*uiHeight * sizeof( TCoeff ) ); 172 memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); 173 memset( m_pcTrCoeffCr, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) ); 151 152 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 153 { 154 const RefPicList rpl=RefPicList(i); 155 m_apiMVPIdx[rpl] = new Char[ uiNumPartition ]; 156 m_apiMVPNum[rpl] = new Char[ uiNumPartition ]; 157 memset( m_apiMVPIdx[rpl], -1,uiNumPartition * sizeof( Char ) ); 158 } 159 160 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 161 { 162 const ComponentID compID = ComponentID(comp); 163 const UInt chromaShift = getComponentScaleX(compID, chromaFormatIDC) + getComponentScaleY(compID, chromaFormatIDC); 164 const UInt totalSize = (uiWidth * uiHeight) >> chromaShift; 165 166 m_crossComponentPredictionAlpha[compID] = (Char* )xMalloc(Char, uiNumPartition); 167 m_puhTransformSkip[compID] = (UChar* )xMalloc(UChar, uiNumPartition); 168 m_explicitRdpcmMode[compID] = (UChar* )xMalloc(UChar, uiNumPartition); 169 m_puhCbf[compID] = (UChar* )xMalloc(UChar, uiNumPartition); 170 m_pcTrCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); 171 memset( m_pcTrCoeff[compID], 0, (totalSize * sizeof( TCoeff )) ); 172 174 173 #if ADAPTIVE_QP_SELECTION 175 if( bGlobalRMARLBuffer ) 176 { 177 if( m_pcGlbArlCoeffY == NULL ) 174 if( bGlobalRMARLBuffer ) 178 175 { 179 176 #if LAYER_CTB 180 m_pcGlbArlCoeffY = (Int*)xMalloc(Int, MAX_CU_SIZE * MAX_CU_SIZE); 181 m_pcGlbArlCoeffCb = (Int*)xMalloc(Int, MAX_CU_SIZE * MAX_CU_SIZE/4); 182 m_pcGlbArlCoeffCr = (Int*)xMalloc(Int, MAX_CU_SIZE * MAX_CU_SIZE/4); 177 if (m_pcGlbArlCoeff[compID] == NULL) m_pcGlbArlCoeff[compID] = (TCoeff*)xMalloc(TCoeff, MAX_CU_SIZE * MAX_CU_SIZE); 183 178 #else 184 m_pcGlbArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); 185 m_pcGlbArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); 186 m_pcGlbArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); 179 if (m_pcGlbArlCoeff[compID] == NULL) m_pcGlbArlCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); 187 180 #endif 188 } 189 m_pcArlCoeffY = m_pcGlbArlCoeffY; 190 m_pcArlCoeffCb = m_pcGlbArlCoeffCb; 191 m_pcArlCoeffCr = m_pcGlbArlCoeffCr; 192 m_ArlCoeffIsAliasedAllocation = true; 193 } 194 else 195 { 196 m_pcArlCoeffY = (Int*)xMalloc(Int, uiWidth*uiHeight); 197 m_pcArlCoeffCb = (Int*)xMalloc(Int, uiWidth*uiHeight/4); 198 m_pcArlCoeffCr = (Int*)xMalloc(Int, uiWidth*uiHeight/4); 199 } 181 182 m_pcArlCoeff[compID] = m_pcGlbArlCoeff[compID]; 183 m_ArlCoeffIsAliasedAllocation = true; 184 } 185 else 186 { 187 m_pcArlCoeff[compID] = (TCoeff*)xMalloc(TCoeff, totalSize); 188 } 200 189 #endif 201 190 m_pcIPCMSample[compID] = (Pel* )xMalloc(Pel , totalSize); 191 } 192 202 193 m_pbIPCMFlag = (Bool* )xMalloc(Bool, uiNumPartition); 203 m_pcIPCMSampleY = (Pel* )xMalloc(Pel , uiWidth*uiHeight); 204 m_pcIPCMSampleCb = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); 205 m_pcIPCMSampleCr = (Pel* )xMalloc(Pel , uiWidth*uiHeight/4); 206 207 m_acCUMvField[0].create( uiNumPartition ); 208 m_acCUMvField[1].create( uiNumPartition ); 209 194 195 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 196 { 197 m_acCUMvField[i].create( uiNumPartition ); 198 } 199 210 200 } 211 201 else 212 202 { 213 m_acCUMvField[0].setNumPartition(uiNumPartition ); 214 m_acCUMvField[1].setNumPartition(uiNumPartition ); 215 } 216 217 m_sliceStartCU = (UInt* )xMalloc(UInt, uiNumPartition); 218 m_sliceSegmentStartCU = (UInt* )xMalloc(UInt, uiNumPartition); 219 220 // create pattern memory 221 m_pcPattern = (TComPattern*)xMalloc(TComPattern, 1); 222 203 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 204 { 205 m_acCUMvField[i].setNumPartition(uiNumPartition ); 206 } 207 } 208 223 209 // create motion vector fields 224 225 m_pcCUAboveLeft = NULL; 226 m_pcCUAboveRight = NULL; 227 m_pcCUAbove = NULL; 228 m_pcCULeft = NULL; 229 230 m_apcCUColocated[0] = NULL; 231 m_apcCUColocated[1] = NULL; 210 211 m_pCtuAboveLeft = NULL; 212 m_pCtuAboveRight = NULL; 213 m_pCtuAbove = NULL; 214 m_pCtuLeft = NULL; 215 216 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 217 { 218 m_apcCUColocated[i] = NULL; 219 } 232 220 } 233 221 234 222 Void TComDataCU::destroy() 235 223 { 224 // encoder-side buffer free 225 if ( !m_bDecSubCu ) 226 { 227 if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } 228 if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } 229 if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } 230 if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } 231 232 if ( m_skipFlag ) { delete[] m_skipFlag; m_skipFlag = NULL; } 233 234 if ( m_pePartSize ) { delete[] m_pePartSize; m_pePartSize = NULL; } 235 if ( m_pePredMode ) { delete[] m_pePredMode; m_pePredMode = NULL; } 236 if ( m_ChromaQpAdj ) { delete[] m_ChromaQpAdj; m_ChromaQpAdj = NULL; } 237 if ( m_CUTransquantBypass ) { delete[] m_CUTransquantBypass;m_CUTransquantBypass = NULL; } 238 if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } 239 if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } 240 if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } 241 242 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 243 { 244 xFree(m_puhIntraDir[ch]); 245 m_puhIntraDir[ch] = NULL; 246 } 247 248 if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } 249 250 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 251 { 252 if ( m_crossComponentPredictionAlpha[comp] ) { xFree(m_crossComponentPredictionAlpha[comp]); m_crossComponentPredictionAlpha[comp] = NULL; } 253 if ( m_puhTransformSkip[comp] ) { xFree(m_puhTransformSkip[comp]); m_puhTransformSkip[comp] = NULL; } 254 if ( m_puhCbf[comp] ) { xFree(m_puhCbf[comp]); m_puhCbf[comp] = NULL; } 255 if ( m_pcTrCoeff[comp] ) { xFree(m_pcTrCoeff[comp]); m_pcTrCoeff[comp] = NULL; } 256 if ( m_explicitRdpcmMode[comp] ) { xFree(m_explicitRdpcmMode[comp]); m_explicitRdpcmMode[comp] = NULL; } 257 258 #if ADAPTIVE_QP_SELECTION 259 if (!m_ArlCoeffIsAliasedAllocation) 260 { 261 if ( m_pcArlCoeff[comp] ) { xFree(m_pcArlCoeff[comp]); m_pcArlCoeff[comp] = NULL; } 262 } 263 264 if ( m_pcGlbArlCoeff[comp] ) { xFree(m_pcGlbArlCoeff[comp]); m_pcGlbArlCoeff[comp] = NULL; } 265 #endif 266 267 if ( m_pcIPCMSample[comp] ) { xFree(m_pcIPCMSample[comp]); m_pcIPCMSample[comp] = NULL; } 268 } 269 if ( m_pbIPCMFlag ) { xFree(m_pbIPCMFlag ); m_pbIPCMFlag = NULL; } 270 271 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 272 { 273 const RefPicList rpl=RefPicList(i); 274 if ( m_apiMVPIdx[rpl] ) { delete[] m_apiMVPIdx[rpl]; m_apiMVPIdx[rpl] = NULL; } 275 if ( m_apiMVPNum[rpl] ) { delete[] m_apiMVPNum[rpl]; m_apiMVPNum[rpl] = NULL; } 276 } 277 278 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 279 { 280 const RefPicList rpl=RefPicList(i); 281 m_acCUMvField[rpl].destroy(); 282 } 283 } 284 236 285 m_pcPic = NULL; 237 286 m_pcSlice = NULL; 238 239 if ( m_pcPattern ) 240 { 241 xFree(m_pcPattern); 242 m_pcPattern = NULL; 243 } 244 245 // encoder-side buffer free 246 if ( !m_bDecSubCu ) 247 { 248 if ( m_phQP ) { xFree(m_phQP); m_phQP = NULL; } 249 if ( m_puhDepth ) { xFree(m_puhDepth); m_puhDepth = NULL; } 250 if ( m_puhWidth ) { xFree(m_puhWidth); m_puhWidth = NULL; } 251 if ( m_puhHeight ) { xFree(m_puhHeight); m_puhHeight = NULL; } 252 253 if ( m_skipFlag ) { delete[] m_skipFlag; m_skipFlag = NULL; } 254 255 if ( m_pePartSize ) { delete[] m_pePartSize; m_pePartSize = NULL; } 256 if ( m_pePredMode ) { delete[] m_pePredMode; m_pePredMode = NULL; } 257 if ( m_CUTransquantBypass ) { delete[] m_CUTransquantBypass;m_CUTransquantBypass = NULL; } 258 if ( m_puhCbf[0] ) { xFree(m_puhCbf[0]); m_puhCbf[0] = NULL; } 259 if ( m_puhCbf[1] ) { xFree(m_puhCbf[1]); m_puhCbf[1] = NULL; } 260 if ( m_puhCbf[2] ) { xFree(m_puhCbf[2]); m_puhCbf[2] = NULL; } 261 if ( m_puhInterDir ) { xFree(m_puhInterDir); m_puhInterDir = NULL; } 262 if ( m_pbMergeFlag ) { xFree(m_pbMergeFlag); m_pbMergeFlag = NULL; } 263 if ( m_puhMergeIndex ) { xFree(m_puhMergeIndex); m_puhMergeIndex = NULL; } 264 if ( m_puhLumaIntraDir ) { xFree(m_puhLumaIntraDir); m_puhLumaIntraDir = NULL; } 265 if ( m_puhChromaIntraDir ) { xFree(m_puhChromaIntraDir); m_puhChromaIntraDir = NULL; } 266 if ( m_puhTrIdx ) { xFree(m_puhTrIdx); m_puhTrIdx = NULL; } 267 if ( m_puhTransformSkip[0]) { xFree(m_puhTransformSkip[0]); m_puhTransformSkip[0] = NULL; } 268 if ( m_puhTransformSkip[1]) { xFree(m_puhTransformSkip[1]); m_puhTransformSkip[1] = NULL; } 269 if ( m_puhTransformSkip[2]) { xFree(m_puhTransformSkip[2]); m_puhTransformSkip[2] = NULL; } 270 if ( m_pcTrCoeffY ) { xFree(m_pcTrCoeffY); m_pcTrCoeffY = NULL; } 271 if ( m_pcTrCoeffCb ) { xFree(m_pcTrCoeffCb); m_pcTrCoeffCb = NULL; } 272 if ( m_pcTrCoeffCr ) { xFree(m_pcTrCoeffCr); m_pcTrCoeffCr = NULL; } 273 #if ADAPTIVE_QP_SELECTION 274 if (!m_ArlCoeffIsAliasedAllocation) 275 { 276 xFree(m_pcArlCoeffY); m_pcArlCoeffY = 0; 277 xFree(m_pcArlCoeffCb); m_pcArlCoeffCb = 0; 278 xFree(m_pcArlCoeffCr); m_pcArlCoeffCr = 0; 279 } 280 if ( m_pcGlbArlCoeffY ) { xFree(m_pcGlbArlCoeffY); m_pcGlbArlCoeffY = NULL; } 281 if ( m_pcGlbArlCoeffCb ) { xFree(m_pcGlbArlCoeffCb); m_pcGlbArlCoeffCb = NULL; } 282 if ( m_pcGlbArlCoeffCr ) { xFree(m_pcGlbArlCoeffCr); m_pcGlbArlCoeffCr = NULL; } 283 #endif 284 if ( m_pbIPCMFlag ) { xFree(m_pbIPCMFlag ); m_pbIPCMFlag = NULL; } 285 if ( m_pcIPCMSampleY ) { xFree(m_pcIPCMSampleY); m_pcIPCMSampleY = NULL; } 286 if ( m_pcIPCMSampleCb ) { xFree(m_pcIPCMSampleCb); m_pcIPCMSampleCb = NULL; } 287 if ( m_pcIPCMSampleCr ) { xFree(m_pcIPCMSampleCr); m_pcIPCMSampleCr = NULL; } 288 if ( m_apiMVPIdx[0] ) { delete[] m_apiMVPIdx[0]; m_apiMVPIdx[0] = NULL; } 289 if ( m_apiMVPIdx[1] ) { delete[] m_apiMVPIdx[1]; m_apiMVPIdx[1] = NULL; } 290 if ( m_apiMVPNum[0] ) { delete[] m_apiMVPNum[0]; m_apiMVPNum[0] = NULL; } 291 if ( m_apiMVPNum[1] ) { delete[] m_apiMVPNum[1]; m_apiMVPNum[1] = NULL; } 292 293 m_acCUMvField[0].destroy(); 294 m_acCUMvField[1].destroy(); 295 296 } 297 298 m_pcCUAboveLeft = NULL; 299 m_pcCUAboveRight = NULL; 300 m_pcCUAbove = NULL; 301 m_pcCULeft = NULL; 302 303 m_apcCUColocated[0] = NULL; 304 m_apcCUColocated[1] = NULL; 305 306 if( m_sliceStartCU ) 307 { 308 xFree(m_sliceStartCU); 309 m_sliceStartCU=NULL; 310 } 311 if(m_sliceSegmentStartCU ) 312 { 313 xFree(m_sliceSegmentStartCU); 314 m_sliceSegmentStartCU=NULL; 315 } 287 288 m_pCtuAboveLeft = NULL; 289 m_pCtuAboveRight = NULL; 290 m_pCtuAbove = NULL; 291 m_pCtuLeft = NULL; 292 293 294 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 295 { 296 m_apcCUColocated[i] = NULL; 297 } 298 299 } 300 301 Bool TComDataCU::CUIsFromSameTile ( const TComDataCU *pCU /* Can be NULL */) const 302 { 303 return pCU!=NULL && 304 pCU->getSlice() != NULL && 305 m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()); 306 } 307 308 Bool TComDataCU::CUIsFromSameSliceAndTile ( const TComDataCU *pCU /* Can be NULL */) const 309 { 310 return pCU!=NULL && 311 pCU->getSlice() != NULL && 312 pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() && 313 m_pcPic->getPicSym()->getTileIdxMap( pCU->getCtuRsAddr() ) == m_pcPic->getPicSym()->getTileIdxMap(getCtuRsAddr()) 314 ; 315 } 316 317 Bool TComDataCU::CUIsFromSameSliceTileAndWavefrontRow( const TComDataCU *pCU /* Can be NULL */) const 318 { 319 return CUIsFromSameSliceAndTile(pCU) 320 && (!getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() || getPic()->getCtu(getCtuRsAddr())->getCUPelY() == getPic()->getCtu(pCU->getCtuRsAddr())->getCUPelY()); 321 } 322 323 Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx) 324 { 325 TComPic* pcPic = getPic(); 326 TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); 327 328 const UInt picWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); 329 const UInt picHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); 330 const UInt granularityWidth = g_uiMaxCUWidth; 331 332 const UInt cuPosX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[absPartIdx] ]; 333 const UInt cuPosY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[absPartIdx] ]; 334 335 return (((cuPosX+getWidth( absPartIdx))%granularityWidth==0||(cuPosX+getWidth( absPartIdx)==picWidth )) 336 && ((cuPosY+getHeight(absPartIdx))%granularityWidth==0||(cuPosY+getHeight(absPartIdx)==picHeight))); 316 337 } 317 338 … … 332 353 \param iCUAddr CU address 333 354 */ 334 Void TComDataCU::initC U( TComPic* pcPic, UInt iCUAddr )355 Void TComDataCU::initCtu( TComPic* pcPic, UInt ctuRsAddr ) 335 356 { 336 357 337 358 m_pcPic = pcPic; 338 359 m_pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); 339 m_ uiCUAddr = iCUAddr;340 m_uiCUPelX = ( iCUAddr % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth;341 m_uiCUPelY = ( iCUAddr / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight;342 m_ uiAbsIdxInLCU= 0;360 m_ctuRsAddr = ctuRsAddr; 361 m_uiCUPelX = ( ctuRsAddr % pcPic->getFrameWidthInCtus() ) * g_uiMaxCUWidth; 362 m_uiCUPelY = ( ctuRsAddr / pcPic->getFrameWidthInCtus() ) * g_uiMaxCUHeight; 363 m_absZIdxInCtu = 0; 343 364 m_dTotalCost = MAX_DOUBLE; 344 365 m_uiTotalDistortion = 0; 345 366 m_uiTotalBits = 0; 346 367 m_uiTotalBins = 0; 347 m_uiNumPartition = pcPic->getNumPartInCU(); 368 m_uiNumPartition = pcPic->getNumPartitionsInCtu(); 369 370 memset( m_skipFlag , false, m_uiNumPartition * sizeof( *m_skipFlag ) ); 348 371 349 372 #if SVC_EXTENSION 350 373 m_layerId = pcPic->getLayerId(); 351 #endif 352 353 for(Int i=0; i<pcPic->getNumPartInCU(); i++) 354 { 355 if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceCurStartCUAddr()) 356 { 357 m_sliceStartCU[i]=getSlice()->getSliceCurStartCUAddr(); 358 } 359 else 360 { 361 m_sliceStartCU[i]=pcPic->getCU(getAddr())->m_sliceStartCU[i]; 362 } 363 } 364 for(Int i=0; i<pcPic->getNumPartInCU(); i++) 365 { 366 if(pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr)*pcPic->getNumPartInCU()+i>=getSlice()->getSliceSegmentCurStartCUAddr()) 367 { 368 m_sliceSegmentStartCU[i]=getSlice()->getSliceSegmentCurStartCUAddr(); 369 } 370 else 371 { 372 m_sliceSegmentStartCU[i]=pcPic->getCU(getAddr())->m_sliceSegmentStartCU[i]; 373 } 374 } 375 376 Int partStartIdx = getSlice()->getSliceSegmentCurStartCUAddr() - pcPic->getPicSym()->getInverseCUOrderMap(iCUAddr) * pcPic->getNumPartInCU(); 377 378 Int numElements = min<Int>( partStartIdx, m_uiNumPartition ); 379 for ( Int ui = 0; ui < numElements; ui++ ) 380 { 381 TComDataCU * pcFrom = pcPic->getCU(getAddr()); 382 m_skipFlag[ui] = pcFrom->getSkipFlag(ui); 383 m_pePartSize[ui] = pcFrom->getPartitionSize(ui); 384 m_pePredMode[ui] = pcFrom->getPredictionMode(ui); 385 m_CUTransquantBypass[ui] = pcFrom->getCUTransquantBypass(ui); 386 m_puhDepth[ui] = pcFrom->getDepth(ui); 387 m_puhWidth [ui] = pcFrom->getWidth(ui); 388 m_puhHeight [ui] = pcFrom->getHeight(ui); 389 m_puhTrIdx [ui] = pcFrom->getTransformIdx(ui); 390 m_puhTransformSkip[0][ui] = pcFrom->getTransformSkip(ui,TEXT_LUMA); 391 m_puhTransformSkip[1][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_U); 392 m_puhTransformSkip[2][ui] = pcFrom->getTransformSkip(ui,TEXT_CHROMA_V); 393 m_apiMVPIdx[0][ui] = pcFrom->m_apiMVPIdx[0][ui];; 394 m_apiMVPIdx[1][ui] = pcFrom->m_apiMVPIdx[1][ui]; 395 m_apiMVPNum[0][ui] = pcFrom->m_apiMVPNum[0][ui]; 396 m_apiMVPNum[1][ui] = pcFrom->m_apiMVPNum[1][ui]; 397 m_phQP[ui]=pcFrom->m_phQP[ui]; 398 m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui]; 399 m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui]; 400 m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui]; 401 m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui]; 402 m_puhInterDir[ui]=pcFrom->m_puhInterDir[ui]; 403 m_puhCbf[0][ui]=pcFrom->m_puhCbf[0][ui]; 404 m_puhCbf[1][ui]=pcFrom->m_puhCbf[1][ui]; 405 m_puhCbf[2][ui]=pcFrom->m_puhCbf[2][ui]; 406 m_pbIPCMFlag[ui] = pcFrom->m_pbIPCMFlag[ui]; 407 } 408 409 Int firstElement = max<Int>( partStartIdx, 0 ); 410 numElements = m_uiNumPartition - firstElement; 411 412 if ( numElements > 0 ) 413 { 414 memset( m_skipFlag + firstElement, false, numElements * sizeof( *m_skipFlag ) ); 415 416 memset( m_pePartSize + firstElement, SIZE_NONE, numElements * sizeof( *m_pePartSize ) ); 417 memset( m_pePredMode + firstElement, MODE_NONE, numElements * sizeof( *m_pePredMode ) ); 418 memset( m_CUTransquantBypass+ firstElement, false, numElements * sizeof( *m_CUTransquantBypass) ); 419 memset( m_puhDepth + firstElement, 0, numElements * sizeof( *m_puhDepth ) ); 420 memset( m_puhTrIdx + firstElement, 0, numElements * sizeof( *m_puhTrIdx ) ); 421 memset( m_puhTransformSkip[0] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[0]) ); 422 memset( m_puhTransformSkip[1] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[1]) ); 423 memset( m_puhTransformSkip[2] + firstElement, 0, numElements * sizeof( *m_puhTransformSkip[2]) ); 424 memset( m_puhWidth + firstElement, g_uiMaxCUWidth, numElements * sizeof( *m_puhWidth ) ); 425 memset( m_puhHeight + firstElement, g_uiMaxCUHeight, numElements * sizeof( *m_puhHeight ) ); 426 memset( m_apiMVPIdx[0] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[0] ) ); 427 memset( m_apiMVPIdx[1] + firstElement, -1, numElements * sizeof( *m_apiMVPIdx[1] ) ); 428 memset( m_apiMVPNum[0] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[0] ) ); 429 memset( m_apiMVPNum[1] + firstElement, -1, numElements * sizeof( *m_apiMVPNum[1] ) ); 430 memset( m_phQP + firstElement, getSlice()->getSliceQp(), numElements * sizeof( *m_phQP ) ); 431 memset( m_pbMergeFlag + firstElement, false, numElements * sizeof( *m_pbMergeFlag ) ); 432 memset( m_puhMergeIndex + firstElement, 0, numElements * sizeof( *m_puhMergeIndex ) ); 433 memset( m_puhLumaIntraDir + firstElement, DC_IDX, numElements * sizeof( *m_puhLumaIntraDir ) ); 434 memset( m_puhChromaIntraDir + firstElement, 0, numElements * sizeof( *m_puhChromaIntraDir ) ); 435 memset( m_puhInterDir + firstElement, 0, numElements * sizeof( *m_puhInterDir ) ); 436 memset( m_puhCbf[0] + firstElement, 0, numElements * sizeof( *m_puhCbf[0] ) ); 437 memset( m_puhCbf[1] + firstElement, 0, numElements * sizeof( *m_puhCbf[1] ) ); 438 memset( m_puhCbf[2] + firstElement, 0, numElements * sizeof( *m_puhCbf[2] ) ); 439 memset( m_pbIPCMFlag + firstElement, false, numElements * sizeof( *m_pbIPCMFlag ) ); 440 } 441 442 UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight; 443 if ( 0 >= partStartIdx ) 444 { 445 m_acCUMvField[0].clearMvField(); 446 m_acCUMvField[1].clearMvField(); 447 memset( m_pcTrCoeffY , 0, sizeof( TCoeff ) * uiTmp ); 374 #endif 375 376 memset( m_pePartSize , NUMBER_OF_PART_SIZES, m_uiNumPartition * sizeof( *m_pePartSize ) ); 377 memset( m_pePredMode , NUMBER_OF_PREDICTION_MODES, m_uiNumPartition * sizeof( *m_pePredMode ) ); 378 memset( m_CUTransquantBypass, false, m_uiNumPartition * sizeof( *m_CUTransquantBypass) ); 379 memset( m_puhDepth , 0, m_uiNumPartition * sizeof( *m_puhDepth ) ); 380 memset( m_puhTrIdx , 0, m_uiNumPartition * sizeof( *m_puhTrIdx ) ); 381 memset( m_puhWidth , g_uiMaxCUWidth, m_uiNumPartition * sizeof( *m_puhWidth ) ); 382 memset( m_puhHeight , g_uiMaxCUHeight, m_uiNumPartition * sizeof( *m_puhHeight ) ); 383 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 384 { 385 const RefPicList rpl=RefPicList(i); 386 memset( m_apiMVPIdx[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPIdx[rpl] ) ); 387 memset( m_apiMVPNum[rpl] , -1, m_uiNumPartition * sizeof( *m_apiMVPNum[rpl] ) ); 388 } 389 memset( m_phQP , getSlice()->getSliceQp(), m_uiNumPartition * sizeof( *m_phQP ) ); 390 memset( m_ChromaQpAdj , 0, m_uiNumPartition * sizeof( *m_ChromaQpAdj ) ); 391 for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 392 { 393 memset( m_crossComponentPredictionAlpha[comp] , 0, m_uiNumPartition * sizeof( *m_crossComponentPredictionAlpha[comp] ) ); 394 memset( m_puhTransformSkip[comp] , 0, m_uiNumPartition * sizeof( *m_puhTransformSkip[comp]) ); 395 memset( m_puhCbf[comp] , 0, m_uiNumPartition * sizeof( *m_puhCbf[comp] ) ); 396 memset( m_explicitRdpcmMode[comp] , NUMBER_OF_RDPCM_MODES, m_uiNumPartition * sizeof( *m_explicitRdpcmMode[comp] ) ); 397 } 398 memset( m_pbMergeFlag , false, m_uiNumPartition * sizeof( *m_pbMergeFlag ) ); 399 memset( m_puhMergeIndex , 0, m_uiNumPartition * sizeof( *m_puhMergeIndex ) ); 400 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 401 { 402 memset( m_puhIntraDir[ch] , ((ch==0) ? DC_IDX : 0), m_uiNumPartition * sizeof( *(m_puhIntraDir[ch]) ) ); 403 } 404 memset( m_puhInterDir , 0, m_uiNumPartition * sizeof( *m_puhInterDir ) ); 405 memset( m_pbIPCMFlag , false, m_uiNumPartition * sizeof( *m_pbIPCMFlag ) ); 406 407 const UInt numCoeffY = g_uiMaxCUWidth*g_uiMaxCUHeight; 408 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 409 { 410 const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(comp)) + m_pcPic->getComponentScaleY(ComponentID(comp)); 411 memset( m_pcTrCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); 448 412 #if ADAPTIVE_QP_SELECTION 449 memset( m_pcArlCoeff Y , 0, sizeof( Int ) * uiTmp );413 memset( m_pcArlCoeff[comp], 0, sizeof(TCoeff)* numCoeffY>>componentShift ); 450 414 #endif 451 memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); 452 uiTmp >>= 2; 453 memset( m_pcTrCoeffCb, 0, sizeof( TCoeff ) * uiTmp ); 454 memset( m_pcTrCoeffCr, 0, sizeof( TCoeff ) * uiTmp ); 455 #if ADAPTIVE_QP_SELECTION 456 memset( m_pcArlCoeffCb, 0, sizeof( Int ) * uiTmp ); 457 memset( m_pcArlCoeffCr, 0, sizeof( Int ) * uiTmp ); 458 #endif 459 memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); 460 memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); 461 } 462 else 463 { 464 TComDataCU * pcFrom = pcPic->getCU(getAddr()); 465 m_acCUMvField[0].copyFrom(&pcFrom->m_acCUMvField[0],m_uiNumPartition,0); 466 m_acCUMvField[1].copyFrom(&pcFrom->m_acCUMvField[1],m_uiNumPartition,0); 467 for(Int i=0; i<uiTmp; i++) 468 { 469 m_pcTrCoeffY[i]=pcFrom->m_pcTrCoeffY[i]; 470 #if ADAPTIVE_QP_SELECTION 471 m_pcArlCoeffY[i]=pcFrom->m_pcArlCoeffY[i]; 472 #endif 473 m_pcIPCMSampleY[i]=pcFrom->m_pcIPCMSampleY[i]; 474 } 475 for(Int i=0; i<(uiTmp>>2); i++) 476 { 477 m_pcTrCoeffCb[i]=pcFrom->m_pcTrCoeffCb[i]; 478 m_pcTrCoeffCr[i]=pcFrom->m_pcTrCoeffCr[i]; 479 #if ADAPTIVE_QP_SELECTION 480 m_pcArlCoeffCb[i]=pcFrom->m_pcArlCoeffCb[i]; 481 m_pcArlCoeffCr[i]=pcFrom->m_pcArlCoeffCr[i]; 482 #endif 483 m_pcIPCMSampleCb[i]=pcFrom->m_pcIPCMSampleCb[i]; 484 m_pcIPCMSampleCr[i]=pcFrom->m_pcIPCMSampleCr[i]; 485 } 415 } 416 417 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 418 { 419 m_acCUMvField[i].clearMvField(); 486 420 } 487 421 488 422 // Setting neighbor CU 489 m_pcCULeft = NULL; 490 m_pcCUAbove = NULL; 491 m_pcCUAboveLeft = NULL; 492 m_pcCUAboveRight = NULL; 493 494 m_apcCUColocated[0] = NULL; 495 m_apcCUColocated[1] = NULL; 496 497 UInt uiWidthInCU = pcPic->getFrameWidthInCU(); 498 if ( m_uiCUAddr % uiWidthInCU ) 499 { 500 m_pcCULeft = pcPic->getCU( m_uiCUAddr - 1 ); 501 } 502 503 if ( m_uiCUAddr / uiWidthInCU ) 504 { 505 m_pcCUAbove = pcPic->getCU( m_uiCUAddr - uiWidthInCU ); 506 } 507 508 if ( m_pcCULeft && m_pcCUAbove ) 509 { 510 m_pcCUAboveLeft = pcPic->getCU( m_uiCUAddr - uiWidthInCU - 1 ); 511 } 512 513 if ( m_pcCUAbove && ( (m_uiCUAddr%uiWidthInCU) < (uiWidthInCU-1) ) ) 514 { 515 m_pcCUAboveRight = pcPic->getCU( m_uiCUAddr - uiWidthInCU + 1 ); 516 } 517 518 if ( getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) 519 { 520 m_apcCUColocated[0] = getSlice()->getRefPic( REF_PIC_LIST_0, 0)->getCU( m_uiCUAddr ); 521 } 522 523 if ( getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) 524 { 525 m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr ); 526 } 527 } 528 529 /** initialize prediction data with enabling sub-LCU-level delta QP 423 m_pCtuLeft = NULL; 424 m_pCtuAbove = NULL; 425 m_pCtuAboveLeft = NULL; 426 m_pCtuAboveRight = NULL; 427 428 429 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 430 { 431 m_apcCUColocated[i] = NULL; 432 } 433 434 UInt frameWidthInCtus = pcPic->getFrameWidthInCtus(); 435 if ( m_ctuRsAddr % frameWidthInCtus ) 436 { 437 m_pCtuLeft = pcPic->getCtu( m_ctuRsAddr - 1 ); 438 } 439 440 if ( m_ctuRsAddr / frameWidthInCtus ) 441 { 442 m_pCtuAbove = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus ); 443 } 444 445 if ( m_pCtuLeft && m_pCtuAbove ) 446 { 447 m_pCtuAboveLeft = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus - 1 ); 448 } 449 450 if ( m_pCtuAbove && ( (m_ctuRsAddr%frameWidthInCtus) < (frameWidthInCtus-1) ) ) 451 { 452 m_pCtuAboveRight = pcPic->getCtu( m_ctuRsAddr - frameWidthInCtus + 1 ); 453 } 454 455 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 456 { 457 const RefPicList rpl=RefPicList(i); 458 if ( getSlice()->getNumRefIdx( rpl ) > 0 ) 459 { 460 m_apcCUColocated[rpl] = getSlice()->getRefPic( rpl, 0)->getCtu( m_ctuRsAddr ); 461 } 462 } 463 } 464 465 466 /** initialize prediction data with enabling sub-CTU-level delta QP 530 467 *\param uiDepth depth of the current CU 531 468 *\param qp qp for the current CU 532 469 *- set CU width and CU height according to depth 533 *- set qp value according to input qp 534 *- set last-coded qp value according to input last-coded qp 470 *- set qp value according to input qp 471 *- set last-coded qp value according to input last-coded qp 535 472 */ 536 Void TComDataCU::initEstData( UInt uiDepth, Int qp,Bool bTransquantBypass )473 Void TComDataCU::initEstData( const UInt uiDepth, const Int qp, const Bool bTransquantBypass ) 537 474 { 538 475 m_dTotalCost = MAX_DOUBLE; … … 546 483 for (UInt ui = 0; ui < m_uiNumPartition; ui++) 547 484 { 548 if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui >= getSlice()->getSliceSegmentCurStartCUAddr()) 549 { 550 m_apiMVPIdx[0][ui] = -1; 551 m_apiMVPIdx[1][ui] = -1; 552 m_apiMVPNum[0][ui] = -1; 553 m_apiMVPNum[1][ui] = -1; 554 m_puhDepth [ui] = uiDepth; 555 m_puhWidth [ui] = uhWidth; 556 m_puhHeight [ui] = uhHeight; 557 m_puhTrIdx [ui] = 0; 558 m_puhTransformSkip[0][ui] = 0; 559 m_puhTransformSkip[1][ui] = 0; 560 m_puhTransformSkip[2][ui] = 0; 561 m_skipFlag[ui] = false; 562 m_pePartSize[ui] = SIZE_NONE; 563 m_pePredMode[ui] = MODE_NONE; 564 m_CUTransquantBypass[ui] = bTransquantBypass; 565 m_pbIPCMFlag[ui] = 0; 566 m_phQP[ui] = qp; 567 m_pbMergeFlag[ui] = 0; 568 m_puhMergeIndex[ui] = 0; 569 m_puhLumaIntraDir[ui] = DC_IDX; 570 m_puhChromaIntraDir[ui] = 0; 571 m_puhInterDir[ui] = 0; 572 m_puhCbf[0][ui] = 0; 573 m_puhCbf[1][ui] = 0; 574 m_puhCbf[2][ui] = 0; 575 } 576 } 577 578 if(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU >= getSlice()->getSliceSegmentCurStartCUAddr()) 579 { 580 m_acCUMvField[0].clearMvField(); 581 m_acCUMvField[1].clearMvField(); 582 UInt uiTmp = uhWidth*uhHeight; 583 584 memset( m_pcTrCoeffY, 0, uiTmp * sizeof( *m_pcTrCoeffY ) ); 485 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 486 { 487 const RefPicList rpl=RefPicList(i); 488 m_apiMVPIdx[rpl][ui] = -1; 489 m_apiMVPNum[rpl][ui] = -1; 490 } 491 m_puhDepth [ui] = uiDepth; 492 m_puhWidth [ui] = uhWidth; 493 m_puhHeight [ui] = uhHeight; 494 m_puhTrIdx [ui] = 0; 495 for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 496 { 497 m_crossComponentPredictionAlpha[comp][ui] = 0; 498 m_puhTransformSkip [comp][ui] = 0; 499 m_explicitRdpcmMode [comp][ui] = NUMBER_OF_RDPCM_MODES; 500 } 501 m_skipFlag[ui] = false; 502 m_pePartSize[ui] = NUMBER_OF_PART_SIZES; 503 m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; 504 m_CUTransquantBypass[ui] = bTransquantBypass; 505 m_pbIPCMFlag[ui] = 0; 506 m_phQP[ui] = qp; 507 m_ChromaQpAdj[ui] = 0; 508 m_pbMergeFlag[ui] = 0; 509 m_puhMergeIndex[ui] = 0; 510 511 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 512 { 513 m_puhIntraDir[ch][ui] = ((ch==0) ? DC_IDX : 0); 514 } 515 516 m_puhInterDir[ui] = 0; 517 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 518 { 519 m_puhCbf[comp][ui] = 0; 520 } 521 } 522 523 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 524 { 525 m_acCUMvField[i].clearMvField(); 526 } 527 528 const UInt numCoeffY = uhWidth*uhHeight; 529 530 for (UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 531 { 532 const ComponentID component = ComponentID(comp); 533 const UInt numCoeff = numCoeffY >> (getPic()->getComponentScaleX(component) + getPic()->getComponentScaleY(component)); 534 memset( m_pcTrCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); 585 535 #if ADAPTIVE_QP_SELECTION 586 memset( m_pcArlCoeff Y , 0, uiTmp * sizeof( *m_pcArlCoeffY) );536 memset( m_pcArlCoeff[comp], 0, numCoeff * sizeof( TCoeff ) ); 587 537 #endif 588 memset( m_pcIPCMSampleY, 0, uiTmp * sizeof( *m_pcIPCMSampleY ) ); 589 590 uiTmp>>=2; 591 memset( m_pcTrCoeffCb, 0, uiTmp * sizeof( *m_pcTrCoeffCb ) ); 592 memset( m_pcTrCoeffCr, 0, uiTmp * sizeof( *m_pcTrCoeffCr ) ); 593 #if ADAPTIVE_QP_SELECTION 594 memset( m_pcArlCoeffCb, 0, uiTmp * sizeof( *m_pcArlCoeffCb ) ); 595 memset( m_pcArlCoeffCr, 0, uiTmp * sizeof( *m_pcArlCoeffCr ) ); 596 #endif 597 memset( m_pcIPCMSampleCb, 0, uiTmp * sizeof( *m_pcIPCMSampleCb ) ); 598 memset( m_pcIPCMSampleCr, 0, uiTmp * sizeof( *m_pcIPCMSampleCr ) ); 538 memset( m_pcIPCMSample[comp], 0, numCoeff * sizeof( Pel) ); 599 539 } 600 540 } … … 610 550 m_pcPic = pcCU->getPic(); 611 551 m_pcSlice = m_pcPic->getSlice(m_pcPic->getCurrSliceIdx()); 612 m_ uiCUAddr = pcCU->getAddr();613 m_ uiAbsIdxInLCU = pcCU->getZorderIdxInCU() + uiPartOffset;552 m_ctuRsAddr = pcCU->getCtuRsAddr(); 553 m_absZIdxInCtu = pcCU->getZorderIdxInCtu() + uiPartOffset; 614 554 615 555 m_uiCUPelX = pcCU->getCUPelX() + ( g_uiMaxCUWidth>>uiDepth )*( uiPartUnitIdx & 1 ); … … 624 564 Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; 625 565 Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; 626 627 566 Int sizeInChar = sizeof( Char ) * m_uiNumPartition; 567 628 568 memset( m_phQP, qp, sizeInChar ); 629 630 569 memset( m_pbMergeFlag, 0, iSizeInBool ); 631 570 memset( m_puhMergeIndex, 0, iSizeInUchar ); 632 memset( m_puhLumaIntraDir, DC_IDX, iSizeInUchar ); 633 memset( m_puhChromaIntraDir, 0, iSizeInUchar ); 571 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 572 { 573 memset( m_puhIntraDir[ch], ((ch==0) ? DC_IDX : 0), iSizeInUchar ); 574 } 575 634 576 memset( m_puhInterDir, 0, iSizeInUchar ); 635 577 memset( m_puhTrIdx, 0, iSizeInUchar ); 636 memset( m_puhTransformSkip[0], 0, iSizeInUchar ); 637 memset( m_puhTransformSkip[1], 0, iSizeInUchar ); 638 memset( m_puhTransformSkip[2], 0, iSizeInUchar ); 639 memset( m_puhCbf[0], 0, iSizeInUchar ); 640 memset( m_puhCbf[1], 0, iSizeInUchar ); 641 memset( m_puhCbf[2], 0, iSizeInUchar ); 578 579 for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 580 { 581 memset( m_crossComponentPredictionAlpha[comp], 0, iSizeInUchar ); 582 memset( m_puhTransformSkip[comp], 0, iSizeInUchar ); 583 memset( m_puhCbf[comp], 0, iSizeInUchar ); 584 memset( m_explicitRdpcmMode[comp], NUMBER_OF_RDPCM_MODES, iSizeInUchar ); 585 } 586 642 587 memset( m_puhDepth, uiDepth, iSizeInUchar ); 643 588 … … 650 595 { 651 596 m_skipFlag[ui] = false; 652 m_pePartSize[ui] = SIZE_NONE;653 m_pePredMode[ui] = MODE_NONE;597 m_pePartSize[ui] = NUMBER_OF_PART_SIZES; 598 m_pePredMode[ui] = NUMBER_OF_PREDICTION_MODES; 654 599 m_CUTransquantBypass[ui] = false; 655 m_apiMVPIdx[0][ui] = -1; 656 m_apiMVPIdx[1][ui] = -1; 657 m_apiMVPNum[0][ui] = -1; 658 m_apiMVPNum[1][ui] = -1; 659 if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU+ui<getSlice()->getSliceSegmentCurStartCUAddr()) 660 { 661 m_apiMVPIdx[0][ui] = pcCU->m_apiMVPIdx[0][uiPartOffset+ui]; 662 m_apiMVPIdx[1][ui] = pcCU->m_apiMVPIdx[1][uiPartOffset+ui];; 663 m_apiMVPNum[0][ui] = pcCU->m_apiMVPNum[0][uiPartOffset+ui];; 664 m_apiMVPNum[1][ui] = pcCU->m_apiMVPNum[1][uiPartOffset+ui];; 665 m_puhDepth [ui] = pcCU->getDepth(uiPartOffset+ui); 666 m_puhWidth [ui] = pcCU->getWidth(uiPartOffset+ui); 667 m_puhHeight [ui] = pcCU->getHeight(uiPartOffset+ui); 668 m_puhTrIdx [ui] = pcCU->getTransformIdx(uiPartOffset+ui); 669 m_puhTransformSkip[0][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_LUMA); 670 m_puhTransformSkip[1][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_U); 671 m_puhTransformSkip[2][ui] = pcCU->getTransformSkip(uiPartOffset+ui,TEXT_CHROMA_V); 672 m_skipFlag[ui] = pcCU->getSkipFlag(uiPartOffset+ui); 673 m_pePartSize[ui] = pcCU->getPartitionSize(uiPartOffset+ui); 674 m_pePredMode[ui] = pcCU->getPredictionMode(uiPartOffset+ui); 675 m_CUTransquantBypass[ui] = pcCU->getCUTransquantBypass(uiPartOffset+ui); 676 m_pbIPCMFlag[ui]=pcCU->m_pbIPCMFlag[uiPartOffset+ui]; 677 m_phQP[ui] = pcCU->m_phQP[uiPartOffset+ui]; 678 m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui]; 679 m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui]; 680 m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui]; 681 m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui]; 682 m_puhInterDir[ui]=pcCU->m_puhInterDir[uiPartOffset+ui]; 683 m_puhCbf[0][ui]=pcCU->m_puhCbf[0][uiPartOffset+ui]; 684 m_puhCbf[1][ui]=pcCU->m_puhCbf[1][uiPartOffset+ui]; 685 m_puhCbf[2][ui]=pcCU->m_puhCbf[2][uiPartOffset+ui]; 686 687 } 688 } 689 UInt uiTmp = uhWidth*uhHeight; 690 memset( m_pcTrCoeffY , 0, sizeof(TCoeff)*uiTmp ); 691 #if ADAPTIVE_QP_SELECTION 692 memset( m_pcArlCoeffY , 0, sizeof(Int)*uiTmp ); 600 m_ChromaQpAdj[ui] = 0; 601 602 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 603 { 604 const RefPicList rpl=RefPicList(i); 605 m_apiMVPIdx[rpl][ui] = -1; 606 m_apiMVPNum[rpl][ui] = -1; 607 } 608 } 609 610 const UInt numCoeffY = uhWidth*uhHeight; 611 for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) 612 { 613 const UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(ch)) + m_pcPic->getComponentScaleY(ComponentID(ch)); 614 memset( m_pcTrCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); 615 #if ADAPTIVE_QP_SELECTION 616 memset( m_pcArlCoeff[ch], 0, sizeof(TCoeff)*(numCoeffY>>componentShift) ); 693 617 #endif 694 memset( m_pcIPCMSampleY , 0, sizeof( Pel ) * uiTmp ); 695 uiTmp >>= 2; 696 memset( m_pcTrCoeffCb, 0, sizeof(TCoeff)*uiTmp ); 697 memset( m_pcTrCoeffCr, 0, sizeof(TCoeff)*uiTmp ); 698 #if ADAPTIVE_QP_SELECTION 699 memset( m_pcArlCoeffCb, 0, sizeof(Int)*uiTmp ); 700 memset( m_pcArlCoeffCr, 0, sizeof(Int)*uiTmp ); 701 #endif 702 memset( m_pcIPCMSampleCb , 0, sizeof( Pel ) * uiTmp ); 703 memset( m_pcIPCMSampleCr , 0, sizeof( Pel ) * uiTmp ); 704 m_acCUMvField[0].clearMvField(); 705 m_acCUMvField[1].clearMvField(); 706 707 if(m_pcPic->getPicSym()->getInverseCUOrderMap(getAddr())*m_pcPic->getNumPartInCU()+m_uiAbsIdxInLCU<getSlice()->getSliceSegmentCurStartCUAddr()) 708 { 709 // Part of this CU contains data from an older slice. Now copy in that data. 710 UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); 711 UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); 712 TComDataCU * bigCU = getPic()->getCU(getAddr()); 713 Int minui = uiPartOffset; 714 minui = -minui; 715 pcCU->m_acCUMvField[0].copyTo(&m_acCUMvField[0],minui,uiPartOffset,m_uiNumPartition); 716 pcCU->m_acCUMvField[1].copyTo(&m_acCUMvField[1],minui,uiPartOffset,m_uiNumPartition); 717 UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*m_uiAbsIdxInLCU/pcCU->getPic()->getNumPartInCU(); 718 uiTmp = uhWidth*uhHeight; 719 for(Int i=0; i<uiTmp; i++) 720 { 721 m_pcTrCoeffY[i]=bigCU->m_pcTrCoeffY[uiCoffOffset+i]; 722 #if ADAPTIVE_QP_SELECTION 723 m_pcArlCoeffY[i]=bigCU->m_pcArlCoeffY[uiCoffOffset+i]; 724 #endif 725 m_pcIPCMSampleY[i]=bigCU->m_pcIPCMSampleY[uiCoffOffset+i]; 726 } 727 uiTmp>>=2; 728 uiCoffOffset>>=2; 729 for(Int i=0; i<uiTmp; i++) 730 { 731 m_pcTrCoeffCr[i]=bigCU->m_pcTrCoeffCr[uiCoffOffset+i]; 732 m_pcTrCoeffCb[i]=bigCU->m_pcTrCoeffCb[uiCoffOffset+i]; 733 #if ADAPTIVE_QP_SELECTION 734 m_pcArlCoeffCr[i]=bigCU->m_pcArlCoeffCr[uiCoffOffset+i]; 735 m_pcArlCoeffCb[i]=bigCU->m_pcArlCoeffCb[uiCoffOffset+i]; 736 #endif 737 m_pcIPCMSampleCb[i]=bigCU->m_pcIPCMSampleCb[uiCoffOffset+i]; 738 m_pcIPCMSampleCr[i]=bigCU->m_pcIPCMSampleCr[uiCoffOffset+i]; 739 } 740 } 741 742 m_pcCULeft = pcCU->getCULeft(); 743 m_pcCUAbove = pcCU->getCUAbove(); 744 m_pcCUAboveLeft = pcCU->getCUAboveLeft(); 745 m_pcCUAboveRight = pcCU->getCUAboveRight(); 746 747 m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); 748 m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); 749 memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); 750 memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition); 618 memset( m_pcIPCMSample[ch], 0, sizeof(Pel)* (numCoeffY>>componentShift) ); 619 } 620 621 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 622 { 623 m_acCUMvField[i].clearMvField(); 624 } 625 626 m_pCtuLeft = pcCU->getCtuLeft(); 627 m_pCtuAbove = pcCU->getCtuAbove(); 628 m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); 629 m_pCtuAboveRight = pcCU->getCtuAboveRight(); 630 631 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 632 { 633 m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); 634 } 751 635 } 752 636 … … 770 654 { 771 655 UInt uiPart = uiAbsPartIdx; 772 656 773 657 m_pcPic = pcCU->getPic(); 774 658 m_pcSlice = pcCU->getSlice(); 775 m_ uiCUAddr = pcCU->getAddr();776 m_ uiAbsIdxInLCU= uiAbsPartIdx;777 659 m_ctuRsAddr = pcCU->getCtuRsAddr(); 660 m_absZIdxInCtu = uiAbsPartIdx; 661 778 662 m_uiCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 779 663 m_uiCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 780 664 781 665 m_skipFlag=pcCU->getSkipFlag() + uiPart; 782 666 783 667 m_phQP=pcCU->getQP() + uiPart; 668 m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiPart; 784 669 m_pePartSize = pcCU->getPartitionSize() + uiPart; 785 670 m_pePredMode=pcCU->getPredictionMode() + uiPart; 786 671 m_CUTransquantBypass = pcCU->getCUTransquantBypass()+uiPart; 787 672 788 673 m_pbMergeFlag = pcCU->getMergeFlag() + uiPart; 789 674 m_puhMergeIndex = pcCU->getMergeIndex() + uiPart; 790 675 791 m_puhLumaIntraDir = pcCU->getLumaIntraDir() + uiPart; 792 m_puhChromaIntraDir = pcCU->getChromaIntraDir() + uiPart; 676 for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) 677 { 678 m_puhIntraDir[ch] = pcCU->getIntraDir(ChannelType(ch)) + uiPart; 679 } 680 793 681 m_puhInterDir = pcCU->getInterDir() + uiPart; 794 682 m_puhTrIdx = pcCU->getTransformIdx() + uiPart; 795 m_puhTransformSkip[0] = pcCU->getTransformSkip(TEXT_LUMA) + uiPart; 796 m_puhTransformSkip[1] = pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPart; 797 m_puhTransformSkip[2] = pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPart; 798 799 m_puhCbf[0]= pcCU->getCbf(TEXT_LUMA) + uiPart; 800 m_puhCbf[1]= pcCU->getCbf(TEXT_CHROMA_U) + uiPart; 801 m_puhCbf[2]= pcCU->getCbf(TEXT_CHROMA_V) + uiPart; 802 683 684 for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 685 { 686 m_crossComponentPredictionAlpha[comp] = pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)) + uiPart; 687 m_puhTransformSkip[comp] = pcCU->getTransformSkip(ComponentID(comp)) + uiPart; 688 m_puhCbf[comp] = pcCU->getCbf(ComponentID(comp)) + uiPart; 689 m_explicitRdpcmMode[comp] = pcCU->getExplicitRdpcmMode(ComponentID(comp)) + uiPart; 690 } 691 803 692 m_puhDepth=pcCU->getDepth() + uiPart; 804 693 m_puhWidth=pcCU->getWidth() + uiPart; 805 694 m_puhHeight=pcCU->getHeight() + uiPart; 806 807 m_apiMVPIdx[0]=pcCU->getMVPIdx(REF_PIC_LIST_0) + uiPart; 808 m_apiMVPIdx[1]=pcCU->getMVPIdx(REF_PIC_LIST_1) + uiPart; 809 m_apiMVPNum[0]=pcCU->getMVPNum(REF_PIC_LIST_0) + uiPart; 810 m_apiMVPNum[1]=pcCU->getMVPNum(REF_PIC_LIST_1) + uiPart; 811 695 812 696 m_pbIPCMFlag = pcCU->getIPCMFlag() + uiPart; 813 697 814 m_pcCUAboveLeft = pcCU->getCUAboveLeft(); 815 m_pcCUAboveRight = pcCU->getCUAboveRight(); 816 m_pcCUAbove = pcCU->getCUAbove(); 817 m_pcCULeft = pcCU->getCULeft(); 818 819 m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); 820 m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); 821 698 m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); 699 m_pCtuAboveRight = pcCU->getCtuAboveRight(); 700 m_pCtuAbove = pcCU->getCtuAbove(); 701 m_pCtuLeft = pcCU->getCtuLeft(); 702 703 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 704 { 705 const RefPicList rpl=RefPicList(i); 706 m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); 707 m_apiMVPIdx[rpl]=pcCU->getMVPIdx(rpl) + uiPart; 708 m_apiMVPNum[rpl]=pcCU->getMVPNum(rpl) + uiPart; 709 } 710 711 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 712 { 713 const RefPicList rpl=RefPicList(i); 714 m_acCUMvField[rpl].linkToWithOffset( pcCU->getCUMvField(rpl), uiPart ); 715 } 716 822 717 UInt uiMaxCuWidth=pcCU->getSlice()->getSPS()->getMaxCUWidth(); 823 718 UInt uiMaxCuHeight=pcCU->getSlice()->getSPS()->getMaxCUHeight(); 824 825 UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartInCU(); 826 827 m_pcTrCoeffY = pcCU->getCoeffY() + uiCoffOffset; 719 720 UInt uiCoffOffset = uiMaxCuWidth*uiMaxCuHeight*uiAbsPartIdx/pcCU->getPic()->getNumPartitionsInCtu(); 721 722 for (UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) 723 { 724 const ComponentID component = ComponentID(ch); 725 const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); 726 const UInt offset = uiCoffOffset >> componentShift; 727 m_pcTrCoeff[ch] = pcCU->getCoeff(component) + offset; 828 728 #if ADAPTIVE_QP_SELECTION 829 m_pcArlCoeffY= pcCU->getArlCoeffY() + uiCoffOffset;729 m_pcArlCoeff[ch] = pcCU->getArlCoeff(component) + offset; 830 730 #endif 831 m_pcIPCMSampleY = pcCU->getPCMSampleY() + uiCoffOffset; 832 833 uiCoffOffset >>=2; 834 m_pcTrCoeffCb=pcCU->getCoeffCb() + uiCoffOffset; 835 m_pcTrCoeffCr=pcCU->getCoeffCr() + uiCoffOffset; 836 #if ADAPTIVE_QP_SELECTION 837 m_pcArlCoeffCb=pcCU->getArlCoeffCb() + uiCoffOffset; 838 m_pcArlCoeffCr=pcCU->getArlCoeffCr() + uiCoffOffset; 839 #endif 840 m_pcIPCMSampleCb = pcCU->getPCMSampleCb() + uiCoffOffset; 841 m_pcIPCMSampleCr = pcCU->getPCMSampleCr() + uiCoffOffset; 842 843 m_acCUMvField[0].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_0), uiPart ); 844 m_acCUMvField[1].linkToWithOffset( pcCU->getCUMvField(REF_PIC_LIST_1), uiPart ); 845 memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); 846 memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiPart,sizeof(UInt)*m_uiNumPartition); 731 m_pcIPCMSample[ch] = pcCU->getPCMSample(component) + offset; 732 } 847 733 } 848 734 … … 852 738 m_pcPic = pcCU->getPic(); 853 739 m_pcSlice = pcCU->getSlice(); 854 m_ uiCUAddr = pcCU->getAddr();855 m_ uiAbsIdxInLCU= uiAbsPartIdx;856 740 m_ctuRsAddr = pcCU->getCtuRsAddr(); 741 m_absZIdxInCtu = uiAbsPartIdx; 742 857 743 Int iRastPartIdx = g_auiZscanToRaster[uiAbsPartIdx]; 858 m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInWidth() ); 859 m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInWidth() ); 860 861 m_pcCUAboveLeft = pcCU->getCUAboveLeft(); 862 m_pcCUAboveRight = pcCU->getCUAboveRight(); 863 m_pcCUAbove = pcCU->getCUAbove(); 864 m_pcCULeft = pcCU->getCULeft(); 865 866 m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); 867 m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); 868 744 m_uiCUPelX = pcCU->getCUPelX() + m_pcPic->getMinCUWidth ()*( iRastPartIdx % m_pcPic->getNumPartInCtuWidth() ); 745 m_uiCUPelY = pcCU->getCUPelY() + m_pcPic->getMinCUHeight()*( iRastPartIdx / m_pcPic->getNumPartInCtuWidth() ); 746 747 m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); 748 m_pCtuAboveRight = pcCU->getCtuAboveRight(); 749 m_pCtuAbove = pcCU->getCtuAbove(); 750 m_pCtuLeft = pcCU->getCtuLeft(); 751 752 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 753 { 754 m_apcCUColocated[i] = pcCU->getCUColocated(RefPicList(i)); 755 } 756 869 757 m_skipFlag = pcCU->getSkipFlag () + uiAbsPartIdx; 870 758 871 759 m_pePartSize = pcCU->getPartitionSize () + uiAbsPartIdx; 872 760 m_pePredMode = pcCU->getPredictionMode() + uiAbsPartIdx; 761 m_ChromaQpAdj = pcCU->getChromaQpAdj() + uiAbsPartIdx; 873 762 m_CUTransquantBypass = pcCU->getCUTransquantBypass() + uiAbsPartIdx; 874 763 m_puhInterDir = pcCU->getInterDir () + uiAbsPartIdx; 875 764 876 765 m_puhDepth = pcCU->getDepth () + uiAbsPartIdx; 877 766 m_puhWidth = pcCU->getWidth () + uiAbsPartIdx; 878 767 m_puhHeight = pcCU->getHeight() + uiAbsPartIdx; 879 768 880 769 m_pbMergeFlag = pcCU->getMergeFlag() + uiAbsPartIdx; 881 770 m_puhMergeIndex = pcCU->getMergeIndex() + uiAbsPartIdx; … … 883 772 m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx; 884 773 m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx; 885 774 886 775 m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx ); 887 888 memcpy(m_sliceStartCU,pcCU->m_sliceStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition);889 memcpy(m_sliceSegmentStartCU,pcCU->m_sliceSegmentStartCU+uiAbsPartIdx,sizeof(UInt)*m_uiNumPartition);890 776 } 891 777 … … 895 781 { 896 782 assert( uiPartUnitIdx<4 ); 897 783 898 784 m_dTotalCost += pcCU->getTotalCost(); 899 785 m_uiTotalDistortion += pcCU->getTotalDistortion(); 900 786 m_uiTotalBits += pcCU->getTotalBits(); 901 787 902 788 UInt uiOffset = pcCU->getTotalNumPart()*uiPartUnitIdx; 903 789 const UInt numValidComp=pcCU->getPic()->getNumberValidComponents(); 790 const UInt numValidChan=pcCU->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; 791 904 792 UInt uiNumPartition = pcCU->getTotalNumPart(); 905 793 Int iSizeInUchar = sizeof( UChar ) * uiNumPartition; 906 794 Int iSizeInBool = sizeof( Bool ) * uiNumPartition; 907 795 908 796 Int sizeInChar = sizeof( Char ) * uiNumPartition; 909 797 memcpy( m_skipFlag + uiOffset, pcCU->getSkipFlag(), sizeof( *m_skipFlag ) * uiNumPartition ); … … 911 799 memcpy( m_pePartSize + uiOffset, pcCU->getPartitionSize(), sizeof( *m_pePartSize ) * uiNumPartition ); 912 800 memcpy( m_pePredMode + uiOffset, pcCU->getPredictionMode(), sizeof( *m_pePredMode ) * uiNumPartition ); 801 memcpy( m_ChromaQpAdj + uiOffset, pcCU->getChromaQpAdj(), sizeof( *m_ChromaQpAdj ) * uiNumPartition ); 913 802 memcpy( m_CUTransquantBypass + uiOffset, pcCU->getCUTransquantBypass(), sizeof( *m_CUTransquantBypass ) * uiNumPartition ); 914 803 memcpy( m_pbMergeFlag + uiOffset, pcCU->getMergeFlag(), iSizeInBool ); 915 804 memcpy( m_puhMergeIndex + uiOffset, pcCU->getMergeIndex(), iSizeInUchar ); 916 memcpy( m_puhLumaIntraDir + uiOffset, pcCU->getLumaIntraDir(), iSizeInUchar ); 917 memcpy( m_puhChromaIntraDir + uiOffset, pcCU->getChromaIntraDir(), iSizeInUchar ); 805 806 for (UInt ch=0; ch<numValidChan; ch++) 807 { 808 memcpy( m_puhIntraDir[ch] + uiOffset, pcCU->getIntraDir(ChannelType(ch)), iSizeInUchar ); 809 } 810 918 811 memcpy( m_puhInterDir + uiOffset, pcCU->getInterDir(), iSizeInUchar ); 919 812 memcpy( m_puhTrIdx + uiOffset, pcCU->getTransformIdx(), iSizeInUchar ); 920 memcpy( m_puhTransformSkip[0] + uiOffset, pcCU->getTransformSkip(TEXT_LUMA), iSizeInUchar ); 921 memcpy( m_puhTransformSkip[1] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_U), iSizeInUchar ); 922 memcpy( m_puhTransformSkip[2] + uiOffset, pcCU->getTransformSkip(TEXT_CHROMA_V), iSizeInUchar ); 923 924 memcpy( m_puhCbf[0] + uiOffset, pcCU->getCbf(TEXT_LUMA) , iSizeInUchar ); 925 memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar ); 926 memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar ); 927 813 814 for(UInt comp=0; comp<numValidComp; comp++) 815 { 816 memcpy( m_crossComponentPredictionAlpha[comp] + uiOffset, pcCU->getCrossComponentPredictionAlpha(ComponentID(comp)), iSizeInUchar ); 817 memcpy( m_puhTransformSkip[comp] + uiOffset, pcCU->getTransformSkip(ComponentID(comp)) , iSizeInUchar ); 818 memcpy( m_puhCbf[comp] + uiOffset, pcCU->getCbf(ComponentID(comp)) , iSizeInUchar ); 819 memcpy( m_explicitRdpcmMode[comp] + uiOffset, pcCU->getExplicitRdpcmMode(ComponentID(comp)) , iSizeInUchar ); 820 } 821 928 822 memcpy( m_puhDepth + uiOffset, pcCU->getDepth(), iSizeInUchar ); 929 823 memcpy( m_puhWidth + uiOffset, pcCU->getWidth(), iSizeInUchar ); 930 824 memcpy( m_puhHeight + uiOffset, pcCU->getHeight(), iSizeInUchar ); 931 932 memcpy( m_apiMVPIdx[0] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_0), iSizeInUchar ); 933 memcpy( m_apiMVPIdx[1] + uiOffset, pcCU->getMVPIdx(REF_PIC_LIST_1), iSizeInUchar ); 934 memcpy( m_apiMVPNum[0] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_0), iSizeInUchar ); 935 memcpy( m_apiMVPNum[1] + uiOffset, pcCU->getMVPNum(REF_PIC_LIST_1), iSizeInUchar ); 936 825 937 826 memcpy( m_pbIPCMFlag + uiOffset, pcCU->getIPCMFlag(), iSizeInBool ); 938 827 939 m_pcCUAboveLeft = pcCU->getCUAboveLeft(); 940 m_pcCUAboveRight = pcCU->getCUAboveRight(); 941 m_pcCUAbove = pcCU->getCUAbove(); 942 m_pcCULeft = pcCU->getCULeft(); 943 944 m_apcCUColocated[0] = pcCU->getCUColocated(REF_PIC_LIST_0); 945 m_apcCUColocated[1] = pcCU->getCUColocated(REF_PIC_LIST_1); 946 947 m_acCUMvField[0].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_0 ), pcCU->getTotalNumPart(), uiOffset ); 948 m_acCUMvField[1].copyFrom( pcCU->getCUMvField( REF_PIC_LIST_1 ), pcCU->getTotalNumPart(), uiOffset ); 949 950 UInt uiTmp = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); 951 UInt uiTmp2 = uiPartUnitIdx*uiTmp; 952 memcpy( m_pcTrCoeffY + uiTmp2, pcCU->getCoeffY(), sizeof(TCoeff)*uiTmp ); 828 m_pCtuAboveLeft = pcCU->getCtuAboveLeft(); 829 m_pCtuAboveRight = pcCU->getCtuAboveRight(); 830 m_pCtuAbove = pcCU->getCtuAbove(); 831 m_pCtuLeft = pcCU->getCtuLeft(); 832 833 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 834 { 835 const RefPicList rpl=RefPicList(i); 836 memcpy( m_apiMVPIdx[rpl] + uiOffset, pcCU->getMVPIdx(rpl), iSizeInUchar ); 837 memcpy( m_apiMVPNum[rpl] + uiOffset, pcCU->getMVPNum(rpl), iSizeInUchar ); 838 m_apcCUColocated[rpl] = pcCU->getCUColocated(rpl); 839 } 840 841 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 842 { 843 const RefPicList rpl=RefPicList(i); 844 m_acCUMvField[rpl].copyFrom( pcCU->getCUMvField( rpl ), pcCU->getTotalNumPart(), uiOffset ); 845 } 846 847 const UInt numCoeffY = g_uiMaxCUWidth*g_uiMaxCUHeight >> (uiDepth<<1); 848 const UInt offsetY = uiPartUnitIdx*numCoeffY; 849 for (UInt ch=0; ch<numValidComp; ch++) 850 { 851 const ComponentID component = ComponentID(ch); 852 const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); 853 const UInt offset = offsetY>>componentShift; 854 memcpy( m_pcTrCoeff [ch] + offset, pcCU->getCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); 953 855 #if ADAPTIVE_QP_SELECTION 954 memcpy( m_pcArlCoeffY + uiTmp2, pcCU->getArlCoeffY(), sizeof(Int)*uiTmp);856 memcpy( m_pcArlCoeff[ch] + offset, pcCU->getArlCoeff(component), sizeof(TCoeff)*(numCoeffY>>componentShift) ); 955 857 #endif 956 memcpy( m_pcIPCMSampleY + uiTmp2 , pcCU->getPCMSampleY(), sizeof(Pel) * uiTmp ); 957 958 uiTmp >>= 2; uiTmp2>>= 2; 959 memcpy( m_pcTrCoeffCb + uiTmp2, pcCU->getCoeffCb(), sizeof(TCoeff)*uiTmp ); 960 memcpy( m_pcTrCoeffCr + uiTmp2, pcCU->getCoeffCr(), sizeof(TCoeff)*uiTmp ); 961 #if ADAPTIVE_QP_SELECTION 962 memcpy( m_pcArlCoeffCb + uiTmp2, pcCU->getArlCoeffCb(), sizeof(Int)*uiTmp ); 963 memcpy( m_pcArlCoeffCr + uiTmp2, pcCU->getArlCoeffCr(), sizeof(Int)*uiTmp ); 964 #endif 965 memcpy( m_pcIPCMSampleCb + uiTmp2 , pcCU->getPCMSampleCb(), sizeof(Pel) * uiTmp ); 966 memcpy( m_pcIPCMSampleCr + uiTmp2 , pcCU->getPCMSampleCr(), sizeof(Pel) * uiTmp ); 858 memcpy( m_pcIPCMSample[ch] + offset, pcCU->getPCMSample(component), sizeof(Pel)*(numCoeffY>>componentShift) ); 859 } 860 967 861 m_uiTotalBins += pcCU->getTotalBins(); 968 memcpy( m_sliceStartCU + uiOffset, pcCU->m_sliceStartCU, sizeof( UInt ) * uiNumPartition );969 memcpy( m_sliceSegmentStartCU + uiOffset, pcCU->m_sliceSegmentStartCU, sizeof( UInt ) * uiNumPartition );970 862 } 971 863 … … 974 866 Void TComDataCU::copyToPic( UChar uhDepth ) 975 867 { 976 TComDataCU*& rpcCU = m_pcPic->getCU( m_uiCUAddr ); 977 978 rpcCU->getTotalCost() = m_dTotalCost; 979 rpcCU->getTotalDistortion() = m_uiTotalDistortion; 980 rpcCU->getTotalBits() = m_uiTotalBits; 981 868 TComDataCU* pCtu = m_pcPic->getCtu( m_ctuRsAddr ); 869 const UInt numValidComp=pCtu->getPic()->getNumberValidComponents(); 870 const UInt numValidChan=pCtu->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; 871 872 pCtu->getTotalCost() = m_dTotalCost; 873 pCtu->getTotalDistortion() = m_uiTotalDistortion; 874 pCtu->getTotalBits() = m_uiTotalBits; 875 982 876 Int iSizeInUchar = sizeof( UChar ) * m_uiNumPartition; 983 877 Int iSizeInBool = sizeof( Bool ) * m_uiNumPartition; 984 985 878 Int sizeInChar = sizeof( Char ) * m_uiNumPartition; 986 879 987 memcpy( rpcCU->getSkipFlag() + m_uiAbsIdxInLCU, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); 988 989 memcpy( rpcCU->getQP() + m_uiAbsIdxInLCU, m_phQP, sizeInChar ); 990 991 memcpy( rpcCU->getPartitionSize() + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); 992 memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); 993 memcpy( rpcCU->getCUTransquantBypass()+ m_uiAbsIdxInLCU, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); 994 memcpy( rpcCU->getMergeFlag() + m_uiAbsIdxInLCU, m_pbMergeFlag, iSizeInBool ); 995 memcpy( rpcCU->getMergeIndex() + m_uiAbsIdxInLCU, m_puhMergeIndex, iSizeInUchar ); 996 memcpy( rpcCU->getLumaIntraDir() + m_uiAbsIdxInLCU, m_puhLumaIntraDir, iSizeInUchar ); 997 memcpy( rpcCU->getChromaIntraDir() + m_uiAbsIdxInLCU, m_puhChromaIntraDir, iSizeInUchar ); 998 memcpy( rpcCU->getInterDir() + m_uiAbsIdxInLCU, m_puhInterDir, iSizeInUchar ); 999 memcpy( rpcCU->getTransformIdx() + m_uiAbsIdxInLCU, m_puhTrIdx, iSizeInUchar ); 1000 memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhTransformSkip[0], iSizeInUchar ); 1001 memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhTransformSkip[1], iSizeInUchar ); 1002 memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhTransformSkip[2], iSizeInUchar ); 1003 1004 memcpy( rpcCU->getCbf(TEXT_LUMA) + m_uiAbsIdxInLCU, m_puhCbf[0], iSizeInUchar ); 1005 memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + m_uiAbsIdxInLCU, m_puhCbf[1], iSizeInUchar ); 1006 memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + m_uiAbsIdxInLCU, m_puhCbf[2], iSizeInUchar ); 1007 1008 memcpy( rpcCU->getDepth() + m_uiAbsIdxInLCU, m_puhDepth, iSizeInUchar ); 1009 memcpy( rpcCU->getWidth() + m_uiAbsIdxInLCU, m_puhWidth, iSizeInUchar ); 1010 memcpy( rpcCU->getHeight() + m_uiAbsIdxInLCU, m_puhHeight, iSizeInUchar ); 1011 1012 memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPIdx[0], iSizeInUchar ); 1013 memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPIdx[1], iSizeInUchar ); 1014 memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + m_uiAbsIdxInLCU, m_apiMVPNum[0], iSizeInUchar ); 1015 memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + m_uiAbsIdxInLCU, m_apiMVPNum[1], iSizeInUchar ); 1016 1017 m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU ); 1018 m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU ); 1019 1020 memcpy( rpcCU->getIPCMFlag() + m_uiAbsIdxInLCU, m_pbIPCMFlag, iSizeInBool ); 1021 1022 UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); 1023 UInt uiTmp2 = m_uiAbsIdxInLCU*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); 1024 memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); 1025 #if ADAPTIVE_QP_SELECTION 1026 memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp ); 880 memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition ); 881 882 memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar ); 883 884 memcpy( pCtu->getPartitionSize() + m_absZIdxInCtu, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition ); 885 memcpy( pCtu->getPredictionMode() + m_absZIdxInCtu, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition ); 886 memcpy( pCtu->getChromaQpAdj() + m_absZIdxInCtu, m_ChromaQpAdj, sizeof( *m_ChromaQpAdj ) * m_uiNumPartition ); 887 memcpy( pCtu->getCUTransquantBypass()+ m_absZIdxInCtu, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * m_uiNumPartition ); 888 memcpy( pCtu->getMergeFlag() + m_absZIdxInCtu, m_pbMergeFlag, iSizeInBool ); 889 memcpy( pCtu->getMergeIndex() + m_absZIdxInCtu, m_puhMergeIndex, iSizeInUchar ); 890 for (UInt ch=0; ch<numValidChan; ch++) 891 { 892 memcpy( pCtu->getIntraDir(ChannelType(ch)) + m_absZIdxInCtu, m_puhIntraDir[ch], iSizeInUchar); 893 } 894 895 memcpy( pCtu->getInterDir() + m_absZIdxInCtu, m_puhInterDir, iSizeInUchar ); 896 memcpy( pCtu->getTransformIdx() + m_absZIdxInCtu, m_puhTrIdx, iSizeInUchar ); 897 898 for(UInt comp=0; comp<numValidComp; comp++) 899 { 900 memcpy( pCtu->getCrossComponentPredictionAlpha(ComponentID(comp)) + m_absZIdxInCtu, m_crossComponentPredictionAlpha[comp], iSizeInUchar ); 901 memcpy( pCtu->getTransformSkip(ComponentID(comp)) + m_absZIdxInCtu, m_puhTransformSkip[comp], iSizeInUchar ); 902 memcpy( pCtu->getCbf(ComponentID(comp)) + m_absZIdxInCtu, m_puhCbf[comp], iSizeInUchar ); 903 memcpy( pCtu->getExplicitRdpcmMode(ComponentID(comp)) + m_absZIdxInCtu, m_explicitRdpcmMode[comp], iSizeInUchar ); 904 } 905 906 memcpy( pCtu->getDepth() + m_absZIdxInCtu, m_puhDepth, iSizeInUchar ); 907 memcpy( pCtu->getWidth() + m_absZIdxInCtu, m_puhWidth, iSizeInUchar ); 908 memcpy( pCtu->getHeight() + m_absZIdxInCtu, m_puhHeight, iSizeInUchar ); 909 910 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 911 { 912 const RefPicList rpl=RefPicList(i); 913 memcpy( pCtu->getMVPIdx(rpl) + m_absZIdxInCtu, m_apiMVPIdx[rpl], iSizeInUchar ); 914 memcpy( pCtu->getMVPNum(rpl) + m_absZIdxInCtu, m_apiMVPNum[rpl], iSizeInUchar ); 915 } 916 917 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 918 { 919 const RefPicList rpl=RefPicList(i); 920 m_acCUMvField[rpl].copyTo( pCtu->getCUMvField( rpl ), m_absZIdxInCtu ); 921 } 922 923 memcpy( pCtu->getIPCMFlag() + m_absZIdxInCtu, m_pbIPCMFlag, iSizeInBool ); 924 925 const UInt numCoeffY = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>(uhDepth<<1); 926 const UInt offsetY = m_absZIdxInCtu*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); 927 for (UInt comp=0; comp<numValidComp; comp++) 928 { 929 const ComponentID component = ComponentID(comp); 930 const UInt componentShift = m_pcPic->getComponentScaleX(component) + m_pcPic->getComponentScaleY(component); 931 memcpy( pCtu->getCoeff(component) + (offsetY>>componentShift), m_pcTrCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); 932 #if ADAPTIVE_QP_SELECTION 933 memcpy( pCtu->getArlCoeff(component) + (offsetY>>componentShift), m_pcArlCoeff[component], sizeof(TCoeff)*(numCoeffY>>componentShift) ); 1027 934 #endif 1028 memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof(Pel)*uiTmp ); 1029 1030 uiTmp >>= 2; uiTmp2 >>= 2; 1031 memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); 1032 memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); 1033 #if ADAPTIVE_QP_SELECTION 1034 memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); 1035 memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); 1036 #endif 1037 memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); 1038 memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); 1039 rpcCU->getTotalBins() = m_uiTotalBins; 1040 memcpy( rpcCU->m_sliceStartCU + m_uiAbsIdxInLCU, m_sliceStartCU, sizeof( UInt ) * m_uiNumPartition ); 1041 memcpy( rpcCU->m_sliceSegmentStartCU + m_uiAbsIdxInLCU, m_sliceSegmentStartCU, sizeof( UInt ) * m_uiNumPartition ); 935 memcpy( pCtu->getPCMSample(component) + (offsetY>>componentShift), m_pcIPCMSample[component], sizeof(Pel)*(numCoeffY>>componentShift) ); 936 } 937 938 pCtu->getTotalBins() = m_uiTotalBins; 1042 939 } 1043 940 1044 941 Void TComDataCU::copyToPic( UChar uhDepth, UInt uiPartIdx, UInt uiPartDepth ) 1045 942 { 1046 TComDataCU* & rpcCU = m_pcPic->getCU( m_uiCUAddr );943 TComDataCU* pCtu = m_pcPic->getCtu( m_ctuRsAddr ); 1047 944 UInt uiQNumPart = m_uiNumPartition>>(uiPartDepth<<1); 1048 945 1049 946 UInt uiPartStart = uiPartIdx*uiQNumPart; 1050 UInt uiPartOffset = m_uiAbsIdxInLCU + uiPartStart; 1051 1052 rpcCU->getTotalCost() = m_dTotalCost; 1053 rpcCU->getTotalDistortion() = m_uiTotalDistortion; 1054 rpcCU->getTotalBits() = m_uiTotalBits; 1055 947 UInt uiPartOffset = m_absZIdxInCtu + uiPartStart; 948 949 const UInt numValidComp=pCtu->getPic()->getNumberValidComponents(); 950 const UInt numValidChan=pCtu->getPic()->getChromaFormat()==CHROMA_400 ? 1:2; 951 952 pCtu->getTotalCost() = m_dTotalCost; 953 pCtu->getTotalDistortion() = m_uiTotalDistortion; 954 pCtu->getTotalBits() = m_uiTotalBits; 955 1056 956 Int iSizeInUchar = sizeof( UChar ) * uiQNumPart; 1057 957 Int iSizeInBool = sizeof( Bool ) * uiQNumPart; 1058 1059 958 Int sizeInChar = sizeof( Char ) * uiQNumPart; 1060 memcpy( rpcCU->getSkipFlag() + uiPartOffset, m_skipFlag, sizeof( *m_skipFlag ) * uiQNumPart ); 1061 1062 memcpy( rpcCU->getQP() + uiPartOffset, m_phQP, sizeInChar ); 1063 memcpy( rpcCU->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart ); 1064 memcpy( rpcCU->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( *m_pePredMode ) * uiQNumPart ); 1065 memcpy( rpcCU->getCUTransquantBypass()+ uiPartOffset, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * uiQNumPart ); 1066 memcpy( rpcCU->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); 1067 memcpy( rpcCU->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); 1068 memcpy( rpcCU->getLumaIntraDir() + uiPartOffset, m_puhLumaIntraDir, iSizeInUchar ); 1069 memcpy( rpcCU->getChromaIntraDir() + uiPartOffset, m_puhChromaIntraDir, iSizeInUchar ); 1070 memcpy( rpcCU->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); 1071 memcpy( rpcCU->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); 1072 memcpy( rpcCU->getTransformSkip(TEXT_LUMA) + uiPartOffset, m_puhTransformSkip[0], iSizeInUchar ); 1073 memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhTransformSkip[1], iSizeInUchar ); 1074 memcpy( rpcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhTransformSkip[2], iSizeInUchar ); 1075 memcpy( rpcCU->getCbf(TEXT_LUMA) + uiPartOffset, m_puhCbf[0], iSizeInUchar ); 1076 memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar ); 1077 memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar ); 1078 1079 memcpy( rpcCU->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); 1080 memcpy( rpcCU->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); 1081 memcpy( rpcCU->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); 1082 1083 memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPIdx[0], iSizeInUchar ); 1084 memcpy( rpcCU->getMVPIdx(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPIdx[1], iSizeInUchar ); 1085 memcpy( rpcCU->getMVPNum(REF_PIC_LIST_0) + uiPartOffset, m_apiMVPNum[0], iSizeInUchar ); 1086 memcpy( rpcCU->getMVPNum(REF_PIC_LIST_1) + uiPartOffset, m_apiMVPNum[1], iSizeInUchar ); 1087 m_acCUMvField[0].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_0 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); 1088 m_acCUMvField[1].copyTo( rpcCU->getCUMvField( REF_PIC_LIST_1 ), m_uiAbsIdxInLCU, uiPartStart, uiQNumPart ); 1089 1090 memcpy( rpcCU->getIPCMFlag() + uiPartOffset, m_pbIPCMFlag, iSizeInBool ); 1091 1092 UInt uiTmp = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); 1093 UInt uiTmp2 = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); 1094 memcpy( rpcCU->getCoeffY() + uiTmp2, m_pcTrCoeffY, sizeof(TCoeff)*uiTmp ); 959 960 memcpy( pCtu->getSkipFlag() + uiPartOffset, m_skipFlag, sizeof( *m_skipFlag ) * uiQNumPart ); 961 962 memcpy( pCtu->getQP() + uiPartOffset, m_phQP, sizeInChar ); 963 memcpy( pCtu->getPartitionSize() + uiPartOffset, m_pePartSize, sizeof( *m_pePartSize ) * uiQNumPart ); 964 memcpy( pCtu->getPredictionMode() + uiPartOffset, m_pePredMode, sizeof( *m_pePredMode ) * uiQNumPart ); 965 966 memcpy( pCtu->getCUTransquantBypass()+ uiPartOffset, m_CUTransquantBypass, sizeof( *m_CUTransquantBypass ) * uiQNumPart ); 967 memcpy( pCtu->getMergeFlag() + uiPartOffset, m_pbMergeFlag, iSizeInBool ); 968 memcpy( pCtu->getMergeIndex() + uiPartOffset, m_puhMergeIndex, iSizeInUchar ); 969 for (UInt ch=0; ch<numValidChan; ch++) 970 { 971 memcpy( pCtu->getIntraDir(ChannelType(ch)) + uiPartOffset, m_puhIntraDir[ch], iSizeInUchar ); 972 } 973 974 memcpy( pCtu->getInterDir() + uiPartOffset, m_puhInterDir, iSizeInUchar ); 975 memcpy( pCtu->getTransformIdx() + uiPartOffset, m_puhTrIdx, iSizeInUchar ); 976 977 for(UInt comp=0; comp<numValidComp; comp++) 978 { 979 memcpy( pCtu->getCrossComponentPredictionAlpha(ComponentID(comp)) + uiPartOffset, m_crossComponentPredictionAlpha[comp], iSizeInUchar ); 980 memcpy( pCtu->getTransformSkip(ComponentID(comp) ) + uiPartOffset, m_puhTransformSkip[comp], iSizeInUchar ); 981 memcpy( pCtu->getCbf(ComponentID(comp)) + uiPartOffset, m_puhCbf[comp], iSizeInUchar ); 982 memcpy( pCtu->getExplicitRdpcmMode(ComponentID(comp) ) + uiPartOffset, m_explicitRdpcmMode[comp], iSizeInUchar ); 983 } 984 985 memcpy( pCtu->getDepth() + uiPartOffset, m_puhDepth, iSizeInUchar ); 986 memcpy( pCtu->getWidth() + uiPartOffset, m_puhWidth, iSizeInUchar ); 987 memcpy( pCtu->getHeight() + uiPartOffset, m_puhHeight, iSizeInUchar ); 988 989 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 990 { 991 const RefPicList rpl=RefPicList(i); 992 memcpy( pCtu->getMVPIdx(rpl) + uiPartOffset, m_apiMVPIdx[rpl], iSizeInUchar ); 993 memcpy( pCtu->getMVPNum(rpl) + uiPartOffset, m_apiMVPNum[rpl], iSizeInUchar ); 994 } 995 996 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 997 { 998 const RefPicList rpl=RefPicList(i); 999 m_acCUMvField[rpl].copyTo( pCtu->getCUMvField( rpl ), m_absZIdxInCtu, uiPartStart, uiQNumPart ); 1000 } 1001 1002 memcpy( pCtu->getIPCMFlag() + uiPartOffset, m_pbIPCMFlag, iSizeInBool ); 1003 1004 const UInt numCoeffY = (g_uiMaxCUWidth*g_uiMaxCUHeight)>>((uhDepth+uiPartDepth)<<1); 1005 const UInt offsetY = uiPartOffset*m_pcPic->getMinCUWidth()*m_pcPic->getMinCUHeight(); 1006 for (UInt comp=0; comp<numValidComp; comp++) 1007 { 1008 UInt componentShift = m_pcPic->getComponentScaleX(ComponentID(comp)) + m_pcPic->getComponentScaleY(ComponentID(comp)); 1009 memcpy( pCtu->getCoeff(ComponentID(comp)) + (offsetY>>componentShift), m_pcTrCoeff[comp], sizeof(TCoeff)*(numCoeffY>>componentShift) ); 1095 1010 #if ADAPTIVE_QP_SELECTION 1096 memcpy( rpcCU->getArlCoeffY() + uiTmp2, m_pcArlCoeffY, sizeof(Int)*uiTmp);1011 memcpy( pCtu->getArlCoeff(ComponentID(comp)) + (offsetY>>componentShift), m_pcArlCoeff[comp], sizeof(TCoeff)*(numCoeffY>>componentShift) ); 1097 1012 #endif 1098 1099 memcpy( rpcCU->getPCMSampleY() + uiTmp2 , m_pcIPCMSampleY, sizeof( Pel ) * uiTmp ); 1100 1101 uiTmp >>= 2; uiTmp2 >>= 2; 1102 memcpy( rpcCU->getCoeffCb() + uiTmp2, m_pcTrCoeffCb, sizeof(TCoeff)*uiTmp ); 1103 memcpy( rpcCU->getCoeffCr() + uiTmp2, m_pcTrCoeffCr, sizeof(TCoeff)*uiTmp ); 1104 #if ADAPTIVE_QP_SELECTION 1105 memcpy( rpcCU->getArlCoeffCb() + uiTmp2, m_pcArlCoeffCb, sizeof(Int)*uiTmp ); 1106 memcpy( rpcCU->getArlCoeffCr() + uiTmp2, m_pcArlCoeffCr, sizeof(Int)*uiTmp ); 1107 #endif 1108 1109 memcpy( rpcCU->getPCMSampleCb() + uiTmp2 , m_pcIPCMSampleCb, sizeof( Pel ) * uiTmp ); 1110 memcpy( rpcCU->getPCMSampleCr() + uiTmp2 , m_pcIPCMSampleCr, sizeof( Pel ) * uiTmp ); 1111 rpcCU->getTotalBins() = m_uiTotalBins; 1112 memcpy( rpcCU->m_sliceStartCU + uiPartOffset, m_sliceStartCU, sizeof( UInt ) * uiQNumPart ); 1113 memcpy( rpcCU->m_sliceSegmentStartCU + uiPartOffset, m_sliceSegmentStartCU, sizeof( UInt ) * uiQNumPart ); 1013 memcpy( pCtu->getPCMSample(ComponentID(comp)) + (offsetY>>componentShift), m_pcIPCMSample[comp], sizeof(Pel)*(numCoeffY>>componentShift) ); 1014 } 1015 1016 pCtu->getTotalBins() = m_uiTotalBins; 1114 1017 } 1115 1018 … … 1118 1021 // -------------------------------------------------------------------------------------------------------------------- 1119 1022 1120 TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, 1121 UInt uiCurrPartUnitIdx, 1122 Bool bEnforceSliceRestriction, 1023 TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx, 1024 UInt uiCurrPartUnitIdx, 1025 Bool bEnforceSliceRestriction, 1123 1026 Bool bEnforceTileRestriction ) 1124 1027 { 1125 1028 UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1126 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_ uiAbsIdxInLCU];1127 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();1128 1129 if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) )1029 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; 1030 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1031 1032 if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) 1130 1033 { 1131 1034 uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; 1132 if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) )1133 { 1134 return m_pcPic->getC U( getAddr() );1035 if ( RasterAddress::isEqualCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) 1036 { 1037 return m_pcPic->getCtu( getCtuRsAddr() ); 1135 1038 } 1136 1039 else 1137 1040 { 1138 uiLPartUnitIdx -= m_ uiAbsIdxInLCU;1041 uiLPartUnitIdx -= m_absZIdxInCtu; 1139 1042 return this; 1140 1043 } 1141 1044 } 1142 1143 uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth - 1 ]; 1144 1145 1146 if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || m_pcCULeft->getSCUAddr()+uiLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) 1147 || 1148 (bEnforceTileRestriction && ( m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) ) ) 1149 ) 1045 1046 uiLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth - 1 ]; 1047 if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuLeft)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuLeft)) ) 1150 1048 { 1151 1049 return NULL; 1152 1050 } 1153 return m_pcCULeft; 1154 } 1051 return m_pCtuLeft; 1052 } 1053 1155 1054 1156 1055 TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx, 1157 UInt uiCurrPartUnitIdx, 1158 Bool bEnforceSliceRestriction, 1159 Bool planarAt LCUBoundary,1056 UInt uiCurrPartUnitIdx, 1057 Bool bEnforceSliceRestriction, 1058 Bool planarAtCtuBoundary, 1160 1059 Bool bEnforceTileRestriction ) 1161 1060 { 1162 1061 UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1163 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_ uiAbsIdxInLCU];1164 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();1165 1166 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) )1167 { 1168 uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth ];1169 if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) )1170 { 1171 return m_pcPic->getC U( getAddr() );1062 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; 1063 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1064 1065 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) 1066 { 1067 uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth ]; 1068 if ( RasterAddress::isEqualRow( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) 1069 { 1070 return m_pcPic->getCtu( getCtuRsAddr() ); 1172 1071 } 1173 1072 else 1174 1073 { 1175 uiAPartUnitIdx -= m_ uiAbsIdxInLCU;1074 uiAPartUnitIdx -= m_absZIdxInCtu; 1176 1075 return this; 1177 1076 } 1178 1077 } 1179 1078 1180 if(planarAt LCUBoundary)1079 if(planarAtCtuBoundary) 1181 1080 { 1182 1081 return NULL; 1183 1082 } 1184 1185 uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; 1186 1187 if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || m_pcCUAbove->getSCUAddr()+uiAPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx))) 1188 || 1189 (bEnforceTileRestriction &&(m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())))) 1190 ) 1083 1084 uiAPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth ]; 1085 1086 if ( (bEnforceSliceRestriction && !CUIsFromSameSlice(m_pCtuAbove)) || (bEnforceTileRestriction && !CUIsFromSameTile(m_pCtuAbove)) ) 1191 1087 { 1192 1088 return NULL; 1193 1089 } 1194 return m_p cCUAbove;1090 return m_pCtuAbove; 1195 1091 } 1196 1092 … … 1198 1094 { 1199 1095 UInt uiAbsPartIdx = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1200 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_ uiAbsIdxInLCU];1201 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();1202 1203 if ( !RasterAddress::isZeroCol( uiAbsPartIdx, uiNumPartInCUWidth ) )1204 { 1205 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) )1206 { 1207 uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - uiNumPartInCUWidth - 1 ];1208 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, uiNumPartInCUWidth ) )1209 { 1210 return m_pcPic->getC U( getAddr() );1096 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[m_absZIdxInCtu]; 1097 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1098 1099 if ( !RasterAddress::isZeroCol( uiAbsPartIdx, numPartInCtuWidth ) ) 1100 { 1101 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) 1102 { 1103 uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - numPartInCtuWidth - 1 ]; 1104 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdx, uiAbsZorderCUIdx, numPartInCtuWidth ) ) 1105 { 1106 return m_pcPic->getCtu( getCtuRsAddr() ); 1211 1107 } 1212 1108 else 1213 1109 { 1214 uiALPartUnitIdx -= m_ uiAbsIdxInLCU;1110 uiALPartUnitIdx -= m_absZIdxInCtu; 1215 1111 return this; 1216 1112 } 1217 1113 } 1218 uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartInCU() - uiNumPartInCUWidth - 1 ]; 1219 if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || 1220 m_pcCUAbove->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1221 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1222 )) 1223 ) 1114 uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx + getPic()->getNumPartitionsInCtu() - numPartInCtuWidth - 1 ]; 1115 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) 1224 1116 { 1225 1117 return NULL; 1226 1118 } 1227 return m_p cCUAbove;1228 } 1229 1230 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, uiNumPartInCUWidth ) )1119 return m_pCtuAbove; 1120 } 1121 1122 if ( !RasterAddress::isZeroRow( uiAbsPartIdx, numPartInCtuWidth ) ) 1231 1123 { 1232 1124 uiALPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdx - 1 ]; 1233 if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || 1234 m_pcCULeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1235 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1236 )) 1237 ) 1125 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) 1238 1126 { 1239 1127 return NULL; 1240 1128 } 1241 return m_pcCULeft; 1242 } 1243 1244 uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - 1 ]; 1245 if ( (bEnforceSliceRestriction && (m_pcCUAboveLeft==NULL || m_pcCUAboveLeft->getSlice()==NULL || 1246 m_pcCUAboveLeft->getSCUAddr()+uiALPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1247 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveLeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1248 )) 1249 ) 1129 return m_pCtuLeft; 1130 } 1131 1132 uiALPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - 1 ]; 1133 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveLeft) ) 1250 1134 { 1251 1135 return NULL; 1252 1136 } 1253 return m_p cCUAboveLeft;1137 return m_pCtuAboveLeft; 1254 1138 } 1255 1139 … … 1257 1141 { 1258 1142 UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1259 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_ uiAbsIdxInLCU] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1;1260 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();1143 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_absZIdxInCtu ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1; 1144 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1261 1145 1262 1146 #if REPN_FORMAT_IN_VPS 1263 if( ( m_pcPic->getC U(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getPicWidthInLumaSamples() )1147 if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getPicWidthInLumaSamples() ) 1264 1148 #else 1265 if( ( m_pcPic->getC U(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )1149 if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) 1266 1150 #endif 1267 1151 { … … 1269 1153 return NULL; 1270 1154 } 1271 1272 if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - 1, uiNumPartInCUWidth ) )1273 { 1274 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) )1275 { 1276 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ] )1277 { 1278 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + 1 ];1279 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) )1155 1156 if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, numPartInCtuWidth - 1, numPartInCtuWidth ) ) 1157 { 1158 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) 1159 { 1160 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + 1 ] ) 1161 { 1162 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + 1 ]; 1163 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, numPartInCtuWidth ) ) 1280 1164 { 1281 return m_pcPic->getC U( getAddr() );1165 return m_pcPic->getCtu( getCtuRsAddr() ); 1282 1166 } 1283 1167 else 1284 1168 { 1285 uiARPartUnitIdx -= m_ uiAbsIdxInLCU;1169 uiARPartUnitIdx -= m_absZIdxInCtu; 1286 1170 return this; 1287 1171 } … … 1290 1174 return NULL; 1291 1175 } 1292 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + 1 ]; 1293 if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || 1294 m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1295 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1296 )) 1297 ) 1176 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + 1 ]; 1177 1178 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) 1298 1179 { 1299 1180 return NULL; 1300 1181 } 1301 return m_p cCUAbove;1302 } 1303 1304 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) )1182 return m_pCtuAbove; 1183 } 1184 1185 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) 1305 1186 { 1306 1187 uiARPartUnitIdx = MAX_UINT; 1307 1188 return NULL; 1308 1189 } 1309 1310 uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth ]; 1311 if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || 1312 m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || 1313 m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1314 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1315 )) 1316 ) 1190 1191 uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth ]; 1192 1193 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveRight) ) 1317 1194 { 1318 1195 return NULL; 1319 1196 } 1320 return m_p cCUAboveRight;1197 return m_pCtuAboveRight; 1321 1198 } 1322 1199 … … 1324 1201 { 1325 1202 UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1326 UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*m_pcPic->getNumPartInWidth();1327 UInt ui NumPartInCUWidth = m_pcPic->getNumPartInWidth();1203 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1204 UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_absZIdxInCtu ] + (m_puhHeight[0] / m_pcPic->getMinCUHeight() - 1)*numPartInCtuWidth; 1328 1205 1329 1206 #if REPN_FORMAT_IN_VPS 1330 if( ( m_pcPic->getC U(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getPicHeightInLumaSamples() )1207 if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getPicHeightInLumaSamples() ) 1331 1208 #else 1332 if( ( m_pcPic->getC U(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )1209 if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 1333 1210 #endif 1334 1211 { … … 1336 1213 return NULL; 1337 1214 } 1338 1339 if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartIn Height() - 1, uiNumPartInCUWidth ) )1340 { 1341 if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) )1342 { 1343 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ] )1344 { 1345 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth - 1 ];1346 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) )1215 1216 if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInCtuHeight() - 1, numPartInCtuWidth ) ) 1217 { 1218 if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, numPartInCtuWidth ) ) 1219 { 1220 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + numPartInCtuWidth - 1 ] ) 1221 { 1222 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + numPartInCtuWidth - 1 ]; 1223 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, numPartInCtuWidth ) ) 1347 1224 { 1348 return m_pcPic->getC U( getAddr() );1225 return m_pcPic->getCtu( getCtuRsAddr() ); 1349 1226 } 1350 1227 else 1351 1228 { 1352 uiBLPartUnitIdx -= m_ uiAbsIdxInLCU;1229 uiBLPartUnitIdx -= m_absZIdxInCtu; 1353 1230 return this; 1354 1231 } … … 1357 1234 return NULL; 1358 1235 } 1359 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiNumPartInCUWidth*2 - 1 ]; 1360 if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || 1361 m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1362 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1363 )) 1364 ) 1236 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + numPartInCtuWidth*2 - 1 ]; 1237 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) 1365 1238 { 1366 1239 return NULL; 1367 1240 } 1368 return m_p cCULeft;1369 } 1370 1241 return m_pCtuLeft; 1242 } 1243 1371 1244 uiBLPartUnitIdx = MAX_UINT; 1372 1245 return NULL; 1373 1246 } 1374 1247 1375 TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction 1248 TComDataCU* TComDataCU::getPUBelowLeftAdi(UInt& uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) 1376 1249 { 1377 1250 UInt uiAbsPartIdxLB = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1378 UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_uiAbsIdxInLCU ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth();1379 UInt ui NumPartInCUWidth = m_pcPic->getNumPartInWidth();1251 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1252 UInt uiAbsZorderCUIdxLB = g_auiZscanToRaster[ m_absZIdxInCtu ] + ((m_puhHeight[0] / m_pcPic->getMinCUHeight()) - 1)*numPartInCtuWidth; 1380 1253 1381 1254 #if REPN_FORMAT_IN_VPS 1382 if( ( m_pcPic->getC U(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getPicHeightInLumaSamples())1255 if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getPicHeightInLumaSamples()) 1383 1256 #else 1384 if( ( m_pcPic->getC U(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples())1257 if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxLB] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples()) 1385 1258 #endif 1386 1259 { … … 1388 1261 return NULL; 1389 1262 } 1390 1391 if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartIn Height() - uiPartUnitOffset, uiNumPartInCUWidth ) )1392 { 1393 if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, uiNumPartInCUWidth ) )1394 { 1395 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ] )1396 { 1397 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * uiNumPartInCUWidth - 1 ];1398 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, uiNumPartInCUWidth ) )1263 1264 if ( RasterAddress::lessThanRow( uiAbsPartIdxLB, m_pcPic->getNumPartInCtuHeight() - uiPartUnitOffset, numPartInCtuWidth ) ) 1265 { 1266 if ( !RasterAddress::isZeroCol( uiAbsPartIdxLB, numPartInCtuWidth ) ) 1267 { 1268 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ] ) 1269 { 1270 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + uiPartUnitOffset * numPartInCtuWidth - 1 ]; 1271 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxLB, uiAbsZorderCUIdxLB, numPartInCtuWidth ) ) 1399 1272 { 1400 return m_pcPic->getC U( getAddr() );1273 return m_pcPic->getCtu( getCtuRsAddr() ); 1401 1274 } 1402 1275 else 1403 1276 { 1404 uiBLPartUnitIdx -= m_ uiAbsIdxInLCU;1277 uiBLPartUnitIdx -= m_absZIdxInCtu; 1405 1278 return this; 1406 1279 } … … 1409 1282 return NULL; 1410 1283 } 1411 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * uiNumPartInCUWidth - 1 ]; 1412 if ( (bEnforceSliceRestriction && (m_pcCULeft==NULL || m_pcCULeft->getSlice()==NULL || 1413 m_pcCULeft->getSCUAddr()+uiBLPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1414 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCULeft->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1415 )) 1416 ) 1284 uiBLPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxLB + (1+uiPartUnitOffset) * numPartInCtuWidth - 1 ]; 1285 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuLeft) ) 1417 1286 { 1418 1287 return NULL; 1419 1288 } 1420 return m_p cCULeft;1421 } 1422 1289 return m_pCtuLeft; 1290 } 1291 1423 1292 uiBLPartUnitIdx = MAX_UINT; 1424 1293 return NULL; 1425 1294 } 1426 1295 1427 TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction 1296 TComDataCU* TComDataCU::getPUAboveRightAdi(UInt& uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) 1428 1297 { 1429 1298 UInt uiAbsPartIdxRT = g_auiZscanToRaster[uiCurrPartUnitIdx]; 1430 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_ uiAbsIdxInLCU] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1;1431 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();1299 UInt uiAbsZorderCUIdx = g_auiZscanToRaster[ m_absZIdxInCtu ] + (m_puhWidth[0] / m_pcPic->getMinCUWidth()) - 1; 1300 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1432 1301 1433 1302 #if REPN_FORMAT_IN_VPS 1434 if( ( m_pcPic->getC U(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getPicWidthInLumaSamples() )1303 if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getPicWidthInLumaSamples() ) 1435 1304 #else 1436 if( ( m_pcPic->getC U(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )1305 if( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxRT] + (m_pcPic->getPicSym()->getMinCUHeight() * uiPartUnitOffset)) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) 1437 1306 #endif 1438 1307 { … … 1440 1309 return NULL; 1441 1310 } 1442 1443 if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, uiNumPartInCUWidth - uiPartUnitOffset, uiNumPartInCUWidth ) )1444 { 1445 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) )1446 { 1447 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ] )1448 { 1449 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - uiNumPartInCUWidth + uiPartUnitOffset ];1450 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, uiNumPartInCUWidth ) )1311 1312 if ( RasterAddress::lessThanCol( uiAbsPartIdxRT, numPartInCtuWidth - uiPartUnitOffset, numPartInCtuWidth ) ) 1313 { 1314 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) 1315 { 1316 if ( uiCurrPartUnitIdx > g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ] ) 1317 { 1318 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT - numPartInCtuWidth + uiPartUnitOffset ]; 1319 if ( RasterAddress::isEqualRowOrCol( uiAbsPartIdxRT, uiAbsZorderCUIdx, numPartInCtuWidth ) ) 1451 1320 { 1452 return m_pcPic->getC U( getAddr() );1321 return m_pcPic->getCtu( getCtuRsAddr() ); 1453 1322 } 1454 1323 else 1455 1324 { 1456 uiARPartUnitIdx -= m_ uiAbsIdxInLCU;1325 uiARPartUnitIdx -= m_absZIdxInCtu; 1457 1326 return this; 1458 1327 } … … 1461 1330 return NULL; 1462 1331 } 1463 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset ]; 1464 if ( (bEnforceSliceRestriction && (m_pcCUAbove==NULL || m_pcCUAbove->getSlice()==NULL || 1465 m_pcCUAbove->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1466 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAbove->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1467 )) 1468 ) 1332 1333 uiARPartUnitIdx = g_auiRasterToZscan[ uiAbsPartIdxRT + m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset ]; 1334 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAbove) ) 1469 1335 { 1470 1336 return NULL; 1471 1337 } 1472 return m_p cCUAbove;1473 } 1474 1475 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, uiNumPartInCUWidth ) )1338 return m_pCtuAbove; 1339 } 1340 1341 if ( !RasterAddress::isZeroRow( uiAbsPartIdxRT, numPartInCtuWidth ) ) 1476 1342 { 1477 1343 uiARPartUnitIdx = MAX_UINT; 1478 1344 return NULL; 1479 1345 } 1480 1481 uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartInCU() - uiNumPartInCUWidth + uiPartUnitOffset-1 ]; 1482 if ( (bEnforceSliceRestriction && (m_pcCUAboveRight==NULL || m_pcCUAboveRight->getSlice()==NULL || 1483 m_pcPic->getPicSym()->getInverseCUOrderMap( m_pcCUAboveRight->getAddr()) > m_pcPic->getPicSym()->getInverseCUOrderMap( getAddr()) || 1484 m_pcCUAboveRight->getSCUAddr()+uiARPartUnitIdx < m_pcPic->getCU( getAddr() )->getSliceStartCU(uiCurrPartUnitIdx)|| 1485 (m_pcPic->getPicSym()->getTileIdxMap( m_pcCUAboveRight->getAddr() ) != m_pcPic->getPicSym()->getTileIdxMap(getAddr())) 1486 )) 1487 ) 1346 1347 uiARPartUnitIdx = g_auiRasterToZscan[ m_pcPic->getNumPartitionsInCtu() - numPartInCtuWidth + uiPartUnitOffset-1 ]; 1348 if ( bEnforceSliceRestriction && !CUIsFromSameSliceAndTile(m_pCtuAboveRight) ) 1488 1349 { 1489 1350 return NULL; 1490 1351 } 1491 return m_p cCUAboveRight;1352 return m_pCtuAboveRight; 1492 1353 } 1493 1354 1494 1355 /** Get left QpMinCu 1495 1356 *\param uiLPartUnitIdx 1496 *\param uiCurrAbsIdxIn LCU1357 *\param uiCurrAbsIdxInCtu 1497 1358 *\returns TComDataCU* point of TComDataCU of left QpMinCu 1498 1359 */ 1499 TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxIn LCU)1500 { 1501 UInt numPartInCUWidth = m_pcPic->getNumPartInWidth();1502 UInt absZorderQpMinCUIdx = (uiCurrAbsIdxIn LCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth -getSlice()->getPPS()->getMaxCuDQPDepth())<<1);1360 TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu ) 1361 { 1362 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1363 UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth -getSlice()->getPPS()->getMaxCuDQPDepth())<<1); 1503 1364 UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; 1504 1365 1505 // check for left LCU boundary1506 if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInC UWidth) )1366 // check for left CTU boundary 1367 if ( RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCtuWidth) ) 1507 1368 { 1508 1369 return NULL; … … 1512 1373 uiLPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - 1]; 1513 1374 1514 // return pointer to current LCU1515 return m_pcPic->getC U( getAddr() );1375 // return pointer to current CTU 1376 return m_pcPic->getCtu( getCtuRsAddr() ); 1516 1377 } 1517 1378 1518 1379 /** Get Above QpMinCu 1519 *\param aPartUnitIdx1520 *\param currAbsIdxInLCU1380 *\param uiAPartUnitIdx 1381 *\param uiCurrAbsIdxInCtu 1521 1382 *\returns TComDataCU* point of TComDataCU of above QpMinCu 1522 1383 */ 1523 TComDataCU* TComDataCU::getQpMinCuAbove( UInt& aPartUnitIdx, UInt currAbsIdxInLCU)1524 { 1525 UInt numPartInCUWidth = m_pcPic->getNumPartInWidth();1526 UInt absZorderQpMinCUIdx = ( currAbsIdxInLCU>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1);1384 TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu ) 1385 { 1386 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 1387 UInt absZorderQpMinCUIdx = (uiCurrAbsIdxInCtu>>((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1); 1527 1388 UInt absRorderQpMinCUIdx = g_auiZscanToRaster[absZorderQpMinCUIdx]; 1528 1389 1529 // check for top LCU boundary1530 if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInC UWidth) )1390 // check for top CTU boundary 1391 if ( RasterAddress::isZeroRow( absRorderQpMinCUIdx, numPartInCtuWidth) ) 1531 1392 { 1532 1393 return NULL; … … 1534 1395 1535 1396 // get index of top-CU relative to top-left corner of current quantization group 1536 aPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCUWidth]; 1537 1538 // return pointer to current LCU 1539 return m_pcPic->getCU( getAddr() ); 1540 } 1397 uiAPartUnitIdx = g_auiRasterToZscan[absRorderQpMinCUIdx - numPartInCtuWidth]; 1398 1399 // return pointer to current CTU 1400 return m_pcPic->getCtu( getCtuRsAddr() ); 1401 } 1402 1403 1541 1404 1542 1405 /** Get reference QP from left QpMinCu or latest coded QP 1543 *\param uiCurrAbsIdxIn LCU1406 *\param uiCurrAbsIdxInCtu 1544 1407 *\returns Char reference QP value 1545 1408 */ 1546 Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInLCU ) 1547 { 1548 UInt lPartIdx = 0, aPartIdx = 0; 1549 TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); 1550 TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU ); 1551 return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInLCU )) + 1) >> 1); 1409 Char TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu ) 1410 { 1411 UInt lPartIdx = MAX_UINT; 1412 UInt aPartIdx = MAX_UINT; 1413 TComDataCU* cULeft = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); 1414 TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu ); 1415 return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + 1) >> 1); 1552 1416 } 1553 1417 … … 1556 1420 Int iLastValidPartIdx = iAbsPartIdx-1; 1557 1421 while ( iLastValidPartIdx >= 0 1558 && getPredictionMode( iLastValidPartIdx ) == MODE_NONE)1422 && getPredictionMode( iLastValidPartIdx ) == NUMBER_OF_PREDICTION_MODES ) 1559 1423 { 1560 1424 UInt uiDepth = getDepth( iLastValidPartIdx ); … … 1567 1431 { 1568 1432 UInt uiQUPartIdxMask = ~((1<<((g_uiMaxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1); 1569 Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); 1570 if ( uiAbsPartIdx < m_uiNumPartition1571 && (getSCUAddr()+iLastValidPartIdx < getSliceStartCU(m_uiAbsIdxInLCU+uiAbsPartIdx)))1433 Int iLastValidPartIdx = getLastValidPartIdx( uiAbsPartIdx&uiQUPartIdxMask ); // A idx will be invalid if it is off the right or bottom edge of the picture. 1434 // If this CU is in the first CTU of the slice and there is no valid part before this one, use slice QP 1435 if ( getPic()->getPicSym()->getCtuTsToRsAddrMap(getSlice()->getSliceCurStartCtuTsAddr()) == getCtuRsAddr() && Int(getZorderIdxInCtu())+iLastValidPartIdx<0) 1572 1436 { 1573 1437 return getSlice()->getSliceQp(); … … 1575 1439 else if ( iLastValidPartIdx >= 0 ) 1576 1440 { 1441 // If there is a valid part within the current Sub-CU, use it 1577 1442 return getQP( iLastValidPartIdx ); 1578 1443 } 1579 1444 else 1580 1445 { 1581 if ( getZorderIdxInCU() > 0 ) 1582 { 1583 return getPic()->getCU( getAddr() )->getLastCodedQP( getZorderIdxInCU() ); 1584 } 1585 else if ( getPic()->getPicSym()->getInverseCUOrderMap(getAddr()) > 0 1586 && getPic()->getPicSym()->getTileIdxMap(getAddr()) == getPic()->getPicSym()->getTileIdxMap(getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1)) 1587 && !( getSlice()->getPPS()->getEntropyCodingSyncEnabledFlag() && getAddr() % getPic()->getFrameWidthInCU() == 0 ) ) 1588 { 1589 return getPic()->getCU( getPic()->getPicSym()->getCUOrderMap(getPic()->getPicSym()->getInverseCUOrderMap(getAddr())-1) )->getLastCodedQP( getPic()->getNumPartInCU() ); 1446 if ( getZorderIdxInCtu() > 0 ) 1447 { 1448 // If this wasn't the first sub-cu within the Ctu, explore the CTU itself. 1449 return getPic()->getCtu( getCtuRsAddr() )->getLastCodedQP( getZorderIdxInCtu() ); // TODO - remove this recursion 1450 } 1451 else if ( getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr()) > 0 1452 && CUIsFromSameSliceTileAndWavefrontRow(getPic()->getCtu(getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1))) ) 1453 { 1454 // 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. 1455 return getPic()->getCtu( getPic()->getPicSym()->getCtuTsToRsAddrMap(getPic()->getPicSym()->getCtuRsToTsAddrMap(getCtuRsAddr())-1) )->getLastCodedQP( getPic()->getNumPartitionsInCtu() ); // TODO - remove this recursion 1590 1456 } 1591 1457 else 1592 1458 { 1459 // No other options available - use the slice-level QP. 1593 1460 return getSlice()->getSliceQp(); 1594 1461 } 1595 1462 } 1596 1463 } 1464 1465 1597 1466 /** Check whether the CU is coded in lossless coding mode 1598 1467 * \param uiAbsPartIdx 1599 * \returns true if the CU is coded in lossless coding mode; false if otherwise 1468 * \returns true if the CU is coded in lossless coding mode; false if otherwise 1600 1469 */ 1601 1470 Bool TComDataCU::isLosslessCoded(UInt absPartIdx) … … 1603 1472 return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx)); 1604 1473 } 1474 1605 1475 1606 1476 /** Get allowed chroma intra modes 1607 1477 *\param uiAbsPartIdx 1608 1478 *\param uiModeList pointer to chroma intra modes array 1609 *\returns 1479 *\returns 1610 1480 *- fill uiModeList with chroma intra modes 1611 1481 */ 1612 Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt * uiModeList)1482 Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] ) 1613 1483 { 1614 1484 uiModeList[0] = PLANAR_IDX; … … 1617 1487 uiModeList[3] = DC_IDX; 1618 1488 uiModeList[4] = DM_CHROMA_IDX; 1619 1620 UInt uiLumaMode = getLumaIntraDir( uiAbsPartIdx ); 1489 assert(4<NUM_CHROMA_MODE); 1490 1491 UInt uiLumaMode = getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); 1621 1492 1622 1493 for( Int i = 0; i < NUM_CHROMA_MODE - 1; i++ ) … … 1636 1507 *\returns Number of MPM 1637 1508 */ 1638 Int TComDataCU::getIntraDirLumaPredictor( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int* piMode ) 1639 { 1640 TComDataCU* pcTempCU; 1641 UInt uiTempPartIdx; 1509 Int TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode ) 1510 { 1511 TComDataCU* pcCULeft, *pcCUAbove; 1512 UInt LeftPartIdx = MAX_UINT; 1513 UInt AbovePartIdx = MAX_UINT; 1642 1514 Int iLeftIntraDir, iAboveIntraDir; 1643 1515 Int uiPredNum = 0; 1644 1516 1517 const ChannelType chType = toChannelType(compID); 1518 const ChromaFormat chForm = getPic()->getChromaFormat(); 1645 1519 // Get intra direction of left PU 1646 pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx ); 1647 1648 iLeftIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; 1649 1520 pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 1521 1522 if (isChroma(compID)) LeftPartIdx = getChromasCorrespondingPULumaIdx(LeftPartIdx, chForm); 1523 iLeftIntraDir = pcCULeft ? ( pcCULeft->isIntra( LeftPartIdx ) ? pcCULeft->getIntraDir( chType, LeftPartIdx ) : DC_IDX ) : DC_IDX; 1524 1650 1525 // Get intra direction of above PU 1651 pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true ); 1652 1653 iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX; 1654 1655 uiPredNum = 3; 1526 pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true ); 1527 1528 if (isChroma(compID)) AbovePartIdx = getChromasCorrespondingPULumaIdx(AbovePartIdx, chForm); 1529 iAboveIntraDir = pcCUAbove ? ( pcCUAbove->isIntra( AbovePartIdx ) ? pcCUAbove->getIntraDir( chType, AbovePartIdx ) : DC_IDX ) : DC_IDX; 1530 1531 if (isChroma(chType)) 1532 { 1533 if (iLeftIntraDir == DM_CHROMA_IDX) iLeftIntraDir = pcCULeft-> getIntraDir( CHANNEL_TYPE_LUMA, LeftPartIdx ); 1534 if (iAboveIntraDir == DM_CHROMA_IDX) iAboveIntraDir = pcCUAbove->getIntraDir( CHANNEL_TYPE_LUMA, AbovePartIdx ); 1535 } 1536 1537 assert (2<NUM_MOST_PROBABLE_MODES); 1538 uiPredNum = NUM_MOST_PROBABLE_MODES; 1656 1539 if(iLeftIntraDir == iAboveIntraDir) 1657 1540 { … … 1660 1543 *piMode = 1; 1661 1544 } 1662 1545 1663 1546 if (iLeftIntraDir > 1) // angular modes 1664 1547 { … … 1671 1554 uiIntraDirPred[0] = PLANAR_IDX; 1672 1555 uiIntraDirPred[1] = DC_IDX; 1673 uiIntraDirPred[2] = VER_IDX; 1556 uiIntraDirPred[2] = VER_IDX; 1674 1557 } 1675 1558 } … … 1682 1565 uiIntraDirPred[0] = iLeftIntraDir; 1683 1566 uiIntraDirPred[1] = iAboveIntraDir; 1684 1567 1685 1568 if (iLeftIntraDir && iAboveIntraDir ) //both modes are non-planar 1686 1569 { … … 1692 1575 } 1693 1576 } 1694 1577 for (Int i=0; i<uiPredNum; i++) 1578 assert(uiIntraDirPred[i] < 35); 1579 1695 1580 return uiPredNum; 1696 1581 } … … 1702 1587 UInt uiCtx; 1703 1588 // Get left split flag 1704 pcTempCU = getPULeft( uiTempPartIdx, m_ uiAbsIdxInLCU+ uiAbsPartIdx );1589 pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 1705 1590 uiCtx = ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; 1706 1591 1707 1592 // Get above split flag 1708 pcTempCU = getPUAbove( uiTempPartIdx, m_ uiAbsIdxInLCU+ uiAbsPartIdx );1593 pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 1709 1594 uiCtx += ( pcTempCU ) ? ( ( pcTempCU->getDepth( uiTempPartIdx ) > uiDepth ) ? 1 : 0 ) : 0; 1710 1595 1711 1596 return uiCtx; 1712 1597 } 1713 1598 1714 UInt TComDataCU::getCtxQtCbf( TextType eType, UInt uiTrDepth ) 1715 { 1716 if( eType ) 1717 { 1718 return uiTrDepth; 1599 UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType ) 1600 { 1601 const UInt transformDepth = rTu.GetTransformDepthRel(); 1602 1603 if (isChroma(chType)) 1604 { 1605 return transformDepth; 1719 1606 } 1720 1607 else 1721 1608 { 1722 const UInt uiCtx = ( uiTrDepth == 0 ? 1 : 0 );1609 const UInt uiCtx = ( transformDepth == 0 ? 1 : 0 ); 1723 1610 return uiCtx; 1724 1611 } … … 1729 1616 UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2; 1730 1617 PartSize partSize = getPartitionSize( absPartIdx ); 1731 UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter();1732 Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA&& partSize == SIZE_NxN ) ? 1 : 0;1733 Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) );1734 1618 UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); 1619 Int intraSplitFlag = ( isIntra( absPartIdx ) && partSize == SIZE_NxN ) ? 1 : 0; 1620 Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && isInter( absPartIdx ) && (partSize != SIZE_2Nx2N) ); 1621 1735 1622 UInt log2MinTUSizeInCU = 0; 1736 if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) 1623 if (log2CbSize < (m_pcSlice->getSPS()->getQuadtreeTULog2MinSize() + quadtreeTUMaxDepth - 1 + interSplitFlag + intraSplitFlag) ) 1737 1624 { 1738 1625 // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is < QuadtreeTULog2MinSize … … 1747 1634 // when fully making use of signaled TUMaxDepth + inter/intraSplitFlag, resulting luma TB size is still > QuadtreeTULog2MaxSize 1748 1635 log2MinTUSizeInCU = m_pcSlice->getSPS()->getQuadtreeTULog2MaxSize(); 1749 } 1636 } 1750 1637 } 1751 1638 return log2MinTUSizeInCU; … … 1757 1644 UInt uiTempPartIdx; 1758 1645 UInt uiCtx = 0; 1759 1646 1760 1647 // Get BCBP of left PU 1761 pcTempCU = getPULeft( uiTempPartIdx, m_ uiAbsIdxInLCU+ uiAbsPartIdx );1648 pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 1762 1649 uiCtx = ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; 1763 1650 1764 1651 // Get BCBP of above PU 1765 pcTempCU = getPUAbove( uiTempPartIdx, m_ uiAbsIdxInLCU+ uiAbsPartIdx );1652 pcTempCU = getPUAbove( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx ); 1766 1653 uiCtx += ( pcTempCU ) ? pcTempCU->isSkipped( uiTempPartIdx ) : 0; 1767 1654 1768 1655 return uiCtx; 1769 1656 } … … 1774 1661 } 1775 1662 1776 Void TComDataCU::setCbfSubParts( UInt uiCbfY, UInt uiCbfU, UInt uiCbfV, UInt uiAbsPartIdx, UInt uiDepth ) 1777 { 1778 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 1779 memset( m_puhCbf[0] + uiAbsPartIdx, uiCbfY, sizeof( UChar ) * uiCurrPartNumb ); 1780 memset( m_puhCbf[1] + uiAbsPartIdx, uiCbfU, sizeof( UChar ) * uiCurrPartNumb ); 1781 memset( m_puhCbf[2] + uiAbsPartIdx, uiCbfV, sizeof( UChar ) * uiCurrPartNumb ); 1782 } 1783 1784 Void TComDataCU::setCbfSubParts( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiDepth ) 1785 { 1786 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 1787 memset( m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); 1663 1664 UChar TComDataCU::getQtRootCbf( UInt uiIdx ) 1665 { 1666 const UInt numberValidComponents = getPic()->getNumberValidComponents(); 1667 return getCbf( uiIdx, COMPONENT_Y, 0 ) 1668 || ((numberValidComponents > COMPONENT_Cb) && getCbf( uiIdx, COMPONENT_Cb, 0 )) 1669 || ((numberValidComponents > COMPONENT_Cr) && getCbf( uiIdx, COMPONENT_Cr, 0 )); 1670 } 1671 1672 Void TComDataCU::setCbfSubParts( const UInt uiCbf[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) 1673 { 1674 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 1675 for(UInt comp=0; comp<MAX_NUM_COMPONENT; comp++) 1676 { 1677 memset( m_puhCbf[comp] + uiAbsPartIdx, uiCbf[comp], sizeof( UChar ) * uiCurrPartNumb ); 1678 } 1679 } 1680 1681 Void TComDataCU::setCbfSubParts( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth ) 1682 { 1683 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 1684 memset( m_puhCbf[compID] + uiAbsPartIdx, uiCbf, sizeof( UChar ) * uiCurrPartNumb ); 1788 1685 } 1789 1686 … … 1796 1693 * \returns Void 1797 1694 */ 1798 Void TComDataCU::setCbfSubParts ( UInt uiCbf, TextType eTType, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 1799 { 1800 setSubPart<UChar>( uiCbf, m_puhCbf[g_aucConvertTxtTypeToIdx[eTType]], uiAbsPartIdx, uiDepth, uiPartIdx ); 1695 Void TComDataCU::setCbfSubParts ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 1696 { 1697 setSubPart<UChar>( uiCbf, m_puhCbf[compID], uiAbsPartIdx, uiDepth, uiPartIdx ); 1698 } 1699 1700 Void TComDataCU::setCbfPartRange ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) 1701 { 1702 memset((m_puhCbf[compID] + uiAbsPartIdx), uiCbf, (sizeof(UChar) * uiCoveredPartIdxes)); 1703 } 1704 1705 Void TComDataCU::bitwiseOrCbfPartRange( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) 1706 { 1707 const UInt stopAbsPartIdx = uiAbsPartIdx + uiCoveredPartIdxes; 1708 1709 for (UInt subPartIdx = uiAbsPartIdx; subPartIdx < stopAbsPartIdx; subPartIdx++) 1710 { 1711 m_puhCbf[compID][subPartIdx] |= uiCbf; 1712 } 1801 1713 } 1802 1714 1803 1715 Void TComDataCU::setDepthSubParts( UInt uiDepth, UInt uiAbsPartIdx ) 1804 1716 { 1805 UInt uiCurrPartNumb = m_pcPic->getNumPart InCU() >> (uiDepth << 1);1717 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 1806 1718 memset( m_puhDepth + uiAbsPartIdx, uiDepth, sizeof(UChar)*uiCurrPartNumb ); 1807 1719 } … … 1809 1721 Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) 1810 1722 { 1811 UInt uiPartNumb = m_pcPic->getNumPart InCU() >> (uiDepth << 1);1812 return (((m_ uiAbsIdxInLCU+ uiAbsPartIdx)% uiPartNumb) == 0);1723 UInt uiPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 1724 return (((m_absZIdxInCtu + uiAbsPartIdx)% uiPartNumb) == 0); 1813 1725 } 1814 1726 … … 1816 1728 { 1817 1729 assert( sizeof( *m_pePartSize) == 1 ); 1818 memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPart InCU() >> ( 2 * uiDepth ) );1730 memset( m_pePartSize + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); 1819 1731 } 1820 1732 1821 1733 Void TComDataCU::setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth ) 1822 1734 { 1823 memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPart InCU() >> ( 2 * uiDepth ) );1735 memset( m_CUTransquantBypass + uiAbsPartIdx, flag, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); 1824 1736 } 1825 1737 … … 1827 1739 { 1828 1740 assert( sizeof( *m_skipFlag) == 1 ); 1829 memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPart InCU() >> ( 2 * depth ) );1741 memset( m_skipFlag + absPartIdx, skip, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); 1830 1742 } 1831 1743 … … 1833 1745 { 1834 1746 assert( sizeof( *m_pePredMode) == 1 ); 1835 memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) ); 1836 } 1837 1838 Void TComDataCU::setQPSubCUs( Int qp, TComDataCU* pcCU, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) 1839 { 1840 UInt currPartNumb = m_pcPic->getNumPartInCU() >> (depth << 1); 1747 memset( m_pePredMode + uiAbsPartIdx, eMode, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) ); 1748 } 1749 1750 Void TComDataCU::setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth ) 1751 { 1752 assert( sizeof(*m_ChromaQpAdj) == 1 ); 1753 memset( m_ChromaQpAdj + absPartIdx, val, m_pcPic->getNumPartitionsInCtu() >> ( 2 * depth ) ); 1754 } 1755 1756 Void TComDataCU::setQPSubCUs( Int qp, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf ) 1757 { 1758 UInt currPartNumb = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); 1841 1759 UInt currPartNumQ = currPartNumb >> 2; 1760 const UInt numValidComp = m_pcPic->getNumberValidComponents(); 1842 1761 1843 1762 if(!foundNonZeroCbf) 1844 1763 { 1845 if( pcCU->getDepth(absPartIdx) > depth)1764 if(getDepth(absPartIdx) > depth) 1846 1765 { 1847 1766 for ( UInt partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++ ) 1848 1767 { 1849 pcCU->setQPSubCUs( qp, pcCU, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf );1768 setQPSubCUs( qp, absPartIdx+partUnitIdx*currPartNumQ, depth+1, foundNonZeroCbf ); 1850 1769 } 1851 1770 } 1852 1771 else 1853 1772 { 1854 if( pcCU->getCbf( absPartIdx, TEXT_LUMA ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_U ) || pcCU->getCbf( absPartIdx, TEXT_CHROMA_V) )1773 if(getCbf( absPartIdx, COMPONENT_Y ) || (numValidComp>COMPONENT_Cb && getCbf( absPartIdx, COMPONENT_Cb )) || (numValidComp>COMPONENT_Cr && getCbf( absPartIdx, COMPONENT_Cr) ) ) 1855 1774 { 1856 1775 foundNonZeroCbf = true; … … 1866 1785 Void TComDataCU::setQPSubParts( Int qp, UInt uiAbsPartIdx, UInt uiDepth ) 1867 1786 { 1868 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 1869 TComSlice * pcSlice = getPic()->getSlice(getPic()->getCurrSliceIdx()); 1870 1871 for(UInt uiSCUIdx = uiAbsPartIdx; uiSCUIdx < uiAbsPartIdx+uiCurrPartNumb; uiSCUIdx++) 1872 { 1873 if( m_pcPic->getCU( getAddr() )->getSliceSegmentStartCU(uiSCUIdx+getZorderIdxInCU()) == pcSlice->getSliceSegmentCurStartCUAddr() ) 1874 { 1875 m_phQP[uiSCUIdx] = qp; 1876 } 1877 } 1878 } 1879 1880 Void TComDataCU::setLumaIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth ) 1881 { 1882 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 1883 1884 memset( m_puhLumaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb ); 1787 const UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 1788 memset(m_phQP+uiAbsPartIdx, qp, numPart); 1789 } 1790 1791 Void TComDataCU::setIntraDirSubParts( const ChannelType channelType, const UInt dir, const UInt absPartIdx, const UInt depth ) 1792 { 1793 UInt numPart = m_pcPic->getNumPartitionsInCtu() >> (depth << 1); 1794 memset( m_puhIntraDir[channelType] + absPartIdx, dir,sizeof(UChar)*numPart ); 1885 1795 } 1886 1796 1887 1797 template<typename T> 1888 Void TComDataCU::setSubPart( T uiParameter, T* puhBase LCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx )1798 Void TComDataCU::setSubPart( T uiParameter, T* puhBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx ) 1889 1799 { 1890 1800 assert( sizeof(T) == 1 ); // Using memset() works only for types of size 1 1891 1892 UInt uiCurrPartNumQ = (m_pcPic->getNumPart InCU() >> (2 * uiCUDepth)) >> 2;1801 1802 UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2; 1893 1803 switch ( m_pePartSize[ uiCUAddr ] ) 1894 1804 { 1895 1805 case SIZE_2Nx2N: 1896 memset( puhBase LCU+ uiCUAddr, uiParameter, 4 * uiCurrPartNumQ );1806 memset( puhBaseCtu + uiCUAddr, uiParameter, 4 * uiCurrPartNumQ ); 1897 1807 break; 1898 1808 case SIZE_2NxN: 1899 memset( puhBase LCU+ uiCUAddr, uiParameter, 2 * uiCurrPartNumQ );1809 memset( puhBaseCtu + uiCUAddr, uiParameter, 2 * uiCurrPartNumQ ); 1900 1810 break; 1901 1811 case SIZE_Nx2N: 1902 memset( puhBase LCU+ uiCUAddr, uiParameter, uiCurrPartNumQ );1903 memset( puhBase LCU+ uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ );1812 memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); 1813 memset( puhBaseCtu + uiCUAddr + 2 * uiCurrPartNumQ, uiParameter, uiCurrPartNumQ ); 1904 1814 break; 1905 1815 case SIZE_NxN: 1906 memset( puhBase LCU + uiCUAddr, uiParameter, uiCurrPartNumQ );1816 memset( puhBaseCtu + uiCUAddr, uiParameter, uiCurrPartNumQ ); 1907 1817 break; 1908 1818 case SIZE_2NxnU: 1909 1819 if ( uiPUIdx == 0 ) 1910 1820 { 1911 memset( puhBase LCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) );1912 memset( puhBase LCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) );1821 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); 1822 memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); 1913 1823 } 1914 1824 else if ( uiPUIdx == 1 ) 1915 1825 { 1916 memset( puhBase LCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) );1917 memset( puhBase LCU + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) );1826 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); 1827 memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, ((uiCurrPartNumQ >> 1) + (uiCurrPartNumQ << 1)) ); 1918 1828 } 1919 1829 else … … 1925 1835 if ( uiPUIdx == 0 ) 1926 1836 { 1927 memset( puhBase LCU + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) );1928 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) );1837 memset( puhBaseCtu + uiCUAddr, uiParameter, ((uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1)) ); 1838 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); 1929 1839 } 1930 1840 else if ( uiPUIdx == 1 ) 1931 1841 { 1932 memset( puhBase LCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) );1933 memset( puhBase LCU + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) );1842 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 1) ); 1843 memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ, uiParameter, (uiCurrPartNumQ >> 1) ); 1934 1844 } 1935 1845 else … … 1941 1851 if ( uiPUIdx == 0 ) 1942 1852 { 1943 memset( puhBase LCU+ uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) );1944 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );1945 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) );1946 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );1853 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); 1854 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 1855 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); 1856 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 1947 1857 } 1948 1858 else if ( uiPUIdx == 1 ) 1949 1859 { 1950 memset( puhBase LCU+ uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) );1951 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) );1952 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) );1953 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) );1860 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); 1861 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); 1862 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); 1863 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); 1954 1864 } 1955 1865 else … … 1960 1870 case SIZE_nRx2N: 1961 1871 if ( uiPUIdx == 0 ) 1962 { 1963 memset( puhBase LCU + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) );1964 memset( puhBase LCU + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );1965 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) );1966 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );1872 { 1873 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); 1874 memset( puhBaseCtu + uiCUAddr + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 1875 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ + (uiCurrPartNumQ >> 2)) ); 1876 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + uiCurrPartNumQ + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 1967 1877 } 1968 1878 else if ( uiPUIdx == 1 ) 1969 1879 { 1970 memset( puhBase LCU + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) );1971 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );1972 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) );1973 memset( puhBase LCU + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) );1880 memset( puhBaseCtu + uiCUAddr, uiParameter, (uiCurrPartNumQ >> 2) ); 1881 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 1882 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1), uiParameter, (uiCurrPartNumQ >> 2) ); 1883 memset( puhBaseCtu + uiCUAddr + (uiCurrPartNumQ << 1) + (uiCurrPartNumQ >> 1), uiParameter, (uiCurrPartNumQ >> 2) ); 1974 1884 } 1975 1885 else … … 1980 1890 default: 1981 1891 assert( 0 ); 1892 break; 1982 1893 } 1983 1894 } … … 1993 1904 } 1994 1905 1995 Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth )1996 {1997 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1);1998 1999 memset( m_puhChromaIntraDir + uiAbsPartIdx, uiDir, sizeof(UChar)*uiCurrPartNumb );2000 }2001 2002 1906 Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) 2003 1907 { … … 2018 1922 Void TComDataCU::setTrIdxSubParts( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth ) 2019 1923 { 2020 UInt uiCurrPartNumb = m_pcPic->getNumPart InCU() >> (uiDepth << 1);2021 1924 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 1925 2022 1926 memset( m_puhTrIdx + uiAbsPartIdx, uiTrIdx, sizeof(UChar)*uiCurrPartNumb ); 2023 1927 } 2024 1928 2025 Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkipY, UInt useTransformSkipU, UInt useTransformSkipV, UInt uiAbsPartIdx, UInt uiDepth ) 2026 { 2027 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 2028 2029 memset( m_puhTransformSkip[0] + uiAbsPartIdx, useTransformSkipY, sizeof( UChar ) * uiCurrPartNumb ); 2030 memset( m_puhTransformSkip[1] + uiAbsPartIdx, useTransformSkipU, sizeof( UChar ) * uiCurrPartNumb ); 2031 memset( m_puhTransformSkip[2] + uiAbsPartIdx, useTransformSkipV, sizeof( UChar ) * uiCurrPartNumb ); 2032 } 2033 2034 Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, TextType eType, UInt uiAbsPartIdx, UInt uiDepth) 2035 { 2036 UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1); 2037 2038 memset( m_puhTransformSkip[g_aucConvertTxtTypeToIdx[eType]] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); 1929 Void TComDataCU::setTransformSkipSubParts( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth ) 1930 { 1931 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 1932 1933 for(UInt i=0; i<MAX_NUM_COMPONENT; i++) 1934 { 1935 memset( m_puhTransformSkip[i] + uiAbsPartIdx, useTransformSkip[i], sizeof( UChar ) * uiCurrPartNumb ); 1936 } 1937 } 1938 1939 Void TComDataCU::setTransformSkipSubParts( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth) 1940 { 1941 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 1942 1943 memset( m_puhTransformSkip[compID] + uiAbsPartIdx, useTransformSkip, sizeof( UChar ) * uiCurrPartNumb ); 1944 } 1945 1946 Void TComDataCU::setTransformSkipPartRange ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) 1947 { 1948 memset((m_puhTransformSkip[compID] + uiAbsPartIdx), useTransformSkip, (sizeof(UChar) * uiCoveredPartIdxes)); 1949 } 1950 1951 Void TComDataCU::setCrossComponentPredictionAlphaPartRange( Char alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) 1952 { 1953 memset((m_crossComponentPredictionAlpha[compID] + uiAbsPartIdx), alphaValue, (sizeof(Char) * uiCoveredPartIdxes)); 1954 } 1955 1956 Void TComDataCU::setExplicitRdpcmModePartRange ( UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes ) 1957 { 1958 memset((m_explicitRdpcmMode[compID] + uiAbsPartIdx), rdpcmMode, (sizeof(UChar) * uiCoveredPartIdxes)); 2039 1959 } 2040 1960 2041 1961 Void TComDataCU::setSizeSubParts( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth ) 2042 1962 { 2043 UInt uiCurrPartNumb = m_pcPic->getNumPart InCU() >> (uiDepth << 1);2044 1963 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 1964 2045 1965 memset( m_puhWidth + uiAbsPartIdx, uiWidth, sizeof(UChar)*uiCurrPartNumb ); 2046 1966 memset( m_puhHeight + uiAbsPartIdx, uiHeight, sizeof(UChar)*uiCurrPartNumb ); 2047 1967 } 2048 1968 2049 UChar TComDataCU::getNumPartitions( )1969 UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx) 2050 1970 { 2051 1971 UChar iNumPart = 0; 2052 2053 switch ( m_pePartSize[ 0] )1972 1973 switch ( m_pePartSize[uiAbsPartIdx] ) 2054 1974 { 2055 1975 case SIZE_2Nx2N: iNumPart = 1; break; … … 2063 1983 default: assert (0); break; 2064 1984 } 2065 1985 2066 1986 return iNumPart; 2067 1987 } … … 2116 2036 return; 2117 2037 } 2118 2038 2119 2039 TComCUMvField* pcCUMvField = pcCU->getCUMvField( eRefPicList ); 2120 2040 rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) ); … … 2123 2043 Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) 2124 2044 { 2125 ruiPartIdxLT = m_ uiAbsIdxInLCU+ uiAbsPartIdx;2045 ruiPartIdxLT = m_absZIdxInCtu + uiAbsPartIdx; 2126 2046 UInt uiPUWidth = 0; 2127 2047 2128 2048 switch ( m_pePartSize[uiAbsPartIdx] ) 2129 2049 { … … 2134 2054 case SIZE_2NxnU: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; 2135 2055 case SIZE_2NxnD: uiPUWidth = m_puhWidth[uiAbsPartIdx]; break; 2136 case SIZE_nLx2N: 2056 case SIZE_nLx2N: 2137 2057 if ( uiPartIdx == 0 ) 2138 2058 { 2139 uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; 2059 uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; 2140 2060 } 2141 2061 else if ( uiPartIdx == 1 ) 2142 2062 { 2143 uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); 2063 uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); 2144 2064 } 2145 2065 else … … 2148 2068 } 2149 2069 break; 2150 case SIZE_nRx2N: 2070 case SIZE_nRx2N: 2151 2071 if ( uiPartIdx == 0 ) 2152 2072 { 2153 uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); 2073 uiPUWidth = (m_puhWidth[uiAbsPartIdx] >> 1) + (m_puhWidth[uiAbsPartIdx] >> 2); 2154 2074 } 2155 2075 else if ( uiPartIdx == 1 ) 2156 2076 { 2157 uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; 2077 uiPUWidth = m_puhWidth[uiAbsPartIdx] >> 2; 2158 2078 } 2159 2079 else … … 2166 2086 break; 2167 2087 } 2168 2088 2169 2089 ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + uiPUWidth / m_pcPic->getMinCUWidth() - 1 ]; 2170 2090 } … … 2179 2099 case SIZE_Nx2N: uiPUHeight = m_puhHeight[uiAbsPartIdx]; break; 2180 2100 case SIZE_NxN: uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 1; break; 2181 case SIZE_2NxnU: 2101 case SIZE_2NxnU: 2182 2102 if ( uiPartIdx == 0 ) 2183 2103 { 2184 uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; 2104 uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; 2185 2105 } 2186 2106 else if ( uiPartIdx == 1 ) 2187 2107 { 2188 uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); 2108 uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); 2189 2109 } 2190 2110 else … … 2193 2113 } 2194 2114 break; 2195 case SIZE_2NxnD: 2115 case SIZE_2NxnD: 2196 2116 if ( uiPartIdx == 0 ) 2197 2117 { 2198 uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); 2118 uiPUHeight = (m_puhHeight[uiAbsPartIdx] >> 1) + (m_puhHeight[uiAbsPartIdx] >> 2); 2199 2119 } 2200 2120 else if ( uiPartIdx == 1 ) 2201 2121 { 2202 uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; 2122 uiPUHeight = m_puhHeight[uiAbsPartIdx] >> 2; 2203 2123 } 2204 2124 else … … 2213 2133 break; 2214 2134 } 2215 2216 ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_ uiAbsIdxInLCU + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInWidth()];2135 2136 ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu + uiAbsPartIdx ] + ((uiPUHeight / m_pcPic->getMinCUHeight()) - 1)*m_pcPic->getNumPartInCtuWidth()]; 2217 2137 } 2218 2138 2219 2139 Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) 2220 2140 { 2221 ruiPartIdxLT = m_ uiAbsIdxInLCU;2141 ruiPartIdxLT = m_absZIdxInCtu; 2222 2142 ruiPartIdxRT = g_auiRasterToZscan [g_auiZscanToRaster[ ruiPartIdxLT ] + m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1 ]; 2223 2143 2224 2144 switch ( m_pePartSize[0] ) 2225 2145 { … … 2254 2174 break; 2255 2175 } 2256 2176 2257 2177 } 2258 2178 2259 2179 Void TComDataCU::deriveLeftBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxLB ) 2260 2180 { 2261 ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_ uiAbsIdxInLCU ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInWidth()];2262 2181 ruiPartIdxLB = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth()]; 2182 2263 2183 switch ( m_pePartSize[0] ) 2264 2184 { … … 2295 2215 /** Derives the partition index of neighbouring bottom right block 2296 2216 * \param [in] eCUMode 2297 * \param [in] uiPartIdx 2298 * \param [out] ruiPartIdxRB 2217 * \param [in] uiPartIdx 2218 * \param [out] ruiPartIdxRB 2299 2219 */ 2300 2220 Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt& ruiPartIdxRB ) 2301 2221 { 2302 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];2222 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]; 2303 2223 2304 2224 switch ( m_pePartSize[0] ) 2305 2225 { 2306 case SIZE_2Nx2N: 2307 ruiPartIdxRB += m_uiNumPartition >> 1; 2308 break; 2309 case SIZE_2NxN: 2310 ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; 2311 break; 2312 case SIZE_Nx2N: 2313 ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); 2314 break; 2315 case SIZE_NxN: 2316 ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); 2226 case SIZE_2Nx2N: 2227 ruiPartIdxRB += m_uiNumPartition >> 1; 2228 break; 2229 case SIZE_2NxN: 2230 ruiPartIdxRB += ( uiPartIdx == 0 )? 0 : m_uiNumPartition >> 1; 2231 break; 2232 case SIZE_Nx2N: 2233 ruiPartIdxRB += ( uiPartIdx == 0 )? m_uiNumPartition >> 2 : (m_uiNumPartition >> 1); 2234 break; 2235 case SIZE_NxN: 2236 ruiPartIdxRB += ( m_uiNumPartition >> 2 ) * ( uiPartIdx - 1 ); 2317 2237 break; 2318 2238 case SIZE_2NxnU: … … 2337 2257 { 2338 2258 UInt uiNumPartInWidth = (m_puhWidth[0]/m_pcPic->getMinCUWidth())>>uiPartDepth; 2339 ruiPartIdxLT = m_ uiAbsIdxInLCU+ uiPartOffset;2259 ruiPartIdxLT = m_absZIdxInCtu + uiPartOffset; 2340 2260 ruiPartIdxRT = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxLT ] + uiNumPartInWidth - 1 ]; 2341 2261 } … … 2345 2265 UInt uiAbsIdx; 2346 2266 UInt uiMinCuWidth, uiWidthInMinCus; 2347 2267 2348 2268 uiMinCuWidth = getPic()->getMinCUWidth(); 2349 2269 uiWidthInMinCus = (getWidth(0)/uiMinCuWidth)>>uiPartDepth; 2350 uiAbsIdx = getZorderIdxInC U()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1;2270 uiAbsIdx = getZorderIdxInCtu()+uiPartOffset+(m_uiNumPartition>>(uiPartDepth<<1))-1; 2351 2271 uiAbsIdx = g_auiZscanToRaster[uiAbsIdx]-(uiWidthInMinCus-1); 2352 2272 ruiPartIdxLB = g_auiRasterToZscan[uiAbsIdx]; … … 2355 2275 Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) 2356 2276 { 2357 2358 2277 if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) ) 2359 2278 { … … 2365 2284 if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) ) 2366 2285 { 2367 if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || 2286 if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiCandAbsPartIdx ) || 2368 2287 getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcCandCU->getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiCandAbsPartIdx ) ) 2369 2288 { … … 2378 2297 /** Constructs a list of merging candidates 2379 2298 * \param uiAbsPartIdx 2380 * \param uiPUIdx 2299 * \param uiPUIdx 2381 2300 * \param uiDepth 2382 2301 * \param pcMvFieldNeighbours … … 2386 2305 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) 2387 2306 { 2388 UInt uiAbsPartAddr = m_ uiAbsIdxInLCU+ uiAbsPartIdx;2307 UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx; 2389 2308 Bool abCandIsInter[ MRG_MAX_NUM_CANDS ]; 2390 2309 for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui ) … … 2404 2323 PartSize cCurPS = getPartitionSize( uiAbsPartIdx ); 2405 2324 deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT ); 2406 deriveLeftBottomIdxGeneral 2325 deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB ); 2407 2326 2408 2327 //left … … 2410 2329 TComDataCU* pcCULeft = 0; 2411 2330 pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB ); 2331 2412 2332 Bool isAvailableA1 = pcCULeft && 2413 pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && 2414 !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && 2415 !pcCULeft->isIntra( uiLeftPartIdx ) ; 2333 pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) && 2334 !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) && 2335 pcCULeft->isInter( uiLeftPartIdx ) ; 2336 2416 2337 if ( isAvailableA1 ) 2417 2338 { … … 2431 2352 iCount ++; 2432 2353 } 2433 2354 2434 2355 // early termination 2435 if (iCount == getSlice()->getMaxNumMergeCand()) 2356 if (iCount == getSlice()->getMaxNumMergeCand()) 2436 2357 { 2437 2358 return; … … 2441 2362 TComDataCU* pcCUAbove = 0; 2442 2363 pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT ); 2364 2443 2365 Bool isAvailableB1 = pcCUAbove && 2444 pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && 2445 !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && 2446 !pcCUAbove->isIntra( uiAbovePartIdx ); 2366 pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) && 2367 !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) && 2368 pcCUAbove->isInter( uiAbovePartIdx ); 2369 2447 2370 if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) ) 2448 2371 { … … 2463 2386 } 2464 2387 // early termination 2465 if (iCount == getSlice()->getMaxNumMergeCand()) 2388 if (iCount == getSlice()->getMaxNumMergeCand()) 2466 2389 { 2467 2390 return; … … 2472 2395 TComDataCU* pcCUAboveRight = 0; 2473 2396 pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT ); 2397 2474 2398 Bool isAvailableB0 = pcCUAboveRight && 2475 pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && 2476 !pcCUAboveRight->isIntra( uiAboveRightPartIdx ); 2399 pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) && 2400 pcCUAboveRight->isInter( uiAboveRightPartIdx ); 2401 2477 2402 if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) ) 2478 2403 { … … 2493 2418 } 2494 2419 // early termination 2495 if (iCount == getSlice()->getMaxNumMergeCand()) 2420 if (iCount == getSlice()->getMaxNumMergeCand()) 2496 2421 { 2497 2422 return; … … 2502 2427 TComDataCU* pcCULeftBottom = 0; 2503 2428 pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB ); 2429 2504 2430 Bool isAvailableA0 = pcCULeftBottom && 2505 pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && 2506 !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ; 2431 pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) && 2432 pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ; 2433 2507 2434 if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) ) 2508 2435 { … … 2523 2450 } 2524 2451 // early termination 2525 if (iCount == getSlice()->getMaxNumMergeCand()) 2452 if (iCount == getSlice()->getMaxNumMergeCand()) 2526 2453 { 2527 2454 return; 2528 2455 } 2529 // above left 2456 2457 // above left 2530 2458 if( iCount < 4 ) 2531 2459 { … … 2533 2461 TComDataCU* pcCUAboveLeft = 0; 2534 2462 pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr ); 2463 2535 2464 Bool isAvailableB2 = pcCUAboveLeft && 2536 pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && 2537 !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx ); 2465 pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) && 2466 pcCUAboveLeft->isInter( uiAboveLeftPartIdx ); 2467 2538 2468 if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) 2539 2469 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) ) … … 2556 2486 } 2557 2487 // early termination 2558 if (iCount == getSlice()->getMaxNumMergeCand()) 2488 if (iCount == getSlice()->getMaxNumMergeCand()) 2559 2489 { 2560 2490 return; 2561 2491 } 2562 if ( getSlice()->getEnableTMVPFlag()) 2492 2493 if ( getSlice()->getEnableTMVPFlag() ) 2563 2494 { 2564 2495 //>> MTK colocated-RightBottom 2565 2496 UInt uiPartIdxRB; 2566 2497 2567 deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 2498 deriveRightBottomIdx( uiPUIdx, uiPartIdxRB ); 2568 2499 2569 2500 UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB]; 2570 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 2501 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 2502 const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); 2571 2503 2572 2504 TComMv cColMv; 2573 2505 Int iRefIdx; 2574 Int uiLCUIdx= -1;2506 Int ctuRsAddr = -1; 2575 2507 2576 2508 #if REPN_FORMAT_IN_VPS 2577 if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getPicWidthInLumaSamples() ) // image boundary check 2578 { 2579 } 2580 else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getPicHeightInLumaSamples() ) 2581 { 2582 } 2509 if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getPicWidthInLumaSamples() ) // image boundary check 2510 && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getPicHeightInLumaSamples() ) ) 2583 2511 #else 2584 if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check 2585 { 2586 } 2587 else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 2588 { 2589 } 2590 #endif 2591 else 2592 { 2593 if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU 2594 ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU 2595 { 2596 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ]; 2597 uiLCUIdx = getAddr(); 2598 } 2599 else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU 2600 { 2601 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ]; 2602 } 2603 else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU 2512 if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check 2513 && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 2514 #endif 2515 { 2516 if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU 2517 ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU 2518 { 2519 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ]; 2520 ctuRsAddr = getCtuRsAddr(); 2521 } 2522 else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU 2523 { 2524 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; 2525 } 2526 else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU 2604 2527 { 2605 2528 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ]; 2606 uiLCUIdx = getAddr() + 1;2607 } 2608 else //is the right bottom corner of LCU2529 ctuRsAddr = getCtuRsAddr() + 1; 2530 } 2531 else //is the right bottom corner of CTU 2609 2532 { 2610 2533 uiAbsPartAddr = 0; 2611 2534 } 2612 2535 } 2613 2614 2536 2615 2537 iRefIdx = 0; 2538 2616 2539 Bool bExistMV = false; 2617 2540 UInt uiPartIdxCenter; 2618 UInt uiCurLCUIdx = getAddr();2619 2541 Int dir = 0; 2620 2542 UInt uiArrayAddr = iCount; 2621 2543 xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter ); 2622 bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );2544 bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx ); 2623 2545 if( bExistMV == false ) 2624 2546 { 2625 bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter,cColMv, iRefIdx );2547 bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); 2626 2548 } 2627 2549 if( bExistMV ) … … 2630 2552 pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx ); 2631 2553 } 2632 2554 2633 2555 if ( getSlice()->isInterB() ) 2634 2556 { 2635 bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);2557 bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx); 2636 2558 if( bExistMV == false ) 2637 2559 { 2638 bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );2560 bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx ); 2639 2561 } 2640 2562 if( bExistMV ) … … 2644 2566 } 2645 2567 } 2646 2568 2647 2569 if (dir != 0) 2648 2570 { … … 2658 2580 } 2659 2581 // early termination 2660 if (iCount == getSlice()->getMaxNumMergeCand()) 2582 if (iCount == getSlice()->getMaxNumMergeCand()) 2661 2583 { 2662 2584 return; 2663 2585 } 2586 2664 2587 UInt uiArrayAddr = iCount; 2665 2588 UInt uiCutoff = uiArrayAddr; 2666 2667 if ( getSlice()->isInterB()) 2668 { 2669 UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; 2670 UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; 2589 2590 if ( getSlice()->isInterB() ) 2591 { 2592 static const UInt NUM_PRIORITY_LIST=12; 2593 static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3}; 2594 static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2}; 2671 2595 2672 2596 for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++) 2673 2597 { 2674 Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx]; 2598 assert(idx<NUM_PRIORITY_LIST); 2599 Int i = uiPriorityList0[idx]; 2600 Int j = uiPriorityList1[idx]; 2675 2601 if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2)) 2676 2602 { … … 2696 2622 } 2697 2623 // early termination 2698 if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 2624 if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 2699 2625 { 2700 2626 return; 2701 2627 } 2628 2702 2629 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); 2630 2703 2631 Int r = 0; 2704 2632 Int refcnt = 0; … … 2715 2643 } 2716 2644 uiArrayAddr++; 2645 2717 2646 if ( refcnt == iNumRefIdx - 1 ) 2718 2647 { … … 2725 2654 } 2726 2655 } 2727 2728 2656 numValidMergeCand = uiArrayAddr; 2729 2657 } … … 2748 2676 return false; 2749 2677 } 2678 2750 2679 /** calculate the location of upper-left corner pixel and size of the current PU. 2751 2680 * \param partIdx PU index within a CU … … 2762 2691 { 2763 2692 case SIZE_2NxN: 2764 nPSW = getWidth(0); 2765 nPSH = getHeight(0) >> 1; 2693 nPSW = getWidth(0); 2694 nPSH = getHeight(0) >> 1; 2766 2695 xP = col; 2767 2696 yP = (partIdx ==0)? row: row + nPSH; 2768 2697 break; 2769 2698 case SIZE_Nx2N: 2770 nPSW = getWidth(0) >> 1; 2771 nPSH = getHeight(0); 2699 nPSW = getWidth(0) >> 1; 2700 nPSH = getHeight(0); 2772 2701 xP = (partIdx ==0)? col: col + nPSW; 2773 2702 yP = row; 2774 2703 break; 2775 2704 case SIZE_NxN: 2776 nPSW = getWidth(0) >> 1; 2777 nPSH = getHeight(0) >> 1; 2705 nPSW = getWidth(0) >> 1; 2706 nPSH = getHeight(0) >> 1; 2778 2707 xP = col + (partIdx&0x1)*nPSW; 2779 2708 yP = row + (partIdx>>1)*nPSH; … … 2806 2735 default: 2807 2736 assert ( m_pePartSize[0] == SIZE_2Nx2N ); 2808 nPSW = getWidth(0); 2809 nPSH = getHeight(0); 2737 nPSW = getWidth(0); 2738 nPSH = getHeight(0); 2810 2739 xP = col ; 2811 2740 yP = row ; … … 2817 2746 /** Constructs a list of candidates for AMVP 2818 2747 * \param uiPartIdx 2819 * \param uiPartAddr 2748 * \param uiPartAddr 2820 2749 * \param eRefPicList 2821 2750 * \param iRefIdx … … 2827 2756 Bool bAddedSmvp = false; 2828 2757 2829 pInfo->iN = 0; 2758 pInfo->iN = 0; 2830 2759 if (iRefIdx < 0) 2831 2760 { 2832 2761 return; 2833 2762 } 2834 2763 2835 2764 //-- Get Spatial MV 2836 2765 UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; 2837 UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth(); 2766 const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth(); 2767 const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight(); 2838 2768 Bool bAdded = false; 2839 2769 2840 2770 deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT ); 2841 2771 deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB ); 2842 2772 2843 2773 TComDataCU* tmpCU = NULL; 2844 2774 UInt idx; 2845 2775 tmpCU = getPUBelowLeft(idx, uiPartIdxLB); 2846 bAddedSmvp = (tmpCU != NULL) && (tmpCU-> getPredictionMode(idx) != MODE_INTRA);2776 bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx)); 2847 2777 2848 2778 if (!bAddedSmvp) 2849 2779 { 2850 2780 tmpCU = getPULeft(idx, uiPartIdxLB); 2851 bAddedSmvp = (tmpCU != NULL) && (tmpCU-> getPredictionMode(idx) != MODE_INTRA);2781 bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx)); 2852 2782 } 2853 2783 2854 2784 // Left predictor search 2855 2785 bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); 2856 if (!bAdded) 2786 if (!bAdded) 2857 2787 { 2858 2788 bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); 2859 2789 } 2860 2790 2861 2791 if(!bAdded) 2862 2792 { 2863 2793 bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT); 2864 if (!bAdded) 2794 if (!bAdded) 2865 2795 { 2866 2796 xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT ); 2867 2797 } 2868 2798 } 2869 2799 2870 2800 // Above predictor search 2871 2801 bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); 2872 2802 2873 if (!bAdded) 2803 if (!bAdded) 2874 2804 { 2875 2805 bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); … … 2881 2811 } 2882 2812 2883 if 2813 if(!bAddedSmvp) 2884 2814 { 2885 2815 bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT); 2886 if (!bAdded) 2816 if (!bAdded) 2887 2817 { 2888 2818 bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE); … … 2894 2824 } 2895 2825 } 2896 2826 2897 2827 if ( pInfo->iN == 2 ) 2898 2828 { … … 2909 2839 TComMv cColMv; 2910 2840 UInt uiPartIdxRB; 2911 UInt uiAbsPartIdx; 2841 UInt uiAbsPartIdx; 2912 2842 UInt uiAbsPartAddr; 2913 2843 2914 2844 deriveRightBottomIdx( uiPartIdx, uiPartIdxRB ); 2915 uiAbsPartAddr = m_ uiAbsIdxInLCU+ uiPartAddr;2845 uiAbsPartAddr = m_absZIdxInCtu + uiPartAddr; 2916 2846 2917 2847 //---- co-located RightBottom Temporal Predictor (H) ---// 2918 2848 uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB]; 2919 Int uiLCUIdx= -1;2849 Int ctuRsAddr = -1; 2920 2850 #if REPN_FORMAT_IN_VPS 2921 if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getPicWidthInLumaSamples() ) // image boundary check 2922 { 2923 } 2924 else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getPicHeightInLumaSamples() ) 2925 { 2926 } 2851 if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getPicWidthInLumaSamples()) // image boundary check 2852 && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getPicHeightInLumaSamples() ) ) 2927 2853 #else 2928 if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) // image boundary check 2929 { 2930 } 2931 else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) 2932 { 2933 } 2934 #endif 2854 if ( ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () ) // image boundary check 2855 && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 2856 #endif 2857 { 2858 if ( ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) && // is not at the last column of CTU 2859 ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) ) // is not at the last row of CTU 2860 { 2861 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth + 1 ]; 2862 ctuRsAddr = getCtuRsAddr(); 2863 } 2864 else if ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) // is not at the last column of CTU But is last row of CTU 2865 { 2866 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ]; 2867 } 2868 else if ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU 2869 { 2870 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ]; 2871 ctuRsAddr = getCtuRsAddr() + 1; 2872 } 2873 else //is the right bottom corner of CTU 2874 { 2875 uiAbsPartAddr = 0; 2876 } 2877 } 2878 if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx_Col ) ) 2879 { 2880 pInfo->m_acMvCand[pInfo->iN++] = cColMv; 2881 } 2935 2882 else 2936 2883 { 2937 if ( ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) && // is not at the last column of LCU2938 ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row of LCU2939 {2940 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + uiNumPartInCUWidth + 1 ];2941 uiLCUIdx = getAddr();2942 }2943 else if ( uiAbsPartIdx % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) // is not at the last column of LCU But is last row of LCU2944 {2945 uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];2946 }2947 else if ( uiAbsPartIdx / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU2948 {2949 uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ];2950 uiLCUIdx = getAddr() + 1;2951 }2952 else //is the right bottom corner of LCU2953 {2954 uiAbsPartAddr = 0;2955 }2956 }2957 if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col ) )2958 {2959 pInfo->m_acMvCand[pInfo->iN++] = cColMv;2960 }2961 else2962 {2963 2884 UInt uiPartIdxCenter; 2964 UInt uiCurLCUIdx = getAddr();2965 2885 xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter ); 2966 if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx_Col ))2886 if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx_Col )) 2967 2887 { 2968 2888 pInfo->m_acMvCand[pInfo->iN++] = cColMv; … … 2976 2896 pInfo->iN = AMVP_MAX_NUM_CANDS; 2977 2897 } 2898 2978 2899 while (pInfo->iN < AMVP_MAX_NUM_CANDS) 2979 2900 { 2980 2981 2901 pInfo->m_acMvCand[pInfo->iN].set(0,0); 2902 pInfo->iN++; 2982 2903 } 2983 2904 return ; 2984 2905 } 2906 2985 2907 2986 2908 Bool TComDataCU::isBipredRestriction(UInt puIdx) … … 2997 2919 return false; 2998 2920 } 2921 2999 2922 3000 2923 Void TComDataCU::clipMv (TComMv& rcMv) … … 3015 2938 #endif 3016 2939 Int iVerMin = ( -(Int)g_uiMaxCUHeight - iOffset - (Int)m_uiCUPelY + 1 ) << iMvShift; 3017 2940 3018 2941 rcMv.setHor( min (iHorMax, max (iHorMin, rcMv.getHor())) ); 3019 2942 rcMv.setVer( min (iVerMax, max (iVerMin, rcMv.getVer())) ); 3020 2943 } 3021 2944 2945 3022 2946 UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) 3023 2947 { 3024 2948 UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 ); 3025 2949 3026 2950 UChar uiWidth = m_puhWidth[uiAbsPartIdx]>>uiShift; 3027 2951 UInt uiCnt = 0; … … 3035 2959 } 3036 2960 3037 Void TComDataCU::clearCbf( UInt uiIdx, TextType eType, UInt uiNumParts )3038 { 3039 ::memset( &m_puhCbf[g_aucConvertTxtTypeToIdx[eType]][uiIdx], 0, sizeof(UChar)*uiNumParts);2961 Void TComDataCU::clearCbf( UInt uiIdx, ComponentID compID, UInt uiNumParts ) 2962 { 2963 memset( &m_puhCbf[compID][uiIdx], 0, sizeof(UChar)*uiNumParts); 3040 2964 } 3041 2965 … … 3048 2972 Void TComDataCU::setIPCMFlagSubParts (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth) 3049 2973 { 3050 UInt uiCurrPartNumb = m_pcPic->getNumPart InCU() >> (uiDepth << 1);2974 UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1); 3051 2975 3052 2976 memset(m_pbIPCMFlag + uiAbsPartIdx, bIpcmFlag, sizeof(Bool)*uiCurrPartNumb ); … … 3079 3003 case MD_ABOVE: 3080 3004 { 3081 pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx 3005 pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx); 3082 3006 break; 3083 3007 } … … 3107 3031 return false; 3108 3032 } 3109 3033 3110 3034 if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )) 3111 3035 { 3112 3036 TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx); 3113 3037 3114 3038 pInfo->m_acMvCand[ pInfo->iN++] = cMvPred; 3115 3039 return true; … … 3144 3068 } 3145 3069 3146 /** 3070 /** 3147 3071 * \param pInfo 3148 * \param eRefPicList 3072 * \param eRefPicList 3149 3073 * \param iRefIdx 3150 3074 * \param uiPartUnitIdx … … 3189 3113 } 3190 3114 3191 if ( pcTmpCU == NULL ) 3115 if ( pcTmpCU == NULL ) 3192 3116 { 3193 3117 return false; 3194 3118 } 3195 3119 3196 3120 RefPicList eRefPicList2nd = REF_PIC_LIST_0; 3197 3121 if( eRefPicList == REF_PIC_LIST_0 ) … … 3208 3132 Int iNeibPOC = iCurrPOC; 3209 3133 Int iNeibRefPOC; 3210 3211 3134 Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm(); 3212 3135 Bool bIsNeibRefLongTerm = false; 3136 3213 3137 //--------------- V1 (END) ------------------// 3214 3138 if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0) … … 3219 3143 3220 3144 bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm(); 3221 if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) 3222 { 3223 if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) 3224 { 3225 rcMv = cMvPred; 3226 } 3227 else 3228 { 3229 Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); 3230 if ( iScale == 4096 ) 3145 if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) 3146 { 3147 if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) 3231 3148 { 3232 3149 rcMv = cMvPred; … … 3234 3151 else 3235 3152 { 3236 rcMv = cMvPred.scaleMv( iScale ); 3237 } 3238 } 3239 pInfo->m_acMvCand[ pInfo->iN++] = rcMv; 3240 return true; 3153 Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); 3154 if ( iScale == 4096 ) 3155 { 3156 rcMv = cMvPred; 3157 } 3158 else 3159 { 3160 rcMv = cMvPred.scaleMv( iScale ); 3161 } 3162 } 3163 3164 pInfo->m_acMvCand[ pInfo->iN++] = rcMv; 3165 return true; 3241 3166 } 3242 3167 } … … 3249 3174 3250 3175 bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm(); 3251 if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) 3252 { 3253 if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) 3254 { 3255 rcMv = cMvPred; 3256 } 3257 else 3258 { 3259 Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); 3260 if ( iScale == 4096 ) 3176 if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm ) 3177 { 3178 if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm ) 3261 3179 { 3262 3180 rcMv = cMvPred; … … 3264 3182 else 3265 3183 { 3266 rcMv = cMvPred.scaleMv( iScale ); 3267 } 3268 } 3269 pInfo->m_acMvCand[ pInfo->iN++] = rcMv; 3270 return true; 3184 Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC ); 3185 if ( iScale == 4096 ) 3186 { 3187 rcMv = cMvPred; 3188 } 3189 else 3190 { 3191 rcMv = cMvPred.scaleMv( iScale ); 3192 } 3193 } 3194 3195 pInfo->m_acMvCand[ pInfo->iN++] = rcMv; 3196 return true; 3271 3197 } 3272 3198 } … … 3275 3201 } 3276 3202 3277 /** 3203 /** 3278 3204 * \param eRefPicList 3279 * \param uiCUAddr 3205 * \param uiCUAddr 3280 3206 * \param uiPartUnitIdx 3281 3207 * \param riRefIdx 3282 3208 * \returns Bool 3283 3209 */ 3284 Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx )3210 Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx ) 3285 3211 { 3286 3212 UInt uiAbsPartAddr = uiPartUnitIdx; … … 3292 3218 // use coldir. 3293 3219 TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx()); 3294 TComDataCU *pColC U = pColPic->getCU( uiCUAddr );3295 if(pColC U->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE)3220 TComDataCU *pColCtu = pColPic->getCtu( ctuRsAddr ); 3221 if(pColCtu->getPic()==0||pColCtu->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES) 3296 3222 { 3297 3223 return false; 3298 3224 } 3299 iCurrPOC = m_pcSlice->getPOC(); 3300 iColPOC = pColC U->getSlice()->getPOC();3301 3302 if ( pColCU->isIntra(uiAbsPartAddr))3225 iCurrPOC = m_pcSlice->getPOC(); 3226 iColPOC = pColCtu->getSlice()->getPOC(); 3227 3228 if (!pColCtu->isInter(uiAbsPartAddr)) 3303 3229 { 3304 3230 return false; 3305 3231 } 3232 3306 3233 eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag()); 3307 3234 3308 Int iColRefIdx = pColC U->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr);3235 Int iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); 3309 3236 3310 3237 if (iColRefIdx < 0 ) 3311 3238 { 3312 3239 eColRefPicList = RefPicList(1 - eColRefPicList); 3313 iColRefIdx = pColC U->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr);3240 iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr); 3314 3241 3315 3242 if (iColRefIdx < 0 ) … … 3320 3247 3321 3248 // Scale the vector. 3322 iColRefPOC = pColC U->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);3323 cColMv = pColC U->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);3249 iColRefPOC = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx); 3250 cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr); 3324 3251 3325 3252 iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC(); 3253 3326 3254 Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm(); 3327 Bool bIsColRefLongTerm = pColC U->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);3328 3329 if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) 3255 Bool bIsColRefLongTerm = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx); 3256 3257 if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) 3330 3258 { 3331 3259 return false; … … 3348 3276 } 3349 3277 } 3278 3350 3279 return true; 3351 3280 } … … 3360 3289 UInt uiLength = 1; 3361 3290 UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); 3362 3291 3363 3292 assert ( uiTemp ); 3364 3293 3365 3294 while ( 1 != uiTemp ) 3366 3295 { … … 3368 3297 uiLength += 2; 3369 3298 } 3370 3299 3371 3300 return uiLength; 3372 3301 } … … 3377 3306 Int iDiffPocD = iColPOC - iColRefPOC; 3378 3307 Int iDiffPocB = iCurrPOC - iCurrRefPOC; 3379 3308 3380 3309 if( iDiffPocD == iDiffPocB ) 3381 3310 { … … 3392 3321 } 3393 3322 3394 /** 3323 /** 3395 3324 * \param eCUMode 3396 * \param uiPartIdx 3325 * \param uiPartIdx 3397 3326 * \param ruiPartIdxCenter 3398 3327 * \returns Void … … 3404 3333 Int iPartHeight; 3405 3334 getPartIndexAndSize( uiPartIdx, uiPartAddr, iPartWidth, iPartHeight); 3406 3407 ruiPartIdxCenter = m_ uiAbsIdxInLCU+uiPartAddr; // partition origin.3335 3336 ruiPartIdxCenter = m_absZIdxInCtu+uiPartAddr; // partition origin. 3408 3337 ruiPartIdxCenter = g_auiRasterToZscan[ g_auiZscanToRaster[ ruiPartIdxCenter ] 3409 + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartIn Width()3338 + ( iPartHeight/m_pcPic->getMinCUHeight() )/2*m_pcPic->getNumPartInCtuWidth() 3410 3339 + ( iPartWidth/m_pcPic->getMinCUWidth() )/2]; 3411 3340 } … … 3416 3345 if (scaleFactor > 0) 3417 3346 { 3418 m_acCUMvField[0].compress(m_pePredMode, scaleFactor); 3419 m_acCUMvField[1].compress(m_pePredMode, scaleFactor); 3420 } 3421 } 3422 3423 UInt TComDataCU::getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra) 3424 { 3425 UInt uiCTXIdx; 3426 UInt uiScanIdx; 3427 UInt uiDirMode; 3428 3429 if ( !bIsIntra ) 3430 { 3431 uiScanIdx = SCAN_DIAG; 3432 return uiScanIdx; 3433 } 3434 3435 switch(uiWidth) 3436 { 3437 case 2: uiCTXIdx = 6; break; 3438 case 4: uiCTXIdx = 5; break; 3439 case 8: uiCTXIdx = 4; break; 3440 case 16: uiCTXIdx = 3; break; 3441 case 32: uiCTXIdx = 2; break; 3442 case 64: uiCTXIdx = 1; break; 3443 default: uiCTXIdx = 0; break; 3444 } 3445 3446 if ( bIsLuma ) 3447 { 3448 uiDirMode = getLumaIntraDir(uiAbsPartIdx); 3449 uiScanIdx = SCAN_DIAG; 3450 if (uiCTXIdx >3 && uiCTXIdx < 6) //if multiple scans supported for transform size 3451 { 3452 uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); 3453 } 3454 } 3455 else 3456 { 3457 uiDirMode = getChromaIntraDir(uiAbsPartIdx); 3458 if( uiDirMode == DM_CHROMA_IDX ) 3459 { 3460 // get number of partitions in current CU 3461 UInt depth = getDepth(uiAbsPartIdx); 3462 UInt numParts = getPic()->getNumPartInCU() >> (2 * depth); 3463 3464 // get luma mode from upper-left corner of current CU 3465 uiDirMode = getLumaIntraDir((uiAbsPartIdx/numParts)*numParts); 3466 } 3467 uiScanIdx = SCAN_DIAG; 3468 if (uiCTXIdx >4 && uiCTXIdx < 7) //if multiple scans supported for transform size 3469 { 3470 uiScanIdx = abs((Int) uiDirMode - VER_IDX) < 5 ? SCAN_HOR : (abs((Int)uiDirMode - HOR_IDX) < 5 ? SCAN_VER : SCAN_DIAG); 3471 } 3472 } 3473 3474 return uiScanIdx; 3475 } 3476 3477 UInt TComDataCU::getSCUAddr() 3478 { 3479 return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU; 3347 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 3348 { 3349 m_acCUMvField[i].compress(m_pePredMode, scaleFactor); 3350 } 3351 } 3352 } 3353 3354 UInt TComDataCU::getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const 3355 { 3356 //------------------------------------------------ 3357 3358 //this mechanism is available for intra only 3359 3360 if (!isIntra(uiAbsPartIdx)) return SCAN_DIAG; 3361 3362 //------------------------------------------------ 3363 3364 //check that MDCS can be used for this TU 3365 3366 const ChromaFormat format = getPic()->getChromaFormat(); 3367 3368 const UInt maximumWidth = MDCS_MAXIMUM_WIDTH >> getComponentScaleX(compID, format); 3369 const UInt maximumHeight = MDCS_MAXIMUM_HEIGHT >> getComponentScaleY(compID, format); 3370 3371 if ((uiWidth > maximumWidth) || (uiHeight > maximumHeight)) return SCAN_DIAG; 3372 3373 //------------------------------------------------ 3374 3375 //otherwise, select the appropriate mode 3376 3377 UInt uiDirMode = getIntraDir(toChannelType(compID), uiAbsPartIdx); 3378 3379 if (uiDirMode==DM_CHROMA_IDX) 3380 { 3381 uiDirMode = getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, getPic()->getChromaFormat())); 3382 } 3383 3384 if (isChroma(compID) && (format == CHROMA_422)) 3385 { 3386 uiDirMode = g_chroma422IntraAngleMappingTable[uiDirMode]; 3387 } 3388 3389 //------------------ 3390 3391 if (abs((Int)uiDirMode - VER_IDX) <= MDCS_ANGLE_LIMIT) return SCAN_HOR; 3392 else if (abs((Int)uiDirMode - HOR_IDX) <= MDCS_ANGLE_LIMIT) return SCAN_VER; 3393 else return SCAN_DIAG; 3480 3394 } 3481 3395 … … 3493 3407 TComPic* baseColPic = m_pcSlice->getBaseColPic(refLayerIdc); 3494 3408 3495 UInt uiPelX = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getWidth( ) - 1, pelX);3496 UInt uiPelY = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getHeight( ) - 1, pelY);3409 UInt uiPelX = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getWidth(COMPONENT_Y) - 1, pelX); 3410 UInt uiPelY = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getHeight(COMPONENT_Y) - 1, pelY); 3497 3411 3498 3412 #if REF_IDX_MFM … … 3561 3475 #endif 3562 3476 3563 if ( iBX < 0 || iBX >= baseColPic->getPicYuvRec()->getWidth( ) || iBY < 0 || iBY >= baseColPic->getPicYuvRec()->getHeight() )3477 if ( iBX < 0 || iBX >= baseColPic->getPicYuvRec()->getWidth(COMPONENT_Y) || iBY < 0 || iBY >= baseColPic->getPicYuvRec()->getHeight(COMPONENT_Y) ) 3564 3478 { 3565 3479 return NULL; … … 3571 3485 UInt baseMinUnitSize = baseColPic->getMinCUWidth(); 3572 3486 3573 uiCUAddrBase = ( iBY / baseMaxCUHeight ) * baseColPic->getFrameWidthInC U() + ( iBX / baseMaxCUWidth );3487 uiCUAddrBase = ( iBY / baseMaxCUHeight ) * baseColPic->getFrameWidthInCtus() + ( iBX / baseMaxCUWidth ); 3574 3488 #else 3575 uiCUAddrBase = (iBY/g_uiMaxCUHeight)*baseColPic->getFrameWidthInC U() + (iBX/g_uiMaxCUWidth);3489 uiCUAddrBase = (iBY/g_uiMaxCUHeight)*baseColPic->getFrameWidthInCtus() + (iBX/g_uiMaxCUWidth); 3576 3490 #endif 3577 3491 3578 assert(uiCUAddrBase < baseColPic->getNum CUsInFrame());3492 assert(uiCUAddrBase < baseColPic->getNumberOfCtusInFrame()); 3579 3493 3580 3494 #if LAYER_CTB 3581 UInt uiRasterAddrBase = ( iBY - (iBY/baseMaxCUHeight)*baseMaxCUHeight ) / baseMinUnitSize * baseColPic->getNumPartIn Width() + ( iBX - (iBX/baseMaxCUWidth)*baseMaxCUWidth ) / baseMinUnitSize;3495 UInt uiRasterAddrBase = ( iBY - (iBY/baseMaxCUHeight)*baseMaxCUHeight ) / baseMinUnitSize * baseColPic->getNumPartInCtuWidth() + ( iBX - (iBX/baseMaxCUWidth)*baseMaxCUWidth ) / baseMinUnitSize; 3582 3496 3583 3497 uiAbsPartIdxBase = g_auiLayerRasterToZscan[baseColPic->getLayerId()][uiRasterAddrBase]; 3584 3498 #else 3585 UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*baseColPic->getNumPartIn Width()3499 UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*baseColPic->getNumPartInCtuWidth() 3586 3500 + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize; 3587 3501 … … 3589 3503 #endif 3590 3504 3591 return baseColPic->getC U(uiCUAddrBase);3505 return baseColPic->getCtu(uiCUAddrBase); 3592 3506 } 3593 3507 … … 3629 3543 } 3630 3544 3631 Int iColBaseDir = pcTempCU->get LumaIntraDir(uiAbsPartAddrBase );3545 Int iColBaseDir = pcTempCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartAddrBase ); 3632 3546 if ( authorizedMode[iColBaseDir] ) //possibly add BL mode 3633 3547 {
Note: See TracChangeset for help on using the changeset viewer.