Skip to content

Commit f553646

Browse files
committed
Initialise residual when less than the transform width is visible
The input stride for forward transforms did not match the output stride of residual computation in this case. Extend the residual stride to the transform width and zero the non-visible portion. Fixes #2662. Fixes #2757.
1 parent c17ce82 commit f553646

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/encoder.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1209,12 +1209,20 @@ pub fn encode_tx_block<T: Pixel, W: Writer>(
12091209
residual,
12101210
&ts.input_tile.planes[p].subregion(area),
12111211
&rec.subregion(area),
1212-
visible_tx_w,
1212+
tx_size.width(),
12131213
visible_tx_h,
12141214
);
1215+
if visible_tx_w < tx_size.width() {
1216+
for row in residual.chunks_mut(tx_size.width()).take(visible_tx_h) {
1217+
for a in &mut row[visible_tx_w..] {
1218+
*a = 0;
1219+
}
1220+
}
1221+
}
12151222
}
1216-
let visible_area = visible_tx_w * visible_tx_h;
1217-
for a in residual[visible_area..].iter_mut() {
1223+
let initialized_area =
1224+
if visible_tx_w == 0 { 0 } else { tx_size.width() * visible_tx_h };
1225+
for a in residual[initialized_area..].iter_mut() {
12181226
*a = 0;
12191227
}
12201228

0 commit comments

Comments
 (0)