Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPrediction.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComPrediction.cpp
r1196 r1313 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 38 38 #include <memory.h> 39 39 #include "TComPrediction.h" 40 #include "TComPic.h" 41 #include "TComTU.h" 40 42 41 43 //! \ingroup TLibCommon 42 44 //! \{ 45 46 // ==================================================================================================================== 47 // Tables 48 // ==================================================================================================================== 49 50 const UChar TComPrediction::m_aucIntraFilter[MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS] = 51 { 52 { // Luma 53 10, //4x4 54 7, //8x8 55 1, //16x16 56 0, //32x32 57 10, //64x64 58 }, 59 { // Chroma 60 10, //4xn 61 7, //8xn 62 1, //16xn 63 0, //32xn 64 10, //64xn 65 } 66 67 }; 43 68 44 69 // ==================================================================================================================== … … 50 75 , m_iLumaRecStride(0) 51 76 { 52 m_piYuvExt = NULL; 53 #if H_3D_VSP 54 m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int)); 77 for(UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) 78 { 79 for(UInt buf=0; buf<2; buf++) 80 { 81 m_piYuvExt[ch][buf] = NULL; 82 } 83 } 84 #if NH_3D_VSP 85 m_pDepthBlock = (Int*) malloc(MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH*sizeof(Int)); 55 86 if (m_pDepthBlock == NULL) 56 87 { … … 58 89 } 59 90 #endif 91 60 92 } 61 93 62 94 TComPrediction::~TComPrediction() 63 95 { 64 #if H_3D_VSP96 #if NH_3D_VSP 65 97 if (m_pDepthBlock != NULL) 66 98 { … … 70 102 #endif 71 103 72 delete[] m_piYuvExt; 73 74 m_acYuvPred[0].destroy(); 75 m_acYuvPred[1].destroy(); 104 destroy(); 105 } 106 107 Void TComPrediction::destroy() 108 { 109 for(UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) 110 { 111 for(UInt buf=0; buf<NUM_PRED_BUF; buf++) 112 { 113 delete [] m_piYuvExt[ch][buf]; 114 m_piYuvExt[ch][buf] = NULL; 115 } 116 } 117 118 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 119 { 120 m_acYuvPred[i].destroy(); 121 } 76 122 77 123 m_cYuvPredTemp.destroy(); 78 124 79 #if H_3D_ARP125 #if NH_3D_ARP 80 126 m_acYuvPredBase[0].destroy(); 81 127 m_acYuvPredBase[1].destroy(); … … 84 130 { 85 131 delete [] m_pLumaRecBuffer; 86 } 87 88 Int i, j; 89 for (i = 0; i < 4; i++) 90 { 91 for (j = 0; j < 4; j++) 132 m_pLumaRecBuffer = 0; 133 } 134 m_iLumaRecStride = 0; 135 136 for (UInt i = 0; i < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; i++) 137 { 138 for (UInt j = 0; j < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; j++) 92 139 { 93 140 m_filteredBlock[i][j].destroy(); … … 97 144 } 98 145 99 Void TComPrediction::initTempBuff() 100 { 101 if( m_piYuvExt == NULL ) 102 { 103 Int extWidth = MAX_CU_SIZE + 16; 146 Void TComPrediction::initTempBuff(ChromaFormat chromaFormatIDC) 147 { 148 // if it has been initialised before, but the chroma format has changed, release the memory and start again. 149 if( m_piYuvExt[COMPONENT_Y][PRED_BUF_UNFILTERED] != NULL && m_cYuvPredTemp.getChromaFormat()!=chromaFormatIDC) 150 { 151 destroy(); 152 } 153 154 if( m_piYuvExt[COMPONENT_Y][PRED_BUF_UNFILTERED] == NULL ) // check if first is null (in which case, nothing initialised yet) 155 { 156 Int extWidth = MAX_CU_SIZE + 16; 104 157 Int extHeight = MAX_CU_SIZE + 1; 105 Int i, j; 106 for (i = 0; i < 4; i++) 107 { 108 m_filteredBlockTmp[i].create(extWidth, extHeight + 7); 109 for (j = 0; j < 4; j++) 110 { 111 m_filteredBlock[i][j].create(extWidth, extHeight); 112 } 113 } 114 m_iYuvExtHeight = ((MAX_CU_SIZE + 2) << 4); 115 m_iYuvExtStride = ((MAX_CU_SIZE + 8) << 4); 116 m_piYuvExt = new Int[ m_iYuvExtStride * m_iYuvExtHeight ]; 158 159 for (UInt i = 0; i < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; i++) 160 { 161 m_filteredBlockTmp[i].create(extWidth, extHeight + 7, chromaFormatIDC); 162 for (UInt j = 0; j < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS; j++) 163 { 164 m_filteredBlock[i][j].create(extWidth, extHeight, chromaFormatIDC); 165 } 166 } 167 168 m_iYuvExtSize = (MAX_CU_SIZE*2+1) * (MAX_CU_SIZE*2+1); 169 for(UInt ch=0; ch<MAX_NUM_COMPONENT; ch++) 170 { 171 for(UInt buf=0; buf<NUM_PRED_BUF; buf++) 172 { 173 m_piYuvExt[ch][buf] = new Pel[ m_iYuvExtSize ]; 174 } 175 } 117 176 118 177 // new structure 119 m_acYuvPred[0] .create( MAX_CU_SIZE, MAX_CU_SIZE ); 120 m_acYuvPred[1] .create( MAX_CU_SIZE, MAX_CU_SIZE ); 121 122 m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE ); 123 #if H_3D_ARP 124 m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); 125 m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); 126 #endif 127 #if H_3D_VSP 128 m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight ); 129 #endif 130 } 178 for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) 179 { 180 m_acYuvPred[i] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC ); 181 } 182 183 m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC ); 184 #if NH_3D_ARP 185 m_acYuvPredBase[0] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC ); 186 m_acYuvPredBase[1] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC ); 187 #endif 188 #if NH_3D_VSP 189 m_cYuvDepthOnVsp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC ); 190 #endif 191 192 } 193 131 194 132 195 if (m_iLumaRecStride != (MAX_CU_SIZE>>1) + 1) … … 138 201 } 139 202 } 140 #if H_3D_IC203 #if NH_3D_IC 141 204 m_uiaShift[0] = 0; 142 205 for( Int i = 1; i < 64; i++ ) … … 152 215 153 216 // Function for calculating DC value of the reference samples used in Intra prediction 154 Pel TComPrediction::predIntraGetPredValDC( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ) 217 //NOTE: Bit-Limit - 25-bit source 218 Pel TComPrediction::predIntraGetPredValDC( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight) 155 219 { 156 220 assert(iWidth > 0 && iHeight > 0); … … 158 222 Pel pDcVal; 159 223 160 if (bAbove) 161 { 162 for (iInd = 0;iInd < iWidth;iInd++) 163 { 164 iSum += pSrc[iInd-iSrcStride]; 165 } 166 } 167 if (bLeft) 168 { 169 for (iInd = 0;iInd < iHeight;iInd++) 170 { 171 iSum += pSrc[iInd*iSrcStride-1]; 172 } 173 } 174 175 if (bAbove && bLeft) 176 { 177 pDcVal = (iSum + iWidth) / (iWidth + iHeight); 178 } 179 else if (bAbove) 180 { 181 pDcVal = (iSum + iWidth/2) / iWidth; 182 } 183 else if (bLeft) 184 { 185 pDcVal = (iSum + iHeight/2) / iHeight; 186 } 187 else 188 { 189 pDcVal = pSrc[-1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available 190 } 191 224 for (iInd = 0;iInd < iWidth;iInd++) 225 { 226 iSum += pSrc[iInd-iSrcStride]; 227 } 228 for (iInd = 0;iInd < iHeight;iInd++) 229 { 230 iSum += pSrc[iInd*iSrcStride-1]; 231 } 232 233 pDcVal = (iSum + iWidth) / (iWidth + iHeight); 234 192 235 return pDcVal; 193 236 } … … 196 239 197 240 /** Function for deriving the simplified angular intra predictions. 198 * \param pSrc pointer to reconstructed sample array 199 * \param srcStride the stride of the reconstructed sample array 200 * \param rpDst reference to pointer for the prediction sample array 201 * \param dstStride the stride of the prediction sample array 202 * \param width the width of the block 203 * \param height the height of the block 204 * \param dirMode the intra prediction mode index 205 * \param blkAboveAvailable boolean indication if the block above is available 206 * \param blkLeftAvailable boolean indication if the block to the left is available 241 * \param bitDepth bit depth 242 * \param pSrc pointer to reconstructed sample array 243 * \param srcStride the stride of the reconstructed sample array 244 * \param pTrueDst reference to pointer for the prediction sample array 245 * \param dstStrideTrue the stride of the prediction sample array 246 * \param uiWidth the width of the block 247 * \param uiHeight the height of the block 248 * \param channelType type of pel array (luma/chroma) 249 * \param format chroma format 250 * \param dirMode the intra prediction mode index 251 * \param blkAboveAvailable boolean indication if the block above is available 252 * \param blkLeftAvailable boolean indication if the block to the left is available 253 * \param bEnableEdgeFilters indication whether to enable edge filters 207 254 * 208 255 * This function derives the prediction samples for the angular mode based on the prediction direction indicated by … … 214 261 * from the extended main reference. 215 262 */ 216 Void TComPrediction::xPredIntraAng(Int bitDepth, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable, Bool bFilter ) 217 { 218 Int k,l; 219 Int blkSize = width; 220 Pel* pDst = rpDst; 263 //NOTE: Bit-Limit - 25-bit source 264 Void TComPrediction::xPredIntraAng( Int bitDepth, 265 const Pel* pSrc, Int srcStride, 266 Pel* pTrueDst, Int dstStrideTrue, 267 UInt uiWidth, UInt uiHeight, ChannelType channelType, 268 UInt dirMode, const Bool bEnableEdgeFilters 269 ) 270 { 271 Int width=Int(uiWidth); 272 Int height=Int(uiHeight); 221 273 222 274 // Map the mode index to main prediction direction and angle 223 assert( dirMode > 0 ); //no planar 224 Bool modeDC = dirMode < 2; 225 Bool modeHor = !modeDC && (dirMode < 18); 226 Bool modeVer = !modeDC && !modeHor; 227 Int intraPredAngle = modeVer ? (Int)dirMode - VER_IDX : modeHor ? -((Int)dirMode - HOR_IDX) : 0; 228 Int absAng = abs(intraPredAngle); 229 Int signAng = intraPredAngle < 0 ? -1 : 1; 230 231 // Set bitshifts and scale the angle parameter to block size 232 Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; 233 Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle 234 Int invAngle = invAngTable[absAng]; 235 absAng = angTable[absAng]; 236 intraPredAngle = signAng * absAng; 275 assert( dirMode != PLANAR_IDX ); //no planar 276 const Bool modeDC = dirMode==DC_IDX; 237 277 238 278 // Do the DC prediction 239 279 if (modeDC) 240 280 { 241 Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height, blkAboveAvailable, blkLeftAvailable); 242 243 for (k=0;k<blkSize;k++) 244 { 245 for (l=0;l<blkSize;l++) 246 { 247 pDst[k*dstStride+l] = dcval; 248 } 249 } 250 } 251 252 // Do angular predictions 253 else 254 { 281 const Pel dcval = predIntraGetPredValDC(pSrc, srcStride, width, height); 282 283 for (Int y=height;y>0;y--, pTrueDst+=dstStrideTrue) 284 { 285 for (Int x=0; x<width;) // width is always a multiple of 4. 286 { 287 pTrueDst[x++] = dcval; 288 } 289 } 290 } 291 else // Do angular predictions 292 { 293 const Bool bIsModeVer = (dirMode >= 18); 294 const Int intraPredAngleMode = (bIsModeVer) ? (Int)dirMode - VER_IDX : -((Int)dirMode - HOR_IDX); 295 const Int absAngMode = abs(intraPredAngleMode); 296 const Int signAng = intraPredAngleMode < 0 ? -1 : 1; 297 const Bool edgeFilter = bEnableEdgeFilters && isLuma(channelType) && (width <= MAXIMUM_INTRA_FILTERED_WIDTH) && (height <= MAXIMUM_INTRA_FILTERED_HEIGHT); 298 299 // Set bitshifts and scale the angle parameter to block size 300 static const Int angTable[9] = {0, 2, 5, 9, 13, 17, 21, 26, 32}; 301 static const Int invAngTable[9] = {0, 4096, 1638, 910, 630, 482, 390, 315, 256}; // (256 * 32) / Angle 302 Int invAngle = invAngTable[absAngMode]; 303 Int absAng = angTable[absAngMode]; 304 Int intraPredAngle = signAng * absAng; 305 255 306 Pel* refMain; 256 307 Pel* refSide; 308 257 309 Pel refAbove[2*MAX_CU_SIZE+1]; 258 310 Pel refLeft[2*MAX_CU_SIZE+1]; 259 311 260 // Initiali se the Main and Left reference array.312 // Initialize the Main and Left reference array. 261 313 if (intraPredAngle < 0) 262 314 { 263 for (k=0;k<blkSize+1;k++) 264 { 265 refAbove[k+blkSize-1] = pSrc[k-srcStride-1]; 266 } 267 for (k=0;k<blkSize+1;k++) 268 { 269 refLeft[k+blkSize-1] = pSrc[(k-1)*srcStride-1]; 270 } 271 refMain = (modeVer ? refAbove : refLeft) + (blkSize-1); 272 refSide = (modeVer ? refLeft : refAbove) + (blkSize-1); 315 const Int refMainOffsetPreScale = (bIsModeVer ? height : width ) - 1; 316 const Int refMainOffset = height - 1; 317 for (Int x=0;x<width+1;x++) 318 { 319 refAbove[x+refMainOffset] = pSrc[x-srcStride-1]; 320 } 321 for (Int y=0;y<height+1;y++) 322 { 323 refLeft[y+refMainOffset] = pSrc[(y-1)*srcStride-1]; 324 } 325 refMain = (bIsModeVer ? refAbove : refLeft) + refMainOffset; 326 refSide = (bIsModeVer ? refLeft : refAbove) + refMainOffset; 273 327 274 328 // Extend the Main reference to the left. 275 329 Int invAngleSum = 128; // rounding for (shift by 8) 276 for ( k=-1; k>blkSize*intraPredAngle>>5; k--)330 for (Int k=-1; k>(refMainOffsetPreScale+1)*intraPredAngle>>5; k--) 277 331 { 278 332 invAngleSum += invAngle; … … 282 336 else 283 337 { 284 for (k=0;k<2*blkSize+1;k++) 285 { 286 refAbove[k] = pSrc[k-srcStride-1]; 287 } 288 for (k=0;k<2*blkSize+1;k++) 289 { 290 refLeft[k] = pSrc[(k-1)*srcStride-1]; 291 } 292 refMain = modeVer ? refAbove : refLeft; 293 refSide = modeVer ? refLeft : refAbove; 294 } 295 296 if (intraPredAngle == 0) 297 { 298 for (k=0;k<blkSize;k++) 299 { 300 for (l=0;l<blkSize;l++) 301 { 302 pDst[k*dstStride+l] = refMain[l+1]; 303 } 304 } 305 306 if ( bFilter ) 307 { 308 for (k=0;k<blkSize;k++) 309 { 310 pDst[k*dstStride] = Clip3(0, (1<<bitDepth)-1, pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) ); 338 for (Int x=0;x<2*width+1;x++) 339 { 340 refAbove[x] = pSrc[x-srcStride-1]; 341 } 342 for (Int y=0;y<2*height+1;y++) 343 { 344 refLeft[y] = pSrc[(y-1)*srcStride-1]; 345 } 346 refMain = bIsModeVer ? refAbove : refLeft ; 347 refSide = bIsModeVer ? refLeft : refAbove; 348 } 349 350 // swap width/height if we are doing a horizontal mode: 351 Pel tempArray[MAX_CU_SIZE*MAX_CU_SIZE]; 352 const Int dstStride = bIsModeVer ? dstStrideTrue : MAX_CU_SIZE; 353 Pel *pDst = bIsModeVer ? pTrueDst : tempArray; 354 if (!bIsModeVer) 355 { 356 std::swap(width, height); 357 } 358 359 if (intraPredAngle == 0) // pure vertical or pure horizontal 360 { 361 for (Int y=0;y<height;y++) 362 { 363 for (Int x=0;x<width;x++) 364 { 365 pDst[y*dstStride+x] = refMain[x+1]; 366 } 367 } 368 369 if (edgeFilter) 370 { 371 for (Int y=0;y<height;y++) 372 { 373 pDst[y*dstStride] = Clip3 (0, ((1 << bitDepth) - 1), pDst[y*dstStride] + (( refSide[y+1] - refSide[0] ) >> 1) ); 311 374 } 312 375 } … … 314 377 else 315 378 { 316 Int deltaPos=0; 317 Int deltaInt; 318 Int deltaFract; 319 Int refMainIndex; 320 321 for (k=0;k<blkSize;k++) 322 { 323 deltaPos += intraPredAngle; 324 deltaInt = deltaPos >> 5; 325 deltaFract = deltaPos & (32 - 1); 379 Pel *pDsty=pDst; 380 381 for (Int y=0, deltaPos=intraPredAngle; y<height; y++, deltaPos+=intraPredAngle, pDsty+=dstStride) 382 { 383 const Int deltaInt = deltaPos >> 5; 384 const Int deltaFract = deltaPos & (32 - 1); 326 385 327 386 if (deltaFract) 328 387 { 329 388 // Do linear filtering 330 for (l=0;l<blkSize;l++) 389 const Pel *pRM=refMain+deltaInt+1; 390 Int lastRefMainPel=*pRM++; 391 for (Int x=0;x<width;pRM++,x++) 331 392 { 332 refMainIndex = l+deltaInt+1; 333 pDst[k*dstStride+l] = (Pel) ( ((32-deltaFract)*refMain[refMainIndex]+deltaFract*refMain[refMainIndex+1]+16) >> 5 ); 393 Int thisRefMainPel=*pRM; 394 pDsty[x+0] = (Pel) ( ((32-deltaFract)*lastRefMainPel + deltaFract*thisRefMainPel +16) >> 5 ); 395 lastRefMainPel=thisRefMainPel; 334 396 } 335 397 } … … 337 399 { 338 400 // Just copy the integer samples 339 for ( l=0;l<blkSize;l++)401 for (Int x=0;x<width; x++) 340 402 { 341 pDst [k*dstStride+l] = refMain[l+deltaInt+1];403 pDsty[x] = refMain[x+deltaInt+1]; 342 404 } 343 405 } … … 346 408 347 409 // Flip the block if this is the horizontal mode 348 if (modeHor) 349 { 350 Pel tmp; 351 for (k=0;k<blkSize-1;k++) 352 { 353 for (l=k+1;l<blkSize;l++) 354 { 355 tmp = pDst[k*dstStride+l]; 356 pDst[k*dstStride+l] = pDst[l*dstStride+k]; 357 pDst[l*dstStride+k] = tmp; 358 } 359 } 360 } 361 } 362 } 363 364 Void TComPrediction::predIntraLumaAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ) 365 { 366 Pel *pDst = piPred; 367 Int *ptrSrc; 410 if (!bIsModeVer) 411 { 412 for (Int y=0; y<height; y++) 413 { 414 for (Int x=0; x<width; x++) 415 { 416 pTrueDst[x*dstStrideTrue] = pDst[x]; 417 } 418 pTrueDst++; 419 pDst+=dstStride; 420 } 421 } 422 } 423 } 424 425 Void TComPrediction::predIntraAng( const ComponentID compID, UInt uiDirMode, Pel* piOrg /* Will be null for decoding */, UInt uiOrgStride, Pel* piPred, UInt uiStride, TComTU &rTu, const Bool bUseFilteredPredSamples, const Bool bUseLosslessDPCM ) 426 { 427 const ChannelType channelType = toChannelType(compID); 428 const TComRectangle &rect = rTu.getRect(isLuma(compID) ? COMPONENT_Y : COMPONENT_Cb); 429 const Int iWidth = rect.width; 430 const Int iHeight = rect.height; 368 431 369 432 assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 370 433 assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 434 //assert( iWidth == iHeight ); 435 436 Pel *pDst = piPred; 437 438 // get starting pixel in block 439 const Int sw = (2 * iWidth + 1); 440 441 if ( bUseLosslessDPCM ) 442 { 443 const Pel *ptrSrc = getPredictorPtr( compID, false ); 444 // Sample Adaptive intra-Prediction (SAP) 445 if (uiDirMode==HOR_IDX) 446 { 447 // left column filled with reference samples 448 // remaining columns filled with piOrg data (if available). 449 for(Int y=0; y<iHeight; y++) 450 { 451 piPred[y*uiStride+0] = ptrSrc[(y+1)*sw]; 452 } 453 if (piOrg!=0) 454 { 455 piPred+=1; // miss off first column 456 for(Int y=0; y<iHeight; y++, piPred+=uiStride, piOrg+=uiOrgStride) 457 { 458 memcpy(piPred, piOrg, (iWidth-1)*sizeof(Pel)); 459 } 460 } 461 } 462 else // VER_IDX 463 { 464 // top row filled with reference samples 465 // remaining rows filled with piOrd data (if available) 466 for(Int x=0; x<iWidth; x++) 467 { 468 piPred[x] = ptrSrc[x+1]; 469 } 470 if (piOrg!=0) 471 { 472 piPred+=uiStride; // miss off the first row 473 for(Int y=1; y<iHeight; y++, piPred+=uiStride, piOrg+=uiOrgStride) 474 { 475 memcpy(piPred, piOrg, iWidth*sizeof(Pel)); 476 } 477 } 478 } 479 } 480 else 481 { 482 const Pel *ptrSrc = getPredictorPtr( compID, bUseFilteredPredSamples ); 483 484 if ( uiDirMode == PLANAR_IDX ) 485 { 486 xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); 487 } 488 else 489 { 490 // Create the prediction 491 TComDataCU *const pcCU = rTu.getCU(); 492 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); 493 const Bool enableEdgeFilters = !(pcCU->isRDPCMEnabled(uiAbsPartIdx) && pcCU->getCUTransquantBypass(uiAbsPartIdx)); 494 #if O0043_BEST_EFFORT_DECODING 495 const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getStreamBitDepth(channelType); 496 #else 497 const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getBitDepth(channelType); 498 #endif 499 xPredIntraAng( channelsBitDepthForPrediction, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType, uiDirMode, enableEdgeFilters ); 500 501 if( uiDirMode == DC_IDX ) 502 { 503 xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType ); 504 } 505 } 506 } 507 508 } 509 510 #if NH_3D_DMM 511 Void TComPrediction::predIntraLumaDmm( TComDataCU* pcCU, UInt uiAbsPartIdx, DmmID dmmType, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight ) 512 { 371 513 assert( iWidth == iHeight ); 372 373 ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); 374 375 // get starting pixel in block 376 Int sw = 2 * iWidth + 1; 377 378 // Create the prediction 379 if ( uiDirMode == PLANAR_IDX ) 380 { 381 xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); 382 } 383 else 384 { 385 if ( (iWidth > 16) || (iHeight > 16) ) 386 { 387 xPredIntraAng(g_bitDepthY, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); 388 } 389 else 390 { 391 xPredIntraAng(g_bitDepthY, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, true ); 392 393 if( (uiDirMode == DC_IDX ) && bAbove && bLeft ) 394 { 395 xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight); 396 } 397 } 398 } 399 } 400 401 // Angular chroma 402 Void TComPrediction::predIntraChromaAng( Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft ) 403 { 404 Pel *pDst = piPred; 405 Int *ptrSrc = piSrc; 406 407 // get starting pixel in block 408 Int sw = 2 * iWidth + 1; 409 410 if ( uiDirMode == PLANAR_IDX ) 411 { 412 xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); 413 } 414 else 415 { 416 // Create the prediction 417 xPredIntraAng(g_bitDepthC, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); 418 } 419 } 420 421 #if H_3D_DIM 422 Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc, TComWedgelet* dmm4Segmentation ) 423 { 424 assert( iWidth == iHeight ); 425 assert( iWidth >= DIM_MIN_SIZE && iWidth <= DIM_MAX_SIZE ); 426 assert( isDimMode( uiIntraMode ) ); 427 428 UInt dimType = getDimType ( uiIntraMode ); 429 Bool isDmmMode = (dimType < DMM_NUM_TYPE); 430 431 Bool* biSegPattern = NULL; 432 UInt patternStride = 0; 433 434 // get partiton 435 #if H_3D_DIM_DMM 436 TComWedgelet* dmmSegmentation = NULL; 437 if( isDmmMode ) 438 { 439 switch( dimType ) 440 { 441 case( DMM1_IDX ): 442 { 443 dmmSegmentation = pcCU->isDMM1UpscaleMode((UInt)iWidth) ? 444 &(g_dmmWedgeLists[ g_aucConvertToBit[pcCU->getDMM1BasePatternWidth((UInt)iWidth)] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]) : 445 &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]); 446 } break; 447 case( DMM4_IDX ): 448 { 449 if( dmm4Segmentation == NULL ) 450 { 451 dmmSegmentation = new TComWedgelet( iWidth, iHeight ); 452 xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation ); 453 } 454 else 455 { 456 xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmm4Segmentation ); 457 dmmSegmentation = dmm4Segmentation; 458 } 459 } break; 460 default: assert(0); 461 } 462 assert( dmmSegmentation ); 463 if( dimType == DMM1_IDX && pcCU->isDMM1UpscaleMode((UInt)iWidth) ) 464 { 465 biSegPattern = dmmSegmentation->getScaledPattern((UInt)iWidth); 466 patternStride = iWidth; 467 } 468 else 469 { 470 biSegPattern = dmmSegmentation->getPattern(); 471 patternStride = dmmSegmentation->getStride (); 472 } 473 } 474 #endif 514 assert( iWidth >= DMM_MIN_SIZE && iWidth <= DMM_MAX_SIZE ); 515 #if NH_3D_SDC_INTRA 516 assert( !pcCU->getSDCFlag( uiAbsPartIdx ) ); 517 #endif 518 519 // get partition 520 Bool* biSegPattern = new Bool[ (UInt)(iWidth*iHeight) ]; 521 UInt patternStride = (UInt)iWidth; 522 switch( dmmType ) 523 { 524 case( DMM1_IDX ): { (getWedgeListScaled( (UInt)iWidth )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( (UInt)iWidth, biSegPattern ); } break; 525 case( DMM4_IDX ): { predContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, biSegPattern ); } break; 526 default: assert(0); 527 } 475 528 476 529 // get predicted partition values 477 assert( biSegPattern ); 478 Int* piMask = NULL; 479 piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering 480 assert( piMask ); 481 Int maskStride = 2*iWidth + 1; 482 Int* ptrSrc = piMask+maskStride+1; 483 Pel predDC1 = 0; Pel predDC2 = 0; 484 xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 ); 530 Pel predDC1 = 0, predDC2 = 0; 531 predBiSegDCs( pcCU, uiAbsPartIdx, iWidth, iHeight, biSegPattern, patternStride, predDC1, predDC2 ); 485 532 486 533 // set segment values with deltaDC offsets 487 Pel segDC1 = 0; 488 Pel segDC2 = 0; 489 if( !pcCU->getSDCFlag( uiAbsPartIdx ) ) 490 { 491 Pel deltaDC1 = pcCU->getDimDeltaDC( dimType, 0, uiAbsPartIdx ); 492 Pel deltaDC2 = pcCU->getDimDeltaDC( dimType, 1, uiAbsPartIdx ); 493 #if H_3D_DIM_DMM 494 if( isDmmMode ) 495 { 496 #if H_3D_DIM_DLT 497 segDC1 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 ); 498 segDC2 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 ); 534 Pel segDC1 = 0, segDC2 = 0; 535 Pel deltaDC1 = pcCU->getDmmDeltaDC( dmmType, 0, uiAbsPartIdx ); 536 Pel deltaDC2 = pcCU->getDmmDeltaDC( dmmType, 1, uiAbsPartIdx ); 537 #if NH_3D_DLT 538 segDC1 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 ) + deltaDC1 ); 539 segDC2 = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 ) + deltaDC2 ); 499 540 #else 500 segDC1 = ClipY( predDC1 + deltaDC1 ); 501 segDC2 = ClipY( predDC2 + deltaDC2 ); 502 #endif 503 } 504 #endif 505 } 506 else 507 { 508 segDC1 = predDC1; 509 segDC2 = predDC2; 510 } 541 segDC1 = ClipBD( predDC1 + deltaDC1, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) ); 542 segDC2 = ClipBD( predDC2 + deltaDC2, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) ); 543 #endif 511 544 512 545 // set prediction signal 513 546 Pel* pDst = piPred; 514 xAssignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 ); 515 pcCU->setDmmPredictor(segDC1, 0); 516 pcCU->setDmmPredictor(segDC2, 1); 517 518 #if H_3D_DIM_DMM 519 if( dimType == DMM4_IDX && dmm4Segmentation == NULL ) 520 { 521 dmmSegmentation->destroy(); 522 delete dmmSegmentation; 523 } 524 #endif 525 } 526 #endif 527 528 /** Function for checking identical motion. 529 * \param TComDataCU* pcCU 530 * \param UInt PartAddr 547 assignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 ); 548 549 delete[] biSegPattern; 550 } 551 #endif 552 553 /** Check for identical motion in both motion vector direction of a bi-directional predicted CU 554 * \returns true, if motion vectors and reference pictures match 531 555 */ 532 556 Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) … … 538 562 Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC(); 539 563 Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC(); 540 #if H_3D_ARP564 #if NH_3D_ARP 541 565 if(!pcCU->getARPW(PartAddr) && RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr)) 542 566 #else … … 551 575 } 552 576 553 #if H_3D_SPIVMP577 #if NH_3D_SPIVMP 554 578 Void TComPrediction::xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr ) 555 579 { … … 560 584 pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]); 561 585 } 586 #if H_3D_ARP || NH_3D_ALIGN_SPIVMP_RP // check this! 562 587 if( pcCU->getARPW( uiPartAddr ) != 0 ) 563 588 { 564 589 return; 565 590 } 591 #endif 566 592 567 593 // horizontal sub-PU merge … … 637 663 #endif 638 664 639 #if H_3D_DBBP665 #if NH_3D_DBBP 640 666 PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU) 641 667 { 668 const TComSPS* sps = pcCU->getSlice()->getSPS(); 669 UInt uiMaxCUWidth = sps->getMaxCUWidth(); 670 UInt uiMaxCUHeight = sps->getMaxCUHeight(); 671 642 672 // find virtual partitioning for this CU based on depth block 643 673 // segmentation of texture block --> mask IDs … … 647 677 Int iSumDepth = 0; 648 678 Int iSubSample = 4; 649 Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth( );650 Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight( );679 Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(COMPONENT_Y); 680 Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(COMPONENT_Y); 651 681 TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag( ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV; 652 682 if( pcCU->getSlice()->getDepthRefinementFlag( ) ) … … 654 684 cDv.setVer(0); 655 685 } 656 Int iBlkX = ( pcCU->get Addr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2);657 Int iBlkY = ( pcCU->get Addr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2);686 Int iBlkX = ( pcCU->getCtuRsAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getHor()+2)>>2); 687 Int iBlkY = ( pcCU->getCtuRsAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getVer()+2)>>2); 658 688 659 689 UInt t=0; … … 742 772 } 743 773 744 PartSize matchedPartSize = SIZE_NONE;774 PartSize matchedPartSize = NUMBER_OF_PART_SIZES; 745 775 746 776 Int iMaxMatchSum = 0; … … 757 787 } 758 788 759 AOF( matchedPartSize != SIZE_NONE);789 AOF( matchedPartSize != NUMBER_OF_PART_SIZES ); 760 790 761 791 return matchedPartSize; … … 764 794 Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU) 765 795 { 796 const TComSPS* sps = pcCU->getSlice()->getSPS(); 797 UInt uiMaxCUWidth = sps->getMaxCUWidth(); 798 UInt uiMaxCUHeight = sps->getMaxCUHeight(); 799 766 800 // segmentation of texture block --> mask IDs 767 801 Pel* pDepthBlockStart = pDepthPels; … … 775 809 iSumDepth = pDepthPels[ 0 ]; 776 810 777 Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth( );778 Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight( );811 Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(COMPONENT_Y); 812 Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(COMPONENT_Y); 779 813 TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag( ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV; 780 814 if( pcCU->getSlice()->getDepthRefinementFlag( ) ) … … 782 816 cDv.setVer(0); 783 817 } 784 Int iBlkX = ( pcCU->get Addr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2);785 Int iBlkY = ( pcCU->get Addr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2);818 Int iBlkX = ( pcCU->getCtuRsAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getHor()+2)>>2); 819 Int iBlkY = ( pcCU->getCtuRsAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getVer()+2)>>2); 786 820 if (iBlkX>(Int)(iPictureWidth - uiWidth)) 787 821 { … … 898 932 } 899 933 900 Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize )901 { 902 Pel* piSrc[2] = {pInYuv[0]->get LumaAddr(uiPartAddr), pInYuv[1]->getLumaAddr(uiPartAddr)};903 UInt uiSrcStride = pInYuv[0]->getStride( );904 Pel* piDst = pOutYuv->get LumaAddr(uiPartAddr);905 UInt uiDstStride = pOutYuv->getStride( );934 Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize, Int bitDepthY ) 935 { 936 Pel* piSrc[2] = {pInYuv[0]->getAddr(COMPONENT_Y, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Y, uiPartAddr)}; 937 UInt uiSrcStride = pInYuv[0]->getStride(COMPONENT_Y); 938 Pel* piDst = pOutYuv->getAddr(COMPONENT_Y, uiPartAddr); 939 UInt uiDstStride = pOutYuv->getStride(COMPONENT_Y); 906 940 907 941 UInt uiMaskStride= MAX_CU_SIZE; … … 942 976 right = (x==uiWidth-1) ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x+1]; 943 977 944 piDst[x] = (l!=r) ? Clip Y( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 )) : tmpTar[y*uiWidth+x];978 piDst[x] = (l!=r) ? ClipBD( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 ), bitDepthY) : tmpTar[y*uiWidth+x]; 945 979 } 946 980 piDst += uiDstStride; … … 960 994 bottom = (y==uiHeight-1) ? tmpTar[y*uiWidth+x] : tmpTar[(y+1)*uiWidth+x]; 961 995 962 piDst[x] = (t!=b) ? Clip Y( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 )) : tmpTar[y*uiWidth+x];996 piDst[x] = (t!=b) ? ClipBD( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 ), bitDepthY) : tmpTar[y*uiWidth+x]; 963 997 } 964 998 piDst += uiDstStride; … … 973 1007 974 1008 // now combine chroma 975 Pel* piSrcU[2] = { pInYuv[0]->get CbAddr(uiPartAddr), pInYuv[1]->getCbAddr(uiPartAddr) };976 Pel* piSrcV[2] = { pInYuv[0]->get CrAddr(uiPartAddr), pInYuv[1]->getCrAddr(uiPartAddr) };977 UInt uiSrcStrideC = pInYuv[0]->get CStride();978 Pel* piDstU = pOutYuv->get CbAddr(uiPartAddr);979 Pel* piDstV = pOutYuv->get CrAddr(uiPartAddr);980 UInt uiDstStrideC = pOutYuv->get CStride();1009 Pel* piSrcU[2] = { pInYuv[0]->getAddr(COMPONENT_Cb, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Cb, uiPartAddr) }; 1010 Pel* piSrcV[2] = { pInYuv[0]->getAddr(COMPONENT_Cr, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Cr, uiPartAddr) }; 1011 UInt uiSrcStrideC = pInYuv[0]->getStride(COMPONENT_Cb); 1012 Pel* piDstU = pOutYuv->getAddr(COMPONENT_Cb, uiPartAddr); 1013 Pel* piDstV = pOutYuv->getAddr(COMPONENT_Cr, uiPartAddr); 1014 UInt uiDstStrideC = pOutYuv->getStride(COMPONENT_Cb); 981 1015 UInt uiWidthC = uiWidth >> 1; 982 1016 UInt uiHeightC = uiHeight >> 1; … … 1024 1058 if (l!=r) 1025 1059 { 1026 filSrcU = Clip C( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ));1027 filSrcV = Clip C( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ));1060 filSrcU = ClipBD( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ), bitDepthY); 1061 filSrcV = ClipBD( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ), bitDepthY); 1028 1062 } 1029 1063 else … … 1057 1091 if (t!=b) 1058 1092 { 1059 filSrcU = Clip C( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 ));1060 filSrcV = Clip C( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 ));1093 filSrcU = ClipBD( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 ), bitDepthY); 1094 filSrcV = ClipBD( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 ), bitDepthY); 1061 1095 } 1062 1096 else … … 1095 1129 { 1096 1130 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); 1097 #if H_3D_VSP1131 #if NH_3D_VSP 1098 1132 if ( pcCU->getVSPFlag(uiPartAddr) == 0) 1099 1133 { … … 1116 1150 else 1117 1151 { 1118 #if H_3D_SPIVMP1152 #if NH_3D_SPIVMP 1119 1153 if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0) 1120 1154 { … … 1156 1190 xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); 1157 1191 } 1158 #if H_3D_SPIVMP1159 } 1160 #endif 1161 } 1162 #if H_3D_VSP1192 #if NH_3D_SPIVMP 1193 } 1194 #endif 1195 } 1196 #if NH_3D_VSP 1163 1197 } 1164 1198 else … … 1181 1215 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); 1182 1216 1183 #if H_3D_VSP1217 #if NH_3D_VSP 1184 1218 if ( pcCU->getVSPFlag(uiPartAddr) == 0 ) 1185 1219 { 1186 1220 #endif 1187 if ( eRefPicList != REF_PIC_LIST_X ) 1188 { 1189 if( pcCU->getSlice()->getPPS()->getUseWP()) 1190 { 1191 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); 1192 } 1193 else 1194 { 1195 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); 1196 } 1197 if ( pcCU->getSlice()->getPPS()->getUseWP() ) 1198 { 1199 xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); 1200 } 1221 if ( eRefPicList != REF_PIC_LIST_X ) 1222 { 1223 if( pcCU->getSlice()->getPPS()->getUseWP()) 1224 { 1225 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true ); 1201 1226 } 1202 1227 else 1203 1228 { 1204 #if H_3D_SPIVMP 1205 if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) 1229 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); 1230 } 1231 if ( pcCU->getSlice()->getPPS()->getUseWP() ) 1232 { 1233 xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred ); 1234 } 1235 } 1236 else 1237 { 1238 #if NH_3D_SPIVMP 1239 if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) 1206 1240 { 1207 1241 Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; … … 1241 1275 xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred ); 1242 1276 } 1243 #if H_3D_SPIVMP1244 1245 #endif 1246 1247 #if H_3D_VSP1277 #if NH_3D_SPIVMP 1278 } 1279 #endif 1280 } 1281 #if NH_3D_VSP 1248 1282 } 1249 1283 else … … 1263 1297 } 1264 1298 1265 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* & rpcYuvPred, Bool bi )1299 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* pcYuvPred, Bool bi ) 1266 1300 { 1267 1301 Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); assert (iRefIdx >= 0); 1268 1302 TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); 1269 1303 pcCU->clipMv(cMv); 1270 #if H_MV1304 #if NH_MV 1271 1305 pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx ); 1272 1306 #endif 1273 #if H_3D_ARP 1274 if(pcCU->getARPW( uiPartAddr ) > 0 && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC()) 1275 { 1276 xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi ); 1307 #if NH_3D_ARP 1308 if( pcCU->getARPW( uiPartAddr ) > 0 ) 1309 { 1310 if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC() ) 1311 { 1312 xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , pcYuvPred , bi ); 1277 1313 } 1278 1314 else 1279 1315 { 1280 if( pcCU->getARPW( uiPartAddr ) > 0 1281 && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N 1282 && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() 1283 ) 1284 { 1285 xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi ); 1316 xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, bi ); 1317 } 1286 1318 } 1287 1319 else 1288 1320 { 1289 1321 #endif 1290 #if H_3D_IC 1291 Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ); 1292 xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi 1293 #if H_3D_ARP 1294 , false 1295 #endif 1296 , bICFlag ); 1297 bICFlag = bICFlag && (iWidth > 8); 1298 xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi 1299 #if H_3D_ARP 1322 for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++) 1323 { 1324 const ComponentID compID=ComponentID(comp); 1325 #if NH_3D_IC 1326 Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ) && ( isLuma(compID) || (iWidth > 8) ); 1327 xPredInterBlk(compID, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) 1328 #if NH_3D_ARP 1300 1329 , false 1301 1330 #endif 1302 1331 , bICFlag ); 1303 1332 #else 1304 xPredInterLumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); 1305 xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); 1306 #endif 1307 #if H_3D_ARP 1308 } 1309 } 1310 #endif 1311 } 1312 1313 #if H_3D_VSP 1333 xPredInterBlk (compID, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) ); 1334 #endif 1335 } 1336 #if NH_3D_ARP 1337 } 1338 #endif 1339 } 1340 1341 #if NH_3D_VSP 1314 1342 Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) 1315 1343 { … … 1332 1360 Void TComPrediction::xPredInterUniSubPU( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU, Int heightSubPU ) 1333 1361 { 1334 UInt numPartsInLine = pcCU->getPic()->getNumPartIn Width();1362 UInt numPartsInLine = pcCU->getPic()->getNumPartInCtuWidth(); 1335 1363 UInt horiNumPartsInSubPU = widthSubPU >> 2; 1336 1364 UInt vertNumPartsInSubPU = (heightSubPU >> 2) * numPartsInLine; … … 1348 1376 pcCU->clipMv(cMv); 1349 1377 1350 xPredInter LumaBlk ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi);1351 xPredInter ChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi);1352 1353 } 1354 } 1355 } 1356 1357 #endif 1358 1359 #if H_3D_ARP1360 Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi , TComMvField * pNewMvFiled)1361 { 1362 Int iRefIdx = p NewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );1363 TComMv cMv = p NewMvFiled ? pNewMvFiled->getMv() : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );1378 xPredInterBlk( COMPONENT_Y, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) ); 1379 xPredInterBlk( COMPONENT_Cb, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) ); 1380 xPredInterBlk( COMPONENT_Cr, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) ); 1381 } 1382 } 1383 } 1384 #endif 1385 1386 #if NH_3D_ARP 1387 //temporal ARP 1388 Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) 1389 { 1390 Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); 1391 TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); 1364 1392 Bool bTobeScaled = false; 1365 1393 TComPic* pcPicYuvBaseCol = NULL; 1366 1394 TComPic* pcPicYuvBaseRef = NULL; 1367 1395 1368 #if H_3D_NBDV1396 #if NH_3D_NBDV 1369 1397 DisInfo cDistparity; 1370 1398 cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV; … … 1375 1403 UChar dW = pcCU->getARPW ( uiPartAddr ); 1376 1404 1377 {1378 1405 Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList); 1379 if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() ) 1380 { 1381 bTobeScaled = true; 1382 } 1383 1384 pcPicYuvBaseCol = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(), cDistparity.m_aVIdxCan ); 1385 1386 pcPicYuvBaseRef = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan ); 1387 1388 if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan)) 1406 if (arpRefIdx < 0 || !pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan)) 1389 1407 { 1390 1408 dW = 0; … … 1393 1411 else 1394 1412 { 1395 assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() ); 1413 if( arpRefIdx != iRefIdx ) 1414 { 1415 bTobeScaled = true; 1416 } 1417 pcPicYuvBaseCol = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(), cDistparity.m_aVIdxCan ); 1418 pcPicYuvBaseRef = pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan ); 1396 1419 } 1397 1420 … … 1400 1423 Int iCurrPOC = pcCU->getSlice()->getPOC(); 1401 1424 Int iColRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx ); 1402 Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, 0);1425 Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, arpRefIdx ); 1403 1426 Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC); 1404 1427 if ( iScale != 4096 ) … … 1406 1429 cMv = cMv.scaleMv( iScale ); 1407 1430 } 1408 iRefIdx = 0; 1409 } 1431 iRefIdx = arpRefIdx; 1410 1432 } 1411 1433 1412 1434 pcCU->clipMv(cMv); 1413 1435 TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(); 1414 xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true ); 1415 xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true ); 1436 1437 for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++) 1438 { 1439 const ComponentID compID=ComponentID(comp); 1440 xPredInterBlk ( compID, pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true ); 1441 } 1416 1442 1417 1443 if( dW > 0 ) … … 1429 1455 pcCU->clipMv( cNBDV ); 1430 1456 1431 pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec(); 1432 xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true ); 1433 if (iWidth > 8) 1434 xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true ); 1457 TComPicYuv* pcPicYuvBaseColRec = pcPicYuvBaseCol->getPicYuvRec(); 1458 TComPicYuv* pcPicYuvBaseRefRec = pcPicYuvBaseRef->getPicYuvRec(); 1435 1459 1436 pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec(); 1437 xPredInterLumaBlk ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true ); 1438 1439 if (iWidth > 8) 1440 xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true ); 1460 UInt uiCompNum = ( iWidth > 8 ) ? 3: 1; 1461 for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++) 1462 { 1463 const ComponentID compID=ComponentID(comp); 1464 xPredInterBlk ( compID, pcCU, pcPicYuvBaseColRec, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true ); 1465 xPredInterBlk ( compID, pcCU, pcPicYuvBaseRefRec, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true ); 1466 } 1441 1467 1442 1468 pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight ); … … 1446 1472 pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); 1447 1473 } 1448 rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi );1474 rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() ); 1449 1475 } 1450 1476 } … … 1455 1481 TComMv cDMv = pcCU->getCUMvField( eBaseRefPicList )->getMv( uiPartAddr ); 1456 1482 TComPic* pcPicYuvBaseCol = pcCU->getSlice()->getRefPic( eBaseRefPicList, iRefIdx ); 1457 TComPicYuv* pcYuvBaseCol = pcPicYuvBaseCol->getPicYuvRec();1458 Int uiLCUAddr,uiAbsPartAddr;1459 1483 Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2 + ((cDMv.getHor() + 2)>>2); 1460 1484 Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2); … … 1462 1486 irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX); 1463 1487 irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); 1464 pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr); 1465 TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr ); 1488 1489 Int uiLCUAddr,uiAbsPartAddr; 1490 pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr); 1491 TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr ); 1466 1492 1467 1493 TComPic* pcPicYuvBaseTRef = NULL; … … 1515 1541 } 1516 1542 1517 Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled ) 1543 //inter-view ARP 1544 Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi ) 1518 1545 { 1519 1546 Int iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); … … 1528 1555 Bool bTMVAvai = false; 1529 1556 TComMv cBaseTMV; 1530 if( pNewMvFiled ) 1531 { 1532 iRefIdx = pNewMvFiled->getRefIdx(); 1533 cDMv = pNewMvFiled->getMv(); 1534 } 1557 1535 1558 pcCU->clipMv(cTempDMv); 1536 1559 1537 assert(dW > 0);1538 if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex()))1539 {1540 dW = 0;1541 }1542 Int uiLCUAddr,uiAbsPartAddr;1543 1560 Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2 + ((cDMv.getHor() + 2)>>2); 1544 1561 Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2); … … 1546 1563 irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX); 1547 1564 irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); 1548 pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr); 1549 TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr ); 1565 1566 Int uiLCUAddr,uiAbsPartAddr; 1567 pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr); 1568 TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr ); 1550 1569 if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getIsDepth() ) 1551 1570 { … … 1618 1637 RefPicList eRefPicListCurr = RefPicList(iList); 1619 1638 Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr); 1620 if( iRef != -1 )1639 if( iRef != -1 && pcCU->getSlice()->getArpRefPicAvailable( eRefPicListCurr, pcPicYuvBaseCol->getViewIndex())) 1621 1640 { 1622 1641 pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); … … 1652 1671 } 1653 1672 1654 xPredInterLumaBlk ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ), bTMVAvai); 1655 xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ), bTMVAvai); 1656 1657 if( dW > 0 && bTMVAvai ) 1658 { 1673 for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++) 1674 { 1675 const ComponentID compID=ComponentID(comp); 1676 xPredInterBlk ( compID, pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), bTMVAvai ); 1677 } 1678 1679 if( dW > 0 ) 1680 { 1681 assert ( bTMVAvai ); 1659 1682 TComYuv* pYuvCurrTRef = &m_acYuvPredBase[0]; 1660 1683 TComYuv* pYuvBaseTRef = &m_acYuvPredBase[1]; … … 1670 1693 pYuvCurrTRef->clear(); pYuvBaseTRef->clear(); 1671 1694 } 1672 xPredInterLumaBlk ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true, true); 1673 1674 if (iWidth > 8) 1675 xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true, true); 1676 1677 xPredInterLumaBlk ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, true, true); 1678 1679 if (iWidth > 8) 1680 xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, true, true); 1695 1696 UInt uiCompNum = ( iWidth > 8 ) ? 3: 1; 1697 for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++) 1698 { 1699 const ComponentID compID=ComponentID(comp); 1700 xPredInterBlk ( compID, pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true ); 1701 xPredInterBlk ( compID, pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true ); 1702 } 1681 1703 1682 1704 pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight ); … … 1685 1707 pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW ); 1686 1708 } 1687 rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi );1688 } 1689 } 1690 #endif 1691 1692 Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* & rpcYuvPred )1709 rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() ); 1710 } 1711 } 1712 #endif 1713 1714 Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvPred ) 1693 1715 { 1694 1716 TComYuv* pcMbYuv; 1695 Int iRefIdx[ 2] = {-1, -1};1696 1697 for ( Int iRefList = 0; iRefList < 2; iRefList++ )1698 { 1699 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);1700 iRefIdx[ iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );1701 1702 if ( iRefIdx[ iRefList] < 0 )1717 Int iRefIdx[NUM_REF_PIC_LIST_01] = {-1, -1}; 1718 1719 for ( UInt refList = 0; refList < NUM_REF_PIC_LIST_01; refList++ ) 1720 { 1721 RefPicList eRefPicList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0); 1722 iRefIdx[refList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr ); 1723 1724 if ( iRefIdx[refList] < 0 ) 1703 1725 { 1704 1726 continue; 1705 1727 } 1706 1728 1707 assert( iRefIdx[ iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) );1708 1709 pcMbYuv = &m_acYuvPred[ iRefList];1729 assert( iRefIdx[refList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) ); 1730 1731 pcMbYuv = &m_acYuvPred[refList]; 1710 1732 if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) 1711 1733 { … … 1714 1736 else 1715 1737 { 1716 if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || 1717 ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) )1738 if ( ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) || 1739 ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) ) 1718 1740 { 1719 1741 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true ); … … 1726 1748 } 1727 1749 1728 if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE )1729 { 1730 xWeightedPredictionBi( pcCU, &m_acYuvPred[ 0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );1731 } 1750 if ( pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE ) 1751 { 1752 xWeightedPredictionBi( pcCU, &m_acYuvPred[REF_PIC_LIST_0], &m_acYuvPred[REF_PIC_LIST_1], iRefIdx[REF_PIC_LIST_0], iRefIdx[REF_PIC_LIST_1], uiPartAddr, iWidth, iHeight, pcYuvPred ); 1753 } 1732 1754 else if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE ) 1733 1755 { 1734 xWeightedPredictionUni( pcCU, &m_acYuvPred[ 0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred );1756 xWeightedPredictionUni( pcCU, &m_acYuvPred[REF_PIC_LIST_0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred ); 1735 1757 } 1736 1758 else 1737 1759 { 1738 xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); 1739 } 1740 } 1741 1742 #if H_3D_VSP 1743 1760 xWeightedAverage( &m_acYuvPred[REF_PIC_LIST_0], &m_acYuvPred[REF_PIC_LIST_1], iRefIdx[REF_PIC_LIST_0], iRefIdx[REF_PIC_LIST_1], uiPartAddr, iWidth, iHeight, pcYuvPred, pcCU->getSlice()->getSPS()->getBitDepths() ); 1761 } 1762 } 1763 1764 #if NH_3D_VSP 1744 1765 Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred ) 1745 1766 { … … 1763 1784 } 1764 1785 1765 xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); 1766 } 1767 1786 xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, pcCU->getSlice()->getSPS()->getBitDepths() ); 1787 } 1768 1788 #endif 1769 1789 1770 1790 /** 1771 * \brief Generate motion-compensated lumablock1791 * \brief Generate motion-compensated block 1772 1792 * 1773 * \param cu Pointer to current CU 1774 * \param refPic Pointer to reference picture 1775 * \param partAddr Address of block within CU 1776 * \param mv Motion vector 1777 * \param width Width of block 1778 * \param height Height of block 1779 * \param dstPic Pointer to destination picture 1780 * \param bi Flag indicating whether bipred is used 1793 * \param compID Colour component ID 1794 * \param cu Pointer to current CU 1795 * \param refPic Pointer to reference picture 1796 * \param partAddr Address of block within CU 1797 * \param mv Motion vector 1798 * \param width Width of block 1799 * \param height Height of block 1800 * \param dstPic Pointer to destination picture 1801 * \param bi Flag indicating whether bipred is used 1802 * \param bitDepth Bit depth 1781 1803 */ 1782 Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi 1783 #if H_3D_ARP 1804 1805 1806 Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth 1807 #if NH_3D_ARP 1784 1808 , Bool filterType 1785 1809 #endif 1786 #if H_3D_IC1810 #if NH_3D_IC 1787 1811 , Bool bICFlag 1788 1812 #endif 1789 ) 1790 { 1791 Int refStride = refPic->getStride(); 1792 Int refOffset = ( mv->getHor() >> 2 ) + ( mv->getVer() >> 2 ) * refStride; 1793 Pel *ref = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; 1794 1795 Int dstStride = dstPic->getStride(); 1796 Pel *dst = dstPic->getLumaAddr( partAddr ); 1797 1798 Int xFrac = mv->getHor() & 0x3; 1799 Int yFrac = mv->getVer() & 0x3; 1800 1801 #if H_3D_IC 1813 ) 1814 { 1815 Int refStride = refPic->getStride(compID); 1816 Int dstStride = dstPic->getStride(compID); 1817 Int shiftHor=(2+refPic->getComponentScaleX(compID)); 1818 Int shiftVer=(2+refPic->getComponentScaleY(compID)); 1819 1820 Int refOffset = (mv->getHor() >> shiftHor) + (mv->getVer() >> shiftVer) * refStride; 1821 1822 Pel* ref = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset; 1823 1824 Pel* dst = dstPic->getAddr( compID, partAddr ); 1825 1826 Int xFrac = mv->getHor() & ((1<<shiftHor)-1); 1827 Int yFrac = mv->getVer() & ((1<<shiftVer)-1); 1828 1829 #if NH_3D_INTEGER_MV_DEPTH 1802 1830 if( cu->getSlice()->getIsDepth() ) 1803 1831 { 1804 1832 refOffset = mv->getHor() + mv->getVer() * refStride; 1805 ref = refPic->get LumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset;1833 ref = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset; 1806 1834 xFrac = 0; 1807 1835 yFrac = 0; 1808 1836 } 1809 1837 #endif 1838 1839 UInt cxWidth = width >> refPic->getComponentScaleX(compID); 1840 UInt cxHeight = height >> refPic->getComponentScaleY(compID); 1841 1842 const ChromaFormat chFmt = cu->getPic()->getChromaFormat(); 1843 1810 1844 if ( yFrac == 0 ) 1811 1845 { 1812 #if H_3D_IC1813 m_if.filterHor Luma( ref, refStride, dst, dstStride, width, height, xFrac, !bi || bICFlag1846 #if NH_3D_IC 1847 m_if.filterHor(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag, chFmt, bitDepth 1814 1848 #else 1815 m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi 1816 #endif 1817 #if H_3D_ARP 1818 , filterType 1819 #endif 1820 ); 1821 } 1822 else if ( xFrac == 0 ) 1823 { 1824 #if H_3D_IC 1825 m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag 1826 #else 1827 m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi 1828 #endif 1829 #if H_3D_ARP 1830 , filterType 1831 #endif 1832 ); 1833 } 1834 else 1835 { 1836 Int tmpStride = m_filteredBlockTmp[0].getStride(); 1837 Short *tmp = m_filteredBlockTmp[0].getLumaAddr(); 1838 1839 Int filterSize = NTAPS_LUMA; 1840 Int halfFilterSize = ( filterSize >> 1 ); 1841 1842 m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false 1843 #if H_3D_ARP 1849 m_if.filterHor(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth 1850 #endif 1851 #if NH_3D_ARP 1844 1852 , filterType 1845 1853 #endif 1846 ); 1847 #if H_3D_IC 1848 m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi || bICFlag 1854 ); 1855 } 1856 else if ( xFrac == 0 ) 1857 { 1858 #if NH_3D_IC 1859 m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag, chFmt, bitDepth 1849 1860 #else 1850 m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi 1851 #endif 1852 #if H_3D_ARP 1861 m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth 1862 #endif 1863 #if NH_3D_ARP 1864 , filterType 1865 #endif 1866 ); 1867 } 1868 else 1869 { 1870 Int tmpStride = m_filteredBlockTmp[0].getStride(compID); 1871 Pel* tmp = m_filteredBlockTmp[0].getAddr(compID); 1872 1873 const Int vFilterSize = isLuma(compID) ? NTAPS_LUMA : NTAPS_CHROMA; 1874 1875 m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false, chFmt, bitDepth 1876 #if NH_3D_ARP 1853 1877 , filterType 1854 1878 #endif 1855 ); 1856 } 1857 1858 #if H_3D_IC 1879 ); 1880 #if NH_3D_IC 1881 m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight, yFrac, false, !bi || bICFlag, chFmt, bitDepth 1882 #else 1883 m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight, yFrac, false, !bi, chFmt, bitDepth 1884 #endif 1885 #if NH_3D_ARP 1886 , filterType 1887 #endif 1888 ); 1889 } 1890 1891 #if NH_3D_IC 1859 1892 if( bICFlag ) 1860 1893 { 1861 1894 Int a, b, i, j; 1862 1895 const Int iShift = IC_CONST_SHIFT; 1863 1864 xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA ); 1865 1866 1867 for ( i = 0; i < height; i++ )1868 { 1869 for ( j = 0; j < width; j++ )1870 { 1871 dst[j] = Clip3( 0, ( 1 << g_bitDepthY) - 1, ( ( a*dst[j] ) >> iShift ) + b );1896 Pel *dst2 = dst; 1897 1898 xGetLLSICPrediction( compID, cu, mv, refPic, a, b, bitDepth ); 1899 1900 for ( i = 0; i < cxHeight; i++ ) 1901 { 1902 for ( j = 0; j < cxWidth; j++ ) 1903 { 1904 dst[j] = Clip3( 0, ( 1 << bitDepth ) - 1, ( ( a*dst[j] ) >> iShift ) + b ); 1872 1905 } 1873 1906 dst += dstStride; … … 1876 1909 if(bi) 1877 1910 { 1878 Pel *dst2 = dstPic->getLumaAddr( partAddr ); 1879 Int shift = IF_INTERNAL_PREC - g_bitDepthY; 1880 for (i = 0; i < height; i++) 1881 { 1882 for (j = 0; j < width; j++) 1883 { 1884 Short val = dst2[j] << shift; 1885 dst2[j] = val - (Short)IF_INTERNAL_OFFS; 1911 Int shift = IF_INTERNAL_PREC - bitDepth; 1912 for (i = 0; i < cxHeight; i++) 1913 { 1914 for (j = 0; j < cxWidth; j++) 1915 { 1916 Pel val = dst2[j] << shift; 1917 dst2[j] = val - (Pel)IF_INTERNAL_OFFS; 1886 1918 } 1887 1919 dst2 += dstStride; … … 1890 1922 } 1891 1923 #endif 1892 } 1893 1894 /** 1895 * \brief Generate motion-compensated chroma block 1896 * 1897 * \param cu Pointer to current CU 1898 * \param refPic Pointer to reference picture 1899 * \param partAddr Address of block within CU 1900 * \param mv Motion vector 1901 * \param width Width of block 1902 * \param height Height of block 1903 * \param dstPic Pointer to destination picture 1904 * \param bi Flag indicating whether bipred is used 1905 */ 1906 Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi 1907 #if H_3D_ARP 1908 , Bool filterType 1909 #endif 1910 #if H_3D_IC 1911 , Bool bICFlag 1912 #endif 1913 ) 1914 { 1915 Int refStride = refPic->getCStride(); 1916 Int dstStride = dstPic->getCStride(); 1917 1918 Int refOffset = (mv->getHor() >> 3) + (mv->getVer() >> 3) * refStride; 1919 1920 Pel* refCb = refPic->getCbAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; 1921 Pel* refCr = refPic->getCrAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset; 1922 1923 Pel* dstCb = dstPic->getCbAddr( partAddr ); 1924 Pel* dstCr = dstPic->getCrAddr( partAddr ); 1925 1926 Int xFrac = mv->getHor() & 0x7; 1927 Int yFrac = mv->getVer() & 0x7; 1928 UInt cxWidth = width >> 1; 1929 UInt cxHeight = height >> 1; 1930 1931 Int extStride = m_filteredBlockTmp[0].getStride(); 1932 Short* extY = m_filteredBlockTmp[0].getLumaAddr(); 1933 1934 Int filterSize = NTAPS_CHROMA; 1935 1936 Int halfFilterSize = (filterSize>>1); 1937 1938 if ( yFrac == 0 ) 1939 { 1940 #if H_3D_IC 1941 m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag 1942 #else 1943 m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi 1944 #endif 1945 #if H_3D_ARP 1946 , filterType 1947 #endif 1948 ); 1949 #if H_3D_IC 1950 m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag 1951 #else 1952 m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi 1953 #endif 1954 #if H_3D_ARP 1955 , filterType 1956 #endif 1957 ); 1958 } 1959 else if ( xFrac == 0 ) 1960 { 1961 #if H_3D_IC 1962 m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag 1963 #else 1964 m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi 1965 #endif 1966 #if H_3D_ARP 1967 , filterType 1968 #endif 1969 ); 1970 #if H_3D_IC 1971 m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag 1972 #else 1973 m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi 1974 #endif 1975 #if H_3D_ARP 1976 , filterType 1977 #endif 1978 ); 1979 } 1980 else 1981 { 1982 m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false 1983 #if H_3D_ARP 1984 , filterType 1985 #endif 1986 ); 1987 #if H_3D_IC 1988 m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag 1989 #else 1990 m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi 1991 #endif 1992 #if H_3D_ARP 1993 , filterType 1994 #endif 1995 ); 1996 1997 m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize-1, xFrac, false 1998 #if H_3D_ARP 1999 , filterType 2000 #endif 2001 ); 2002 #if H_3D_IC 2003 m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi || bICFlag 2004 #else 2005 m_if.filterVerChroma(extY + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi 2006 #endif 2007 #if H_3D_ARP 2008 , filterType 2009 #endif 2010 ); 2011 } 2012 2013 #if H_3D_IC 2014 if( bICFlag ) 2015 { 2016 Int a, b, i, j; 2017 const Int iShift = IC_CONST_SHIFT; 2018 2019 xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb 2020 for ( i = 0; i < cxHeight; i++ ) 2021 { 2022 for ( j = 0; j < cxWidth; j++ ) 2023 { 2024 dstCb[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b ); 2025 } 2026 dstCb += dstStride; 2027 } 2028 xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr 2029 for ( i = 0; i < cxHeight; i++ ) 2030 { 2031 for ( j = 0; j < cxWidth; j++ ) 2032 { 2033 dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b ); 2034 } 2035 dstCr += dstStride; 2036 } 2037 2038 if(bi) 2039 { 2040 Pel* dstCb2 = dstPic->getCbAddr( partAddr ); 2041 Pel* dstCr2 = dstPic->getCrAddr( partAddr ); 2042 Int shift = IF_INTERNAL_PREC - g_bitDepthC; 2043 for (i = 0; i < cxHeight; i++) 2044 { 2045 for (j = 0; j < cxWidth; j++) 2046 { 2047 Short val = dstCb2[j] << shift; 2048 dstCb2[j] = val - (Short)IF_INTERNAL_OFFS; 2049 2050 val = dstCr2[j] << shift; 2051 dstCr2[j] = val - (Short)IF_INTERNAL_OFFS; 2052 } 2053 dstCb2 += dstStride; 2054 dstCr2 += dstStride; 2055 } 2056 } 2057 } 2058 #endif 2059 } 2060 2061 Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) 1924 1925 } 1926 1927 Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths 1928 ) 2062 1929 { 2063 1930 if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) 2064 1931 { 2065 rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight);1932 pcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, clipBitDepths ); 2066 1933 } 2067 1934 else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) 2068 1935 { 2069 pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight );1936 pcYuvSrc0->copyPartToPartYuv( pcYuvDst, uiPartIdx, iWidth, iHeight ); 2070 1937 } 2071 1938 else if ( iRefIdx0 < 0 && iRefIdx1 >= 0 ) 2072 1939 { 2073 pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight );1940 pcYuvSrc1->copyPartToPartYuv( pcYuvDst, uiPartIdx, iWidth, iHeight ); 2074 1941 } 2075 1942 } … … 2079 1946 { 2080 1947 AMVPInfo* pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo(); 1948 2081 1949 if( pcAMVPInfo->iN <= 1 ) 2082 1950 { … … 2094 1962 2095 1963 /** Function for deriving planar intra prediction. 2096 * \param pSrc pointer to reconstructed sample array 2097 * \param srcStride the stride of the reconstructed sample array 2098 * \param rpDst reference to pointer for the prediction sample array 2099 * \param dstStride the stride of the prediction sample array 2100 * \param width the width of the block 2101 * \param height the height of the block 1964 * \param pSrc pointer to reconstructed sample array 1965 * \param srcStride the stride of the reconstructed sample array 1966 * \param rpDst reference to pointer for the prediction sample array 1967 * \param dstStride the stride of the prediction sample array 1968 * \param width the width of the block 1969 * \param height the height of the block 1970 * \param channelType type of pel array (luma, chroma) 1971 * \param format chroma format 2102 1972 * 2103 1973 * This function derives the prediction samples for planar mode (intra coding). 2104 1974 */ 2105 Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) 2106 { 2107 assert(width == height); 2108 2109 Int k, l, bottomLeft, topRight; 2110 Int horPred; 1975 //NOTE: Bit-Limit - 24-bit source 1976 Void TComPrediction::xPredIntraPlanar( const Pel* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) 1977 { 1978 assert(width <= height); 1979 2111 1980 Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE]; 2112 UInt blkSize = width; 2113 UInt offset2D = width; 2114 UInt shift1D = g_aucConvertToBit[ width ] + 2; 2115 UInt shift2D = shift1D + 1; 1981 UInt shift1Dhor = g_aucConvertToBit[ width ] + 2; 1982 UInt shift1Dver = g_aucConvertToBit[ height ] + 2; 2116 1983 2117 1984 // Get left and above reference column and row 2118 for( k=0;k<blkSize+1;k++)1985 for(Int k=0;k<width+1;k++) 2119 1986 { 2120 1987 topRow[k] = pSrc[k-srcStride]; 1988 } 1989 1990 for (Int k=0; k < height+1; k++) 1991 { 2121 1992 leftColumn[k] = pSrc[k*srcStride-1]; 2122 1993 } 2123 1994 2124 1995 // Prepare intermediate variables used in interpolation 2125 bottomLeft = leftColumn[blkSize]; 2126 topRight = topRow[blkSize]; 2127 for (k=0;k<blkSize;k++) 2128 { 2129 bottomRow[k] = bottomLeft - topRow[k]; 2130 rightColumn[k] = topRight - leftColumn[k]; 2131 topRow[k] <<= shift1D; 2132 leftColumn[k] <<= shift1D; 2133 } 1996 Int bottomLeft = leftColumn[height]; 1997 Int topRight = topRow[width]; 1998 1999 for(Int k=0;k<width;k++) 2000 { 2001 bottomRow[k] = bottomLeft - topRow[k]; 2002 topRow[k] <<= shift1Dver; 2003 } 2004 2005 for(Int k=0;k<height;k++) 2006 { 2007 rightColumn[k] = topRight - leftColumn[k]; 2008 leftColumn[k] <<= shift1Dhor; 2009 } 2010 2011 const UInt topRowShift = 0; 2134 2012 2135 2013 // Generate prediction signal 2136 for (k=0;k<blkSize;k++) 2137 { 2138 horPred = leftColumn[k] + offset2D; 2139 for (l=0;l<blkSize;l++) 2140 { 2141 horPred += rightColumn[k]; 2142 topRow[l] += bottomRow[l]; 2143 rpDst[k*dstStride+l] = ( (horPred + topRow[l]) >> shift2D ); 2014 for (Int y=0;y<height;y++) 2015 { 2016 Int horPred = leftColumn[y] + width; 2017 for (Int x=0;x<width;x++) 2018 { 2019 horPred += rightColumn[y]; 2020 topRow[x] += bottomRow[x]; 2021 2022 Int vertPred = ((topRow[x] + topRowShift)>>topRowShift); 2023 rpDst[y*dstStride+x] = ( horPred + vertPred ) >> (shift1Dhor+1); 2144 2024 } 2145 2025 } … … 2149 2029 * \param pSrc pointer to reconstructed sample array 2150 2030 * \param iSrcStride the stride of the reconstructed sample array 2151 * \param rpDst reference to pointer for the prediction sample array2031 * \param pDst reference to pointer for the prediction sample array 2152 2032 * \param iDstStride the stride of the prediction sample array 2153 2033 * \param iWidth the width of the block 2154 2034 * \param iHeight the height of the block 2035 * \param channelType type of pel array (luma, chroma) 2155 2036 * 2156 2037 * This function performs filtering left and top edges of the prediction samples for DC mode (intra coding). 2157 2038 */ 2158 Void TComPrediction::xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ) 2159 { 2160 Pel* pDst = rpDst; 2039 Void TComPrediction::xDCPredFiltering( const Pel* pSrc, Int iSrcStride, Pel* pDst, Int iDstStride, Int iWidth, Int iHeight, ChannelType channelType ) 2040 { 2161 2041 Int x, y, iDstStride2, iSrcStride2; 2162 2042 2163 // boundary pixels processing 2164 pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); 2165 2166 for ( x = 1; x < iWidth; x++ ) 2167 { 2168 pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); 2169 } 2170 2171 for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) 2172 { 2173 pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); 2043 if (isLuma(channelType) && (iWidth <= MAXIMUM_INTRA_FILTERED_WIDTH) && (iHeight <= MAXIMUM_INTRA_FILTERED_HEIGHT)) 2044 { 2045 //top-left 2046 pDst[0] = (Pel)((pSrc[-iSrcStride] + pSrc[-1] + 2 * pDst[0] + 2) >> 2); 2047 2048 //top row (vertical filter) 2049 for ( x = 1; x < iWidth; x++ ) 2050 { 2051 pDst[x] = (Pel)((pSrc[x - iSrcStride] + 3 * pDst[x] + 2) >> 2); 2052 } 2053 2054 //left column (horizontal filter) 2055 for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride-1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) 2056 { 2057 pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); 2058 } 2174 2059 } 2175 2060 2176 2061 return; 2177 2062 } 2178 #if H_3D_IC 2063 2064 /* Static member function */ 2065 Bool TComPrediction::UseDPCMForFirstPassIntraEstimation(TComTU &rTu, const UInt uiDirMode) 2066 { 2067 return (rTu.getCU()->isRDPCMEnabled(rTu.GetAbsPartIdxTU()) ) && 2068 rTu.getCU()->getCUTransquantBypass(rTu.GetAbsPartIdxTU()) && 2069 (uiDirMode==HOR_IDX || uiDirMode==VER_IDX); 2070 } 2071 #if NH_3D_IC 2179 2072 /** Function for deriving the position of first non-zero binary bit of a value 2180 2073 * \param x input value … … 2206 2099 /** Function for deriving LM illumination compensation. 2207 2100 */ 2208 Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType)2101 Void TComPrediction::xGetLLSICPrediction( const ComponentID compID, TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, const Int bitDepth ) 2209 2102 { 2210 2103 TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec(); 2211 2104 Pel *pRec = NULL, *pRef = NULL; 2212 2105 UInt uiWidth, uiHeight, uiTmpPartIdx; 2213 Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride();2214 Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride();2106 Int iRecStride = pRecPic->getStride(compID); 2107 Int iRefStride = pRefPic->getStride(compID); 2215 2108 Int iRefOffset, iHor, iVer; 2216 2109 iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 ); 2217 2110 iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 ); 2218 if( eType != TEXT_LUMA)2111 if( !isLuma(compID) ) 2219 2112 { 2220 2113 iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 ); 2221 2114 iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 ); 2222 2115 } 2223 uiWidth = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 ) : ( pcCU->getWidth( 0 ) >> 1);2224 uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1);2116 uiWidth = pcCU->getWidth( 0 ) >> pRefPic->getComponentScaleX(compID); 2117 uiHeight = pcCU->getHeight( 0 ) >> pRefPic->getComponentScaleY(compID); 2225 2118 2226 2119 Int i, j, iCountShift = 0; 2227 2120 2228 // LLS parameters estimation -->2121 // LLS parameters estimation 2229 2122 2230 2123 Int x = 0, y = 0, xx = 0, xy = 0; 2231 Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12); 2232 2233 if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) ) 2124 Int precShift = std::max(0, bitDepth - 12); 2125 2126 UInt partAddr = 0; 2127 if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCtu() ) ) 2234 2128 { 2235 2129 iRefOffset = iHor + iVer * iRefStride - iRefStride; 2236 if( eType == TEXT_LUMA ) 2237 { 2238 pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2239 pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; 2240 } 2241 else if( eType == TEXT_CHROMA_U ) 2242 { 2243 pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2244 pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; 2245 } 2246 else 2247 { 2248 assert( eType == TEXT_CHROMA_V ); 2249 pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2250 pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride; 2251 } 2252 2130 pRef = pRefPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) + iRefOffset; 2131 pRec = pRecPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) - iRecStride; 2253 2132 for( j = 0; j < uiWidth; j+=2 ) 2254 2133 { 2255 2134 x += pRef[j]; 2256 2135 y += pRec[j]; 2257 if ( eType == TEXT_LUMA)2136 if( isLuma(compID) ) 2258 2137 { 2259 2138 xx += (pRef[j] * pRef[j])>>precShift; … … 2264 2143 } 2265 2144 2266 if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInC U() ) )2145 if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCtu() ) ) 2267 2146 { 2268 2147 iRefOffset = iHor + iVer * iRefStride - 1; 2269 if( eType == TEXT_LUMA ) 2270 { 2271 pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2272 pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; 2273 } 2274 else if( eType == TEXT_CHROMA_U ) 2275 { 2276 pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2277 pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; 2278 } 2279 else 2280 { 2281 assert( eType == TEXT_CHROMA_V ); 2282 pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset; 2283 pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1; 2284 } 2285 2148 pRef = pRefPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) + iRefOffset; 2149 pRec = pRecPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) - 1; 2286 2150 for( i = 0; i < uiHeight; i+=2 ) 2287 2151 { 2288 2152 x += pRef[0]; 2289 2153 y += pRec[0]; 2290 if ( eType == TEXT_LUMA)2154 if( isLuma(compID) ) 2291 2155 { 2292 2156 xx += (pRef[0] * pRef[0])>>precShift; … … 2306 2170 } 2307 2171 2308 if ( eType != TEXT_LUMA)2309 { 2310 a = 32;2172 if( !isLuma(compID) ) 2173 { 2174 a = ( 1 << IC_CONST_SHIFT ); 2311 2175 b = ( y - x + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift; 2312 2176 } … … 2318 2182 Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift); 2319 2183 const Int iShift = IC_CONST_SHIFT; 2320 {2321 {2322 2184 const Int iShiftA2 = 6; 2323 2185 const Int iAccuracyShift = 15; … … 2325 2187 Int iScaleShiftA2 = 0; 2326 2188 Int iScaleShiftA1 = 0; 2327 Int a1s = a1;2328 Int a2s = a2;2189 Int a1s; 2190 Int a2s; 2329 2191 2330 2192 a1 = Clip3(0, 2*a2, a1); … … 2354 2216 } 2355 2217 } 2356 } 2357 } 2358 #endif 2359 2360 #if H_3D_DIM 2361 Void TComPrediction::xPredBiSegDCs( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ) 2362 { 2218 #endif 2219 2220 #if NH_3D_SDC_INTRA 2221 Void TComPrediction::predConstantSDC( Pel* ptrSrc, UInt srcStride, UInt uiSize, Pel& predDC ) 2222 { 2223 Pel* pLeftTop = ptrSrc; 2224 Pel* pRightTop = ptrSrc + (uiSize-1); 2225 Pel* pLeftBottom = (ptrSrc+ (srcStride*(uiSize-1)) ); 2226 Pel* pRightBottom = (ptrSrc+ (srcStride*(uiSize-1)) + (uiSize-1)); 2227 predDC = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2; 2228 } 2229 #endif // NH_3D_SDC_INTRA 2230 2231 #if NH_3D_DMM 2232 Void TComPrediction::predContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool* segPattern ) 2233 { 2234 // get copy of co-located texture luma block 2235 TComYuv cTempYuv; 2236 cTempYuv.create( uiWidth, uiHeight, CHROMA_400 ); 2237 cTempYuv.clear(); 2238 Pel* piRefBlkY = cTempYuv.getAddr( COMPONENT_Y ); 2239 TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec(); 2240 assert( pcPicYuvRef != NULL ); 2241 Int iRefStride = pcPicYuvRef->getStride( COMPONENT_Y ); 2242 Pel* piRefY = pcPicYuvRef->getAddr ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); 2243 2244 for( Int y = 0; y < uiHeight; y++ ) 2245 { 2246 ::memcpy(piRefBlkY, piRefY, sizeof(Pel)*uiWidth); 2247 piRefBlkY += uiWidth; 2248 piRefY += iRefStride; 2249 } 2250 2251 2252 // find contour for texture luma block 2253 piRefBlkY = cTempYuv.getAddr( COMPONENT_Y ); 2254 UInt iDC = 0; 2255 iDC = piRefBlkY[ 0 ]; 2256 iDC += piRefBlkY[ uiWidth - 1 ]; 2257 iDC += piRefBlkY[ uiWidth * (uiHeight - 1) ]; 2258 iDC += piRefBlkY[ uiWidth * (uiHeight - 1) + uiWidth - 1 ]; 2259 iDC = iDC >> 2; 2260 2261 piRefBlkY = cTempYuv.getAddr( COMPONENT_Y ); 2262 for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) 2263 { 2264 segPattern[k] = (piRefBlkY[k] > iDC) ? true : false; 2265 } 2266 2267 cTempYuv.destroy(); 2268 } 2269 2270 Void TComPrediction::predBiSegDCs( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 ) 2271 { 2272 assert( biSegPattern ); 2273 const Pel *piMask = getPredictorPtr( COMPONENT_Y, false ); 2274 assert( piMask ); 2275 Int srcStride = 2*uiWidth + 1; 2276 const Pel *ptrSrc = piMask+srcStride+1; 2277 2363 2278 Int refDC1, refDC2; 2364 2279 const Int iTR = ( patternStride - 1 ) - srcStride; … … 2387 2302 } 2388 2303 2389 Void TComPrediction::xAssignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 ) 2390 { 2304 Void TComPrediction::assignBiSegDCs( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel valDC1, Pel valDC2 ) 2305 { 2306 assert( biSegPattern ); 2391 2307 if( dstStride == patternStride ) 2392 2308 { 2393 2309 for( UInt k = 0; k < (patternStride * patternStride); k++ ) 2394 2310 { 2395 if( true == biSegPattern[k] ) 2396 { 2397 ptrDst[k] = valDC2; 2398 } 2399 else 2400 { 2401 ptrDst[k] = valDC1; 2402 } 2311 if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; } 2312 else { ptrDst[k] = valDC1; } 2403 2313 } 2404 2314 } … … 2410 2320 for( UInt uiX = 0; uiX < patternStride; uiX++ ) 2411 2321 { 2412 if( true == biSegPattern[uiX] ) 2413 { 2414 piTemp[uiX] = valDC2; 2415 } 2416 else 2417 { 2418 piTemp[uiX] = valDC1; 2419 } 2322 if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; } 2323 else { piTemp[uiX] = valDC1; } 2420 2324 } 2421 2325 piTemp += dstStride; … … 2424 2328 } 2425 2329 } 2426 2427 #if H_3D_DIM_DMM2428 2429 Void TComPrediction::xPredContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge )2430 {2431 pcContourWedge->clear();2432 2433 // get copy of co-located texture luma block2434 TComYuv cTempYuv;2435 cTempYuv.create( uiWidth, uiHeight );2436 cTempYuv.clear();2437 Pel* piRefBlkY = cTempYuv.getLumaAddr();2438 xCopyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight );2439 piRefBlkY = cTempYuv.getLumaAddr();2440 2441 // find contour for texture luma block2442 UInt iDC = 0;2443 2444 iDC = piRefBlkY[ 0 ];2445 iDC += piRefBlkY[ uiWidth - 1 ];2446 iDC += piRefBlkY[ uiWidth * (uiHeight - 1) ];2447 iDC += piRefBlkY[ uiWidth * (uiHeight - 1) + uiWidth - 1 ];2448 iDC = iDC >> 2;2449 2450 piRefBlkY = cTempYuv.getLumaAddr();2451 2452 Bool* pabContourPattern = pcContourWedge->getPattern();2453 for( UInt k = 0; k < (uiWidth*uiHeight); k++ )2454 {2455 pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false;2456 }2457 2458 cTempYuv.destroy();2459 }2460 2461 2462 Void TComPrediction::xCopyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight )2463 {2464 TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec();2465 assert( pcPicYuvRef != NULL );2466 Int iRefStride = pcPicYuvRef->getStride();2467 Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx );2468 2469 for ( Int y = 0; y < uiHeight; y++ )2470 {2471 ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth);2472 piDestBlockY += uiWidth;2473 piRefY += iRefStride;2474 }2475 }2476 #endif2477 2478 2479 #if H_3D_DIM_SDC2480 Void TComPrediction::analyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride2481 ,UInt uiIntraMode2482 ,Bool orgDC2483 )2484 {2485 Int iSumDepth[2];2486 memset(iSumDepth, 0, sizeof(Int)*2);2487 Int iSumPix[2];2488 memset(iSumPix, 0, sizeof(Int)*2);2489 2490 for( Int i = 0; i < uiNumSegments; i++ )2491 {2492 rpSegMeans[i] = 0;2493 }2494 2495 if ( !orgDC )2496 {2497 Pel* pLeftTop = pOrig;2498 Pel* pRightTop = pOrig + (uiSize-1);2499 Pel* pLeftBottom = (pOrig+ (uiStride*(uiSize-1)));2500 Pel* pRightBottom = (pOrig+ (uiStride*(uiSize-1)) + (uiSize-1));2501 2502 rpSegMeans[0] = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2;2503 return;2504 }2505 2506 Int subSamplePix;2507 if ( uiSize == 64 || uiSize == 32 )2508 {2509 subSamplePix = 2;2510 }2511 else2512 {2513 subSamplePix = 1;2514 }2515 2516 for (Int y=0; y<uiSize; y+=subSamplePix)2517 {2518 for (Int x=0; x<uiSize; x+=subSamplePix)2519 {2520 UChar ucSegment = pMask?(UChar)pMask[x]:0;2521 assert( ucSegment < uiNumSegments );2522 2523 iSumDepth[ucSegment] += pOrig[x];2524 iSumPix[ucSegment] += 1;2525 }2526 2527 pOrig += uiStride*subSamplePix;2528 pMask += uiMaskStride*subSamplePix;2529 }2530 2531 // compute mean for each segment2532 for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ )2533 {2534 if( iSumPix[ucSeg] > 0 )2535 {2536 rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg];2537 }2538 else2539 {2540 rpSegMeans[ucSeg] = 0; // this happens for zero-segments2541 }2542 }2543 }2544 #endif // H_3D_DIM_SDC2545 2330 #endif 2546 2331 //! \}
Note: See TracChangeset for help on using the changeset viewer.