test(video): bound Screen Video output and hostile packet handling

This commit is contained in:
Dylan M. Taylor
2026-11-16 22:33:39 -05:00
parent 8ad90cc70d
commit 3e0bb788a7
3 changed files with 22 additions and 0 deletions
+4
View File
@@ -114,3 +114,7 @@ The XML reader in `crates/plist/src/xml.rs` and its base64 compatibility helper
## GIMP palette reader
`crates/palette` extracts the GPL text parser from AniCraft `crates/doc/src/swatch.rs` at `d875a7feb250e6ab06aa28a37fb78a0699e88330` (MIT OR Apache-2.0), introduced by Tanish Manku in `a64130a9da9bdde545463b852d95d6a6774b1dfd` (AniCraft #270). The import preserves Tanish as primary author. Neutral RGB/name adaptation separates application display-name sanitization and the `Untitled` policy; validation tests and integration are subsequent Dylan M. Taylor changes.
## Screen Video key frames
`crates/video/src/screen_video.rs` extracts AniCraft `crates/xfl/src/video.rs` codec-3 decoding and its synthetic partial-block fixture, introduced by Tanish Manku in `1f3e603b7ff53a3da364e41ec4da8d43dc83aab0` with pixel-loop cleanup `2b7571363b4b647266df758f95b6e397021cfd4d` (MIT OR Apache-2.0). Import commits preserve Tanish as primary author. Caller-owned bounds and neutral RGBA output separate codec work from the consuming app's FLV first-frame/report policy. Boundary tests and integration are subsequent Dylan M. Taylor changes.
Generated
+1
View File
@@ -3286,6 +3286,7 @@ dependencies = [
"craft-jpeg",
"craft-media",
"craft-media-testkit",
"miniz_oxide 0.8.9",
"rav1e",
"rayon",
"thiserror 2.0.21",
+17
View File
@@ -99,4 +99,21 @@ mod tests {
assert_eq!(&rgba[i..i + 4], &[r, g, b, 255], "({x}, {y})");
}
}
#[test]
fn limits_truncation_and_unchanged_blocks_are_refused() {
let p = packet(40, 20, 16, |x, y| [x as u8, y as u8, 7]);
assert!(decode_keyframe(&p, 40, 40 * 20 * 4).is_some());
assert!(decode_keyframe(&p, 39, usize::MAX).is_none());
assert!(decode_keyframe(&p, 40, 40 * 20 * 4 - 1).is_none());
for cut in 0..p.len() {
let _ = decode_keyframe(&p[..cut], 40, 40 * 20 * 4);
}
let mut unchanged = p.clone();
unchanged[4..6].fill(0);
assert!(decode_keyframe(&unchanged, 40, 40 * 20 * 4).is_none());
assert!(decode_keyframe(&[0, 0, 0, 0], 40, usize::MAX).is_none());
let mut trailing = p.clone();
trailing.extend_from_slice(&[1, 2, 3]);
assert_eq!(decode_keyframe(&trailing, 40, 3200), decode_keyframe(&p, 40, 3200));
}
}