Changeset 62 in 3DVCSoftware for branches/HTM-3.0-LG/source/Lib/TLibEncoder/TEncSearch.cpp
- Timestamp:
- 18 May 2012, 09:38:25 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-3.0-LG/source/Lib/TLibEncoder/TEncSearch.cpp
r56 r62 2505 2505 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost, TComMvField* cMvFieldNeighbours, UChar* uhInterDirNeighbours, Int& numValidMergeCand ) 2506 2506 #else 2507 #if LG_RESTRICTEDRESPRED_M24766 2508 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* rpcResiPredYuv, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost ) 2509 #else 2507 2510 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost ) 2511 #endif 2508 2512 #endif 2509 2513 { … … 2553 2557 const int maxNumMergeCand = MRG_MAX_NUM_CANDS_SIGNALED + ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); 2554 2558 #endif 2555 2559 #if LG_RESTRICTEDRESPRED_M24766 2560 Int iPUResiPredShift[4]; 2561 Int iLastAddResiShift = -1000; 2562 #endif 2556 2563 ruiCost = MAX_UINT; 2557 2564 for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand ) … … 2565 2572 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx ); 2566 2573 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx ); 2567 2574 #if LG_RESTRICTEDRESPRED_M24766 2575 Int iAddResiShift; 2576 UInt uiPartAddr; 2577 Int iRoiWidth, iRoiHeight; 2578 2579 pcCU->getPartIndexAndSize( iPUIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 2580 iAddResiShift = pcCU->getResiPredMode(uiPartAddr); 2581 iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1 - iAddResiShift : -1); 2582 2583 if( pcCU->getResPredFlag( 0 )) 2584 { // subtract residual prediction from original in motion search 2585 if(iLastAddResiShift != iAddResiShift) 2586 { 2587 //add subtracted residual last time 2588 if(iLastAddResiShift >= 0) 2589 { 2590 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift; 2591 pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 2592 } 2593 //subtract residual 2594 if(iAddResiShift >= 0) 2595 { 2596 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift; 2597 pcYuvOrg->add(iPUResiPredShift, ePartSize, rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true ); 2598 } 2599 iLastAddResiShift = iAddResiShift; 2600 } 2601 } 2602 #endif 2568 2603 xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() ); 2569 2604 uiBitsCand = uiMergeCand + 1; … … 2587 2622 } 2588 2623 } 2624 #if LG_RESTRICTEDRESPRED_M24766 2625 if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0) 2626 { 2627 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift; 2628 pcYuvOrg->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 2629 } 2630 #endif 2589 2631 } 2590 2632 … … 2599 2641 */ 2600 2642 #if AMP_MRG 2643 #if LG_RESTRICTEDRESPRED_M24766 2644 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv* rpcResiPredYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG ) 2645 #else 2601 2646 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG ) 2647 #endif 2602 2648 #else 2603 2649 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes ) … … 2702 2748 for (Int iNumRef=0; iNumRef < MAX_NUM_REF; iNumRef++) uiCostTempL0[iNumRef] = MAX_UINT; 2703 2749 UInt uiBitsTempL0[MAX_NUM_REF]; 2704 2750 #if LG_RESTRICTEDRESPRED_M24766 2751 Int iPUResiPredShift[4] = {0, 0, 0, 0}; 2752 #endif 2705 2753 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 2706 2754 … … 2718 2766 { 2719 2767 #endif 2720 2768 #if LG_RESTRICTEDRESPRED_M24766 2769 Bool bLastResiFlag = false; 2770 #endif 2721 2771 // Uni-directional prediction 2722 2772 for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ ) … … 2726 2776 for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ ) 2727 2777 { 2778 #if LG_RESTRICTEDRESPRED_M24766 2779 if( pcCU->getResPredFlag( 0 )) 2780 { 2781 if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp)) 2782 { // subtract residual prediction from original in motion search 2783 if(!bLastResiFlag) 2784 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true ); 2785 bLastResiFlag = true; 2786 } 2787 else 2788 { 2789 if(bLastResiFlag) 2790 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 2791 bLastResiFlag = false; 2792 } 2793 } 2794 #endif 2728 2795 uiBitsTemp = uiMbBits[iRefList]; 2729 2796 if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 ) … … 2889 2956 } 2890 2957 } 2958 #if LG_RESTRICTEDRESPRED_M24766 2959 if( pcCU->getResPredFlag( 0 ) && bLastResiFlag) 2960 { // subtract residual prediction from original in motion search 2961 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 2962 } 2963 #endif 2891 2964 // Bi-directional prediction 2892 2965 if ( pcCU->getSlice()->isInterB() ) 2893 2966 { 2894 2967 #if LG_RESTRICTEDRESPRED_M24766 2968 Int iLastAddResiShift = -1000; 2969 #endif 2895 2970 cMvBi[0] = cMv[0]; cMvBi[1] = cMv[1]; 2896 2971 iRefIdxBi[0] = iRefIdx[0]; iRefIdxBi[1] = iRefIdx[1]; … … 2994 3069 #else 2995 3070 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdxBi[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; 3071 #endif 3072 #if LG_RESTRICTEDRESPRED_M24766 3073 Int iAddResiShift = -1, iPredFrom = 0; 3074 Int iBestRefIdx = pcCU->getCUMvField(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0)->getRefIdx(uiPartAddr); 3075 3076 iPredFrom = iBestRefIdx >= 0 ? 3 : 1; 3077 if(iBestRefIdx >= 0 && pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0, iBestRefIdx)) 3078 iAddResiShift++; 3079 if(pcCU->getSlice()->getViewId() == pcCU->getSlice()->getRefViewId(eRefPicList, iRefIdxTemp)) 3080 iAddResiShift++; 3081 iAddResiShift = (pcCU->getSlice()->getPPS()->getUseWP() || iPredFrom != 3) ? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1); 3082 3083 if( pcCU->getResPredFlag( 0 ) ) 3084 { 3085 if(iLastAddResiShift != iAddResiShift) 3086 { 3087 //add substracted residual last time 3088 if(iLastAddResiShift >= 0 ) 3089 { 3090 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift; 3091 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 3092 } 3093 //substract residual 3094 if(iAddResiShift >= 0) 3095 { 3096 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iAddResiShift; 3097 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true ); 3098 } 3099 iLastAddResiShift = iAddResiShift; 3100 } 3101 } 2996 3102 #endif 2997 3103 // call ME … … 3049 3155 } 3050 3156 } // for loop-iter 3157 #if LG_RESTRICTEDRESPRED_M24766 3158 if( pcCU->getResPredFlag( 0 ) && iLastAddResiShift >= 0) 3159 { 3160 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = iLastAddResiShift; 3161 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 3162 } 3163 #endif 3051 3164 } // if (B_SLICE) 3052 3165 #if ZERO_MVD_EST … … 3255 3368 if (bTestNormalMC) 3256 3369 { 3370 #if LG_RESTRICTEDRESPRED_M24766 3371 Int iAddResiShift = pcCU->getResiPredMode(uiPartAddr); 3372 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = \ 3373 (pcCU->getSlice()->getPPS()->getUseWP() || pcCU->getInterDir(uiPartAddr) != 3)? (iAddResiShift >= 0 ? 0 : -1) : (iAddResiShift >= 0 ? 1-iAddResiShift : -1); 3374 if(pcCU->getResPredFlag(0) && iAddResiShift >= 0) 3375 { 3376 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 ), true); 3377 } 3378 #endif 3257 3379 xGetInterPredictionError( pcCU, pcOrgYuv, iPartIdx, uiMEError, m_pcEncCfg->getUseHADME() ); 3258 3380 uiMECost = uiMEError + m_pcRdCost->getCost( uiMEBits ); 3381 #if LG_RESTRICTEDRESPRED_M24766 3382 if(pcCU->getResPredFlag(0) && iAddResiShift >= 0) 3383 { 3384 pcOrgYuv->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcResiPredYuv, pcCU->getWidth( 0 ), pcCU->getHeight( 0 )); 3385 } 3386 #endif 3259 3387 } 3260 3388 #else … … 3274 3402 xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); 3275 3403 #else 3276 xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost ); 3404 #if LG_RESTRICTEDRESPRED_M24766 3405 xMergeEstimation( pcCU, pcOrgYuv, rpcResiPredYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost ); 3406 #else 3407 xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost ); 3408 #endif 3277 3409 #endif 3278 3410 if ( uiMRGCost < uiMECost ) … … 4116 4248 UInt uiWidth = pcCU->getWidth ( 0 ); 4117 4249 UInt uiHeight = pcCU->getHeight( 0 ); 4118 4250 #if LG_RESTRICTEDRESPRED_M24766 4251 Int iPUResiPredShift[4]; 4252 #endif 4119 4253 // No residual coding : SKIP mode 4120 4254 if ( ePredMode == MODE_SKIP && bSkipRes ) … … 4128 4262 if( pcCU->getResPredFlag( 0 ) ) 4129 4263 { 4264 #if LG_RESTRICTEDRESPRED_M24766 4265 pcCU->getPUResiPredShift(iPUResiPredShift, 0); 4266 rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd, uiWidth, uiHeight ); 4267 #else 4130 4268 rpcYuvRec->add( rpcYuvResPrd, uiWidth, uiHeight ); 4269 #endif 4131 4270 rpcYuvRec->clip( uiWidth, uiHeight ); 4132 4271 } … … 4237 4376 else 4238 4377 { 4239 rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth ); 4378 #if LG_RESTRICTEDRESPRED_M24766 4379 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0; 4380 rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), pcYuvOrg, pcYuvPred, 0, uiWidth ); 4381 #else 4382 rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth ); 4383 #endif 4240 4384 #if HHI_INTER_VIEW_RESIDUAL_PRED 4241 4385 // subtract residual prediction 4242 4386 if( pcCU->getResPredFlag( 0 ) ) 4243 4387 { 4388 #if LG_RESTRICTEDRESPRED_M24766 4389 pcCU->getPUResiPredShift(iPUResiPredShift, 0); 4390 rpcYuvResi->subtract(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResi, rpcYuvResPrd, 0, uiWidth ); 4391 #else 4244 4392 rpcYuvResi->subtract( rpcYuvResi, rpcYuvResPrd, 0, uiWidth ); 4393 #endif 4245 4394 } 4246 4395 #endif … … 4456 4605 { 4457 4606 pcYuvPred->copyToPartYuv( rpcYuvRec, 0 ); 4458 rpcYuvRec->add( rpcYuvResPrd, uiWidth, uiHeight ); 4459 rpcYuvRec->add( rpcYuvResiBest, uiWidth, uiHeight ); 4607 #if LG_RESTRICTEDRESPRED_M24766 4608 pcCU->getPUResiPredShift(iPUResiPredShift, 0); 4609 rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResPrd, uiWidth, uiHeight ); 4610 iPUResiPredShift[0] = iPUResiPredShift[1] = iPUResiPredShift[2] = iPUResiPredShift[3] = 0; 4611 rpcYuvRec->add(iPUResiPredShift, pcCU->getPartitionSize(0), rpcYuvResiBest, uiWidth, uiHeight ); 4612 #else 4613 rpcYuvRec->add( rpcYuvResPrd, uiWidth, uiHeight ); 4614 rpcYuvRec->add( rpcYuvResiBest, uiWidth, uiHeight ); 4615 #endif 4460 4616 rpcYuvRec->clip( uiWidth, uiHeight ); 4461 4617 }
Note: See TracChangeset for help on using the changeset viewer.