forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 2a2adbabb7cf5c876fc67adeb705e5b6f8efdd0dFiltered to crates/ec-av1/src/decode.rsClear filter

2026-09-05

perf(av1): deblock -- masked transform-alignment gate, inlined edge_params head, running-sum filter14Ahmet Kaan Gümüş · 2a2adba
perf(av1): deblock -- masked transform-alignment gate, inlined edge_params head, running-sum filter14

Three measured steps on the loop filter, all byte-exact (the four gate
streams hash identically at 1, 4 and 16 threads):

1. `edge_params`' transform-alignment test was `coord % cur_tx`, a hardware
   `divl` whose result test carried 10.7% of the function's samples;
   `cur_tx` is a power of two, so it is a mask. -0.29% instructions.
2. That gate rejects most 4-pixel edge groups, so it is now inlined into the
   deblock loops and only survivors pay the call and the register-spilling
   prologue of `edge_params_body`. -1.83%.
3. The AVX2 kernel's wide-filter rows took their weights as slices, leaving a
   branch and a weight load per tap (`testl`/`je`/`movzwl` were 34% of the
   kernel's samples): `filter6`/`filter8` rows are unrolled with const
   weights, and `filter14`'s twelve rows become a running sum over the
   constant row-to-row deltas (168 tap operations -> 44). -1.50%.

seg4k at one thread: 553.30 -> 533.44 G instructions:u (-3.59%); the deblock
share of the 4K profile falls from ~7.3% to ~6.0% and the kernel itself from
4.00% to 2.52%. `deblock_simd_kernel_matches_the_scalar_filter` already pins
the kernel against the scalar `filter_edge` at 8/10/12-bit over every length,
level and sharpness.
perf(av1): coefficient reading -- buffered msac bit window, static scan tables, no per-block level allocationAhmet Kaan Gümüş · 8841aa8
perf(av1): coefficient reading -- buffered msac bit window, static scan tables, no per-block level allocation

The frame thread's coefficient path paid four avoidable costs per transform
block, all bit-exact to remove:

* every symbol's renormalisation assembled five bytes out of the payload and
  shifted twice; `SymbolDecoder` now keeps a 64-bit window refilled once per
  eight bytes (`bulk_bit_reads_match_the_per_bit_form` still pins `f(n)`
  against the per-bit form, through the new `seek_bits`);
* `symbol_fixed`/`symbol`/`f`/`update_cdf` were out-of-line across codegen
  units, and the CDF walk indexed a slice the bounds checker could not see
  the end of -- inlined, and the walk iterates instead;
* `default_scan` allocated a `Vec` and regenerated the whole anti-diagonal
  walk on every block: one table per side (4/8/16/32), built once;
* `read_coeffs` divided by the transform side per coefficient (always a power
  of two) and allocated its level buffer per block.

instructions:u on the 4K segment at one thread: 570.76 G -> 559.11 G (-2.0%).
All 12 gate hashes unchanged at 1/4/16 threads; lib suite 500 passed, 27
ignored.
perf(av1): mi-grid writers fill whole rows and MiInfo carries u8 block sidesAhmet Kaan Gümüş · 77576dd
perf(av1): mi-grid writers fill whole rows and MiInfo carries u8 block sides

The mode-info bookkeeping the parse thread runs per coded block wrote its
grids one 4x4 cell at a time, each write a bounds check: `fill_lf_grid_rect`
(6 grids), `fill_skip_grid_rect` (4), `record_uv_mode_mi`, `record_mi_rect`
and `record_inter_rect_mi`. A mi rect's cells are contiguous inside one grid
row, so each of those rows is one `fill_span` -- same cells, same values,
including the out-of-range drop the per-cell `get_mut`/`break` did.

`record_mi_rect`'s per-cell `array::from_fn` predicate is monotone in the
plane bound (`bound[1] == bound[2] >= bound[0]`), so the left/above neighbour
state is three contiguous runs, not a branch per cell.

`MiInfo::size`/`size_h` are 4x4-cell counts that never exceed 32; as `u8`
they take `Option<MiInfo>` from 48 to 28 bytes, shrinking both the per-frame
grid fill and the mv-stack scans' cache footprint.

Byte-exact: all 12 gate hashes unchanged. instructions:u on the 4K segment
570.74 G -> 565.02 G (-1.00%).
perf(av1): the output crop and the post-deblock snapshot stop copying whole planesAhmet Kaan Gümüş · 36f0c53
perf(av1): the output crop and the post-deblock snapshot stop copying whole planes

Two bulk copies on the frame thread's serial tail, both of them avoidable:

* The output crop rebuilt every plane row by row whenever the padded
  coding surface was bigger than the visible frame. A 4K 3840x1608 frame
  is superblock-aligned in WIDTH and padded only in HEIGHT, so its padded
  buffer's stride already equals the visible width and the "crop" is a
  pure truncation of the buffer we already own. `crop_owned` takes the
  plane by value and truncates in that case, falling back to the old
  row-by-row copy for a genuinely narrower plane.

* The post-deblock snapshot loop restoration reads cloned all three
  planes. Spec 7.17.2's stripe boundary substitution only ever reads the
  two rows above and the two below each interior stripe boundary
  (`restoration::lr_src_row` resolves every out-of-stripe row to
  `stripe_v_start-1/-2` or `stripe_v_end/+1`), and stripes are
  `64 >> ss_y` rows offset by `RESTORATION_UNIT_OFFSET`, so the snapshot
  now copies 4 rows in 64 into a pooled buffer whose other rows keep a
  previous frame's samples -- initialised values no reader reaches.

Byte-exact: seg1080/seg4k/seg4k_lr/palette hashes unchanged at 1, 4 and
16 frame threads (the last with 4 filter + 2 recon threads).
perf(av1): remove four per-block allocation sites from the parse pathAhmet Kaan Gümüş · d4c852e
perf(av1): remove four per-block allocation sites from the parse path

lane-alloc. A tracking global allocator (new `alloc_probe` example: size
histogram plus a sampled backtrace per 512 allocations, with line numbers)
ranked the decoder's allocation sites on the 4K segment -- 83.6 M
allocations over 272 frames. Four of the top sites are removed here:

* `find_samples` built a `String` per warp block (`format!("{mi_row},
  {mi_col}")` plus the env snapshot's own `String` clone) to compare against
  an unset debug flag; the OBMC blend did the same for `EC_MCB`. Both now
  sit behind the per-call-site `env_flag!` load.
* `Edges::build` allocated four vectors per intra prediction (collect,
  grow, then a second buffer to prepend the corner); it builds each edge
  once, corner first. `directional`'s two working buffers were a copy of
  those same vectors, so it takes the `Edges` by value instead.
* `obmc_neighbour_pred` allocated its prediction buffer per neighbour per
  plane; the caller now keeps one buffer per plane for the whole block.
* The MV stacks and the OBMC neighbour lists are capped (8 entries /
  `max_neighbors`), so they reserve once rather than growing and memcpying
  up to four times.

seg4k at one thread: 601.657 -> 599.329 G instructions:u (-0.39%, perf stat
-r 3). Reverting only the reserve step measured 600.014 G, so it stays
despite raising the raw allocation COUNT (an empty stack now allocates):
the saved reallocation memcpys outweigh the extra tcache hits.

Byte-exact: sha6t hashes equal the reference for all four streams at
threads 1, 4 and 16 (the last with FILTER_THREADS=4 RECON_THREADS=2).
perf(av1): recon workers pick per superblock ROW, not raster orderAhmet Kaan Gümüş · bdf81cd
perf(av1): recon workers pick per superblock ROW, not raster order

At EC_AV1_RECON_THREADS > 1 the wavefront handed out jobs from one FIFO in
raster order, so N workers popped N CONSECUTIVE superblocks of the SAME
row -- which the wavefront rule serialises (a job waits on its own left
neighbour). The workers then all blocked on one dependency chain and the
tile ran near-serial: 4 workers, 155% CPU, 1.23x.

The queue is now per superblock row and a worker takes the lowest row whose
front job's dependencies are met, which is the only job of that row that can
be runnable; deadlock-freedom is unchanged (the globally oldest job is always
runnable once no worker is active). EC_AV1_WAVE_STATS=1 dumps the per-worker
busy/wait/jobs accounting, the parse-thread time between submits and the
barrier/drain waits, cumulatively, on every tile.

seg4k (frame,filter,recon)=(1,1,4): 24.43 s -> 22.90 s, the parse-side
barrier wait 1917 ms -> 123 ms over the same 6712 barriers. All 12 sha6t
hashes exact at (1,1,1), (1,1,4) and (16,2,2).
refactor(av1): name the pool worker threads by submitting class; drop two dead recordersAhmet Kaan Gümüş · 9a4d798
refactor(av1): name the pool worker threads by submitting class; drop two dead recorders

The persistent pool is thread-local and shared by every class a thread
submits, so a worker's name is the class that grew the pool for it:
`ec-av1-frame` (stream.rs), `ec-av1-recon` (the tile wavefront) and
`ec-av1-filter` (par::run_bands), plus its index. The test-only ffmpeg
and aomenc stdin writers in decode.rs/stream.rs get names too.

Also deletes `push_intra_owned`/`push_mc_rect_owned`, dead since the
wavefront lanes, and replaces a `drop` of a `Copy` `Shared` in
film_grain.rs with `let _ =`, which was the last ec-av1 warning.

Byte-exact: the four perf6 inputs hash unchanged at default and at
(6,2,4) threads.
perf(av1): persistent worker pools instead of per-frame and per-tile threadsAhmet Kaan Gümüş · a02c7bd
perf(av1): persistent worker pools instead of per-frame and per-tile threads

Every threaded stage spawned its threads per unit of work: one
`thread::scope` per filter stage per frame, `EC_AV1_RECON_THREADS`
workers per tile, one frame worker per coded frame -- 2363 distinct
threads in a 13 s 4K decode. What died with each of them was the
`thread_local!` decode scratch (planes, rows, dq, mc, wiener, sgr),
re-allocated and re-faulted on every new thread.

`par::Batch` submits jobs to a pool owned by the submitting thread
(thread-local, joined at thread exit), growing to `busy + queued` so a
job never queues behind a blocking one -- the recon wavefront's workers
block on their own dependencies. `Batch`'s drop waits every job out and
re-raises the first panic, which is `thread::scope`'s contract minus the
spawns, so the three call sites keep their borrows.

Byte-exact: all 12 sha6t hashes at (frame, filter, recon) = (1,1,1),
(6,2,4) and (1,1,4). seg4k (6,2,4) best-of-2 interleaved: 13.02 s -> 12.24 s.
perf(av1): a deferred transform unit takes its window on the worker, not a strided residualAhmet Kaan Gümüş · 3d6af60
perf(av1): a deferred transform unit takes its window on the worker, not a strided residual

lane-wave4: recording a unit's prediction as an offset into the block made
the worker lay its residual out at the block's stride again (a 4x4 unit of a
64-wide block meant a 64x64 i32 grid). The residual stays dense and the
worker copies the w x h window out of the block prediction instead -- the
copy the parsing thread used to make. Byte-exact, wall unchanged.
perf(av1): a compound inter block predicts on the worker tooAhmet Kaan Gümüş · 52da7db
perf(av1): a compound inter block predicts on the worker too

lane-wave4: the compound arm's whole prediction -- both references, the
wedge/diffwtd/distance blend, all three planes -- becomes the same deferred
closure the single-reference arm got. A compound block reads neither
motion_mode nor interintra, so its build has nothing that must stay on the
parsing thread.
perf(av1): a single-reference inter block predicts on the worker that reconstructs itAhmet Kaan Gümüş · 4a7d65a
perf(av1): a single-reference inter block predicts on the worker that reconstructs it

lane-wave4: the whole-block prediction of `decode_inter_block`'s
single-reference arm (motion compensation + warp + the interintra blend) is
now a closure instead of a buffer. At one reconstruction thread the parse
thread runs it at the same point as before; at EC_AV1_RECON_THREADS > 1 it
is pushed as a `ReconOp::Pred` and runs on the wavefront worker, whose
transform units then read their windows out of it -- so mc no longer runs on
the parsing thread there. The interintra blend goes with it, which retires
that arm's `flush_recon` barrier: the wavefront rule already guarantees the
block's own edges. OBMC and the sub-8x8 chroma piece still build inline
(both can fail, and a recorded op cannot report it).

Also fixes the inline path stage 1 broke: a window handed over at the
block's stride was reconstructed against a dense residual.
refactor(av1): a recorded inter write names where its prediction comes fromAhmet Kaan Gümüş · 8aa7db1
refactor(av1): a recorded inter write names where its prediction comes from

lane-wave4 step 1: `ReconOp::Mc` carries a `PredSrc` (an owned window, or
an offset into the block prediction a worker builds) and the inter readers
take a `Pred` instead of a slice, so a prediction can be deferred without
touching every call site again. No deferral yet: every site passes
`Pred::dense`, which is the same window copy as before.
perf(av1): a recorded inter write carries its own transform unit, not the blockAhmet Kaan Gümüş · 89f1aa3
perf(av1): a recorded inter write carries its own transform unit, not the block

reconstruct_mc_rect reads exactly rows 0..h and columns 0..w of the two
buffers, so recording the whole block prediction copied 64*64 samples on
the parsing thread for a 4x4 unit. The record now holds that window
densely at stride w, and the deferred residual is produced dense to match
(TxParams::stride = 0) -- the same numbers in the same places.

Byte-exact at recon 4 on all four probe inputs.
perf(av1): the inverse transform travels with the recorded write, not its resultAhmet Kaan Gümüş · c027c27
perf(av1): the inverse transform travels with the recorded write, not its result

A recorded reconstruction carried the already-transformed residual, so the
parsing thread ran the dequantization and the inverse transform for every
transform unit before a recon worker ever saw it. The three fused
coefficient readers now record TxParams + the coded grid instead
(ReconOp::{Intra,Mc}.residual is a Residual: Done or Coeffs), and
TxParams::run is the single copy of the produce-the-residual code both
paths call -- so at EC_AV1_RECON_THREADS=1 it still runs at the push site,
unchanged, and above 1 it runs on the worker.

Byte-exact at recon 1 and 4 on all four probe inputs (seg1080 c2d4ef66,
seg4k 3ac25ee5, seg4k_lr d197dbe0, palette 2bfb6839).
test(av1): the direct-call NEARMV gate replays its own recorded writesAhmet Kaan Gümüş · c28f320
test(av1): the direct-call NEARMV gate replays its own recorded writes

Left red by step (i) (ace5dcb9), which this lane inherited: the gate calls
the inter block decoder itself and reads the luma plane back, but a direct
caller records its writes now -- only the tile decoder replays them -- so
it compared an untouched plane against the reference prediction. It is
the one test in `ec-av1 --lib` in that shape (499 passed, this one
failed).
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): CDEF band body as a real function, so its plane writes are noaliasAhmet Kaan Gümüş · 065f637
perf(av1): CDEF band body as a real function, so its plane writes are noalias

The CDEF row band ran as the body of the `run_bands` closure, where the
three destination planes are `&mut PlaneBuf` derived from a `par::Shared`
raw pointer in the same scope as the `src_*` pre-CDEF snapshot reads. LLVM
cannot tell those apart, so every tap re-loaded plane fields and snapshot
samples it had just read. Lifting the band into `cdef_band`, whose planes
and snapshots arrive as distinct reference parameters, restores the alias
facts; the strength lookup moves in with it (the grid arrives as `&[u8]`).

Pure restructuring -- same walk, same order, same arithmetic.

seg4k instructions:u 607.187 G -> 601.987 G (-0.86%), wall median of 3
30.50 s -> 30.27 s; seg1080 189.813 G -> 189.790 G, wall 9.23 s -> 9.28 s
(noise). Byte-exact: all four gate streams hash identically at
EC_AV1_FILTER_THREADS=1 and =4.
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): 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).
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.
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): 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.
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.
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.
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.
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): 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).
perf(av1): AVX2 CDEF filter -- 4K decode 47.1 s -> 41.2 sAhmet Kaan Gümüş · e2f820e
perf(av1): AVX2 CDEF filter -- 4K decode 47.1 s -> 41.2 s

`cdef_filter_block` was 13.1% of a 4K decode's self time: a scalar loop
doing ~17 bounds-checked window reads, four `constrain` calls and a
min/max clamp per output sample.

The kernel does the same arithmetic 16 samples (two rows) at a time in
16-bit AVX2 lanes -- the same primary/secondary taps, the same
`sign(diff) * clamp(threshold - (|diff| >> shift), 0, |diff|)` (one
`_mm256_sign_epi16` reproduces `signum`, zero included), the same
exclusion of the `CDEF_VERY_LARGE` out-of-frame sentinel from the max
clamp (masking it to 0 cannot win a max seeded with a non-negative
sample), and the same `x + ((8 + sum - (sum < 0)) >> 4)` rounding.
16-bit lanes are exact for every value the filter sees: window samples
are in [0, 0x4000], so a tap difference fits in `i16` and the
tap-weighted sum is bounded by 24 * the threshold (at most 15 << 4).

The scalar form stays the reference (`cdef_filter_block_scalar`, the
only path on non-x86_64 and pre-AVX2 CPUs) and
`cdef_simd_kernel_matches_the_scalar_filter` pins the pair over the
whole domain: both block shapes, all 8 directions, every enable pair,
the 8/10/12-bit strength/damping ranges and windows that mix real
samples with sentinel borders.

Byte-exact on all four gate inputs (seg1080, seg4k, seg4k_lr, palette).
seg4k interleaved medians 3x: 47.08 s -> 41.23 s (-12.4%, 5.78 ->
6.60 fps); 1080p 11.00 -> 10.95 s.
perf(av1): resolve the deblock kernels' bit-depth reads once per callAhmet Kaan Gümüş · 801fe73
perf(av1): resolve the deblock kernels' bit-depth reads once per call

`filter4` runs once per deblocked sample and read the thread-local bit
depth nine times doing it -- once for its centring constant and once
inside each of `sclamp`'s eight calls -- while `filter_edge` re-read it
through `sample_max()` on all fifteen of its stores. Both are constant
for the whole call; same bounds, read once.

Byte-exact on seg1080/seg4k/seg4k_lr/palette; 4K 60.53 s -> 48.33 s
(1.252x, from 1.221x at the previous step), 1080p 10.74 s.
perf(av1): pool the post-filter plane buffers instead of allocating per frameAhmet Kaan Gümüş · 583ed90
perf(av1): pool the post-filter plane buffers instead of allocating per frame

Each frame allocated a pre-CDEF snapshot of all three planes, a
post-deblock snapshot of all three when loop restoration is active, and
one fresh `cdef.to_vec()` destination per restored plane: ~25 MB of
multi-megabyte `Vec`s per frame at 4K, every one of them served by a
fresh `mmap` whose pages then fault in on first touch, and returned to
the allocator at the end of the frame. `PLANE_SCRATCH` hands the same
buffers back out; `apply_loop_restoration_plane` now fills a caller-owned
`out` buffer (refilled from `cdef` on entry, same "never filter in place"
contract) which the caller swaps into the plane and returns to the pool.

Byte-exact on seg1080/seg4k/seg4k_lr/palette; 4K 60.48 s -> 49.55 s
(1.221x, from 1.156x at the previous step), LR-heavy 4K cut 59.95 s ->
54.16 s, 1080p 11.14 s. Peak RSS 417 MB -> 466 MB, the retained pool.
perf(av1): CDEF filters a gathered window with a resolved damping shiftAhmet Kaan Gümüş · 126001f
perf(av1): CDEF filters a gathered window with a resolved damping shift

Every tap read went through a closure that re-derived the frame-bounds
test (four compares plus the stride multiply) for each of a pixel's ~17
reads, and `constrain` recomputed its damping shift -- a `leading_zeros`
and a branch -- twice per tap. `cdef_gather` now lifts a unit's whole
footprint (its samples plus the two-pixel `CDEF_DIRECTIONS` ring) into a
reused scratch window once, contiguously for the interior case, and both
the direction search and `cdef_filter_block` index that; the shift is
resolved once per block by `cdef_constrain_shift`. A unit whose four
strengths are all zero now skips the gather and the direction search
outright -- `dir`/`var` are only ever consumed through a strength.

Byte-exact on seg1080/seg4k/seg4k_lr/palette; 4K 59.40 s -> 51.37 s
against the same-session base (interleaved medians of 3, 1.156x vs the
previous step's 1.140x), 1080p 10.72 s.
perf(av1): inter reconstruction adds a row at a timeAhmet Kaan Gümüş · 180e079
perf(av1): inter reconstruction adds a row at a time

`PlaneBuf::reconstruct_mc_rect` re-derived `row * side + col` twice and
`(y + row) * self.width + x + col` once per sample, with a bounds check
on each of the three buffers. `side` is the prediction/residual stride
and `self.width` the plane's, so the three row bases are now taken once
per row and the row slices zipped; the arithmetic on each sample
(`clamp(0, sample_max())`) is untouched, as is the bottom/right overhang
truncation above it.

Byte-exact: EC_PROBE_OUT16 sha256 unchanged on a 1080p and a 4K segment
and on `palette_screen_witness.obu`. Interleaved medians against the
parent build alone (3 pairs, 1080p): 11.17 s -> 11.06 s.
perf(av1): intra DC edge extension without allocation; pre-CDEF planes cloned only when loop restoration runsAhmet Kaan Gümüş · bea828c
perf(av1): intra DC edge extension without allocation; pre-CDEF planes cloned only when loop restoration runs

Two allocation sites the 1080p profile put at ~1.3% of self time between
them, neither of which any pixel depends on:

* `intra::dc` built one `Vec<u16>` per existing edge per intra block only
  to sum it. The replication libaom's `build_intra_predictors` performs is
  never indexed here, so the extended edge becomes a sum:
  `sum(samples[..n]) + last * (want - n)`, the same integers in the same
  order of magnitude, and the square/rect divisors come from `bw`/`bh`
  directly rather than from the (equal) vector lengths.
* Both frame paths cloned all three planes before CDEF as the loop
  restoration source, and `apply_loop_restoration_plane` then copied each
  plane again to return it unchanged when its restoration type is `None`.
  The clone is now taken only when some plane's type is not `None` with a
  non-zero unit size, i.e. exactly when a restored sample can differ.

Byte-exact: EC_PROBE_OUT16 sha256 unchanged on a 1080p and a 4K segment
and on `palette_screen_witness.obu`. Interleaved medians (3 pairs 1080p,
one pair 4K): 11.82 s -> 11.65 s at 1080p, 64.91 s -> 60.86 s at 4K.
fix(av1): superres upscales between CDEF and loop restoration, not after LRAhmet Kaan Gümüş · 08a2542
fix(av1): superres upscales between CDEF and loop restoration, not after LR

Spec 7.16 (libaom `superres_post_decode`, called in `decodeframe.c` between
`av1_cdef_frame` and `av1_loop_restoration_filter_frame`): the horizontal
upscale runs after CDEF and BEFORE loop restoration. This decoder ran the
whole filter chain on the downscaled frame and upscaled last, in `stream.rs`,
so under superres loop restoration filtered downscaled pixels through a unit
grid sized from the downscaled width.

Three widths were wrong, all in the same class (`wrong-stage-width`: each
plane width in the filter chain is either the downscaled one -- deblock, CDEF
and the mi grid -- or the upscaled one -- everything loop restoration does):

* `RestorationGrid::new` sized its unit counts from `frame_width`; libaom
  sizes them with `av1_get_upsampled_plane_size` (upscaled width).
* `read_lr`'s unit corners divided downscaled mi columns by the unit size;
  `av1_loop_restoration_corners_in_sb` scales by `superres_denom /
  SCALE_NUMERATOR` (`mi_to_num_x`/`denom_x`) when the frame is scaled.
* The pixel filters ran on downscaled planes. Both the post-CDEF frame and
  the post-deblock frame LR substitutes at stripe boundaries are now upscaled
  first (libaom's `save_deblock_boundary_lines` runs
  `av1_upscale_normative_rows` over its saved rows when the frame is scaled).

`decode::set_superres` carries the state per frame, like `set_bit_depth`, and
the reconstruction buffer's own real columns past `frame_width` stay the
upscale's right margin -- the `take_last_frame_wide_margin` hand-off to
`stream.rs` is gone with the late upscale it fed.

Gate: `fixtures/superres_kf_cdef_lr_64x64.obu`, a real aomenc key frame with
CDEF and loop restoration under `--superres-denominator=12`, was 1873 wrong
samples (max 7) and is now byte-exact against ffmpeg.

Residual, pinned ignored: `fixtures/superres_alltools_sb128_320x180.obu` (10
frames, all tools, sb128, cpu-used=4) went from 37315 wrong samples/max 171
to 1620/max 11 -- what is left is CHROMA ONLY (luma exact in all 10 frames)
and survives `--enable-cdef=0 --enable-restoration=0`, so it is a
scaled-reference chroma prediction defect, not filtering.
feat(av1): all three scaled-reference (superres) refusals lifted -- 8x8 leaf, sub-8x8, warpAhmet Kaan Gümüş · 421ae92
feat(av1): all three scaled-reference (superres) refusals lifted -- 8x8 leaf, sub-8x8, warp

The 8x8-leaf guard's own comment blamed a below-8x8 desync ("a 4th symbol
out of a 3-symbol alphabet"). That premise was stale: deleting the guard
decodes the pinned --superres-denominator=12 stream straight through to the
NEXT refusal. One wrong alphabet was behind all three.

Root cause (class wrong-alphabet-same-value / branch-dropped-as-unreachable):
decode_inter_block8 read the 3-symbol motion_mode row under a SCALED
reference, where libaom motion_mode_allowed makes WARPED_CAUSAL eligible
only if (num_proj_ref >= 1 && (allow_warped_motion && !av1_is_scaled(sf))) --
so the alphabet shrinks to the 2-symbol obmc one (with OBMC off, no symbol
at all). The 16x16+ path already had `&& !ref_is_scaled`; the leaf's own
comment asked whoever lifted the refusal to add it, and nobody could reach
the code to notice. First-bad without it: 96x96 denom-12 warped stream,
decode-order frame 3, luma (15,54), 7652 samples wrong, max 155.

Lifted, each byte-exact vs ffmpeg with its own hit counter:
* "an 8x8 partition leaf under a scaled reference"
* "a sub-8x8 inter block under a scaled reference" (both sub8 readers)
* "warp prediction with a scaled reference" -- its translational fallback
  was already implemented and the refusal sat in FRONT of it (class
  refusal-short-circuits-its-own-code); the r1 mismatch that kept it alive
  was the strip chroma piece below, not the fallback.

Same-shape sweep of "every caller that computes a scaled start position":
* mc::predict_maybe_scaled -- the one dispatch the sub-8x8 luma/chroma
  callers now share instead of hardcoding the unscaled walk.
* the 16x4/4x16 strip's sub-8x8 chroma piece was SKIPPED entirely under a
  scaled reference (silent wrong pixels, no refusal); it now rebuilds from
  the PREVIOUS strip's own reference and that reference's own scale factor.
* allow_warp's scale bail-out was missing at the 8x8-leaf single-ref warp
  and at both compound warp sites (PER SLOT: one tap can be scaled while
  its sibling still warps).

Gate: real_superres_streams_with_sub8_leaf8_and_warp_decode_pixel_exact --
two 96x96 denom-12 streams, every unrelated tool off, pixel-exact vs ffmpeg;
arm A hard-asserts scaled leaf8 + sub8 hits, arm B asserts a WARPED_CAUSAL
eligibility was suppressed by scale. The r27 census now asserts none of the
three strings can come back. Inventory rows removed.
test(av1): four more refusals proven -- empty ref slot, segmentation overrides, OBMC filter band, superres 8x8 leafAhmet Kaan Gümüş · baa89bd
test(av1): four more refusals proven -- empty ref slot, segmentation overrides, OBMC filter band, superres 8x8 leaf

Round 27 of the refusal-proving lane. 25 -> 29 proven of 40.

* "a reference frame selected with no picture at this frame's own
  ref_frame_idx slot for it": negative gate on `ref_planes` over all six
  non-LAST references. No stream-level witness exists with this crate's
  writers -- a shown key frame refreshes all eight slots and nothing
  clears one, and a stream opening on an inter frame is stopped one
  guard earlier ("an inter frame with no key frame before it"). The
  reachable premise is a HIDDEN key frame with a partial
  refresh_frame_flags, which write_frame_header cannot write; that is
  the open half, recorded in the inventory.
* "a frame whose segmentation enables SEG_LVL_REF_FRAME/SKIP/GLOBALMV":
  negative gate (written key frame, three features x three segment ids,
  refused by name with 0 pictures) plus a census of what aomenc emits.
  Measured: --aq-mode=1/2 and --deltaq-mode=1 reproduce the baseline
  stream byte for byte at this recipe (the flags change nothing);
  --aq-mode=3 does code segment_id symbols (133 at cq40, 444 at cq10)
  and never enables any of the three. No capability gap here.
* "an OBMC neighbour whose switchable interp filter was never recorded":
  structural audit -- record_inter_rect_mi is the band's single writer
  and no call site stamps the [3, 3] sentinel on an INTER cell (each
  site's arguments tokenised, never substring-matched) -- plus a witness
  gate on two real --enable-obmc --enable-dual-filter streams: 237 band
  reads over ~115 OBMC blocks each, refusal 0x. --cpu-used=0 is
  load-bearing: at speed 4 aomenc settles on a frame-level fixed filter
  and the band is never read (0 reads, measured).
* superres trio census, six real streams: the four fixed-denominator
  --superres-mode=1 encodes (denoms 10/12/16, warp + OBMC on) ALL stop
  at "an 8x8 partition leaf under a scaled reference", and the two
  --superres-mode=3 auto encodes pick denominator 8 and carry no scaling
  at all (0 scaled MC blocks). The warp and sub-8x8 scaled refusals
  never fire: the 8x8-leaf guard sits in front of them, so they stay
  unproven until that gap is lifted. All three are real capability gaps.