On panic = "abort" targets (wasm32) the catch_unwind fallback can't run, so
frames whose first component is sampled below the frame's largest factors
go to craft-jpeg before zune-jpeg is called.
zune-jpeg allocates its whole output before reading a scan, so
decode_jpeg_inks now applies decode's scan-data guard (one byte for every
2048 pixels, counted on scan data, not APP padding) first. The comparison
test's noise is computed in u64, so it doesn't overflow on 32-bit targets.
zune-jpeg 0.5 asserts in its upsampler on some subsampled four-component
frames whose first component isn't the largest. decode now catches that
panic and reads the file with craft-jpeg, as it reads arithmetic-coded and
12-bit files. Refs #778.
A jpeg_inks module for apps that keep a CMYK JPEG's inks the way zune-jpeg
readers gave them: every four-component file taken as Adobe-inverted, YCCK
turned into CMYK as libjpeg does (truncating), only the 8-bit Huffman frames
zune-jpeg decodes (arithmetic-coded and 12-bit files are refused), within
Limits. Also the frame's component count and the assembled ICC profile from
the headers alone. Refs #778.
* image-codecs: decode AVIF pixels with craft-video's pure-Rust AV1 decoder
New optional `avif-decode` feature (native targets) reads still AVIF
files: the HEIF/ISOBMFF item graph, grids, clap/irot/imir, alpha
auxiliary images (including premultiplied), 8/10/12-bit 4:0:0, 4:2:0,
4:2:2 and 4:4:4, nclx/ICC colour, Exif and XMP, and PQ/HLG to linear
F32 through cicp::linearize as the HEIF path does.
The container walk follows LightCraft #3017 by @emmertex. Every size is
checked against the caller's Limits before the AV1 decoder runs, the
decoder's memory budget is capped by max_alloc, and the decode is
wrapped in catch_unwind so a decoder panic becomes an error.
Fixtures are tiny ffmpeg/libaom files; the 4:2:0 planes match libdav1d
bit for bit. Adds a decode_avif fuzz target.
Part of storytold/craft-libs#778.
* image-codecs, video: address review on the AVIF decoder
- clap: width and height are unsigned fractions, the offsets have signed
numerators, so 0x80000000/0x40000000 is a width of 2, not -2.
- An item with clap, irot or imir more than once (repeated ipma records)
is refused before any canvas work, instead of rotating 261120 times.
- Matrix coefficients 10 (BT.2020 constant luminance) is refused rather
than converted with the non-constant-luminance equations.
- An alpha plane whose own transforms differ from the colour's is refused
rather than composed in the wrong place; none, or the colour's, still
decode.
- craft-video: Decoder::set_shown_budget lowers the per-chunk byte cap on
shown pictures (never above 1 GiB), and the AVIF decoder sets it to
max_alloc, so a payload of many shown pictures is refused before they
are built.
probe_size returned Unsupported for PNG, JPEG and TIFF, so callers sized
those images with a full decode. Each now reads only its header with the
checks decode runs: PNG's IHDR/fcTL, limits and plausibility; JPEG's
first frame header and EXIF; TIFF's default page directory, camera-raw
refusal and Orientation tag. The size is turned upright for 5-8, as
decode returns it.
Extract the remaining metadata delegation from #1198 after #1331 landed the raster facade changes. Preserve current image-codecs API, pixel transforms, docs and regression tests; omit unrelated resolution reexports and TIFF cleanup.
Original-change: 1d52e89405