forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on f7306dde2fb1e120acbeaca20ee4c99fbef5b43f

2026-09-05

perf(av1): reconstruction on a superblock-row wavefront (EC_AV1_RECON_THREADS)Ahmet Kaan Gümüş · f7306dd
perf(av1): reconstruction on a superblock-row wavefront (EC_AV1_RECON_THREADS)

lane-wave1 step (ii). Above one reconstruction thread the parser keeps
parsing and never writes the planes: each superblock's drained
`Vec<ReconOp>` becomes one job (one per 128x128 superblock when `sb128`,
since a 128 block writes across its four 64x64 visits), and N scoped-per-
tile workers reconstruct them in wavefront order -- job `(r, c)` starts
once `(r - 1, min(c + 1, last_col))` and `(r, c - 1)` are complete, which
covers every pixel an intra predictor can reach and every CfL AC read.
Jobs are handed out in raster order, so the oldest outstanding one always
has its dependencies met; a `WaveGuard` joins every worker on each exit
from the tile decoder, including the `?` ones.

The two parse-time pixel READS (the intrabc source fetch, the interintra
intra predictor) keep their `flush_recon`, which now waits the wavefront
out first and replays the current superblock inline -- so an intrabc block
serialises the tile at that point instead of trusting the spec's 256-px
delay against our lag, and stays byte-exact.

MEASURED and it does not pay: seg4k 31.8 s at (frame, filter, recon) =
(1,1,1) vs 31.9 s at (1,1,4) with CPU 99% -> 117%, seg1080 9.4 -> 9.9 s;
with frame threading it is a loss (seg4k 13.5 s at (6,2,1) vs 14.5 s at
(6,2,4)). Recording the ops copies the residual and the MC prediction on
the PARSE thread, which cancels what the workers take off it. Default
stays 1 (inline), where nothing is recorded at all.

Byte-exact: sha6 on seg1080/seg4k/seg4k_lr/palette at recon 1, at recon 4,
and at EC_AV1_THREADS=6 EC_AV1_FILTER_THREADS=2 EC_AV1_RECON_THREADS=4;
new gate `a_real_stream_reconstructs_identically_with_one_and_four_recon_threads`
on reelb_arf_witness (hidden ARF, 10-bit) and both palette/intrabc screen
witnesses.
perf(av1): recorded writes run inline at one reconstruction threadAhmet Kaan Gümüş · 9258b06
perf(av1): recorded writes run inline at one reconstruction thread

lane-wave1 step (ii), first half. Step (i) deferred every recorded
`ReconOp` to the end of its superblock, which cost +1.2% instructions and
+4.5% wall on 4K: the residual is written at parse and read back
cache-cold at replay.

`EC_AV1_RECON_THREADS` (default 1) now decides. At 1 the tile decoder
registers its three planes (`ReconInline`, dropped on every exit from the
tile including `?`) and every `push_*` performs its write on the spot,
with the residual still borrowed -- no record built, no queue, no
`to_vec`. Above 1 the queue behaves exactly as step (i) left it, for the
wavefront workers to come.

Measured against 69e1e50e, interleaved, same box: seg4k 607.12 -> 603.33 G
instructions:u (-0.62%), seg1080 189.81 -> 188.83 G (-0.52%); wall inside
the run-to-run noise on both (seg4k 30.5 vs 30.0-30.9 s, seg1080 9.2 vs
9.1-9.7 s). sha6 byte-exact on seg1080/seg4k/seg4k_lr/palette.
perf(av1): the recorded residual moves, and the record queue keeps its capacityAhmet Kaan Gümüş · d5fa0c1
perf(av1): the recorded residual moves, and the record queue keeps its capacity

Two costs the plain record/replay split paid for nothing: the three fused
coefficient readers copied a residual that is dead the instant it is
recorded (now moved through `push_intra_owned`/`push_mc_rect_owned`), and
`flush_recon` dropped the whole queue's allocation every superblock, so the
next one regrew it from zero (now swapped through `recon_spare`).

seg4k instructions:u 616.06 G -> 614.25 G, seg1080 193.18 G -> 192.37 G.
Byte-exact on all four gate inputs, unchanged.

2026-09-04

refactor(av1): entropy parse split from reconstruction inside the tile decoderAhmet Kaan Gümüş · 1499973
refactor(av1): entropy parse split from reconstruction inside the tile decoder

Step (i) of the decode-speed wavefront: a superblock's parsing no longer
writes (or reads) the frame's own planes. Every `PlaneBuf::reconstruct*`
call is recorded as a `ReconOp` on `FrameCtx::recon_ops` -- the resolved
argument tuple of the call it replaces -- and `flush_recon` replays the
queue, in push order, at the top of each superblock visit and at the end of
each tile. Same thread, same order, so the output is byte-identical, and
step (ii) can hand the replay to a superblock-row worker.

Three pixel dependencies that used to sit in the middle of parsing moved
with it:

- the CfL AC signal is no longer read at parse time (it wanted this block's
  own luma, which is now still queued); parse records the luma window as a
  `CflSrc` and the replay reads it back off the luma it has just written;
- the palette/intrabc prediction override no longer crosses into
  reconstruction through `FrameCtx::palette_pred` -- the push site takes it,
  in parse order, and carries it in the record, so `reconstruct`/
  `reconstruct_rect` take it as a parameter;
- `reconstruct_mc` folded into `reconstruct_mc_rect`, its only body.

Two parse-time pixel READS survive and flush ahead of themselves instead:
the intrabc source fetch and the interintra intra predictor. They are what
step (ii) still has to move, and naming them is the point of doing it this
way.

Byte-exact at 1 thread on seg1080/seg4k/seg4k_lr/palette_screen_witness.
perf(av1): parallelise the in-frame filter chain (deblock, CDEF, LR, film grain)Ahmet Kaan Gümüş · 63e598c
perf(av1): parallelise the in-frame filter chain (deblock, CDEF, LR, film grain)

`EC_AV1_FILTER_THREADS` (default 1, so the shipped behaviour is unchanged)
splits every post-decode filter stage across `std:🧵:scope` workers,
each along an axis whose writes are disjoint:

* deblock: 16-row bands for the vertical-edge pass (a vertical edge writes
  columns x0-7..x0+5 of its OWN 4 rows) and 16-column bands for the
  horizontal one (rows y0-7..y0+6 of its own 4 columns); the horizontal pass
  still runs after the whole vertical pass of that plane, spec 7.14 order.
* CDEF: mi ROW bands. Every unit reads only the pre-CDEF snapshots and
  writes its own 8x8 luma / 4x4 chroma square.
* loop restoration: restoration-unit row bands. The RU row walk is resolved
  into a row list first (a short remainder is swallowed by the previous
  row), and row `r`'s write range starts where row `r-1`'s ended.
* film grain: 32-pixel block rows. A row's noise comes from
  `Rng::line(y * 2, seed)` alone, and the one carry across rows -- the
  line buffers -- is rebuilt by replaying exactly ONE preceding row with
  its pixel writes suppressed.

`FrameCtx` stays `!Sync`; a worker gets `filter_ctx_copy`'s copy of the
fields the filter chain reads (bit depth, segmentation, superres, grain bit
depth). The aliasing that the band arithmetic proves and the borrow checker
cannot is confined to `par::Shared` (one `#[allow(unsafe_code)]` module).

Gated byte-exact: the new
`a_real_stream_filters_identically_with_one_and_four_filter_threads`
compares every output plane of a 10-bit CDEF+LR stream and of a film-grain
stream at 1 vs 4 filter threads, with per-stage firing counters asserted;
the four perf6 stream hashes are equal at 1 and at 4 filter threads.

seg4k 272 frames: 34.99 s -> 31.33 s (7.77 -> 8.68 fps), seg4k_lr 32.13 s ->
27.31 s at 4 filter threads (interleaved medians of 3, 12-core box under
load 6.5). Single-threaded cost: +1.6% instructions (607.34 G -> 617.18 G on
seg4k), mostly CDEF losing alias facts through the raw-pointer-derived
`&mut`.
perf(av1): run the inverse DCT network on a fixed-size scratch arrayAhmet Kaan Gümüş · e428d82
perf(av1): run the inverse DCT network on a fixed-size scratch array

Every butterfly, Hadamard and permutation of the spec's DCT network
indexes the 64-entry scratch with a computed index, and on a `&mut [i32]`
each one carried its own bounds check against a length the optimiser
could not see. The network now runs on `&mut [i32; 64]`, which discharges
them against the constant length; `inverse_dct` keeps its slice-taking
signature as a wrapper for callers outside the 2D driver, and `inverse_1d`
calls the fixed-size body directly.

Byte-exact on seg1080/seg4k/seg4k_lr/palette_screen_witness. seg1080
189.06 G instructions (was 190.19 G, -0.59%); seg4k 599.04 G (was
602.71 G, -0.61%).
perf(av1): broadcast the column transform when the row pass leaves one constant rowAhmet Kaan Gümüş · 7086b91
perf(av1): broadcast the column transform when the row pass leaves one constant row

The dominant inter residual is DC-only: the row pass then writes a single
non-zero row that is constant along its length, and the column pass runs
the same `inverse_1d` on the same input vector once per column, `w` times
over.

`inverse_transform_2d_typed_wh` now counts the non-zero rows the row pass
produced and whether the first of them is constant. When there is at most
one such row, one column transform is run and its output broadcast across
each output row -- byte-identical to the `w` transforms it replaces
(`inverse_1d` is a pure function of its input), and the per-column gather
goes with them.

Byte-exact on seg1080/seg4k/seg4k_lr/palette_screen_witness. seg1080
190.19 G instructions (was 193.75 G, -1.84%); seg4k 602.71 G (was
604.37 G, -0.28%).
perf(av1): reference planes borrow the DPB picture instead of copying itAhmet Kaan Gümüş · c42b240
perf(av1): reference planes borrow the DPB picture instead of copying it

`decode_inter_frame_tile_with_cdfs` built a `PlaneBuf` for the LAST
reference and for each of the eight `ref_frame_idx` slots by collecting
the picture's `u16` planes into fresh `Vec`s -- nine full-frame copies
per inter frame (about 166 MB per 4K frame), and 72% of the tile
function's own self time in a `perf annotate` of a 1080p decode.

`Picture`'s planes are already `u16`, so the `map(|&s| s as u16)` was a
memcpy with extra steps. `PlaneBuf::data` becomes `Cow<'a, [u16]>`: the
reference planes borrow, everything the decoder writes to stays
`Cow::Owned` (`to_mut()` at the fourteen mutating sites is free on an
owned buffer). Mutable plane parameters take `PlaneBuf<'static>` so the
`&mut` invariance never forces two output planes' lifetimes to unify.

Byte-exact on seg1080/seg4k/seg4k_lr/palette_screen_witness. seg4k
604.37 G instructions (was 607.45 G), 39.5 s wall (was 44.0 s);
seg1080 193.75 G (was 194.50 G), 12.4 s (was 13.5 s).
test(av1): two gate counters incremented and never read now report and assertAhmet Kaan Gümüş · 9c001a3
test(av1): two gate counters incremented and never read now report and assert

class [[gate-blind-to-feature]], two instances in stream.rs `mod tests`:

- the 16x16 1:4-partition gate's `rect_residual_refusals` counted attempts
  stopping on "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs
  rectangular residual coding" and never printed or asserted it. The refusal
  string still exists in decode.rs but is narrowed past this shape: the sweep
  now reaches it ZERO times at either depth (attempt 1, the recipe r5
  recorded stopping there, decodes). Reported in the summary and pinned at 0.

- the superres census's `other` was incremented and then panicked on in the
  same arm, so the CENSUS line -- the gate's whole output -- never printed
  when an unknown refusal fired. Unknown strings are collected instead,
  counted in the summary, and asserted empty after it.
perf(av1): a show_existing_frame output no longer stalls the parsing threadAhmet Kaan Gümüş · fada71e
perf(av1): a show_existing_frame output no longer stalls the parsing thread

The parser waited for the named slot's promise before emitting the picture,
and that wait was where the whole decode went: 7.9 s of an 8.8 s 1080p decode
and 18.9 s of a 23.3 s 4K one, measured with a counter around the wait. A
stalled parser dispatches nothing, so every worker drained behind it.

The output job now runs on a worker too (wait for the slot, synthesise grain,
send): the parser only copies the promise into the slots the header refreshes,
which needs no value at all. The wait still points at an earlier coded frame,
so the deadlock argument at `SlotPromise` is unchanged.

Frame decodes and output jobs are bounded separately (`threads + 2` each): an
output job is a wait plus a memcpy, so letting it hold a decode's budget just
idles a core (4K 18.7 s at 244% CPU sharing one bound, 17.7 s at 287% not).

seg4k 272 frames: 35.7 s at 1 thread -> 18.7 s at 4 (was 24.2 s before this
commit); seg1080 299 frames: 10.5 s -> 8.0 s (was 9.4 s). All twelve gate
hashes unchanged at 1, 2 and 4 threads.
chore(av1): clear the ec-av1 compiler warnings (300 -> 0 on the release lib)Ahmet Kaan Gümüş · 16efbd9
chore(av1): clear the ec-av1 compiler warnings (300 -> 0 on the release lib)

No arithmetic, control flow or public signature changes; the four perf6
decode hashes are byte-identical.

- gate-counter accessors and other test-only items carry
  `#[allow(dead_code)]` with the reason on the line (they are read from the
  `#[cfg(test)]` gates, which the plain lib build cannot see);
- `///` blocks sitting on `thread_local!`/macro invocations become `//`
  (rustc never attached them to anything);
- `cdf.rs` tables and the `InterpFilterKind` variants get a one-line doc;
- unused locals/params prefixed `_` where the value is genuinely unused;
  dead initializers dropped where the compiler proves every read is
  preceded by an assignment;
- `decode_key_frame_tile` import is now `#[cfg(test)]` (its only user).

Left standing on purpose, as findings rather than hidden warnings:
`stream.rs` census counters `other` and `rect_residual_refusals` are
incremented and never read back by their gates.
fix(av1): a non-skip palette block on a superblock-level strip lost its UV predictionAhmet Kaan Gümüş · 3a302e7
fix(av1): a non-skip palette block on a superblock-level strip lost its UV prediction

`decode_block_rect64` built the UV-palette prediction buffers and
installed them into the PALETTE_PRED slot only in its `skip` arm. The
non-skip arm reconstructed both chroma planes straight from
`reconstruct_rect`'s edge prediction, so a palette block with a real
residual on a 64x32/32x64 strip decoded its luma exactly and both
chroma planes wrong -- which is why the shape was refused by name
("corner-cropped luma coefficients not ported for palette", a
misattribution: the corner crop was never the defect).

FIRST BAD: testsrc2 128x128 10-bit cq55 `--tune-content=screen
--enable-palette=1 --min-partition-size=8 --sb-size=64 --tile-columns=1
--enable-tx-size-search=0`, the 32x64 strip at px=96: luma byte-exact,
U/V each 512 samples wrong over the block's 16x32 chroma footprint.
Installing the per-plane override right before each chroma
`reconstruct_rect`, exactly as the `skip` arm does, makes the frame
byte-exact against ffmpeg.

Class: an override slot installed on one arm of a skip/non-skip split.
Swept every palette+residual reconstruct path in decode.rs (rect, rect4,
rect_split, leaf_rect, leaf8, block, inter_block, inter_block8): this
was the only site missing the install.

The gate that documented the refusal now asserts zero refusals and a
non-zero superblock-strip palette count; inventory row deleted.
feat(av1): intrabc under a 128x128 superblock decodes by defaultAhmet Kaan Gümüş · c4ca926
feat(av1): intrabc under a 128x128 superblock decodes by default

`av1_find_ref_dv` (mvref_common.c) takes `mib_size` -- the sequence's
superblock size in mi units -- so under `use_128x128_superblock` the
fallback block vector is one 128-px superblock up, or 128 +
INTRABC_DELAY_PIXELS to the left on the tile's first superblock row.
`read_intrabc_dv` hardcoded the 64-px superblock, which is why the
frame-header refusal "intrabc under a 128x128 superblock" existed.

Reading it off `sb_mi_cur` lifts the refusal: all four arms of r33's
census (`--sb-size=128 --tune-content=screen --enable-intrabc=1`, both
`--enable-tx-size-search` settings, cq 30/45, 2x2-tiled 128x96 bars at
256x192) now decode pixel-exact against ffmpeg, so the r33 census is
replaced by the un-ignored witness it pinned, which additionally
asserts a non-zero decoded-intrabc-block count so a stream that stopped
using intrabc cannot make it vacuous. Inventory row deleted.
feat(av1): dependency-aware frame scheduling -- every non-key frame decodes on a workerAhmet Kaan Gümüş · fcddd9c
feat(av1): dependency-aware frame scheduling -- every non-key frame decodes on a worker

lane-thread2 could only dispatch LEAVES of the reference graph (shown,
non-key, refresh_frame_flags == 0), which on an aomenc pyramid stream is
almost nothing: seg1080 has 1 dispatchable frame in 299.

Each of the 8 reference slots now holds a `SlotPromise` instead of a value
when `threads > 1`: the parsing thread installs a frame's promise into every
slot its `refresh_frame_flags` names at DISPATCH time, in decode order, so
the next frame's dependencies are known without waiting for the previous one
to finish. A worker waits on exactly the promises of the slots its frame
reads (its `ref_frame_idx` entries -- references, primary CDFs, previous
segment map, reference order hints and spec 7.9's motion-field projection all
come from those), then decodes, publishes its clean picture/CDFs/motion
field/segment map, and only then synthesises film grain.

`setup_motion_field` therefore runs on the DECODING thread, inside
`RefSnapshot::take`, after those waits (it takes borrowed slots now, so no
motion field is copied to hand it over).

Deadlock argument, spelled out at `SlotPromise`: every wait points from a
later coded frame to an earlier one, so the wait graph is the reference DAG;
the parsing thread waits only for a `show_existing_frame` output and at the
in-flight bound (threads + 2), where the earliest in-flight frame always has
its producers already finished. A frame that errors or panics marks its
promise Failed, so no consumer waits for a value that never arrives.

Key frames and `show_existing_frame` headers stay inline. `threads == 1` is
untouched: no promise is ever created and the owned bank is the same one.

`leaf_frames_dispatched` -> `frames_dispatched`. The 1-vs-4-thread gate now
dispatches 39 of reelb_arf_witness's 40 coded frames (was 18) and 14 of
palette_screen_witness's 15 (was 0), and asserts more than half the shown
frames really ran on a worker.
test(av1): census the last three unproven refusals; pin the sb128-intrabc gapAhmet Kaan Gümüş · da8c1a6
test(av1): census the last three unproven refusals; pin the sb128-intrabc gap

The three intrabc refusals are the inventory's residue, and all three are now
measured against real aomenc streams rather than asserted:

* sb128 + intrabc is REACHED -- all four `--sb-size=128` exact-repetition
  screen arms code `use_128x128_superblock && allow_intrabc` and every one of
  them refuses by name. A capability gap, pinned with its first-bad recipe and
  a waiting (ignored) pixel-exact witness;
* a sub-8x8 leaf's `use_intrabc` symbol is read 38 times over two
  `--min-partition-size=4` arms and comes back 0 every time, frames exact;
* the intrabc var-tx tree is read for 5 blocks over four quantisers, every one
  resolving to a uniform leaf size, frames exact.

refusal inventory: 35 refusals / 32 proven -> 35 refusals / 35 proven.
test(av1): prove four refusals by enumeration and delete the dead palette (Y) guardAhmet Kaan Gümüş · 2937d25
test(av1): prove four refusals by enumeration and delete the dead palette (Y) guard

The two `decode_rect_split` shape refusals (rect chroma tables, split intra
strip transform unit) are enumerated over their five callers' footprint domain
at every tx depth, against both `match` tables read out of decode.rs itself.
The 128-root CfL/filter-intra/palette guard is enumerated over its four
symbols' own size gates. The palette (Y) guard was dead -- all eight
`read_intra_mode`/`read_intra_mode_rect` call sites hand the reader a real
ctx/cache pair -- so both arms are deleted and an audit keeps the invariant.
The superblock-strip palette refusal is registered as a witnessed capability
gap: its gate already hard-asserts a real screen stream reaches it by name.

refusal inventory: 36 refusals / 28 proven -> 35 refusals / 32 proven.
test(av1): a real stream decodes identically at 1 and at 4 threadsAhmet Kaan Gümüş · 5f3725c
test(av1): a real stream decodes identically at 1 and at 4 threads

Two real fixtures through `decode_stream_with_threads`, every sink call
compared (decode index, shown flag, all three planes).
`reelb_arf_witness.obu` is the arm that proves the parallel path -- 18 of
its 40 coded frames are leaves of the reference graph and really are
decoded off the main thread, and it carries hidden alt-refs, where
"output in coded order" and "output in worker completion order" differ;
`palette_screen_witness.obu` is the complement, an 8-bit screen stream
that dispatches nothing because every coded frame refreshes a slot. The
dispatch counter is asserted in both directions (18 and 0), so neither
arm can pass vacuously.
feat(av1): decode leaf frames on worker threads (EC_AV1_THREADS, default 1)Ahmet Kaan Gümüş · b3a78b4
feat(av1): decode leaf frames on worker threads (EC_AV1_THREADS, default 1)

`decode_stream_with_threads(data, threads, sink)` decodes the frames no
later frame can reference -- shown, non-key, `refresh_frame_flags == 0`,
the leaves of the reference graph -- on scoped worker threads, while the
main thread keeps parsing headers and decodes inline every frame that
does feed the banks. Each worker gets a fresh `FrameCtx` and a
`RefSnapshot` taken before dispatch (`Arc` clones of the DPB slots this
frame names, re-shared until the slot is overwritten; the DPB itself
stays owned `Picture`s, an `Arc` DPB measured slower single-threaded),
so nothing is shared. A `Reorder` queue keyed on the output position
hands `sink` every picture in coded order regardless of when a worker
finishes; in-flight leaves are bounded to `threads + 1`; a worker error
(panic included) aborts the stream with that error.

`decode_stream_with` reads `EC_AV1_THREADS` (default 1), so the whole
suite and every per-thread gate counter keep the serial semantics; the
four perf-gate streams hash identically at 1 and at 4 threads.
`stream::leaf_frames_dispatched()` (process-global, atomic) is the proof
a threaded run actually used the parallel path -- decode_probe prints it.
test(av1): witness the lifted 128-root screen-strip refusal with a real screen streamAhmet Kaan Gümüş · 0b83527
test(av1): witness the lifted 128-root screen-strip refusal with a real screen stream

r18's edge-forced 704x320 recipe re-encoded with `--tune-content=screen
--enable-palette=0 --enable-intrabc=0` DOES code 128-root HORZ/VERT halves
inside its inter frames -- r23's census missed them because it never tried
this source. Six encodes: cq 20/35/50 fire 15x 128x64 plus 8/10/6x 64x128
and decode all 15 frames byte-exact on every plane, and each one's
`--enable-rect-partitions=0` twin codes zero 128-root halves, which is what
says the shape is the coded HORZ/VERT arm.

cq20 is pinned as `fixtures/intra128_in_inter_screen_witness.obu` (119048
bytes, sha256 c84a493f...). The gate reads `allow_screen_content_tools` out
of the frame headers rather than trusting the encoder flag, so it cannot go
vacuous against the condition the deleted refusal named.
test(av1): un-ignore the intrabc TX_MODE_SELECT witness; lift the 128-root screen-strip refusalAhmet Kaan Gümüş · bbe0850
test(av1): un-ignore the intrabc TX_MODE_SELECT witness; lift the 128-root screen-strip refusal

Both arms of `an_intrabc_block_under_tx_mode_select_decodes_pixel_exact`
decode pixel-exact against ffmpeg, and the census gate's `tiled-square-cq45`
arm rejoins the ordinary table (it is no longer the hole the refusal was one
`&&` narrower than). r31's note that cq=45's intrabc blocks are all `skip`
was read off the desynced decode: corrected, cq=45 carries 3 unskipped of 10
and cq=30 carries 1 of 16, so both arms exercise both sides of the split and
both assert the var-tx counter fired.

Inventory: "an intrabc block under TxMode::Select" deleted (lifted); "a
HORZ/VERT intra strip in a screen-content frame" deleted -- r31's
enumeration (`av1_allow_palette`'s `bw > 64 || bh > 64` bound) is its proof
that a 128-root half codes no palette syntax at all, so a screen frame's
half is syntactically identical to the non-screen one the r18 witness
already decodes byte-exact. One residue registered: a var-tx tree resolving
to mixed leaf sizes, unreached by either arm.
refactor(av1): one coded frame decodes from a bank snapshot alone (decode_frame)Ahmet Kaan Gümüş · 1241afc
refactor(av1): one coded frame decodes from a bank snapshot alone (decode_frame)

The body of `decode_stream_with`'s loop between "frame header parsed" and
"reference banks updated" becomes `decode_frame(fctx, header, tile_bufs,
seq, snap, ..) -> FrameOutput`, a function of the bitstream plus a
`RefSnapshot` (the 8 DPB slots, the primary reference's saved CDFs and
segment map, spec 7.9's projected motion field, the reference order
hints) and `SeqFlags` (the sequence-header bits it needs). Nothing in it
reaches for the parser or for a bank any more, which is what lets a frame
be decoded off the parsing thread at all.

Pure refactor: the four perf-gate streams hash exactly as before
(seg1080 c2d4ef66, seg4k 3ac25ee5, seg4k_lr d197dbe0, palette 2bfb6839),
and the refusal ORDER is preserved deliberately -- the "primary_ref_frame
at a slot with no saved CDF state" error still fires inside
`decode_frame`, after the segmentation and 12-bit refusals, even though
the snapshot that carries the slot is taken before the call.
feat(av1): an intrabc block reads the INTER tx-size syntax under TX_MODE_SELECTAhmet Kaan Gümüş · 0674134
feat(av1): an intrabc block reads the INTER tx-size syntax under TX_MODE_SELECT

libaom's `parse_decode_block` dispatches `read_block_tx_size` on
`is_inter_block`, which counts an intrabc block (`blockd.h:373`). This
decoder read the intra `tx_depth` symbol for both cases, so:

* a SKIPPED intrabc block consumed a symbol libaom never wrote
  (`allowSelect = !skip || !is_inter` is false for it, spec 5.11.16), which
  desynced the tile from that block on -- the cq45 arm's first divergent
  pixel was the top-left of the superblock at (192,64), one whole block
  after the bad read (class `equal-range-means-unread`);
* an UNSKIPPED one was refused by name.

Both now follow the inter rule: skipped takes `maxRectTxSize` with no
symbol, unskipped reads `read_var_tx_size`. The intrabc luma prediction
moves onto the per-TU-windowed override slot (a split transform is the
first shape that can reach the multi-TU loop with one set), the 4x4 units
of an 8x8 intrabc leaf code off the inter ext-tx set, and every key-frame
block publishes `set_txfm_ctxs` when `allow_intrabc` -- the var-tx read is
the only intra-path reader of those bands and they were stuck at
`TXFM_CTX_INIT`.

A var-tx tree resolving to mixed leaf sizes is refused by name (the luma
reconstruct loop is a uniform grid); neither test stream reaches it.
refactor(av1): FrameCtx stays crate-private -- public signatures back to what they wereAhmet Kaan Gümüş · 1c71b70
refactor(av1): FrameCtx stays crate-private -- public signatures back to what they were

The FrameCtx refactor threaded `&crate::decode::FrameCtx` through 21 `pub fn`
signatures, which put a `pub(crate)` type in the crate's public API: external
callers of `Av1Encoder::encode` stopped compiling (tools/ec-bench).

`Av1Encoder` now owns its `FrameCtx` -- one per stream, not per frame, since
the inter-frame inheritance guards carry state across frames -- so `encode`
takes `(&mut self, picture)` again. `encode_key_frame`,
`encode_key_frame_with_modes` and `encode_sequence` keep their old public
signatures as wrappers over `pub(crate) *_with_ctx` inners that make the
context. The other 14 helpers that gained the parameter (intra/mc/warp/motion
predictors, `decode_key_frame_tile`) have no caller outside the crate and
become `pub(crate)`.

`Av1Encoder` is still `Send` (compile-time assert), but owning cells makes it
`!Sync`; nothing in the workspace shares one by reference.
test(av1): pin that no per-frame decode state is thread_local againAhmet Kaan Gümüş · 4c4f667
test(av1): pin that no per-frame decode state is thread_local again

The 38 names that moved into FrameCtx are asserted absent as `static` in
decode.rs/encode.rs/film_grain.rs, and the scratch pools + gate hit counters
are asserted still thread_local (they are per-thread by design; the gates
read the counters on the test thread).
refactor(av1): the 38 per-frame decode-state thread_locals become one FrameCtxAhmet Kaan Gümüş · b9a9498
refactor(av1): the 38 per-frame decode-state thread_locals become one FrameCtx

Every per-frame/per-stream decode state in ec-av1 lived in a thread_local!
static, so a decode was a function of the calling THREAD's history rather
than of the bitstream, and a worker thread saw empty state -- the blocker
for frame-parallel decoding.

All 38 (SB128, BIT_DEPTH, SUPERRES, CDEF_*, DELTA_Q_*/DELTA_LF_*,
CURRENT_Q_IDX, QUANT_DELTAS, the 9 SEG* maps, TX_SELECT_INTER,
REDUCED_TX_SET_INTER, ENABLE_FILTER_INTRA_INTER, PALETTE_PRED, INTRABC_*,
LUMA_TX_TYPE, INTRA_IN_INTER_MODE, INTER_STRIP_CHROMA, INTER_LAST_MC,
ENABLE_EDGE_FILTER, LAST_FRAME_WIDE_MARGIN, REACH_SB_PX, GRAIN_BIT_DEPTH)
are now fields of decode::FrameCtx, owned by decode_stream_with and threaded
as `fctx: &FrameCtx` down the decode call graph (~1200 call sites).

The fields keep the Cell/RefCell interior mutability the statics had, so
every read/write site is byte-identical and this is a pure ownership move;
Cell/RefCell also make FrameCtx !Sync on purpose -- one context per decoding
thread, never shared. The scratch pools, gate hit counters and trace
switches stay thread_local by design.
test(av1): no block footprint with a 128-pixel side can carry palette syntaxAhmet Kaan Gümüş · 552edc4
test(av1): no block footprint with a 128-pixel side can carry palette syntax

Two inventory entries.

The intrabc/TX_MODE_SELECT refusal is registered as proven by the new census
gate: it is measured, reachable, and a capability gap rather than a claim.

The 128-root screen-strip refusal ("palette syntax is consumed for square
blocks only") gets an enumeration that DISPROVES its premise: av1_allow_palette's
bound, as decode.rs spells it in palette_bsize_ctx_wh, rejects every footprint
with a 128-pixel side, so a screen-content frame codes no palette syntax on a
128x64/64x128 half and that half decodes exactly like the non-screen twin
already witnessed. The bound is asserted against decode.rs's own source, not a
copy, so moving the predicate breaks the test.

It is deliberately NOT registered as proven: the guarded condition is still
reachable, so this proves the lift safe, not the case absent -- and the lift is
a decode.rs edit plus a --sb-size=128 --tune-content=screen witness that codes a
128-root half, which no encode has produced yet.
test(av1): a real screen key frame codes an unskipped intrabc block under TX_MODE_SELECTAhmet Kaan Gümüş · c72e315
test(av1): a real screen key frame codes an unskipped intrabc block under TX_MODE_SELECT

The refusal "an intrabc block under TxMode::Select" was an unmeasured claim
about the encoder. Spec-wise its premise is open (tx_mode is forced to
ONLY_4X4 only under CodedLossless; allow_intrabc is an independent
screen-content condition) and libaom leaves it open too -- select_tx_mode
never consults allow_intrabc, and the only downgrade to TX_MODE_LARGEST is
txb_split_count == 0.

The census over 13 real --tune-content=screen --enable-intrabc=1 key frames
settles it: ordinary sources never present the premise (with tx-size-search on,
RD never picks intrabc and libaom clears allow_intrabc again; with it off the
frame is TX_MODE_LARGEST), but an exact-repetition source -- a 2x2 tiling of one
bar pattern -- codes allow_intrabc under TX_MODE_SELECT, and with the rect/1:4
partitions off its intrabc block lands on a square block unskipped and reaches
the refusal by name. Twelve arms decode pixel-exact against ffmpeg; exactly one
refuses. So the refusal is real and load-bearing, and the lift it names gets a
waiting witness gate (ignored until the intra path reads the inter var-tx tree).

The same recipe at cq=45 exposes the hole the refusal does NOT cover: those
intrabc blocks are all skip, pass the `&& !skip` guard and decode WRONG against
ffmpeg. That arm sits in the ignored gate with a note; narrowing the guard is a
decode.rs edit this round could not make.
fix(av1): a chroma deblock edge must read the group's BOTTOM/RIGHT miAhmet Kaan Gümüş · 58b009b
fix(av1): a chroma deblock edge must read the group's BOTTOM/RIGHT mi

`set_lpf_parameters` (libaom av1_loopfilter.c:245) indexes the mi grid for a
CHROMA edge at `scale | ((coord << scale) >> MI_SIZE_LOG2)` -- the bottom/right
mi of the co-located 8x8 luma group, the same cell that donates the group's
chroma prediction -- steps to the previous cell by `1 << ss` mi, and prices
`pu_edge` by testing the edge coordinate against the block size in the FILTERED
plane's own pixels (chroma bottoms out at 4 px).

This decoder dropped the `| 1`, stepped by one mi, and compared mi origins.
All three are invisible while every block is 8x8 or larger -- all four mi of a
group carry the same tx size, ref frame, skip flag and delta_lf -- and wrong
the moment cpu-used=4 splits a group into 4x4 luma blocks: the top-left mi's
filter level 12 fired filter4 on a U edge where the bottom/right block's level
8 leaves it alone. Class `context-read-from-one-cell`.

Measured on fixtures/superres_alltools_sb128_320x180.obu against the
instrumented libaom: post-deblock (EC_AV1_POSTDEBLOCK_DUMP) 1 wrong U sample in
frame 2 growing to 137 U + 131 V by frame 9 -> 0 in all 10 frames, and the
final output goes from 280 U + 331 V (max 9) to byte-exact vs ffmpeg. The
prediction path was never at fault: every prefilt frame was already exact, and
the frame-4 prefilt drift was the deblocked reference chain.

`a_superres_all_tools_sb128_stream_decodes_pixel_exact` is un-ignored.
revert "perf(av1): the DPB shares one Arc per picture instead of copying it per slot"Ahmet Kaan Gümüş · 173712b
revert "perf(av1): the DPB shares one Arc per picture instead of copying it per slot"

The wall-clock pairs that commit shipped (38.59 s -> 37.62 s) were noise: at
+-2% run-to-run on this box three pairs cannot resolve a 1% effect. Measured
again with `perf stat` (near-deterministic for this decoder) over six
interleaved runs each, the Arc form retires 0.15 G fewer instructions -- the
picture copies really do disappear, and page faults drop 401 k -> 142 k -- and
still burns ~1% MORE cycles on seg4k: 188.4 G median (main) vs 190.7 G. The
eight stable per-slot buffers the copies recycle are cheaper to walk than the
one buffer per decoded frame the shared form allocates and frees.

`perf stat -e cycles:u,instructions:u` on seg4k, alternating binaries, is the
instrument the rest of this lane used; wall clock is not.
perf(av1): the deblock edge derivation reads segmentation once per plane passAhmet Kaan Gümüş · bf70705
perf(av1): the deblock edge derivation reads segmentation once per plane pass

`edge_params` (2.9% self time at 4K, called for every 4x4 edge position) took
four thread-local reads (`SEG_MI_DIMS` and `SEG_IDS`, twice each) plus two
`SEG` borrows per call to look up two segment ids and their `SEG_LVL_ALT_LF_*`
deltas. `segmentation_enabled` is a per-frame flag, so it is read once per
plane pass now: with it clear every segment id is 0 and no LF feature can be
active, so both lookups are skipped and the levels are identical.

Small: seg4k pair deltas 0.20/0.16/0.04 s, medians 35.31 s -> 35.27 s.
Byte-exact on all four inputs.
perf(av1): sgrproj box sums slide down the grid as well as across itAhmet Kaan Gümüş · c80d9e9
perf(av1): sgrproj box sums slide down the grid as well as across it

`compute_ab` (3.6% self time at 4K, the remaining loop-restoration cost now
that Wiener runs on the MC kernels) recomputed each grid row's column sums
from scratch, so every source sample was read -- through `lr_sample`'s
stripe-boundary test, the expensive part -- (2r+1) times. Consecutive grid
rows share all but two source rows: subtract the row leaving the window, add
the one entering it. The horizontal sum slides the same way, one add and one
subtract per grid point instead of 2r+1 adds.

Exact, not approximate: i64 addition is associative and subtracting a row
that was added back is exact, and `lr_sample` is a pure function of its
(row, col).

Charter asked for an AVX2 kernel over the per-pixel A/B arithmetic; the
sliding window removes strictly more work in a quarter of the lines, so it
took that rung first. seg4k_lr 35.49 s -> 35.02 s, seg4k 36.45 s -> 36.27 s
(medians of 3 interleaved pairs each); byte-exact on all four inputs.
perf(av1): AVX2 film-grain chroma rowsAhmet Kaan Gümüş · 8d96c7f
perf(av1): AVX2 film-grain chroma rows

The chroma arm of spec 7.18.3.5's `add_noise_to_block` was the last scalar
half of grain synthesis (`add_noise_to_block` 4.6% self time at 4K next to the
already-vectorised luma kernel's 2.4%): one loop doing both planes with the
loop-invariant `apply_cb`/`apply_cr` tests inside it.

Split per plane into `chroma_noise_row` (scalar reference) plus an AVX2 kernel
that does 8 chroma samples at a time -- the 4:2:0 luma pair sum is one
`vpmaddwd` against ones, the LUT read the same clamped gather as the luma
kernel. `simd_matches_scalar_chroma_noise_row` pins the pair over every grain
bit depth, both clip ranges, three multiplier triples (including
`chroma_scaling_from_luma`'s 0/64/0) and lengths either side of the vector
step.

seg4k 36.70 s -> 35.88 s (medians of 3 interleaved pairs); byte-exact on
seg1080/seg4k/seg4k_lr/palette.
perf(av1): the DPB shares one Arc per picture instead of copying it per slotAhmet Kaan Gümüş · 68c67bf
perf(av1): the DPB shares one Arc per picture instead of copying it per slot

`refresh_frame_flags` names up to eight reference slots, and each one took a
full `Picture` copy -- ~25 MB at 4K, so a key frame alone memcpy'd ~200 MB and
every inter frame paid one copy per slot it refreshed. `perf --call-graph fp`
attributes 2.2 of the 5.7% `memmove` self time to `decode_stream`'s own frame
(the slot stores), the rest to the tile decode, `decode_inter_block`, loop
restoration and the per-TU transform buffer.

The slots now hold `Arc<Picture>`: one allocation per decoded frame, pointer
copies per slot, and the shown-frame sink borrows either the grain-synthesised
picture or the stored one instead of moving a copy through `output`.

seg4k 38.59 s -> 37.62 s (medians of 3 interleaved pairs); byte-exact on
seg1080/seg4k/seg4k_lr/palette.
perf(av1): Wiener restoration runs on the motion-compensation kernelsAhmet Kaan Gümüş · 91d30fe
perf(av1): Wiener restoration runs on the motion-compensation kernels

`apply_loop_restoration_plane` was 6.3% of a 4K decode's self time, and
Wiener owns most of it: on the two 4K probe inputs Wiener units cover
82% and 95% of all restored pixels (instrumented, then reverted).

Its two passes ARE `mc.rs`'s: a 7-tap `i16` convolution over contiguous
samples rounded by `Round2(_, 3) == INTER_ROUND_0`, then a 7-tap `i32`
one rounded by `Round2(_, 11) == INTER_ROUND_1`. Zeroing an eighth tap
makes both `mc::hpass_contig`/`mc::vpass_row` calls exactly -- so this
reuses those AVX2/SSE kernels rather than growing a third copy of the
same convolution.

That also removes the horizontal pass's real cost: it called
`lr_sample` (stripe-boundary substitution plus a column clamp) once per
tap, seven times per output. Which buffer and row a sample comes from
depends only on the row, so `lr_sample` is now that resolution
(`lr_src_row`) plus its clamp, and the pass resolves it once per row and
convolves straight over the plane -- only a unit touching the plane's
left or right edge still copies through the clamp.

4K decode 40.6 s -> 35.7 s and the LR-heavy 4K input 40.1 s -> 34.1 s
(interleaved medians of 3 against this lane's base), byte-exact on all
four probe inputs.
perf(av1): AVX2 deblock kernel -- 4K decode 40.6 s -> 38.1 sAhmet Kaan Gümüş · 1332eb0
perf(av1): AVX2 deblock kernel -- 4K decode 40.6 s -> 38.1 s

`filter_edge` was 8.0% of a 4K decode's self time and `edge_params`
another 3.5%; `perf annotate` puts the cost on the per-tap strided
addressing (`leaq`/`movzwl` pairs), not the arithmetic, which is why
lane-perf7's three scalar restructures all measured neutral-to-worse.

This filters 16 edge lines at once in 16-bit AVX2 lanes: the same masks,
the same `filter4` centred-domain clamps and the same `filter6`/`8`/`14`
weighted sums (their weights total 8 or 16, so a sum of 12-bit samples
stays inside `u16` and the rounding shift is the unsigned one). A
horizontal edge's taps are whole row segments, loaded directly; a
vertical edge's are consecutive samples, so 16 rows are loaded as a
16x16 tile and transposed through the unpack ladder.

Both passes now iterate the edge's own direction innermost so four
consecutive 4-sample groups can share one kernel call. The swap is
order-preserving: a group's writes reach only along its own edge, so
the dependence stays on the outer loop's ascending order. Where the
four groups' `edge_params` disagree, or the edge sits too close to a
plane border for the kernel's window, the scalar `filter_edge` still
runs -- it remains the reference, and a property test pins the kernel
to it sample-exact over every bit depth, filter length, level,
sharpness and both directions.

Byte-exact on all four probe inputs (1080p, 4K, 4K+LR, palette).