Commit Graph
48 Commits
Author SHA1 Message Date
FredApps 9399c25341 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.
2026-11-15 16:10:22 +01:00
Dylan M. Taylor 4780f75080 Merge remote-tracking branch 'origin/main' into fix/avif-exif-hlg
# Conflicts:
#	Cargo.lock
2026-11-15 11:39:31 +00:00
Dylan M. Taylor 55b1d7f3c5 Merge pull request #1501 from storytold/extract/apng-container
craft-image-codecs: extract bounded APNG container assembly
2026-11-15 06:30:57 -05:00
Dylan M. Taylor dab6a8ea21 Flush delayed AV1 frames in HLG regression 2026-11-15 11:13:51 +00:00
Dylan M. Taylor a8f2612c7c Test decoded HLG AVIF reference levels 2026-11-15 10:46:51 +00:00
Dylan M. Taylor 30b78d048a Preserve requested AVIF alpha quality 2026-11-15 10:41:10 +00:00
.CooCoo b63198042b craft-image-codecs: check the deep EXR corpus against pinned SHA-256 values (#1487)
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.
2026-11-15 04:11:00 -05:00
Dylan M. Taylor 14e4ef8e5c fix(apng): enforce PNG integer ranges and satisfy chunk lint 2026-11-15 04:01:54 -05:00
.CooCoo cd8207b436 Merge pull request #1489 from dotCooCoo/fix/bounded-to-rgba-f32-a-tiff-strip-past-the-file
image-codecs: to_rgba_f32 checks its output against caller Limits
2026-11-15 04:01:40 -05:00
Tanish Manku 82fa80fca9 feat(image-codecs): extract bounded APNG container assembly
Preserve AniCraft animated PNG wire semantics while validating geometry, sequence numbers and allocation budget before writing.

Co-authored-by: Tanish Manku <tmanku.dev@gmail.com>
2026-11-15 03:58:22 -05:00
Dylan M. Taylor 543786812c Merge remote-tracking branch 'origin/main' into fix/avif-exif-hlg 2026-11-15 02:03:26 +00:00
Dylan M. Taylor 5c0b0a3632 Deduplicate raster codecs via shared image implementations (successor to #1198) (#1331)
* Share small raster format implementations

(cherry picked from commit 7aedc1de73)

* Preserve raster facade encode contracts

(cherry picked from commit 2db7c82705)

* Allow alpha in IFF compatibility encoder

(cherry picked from commit 80b55dee5a)

* Test shared raster facade contracts and refresh lockfile
2026-11-14 20:46:22 -05:00
Dylan M. Taylor e46c81e9cb test(avif): assert HLG color metadata without decoder 2026-11-15 00:40:25 +00:00
Dylan M. Taylor e54d36a76c fix(image-codecs): place AVIF tests after encoders 2026-11-15 00:10:45 +00:00
Dylan M. Taylor 35a16a63fd fix(image-codecs): preserve AVIF EXIF and HLG levels 2026-11-14 23:56:16 +00:00
Dylan M. Taylor d6cd7836d3 feat(video,image-codecs,stream-codecs): add encode_with_key, encode_avif_hdr, and decode_ccitt_raw (#1369) 2026-11-14 16:15:44 -05:00
Dylan M. Taylor 30209caad8 feat(gif,image-codecs): add indexed/interlaced GIF, jpeg_progressive_scans, and JP2 decode (#1358)
* feat(gif,image-codecs): add indexed/interlaced GIF, jpeg_progressive_scans, and JP2 decode

* chore: update Cargo.lock for craft-image-codecs jp2 dep

* fix(image-codecs,svg): deref jp2 ch and re-export resvg from craft_svg::tree::draw
2026-11-14 15:13:21 -05:00
Dylan M. Taylor d542e68c5b Merge pull request #1305 from TrevorBrown-dev/fix/web-jpeg-oversized-xmp
image-codecs: the web JPEG encoder trims or leaves out an XMP packet past one segment
2026-11-14 11:40:56 -05:00
Dylan M. Taylor 8ef708255e test(jpeg): cover unmarked CMYK craft decoding 2026-11-14 13:39:46 +00:00
Trevor Brown 25d56bb49c Merge upstream/main into fix/web-jpeg-oversized-xmp 2026-11-14 08:32:33 -05:00
Dylan M. Taylor 8f3247882d Fix unmarked CMYK polarity on craft JPEG path 2026-11-14 13:26:52 +00:00
Dylan M. Taylor c2a69bbdc6 Preserve unmarked CMYK JPEG samples 2026-11-14 13:23:47 +00:00
Dylan M. Taylor d15bf1f35b Merge pull request #1288 from despotak/fix/12473-jpeg-past-2-30
image-codecs: jpeg_info, a JPEG's frame and held coefficients from its markers
2026-11-14 07:42:05 -05:00
aiongg ea1c84290d image-codecs: list InkSet and ExtraSamples on TiffPage (#1307)
* 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
2026-11-14 07:18:01 -05:00
Trevor Brown db474747d0 image-codecs: wrap the encode_jpeg_rgb8 doc comment like the rest of the file 2026-11-14 06:44:08 -05:00
Trevor Brown a2722537fc image-codecs: the web JPEG encoder trims or leaves out an XMP packet past one segment
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.
2026-11-14 06:43:36 -05:00
ChristosandΝύξ 🌑 b270477c25 image-codecs: count the coefficients of a frame whose first scan lacks components
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>
2026-11-14 12:05:41 +02:00
ChristosandΝύξ 🌑 b3558f6821 image-codecs: test jpeg_info with four and two components
Four components read as CMYK. Two, a layout decode doesn't return,
give None.

Co-Authored-By: Νύξ (Nyx, AI) 🌑 <nyx@despotak.is>
2026-11-14 12:05:41 +02:00
ChristosandΝύξ 🌑 44dfda20d7 image-codecs: count the coefficients an 8-bit progressive decode keeps
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>
2026-11-14 12:05:41 +02:00
ChristosandΝύξ 🌑 7ff39bfda8 image-codecs: read a JPEG's frame from its markers (jpeg_info)
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>
2026-11-14 12:05:40 +02:00
Dylan M. Taylor f0f4758c01 image-codecs: preserve PNG HDR metadata and PQ output (#1249)
* image-codecs: preserve PNG HDR colour metadata and PQ output

* image-codecs: keep PQ PNG dimension checks overflow-safe

* image-codecs: test empty PQ PNG input rejection

* fix(png): preserve HDR color metadata semantics
2026-11-14 04:08:23 -05:00
Dylan M. Taylor 9481cecd22 docs: clarify shared resolution precedence 2026-11-14 04:24:37 +00:00
Dylan M. Taylor c526df24f3 image-codecs: delegate metadata edits to shared crate 2026-11-14 04:22:36 +00:00
Dylan M. Taylor fd708734aa Merge pull request #1182 from storytold/codex/photocraft-file-caps
Add shared format capability catalog
2026-11-13 22:38:59 -05:00
Dylan M. Taylor 49056e5408 image-codecs: align JPEG tests with progressive support 2026-11-14 03:21:46 +00:00
Dylan M. Taylor 1532c43674 Align EXIF thumbnail test with shared metadata 2026-11-13 07:33:07 -05:00
Dylan M. Taylor 38560a9ab6 Preserve malformed error for truncated oversized EXR 2026-11-13 06:51:57 -05:00
Dylan M. Taylor a07481b416 Bound EXR pixel area and SVG image recursion 2026-11-13 06:27:24 -05:00
Dylan M. Taylor d4685b2257 Retain GIF frame bounds when payload is truncated 2026-11-13 05:56:21 -05:00
Dylan M. Taylor 6417d6b90a Preserve shared format boundary behavior 2026-11-13 04:49:49 -05:00
Dylan M. Taylor 34f2d55dc0 Match Apple HEIF chroma reconstruction 2026-11-13 04:36:58 -05:00
Dylan M. Taylor 3fea43cf83 Match Apple HEIF chroma reconstruction 2026-11-13 04:36:50 -05:00
Dylan M. Taylor afe51ed11e Probe maximum raster frame allocation bounds 2026-11-13 01:51:42 -05:00
Dylan M. Taylor fdfb188855 Use array chunks for raster pixels 2026-11-13 01:24:36 -05:00
Dylan M. Taylor a47b78256c Expose shared embedded ICC extraction 2026-11-13 01:15:30 -05:00
Dylan M. Taylor 85145d8dfd Expose shared raster source and tone inspection 2026-11-13 00:58:35 -05:00
Dylan M. Taylor 3bdf0eaadd Format shared image codec crate 2026-11-13 00:17:35 -05:00
Dylan M. Taylor 9430f2807e Add shared image codec facade 2026-11-13 00:17:04 -05:00