Changeset 56 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPrediction.cpp
 Timestamp:
 11 May 2012, 21:20:17 (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/source/Lib/TLibCommon/TComPrediction.cpp
r21 r56 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) 2010201 1,ISO/IEC6 * Copyright (c) 20102012, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 15 15 * this list of conditions and the following disclaimer in the documentation 16 16 * and/or other materials provided with the distribution. 17 * * Neither the name of the I SO/IEC nor the names of its contributors may17 * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may 18 18 * be used to endorse or promote products derived from this software without 19 19 * specific prior written permission. … … 32 32 */ 33 33 34 35 36 34 /** \file TComPrediction.cpp 37 35 \brief prediction class … … 41 39 #include "TComPrediction.h" 42 40 41 //! \ingroup TLibCommon 42 //! \{ 43 43 44 // ==================================================================================================================== 44 45 // Constructor / destructor / initialize … … 53 54 TComPrediction::~TComPrediction() 54 55 { 55 m_cYuvExt.destroy(); 56 56 57 57 delete[] m_piYuvExt; 58 58 … … 62 62 m_cYuvPredTemp.destroy(); 63 63 64 #if LM_CHROMA65 64 if( m_pLumaRecBuffer ) 66 delete [] m_pLumaRecBuffer; 67 #endif 65 { 66 delete [] m_pLumaRecBuffer; 67 } 68 69 Int i, j; 70 for (i = 0; i < 4; i++) 71 { 72 for (j = 0; j < 4; j++) 73 { 74 m_filteredBlock[i][j].destroy(); 75 } 76 m_filteredBlockTmp[i].destroy(); 77 } 68 78 } 69 79 … … 72 82 if( m_piYuvExt == NULL ) 73 83 { 84 Int extWidth = g_uiMaxCUWidth + 16; 85 Int extHeight = g_uiMaxCUHeight + 1; 86 Int i, j; 87 for (i = 0; i < 4; i++) 88 { 89 m_filteredBlockTmp[i].create(extWidth, extHeight + 7); 90 for (j = 0; j < 4; j++) 91 { 92 m_filteredBlock[i][j].create(extWidth, extHeight); 93 } 94 } 74 95 m_iYuvExtHeight = ((g_uiMaxCUHeight + 2) << 4); 75 96 m_iYuvExtStride = ((g_uiMaxCUWidth + 8) << 4); 76 m_cYuvExt.create( m_iYuvExtStride, m_iYuvExtHeight );77 97 m_piYuvExt = new Int[ m_iYuvExtStride * m_iYuvExtHeight ]; 78 98 … … 84 104 } 85 105 86 #if LM_CHROMA87 106 m_iLumaRecStride = (g_uiMaxCUWidth>>1) + 1; 88 107 m_pLumaRecBuffer = new Pel[ m_iLumaRecStride * m_iLumaRecStride ]; 89 108 90 for( Int i = 1; i < 66; i++ ) 109 for( Int i = 1; i < 64; i++ ) 110 { 91 111 m_uiaShift[i1] = ( (1 << 15) + i/2 ) / i; 92 #endif 112 } 93 113 } 94 114 … … 106 126 { 107 127 for (iInd = 0;iInd < iWidth;iInd++) 128 { 108 129 iSum += pSrc[iIndiSrcStride]; 130 } 109 131 } 110 132 if (bLeft) 111 133 { 112 134 for (iInd = 0;iInd < iHeight;iInd++) 135 { 113 136 iSum += pSrc[iInd*iSrcStride1]; 137 } 114 138 } 115 139 116 140 if (bAbove && bLeft) 141 { 117 142 pDcVal = (iSum + iWidth) / (iWidth + iHeight); 143 } 118 144 else if (bAbove) 145 { 119 146 pDcVal = (iSum + iWidth/2) / iWidth; 147 } 120 148 else if (bLeft) 149 { 121 150 pDcVal = (iSum + iHeight/2) / iHeight; 151 } 122 152 else 153 { 123 154 pDcVal = pSrc[1]; // Default DC value already calculated and placed in the prediction array if no neighbors are available 124 155 } 156 125 157 return pDcVal; 126 158 } … … 147 179 * from the extended main reference. 148 180 */ 149 Void TComPrediction::xPredIntraAng( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable )181 Void TComPrediction::xPredIntraAng( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable, Bool bFilter ) 150 182 { 151 183 Int k,l; … … 154 186 155 187 // Map the mode index to main prediction direction and angle 188 #if LOGI_INTRA_NAME_3MPM 189 assert( dirMode > 0 ); //no planar 190 Bool modeDC = dirMode < 2; 191 Bool modeHor = !modeDC && (dirMode < 18); 192 Bool modeVer = !modeDC && !modeHor; 193 Int intraPredAngle = modeVer ? (Int)dirMode  VER_IDX : modeHor ? ((Int)dirMode  HOR_IDX) : 0; 194 #else 156 195 Bool modeDC = dirMode == 0; 157 196 Bool modeVer = !modeDC && (dirMode < 18); 158 197 Bool modeHor = !modeDC && !modeVer; 159 198 Int intraPredAngle = modeVer ? dirMode  9 : modeHor ? dirMode  25 : 0; 199 #endif 160 200 Int absAng = abs(intraPredAngle); 161 201 Int signAng = intraPredAngle < 0 ? 1 : 1; … … 223 263 } 224 264 refMain = modeVer ? refAbove : refLeft; 265 refSide = modeVer ? refLeft : refAbove; 225 266 } 226 267 … … 232 273 { 233 274 pDst[k*dstStride+l] = refMain[l+1]; 275 } 276 } 277 278 if ( bFilter ) 279 { 280 for (k=0;k<blkSize;k++) 281 { 282 #if REMOVE_DIV_OPERATION 283 pDst[k*dstStride] = Clip ( pDst[k*dstStride] + (( refSide[k+1]  refSide[0] ) >> 1) ); 284 #else 285 pDst[k*dstStride] = Clip ( pDst[k*dstStride] + ( refSide[k+1]  refSide[0] ) / 2 ); 286 #endif 234 287 } 235 288 } … … 290 343 Int *ptrSrc; 291 344 292 // only assign variable in debug mode 293 #ifndef NDEBUG 294 // get intra direction 295 Int iIntraSizeIdx = g_aucConvertToBit[ iWidth ] + 1; 296 297 assert( iIntraSizeIdx >= 1 ); // 4x 4 298 assert( iIntraSizeIdx <= 6 ); // 128x128 345 assert( g_aucConvertToBit[ iWidth ] >= 0 ); // 4x 4 346 assert( g_aucConvertToBit[ iWidth ] <= 5 ); // 128x128 299 347 assert( iWidth == iHeight ); 300 #endif //NDEBUG 301 302 #if QC_MDIS 303 ptrSrc = pcTComPattern>getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 1, iWidth, iHeight, m_piYuvExt ); 304 #else 305 ptrSrc = pcTComPattern>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); 306 #endif //QC_MDIS 348 349 ptrSrc = pcTComPattern>getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); 307 350 308 351 // get starting pixel in block 309 Int sw = ( iWidth<<1 )+ 1;310 311 #if ADD_PLANAR_MODE 352 Int sw = 2 * iWidth + 1; 353 354 // Create the prediction 312 355 if ( uiDirMode == PLANAR_IDX ) 313 356 { 314 #if REFERENCE_SAMPLE_PADDING315 357 xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); 316 #else 317 xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, bAbove, bLeft ); 318 #endif 319 return; 320 } 321 #endif 322 323 // get converted direction 324 uiDirMode = g_aucAngIntraModeOrder[ uiDirMode ]; 325 326 // Create the prediction 327 xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft ); 328 329 #if MN_DC_PRED_FILTER 330 if ((uiDirMode == 0) && pcTComPattern>getDCPredFilterFlag()) 331 xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight); 332 #endif 333 } 334 335 336 Void 337 TComPrediction::predIntraDepthAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight ) 338 { 339 Pel* pDst = piPred; 340 Int* ptrSrc = pcTComPattern>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); 341 Int sw = ( iWidth<<1 ) + 1; 342 uiDirMode = g_aucAngIntraModeOrder[ uiDirMode ]; 343 xPredIntraAngDepth( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode ); 344 } 345 346 Int 347 TComPrediction::xGetDCDepth( Int* pSrc, Int iDelta, Int iBlkSize ) 348 { 349 Int iDC = PDM_UNDEFINED_DEPTH; 350 Int iSum = 0; 351 Int iNum = 0; 352 for( Int k = 0; k < iBlkSize; k++, pSrc += iDelta ) 353 { 354 if( *pSrc != PDM_UNDEFINED_DEPTH ) 355 { 356 iSum += *pSrc; 357 iNum ++; 358 } 359 } 360 if( iNum ) 361 { 362 iDC = ( iSum + ( iNum >> 1 ) ) / iNum; 363 } 364 return iDC; 365 } 366 367 Int 368 TComPrediction::xGetDCValDepth( Int iVal1, Int iVal2, Int iVal3, Int iVal4 ) 369 { 370 if ( iVal1 != PDM_UNDEFINED_DEPTH ) return iVal1; 371 else if( iVal2 != PDM_UNDEFINED_DEPTH ) return iVal2; 372 else if( iVal3 != PDM_UNDEFINED_DEPTH ) return iVal3; 373 return iVal4; 374 } 375 376 Void 377 TComPrediction::xPredIntraAngDepth( Int* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, UInt dirMode ) 378 { 379 AOF( width == height ); 380 Int blkSize = width; 381 Int iDCAbove = xGetDCDepth( pSrc  srcStride, 1, blkSize ); 382 Int iDCAboveRight = xGetDCDepth( pSrc  srcStride + blkSize, 1, blkSize ); 383 Int iDCLeft = xGetDCDepth( pSrc  1, srcStride, blkSize ); 384 Int iDCBelowLeft = xGetDCDepth( pSrc  1 + blkSize * srcStride, srcStride, blkSize ); 385 Int iWgt, iDC1, iDC2; 386 if( dirMode == 0 ) // 0 387 { 388 iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); 389 iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); 390 iWgt = 8; 391 } 392 else if( dirMode < 10 ) // 1..9 393 { 394 iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); 395 iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); 396 iWgt = 7 + dirMode; 397 } 398 else if( dirMode < 18 ) // 10..17 399 { 400 iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); 401 iDC2 = xGetDCValDepth( iDCAboveRight, iDCAbove, iDCLeft, iDCBelowLeft ); 402 iWgt = 25  dirMode; 403 } 404 else if( dirMode < 26 ) // 18..25 405 { 406 iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); 407 iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); 408 iWgt = 25  dirMode; 409 } 410 else if( dirMode < 34 ) // 26..33 411 { 412 iDC1 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); 413 iDC2 = xGetDCValDepth( iDCBelowLeft, iDCLeft, iDCAbove, iDCAboveRight ); 414 iWgt = 41  dirMode; 415 } 416 else // 34 (wedgelet > use simple DC prediction 417 { 418 iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); 419 iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); 420 iWgt = 8; 421 } 422 Int iWgt2 = 16  iWgt; 423 Int iDCVal = ( iWgt * iDC1 + iWgt2 * iDC2 + 8 ) >> 4; 424 425 // set depth 426 for( Int iY = 0; iY < blkSize; iY++, pDst += dstStride ) 427 { 428 for( Int iX = 0; iX < blkSize; iX++ ) 429 { 430 pDst[ iX ] = iDCVal; 431 } 432 } 433 } 434 358 } 359 else 360 { 361 #if LOGI_INTRA_NAME_3MPM 362 xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, true ); 363 #else 364 xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, g_aucAngIntraModeOrder[ uiDirMode ], bAbove, bLeft, true ); 365 #endif 366 367 if( (uiDirMode == DC_IDX ) && bAbove && bLeft ) 368 { 369 xDCPredFiltering( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight); 370 } 371 } 372 } 435 373 436 374 // Angular chroma … … 441 379 442 380 // get starting pixel in block 443 Int sw = ( iWidth<<1 ) + 1; 444 445 #if ADD_PLANAR_MODE 381 Int sw = 2 * iWidth + 1; 382 446 383 if ( uiDirMode == PLANAR_IDX ) 447 384 { 448 #if REFERENCE_SAMPLE_PADDING449 385 xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight ); 450 #else451 xPredIntraPlanar( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, bAbove, bLeft );452 #endif453 return;454 }455 #endif456 457 // get converted direction458 uiDirMode = g_aucAngIntraModeOrder[ uiDirMode ];459 460 // Create the prediction461 xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft );462 }463 464 #if HHI_DMM_WEDGE_INTRA  HHI_DMM_PRED_TEX465 Void TComPrediction::predIntraLumaDMM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder )466 {467 #if HHI_DMM_WEDGE_INTRA468 if( uiMode == DMM_WEDGE_FULL_IDX ) { xPredIntraWedgeFull ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU>getWedgeFullTabIdx ( uiAbsPartIdx ) ); }469 if( uiMode == DMM_WEDGE_FULL_D_IDX ) { xPredIntraWedgeFull ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU>getWedgeFullTabIdx( uiAbsPartIdx ), pcCU>getWedgeFullDeltaDC1( uiAbsPartIdx ), pcCU>getWedgeFullDeltaDC2( uiAbsPartIdx ) ); }470 if( uiMode == DMM_WEDGE_PREDDIR_IDX ) { xPredIntraWedgeDir ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU>getWedgePredDirDeltaEnd( uiAbsPartIdx ) ); }471 if( uiMode == DMM_WEDGE_PREDDIR_D_IDX ) { xPredIntraWedgeDir ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU>getWedgePredDirDeltaEnd( uiAbsPartIdx ), pcCU>getWedgePredDirDeltaDC1( uiAbsPartIdx ), pcCU>getWedgePredDirDeltaDC2( uiAbsPartIdx ) ); }472 #endif473 #if HHI_DMM_PRED_TEX474 if( uiMode == DMM_WEDGE_PREDTEX_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); }475 if( uiMode == DMM_WEDGE_PREDTEX_D_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU>getWedgePredTexDeltaDC1( uiAbsPartIdx ), pcCU>getWedgePredTexDeltaDC2( uiAbsPartIdx ) ); }476 if( uiMode == DMM_CONTOUR_PREDTEX_IDX ) { xPredIntraContourTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); }477 if( uiMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xPredIntraContourTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU>getContourPredTexDeltaDC1( uiAbsPartIdx ), pcCU>getContourPredTexDeltaDC2( uiAbsPartIdx ) ); }478 #endif479 }480 481 Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Int& riDeltaDC )482 {483 Int iSign = riDeltaDC < 0 ? 1 : 1;484 UInt uiAbs = abs( riDeltaDC );485 486 Int iQp = pcCU>getQP(0);487 Int iMax = ( 1<<( g_uiBitDepth + g_uiBitIncrement  1) );488 Double dStepSize = Clip3( 1, iMax, pow( 2.0, iQp/10.0 + g_dDeltaDCsQuantOffset ) );489 490 riDeltaDC = iSign * roftoi( uiAbs * dStepSize );491 return;492 }493 494 Void TComPrediction::calcWedgeDCs( TComWedgelet* pcWedgelet, Pel* piOrig, UInt uiStride, Int& riDC1, Int& riDC2 )495 {496 UInt uiDC1 = 0;497 UInt uiDC2 = 0;498 UInt uiNumPixDC1 = 0, uiNumPixDC2 = 0;499 Bool* pabWedgePattern = pcWedgelet>getPattern();500 if( uiStride == pcWedgelet>getStride() )501 {502 for( UInt k = 0; k < (pcWedgelet>getWidth() * pcWedgelet>getHeight()); k++ )503 {504 if( true == pabWedgePattern[k] )505 {506 uiDC2 += piOrig[k];507 uiNumPixDC2++;508 }509 else510 {511 uiDC1 += piOrig[k];512 uiNumPixDC1++;513 }514 }515 386 } 516 387 else 517 388 { 518 Pel* piTemp = piOrig; 519 UInt uiWedgeStride = pcWedgelet>getStride(); 520 for( UInt uiY = 0; uiY < pcWedgelet>getHeight(); uiY++ ) 521 { 522 for( UInt uiX = 0; uiX < pcWedgelet>getWidth(); uiX++ ) 523 { 524 if( true == pabWedgePattern[uiX] ) 525 { 526 uiDC2 += piTemp[uiX]; 527 uiNumPixDC2++; 528 } 529 else 530 { 531 uiDC1 += piTemp[uiX]; 532 uiNumPixDC1++; 533 } 534 } 535 piTemp += uiStride; 536 pabWedgePattern += uiWedgeStride; 537 } 538 } 539 540 if( uiNumPixDC1 > 0 ) { riDC1 = uiDC1 / uiNumPixDC1; } 541 else { riDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement  1) ); } 542 543 if( uiNumPixDC2 > 0 ) { riDC2 = uiDC2 / uiNumPixDC2; } 544 else { riDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement  1) ); } 545 } 546 547 Void TComPrediction::assignWedgeDCs2Pred( TComWedgelet* pcWedgelet, Pel* piPred, UInt uiStride, Int iDC1, Int iDC2 ) 548 { 549 Bool* pabWedgePattern = pcWedgelet>getPattern(); 550 551 if( uiStride == pcWedgelet>getStride() ) 552 { 553 for( UInt k = 0; k < (pcWedgelet>getWidth() * pcWedgelet>getHeight()); k++ ) 554 { 555 if( true == pabWedgePattern[k] ) 556 { 557 piPred[k] = iDC2; 558 } 559 else 560 { 561 piPred[k] = iDC1; 562 } 563 } 564 } 565 else 566 { 567 Pel* piTemp = piPred; 568 UInt uiWedgeStride = pcWedgelet>getStride(); 569 for( UInt uiY = 0; uiY < pcWedgelet>getHeight(); uiY++ ) 570 { 571 for( UInt uiX = 0; uiX < pcWedgelet>getWidth(); uiX++ ) 572 { 573 if( true == pabWedgePattern[uiX] ) 574 { 575 piTemp[uiX] = iDC2; 576 } 577 else 578 { 579 piTemp[uiX] = iDC1; 580 } 581 } 582 piTemp += uiStride; 583 pabWedgePattern += uiWedgeStride; 584 } 585 } 586 } 587 588 Void TComPrediction::getWedgePredDCs( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft ) 589 { 590 riPredDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement  1) ); //pred val, if no neighbors are available 591 riPredDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement  1) ); 592 593 if( !bAbove && !bLeft ) { return; } 594 595 UInt uiNumSmpDC1 = 0, uiNumSmpDC2 = 0; 596 Int iPredDC1 = 0, iPredDC2 = 0; 597 598 Bool* pabWedgePattern = pcWedgelet>getPattern(); 599 UInt uiWedgeStride = pcWedgelet>getStride(); 600 601 if( bAbove ) 602 { 603 for( Int k = 0; k < pcWedgelet>getWidth(); k++ ) 604 { 605 if( true == pabWedgePattern[k] ) 606 { 607 iPredDC2 += piMask[kiMaskStride]; 608 uiNumSmpDC2++; 609 } 610 else 611 { 612 iPredDC1 += piMask[kiMaskStride]; 613 uiNumSmpDC1++; 614 } 615 } 616 } 617 if( bLeft ) 618 { 619 for( Int k = 0; k < pcWedgelet>getHeight(); k++ ) 620 { 621 if( true == pabWedgePattern[k*uiWedgeStride] ) 622 { 623 iPredDC2 += piMask[k*iMaskStride1]; 624 uiNumSmpDC2++; 625 } 626 else 627 { 628 iPredDC1 += piMask[k*iMaskStride1]; 629 uiNumSmpDC1++; 630 } 631 } 632 } 633 634 if( uiNumSmpDC1 > 0 ) 635 { 636 iPredDC1 /= uiNumSmpDC1; 637 riPredDC1 = iPredDC1; 638 } 639 if( uiNumSmpDC2 > 0 ) 640 { 641 iPredDC2 /= uiNumSmpDC2; 642 riPredDC2 = iPredDC2; 643 } 644 } 645 #endif 646 647 #if HHI_DMM_WEDGE_INTRA 648 Void TComPrediction::xPredIntraWedgeFull( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, UInt uiTabIdx, Int iDeltaDC1, Int iDeltaDC2 ) 649 { 650 assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); 651 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; 652 TComWedgelet* pcWedgelet = &(pacWedgeList>at(uiTabIdx)); 653 654 // get wedge pred DCs 655 Int iPredDC1 = 0; 656 Int iPredDC2 = 0; 657 658 Int* piMask = pcCU>getPattern()>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); 659 Int iMaskStride = ( iWidth<<1 ) + 1; 660 piMask += iMaskStride+1; 661 getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); 662 663 if( bDelta ) 664 { 665 xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); 666 xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); 667 } 668 669 // assign wedge pred DCs to prediction 670 if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } 671 else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } 672 } 673 674 UInt TComPrediction::getBestContinueWedge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd ) 675 { 676 UInt uiThisBlockSize = uiWidth; 677 assert( uiThisBlockSize >= DMM_WEDGEMODEL_MIN_SIZE && uiThisBlockSize <= DMM_WEDGEMODEL_MAX_SIZE ); 678 WedgeList* pacContDWedgeList = &g_aacWedgeLists [(g_aucConvertToBit[uiThisBlockSize])]; 679 WedgeRefList* pacContDWedgeRefList = &g_aacWedgeRefLists[(g_aucConvertToBit[uiThisBlockSize])]; 680 681 UInt uiPredDirWedgeTabIdx = 0; 682 TComDataCU* pcTempCU; 683 UInt uiTempPartIdx; 684 // 1st: try continue above wedgelet 685 pcTempCU = pcCU>getPUAbove( uiTempPartIdx, pcCU>getZorderIdxInCU() + uiAbsPartIdx ); 686 if( pcTempCU ) 687 { 688 UChar uhLumaIntraDir = pcTempCU>getLumaIntraDir( uiTempPartIdx ); 689 if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir  690 DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir  691 DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir  692 DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir 693 #if HHI_DMM_PRED_TEX 694  695 DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir  696 DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir 697 #endif 698 ) 699 { 700 UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU>getIntraSizeIdx( uiTempPartIdx )]; 701 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; 702 703 // get offset between current and reference block 704 UInt uiOffsetX = 0; 705 UInt uiOffsetY = 0; 706 xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); 707 708 // get reference wedgelet 709 UInt uiRefWedgeTabIdx = 0; 710 switch( uhLumaIntraDir ) 711 { 712 case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgeFullTabIdx ( uiTempPartIdx ); } break; 713 case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgeFullTabIdx ( uiTempPartIdx ); } break; 714 case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredDirTabIdx( uiTempPartIdx ); } break; 715 case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredDirTabIdx( uiTempPartIdx ); } break; 716 #if HHI_DMM_PRED_TEX 717 case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredTexTabIdx( uiTempPartIdx ); } break; 718 case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredTexTabIdx( uiTempPartIdx ); } break; 719 #endif 720 default: { assert( 0 ); return uiPredDirWedgeTabIdx; } 721 } 722 TComWedgelet* pcRefWedgelet; 723 pcRefWedgelet = &(pacWedgeList>at( uiRefWedgeTabIdx )); 724 725 // find reference wedgelet, if direction is suitable for continue wedge 726 if( pcRefWedgelet>checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) ) 727 { 728 UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; 729 pcRefWedgelet>getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd ); 730 getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); 731 return uiPredDirWedgeTabIdx; 732 } 733 } 734 } 735 736 // 2nd: try continue left wedglelet 737 pcTempCU = pcCU>getPULeft( uiTempPartIdx, pcCU>getZorderIdxInCU() + uiAbsPartIdx ); 738 if( pcTempCU ) 739 { 740 UChar uhLumaIntraDir = pcTempCU>getLumaIntraDir( uiTempPartIdx ); 741 if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir  742 DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir  743 DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir  744 DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir 745 #if HHI_DMM_PRED_TEX 746  747 DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir  748 DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir 749 #endif 750 ) 751 { 752 UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU>getIntraSizeIdx( uiTempPartIdx )]; 753 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; 754 755 // get offset between current and reference block 756 UInt uiOffsetX = 0; 757 UInt uiOffsetY = 0; 758 xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); 759 760 // get reference wedgelet 761 UInt uiRefWedgeTabIdx = 0; 762 switch( uhLumaIntraDir ) 763 { 764 case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgeFullTabIdx ( uiTempPartIdx ); } break; 765 case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgeFullTabIdx ( uiTempPartIdx ); } break; 766 case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredDirTabIdx( uiTempPartIdx ); } break; 767 case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredDirTabIdx( uiTempPartIdx ); } break; 768 #if HHI_DMM_PRED_TEX 769 case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredTexTabIdx( uiTempPartIdx ); } break; 770 case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredTexTabIdx( uiTempPartIdx ); } break; 771 #endif 772 default: { assert( 0 ); return uiPredDirWedgeTabIdx; } 773 } 774 TComWedgelet* pcRefWedgelet; 775 pcRefWedgelet = &(pacWedgeList>at( uiRefWedgeTabIdx )); 776 777 // find reference wedgelet, if direction is suitable for continue wedge 778 if( pcRefWedgelet>checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) ) 779 { 780 UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; 781 pcRefWedgelet>getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd ); 782 getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); 783 return uiPredDirWedgeTabIdx; 784 } 785 } 786 } 787 788 // 3rd: (default) make wedglet from intra dir and max slope point 789 Int iSlopeX = 0; 790 Int iSlopeY = 0; 791 UInt uiStartPosX = 0; 792 UInt uiStartPosY = 0; 793 if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) ) 794 { 795 UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; 796 xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd ); 797 getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); 798 return uiPredDirWedgeTabIdx; 799 } 800 801 return uiPredDirWedgeTabIdx; 802 } 803 804 Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ) 805 { 806 ruiOffsetX = 0; 807 ruiOffsetY = 0; 808 809 // get offset between current and above/left block 810 UInt uiThisOriginX = pcCU>getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 811 UInt uiThisOriginY = pcCU>getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 812 813 UInt uiNumPartInRefCU = pcRefCU>getTotalNumPart(); 814 UInt uiMaxDepthRefCU = 0; 815 while( uiNumPartInRefCU > 1 ) 816 { 817 uiNumPartInRefCU >>= 2; 818 uiMaxDepthRefCU++; 819 } 820 821 UInt uiDepthRefPU = (pcRefCU>getDepth(uiRefAbsPartIdx)) + (pcRefCU>getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1); 822 UInt uiShifts = (uiMaxDepthRefCU  uiDepthRefPU)*2; 823 UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts; 824 825 UInt uiRefOriginX = pcRefCU>getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; 826 UInt uiRefOriginY = pcRefCU>getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; 827 828 if( (uiThisOriginX  uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX  uiRefOriginX); } 829 if( (uiThisOriginY  uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY  uiRefOriginY); } 830 } 831 832 Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ) 833 { 834 riSlopeX = 0; 835 riSlopeY = 0; 836 ruiStartPosX = 0; 837 ruiStartPosY = 0; 838 839 // 1st step: get wedge start point (max. slope) 840 Int* piSource = pcCU>getPattern()>getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt ); 841 Int iSourceStride = ( uiBlockSize<<1 ) + 1; 842 843 UInt uiSlopeMaxAbove = 0; 844 UInt uiPosSlopeMaxAbove = 0; 845 for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize1); uiPosHor++ ) 846 { 847 if( abs( piSource[uiPosHor+1]  piSource[uiPosHor] ) > uiSlopeMaxAbove ) 848 { 849 uiSlopeMaxAbove = abs( piSource[uiPosHor+1]  piSource[uiPosHor] ); 850 uiPosSlopeMaxAbove = uiPosHor; 851 } 852 } 853 854 UInt uiSlopeMaxLeft = 0; 855 UInt uiPosSlopeMaxLeft = 0; 856 for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize1); uiPosVer++ ) 857 { 858 if( abs( piSource[(uiPosVer+1)*iSourceStride]  piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft ) 859 { 860 uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride]  piSource[uiPosVer*iSourceStride] ); 861 uiPosSlopeMaxLeft = uiPosVer; 862 } 863 } 864 865 if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 ) 866 { 867 return false; 868 } 869 870 if( uiSlopeMaxAbove > uiSlopeMaxLeft ) 871 { 872 ruiStartPosX = uiPosSlopeMaxAbove; 873 ruiStartPosY = 0; 874 } 875 else 876 { 877 ruiStartPosX = 0; 878 ruiStartPosY = uiPosSlopeMaxLeft; 879 } 880 881 // 2nd step: derive wedge direction 882 Int angTable[9] = {0,2,5,9,13,17,21,26,32}; 883 884 Int uiPreds[2] = {1, 1}; 885 Int uiPredNum = pcCU>getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds ); 886 887 UInt uiDirMode = 0; 888 if( uiPredNum == 1 ) 889 { 890 uiDirMode = g_aucAngIntraModeOrder[uiPreds[0]]; 891 } 892 else if( uiPredNum == 2 ) 893 { 894 uiDirMode = g_aucAngIntraModeOrder[uiPreds[1]]; 895 } 896 897 if( uiDirMode == 0 ) 898 { 899 return false; 900 } 901 902 Bool modeVer = (uiDirMode < 18); 903 Bool modeHor = !modeVer; 904 Int intraPredAngle = modeVer ? uiDirMode  9 : modeHor ? uiDirMode  25 : 0; 905 Int absAng = abs(intraPredAngle); 906 Int signAng = intraPredAngle < 0 ? 1 : 1; 907 absAng = angTable[absAng]; 908 intraPredAngle = signAng * absAng; 909 910 // 3rd step: set slope for direction 911 if( modeHor ) 912 { 913 if( intraPredAngle > 0 ) 914 { 915 riSlopeX = 32; 916 riSlopeY = intraPredAngle; 917 } 918 else 919 { 920 riSlopeX = 32; 921 riSlopeY = intraPredAngle; 922 } 923 } 924 else if( modeVer ) 925 { 926 if( intraPredAngle > 0 ) 927 { 928 riSlopeX = intraPredAngle; 929 riSlopeY = 32; 930 } 931 else 932 { 933 riSlopeX = intraPredAngle; 934 riSlopeY = 32; 935 } 936 } 937 938 return true; 939 } 940 941 Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd ) 942 { 943 ruhXs = 0; 944 ruhYs = 0; 945 ruhXe = 0; 946 ruhYe = 0; 947 UInt uiOri; 948 949 // scaling of start pos and block size to wedge resolution 950 UInt uiScaledStartPosX = 0; 951 UInt uiScaledStartPosY = 0; 952 UInt uiScaledBlockSize = 0; 953 WedgeResolution eWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiBlockSize]]; 954 switch( eWedgeRes ) 955 { 956 case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; } 957 case( FULL_PEL ): { uiScaledStartPosX = uiPMSPosX; uiScaledStartPosY = uiPMSPosY; uiScaledBlockSize = uiBlockSize; break; } 958 case( HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; } 959 } 960 961 // case above 962 if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 ) 963 { 964 ruhXs = (UChar)uiScaledStartPosX; 965 ruhYs = 0; 966 967 if( iDeltaY == 0 ) 968 { 969 if( iDeltaX < 0 ) 970 { 971 uiOri = 0; 972 ruhXe = 0; 973 ruhYe = (UChar)Min( Max( iDeltaEnd, 0 ), (uiScaledBlockSize1) ); 974 return; 975 } 976 else 977 { 978 uiOri = 1; 979 ruhXe = (UChar)(uiScaledBlockSize1); ; 980 ruhYe = (UChar)Min( Max( iDeltaEnd, 0 ), (uiScaledBlockSize1) ); 981 std::swap( ruhXs, ruhXe ); 982 std::swap( ruhYs, ruhYe ); 983 return; 984 } 985 } 986 987 // regular case 988 Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)(uiScaledBlockSize1) * ((Double)iDeltaX / (Double)iDeltaY) ); 989 990 if( iVirtualEndX < 0 ) 991 { 992 Int iYe = roftoi( (Double)(0  (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd; 993 if( iYe < (Int)uiScaledBlockSize ) 994 { 995 uiOri = 0; 996 ruhXe = 0; 997 ruhYe = (UChar)Max( iYe, 0 ); 998 return; 999 } 1000 else 1001 { 1002 uiOri = 4; 1003 ruhXe = (UChar)Min( (iYe  (uiScaledBlockSize1)), (uiScaledBlockSize1) ); 1004 ruhYe = (UChar)(uiScaledBlockSize1); 1005 return; 1006 } 1007 } 1008 else if( iVirtualEndX > (uiScaledBlockSize1) ) 1009 { 1010 Int iYe = roftoi( (Double)((Int)(uiScaledBlockSize1)  (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) )  iDeltaEnd; 1011 if( iYe < (Int)uiScaledBlockSize ) 1012 { 1013 uiOri = 1; 1014 ruhXe = (UChar)(uiScaledBlockSize1); 1015 ruhYe = (UChar)Max( iYe, 0 ); 1016 std::swap( ruhXs, ruhXe ); 1017 std::swap( ruhYs, ruhYe ); 1018 return; 1019 } 1020 else 1021 { 1022 uiOri = 4; 1023 ruhXe = (UChar)Max( ((uiScaledBlockSize1)  (iYe  (uiScaledBlockSize1))), 0 ); 1024 ruhYe = (UChar)(uiScaledBlockSize1); 1025 return; 1026 } 1027 } 1028 else 1029 { 1030 Int iXe = iVirtualEndX + iDeltaEnd; 1031 if( iXe < 0 ) 1032 { 1033 uiOri = 0; 1034 ruhXe = 0; 1035 ruhYe = (UChar)Max( ((uiScaledBlockSize1) + iXe), 0 ); 1036 return; 1037 } 1038 else if( iXe > (uiScaledBlockSize1) ) 1039 { 1040 uiOri = 1; 1041 ruhXe = (UChar)(uiScaledBlockSize1); 1042 ruhYe = (UChar)Max( ((uiScaledBlockSize1)  (iXe  (uiScaledBlockSize1))), 0 ); 1043 std::swap( ruhXs, ruhXe ); 1044 std::swap( ruhYs, ruhYe ); 1045 return; 1046 } 1047 else 1048 { 1049 uiOri = 4; 1050 ruhXe = (UChar)iXe; 1051 ruhYe = (UChar)(uiScaledBlockSize1); 1052 return; 1053 } 1054 } 1055 } 1056 1057 // case left 1058 if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 ) 1059 { 1060 ruhXs = 0; 1061 ruhYs = (UChar)uiScaledStartPosY; 1062 1063 if( iDeltaX == 0 ) 1064 { 1065 if( iDeltaY < 0 ) 1066 { 1067 uiOri = 0; 1068 ruhXe = (UChar)Min( Max( iDeltaEnd, 0 ), (uiScaledBlockSize1) ); 1069 ruhYe = 0; 1070 std::swap( ruhXs, ruhXe ); 1071 std::swap( ruhYs, ruhYe ); 1072 return; 1073 } 1074 else 1075 { 1076 uiOri = 3; 1077 ruhXe = (UChar)Min( Max( iDeltaEnd, 0 ), (uiScaledBlockSize1) ); 1078 ruhYe = (UChar)(uiScaledBlockSize1); 1079 return; 1080 } 1081 } 1082 1083 // regular case 1084 Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)(uiScaledBlockSize1) * ((Double)iDeltaY / (Double)iDeltaX) ); 1085 1086 if( iVirtualEndY < 0 ) 1087 { 1088 Int iXe = roftoi( (Double)(0  (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) )  iDeltaEnd; 1089 if( iXe < (Int)uiScaledBlockSize ) 1090 { 1091 uiOri = 0; 1092 ruhXe = (UChar)Max( iXe, 0 ); 1093 ruhYe = 0; 1094 std::swap( ruhXs, ruhXe ); 1095 std::swap( ruhYs, ruhYe ); 1096 return; 1097 } 1098 else 1099 { 1100 uiOri = 5; 1101 ruhXe = (UChar)(uiScaledBlockSize1); 1102 ruhYe = (UChar)Min( (iXe  (uiScaledBlockSize1)), (uiScaledBlockSize1) ); 1103 std::swap( ruhXs, ruhXe ); 1104 std::swap( ruhYs, ruhYe ); 1105 return; 1106 } 1107 } 1108 else if( iVirtualEndY > (uiScaledBlockSize1) ) 1109 { 1110 Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize1)  (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd; 1111 if( iXe < (Int)uiScaledBlockSize ) 1112 { 1113 uiOri = 3; 1114 ruhXe = (UChar)Max( iXe, 0 ); 1115 ruhYe = (UChar)(uiScaledBlockSize1); 1116 return; 1117 } 1118 else 1119 { 1120 uiOri = 5; 1121 ruhXe = (UChar)(uiScaledBlockSize1); 1122 ruhYe = (UChar)Max( ((uiScaledBlockSize1)  (iXe  (uiScaledBlockSize1))), 0 ); 1123 std::swap( ruhXs, ruhXe ); 1124 std::swap( ruhYs, ruhYe ); 1125 return; 1126 } 1127 } 1128 else 1129 { 1130 Int iYe = iVirtualEndY  iDeltaEnd; 1131 if( iYe < 0 ) 1132 { 1133 uiOri = 0; 1134 ruhXe = (UChar)Max( ((uiScaledBlockSize1) + iYe), 0 ); 1135 ruhYe = 0; 1136 std::swap( ruhXs, ruhXe ); 1137 std::swap( ruhYs, ruhYe ); 1138 return; 1139 } 1140 else if( iYe > (uiScaledBlockSize1) ) 1141 { 1142 uiOri = 3; 1143 ruhXe = (UChar)Max( ((uiScaledBlockSize1)  (iYe  (uiScaledBlockSize1))), 0 ); 1144 ruhYe = (UChar)(uiScaledBlockSize1); 1145 return; 1146 } 1147 else 1148 { 1149 uiOri = 5; 1150 ruhXe = (UChar)(uiScaledBlockSize1); 1151 ruhYe = (UChar)iYe; 1152 std::swap( ruhXs, ruhXe ); 1153 std::swap( ruhYs, ruhYe ); 1154 return; 1155 } 1156 } 1157 } 1158 1159 // case origin 1160 if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 ) 1161 { 1162 if( iDeltaX*iDeltaY < 0 ) 1163 { 1164 return; 1165 } 1166 1167 ruhXs = 0; 1168 ruhYs = 0; 1169 1170 if( iDeltaY == 0 ) 1171 { 1172 uiOri = 1; 1173 ruhXe = (UChar)(uiScaledBlockSize1); 1174 ruhYe = 0; 1175 std::swap( ruhXs, ruhXe ); 1176 std::swap( ruhYs, ruhYe ); 1177 return; 1178 } 1179 1180 if( iDeltaX == 0 ) 1181 { 1182 uiOri = 0; 1183 ruhXe = 0; 1184 ruhYe = (UChar)(uiScaledBlockSize1); 1185 return; 1186 } 1187 1188 Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)(uiScaledBlockSize1) * ((Double)iDeltaX / (Double)iDeltaY) ); 1189 1190 if( iVirtualEndX > (uiScaledBlockSize1) ) 1191 { 1192 Int iYe = roftoi( (Double)((Int)(uiScaledBlockSize1)  (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) )  iDeltaEnd; 1193 if( iYe < (Int)uiScaledBlockSize ) 1194 { 1195 uiOri = 1; 1196 ruhXe = (UChar)(uiScaledBlockSize1); 1197 ruhYe = (UChar)Max( iYe, 0 ); 1198 std::swap( ruhXs, ruhXe ); 1199 std::swap( ruhYs, ruhYe ); 1200 return; 1201 } 1202 else 1203 { 1204 uiOri = 3; 1205 ruhXe = (UChar)Max( ((uiScaledBlockSize1)  (iYe  (uiScaledBlockSize1))), 0 ); 1206 ruhYe = (UChar)(uiScaledBlockSize1); 1207 return; 1208 } 1209 } 1210 else 1211 { 1212 Int iXe = iVirtualEndX + iDeltaEnd; 1213 if( iXe < 0 ) 1214 { 1215 uiOri = 0; 1216 ruhXe = 0; 1217 ruhYe = (UChar)Max( ((uiScaledBlockSize1) + iXe), 0 ); 1218 return; 1219 } 1220 else if( iXe > (uiScaledBlockSize1) ) 1221 { 1222 uiOri = 1; 1223 ruhXe = (UChar)(uiScaledBlockSize1); 1224 ruhYe = (UChar)Max( ((uiScaledBlockSize1)  (iXe  (uiScaledBlockSize1))), 0 ); 1225 std::swap( ruhXs, ruhXe ); 1226 std::swap( ruhYs, ruhYe ); 1227 return; 1228 } 1229 else 1230 { 1231 uiOri = 3; 1232 ruhXe = (UChar)iXe; 1233 ruhYe = (UChar)(uiScaledBlockSize1); 1234 return; 1235 } 1236 } 1237 } 1238 } 1239 1240 Bool TComPrediction::getWedgeListIdx( WedgeList* pcWedgeList, WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ) 1241 { 1242 ruiTabIdx = 0; 1243 1244 for( UInt uiIdx = 0; uiIdx < pcWedgeList>size(); uiIdx++ ) 1245 { 1246 TComWedgelet* pcTestWedge = &(pcWedgeList>at(uiIdx)); 1247 1248 if( pcTestWedge>getStartX() == uhXs && 1249 pcTestWedge>getStartY() == uhYs && 1250 pcTestWedge>getEndX() == uhXe && 1251 pcTestWedge>getEndY() == uhYe ) 1252 { 1253 ruiTabIdx = uiIdx; 1254 return true; 1255 } 1256 } 1257 1258 // additionally search in WedgeRef lists of duplicated patterns 1259 for( UInt uiIdx = 0; uiIdx < pcWedgeRefList>size(); uiIdx++ ) 1260 { 1261 TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList>at(uiIdx)); 1262 1263 if( pcTestWedgeRef>getStartX() == uhXs && 1264 pcTestWedgeRef>getStartY() == uhYs && 1265 pcTestWedgeRef>getEndX() == uhXe && 1266 pcTestWedgeRef>getEndY() == uhYe ) 1267 { 1268 ruiTabIdx = pcTestWedgeRef>getRefIdx(); 1269 return true; 1270 } 1271 } 1272 389 // Create the prediction 390 #if LOGI_INTRA_NAME_3MPM 391 xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false ); 392 #else 393 xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, g_aucAngIntraModeOrder[ uiDirMode ], bAbove, bLeft, false ); 394 #endif 395 } 396 } 397 398 /** Function for checking identical motion. 399 * \param TComDataCU* pcCU 400 * \param UInt PartAddr 401 */ 402 Bool TComPrediction::xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr ) 403 { 404 if( pcCU>getSlice()>isInterB() && pcCU>getSlice()>getPPS()>getWPBiPredIdc() == 0 ) 405 { 406 if( pcCU>getCUMvField(REF_PIC_LIST_0)>getRefIdx(PartAddr) >= 0 && pcCU>getCUMvField(REF_PIC_LIST_1)>getRefIdx(PartAddr) >= 0) 407 { 408 Int RefPOCL0 = pcCU>getSlice()>getRefPic(REF_PIC_LIST_0, pcCU>getCUMvField(REF_PIC_LIST_0)>getRefIdx(PartAddr))>getPOC(); 409 Int RefViewIdL0 = pcCU>getSlice()>getRefPic(REF_PIC_LIST_0, pcCU>getCUMvField(REF_PIC_LIST_0)>getRefIdx(PartAddr))>getViewId(); 410 Int RefPOCL1 = pcCU>getSlice()>getRefPic(REF_PIC_LIST_1, pcCU>getCUMvField(REF_PIC_LIST_1)>getRefIdx(PartAddr))>getPOC(); 411 Int RefViewIdL1 = pcCU>getSlice()>getRefPic(REF_PIC_LIST_1, pcCU>getCUMvField(REF_PIC_LIST_1)>getRefIdx(PartAddr))>getViewId(); 412 if(RefPOCL0 == RefPOCL1 && RefViewIdL0 == RefViewIdL1 && pcCU>getCUMvField(REF_PIC_LIST_0)>getMv(PartAddr) == pcCU>getCUMvField(REF_PIC_LIST_1)>getMv(PartAddr)) 413 { 414 return true; 415 } 416 } 417 } 1273 418 return false; 1274 419 } 1275 1276 Void TComPrediction::xPredIntraWedgeDir( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iWedgeDeltaEnd, Int iDeltaDC1, Int iDeltaDC2 )1277 {1278 assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE );1279 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])];1280 1281 // get wedge pattern1282 UInt uiDirWedgeTabIdx = 0;1283 if( bEncoder )1284 {1285 // encoder: load stored wedge pattern from CU1286 uiDirWedgeTabIdx = pcCU>getWedgePredDirTabIdx( uiAbsPartIdx );1287 }1288 else1289 {1290 uiDirWedgeTabIdx = getBestContinueWedge( pcCU, uiAbsPartIdx, iWidth, iHeight, iWedgeDeltaEnd );1291 1292 UInt uiDepth = (pcCU>getDepth(0)) + (pcCU>getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1);1293 pcCU>setWedgePredDirTabIdxSubParts( uiDirWedgeTabIdx, uiAbsPartIdx, uiDepth );1294 }1295 TComWedgelet* pcWedgelet = &(pacWedgeList>at(uiDirWedgeTabIdx));1296 1297 // get wedge pred DCs1298 Int iPredDC1 = 0;1299 Int iPredDC2 = 0;1300 1301 Int* piMask = pcCU>getPattern()>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );1302 Int iMaskStride = ( iWidth<<1 ) + 1;1303 piMask += iMaskStride+1;1304 getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );1305 1306 if( bDelta )1307 {1308 xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );1309 xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );1310 }1311 1312 // assign wedge pred DCs to prediction1313 if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }1314 else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); }1315 }1316 #endif1317 1318 #if HHI_DMM_PRED_TEX1319 Void TComPrediction::xPredIntraWedgeTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 )1320 {1321 assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE );1322 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])];1323 1324 // get wedge pattern1325 UInt uiTextureWedgeTabIdx = 0;1326 if( bEncoder )1327 {1328 // encoder: load stored wedge pattern from CU1329 uiTextureWedgeTabIdx = pcCU>getWedgePredTexTabIdx( uiAbsPartIdx );1330 }1331 else1332 {1333 // decoder: get and store wedge pattern in CU1334 uiTextureWedgeTabIdx = getBestWedgeFromText( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight );1335 UInt uiDepth = (pcCU>getDepth(0)) + (pcCU>getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1);1336 pcCU>setWedgePredTexTabIdxSubParts( uiTextureWedgeTabIdx, uiAbsPartIdx, uiDepth );1337 }1338 TComWedgelet* pcWedgelet = &(pacWedgeList>at(uiTextureWedgeTabIdx));1339 1340 // get wedge pred DCs1341 Int iPredDC1 = 0;1342 Int iPredDC2 = 0;1343 Int* piMask = pcCU>getPattern()>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );1344 Int iMaskStride = ( iWidth<<1 ) + 1;1345 piMask += iMaskStride+1;1346 getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );1347 1348 if( bDelta )1349 {1350 xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );1351 xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );1352 }1353 1354 // assign wedge pred DCs to prediction1355 if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }1356 else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); }1357 }1358 1359 Void TComPrediction::xPredIntraContourTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 )1360 {1361 // get contour pattern1362 TComWedgelet* pcContourWedge = new TComWedgelet( iWidth, iHeight );1363 getBestContourFromText( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight, pcContourWedge );1364 1365 // get wedge pred DCs1366 Int iPredDC1 = 0;1367 Int iPredDC2 = 0;1368 Int* piMask = pcCU>getPattern()>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );1369 Int iMaskStride = ( iWidth<<1 ) + 1;1370 piMask += iMaskStride+1;1371 getWedgePredDCs( pcContourWedge, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );1372 1373 if( bDelta )1374 {1375 xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );1376 xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );1377 }1378 1379 // assign wedge pred DCs to prediction1380 if( bDelta ) { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }1381 else { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, iPredDC1, iPredDC2 ); }1382 1383 pcContourWedge>destroy();1384 delete pcContourWedge;1385 }1386 1387 Void TComPrediction::getBestContourFromText( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge, Pel* piTextureBlock )1388 {1389 pcContourWedge>clear();1390 Bool* pabContourPattern = pcContourWedge>getPattern();1391 1392 // get copy of according texture luma block1393 Pel* piTempY = NULL;1394 TComYuv cTempYuv;1395 1396 if ( piTextureBlock )1397 {1398 piTempY = piTextureBlock;1399 }1400 else1401 {1402 cTempYuv.create( uiWidth, uiHeight ); cTempYuv.clear();1403 piTempY = cTempYuv.getLumaAddr();1404 1405 fillTexturePicTempBlock( pcCU, uiAbsPartIdx, piTempY, uiWidth, uiHeight );1406 1407 piTempY = cTempYuv.getLumaAddr();1408 }1409 1410 // find contour for texture luma block1411 UInt iDC = 0;1412 for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) { iDC += piTempY[k]; }1413 iDC /= (uiWidth*uiHeight);1414 1415 if ( piTextureBlock )1416 {1417 piTempY = piTextureBlock;1418 }1419 else1420 {1421 piTempY = cTempYuv.getLumaAddr();1422 }1423 1424 for( UInt k = 0; k < (uiWidth*uiHeight); k++ )1425 {1426 pabContourPattern[k] = (piTempY[k] > iDC) ? true : false;1427 }1428 1429 cTempYuv.destroy();1430 }1431 1432 UInt TComPrediction::getBestWedgeFromText( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, WedgeDist eWedgeDist, Pel* piTextureBlock )1433 {1434 assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE );1435 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];1436 1437 // get copy of according texture luma block1438 Pel* piTempY = NULL;1439 TComYuv cTempYuv;1440 1441 if ( piTextureBlock )1442 {1443 piTempY = piTextureBlock;1444 }1445 else1446 {1447 cTempYuv.create( uiWidth, uiHeight ); cTempYuv.clear();1448 piTempY = cTempYuv.getLumaAddr();1449 1450 fillTexturePicTempBlock( pcCU, uiAbsPartIdx, piTempY, uiWidth, uiHeight );1451 1452 piTempY = cTempYuv.getLumaAddr();1453 }1454 1455 TComWedgeDist cWedgeDist;1456 UInt uiTextureWedgeTabIdx = 0;1457 1458 // local pred buffer1459 TComYuv cPredYuv;1460 cPredYuv.create( uiWidth, uiHeight );1461 cPredYuv.clear();1462 1463 UInt uiPredStride = cPredYuv.getStride();1464 Pel* piPred = cPredYuv.getLumaAddr();1465 1466 Int iDC1 = 0;1467 Int iDC2 = 0;1468 // regular wedge search1469 UInt uiBestDist = MAX_UINT;1470 UInt uiBestTabIdx = 0;1471 1472 for( UInt uiIdx = 0; uiIdx < pacWedgeList>size(); uiIdx++ )1473 {1474 calcWedgeDCs ( &(pacWedgeList>at(uiIdx)), piTempY, uiWidth, iDC1, iDC2 );1475 assignWedgeDCs2Pred( &(pacWedgeList>at(uiIdx)), piPred, uiPredStride, iDC1, iDC2 );1476 1477 UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piTempY, uiWidth, uiWidth, uiHeight, eWedgeDist );1478 1479 if( uiActDist < uiBestDist  uiBestDist == MAX_UINT )1480 {1481 uiBestDist = uiActDist;1482 uiBestTabIdx = uiIdx;1483 }1484 }1485 uiTextureWedgeTabIdx = uiBestTabIdx;1486 1487 cPredYuv.destroy();1488 cTempYuv.destroy();1489 return uiTextureWedgeTabIdx;1490 }1491 1492 Void TComPrediction::fillTexturePicTempBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piTempBlockY, UInt uiWidth, UInt uiHeight )1493 {1494 TComPicYuv* pcPicYuvRef = pcCU>getSlice()>getTexturePic()>getPicYuvRec();1495 Int iRefStride = pcPicYuvRef>getStride();1496 Pel* piRefY;1497 1498 piRefY = pcPicYuvRef>getLumaAddr( pcCU>getAddr(), pcCU>getZorderIdxInCU() + uiAbsPartIdx );1499 1500 for ( Int y = 0; y < uiHeight; y++ )1501 {1502 ::memcpy(piTempBlockY, piRefY, sizeof(Pel)*uiWidth);1503 piTempBlockY += uiWidth;1504 piRefY += iRefStride;1505 }1506 }1507 #endif1508 420 1509 421 #if DEPTH_MAP_GENERATION 1510 422 Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY ) 1511 423 #else 1512 Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )424 Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) 1513 425 #endif 1514 426 { … … 1531 443 if ( eRefPicList != REF_PIC_LIST_X ) 1532 444 { 445 if( pcCU>getSlice()>getPPS()>getUseWP()) 446 { 1533 447 #if DEPTH_MAP_GENERATION 1534 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY ); 1535 #else 1536 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); 1537 #endif 1538 #ifdef WEIGHT_PRED 448 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); 449 #else 450 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, true ); 451 #endif 452 } 453 else 454 { 455 #if DEPTH_MAP_GENERATION 456 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); 457 #else 458 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false ); 459 #endif 460 } 1539 461 if ( pcCU>getSlice()>getPPS()>getUseWP() ) 1540 462 { 1541 463 xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); 1542 464 } 1543 #endif1544 465 } 1545 466 else 1546 467 { 1547 468 #if DEPTH_MAP_GENERATION 1548 xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); 1549 #else 1550 xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx ); 1551 #endif 469 if( xCheckIdenticalMotion( pcCU, uiPartAddr ) && !bPrdDepthMap ) 470 #else 471 if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) 472 #endif 473 { 474 #if DEPTH_MAP_GENERATION 475 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); 476 #else 477 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, false ); 478 #endif 479 } 480 else 481 { 482 #if DEPTH_MAP_GENERATION 483 xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); 484 #else 485 xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx ); 486 #endif 487 } 1552 488 } 1553 489 return; … … 1568 504 if ( eRefPicList != REF_PIC_LIST_X ) 1569 505 { 506 if( pcCU>getSlice()>getPPS()>getUseWP()) 507 { 1570 508 #if DEPTH_MAP_GENERATION 1571 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY ); 1572 #else 1573 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); 1574 #endif 1575 #ifdef WEIGHT_PRED 509 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); 510 #else 511 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, true ); 512 #endif 513 } 514 else 515 { 516 #if DEPTH_MAP_GENERATION 517 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); 518 #else 519 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false ); 520 #endif 521 } 522 #if DEPTH_MAP_GENERATION 523 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); 524 #else 525 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false ); 526 #endif 1576 527 if ( pcCU>getSlice()>getPPS()>getUseWP() ) 1577 528 { 1578 529 xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx ); 1579 530 } 1580 #endif1581 531 } 1582 532 else 1583 533 { 534 if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) ) 535 { 1584 536 #if DEPTH_MAP_GENERATION 1585 xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); 1586 #else 1587 xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx ); 1588 #endif 537 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); 538 #else 539 xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, false ); 540 #endif 541 } 542 else 543 { 544 #if DEPTH_MAP_GENERATION 545 xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap ); 546 #else 547 xPredInterBi (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx ); 548 #endif 549 } 1589 550 } 1590 551 } … … 1592 553 } 1593 554 1594 #if HIGH_ACCURACY_BI 555 556 1595 557 #if DEPTH_MAP_GENERATION 1596 558 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi ) 1597 559 #else 1598 560 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi ) 1599 #endif1600 #else1601 #if DEPTH_MAP_GENERATION1602 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )1603 #else1604 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx )1605 #endif1606 561 #endif 1607 562 { … … 1614 569 { 1615 570 UInt uiRShift = 0; 1616 xPredInterPrdDepthMap( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift );571 xPredInterPrdDepthMap( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 ); 1617 572 return; 1618 573 } … … 1622 577 if( pcCU>getSlice()>getSPS()>isDepth() ) 1623 578 { 1624 #if HIGH_ACCURACY_BI1625 579 UInt uiRShift = ( bi ? 14g_uiBitDepthg_uiBitIncrement : 0 ); 1626 #else 1627 UInt uiRShift = 0; 1628 #endif 580 UInt uiOffset = bi ? IF_INTERNAL_OFFS : 0; 1629 581 #if DEPTH_MAP_GENERATION 1630 xPredInterPrdDepthMap( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift );1631 #else 1632 xPredInterPrdDepthMap( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift );582 xPredInterPrdDepthMap( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift, uiOffset ); 583 #else 584 xPredInterPrdDepthMap( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, uiOffset ); 1633 585 #endif 1634 586 } … … 1636 588 { 1637 589 #endif 1638 #if HIGH_ACCURACY_BI 1639 if(!bi) 1640 { 1641 xPredInterLumaBlk ( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec() , uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); 1642 } 1643 else 1644 { 1645 xPredInterLumaBlk_ha ( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec() , uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); 1646 } 1647 #else 1648 xPredInterLumaBlk ( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); 1649 #endif 590 xPredInterLumaBlk ( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); 1650 591 #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC 1651 592 } 1652 593 #endif 1653 1654 #if HIGH_ACCURACY_BI 1655 if (!bi) 1656 { 1657 xPredInterChromaBlk ( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); 1658 } 1659 else 1660 { 1661 xPredInterChromaBlk_ha ( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec() , uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); 1662 } 1663 #else 1664 xPredInterChromaBlk ( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred ); 1665 #endif 1666 } 594 xPredInterChromaBlk( pcCU, pcCU>getSlice()>getRefPic( eRefPicList, iRefIdx )>getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi ); 595 } 596 1667 597 1668 598 #if DEPTH_MAP_GENERATION … … 1688 618 1689 619 pcMbYuv = &m_acYuvPred[iRefList]; 1690 #if HIGH_ACCURACY_BI1691 620 if( pcCU>getCUMvField( REF_PIC_LIST_0 )>getRefIdx( uiPartAddr ) >= 0 && pcCU>getCUMvField( REF_PIC_LIST_1 )>getRefIdx( uiPartAddr ) >= 0 ) 621 { 1692 622 #if DEPTH_MAP_GENERATION 1693 623 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); … … 1695 625 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true ); 1696 626 #endif 627 } 1697 628 else 629 { 630 if ( pcCU>getSlice()>getPPS()>getWPBiPredIdc() ) 631 { 1698 632 #if DEPTH_MAP_GENERATION 1699 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY ); 1700 #else 1701 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx ); 1702 #endif 1703 #else 633 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true ); 634 #else 635 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true ); 636 #endif 637 } 638 else 639 { 1704 640 #if DEPTH_MAP_GENERATION 1705 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY);1706 #else 1707 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx);1708 #endif 1709 #endif 1710 }1711 1712 #ifdef WEIGHT_PRED 641 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false ); 642 #else 643 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, false ); 644 #endif 645 } 646 } 647 } 648 1713 649 if ( pcCU>getSlice()>getPPS()>getWPBiPredIdc() ) 1714 650 { … … 1716 652 } 1717 653 else 1718 #endif 1719 654 { 1720 655 #if DEPTH_MAP_GENERATION 1721 if ( bPrdDepthMap )1722 {1723 xWeightedAveragePdm( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, uiSubSampExpX, uiSubSampExpY );1724 }1725 else1726 {656 if ( bPrdDepthMap ) 657 { 658 xWeightedAveragePdm( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, uiSubSampExpX, uiSubSampExpY ); 659 } 660 else 661 { 1727 662 xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); 1728 663 } 1729 664 #else 1730 xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); 1731 #endif 1732 1733 } 1734 665 xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); 666 #endif 667 } 668 } 1735 669 1736 670 Void 1737 671 #if DEPTH_MAP_GENERATION 1738 TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift )1739 #else 1740 TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift )672 TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset ) 673 #else 674 TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset ) 1741 675 #endif 1742 676 { … … 1769 703 iHor = pcMv>getHor() * 4; 1770 704 iVer = pcMv>getVer() * 4; 1771 705 } 1772 706 #endif 1773 707 Int ixFrac = iHor & 0x3; … … 1779 713 Pel* piDstY = rpcYuv>getLumaAddr( uiPartAddr ); 1780 714 1781 for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride ) 1782 { 1783 for( Int x = 0; x < iWidth; x++ ) 1784 { 1785 piDstY[ x ] = piRefY[ x ] << uiRShift; 1786 } 1787 } 1788 } 1789 1790 1791 1792 #if HIGH_ACCURACY_BI 1793 1794 Void TComPrediction::xPredInterLumaBlk_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) 1795 { 1796 Int iRefStride = pcPicYuvRef>getStride(); 1797 Int iDstStride = rpcYuv>getStride(); 1798 1799 Int iRefOffset = ( pcMv>getHor() >> 2 ) + ( pcMv>getVer() >> 2 ) * iRefStride; 1800 Pel* piRefY = pcPicYuvRef>getLumaAddr( pcCU>getAddr(), pcCU>getZorderIdxInCU() + uiPartAddr ) + iRefOffset; 1801 1802 Int ixFrac = pcMv>getHor() & 0x3; 1803 Int iyFrac = pcMv>getVer() & 0x3; 1804 1805 Pel* piDstY = rpcYuv>getLumaAddr( uiPartAddr ); 1806 UInt shiftNum = 14g_uiBitDepthg_uiBitIncrement; 1807 // Integer point 1808 if ( ixFrac == 0 && iyFrac == 0 ) 1809 { 1810 for ( Int y = 0; y < iHeight; y++ ) 1811 { 1812 for(Int x=0; x<iWidth; x++) 1813 piDstY[x] = piRefY[x]<<shiftNum; 1814 piDstY += iDstStride; 1815 piRefY += iRefStride; 1816 } 1817 return; 1818 } 1819 1820 // Halfpel horizontal 1821 if ( ixFrac == 2 && iyFrac == 0 ) 1822 { 1823 xCTI_FilterHalfHor_ha ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 1824 return; 1825 } 1826 1827 // Halfpel vertical 1828 if ( ixFrac == 0 && iyFrac == 2 ) 1829 { 1830 xCTI_FilterHalfVer_ha ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 1831 return; 1832 } 1833 1834 Int iExtStride = m_iYuvExtStride;//m_cYuvExt.getStride(); 1835 Int* piExtY = m_piYuvExt;//m_cYuvExt.getLumaAddr(); 1836 1837 // Halfpel center 1838 if ( ixFrac == 2 && iyFrac == 2 ) 1839 { 1840 xCTI_FilterHalfVer (piRefY  3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); 1841 xCTI_FilterHalfHor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 1842 return; 1843 } 1844 1845 // Quaterpel horizontal 1846 if ( iyFrac == 0) 1847 { 1848 if ( ixFrac == 1) 1849 { 1850 xCTI_FilterQuarter0Hor_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 1851 return; 1852 } 1853 if ( ixFrac == 3) 1854 { 1855 xCTI_FilterQuarter1Hor_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 1856 return; 1857 } 1858 } 1859 if ( iyFrac == 2 ) 1860 { 1861 if ( ixFrac == 1) 1862 { 1863 xCTI_FilterHalfVer (piRefY 3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); 1864 xCTI_FilterQuarter0Hor_ha (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 1865 return; 1866 } 1867 if ( ixFrac == 3) 1868 { 1869 xCTI_FilterHalfVer (piRefY  3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 1870 xCTI_FilterQuarter1Hor_ha (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 1871 return; 1872 } 1873 } 1874 1875 // Quaterpel vertical 1876 if( ixFrac == 0 ) 1877 { 1878 if( iyFrac == 1 ) 1879 { 1880 xCTI_FilterQuarter0Ver_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 1881 return; 1882 } 1883 if( iyFrac == 3 ) 1884 { 1885 xCTI_FilterQuarter1Ver_ha( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 1886 return; 1887 } 1888 } 1889 1890 if( ixFrac == 2 ) 1891 { 1892 if( iyFrac == 1 ) 1893 { 1894 xCTI_FilterQuarter0Ver (piRefY  3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 1895 xCTI_FilterHalfHor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 1896 1897 return; 1898 } 1899 if( iyFrac == 3 ) 1900 { 1901 xCTI_FilterQuarter1Ver (piRefY 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 1902 xCTI_FilterHalfHor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 1903 return; 1904 } 1905 } 1906 1907 /// Quarterpel center 1908 if ( iyFrac == 1) 1909 { 1910 if ( ixFrac == 1) 1911 { 1912 xCTI_FilterQuarter0Ver (piRefY  3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 1913 xCTI_FilterQuarter0Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 1914 return; 1915 } 1916 if ( ixFrac == 3) 1917 { 1918 xCTI_FilterQuarter0Ver (piRefY  3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); 1919 xCTI_FilterQuarter1Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 1920 1921 return; 1922 } 1923 } 1924 if ( iyFrac == 3 ) 1925 { 1926 if ( ixFrac == 1) 1927 { 1928 xCTI_FilterQuarter1Ver (piRefY  3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 1929 xCTI_FilterQuarter0Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 1930 return; 1931 } 1932 if ( ixFrac == 3) 1933 { 1934 xCTI_FilterQuarter1Ver (piRefY  3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 1935 xCTI_FilterQuarter1Hor_ha (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 1936 return; 1937 } 1938 } 1939 } 1940 1941 #endif 1942 1943 Void TComPrediction::xPredInterLumaBlk( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) 1944 { 1945 Int iRefStride = pcPicYuvRef>getStride(); 1946 Int iDstStride = rpcYuv>getStride(); 1947 1948 Int iRefOffset = ( pcMv>getHor() >> 2 ) + ( pcMv>getVer() >> 2 ) * iRefStride; 1949 Pel* piRefY = pcPicYuvRef>getLumaAddr( pcCU>getAddr(), pcCU>getZorderIdxInCU() + uiPartAddr ) + iRefOffset; 1950 1951 Int ixFrac = pcMv>getHor() & 0x3; 1952 Int iyFrac = pcMv>getVer() & 0x3; 1953 1954 Pel* piDstY = rpcYuv>getLumaAddr( uiPartAddr ); 1955 1956 // Integer point 1957 if ( ixFrac == 0 && iyFrac == 0 ) 1958 { 1959 for ( Int y = 0; y < iHeight; y++ ) 1960 { 1961 ::memcpy(piDstY, piRefY, sizeof(Pel)*iWidth); 1962 piDstY += iDstStride; 1963 piRefY += iRefStride; 1964 } 1965 return; 1966 } 1967 1968 // Halfpel horizontal 1969 if ( ixFrac == 2 && iyFrac == 0 ) 1970 { 1971 xCTI_FilterHalfHor ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 1972 return; 1973 } 1974 1975 // Halfpel vertical 1976 if ( ixFrac == 0 && iyFrac == 2 ) 1977 { 1978 xCTI_FilterHalfVer ( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 1979 return; 1980 } 1981 1982 Int iExtStride = m_iYuvExtStride;//m_cYuvExt.getStride(); 1983 Int* piExtY = m_piYuvExt;//m_cYuvExt.getLumaAddr(); 1984 1985 // Halfpel center 1986 if ( ixFrac == 2 && iyFrac == 2 ) 1987 { 1988 1989 xCTI_FilterHalfVer (piRefY  3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); 1990 xCTI_FilterHalfHor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 1991 return; 1992 } 1993 1994 // Quaterpel horizontal 1995 if ( iyFrac == 0) 1996 { 1997 if ( ixFrac == 1) 1998 { 1999 xCTI_FilterQuarter0Hor( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 2000 return; 2001 } 2002 if ( ixFrac == 3) 2003 { 2004 xCTI_FilterQuarter1Hor( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 2005 return; 2006 } 2007 } 2008 if ( iyFrac == 2 ) 2009 { 2010 if ( ixFrac == 1) 2011 { 2012 xCTI_FilterHalfVer (piRefY 3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); 2013 xCTI_FilterQuarter0Hor (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 2014 return; 2015 } 2016 if ( ixFrac == 3) 2017 { 2018 xCTI_FilterHalfVer (piRefY  3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 2019 xCTI_FilterQuarter1Hor (piExtY + 3, iExtStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 2020 return; 2021 } 2022 } 2023 2024 // Quaterpel vertical 2025 if( ixFrac == 0 ) 2026 { 2027 if( iyFrac == 1 ) 2028 { 2029 xCTI_FilterQuarter0Ver( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 2030 return; 2031 } 2032 if( iyFrac == 3 ) 2033 { 2034 xCTI_FilterQuarter1Ver( piRefY, iRefStride, 1, iWidth, iHeight, iDstStride, 1, piDstY ); 2035 return; 2036 } 2037 } 2038 2039 if( ixFrac == 2 ) 2040 { 2041 if( iyFrac == 1 ) 2042 { 2043 xCTI_FilterQuarter0Ver (piRefY  3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 2044 xCTI_FilterHalfHor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 2045 return; 2046 } 2047 if( iyFrac == 3 ) 2048 { 2049 xCTI_FilterQuarter1Ver (piRefY 3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 2050 xCTI_FilterHalfHor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 2051 return; 2052 } 2053 } 2054 2055 /// Quarterpel center 2056 if ( iyFrac == 1) 2057 { 2058 if ( ixFrac == 1) 2059 { 2060 xCTI_FilterQuarter0Ver (piRefY  3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 2061 xCTI_FilterQuarter0Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 2062 return; 2063 } 2064 if ( ixFrac == 3) 2065 { 2066 xCTI_FilterQuarter0Ver (piRefY  3, iRefStride, 1, iWidth +7, iHeight, iExtStride, 1, piExtY ); 2067 xCTI_FilterQuarter1Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 2068 return; 2069 } 2070 } 2071 if ( iyFrac == 3 ) 2072 { 2073 if ( ixFrac == 1) 2074 { 2075 xCTI_FilterQuarter1Ver (piRefY  3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 2076 xCTI_FilterQuarter0Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 2077 return; 2078 } 2079 if ( ixFrac == 3) 2080 { 2081 xCTI_FilterQuarter1Ver (piRefY  3, iRefStride, 1, iWidth + 7, iHeight, iExtStride, 1, piExtY ); 2082 xCTI_FilterQuarter1Hor (piExtY + 3, iExtStride, 1, iWidth , iHeight, iDstStride, 1, piDstY ); 2083 return; 2084 } 2085 } 2086 } 2087 2088 #if HIGH_ACCURACY_BI 2089 Void TComPrediction::xPredInterChromaBlk_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) 2090 { 2091 Int iRefStride = pcPicYuvRef>getCStride(); 2092 Int iDstStride = rpcYuv>getCStride(); 2093 2094 Int iRefOffset = (pcMv>getHor() >> 3) + (pcMv>getVer() >> 3) * iRefStride; 2095 2096 Pel* piRefCb = pcPicYuvRef>getCbAddr( pcCU>getAddr(), pcCU>getZorderIdxInCU() + uiPartAddr ) + iRefOffset; 2097 Pel* piRefCr = pcPicYuvRef>getCrAddr( pcCU>getAddr(), pcCU>getZorderIdxInCU() + uiPartAddr ) + iRefOffset; 2098 2099 Pel* piDstCb = rpcYuv>getCbAddr( uiPartAddr ); 2100 Pel* piDstCr = rpcYuv>getCrAddr( uiPartAddr ); 2101 2102 Int ixFrac = pcMv>getHor() & 0x7; 2103 Int iyFrac = pcMv>getVer() & 0x7; 2104 UInt uiCWidth = iWidth >> 1; 2105 UInt uiCHeight = iHeight >> 1; 2106 2107 xDCTIF_FilterC_ha(piRefCb, iRefStride,piDstCb,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); 2108 xDCTIF_FilterC_ha(piRefCr, iRefStride,piDstCr,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); 2109 return; 2110 } 2111 #endif 2112 2113 // 2114 Void TComPrediction::xPredInterChromaBlk( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ) 2115 { 2116 Int iRefStride = pcPicYuvRef>getCStride(); 2117 Int iDstStride = rpcYuv>getCStride(); 2118 2119 Int iRefOffset = (pcMv>getHor() >> 3) + (pcMv>getVer() >> 3) * iRefStride; 2120 2121 Pel* piRefCb = pcPicYuvRef>getCbAddr( pcCU>getAddr(), pcCU>getZorderIdxInCU() + uiPartAddr ) + iRefOffset; 2122 Pel* piRefCr = pcPicYuvRef>getCrAddr( pcCU>getAddr(), pcCU>getZorderIdxInCU() + uiPartAddr ) + iRefOffset; 2123 2124 Pel* piDstCb = rpcYuv>getCbAddr( uiPartAddr ); 2125 Pel* piDstCr = rpcYuv>getCrAddr( uiPartAddr ); 2126 2127 Int ixFrac = pcMv>getHor() & 0x7; 2128 Int iyFrac = pcMv>getVer() & 0x7; 2129 UInt uiCWidth = iWidth >> 1; 2130 UInt uiCHeight = iHeight >> 1; 2131 2132 xDCTIF_FilterC(piRefCb, iRefStride,piDstCb,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); 2133 xDCTIF_FilterC(piRefCr, iRefStride,piDstCr,iDstStride,uiCWidth,uiCHeight, iyFrac, ixFrac); 2134 return; 2135 } 2136 2137 Void TComPrediction::xDCTIF_FilterC ( Pel* piRefC, Int iRefStride,Pel* piDstC,Int iDstStride, 2138 Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac) 2139 { 2140 // Integer point 2141 if ( iMVxFrac == 0 && iMVyFrac == 0 ) 2142 { 2143 for ( Int y = 0; y < iHeight; y++ ) 2144 { 2145 ::memcpy(piDstC, piRefC, sizeof(Pel)*iWidth); 2146 piDstC += iDstStride; 2147 piRefC += iRefStride; 2148 } 2149 return; 2150 } 2151 2152 if ( iMVyFrac == 0 ) 2153 { 2154 xCTI_Filter1DHorC (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVxFrac ); 2155 return; 2156 } 2157 2158 if ( iMVxFrac == 0 ) 2159 { 2160 xCTI_Filter1DVerC (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVyFrac ); 2161 return; 2162 } 2163 2164 Int iExtStride = m_iYuvExtStride; 2165 Int* piExtC = m_piYuvExt; 2166 2167 xCTI_Filter2DVerC (piRefC  1, iRefStride, iWidth + 3, iHeight, iExtStride, piExtC, iMVyFrac ); 2168 xCTI_Filter2DHorC (piExtC + 1, iExtStride, iWidth , iHeight, iDstStride, piDstC, iMVxFrac ); 2169 } 2170 2171 #if HIGH_ACCURACY_BI 2172 2173 Void TComPrediction::xDCTIF_FilterC_ha ( Pel* piRefC, Int iRefStride,Pel* piDstC,Int iDstStride, 2174 Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac) 2175 { 2176 UInt shiftNumOrg = 6  g_uiBitIncrement + 8  g_uiBitDepth; 2177 // Integer point 2178 if ( iMVxFrac == 0 && iMVyFrac == 0 ) 2179 { 2180 for (Int y = 0; y < iHeight; y++ ) 2181 { 2182 for(Int x=0; x<iWidth; x++) 2183 { 2184 piDstC[x] = (piRefC[x]<<shiftNumOrg); 2185 } 2186 piDstC += iDstStride; 2187 piRefC += iRefStride; 2188 } 2189 return; 2190 } 2191 2192 if ( iMVyFrac == 0 ) 2193 { 2194 xCTI_Filter1DHorC_ha (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVxFrac ); 2195 return; 2196 2197 } 2198 2199 if ( iMVxFrac == 0 ) 2200 { 2201 xCTI_Filter1DVerC_ha (piRefC, iRefStride, iWidth, iHeight, iDstStride, piDstC, iMVyFrac ); 2202 return; 2203 } 2204 2205 Int iExtStride = m_iYuvExtStride; 2206 Int* piExtC = m_piYuvExt; 2207 2208 xCTI_Filter2DVerC (piRefC  1, iRefStride, iWidth + 3, iHeight, iExtStride, piExtC, iMVyFrac ); 2209 xCTI_Filter2DHorC_ha (piExtC + 1, iExtStride, iWidth , iHeight, iDstStride, piDstC, iMVxFrac ); 2210 return; 2211 2212 } 2213 2214 #endif 715 for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride ) 716 { 717 for( Int x = 0; x < iWidth; x++ ) 718 { 719 piDstY[ x ] = ( piRefY[ x ] << uiRShift )  uiOffset; 720 } 721 } 722 } 723 724 725 /** 726 * \brief Generate motioncompensated luma block 727 * 728 * \param cu Pointer to current CU 729 * \param refPic Pointer to reference picture 730 * \param partAddr Address of block within CU 731 * \param mv Motion vector 732 * \param width Width of block 733 * \param height Height of block 734 * \param dstPic Pointer to destination picture 735 * \param bi Flag indicating whether bipred is used 736 */ 737 Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi ) 738 { 739 Int refStride = refPic>getStride(); 740 Int refOffset = ( mv>getHor() >> 2 ) + ( mv>getVer() >> 2 ) * refStride; 741 Pel *ref = refPic>getLumaAddr( cu>getAddr(), cu>getZorderIdxInCU() + partAddr ) + refOffset; 742 743 Int dstStride = dstPic>getStride(); 744 Pel *dst = dstPic>getLumaAddr( partAddr ); 745 746 Int xFrac = mv>getHor() & 0x3; 747 Int yFrac = mv>getVer() & 0x3; 748 749 #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC 750 assert( ! cu>getSlice()>getIsDepth()  ( xFrac == 0 && yFrac == 0 ) ); 751 #endif 752 753 if ( yFrac == 0 ) 754 { 755 m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac, !bi ); 756 } 757 else if ( xFrac == 0 ) 758 { 759 m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi ); 760 } 761 else 762 { 763 Int tmpStride = m_filteredBlockTmp[0].getStride(); 764 Short *tmp = m_filteredBlockTmp[0].getLumaAddr(); 765 766 Int filterSize = NTAPS_LUMA; 767 Int halfFilterSize = ( filterSize >> 1 ); 768 769 m_if.filterHorLuma(ref  (halfFilterSize1)*refStride, refStride, tmp, tmpStride, width, height+filterSize1, xFrac, false ); 770 m_if.filterVerLuma(tmp + (halfFilterSize1)*tmpStride, tmpStride, dst, dstStride, width, height, yFrac, false, !bi); 771 } 772 } 773 774 /** 775 * \brief Generate motioncompensated chroma block 776 * 777 * \param cu Pointer to current CU 778 * \param refPic Pointer to reference picture 779 * \param partAddr Address of block within CU 780 * \param mv Motion vector 781 * \param width Width of block 782 * \param height Height of block 783 * \param dstPic Pointer to destination picture 784 * \param bi Flag indicating whether bipred is used 785 */ 786 Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi ) 787 { 788 Int refStride = refPic>getCStride(); 789 Int dstStride = dstPic>getCStride(); 790 791 Int refOffset = (mv>getHor() >> 3) + (mv>getVer() >> 3) * refStride; 792 793 Pel* refCb = refPic>getCbAddr( cu>getAddr(), cu>getZorderIdxInCU() + partAddr ) + refOffset; 794 Pel* refCr = refPic>getCrAddr( cu>getAddr(), cu>getZorderIdxInCU() + partAddr ) + refOffset; 795 796 Pel* dstCb = dstPic>getCbAddr( partAddr ); 797 Pel* dstCr = dstPic>getCrAddr( partAddr ); 798 799 Int xFrac = mv>getHor() & 0x7; 800 Int yFrac = mv>getVer() & 0x7; 801 UInt cxWidth = width >> 1; 802 UInt cxHeight = height >> 1; 803 804 Int extStride = m_filteredBlockTmp[0].getStride(); 805 Short* extY = m_filteredBlockTmp[0].getLumaAddr(); 806 807 Int filterSize = NTAPS_CHROMA; 808 809 Int halfFilterSize = (filterSize>>1); 810 811 if ( yFrac == 0 ) 812 { 813 m_if.filterHorChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, xFrac, !bi); 814 m_if.filterHorChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, xFrac, !bi); 815 } 816 else if ( xFrac == 0 ) 817 { 818 m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi); 819 m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi); 820 } 821 else 822 { 823 m_if.filterHorChroma(refCb  (halfFilterSize1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize1, xFrac, false); 824 m_if.filterVerChroma(extY + (halfFilterSize1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight , yFrac, false, !bi); 825 826 m_if.filterHorChroma(refCr  (halfFilterSize1)*refStride, refStride, extY, extStride, cxWidth, cxHeight+filterSize1, xFrac, false); 827 m_if.filterVerChroma(extY + (halfFilterSize1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight , yFrac, false, !bi); 828 } 829 } 2215 830 2216 831 #if DEPTH_MAP_GENERATION … … 2236 851 #endif 2237 852 2238 2239 853 Void TComPrediction::xWeightedAverage( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ) 2240 854 { 2241 855 if( iRefIdx0 >= 0 && iRefIdx1 >= 0 ) 2242 856 { 2243 #ifdef ROUNDING_CONTROL_BIPRED2244 rpcYuvDst>addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, pcCU>getSlice()>isRounding());2245 #else2246 857 rpcYuvDst>addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight ); 2247 #endif2248 858 } 2249 859 else if ( iRefIdx0 >= 0 && iRefIdx1 < 0 ) … … 2254 864 { 2255 865 pcYuvSrc1>copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight ); 2256 }2257 else2258 {2259 assert (0);2260 866 } 2261 867 } … … 2280 886 } 2281 887 2282 #if ADD_PLANAR_MODE2283 888 /** Function for deriving planar intra prediction. 2284 889 * \param pSrc pointer to reconstructed sample array … … 2288 893 * \param width the width of the block 2289 894 * \param height the height of the block 2290 * \param blkAboveAvailable boolean indication if the block above is available2291 * \param blkLeftAvailable boolean indication if the block to the left is available2292 895 * 2293 896 * This function derives the prediction samples for planar mode (intra coding). 2294 897 */ 2295 #if REFERENCE_SAMPLE_PADDING 2296 Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height ) 2297 #else 2298 Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, Bool blkAboveAvailable, Bool blkLeftAvailable ) 2299 #endif 898 Void TComPrediction::xPredIntraPlanar( Int* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height ) 2300 899 { 2301 900 assert(width == height); … … 2310 909 2311 910 // Get left and above reference column and row 2312 #if REFERENCE_SAMPLE_PADDING 2313 for(k=0;k<blkSize;k++) 911 for(k=0;k<blkSize+1;k++) 2314 912 { 2315 913 topRow[k] = pSrc[ksrcStride]; 2316 914 leftColumn[k] = pSrc[k*srcStride1]; 2317 915 } 2318 #else2319 if (!blkAboveAvailable && !blkLeftAvailable)2320 {2321 for(k=0;k<blkSize;k++)2322 {2323 leftColumn[k] = topRow[k] = ( 1 << ( g_uiBitDepth + g_uiBitIncrement  1 ) );2324 }2325 }2326 else2327 {2328 if(blkAboveAvailable)2329 {2330 for(k=0;k<blkSize;k++)2331 {2332 topRow[k] = pSrc[ksrcStride];2333 }2334 }2335 else2336 {2337 Int leftSample = pSrc[1];2338 for(k=0;k<blkSize;k++)2339 {2340 topRow[k] = leftSample;2341 }2342 }2343 if(blkLeftAvailable)2344 {2345 for(k=0;k<blkSize;k++)2346 {2347 leftColumn[k] = pSrc[k*srcStride1];2348 }2349 }2350 else2351 {2352 Int aboveSample = pSrc[srcStride];2353 for(k=0;k<blkSize;k++)2354 {2355 leftColumn[k] = aboveSample;2356 }2357 }2358 }2359 #endif2360 916 2361 917 // Prepare intermediate variables used in interpolation 2362 bottomLeft = leftColumn[blkSize 1];2363 topRight = topRow[blkSize 1];918 bottomLeft = leftColumn[blkSize]; 919 topRight = topRow[blkSize]; 2364 920 for (k=0;k<blkSize;k++) 2365 921 { … … 2382 938 } 2383 939 } 2384 #endif 2385 2386 #if LM_CHROMA 940 2387 941 /** Function for deriving chroma LM intra prediction. 2388 942 * \param pcPattern pointer to neighbouring pixel access pattern 2389 * \param p Src pointer to reconstructed chroma sample array943 * \param piSrc pointer to reconstructed chroma sample array 2390 944 * \param pPred pointer for the prediction sample array 2391 945 * \param uiPredStride the stride of the prediction sample array … … 2393 947 * \param uiCHeight the height of the chroma block 2394 948 * \param uiChromaId boolean indication of chroma component 2395 2396 \This function derives the prediction samples for chroma LM mode (chroma intra coding)949 * 950 * This function derives the prediction samples for chroma LM mode (chroma intra coding) 2397 951 */ 2398 952 Void TComPrediction::predLMIntraChroma( TComPattern* pcPattern, Int* piSrc, Pel* pPred, UInt uiPredStride, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId ) 2399 953 { 2400 UInt uiWidth = uiCWidth << 1; 2401 UInt uiHeight = uiCHeight << 1; 2402 2403 if (uiChromaId == 0) 2404 xGetRecPixels( pcPattern, pcPattern>getROIY(), pcPattern>getPatternLStride(), m_pLumaRecBuffer + m_iLumaRecStride + 1, m_iLumaRecStride, uiWidth, uiHeight ); 954 UInt uiWidth = 2 * uiCWidth; 2405 955 2406 956 xGetLLSPrediction( pcPattern, piSrc+uiWidth+2, uiWidth+1, pPred, uiPredStride, uiCWidth, uiCHeight, 1 ); … … 2409 959 /** Function for deriving downsampled luma sample of current chroma block and its above, left causal pixel 2410 960 * \param pcPattern pointer to neighbouring pixel access pattern 2411 * \param pRecSrc pointer to reconstructed luma sample array 2412 * \param iRecSrcStride the stride of reconstructed luma sample array 2413 * \param pDst0 pointer to downsampled luma sample array 2414 * \param iDstStride the stride of downsampled luma sample array 2415 * \param uiWidth0 the width of the luma block 2416 * \param uiHeight0 the height of the luma block 2417 2418 \ This function derives downsampled luma sample of current chroma block and its above, left causal pixel 961 * \param uiCWidth the width of the chroma block 962 * \param uiCHeight the height of the chroma block 963 * 964 * This function derives downsampled luma sample of current chroma block and its above, left causal pixel 2419 965 */ 2420 2421 Void TComPrediction::xGetRecPixels( TComPattern* pcPattern, Pel* pRecSrc, Int iRecSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth0, UInt uiHeight0 ) 2422 { 2423 Pel* pSrc = pRecSrc; 2424 Pel* pDst = pDst0; 2425 2426 Int uiCWidth = uiWidth0/2; 2427 Int uiCHeight = uiHeight0/2; 2428 2429 if( pcPattern>isLeftAvailable() ) 2430 { 2431 pSrc = pSrc  2; 2432 pDst = pDst  1; 2433 2434 uiCWidth += 1; 2435 } 2436 2437 if( pcPattern>isAboveAvailable() ) 2438 { 2439 pSrc = pSrc  2*iRecSrcStride; 2440 pDst = pDst  iDstStride; 2441 2442 uiCHeight += 1; 2443 } 2444 966 Void TComPrediction::getLumaRecPixels( TComPattern* pcPattern, UInt uiCWidth, UInt uiCHeight ) 967 { 968 UInt uiWidth = 2 * uiCWidth; 969 UInt uiHeight = 2 * uiCHeight; 970 971 Pel* pRecSrc = pcPattern>getROIY(); 972 Pel* pDst0 = m_pLumaRecBuffer + m_iLumaRecStride + 1; 973 974 Int iRecSrcStride = pcPattern>getPatternLStride(); 975 Int iRecSrcStride2 = iRecSrcStride << 1; 976 Int iDstStride = m_iLumaRecStride; 977 Int iSrcStride = ( max( uiWidth, uiHeight ) << 1 ) + 1; 978 979 Int* ptrSrc = pcPattern>getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); 980 981 // initial pointers 982 Pel* pDst = pDst0  1  iDstStride; 983 Int* piSrc = ptrSrc; 984 985 // top left corner downsampled from ADI buffer 986 // don't need this point 987 988 // top row downsampled from ADI buffer 989 pDst++; 990 piSrc ++; 991 for (Int i = 0; i < uiCWidth; i++) 992 { 993 pDst[i] = ((piSrc[2*i] * 2 ) + piSrc[2*i  1] + piSrc[2*i + 1] + 2) >> 2; 994 } 995 996 // left column downsampled from ADI buffer 997 pDst = pDst0  1; 998 piSrc = ptrSrc + iSrcStride; 999 for (Int j = 0; j < uiCHeight; j++) 1000 { 1001 pDst[0] = ( piSrc[0] + piSrc[iSrcStride] ) >> 1; 1002 piSrc += iSrcStride << 1; 1003 pDst += iDstStride; 1004 } 1005 1006 // inner part from reconstructed picture buffer 2445 1007 for( Int j = 0; j < uiCHeight; j++ ) 2446 { 2447 for( Int i = 0, ii = i << 1; i < uiCWidth; i++, ii = i << 1 ) 2448 pDst[i] = (pSrc[ii] + pSrc[ii + iRecSrcStride]) >> 1; 2449 2450 pDst += iDstStride; 2451 pSrc += iRecSrcStride*2; 2452 } 1008 { 1009 for (Int i = 0; i < uiCWidth; i++) 1010 { 1011 pDst0[i] = (pRecSrc[2*i] + pRecSrc[2*i + iRecSrcStride]) >> 1; 1012 } 1013 1014 pDst0 += iDstStride; 1015 pRecSrc += iRecSrcStride2; 1016 } 2453 1017 } 2454 1018 2455 1019 /** Function for deriving the positon of first nonzero binary bit of a value 2456 1020 * \param x input value 2457 \ This function derives the positon of first nonzero binary bit of a value 1021 * 1022 * This function derives the positon of first nonzero binary bit of a value 2458 1023 */ 2459 1024 Int GetMSB( UInt x ) 2460 1025 { 2461 #if 12462 1026 Int iMSB = 0, bits = ( sizeof( Int ) << 3 ), y = 1; 2463 1027 … … 2476 1040 iMSB+=y; 2477 1041 2478 #else2479 2480 Int iMSB = 0;2481 while( x > 0 )2482 {2483 x >>= 1;2484 iMSB++;2485 }2486 #endif2487 2488 1042 return iMSB; 1043 } 1044 1045 /** Function for counting leading number of zeros/ones 1046 * \param x input value 1047 \ This function counts leading number of zeros for positive numbers and 1048 \ leading number of ones for negative numbers. This can be implemented in 1049 \ single instructure cycle on many processors. 1050 */ 1051 1052 Short CountLeadingZerosOnes (Short x) 1053 { 1054 Short clz; 1055 Short i; 1056 1057 if(x == 0) 1058 { 1059 clz = 0; 1060 } 1061 else 1062 { 1063 if (x == 1) 1064 { 1065 clz = 15; 1066 } 1067 else 1068 { 1069 if(x < 0) 1070 { 1071 x = ~x; 1072 } 1073 clz = 15; 1074 for(i = 0;i < 15;++i) 1075 { 1076 if(x) 1077 { 1078 clz ; 1079 } 1080 x = x >> 1; 1081 } 1082 } 1083 } 1084 return clz; 2489 1085 } 2490 1086 … … 2498 1094 * \param uiHeight the height of the chroma block 2499 1095 * \param uiExt0 line number of neiggboirng pixels for calculating LM model parameter, default value is 1 2500 2501 \This function derives the prediction samples for chroma LM mode (chroma intra coding)1096 * 1097 * This function derives the prediction samples for chroma LM mode (chroma intra coding) 2502 1098 */ 2503 1099 Void TComPrediction::xGetLLSPrediction( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 ) … … 2518 1114 Int x = 0, y = 0, xx = 0, xy = 0; 2519 1115 2520 if( pcPattern>isAboveAvailable() ) 2521 { 2522 pSrc = pSrc0  iSrcStride; 2523 pLuma = pLuma0  iLumaStride; 2524 2525 for( j = 0; j < uiWidth; j++ ) 2526 { 2527 x += pLuma[j]; 2528 y += pSrc[j]; 2529 xx += pLuma[j] * pLuma[j]; 2530 xy += pLuma[j] * pSrc[j]; 2531 } 2532 iCountShift += g_aucConvertToBit[ uiWidth ] + 2; 2533 } 2534 2535 if( pcPattern>isLeftAvailable() ) 2536 { 2537 pSrc = pSrc0  uiExt; 2538 pLuma = pLuma0  uiExt; 2539 2540 for( i = 0; i < uiHeight; i++ ) 2541 { 2542 x += pLuma[0]; 2543 y += pSrc[0]; 2544 xx += pLuma[0] * pLuma[0]; 2545 xy += pLuma[0] * pSrc[0]; 2546 2547 pSrc += iSrcStride; 2548 pLuma += iLumaStride; 2549 } 2550 iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); 2551 } 2552 2553 Int iBitdepth = ( ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3 ) * 2; 2554 Int iTempShift = Max( ( iBitdepth  31 + 1) / 2, 0); 1116 pSrc = pSrc0  iSrcStride; 1117 pLuma = pLuma0  iLumaStride; 1118 1119 for( j = 0; j < uiWidth; j++ ) 1120 { 1121 x += pLuma[j]; 1122 y += pSrc[j]; 1123 xx += pLuma[j] * pLuma[j]; 1124 xy += pLuma[j] * pSrc[j]; 1125 } 1126 iCountShift += g_aucConvertToBit[ uiWidth ] + 2; 1127 1128 pSrc = pSrc0  uiExt; 1129 pLuma = pLuma0  uiExt; 1130 1131 for( i = 0; i < uiHeight; i++ ) 1132 { 1133 x += pLuma[0]; 1134 y += pSrc[0]; 1135 xx += pLuma[0] * pLuma[0]; 1136 xy += pLuma[0] * pSrc[0]; 1137 1138 pSrc += iSrcStride; 1139 pLuma += iLumaStride; 1140 } 1141 iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 ); 1142 1143 Int iTempShift = ( g_uiBitDepth + g_uiBitIncrement ) + g_aucConvertToBit[ uiWidth ] + 3  15; 2555 1144 2556 1145 if(iTempShift > 0) … … 2568 1157 { 2569 1158 a = 0; 2570 b = 1 28 << g_uiBitIncrement;1159 b = 1 << (g_uiBitDepth + g_uiBitIncrement  1); 2571 1160 iShift = 0; 2572 1161 } … … 2576 1165 Int a2 = ( xx << iCountShift )  x * x; 2577 1166 2578 if( a2 == 0  a1 == 0 )2579 {2580 a = 0;2581 b = ( y + ( 1 << ( iCountShift  1 ) ) )>> iCountShift;2582 iShift = 0;2583 }2584 else2585 1167 { 2586 1168 const Int iShiftA2 = 6; … … 2597 1179 2598 1180 if( iScaleShiftA1 < 0 ) 1181 { 2599 1182 iScaleShiftA1 = 0; 2600 1183 } 1184 2601 1185 if( iScaleShiftA2 < 0 ) 1186 { 2602 1187 iScaleShiftA2 = 0; 2603 1188 } 1189 2604 1190 Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift  iShift  iScaleShiftA1; 2605 1191 … … 2608 1194 a1s = a1 >> iScaleShiftA1; 2609 1195 2610 a = a1s * m_uiaShift[ abs( a2s ) ]; 1196 if (a2s >= 1) 1197 { 1198 a = a1s * m_uiaShift[ a2s  1]; 1199 } 1200 else 1201 { 1202 a = 0; 1203 } 2611 1204 2612 1205 if( iScaleShiftA < 0 ) 1206 { 2613 1207 a = a << iScaleShiftA; 1208 } 2614 1209 else 1210 { 2615 1211 a = a >> iScaleShiftA; 2616 2617 if( a > ( 1 << 15 )  1 ) 2618 a = ( 1 << 15 )  1; 2619 else if( a < ( 1 << 15 ) ) 2620 a = ( 1 << 15 ); 1212 } 1213 1214 a = Clip3(( 1 << 15 ), ( 1 << 15 )  1, a); 1215 1216 Int minA = (1 << (6)); 1217 Int maxA = (1 << 6)  1; 1218 if( a <= maxA && a >= minA ) 1219 { 1220 // do nothing 1221 } 1222 else 1223 { 1224 Short n = CountLeadingZerosOnes(a); 1225 a = a >> (9n); 1226 iShift = (9n); 1227 } 2621 1228 2622 1229 b = ( y  ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift  1 ) ) ) >> iCountShift; … … 2634 1241 { 2635 1242 for( j = 0; j < uiWidth; j++ ) 1243 { 2636 1244 pDst[j] = Clip( ( ( a * pLuma[j] ) >> iShift ) + b ); 2637 1245 } 1246 2638 1247 pDst += iDstStride; 2639 1248 pLuma += iLumaStride; … … 2642 1251 2643 1252 } 2644 #endif 2645 2646 #if MN_DC_PRED_FILTER 1253 2647 1254 /** Function for filtering intra DC predictor. 2648 1255 * \param pSrc pointer to reconstructed sample array … … 2659 1266 Pel* pDst = rpDst; 2660 1267 Int x, y, iDstStride2, iSrcStride2; 2661 Int iIntraSizeIdx = g_aucConvertToBit[ iWidth ] + 1; 2662 static const UChar g_aucDCPredFilter[7] = { 0, 3, 2, 1, 0, 0, 0}; 2663 2664 switch (g_aucDCPredFilter[iIntraSizeIdx]) 2665 { 2666 case 0: 2667 {} 2668 break; 2669 case 1: 2670 { 2671 // boundary pixels processing 2672 pDst[0] = (Pel)((pSrc[iSrcStride] + pSrc[1] + 6 * pDst[0] + 4) >> 3); 2673 2674 for ( x = 1; x < iWidth; x++ ) 2675 pDst[x] = (Pel)((pSrc[x  iSrcStride] + 7 * pDst[x] + 4) >> 3); 2676 2677 for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) 2678 pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 7 * pDst[iDstStride2] + 4) >> 3); 2679 } 2680 break; 2681 case 2: 2682 { 2683 // boundary pixels processing 2684 pDst[0] = (Pel)((pSrc[iSrcStride] + pSrc[1] + 2 * pDst[0] + 2) >> 2); 2685 2686 for ( x = 1; x < iWidth; x++ ) 2687 pDst[x] = (Pel)((pSrc[x  iSrcStride] + 3 * pDst[x] + 2) >> 2); 2688 2689 for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) 2690 pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); 2691 } 2692 break; 2693 case 3: 2694 { 2695 // boundary pixels processing 2696 pDst[0] = (Pel)((3 * (pSrc[iSrcStride] + pSrc[1]) + 2 * pDst[0] + 4) >> 3); 2697 2698 for ( x = 1; x < iWidth; x++ ) 2699 pDst[x] = (Pel)((3 * pSrc[x  iSrcStride] + 5 * pDst[x] + 4) >> 3); 2700 2701 for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) 2702 pDst[iDstStride2] = (Pel)((3 * pSrc[iSrcStride2] + 5 * pDst[iDstStride2] + 4) >> 3); 2703 } 2704 break; 1268 1269 // boundary pixels processing 1270 pDst[0] = (Pel)((pSrc[iSrcStride] + pSrc[1] + 2 * pDst[0] + 2) >> 2); 1271 1272 for ( x = 1; x < iWidth; x++ ) 1273 { 1274 pDst[x] = (Pel)((pSrc[x  iSrcStride] + 3 * pDst[x] + 2) >> 2); 1275 } 1276 1277 for ( y = 1, iDstStride2 = iDstStride, iSrcStride2 = iSrcStride1; y < iHeight; y++, iDstStride2+=iDstStride, iSrcStride2+=iSrcStride ) 1278 { 1279 pDst[iDstStride2] = (Pel)((pSrc[iSrcStride2] + 3 * pDst[iDstStride2] + 2) >> 2); 2705 1280 } 2706 1281 2707 1282 return; 2708 1283 } 2709 #endif2710 1284 2711 1285 #if HHI_DMM_WEDGE_INTRA  HHI_DMM_PRED_TEX 2712 TComWedgeDist::TComWedgeDist() 2713 { 2714 init(); 2715 } 2716 2717 TComWedgeDist::~TComWedgeDist() 2718 { 2719 } 2720 2721 Void TComWedgeDist::init() 2722 { 2723 // m_afpDistortFunc[0] = NULL; // for DF_DEFAULT 2724 2725 // m_afpDistortFunc[8] = TComRdCost::xGetSAD; 2726 m_afpDistortFunc[0] = TComWedgeDist::xGetSAD4; 2727 m_afpDistortFunc[1] = TComWedgeDist::xGetSAD8; 2728 m_afpDistortFunc[2] = TComWedgeDist::xGetSAD16; 2729 m_afpDistortFunc[3] = TComWedgeDist::xGetSAD32; 2730 2731 m_afpDistortFunc[4] = TComWedgeDist::xGetSSE4; 2732 m_afpDistortFunc[5] = TComWedgeDist::xGetSSE8; 2733 m_afpDistortFunc[6] = TComWedgeDist::xGetSSE16; 2734 m_afpDistortFunc[7] = TComWedgeDist::xGetSSE32; 2735 2736 // m_afpDistortFunc[13] = TComRdCost::xGetSAD64; 2737 #ifdef ROUNDING_CONTROL_BIPRED 2738 // m_afpDistortFuncRnd[0] = NULL; 2739 // m_afpDistortFuncRnd[8] = TComRdCost::xGetSAD; 2740 m_afpDistortFuncRnd[9] = TComRdCost::xGetSAD4; 2741 m_afpDistortFuncRnd[10] = TComRdCost::xGetSAD8; 2742 m_afpDistortFuncRnd[11] = TComRdCost::xGetSAD16; 2743 m_afpDistortFuncRnd[12] = TComRdCost::xGetSAD32; 2744 // m_afpDistortFuncRnd[13] = TComRdCost::xGetSAD64; 2745 #endif 2746 } 2747 2748 UInt TComWedgeDist::xGetSAD4( DistParam* pcDtParam ) 2749 { 2750 Pel* piOrg = pcDtParam>pOrg; 2751 Pel* piCur = pcDtParam>pCur; 2752 Int iRows = pcDtParam>iRows; 2753 Int iSubShift = pcDtParam>iSubShift; 2754 Int iSubStep = ( 1 << iSubShift ); 2755 Int iStrideCur = pcDtParam>iStrideCur*iSubStep; 2756 Int iStrideOrg = pcDtParam>iStrideOrg*iSubStep; 2757 2758 UInt uiSum = 0; 2759 2760 for( ; iRows != 0; iRows=iSubStep ) 2761 { 2762 uiSum += abs( piOrg[0]  piCur[0] ); 2763 uiSum += abs( piOrg[1]  piCur[1] ); 2764 uiSum += abs( piOrg[2]  piCur[2] ); 2765 uiSum += abs( piOrg[3]  piCur[3] ); 2766 2767 piOrg += iStrideOrg; 2768 piCur += iStrideCur; 2769 } 2770 2771 uiSum <<= iSubShift; 2772 return ( uiSum >> g_uiBitIncrement ); 2773 } 2774 2775 UInt TComWedgeDist::xGetSAD8( DistParam* pcDtParam ) 2776 { 2777 Pel* piOrg = pcDtParam>pOrg; 2778 Pel* piCur = pcDtParam>pCur; 2779 Int iRows = pcDtParam>iRows; 2780 Int iSubShift = pcDtParam>iSubShift; 2781 Int iSubStep = ( 1 << iSubShift ); 2782 Int iStrideCur = pcDtParam>iStrideCur*iSubStep; 2783 Int iStrideOrg = pcDtParam>iStrideOrg*iSubStep; 2784 2785 UInt uiSum = 0; 2786 2787 for( ; iRows != 0; iRows=iSubStep ) 2788 { 2789 uiSum += abs( piOrg[0]  piCur[0] ); 2790 uiSum += abs( piOrg[1]  piCur[1] ); 2791 uiSum += abs( piOrg[2]  piCur[2] ); 2792 uiSum += abs( piOrg[3]  piCur[3] ); 2793 uiSum += abs( piOrg[4]  piCur[4] ); 2794 uiSum += abs( piOrg[5]  piCur[5] ); 2795 uiSum += abs( piOrg[6]  piCur[6] ); 2796 uiSum += abs( piOrg[7]  piCur[7] ); 2797 2798 piOrg += iStrideOrg; 2799 piCur += iStrideCur; 2800 } 2801 2802 uiSum <<= iSubShift; 2803 return ( uiSum >> g_uiBitIncrement ); 2804 } 2805 2806 UInt TComWedgeDist::xGetSAD16( DistParam* pcDtParam ) 2807 { 2808 Pel* piOrg = pcDtParam>pOrg; 2809 Pel* piCur = pcDtParam>pCur; 2810 Int iRows = pcDtParam>iRows; 2811 Int iSubShift = pcDtParam>iSubShift; 2812 Int iSubStep = ( 1 << iSubShift ); 2813 Int iStrideCur = pcDtParam>iStrideCur*iSubStep; 2814 Int iStrideOrg = pcDtParam>iStrideOrg*iSubStep; 2815 2816 UInt uiSum = 0; 2817 2818 for( ; iRows != 0; iRows=iSubStep ) 2819 { 2820 uiSum += abs( piOrg[0]  piCur[0] ); 2821 uiSum += abs( piOrg[1]  piCur[1] ); 2822 uiSum += abs( piOrg[2]  piCur[2] ); 2823 uiSum += abs( piOrg[3]  piCur[3] ); 2824 uiSum += abs( piOrg[4]  piCur[4] ); 2825 uiSum += abs( piOrg[5]  piCur[5] ); 2826 uiSum += abs( piOrg[6]  piCur[6] ); 2827 uiSum += abs( piOrg[7]  piCur[7] ); 2828 uiSum += abs( piOrg[8]  piCur[8] ); 2829 uiSum += abs( piOrg[9]  piCur[9] ); 2830 uiSum += abs( piOrg[10]  piCur[10] ); 2831 uiSum += abs( piOrg[11]  piCur[11] ); 2832 uiSum += abs( piOrg[12]  piCur[12] ); 2833 uiSum += abs( piOrg[13]  piCur[13] ); 2834 uiSum += abs( piOrg[14]  piCur[14] ); 2835 uiSum += abs( piOrg[15]  piCur[15] ); 2836 2837 piOrg += iStrideOrg; 2838 piCur += iStrideCur; 2839 } 2840 2841 uiSum <<= iSubShift; 2842 return ( uiSum >> g_uiBitIncrement ); 2843 } 2844 2845 UInt TComWedgeDist::xGetSAD32( DistParam* pcDtParam ) 2846 { 2847 Pel* piOrg = pcDtParam>pOrg; 2848 Pel* piCur = pcDtParam>pCur; 2849 Int iRows = pcDtParam>iRows; 2850 Int iSubShift = pcDtParam>iSubShift; 2851 Int iSubStep = ( 1 << iSubShift ); 2852 Int iStrideCur = pcDtParam>iStrideCur*iSubStep; 2853 Int iStrideOrg = pcDtParam>iStrideOrg*iSubStep; 2854 2855 UInt uiSum = 0; 2856 2857 for( ; iRows != 0; iRows=iSubStep ) 2858 { 2859 uiSum += abs( piOrg[0]  piCur[0] ); 2860 uiSum += abs( piOrg[1]  piCur[1] ); 2861 uiSum += abs( piOrg[2]  piCur[2] ); 2862 uiSum += abs( piOrg[3]  piCur[3] ); 2863 uiSum += abs( piOrg[4]  piCur[4] ); 2864 uiSum += abs( piOrg[5]  piCur[5] ); 2865 uiSum += abs( piOrg[6]  piCur[6] ); 2866 uiSum += abs( piOrg[7]  piCur[7] ); 2867 uiSum += abs( piOrg[8]  piCur[8] ); 2868 uiSum += abs( piOrg[9]  piCur[9] ); 2869 uiSum += abs( piOrg[10]  piCur[10] ); 2870 uiSum += abs( piOrg[11]  piCur[11] ); 2871 uiSum += abs( piOrg[12]  piCur[12] ); 2872 uiSum += abs( piOrg[13]  piCur[13] ); 2873 uiSum += abs( piOrg[14]  piCur[14] ); 2874 uiSum += abs( piOrg[15]  piCur[15] ); 2875 uiSum += abs( piOrg[16]  piCur[16] ); 2876 uiSum += abs( piOrg[17]  piCur[17] ); 2877 uiSum += abs( piOrg[18]  piCur[18] ); 2878 uiSum += abs( piOrg[19]  piCur[19] ); 2879 uiSum += abs( piOrg[20]  piCur[20] ); 2880 uiSum += abs( piOrg[21]  piCur[21] ); 2881 uiSum += abs( piOrg[22]  piCur[22] ); 2882 uiSum += abs( piOrg[23]  piCur[23] ); 2883 uiSum += abs( piOrg[24]  piCur[24] ); 2884 uiSum += abs( piOrg[25]  piCur[25] ); 2885 uiSum += abs( piOrg[26]  piCur[26] ); 2886 uiSum += abs( piOrg[27]  piCur[27] ); 2887 uiSum += abs( piOrg[28]  piCur[28] ); 2888 uiSum += abs( piOrg[29]  piCur[29] ); 2889 uiSum += abs( piOrg[30]  piCur[30] ); 2890 uiSum += abs( piOrg[31]  piCur[31] ); 2891 2892 piOrg += iStrideOrg; 2893 piCur += iStrideCur; 2894 } 2895 2896 uiSum <<= iSubShift; 2897 return ( uiSum >> g_uiBitIncrement ); 2898 } 2899 2900 UInt TComWedgeDist::xGetSSE4( DistParam* pcDtParam ) 2901 { 2902 Pel* piOrg = pcDtParam>pOrg; 2903 Pel* piCur = pcDtParam>pCur; 2904 Int iRows = pcDtParam>iRows; 2905 Int iStrideOrg = pcDtParam>iStrideOrg; 2906 Int iStrideCur = pcDtParam>iStrideCur; 2907 2908 UInt uiSum = 0; 2909 UInt uiShift = g_uiBitIncrement<<1; 2910 2911 Int iTemp; 2912 2913 for( ; iRows != 0; iRows ) 2914 { 2915 2916 iTemp = piOrg[0]  piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; 2917 iTemp = piOrg[1]  piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; 2918 iTemp = piOrg[2]  piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; 2919 iTemp = piOrg[3]  piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; 2920 2921 piOrg += iStrideOrg; 2922 piCur += iStrideCur; 2923 } 2924 2925 return ( uiSum ); 2926 } 2927 2928 UInt TComWedgeDist::xGetSSE8( DistParam* pcDtParam ) 2929 { 2930 Pel* piOrg = pcDtParam>pOrg; 2931 Pel* piCur = pcDtParam>pCur; 2932 Int iRows = pcDtParam>iRows; 2933 Int iStrideOrg = pcDtParam>iStrideOrg; 2934 Int iStrideCur = pcDtParam>iStrideCur; 2935 2936 UInt uiSum = 0; 2937 UInt uiShift = g_uiBitIncrement<<1; 2938 2939 Int iTemp; 2940 2941 for( ; iRows != 0; iRows ) 2942 { 2943 iTemp = piOrg[0]  piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; 2944 iTemp = piOrg[1]  piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; 2945 iTemp = piOrg[2]  piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; 2946 iTemp = piOrg[3]  piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; 2947 iTemp = piOrg[4]  piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; 2948 iTemp = piOrg[5]  piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; 2949 iTemp = piOrg[6]  piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; 2950 iTemp = piOrg[7]  piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; 2951 2952 piOrg += iStrideOrg; 2953 piCur += iStrideCur; 2954 } 2955 2956 return ( uiSum ); 2957 } 2958 2959 UInt TComWedgeDist::xGetSSE16( DistParam* pcDtParam ) 2960 { 2961 Pel* piOrg = pcDtParam>pOrg; 2962 Pel* piCur = pcDtParam>pCur; 2963 Int iRows = pcDtParam>iRows; 2964 Int iStrideOrg = pcDtParam>iStrideOrg; 2965 Int iStrideCur = pcDtParam>iStrideCur; 2966 2967 UInt uiSum = 0; 2968 UInt uiShift = g_uiBitIncrement<<1; 2969 2970 Int iTemp; 2971 2972 for( ; iRows != 0; iRows ) 2973 { 2974 2975 iTemp = piOrg[ 0]  piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; 2976 iTemp = piOrg[ 1]  piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; 2977 iTemp = piOrg[ 2]  piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; 2978 iTemp = piOrg[ 3]  piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; 2979 iTemp = piOrg[ 4]  piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; 2980 iTemp = piOrg[ 5]  piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; 2981 iTemp = piOrg[ 6]  piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; 2982 iTemp = piOrg[ 7]  piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; 2983 iTemp = piOrg[ 8]  piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; 2984 iTemp = piOrg[ 9]  piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; 2985 iTemp = piOrg[10]  piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; 2986 iTemp = piOrg[11]  piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; 2987 iTemp = piOrg[12]  piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; 2988 iTemp = piOrg[13]  piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; 2989 iTemp = piOrg[14]  piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; 2990 iTemp = piOrg[15]  piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; 2991 2992 piOrg += iStrideOrg; 2993 piCur += iStrideCur; 2994 } 2995 2996 return ( uiSum ); 2997 } 2998 2999 UInt TComWedgeDist::xGetSSE32( DistParam* pcDtParam ) 3000 { 3001 Pel* piOrg = pcDtParam>pOrg; 3002 Pel* piCur = pcDtParam>pCur; 3003 Int iRows = pcDtParam>iRows; 3004 Int iStrideOrg = pcDtParam>iStrideOrg; 3005 Int iStrideCur = pcDtParam>iStrideCur; 3006 3007 UInt uiSum = 0; 3008 UInt uiShift = g_uiBitIncrement<<1; 3009 Int iTemp; 3010 3011 for( ; iRows != 0; iRows ) 3012 { 3013 3014 iTemp = piOrg[ 0]  piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; 3015 iTemp = piOrg[ 1]  piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; 3016 iTemp = piOrg[ 2]  piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; 3017 iTemp = piOrg[ 3]  piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; 3018 iTemp = piOrg[ 4]  piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; 3019 iTemp = piOrg[ 5]  piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; 3020 iTemp = piOrg[ 6]  piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; 3021 iTemp = piOrg[ 7]  piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; 3022 iTemp = piOrg[ 8]  piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; 3023 iTemp = piOrg[ 9]  piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; 3024 iTemp = piOrg[10]  piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; 3025 iTemp = piOrg[11]  piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; 3026 iTemp = piOrg[12]  piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; 3027 iTemp = piOrg[13]  piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; 3028 iTemp = piOrg[14]  piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; 3029 iTemp = piOrg[15]  piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; 3030 iTemp = piOrg[16]  piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; 3031 iTemp = piOrg[17]  piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; 3032 iTemp = piOrg[18]  piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; 3033 iTemp = piOrg[19]  piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; 3034 iTemp = piOrg[20]  piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; 3035 iTemp = piOrg[21]  piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; 3036 iTemp = piOrg[22]  piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; 3037 iTemp = piOrg[23]  piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; 3038 iTemp = piOrg[24]  piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; 3039 iTemp = piOrg[25]  piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; 3040 iTemp = piOrg[26]  piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; 3041 iTemp = piOrg[27]  piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; 3042 iTemp = piOrg[28]  piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; 3043 iTemp = piOrg[29]  piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; 3044 iTemp = piOrg[30]  piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; 3045 iTemp = piOrg[31]  piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; 3046 3047 piOrg += iStrideOrg; 3048 piCur += iStrideCur; 3049 } 3050 3051 return ( uiSum ); 3052 } 3053 3054 Void TComWedgeDist::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist, DistParam& rcDistParam ) 3055 { 3056 // set Block Width / Height 3057 rcDistParam.iCols = uiBlkWidth; 3058 rcDistParam.iRows = uiBlkHeight; 3059 rcDistParam.DistFunc = m_afpDistortFunc[eWDist + g_aucConvertToBit[ rcDistParam.iCols ] ]; 3060 3061 // initialize 3062 rcDistParam.iSubShift = 0; 3063 } 3064 3065 UInt TComWedgeDist::getDistPart( Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist ) 3066 { 3067 DistParam cDtParam; 3068 setDistParam( uiBlkWidth, uiBlkHeight, eWDist, cDtParam ); 3069 cDtParam.pOrg = piOrg; 3070 cDtParam.pCur = piCur; 3071 cDtParam.iStrideOrg = iOrgStride; 3072 cDtParam.iStrideCur = iCurStride; 3073 #ifdef DCM_RDCOST_TEMP_FIX //Temporary fix since DistParam is lacking a constructor and the variable iStep is not initialized 3074 cDtParam.iStep = 1; 3075 #endif 3076 return cDtParam.DistFunc( &cDtParam ); 3077 } 3078 #endif 1286 Void TComPrediction::predIntraLumaDMM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder ) 1287 { 1288 #if HHI_DMM_WEDGE_INTRA 1289 if( uiMode == DMM_WEDGE_FULL_IDX ) { xPredIntraWedgeFull ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU>getWedgeFullTabIdx ( uiAbsPartIdx ) ); } 1290 if( uiMode == DMM_WEDGE_FULL_D_IDX ) { xPredIntraWedgeFull ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU>getWedgeFullTabIdx( uiAbsPartIdx ), pcCU>getWedgeFullDeltaDC1( uiAbsPartIdx ), pcCU>getWedgeFullDeltaDC2( uiAbsPartIdx ) ); } 1291 if( uiMode == DMM_WEDGE_PREDDIR_IDX ) { xPredIntraWedgeDir ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU>getWedgePredDirDeltaEnd( uiAbsPartIdx ) ); } 1292 if( uiMode == DMM_WEDGE_PREDDIR_D_IDX ) { xPredIntraWedgeDir ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU>getWedgePredDirDeltaEnd( uiAbsPartIdx ), pcCU>getWedgePredDirDeltaDC1( uiAbsPartIdx ), pcCU>getWedgePredDirDeltaDC2( uiAbsPartIdx ) ); } 1293 #endif 1294 #if HHI_DMM_PRED_TEX 1295 if( uiMode == DMM_WEDGE_PREDTEX_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); } 1296 if( uiMode == DMM_WEDGE_PREDTEX_D_IDX ) { xPredIntraWedgeTex ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU>getWedgePredTexDeltaDC1( uiAbsPartIdx ), pcCU>getWedgePredTexDeltaDC2( uiAbsPartIdx ) ); } 1297 if( uiMode == DMM_CONTOUR_PREDTEX_IDX ) { xPredIntraContourTex( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); } 1298 if( uiMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xPredIntraContourTex( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU>getContourPredTexDeltaDC1( uiAbsPartIdx ), pcCU>getContourPredTexDeltaDC2( uiAbsPartIdx ) ); } 1299 #endif 1300 } 1301 1302 Void TComPrediction::getWedgePredDCs( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft ) 1303 { 1304 riPredDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement  1) ); //pred val, if no neighbors are available 1305 riPredDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement  1) ); 1306 1307 if( !bAbove && !bLeft ) { return; } 1308 1309 UInt uiNumSmpDC1 = 0, uiNumSmpDC2 = 0; 1310 Int iPredDC1 = 0, iPredDC2 = 0; 1311 1312 Bool* pabWedgePattern = pcWedgelet>getPattern(); 1313 UInt uiWedgeStride = pcWedgelet>getStride(); 1314 1315 if( bAbove ) 1316 { 1317 for( Int k = 0; k < pcWedgelet>getWidth(); k++ ) 1318 { 1319 if( true == pabWedgePattern[k] ) 1320 { 1321 iPredDC2 += piMask[kiMaskStride]; 1322 uiNumSmpDC2++; 1323 } 1324 else 1325 { 1326 iPredDC1 += piMask[kiMaskStride]; 1327 uiNumSmpDC1++; 1328 } 1329 } 1330 } 1331 if( bLeft ) 1332 { 1333 for( Int k = 0; k < pcWedgelet>getHeight(); k++ ) 1334 { 1335 if( true == pabWedgePattern[k*uiWedgeStride] ) 1336 { 1337 iPredDC2 += piMask[k*iMaskStride1]; 1338 uiNumSmpDC2++; 1339 } 1340 else 1341 { 1342 iPredDC1 += piMask[k*iMaskStride1]; 1343 uiNumSmpDC1++; 1344 } 1345 } 1346 } 1347 1348 if( uiNumSmpDC1 > 0 ) 1349 { 1350 iPredDC1 /= uiNumSmpDC1; 1351 riPredDC1 = iPredDC1; 1352 } 1353 if( uiNumSmpDC2 > 0 ) 1354 { 1355 iPredDC2 /= uiNumSmpDC2; 1356 riPredDC2 = iPredDC2; 1357 } 1358 } 1359 1360 Void TComPrediction::calcWedgeDCs( TComWedgelet* pcWedgelet, Pel* piOrig, UInt uiStride, Int& riDC1, Int& riDC2 ) 1361 { 1362 UInt uiDC1 = 0; 1363 UInt uiDC2 = 0; 1364 UInt uiNumPixDC1 = 0, uiNumPixDC2 = 0; 1365 Bool* pabWedgePattern = pcWedgelet>getPattern(); 1366 if( uiStride == pcWedgelet>getStride() ) 1367 { 1368 for( UInt k = 0; k < (pcWedgelet>getWidth() * pcWedgelet>getHeight()); k++ ) 1369 { 1370 if( true == pabWedgePattern[k] ) 1371 { 1372 uiDC2 += piOrig[k]; 1373 uiNumPixDC2++; 1374 } 1375 else 1376 { 1377 uiDC1 += piOrig[k]; 1378 uiNumPixDC1++; 1379 } 1380 } 1381 } 1382 else 1383 { 1384 Pel* piTemp = piOrig; 1385 UInt uiWedgeStride = pcWedgelet>getStride(); 1386 for( UInt uiY = 0; uiY < pcWedgelet>getHeight(); uiY++ ) 1387 { 1388 for( UInt uiX = 0; uiX < pcWedgelet>getWidth(); uiX++ ) 1389 { 1390 if( true == pabWedgePattern[uiX] ) 1391 { 1392 uiDC2 += piTemp[uiX]; 1393 uiNumPixDC2++; 1394 } 1395 else 1396 { 1397 uiDC1 += piTemp[uiX]; 1398 uiNumPixDC1++; 1399 } 1400 } 1401 piTemp += uiStride; 1402 pabWedgePattern += uiWedgeStride; 1403 } 1404 } 1405 1406 if( uiNumPixDC1 > 0 ) { riDC1 = uiDC1 / uiNumPixDC1; } 1407 else { riDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement  1) ); } 1408 1409 if( uiNumPixDC2 > 0 ) { riDC2 = uiDC2 / uiNumPixDC2; } 1410 else { riDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement  1) ); } 1411 } 1412 1413 Void TComPrediction::assignWedgeDCs2Pred( TComWedgelet* pcWedgelet, Pel* piPred, UInt uiStride, Int iDC1, Int iDC2 ) 1414 { 1415 Bool* pabWedgePattern = pcWedgelet>getPattern(); 1416 1417 if( uiStride == pcWedgelet>getStride() ) 1418 { 1419 for( UInt k = 0; k < (pcWedgelet>getWidth() * pcWedgelet>getHeight()); k++ ) 1420 { 1421 if( true == pabWedgePattern[k] ) 1422 { 1423 piPred[k] = iDC2; 1424 } 1425 else 1426 { 1427 piPred[k] = iDC1; 1428 } 1429 } 1430 } 1431 else 1432 { 1433 Pel* piTemp = piPred; 1434 UInt uiWedgeStride = pcWedgelet>getStride(); 1435 for( UInt uiY = 0; uiY < pcWedgelet>getHeight(); uiY++ ) 1436 { 1437 for( UInt uiX = 0; uiX < pcWedgelet>getWidth(); uiX++ ) 1438 { 1439 if( true == pabWedgePattern[uiX] ) 1440 { 1441 piTemp[uiX] = iDC2; 1442 } 1443 else 1444 { 1445 piTemp[uiX] = iDC1; 1446 } 1447 } 1448 piTemp += uiStride; 1449 pabWedgePattern += uiWedgeStride; 1450 } 1451 } 1452 } 1453 1454 Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Int& riDeltaDC ) 1455 { 1456 Int iSign = riDeltaDC < 0 ? 1 : 1; 1457 UInt uiAbs = abs( riDeltaDC ); 1458 1459 Int iQp = pcCU>getQP(0); 1460 Double dMax = (Double)( 1<<( g_uiBitDepth + g_uiBitIncrement  1) ); 1461 Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 + g_iDeltaDCsQuantOffset ) ); 1462 1463 riDeltaDC = iSign * roftoi( uiAbs * dStepSize ); 1464 return; 1465 } 1466 1467 Void TComPrediction::xDeltaDCQuantScaleDown( TComDataCU* pcCU, Int& riDeltaDC ) 1468 { 1469 Int iSign = riDeltaDC < 0 ? 1 : 1; 1470 UInt uiAbs = abs( riDeltaDC ); 1471 1472 Int iQp = pcCU>getQP(0); 1473 Double dMax = (Double)( 1<<( g_uiBitDepth + g_uiBitIncrement  1) ); 1474 Double dStepSize = Clip3( 1.0, dMax, pow( 2.0, iQp/10.0 + g_iDeltaDCsQuantOffset ) ); 1475 1476 riDeltaDC = iSign * roftoi( uiAbs / dStepSize ); 1477 return; 1478 } 1479 #endif 1480 1481 #if HHI_DMM_PRED_TEX 1482 Void TComPrediction::getBestContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ) 1483 { 1484 pcContourWedge>clear(); 1485 1486 // get copy of colocated texture luma block 1487 TComYuv cTempYuv; 1488 cTempYuv.create( uiWidth, uiHeight ); 1489 cTempYuv.clear(); 1490 Pel* piRefBlkY = cTempYuv.getLumaAddr(); 1491 copyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); 1492 piRefBlkY = cTempYuv.getLumaAddr(); 1493 1494 // find contour for texture luma block 1495 UInt iDC = 0; 1496 for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) 1497 { 1498 iDC += piRefBlkY[k]; 1499 } 1500 iDC /= (uiWidth*uiHeight); 1501 piRefBlkY = cTempYuv.getLumaAddr(); 1502 1503 Bool* pabContourPattern = pcContourWedge>getPattern(); 1504 for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) 1505 { 1506 pabContourPattern[k] = (piRefBlkY[k] > iDC) ? true : false; 1507 } 1508 1509 cTempYuv.destroy(); 1510 } 1511 1512 UInt TComPrediction::getBestWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight ) 1513 { 1514 assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE ); 1515 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])]; 1516 1517 // get copy of colocated texture luma block 1518 TComYuv cTempYuv; 1519 cTempYuv.create( uiWidth, uiHeight ); 1520 cTempYuv.clear(); 1521 Pel* piRefBlkY = cTempYuv.getLumaAddr(); 1522 1523 copyTextureLumaBlock( pcCU, uiAbsPartIdx, piRefBlkY, uiWidth, uiHeight ); 1524 piRefBlkY = cTempYuv.getLumaAddr(); 1525 1526 // local pred buffer 1527 TComYuv cPredYuv; 1528 cPredYuv.create( uiWidth, uiHeight ); 1529 cPredYuv.clear(); 1530 Pel* piPred = cPredYuv.getLumaAddr(); 1531 1532 UInt uiPredStride = cPredYuv.getStride(); 1533 1534 // regular wedge search 1535 TComWedgeDist cWedgeDist; 1536 UInt uiBestDist = MAX_UINT; 1537 UInt uiBestTabIdx = 0; 1538 Int iDC1 = 0; 1539 Int iDC2 = 0; 1540 1541 for( UInt uiIdx = 0; uiIdx < pacWedgeList>size(); uiIdx++ ) 1542 { 1543 calcWedgeDCs ( &(pacWedgeList>at(uiIdx)), piRefBlkY, uiWidth, iDC1, iDC2 ); 1544 assignWedgeDCs2Pred( &(pacWedgeList>at(uiIdx)), piPred, uiPredStride, iDC1, iDC2 ); 1545 1546 UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD ); 1547 1548 if( uiActDist < uiBestDist  uiBestDist == MAX_UINT ) 1549 { 1550 uiBestDist = uiActDist; 1551 uiBestTabIdx = uiIdx; 1552 } 1553 } 1554 1555 cPredYuv.destroy(); 1556 cTempYuv.destroy(); 1557 return uiBestTabIdx; 1558 } 1559 1560 Void TComPrediction::copyTextureLumaBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight ) 1561 { 1562 TComPicYuv* pcPicYuvRef = pcCU>getSlice()>getTexturePic()>getPicYuvRec(); 1563 Int iRefStride = pcPicYuvRef>getStride(); 1564 Pel* piRefY; 1565 1566 piRefY = pcPicYuvRef>getLumaAddr( pcCU>getAddr(), pcCU>getZorderIdxInCU() + uiAbsPartIdx ); 1567 1568 for ( Int y = 0; y < uiHeight; y++ ) 1569 { 1570 ::memcpy(piDestBlockY, piRefY, sizeof(Pel)*uiWidth); 1571 // ::memset(piDestBlockY, 128, sizeof(Pel)*uiWidth); 1572 piDestBlockY += uiWidth; 1573 piRefY += iRefStride; 1574 } 1575 } 1576 1577 Void TComPrediction::xPredIntraWedgeTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 ) 1578 { 1579 assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); 1580 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; 1581 1582 // get wedge pattern 1583 UInt uiTextureWedgeTabIdx = 0; 1584 if( bEncoder ) 1585 { 1586 // encoder: load stored wedge pattern from CU 1587 uiTextureWedgeTabIdx = pcCU>getWedgePredTexTabIdx( uiAbsPartIdx ); 1588 } 1589 else 1590 { 1591 // decoder: get and store wedge pattern in CU 1592 uiTextureWedgeTabIdx = getBestWedgeFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight ); 1593 1594 UInt uiDepth = (pcCU>getDepth(0)) + (pcCU>getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1); 1595 pcCU>setWedgePredTexTabIdxSubParts( uiTextureWedgeTabIdx, uiAbsPartIdx, uiDepth ); 1596 } 1597 TComWedgelet* pcWedgelet = &(pacWedgeList>at(uiTextureWedgeTabIdx)); 1598 1599 // get wedge pred DCs 1600 Int iPredDC1 = 0; 1601 Int iPredDC2 = 0; 1602 Int* piMask = pcCU>getPattern()>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); 1603 Int iMaskStride = ( iWidth<<1 ) + 1; 1604 piMask += iMaskStride+1; 1605 getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); 1606 1607 if( bDelta ) 1608 { 1609 xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); 1610 xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); 1611 } 1612 1613 // assign wedge pred DCs to prediction 1614 if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } 1615 else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } 1616 } 1617 1618 Void TComPrediction::xPredIntraContourTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 ) 1619 { 1620 // get contour pattern 1621 TComWedgelet* pcContourWedge = new TComWedgelet( iWidth, iHeight ); 1622 getBestContourFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight, pcContourWedge ); 1623 1624 // get wedge pred DCs 1625 Int iPredDC1 = 0; 1626 Int iPredDC2 = 0; 1627 Int* piMask = pcCU>getPattern()>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); 1628 Int iMaskStride = ( iWidth<<1 ) + 1; 1629 piMask += iMaskStride+1; 1630 getWedgePredDCs( pcContourWedge, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); 1631 1632 if( bDelta ) 1633 { 1634 xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); 1635 xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); 1636 } 1637 1638 // assign wedge pred DCs to prediction 1639 if( bDelta ) { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } 1640 else { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, iPredDC1, iPredDC2 ); } 1641 1642 pcContourWedge>destroy(); 1643 delete pcContourWedge; 1644 } 1645 #endif 1646 1647 #if HHI_DMM_WEDGE_INTRA 1648 UInt TComPrediction::getBestContinueWedge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd ) 1649 { 1650 UInt uiThisBlockSize = uiWidth; 1651 assert( uiThisBlockSize >= DMM_WEDGEMODEL_MIN_SIZE && uiThisBlockSize <= DMM_WEDGEMODEL_MAX_SIZE ); 1652 WedgeRefList* pacContDWedgeRefList = &g_aacWedgeRefLists[(g_aucConvertToBit[uiThisBlockSize])]; 1653 1654 UInt uiPredDirWedgeTabIdx = 0; 1655 TComDataCU* pcTempCU; 1656 UInt uiTempPartIdx; 1657 // 1st: try continue above wedgelet 1658 pcTempCU = pcCU>getPUAbove( uiTempPartIdx, pcCU>getZorderIdxInCU() + uiAbsPartIdx ); 1659 if( pcTempCU ) 1660 { 1661 UChar uhLumaIntraDir = pcTempCU>getLumaIntraDir( uiTempPartIdx ); 1662 if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir  1663 DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir  1664 DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir  1665 DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir 1666 #if HHI_DMM_PRED_TEX 1667  1668 DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir  1669 DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir 1670 #endif 1671 ) 1672 { 1673 UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU>getIntraSizeIdx( uiTempPartIdx )]; 1674 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; 1675 1676 // get offset between current and reference block 1677 UInt uiOffsetX = 0; 1678 UInt uiOffsetY = 0; 1679 xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); 1680 1681 // get reference wedgelet 1682 UInt uiRefWedgeTabIdx = 0; 1683 switch( uhLumaIntraDir ) 1684 { 1685 case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgeFullTabIdx ( uiTempPartIdx ); } break; 1686 case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgeFullTabIdx ( uiTempPartIdx ); } break; 1687 case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredDirTabIdx( uiTempPartIdx ); } break; 1688 case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredDirTabIdx( uiTempPartIdx ); } break; 1689 #if HHI_DMM_PRED_TEX 1690 case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredTexTabIdx( uiTempPartIdx ); } break; 1691 case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredTexTabIdx( uiTempPartIdx ); } break; 1692 #endif 1693 default: { assert( 0 ); return uiPredDirWedgeTabIdx; } 1694 } 1695 TComWedgelet* pcRefWedgelet; 1696 pcRefWedgelet = &(pacWedgeList>at( uiRefWedgeTabIdx )); 1697 1698 // find reference wedgelet, if direction is suitable for continue wedge 1699 if( pcRefWedgelet>checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) ) 1700 { 1701 UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; 1702 pcRefWedgelet>getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd ); 1703 getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); 1704 return uiPredDirWedgeTabIdx; 1705 } 1706 } 1707 } 1708 1709 // 2nd: try continue left wedglelet 1710 pcTempCU = pcCU>getPULeft( uiTempPartIdx, pcCU>getZorderIdxInCU() + uiAbsPartIdx ); 1711 if( pcTempCU ) 1712 { 1713 UChar uhLumaIntraDir = pcTempCU>getLumaIntraDir( uiTempPartIdx ); 1714 if( DMM_WEDGE_FULL_IDX == uhLumaIntraDir  1715 DMM_WEDGE_FULL_D_IDX == uhLumaIntraDir  1716 DMM_WEDGE_PREDDIR_IDX == uhLumaIntraDir  1717 DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir 1718 #if HHI_DMM_PRED_TEX 1719  1720 DMM_WEDGE_PREDTEX_IDX == uhLumaIntraDir  1721 DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir 1722 #endif 1723 ) 1724 { 1725 UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU>getIntraSizeIdx( uiTempPartIdx )]; 1726 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])]; 1727 1728 // get offset between current and reference block 1729 UInt uiOffsetX = 0; 1730 UInt uiOffsetY = 0; 1731 xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY ); 1732 1733 // get reference wedgelet 1734 UInt uiRefWedgeTabIdx = 0; 1735 switch( uhLumaIntraDir ) 1736 { 1737 case( DMM_WEDGE_FULL_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgeFullTabIdx ( uiTempPartIdx ); } break; 1738 case( DMM_WEDGE_FULL_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgeFullTabIdx ( uiTempPartIdx ); } break; 1739 case( DMM_WEDGE_PREDDIR_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredDirTabIdx( uiTempPartIdx ); } break; 1740 case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredDirTabIdx( uiTempPartIdx ); } break; 1741 #if HHI_DMM_PRED_TEX 1742 case( DMM_WEDGE_PREDTEX_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredTexTabIdx( uiTempPartIdx ); } break; 1743 case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU>getWedgePredTexTabIdx( uiTempPartIdx ); } break; 1744 #endif 1745 default: { assert( 0 ); return uiPredDirWedgeTabIdx; } 1746 } 1747 TComWedgelet* pcRefWedgelet; 1748 pcRefWedgelet = &(pacWedgeList>at( uiRefWedgeTabIdx )); 1749 1750 // find reference wedgelet, if direction is suitable for continue wedge 1751 if( pcRefWedgelet>checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) ) 1752 { 1753 UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; 1754 pcRefWedgelet>getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd ); 1755 getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); 1756 return uiPredDirWedgeTabIdx; 1757 } 1758 } 1759 } 1760 1761 // 3rd: (default) make wedglet from intra dir and max slope point 1762 Int iSlopeX = 0; 1763 Int iSlopeY = 0; 1764 UInt uiStartPosX = 0; 1765 UInt uiStartPosY = 0; 1766 if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) ) 1767 { 1768 UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye; 1769 xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd ); 1770 getWedgePatternIdx( pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye ); 1771 return uiPredDirWedgeTabIdx; 1772 } 1773 1774 return uiPredDirWedgeTabIdx; 1775 } 1776 1777 Bool TComPrediction::getWedgePatternIdx( WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ) 1778 { 1779 ruiTabIdx = 0; 1780 1781 for( UInt uiIdx = 0; uiIdx < pcWedgeRefList>size(); uiIdx++ ) 1782 { 1783 TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList>at(uiIdx)); 1784 1785 if( pcTestWedgeRef>getStartX() == uhXs && 1786 pcTestWedgeRef>getStartY() == uhYs && 1787 pcTestWedgeRef>getEndX() == uhXe && 1788 pcTestWedgeRef>getEndY() == uhYe ) 1789 { 1790 ruiTabIdx = pcTestWedgeRef>getRefIdx(); 1791 return true; 1792 } 1793 } 1794 1795 return false; 1796 } 1797 1798 Void TComPrediction::xPredIntraWedgeFull( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, UInt uiTabIdx, Int iDeltaDC1, Int iDeltaDC2 ) 1799 { 1800 assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); 1801 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; 1802 TComWedgelet* pcWedgelet = &(pacWedgeList>at(uiTabIdx)); 1803 1804 // get wedge pred DCs 1805 Int iPredDC1 = 0; 1806 Int iPredDC2 = 0; 1807 1808 Int* piMask = pcCU>getPattern()>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); 1809 Int iMaskStride = ( iWidth<<1 ) + 1; 1810 piMask += iMaskStride+1; 1811 getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); 1812 1813 if( bDelta ) 1814 { 1815 xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); 1816 xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); 1817 } 1818 1819 // assign wedge pred DCs to prediction 1820 if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } 1821 else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } 1822 } 1823 1824 Void TComPrediction::xPredIntraWedgeDir( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iWedgeDeltaEnd, Int iDeltaDC1, Int iDeltaDC2 ) 1825 { 1826 assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE ); 1827 WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])]; 1828 1829 // get wedge pattern 1830 UInt uiDirWedgeTabIdx = 0; 1831 if( bEncoder ) 1832 { 1833 // encoder: load stored wedge pattern from CU 1834 uiDirWedgeTabIdx = pcCU>getWedgePredDirTabIdx( uiAbsPartIdx ); 1835 } 1836 else 1837 { 1838 uiDirWedgeTabIdx = getBestContinueWedge( pcCU, uiAbsPartIdx, iWidth, iHeight, iWedgeDeltaEnd ); 1839 1840 UInt uiDepth = (pcCU>getDepth(0)) + (pcCU>getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1); 1841 pcCU>setWedgePredDirTabIdxSubParts( uiDirWedgeTabIdx, uiAbsPartIdx, uiDepth ); 1842 } 1843 TComWedgelet* pcWedgelet = &(pacWedgeList>at(uiDirWedgeTabIdx)); 1844 1845 // get wedge pred DCs 1846 Int iPredDC1 = 0; 1847 Int iPredDC2 = 0; 1848 1849 Int* piMask = pcCU>getPattern()>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); 1850 Int iMaskStride = ( iWidth<<1 ) + 1; 1851 piMask += iMaskStride+1; 1852 getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft ); 1853 1854 if( bDelta ) 1855 { 1856 xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); 1857 xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 ); 1858 } 1859 1860 // assign wedge pred DCs to prediction 1861 if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); } 1862 else { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 ); } 1863 } 1864 1865 Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ) 1866 { 1867 ruiOffsetX = 0; 1868 ruiOffsetY = 0; 1869 1870 // get offset between current and above/left block 1871 UInt uiThisOriginX = pcCU>getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1872 UInt uiThisOriginY = pcCU>getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1873 1874 UInt uiNumPartInRefCU = pcRefCU>getTotalNumPart(); 1875 UInt uiMaxDepthRefCU = 0; 1876 while( uiNumPartInRefCU > 1 ) 1877 { 1878 uiNumPartInRefCU >>= 2; 1879 uiMaxDepthRefCU++; 1880 } 1881 1882 UInt uiDepthRefPU = (pcRefCU>getDepth(uiRefAbsPartIdx)) + (pcRefCU>getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1); 1883 UInt uiShifts = (uiMaxDepthRefCU  uiDepthRefPU)*2; 1884 UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts; 1885 1886 UInt uiRefOriginX = pcRefCU>getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; 1887 UInt uiRefOriginY = pcRefCU>getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ]; 1888 1889 if( (uiThisOriginX  uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX  uiRefOriginX); } 1890 if( (uiThisOriginY  uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY  uiRefOriginY); } 1891 } 1892 1893 Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ) 1894 { 1895 riSlopeX = 0; 1896 riSlopeY = 0; 1897 ruiStartPosX = 0; 1898 ruiStartPosY = 0; 1899 1900 // 1st step: get wedge start point (max. slope) 1901 Int* piSource = pcCU>getPattern()>getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt ); 1902 Int iSourceStride = ( uiBlockSize<<1 ) + 1; 1903 1904 UInt uiSlopeMaxAbove = 0; 1905 UInt uiPosSlopeMaxAbove = 0; 1906 for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize1); uiPosHor++ ) 1907 { 1908 if( abs( piSource[uiPosHor+1]  piSource[uiPosHor] ) > uiSlopeMaxAbove ) 1909 { 1910 uiSlopeMaxAbove = abs( piSource[uiPosHor+1]  piSource[uiPosHor] ); 1911 uiPosSlopeMaxAbove = uiPosHor; 1912 } 1913 } 1914 1915 UInt uiSlopeMaxLeft = 0; 1916 UInt uiPosSlopeMaxLeft = 0; 1917 for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize1); uiPosVer++ ) 1918 { 1919 if( abs( piSource[(uiPosVer+1)*iSourceStride]  piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft ) 1920 { 1921 uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride]  piSource[uiPosVer*iSourceStride] ); 1922 uiPosSlopeMaxLeft = uiPosVer; 1923 } 1924 } 1925 1926 if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 ) 1927 { 1928 return false; 1929 } 1930 1931 if( uiSlopeMaxAbove > uiSlopeMaxLeft ) 1932 { 1933 ruiStartPosX = uiPosSlopeMaxAbove; 1934 ruiStartPosY = 0; 1935 } 1936 else 1937 { 1938 ruiStartPosX = 0; 1939 ruiStartPosY = uiPosSlopeMaxLeft; 1940 } 1941 1942 // 2nd step: derive wedge direction 1943 #if LOGI_INTRA_NAME_3MPM 1944 Int uiPreds[3] = {1, 1, 1}; 1945 #else 1946 Int uiPreds[2] = {1, 1}; 1947 #endif 1948 Int iMode = 1; 1949 Int iPredNum = pcCU>getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds, &iMode ); 1950 1951 UInt uiDirMode = 0; 1952 #if LOGI_INTRA_NAME_3MPM 1953 if( iMode >= 0 ) { iPredNum = iMode; } 1954 if( iPredNum == 1 ) { uiDirMode = uiPreds[0]; } 1955 if( iPredNum == 2 ) { uiDirMode = uiPreds[1]; } 1956 1957 if( uiDirMode < 2 ) { return false; } // no planar & DC 1958 1959 Bool modeHor = (uiDirMode < 18); 1960 Bool modeVer = !modeHor; 1961 Int intraPredAngle = modeVer ? (Int)uiDirMode  VER_IDX : modeHor ? ((Int)uiDirMode  HOR_IDX) : 0; 1962 #else 1963 if( iPredNum == 1 ) { uiDirMode = g_aucAngIntraModeOrder[uiPreds[0]]; } 1964 if( iPredNum == 2 ) { uiDirMode = g_aucAngIntraModeOrder[uiPreds[1]]; } 1965 1966 if( uiDirMode == 0 ) { return false; } // no DC 1967 1968 Bool modeVer = (uiDirMode < 18); 1969 Bool modeHor = !modeVer; 1970 Int intraPredAngle = modeVer ? uiDirMode  9 : modeHor ? uiDirMode  25 : 0; 1971 #endif 1972 Int absAng = abs(intraPredAngle); 1973 Int signAng = intraPredAngle < 0 ? 1 : 1; 1974 Int angTable[9] = {0,2,5,9,13,17,21,26,32}; 1975 absAng = angTable[absAng]; 1976 intraPredAngle = signAng * absAng; 1977 1978 // 3rd step: set slope for direction 1979 if( modeHor ) 1980 { 1981 if( intraPredAngle > 0 ) 1982 { 1983 riSlopeX = 32; 1984 riSlopeY = intraPredAngle; 1985 } 1986 else 1987 { 1988 riSlopeX = 32; 1989 riSlopeY = intraPredAngle; 1990 } 1991 } 1992 else if( modeVer ) 1993 { 1994 if( intraPredAngle > 0 ) 1995 { 1996 riSlopeX = intraPredAngle; 1997 riSlopeY = 32; 1998 } 1999 else 2000 { 2001 riSlopeX = intraPredAngle; 2002 riSlopeY = 32; 2003 } 2004 } 2005 2006 return true; 2007 } 2008 2009 Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd ) 2010 { 2011 ruhXs = 0; 2012 ruhYs = 0; 2013 ruhXe = 0; 2014 ruhYe = 0; 2015 2016 // scaling of start pos and block size to wedge resolution 2017 UInt uiScaledStartPosX = 0; 2018 UInt uiScaledStartPosY = 0; 2019 UInt uiScaledBlockSize = 0; 2020 WedgeResolution eWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiBlockSize]]; 2021 switch( eWedgeRes ) 2022 { 2023 case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; } 2024 case( FULL_PEL ): { uiScaledStartPosX = uiPMSPosX; uiScaledStartPosY = uiPMSPosY; uiScaledBlockSize = uiBlockSize; break; } 2025 case( HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; } 2026 } 2027 Int iMaxPos = (Int)uiScaledBlockSize  1; 2028 2029 // case above 2030 if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 ) 2031 { 2032 ruhXs = (UChar)uiScaledStartPosX; 2033 ruhYs = 0; 2034 2035 if( iDeltaY == 0 ) 2036 { 2037 if( iDeltaX < 0 ) 2038 { 2039 ruhXe = 0; 2040 ruhYe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); 2041 return; 2042 } 2043 else 2044 { 2045 ruhXe = (UChar)iMaxPos; 2046 ruhYe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); 2047 std::swap( ruhXs, ruhXe ); 2048 std::swap( ruhYs, ruhYe ); 2049 return; 2050 } 2051 } 2052 2053 // regular case 2054 Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); 2055 2056 if( iVirtualEndX < 0 ) 2057 { 2058 Int iYe = roftoi( (Double)(0  (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd; 2059 if( iYe < (Int)uiScaledBlockSize ) 2060 { 2061 ruhXe = 0; 2062 ruhYe = (UChar)std::max( iYe, 0 ); 2063 return; 2064 } 2065 else 2066 { 2067 ruhXe = (UChar)std::min( (iYe  iMaxPos), iMaxPos ); 2068 ruhYe = (UChar)iMaxPos; 2069 return; 2070 } 2071 } 2072 else if( iVirtualEndX > iMaxPos ) 2073 { 2074 Int iYe = roftoi( (Double)(iMaxPos  (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) )  iDeltaEnd; 2075 if( iYe < (Int)uiScaledBlockSize ) 2076 { 2077 ruhXe = (UChar)iMaxPos; 2078 ruhYe = (UChar)std::max( iYe, 0 ); 2079 std::swap( ruhXs, ruhXe ); 2080 std::swap( ruhYs, ruhYe ); 2081 return; 2082 } 2083 else 2084 { 2085 ruhXe = (UChar)std::max( (iMaxPos  (iYe  iMaxPos)), 0 ); 2086 ruhYe = (UChar)iMaxPos; 2087 return; 2088 } 2089 } 2090 else 2091 { 2092 Int iXe = iVirtualEndX + iDeltaEnd; 2093 if( iXe < 0 ) 2094 { 2095 ruhXe = 0; 2096 ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); 2097 return; 2098 } 2099 else if( iXe > iMaxPos ) 2100 { 2101 ruhXe = (UChar)iMaxPos; 2102 ruhYe = (UChar)std::max( (iMaxPos  (iXe  iMaxPos)), 0 ); 2103 std::swap( ruhXs, ruhXe ); 2104 std::swap( ruhYs, ruhYe ); 2105 return; 2106 } 2107 else 2108 { 2109 ruhXe = (UChar)iXe; 2110 ruhYe = (UChar)iMaxPos; 2111 return; 2112 } 2113 } 2114 } 2115 2116 // case left 2117 if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 ) 2118 { 2119 ruhXs = 0; 2120 ruhYs = (UChar)uiScaledStartPosY; 2121 2122 if( iDeltaX == 0 ) 2123 { 2124 if( iDeltaY < 0 ) 2125 { 2126 ruhXe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); 2127 ruhYe = 0; 2128 std::swap( ruhXs, ruhXe ); 2129 std::swap( ruhYs, ruhYe ); 2130 return; 2131 } 2132 else 2133 { 2134 ruhXe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos ); 2135 ruhYe = (UChar)iMaxPos; 2136 return; 2137 } 2138 } 2139 2140 // regular case 2141 Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iMaxPos * ((Double)iDeltaY / (Double)iDeltaX) ); 2142 2143 if( iVirtualEndY < 0 ) 2144 { 2145 Int iXe = roftoi( (Double)(0  (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) )  iDeltaEnd; 2146 if( iXe < (Int)uiScaledBlockSize ) 2147 { 2148 ruhXe = (UChar)std::max( iXe, 0 ); 2149 ruhYe = 0; 2150 std::swap( ruhXs, ruhXe ); 2151 std::swap( ruhYs, ruhYe ); 2152 return; 2153 } 2154 else 2155 { 2156 ruhXe = (UChar)iMaxPos; 2157 ruhYe = (UChar)std::min( (iXe  iMaxPos), iMaxPos ); 2158 std::swap( ruhXs, ruhXe ); 2159 std::swap( ruhYs, ruhYe ); 2160 return; 2161 } 2162 } 2163 else if( iVirtualEndY > (uiScaledBlockSize1) ) 2164 { 2165 Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize1)  (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd; 2166 if( iXe < (Int)uiScaledBlockSize ) 2167 { 2168 ruhXe = (UChar)std::max( iXe, 0 ); 2169 ruhYe = (UChar)(uiScaledBlockSize1); 2170 return; 2171 } 2172 else 2173 { 2174 ruhXe = (UChar)iMaxPos; 2175 ruhYe = (UChar)std::max( (iMaxPos  (iXe  iMaxPos)), 0 ); 2176 std::swap( ruhXs, ruhXe ); 2177 std::swap( ruhYs, ruhYe ); 2178 return; 2179 } 2180 } 2181 else 2182 { 2183 Int iYe = iVirtualEndY  iDeltaEnd; 2184 if( iYe < 0 ) 2185 { 2186 ruhXe = (UChar)std::max( (iMaxPos + iYe), 0 ); 2187 ruhYe = 0; 2188 std::swap( ruhXs, ruhXe ); 2189 std::swap( ruhYs, ruhYe ); 2190 return; 2191 } 2192 else if( iYe > iMaxPos ) 2193 { 2194 ruhXe = (UChar)std::max( (iMaxPos  (iYe  iMaxPos)), 0 ); 2195 ruhYe = (UChar)iMaxPos; 2196 return; 2197 } 2198 else 2199 { 2200 ruhXe = (UChar)iMaxPos; 2201 ruhYe = (UChar)iYe; 2202 std::swap( ruhXs, ruhXe ); 2203 std::swap( ruhYs, ruhYe ); 2204 return; 2205 } 2206 } 2207 } 2208 2209 // case origin 2210 if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 ) 2211 { 2212 if( iDeltaX*iDeltaY < 0 ) 2213 { 2214 return; 2215 } 2216 2217 ruhXs = 0; 2218 ruhYs = 0; 2219 2220 if( iDeltaY == 0 ) 2221 { 2222 ruhXe = (UChar)iMaxPos; 2223 ruhYe = 0; 2224 std::swap( ruhXs, ruhXe ); 2225 std::swap( ruhYs, ruhYe ); 2226 return; 2227 } 2228 2229 if( iDeltaX == 0 ) 2230 { 2231 ruhXe = 0; 2232 ruhYe = (UChar)iMaxPos; 2233 return; 2234 } 2235 2236 Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) ); 2237 2238 if( iVirtualEndX > iMaxPos ) 2239 { 2240 Int iYe = roftoi( (Double)((Int)iMaxPos  (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) )  iDeltaEnd; 2241 if( iYe < (Int)uiScaledBlockSize ) 2242 { 2243 ruhXe = (UChar)(uiScaledBlockSize1); 2244 ruhYe = (UChar)std::max( iYe, 0 ); 2245 std::swap( ruhXs, ruhXe ); 2246 std::swap( ruhYs, ruhYe ); 2247 return; 2248 } 2249 else 2250 { 2251 ruhXe = (UChar)std::max( (iMaxPos  (iYe  iMaxPos)), 0 ); 2252 ruhYe = (UChar)(uiScaledBlockSize1); 2253 return; 2254 } 2255 } 2256 else 2257 { 2258 Int iXe = iVirtualEndX + iDeltaEnd; 2259 if( iXe < 0 ) 2260 { 2261 ruhXe = 0; 2262 ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 ); 2263 return; 2264 } 2265 else if( iXe > iMaxPos ) 2266 { 2267 ruhXe = (UChar)(uiScaledBlockSize1); 2268 ruhYe = (UChar)std::max( (iMaxPos  (iXe  iMaxPos)), 0 ); 2269 std::swap( ruhXs, ruhXe ); 2270 std::swap( ruhYs, ruhYe ); 2271 return; 2272 } 2273 else 2274 { 2275 ruhXe = (UChar)iXe; 2276 ruhYe = (UChar)(uiScaledBlockSize1); 2277 return; 2278 } 2279 } 2280 } 2281 } 2282 #endif 2283 2284 Void 2285 TComPrediction::predIntraDepthAng(TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight ) 2286 { 2287 Pel* pDst = piPred; 2288 Int* ptrSrc = pcTComPattern>getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); 2289 Int sw = ( iWidth<<1 ) + 1; 2290 #if !LOGI_INTRA_NAME_3MPM 2291 uiDirMode = g_aucAngIntraModeOrder[ uiDirMode ]; 2292 #endif 2293 xPredIntraAngDepth( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode ); 2294 } 2295 2296 Int 2297 TComPrediction::xGetDCDepth( Int* pSrc, Int iDelta, Int iBlkSize ) 2298 { 2299 Int iDC = PDM_UNDEFINED_DEPTH; 2300 Int iSum = 0; 2301 Int iNum = 0; 2302 for( Int k = 0; k < iBlkSize; k++, pSrc += iDelta ) 2303 { 2304 if( *pSrc != PDM_UNDEFINED_DEPTH ) 2305 { 2306 iSum += *pSrc; 2307 iNum ++; 2308 } 2309 } 2310 if( iNum ) 2311 { 2312 iDC = ( iSum + ( iNum >> 1 ) ) / iNum; 2313 } 2314 return iDC; 2315 } 2316 2317 Int 2318 TComPrediction::xGetDCValDepth( Int iVal1, Int iVal2, Int iVal3, Int iVal4 ) 2319 { 2320 if ( iVal1 != PDM_UNDEFINED_DEPTH ) return iVal1; 2321 else if( iVal2 != PDM_UNDEFINED_DEPTH ) return iVal2; 2322 else if( iVal3 != PDM_UNDEFINED_DEPTH ) return iVal3; 2323 return iVal4; 2324 } 2325 2326 Void 2327 TComPrediction::xPredIntraAngDepth( Int* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, UInt dirMode ) 2328 { 2329 AOF( width == height ); 2330 Int blkSize = width; 2331 Int iDCAbove = xGetDCDepth( pSrc  srcStride, 1, blkSize ); 2332 Int iDCAboveRight = xGetDCDepth( pSrc  srcStride + blkSize, 1, blkSize ); 2333 Int iDCLeft = xGetDCDepth( pSrc  1, srcStride, blkSize ); 2334 Int iDCBelowLeft = xGetDCDepth( pSrc  1 + blkSize * srcStride, srcStride, blkSize ); 2335 Int iWgt, iDC1, iDC2; 2336 if( dirMode < 2 ) // 1..2 2337 { 2338 iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); 2339 iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); 2340 iWgt = 8; 2341 } 2342 else if( dirMode < 11 ) // 3..10 2343 { 2344 iDC1 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); 2345 iDC2 = xGetDCValDepth( iDCBelowLeft, iDCLeft, iDCAbove, iDCAboveRight ); 2346 iWgt = 6 + dirMode; 2347 } 2348 else if( dirMode < 27 ) // 11..26 2349 { 2350 iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); 2351 iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); 2352 iWgt = dirMode  10; 2353 } 2354 else if( dirMode < 35 ) // 27..34 2355 { 2356 iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); 2357 iDC2 = xGetDCValDepth( iDCAboveRight, iDCAbove, iDCLeft, iDCBelowLeft ); 2358 iWgt = 42  dirMode; 2359 } 2360 else // (wedgelet > use simple DC prediction 2361 { 2362 iDC1 = xGetDCValDepth( iDCAbove, iDCAboveRight, iDCLeft, iDCBelowLeft ); 2363 iDC2 = xGetDCValDepth( iDCLeft, iDCBelowLeft, iDCAbove, iDCAboveRight ); 2364 iWgt = 8; 2365 } 2366 Int iWgt2 = 16  iWgt; 2367 Int iDCVal = ( iWgt * iDC1 + iWgt2 * iDC2 + 8 ) >> 4; 2368 2369 // set depth 2370 for( Int iY = 0; iY < blkSize; iY++, pDst += dstStride ) 2371 { 2372 for( Int iX = 0; iX < blkSize; iX++ ) 2373 { 2374 pDst[ iX ] = iDCVal; 2375 } 2376 } 2377 } 2378 2379 //! \}
Note: See TracChangeset for help on using the changeset viewer.