Ticket #1477: MergeCandidateRound.patch
File MergeCandidateRound.patch, 11.4 KB (added by libin, 7 years ago) |
---|
-
Lib/TLibCommon/TComDataCU.cpp
2320 2320 { 2321 2321 TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 2322 2322 } 2323 if ( m_pcSlice->getUseIntegerMv() )2324 {2325 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2326 {2327 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2328 }2329 }2330 else2331 {2332 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2333 {2334 Int iCurrRefIdx = pcMvFieldNeighbours[i].getRefIdx();2335 if(iCurrRefIdx >= 0)2336 {2337 if(getSlice()->getRefPic(RefPicList(i&0x1),iCurrRefIdx)->getPOC() == getSlice()->getPOC())2338 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2339 }2340 }2341 }2342 2343 2323 if ( mrgCandIdx == iCount ) 2344 2324 { 2345 2325 return; … … 2372 2352 { 2373 2353 TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 2374 2354 } 2375 if ( m_pcSlice->getUseIntegerMv() )2376 {2377 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2378 {2379 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2380 }2381 }2382 else2383 {2384 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2385 {2386 Int iCurrRefIdx = pcMvFieldNeighbours[i].getRefIdx();2387 if(iCurrRefIdx >= 0)2388 {2389 if(getSlice()->getRefPic(RefPicList(i&0x1),iCurrRefIdx)->getPOC() == getSlice()->getPOC())2390 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2391 }2392 }2393 }2394 2395 2355 if ( mrgCandIdx == iCount ) 2396 2356 { 2397 2357 return; … … 2423 2383 { 2424 2384 TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 2425 2385 } 2426 2427 if ( m_pcSlice->getUseIntegerMv() )2428 {2429 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2430 {2431 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2432 }2433 }2434 else2435 {2436 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2437 {2438 Int iCurrRefIdx = pcMvFieldNeighbours[i].getRefIdx();2439 if(iCurrRefIdx >= 0)2440 {2441 if(getSlice()->getRefPic(RefPicList(i&0x1),iCurrRefIdx)->getPOC() == getSlice()->getPOC())2442 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2443 }2444 }2445 }2446 2447 2386 if ( mrgCandIdx == iCount ) 2448 2387 { 2449 2388 return; … … 2475 2414 { 2476 2415 TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 2477 2416 } 2478 if ( m_pcSlice->getUseIntegerMv() )2479 {2480 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2481 {2482 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2483 }2484 }2485 else2486 {2487 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2488 {2489 Int iCurrRefIdx = pcMvFieldNeighbours[i].getRefIdx();2490 if(iCurrRefIdx >= 0)2491 {2492 if(getSlice()->getRefPic(RefPicList(i&0x1),iCurrRefIdx)->getPOC() == getSlice()->getPOC())2493 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2494 }2495 }2496 }2497 2498 2417 if ( mrgCandIdx == iCount ) 2499 2418 { 2500 2419 return; … … 2529 2448 { 2530 2449 TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] ); 2531 2450 } 2532 if ( m_pcSlice->getUseIntegerMv() )2533 {2534 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2535 {2536 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2537 }2538 }2539 else2540 {2541 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2542 {2543 Int iCurrRefIdx = pcMvFieldNeighbours[i].getRefIdx();2544 if(iCurrRefIdx >= 0)2545 {2546 if(getSlice()->getRefPic(RefPicList(i&0x1),iCurrRefIdx)->getPOC() == getSlice()->getPOC())2547 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2548 }2549 }2550 }2551 2552 2451 if ( mrgCandIdx == iCount ) 2553 2452 { 2554 2453 return; … … 2637 2536 { 2638 2537 puhInterDirNeighbours[uiArrayAddr] = dir; 2639 2538 abCandIsInter[uiArrayAddr] = true; 2640 if ( m_pcSlice->getUseIntegerMv() )2641 {2642 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2643 {2644 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2645 }2646 }2647 else2648 {2649 for ( Int i = iCount<<1; i < (iCount<<1) + 1 + getSlice()->isInterB() ? 1 : 0; i++ )2650 {2651 Int iCurrRefIdx = pcMvFieldNeighbours[i].getRefIdx();2652 if(iCurrRefIdx >= 0)2653 {2654 if(getSlice()->getRefPic(RefPicList(i&0x1),iCurrRefIdx)->getPOC() == getSlice()->getPOC())2655 pcMvFieldNeighbours[i].setMvField( (pcMvFieldNeighbours[i].getMv()>>2)<<2, pcMvFieldNeighbours[i].getRefIdx() );2656 }2657 }2658 }2659 2539 2660 2540 if ( mrgCandIdx == iCount ) 2661 2541 { … … 3823 3703 } 3824 3704 } 3825 3705 3706 Void TComDataCU::roundMergeCandidates(TComMvField* pcMvFieldNeighbours, Int iCount) const 3707 { 3708 if (m_pcSlice->getUseIntegerMv()) 3709 { 3710 for (Int i = 0; i < (iCount << 1); i += getSlice()->isInterB() ? 1 : 2) 3711 { 3712 pcMvFieldNeighbours[i].setMvField((pcMvFieldNeighbours[i].getMv() >> 2) << 2, pcMvFieldNeighbours[i].getRefIdx()); 3713 } 3714 } 3715 else 3716 { 3717 for (Int i = 0; i < (iCount << 1); i += getSlice()->isInterB() ? 1 : 2) 3718 { 3719 Int iCurrRefIdx = pcMvFieldNeighbours[i].getRefIdx(); 3720 if (iCurrRefIdx >= 0) 3721 { 3722 if (getSlice()->getRefPic(RefPicList(i & 0x1), iCurrRefIdx)->getPOC() == getSlice()->getPOC()) 3723 { 3724 pcMvFieldNeighbours[i].setMvField((pcMvFieldNeighbours[i].getMv() >> 2) << 2, pcMvFieldNeighbours[i].getRefIdx()); 3725 } 3726 } 3727 } 3728 } 3729 } 3730 3826 3731 Bool TComDataCU::is8x8BipredRestriction(TComMv mvL0,TComMv mvL1, Int iRefIdxL0, Int iRefIdxL1 ) const 3827 3732 { 3828 3733 if (iRefIdxL0 < -1 || iRefIdxL0 >= MAX_NUM_REF) -
Lib/TLibCommon/TComDataCU.h
512 512 UInt getIntraBCSearchAreaWidth( UInt uiMaxSearchWidthToLeftInCTUs ); 513 513 Bool is8x8BipredRestriction(TComMv mvL0,TComMv mvL1, Int iRefIdxL0, Int iRefIdxL1 ) const; 514 514 Void xRestrictBipredMergeCand( UInt puIdx, TComMvField* mvFieldNeighbours, UChar* interDirNeighbours, Int numValidMergeCand ); 515 Void roundMergeCandidates(TComMvField* pcMvFieldNeighbours, Int iCount) const; 515 516 Bool hasAssociatedACTFlag ( UInt absPartIdx ); 516 517 UInt getCtxEscapeFlag( UInt absPartIdx, UInt idx, Pel *pEscapeFlag ); 517 518 -
Lib/TLibDecoder/TDecCu.cpp
284 284 UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); 285 285 m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); 286 286 m_ppcCU[uiDepth]->xRestrictBipredMergeCand(0,cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); 287 m_ppcCU[uiDepth]->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand); 287 288 pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); 288 289 289 290 TComMv cTmpMv( 0, 0 ); -
Lib/TLibDecoder/TDecEntropy.cpp
245 245 pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); 246 246 } 247 247 pcSubCU->xRestrictBipredMergeCand(0,cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); 248 pcSubCU->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand); 248 249 pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 249 250 250 251 TComMv cTmpMv( 0, 0 ); -
Lib/TLibEncoder/TEncCu.cpp
1796 1796 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to CTU level 1797 1797 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand ); 1798 1798 rpcTempCU->xRestrictBipredMergeCand(0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); 1799 rpcTempCU->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand); 1799 1800 1800 1801 Int mergeCandBuffer[MRG_MAX_NUM_CANDS]; 1801 1802 for( UInt ui = 0; ui < numValidMergeCand; ++ui ) … … 2655 2656 rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, depth ); 2656 2657 rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,interDirNeighbours, numValidMergeCand ); 2657 2658 rpcTempCU->xRestrictBipredMergeCand( 0, cMvFieldNeighbours, interDirNeighbours, numValidMergeCand ); 2659 rpcTempCU->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand); 2658 2660 2659 2661 Int mergeCandBuffer[MRG_MAX_NUM_CANDS]; 2660 2662 for( UInt ui = 0; ui < numValidMergeCand; ++ui ) -
Lib/TLibEncoder/TEncSearch.cpp
3048 3048 } 3049 3049 3050 3050 xRestrictBipredMergeCand( pcCU, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); 3051 pcCU->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand); 3051 3052 3052 3053 ruiCost = std::numeric_limits<Distortion>::max(); 3053 3054 if ( iCostCalcType ) … … 9618 9619 } 9619 9620 9620 9621 xRestrictBipredMergeCand( pcCU, partIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); 9622 pcCU->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand); 9621 9623 9622 9624 for ( mrgIdxTemp = 0; mrgIdxTemp < numValidMergeCand; mrgIdxTemp++ ) 9623 9625 { … … 9906 9908 } 9907 9909 9908 9910 xRestrictBipredMergeCand( pcCU, partIdx, cMvFieldNeighboursIBC, uhInterDirNeighboursIBC, numValidMergeCandIBC ); 9911 pcCU->roundMergeCandidates(cMvFieldNeighboursIBC, numValidMergeCandIBC); 9909 9912 9910 9913 for ( mrgIdxTemp = 0; mrgIdxTemp < numValidMergeCandIBC; mrgIdxTemp++ ) 9911 9914 {