Commit Graph
13 Commits
Author SHA1 Message Date
aiongg 2df33d2f01 Merge remote-tracking branch 'upstream/main' into sync/main-1116
# Conflicts:
#	Cargo.lock
#	crates/audio/src/lib.rs
#	crates/exr/src/decode.rs
#	crates/font-catalog/src/lib.rs
#	crates/ps/src/lib.rs
#	crates/svg/Cargo.toml
#	crates/text/Cargo.toml
#	crates/text/src/lib.rs
#	crates/video/Cargo.toml
#	crates/video/src/lib.rs
2026-11-16 14:23:07 +00:00
Alex Chambers ed70d09162 craft-heif: a protected Exif or XMP item is unreadable, not absent
A nonzero protection index made `item_info` return before it read the
item type, so a protected `Exif` or XMP item vanished: `scan` was
complete and empty, as if the file held no metadata. The protection
index doesn't hide the type, so read it, and return the item from
`scan` as `Unreadable::Protected`. `read` still leaves it out.
2026-11-15 00:28:28 +01:00
Alex Chambers 7ad164ff8a craft-heif: refuse a too-large item before copying any of it
`Iloc::gather` copied extents until it passed its limit and then
returned `TooLarge`, and `scan` charges its byte budget only for items
it returns. So 1,024 items, each naming one 64 KiB region 257 times,
copied 16 GiB from a 2 MiB file, and `read` up to 1 GiB.

Check every extent and sum the lengths first, and copy only when the
total fits. The new test counts the bytes copied over the full
1,024-gather scan and `read`'s 64 candidates; it copied 16 GiB before.
2026-11-15 00:26:42 +01:00
Alex Chambers 402e686c7a craft-heif: document items::read, scan and exif_tiff 2026-11-14 21:57:59 +01:00
Alex Chambers 76ddfc3749 craft-heif: items reads the primary image's metadata; add scan and exif_tiff
Port the container reader of storytold/lightcraft#1208 into `items`:

- `read` follows `pitm`, `cdsc` and the `dimg` inputs to return the
  primary image's EXIF and XMP, then items tied to no image. A
  thumbnail's or depth map's metadata is no longer the photo's.
- `scan` returns every EXIF and XMP item, with each item's bytes or why
  they can't be read, and `Scan::complete` is false when the item
  catalog can't be read in full. An app that must prove a file has no
  location refuses when unsure.
- `exif_tiff` finds the TIFF stream with or without a correct offset
  field or an `Exif\0\0` prefix.
- `iloc` is walked once; the module denies indexing and unchecked
  arithmetic; boxes, items and gathered bytes are bounded.

The tests of #1055 and lightcraft#1208 come along, adapted to assert
the returned bytes and the scan's completeness.
2026-11-14 21:57:59 +01:00
aiongg 0c586294ea Lints: fix clippy and rustdoc findings in ui-contract, i18n, heif, mesh, video, audio, doc and the doc links 2026-11-14 00:35:31 +00:00
aiongg 25597ecfc7 Media, formats and engine crates: follow-ups from the framework migration 2026-11-12 14:32:38 +00:00
Dylan M. Taylor 5fc172eeb5 craft-heif: metadata feature, Exif/XMP items without heic-rs (#1055)
* craft-heif: a metadata feature that reads Exif and XMP without heic-rs

The decoder is now the default feature decode, and heic-rs and rayon are
optional. The new metadata feature adds items::read: the first Exif item
and the XMP mime item from the box structure alone (iinf, iloc, idat), with
limits on boxes, items, extents and item size, moved from LightCraft's
lightcraft-meta. Built with --no-default-features --features metadata the
crate has no heic-rs dependency and read_metadata is that reader; default
builds are unchanged. With both features a test checks that the two readers
agree on synthetic files.

* craft-heif: keep #[cfg(test)] on the test modules so clippy treats them as tests

#[cfg(all(test, feature = "decode"))] hid the test cfg from clippy's
allow-unwrap-in-tests, so the helpers in tests_icc.rs and tests_synthetic.rs
failed all-targets clippy. The modules now carry #[cfg(test)] and
#[cfg(feature = "decode")] as two attributes.
2026-11-11 21:58:39 -05:00
d1f13fbea2 craft-heif: crop to the declared size, read_metadata, stereo test data (ports of open LightCraft PRs) (#841)
* craft-heif: stills decode at the size the container declares

A coded HEVC picture is a whole number of coding blocks and can be larger
than the image the container's ispe declares (Sony codes 1920x1080 as
1920x1088 without a conformance window). decode returned the coded size,
so probe and decode disagreed and the padding rows showed as a dark band.

decode_item now crops to ispe before the alpha merge and the transforms,
measures the clap parity on the declared size, and compares the alpha
item's declared size with the picture's instead of the coded planes.
A declared size larger than the coded picture is Malformed.

Ported from storytold/lightcraft#3977.

* craft-heif: read_metadata reads the primary image's EXIF and XMP without decoding

Cataloguing a photo needs its EXIF and XMP, not its pixels. read_metadata
opens the container under the same panic guard and box census as probe
and returns what decode would attach.

Ported from storytold/lightcraft#2087.

* craft-heif testdata: Spec::stereo builds a spatial photo (grpl/ster entity group)

A second image of the primary's size and a ster entity group naming both,
so callers can test stereo detection on a file this crate decodes.

Ported from storytold/lightcraft#1684.

* craft-heif: put_alpha uses is_multiple_of

---------

Co-authored-by: Mason <mason276752@gmail.com>
Co-authored-by: jkalkstein <76634771+jkalkstein@users.noreply.github.com>
Co-authored-by: Mitch Lindgren <mitch@lindg.ren>
2026-11-11 15:22:02 -05:00
Dylan M. Taylor 4e309f8458 craft-heif: cap hvcC parameter sets and tiles, count alpha-grid tiles (port of lightcraft #3645) (#812)
* craft-heif: cap hvcC parameter sets and tiles, count alpha-grid tiles in the visit budget

* craft-heif: charge every tile reference of a thumbnail candidate to the visit budget
2026-11-11 13:53:29 -05:00
Dylan M. Taylor 2408292033 craft-heif: cap zero-width iloc extents, apply the census on the thumbnail path (#813) 2026-11-11 13:30:58 -05:00
Dylan M. Taylor 081078bb1b craft-heif: optional Apple-style chroma upsampling (#799)
* craft-heif: optional Apple-style chroma upsampling

* craft-heif: the Chroma docs say rows blend too, and the README example compiles
2026-11-10 22:32:39 -05:00
Dylan M. Taylor 6e21c5b0b1 Add craft-heif: the HEIF/HEIC decoder shared by LightCraft and PhotoCraft (#794)
Moved from lightcraft-heif (lightcraft b188295e), the more complete of the
two copies: libheif-matching YCbCr conversion from the VUI, monochrome,
thumbnails and the box caps. PhotoCraft's grid-tile ICC inheritance tests
are ported to it.

Part of #778. Closes #784 once both apps switch.
2026-11-10 20:24:21 -05:00