Changeset 21 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPrediction.cpp
- Timestamp:
- 15 Feb 2012, 19:05:04 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComPrediction.cpp
r5 r21 1507 1507 #endif 1508 1508 1509 Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap ) 1509 #if DEPTH_MAP_GENERATION 1510 Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY ) 1511 #else 1512 Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx ) 1513 #endif 1510 1514 { 1511 1515 Int iWidth; … … 1516 1520 { 1517 1521 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 1518 1531 if ( eRefPicList != REF_PIC_LIST_X ) 1519 1532 { 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 1521 1538 #ifdef WEIGHT_PRED 1522 1539 if ( pcCU->getSlice()->getPPS()->getUseWP() ) … … 1528 1545 else 1529 1546 { 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 1532 1552 } 1533 1553 return; … … 1538 1558 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight ); 1539 1559 1560 #if DEPTH_MAP_GENERATION 1561 if( bPrdDepthMap ) 1562 { 1563 iWidth >>= uiSubSampExpX; 1564 iHeight >>= uiSubSampExpY; 1565 } 1566 #endif 1567 1540 1568 if ( eRefPicList != REF_PIC_LIST_X ) 1541 1569 { 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 1543 1575 #ifdef WEIGHT_PRED 1544 1576 if ( pcCU->getSlice()->getPPS()->getUseWP() ) … … 1550 1582 else 1551 1583 { 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 1553 1589 } 1554 1590 } … … 1558 1594 #if HIGH_ACCURACY_BI 1559 1595 #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 )1596 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi ) 1561 1597 #else 1562 1598 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi ) … … 1564 1600 #else 1565 1601 #if DEPTH_MAP_GENERATION 1566 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )1602 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY ) 1567 1603 #else 1568 1604 Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx ) … … 1576 1612 #if DEPTH_MAP_GENERATION 1577 1613 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() ) 1578 1623 { 1579 1624 #if HIGH_ACCURACY_BI … … 1582 1627 UInt uiRShift = 0; 1583 1628 #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 ); 1594 1631 #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 1598 1634 } 1599 1635 else … … 1630 1666 } 1631 1667 1632 Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ) 1668 #if DEPTH_MAP_GENERATION 1669 Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ) 1670 #else 1671 Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx ) 1672 #endif 1633 1673 { 1634 1674 TComYuv* pcMbYuv; … … 1651 1691 if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) 1652 1692 #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 ); 1654 1694 #else 1655 1695 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true ); … … 1657 1697 else 1658 1698 #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 ); 1660 1700 #else 1661 1701 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx ); … … 1663 1703 #else 1664 1704 #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 ); 1666 1706 #else 1667 1707 xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx ); … … 1677 1717 else 1678 1718 #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 1679 1730 xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred ); 1731 #endif 1732 1680 1733 } 1681 1734 1682 1735 1683 1736 Void 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 1738 TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift ) 1739 #else 1740 TComPrediction::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 1688 1761 Int iFPelMask = ~3; 1689 1762 Int iRefStride = pcPicYuvRef->getStride(); 1690 1763 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; 1693 1766 #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC 1694 1767 if( pcCU->getSlice()->getSPS()->isDepth() ) 1695 1768 { 1696 assert( uiFilterMode == 2 );1697 1769 iHor = pcMv->getHor() * 4; 1698 1770 iVer = pcMv->getVer() * 4; 1699 1771 } 1700 1772 #endif 1701 Int iRefOffset = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride;1702 1773 Int ixFrac = iHor & 0x3; 1703 1774 Int iyFrac = iVer & 0x3; 1775 Int iRefOffset = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride; 1776 #endif 1777 1704 1778 Pel* piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset; 1705 1779 Pel* piDstY = rpcYuv->getLumaAddr( uiPartAddr ); 1706 1780 1707 // Integer position1708 if( ixFrac == 0 && iyFrac == 0 )1709 {1710 1781 for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride ) 1711 1782 { … … 1715 1786 } 1716 1787 } 1717 return;1718 }1719 1720 // bi-linear interpolation1721 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;1743 1788 } 1744 1789 … … 2167 2212 } 2168 2213 2214 #endif 2215 2216 #if DEPTH_MAP_GENERATION 2217 Void 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 } 2169 2236 #endif 2170 2237
Note: See TracChangeset for help on using the changeset viewer.