Batch fix: the header test's RLE PSD fixture uses PackBits runs of at most 128 bytes

The fixture wrote each row as one literal run of w bytes, which PackBits
can't express past 128 (a 160-pixel row's header byte read as a repeat
run). The old decoder clipped such rows silently; with the PSD fix in
this batch an overrun is an error, as it should be, and the fixture now
splits rows into valid runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01912WaK6Rmew3wxZuPyX7E8
This commit is contained in:
Claude 2026-10-08 22:23:51 +00:00
parent d316d97d80
commit 8d79bf082e
No known key found for this signature in database
1 changed files with 7 additions and 4 deletions

View File

@ -55,15 +55,18 @@ fn psd(w: usize, h: usize, orientation: Option<u16>, rle: bool) -> Vec<u8> {
b.extend_from_slice(&(rle as u16).to_be_bytes());
let plane = |c: usize| (0..w * h).map(move |i| ((i * (c + 3) * 11) % 256) as u8);
if rle {
// every row one literal run of `w` bytes (w ≤ 128)
// every row as literal runs of at most 128 bytes (PackBits' longest)
let row_len = w + w.div_ceil(128);
for _ in 0..3 * h {
b.extend_from_slice(&(w as u16 + 1).to_be_bytes());
b.extend_from_slice(&(row_len as u16).to_be_bytes());
}
for c in 0..3 {
let p: Vec<u8> = plane(c).collect();
for row in p.chunks(w) {
b.push(w as u8 - 1);
b.extend_from_slice(row);
for run in row.chunks(128) {
b.push(run.len() as u8 - 1);
b.extend_from_slice(run);
}
}
}
} else {