Ticket #1477: MergeCandidateRound.patch

File MergeCandidateRound.patch, 11.4 KB (added by libin, 7 years ago)
  • Lib/TLibCommon/TComDataCU.cpp

     
    23202320    {
    23212321      TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    23222322    }
    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     else
    2331     {
    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 
    23432323    if ( mrgCandIdx == iCount )
    23442324    {
    23452325      return;
     
    23722352    {
    23732353      TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    23742354    }
    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     else
    2383     {
    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 
    23952355    if ( mrgCandIdx == iCount )
    23962356    {
    23972357      return;
     
    24232383    {
    24242384      TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    24252385    }
    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     else
    2435     {
    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 
    24472386    if ( mrgCandIdx == iCount )
    24482387    {
    24492388      return;
     
    24752414    {
    24762415      TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    24772416    }
    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     else
    2486     {
    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 
    24982417    if ( mrgCandIdx == iCount )
    24992418    {
    25002419      return;
     
    25292448      {
    25302449        TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    25312450      }
    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       else
    2540       {
    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 
    25522451      if ( mrgCandIdx == iCount )
    25532452      {
    25542453        return;
     
    26372536    {
    26382537      puhInterDirNeighbours[uiArrayAddr] = dir;
    26392538      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       else
    2648       {
    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       }
    26592539
    26602540      if ( mrgCandIdx == iCount )
    26612541      {
     
    38233703  }
    38243704}
    38253705
     3706Void 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
    38263731Bool TComDataCU::is8x8BipredRestriction(TComMv mvL0,TComMv mvL1, Int iRefIdxL0, Int iRefIdxL1 ) const
    38273732{
    38283733  if (iRefIdxL0 < -1 || iRefIdxL0 >= MAX_NUM_REF)
  • Lib/TLibCommon/TComDataCU.h

     
    512512  UInt          getIntraBCSearchAreaWidth( UInt uiMaxSearchWidthToLeftInCTUs );
    513513  Bool          is8x8BipredRestriction(TComMv mvL0,TComMv mvL1, Int iRefIdxL0, Int iRefIdxL1 ) const;
    514514  Void          xRestrictBipredMergeCand( UInt puIdx, TComMvField* mvFieldNeighbours, UChar* interDirNeighbours, Int numValidMergeCand );
     515  Void          roundMergeCandidates(TComMvField* pcMvFieldNeighbours, Int iCount) const;
    515516  Bool          hasAssociatedACTFlag ( UInt absPartIdx );
    516517  UInt          getCtxEscapeFlag( UInt   absPartIdx, UInt idx,  Pel *pEscapeFlag );
    517518
  • Lib/TLibDecoder/TDecCu.cpp

     
    284284    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
    285285    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    286286    m_ppcCU[uiDepth]->xRestrictBipredMergeCand(0,cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
     287    m_ppcCU[uiDepth]->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand);
    287288    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
    288289
    289290    TComMv cTmpMv( 0, 0 );
  • Lib/TLibDecoder/TDecEntropy.cpp

     
    245245        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    246246      }
    247247      pcSubCU->xRestrictBipredMergeCand(0,cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
     248      pcSubCU->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand);
    248249      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
    249250
    250251      TComMv cTmpMv( 0, 0 );
  • Lib/TLibEncoder/TEncCu.cpp

     
    17961796  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to CTU level
    17971797  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
    17981798  rpcTempCU->xRestrictBipredMergeCand(0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     1799  rpcTempCU->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand);
    17991800
    18001801  Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
    18011802  for( UInt ui = 0; ui < numValidMergeCand; ++ui )
     
    26552656  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, depth );
    26562657  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,interDirNeighbours, numValidMergeCand );
    26572658  rpcTempCU->xRestrictBipredMergeCand( 0, cMvFieldNeighbours, interDirNeighbours, numValidMergeCand );
     2659  rpcTempCU->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand);
    26582660
    26592661  Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
    26602662  for( UInt ui = 0; ui < numValidMergeCand; ++ui )
  • Lib/TLibEncoder/TEncSearch.cpp

     
    30483048  }
    30493049
    30503050  xRestrictBipredMergeCand( pcCU, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     3051  pcCU->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand);
    30513052
    30523053  ruiCost = std::numeric_limits<Distortion>::max();
    30533054  if ( iCostCalcType )
     
    96189619      }
    96199620
    96209621      xRestrictBipredMergeCand( pcCU, partIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     9622      pcCU->roundMergeCandidates(cMvFieldNeighbours, numValidMergeCand);
    96219623
    96229624      for ( mrgIdxTemp = 0; mrgIdxTemp < numValidMergeCand; mrgIdxTemp++ )
    96239625      {
     
    99069908          }
    99079909
    99089910          xRestrictBipredMergeCand( pcCU, partIdx, cMvFieldNeighboursIBC, uhInterDirNeighboursIBC, numValidMergeCandIBC );
     9911          pcCU->roundMergeCandidates(cMvFieldNeighboursIBC, numValidMergeCandIBC);
    99099912
    99109913          for ( mrgIdxTemp = 0; mrgIdxTemp < numValidMergeCandIBC; mrgIdxTemp++ )
    99119914          {