Ticket #1320: fix_1320_rdpcm_accumulator.patch
File fix_1320_rdpcm_accumulator.patch, 6.3 KB (added by karlsharman, 10 years ago) |
---|
-
source/Lib/TLibCommon/TComTrQuant.cpp
1630 1630 UInt uiX = 0; 1631 1631 UInt uiY = 0; 1632 1632 1633 #if FIX_1320_RDPCM_ACCUMULATOR 1634 UInt &majorAxis = (mode == RDPCM_VER) ? uiX : uiY; 1635 UInt &minorAxis = (mode == RDPCM_VER) ? uiY : uiX; 1636 const UInt majorAxisLimit = (mode == RDPCM_VER) ? uiWidth : uiHeight; 1637 const UInt minorAxisLimit = (mode == RDPCM_VER) ? uiHeight : uiWidth; 1638 static const TCoeff pelMin=(Int) std::numeric_limits<Pel>::min(); 1639 static const TCoeff pelMax=(Int) std::numeric_limits<Pel>::max(); 1640 #else 1633 1641 UInt &majorAxis = (mode == RDPCM_HOR) ? uiX : uiY; 1634 1642 UInt &minorAxis = (mode == RDPCM_HOR) ? uiY : uiX; 1635 1643 const UInt majorAxisLimit = (mode == RDPCM_HOR) ? uiWidth : uiHeight; 1636 1644 const UInt minorAxisLimit = (mode == RDPCM_HOR) ? uiHeight : uiWidth; 1637 1645 const UInt referenceSampleOffset = (mode == RDPCM_HOR) ? 1 : uiWidth; 1646 #endif 1638 1647 1639 const Bool bUseHalfRoundingPoint = (mode != RDPCM_OFF);1648 const Bool bUseHalfRoundingPoint = (mode != RDPCM_OFF); 1640 1649 1641 1650 uiAbsSum = 0; 1642 1651 1643 1652 for ( majorAxis = 0; majorAxis < majorAxisLimit; majorAxis++ ) 1644 1653 { 1654 #if FIX_1320_RDPCM_ACCUMULATOR 1655 TCoeff accumulatorValue = 0; // 32-bit accumulator 1656 #endif 1645 1657 for ( minorAxis = 0; minorAxis < minorAxisLimit; minorAxis++ ) 1646 1658 { 1647 1659 const UInt sampleIndex = (uiY * uiWidth) + uiX; 1648 1660 const UInt coefficientIndex = (rotateResidual ? (uiSizeMinus1-sampleIndex) : sampleIndex); 1649 1661 const Pel currentSample = pcResidual[(uiY * uiStride) + uiX]; 1662 #if FIX_1320_RDPCM_ACCUMULATOR 1663 const TCoeff encoderSideDelta = TCoeff(currentSample) - accumulatorValue; 1664 #else 1650 1665 const Pel referenceSample = ((mode != RDPCM_OFF) && (majorAxis > 0)) ? reconstructedResi[sampleIndex - referenceSampleOffset] : 0; 1651 1666 1652 1667 const Pel encoderSideDelta = currentSample - referenceSample; 1668 #endif 1653 1669 1654 1670 Pel reconstructedDelta; 1655 1671 if ( bLossless ) … … 1665 1681 1666 1682 uiAbsSum += abs(pcCoeff[coefficientIndex]); 1667 1683 1684 #if FIX_1320_RDPCM_ACCUMULATOR 1685 if (mode == RDPCM_OFF) { reconstructedResi[sampleIndex] = reconstructedDelta; } 1686 else 1687 { 1688 accumulatorValue += reconstructedDelta; 1689 reconstructedResi[sampleIndex] = (Pel) Clip3<TCoeff>(pelMin, pelMax, accumulatorValue); 1690 } 1691 #else 1668 1692 reconstructedResi[sampleIndex] = reconstructedDelta + referenceSample; 1693 #endif 1669 1694 } 1670 1695 } 1671 1696 } … … 1764 1789 rdpcmMode = RDPCMMode(pcCU->getExplicitRdpcmMode( compID, uiAbsPartIdx )); 1765 1790 } 1766 1791 1792 #if FIX_1320_RDPCM_ACCUMULATOR 1793 static const TCoeff pelMin=(Int) std::numeric_limits<Pel>::min(); 1794 static const TCoeff pelMax=(Int) std::numeric_limits<Pel>::max(); 1795 #endif 1767 1796 if (rdpcmMode == RDPCM_VER) 1768 1797 { 1798 #if FIX_1320_RDPCM_ACCUMULATOR 1799 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 1800 { 1801 Pel *pcCurResidual = pcResidual+uiX; 1802 TCoeff accumulator = *pcCurResidual; // 32-bit accumulator 1803 pcCurResidual+=uiStride; 1804 for( UInt uiY = 1; uiY < uiHeight; uiY++, pcCurResidual+=uiStride ) 1805 { 1806 accumulator += *(pcCurResidual); 1807 *pcCurResidual = (Pel)Clip3<TCoeff>(pelMin, pelMax, accumulator); 1808 } 1809 } 1810 #else 1769 1811 pcResidual += uiStride; //start from row 1 1770 1812 1771 1813 for( UInt uiY = 1; uiY < uiHeight; uiY++ ) … … 1776 1818 } 1777 1819 pcResidual += uiStride; 1778 1820 } 1821 #endif 1779 1822 } 1780 1823 else if (rdpcmMode == RDPCM_HOR) 1781 1824 { 1825 #if FIX_1320_RDPCM_ACCUMULATOR 1826 for( UInt uiY = 0; uiY < uiHeight; uiY++ ) 1827 { 1828 Pel *pcCurResidual = pcResidual+uiY*uiStride; 1829 TCoeff accumulator = *pcCurResidual; 1830 pcCurResidual++; 1831 for( UInt uiX = 1; uiX < uiWidth; uiX++, pcCurResidual++ ) 1832 { 1833 accumulator += *(pcCurResidual); 1834 *pcCurResidual = (Pel)Clip3<TCoeff>(pelMin, pelMax, accumulator); 1835 } 1836 } 1837 #else 1782 1838 for( UInt uiY = 0; uiY < uiHeight; uiY++ ) 1783 1839 { 1784 1840 for( UInt uiX = 1; uiX < uiWidth; uiX++ ) … … 1787 1843 } 1788 1844 pcResidual += uiStride; 1789 1845 } 1846 #endif 1790 1847 } 1791 1848 } 1792 1849 } … … 3141 3198 } 3142 3199 } 3143 3200 3201 #if FIX_1320_RDPCM_ACCUMULATOR 3202 Void TComTrQuant::transformSkipQuantOneSample(TComTU &rTu, const ComponentID compID, const TCoeff resiDiff, TCoeff* pcCoeff, const UInt uiPos, const QpParam &cQP, const Bool bUseHalfRoundingPoint) 3203 #else 3144 3204 Void TComTrQuant::transformSkipQuantOneSample(TComTU &rTu, const ComponentID compID, const Pel resiDiff, TCoeff* pcCoeff, const UInt uiPos, const QpParam &cQP, const Bool bUseHalfRoundingPoint) 3205 #endif 3145 3206 { 3146 3207 TComDataCU *pcCU = rTu.getCU(); 3147 3208 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); -
source/Lib/TLibCommon/TypeDef.h
235 235 236 236 #define MAX_NUM_LONG_TERM_REF_PICS 33 237 237 238 #define FIX_1320_RDPCM_ACCUMULATOR 1 ///< Fix for accumulator size in RDPCM. 238 239 239 240 // ==================================================================================================================== 240 241 // RExt control settings -
source/Lib/TLibCommon/TComTrQuant.h
194 194 Int* getSliceNSamples(){ return m_sliceNsamples ;} 195 195 Double* getSliceSumC() { return m_sliceSumC; } 196 196 #endif 197 #if FIX_1320_RDPCM_ACCUMULATOR 198 Void transformSkipQuantOneSample(TComTU &rTu, const ComponentID compID, const TCoeff resiDiff, TCoeff* pcCoeff, const UInt uiPos, const QpParam &cQP, const Bool bUseHalfRoundingPoint); 199 #else 197 200 Void transformSkipQuantOneSample(TComTU &rTu, const ComponentID compID, const Pel resiDiff, TCoeff* pcCoeff, const UInt uiPos, const QpParam &cQP, const Bool bUseHalfRoundingPoint); 201 #endif 198 202 Void invTrSkipDeQuantOneSample(TComTU &rTu, ComponentID compID, TCoeff pcCoeff, Pel &reconSample, const QpParam &cQP, UInt uiPos ); 199 203 200 204 protected: