forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on c0d40241df09faa4dbcb6edb587ffe6ab4f5eb96Filtered to crates/ec-image/src/lib.rsClear filter

2026-08-26

Merge remote-tracking branch 'origin/main' into lane-image-tiffAhmet Kaan Gümüş · fd823fc
Merge remote-tracking branch 'origin/main' into lane-image-tiff

# Conflicts:
#	crates/ec-image/src/lib.rs
fix(image): budget every header-declared allocation; bound LZW growthAhmet Kaan Gümüş · 81c7624
fix(image): budget every header-declared allocation; bound LZW growth

Both 2026-08-26 machine OOMs were crates/ec-image tests/fuzz: decoders
allocated from wire-declared fields with no budget. Class fix:

- Limits::check_bytes + AllocBudget: per-buffer cap lowered to 1 GiB,
  decode-wide total of 4 GiB; GIF/WebP animation paths spend the budget
  per frame, closing the frame_count x canvas multiplier.
- GIF frame rectangles get their own limits check (they need not fit the
  canvas the screen descriptor bounded).
- lzw_decode stops once the declared frame is full instead of expanding
  a bomb stream to ~400 MB from a 155 KB input.
- HEVC slice headers reject num_ref_idx_lX_active_minus1 > 14 (7.4.7.1)
  before pred_weight_table sizes vectors from it.

Fuzz suite holds under a 4G scope (max RSS 3.1G, was 27G); differential
and real-library suites stay green.
feat(image): decode BMP, including the shapes ImageMagick will not writeAhmet Kaan Gümüş · f1f296e
feat(image): decode BMP, including the shapes ImageMagick will not write

gpui names ImageFormat::Bmp, so the shim needed a decoder behind it. This
reads every shape the format defines: 1/2/4/8/16/24/32-bit samples, palettes
with three- or four-byte entries, BI_RLE4 and BI_RLE8, arbitrary BI_BITFIELDS
masks, bottom-up and top-down rows, and headers of every defined length from
the 12-byte OS/2 v1 to the 124-byte BITMAPV5HEADER.

Two shapes that started as refusals are decoded instead. BI_PNG and BI_JPEG
files are a BMP header wrapped around a whole file of another format, so they
are handed to this crate's own PNG and JPEG decoders. The 16-byte OS/2 v2
header is the Windows layout truncated where the two stop agreeing, so it is
read through those 16 bytes -- which is what ffmpeg does, and what the
incumbent image crate refuses.

Gate: fourteen fixtures pixel-exact against image 0.25.10, the two wrapper
files exact against the incumbent decoding their payloads directly, and the
OS/2 v2 file exact against the same picture in a header the incumbent reads.
Twenty thousand fuzz mutations across the plain and run-length paths, no
panics. Full report in lanes/image-bmp-r1.report.md.
feat(image): animated WebP, composited frame by frameAhmet Kaan Gümüş · 275d306
feat(image): animated WebP, composited frame by frame

decode_frames walks the ANMF chunks and composites them onto the canvas:
frame rectangles, both blending methods, and dispose-to-background applied
before the next frame is drawn. is_animated answers from the container
alone. The still and animated paths now share one payload decoder.

The incumbent decoder ignores the dispose-to-background flag, so it cannot
be the oracle for the frame after a disposal: that fixture is gated
against libwebp's own composited frames instead, pixel-exact, and the
incumbent remains the oracle for the opaque fixture. ffmpeg refuses
animated WebP outright and cannot arbitrate.

Adds a lossless fixture whose three frames carry alpha and exercise both
blending methods and the disposal rectangle -- the existing animation is
opaque and disposes nothing.
feat(image): GIF decoding and a format-agnostic animation surfaceAhmet Kaan Gümüş · 166bcc8
feat(image): GIF decoding and a format-agnostic animation surface

A GIF87a/GIF89a decoder written to the spec: LSB-first LZW with the
one-code-early width bump and the cScSc case, sub-block chains, the
four-pass interlace, graphic control extensions, local and global colour
tables, and frame compositing with all four disposal methods.

Adds decode_animation(), which every format answers -- a still is one
frame with a zero delay -- so a caller that wants to play something never
branches on the format. One colour form is chosen for the whole
animation, so the pixel layout cannot change under a caller mid-walk.

Gated pixel-exact against the incumbent decoder: 6/6 fixtures, and 7/7
real GIFs on this machine over 454 frames, frame count and per-frame
delays included. Two 10 000-round mutation sweeps cover the still and
the animation path.

2026-08-14

feat(image): WebP decoding, VP8 key frames and VP8LAhmet Kaan Gümüş · 22ac6ab
feat(image): WebP decoding, VP8 key frames and VP8L

The RIFF container, both bitstreams, and the separate alpha plane an
extended file carries.

VP8 (RFC 6386) is a complete key frame decoder: boolean entropy decoder,
segmentation, per-partition token decoding with the neighbour contexts,
the WHT and DCT inversions bit-exactly as specified, all sixteen intra
prediction modes including the six diagonal subblock ones, and both loop
filters with their per-macroblock strength derivation. The probability and
quantizer tables are generated from the RFC text rather than retyped —
two thousand values transcribed by hand is a defect waiting to be found
several macroblocks into a picture.

VP8L is the lossless bitstream: canonical prefix codes with meta prefix
groups, the colour cache, LZ77 over the two-dimensional distance map, and
all four transforms applied in the reverse of the order they were read.
The colour cache size is read *before* the meta prefix codes; the other
order parses plausibly and then fails on the first real file.

Alpha arrives either raw or as a headerless lossless stream in the green
channel, then unfiltered by the method its chunk declares. Animation is
refused by name: a still decoder that quietly returns frame one makes
"this plays" and "this decoded" indistinguishable to its caller.
feat(image): baseline and progressive JPEG decodingAhmet Kaan Gümüş · 7eed0e7
feat(image): baseline and progressive JPEG decoding

ITU-T T.81 baseline (SOF0), extended sequential (SOF1) and progressive
(SOF2), Huffman coded, with restart intervals and both spectral-selection
and successive-approximation refinement.

Chroma is upsampled with the triangle filter both reference decoders use,
in a module JPEG and WebP share: pixel replication is a decibel cheaper
against the source and puts a visible staircase on every saturated colour
edge. The IDCT is a separable fixed-point inversion carrying thirteen
fractional bits, which lands within one count of the incumbent on
grayscale, where no colour matrix or upsampler is in the way.

EXIF orientation is parsed and exposed, never applied — the same choice
the incumbent makes, so a caller swapping between them sees one picture.
Arithmetic-coded, lossless and hierarchical JPEGs, and the 4-component
CMYK/YCCK family, are refused by name with the reason: decoding ink
colours without their ICC profile looks right in a thumbnail and is wrong
in print.
feat(image): PNG decoding and the still-image APIAhmet Kaan Gümüş · 7bceff2
feat(image): PNG decoding and the still-image API

ec-image decodes stills for the engine's placed-picture path. This first
stage is the shared API — format guessing from content, a Pixels buffer in
the file's own colour form, parsed-but-unapplied metadata, and pixel limits
checked before any buffer is sized from a header — plus the PNG decoder
over ec-inflate.

Every colour type at every legal bit depth, all five filter types, Adam7
interlace, palette and colour-key transparency, gamma and sRGB exposed,
ancillary chunks skipped by length, and every chunk CRC verified: a PNG
that fails its own checksum is refused rather than decoded into a picture
nobody can tell is wrong.

scripts/gen-still-fixtures.sh generates the seeded corpus the later stages
measure against; the fixtures themselves stay out of the repository.