forge
Explore
Log in

Don't you dare go Hollow

Commits

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

2026-09-06

perf(av1): band the encoder's frame-level filter stage across the tile workersAhmet Kaan Gümüş · 996b587
perf(av1): band the encoder's frame-level filter stage across the tile workers

The per-tile search leaves every core idle for the rest of the frame. The
filter stage now bands itself across the same workers:
`par::override_filter_threads` (thread-local, so nothing outside this span
changes) puts the deblock and CDEF replays, the capture decode's own filter
chain and the loop-restoration passes on the decoder's existing band split,
the per-64 SSE gets a unit-row band of its own (`unit_sse_rows`, partial
u64 sums), and a candidate's ~6 MB plane copies come off a recycled buffer
pool -- a fresh Vec per copy was 12.6% of a 1080p frame's wall in page
faults alone -- banded when the buffer is already the right length.

Gated by `filter_stage_bytes_do_not_depend_on_the_thread_count` (one tile,
a cropping size, 1 vs 2/4/8 threads) and by `unit_sse_matches_the_naive_sum`
at 2/4/8 bands.
perf(av1): the filter search's replay now covers cropped framesAhmet Kaan Gümüş · 8a4a771
perf(av1): the filter search's replay now covers cropped frames

The encoder scores ~30 deblock/CDEF candidates per frame by replaying the
loop filters on one captured reconstruction (`decode::FilterReplay`), but
the capture demanded `frame == plane` dimensions -- and no export size meets
that: 1080 and 1608 both pad to a superblock row. Every candidate at those
sizes fell through to a full re-decode of the frame, which the new per-stage
breakdown measures at 57% of a 1080p frame's wall.

The capture now also fires on a cropped frame and the replay finishes with
the decoder's own cropped return path (crop + wide-margin stash), so it is
still exactly the decode it stands in for.

1920x1080, 8 frames, 4x2 tiles, 8 tile threads: 6.75s -> 2.63s (1.19 ->
3.05 fps); filter search 57.2% -> 27.6% of wall.

Adds `par::timer`/`EC_AV1_STAGE_TIMES` (off by default: one relaxed atomic
load per stage per frame) and `encoder::tests::filter_stage_wall_*`, plus
`filter_replay_codes_the_same_stream_as_a_full_decode` at a cropping size.
merge main 1c844b01 (tile layout) into the palette laneAhmet Kaan Gümüş · eeee023
merge main 1c844b01 (tile layout) into the palette lane

Hand-resolved: the palette write sits inside the per-tile closures main's
TileLayout introduced, so `arm_screen` is armed per tile job beside
`arm_sign_bias`/`arm_reference_select`; the new plural
`decode_inter_frame_tiles_lr` takes this lane's `allow_screen_content_tools`
and the single-tile wrapper forwards it.
fix(av1): the GOP round-trip tests decode the key frame under its own screen flagAhmet Kaan Gümüş · 625e01e
fix(av1): the GOP round-trip tests decode the key frame under its own screen flag

Three decode::tests GOP tests handed `decode_key_frame_tile_lr` a hard-coded
`allow_screen_content_tools = false` while decoding an encoder-written tile
whose detector had fired (stale-header class, same shape as the
`reference_select` instance): frame 0's luma came back wrong.
feat(av1): palette on the intra blocks of inter frames tooAhmet Kaan Gümüş · 17922e6
feat(av1): palette on the intra blocks of inter frames too

The three intra arms of the inter-frame writers (32/16/8) now code the same
spec 5.11.46 syntax the key frame's does, through one shared
`write_palette_syntax`; the neighbour bands are published from
`record_mi_planes` -- the single point EVERY block of either frame type
passes through -- so an inter block clears what an earlier palette block left
in its column instead of desyncing the next context (the hazard lane-t900 r23
hit on the decoder side).

The inter frame sets `allow_screen_content_tools` from its own detection,
gated on the sequence having offered the bit at all (the key frame's
decision); `decode_inter_frame_tile_lr` takes the flag rather than assuming
false, and `Encoded::screen` carries it to every raw-tile decode.

The leaf (16/8) intra candidates get the palette RD for free -- they route
through `code_square`. The 32x32 inter search's own intra loop does NOT yet
offer one (corner-cut: its candidates are hand-rolled beside the inter ones).

Check: a_screen_content_picture_codes_palette_blocks_ffmpeg_decodes_exactly
now codes a 4-frame GOP as well -- 3 inter frames set the bit, 56 palette
blocks, ffmpeg reconstructs all four frames exactly in all three planes.
merge: lane-av1tiles with main ac6e60b4 (compound prediction)Ahmet Kaan Gümüş · e6c05e0
merge: lane-av1tiles with main ac6e60b4 (compound prediction)

The per-tile jobs arm the compound lane's new thread-locals
(arm_reference_select / arm_order_hints) on their own workers.
feat(av1): palette-coded luma intra blocks on a screen-content key frameAhmet Kaan Gümüş · f2eac79
feat(av1): palette-coded luma intra blocks on a screen-content key frame

The whole spec 5.11.46 chain, mirrored symbol for symbol from this crate's
own decoder: `palette_y_mode` off the real `av1_get_palette_mode_ctx`
neighbour bands, `palette_y_size`, the colours coded against the above/left
colour cache `av1_get_palette_cache` builds (`palette_ctx_and_cache`, the
decoder's own merge and dedup), and the colour-index map on
`decode_color_map_tokens`' wavefront diagonal with
`av1_get_palette_color_index_context`'s ordering.

The candidate palettes are libaom `av1_k_means`-shaped: a block with at most
8 distinct colours takes them all (exact prediction), a busier one is
quantised to 8 and to 4 by a histogram Lloyd iteration, and each is priced
through the very writers the tile uses (`palette_bits` on a
`SymbolEncoder::pricer`) against the mode the intra search already settled.

Check: encode::tests::a_screen_content_picture_codes_palette_blocks_ffmpeg_decodes_exactly
-- 48 palette blocks (sizes 2/3/4, 16 each) on a 192x96 screen card, ffmpeg
and our own decoder both reconstruct the encoder's picture exactly, and the
film-shaped test card leaves the detector off.
feat(av1): screen-content detection sets allow_screen_content_tools on a key frameAhmet Kaan Gümüş · 3136cbe
feat(av1): screen-content detection sets allow_screen_content_tools on a key frame

libaom's `av1_set_screen_content_options` shape (distinct colours per 16x16
luma block, blocks with 2..=4 of them covering more than a tenth of the
frame), run on the source luma before any header is built. When it fires the
sequence header carries the SELECT form of
`seq_force_screen_content_tools` and the key frame sets its own
`allow_screen_content_tools`; every intra block of that tile then codes the
two `read_palette_mode_info` flags (spec 5.11.46), both at ctx 0 and both
"no palette" -- the syntax a palette block will fire inside next.

A sequence with no screen content leaves the sequence bit at 0 and writes
exactly the stream it wrote before: the byte pins do not move.

Verified with the detector forced on (EC_AV1_SCREEN=1):
ffmpeg_decodes_exactly_what_the_encoder_reconstructed and
every_frame_of_a_sequence_decodes_through_our_own_decoder both pass, so the
new symbols are the ones libaom reads.
feat(av1): compound reference on by default -- BD down on all three gate clipsAhmet Kaan Gümüş · e062d5b
feat(av1): compound reference on by default -- BD down on all three gate clips

Flat BD gate, same machine: vs libaom +121.2/+146.4/+79.1 -> +120.1/+128.5/+73.0
(1080p/2160p/screen), vs rav1e +71.8/+97.8/+17.0 -> +67.8/+86.0/+13.7, wall
6.5/5.6/6.2 s -> 7.5/6.4/6.4 s. Compound takes 8.1%/8.6%/13.8% of coded inter
blocks; modes NEAREST_NEAREST 1218/1439/1848, GLOBAL_GLOBAL 268/377/0, NEW_NEW
203/34/0; pairs LAST+GOLDEN 450/397/311, LAST+ALTREF 1239/1453/1537.

The three GOP round trips in decode.rs called decode_inter_frame_tile_lr with a
hard-coded reference_select = false while decoding a tile the ENCODER wrote
(stale-header class); they now pass the encoder's own bit. Byte pins updated.
feat(av1): compound-reference blocks -- comp_ref/compound_mode syntax and averaged two-reference predictionAhmet Kaan Gümüş · 3cac217
feat(av1): compound-reference blocks -- comp_ref/compound_mode syntax and averaged two-reference prediction

The tile writer now codes a COMPOUND_REFERENCE block: comp_mode = 1, the
comp_ref_type/uni_comp_ref/comp_ref/comp_bwdref pair tree, the
inter_compound_mode symbol at the compound MV stack's own context, and (for
NEW_NEWMV) the compound DRL walk plus both motion vectors -- mirrored symbol
for symbol from decode.rs read_compound_ref_frames /
read_inter_compound_mode / assign_compound_mv. comp_group_idx/compound_idx
are NOT coded: this crate's sequence header clears enable_masked_compound and
enable_jnt_comp, under which decode.rs reads neither and infers the simple
average, which is the only blend the encoder forms.

The 32x32 block search offers NEAREST_NEARESTMV, GLOBAL_GLOBALMV and
NEW_NEWMV (seeded from the two single-reference searches, no joint search)
for the pairs LAST+GOLDEN and LAST+ALTREF, predicted through
mc::predict_compound_intermediate + mc::combine_compound at the 8/8 split.

Root cause found on the way: write_single_ref dropped the neighbour's SECOND
reference from every single_ref_p*_ctx vote (libaom
av1_collect_neighbors_ref_counts counts both), so every single-reference
block sitting under a compound neighbour decoded a different reference name.
feat(av1): the encoder writes multi-tile frames, sample-exact at every layoutAhmet Kaan Gümüş · a01d142
feat(av1): the encoder writes multi-tile frames, sample-exact at every layout

Uniform tile spacing (spec 5.9.15), one tile group OBU with per-tile sizes,
context_update_tile_id on the largest tile, and per-tile CDF / LR-reference /
neighbour-band / MV-grid resets mirroring the decoder's own tile loop. The
writer's availability answers are tile-relative now (the intra_inter and
tx-size contexts asked mi_row > 0 and coded a tile's first row against a
neighbour the decoder does not have).

EncoderConfig gains tile_cols_log2/tile_rows_log2 (default 0/0, byte-identical
to the one-tile stream); ec-bench takes EC_AV1_TILES=<cols>:<rows>.
perf(av1): the filter replay deblocks once per level pairAhmet Kaan Gümüş · 95de47f
perf(av1): the filter replay deblocks once per level pair

The search fixes the deblocking levels in its first three stages and
then walks 18 CDEF strength candidates that all replay the same
deblock. The replay now keeps the deblocked planes with the levels that
produced them and copies those instead when the levels match -- the
same copy the replay was already making, with the deblock skipped.
Byte-identical on the three gate clips; ladder wall 4.64/4.21/4.91 ->
4.51/4.08/4.80 s.
fix(av1): the encoder's filter-search re-decode ignored ref_frame_sign_biasAhmet Kaan Gümüş · 28f2d42
fix(av1): the encoder's filter-search re-decode ignored ref_frame_sign_bias

decode_inter_frame_tile_lr hard-coded NO_SIGN_BIAS, so the trial decode of a
pyramid leaf reading its group's backward hidden ALTREF built different MV
stacks than the writer and desynced into 'a reference frame selected with no
picture at this frame's own ref_frame_idx slot'.
Merge branch 'main' (d5fc99e0) into lane-av1lrAhmet Kaan Gümüş · 8e2799a
Merge branch 'main' (d5fc99e0) into lane-av1lr

Nine hunks across three files, all taken both ways.

tile.rs: that lane split each writer into a `_tx` wrapper and a
`_cdfs` worker, so this lane's arm/clear guard moves down into the
worker, where the symbols are actually written.

decode.rs: `decode_inter_frame_tile_lr` now takes `initial_cdfs`
alongside `lr` and both wrappers thread it; the two chained-decode
tests pass this frame's own `loop_restoration` AND its `start_cdfs`.

encode.rs: the tile is written through the CDF-carrying writer, and
this lane's re-codes (for the `cdef_idx` literals and the per-unit
restoration syntax) each restart from the frame's OWN `start_cdfs`
rather than from where the first write left them -- the second tile is
the first tile's symbol sequence plus new ones, so it has to adapt from
the same point the decoder will. The winning re-code publishes its
end-of-tile tables into `next_cdfs`, which is what the next frame's
writer starts from; the first write's would have been stale.

Byte pins re-measured on the merged tree: q=150 7416 -> 7458 bytes,
q=60 27927 -> 27807.
Merge branch 'lane-av1s3' (91f6923f): NEARMV/GLOBALMV with a real DRL index, GOLDEN/ALTREF references, CDF carry across framesAhmet Kaan Gümüş · 0f15668
Merge branch 'lane-av1s3' (91f6923f): NEARMV/GLOBALMV with a real DRL index, GOLDEN/ALTREF references, CDF carry across frames

Merge resolution: the byte pins from lane-av1fwd move to the merged tree's
streams (7416 / 27927 bytes), since the inter syntax changed on purpose.
Merge branch 'main' (45b942bd) into lane-av1lrAhmet Kaan Gümüş · 3bf4b1b
Merge branch 'main' (45b942bd) into lane-av1lr

Five hunks in `pick_and_apply_filters` and its two call sites, resolved
so both lanes survive: the deblocking/CDEF coordinate search runs
through main's `FilterReplay` (one decode, then the filters alone per
candidate), and the per-64x64 error this lane's CDEF preset search reads
comes off those REPLAYED pictures -- the replay is pinned byte-exact
against a decode, so the per-unit measurement is the same measurement.
The tile recode with `cdef_idx` literals and the one capturing decode
the loop restoration stage needs both run after the replay is cleared.

The byte pins move, as that lane's own comment said they would for new
tile syntax: 7823 -> 7796 bytes at q=150 and 28189 -> 28182 at q=60,
both SMALLER, re-measured on this merged tree.
feat(av1): ALTREF as the frame two back, on an alternating slotAhmet Kaan Gümüş · 9310981
feat(av1): ALTREF as the frame two back, on an alternating slot

Frame n refreshes slot 0 for odd n and slot 2 for even n, so the frame
two back is still intact in the very slot this one is about to overwrite
(read before write): ref_frame_idx names it as ALTREF_FRAME, LAST names
the other slot, GOLDEN stays on slot 1. inter_frame_headers_slots is the
header builder that takes the three slots apart; the five-argument
inter_frame_headers keeps its old read-and-write-one-slot meaning for the
hand-built fixtures. The RD prices each extra reference's two
search-free modes from a slice, so LAST/GOLDEN/ALTREF share one code path.

ALTREF is picked for 337/405/1793 blocks per ladder. BD-rate vs libaom
127.3/153.4/83.0 -> 126.5/152.9/80.9, vs rav1e 78.6/105.7/18.3 ->
77.9/105.5/17.6; wall 7.8/7.1/7.8 -> 8.0/7.2/7.7 s. ffmpeg decodes every
stream sample-exact.
feat(av1): a real GOLDEN reference beside LASTAhmet Kaan Gümüş · 2f069ae
feat(av1): a real GOLDEN reference beside LAST

The key frame refreshes all eight DPB slots and every inter frame only
slot 0, so slot 1 still holds the key frame however long the GOP runs:
inter_frame_headers now points ref_frame_idx[3] (GOLDEN_FRAME) at it, the
encoder carries that picture through encode_sequence and Av1Encoder, and
the 32x32 inter RD prices GOLDEN's two search-free modes (NEARESTMV off
its own mv stack, GLOBALMV) beside LAST's whole mode set. No second
motion search -- that stage owns the wall -- and one trial set per
distinct (reference, vector) pair, so the added modes mostly reuse work.

The trial decode of the filter search and the two GOP tests take the
golden plane at RefPix index 4 (the array is keyed by reference NAME, not
by DPB slot).

GOLDEN is picked for 50%/56%/37% of inter blocks. BD-rate vs libaom
133.7/162.3/83.8 -> 127.3/153.4/83.0, vs rav1e 84.7/113.1/18.0 ->
78.6/105.7/18.3; wall 10.1/9.5/9.4 -> 7.8/7.1/7.8 s. ffmpeg decodes every
stream sample-exact (ffmpeg_and_this_decoder_agree_on_a_gop).
perf(av1): the filter search decodes its tile once instead of once per candidateAhmet Kaan Gümüş · 675eebb
perf(av1): the filter search decodes its tile once instead of once per candidate

`filter_search::pick_filters` scores ~25 deblock/CDEF candidates by handing
the coded tile back to the decoder under each one. The entropy decode and
reconstruction it repeated are identical every time -- both filters run
after them -- and that re-parse was 24% of the encoder's profile.

The decoder now captures its pre-filter frame plus the neighbour state the
filters read (`decode::FilterReplay`, armed for exactly one decode), and
`replay_filters` re-runs `apply_deblock` + `apply_cdef` on a copy of it.
Capture only happens on the shape whose decode tail is those two calls and
nothing else (no superres, no loop restoration, no crop); anything else
decodes for real as before.

Byte-exact: the four-point ladder of the 1080p gate clip is unchanged
(17643/32317/53048/76330 bytes, same FNV-1a per stream); 8.24s -> 6.61s.
Merge branch 'lane-av1filt' (193d9a9e): the encoder searches deblock levels and CDEF strengths by re-decoding its own tileAhmet Kaan Gümüş · 1b6265b
Merge branch 'lane-av1filt' (193d9a9e): the encoder searches deblock levels and CDEF strengths by re-decoding its own tile

Merge resolution: the trial decoder now takes the frame's own tx_select bit
(c78863b8), so the filter search runs under inter TxMode::Select too instead
of skipping -- with Select the default since lane-av1tx2, the lane's own skip
would have left every inter frame unfiltered (class: merge cross-product).
feat(av1): carry the CDF state across frames (spec 7.20)Ahmet Kaan Gümüş · e161916
feat(av1): carry the CDF state across frames (spec 7.20)

Inter frames now leave `disable_frame_end_update_cdf` off, so each one
stores its end-of-tile tables with the counts reset and the next frame's
writer starts from them -- the encoder mirrors `stream::stored_cdfs_for`
exactly, and the key frame keeps the bit set, so what it stores is the
defaults it started from and the first inter frame is unchanged.

`sb_coeff_{key,inter}_frame_tile_cdfs` are the writers that take and leave
the caller's `Cdfs`; the old entry points wrap them with a fresh one.
`Encoded` carries `start_cdfs`/`next_cdfs`, `Av1Encoder` carries the state
between `encode` calls, and `decode_inter_frame_tile` takes an
`initial_cdfs` -- the same threading the frame's `tx_select` bit needed,
third instance of that class, and the three GOP tests (one of which checks
ffmpeg against us) now pass the frame's own start state.

BD-rate vs libaom 210.1/218.7/167.4 -> 202.6/206.6/159.0, vs rav1e
151.8/164.7/72.7 -> 144.5/153.2/65.9; wall unchanged at 7.9/7.4/7.6 s.
test(av1): the raw inter-tile decode entry point takes the frame's own tx_select bitAhmet Kaan Gümüş · 52ec542
test(av1): the raw inter-tile decode entry point takes the frame's own tx_select bit

Three gop round-trip tests decoded inter tiles through decode_inter_frame_tile,
which hard-coded tx_select=false with a comment claiming this crate's encoder
always writes TxMode::Largest. Inter frames write Select by default now, so
the reader consumed the first tx_depth symbol as coefficient data and failed
with a hallucinated empty-reference-slot refusal (class: test asserts against
a stale header, second instance; the key-frame twin was fixed one merge ago).
The entry point now takes tx_select and the tests pass Encoded::tx_select.
test(av1): the raw inter-tile decode entry point takes the frame's own tx_select bitAhmet Kaan Gümüş · 2d62fa6
test(av1): the raw inter-tile decode entry point takes the frame's own tx_select bit

Three gop round-trip tests decoded inter tiles through decode_inter_frame_tile,
which hard-coded tx_select=false with a comment claiming this crate's encoder
always writes TxMode::Largest. Inter frames write Select by default now, so
the reader consumed the first tx_depth symbol as coefficient data and failed
with a hallucinated empty-reference-slot refusal (class: test asserts against
a stale header, second instance; the key-frame twin was fixed one merge ago).
The entry point now takes tx_select and the tests pass Encoded::tx_select.
feat(av1): encoder enables CDEF and searches its strengths (cdef_bits = 0)Ahmet Kaan Gümüş · df76271
feat(av1): encoder enables CDEF and searches its strengths (cdef_bits = 0)

The sequence header now sets enable_cdef and every frame header carries one
strength pair per plane type, chosen by the same re-decode search as the
deblocking levels -- cdef_bits = 0 means no cdef_idx literal is read in the
tile, so this costs no tile-writer change. Encoded carries the chosen
CdefParams and the tests that decode Encoded::tile take them from there.

BD-rate vs libaom 198.2/218.1/136.9 -> 143.6/179.5/88.0 (1080p/2160p/screen),
vs rav1e 143.1/162.4/52.7 -> 94.0/128.8/21.5.
feat(av1): encoder picks per-frame deblocking levels by re-decoding its own tileAhmet Kaan Gümüş · 873a1fb
feat(av1): encoder picks per-frame deblocking levels by re-decoding its own tile

The encoder runs no loop filter of its own: filter_search hands the coded
tile back to this crate's decoder under each candidate loop_filter_level and
keeps the winning picture as the reconstruction, so the reference frame stays
identical to what a decoder produces. Encoded now carries the chosen
LoopFilterParams and every test that decodes Encoded::tile takes them from
there (class: test asserts against a stale header).
Reapply "Merge branch 'lane-av1tx' (723ab821): key-frame TxMode::Select -- intra blocks search tx_depth 0..2 with per-transform-unit prediction/reconstruction, writer codes tx_depth with the deblock-grid context and cul_level-based skip contexts; BD-rate vs rav1e screen +141% -> +73%, films -1; inter var-tx syntax written but desyncs, shipped off behind EC_AV1_TX_SELECT_INTER=1; ffmpeg decodes every default stream sample-exact"Ahmet Kaan Gümüş · 5f7a053
Reapply "Merge branch 'lane-av1tx' (723ab821): key-frame TxMode::Select -- intra blocks search tx_depth 0..2 with per-transform-unit prediction/reconstruction, writer codes tx_depth with the deblock-grid context and cul_level-based skip contexts; BD-rate vs rav1e screen +141% -> +73%, films -1; inter var-tx syntax written but desyncs, shipped off behind EC_AV1_TX_SELECT_INTER=1; ffmpeg decodes every default stream sample-exact"

This reverts commit 582fbd0bb1adb7724e9fa24f57bffd217fa38c3b.
fix(av1): a key frame test decoded its own tile as TxMode::LargestAhmet Kaan Gümüş · 787a14a
fix(av1): a key frame test decoded its own tile as TxMode::Largest

The nine failing gates fed decode_key_frame_tile a hardcoded tx_select =
false while the encoder had moved its key frame header to
TxMode::Select, so the decoder missed the first block tx_depth symbol
and desynced at pixel (0,0). Encoded now carries the header bit and the
encoder-driven decode sites pass it along.
Revert "Merge branch 'lane-av1tx' (723ab821): key-frame TxMode::Select -- intra blocks search tx_depth 0..2 with per-transform-unit prediction/reconstruction, writer codes tx_depth with the deblock-grid context and cul_level-based skip contexts; BD-rate vs rav1e screen +141% -> +73%, films -1; inter var-tx syntax written but desyncs, shipped off behind EC_AV1_TX_SELECT_INTER=1; ffmpeg decodes every default stream sample-exact"Ahmet Kaan Gümüş · 041eb21
Revert "Merge branch 'lane-av1tx' (723ab821): key-frame TxMode::Select -- intra blocks search tx_depth 0..2 with per-transform-unit prediction/reconstruction, writer codes tx_depth with the deblock-grid context and cul_level-based skip contexts; BD-rate vs rav1e screen +141% -> +73%, films -1; inter var-tx syntax written but desyncs, shipped off behind EC_AV1_TX_SELECT_INTER=1; ffmpeg decodes every default stream sample-exact"

This reverts commit 80f4e998bf89f8bfa64daf228d3e2b08dc10191c, reversing
changes made to 79ce824128513b891bfae8a68ee36c1fd54cb062.
feat(av1): chroma searches its own uv_mode instead of coding DC unconditionallyAhmet Kaan Gümüş · b0a80f3
feat(av1): chroma searches its own uv_mode instead of coding DC unconditionally

Both chroma planes were predicted DC_PRED at every block because that is all
the tile writer coded. They now search the seven modes that read no further
than the row directly above and the column directly to the left -- DC, V, H,
SMOOTH, SMOOTH_V, SMOOTH_H, PAETH -- which is exactly the set a chroma block
coded with `Reach::none()` may offer; the eight directional modes read past
that and UV_CFL_PRED needs its own alpha syntax.

A chroma block never codes a tx_type symbol: the decoder derives it from the
chroma mode (`Intra_Mode_To_Tx_Type`, spec 9.3), so a non-DC uv_mode moves
chroma onto an ADST-bearing transform. The forward half of that is new here
and measured off the decoder's own inverse network -- a unit coefficient
through `inverse_1d` IS the basis function it synthesises -- rather than
written out, which is safe because only the levels and the derived type reach
the decoder: the reconstruction the search scores still comes back through
the exact inverse.

BD-rate vs libaom 234.0/260.3/318.5 -> 216.4/235.5/289.2 and vs rav1e
171.9/203.2/155.3 -> 157.8/178.3/141.1 (1080p/2160p/screen), down on all
three against both references. Wall 9.8s -> ~11.1s per clip ladder. The gate's
own ffmpeg-decodes-sample-exact assertion holds, so the writer's uv_mode and
angle_delta_uv syntax and the derived chroma transform agree with a real
decoder. Fire counts printed per clip: DC wins 79.1/84.1/43.8%, PAETH
7.1/6.6/29.0%, H 3.3/2.5/16.6%.
perf(av1): the square coefficient loop's trace sites move out of lineAhmet Kaan Gümüş · 70a2869
perf(av1): the square coefficient loop's trace sites move out of line

`eprintln!` builds its `fmt::Arguments` on the stack at the call site, so the
six trace sites inside `read_coeffs`'s base and sign loops kept their values
pinned in the hot loop's frame -- the annotated profile's top line was stack
spill traffic. Each is a `#[cold] #[inline(never)]` call taking the values it
prints; the output is character-for-character what it was.

instructions:u at EC_AV1_THREADS=1: 4K segment -0.25%, 1080p segment -0.32%.

The same treatment on `read_coeffs_rect`'s four sites plus the two remaining
`TRACE` sites of the sign pass measured WORSE (4K +0.04%, 1080p +0.05%,
reproduced in two interleaved pairs on both segments) and was reverted by
inverse edit -- those loops are short enough that the extra call sequences
cost more than the frame they free.
perf(av1): coefficient reading walks a non-zero list and flat neighbour tapsAhmet Kaan Gümüş · de3e402
perf(av1): coefficient reading walks a non-zero list and flat neighbour taps

The sign pass re-walked `scan[..eob]`, redid the `pos >> sh` / `& mask`
decomposition and loaded each level back out of the padded frame only to
skip the zeros. The base pass already knows both, so it now records
`(scan_idx << 4) | level` per non-zero coefficient and the sign pass walks
that list in reverse -- same coefficients, same order, same trace output.

The five base-context neighbour taps and the three base-range ones are a
function of the tx class alone, which is fixed for a whole transform unit:
`flat_taps` resolves them once per unit as flat offsets into the padded
level frame, so the per-coefficient path loses the class match and the
`(dr, dc)` -> `dr * stride + dc` arithmetic. Both readers (square and rect)
share the new `base_mag`/`br_mag`; `br_ctx`/`br_ctx_rect` stay as the
`(row, col)` form the new test pins the flat one against, over every class,
every square size and the whole `(row, col)` domain.

`SymbolDecoder::literal` was a real call per raw bit across a codegen-unit
boundary (this crate builds without LTO) -- the sign pass and the Golomb
tail read one bit at a time; it is `#[inline]` now.

instructions:u at EC_AV1_THREADS=1: 4K segment -1.01%, 1080p segment -1.42%.
perf(av1): recycle the three per-superblock recon-job buffers instead of allocating them per submitAhmet Kaan Gümüş · ce3d0d9
perf(av1): recycle the three per-superblock recon-job buffers instead of allocating them per submit

wave_submit made three fresh Vecs per superblock (op list, coefficient
arena, prediction arena) and the worker freed them when the ReconJob
dropped -- 4680 allocations and frees per 4K frame, each first-touched.
The worker now clears them and hands them back to a bounded free list
inside the queue mutex both sides already take, so only the first few
superblocks of a tile allocate.

-0.12% instructions at (16,4,2) on the 4K segment; byte-exact.

2026-09-05

perf(av1): one pool per job tree and a shared capped plane-scratch poolAhmet Kaan Gümüş · 2636658
perf(av1): one pool per job tree and a shared capped plane-scratch pool

A filter band job opened a sub-pool on the worker running it, one level
per pipeline stage, and no pool ever shrank: 1038 threads at
(16,4,2). A job now submits back into the pool it is running on
(`ON_POOL`), so the thread count is the peak of `busy + queued` over the
whole job tree. `Pool`'s handles moved behind the queue lock because the
thread that grows the pool is now whichever one submits.

The whole-plane scratch pool was per thread while its buffers are not:
the frame thread allocates the snapshots and a filter worker returns
them, so ~19 MB a set leaked into every worker the decode touched. One
process-wide pool, best-fit by capacity, hard-capped at 32 buffers.

4K peak RSS 9.33 GB -> 4.07 GB, peak threads 1053 -> 59, instructions:u
+0.10% and page faults -30% on seg4k at (16,4,2).