* EXR: decode a flat part of a file that also holds deep parts
decode_part refused every part of a file with any deep part, and
decode_display_part, which checked only the selected part, still failed
because the exr crate's image reader validates every header and refuses
deep ones before it reads a chunk.
Both now decide from the selected part's own header. When any part is
deep, the selected flat part is read chunk by chunk: the flat headers are
validated, every part's offset table is walked from the end of the
headers, and only the selected table's chunks are read. A chunk must start
past the last offset table and inside the file, carry the selected part's
number and hold a block no other chunk of the part holds; anything else is
Malformed. Files with only flat parts keep the crate's reader.
The file-size ratio check, which was skipped for every part when any part
was deep, now applies to the flat parts of such a file; deep parts are not
counted.
* EXR: a flat part beside a deep part needs a chunk for each of its blocks
The chunk reader for a flat part of a file that also holds deep parts
refused only a second chunk for the same block. A tiled part's chunk that
named a level the part does not have was skipped without decompressing,
so the tile it took the place of had no chunk and the part decoded with
that tile left at zero.
Each chunk now has to hold one of the part's own blocks, taken from the
header, that no other chunk holds; anything else is Malformed. Since a
part has as many chunks as blocks, every block then has a chunk.
The mixed-file tests also run with a tiled flat part, and a new test
names a missing level and a repeated tile.
* EXR: a scan-line chunk beside a deep part must start at its block's first line
The block index of a scan-line chunk is its y offset divided by the
lines a block holds, rounded toward zero. A chunk whose y was not the
first line of a block, or lay up to 15 lines above the data window of
a ZIP part, still named a block and was decoded into it. Such a chunk
is now Malformed.
* EXR: a block too large to address is LimitExceeded instead of a panic
The exr crate bounds a flat chunk by a block's pixels times the bytes a
pixel takes, an unchecked product, before it reads the chunk. A 1 x 1
part with five float channels in 10^9 x 10^9 tiles passed every size
limit, and decode_part and decode_display_part then panicked with an
overflow, for files of flat parts only and for mixed files alike.
read_meta now computes the product with checked arithmetic for each
flat part and returns LimitExceeded when it does not fit in a usize.
* EXR: a chunk beside a deep part must fit the rest of the file
The exr crate allocates a chunk's declared payload, up to the size of a
block, before it reads it. In a mixed file whose flat part has large
tiles, a chunk declaring i32::MAX bytes made a 2 GiB allocation from a
file of a few hundred bytes. read_flat_part_chunks now reads the
declared length first and returns Malformed when it is longer than the
bytes left in the file.
* test(exr): verify mixed-part ratio and display block budgets
* fix(exr): bound mixed-part payload and block bookkeeping allocations
* fix(exr): expose internal ordinal helpers to regression tests
---------
Co-authored-by: dotCooCoo <RobertLeeLW@gmail.com>
A part shorter than its compression's scan-line group (a one-row ZIP16 part) only decodes its
own rows, so the all-channel block bound is min(scan_lines_per_block, layer_h) rows.
decode_display_part refused a part whose data window across all channels
exceeded max_bytes, even when the kept planes fit. The EXR crate decompresses
one block at a time, so bound the largest all-channel block (a tile within the
data window, or one scan-line group across it) instead. Large multi-layer
files whose picture planes fit now decode; the selected-plane and file
capacity checks are unchanged.
In a multipart file the chunks start after the offset tables of all
parts. The deep readers in craft-exr and craft-image-codecs took the end
of the deep part's own table as the start of the chunk area, so an
offset into a later part's table passed the chunk-area check and its
bytes were parsed as a chunk.
Both readers now compute where the deep part's table starts and where
the last table ends with checked arithmetic, and refuse a file whose
tables run past its end before reading any offsets. The earlier tables'
sizes are no longer capped or saturated.
Tests build a two-part file from scratch (a deep part and a 1x1 flat
part, in both orders): the deep part decodes as in a single-part file,
an offset into the second table or one byte before the end of the
tables is refused, and a file that ends inside the second table is
refused.
* craft-exr: bounded part listing, flat decoding and writing (feature decode)
PhotoCraft's exr-crate wrapper (preview check, per-part and total size limits,
file-size plausibility, part ranking, one-part decode) and EffectCraft's
streaming channel filter, as one reader that returns a neutral model: part
headers with text attributes, and the kept channels in their stored type.
* craft-exr: deep data and Cryptomatte samples (feature decode)
PhotoCraft's deep OpenEXR reader (NONE, RLE and ZIPS deep scan lines and
tiles, every allocation admitted against the byte budget) and its flattening,
and its Cryptomatte layer listing and rank decoding, on the decode module.
* craft-exr: bounded band-by-band reader for flat scan-line parts
PhotoCraft's exr_stream decoder: bounded metadata, the offset table, then one
compression block at a time as interleaved f32. Custom chromaticities are
reported instead of refused, so the colour policy stays with the caller.
* craft-exr: bounded part listing, flat decoding and writing (feature decode)
PhotoCraft's exr-crate wrapper (preview check, per-part and total size limits,
file-size plausibility, part ranking, one-part decode) and EffectCraft's
streaming channel filter, as one reader that returns a neutral model: part
headers with text attributes, and the kept channels in their stored type.
* craft-exr: deep data and Cryptomatte samples (feature decode)
PhotoCraft's deep OpenEXR reader (NONE, RLE and ZIPS deep scan lines and
tiles, every allocation admitted against the byte budget) and its flattening,
and its Cryptomatte layer listing and rank decoding, on the decode module.
PhotoCraft's exr-crate wrapper (preview check, per-part and total size limits,
file-size plausibility, part ranking, one-part decode) and EffectCraft's
streaming channel filter, as one reader that returns a neutral model: part
headers with text attributes, and the kept channels in their stored type.
The OpenEXR naming layer PhotoCraft and EffectCraft each have: layer and
channel names, the channels that make a colour picture, and Cryptomatte IDs,
metadata keys, manifests and rank channels. No decoder dependency; decoding
follows in later changes.