shithub: dav1d

Download patch

ref: c37b5ee3ce9a489cbc3db4d30fa552722da06455
parent: a7ca7b225f71b78f1c67e7f095e00fe207fe69ef
author: Henrik Gramner <gramner@twoorioles.com>
date: Tue Jan 7 19:44:29 EST 2020

Skip clipping in the inverse wht transform C implementation

The spec requires that the final residual values of a compliant
bitstream must be representable in bitdepth+1 bits, which is not
possible if intermediate values are large enough to be clipped.

--- a/src/itx_tmpl.c
+++ b/src/itx_tmpl.c
@@ -161,9 +161,6 @@
                                        coef *const coeff, const int eob
                                        HIGHBD_DECL_SUFFIX)
 {
-    const int bitdepth = bitdepth_from_max(bitdepth_max);
-    const int col_clip_max = (1 << (imax(bitdepth + 6, 16) - 1)) -1;
-    const int col_clip_min = -col_clip_max - 1;
     int32_t tmp[4 * 4], out[4], in_mem[4];
 
     for (int i = 0; i < 4; i++) {
@@ -171,8 +168,6 @@
             in_mem[j] = coeff[i + j * 4];
         dav1d_inv_wht4_1d_c(in_mem, 1, &tmp[i * 4], 1, 0);
     }
-    for (int k = 0; k < 4 * 4; k++)
-        tmp[k] = iclip(tmp[k], col_clip_min, col_clip_max);
 
     for (int i = 0; i < 4; i++) {
         dav1d_inv_wht4_1d_c(&tmp[i], 4, out, 1, 1);