forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on dc2d88c55ef361321ded597efbeaf4f8b2af4345

2026-08-26

fix(av1): clamp intra reference reads to the true edge even off a block's own row/colAhmet Kaan Gümüş · dc2d88c
fix(av1): clamp intra reference reads to the true edge even off a block's own row/col

libaom's av1_predict_intra_block (av1/common/reconintra.c) derives xr/yd --
the distance from a block's own right/bottom to the frame edge -- from
mb_to_right_edge/mb_to_bottom_edge, which are built from mi_cols/mi_rows
(the true, decodable extent), never any padded coding surface. n_top_px/
n_left_px is min(side, xr + side) even for a block whose own extent
straddles that edge legally (has_half) -- prediction does not get real
reconstructed pixels past the true edge for its own row/column either,
only reach ever got that clamp before. Plane::edges() now clamps the
own-portion the same way libaom's xr/yd do.

Verified pixel-exact against aomdec on the 216x96 col-edge repro
(mi(8,48)) that was silently wrong before (0 diffs, previously untested).
Gate unchanged at 124/127 -- the remaining 3 reds (854x480, 1920x1080,
non-multiple-size sequence) trace to a separate, not-yet-isolated defect:
a uniform -3 luma offset across every straddling block in a column strip,
first appearing at mi_row=8 mi_col=208 in 854x480 with a nonzero DC
coefficient present, i.e. downstream of this fix (dequant/IDCT or mode
choice, not reference-sample availability).
fix(av1): narrow the true-edge availability clamp to the reach extension onlyAhmet Kaan Gümüş · 01cb49b
fix(av1): narrow the true-edge availability clamp to the reach extension only

A block's own edge read (no `reach`) can land on a block that is legally
whole despite straddling the true frame edge (spec hasRows/hasCols, this
crate's has_half): such a block gets a real transform over its full
padded extent, not a garbage tail, and both this encoder and a real
decoder reconstruct it that way, so clamping that base read to the true
bound (mi_cols*4/mi_rows*4) was wrong -- verified by comparing against a
worktree at the prior commit: it moved the first luma mismatch in both
a_frame_round_trips_at_its_own_size (1920x1080) and
an_854x480_picture_round_trips_through_its_padding earlier in the frame
instead of fixing them, gate unchanged at 124/3/4 either way. Only a
`reach` extension (above-right/below-left) crosses into a block that may
never be coded past the true edge at all, so only that portion still
clamps to true_width/true_height; re-verified against the same baseline
worktree that this leaves the three pre-existing failures at their exact
prior mismatch positions (byte-for-byte), i.e. a true no-op for them,
while still fixing the genuine reach-based true-edge case this lane's
prior commit targeted.
fix(av1): clamp intra reference-sample availability to the true frame edge, not the padded coding surfaceAhmet Kaan Gümüş · f79d3fd
fix(av1): clamp intra reference-sample availability to the true frame edge, not the padded coding surface

Plane::width/height is the picture padded to a 32-aligned coding surface
(Picture::padded_to); Reach::of and Plane::edges used it both to decide
whether a directional mode's above-right/below-left extension is available
and to clamp how far the above/left reference rows read, so a block near
the true frame edge (but still inside the padded surface) read real
padded-reconstruction samples a real decoder never has -- it stops at
mi_cols*4 / mi_rows*4 (spec compute_image_size; libaom
av1/common/reconintra.c build_intra_predictors clamps the same way via
mb_to_right_edge/mb_to_bottom_edge) and replicates the last valid sample
instead. Plane now carries that true bound (true_width/true_height,
mi_cols*4/mi_rows*4) separately from its padded width/height, and Reach::of
plus the edge-row clamp use it.

A partition trial can still price a sub-block whose own origin already
sits past that true bound (kept only for cost comparison against a split
this frame goes on to refuse) -- across/down can now land at or below x/y
for such a block, so edges() treats an empty read range as unavailable
(None) rather than crashing on an empty "last sample" the same way y==0/
x==0 already do.
fix(av1): clamp chroma's dc-sign/skip context to its own subsampled true edge; fix a stale padded-decode testAhmet Kaan Gümüş · 82410a6
fix(av1): clamp chroma's dc-sign/skip context to its own subsampled true edge; fix a stale padded-decode test

Neighbours::record clamped chroma the same as luma (true mi_cols/mi_rows),
but libaom rounds a subsampled plane's edge up to its own 4x4 unit before
clamping (ROUND_POWER_OF_TWO(max_blocks_high, subsampling_y) in
av1_write_intra_coeffs_mb, encodetxb.c:456-459): a chroma unit straddling
an odd luma edge is still whole in chroma's own halved grid. Fixed by
rounding the luma bound up to even before clamping planes 1/2. No test in
the current suite exercises an odd true mi_rows/mi_cols with chroma
residual, so this doesn't move the gate; landed as a correctness fix
proven safe (no regression) pending such a case.

an_854x480_picture_round_trips_through_its_padding decoded at the padded
864x480 size and cropped to 854x480 by hand -- stale since 7ba33dd started
writing the true display size into frame_width/frame_height, which makes
ffmpeg crop to 854x480 on its own. Decoding at padded size now reads past
what ffmpeg emits (out.stdout shorter than expected, not a hard decode
error). Fixed the test to decode at the true size directly; it now
exercises the real desync (a luma mismatch, bitstream confirmed
byte-identical to a real decoder via EC_RNG trace, so a reconstruction-side
bug, not an entropy desync) instead of failing on a wrong expectation.

Gate: cargo test -p ec-av1 --release = 124 passed, 3 failed (same three
tests, still red, no regressions), 4 ignored.
fix(av1): gather dc-sign context per 4x4 unit, clamped to the true edgeAhmet Kaan Gümüş · 77b7e14
fix(av1): gather dc-sign context per 4x4 unit, clamped to the true edge

get_txb_ctx_general (libaom av1/common/txb_common.h) sums the DC-sign vote
over every 4x4 mode-info unit a transform spans, not once per coded
neighbour cell; av1_set_entropy_contexts (av1/common/blockd.c) clamps that
per-unit state to the frame's true (unpadded) mi_cols/mi_rows, zeroing
units past the edge even mid-cell. Our writer tracked one vote per 16x16
neighbour cell, so a 32x32 transform straddling the true bottom edge
(mi_rows=30, block rows 24..31) summed 2 cells instead of libaom's 8, and
never zeroed the two invisible mi-rows within the last cell -- producing
dc_sign_ctx=0 where the real decoder reads 2 (traced at mi(24,8), tell
2969, in a 192x120 key frame).

Widens Neighbours' above/left tracking from the 16x16 (SUB) grid to the
4x4 (MI) grid libaom actually keeps it on, and clamps record() to the
frame's true mi_cols/mi_rows the same way av1_set_entropy_contexts does.
mode/side/skip/inter tracking (single-cell lookups, not summed) stays on
the coarser grid.

192x120 (the established repro) now round-trips through ffmpeg bit-exact.
1920x1080 and the 854x480/non-multiple sequence tests still fail at other
positions -- a further defect of the same edge-clamping class, not yet
isolated; not chased further this round per budget.
wip(av1): per-symbol EC_RNG trace through write_coeffs/write_eobAhmet Kaan Gümüş · dcd1644
wip(av1): per-symbol EC_RNG trace through write_coeffs/write_eob

Every coefficient-path symbol (txb_skip, tx type, eob_pt/extra/bits,
base, base-range, DC sign, golomb tail) now prints under EC_RNG in the
same tag format the debug aomdec build emits, so the two traces diff
line-for-line. A plane: Option<usize> argument gates the prints to the
real tile writer -- the rate estimator calls write_coeffs thousands of
times per frame and drowned the trace without it.

The trace names the true-size desync: at mi(24,8), the first whole
32x32 quadrant straddling the true frame height, the writer's DC-sign
context is 0 where the reference decoder computes 2 at the same tell.
Root cause still open on this lane.
wip(av1): EC_RNG per-symbol trace localizes true-size desync to one edge quadrantAhmet Kaan Gümüş · 24b23ce
wip(av1): EC_RNG per-symbol trace localizes true-size desync to one edge quadrant

Adds an env-gated (EC_RNG=1) EC_PART/EC_TOK/EC_PLANE trace to the real
key-frame tile writer (sb_coeff_key_frame_tile), in the same format the
debug aomdec build already prints under the same variable, so encoder and
decoder traces diff line for line. Diffing a 192x120 test_card key frame
(the smallest repro of the three currently-failing round-trip tests)
against aomdec's own trace shows every tell (bit position) identical for
19 superblocks, then a hard divergence entirely inside the coefficient
coding of one 32x32 quadrant: the block at mi (24,8), the frame's first
Whole 32x32 quadrant whose has_cols32 and has_rows32 are both true while
its own extent (y=96..127) still runs past the true frame edge (height
120) into the padded region -- exactly the case the round-3 bisection
named. The writer's own tell after that block is 3019; the same bytes
read back on aomdec land at 3039, a 20-bit gap with no matching event on
our side, so something inside that one block's mode or coefficient
coding chooses a context, CDF, or symbol count the real decoder does not.
Root cause not yet isolated to a line -- see the ledger DELTA for what
is ruled out and what stays open. No behavior change: the trace is off
by default (one atomic load per call) and the three tests stay red at
124/127, unchanged from before this commit.
wip(av1): gather 32x32-level partial partitions; refusal test names the true-frame messagesAhmet Kaan Gümüş · ec3ad48
wip(av1): gather 32x32-level partial partitions; refusal test names the true-frame messages

The 32x32 recursion level now recomputes has_cols/has_rows the way
decode_partition does at every depth: both true writes the full partition
symbol, one false writes the single gathered split_or_horz/split_or_vert
bool, neither writes nothing and the split is inferred. The refusal test
sweeps the two sizes whose edge forces an 8x8 split this writer does not
code, and asserts on the messages both paths actually produce.

Still open on this lane: true-size streams >=192 wide with a partial mi
row corrupt at the first whole 32x32 edge quadrant (192x120 repro);
sb_coeff_inter_frame_tile still assumes whole superblocks.
wip(av1): write the true display size as frame_width/height, not the padded oneAhmet Kaan Gümüş · 6b1cdcc
wip(av1): write the true display size as frame_width/height, not the padded one

Frame headers now carry the picture's true (unpadded) size as
frame_width/frame_height, with mi_cols/mi_rows derived from that true size
via spec compute_image_size (2*((w+7)>>3)) instead of the padded picture's
width/4 -- mirroring rav1e/libaom, so a decoder crops to the true size
instead of the coded (padded-to-32/64) one. render_width/render_height come
out equal to frame_width/frame_height, so render_and_frame_size_different is
false and no render_size bits are written.

tile.rs: check_blocks no longer requires mi_cols/mi_rows to be an exact
multiple of the 32x32 block grid (a true size need not be); a new
block_grid() ceiling-divides mi_cols/mi_rows into the block-column/row count
actually coded, shared by sb_coeff_key_frame_tile, split_coeff_key_frame_tile
and (now) encode_key_frame_inner's own block/superblock generation loop,
which used to derive its cols/rows straight from the padded picture's width
-- it must agree with the tile writer's own count exactly.

KNOWN REGRESSION, not yet root-caused: three existing round-trip tests that
used a size not a whole 32x32 (or, for the facade, 64x64) block now fail
ffmpeg/dav1d decode with "Invalid data found" (an_854x480_picture_round_
trips_through_its_padding, a_frame_round_trips_at_its_own_size at 1920x1080/
640x352/1280x720, sequence_round_trips_at_a_non_multiple_size at 160x96).
Reasoned through the cols/rows/has_cols/has_rows arithmetic by hand for the
BLOCK(32)-alignment case and it should be invariant (true mi_cols/mi_rows
land in the same (padded-8, padded] window that keeps every BLOCK_MI(8)-
aligned threshold's comparison unchanged) -- confirmed by an EC_RNG-gated
rng-per-symbol trace (temporary, reverted) diverging from aomdec's own trace
from the very first symbol, which does not match that reasoning and was not
resolved before the turn budget ran out. The three tests' own assertions
were updated to expect the new true-size ffprobe/decode behaviour (that part
is not in question); the decode failure itself is the open defect.

Not attempted: sb_coeff_inter_frame_tile has no has_cols/has_rows-style
partial-superblock handling at all (always PARTITION_SPLIT, always 4
quadrants) -- a true size that isn't a 64x64 (SUPERBLOCK) multiple needs that
ported from the key-frame writer before an inter/multi-frame stream can use
a true, non-superblock-aligned size. The facade's key-frame path already
regresses today for the same underlying reason before inter frames are even
reached.
Merge branch 'lane-av1-interdesync': corner-only matches raise new_mv_ctxAhmet Kaan Gümüş · c47074a
Merge branch 'lane-av1-interdesync': corner-only matches raise new_mv_ctx

Closes the I8 verifier's CLASS B real-content inter desync at aligned sizes.
fix(av1): new_mv_ctx case-0 takes the corner-derived ref_match_count bitAhmet Kaan Gümüş · d5bf53b
fix(av1): new_mv_ctx case-0 takes the corner-derived ref_match_count bit

Real-motion content desynced from inter frame 3-4 at aligned sizes: a block
whose only neighbour match is the diagonal corner has nearest_match == 0
but ref_match_count == 1, and libaom sets mode_context |= 1 there
(mvref_common.c ~621) while our arm hardcoded 0 — wrong NEWMV CDF row,
rng drift, decoder rejects the tile. Sibling of the ref_mv_ctx corner fix;
zero_mv_ctx checked, no such dependency. New test pins the corner-only-match
shape. Both I8 failing clips re-encode to 10/10 clean aomdec+ffmpeg decodes,
byte-exact vs reconstruction.
Merge branch 'lane-av1-pad854': Reach tables indexed at libaom's 128px strideAhmet Kaan Gümüş · af95500
Merge branch 'lane-av1-pad854': Reach tables indexed at libaom's 128px stride

854x480 padded key frame closed: HAS_TOP_RIGHT/HAS_BOTTOM_LEFT are libaom's
has_tr_*/has_bl_* tables, indexed there with row stride 128/side (its
compile-time max superblock), not our 64/side — one 16x16 read bit 10
instead of bit 18 and lost its bottom-left neighbour, drifting the
reconstruction by one blend step. Boundary checks stay 64-relative.
New sweep test cross-checks Reach against a fresh transcription of
libaom's has_top_right/has_bottom_left at every position.

Gate: cargo test -p ec-av1 --release -- --include-ignored 122 passed / 0 failed.
fix(av1): Reach's has_top_right/has_bottom_left table stride was 64-relativeAhmet Kaan Gümüş · d1d8e10
fix(av1): Reach's has_top_right/has_bottom_left table stride was 64-relative

Round-2 of the 854x480 padded key frame desync: a debug aomdec trace of
has_top_right/has_bottom_left at the exact first-mismatch block (a 16x16 at
mi (40, 88)) found libaom indexing its pinned has_bl_16x16 table at bit 18
(row * 8 + col), while Reach::bottom_left indexed the same table at bit 10
(row * 4 + col) -- different bits, one true one false. libaom's tables are
pinned to its compile-time maximum superblock (128px, MAX_MIB_SIZE_LOG2 = 5),
not the superblock size a stream actually uses, so the row stride for a
16x16/32x32 block is 128 / side, not SUPERBLOCK / side (this crate's 64px
superblock) -- Reach::of's own row/col position within the superblock was
already right; only the table's row stride was wrong.

Un-ignores open_defect_854x480_padded_key_frame_desyncs, renamed
an_854x480_picture_round_trips_through_its_padding, and adds
reach_matches_libaom_has_top_right_and_has_bottom_left, a from-scratch
transcription of libaom's has_top_right/has_bottom_left checked against
Reach for every 16x16/32x32 position across three superblocks square,
including every superblock edge -- the class this bug was (an index stride
silently wrong for one block size, plausible for the other).
docs(av1): redirect the 854x480 pad desync hunt from CDF desync to ReachAhmet Kaan Gümüş · f1da657
docs(av1): redirect the 854x480 pad desync hunt from CDF desync to Reach

An EC_RNG-per-symbol trace of this frame's writer against a debug libaom
decoder (od_ec_decode_cdf_q15/od_ec_decode_bool_q15 instrumented) proved the
arithmetic coder is byte-for-byte identical to libaom across all 51188
symbols -- the bitstream itself is not desynced, and the (has_cols, has_rows)
partial-superblock partition code at tile.rs:783-795 this lane was told to
suspect first is exercised correctly here.

The real divergence: our own Encoded::reconstruction reports 147 at luma
(161, 369) where both a debug aomdec decode of our own bitstream and ffmpeg
agree on 148 -- an exact off-by-one that cascades rightward through
everything predicted from that block. Every mismatch in the frame is
`ours == correct - 1`. That points at encode.rs's Reach::of /
Reach::top_right / Reach::bottom_left (the pinned HAS_TOP_RIGHT/
HAS_BOTTOM_LEFT tables deciding how far a directional intra predictor may
read past a block's own edges) computing different above-right/below-left
availability than the real decoder for this specific block position, not a
partition/edge-superblock bug.

Left #[ignore]d with the corrected diagnosis in its doc comment; instrumentation
(EC_RNG-gated msac.rs tracing, matching aomdec build at
/tmp/libaom-src/build/decoder-debug, dump-and-diff scripts) reverted, none of
it kept in the tree.
Merge branch 'lane-av1-facade': I11 streaming encoder facade with colour signallingAhmet Kaan Gümüş · ec4c3f6
Merge branch 'lane-av1-facade': I11 streaming encoder facade with colour signalling

Av1Encoder{new,encode,coded_size,display_size} one-in-one-out;
EncoderConfig{width,height,base_q_idx,gop,colour}; Colour maps to CICP
(BT709/BT601 limited, unspecified) wired into the key-frame sequence
header; encode_sequence and the facade share encode_key_frame_inner/
encode_inter_frame. Gate: cargo test -p ec-av1 --release 123 passed / 5 ignored.
feat(av1): streaming encoder facade with configurable colour (I11)Ahmet Kaan Gümüş · f421d98
feat(av1): streaming encoder facade with configurable colour (I11)

Av1Encoder is the one-in-one-out surface edith_replica's engine will call
in place of rav1e: EncoderConfig{width,height,base_q_idx,gop,colour} in,
encode(&Picture) -> Packet{data,key,order} out, gop-cadenced key frames
predicting inter frames from the previous reconstruction like
encode_sequence already did. encode_key_frame_inner/encode_inter_frame
are now shared (pub(crate)) between encode_sequence and the facade
instead of being duplicated. The sequence header's colour_config is wired
to Colour::{Bt709Limited,Bt601Limited,Unspecified} (spec 5.5.2's CICP
triple + range), replacing the hardcoded "unspecified" -- verified against
ffprobe.
Merge branch 'lane-av1-size': pad-to-32 with cropped reconstructionsAhmet Kaan Gümüş · 77b8ab9
Merge branch 'lane-av1-size': pad-to-32 with cropped reconstructions

The merge exposed a latent mvstack defect the two lanes could only trip
together: real inter residuals (lane-av1-desync) on padded content
(lane-av1-size) hit a block whose ref_mv context libaom derives from a
diagonal corner probe our reduction never ran. Folded into this merge:

- port libaom's scan_blk_mbmi(-1,-1) corner probe; ref_mv_ctx now
  splits (nearest_match, ref_match_count) exactly as mvref_common.c does
- fix the REF_CAT_LEVEL DRL boost comparison (was trivially true);
  weights are boosted in place before the corner probe can add an
  unboosted entry
- SymbolEncoder::tell(), the od_ec_enc_tell mirror the hunt relied on

Gate: cargo test -p ec-av1 --release = 116 passed, 5 ignored.
fix(av1): code tx_type for inter 32x32 residuals; drop the skip-only corner-cutAhmet Kaan Gümüş · ac63d1d
fix(av1): code tx_type for inter 32x32 residuals; drop the skip-only corner-cut

Spec 5.11.48: an is_inter 32x32 luma transform sits in TX_SET_INTER_3, not
TX_SET_DCTONLY, so the decoder reads a tx_type bit right after all_zero. The
writer reused the intra DCT-only TxbSet for inter blocks and never wrote it,
desyncing every symbol after the first coded inter coefficient. New
TxbSet::Luma32Inter carries the TX_SET_INTER_3 CDF row (libaom
entropymode.c:369); search_inter_block now prices real residuals and derives
skip from the quantized levels.
feat(av1): arbitrary even frame sizes via block-grid padding + render cropAhmet Kaan Gümüş · 51570f6
feat(av1): arbitrary even frame sizes via block-grid padding + render crop

Picture::check_even() replaces the whole-32x32-blocks requirement at the
public encode_key_frame/encode_key_frame_with_modes/encode_sequence entry
points; any even, nonzero width/height is accepted. Picture::padded_to()
pads by edge replication to the block coder's own grid (32 for a lone key
frame, 64 for a sequence, so an inter frame's reference always matches the
frame coded against it) and is identity when already aligned. Encoded's
public reconstruction is always cropped back to the caller's own size
(crop_encoded/crop_plane); render_width/render_height are set correctly in
the frame header regardless.

Also fixes an internal regression this surfaced: padded_to previously
padded every path to 64, which broke the existing 32-aligned-but-not-64
fast path (96x64) for a lone key frame.

Leaves one open, pre-existing-looking defect this lane's sweep found:
854x480 padded to 864x480 desyncs against ffmpeg's decode at a spot well
inside the real (non-padded) region -- content-dependent, not padding
wiring (864x480 coded directly, no padding, is bit-exact). Documented and
left #[ignore]d as open_defect_854x480_padded_key_frame_desyncs rather than
silently dropped from the size sweep.
feat(av1): inter encode loop — decoded-reference sequence codingAhmet Kaan Gümüş · 50130dc
feat(av1): inter encode loop — decoded-reference sequence coding

encode_sequence keys the first picture and codes every later one against the
previous frame's own decoded reconstruction (single LAST slot). Per-block RD
weighs the intra modes against NEARESTMV and NEWMV, mv bits priced through the
CDF intervals. Inter residuals are corner-cut to skip=true pending the tile
writer's is_inter coefficient desync fix; the ceiling and reinstatement point
are named at the corner-cut comment.
feat(av1): coefficient CDFs for all four q contextsAhmet Kaan Gümüş · 2edeb94
feat(av1): coefficient CDFs for all four q contexts

Q0/Q1/Q3 tables added alongside the existing Q2 (61..=120) family for
all 34 coefficient CDF groups, transcribed and verified against the
Q2 baseline. tile::q_ctx_of buckets base_q_idx into the four bands
(0..=20, 21..=60, 61..=120, 121..=255) and Cdfs::pick selects the
matching table, so the tile writer now accepts the full 0..=255 range
instead of refusing everything outside 61..=120.

Removed the three test assertions that pinned the old refusal
(a_picture_off_the_block_grid_is_refused, dc_levels_the_base_syntax_-
cannot_carry_are_refused, coefficients_the_writer_cannot_code_are_-
refused) and extended the ffmpeg roundtrip and quantizer-monotonicity
gates to exercise one q index from each context, including the three
context boundaries.
feat(av1): inter tile writer sb_coeff_inter_frame_tileAhmet Kaan Gümüş · 302d3c4
feat(av1): inter tile writer sb_coeff_inter_frame_tile

Flat 32x32-block-grid writer for inter frames: skip -> is_inter (ctx
from above/left skip+inter tracking) -> intra path (Y_MODE by size
group, not KF_Y_MODE) or inter path (single_ref chain, find_mv_stack,
read_inter_mode NEWMV/NEARESTMV, DRL idx 0 only, mv_joint + per
component symbols) -> existing coefficient path. Widens
SymbolDecoder::symbol to pub(crate) for cross-module roundtrip tests.

One-line encode.rs fix required for BlockCoeffs' two new fields
(skip, inter) via ..BlockCoeffs::default() at its one non-spread
construction site.

Corner-cuts (documented in tile.rs): whole-superblock frames only,
DRL always index 0, allow_high_precision_mv=0 assumed (validated,
not silently rounded), InterMode limited to NearestMv/NewMv.
fix(image): close a TIFF LZW dictionary-corruption cycle that grew unboundedAhmet Kaan Gümüş · 55b1d36
fix(image): close a TIFF LZW dictionary-corruption cycle that grew unbounded

A code strictly greater than the dictionary's next slot was accepted into
the KwKwK branch and stored as `previous`; a later entry then chained
through that out-of-range value, breaking the prefix-chain invariant and
letting the decode walk cycle, growing `stack` to gigabytes on a
fuzzed 8950-byte fixture. Require code == next for KwKwK; anything else
is corrupt input, not a decodable stream.
feat(av1): diamond/log integer + half/quarter-pel motion searchAhmet Kaan Gümüş · 5986059
feat(av1): diamond/log integer + half/quarter-pel motion search

Adds crates/ec-av1/src/motion.rs: a log/diamond integer-pel search over one
reference plane through mc::predict, refined by one half-pel then one
quarter-pel round. Cost is SAD + lambda * mv_bits, where mv_bits prices the
MV residual (joint/class/bit/fraction/hp) by interval-narrowing through
encode::symbol_bits against the cdf::MV_* tables, matching the tile writer's
own convention rather than a per-entry probability lookup.

SEARCH_INITIAL_STEP_PEL=8 landed from a three-way sweep (4/8/16) recorded in
motion.rs's own inline test. SAD chosen over SSE per a doc-comment measurement.
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(av1): exact spec 7.10.2.8 mvstack contexts, 7.10.2.14 MV clampingAhmet Kaan Gümüş · 23d548c
fix(av1): exact spec 7.10.2.8 mvstack contexts, 7.10.2.14 MV clamping

Replaces the documented monotonic stand-in NewMvContext/RefMvContext/
ZeroMvContext/DrlCtx with an exact port of libaom's av1_find_mv_stack
mode_context switch and av1_drl_ctx (mvref_common.c/.h), which collapse
to closed forms given this module's already-reduced scan (no extended
row/col offsets, no temporal MV projection): ref_match_count ==
nearest_match always, so drl_ctx is always 0 (every candidate gets the
REF_CAT_LEVEL nearest-bonus), and zero_mv_ctx is always 0 (GLOBALMV_OFFSET
is only ever set by temporal MV projection). Adds MiInfo::is_new_mv so
new_mv_ctx can read whether a neighbour was itself coded NEWMV, matching
libaom's newmv_count. Adds clamp_mv_ref (7.10.2.14) applied to
nearest_mv/near_mv/pred_mv, requiring find_mv_stack's new mi_cols/mi_rows
params. Adds single_ref_ctx: the LAST-only reduction collapses libaom's
three single_ref_p1/p3/p4 context functions to one two-valued test since
LAST2/LAST3/GOLDEN/backward counts are always zero here.

Ledger: does not include the inter tile writer (ec-av1 tile.rs) this
lane's charter also scoped -- see HANDOFF for the exact block-writer
design (symbol order, size groups, MV component coding) worked out but
not yet landed.
feat(av1): write inter frame headers, referencing one reference slotAhmet Kaan Gümüş · d95e550
feat(av1): write inter frame headers, referencing one reference slot

Extends write_frame_header to shown inter frames: error_resilient_mode,
primary_ref_frame, refresh_frame_flags, the ref_order_hint loop (when
error-resilient), frame_refs_short_signaling (off) + ref_frame_idx[0..7],
allow_high_precision_mv, interpolation_filter (EIGHTTAP, non-switchable),
is_motion_mode_switchable, use_ref_frame_mvs, reference_select (forced off,
non-zero refused by name along with the skip mode and warped motion it
gates), and per-reference is_global (forced identity, non-identity global
motion refused by name). Adds inter_frame_headers() beside key_frame_headers,
reusing its sequence header verbatim and pointing every ref_frame_idx at the
slot holding the previous decoded frame.

New inline test parses a key + two inter frame header sequence back through
ec_av1_syntax::Av1Parser's own FrameState threading and checks every field
(after taking the reader's own derived fields — showable_frame, OrderHints,
RefFrameSignBias, header_bits — from the parse) plus written-vs-consumed bit
length, per frame.
feat(av1): MV prediction stack (spec 7.10.2, single-ref reduction)Ahmet Kaan Gümüş · ec98d16
feat(av1): MV prediction stack (spec 7.10.2, single-ref reduction)

find_mv_stack scans row-above/col-left/top-right neighbours over a
block's whole 4x4-mi span, dedupes into a weighted RefStackMv, and
derives NearestMv/NearMv/PredMv plus NewMv/RefMv/ZeroMv/DRL contexts.
Compound refs, temporal MV projection and bit-exact context tables are
deliberately out of scope until a consumer needs them.
feat(av1): default CDF tables for inter-frame mode and MV syntaxAhmet Kaan Gümüş · e9086ec
feat(av1): default CDF tables for inter-frame mode and MV syntax

Spec 9.4's Default_Intra_Inter_Cdf, Default_Single_Ref_Cdf,
Default_Y_Mode_Cdf, the new/zero/ref-mv and drl-mode families, and the
full per-component motion vector set (joint, class, class0 bit/fr/hp,
bit, fr, hp, sign), transcribed from libaom's own default tables
(av1/common/entropymode.c, entropymv.c) rather than rav1e's transposed
layout. Cdfs gains owned copies, with the MV tables split into a
two-element per-component array so adapting one component cannot leak
into the other.

Compound reference and compound-mode CDFs are left out: this encoder
never sets reference_select.
feat(av1): sub-pel motion compensation (spec 7.11.3, EIGHTTAP regular)Ahmet Kaan Gümüş · 082d993
feat(av1): sub-pel motion compensation (spec 7.11.3, EIGHTTAP regular)

Two-stage separable 8-tap filter, InterRound0=3/InterRound1=11 for
8-bit non-compound per spec 7.11.3.2, edge samples clamped rather than
read out of range. Not yet wired into encode.rs (later lane).
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(infra): cap every cargo-run test binary in a 10G systemd scopeAhmet Kaan Gümüş · df0c158
feat(infra): cap every cargo-run test binary in a 10G systemd scope

Three kernel OOM kills in 48h came from test binaries launched outside the
omp-worker scope; a cap that lives in the launcher misses every other path.
The cargo target runner now wraps each test/bin in a transient user scope
(MemoryMax=10G, MemorySwapMax=2G), resolved via git rev-parse so every
worktree checkout carries it. EC_NOMEMGUARD=1 bypasses; fails open where
systemd is absent.
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-shim): the gpui-only surface, behind a cargo featureAhmet Kaan Gümüş · c6f0f87
feat(image-shim): the gpui-only surface, behind a cargo feature

gpui consumes half an image crate this shim never needed: Frame, Delay,
AnimationDecoder, GifDecoder, WebPDecoder, guess_format,
load_from_memory_with_format, ImageBuffer, and the Gif/Bmp/Tiff format
names. None of it belongs to still-image decoding, so it lives behind a
`gpui` feature the way chrono keeps its serde impls behind one -- a build
that does not draw windows compiles none of it, and the default surface is
unchanged.

Served by ec_image: the animation paths go through decode_animation, and
WebPDecoder::has_animation answers from webp::is_animated.
set_background_color accepts only a fully transparent colour, which is
what gpui asks for and what the frames are composited onto.
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.