From f034ced24205ec0eaf82bfe4e58271d9ae2c7fad Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 06:22:10 -0500 Subject: [PATCH] fix(exr): expose internal ordinal helpers to regression tests --- crates/exr/src/decode.rs | 4 ++-- crates/exr/src/decode_tests.rs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/exr/src/decode.rs b/crates/exr/src/decode.rs index 7d0f66795..2797e3641 100644 --- a/crates/exr/src/decode.rs +++ b/crates/exr/src/decode.rs @@ -245,7 +245,7 @@ fn window_size(size: exr::math::Vec2) -> (u32, u32) { /// Reads the headers and checks every part's declared size, alone and together, before any pixel /// allocation. Headers are read without the crate's validation, which refuses deep parts. -fn read_meta(bytes: &[u8], limits: &Limits) -> Result { +pub(super) fn read_meta(bytes: &[u8], limits: &Limits) -> Result { check_previews(bytes)?; let meta = MetaData::read_from_buffered(Cursor::new(bytes), false).map_err(map_exr)?; let (mut total, mut flat, mut dwa) = (0u64, 0u64, 0u64); @@ -758,7 +758,7 @@ fn tables_start(bytes: &[u8]) -> Result { /// Stable dense ordinal without materializing every tile. The library's block iterator /// internally allocates a Vec of all coordinates, which is unsuitable for cropped reads. -fn flat_block_ordinal(header: &Header, tile: TileCoordinates) -> Result { +pub(super) fn flat_block_ordinal(header: &Header, tile: TileCoordinates) -> Result { use exr::math::Vec2; use exr::meta::attribute::LevelMode; let mut start = 0usize; diff --git a/crates/exr/src/decode_tests.rs b/crates/exr/src/decode_tests.rs index 8622cb56c..89f44d506 100644 --- a/crates/exr/src/decode_tests.rs +++ b/crates/exr/src/decode_tests.rs @@ -574,13 +574,13 @@ fn mixed_one_tile(channels: &[&str], tile: u32, size: i32) -> Vec { #[test] fn a_chunk_beside_a_deep_part_must_fit_the_rest_of_the_file() { - // 2^15 × 2^15 tiles of three floats let a chunk hold up to 12 GiB, so the crate would + // 2^14 × 2^14 tiles of three floats let a chunk hold up to 3 GiB (also on 32-bit), so the crate would // allocate the 2 GiB this chunk declares before it found the file too short. let limits = Limits::default(); let channels = ["B", "G", "R"]; - let good = mixed_one_tile(&channels, 1 << 15, 12); + let good = mixed_one_tile(&channels, 1 << 14, 12); assert_eq!(decode_part(&good, 0, &all, &limits).unwrap().channel("R").unwrap().samples, Samples::F32(vec![1.0])); - let b = mixed_one_tile(&channels, 1 << 15, i32::MAX); + let b = mixed_one_tile(&channels, 1 << 14, i32::MAX); for r in [decode_part(&b, 0, &all, &limits).map(|_| ()), decode_display_part(&b, 0, &all, &|_| 0.0, &limits).map(|_| ())] { assert!(matches!(&r, Err(Error::Malformed(m)) if m.contains("remain in the file")), "{r:?}"); } @@ -689,6 +689,7 @@ fn cropped_mixed_display_bounds_block_tracking() { #[test] fn dense_block_ordinals_cover_scan_lines_and_all_tile_levels() { + use exr::block::chunk::TileCoordinates; use exr::meta::attribute::LevelMode; for tiled in [false, true] { let bytes = file(vec![layer(None, 9, 7, &["R"], tiled, exr::prelude::Compression::ZIP1)], (9, 7));