From e7bbd0f18b8dd65497361e5444a4645558fefb7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 8 Sep 2026 15:27:52 +0300 Subject: [PATCH] docs(av1): lane-b128m report -- four 128-superblock defects, the gates and the flip --- crates/ec-av1/src/encode.rs | 12 ++-- lanes/b128m.report.md | 127 ++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 6 deletions(-) create mode 100644 lanes/b128m.report.md diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index 606cb2ae..44ac1dea 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -5905,14 +5905,14 @@ fn cfl_on() -> bool { /// /// | row | 64 superblocks | 128 + the 128 root | /// |---|---|---| -/// | bars 1080p | -2.6 / -18.3 | **-3.3 / -18.9** | -/// | bars 2160p | +8.8 / -13.2 | **+7.9 / -14.0** | -/// | film A | +20.6 / -5.1 | **+20.4 / -5.2** | -/// | film B | +24.8 / -2.1 | **+24.2 / -2.5** | +/// | bars 1080p | -3.1 / -18.7 | **-3.7 / -19.2** | +/// | bars 2160p | +9.1 / -13.3 | **+8.5 / -13.8** | +/// | film A | +20.3 / -5.0 | **+20.1 / -5.2** | +/// | film B | +24.6 / -2.0 | **+24.3 / -2.2** | /// | screen capture | +14.6 / -33.2 | **+14.4 / -33.2** | /// -/// and the long-GOP gate agrees (film A +24.7/-7.5 -> +24.4/-7.7, film B -/// +86.8/+7.4 -> +85.6/+6.6). +/// and the long-GOP gate agrees (film A +24.0/-7.6 -> +23.6/-7.9, film B +/// +85.8/+7.1 -> +85.1/+6.6). Both arms re-run on lane-b128m's own base. /// /// ON since lane-b128m closed the eleven 128-superblock desyncs that held it /// off (the delta_q unit at the 128 superblock, the superblock size travelling diff --git a/lanes/b128m.report.md b/lanes/b128m.report.md new file mode 100644 index 00000000..46b2109c --- /dev/null +++ b/lanes/b128m.report.md @@ -0,0 +1,127 @@ +# lane-b128m — the eleven 128-superblock desyncs, and the default flip + +`SB128_DEFAULT` is **true**: every sequence this encoder writes codes +128x128 superblocks, with lane-b128's `PARTITION_NONE` 128 root inside them. +Four defects closed, each with its own first divergent symbol. + +## 1. The delta_q unit is the 128 superblock (`0aa5a5e3`) + +Defect 0 of the charter, and new at this merge (per-SB delta_q from lane-dq +met 128 superblocks from lane-b128 — class *merge cross-product defect*). + +- **First divergent symbol**: the SECOND 64x64 cell's `delta_q_abs` inside a + 128 root. `tile::write_delta_q` gated on a hardcoded `SB_MI` (64), while + decode.rs `maybe_read_delta_q` gates on `sb_mi_cur` — so the writer coded + four symbol groups per 128 root and the reader read one. It surfaced frames + later as the arf's "a reference frame selected with no picture at this + frame's own ref_frame_idx slot". +- Two more halves of the same defect: the 64-root whole-block call passed + `is_whole_sb = true` under a 128 superblock (which suppresses the read on + the wrong side), and the search-side `sb_q` grid gave each 64 cell its own + qindex when only the root's top-left one is coded — flattened per 128 root + so a cell is quantized at the qindex its root signals. +- Witness: `encode::tests::a_128_superblock_clip_whose_root_search_codes_128x128_blocks_decodes_exact` + (`--ignored`) — red with the refusal above, green after (405 blocks). + +## 2. The superblock size travels with a `FrameCtx` copy (`c0635108`'s parent) + +`decode::filter_ctx_copy` copied nine fields and not `sb128_flag` / +`reach_sb_px`, so a tile SEARCH worker (`encode::search_tiles`, threads > 1) +searched at 64 while the calling thread searched at 128. + +- Symptom: `tile_bytes_do_not_depend_on_the_thread_count`, 1x2 tiles, 9251 + bytes at one thread vs 9239 at four. +- Two neighbouring gates were TEST staleness and are pinned instead of + fixed: `reach_matches_libaom_has_top_right_and_has_bottom_left` and + `every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock` + transcribe libaom's 64-superblock tables, so they build a 64 context + explicitly rather than following the process knob. +- `every_tile_layout_decodes_sample_exact_through_both_decoders` asserted + `1 << log2` tiles; the SPEC derives the count from the superblock grid + (`tileWidthSb = ceil(sbCols >> log2)`), and 640x384 has 5 128-superblock + columns, so `tile_cols_log2 = 2` legitimately codes 3 tiles. The test now + expects the encoder's own `TileLayout` (identical to `1 << log2` at 64). + +## 3. The writer's intrabc DV predictor (`c0635108`) + +- **First divergent symbol: none.** The writer's and the reader's symbol + traces are identical for all 111384 symbols; only the `# MVDBG` annotation + differs — writer DV (-48, 0) px, reader (-112, 0) px at mi=(36,4). + `tile::intrabc_dv_pred` hardcoded `mib_size = 16` where decode.rs + `read_intrabc_dv` takes `sb_mi_cur`, so `av1_find_ref_dv`'s fallback was one + 64 superblock up on one side and one 128 on the other: same bits, different + reconstruction. +- `Ibc::dv_valid` likewise counted libaom's 256-pixel intrabc delay in 64s + (`>> 6`, `INTRABC_DELAY_SB64`), offering sources the 128 visit order had not + reconstructed yet; it now derives both the shift and the delay from the + superblock size. +- Witness: `a_repeated_pattern_key_frame_codes_intrabc_blocks_ffmpeg_decodes_exactly`. + +## 4. Seven test harnesses handed the encoder a 64 context (`b6e573a4`) + +The seven remaining `stream::tests` failures were one cause: each built a +plain `FrameCtx` (superblock 64) and passed it to `encode_*_with_ctx`, so the +encoder's own trial decode — and the raw tile decode beside it — read at 64 +while the writer coded 128 roots. + +- **First divergent symbol** (`decode_stream_matches_the_tile_path_on_a_key_frame`, + 216x96): index 33, the writer's 8-symbol `partition_w128` (value 3, SPLIT), + which the reader skipped straight into the 10-symbol `partition_w64`. + The other six surfaced as the ref-slot refusal inside the encoder's trial + decode. +- Same class the lane-b128 merge swept through ten of their neighbours + (`FrameCtx::for_encoder`); these seven were the rest of it. + +## The gates (both arms re-run on THIS tree) + +`bd_rate_screen_native`, 12 frames, BD-rate vs libaom cpu-6 / rav1e s6 +(lower is better): + +| row | 64 superblocks (control) | 128 superblocks (default) | +|---|---|---| +| bars 1080p | -3.1 / -18.7 | **-3.7 / -19.2** | +| bars 2160p | +9.1 / -13.3 | **+8.5 / -13.8** | +| film A (1080p) | +20.3 / -5.0 | **+20.1 / -5.2** | +| film B (2160p) | +24.6 / -2.0 | **+24.3 / -2.2** | +| screen capture | +14.6 / -33.2 | **+14.4 / -33.2** | + +`bd_rate_film_long_gop`, 48 frames: + +| row | 64 superblocks | 128 superblocks | +|---|---|---| +| film A | +24.0 / -7.6 | **+23.6 / -7.9** | +| film B | +85.8 / +7.1 | **+85.1 / +6.6** | + +Every row is DOWN on both columns; screen is down on one and flat on the +other. The keep rule holds with room to spare. + +## Pins + +Re-taken for the flip (the same four pictures, now in 128 superblocks): +`(150, 8327, 0x33eb7bd59beaf2e3)`, `(60, 33194, 0xafded5cfca824703)` — was +`(150, 8252, ...)`, `(60, 33053, ...)`. `EC_AV1_SB128=0` restores the old +bytes exactly, which is also the proof that none of the four fixes moves the +64-superblock encoder. No other byte pin moved. + +## Suite / checks + + EC_AV1_SB128=1 (before the flip) + s1 --skip stream:: 341 passed; 0 failed; 34 ignored (only the 64-pins gate red) + s2 stream:: 201 passed; 0 failed; 15 ignored RC=0 + s3 10bit 42 passed; 0 failed; 1 ignored RC=0 + + default (SB128_DEFAULT = true, pins re-taken) + s1 342 passed; 0 failed; 34 ignored RC=0 + s2 201 passed; 0 failed; 15 ignored RC=0 + s3 42 passed; 0 failed; 1 ignored RC=0 + --ignored every_speed_preset_decodes_sample_exact_through_both_decoders ok + --ignored a_128_superblock_clip_whose_root_search... ok (405 blocks) + cargo check --workspace --all-targets 0 errors, 0 ec-av1 warnings + +## Disposition + +- `deferred`: HORZ / VERT at the 128 root, the 128 block's residual and its + compound arm, and the intra 128 root on key frames — lane-b128's three + deferrals, unchanged (the writer still refuses a non-skip 128 block). +- `open`: search-time vs write-time mv stacks still differ (lane-sb128b's own + second open item); the writer's clamp makes it safe, not right.