Changeset 100 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPrediction.cpp
- Timestamp:
- 9 Aug 2012, 12:53:16 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComPrediction.cpp
r56 r100 46 46 // ==================================================================================================================== 47 47 48 #if LGE_EDGE_INTRA 49 #define MAX_DISTANCE_EDGEINTRA 255 50 #endif 51 48 52 TComPrediction::TComPrediction() 49 53 : m_pLumaRecBuffer(0) … … 419 423 } 420 424 425 #if LGE_EDGE_INTRA 426 Void TComPrediction::predIntraLumaEdge ( TComDataCU* pcCU, TComPattern* pcTComPattern, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Pel* piPred, UInt uiStride, Bool bDelta ) 427 { 428 Pel *piDst = piPred; 429 Int *piSrc; 430 Int iSrcStride = ( iWidth<<1 ) + 1; 431 Int iDstStride = uiStride; 432 433 piSrc = pcTComPattern->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt ); 434 435 xPredIntraEdge ( pcCU, uiAbsPartIdx, iWidth, iHeight, piSrc, iSrcStride, piDst, iDstStride 436 #if LGE_EDGE_INTRA_DELTA_DC 437 , bDelta 438 #endif 439 ); 440 } 441 442 Pel TComPrediction::xGetNearestNeighbor( Int x, Int y, Int* pSrc, Int srcStride, Int iWidth, Int iHeight, Bool* bpRegion ) 443 { 444 Bool bLeft = (x < y) ? true : false; 445 Bool bFound = false; 446 Int iFoundX = -1, iFoundY = -1; 447 Int cResult = 0; 448 449 UChar* piTopDistance = new UChar[iWidth]; 450 UChar* piLeftDistance = new UChar[iHeight]; 451 452 for( Int i = 0; i < iWidth; i++ ) 453 { 454 int Abs = x > i ? x - i : i - x; 455 piTopDistance[ i ] = y + Abs; 456 457 Abs = y > i ? y - i : i - y; 458 piLeftDistance[ i ] = x + Abs; 459 } 460 461 for( Int dist = 0; dist < MAX_DISTANCE_EDGEINTRA && !bFound; dist++ ) 462 { 463 if( !bLeft ) 464 { 465 for( Int i = 0; i < iWidth; i++ ) 466 { 467 if( piTopDistance[ i ] == dist ) 468 { 469 if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] ) 470 { 471 iFoundX = i; 472 iFoundY = 0; 473 bFound = true; 474 } 475 } 476 } 477 for( Int i = 0; i < iHeight; i++ ) 478 { 479 if( piLeftDistance[ i ] == dist ) 480 { 481 if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] ) 482 { 483 iFoundX = 0; 484 iFoundY = i; 485 bFound = true; 486 } 487 } 488 } 489 } 490 else 491 { 492 for( Int i = 0; i < iHeight; i++ ) 493 { 494 if( piLeftDistance[ i ] == dist ) 495 { 496 if( bpRegion[ i * iWidth ] == bpRegion[ x + y * iWidth ] ) 497 { 498 iFoundX = 0; 499 iFoundY = i; 500 bFound = true; 501 } 502 } 503 } 504 for( Int i = 0; i < iWidth; i++ ) 505 { 506 if( piTopDistance[ i ] == dist ) 507 { 508 if( bpRegion[ i ] == bpRegion[ x + y * iWidth ] ) 509 { 510 iFoundX = i; 511 iFoundY = 0; 512 bFound = true; 513 } 514 } 515 } 516 } 517 } 518 519 if( iFoundY == 0 ) 520 { 521 cResult = pSrc[ iFoundX + 1 ]; 522 } 523 else // iFoundX == 0 524 { 525 cResult = pSrc[ (iFoundY + 1) * srcStride ]; 526 } 527 528 delete[] piTopDistance; piTopDistance = NULL; 529 delete[] piLeftDistance; piLeftDistance = NULL; 530 531 assert( bFound ); 532 533 return cResult; 534 } 535 536 Void TComPrediction::xPredIntraEdge( TComDataCU* pcCU, UInt uiAbsPartIdx, Int iWidth, Int iHeight, Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, Bool bDelta ) 537 { 538 Pel* pDst = rpDst; 539 Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx ); 540 541 // Do prediction 542 { 543 //UInt uiSum0 = 0, uiSum1 = 0; 544 Int iSum0 = 0, iSum1 = 0; 545 //UInt uiMean0, uiMean1; 546 Int iMean0, iMean1; 547 //UInt uiCount0 = 0, uiCount1 = 0; 548 Int iCount0 = 0, iCount1 = 0; 549 for( UInt ui = 0; ui < iWidth; ui++ ) 550 { 551 if( pbRegion[ ui ] == false ) 552 { 553 iSum0 += (pSrc[ ui + 1 ]); 554 iCount0++; 555 } 556 else 557 { 558 iSum1 += (pSrc[ ui + 1 ]); 559 iCount1++; 560 } 561 } 562 for( UInt ui = 0; ui < iHeight; ui++ ) // (0,0) recount (to avoid division) 563 { 564 if( pbRegion[ ui * iWidth ] == false ) 565 { 566 iSum0 += (pSrc[ (ui + 1) * srcStride ]); 567 iCount0++; 568 } 569 else 570 { 571 iSum1 += (pSrc[ (ui + 1) * srcStride ]); 572 iCount1++; 573 } 574 } 575 if( iCount0 == 0 ) 576 assert(false); 577 if( iCount1 == 0 ) 578 assert(false); 579 iMean0 = iSum0 / iCount0; // TODO : integer op. 580 iMean1 = iSum1 / iCount1; 581 #if LGE_EDGE_INTRA_DELTA_DC 582 if( bDelta ) 583 { 584 Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx ); 585 Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx ); 586 xDeltaDCQuantScaleUp( pcCU, iDeltaDC0 ); 587 xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 ); 588 iMean0 = Clip( iMean0 + iDeltaDC0 ); 589 iMean1 = Clip( iMean1 + iDeltaDC1 ); 590 } 591 #endif 592 for( UInt ui = 0; ui < iHeight; ui++ ) 593 { 594 for( UInt uii = 0; uii < iWidth; uii++ ) 595 { 596 if( pbRegion[ uii + ui * iWidth ] == false ) 597 pDst[ uii + ui * dstStride ] = iMean0; 598 else 599 pDst[ uii + ui * dstStride ] = iMean1; 600 } 601 } 602 } 603 } 604 #endif 605 421 606 #if DEPTH_MAP_GENERATION 422 607 Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY ) … … 569 754 { 570 755 UInt uiRShift = 0; 571 xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 ); 756 #if PDM_REMOVE_DEPENDENCE 757 if( pcCU->getPic()->getStoredPDMforV2() == 1 ) 758 xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMapTemp(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 ); 759 else 760 #endif 761 xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift, 0 ); 762 572 763 return; 573 764 }
Note: See TracChangeset for help on using the changeset viewer.