Ticket #268: vtm5-invResDPCM-clipping-addition.patch

File vtm5-invResDPCM-clipping-addition.patch, 1.4 KB (added by gordon, 5 years ago)
  • source/Lib/CommonLib/Quant.cpp

    diff --git a/source/Lib/CommonLib/Quant.cpp b/source/Lib/CommonLib/Quant.cpp
    index 31bcfdc6..febd661b 100644
    a b void invResDPCM( const TransformUnit &tu, const ComponentID &compID, CoeffBuf &d 
    149149  const int      hgt = rect.height;
    150150  const CCoeffBuf coeffs = tu.getCoeffs(compID);
    151151
     152  const int             maxLog2TrDynamicRange = tu.cs->sps->getMaxLog2TrDynamicRange(toChannelType(compID));
     153  const TCoeff          inputMinimum   = -(1 << maxLog2TrDynamicRange);
     154  const TCoeff          inputMaximum   =  (1 << maxLog2TrDynamicRange) - 1;
     155
    152156  const TCoeff* coef = &coeffs.buf[0];
    153157  TCoeff* dst = &dstBuf.buf[0];
    154158
    void invResDPCM( const TransformUnit &tu, const ComponentID &compID, CoeffBuf &d 
    159163      dst[0] = coef[0];
    160164      for( int x = 1; x < wdt; x++ )
    161165      {
    162         dst[x] = dst[x - 1] + coef[x];
     166        dst[x] = Clip3(inputMinimum, inputMaximum, dst[x - 1] + coef[x]);
    163167      }
    164168      coef += coeffs.stride;
    165169      dst += dstBuf.stride;
    void invResDPCM( const TransformUnit &tu, const ComponentID &compID, CoeffBuf &d 
    175179    {
    176180      for( int x = 0; x < wdt; x++ )
    177181      {
    178         dst[dstBuf.stride + x] = dst[x] + coef[coeffs.stride + x];
     182        dst[dstBuf.stride + x] = Clip3(inputMinimum, inputMaximum, dst[x] + coef[coeffs.stride + x]);
    179183      }
    180184      coef += coeffs.stride;
    181185      dst += dstBuf.stride;