forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on c76c7ff7e6d7698912d97b69ffc2493583ac5eba

2026-09-06

feat(av1): the motion search starts from a step scaled by the reference's order-hint distanceAhmet Kaan Gümüş · d53c852
feat(av1): the motion search starts from a step scaled by the reference's order-hint distance

A reference twice as far back holds content that has moved about twice as
far, so motion::search now takes that reference's own order-hint distance and
opens its log stage at step * (1 + 0.5 * (dist - 1)), capped at 4x the flat
step. LAST stays at the flat step; GOLDEN (the key frame, 2..12 frames back
in this GOP) and ALTREF (2) widen.

The hints had to be armed before the search: tile::arm_order_hints ran beside
the tile WRITE, so ref_distance read (0, 0, [0; 7]) and returned 1 for every
reference -- the first sweep came out byte-identical at every scale (the knob
never reached the tool). Armed in encode_inter_frame's header setup, the
traced distances are ALTREF 2 and GOLDEN 2..12.

Sweep vs libaom (1080p/2160p, screen byte-identical at every point): 0
+100.7/+115.8, 0.25 +98.5/+112.2, 0.375 +98.2/+115.6, 0.5 +94.4/+104.3, 0.625
+95.9/+106.5, 0.75 +92.8/+112.7, 1.0 +98.8/+113.0. Ships at 0.5 (-6.3/-11.5
/flat, vs rav1e +47.5/+63.6/+13.8); wall 5.7s/5.1s/5.8s, unchanged.

Byte pins move with the streams.
feat(av1): NEAREST_NEWMV / NEW_NEARESTMV compound candidates on by defaultAhmet Kaan Gümüş · 757ff82
feat(av1): NEAREST_NEWMV / NEW_NEARESTMV compound candidates on by default

Each half-new mode pairs the compound stack's derived NEAREST vector on one
side with the single-reference search this block already ran on the other, so
neither costs a joint search. Both mirror decode.rs assign_compound_mv: no DRL
index, residual against compound stack entry 0.

Measured alone on the BD gate against the grid fix's base (+101.7/+116.6/+73.3
vs libaom): half-new +100.7/+115.8/+73.3 keeps (two down, screen byte-identical
-- it codes NEAREST_NEAREST only) and ships on; NEAR_NEARMV +102.2/+116.4/+73.3
does not and stays behind EC_AV1_COMP_NEARNEAR, both arms together
+100.7/+116.1/+73.3. Compound share 12.1/13.0/31.9%; NEAREST_NEW 93/33/0,
NEW_NEAREST 39/13/0 blocks per gate run. Wall 6.6s/5.1s/5.6s.

Byte pins and the coefficient-price drift bound move with the streams (the
gate's own failure output); the drift widens to +29.6% because a compound
block's second reference tree, compound mode symbol and MV residual are all
outside the coefficient sum.
Merge branch 'lane-av1tiles' (d53ac525): multi-tile frames (uniform spacing, per-tile CDF/LR/neighbour reset) with deterministic parallel tile writesAhmet Kaan Gümüş · b58ff3f
Merge branch 'lane-av1tiles' (d53ac525): multi-tile frames (uniform spacing, per-tile CDF/LR/neighbour reset) with deterministic parallel tile writes

Sample-exact through our decoder and ffmpeg at 1x1/2x1/1x2/2x2/4x2; default
1x1 byte-identical. Root cause on the way: the writer's intra_inter/tx-size
contexts asked frame-relative availability (class: new map ignores tile
edge). Tile threads buy no wall yet: the search is still whole-frame.
fix(av1): the encoder's own mi grid recorded a compound block as single-referenceAhmet Kaan Gümüş · 9b0008b
fix(av1): the encoder's own mi grid recorded a compound block as single-reference

record_mi published every 32x32 inter block with ref_frame1 = NO_REF1 and
mv1 = (0,0), so from the first compound block on the encoder searched against
a grid the tile writer -- and therefore the decoder -- never had. The damage
is silent: the reconstruction the gate measures comes from re-decoding the
written tile, so 95 blocks per gate run were predicted from a vector the
encoder had never trialled and the ffmpeg sample-exact assert still passed.

The grid now votes both references, both vectors and decode.rs' own is_new_mv
(NEWMV plus compound modes 2/3/7). EC_COMP_MISMATCH=1 arms a writer-side
report of every block whose written vectors differ from the trialled ones:
95 -> 0 over the whole BD gate.

BD vs libaom +120.1/+128.5/+73.0 -> +101.7/+116.6/+73.3, vs rav1e
+67.8/+86.0/+13.7 -> +54.0/+74.5/+13.8; compound share 8.8/8.8/13.8% ->
11.5/12.9/31.9%. Wall 6.4s/5.1s/5.6s.

Also adds writer support and env-gated encoder candidates for NEAR_NEARMV /
NEAREST_NEWMV / NEW_NEARESTMV (EC_AV1_COMP_NEARNEAR, EC_AV1_COMP_HALFNEW),
both default off pending their own measurement.
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): writer support for NEAR_NEAR / NEAREST_NEW / NEW_NEAREST compound modesAhmet Kaan Gümüş · d49885f
feat(av1): writer support for NEAR_NEAR / NEAREST_NEW / NEW_NEAREST compound modes

The tile writer now forms three more of the spec's INTER_COMPOUND_MODES,
mirroring decode.rs assign_compound_mv exactly: NEAR_NEARMV walks the DRL
from index 1 and reads stack entry ref_mv_idx + 1, NEAREST_NEWMV and
NEW_NEARESTMV code no DRL index at all and write their single residual
against stack entry 0. is_new_mv now reports the decoder's own modes
2/3/4/5/7.

No encoder candidate forms them yet, so every gate stream is byte-identical:
BD +120.1/+128.5/+73.0 vs libaom, +67.8/+86.0/+13.7 vs rav1e, same bytes at
all twelve ladder points.
Merge branch 'lane-av1comp' (1300db86): compound reference prediction (NEAREST_NEAREST / GLOBAL_GLOBAL / NEW_NEW, LAST+GOLDEN and LAST+ALTREF) on by defaultAhmet Kaan Gümüş · 583d98d
Merge branch 'lane-av1comp' (1300db86): compound reference prediction (NEAREST_NEAREST / GLOBAL_GLOBAL / NEW_NEW, LAST+GOLDEN and LAST+ALTREF) on by default

BD vs libaom +120.1/+128.5/+73.0, vs rav1e +67.8/+86.0/+13.7 (all down
from 1dbd8f15); compound takes 8-14% of inter blocks. Two defects found on
the way: write_single_ref dropped a compound neighbour's second reference
from its context votes, and comp_group_idx/compound_idx must not be written
under a sequence that clears masked/jnt compound.
test(av1): tile BD-cost knob for the gate and a 1080p tile/thread wall tableAhmet Kaan Gümüş · ebca9e8
test(av1): tile BD-cost knob for the gate and a 1080p tile/thread wall table

EC_AV1_TILES in a test build lets the BD gate code the same ladder under a
tile grid; the 1080p wall table shows tile threads buy nothing yet -- the
per-tile ENTROPY write is a few percent of the frame, the search is still
whole-frame and single-threaded.
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.
Merge branch 'lane-av1fsearch' (0a6ed84e): filter search scores per unit in one chunked pass and replays CDEF candidates off cached deblocked planesAhmet Kaan Gümüş · 39035c8
Merge branch 'lane-av1fsearch' (0a6ed84e): filter search scores per unit in one chunked pass and replays CDEF candidates off cached deblocked planes

Byte-identical to 7f2ab3ea (FNV sets on the three gate clips, BD
unchanged); instructions -11.2%, ladder wall 5.34/4.91/7.06 -> 4.51/4.08/4.80 s.
The filter stage is 12.9% of the encode now (26.3% before).
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): a frame's tiles are written in parallel on the crate's own poolAhmet Kaan Gümüş · 1878642
feat(av1): a frame's tiles are written in parallel on the crate's own pool

EC_AV1_TILE_THREADS workers (default 1) take bands of the frame's tiles;
each tile is written from the frame's own starting tables into its own slot,
so the bytes never depend on the thread count -- pinned by
tile_bytes_do_not_depend_on_the_thread_count at 2x1/1x2/2x2/4x2.
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>.
feat(av1): reference_select frames -- the comp_mode symbol and its skip-mode header gateAhmet Kaan Gümüş · 14a71ba
feat(av1): reference_select frames -- the comp_mode symbol and its skip-mode header gate

The frame-header writer refused reference_select outright; it now writes the
bit, and with it spec 5.9.22's skip_mode_present gate (skipModeAllowed
mirrored from ec-av1-syntax's own read_skip_mode_params, off the per-reference
order hints the encoder now hands the header from its DPB). Every inter block
of a reference_select frame codes a comp_mode symbol at
mvstack::reference_mode_ctx's context -- the writer side of decode.rs
read_comp_mode -- and every block still names SINGLE, so the only stream
change is that one symbol per block.

Armed by EC_AV1_COMPOUND=1 in a test build; off by default until compound
candidates exist to pay for the bit.
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.
perf(av1): score the filter search's two sides once each, per unitAhmet Kaan Gümüş · 2b23fd6
perf(av1): score the filter search's two sides once each, per unit

The filter search's per-64x64 error pass (`unit_sse`) was the encoder's
second-largest self-time symbol (10.6%), and the frame-level `plane_sse`
that ran beside it (1.7%) summed the very same terms a second time.

Two exact changes, no decision moved (byte-identical streams on the
three gate clips):

* `unit_sse` returns the frame total as well, so `plane_sse` is gone,
  and its inner loop walks unit-sized chunks with a `u32` accumulator
  instead of dividing `col / unit` per sample and accumulating straight
  into `out` -- a shape LLVM turns into a reduction.
* Each candidate's luma and chroma error is memoized under the
  parameters that side actually reads: `apply_deblock` filters luma on
  `level[0..2]` and chroma on `level[2..4]`, and CDEF's strengths are
  per plane type, so the ~11 luma-deblock candidates all share one
  chroma score and the 9 chroma-CDEF candidates all share one luma
  score. The luma deblock level is in the CHROMA key because CDEF's
  direction search runs on the post-deblock luma window and chroma
  reuses that direction -- except when chroma CDEF is off, which is the
  case that makes the deblock stages share.

1080p / 2160p / screen ladder wall 5.34/4.91/7.06 -> 4.64/4.21/4.91 s.
Merge branch 'lane-av1trial' (782b5748): trial-set census, exact SAD pre-pass skip, split RD breakout (0.125 lambda)Ahmet Kaan Gümüş · 826851c
Merge branch 'lane-av1trial' (782b5748): trial-set census, exact SAD pre-pass skip, split RD breakout (0.125 lambda)

Wall -11.0/-11.1/-6.9% (instructions -10.0% 1080p) for BD +0.1/+0.3/-0.2
vs libaom (+121.2/+146.4/+79.1). Chroma top-K ships off (measured: SAD
ranks the chroma winner first only 67-77% of the time). Census via
EC_AV1_CENSUS=1 on examples/enc_probe.
Merge branch 'lane-av1pyr' (a5447b64): two-level frame pyramid (opt-in), target-bitrate rate mode, encode_frames/flush APIAhmet Kaan Gümüş · 7c2597d
Merge branch 'lane-av1pyr' (a5447b64): two-level frame pyramid (opt-in), target-bitrate rate mode, encode_frames/flush API

Pyramid ships OFF: 4:-16:8 measures +131.9/+178.7/+78.4 vs libaom against
flat +121.1/+146.1/+79.3 (hidden frame predicted mini_gop pictures ahead
under the same search range; leaves reach it only via extra-ref modes).
Defect fixed on the way: decode_inter_frame_tile_lr hard-coded
NO_SIGN_BIAS, desyncing the encoder's own filter-search re-decode for any
backward reference (surfaced as a missing-picture refusal).
perf(av1): RD breakout on the inter split trial, chroma top-K lever, leaf censusAhmet Kaan Gümüş · 4e368e4
perf(av1): RD breakout on the inter split trial, chroma top-K lever, leaf census

The census says the split trial runs on nearly every non-skip 32x32 block and
wins 7.6% of the time on film, 3.0% on screen. A 32x32 whose whole-block RD
cost per pixel comes out under 0.125*lambda (and a 16x16 leaf likewise) is no
longer offered the split: -10.0%/-5.7% instructions (1080p/screen) for
+0.1/+0.3/-0.2 BD points vs libaom. Chroma top-K by prediction SAD ships off:
no K bought >=5% wall inside +0.3 BD.
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'.
perf(av1): trial-set census, and the intra SAD pre-pass only when something ranks by itAhmet Kaan Gümüş · bf299cd
perf(av1): trial-set census, and the intra SAD pre-pass only when something ranks by it

The key-frame luma search summed a per-mode SAD the unpruned default never
reads (top_k is None there); byte-exact on all three probe clips, ~2% wall.
EC_AV1_CENSUS=1 counts the search's full RD trials by kind and histograms
where the RD winner sat in the SAD ranking.
Merge branch 'lane-av1price' (128ba78b): byte-exact pricer speed -- telescoped symbol cost, pricing coder without the carry state, interior context fast path, all-zero eob testAhmet Kaan Gümüş · e6e02af
Merge branch 'lane-av1price' (128ba78b): byte-exact pricer speed -- telescoped symbol cost, pricing coder without the carry state, interior context fast path, all-zero eob test

-5.3% instructions on the 1080p ladder, streams byte-identical (12/12 FNV
points on the three gate clips against its base; the byte pins from
lane-av1mv hold on the merged tree).
Merge branch 'lane-av1mv' (8f1e2498): NEWMV against GOLDEN/ALTREF with stack-seeded starts and a swept early-outAhmet Kaan Gümüş · 3e400dc
Merge branch 'lane-av1mv' (8f1e2498): NEWMV against GOLDEN/ALTREF with stack-seeded starts and a swept early-out

BD vs libaom +121.1/+146.1/+79.3, vs rav1e +71.8/+97.5/+17.2 (all down or
flat from 52819482); wall +2-3% on the film clips, inside this box's
run-to-run noise. Census: motion::search is not the wall (halving its evals
moved a 6 s ladder by 0.2 s).
feat(av1): a two-level frame pyramid in the encoder facadeAhmet Kaan Gümüş · d496905
feat(av1): a two-level frame pyramid in the encoder facade

Hidden ALTREF coded ahead of its display position and re-output by a
show_existing_frame header, per-level quantizer offsets, a per-level rate
loop and packet dts/level. The flat one-in-one-out path is untouched.
Merge branch 'lane-av1lr' (12055f9c): per-64x64 CDEF strengths and luma Wiener loop restoration in the encoderAhmet Kaan Gümüş · 56a796a
Merge branch 'lane-av1lr' (12055f9c): per-64x64 CDEF strengths and luma Wiener loop restoration in the encoder

Both searched with the decoder's own kernels on decoder-exposed post-deblock /
post-CDEF planes (FrameCtx::capture_stages, one bool read when off). BD vs
libaom +122.7/+147.3/+79.4, vs rav1e +73.4/+98.5/+17.2 (all six down from
d5fc99e0); wall +0.6 s 2160p / +0.8 s screen for the tile re-code.
perf(av1): settle an all-zero transform block before the scan-order searchAhmet Kaan Gümüş · c3d93a7
perf(av1): settle an all-zero transform block before the scan-order search

Finding the end of block walks the scan backwards through one dependent
grid load per position, so an all-zero block pays the whole scan -- once
per priced candidate. A straight-line all-zero test runs first: it
vectorises, and a block that codes anything at all almost always codes its
DC, so the test stops at the first element. Byte-exact on all twelve ladder
points; 1080p ladder -0.41% instructions:u (110.14G -> 109.69G, ABAB x2).
perf(av1): gather a coefficient's context neighbours without per-neighbour edge testsAhmet Kaan Gümüş · 02bd8ae
perf(av1): gather a coefficient's context neighbours without per-neighbour edge tests

`neighbour` was a third of `write_coeffs`'s self time: five (base) or three
(base-range) loads, each behind its own pair of edge compares plus a slice
bound check, for every coefficient of every candidate the search prices. A
coefficient clear of the far edges reaches all of them, so that case indexes
straight off the position. Byte-exact on all twelve ladder points; 1080p
ladder -0.71% instructions:u (110.95G -> 110.15G, ABAB x2).
perf(av1): price a symbol string off its final interval, not one log2 per symbolAhmet Kaan Gümüş · fb3fa69
perf(av1): price a symbol string off its final interval, not one log2 per symbol

The bit account the RD search prices with cost `__log2_fma` 8.2% of the
encoder's profile, one call per symbol written or priced. A symbol costs
`log2(r) - log2(rng)` for the two widths it narrows between, and the next
symbol's `r` is this one's `rng` shifted up by the renormalisation, so a
whole string's cost telescopes to `bits_base + shifts - log2(rng)`: one
`log2` per price asked for. Same reading as libaom's `od_ec_enc_tell_frac`.

A pricing coder also keeps `low`, `cnt` and the precarry buffer whose only
consumer is `finish`, which a search never calls; `SymbolEncoder::pricer`
drops that bookkeeping and keeps the interval width the account reads.

Byte-exact: all twelve ladder points of the three gate clips keep their
length and FNV-1a hash. 1080p ladder -4.76% instructions:u (116.49G ->
110.95G, ABAB x2), of which the pricer accounts for -0.92%.
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.