Commit f805edf6 authored by Frank Bossen's avatar Frank Bossen
Browse files

Merge branch 'improve_reshaper_cscale_clipping' into 'master'

add clipping in chroma residue scaling to avoid potential overflow

See merge request jvet/VVCSoftware_VTM!301
parents dbfa25c2 0a9148ea
......@@ -448,7 +448,12 @@ void AreaBuf<Pel>::scaleSignal(const int scale, const bool dir, const ClpRng& cl
{
sign = src[x] >= 0 ? 1 : -1;
absval = sign * src[x];
dst[x] = sign * ((absval * scale + (1 << (CSCALE_FP_PREC - 1))) >> CSCALE_FP_PREC);
int val = sign * ((absval * scale + (1 << (CSCALE_FP_PREC - 1))) >> CSCALE_FP_PREC);
if (sizeof(Pel) == 2) // avoid overflow when storing data
{
val = Clip3<int>(-32768, 32767, val);
}
dst[x] = (Pel)val;
}
dst += stride;
src += stride;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment