* 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.
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
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.
Adds Format::JpegLs: lossless and near-lossless gray and RGB, 2 to 16
bits. Reads scans that code one component each; writes lossless 8- and
16-bit gray and RGB. Line- and sample-interleaved scans, mapping tables
and colour transforms are reported as unsupported.
Closes#1558
The deep EXR corpus test read the five OpenEXR files in corpus/exr/
without a size bound or digest check, and a missing file failed with
advice to run `cargo xtask corpus --exr`, which craft-libs does not have.
- REAL_FILE_SHA256 pins the five files (OpenEXR commit 69b2604f). The
test reads only those names, refuses a file that is missing, is not
a regular file, is larger than 4 MiB or does not match its digest,
and names the file and both digests.
- The failure points at the crate README, which says where the files
come from and how to fill corpus/exr/, either from OpenEXR or with
PhotoCraft's fetcher at the commit CI uses.
- Three tests that run without the corpus feature cover the pins, a
changed byte, and missing, oversize and folder inputs.
* image-codecs: list InkSet and ExtraSamples on TiffPage
* image-codecs: TiffPage InkSet and ExtraSamples as enums
* image-codecs: InkSet::InkNames, and Invalid for undefined tag values
encode_jpeg_rgb8 wrote the XMP packet straight into an APP1 segment, so a packet past the limit failed the whole encode. It now builds the segment with the shared jpeg::xmp_segment, as the other JPEG paths do, and jpeg_xmp_fits tells callers whether the XMP will be written.
zune-jpeg also holds every coefficient beside its output when an 8-bit
sequential frame's first scan lacks some of its components: no row is
finished until the scans that bring the others. jpeg_info now reads the
first scan's component count and reports these as held_coefficients
(was progressive_coefficients). The #12473 map rewritten with one
component per scan was admitted at 12.6 GB without this, and
OOM-killed in a 14 GB cgroup.
Co-Authored-By: Νύξ (Nyx, AI) 🌑 <nyx@despotak.is>
zune-jpeg keeps every coefficient of an 8-bit progressive frame (SOF2)
beside its output: 2 bytes per sample, per component at its sampling.
That is 9.85 GB for a 48,000 x 34,200 4:4:4 file, more than the decoded
image. JpegInfo::progressive_coefficients reports them from the frame
header, so a caller can admit the decode against its real peak.
Co-Authored-By: Νύξ (Nyx, AI) 🌑 <nyx@despotak.is>
For storytold/photocraft#12473: PhotoCraft lifts its 2^30 px JPEG cap
only after admitting the decode against free memory, and for that it
needs the frame before decoding. jpeg_info reads it from the markers
alone: the stored size, the layout decode returns, and
whole_coefficients, set when decode hands the file to craft-jpeg
(arithmetic-coded, lossless or 12-bit frames), whose working set is
several times the decoded image. None without a frame of 1, 3 or 4
components.
This was part of storytold/photocraft#12604 until
storytold/photocraft#14236 moved the codecs here.
Co-Authored-By: Νύξ (Nyx, AI) 🌑 <nyx@despotak.is>