Changeset 833 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComRdCost.cpp
- Timestamp:
- 7 Feb 2014, 20:31:12 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComRdCost.cpp
r655 r833 266 266 m_bUseEstimatedVSD = false; 267 267 #endif 268 #if H_3D_DBBP 269 m_bUseMask = false; 270 #endif 268 271 } 269 272 … … 326 329 rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; 327 330 331 #if H_3D_DBBP 332 if( m_bUseMask ) 333 { 334 if( eDFunc >= DF_SSE && eDFunc <= DF_SSE16N ) 335 { 336 rcDistParam.DistFunc = TComRdCost::xGetMaskedSSE; 337 } 338 else if( eDFunc >= DF_SAD && eDFunc <= DF_SADS16N ) 339 { 340 rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD; 341 } 342 else if( eDFunc >= DF_HADS && eDFunc <= DF_HADS16N ) 343 { 344 rcDistParam.DistFunc = TComRdCost::xGetMaskedHADs; 345 } 346 else if( eDFunc >= DF_VSD && eDFunc <= DF_VSD16N ) 347 { 348 rcDistParam.DistFunc = TComRdCost::xGetMaskedVSD; 349 } 350 else if( eDFunc >= DF_SAD12 && eDFunc <= DF_SADS48 ) 351 { 352 rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD; 353 } 354 } 355 #endif 356 328 357 // initialize 329 358 rcDistParam.iSubShift = 0; … … 357 386 { 358 387 rcDistParam.DistFunc = m_afpDistortFunc[45 ]; 388 } 389 #endif 390 391 #if H_3D_DBBP 392 if( m_bUseMask ) 393 { 394 rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD; 359 395 } 360 396 #endif … … 411 447 rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; 412 448 } 449 450 #if H_3D_DBBP 451 if( m_bUseMask ) 452 { 453 rcDistParam.DistFunc = (bHADME)?TComRdCost::xGetMaskedHADs:TComRdCost::xGetMaskedSAD; 454 } 455 #endif 413 456 414 457 // initialize … … 433 476 rcDP.bitDepth = bitDepth; 434 477 rcDP.DistFunc = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ]; 478 479 #if H_3D_DBBP 480 if( m_bUseMask ) 481 { 482 rcDP.DistFunc = (bHadamard)?TComRdCost::xGetMaskedHADs:TComRdCost::xGetMaskedSAD; 483 } 484 #endif 485 435 486 #if NS_HAD 436 487 rcDP.bUseNSHAD = bUseNSHAD; … … 586 637 cDtParam.uiComp = 255; // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed. 587 638 639 #if SCU_HS_VSD_BUGFIX_IMPROV_G0163 640 cDtParam.bitDepth = g_bitDepthY; 641 #endif 588 642 Dist dist = cDtParam.DistFunc( &cDtParam ); 589 643 … … 631 685 // Distortion functions 632 686 // ==================================================================================================================== 687 688 #if H_3D_DBBP 689 // -------------------------------------------------------------------------------------------------------------------- 690 // Masked distortion functions 691 // -------------------------------------------------------------------------------------------------------------------- 692 693 UInt TComRdCost::xGetMaskedSSE( DistParam* pcDtParam ) 694 { 695 Pel* piOrg = pcDtParam->pOrg; 696 Pel* piCur = pcDtParam->pCur; 697 Int iRows = pcDtParam->iRows; 698 Int iCols = pcDtParam->iCols; 699 Int iStrideOrg = pcDtParam->iStrideOrg; 700 Int iStrideCur = pcDtParam->iStrideCur; 701 702 UInt uiSum = 0; 703 704 UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); 705 706 Int iTemp; 707 708 for( ; iRows != 0; iRows-- ) 709 { 710 for (Int n = 0; n < iCols; n++ ) 711 { 712 if( piOrg[n] != DBBP_INVALID_SHORT ) 713 { 714 iTemp = piOrg[n ] - piCur[n ]; 715 uiSum += ( iTemp * iTemp ) >> uiShift; 716 } 717 } 718 piOrg += iStrideOrg; 719 piCur += iStrideCur; 720 } 721 722 return ( uiSum ); 723 } 724 725 UInt TComRdCost::xGetMaskedSAD( DistParam* pcDtParam ) 726 { 727 728 AOF(!pcDtParam->bApplyWeight); 729 #if H_3D_IC 730 AOF(!pcDtParam->bUseIC); 731 #endif 732 733 Pel* piOrg = pcDtParam->pOrg; 734 Pel* piCur = pcDtParam->pCur; 735 Int iRows = pcDtParam->iRows; 736 Int iCols = pcDtParam->iCols; 737 Int iStrideCur = pcDtParam->iStrideCur; 738 Int iStrideOrg = pcDtParam->iStrideOrg; 739 740 UInt uiSum = 0; 741 742 for( ; iRows != 0; iRows-- ) 743 { 744 for (Int n = 0; n < iCols; n++ ) 745 { 746 if( piOrg[n] != DBBP_INVALID_SHORT ) 747 { 748 uiSum += abs( piOrg[n] - piCur[n] ); 749 } 750 } 751 piOrg += iStrideOrg; 752 piCur += iStrideCur; 753 } 754 755 return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); 756 } 757 758 UInt TComRdCost::xGetMaskedHADs( DistParam* pcDtParam ) 759 { 760 AOF(!pcDtParam->bApplyWeight); 761 #if H_3D_IC 762 AOF(!pcDtParam->bUseIC); 763 #endif 764 Pel* piOrg = pcDtParam->pOrg; 765 Pel* piCur = pcDtParam->pCur; 766 Int iRows = pcDtParam->iRows; 767 Int iCols = pcDtParam->iCols; 768 Int iStrideCur = pcDtParam->iStrideCur; 769 Int iStrideOrg = pcDtParam->iStrideOrg; 770 Int iStep = pcDtParam->iStep; 771 772 Int x, y; 773 774 UInt uiSum = 0; 775 776 #if NS_HAD 777 if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) ) 778 #else 779 if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) 780 #endif 781 { 782 Int iOffsetOrg = iStrideOrg<<3; 783 Int iOffsetCur = iStrideCur<<3; 784 for ( y=0; y<iRows; y+= 8 ) 785 { 786 for ( x=0; x<iCols; x+= 8 ) 787 { 788 if( piOrg[x] != DBBP_INVALID_SHORT ) 789 { 790 uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); 791 } 792 } 793 piOrg += iOffsetOrg; 794 piCur += iOffsetCur; 795 } 796 } 797 #if NS_HAD 798 else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD ) 799 { 800 Int iOffsetOrg = iStrideOrg<<2; 801 Int iOffsetCur = iStrideCur<<2; 802 for ( y=0; y<iRows; y+= 4 ) 803 { 804 for ( x=0; x<iCols; x+= 16 ) 805 { 806 if( piOrg[x] != DBBP_INVALID_SHORT ) 807 { 808 uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); 809 } 810 } 811 piOrg += iOffsetOrg; 812 piCur += iOffsetCur; 813 } 814 } 815 else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD ) 816 { 817 Int iOffsetOrg = iStrideOrg<<4; 818 Int iOffsetCur = iStrideCur<<4; 819 for ( y=0; y<iRows; y+= 16 ) 820 { 821 for ( x=0; x<iCols; x+= 4 ) 822 { 823 if( piOrg[x] != DBBP_INVALID_SHORT ) 824 { 825 uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); 826 } 827 } 828 piOrg += iOffsetOrg; 829 piCur += iOffsetCur; 830 } 831 } 832 #endif 833 else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) 834 { 835 Int iOffsetOrg = iStrideOrg<<2; 836 Int iOffsetCur = iStrideCur<<2; 837 838 for ( y=0; y<iRows; y+= 4 ) 839 { 840 for ( x=0; x<iCols; x+= 4 ) 841 { 842 if( piOrg[x] != DBBP_INVALID_SHORT ) 843 { 844 uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); 845 } 846 } 847 piOrg += iOffsetOrg; 848 piCur += iOffsetCur; 849 } 850 } 851 else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) 852 { 853 Int iOffsetOrg = iStrideOrg<<1; 854 Int iOffsetCur = iStrideCur<<1; 855 for ( y=0; y<iRows; y+=2 ) 856 { 857 for ( x=0; x<iCols; x+=2 ) 858 { 859 if( piOrg[x] != DBBP_INVALID_SHORT ) 860 { 861 uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); 862 } 863 } 864 piOrg += iOffsetOrg; 865 piCur += iOffsetCur; 866 } 867 } 868 else 869 { 870 assert(false); 871 } 872 873 return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); 874 } 875 876 UInt TComRdCost::xGetMaskedVSD( DistParam* pcDtParam ) 877 { 878 Pel* piOrg = pcDtParam->pOrg; 879 Pel* piCur = pcDtParam->pCur; 880 Pel* piVirRec = pcDtParam->pVirRec; 881 Pel* piVirOrg = pcDtParam->pVirOrg; 882 Int iRows = pcDtParam->iRows; 883 Int iCols = pcDtParam->iCols; 884 Int iStrideOrg = pcDtParam->iStrideOrg; 885 Int iStrideCur = pcDtParam->iStrideCur; 886 Int iStrideVir = pcDtParam->iStrideVir; 887 888 UInt uiSum = 0; 889 UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; 890 891 Int dDM; 892 893 for ( Int y = 0 ; y < iRows ; y++ ) 894 { 895 for (Int x = 0; x < iCols; x++ ) 896 { 897 if( piOrg[x] != DBBP_INVALID_SHORT ) 898 { 899 dDM = (Int) ( piOrg[x ] - piCur[x ] ); 900 uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; 901 } 902 } 903 piOrg += iStrideOrg; 904 piCur += iStrideCur; 905 } 906 907 return ( uiSum ); 908 } 909 #endif 633 910 634 911 // -------------------------------------------------------------------------------------------------------------------- … … 2747 3024 dD = ( (Double) ( dDM >> DISTORTION_PRECISION_ADJUSTMENT( g_bitDepthY - 8 ) ) ) * m_dDisparityCoeff; 2748 3025 3026 #if SCU_HS_VSD_BUGFIX_IMPROV_G0163 3027 Double dDepthWeight = ( pOrg[x] >= ( (1<<(g_bitDepthY - 3)) + (1<<(g_bitDepthY - 2)) ) ? 4 : pOrg[x] > ((1<<g_bitDepthY) >> 4) ? (Float)(pOrg[x] - ((1<<g_bitDepthY) >> 4))/(Float)((1<<g_bitDepthY) >> 3) + 1 : 1.0 ); 3028 Double dTemp = ( 0.5 * fabs(dD) * dDepthWeight * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) ); 3029 #else 2749 3030 Double dTemp = ( 0.5 * fabs(dD) * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) ); 3031 #endif 2750 3032 iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5)); 2751 3033
Note: See TracChangeset for help on using the changeset viewer.