Boundary tests set by a production constant check a small limit through a
private seam that takes it (b64 decode, drawingml table normalize, openpgp
verify), with the real constant nightly; captions and jbig2 check their
full-size boundaries nightly. Sweeps run every divisor-th case at the gate
(develop balanced highlights and thin line, jpeg low-memory tokens, png
streamed rows, mxf extreme fields, pdf crypt proptests), the fax bomb guard
page is wider and shorter, the resample bound pulls a shorter block, the nef
measured frames are read through probe_info, and local tone compares 64 and
256 pixels.
The PNG writer copied the caller's ICC profile, and the exported EXIF,
into new buffers before writing the header. Each tagged save allocated a
second profile-sized buffer that could abort the process when memory ran
short. The header now borrows the profile, and borrows the EXIF whenever
export_exif returns it unchanged.
For an RGB image with no source profile and a display other than sRGB,
`to_display_rgba8` rounded the samples to RGBA8 and then converted them
from sRGB, which lost precision and clipped float values before the
transform. It now converts the samples through the sRGB profile directly,
so the result matches the same image tagged with sRGB. Gray, CMYK and Lab
images without a profile still go through their `to_rgba8` values.
Chromaticity-derived reconstruction (matrix 12) took Kr and Kb from the
raw primaries code, so primaries 2 got BT.2020 weights while the HLG gain
in `cicp::linearize` read them as BT.709. Reconstruction now reads
unspecified primaries as BT.709 too, so a file tagged 2 decodes the same
as one tagged 1. Explicit BT.2020 keeps its weights.
The display conversion reads CICP primaries 2 (unspecified) as BT.709,
but the HLG gain in `to_display_rgba8` and in `cicp::linearize` took
BT.2020 luma weights for it, so a chromatic HLG pixel with unspecified
primaries was shown differently from the same pixel tagged BT.709, and
differently again after the HEIF and AVIF readers decoded it to linear
light. Both paths now read unspecified primaries as BT.709 when they
pick the weights. Explicit BT.2020 primaries keep BT.2020 weights.
While a restart interval is in effect, the decoder now rejects a restart
marker anywhere outside a scan's data, including one that comes after a
comment or another segment. Before, only a marker directly after the scan
was rejected, and one after a comment was skipped and the image decoded.
With an interval of 0 a stray restart marker is still skipped.
`detect` documents that a buffer of only `FF D8` matches no format, and
the tests check the error kind of a malformed DRI segment and a DRI change
between the component scans of an RGB file.
Image::to_rgba8 changes only the layout and sample type, so an app that
shows the result as sRGB draws a Display P3, Adobe RGB or BT.2020 picture
with the wrong colors.
With the new `cms` feature, Image::source_profile returns the profile
that describes the samples (the embedded ICC profile, or for an RGB
image without one, the profile of its CICP description), and
Image::to_display_rgba8 converts the pixels through craft-cms into a
display profile the caller passes. An image with neither is treated as
sRGB. PQ and HLG samples are decoded to linear light first and clipped
at diffuse white. The output is checked against Limits and reserved
before conversion, and 16-bit and float images are converted in bands.
Image::try_to_rgba8 and Image::try_to_rgba16 check the output against
Limits and reserve it with try_reserve_exact before any pixel is
converted, as Image::to_rgba_f32 does. A gray image is a quarter of its
RGBA8 copy, so a decode that fits the budget could still allocate past
it when converted. Sources other than U8 and U16 are converted one pixel
at a time, without the whole-image f32 buffers.
Image::into_rgba8 consumes the image and returns the pixel buffer of an
RGBA8 image as it is. A caller that decodes and then needs RGBA8 no
longer holds the decoded image and a copy at once.
to_rgba8 and to_rgba16 convert the pixel data only, without cloning the
image's metadata first.
encode_png_rgba8 writes interleaved 8-bit RGBA pixels as a PNG from a
borrowed slice. encode takes an Image, which owns its buffer, so a
caller holding pixels in a frame or a shared buffer had to copy the
whole image before saving it. The output is the same as encode of an
Image with the same pixels, no ICC profile and default metadata. A
buffer whose length is not width * height * 4 is rejected with
InvalidImage.
The decoders take a byte slice, and Limits bound only the decoded image,
so a caller had to cap and read the input itself. read_bounded(reader,
max_bytes) reads at most one byte past max_bytes and fails with
ErrorKind::FileTooLarge for longer input, including a file that grows
after its size was checked and a stream with no end.
* 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.
Follow-up to the brob budget:
- an over-cap or broken stream now charges the bytes it produced to the shared budget, so
a file of many such streams cannot inflate the whole budget once per box;
- a Brotli header that declares a large window is refused before decoding (the decoder reserves
its ring buffer up front, outside the output cap);
- boxes are walked one at a time instead of collected into a Vec of spans before the brob check.
image-codecs: document that JPEG XL ignores keep_orientation.
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.