forge
Explore
Log in

Don't you dare go Hollow

Commits

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

2026-09-07

fix(av1): every distortion score is over the inside of the frame onlyAhmet Kaan Gümüş · 62921b6
fix(av1): every distortion score is over the inside of the frame only

The search's SSE scored the PADDING for every block the true frame edge
cuts through -- samples the decoder reconstructs and the display crop
throws away. lane-b64b fixed the 64x64 root alone; this moves the clip
into Plane::block_sse itself, so every mode, transform, CfL alpha and
partition trial is ranked the way libaom's av1_dist_block measures
(over max_blocks_wide/high). intrabc's own distortion clips too.

Both gate films are superblock-aligned so nothing default moves; the
user's export sizes all straddle. EC_AV1_EDGESSE=0 restores the old
score for the before/after arms, EC_AV1_EDGE_CENSUS=1 counts the
straddling blocks and their padding share, EC_AV1_NATIVE_CROP=WxH puts
the native gate on a non-superblock-aligned window.
Merge branch 'lane-b64b' (6f53db9b): the 64x64 root prices compound references and depth-1 var-tx, and edge superblocks score only the insideAhmet Kaan Gümüş · e08e2e6
Merge branch 'lane-b64b' (6f53db9b): the 64x64 root prices compound references and depth-1 var-tx, and edge superblocks score only the inside

12-frame film A +37.5/+7.6 -> +35.4/+5.4, film B +54.1/+23.9 ->
+47.6/+17.0 (compound off on screen); long-GOP at the lane's base film A
+39.2/+1.3, film B +118.5/+25.1. Pins re-taken on the merged tree.
Merge branch 'lane-arfcen' (f550d2e1): the temporal lambda map runs on the pyramid path; a top ARF names the ARF two groups back as its second referenceAhmet Kaan Gümüş · e7e40c6
Merge branch 'lane-arfcen' (f550d2e1): the temporal lambda map runs on the pyramid path; a top ARF names the ARF two groups back as its second reference

The pyramid path passed an empty lookahead, so the shipped tpl map was
inert on every default stream; the top ARF named the key twice. Long-GOP
film A +43.1/+4.6 -> +40.9/+3.1, film B +129.0/+34.3 -> +125.6/+32.0;
12-frame film A +37.1/+7.3, film B +52.5/+22.3. Pins 9853 / 35866.
Refuted: anchor density, hidden-only lambda, distance-scaled search.
feat(av1): a 64x64 root may be taken at a superblock the frame edge cutsAhmet Kaan Gümüş · cb5978f
feat(av1): a 64x64 root may be taken at a superblock the frame edge cuts

sb64_legal asked for the whole superblock to be inside the true frame; AV1
asks only for its half (has_cols/has_rows), which is what the writer already
codes. The trial is now ranked over the inside part alone (inside_sse), so
the root is not chosen for predicting padding the source does not have.
Both gate films are superblock-aligned, so only the user's own arbitrary
export sizes reach this: a 232x168 synthetic decodes sample-exact through
both decoders with 9 edge roots. EC_AV1_B64EDGE=0 restores the old rule.
feat(av1): a group's top ARF names the ARF two groups back as its second anchorAhmet Kaan Gümüş · 6aa3e57
feat(av1): a group's top ARF names the ARF two groups back as its second anchor

The ARF-vs-ARF census found our first top ARF naming the SAME picture as LAST
and GOLDEN (refs LAST@-8 GOLDEN@-8), where rav1e's ARFs read two distinct
anchors of their own chain. The slot the ARF is about to refresh still holds
the anchor from two groups back while this frame is coded, so naming it as
ALTREF costs no DPB slot and no extra encode.

Long-GOP gate on top of the pyramid tpl window: film A +42.8/+4.5 ->
+40.9/+3.1, film B +127.3/+32.9 -> +125.6/+32.0 -- both films down on both
columns. Pins re-taken: 9853 at q=150, 35866 at q=60; EC_AV1_ARF_ALTREF=0
restores 9859 / 35904.
feat(av1): a 64x64 root may split its luma into four TX_32X32 unitsAhmet Kaan Gümüş · 3f6896d
feat(av1): a 64x64 root may split its luma into four TX_32X32 units

commit_inter_luma reaches side 64 now (its halved transform is TX_32X32),
so the root's residual takes the same var-tx decision every other inter
block does, and the writer's Whole64 arm codes txfm_split=1 with the four
units write_luma_tus slices out of the block's 64x64 levels. The pricer
learns the new variant in the same diff. EC_AV1_B64VARTX=0 restores the
single TX_64X64.
test(av1): re-take the encoder's stream pins for the pyramid tpl window, and wire a second past anchor for the top ARF behind EC_AV1_ARF_ALTREFAhmet Kaan Gümüş · 51ec13e
test(av1): re-take the encoder's stream pins for the pyramid tpl window, and wire a second past anchor for the top ARF behind EC_AV1_ARF_ALTREF

The pins move by construction: every superblock of the four pinned pictures
is priced at its own temporal lambda now (9835 -> 9859 at q=150, 35798 ->
35904 at q=60, EC_AV1_TPL_PYRAMID=0 restores the pair). The long-GOP gate
keeps the change on both films and both columns (film A +43.1/+4.6 ->
+42.8/+4.5, film B +129.0/+34.3 -> +127.3/+32.9) and so does the 12-frame
gate on its two real film rows.

EC_AV1_ARF_ALTREF (default off) names the ARF from two groups back as the top
ARF's ALTREF instead of the key it already reads as GOLDEN -- the census
found our first ARF naming the SAME picture as LAST and GOLDEN where rav1e's
ARFs read two distinct anchors. The slot the ARF is about to refresh still
holds that older anchor, so it costs no DPB slot; its gate arm is running.
feat(av1): the rate loop prices a run by its measured level modelAhmet Kaan Gümüş · 0a23745
feat(av1): the rate loop prices a run by its measured level model

The mini-GOP byte split assumed ONE hidden frame per group and priced it
at a flat two leaves; the group has coded two hidden frames since the mid
level landed, and the census reads the top ARF at 24x a leaf, not 2x.
The two errors cancelled, so neither could be fixed alone (lane-pyr6).

Both are replaced by one measured model: a level's bytes/frame is
log-linear in its own q offset at d(ln bytes)/d(q_idx) = -0.0557, fitted
over films A and B at three quantizers each, and the key is priced
through the same function (KEY_WEIGHT = 1.08 on top of it). gop_shape
enumerates the frames a run really codes, so the plan spends the run's
budget exactly, and the loop re-plans the rest of the run from what it
has actually spent -- the key frame is never steered, and a level whose
q hits the floor cannot spend its share.

48-frame bitrate gate, pyramid arm: 384k +3.0%, 768k -0.0%, 1536k +0.2%,
2M -4.4% (was -0.4% / -6.3% at the two rates it covered), tolerance cut
from +-10% to +-5% with two new bitrate arms.
feat(av1): compound references at the 64x64 rootAhmet Kaan Gümüş · 52db304
feat(av1): compound references at the 64x64 root

The 64 root offered only single-reference LAST. It now also prices the
LAST + GOLDEN/ALTREF pairs at NEAREST_NEARESTMV, GLOBAL_GLOBALMV and
NEW_NEARESTMV (the NEW half is the vector the root's own search already
found -- the two remaining modes need the second reference's own NEWMV
vector, i.e. a second 64x64 search, which is the wall this root exists
to save), and the writer's Whole64 arm codes one through
write_compound_block at SB_MI 16 with no motion_mode symbol.

EC_AV1_B64COMP=0 restores the single-reference root.
feat(av1): the temporal lambda map runs on the pyramid path, which is every default streamAhmet Kaan Gümüş · ccbcc73
feat(av1): the temporal lambda map runs on the pyramid path, which is every default stream

encode_pyramid_inter passed an empty lookahead window, so the propagating
per-superblock lambda map lane-av1tpl2/3 shipped has been inert on every
stream the encoder writes by default since the pyramid became the default --
it only ever ran on the flat A/B arm. The window is the group's own buffered
sources: display-order successors for a frame inside the leaf run, and the
group's leaves in reverse display order for its top ARF, whose successors are
not buffered yet and which those leaves predict backward from.

Measured through enc_probe on film B against the control's own rate/quality
slope: 1.9% fewer bytes at the q=150 point's PSNR and 0.2% at q=90, wall
unchanged. EC_AV1_TPL_PYRAMID=0 restores the old behaviour.

Also from the census lane: EC_AV1_LAMBDA_HIDDEN, a rate weight for hidden
frames alone (default 1.0 = unchanged), which is the knob the pyramid's q
offsets cannot express; the sweep says 1.0 is already the optimum.
test(av1): tests that read a process-global hit counter take the exclusive knob lock; a reader-locked sibling zeroed the reference counter under the parallel suiteAhmet Kaan Gümüş · 2871886
test(av1): tests that read a process-global hit counter take the exclusive knob lock; a reader-locked sibling zeroed the reference counter under the parallel suite
fix(av1): keep the rate loop's one-hidden-frame group splitAhmet Kaan Gümüş · 84491e1
fix(av1): keep the rate loop's one-hidden-frame group split

Pricing the group by its real hidden-frame count is the truthful model and
lands the 48-frame bitrate gate -9.4% / -14.9% under target against -1.8% /
-6.3%: the old split's over-allocation cancels ARF_WEIGHT's under-pricing of
a hidden frame, and fixing one alone un-cancels them. Documented at the line
with the measured pair; recalibration is a rate-control lane.
feat(av1): a fourth pyramid level -- hidden quarter-point ARFsAhmet Kaan Gümüş · e9fd8a5
feat(av1): a fourth pyramid level -- hidden quarter-point ARFs

Within a mini-GOP the leaf run now carries two more hidden frames, at the
middle of each half (pictures 2 and 6 of eight), coded at their own
quarter_q_offset -- the sixth EC_AV1_PYRAMID field, off by default until
the long-GOP sweep picks its offset. Every leaf names the nearest hidden
frame behind it as LAST_FRAME and the nearest one ahead as ALTREF_FRAME,
which the leaf loop now derives from one sorted list of the group's inner
hidden frames instead of the mid frame's index (byte-identical at three
levels and at two). The quarters take DPB slots 5 and 6; the whole slot
map is documented on QUARTER_SLOTS. RateLoop prices a group as h hidden
frames plus mini_gop - h leaves instead of assuming one hidden frame.
feat(av1): the pyramid codes its key frame 48 q-steps below baseAhmet Kaan Gümüş · 20d60a5
feat(av1): the pyramid codes its key frame 48 q-steps below base

The long-GOP sweep (lanes/keyq.sweep.txt): every arm from -16 to -48
improves both films on both columns, -48 is the floor (film A +52.0/+11.7
-> +43.5/+4.6, film B +144.5/+44.3 -> +131.3/+35.0), -64 overshoots on
film B, and a deeper ARF under the same key gives the bytes back. The
12-frame gate agrees (film A +43.3/+15.0 -> +38.5/+8.2, film B
+66.9/+35.1 -> +58.2/+26.5), so the offset is not gated on GOP length.

The rate loop had to learn the offset: a run holds one key frame, so the
key slot never gets a second frame to steer on, and the finer key ran the
48-frame bitrate gate +10.8% over target. Its byte share is now priced
through the calibration slope and the rest of the run pays for it (-0.3%).

Pins re-taken: 8590 -> 9778 and 28535 -> 35450.
feat(av1): a key-frame quantizer offset for the coding pyramidAhmet Kaan Gümüş · f7ddd74
feat(av1): a key-frame quantizer offset for the coding pyramid

The 48-frame census found our key frame coded at base q while its own
ARFs sit 32 steps finer, where rav1e (key 100 / arf 120 / leaf 153) and
libaom (63 / 95 / 163) both make the key the best frame of the run.
Pyramid::key_q_offset carries that offset, read as the fifth field of
EC_AV1_PYRAMID; the default is 0 until the sweep picks a point, so every
stream is byte-identical here.
Merge branch 'lane-pyr5' (9d330425): a third pyramid level (hidden mid ARF at -8) for GOPs longer than 1.5 mini-GOPs; the 48-frame censusAhmet Kaan Gümüş · 5c50b7f
Merge branch 'lane-pyr5' (9d330425): a third pyramid level (hidden mid ARF at -8) for GOPs longer than 1.5 mini-GOPs; the 48-frame census

Long-GOP film A +55.2/+12.8 -> +52.1/+11.7, film B +151.3/+47.4 ->
+145.3/+45.0; 12-frame streams byte-identical. Census: the gap is the
ARFs and the key frame (references spend 22-37% of the stream on the
key, ours 10-11%), not the leaves. Our decoder cannot read libaom's
film B streams (Golomb tail) -- a decoder defect to fix.
Merge branch 'lane-tx64' (b771ffc0): the 64x64 inter root codes a real residual; the root's early-out clamped so it ships at every presetAhmet Kaan Gümüş · 6932598
Merge branch 'lane-tx64' (b771ffc0): the 64x64 inter root codes a real residual; the root's early-out clamped so it ships at every preset

The forward 64-point transform already existed; the missing ends were the
64-sided residual scratch and the writer's non-skip Whole64 arm. Film A
+43.0/+15.0 -> +42.9/+14.8, film B +64.7/+34.0 -> +63.3/+31.5 on the
12-frame gate at the 16:-24:16 base; the residual arm is off on screen
content. Speed 6 improves on every row. Pins re-taken on the merged tree
(8:-32:16 pyramid): 8590 / 28535.
fix(av1): the third pyramid level only inside a run that holds more than one mini-GOPAhmet Kaan Gümüş · 0061431
fix(av1): the third pyramid level only inside a run that holds more than one mini-GOP

A 12-picture GOP is one absorbed group of 11 and pays 2.8 BD points against
libaom on film B for a second hidden frame at every offset measured, while a
48-picture GOP gains 6.0. Gated on gop > mini_gop * 1.5, so the 12-frame gate
codes byte for byte what it coded before (+43.9/+15.6, +68.4/+38.2).
feat(av1): the three-level pyramid ships by default (mid ARF at -8)Ahmet Kaan Gümüş · 7aedb7b
feat(av1): the three-level pyramid ships by default (mid ARF at -8)

Long-GOP sweep against a control arm on this head (lanes/pyr5.sweep.txt):
film A +55.2/+12.8 -> +52.1/+11.7, film B +151.3/+47.4 -> +145.3/+45.0 vs
libaom cpu-used 6 / rav1e speed 6. Byte pins are unmoved (their 4-picture
clip codes one group of 3, which has no room for a mid level).
test(av1): the ignored encoder:: gates raced on the process-global speed presetAhmet Kaan Gümüş · 8c24e30
test(av1): the ignored encoder:: gates raced on the process-global speed preset

`Av1Encoder::with_speed` stores the preset in a process-global atomic
(`speed::SPEED`) and `par::set_tile_threads` in another, so with the default
`--test-threads` the ignored gate
`every_speed_preset_decodes_sample_exact_through_both_decoders` (presets
0..=10) and the `tile_*`/`filter_stage_*` wall tables changed the preset
UNDER five concurrently encoding gates: four died in the encoder's own
"a reference frame selected with no picture at this frame's own
ref_frame_idx slot" (a sequence planned at one preset continuing at another)
and `the_facade_codes_the_same_bytes_as_encode_sequence` on a byte compare.
Every one of them passes standalone or at --test-threads 1.

Root fix, test-only: `speed::KNOBS`, a reader/writer lock -- a test that SETS
a process-global knob holds `knob_write()` for its whole body, every other
`encoder::` test holds `knob_read()`, so a setter never overlaps an encode.
Poison is ignored so one failing gate does not turn every later one into a
lock panic. No production path changes; the temp files these gates write were
already PID-keyed and no test in the crate calls `set_var`.

Gates: the parallel run 28/28 twice (603 s, 658 s; it was 23 passed / 5 failed
before), --test-threads 1 28/28, `cargo test -p ec-av1 --release -j4`
545 passed / 43 ignored, `cargo check --workspace --all-targets` 0 errors and
0 ec-av1 warnings, pins 8446 / 28548 unchanged.
feat(av1): a third pyramid level -- a hidden mid ARF inside each mini-GOPAhmet Kaan Gümüş · 5502480
feat(av1): a third pyramid level -- a hidden mid ARF inside each mini-GOP

Pyramid gains mid_q_offset (EC_AV1_PYRAMID=<mini_gop>:<arf>:<leaf>[:<mid>],
'off' for the two-level shape). A group of at least four codes a second
hidden frame at the middle of its leaf run, off the anchor with the top ARF
as its backward reference; the leaves before it name it as ALTREF and the
first leaf after it starts its chain from it. Default stays two-level until
the long-GOP sweep decides.
feat(av1): a GOP-length-aware mini-GOP layout -- a short tail group is absorbedAhmet Kaan Gümüş · 52506a7
feat(av1): a GOP-length-aware mini-GOP layout -- a short tail group is absorbed

`Av1Encoder::encode_frames` closed every mini-GOP at `Pyramid::mini_gop`
flat, so a run that is not a multiple of it left a SHORT TAIL group: 12
pictures under mini_gop 8 coded 8 + 3, and lane-pyr4 measured that tail as
the whole disagreement between the two BD gates (the 12-frame gate wanted
16:-24:16, the 48-frame gate 8:-32:16).

`group_target()` now sizes the group being collected from the pictures left
before the next key frame -- both entry points know it (`encode_sequence`
sets gop = pictures.len(), the facade has its config) -- and absorbs a tail
shorter than half a group into the group before it.

  12-frame gate at 8:-32:16, film A / film B vs libaom / rav1e:
    fixed 8 + 3   +51.2 / +21.4   +91.0 / +53.5
    absorb -> 11  +43.9 / +15.6   +68.4 / +38.2   (bars rows improve too)
  48-frame gate: 47 inter pictures are 8 x 5 + 7 under BOTH rules, and the
  control arm confirms it byte for byte -- all eight ladder points identical,
  +55.2 / +12.8 and +151.3 / +47.4 either way.

The balanced-split variant (equal groups <= mini_gop, 6 + 5 at gop 12) was
measured and is worse on every row; a group-length-scaled ARF offset was
dropped unbuilt, since the absorbed group at arf -32 already beats the -24
the 12-frame gate used to prefer. Table and logs: lanes/gopad.sweep.txt.

`EC_AV1_GOP_LAYOUT=fixed` restores the old rule for an A/B.
Merge branch 'lane-pyr4' (e0a8b8a2): a 48-frame long-GOP film gate; the default pyramid is 8:-32:16, the long-GOP optimumAhmet Kaan Gümüş · d248e08
Merge branch 'lane-pyr4' (e0a8b8a2): a 48-frame long-GOP film gate; the default pyramid is 8:-32:16, the long-GOP optimum

Long GOP (48 pictures, gop 48): film A +67.4/+21.0 -> +55.7/+13.5, film B
+165.5/+57.6 -> +165.1/+56.6 vs libaom cpu-used 6 / rav1e speed 6. The
12-frame gate prefers 16:-24:16, so the optimum is GOP-length dependent;
long GOP governs because that is what the editor exports. Pins re-taken
on the merged tree with the 64x64 skip root: 8446 / 28548.
feat(av1): the coding pyramid decided on a long GOP -- Pyramid::default 16:-24:16 -> 8:-32:16Ahmet Kaan Gümüş · 0d3b9a0
feat(av1): the coding pyramid decided on a long GOP -- Pyramid::default 16:-24:16 -> 8:-32:16

The shipped shape came off bd_rate_screen_native, which codes 12 frames with
gop = 12; a mini-GOP is cut at every key frame, so any mini_gop over 12 codes
the SAME stream there and the 16 was really "one hidden ARF per 12-picture
GOP". On the new long-GOP arm (48 pictures, gop 48, the two real films, vs
libaom cpu-used 6 and rav1e speed 6 at -g 48) a real 16- or 32-picture group
is WORSE than an 8-picture one, and ARF -32 is an interior optimum (-40 turns
back). 8:-32:16 takes 11.7 / 7.5 points off film A and 0.4 / 1.0 off film B
against 16:-24:16 -- all four columns down.

The price is stated in Pyramid::default and lanes/pyr4.sweep.txt: at a
12-frame GOP the new shape is 7.0 / 5.7 (film A) and 20.5 / 18.3 (film B)
worse, because the best shape depends on GOP length and the long GOP is what
the editor exports. Pins re-taken: 8076 -> 8755 at q=150, 27585 -> 28637 at
q=60.
feat(av1): a 64x64 inter root can code a real residualAhmet Kaan Gümüş · 236d76c
feat(av1): a 64x64 inter root can code a real residual

lane-tx64 step 1+2. The charter's premise (a) -- "transform.rs has no
forward TX_64X64" -- is STALE: forward_dct_n::<_, 6> has been there since
the network was written, quantize already drops everything outside the
coded 32x32 corner, and a_64x64_transform_keeps_what_fits_in_its_coded_quarter
round-trips a 64x64 residual through the decoder's own inverse. What was
missing was the two ends around it.

Encoder: code_from_prediction takes a 64-sided block (heap residual only
for that one case, the 4x4..32x32 path keeps its stack array) and hands
back the coded 32x32 corner as its levels, which is what both the pricer
and the writer want. search_skip_64 prices the skip winner's prediction a
second time with a real residual -- one TX_64X64 luma, one TX_32X32 per
chroma plane -- and takes it when it costs less.

Writer: Quadrant::Whole64 no longer refuses a non-skip block; it codes
skip 0, the txfm_split flag at depth 0, and TxbSet::Luma64 + two
Chroma32 planes, the same pair sb_coeff_key_frame_tile's
Superblock::Whole already wrote.

Deferred: compound refs at the 64 root, depth-1 4x32x32 var-tx, intra 64,
edge superblocks -- all still refused/unsearched.
feat(av1): a 64x64 PARTITION_NONE skip root for the inter searchAhmet Kaan Gümüş · 5bcc6a5
feat(av1): a 64x64 PARTITION_NONE skip root for the inter search

The census (lanes/census-filmB.md) found rav1e speed 6 coding 45.2% of its
blocks at 64x64 -- 73.8% of its leaf blocks, 99.2% of them skip -- while
every block this encoder wrote was a 32x32 quadrant or smaller, which put our
mode+mv+partition+tx_size spend at 162,669 bits against rav1e's 61,988.

The search now offers the whole superblock as one 64x64 block coded SKIP
(NEAREST/NEAR/GLOBAL/NEW single-ref, priced through the same symbol_bits
path) against the four quadrants, and takes it outright when its per-pixel
cost is already under the split-RD threshold -- where the lever saves wall
rather than spending it. Skip-only: a 64x64 residual needs a forward
TX_64X64 the encoder does not have, and the writer refuses any other shape.

EC_AV1_B64=0 switches it off; speed::B64_ROOT is the preset column.
perf(av1): re-sweep the coding pyramid on real film -- 16:-24:16Ahmet Kaan Gümüş · 92428b3
perf(av1): re-sweep the coding pyramid on real film -- 16:-24:16

The shipped 4:-16:8 was chosen when the BD gate's "film" rows were still
testsrc2 colour bars, and CfL, the luma angle deltas, filter intra, the
propagating tpl map and the rate-loop step have all landed since, so the
shape was unswept on real content (class `unswept decision constants`).

Swept through the gate's own EC_AV1_PYRAMID knob on the two real film rows
of encode::tests::bd_rate_screen_native: the mini-GOP axis at the shipped
offsets, then both offset axes at the best mini-GOP, then the joint corners
(21 arms, table in Pyramid::default and lanes/pyr3.sweep.txt).

16:-24:16 takes 8.6 / 7.6 BD points off film A and 10.5 / 10.9 off film B
against 4:-16:8 (vs libaom / vs rav1e); the screen row is byte-identical in
every arm because the content gate codes it flat. Leaf +16 was the swept
range's edge and still improving on film A, so two arms past it were run:
film B turns back up at +20, so +16 is where both films are minimal.

Pins re-taken: encode_sequence codes the 4-picture pin clip as one truncated
group now (hidden ALTREF at q-24, three leaves at q+16), 7373 -> 8076 at
q=150 and 27074 -> 27585 at q=60; EC_AV1_PYRAMID=4:-16:8 restores them.
test(av1): the shipped presets decode sample-exact through both decodersAhmet Kaan Gümüş · e66bbaa
test(av1): the shipped presets decode sample-exact through both decoders

Re-adds the preset gate the crate-wide rustfmt revert took with it, and
records the measured lever table and preset rows in speed.rs's own docs.
feat(av1): a speed preset axis (0..=10), preset 0 the search we shipAhmet Kaan Gümüş · 597c1a3
feat(av1): a speed preset axis (0..=10), preset 0 the search we ship

Every search lever this crate already has an EC_AV1_* knob for reads its
default from a per-speed table in the new `speed` module, indexed by one
process-global preset (`Av1Encoder::with_speed`, `EC_AV1_SPEED`). Index 0
of every table IS the shipped constant, so preset 0 is byte-identical by
construction; `speed::levers` names what each preset switches off, and
ec-bench codes one row per preset {0,3,6,10}.

2026-09-06

fix(av1): the rate loop seeds each level's quantizer off its first coded frameAhmet Kaan Gümüş · 12e6ab7
fix(av1): the rate loop seeds each level's quantizer off its first coded frame

`STEP_CLAMP` protects an operating point the slot has not found yet: every
slot starts at the caller's `base_q_idx` guess (100 in the gate) and the
clamp made the loop WALK to the right quantizer at twelve steps a frame.
Traced over the 48-frame bitrate gate, the pyramid's ARF slot spent five of
its twelve frames pinned at -STEP_CLAMP and the stream landed 10.2% under
target. That is convergence lag, not steady-state offset -- this loop's
fixed point is actual == target exactly -- so the fix is one unclamped
acquisition step per slot, not an accumulated error term: nothing is carried
between frames and the windup bound still holds from the second frame on.

  bits/s   pyramid   before    after
  768000   false     -0.1%     -1.8%
  768000   true      +0.7%     +1.1%
  1536000  false     -3.6%     -3.0%
  1536000  true     -10.2%     -2.7%

bytes_per_frame_controller_never_oscillates_past_its_clamp now exempts the
acquisition step alone (the first frame q moves at all -- the lookahead
queue means that is not frame zero) and asserts the clamp on every frame
after it.
test(av1): re-take the byte pins under the default pyramid; zip the rate census in coding orderAhmet Kaan Gümüş · ef22613
test(av1): re-take the byte pins under the default pyramid; zip the rate census in coding order

EncodedSequence now carries coding_order, the map from coding order (what a
per-coded-frame census counts) to the display-order frames.
feat(av1): encode_sequence codes the content-gated pyramid by defaultAhmet Kaan Gümüş · 534fad0
feat(av1): encode_sequence codes the content-gated pyramid by default

The mini-GOP driver is the facade's own (Av1Encoder::encode_sequence_pyramid),
so the two paths cannot drift: encode_sequence hands its pictures to the
facade under Pyramid::from_env() (default 4:-16:8, EC_AV1_PYRAMID=0 for the
flat A/B) unless the content gate reads the first picture as screen, and
returns the frames in display order. The identity gate now pins both content
classes -- film-like (reordered, hidden ALTREF) and screen-like (gated flat,
identical frame by frame).
feat(av1): the coding pyramid is gated on content -- a screen-content stream codes the flat bytesAhmet Kaan Gümüş · 47529de
feat(av1): the coding pyramid is gated on content -- a screen-content stream codes the flat bytes

The pyramid lost on the OBS capture in every sweep and won on both real
films; the screen detector is 0/48 on the films and 48/48 on the capture,
so it is the signal. Av1Encoder::encode_frames decides once, on the first
picture, and drops a screen stream back to the flat path (byte-identical
to the pre-pyramid encoder). The BD gate prints the requested and the
EFFECTIVE pyramid per row.
perf(av1): the coefficient writer splits a scan position by shifting, and a wall table for the film cropAhmet Kaan Gümüş · 65aa140
perf(av1): the coefficient writer splits a scan position by shifting, and a wall table for the film crop

`side` is 4, 8, 16 or 32, but it reaches `write_coeffs` as a runtime
value, so `pos / side` and `pos % side` compiled to a real integer
division and remainder once per coefficient -- inside the encoder's
largest self-time symbol. Same row and column by construction (the side
is a power of two, now debug-asserted).

640x384 gate clip, 4 frames, q 150/120/90/60 and both real-film 1920x768
crops at q 150/60: byte-identical to a b7990ec1 baseline binary.
1920x1080 4 frames q=120, instructions:u ABABx2: 59.344e9 -> 59.200e9
(-0.24%), on top of the CDEF written-map commit.

`filter_stage_wall_film` runs the same stage breakdown at 1920x768, and
`EC_AV1_WALL_CLIP` points the test loader at a clip outside the repo, so
the table can be read on a real film window as well as on the colour-bar
fixture. It answers which stage grows on film: the TILE SEARCH does
(285.9 -> 497.7 ms/frame, bars vs film A), while every filter stage is
flat or lower -- deblock replay 15.4 -> 10.0, plane copies 28.9 -> 23.7,
first decode 14.7 -> 17.2 ms/frame. Only the CDEF replay grows (13.0 ->
21.7), which is the film choosing non-zero strengths where bars do not.
Merge branch 'lane-av1tpl2' (d6ef3909): a propagating multi-frame tpl map behind EC_AV1_TPL_PROP; the facade queue depth follows tpl_depthAhmet Kaan Gümüş · 7169554
Merge branch 'lane-av1tpl2' (d6ef3909): a propagating multi-frame tpl map behind EC_AV1_TPL_PROP; the facade queue depth follows tpl_depth

The propagating map is non-flat (0.25..1.12 over 7680 cells) but loses on
the 2160p film at every k/D/p, so the one-frame map stays the default and
bytes are identical to main. OBMC / tx32 depth / compound var-tx re-judged
on the best map: none flips.
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): a propagating lookahead lambda map -- mc_dep chained back through a D-frame windowAhmet Kaan Gümüş · 65f3164
feat(av1): a propagating lookahead lambda map -- mc_dep chained back through a D-frame window

The one-frame area map only knew how much of this frame the next one
lands on; it was flat by construction. This walks a window of D source
frames back to front, accumulating max(intra - inter, 0) + mc_dep along
each cell's coarse motion chain, and turns the accumulated dependence
into a per-16x16 lambda factor applied at 32x32 (the finest granularity
at which the whole-vs-split RD comparison stays self-consistent).

The streaming facade queues D-1 pictures so its window is the one the
sequence path builds; both read tpl_depth(), so they cannot disagree.
feat(av1): the streaming facade codes what the gate measures -- one frame of lookahead delayAhmet Kaan Gümüş · 921a9a8
feat(av1): the streaming facade codes what the gate measures -- one frame of lookahead delay

The facade passed lookahead=None, so every inter frame the editor's
export coded missed the per-superblock temporal lambda map the BD gate's
numbers were measured with. encode_frames now holds a picture back and
codes it with the NEXT one as its lookahead, exactly as encode_sequence
does; flush codes the last one. encode() keeps its Result<Packet> shape,
returning the previous picture's packet (empty data on the first call).

A new gate pins the facade's bytes identical to encode_sequence's over
12 frames at the gate's own size, and EC_AV1_GATE_FACADE=1 runs the BD
ladder through the facade.
doc(av1): the pyramid measured at native resolution -- still offAhmet Kaan Gümüş · 7ad04d2
doc(av1): the pyramid measured at native resolution -- still off

The 640x384 verdict was taken on a 4x-downscaled recipe. At native
1920x1024 crops the pyramid gap is 5 BD points rather than 30, but no
arm beats the flat encoder on both films: every arm costs 4-6 points on
1080p, and the only arm that wins anything (2:-16:8, -1.2 on the 2160p
film vs libaom) pays +10 on screen capture. A 3x3 native offset sweep
on the 2160p clip spans 2.9 points and never reaches flat, with a
monotone gradient in both knobs -- the offsets are not the limit.

Default unchanged (pyramid opt-in, encoder byte-identical).
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: 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.
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.