forge
Explore
Log in

Don't you dare go Hollow

Commits

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

2026-09-07

fix(av1): two lossless INTER defects on screen content -- a skip 8x8 leaf restored the previous block's luma band, and a rect sub-8x8 intra leaf read one TX_4X8Ahmet Kaan Gümüş · 025c254
fix(av1): two lossless INTER defects on screen content -- a skip 8x8 leaf restored the previous block's luma band, and a rect sub-8x8 intra leaf read one TX_4X8

- decode_leaf8/decode_inter_block8: `saved_luma_ctx` is only valid on the arm that
  actually published per-TU luma state. A SKIP block publishes none, and on a lossless
  frame `read_block_tx_size` hands back 4x4 leaves for a skip block too, so the restore
  put the previous block's levels back over the zeros `record_mi` had written
  (libaom `av1_reset_entropy_context`). Class [[override-slot-on-one-arm]].
- decode_intra_sub8_leaf / decode_leaf_rect8 / the 16x4 rect4 reader: their
  `tx_depth != 0` split guards never fire on a lossless frame (no depth symbol is
  coded), so a 4x8/8x4 intra leaf read ONE rect transform where libaom codes two
  TX_4X4 -- the same widening the five other rect sites already carry.

Gate: a_lossless_libaom_inter_frame_decodes_sample_exact grows a 640x384
tune-content=screen -g 3 six-frame row (inter frames of screen content).
fix(av1): lossless chroma units read a windowed palette prediction, one entropy cell, and stop at the frame edgeAhmet Kaan Gümüş · 6f56c94
fix(av1): lossless chroma units read a windowed palette prediction, one entropy cell, and stop at the frame edge

Three defects the synthetic (non-screen) fixtures could not see, all found by
a tune-content=screen -crf 0 stream:

- a 4x4 chroma unit was handed the WHOLE-BLOCK palette prediction buffer and
  read it at its own stride, so every unit reconstructed the block's top-left
  corner (the luma split-transform paths already window; palette_window() is
  now shared by decode_block, decode_rect_split and the new intra helper).
  A 320x192 screen key frame decoded 9600/15360 chroma samples wrong.
- a unit whose block hangs off the frame edge is still coded by libaom
  (max_blocks_high clips in LUMA mi, then rounds UP for chroma), and our
  two-cell neighbour read then indexed past the band. libaom reads exactly
  ONE chroma entropy entry for a TX_4X4 chroma unit (get_txb_ctx's a[0]/l[0]);
  our bands carry that entry replicated over the unit's two luma-mi cells, so
  one cell is the same answer and never runs off.
- units whose ORIGIN is past the frame edge are not coded at all.

The 320x192 and 640x384 screen key frames are now sample-exact.
feat(av1): lossless INTER frames decode -- the chroma plane is 4x4 units, plane-majorAhmet Kaan Gümüş · 5136c0f
feat(av1): lossless INTER frames decode -- the chroma plane is 4x4 units, plane-major

A lossless frame codes TX_4X4 on every plane (libaom read_tx_size returns
TX_4X4 before it ever consults max_txsize_rect_lookup), and
decode_token_recon_block walks a 64x64 mu chunk PLANE-MAJOR
(for (plane..) for (blk_row..) for (blk_col..)). The inter readers still
read chroma as one transform per block, so a lossless inter frame was
refused by name; they now walk the 4x4 units, and the refusal is gone.

Three defects the previous lane's gate could not see (its source had a FLAT
chroma plane, so every chroma unit coded one txb_skip symbol against
all-zero contexts -- class gate-blind-to-feature):

- decode_block read its chroma units interleaved U,V per unit instead of
  plane-major. Identical order at one unit per plane per chunk (every
  non-lossless case), wrong for a lossless block's 4x4 raster.
- decode_rect_split's lossless chroma branch stamped each unit's neighbour
  context and then let record_split_luma_rect_mi overwrite all of them with
  the LAST unit's state, so the next block read dc_sign_ctx 1 where libaom
  reads 0 (class override-slot-on-one-arm).
- decode_inter_sub8_rect2 kept one 8x4/4x8 luma transform on a lossless
  frame, which fed a rect grid to the 4x4 Walsh-Hadamard.

Gates: the key gate's source is now textured chroma, and
a_lossless_libaom_inter_frame_decodes_sample_exact replaces the retired
refusal gate with four libaom -crf 0 fixtures (256x128 8-bit, 192x96
10-bit, 320x192, 256x256 --sb-size=128), each sample-exact vs ffmpeg.
feat(av1): lossless key frames decode exact; lossless inter refused by nameAhmet Kaan Gümüş · 1e1a080
feat(av1): lossless key frames decode exact; lossless inter refused by name

Key/intra-only lossless frames decode sample-exact at 8 and 10 bit (64x64,
256x128 8-bit, 192x96 10-bit libaom -crf 0 streams, 0 sample diffs vs
ffmpeg). The inter path's luma leaves are synthesized as TX_4X4 but its
chroma plane is still one transform per block, so a lossless INTER frame is
refused by name and the refusal inventory carries it. The old refusal gate
becomes a_lossless_libaom_key_frame_decodes_sample_exact.
feat(av1): a lossless key frame decodes sample-exactAhmet Kaan Gümüş · b0db8e9
feat(av1): a lossless key frame decodes sample-exact

The rect strip readers take the per-transform-unit walk on a lossless frame
(depth_to_tx_wh returns TX_4X4 before it looks at the block), their chroma is
coded as 4x4 units plane-major with get_txb_ctx's +10 offset rows, and the
Walsh-Hadamard orientation is pinned by measurement. A 64x64 libaom -crf 0
key frame now decodes sample-exact against ffmpeg (6488 entropy steps
identical to aomdec's EC_TRACE_COEFF, 0 sample diffs).
feat(av1): lossless decode groundwork -- WHT, TX_4X4 forcing, CfL narrowingAhmet Kaan Gümüş · f0a5a15
feat(av1): lossless decode groundwork -- WHT, TX_4X4 forcing, CfL narrowing

The 4x4 Walsh-Hadamard inverse (libaom av1_iwht4x4_16_add_c) with its own
round-trip test, a per-frame CodedLossless flag replacing the refusal (a
frame mixing lossless and lossy segments is still refused by name), the
TX_4X4 forcing in the square and 8x8-leaf intra readers, no tx_type symbol
(libaom read_tx_type: qindex 0 returns early), DCT_DCT on every plane, the
is_cfl_allowed narrowing to a 4x4 chroma plane block, and the +10 chroma
txb_skip rows at TX_4X4 that only a lossless frame reaches.
fix(av1): the palette neighbour bands are cleared by the key-frame sub-8x8 leavesAhmet Kaan Gümüş · 2fe9a36
fix(av1): the palette neighbour bands are cleared by the key-frame sub-8x8 leaves

Narrows the previous commit: the 5 INTER-side zero-stamps regressed 13 tests
(our own encoder's screen streams stopped decoding) because the inter readers'
band index/footprint convention is not the palette bands' -- reverted, recorded
in lanes/dkey.report.md as the open half of the sweep. The two key-frame
sub-8x8 stamps, which are what the measured mi(76,88) desync needed, stay.
fix(av1): temporal MV candidates ignored force_integer_mvAhmet Kaan Gümüş · 0c17efc
fix(av1): temporal MV candidates ignored force_integer_mv

`lower_mv_precision` implemented only its `is_integer == false` half, on a
comment claiming no reachable stream sets `force_integer_mv` because
`allow_screen_content_tools` is refused at the stream level. Neither half of
that claim holds: libaom turns screen-content tools on for dark, smooth FILM
(`av1_set_screen_content_options` counts near-flat 16x16 blocks) and then sets
`force_integer_mv` on the frames its hash test calls static, and this decoder
parses such streams without refusing anything.

The consequence was invisible to the parse: every temporal MV candidate came
out at eighth-pel where libaom rounds it to full pel, so the mv stack held
values libaom never produced. The stack still had the right shape for a
while, so the frame decoded "successfully" into a whole-frame prediction
mismatch, and the entropy desync that followed surfaced as the unrelated
refusal "a Golomb tail longer than this decoder reads" (class
`refusal-names-a-correlate`).

First divergence, measured against the instrumented libaom oracle: film-B
gate clip, `-cpu-used 6 -crf 35 -g 12`, decode-order frame 3 (order_hint 1,
the one inter frame with `force_integer_mv == 1`), block mi(0,0), the NEWMV
predictor -- identical `EC_TPL` field cells and identical range in both
decoders, aomdec's stack `(16,0)w16 (16,-8)w12 (8,-40)w4` against ours
`(14,-4)w16 (12,-2)w8 (12,-38)w4 (16,-4)w4`.

Class: `branch-dropped-as-unreachable` -- a spec branch deleted on an
unreachability note that a capability change (screen-content streams no
longer refused) silently invalidated.

All four libaom film-B ladder points at 48 frames now decode sample-exact
against ffmpeg/libdav1d except crf 5, which desyncs on the KEY frame at
mi(184,344) (base_q 9) -- a separate, still-open defect.
feat(av1): a decode-side syntax census, and the film B vs rav1e table it producedAhmet Kaan Gümüş · 373b6a2
feat(av1): a decode-side syntax census, and the film B vs rav1e table it produced

The BD gate says our stream is bigger; it never says which syntax it is
bigger in. This adds a per-CDF-table bit accountant to the symbol decoder
(EC_AV1_BITCENSUS=1, one relaxed load per symbol when off) plus block, tx,
mv, mode and frame-header funnels, and an examples/syntax_census.rs that
prints one table per stream -- so our stream and rav1e's are measured by the
same reader.

lanes/census-filmB.md holds the answer for film B at matched PSNR: the whole
gap is in the inter frames (our key frame is the smaller and the worse one),
75% of it in the leaves, and the three mechanisms are the flat pyramid q
ladder, the missing 64x64 blocks and transforms, and a 52.5% vs 84.8% skip
share.
Merge branch 'lane-fintra' (88c5ef0f): filter intra as an intra-search candidate, default on; enable_filter_intra threaded through every raw decode of the encoder's own tilesAhmet Kaan Gümüş · 9b5376d
Merge branch 'lane-fintra' (88c5ef0f): filter intra as an intra-search candidate, default on; enable_filter_intra threaded through every raw decode of the encoder's own tiles

Native table: film A +53.2/+23.4 -> +52.8/+23.3, film B +81.5/+46.5 ->
+81.0/+46.1, screen flat. Pins 7373 / 27074. Six gate decodes passed a
literal false for the header bit (stale-header class, swept).
test(av1): a filter-intra key frame decodes pixel-exact through ffmpeg; native gate prints the fire rateAhmet Kaan Gümüş · 24771c9
test(av1): a filter-intra key frame decodes pixel-exact through ffmpeg; native gate prints the fire rate
perf(av1): measure the encoder's first decode -- 94% of it is parse, not reconstructionAhmet Kaan Gümüş · 591f575
perf(av1): measure the encoder's first decode -- 94% of it is parse, not reconstruction

The encoder decodes its own written tiles once per frame to reach the
reconstruction and the per-mi neighbour state the filter search reads
(`par::S_FIRST`). The plan for removing it was to hand the decoder the
encoder's own reconstruction, which the writer already holds.

`EC_AV1_NORECON=1` drops every recorded pixel write in `exec_op` and
leaves the entropy parse and the neighbour bookkeeping alone. At
3840x1608 (4 frames, 4x2 tiles, 8 tile threads) the stage moves 150 ms
-> 141 ms: the reconstruction is 6% of it, the parse and the per-mi
grids are the other 94%. So the planes are not the lever -- only a
writer-side publisher of the filter-relevant `decode::Neighbours` grids
(blk_grid, tx/tx_h, uv_tx/uv_tx_h, ref_grid, delta_lf_grid), which skips
the parse entirely, can remove the stage.

Measurement only; the flag is off by default and the encoder's own
streams are byte-identical to their pins.
feat(av1): filter intra as an intra-search candidateAhmet Kaan Gümüş · b978eaa
feat(av1): filter intra as an intra-search candidate

Threads the sequence header's `enable_filter_intra` through the raw inter
tile decode entry points and the gates that decode the encoder's own tiles
(stale-header class: five hard-coded `false`s), writes
`filter_intra_mode_info` at all five intra write sites between the palette
colour lists and the colour-index maps, and offers the five recursive
filter-intra modes as RD-priced candidates after the mode/tx-depth/palette
searches. `EC_AV1_FILTER_INTRA=0` restores the previous streams.

2026-09-06

feat(av1): the chroma search offers UV_CFL_PRED, alpha searched and codedAhmet Kaan Gümüş · f944910
feat(av1): the chroma search offers UV_CFL_PRED, alpha searched and coded

The encoder never coded chroma-from-luma: every intra block's chroma came
off DC/V/H/SMOOTH*/PAETH while the decoder has read `cfl_alpha_signs` and
scaled the luma AC since lane-cfl. The chroma search now builds the
decoder's own CfL candidate -- `cfl_ac_q3_at` (the shared body behind
`cfl_ac_q3`/`cfl_ac_q3_rect`) over the committed luma reconstruction, the
decoder's `cfl_scaled` nudge on a DC_PRED base -- picks each plane's
alpha_q3 from the least-squares optimum and its two neighbours, and prices
the three sign combinations against the best ordinary chroma mode and the
chroma palette. Offered only where `is_cfl_allowed` does (<=32x32).

The writer codes `uv_mode = UV_CFL_PRED` plus the joint sign and magnitude
symbols at all four uv_mode sites; the three intra-in-inter sites needed it
too (without them the inter path desynced at picture 8).

5-row native gate, EC_AV1_CFL=0 -> default:
  bars 1080p +15.6/-1.7 -> +0.3/-15.5, bars 2160p +46.5/+18.8 -> +16.8/-6.5,
  film A +69.0/+37.5 -> +67.7/+36.3, film B +100.0/+61.5 -> +99.6/+61.2,
  screen +51.0/-14.5 -> +50.4/-15.1.
perf(av1): the CDEF candidate loop keeps one destination and restores only what the last candidate wroteAhmet Kaan Gümüş · 3847d87
perf(av1): the CDEF candidate loop keeps one destination and restores only what the last candidate wrote

The encoder's filter search scores ~32 candidates on one captured
reconstruction, and the ~17 of them that only move a CDEF strength used
to copy the three post-deblock planes (~19 MB at 4K) into fresh
destinations before every one -- 7% of a 4K frame's wall, the largest
plane-copy bucket left.

`cdef_band` now fills a per-8x8-unit map (bit 0 luma, bit 1 chroma) of
the units it actually filtered, which is what the reuse needs: the
per-unit variance goes through `cdef_adjust_strength`, so a candidate
with a lower primary strength can leave units its predecessor wrote and
the map is not a function of the strengths alone (the reason an earlier
lane recorded this reuse as not provably exact).

The replay keeps its destination planes between candidates and restores,
from the post-deblock cache, the column span between the first and last
written unit of each unit row -- contiguous, never more than the
whole-plane copy it replaces. Two restores fall away entirely: a plane
whose strengths did not move, and a plane whose new primary strength is
no lower with a secondary that is zero only if the old one's was, since
`cdef_adjust_strength` is monotone and every unit CDEF writes it writes
from the post-deblock source alone. Only while both candidates carry one
strength pair and read the same cdef_idx grid; the final replay restores
everything.

Byte-exact: the pins (q150 7173 / q60 26362), enc_probe FNV on the
640x384 gate clip at q 150/120/90/60 and on both real-film 1920x768
crops at q 150/60 all match a b7990ec1 baseline binary exactly, and the
replay-identity, facade and thread-count determinism tests pass.

4K 3840x1608 4x2 tiles / 8 threads, best of 3 on a contended box:
plane copies 316 -> 268 ms per 4 frames (-15%), cdef replay unmoved.
perf(av1): a deblock-only filter candidate keeps its own planes as the deblock cacheAhmet Kaan Gümüş · 3a4b874
perf(av1): a deblock-only filter candidate keeps its own planes as the deblock cache

An all-zero-strength CDEF writes no sample (apply_cdef's cdef_all_zero
early return), so the planes a level-changing candidate just deblocked
ARE its output: they become the cache directly instead of being copied
into it, three ~6 MB copies less on every candidate of the deblocking
half of the search. 4K 4x2/8 plane copies 235 -> 204 ms.
perf(av1): the loop-restoration stage replays the decoder's own kernel instead of decoding the re-coded tileAhmet Kaan Gümüş · 34dfd1e
perf(av1): the loop-restoration stage replays the decoder's own kernel instead of decoding the re-coded tile

The chosen Wiener units used to be realised by DECODING the re-coded tile
(5.6% of a 4K frame), purely to reach the restored reference frame. Loop
restoration reads nothing of that tile beyond the per-unit filters the
stage just chose, so the final replay now keeps its post-CDEF luma plus
the TRUE post-deblock stripe-border rows (plane_snapshot, exactly the
rows restoration::lr_src_row substitutes) and runs
apply_loop_restoration_plane on them. Chroma restores nothing, so only
luma moves; the wide-margin stash's luma is refreshed in place.

Pinned by encoder::tests::filter_replay_final_matches_the_capture_decode,
which now also decodes the re-coded tile and asserts picture, chroma and
wide-margin luma identical (fired on 8 frames of the gate clip).
perf(av1): the filter replay's CDEF reads the deblock cache instead of copyingAhmet Kaan Gümüş · 1085bf2
perf(av1): the filter replay's CDEF reads the deblock cache instead of copying

Every CDEF unit reads the pre-CDEF planes, so apply_cdef opened by copying
all three (~19 MB at 4K) into a scratch. The replay already holds an
untouched copy of exactly those planes -- the post-deblock cache the working
planes were copied FROM -- so it hands them in and the copy does not happen.
4K/8 threads: cdef replay 162 -> 124 ms.
perf(av1): the filter stage's capture decode replaced by one more filter replayAhmet Kaan Gümüş · 2d19659
perf(av1): the filter stage's capture decode replaced by one more filter replay

The stage decoded the coded tile a SECOND time after the search -- 10% of a
4K frame's encode -- only to reach the post-CDEF plane the loop restoration
search reads and the picture the stage splices back. Both come out of one
more replay of the winning deblock/CDEF parameters on the pre-filter planes
the search already captured: the same two kernels, on the same input, in the
same order. The re-coded tile still carries the cdef_idx literals, which the
replay is handed directly.

Also gates the per-trial stage timers on par::stage_times: two Instant::now()
ran per transform trial and per mc::predict call in every cfg(test) build
whether or not anyone read the breakdown.
feat(av1): local warp on by default and a looser second-reference margin, re-judged at the new rate weightAhmet Kaan Gümüş · 70b0f42
feat(av1): local warp on by default and a looser second-reference margin, re-judged at the new rate weight

Halving LAMBDA_SCALE re-opened every decision constant taken at the old
weight. Re-measured on the native gate, one run per arm:

- local warp (EC_AV1_WARP) KEPT ON: +16.7/-0.5, +47.0/+19.1, +51.3/-14.3
  against the base's +17.0/-0.3, +47.0/+19.2, +51.6/-14.2 -- two rows down
  on both columns, one flat. Fires on 5.4/3.3/3.3% of motion_mode blocks;
  clean under EC_COMP_MISMATCH=1 and under EC_AV1_TILES=2:2.
- LEAF_SECOND_NEW_MARGIN 0.8 -> 1.2, the floor of a re-swept bowl
  (0.6/0.8/1.2/1.6/never = +16.9/+16.7/+16.2/+16.4/+16.4 on the 1080p film),
  for ~10% encoder wall on the film clips.
- OBMC, SPLIT_RD_THRESHOLD, EXTRA_NEW_SKIP_MARGIN, COMP_NEARNEAR, the coding
  pyramid and CHROMA_TOP_K re-measured and left where they were, each with
  its new table at its decision site.

Native, defaults: +16.2/-1.1, +46.6/+18.8, +51.3/-14.4.
feat(av1): a local-warp candidate behind EC_AV1_WARPAhmet Kaan Gümüş · a745879
feat(av1): a local-warp candidate behind EC_AV1_WARP

The 3-symbol motion_mode alphabet in the tile writer (num_proj_ref
mirrored from the decoder), the encoder-side WARPED_CAUSAL candidate
built by the decoder's own find_samples/select_samples/find_projection/
warp_affine, and the frame's allow_warped_motion threaded into the
encoder's trial decode -- hard-coding it false there desynced every
warp-knob stream.
feat(av1): an OBMC candidate for the 32x32 single-reference winner, measured and defaulted offAhmet Kaan Gümüş · 84a1ea3
feat(av1): an OBMC candidate for the 32x32 single-reference winner, measured and defaulted off

The encoder now offers the 32x32 single-reference winner an OBMC_CAUSAL
candidate built by the DECODER's own plan and blend (decode::obmc_plan /
obmc_run, libaom av1_build_obmc_inter_prediction) off the committed
neighbours' mvs the search grid already carries, prices the motion_mode
symbol against the default obmc CDF, and the tile writer codes whichever
value won. obmc_plan lost its Neighbours parameter for the two filter bands
themselves so an encoder with a fixed interpolation filter can call it; no
second implementation of the blend exists.

MEASURED and NOT KEPT ON: native crop BD with it on is +18.2/+0.9,
+47.3/+19.2, +59.1/-10.0 against +18.0/+0.7, +47.3/+19.2, +59.4/-10.0 off
-- one row down, one flat, one up, short of the two-down-one-flat rule. It
is behind EC_AV1_OBMC=1 with the numbers at the decision site; the default
path is byte-identical to the SIMPLE-only commit before it. Only the 32x32
winner is offered OBMC and the price is the static-CDF estimate: the leaves
and a real-CDF price are the upgrade path.

Byte-exact either way: EC_COMP_MISMATCH=1 prints nothing with OBMC on, and
every decode round trip (our own decoder and ffmpeg) is sample-exact.
feat(av1): arm is_motion_mode_switchable and code a SIMPLE motion_mode symbol on every eligible inter blockAhmet Kaan Gümüş · ba4398c
feat(av1): arm is_motion_mode_switchable and code a SIMPLE motion_mode symbol on every eligible inter block

The encoder's inter frames now set is_motion_mode_switchable and the tile
writer codes the motion_mode/obmc symbol decode.rs' read_motion_mode has
always read, for every single-reference inter block libaom's
motion_mode_allowed accepts. Every block still chooses SIMPLE_TRANSLATION,
so the streams are the old ones plus the header bit and one symbol per
eligible block: 7106 -> 7111 bytes at q=150 and 25963 -> 25969 at q=60 on
the 640x384 gate clip (+0.07%/+0.02%), pins updated.

Eligibility is decode.rs' own motion_mode_eligible term for term, sharing
the neighbour walk through the new has_overlappable_neighbour so writer and
decoder cannot drift; write_motion_mode prints an EC_COMP_MISMATCH line if
a block was trialled OBMC but coded SIMPLE, and EC_TRACE_MODE_STEP prints
the writer-side EC_MMW counterpart of the decoder's EC_MM rung.

is_motion_mode_switchable is threaded to the raw inter tile decode entry
points and carried on Encoded (stale-header class, same contract as
tx_select/start_cdfs) -- hard-coding false there desynced three decode
round trips before it was threaded.
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.