Blame f553646d70fba8e265d436103a73520eb7adec8c.patch

8c7452f
From f553646d70fba8e265d436103a73520eb7adec8c Mon Sep 17 00:00:00 2001
8c7452f
From: David Michael Barr <b@rr-dav.id.au>
8c7452f
Date: Thu, 8 Jul 2021 13:39:59 +0900
8c7452f
Subject: [PATCH] Initialise residual when less than the transform width is
8c7452f
 visible
8c7452f
8c7452f
The input stride for forward transforms did not match the output
8c7452f
stride of residual computation in this case. Extend the residual
8c7452f
stride to the transform width and zero the non-visible portion.
8c7452f
Fixes #2662. Fixes #2757.
8c7452f
---
8c7452f
 src/encoder.rs | 14 +++++++++++---
8c7452f
 1 file changed, 11 insertions(+), 3 deletions(-)
8c7452f
8c7452f
diff --git a/src/encoder.rs b/src/encoder.rs
8c7452f
index 564d78d7e..1ccf8c831 100644
8c7452f
--- a/src/encoder.rs
8c7452f
+++ b/src/encoder.rs
8c7452f
@@ -1209,12 +1209,20 @@ pub fn encode_tx_block<T: Pixel, W: Writer>(
8c7452f
       residual,
8c7452f
       &ts.input_tile.planes[p].subregion(area),
8c7452f
       &rec.subregion(area),
8c7452f
-      visible_tx_w,
8c7452f
+      tx_size.width(),
8c7452f
       visible_tx_h,
8c7452f
     );
8c7452f
+    if visible_tx_w < tx_size.width() {
8c7452f
+      for row in residual.chunks_mut(tx_size.width()).take(visible_tx_h) {
8c7452f
+        for a in &mut row[visible_tx_w..] {
8c7452f
+          *a = 0;
8c7452f
+        }
8c7452f
+      }
8c7452f
+    }
8c7452f
   }
8c7452f
-  let visible_area = visible_tx_w * visible_tx_h;
8c7452f
-  for a in residual[visible_area..].iter_mut() {
8c7452f
+  let initialized_area =
8c7452f
+    if visible_tx_w == 0 { 0 } else { tx_size.width() * visible_tx_h };
8c7452f
+  for a in residual[initialized_area..].iter_mut() {
8c7452f
     *a = 0;
8c7452f
   }
8c7452f