# lane-b64b — the 64x64 root: compound, var-tx, edge, intra Branch `lane-b64b`, base `12a8c4a7`. Scope: `crates/ec-av1/src/encode.rs`'s 64 root (`search_skip_64`, its residual arm, `sb64_legal`), `tile.rs`'s `Quadrant::Whole64` writer arm, tests. ## Step 1 — COMPOUND references at the 64 root (commit `b9a4d589`) Search: `search_skip_64` takes this superblock's `LAST` + GOLDEN/ALTREF compound stacks (`find_mv_stack_compound` at the 16x16-mi window the writer rebuilds from) and prices three modes — `NEAREST_NEARESTMV`, `GLOBAL_GLOBALMV`, `NEW_NEARESTMV` — through `predict_compound_u8`, a heap counterpart of `predict_u8` on the same `predict_compound_intermediate` + `combine_compound` path (`mc_trial_compound`'s fixed buffers are sized for a 32x32 block, so they cannot serve a 64 root). Every candidate is compared against the single-reference arm at ONE syntax price: `fixed` minus the single reference tree, plus the pair tree and the compound mode symbol. DEVIATION from the charter, named: `NEAREST_NEWMV` and `NEW_NEWMV` are NOT offered. Both need the SECOND reference's own `NEWMV` vector, which only a second 64x64 motion search per superblock produces — the wall this root exists to save (`b64_residual`'s doc: a root that wins is four quadrant searches that never run). The three modes above cost no extra search. Writer: the `Whole64` arm's "a 64x64 root block is coded single-reference" refusal is gone; a compound root codes `comp_mode` 1 and the whole `write_compound_block` chain at `(bw4, bh4) = (16, 16)`, publishes both references and both vectors into the MI grid, writes NO `motion_mode` symbol (libaom's `motion_mode_allowed` refuses a compound block) and stamps `record_block_compound` so the next block reads the right compound contexts. `EC_AV1_B64COMP=0` restores the single-reference root, so both arms measure on one build. ### Exactness `encoder::tests::a_crossfade_clip_codes_a_compound_64x64_root_and_decodes_sample_exact` — a 9-picture linear crossfade between two test cards, so on a leaf frame the average of `LAST` and `ALTREF` IS the source: 2 compound 64x64 roots fire and every frame decodes sample-exact through our decoder AND ffmpeg, with `EC_COMP_MISMATCH=1` printing nothing. ### Step 1's 12-frame table (`encode::tests::bd_rate_screen_native`, 12 frames, gop 12) Two arms of ONE build, `EC_AV1_B64COMP=0` vs default; the OFF arm reproduces the charter's control to the digit (film A +37.5/+7.6, film B +54.1/+23.9, screen +33.4/-23.8), so the baseline is this build's own. | row | OFF (control) | ON (all clips) | SHIPPED (`!screen`) | |---|---|---|---| | bars 1080p | +1.7% / -14.5% | +1.8% / -14.4% | +1.8% / -14.4% | | bars 2160p | +12.2% / -10.2% | +12.3% / -10.2% | +12.3% / -10.2% | | film A | +37.5% / +7.6% | **+35.5% / +5.6%** | **+35.5% / +5.6%** | | film B | +54.1% / +23.9% | **+47.8% / +17.1%** | **+47.8% / +17.1%** | | screen | +33.4% / -23.8% | +33.7% / -23.6% | +33.4% / -23.8% (byte-identical) | Screen at +33.7 was exactly the keep rule's 0.3 bound, so the compound arm takes the same `!screen` content gate the residual arm does; the shipped arm is byte-identical to the control there. Wall (ours:libaom:rav1e, noisy, two arms sharing the box): film A 94.1 -> 93.8 s, film B 88.7 -> 88.0 s. DECISION: **KEEP, default on** (`EC_AV1_B64COMP=0` restores). Both film rows improve on both columns; screen unchanged. Fire shares (shipped, from the gate's own `64x64 roots` census line): film A 9141 roots, 3559 compound (38.9%); film B 15248 roots, 6913 compound (45.3%); screen 20558 roots, 0 compound (gated). ## Step 2 — depth-1 var-tx under the 64 root (commit `484c390e`) `commit_inter_luma` -- the var-tx decision every other inter block already takes -- reaches side 64 now: its halved transform is TX_32X32 (`TxbSet::Luma32Inter`), and the eligibility line that read `side < BLOCK || tx32_depth_search()` reads `side != BLOCK || ...` so a 64 root is offered the trial while the 32x32 knob keeps meaning what it meant. The root's own counter (`take_b64_var_tx_hits`) keeps it out of the depth census's leaf row. The writer's `Whole64` arm codes `txfm_split = usize::from(block.tx_depth)` and, at depth 1, the four TX_32X32 units `write_luma_tus` slices out of the block's 64x64 levels (its "a 64x64 block's split luma transform is not written yet" refusal now only covers a split finer than TX_32X32); the pricer (`predicted_coeff_bits`) slices the same four units in the same diff. `EC_AV1_B64VARTX=0` restores the single TX_64X64. ### Exactness `encoder::tests::a_high_frequency_clip_splits_the_64x64_roots_luma_and_decodes_sample_exact` — every frame adds a 4-pixel checkerboard, which is exactly the detail TX_64X64 throws away (it codes only the top-left 32x32 corner of its coefficient space): 24 roots split their luma and every frame decodes sample-exact through our decoder AND ffmpeg. ### 12-frame table (`EC_AV1_B64VARTX=0` vs default, one build) | row | OFF (= step 1 shipped) | ON | roots / with residual / split luma | |---|---|---|---| | bars 1080p | +1.8% / -14.4% | +1.6% / -14.6% | 17585 / 12602 / 3076 | | bars 2160p | +12.3% / -10.2% | +12.4% / -10.1% | 18446 / 12409 / 2477 | | film A | +35.5% / +5.6% | **+35.4% / +5.4%** | 9159 / 6146 / 2873 (46.7% of residual roots) | | film B | +47.8% / +17.1% | **+47.6% / +17.0%** | 15308 / 6604 / 1942 (29.4%) | | screen | +33.4% / -23.8% | +33.4% / -23.8% | 20558 / 0 / 0 (byte-identical) | Wall: film A 102.7 -> 103.0 s, film B 90.1 -> 89.9 s (both arms sharing the box with a second gate). DECISION: **KEEP, default on**. Both film rows improve on both columns (small: 0.1-0.2), screen byte-identical. Pins re-taken for steps 1+2 together: 9835 -> 9798 at q=150 and 35798 -> 35614 at q=60. ## Step 3 — EDGE superblocks (commit pending) `sb64_legal` required the WHOLE superblock inside the true frame. AV1 asks only that the block's own half is (`has_cols`/`has_rows`, spec `decode_partition`), and the writer's `Whole64` arm already refuses exactly the other case, so the missing half was the SEARCH's: a trial scored over the padding the encoder invented past the edge. `inside_sse` scores the inside part alone and `clip_sb64_sse` rescores all three planes of every 64-root trial set (skip, compound and residual arms) when the edge cuts the superblock. The root's var-tx arm stays off there by `commit_inter_luma`'s own "wholly inside" rule, so an edge root is one TX_64X64 or a skip. `EC_AV1_B64EDGE=0` restores the old rule. ### Exactness `encoder::tests::a_non_superblock_aligned_clip_codes_edge_64x64_roots_and_decodes_sample_exact` — 232x168 (mi 58x42: the last superblock column and row are cut with more than half inside): 9 edge roots, every frame sample-exact through our decoder AND ffmpeg. ### 12-frame gate The gate CANNOT see this step: film A is 1920x768 (mi 480x192), film B and the screen capture are 1920x1024 (mi 480x256) — every row is superblock aligned, so `take_b64_edge_hits` is 0 on all five and the shipped table below is identical to step 2's ON arm. The decision rests on the synthetic exactness test above plus the fact that it is the user's arbitrary export sizes, not the gate clips, that reach the path (class `gate-blind-to-feature`, stated rather than hidden). DECISION: **KEEP, default on** — no gate row moves, one new capability, one witness. ## Step 4 — INTRA 64x64 root NOT IMPLEMENTED this round. `Superblock::Whole` is produced nowhere but three unit tests (`tile.rs:8024/8142/8710`), so the key-frame search would need a whole-superblock intra candidate (13 modes at 64x64, TX_64X64 luma plus two TX_32X32 chroma), its own `Superblock::Whole` assembly in the key search's block list, and the pricer's key-frame arm — a diff the size of steps 1 and 2 together, which did not fit this lane's budget after three gate rounds. `deferred: the intra 64x64 root on key frames — the key-frame search has no whole-superblock candidate at all and the change is not a variant of the inter root's — unblocks: one lane scoped to the key search plus `sb_coeff_key_frame_tile`'s `Superblock::Whole` arm, gated on the key-frame share of the film rows (a 12-frame gate at gop 12 codes one key frame in twelve, so the long-GOP arm is the honest one for it).` ## Shipped state Steps 1, 2 and 3 all default ON; step 4 deferred (above). ### 12-frame `bd_rate_screen_native` at the shipped state | clip | vs libaom cpu-used 6 | vs rav1e speed 6 | roots / residual / split luma / compound | wall ours:libaom:rav1e | |---|---|---|---|---| | bars 1080p | +1.6% | -14.6% | 17585 / 12602 / 3076 / 6371 | 43.5s:8.1s:21.8s | | bars 2160p | +12.4% | -10.1% | 18446 / 12409 / 2477 / 5387 | 35.6s:6.7s:19.0s | | film A 1920x768 | **+35.4%** | **+5.4%** | 9159 / 6146 / 2873 / 3543 | 82.8s:12.8s:18.9s | | film B 1920x1024 | **+47.6%** | **+17.0%** | 15308 / 6604 / 1942 / 6976 | 83.1s:21.2s:16.6s | | screen capture | +33.4% | -23.8% | 20558 / 0 / 0 / 0 | 43.2s:10.9s:16.1s | Against the charter's control (film A +37.5/+7.6, film B +54.1/+23.9, screen +33.4/-23.8, reproduced to the digit by this build's OFF arm): film A -2.1 / -2.2, film B -6.5 / -6.9, screen unchanged. Edge roots on every row: 0 (all five clips are superblock aligned). ### Long-GOP `bd_rate_film_long_gop` at the shipped state (48 frames, gop 48) | clip | vs libaom | vs rav1e | wall ours:libaom:rav1e | |---|---|---|---| | film A 1920x768 | **+39.2%** | **+1.3%** | 349.5s:37.0s:61.6s | | film B 1920x1024 | **+118.5%** | **+25.1%** | 276.4s:74.4s:60.2s | Charter control: film A +43.1/+4.6, film B +129.0/+34.3 — so -3.9 / -3.3 and -10.5 / -9.2. ### Invariants - `the_encoders_own_streams_are_byte_identical_to_their_pins`: green at 9798 (q=150) / 35614 (q=60), re-taken once for steps 1+2 (step 3 does not move that clip: it is superblock aligned). - `every_speed_preset_decodes_sample_exact_through_both_decoders --ignored`: green (speeds 0, 3, 6, 10). - `tile_bytes_do_not_depend_on_the_thread_count --include-ignored`, `filter_stage_bytes_do_not_depend_on_the_thread_count`, `the_facade_codes_the_same_bytes_as_encode_sequence`, `predicted_coeff_bits_track_the_tile_the_writer_wrote`: green. - `EC_COMP_MISMATCH=1` over all of the above and the four 64-root witnesses: silent. - Full lib suite (release binary, `--test-threads=4`): **561 passed / 0 failed / 44 ignored**, 707.9 s (558 + this lane's three new tests). - `timeout 900 cargo check --workspace --all-targets -j4`: 0 errors, 0 ec-av1 warnings (21 pre-existing ec-opus doc warnings, 1 ec-vorbis).