Changeset 21 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPrediction.cpp


Ignore:
Timestamp:
15 Feb 2012, 19:05:04 (13 years ago)
Author:
hschwarz
Message:

updated with HHI branch (0.2-HHI)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r5 r21  
    15071507#endif
    15081508
    1509 Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap )
     1509#if DEPTH_MAP_GENERATION
     1510Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
     1511#else
     1512Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
     1513#endif
    15101514{
    15111515  Int         iWidth;
     
    15161520  {
    15171521    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
     1522
     1523#if DEPTH_MAP_GENERATION
     1524    if( bPrdDepthMap )
     1525    {
     1526      iWidth  >>= uiSubSampExpX;
     1527      iHeight >>= uiSubSampExpY;
     1528    }
     1529#endif
     1530
    15181531    if ( eRefPicList != REF_PIC_LIST_X )
    15191532    {
    1520       xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap );
     1533#if DEPTH_MAP_GENERATION
     1534      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
     1535#else
     1536      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx );
     1537#endif
    15211538#ifdef WEIGHT_PRED
    15221539      if ( pcCU->getSlice()->getPPS()->getUseWP() )
     
    15281545    else
    15291546    {
    1530       xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx, bPrdDepthMap );
    1531 
     1547#if DEPTH_MAP_GENERATION
     1548      xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
     1549#else
     1550      xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx );
     1551#endif
    15321552    }
    15331553    return;
     
    15381558    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
    15391559
     1560#if DEPTH_MAP_GENERATION
     1561    if( bPrdDepthMap )
     1562    {
     1563      iWidth  >>= uiSubSampExpX;
     1564      iHeight >>= uiSubSampExpY;
     1565    }
     1566#endif
     1567
    15401568    if ( eRefPicList != REF_PIC_LIST_X )
    15411569    {
    1542       xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap );
     1570#if DEPTH_MAP_GENERATION
     1571      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
     1572#else
     1573      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx );
     1574#endif
    15431575#ifdef WEIGHT_PRED
    15441576      if ( pcCU->getSlice()->getPPS()->getUseWP() )
     
    15501582    else
    15511583    {
    1552       xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx, bPrdDepthMap );
     1584#if DEPTH_MAP_GENERATION
     1585      xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
     1586#else
     1587      xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx );
     1588#endif
    15531589    }
    15541590  }
     
    15581594#if HIGH_ACCURACY_BI
    15591595#if DEPTH_MAP_GENERATION
    1560 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, Bool bi )
     1596Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi )
    15611597#else
    15621598Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi )
     
    15641600#else
    15651601#if DEPTH_MAP_GENERATION
    1566 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
     1602Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
    15671603#else
    15681604Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx )
     
    15761612#if DEPTH_MAP_GENERATION
    15771613  if( bPrdDepthMap )
     1614  {
     1615    UInt uiRShift = 0;
     1616    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, rpcYuvPred, uiRShift );
     1617    return;
     1618  }
     1619#endif
     1620
     1621#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
     1622  if( pcCU->getSlice()->getSPS()->isDepth() )
    15781623  {
    15791624#if HIGH_ACCURACY_BI
     
    15821627    UInt uiRShift = 0;
    15831628#endif
    1584     xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPredDepthMap(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, PDM_DEPTH_MAP_MCP_FILTER );
    1585     return;
    1586   }
    1587 #endif
    1588 
    1589 #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    1590   if( pcCU->getSlice()->getSPS()->isDepth() )
    1591   {
    1592 #if HIGH_ACCURACY_BI
    1593     UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 );
     1629#if DEPTH_MAP_GENERATION
     1630    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift );
    15941631#else
    1595     UInt uiRShift = 0;
    1596 #endif
    1597     xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, 2 );
     1632    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift );
     1633#endif
    15981634  }
    15991635  else
     
    16301666}
    16311667
    1632 Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
     1668#if DEPTH_MAP_GENERATION
     1669Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
     1670#else
     1671Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx )
     1672#endif
    16331673{
    16341674  TComYuv* pcMbYuv;
     
    16511691    if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 )
    16521692#if DEPTH_MAP_GENERATION
    1653       xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, true );
     1693      xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
    16541694#else
    16551695      xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true );
     
    16571697    else
    16581698#if DEPTH_MAP_GENERATION
    1659      xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap );
     1699     xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
    16601700#else
    16611701     xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx );
     
    16631703#else
    16641704#if DEPTH_MAP_GENERATION
    1665     xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap );
     1705    xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY );
    16661706#else
    16671707    xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx );
     
    16771717  else
    16781718#endif
     1719
     1720#if DEPTH_MAP_GENERATION
     1721  if ( bPrdDepthMap )
     1722  {
     1723    xWeightedAveragePdm( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, uiSubSampExpX, uiSubSampExpY );
     1724  }
     1725  else
     1726  {
     1727    xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
     1728  }
     1729#else
    16791730  xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
     1731#endif
     1732
    16801733}
    16811734
    16821735
    16831736Void
    1684 TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift, UInt uiFilterMode ) // 0:std, 1:bilin, 2:nearest neighbour
    1685 {
    1686   AOF( uiFilterMode <= 2 );
    1687 
     1737#if DEPTH_MAP_GENERATION
     1738TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift )
     1739#else
     1740TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift )
     1741#endif
     1742{
     1743#if DEPTH_MAP_GENERATION
     1744  Int     iShiftX     = 2 + uiSubSampExpX;
     1745  Int     iShiftY     = 2 + uiSubSampExpY;
     1746  Int     iAddX       = ( 1 << iShiftX ) >> 1;
     1747  Int     iAddY       = ( 1 << iShiftY ) >> 1;
     1748  Int     iHor        = ( pcMv->getHor() + iAddX ) >> iShiftX;
     1749  Int     iVer        = ( pcMv->getVer() + iAddY ) >> iShiftY;
     1750#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
     1751  if( pcCU->getSlice()->getSPS()->isDepth() )
     1752  {
     1753    iHor = pcMv->getHor();
     1754    iVer = pcMv->getVer();
     1755  }
     1756#endif
     1757  Int     iRefStride  = pcPicYuvRef->getStride();
     1758  Int     iDstStride  = rpcYuv->getStride();
     1759  Int     iRefOffset  = iHor + iVer * iRefStride;
     1760#else
    16881761  Int     iFPelMask   = ~3;
    16891762  Int     iRefStride  = pcPicYuvRef->getStride();
    16901763  Int     iDstStride  = rpcYuv->getStride();
    1691   Int     iHor        = ( uiFilterMode == 2 ? ( pcMv->getHor() + 2 ) & iFPelMask : pcMv->getHor() );
    1692   Int     iVer        = ( uiFilterMode == 2 ? ( pcMv->getVer() + 2 ) & iFPelMask : pcMv->getVer() );
     1764  Int     iHor        = ( pcMv->getHor() + 2 ) & iFPelMask;
     1765  Int     iVer        = ( pcMv->getVer() + 2 ) & iFPelMask;
    16931766#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    16941767  if( pcCU->getSlice()->getSPS()->isDepth() )
    16951768  {
    1696     assert( uiFilterMode == 2 );
    16971769    iHor = pcMv->getHor() * 4;
    16981770    iVer = pcMv->getVer() * 4;
    16991771  }
    17001772#endif
    1701   Int     iRefOffset  = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride;
    17021773  Int     ixFrac      = iHor & 0x3;
    17031774  Int     iyFrac      = iVer & 0x3;
     1775  Int     iRefOffset  = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride;
     1776#endif
     1777
    17041778  Pel*    piRefY      = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
    17051779  Pel*    piDstY      = rpcYuv->getLumaAddr( uiPartAddr );
    17061780
    1707   //  Integer position
    1708   if( ixFrac == 0 && iyFrac == 0 )
    1709   {
    17101781    for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride )
    17111782    {
     
    17151786      }
    17161787    }
    1717     return;
    1718   }
    1719 
    1720   // bi-linear interpolation
    1721   if( uiFilterMode == 1 )
    1722   {
    1723     Int   iW00    = ( 4 - ixFrac ) * ( 4 - iyFrac );
    1724     Int   iW01    = (     ixFrac ) * ( 4 - iyFrac );
    1725     Int   iW10    = ( 4 - ixFrac ) * (     iyFrac );
    1726     Int   iW11    = (     ixFrac ) * (     iyFrac );
    1727     Pel*  piRefY1 = piRefY + iRefStride;
    1728     for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride, piRefY1 += iRefStride )
    1729     {
    1730       for( Int x = 0; x < iWidth; x++ )
    1731       {
    1732         Int iSV     = iW00 * piRefY [ x ] + iW01 * piRefY [ x + 1 ]
    1733                     + iW10 * piRefY1[ x ] + iW11 * piRefY1[ x + 1 ];
    1734         iSV       <<= uiRShift;
    1735         piDstY[ x ] = ( iSV + 8 ) >> 4;
    1736       }
    1737     }
    1738     return;
    1739   }
    1740 
    1741   xPredInterLumaBlk( pcCU, pcPicYuvRef, uiPartAddr, pcMv, iWidth, iHeight, rpcYuv );
    1742   return;
    17431788}
    17441789
     
    21672212}
    21682213
     2214#endif
     2215
     2216#if DEPTH_MAP_GENERATION
     2217Void TComPrediction::xWeightedAveragePdm( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY )
     2218{
     2219  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
     2220  {
     2221    rpcYuvDst->addAvgPdm( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY );
     2222  }
     2223  else if ( iRefIdx0 >= 0 && iRefIdx1 <  0 )
     2224  {
     2225    pcYuvSrc0->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY );
     2226  }
     2227  else if ( iRefIdx0 <  0 && iRefIdx1 >= 0 )
     2228  {
     2229    pcYuvSrc1->copyPartToPartYuvPdm( rpcYuvDst, uiPartIdx, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY );
     2230  }
     2231  else
     2232  {
     2233    assert (0);
     2234  }
     2235}
    21692236#endif
    21702237
Note: See TracChangeset for help on using the changeset viewer.