# lane-b128hv — HORZ and VERT at the 128 superblock root The partition lane-b128 deferred and lane-b128r deferred again: a `PARTITION_HORZ` / `PARTITION_VERT` 128x128 root, two 128x64 / 64x128 inter blocks where the NONE arm codes one square. Written, witnessed on both cuts through both decoders, measured on all five 12-frame rows and both long-GOP rows, and **shipped on** (`EC_AV1_B128HV=0` is the attribution control). ## 1. What the deferral actually cost Both earlier reports name the blocker as "rect neighbour recording in the writer and rect trials in the search". That is exactly right and it was the whole of the work: **this writer had no rectangular block of any size**. `record` / `record_planes` / `record_mi_planes` / `record_inter_mi` / `record_txfm` and both palette bands each took ONE side and stamped it into the above band AND the left band. Every one of them now has an (above = width, left = height) twin, with the square entry point delegating to it — decode.rs' own `record_rect` / `record_inter_rect_mi` / `txfm_partition_update_rect` split, mirrored on the writer side. > **Stale premise in the charter**: "the 64 root's rect machinery > (64x32/32x64 in `code_square`/`code_rect` paths) is the model". There is no > such machinery: `grep PARTITION_HORZ crates/ec-av1/src/tile.rs` was empty > before this lane. The tile writer has only ever coded `PARTITION_NONE` and > `PARTITION_SPLIT` at every level. decode.rs' `sb128_rect` arm > (decode.rs:35343) was the only model, and it is the one this mirrors. ## 2. The writer `write_inter_block_128_rect` codes one half: `skip`, `cdef_idx`, `delta_q`, `intra_inter`, `comp_mode`, the reference/mode chain, the motion mode and the transform syntax — the same chain `write_inter_block_128` writes, with every CDF/context decision taken at the enclosing **square** side of 128 (what the decoder's `inter_piece!` passes as `side`) and only the mv-stack window, the mi/grid stamp and the neighbour bands taking the block's true `128x64` / `64x128` footprint. Two details the square arm does not have: - **`delta_q` is coded.** decode.rs' `whole_sb` is `side == write_w == write_h == sb_px`, so a rect half is NOT the whole superblock and its `delta_q` group is read even when the block is skipped — where a skipped NONE root writes none. A writer passing `is_whole_sb = true` here would drop a symbol group the reader reads. - **`record_txfm_rect`**, since `read_block_tx_size_rect`'s skip arm records the BLOCK's own width above and height left, not one square side. SKIP only. The decoder reads a rect half's residual (it is in `rect_inter_residual_supported`), but the residual arm it would share is the 128 NONE one, which is parked behind `EC_AV1_B128RES=1` over an open filter-stage mismatch (lane-b128r) — an inert candidate does not buy a live mismatch, and the same holds here. `Quadrant::Rect128(horz, halves)` carries the pair on the root's top-left 32x32 entry, exactly as `Whole128` does. ## 3. The search `search_root_128_rect` prices the root as two halves, single reference or compound, through the same `search_skip_64` the NONE arm uses — which now takes a `(w, h)` footprint and tiles it into squares of its SHORTER side (one square when it is square, so the square path is byte-identical; two 64x64 luma + two 32x32 chroma squares per half otherwise). Both cuts are priced and the cheaper one competes with the NONE block and with the four superblocks, all four candidates carrying their own partition symbol (`tile::partition_bits_sym`). **The first half is published into the mi grid before the second is searched.** The writer publishes it (`grid.set` over the half's footprint), so a second half searched against the stale grid would be priced — and its mv predicted — off a stack the decoder never derives (class *encoder-grid-drift-invisible-to-pixel-gate*). `MiGrid::snapshot_rect` / `restore_rect` put the root's 32x32-mi window back before the four-superblock arm is measured against it. ## 4. Witness (red before / green after) `encode::tests::a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders` (`--ignored`, it moves the process-global superblock size), three passes over one 12-frame `testsrc2` clip at 1280x768: HORZ: search won 660 HORZ + 0 VERT roots, writer coded 2640 128x64 + 0 64x128 halves VERT: search won 0 HORZ + 660 VERT roots, writer coded 0 128x64 + 2640 64x128 halves unforced: search won 17 HORZ + 9 VERT roots, writer coded 68 128x64 + 36 64x128 halves test ... ok (the writer counts are 4x the search counts because the filter search re-codes each tile). Every pass sample-exact against the encoder's own reconstruction through `decode_stream` **and** through ffmpeg. RED before this lane by construction: `write_sb128_root` could only name `PARTITION_NONE` or `PARTITION_SPLIT`, so all three counts were 0 and no such block existed to decode. It was green on the first draft — no bisect was needed. The **unforced** row is the point: 17 HORZ + 9 VERT roots over 12 frames of film-like content, with no knob set. ## 5. Census on real content (`EC_AV1_B128_CENSUS=1`) Extended with the two shapes; the 4K 12-frame gate, 88 inter frames: | shape | per frame | total | |---|---|---| | whole 128x128 NONE roots | 89-102 | — | | **HORZ roots** | 0-3 | **175** | | **VERT roots** | 0-1 | **119** | On the long-GOP film A rows the 128 root fires far less often overall (3-8 whole roots a frame, 2-7% of the frame's area) and the rect cut fires 0 there — the lever is a 4K/quiet-content one. ## 6. Gates `bd_rate_screen_native`, 12 frames, four quantizers, BD-rate vs libaom `cpu-used 6` / rav1e `speed 6` (lower is better). Control = the same binary at `EC_AV1_B128HV=0`, which is byte-identical to the merge base (pin evidence below). | row | control | + HORZ/VERT | |---|---|---| | bars 1080p | -3.5 / -19.0 | -3.4 / -19.0 | | film A (1080p) | +17.9 / -6.4 | +18.0 / -6.3 | | bars 2160p | +8.6 / -13.7 | **+8.4 / -14.0** | | film B (2160p) | +22.9 / -3.6 | +23.0 / -3.5 | | screen capture | +14.4 / -33.2 | +14.4 / -33.2 | The two film rows move +0.1 on both columns — WORSE, inside the ±0.3 flat band but not an improvement; bars 2160p is 0.2/0.3 better; screen is unchanged to the digit. `bd_rate_film_long_gop`, 48 pictures, one key frame and 47 inter: | row | control | + HORZ/VERT | |---|---|---| | film A | +22.0 / -8.4 | **+21.9 / -8.6** | | film B | +76.5 / +1.2 | **+75.8 / +0.8** | **Both films down on both columns**, film B by 0.7 / 0.4. This is where the arm pays and it is the arm his exports are: a 48-picture GOP has the long reference chains whose 128-wide regions split cleanly along one axis. Wall on the long-GOP arm: film A 537.6s -> 594.0s (+10.5%), film B 434.2s -> 446.7s (+2.9%) — both under the +15% ceiling. (The gate's own `ours:rav1e` ratios are noisier than the raw walls here: rav1e's own column moved 50.3s vs 55.8s between the two runs.) **Verdict: ships on.** Both long-GOP film rows improve on both columns, the 12-frame film rows are flat at ±0.1 (inside the band the compound arm shipped under), screen is unchanged and bars 2160p improves. ## 7. Pins `encode::tests::the_encoders_own_streams_are_byte_identical_to_their_pins` re-taken: **`(150, 8291, 0x1f00bb0eb099a27f)`** — was `(150, 8290, 0x92cb11033d1f5813)`. The **q=60 pin does NOT move** (`(60, 33227, 0x57ee6b1f8eacd881)` stands): at that quantizer the rect cut never wins its own comparison on the pin clip, which is itself the cheapest possible statement of how sparse the arm is. `EC_AV1_B128HV=0` restores 8290 exactly — the proof that nothing else in this lane touches the shipped stream. Green at the default and at `EC_AV1_SPEED=6`. No other byte pin moved. ## 8. Suite / checks (the shipped state) cargo check --workspace --all-targets -j4 0 errors, 0 ec-av1 warnings s1 --skip stream:: 345 passed; 0 failed; 38 ignored RC=0 s2 stream:: --skip 10bit 202 passed; 0 failed; 15 ignored RC=0 s3 10bit 42 passed; 0 failed; 1 ignored RC=0 --ignored every_speed_preset_decodes_sample_exact_through_both_decoders ok --ignored a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders ok the_encoders_own_streams_are_byte_identical_to_their_pins ok, and ok at EC_AV1_SPEED=6 `encoder::tests::bitrate_target_lands_within_5_percent_over_48_frames` (it is NOT `--ignored`; it runs inside s1). Its numbers on this tree, tolerance ±5%: | target | flat | pyramid | |---|---|---| | 384 kbit/s | -1.9% | +2.0% | | 768 kbit/s | -2.6% | -0.0% | | 1536 kbit/s | **-2.8%** | +0.1% | | 2000 kbit/s | -1.7% | +0.0% | Worst arm -2.8%, and the arm the test's own doc calls its ceiling (the 2 Mbit/s pyramid, -4.4% when the tolerance was cut) now lands at +0.0%. It is not sitting near its bound on this tree. ## 9. Disposition - `open`: **the rect root's `delta_q` group is not priced.** A rect 128 root codes a `delta_q` symbol group that a SKIPPED NONE root omits (section 2), and `search_root_128_rect`'s cost does not charge for it — so the arm is under-priced by a few bits per root. This is the most likely reason the two 12-frame film rows read +0.1 instead of flat-or-better while the long-GOP rows gain. Next step: add `delta_q`'s own symbol cost to the rect candidate and re-run the 12-frame film rows; if they go flat-or-down the arm is a clean win on both arms of the gate. - `deferred`: **the rect halves' RESIDUAL.** The decoder already reads it (`rect_inter_residual_supported` lists (128,64)/(64,128) and `read_block_tx_size_rect` codes two TX_64X64 units per half), but the arm it would share is the 128 NONE residual, parked behind `EC_AV1_B128RES=1` over an open filter-stage mismatch at a 128 block's own edge (lane-b128r). Unblocked by root-causing that mismatch. - `deferred`: **the AB shapes at the 128 root** (`PARTITION_HORZ_A/_B`, `VERT_A/_B` — one 128x64/64x128 half plus two 64x64 quadrants). The decoder reads them (`sb128_ab`, decode.rs:35330); the writer now has the rect half it needs, so this is the cheapest remaining partition lever at the root. - `open` (inherited): search-time vs write-time mv stacks still differ (lane-sb128b's second open item).