From 408f8b3e4d0f0d69bdfe2fb1bd8b0538d7ca757b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 9 Sep 2026 20:29:46 +0300 Subject: [PATCH] docs(av1): lane-ab128 report --- lanes/ab128.report.md | 138 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 lanes/ab128.report.md diff --git a/lanes/ab128.report.md b/lanes/ab128.report.md new file mode 100644 index 00000000..a1785b0b --- /dev/null +++ b/lanes/ab128.report.md @@ -0,0 +1,138 @@ +# lane-ab128 — the four AB shapes at the 128 superblock root + +`PARTITION_HORZ_A` (two 64x64 on top, one 128x64 below), `_HORZ_B` (one +128x64 on top, two 64x64 below), `_VERT_A` (two 64x64 left, one 64x128 +right), `_VERT_B` (one 64x128 left, two 64x64 right) are written, witnessed +sample-exact through `decode_stream` AND ffmpeg on all four shapes, and +measured on both gates. **They ship OFF** (`EC_AV1_B128AB=1` turns them on): +every gate row is flat or 0.1 worse. The lane's value is the measurement and +the machinery, not a shipped default. + +## 1. What was built + +* `crate::encode::ab128_pieces(symbol, (mi_row, mi_col))` — the three pieces + of a shape, position and footprint, in libaom's `decode_partition` order + and decode.rs' `sb128_ab` order (decode.rs ~35269): HORZ_A = TL, TR, bottom + half; HORZ_B = top half, BL, BR; VERT_A = TL, BL, right half; VERT_B = left + half, TR, BR. One table, read by the search, by the writer and by the + winner's grid publication, so the three cannot drift (class + *table and reader move together*). +* `search_root_128_ab` — the three pieces priced through the same + `search_skip_64` the NONE and HORZ/VERT arms use, each at its own + footprint, each published into the mi grid (`record_mi_rect`) before the + next is searched and the whole 32x32-mi window restored with + `MiGrid::snapshot_rect`/`restore_rect` before returning (class + *encoder-grid-drift-invisible-to-pixel-gate*). The cost carries the root's + own `partition_bits_sym(128, symbol)`. +* `Quadrant::Ab128(symbol, pieces)` on the root's top-left 32x32 entry, the + fifteen others `Covered` — exactly as `Rect128` does. +* The writer needed **no new block function**: a 64x64 AB piece is one inter + block coded at side 64 with `write_w == write_h == 64`, and a half is the + 128x64/64x128 `write_inter_block_128_rect` already codes. All three go + through `write_inter_block_128_rect` at their own `(w, h)`. +* `EC_AV1_B128AB` (default off), `force_b128_ab` (test knob, 0 or the + partition symbol 4..=7), per-shape search and writer counters, and the + `EC_AV1_B128_CENSUS` line extended with `AB roots a/b/c/d`. + +## 2. Charter premises checked against the code + +* **"decide whether the 64 pieces of an AB shape run the full 64-root search + or the skip-64 search, and justify by measurement; the full search is what + libaom does" — refuted by the syntax, so nothing to measure.** decode.rs' + `sb128_ab` codes each 64x64 piece as ONE `decode_inter_block` at + `side = SB` with no partition symbol of its own (`square64_inter!`), which + is libaom's own AB shape: an AB piece is a whole block, never a + further-partitionable root. A "full 64-root search" candidate could not be + written at all. The pieces are `search_skip_64` at (64, 64), skip-only, for + the same reason `search_root_128_rect`'s halves are: the 128 residual arm + they would share is parked behind `EC_AV1_B128RES`. +* **"Extend `cdef_unit_owner` for the two-unit shape and the four-way + `pick_filters` grouping" — not needed, and NOT done (rung 1: it would be + dead code).** `write_cdef_idx` writes a literal only for a NON-SKIP block; + every AB piece and every HORZ/VERT half is skip, so such a root puts no + `cdef_idx` in the stream at all and CDEF filters none of its (all-skip) + units. `cdef_unit_owner` collapses units only for `Whole128`, which is the + one 128-wide shape that can carry a residual (`EC_AV1_B128RES`). The same + reasoning covers `Rect128`, which lane-b128hv also left out of the map — + swept and confirmed inert, not a sibling defect. The day a piece carries a + residual, `cdef_unit_owner` must learn `Rect128` and `Ab128` in the SAME + diff; that is named as the constraint below. +* `write_delta_q` needed no change: it already gates on the block's own + position within the (128-wide) superblock, and no AB piece is the whole + superblock, so `is_whole_sb = false` — what `write_inter_block_128_rect` + passes — is right for all three. `intrabc_dv_pred` is intra-frame only and + this is the inter writer. +* The charter's witness fixtures ("4K bars + film B 12-frame fixtures used by + `a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders`") are + stale: that test encodes ONE synthetic `testsrc2` 1280x768 12-frame clip. + The AB witness mirrors it exactly. + +## 3. Witness + +`encode::tests::a_128_root_ab_shapes_decode_exact_through_both_decoders` +(`--ignored`), five passes over the same clip — each shape forced at every +root, then unforced: + + HORZ_A: search won [660, 0, 0, 0] writer coded [1320, 0, 0, 0] + HORZ_B: search won [0, 660, 0, 0] writer coded [0, 1320, 0, 0] + VERT_A: search won [0, 0, 660, 0] writer coded [0, 0, 1320, 0] + VERT_B: search won [0, 0, 0, 660] writer coded [0, 0, 0, 660*2] + unforced: search won [0, 0, 1, 1] writer coded [0, 0, 2, 2] + +Every pass sample-exact against the encoder's own reconstruction through +`decode_stream` and through ffmpeg, first run, no bisect needed. RED before +this lane by construction: `write_sb128_root` could name only NONE / HORZ / +VERT / SPLIT. + +## 4. Census on real content (`EC_AV1_B128_CENSUS=1`, long-GOP films) + +171 inter frames: a typical frame is `7 whole 128 roots, 0-1 HORZ + 0-1 VERT, +AB roots 0/0/0/1`, out of ~1050-1900 coded blocks. 44 of 171 frames took no +AB root at all; the modal non-zero frame takes exactly one. The shapes are +real but rare — which is the whole BD result below. + +## 5. Gates (arm = default-on build, control = `EC_AV1_B128AB=0`; lower is better) + +12-frame `bd_rate_screen_native` (`~/.cache/ab128/12arm.log`, `12ctl.log`): + +| row | arm vs libaom | ctl vs libaom | arm vs rav1e | ctl vs rav1e | +| --- | --- | --- | --- | --- | +| bars 1080p | -3.4% | -3.4% | -19.0% | -19.0% | +| bars 2160p | +8.4% | +8.4% | -14.0% | -14.0% | +| film A | +18.1% | +18.0% | -6.2% | -6.3% | +| film B | +23.1% | +23.0% | -3.3% | -3.5% | +| screen | +14.4% | +14.4% | -33.2% | -33.2% | + +Long-GOP `bd_rate_film_long_gop` — the deciding gate (`lgarm.log`, +`lgctl.log`): + +| row | arm vs libaom | ctl vs libaom | arm vs rav1e | ctl vs rav1e | +| --- | --- | --- | --- | --- | +| film A | +22.0% | +21.9% | -8.5% | -8.6% | +| film B | +75.8% | +75.8% | +0.8% | +0.8% | + +Wall (both arms run concurrently, so the contention is shared): long-GOP +706.6 + 520.0 = 1226.6 s arm against 665.0 + 463.5 = 1128.5 s control, +**+8.7%** — inside the +15% ceiling, but bought for nothing. + +**Keep rule: FAILED.** It asks for both film rows down on both columns, or +one >= 0.5 down with the other flat. Film A is 0.1 WORSE on both columns, +film B is unchanged to the decimal. The candidate costs a partition symbol on +every root it wins and buys back less than it spends. Shipped off. + +Known under-pricing shared with lane-b128hv (unchanged by this lane): a +non-origin AB piece codes no `delta_q` group, but the piece AT the superblock +origin does, and nothing here prices it — lane-rectdq is adding the +`delta_q_bits` pricer. The mispricing is under a bit per root and is the same +for the rect arm, so it cannot explain a 0.1 BD miss on its own. + +## 6. Suite, pins, checks + +* Pins: `encode::tests::the_encoders_own_streams_are_byte_identical_to_their_pins` + green at default and at `EC_AV1_SPEED=6`, **unmoved** (`pins2.log`) — the + arm is off by default, so the default encoder is byte-identical to main's. +* `--ignored --exact encoder::tests::every_speed_preset_decodes_sample_exact_through_both_decoders`: ok. +* `--ignored` HORZ/VERT witness (lane-b128hv's): ok, unaffected by the + counter split (a 64x64 piece no longer counts as a "64x128 half"). +* Suite in three lanes and `cargo check --workspace --all-targets`: see + section 7 (filled from `s1.log` / `s2.log` / `s3.log` / `chk.log`).