Lane-b128hv report — HORZ/VERT at the 128 root, measured and shipped
Browse files at this commit92339f4f3c334d29a6f2963ade7d484d7c52d646Parent: d106c89- docs
- lane-b128hv report — HORZ/VERT at the 128 root, measured and shipped
1 changed file +205 -0
- lanes/b128hv.report.md +205 -0
lanes/b128hv.report.mdadded+205 -0
| @@ -0,0 +1,205 @@ | ||
| 1 | +# lane-b128hv — HORZ and VERT at the 128 superblock root | |
| 2 | + | |
| 3 | +The partition lane-b128 deferred and lane-b128r deferred again: a | |
| 4 | +`PARTITION_HORZ` / `PARTITION_VERT` 128x128 root, two 128x64 / 64x128 inter | |
| 5 | +blocks where the NONE arm codes one square. Written, witnessed on both cuts | |
| 6 | +through both decoders, measured on all five 12-frame rows and both long-GOP | |
| 7 | +rows, and **shipped on** (`EC_AV1_B128HV=0` is the attribution control). | |
| 8 | + | |
| 9 | +## 1. What the deferral actually cost | |
| 10 | + | |
| 11 | +Both earlier reports name the blocker as "rect neighbour recording in the | |
| 12 | +writer and rect trials in the search". That is exactly right and it was the | |
| 13 | +whole of the work: **this writer had no rectangular block of any size**. | |
| 14 | +`record` / `record_planes` / `record_mi_planes` / `record_inter_mi` / | |
| 15 | +`record_txfm` and both palette bands each took ONE side and stamped it into | |
| 16 | +the above band AND the left band. Every one of them now has an | |
| 17 | +(above = width, left = height) twin, with the square entry point delegating to | |
| 18 | +it — decode.rs' own `record_rect` / `record_inter_rect_mi` / | |
| 19 | +`txfm_partition_update_rect` split, mirrored on the writer side. | |
| 20 | + | |
| 21 | +> **Stale premise in the charter**: "the 64 root's rect machinery | |
| 22 | +> (64x32/32x64 in `code_square`/`code_rect` paths) is the model". There is no | |
| 23 | +> such machinery: `grep PARTITION_HORZ crates/ec-av1/src/tile.rs` was empty | |
| 24 | +> before this lane. The tile writer has only ever coded `PARTITION_NONE` and | |
| 25 | +> `PARTITION_SPLIT` at every level. decode.rs' `sb128_rect` arm | |
| 26 | +> (decode.rs:35343) was the only model, and it is the one this mirrors. | |
| 27 | + | |
| 28 | +## 2. The writer | |
| 29 | + | |
| 30 | +`write_inter_block_128_rect` codes one half: `skip`, `cdef_idx`, `delta_q`, | |
| 31 | +`intra_inter`, `comp_mode`, the reference/mode chain, the motion mode and the | |
| 32 | +transform syntax — the same chain `write_inter_block_128` writes, with every | |
| 33 | +CDF/context decision taken at the enclosing **square** side of 128 (what the | |
| 34 | +decoder's `inter_piece!` passes as `side`) and only the mv-stack window, the | |
| 35 | +mi/grid stamp and the neighbour bands taking the block's true `128x64` / | |
| 36 | +`64x128` footprint. Two details the square arm does not have: | |
| 37 | + | |
| 38 | +- **`delta_q` is coded.** decode.rs' `whole_sb` is `side == write_w == | |
| 39 | + write_h == sb_px`, so a rect half is NOT the whole superblock and its | |
| 40 | + `delta_q` group is read even when the block is skipped — where a skipped | |
| 41 | + NONE root writes none. A writer passing `is_whole_sb = true` here would drop | |
| 42 | + a symbol group the reader reads. | |
| 43 | +- **`record_txfm_rect`**, since `read_block_tx_size_rect`'s skip arm records | |
| 44 | + the BLOCK's own width above and height left, not one square side. | |
| 45 | + | |
| 46 | +SKIP only. The decoder reads a rect half's residual (it is in | |
| 47 | +`rect_inter_residual_supported`), but the residual arm it would share is the | |
| 48 | +128 NONE one, which is parked behind `EC_AV1_B128RES=1` over an open | |
| 49 | +filter-stage mismatch (lane-b128r) — an inert candidate does not buy a live | |
| 50 | +mismatch, and the same holds here. | |
| 51 | + | |
| 52 | +`Quadrant::Rect128(horz, halves)` carries the pair on the root's top-left | |
| 53 | +32x32 entry, exactly as `Whole128` does. | |
| 54 | + | |
| 55 | +## 3. The search | |
| 56 | + | |
| 57 | +`search_root_128_rect` prices the root as two halves, single reference or | |
| 58 | +compound, through the same `search_skip_64` the NONE arm uses — which now | |
| 59 | +takes a `(w, h)` footprint and tiles it into squares of its SHORTER side (one | |
| 60 | +square when it is square, so the square path is byte-identical; two 64x64 | |
| 61 | +luma + two 32x32 chroma squares per half otherwise). Both cuts are priced and | |
| 62 | +the cheaper one competes with the NONE block and with the four superblocks, | |
| 63 | +all four candidates carrying their own partition symbol | |
| 64 | +(`tile::partition_bits_sym`). | |
| 65 | + | |
| 66 | +**The first half is published into the mi grid before the second is | |
| 67 | +searched.** The writer publishes it (`grid.set` over the half's footprint), so | |
| 68 | +a second half searched against the stale grid would be priced — and its mv | |
| 69 | +predicted — off a stack the decoder never derives (class | |
| 70 | +*encoder-grid-drift-invisible-to-pixel-gate*). `MiGrid::snapshot_rect` / | |
| 71 | +`restore_rect` put the root's 32x32-mi window back before the four-superblock | |
| 72 | +arm is measured against it. | |
| 73 | + | |
| 74 | +## 4. Witness (red before / green after) | |
| 75 | + | |
| 76 | +`encode::tests::a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders` | |
| 77 | +(`--ignored`, it moves the process-global superblock size), three passes over | |
| 78 | +one 12-frame `testsrc2` clip at 1280x768: | |
| 79 | + | |
| 80 | + HORZ: search won 660 HORZ + 0 VERT roots, writer coded 2640 128x64 + 0 64x128 halves | |
| 81 | + VERT: search won 0 HORZ + 660 VERT roots, writer coded 0 128x64 + 2640 64x128 halves | |
| 82 | + unforced: search won 17 HORZ + 9 VERT roots, writer coded 68 128x64 + 36 64x128 halves | |
| 83 | + test ... ok | |
| 84 | + | |
| 85 | +(the writer counts are 4x the search counts because the filter search re-codes | |
| 86 | +each tile). Every pass sample-exact against the encoder's own reconstruction | |
| 87 | +through `decode_stream` **and** through ffmpeg. RED before this lane by | |
| 88 | +construction: `write_sb128_root` could only name `PARTITION_NONE` or | |
| 89 | +`PARTITION_SPLIT`, so all three counts were 0 and no such block existed to | |
| 90 | +decode. It was green on the first draft — no bisect was needed. | |
| 91 | + | |
| 92 | +The **unforced** row is the point: 17 HORZ + 9 VERT roots over 12 frames of | |
| 93 | +film-like content, with no knob set. | |
| 94 | + | |
| 95 | +## 5. Census on real content (`EC_AV1_B128_CENSUS=1`) | |
| 96 | + | |
| 97 | +Extended with the two shapes; the 4K 12-frame gate, 88 inter frames: | |
| 98 | + | |
| 99 | +| shape | per frame | total | | |
| 100 | +|---|---|---| | |
| 101 | +| whole 128x128 NONE roots | 89-102 | — | | |
| 102 | +| **HORZ roots** | 0-3 | **175** | | |
| 103 | +| **VERT roots** | 0-1 | **119** | | |
| 104 | + | |
| 105 | +On the long-GOP film A rows the 128 root fires far less often overall (3-8 | |
| 106 | +whole roots a frame, 2-7% of the frame's area) and the rect cut fires 0 there | |
| 107 | +— the lever is a 4K/quiet-content one. | |
| 108 | + | |
| 109 | +## 6. Gates | |
| 110 | + | |
| 111 | +`bd_rate_screen_native`, 12 frames, four quantizers, BD-rate vs libaom | |
| 112 | +`cpu-used 6` / rav1e `speed 6` (lower is better). Control = the same binary at | |
| 113 | +`EC_AV1_B128HV=0`, which is byte-identical to the merge base (pin evidence | |
| 114 | +below). | |
| 115 | + | |
| 116 | +| row | control | + HORZ/VERT | | |
| 117 | +|---|---|---| | |
| 118 | +| bars 1080p | -3.5 / -19.0 | -3.4 / -19.0 | | |
| 119 | +| film A (1080p) | +17.9 / -6.4 | +18.0 / -6.3 | | |
| 120 | +| bars 2160p | +8.6 / -13.7 | **+8.4 / -14.0** | | |
| 121 | +| film B (2160p) | +22.9 / -3.6 | +23.0 / -3.5 | | |
| 122 | +| screen capture | +14.4 / -33.2 | +14.4 / -33.2 | | |
| 123 | + | |
| 124 | +The two film rows move +0.1 on both columns — WORSE, inside the ±0.3 flat | |
| 125 | +band but not an improvement; bars 2160p is 0.2/0.3 better; screen is | |
| 126 | +unchanged to the digit. | |
| 127 | + | |
| 128 | +`bd_rate_film_long_gop`, 48 pictures, one key frame and 47 inter: | |
| 129 | + | |
| 130 | +| row | control | + HORZ/VERT | | |
| 131 | +|---|---|---| | |
| 132 | +| film A | +22.0 / -8.4 | **+21.9 / -8.6** | | |
| 133 | +| film B | +76.5 / +1.2 | **+75.8 / +0.8** | | |
| 134 | + | |
| 135 | +**Both films down on both columns**, film B by 0.7 / 0.4. This is where the | |
| 136 | +arm pays and it is the arm his exports are: a 48-picture GOP has the long | |
| 137 | +reference chains whose 128-wide regions split cleanly along one axis. | |
| 138 | + | |
| 139 | +Wall on the long-GOP arm: film A 537.6s -> 594.0s (+10.5%), film B 434.2s -> | |
| 140 | +446.7s (+2.9%) — both under the +15% ceiling. (The gate's own `ours:rav1e` | |
| 141 | +ratios are noisier than the raw walls here: rav1e's own column moved 50.3s vs | |
| 142 | +55.8s between the two runs.) | |
| 143 | + | |
| 144 | +**Verdict: ships on.** Both long-GOP film rows improve on both columns, the | |
| 145 | +12-frame film rows are flat at ±0.1 (inside the band the compound arm shipped | |
| 146 | +under), screen is unchanged and bars 2160p improves. | |
| 147 | + | |
| 148 | +## 7. Pins | |
| 149 | + | |
| 150 | +`encode::tests::the_encoders_own_streams_are_byte_identical_to_their_pins` | |
| 151 | +re-taken: **`(150, 8291, 0x1f00bb0eb099a27f)`** — was `(150, 8290, | |
| 152 | +0x92cb11033d1f5813)`. The **q=60 pin does NOT move** (`(60, 33227, | |
| 153 | +0x57ee6b1f8eacd881)` stands): at that quantizer the rect cut never wins its | |
| 154 | +own comparison on the pin clip, which is itself the cheapest possible | |
| 155 | +statement of how sparse the arm is. `EC_AV1_B128HV=0` restores 8290 exactly — | |
| 156 | +the proof that nothing else in this lane touches the shipped stream. Green at | |
| 157 | +the default and at `EC_AV1_SPEED=6`. No other byte pin moved. | |
| 158 | + | |
| 159 | +## 8. Suite / checks (the shipped state) | |
| 160 | + | |
| 161 | + cargo check --workspace --all-targets -j4 0 errors, 0 ec-av1 warnings | |
| 162 | + s1 --skip stream:: 345 passed; 0 failed; 38 ignored RC=0 | |
| 163 | + s2 stream:: --skip 10bit 202 passed; 0 failed; 15 ignored RC=0 | |
| 164 | + s3 10bit 42 passed; 0 failed; 1 ignored RC=0 | |
| 165 | + --ignored every_speed_preset_decodes_sample_exact_through_both_decoders ok | |
| 166 | + --ignored a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders ok | |
| 167 | + the_encoders_own_streams_are_byte_identical_to_their_pins ok, and ok at EC_AV1_SPEED=6 | |
| 168 | + | |
| 169 | +`encoder::tests::bitrate_target_lands_within_5_percent_over_48_frames` (it is | |
| 170 | +NOT `--ignored`; it runs inside s1). Its numbers on this tree, tolerance ±5%: | |
| 171 | + | |
| 172 | +| target | flat | pyramid | | |
| 173 | +|---|---|---| | |
| 174 | +| 384 kbit/s | -1.9% | +2.0% | | |
| 175 | +| 768 kbit/s | -2.6% | -0.0% | | |
| 176 | +| 1536 kbit/s | **-2.8%** | +0.1% | | |
| 177 | +| 2000 kbit/s | -1.7% | +0.0% | | |
| 178 | + | |
| 179 | +Worst arm -2.8%, and the arm the test's own doc calls its ceiling (the 2 | |
| 180 | +Mbit/s pyramid, -4.4% when the tolerance was cut) now lands at +0.0%. It is | |
| 181 | +not sitting near its bound on this tree. | |
| 182 | + | |
| 183 | +## 9. Disposition | |
| 184 | + | |
| 185 | +- `open`: **the rect root's `delta_q` group is not priced.** A rect 128 root | |
| 186 | + codes a `delta_q` symbol group that a SKIPPED NONE root omits (section 2), | |
| 187 | + and `search_root_128_rect`'s cost does not charge for it — so the arm is | |
| 188 | + under-priced by a few bits per root. This is the most likely reason the two | |
| 189 | + 12-frame film rows read +0.1 instead of flat-or-better while the long-GOP | |
| 190 | + rows gain. Next step: add `delta_q`'s own symbol cost to the rect candidate | |
| 191 | + and re-run the 12-frame film rows; if they go flat-or-down the arm is a | |
| 192 | + clean win on both arms of the gate. | |
| 193 | +- `deferred`: **the rect halves' RESIDUAL.** The decoder already reads it | |
| 194 | + (`rect_inter_residual_supported` lists (128,64)/(64,128) and | |
| 195 | + `read_block_tx_size_rect` codes two TX_64X64 units per half), but the arm it | |
| 196 | + would share is the 128 NONE residual, parked behind `EC_AV1_B128RES=1` over | |
| 197 | + an open filter-stage mismatch at a 128 block's own edge (lane-b128r). | |
| 198 | + Unblocked by root-causing that mismatch. | |
| 199 | +- `deferred`: **the AB shapes at the 128 root** (`PARTITION_HORZ_A/_B`, | |
| 200 | + `VERT_A/_B` — one 128x64/64x128 half plus two 64x64 quadrants). The decoder | |
| 201 | + reads them (`sb128_ab`, decode.rs:35330); the writer now has the rect | |
| 202 | + half it needs, so this is the cheapest remaining partition lever at the | |
| 203 | + root. | |
| 204 | +- `open` (inherited): search-time vs write-time mv stacks still differ | |
| 205 | + (lane-sb128b's second open item). |