* mesh, image-codecs: add clearcoat/sheen GLB, obj_with_mtl, and EXR chromaticities (#778)
* fix(mesh): import Image and TextureRef in obj tests
* fix(mesh): construct Mesh via struct literal in gltf test
Merges main at d7c9632bfb.
- Cargo.toml: both sides' new workspace crates (next's font-subset, harfbuzz-subset-sys and
host; main's gpu, gpu-null, gpu-providers and gpu-wgpu).
- crates/jpeg: next split lib.rs into modules; main's reduced-size decoding goes to them: the
scaled IDCT, reconstruction and render_scaled to idct.rs, MAX_SHRINK, reduced_estimate and
decode_reduced stay public in lib.rs. Main's new test added; the frame test next removed
stays removed.
- crates/audio, crates/media: next builds the integration tests into the library's test
executable (autotests off, tests/main.rs); main's new DSD and MPEG-TS mux tests are modules
there behind their features instead of [[test]] targets, and the mux tests reach their shared
helper module through the integration module.
- crates/media/src/matroska/track.rs: main's new FFV1 codec-parameter test added; the test
modules next removed stay removed.
- crates/file-formats: main's JXL capability test, which asks the codec whether JXL reads,
replaces next's interim check.
PrefixDetector::detect requires each call's bytes to start with the
previous call's bytes. Two integration tests passed a buffer that broke
that rule, so a detector that rechecks the SOI before resuming would
have failed them while still honoring the contract.
The tests now pass longer prefixes of one file and compare each answer
with detect_prefix on the same bytes. The check that a walk resumes at
the marker it stopped at stays in the jpegls unit tests, and a new unit
test checks that a walk that found a non-JPEG-LS frame header stays at
that marker.
Merges main at 3b8e426a26.
- crates/ui: main's e-sign dialog (crates/ui/src/esign) moves to craft-cloud-ui beside the
share dialog, behind craft-cloud-ui's esign feature; craft-ui forwards `esign` and
re-exports the module.
- crates/proof: main's can_suggest_cased goes to affix/check.rs and its tests to
affix/tests.rs (next split affix.rs); French wiring in lib.rs.
- crates/svg: main's validated resolver and raster validation stay under tree-render, which
now also enables gif and image-webp; the shared image-codec helpers are gated on tree.
- craft-ai-agents: main's rev (craft-ai-integrations main), one entry.
- crates/craft: facade dependencies, features and re-exports for main's new crates.
* image-codecs: find the JPEG-LS frame header past 64 segments, and add detect_prefix
detect walked at most 64 marker segments looking for the SOF55 frame
header, so a JPEG-LS file with more segments before its frame header,
such as an ICC profile split over 255 APP2 segments, was reported as
JPEG. The walk now runs until it reaches a frame or scan header or the
end of the bytes. Each step moves forward at least one byte, so the walk
takes at most one step per byte.
detect also reported JPEG for a buffer that ended before the frame
header, which is what a caller that reads only the start of a file
passes. The new detect_prefix returns Detection::NeedBytes(n) in that
case, with the length the next step reads, and otherwise the answer
detect gives. The doc comment on detect now says that it needs the bytes
up to the frame header.
* image-codecs: walk each JPEG marker segment once when detecting in steps
detect_prefix walks the marker segments from the SOI on every call, so a
caller that reads exactly the length each Detection::NeedBytes asks for
walks the earlier segments again on each call. Over a file with many
small segments before its frame header, the total walk grows with the
square of the segment count.
The new PrefixDetector keeps the offset of the marker where its last
walk stopped and starts the next walk there. Its detect gives the same
answer and asks for the same lengths as detect_prefix, and
detect_prefix now runs a single step of a new PrefixDetector.
* image-codecs: read past a JPEG-LS restart interval segment and stop at FF 00
The JPEG-LS frame walk treated a DRI segment before the SOF55 frame header
as the end of the walk, so a file with one was detected and decoded as
JPEG. DRI now takes the length-prefixed path. The decoder accepts a 2-, 3-
or 4-byte interval of 0, reports a nonzero interval as unsupported, and
rejects other segment sizes as malformed.
`FF 00` after the SOI is a stuffed zero, not a marker, so the walk now ends
there instead of asking for a length field.
A PrefixDetector whose walk stopped at another frame header answers JPEG
for bytes that start with `FF D8 FF`, without walking from the SOI again.
* image-codecs: apply the JPEG-LS restart interval in effect at each scan
A later DRI with an interval of 0 turns restarts off again, and an
interval of at least the frame height puts a non-interleaved scan in
one interval with no restart marker. Both decode again. A nonzero
interval shorter than the frame height is still unsupported.
* image-codecs: reject a restart marker after a JPEG-LS scan of one interval
A restart marker comes only between two restart intervals. When the
interval in effect is at least the frame height, the scan is one
interval, so a restart marker after it, with or without fill bytes
before it, is now an error instead of being skipped.
Adds a test that a PrefixDetector starts each call at the marker where
its previous walk stopped.
The VP8 encoder cloned the whole luma reconstruction before each
macroblock's B_PRED trial and restored it when a whole-block mode won,
so encoding P pixels copied about P^2/256 bytes. The trial writes only
the current macroblock, and the whole-block path writes every pixel of
that macroblock again without reading the trial's values, so the copy
and the restore are removed.
The output is byte-identical: a new test pins the SHA-256 of ten
encoded files (1x1 to 640x480, sizes that are not multiples of 16,
qualities 10 to 95) taken before the change, and decodes each with
image-webp. An ignored test prints encode times for 512 to 4096
squares; in release on one machine, 4096x4096 took 162.9 s before and
1.36 s after.
R16G16_UNORM stores a red and a green channel
(https://learn.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format),
but craft-dds read it as gray and alpha, so a two-channel normal map
opened with its green channel as transparency. It now reads as RGB with
blue 0, as BC5 and G16R16 channel masks already do. encode16 still
writes two-channel 16-bit pixels as R16G16; they read back as red and
green.
craft-image-codecs decoded every DDS at 8 bits. Texture::bits_per_channel
gives the widest stored channel, and textures wider than 8 bits (R16,
R16G16, R16G16B16A16, legacy FourCC 36, and channel masks with a 10- or
16-bit field) now open as U16 through decode16. craft-raster-codecs'
decode_levels does the same for every mip level.
* image-codecs: read JPEG XL through craft-jxl behind a jxl feature
Format::Jxl reads when the non-default `jxl` feature is on (decode only, so the
encoder's jixel dependency is not built); without it JPEG XL is still detected and
opening one is an Unsupported error that says the build lacks it. Orientation is
applied by the decoder, so the Exif and XMP orientation become 1. ICC, Exif and XMP
come through; associated alpha is divided out; float files open as F32.
* image-codecs: skip JPEG XL in the one-pixel round trip
The encoder refuses images narrower than two pixels; with the jxl feature JPEG XL is a
read-and-write format, so the generic round trip reached it.
For an animation frame that starts with an `ALPH` chunk, image-webp 0.2.4 decodes
the next chunk as VP8 whatever its FourCC, skips the size check it makes for frames
without alpha, and indexes the frame's buffers by the picture's own size. A picture
larger than its `ANMF` header, or a non-key frame (decoded as 0x0), panicked with
out-of-bounds indexing in `read_frame` and `fill_rgba`. image-webp also steps from one
frame to the next without the padding byte, so after an odd-sized `ANMF` chunk it
reads the next frame one byte early.
Before decoding, the container is walked for the first frame with alpha whose picture
is not a VP8 key frame of its header's size, and for the first odd-sized `ANMF` chunk.
That frame is refused like a damaged frame: `decode` (which reads frame 0) errors only
when it is the first, and `decode_webp_frames` keeps the frames before it with a
`Truncated` warning.
Found by fuzzing `decode_webp`; ported from storytold/photocraft#10473, which was
written before PhotoCraft's codecs moved here. The regression test panics without the
fix.
Co-authored-by: DJHoltkamp <4955429+DJHoltkamp@users.noreply.github.com>
* image-codecs: PNG bounds its image on the IDAT data and reserves only what it can make (lightcraft#3912)
The plausibility check measured the stored samples against the whole file
length, so ancillary chunks lifted the bound, and the decoder then reserved
the whole expanded output up front. A 1-bit 20000x20000 image is 50 MB
stored but 400 MB to 1.6 GB once expanded to 8-bit grey, RGB or RGBA, so
about 60 KB of IDAT reserved gigabytes.
- Bound the stored samples on the bytes of the first IDAT run (1032:1 plus
1 MiB), not the file length.
- Reserve up front only what the IDAT data can inflate to; past that, grow
the buffer as rows decode, at most doubling and never past the full
output. A forged file fails on its first row; a real solid or sparse
1-bit image that is past the ratio once expanded still decodes.
- Interlaced images decode into the whole zero-filled output in one go,
so their expanded size is checked against the IDAT data.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fnx9MwPUug72xHRgg993uc
* Fix Adam7 palette expansion bounds without allocating unvalidated output
---------
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
- Workflows: main's per-crate layout, with next in the push triggers, Linux only for pushes to
next, next's crate features (keymap egui, window and update ui) and test paths (crw samples and
the pdf fixtures run inside the lib's test binary). The workspace gate keeps --keep-going and
the facade-as-an-app clippy from next's ui.yml. Per-crate doc steps live in docs.yml, which also
documents craft-ui, the ui-* crates, craft-doc and craft-pdf with every feature. docpath, i18n,
print and ui workflows go, as on main. actions.lock lists docs.yml and theme.yml.
- Main's cloud and share UI (account, cloud, share, presence, the overflow menu and split button)
lives in the new crate craft-cloud-ui as main wrote it; the craft-ui facade forwards share and
cloud and re-exports account, cloud, share and presence, so craft-cloud-local builds unchanged.
- audio and media: main's new tests join tests/main.rs under their features.
- cms: main's new synth and FOGRA39 tests, with the fogra39() helper they use.
- nextest: no gpu group on unix; next's tests create no GPU device.
A conservative pre-decode coefficient budget for hostile JPEG headers: the
larger of JpegInfo::held_coefficients and a whole-picture estimate over every
progressive frame header (SOF2/6/10/14, any precision, sampling clamped to
1..=4), with the costliest frame charged at the first frame's size when the
header can't be followed. held_coefficients is unchanged.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
storytold main 83cb1133dd (291 commits) into the integration head bab1a99b85; 47 conflicted files.
- Domain test files (metafile, prepress, pdf plates, settings store, heif, media-testkit, atomic): tests next cut stay cut; tests new on main are kept, as trials where the crate's test target runs trials.
- atomic: main's group-bits test and Faulty::set_group go to src/tests.rs. audio: main's GSM and SBC oracles join tests/main.rs. cms constructors, pdf knockout_backdrop and testing_pdf join their crates' one test binary; timeline's preflight tests become src/preflight_tests.rs trials.
- update: main's changes to detect, install (linux, macos) and the tests land in next's split modules. The app's own offer is inspected on a thread of its own, picked up by tick's polling; settle_for_tests settles offers too. Later on a ready update drops the close it asked for. updater_pin_tests.rs stays deleted; its new pin test is in tests/it/update.rs.
- craft-color: main added a different crate at crates/color (the colour tags of compositor and display frames); it is next's craft-color module `tags`, re-exported at the root.
- Old crates/ui (combo, docking, testing, README) and keymap's ui/view.rs stay deleted; main's new crates/ui/src/testing files are dropped with them.
- New crates in the craft facade: ai, control, dds, frame, ipc, media-source, palette, press-print, score, ssip. testkit and xtask are listed outside it.
- Cargo.lock: the union of both locks, resolved by cargo metadata. Workflow: main's nextest Windows leg, with next's --keep-going clippy.
camera_raw_mode read a missing SubIFDs offset as 0, so it walked the TIFF
header as the pointer array and could classify a malformed TIFF as RAW.
Skip the entry instead, matching LightCraft's classifier.
A BMP stores its resolution in biXPelsPerMeter and biYPelsPerMeter
(BITMAPINFOHEADER and later). The image crate writes 0 there and nothing
read the fields, so a 300 ppi image saved as BMP reopened at 72 ppi and an
opened BMP's resolution was lost (storytold/photocraft#13630).
decode now reads the fields into Metadata::dpi, encode writes
Metadata::dpi into them whatever embed_metadata says, and
caps(Format::Bmp).dpi is true. encode_bmp_indexed_with_dpi is the palette
writer with a resolution; encode_bmp_indexed keeps its signature and output.
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.