Changeset 608 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComYuv.cpp
- Timestamp:
- 1 Sep 2013, 22:47:26 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComYuv.cpp
r443 r608 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 2, ITU/ISO/IEC6 * Copyright (c) 2010-2013, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 282 282 } 283 283 284 #if DEPTH_MAP_GENERATION285 Void TComYuv::copyPartToPartYuvPdm ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY )286 {287 copyPartToPartLumaPdm (pcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY );288 }289 #endif290 291 284 Void TComYuv::copyPartToPartYuv ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) 292 285 { … … 294 287 copyPartToPartChroma (pcYuvDst, uiPartIdx, iWidth>>1, iHeight>>1 ); 295 288 } 296 297 #if DEPTH_MAP_GENERATION298 Void TComYuv::copyPartToPartLumaPdm ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY )299 {300 UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpX;301 UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ uiPartIdx ] ] >> uiSubSampExpY;302 Pel* pSrc = getLumaAddr(uiPartIdx);303 Pel* pDst = pcYuvDst->getLumaAddr() + uiBlkY * pcYuvDst->getStride() + uiBlkX;304 305 if( pSrc == pDst )306 {307 //th not a good idea308 //th best would be to fix the caller309 return ;310 }311 312 UInt iSrcStride = getStride();313 UInt iDstStride = pcYuvDst->getStride();314 for ( UInt y = iHeight; y != 0; y-- )315 {316 ::memcpy( pDst, pSrc, iWidth * sizeof(Pel) );317 pSrc += iSrcStride;318 pDst += iDstStride;319 }320 }321 #endif322 289 323 290 Void TComYuv::copyPartToPartLuma ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight ) … … 369 336 } 370 337 371 Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) 372 { 373 Int x, y; 374 375 Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx); 376 Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx); 377 Pel* pDst = getLumaAddr( uiTrUnitIdx); 378 338 Void TComYuv::copyPartToPartChroma( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt chromaId) 339 { 340 if(chromaId == 0) 341 { 342 Pel* pSrcU = getCbAddr(uiPartIdx); 343 Pel* pDstU = pcYuvDst->getCbAddr(uiPartIdx); 344 if( pSrcU == pDstU) 345 { 346 return ; 347 } 348 UInt iSrcStride = getCStride(); 349 UInt iDstStride = pcYuvDst->getCStride(); 350 for ( UInt y = iHeight; y != 0; y-- ) 351 { 352 ::memcpy( pDstU, pSrcU, iWidth * sizeof(Pel) ); 353 pSrcU += iSrcStride; 354 pDstU += iDstStride; 355 } 356 } 357 else if (chromaId == 1) 358 { 359 Pel* pSrcV = getCrAddr(uiPartIdx); 360 Pel* pDstV = pcYuvDst->getCrAddr(uiPartIdx); 361 if( pSrcV == pDstV) 362 { 363 return; 364 } 365 UInt iSrcStride = getCStride(); 366 UInt iDstStride = pcYuvDst->getCStride(); 367 for ( UInt y = iHeight; y != 0; y-- ) 368 { 369 ::memcpy( pDstV, pSrcV, iWidth * sizeof(Pel) ); 370 pSrcV += iSrcStride; 371 pDstV += iDstStride; 372 } 373 } 374 else 375 { 376 Pel* pSrcU = getCbAddr(uiPartIdx); 377 Pel* pSrcV = getCrAddr(uiPartIdx); 378 Pel* pDstU = pcYuvDst->getCbAddr(uiPartIdx); 379 Pel* pDstV = pcYuvDst->getCrAddr(uiPartIdx); 380 381 if( pSrcU == pDstU && pSrcV == pDstV) 382 { 383 //th not a good idea 384 //th best would be to fix the caller 385 return ; 386 } 387 UInt iSrcStride = getCStride(); 388 UInt iDstStride = pcYuvDst->getCStride(); 389 for ( UInt y = iHeight; y != 0; y-- ) 390 { 391 ::memcpy( pDstU, pSrcU, iWidth * sizeof(Pel) ); 392 ::memcpy( pDstV, pSrcV, iWidth * sizeof(Pel) ); 393 pSrcU += iSrcStride; 394 pSrcV += iSrcStride; 395 pDstU += iDstStride; 396 pDstV += iDstStride; 397 } 398 } 399 } 400 401 Void TComYuv::addClip( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) 402 { 403 addClipLuma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize ); 404 addClipChroma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1 ); 405 } 406 407 Void TComYuv::addClipLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) 408 { 409 Int x, y; 410 411 Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize ); 412 Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize ); 413 Pel* pDst = getLumaAddr( uiTrUnitIdx, uiPartSize ); 414 379 415 UInt iSrc0Stride = pcYuvSrc0->getStride(); 380 416 UInt iSrc1Stride = pcYuvSrc1->getStride(); … … 384 420 for ( x = uiPartSize-1; x >= 0; x-- ) 385 421 { 386 pDst[x] = Clip( pSrc0[x] + pSrc1[x] ); 387 } 388 pSrc0 += iSrc0Stride; 389 pSrc1 += iSrc1Stride; 390 pDst += iDstStride; 391 } 392 } 393 394 Void 395 TComYuv::add( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) 396 { 397 addLuma ( pcYuvAdd, iWidth, iHeight, bSubtract ); 398 addChroma ( pcYuvAdd, iWidth>>1, iHeight>>1, bSubtract ); 399 } 400 401 402 Void 403 TComYuv::addLuma( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) 404 { 405 Int iScale = ( bSubtract ? -1 : 1 ); 406 Int iAddStride = pcYuvAdd->getStride(); 407 Int iDstStride = getStride(); 408 Pel* pAddSamples = pcYuvAdd->getLumaAddr(); 409 Pel* pDstSamples = getLumaAddr(); 410 411 for( Int iY = 0; iY < iHeight; iY++, pDstSamples += iDstStride, pAddSamples += iAddStride ) 412 { 413 for( Int iX = 0; iX < iWidth; iX++ ) 414 { 415 pDstSamples[iX] += iScale * pAddSamples[iX]; 416 } 417 } 418 } 419 420 Void 421 TComYuv::addChroma( TComYuv* pcYuvAdd, Int iWidth, Int iHeight, Bool bSubtract ) 422 { 423 Int iScale = ( bSubtract ? -1 : 1 ); 424 Int iAddStride = pcYuvAdd->getCStride(); 425 Int iDstStride = getCStride(); 426 Pel* pAddSamplesCb = pcYuvAdd->getCbAddr(); 427 Pel* pAddSamplesCr = pcYuvAdd->getCrAddr(); 428 Pel* pDstSamplesCb = getCbAddr(); 429 Pel* pDstSamplesCr = getCrAddr(); 430 431 for( Int iY = 0; iY < iHeight; iY++, pDstSamplesCb += iDstStride, pAddSamplesCb += iAddStride, 432 pDstSamplesCr += iDstStride, pAddSamplesCr += iAddStride ) 433 { 434 for( Int iX = 0; iX < iWidth; iX++ ) 435 { 436 pDstSamplesCb[iX] += iScale * pAddSamplesCb[iX]; 437 pDstSamplesCr[iX] += iScale * pAddSamplesCr[iX]; 438 } 439 } 440 } 441 442 Void 443 TComYuv::clip( Int iWidth, Int iHeight ) 444 { 445 clipLuma ( iWidth, iHeight ); 446 clipChroma ( iWidth>>1, iHeight>>1 ); 447 } 448 449 Void 450 TComYuv::clipLuma( Int iWidth, Int iHeight ) 451 { 452 Int iStride = getStride(); 453 Pel* pSamples = getLumaAddr(); 454 for( Int iY = 0; iY < iHeight; iY++, pSamples += iStride ) 455 { 456 for( Int iX = 0; iX < iWidth; iX++ ) 457 { 458 pSamples[iX] = xClip( pSamples[iX] ); 459 } 460 } 461 } 462 463 Void 464 TComYuv::clipChroma( Int iWidth, Int iHeight ) 465 { 466 Int iStride = getCStride(); 467 Pel* pSamplesCb = getCbAddr(); 468 Pel* pSamplesCr = getCrAddr(); 469 for( Int iY = 0; iY < iHeight; iY++, pSamplesCb += iStride, pSamplesCr += iStride ) 470 { 471 for( Int iX = 0; iX < iWidth; iX++ ) 472 { 473 pSamplesCb[iX] = xClip( pSamplesCb[iX] ); 474 pSamplesCr[iX] = xClip( pSamplesCr[iX] ); 475 } 476 } 477 } 478 479 Void TComYuv::addClip( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) 480 { 481 addClipLuma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize ); 482 addClipChroma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1 ); 483 } 484 485 Void TComYuv::addClipLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) 486 { 487 Int x, y; 488 489 Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize ); 490 Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize ); 491 Pel* pDst = getLumaAddr( uiTrUnitIdx, uiPartSize ); 492 493 UInt iSrc0Stride = pcYuvSrc0->getStride(); 494 UInt iSrc1Stride = pcYuvSrc1->getStride(); 495 UInt iDstStride = getStride(); 496 for ( y = uiPartSize-1; y >= 0; y-- ) 497 { 498 for ( x = uiPartSize-1; x >= 0; x-- ) 499 { 500 pDst[x] = Clip( pSrc0[x] + pSrc1[x] ); 422 pDst[x] = ClipY( pSrc0[x] + pSrc1[x] ); 501 423 } 502 424 pSrc0 += iSrc0Stride; … … 524 446 for ( x = uiPartSize-1; x >= 0; x-- ) 525 447 { 526 pDstU[x] = Clip ( pSrcU0[x] + pSrcU1[x] );527 pDstV[x] = Clip ( pSrcV0[x] + pSrcV1[x] );448 pDstU[x] = ClipC( pSrcU0[x] + pSrcU1[x] ); 449 pDstV[x] = ClipC( pSrcV0[x] + pSrcV1[x] ); 528 450 } 529 451 … … 554 476 Int iSrc1Stride = pcYuvSrc1->getStride(); 555 477 Int iDstStride = getStride(); 556 557 478 for ( y = uiPartSize-1; y >= 0; y-- ) 558 479 { … … 616 537 UInt iSrc1Stride = pcYuvSrc1->getStride(); 617 538 UInt iDstStride = getStride(); 618 Int shiftNum = IF_INTERNAL_PREC + 1 - ( g_uiBitDepth + g_uiBitIncrement );539 Int shiftNum = IF_INTERNAL_PREC + 1 - g_bitDepthY; 619 540 Int offset = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS; 620 541 … … 623 544 for ( x = 0; x < iWidth; x += 4 ) 624 545 { 625 pDstY[ x + 0 ] = Clip ( ( pSrcY0[ x + 0 ] + pSrcY1[ x + 0 ] + offset ) >> shiftNum );626 pDstY[ x + 1 ] = Clip ( ( pSrcY0[ x + 1 ] + pSrcY1[ x + 1 ] + offset ) >> shiftNum );627 pDstY[ x + 2 ] = Clip ( ( pSrcY0[ x + 2 ] + pSrcY1[ x + 2 ] + offset ) >> shiftNum );628 pDstY[ x + 3 ] = Clip ( ( pSrcY0[ x + 3 ] + pSrcY1[ x + 3 ] + offset ) >> shiftNum );546 pDstY[ x + 0 ] = ClipY( ( pSrcY0[ x + 0 ] + pSrcY1[ x + 0 ] + offset ) >> shiftNum ); 547 pDstY[ x + 1 ] = ClipY( ( pSrcY0[ x + 1 ] + pSrcY1[ x + 1 ] + offset ) >> shiftNum ); 548 pDstY[ x + 2 ] = ClipY( ( pSrcY0[ x + 2 ] + pSrcY1[ x + 2 ] + offset ) >> shiftNum ); 549 pDstY[ x + 3 ] = ClipY( ( pSrcY0[ x + 3 ] + pSrcY1[ x + 3 ] + offset ) >> shiftNum ); 629 550 } 630 551 pSrcY0 += iSrc0Stride; … … 633 554 } 634 555 556 shiftNum = IF_INTERNAL_PREC + 1 - g_bitDepthC; 557 offset = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS; 558 635 559 iSrc0Stride = pcYuvSrc0->getCStride(); 636 560 iSrc1Stride = pcYuvSrc1->getCStride(); … … 645 569 { 646 570 // note: chroma min width is 2 647 pDstU[x] = Clip ((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum);648 pDstV[x] = Clip ((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--;649 pDstU[x] = Clip ((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum);650 pDstV[x] = Clip ((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--;571 pDstU[x] = ClipC((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); 572 pDstV[x] = ClipC((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; 573 pDstU[x] = ClipC((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum); 574 pDstV[x] = ClipC((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--; 651 575 } 652 576 … … 660 584 } 661 585 662 #if DEPTH_MAP_GENERATION663 Void TComYuv::addAvgPdm( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY )664 {665 Int x, y;666 667 UInt uiBlkX = g_auiRasterToPelX[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpX;668 UInt uiBlkY = g_auiRasterToPelY[ g_auiZscanToRaster[ iPartUnitIdx ] ] >> uiSubSampExpY;669 Pel* pSrcY0 = pcYuvSrc0->getLumaAddr( iPartUnitIdx );670 Pel* pSrcY1 = pcYuvSrc1->getLumaAddr( iPartUnitIdx );671 Pel* pDstY = getLumaAddr() + uiBlkY * getStride() + uiBlkX;672 673 UInt iSrc0Stride = pcYuvSrc0->getStride();674 UInt iSrc1Stride = pcYuvSrc1->getStride();675 UInt iDstStride = getStride();676 677 for ( y = iHeight-1; y >= 0; y-- )678 {679 for ( x = iWidth-1; x >= 0; x-- )680 {681 pDstY[x] = (pSrcY0[x] + pSrcY1[x] + 1) >> 1;682 }683 pSrcY0 += iSrc0Stride;684 pSrcY1 += iSrc1Stride;685 pDstY += iDstStride;686 }687 }688 #endif689 690 586 Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight ) 691 587 { … … 741 637 } 742 638 } 743 #if QC_ARP_D0177 744 Void TComYuv::addARP(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip ) 639 640 #if H_3D 641 Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize ) 642 { 643 Int x, y; 644 645 Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx); 646 Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx); 647 Pel* pDst = getLumaAddr( uiTrUnitIdx); 648 649 UInt iSrc0Stride = pcYuvSrc0->getStride(); 650 UInt iSrc1Stride = pcYuvSrc1->getStride(); 651 UInt iDstStride = getStride(); 652 for ( y = uiPartSize-1; y >= 0; y-- ) 653 { 654 for ( x = uiPartSize-1; x >= 0; x-- ) 655 { 656 pDst[x] = ClipY( pSrc0[x] + pSrc1[x] ); 657 } 658 pSrc0 += iSrc0Stride; 659 pSrc1 += iSrc1Stride; 660 pDst += iDstStride; 661 } 662 } 663 664 #if H_3D_ARP 665 Void TComYuv::addARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip ) 745 666 { 746 667 addARPLuma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth , uiHeight , bClip ); … … 748 669 } 749 670 750 Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight, Bool bClip )671 Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip ) 751 672 { 752 673 Int x, y; … … 765 686 pDst[x] = pSrc0[x] + pSrc1[x]; 766 687 if( bClip ) 767 pDst[x] = Clip( pDst[x] ); 688 { 689 pDst[x] = ClipY( pDst[x] ); 690 } 768 691 } 769 692 pSrc0 += iSrc0Stride; … … 773 696 } 774 697 775 Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight, Bool bClip )698 Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip ) 776 699 { 777 700 Int x, y; … … 795 718 if( bClip ) 796 719 { 797 pDstU[x] = Clip ( pDstU[x] );798 pDstV[x] = Clip ( pDstV[x] );720 pDstU[x] = ClipC( pDstU[x] ); 721 pDstV[x] = ClipC( pDstV[x] ); 799 722 } 800 723 } … … 809 732 } 810 733 811 Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight)734 Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ) 812 735 { 813 736 subtractARPLuma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth , uiHeight ); … … 815 738 } 816 739 817 Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight)740 Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ) 818 741 { 819 742 Int x, y; … … 838 761 } 839 762 840 Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight)763 Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight ) 841 764 { 842 765 Int x, y; … … 874 797 } 875 798 876 Void TComYuv::xxMultiplyLine( Pel 799 Void TComYuv::xxMultiplyLine( Pel* pSrcDst , UInt uiWidth , UChar dW ) 877 800 { 878 801 assert( dW == 2 ); … … 907 830 } 908 831 #endif 832 #endif 909 833 //! \}
Note: See TracChangeset for help on using the changeset viewer.