Lane-seg2 report
Browse files at this commitbcdc861dd742b518f2662890072f576295c5a0c0Parent: 6c9362c- docs
- lane-seg2 report
1 changed file +106 -0
- lanes/seg2.report.md +106 -0
lanes/seg2.report.mdadded+106 -0
| @@ -0,0 +1,106 @@ | |||
| 1 | +# lane-seg2 — libaom `-aq-mode 1` on film B: the sub-8x8 intra reader had no segment id | ||
| 2 | + | ||
| 3 | +Two defects, one reader. Class: **`symbol-consumption-gap`** (a syntax element | ||
| 4 | +the spec codes for every block was never read on one block-shape path), with | ||
| 5 | +the second half in the **`tx-grid-published-block-side`** shape (a per-mi map | ||
| 6 | +stamped with the wrong footprint). | ||
| 7 | + | ||
| 8 | +## First divergent symbol | ||
| 9 | + | ||
| 10 | +`filmB_aom45.obu` (`crop=1920:1024`, 12 frames, libaom `-cpu-used 6 -crf 45 | ||
| 11 | +-aq-mode 1`), frame 0 = KEY frame, first bad luma sample (883, 888). | ||
| 12 | + | ||
| 13 | +Cross-decoder `EC_IMODE` range ladder (aomdec `EC_TRACE_MODE_STEP` vs our | ||
| 14 | +`EC_TRACE_MODE_STEP`), blocks 1..1799 identical, block 1800 diverges: | ||
| 15 | + | ||
| 16 | +``` | ||
| 17 | +aom EC_IMODE mi_row=226 mi_col=218 bsize=0 rng=35072 (BLOCK_4X4 split leaf) | ||
| 18 | +ours EC_IMODE mi_row=226 mi_col=218 fn=sub8 rng=35072 | ||
| 19 | +aom ... next block EC_IMODE mi_row=226 mi_col=219 rng=43528 | ||
| 20 | +ours ... next block EC_IMODE mi_row=226 mi_col=219 rng=33544 | ||
| 21 | +``` | ||
| 22 | + | ||
| 23 | +i.e. the desync is INSIDE the frame's first sub-8x8 intra leaf. | ||
| 24 | + | ||
| 25 | +At `crf 5` the same ladder puts the first divergence at mi (198, 148), and the | ||
| 26 | +new `EC_SEG` trace (added to both decoders) names the element exactly: | ||
| 27 | + | ||
| 28 | +``` | ||
| 29 | +aom EC_SEG mi_row=198 mi_col=148 cdf=1 pred=1 coded=1 id=2 rng=61592 | ||
| 30 | +ours EC_SEG mi_row=198 mi_col=148 cdf=0 pred=0 coded=1 id=1 rng=35672 | ||
| 31 | +``` | ||
| 32 | + | ||
| 33 | +`cdf_index` 0 vs 1 and prediction 0 vs 1: our `av1_get_spatial_seg_pred` read | ||
| 34 | +segment 0 out of the LEFT neighbour mi (198, 147). | ||
| 35 | + | ||
| 36 | +## Root cause | ||
| 37 | + | ||
| 38 | +`crates/ec-av1/src/decode.rs read_intra_mode_sub8` — the reader every | ||
| 39 | +`BLOCK_4X4` split leaf AND every 8x4/4x8 leaf goes through — never called | ||
| 40 | +spec 5.11.6's `intra_segment_id` at all: | ||
| 41 | + | ||
| 42 | +1. **the symbol was never read.** On a stream with `segmentation_enabled` the | ||
| 43 | + leaf's `segment_id` symbol stayed in the bitstream, so the tile desynced | ||
| 44 | + from the frame's first sub-8x8 partition on (and `cur_segment_id` kept the | ||
| 45 | + PREVIOUS block's value, so the leaf also dequantized with a neighbour's | ||
| 46 | + `SEG_LVL_ALT_Q`). Fixed at `098e5e1c`. | ||
| 47 | +2. **the stamp was 1x1.** Reading it with a hardcoded 1x1 mi footprint is the | ||
| 48 | + second half: the same reader serves 8x4/4x8 leaves, whose second mi cell | ||
| 49 | + stayed at segment 0 and was read back by the NEXT block as its spatial | ||
| 50 | + prediction and CDF row. Fixed at `8e58fcc7` (footprint threaded from the | ||
| 51 | + leaf's own `bw`/`bh`: 1x1 for a 4x4 leaf, `bw/4 x bh/4` for a rect one). | ||
| 52 | + | ||
| 53 | +Both halves are needed: with only (1) the film B libaom crf 5 and 20 points are | ||
| 54 | +still 9.2M/9.7M samples off; the witness below is red under either half alone. | ||
| 55 | + | ||
| 56 | +## Same-shape sweep — every site that reads or stamps the segment map | ||
| 57 | + | ||
| 58 | +| site (`decode.rs`) | reader | footprint passed | verdict | | ||
| 59 | +| --- | --- | --- | --- | | ||
| 60 | +| `read_intra_mode_rect` (8922/8927) | rect intra | `(bw/4, bh/4)` | ok | | ||
| 61 | +| `decode_leaf8`/square (13031/13039) | square intra | `(side/4, side/4)` | ok | | ||
| 62 | +| `read_intra_mode_sub8` (15747/15755) | 4x4 split + 8x4/4x8 intra leaf | **absent, then 1x1** | **FIXED (both halves)** | | ||
| 63 | +| inter block reader (26625/26644) | inter | `(write_w/4, write_h/4)` | ok | | ||
| 64 | +| `decode_inter_sub8_split4` (30394/30398) | 4x4 inter leaf | `(1, 1)` | ok (BLOCK_4X4 is 1x1 mi) | | ||
| 65 | +| inter 4x8/8x4 leaf (31437/31441) | rect inter leaf | `(bw/MI, bh/MI)` | ok | | ||
| 66 | +| inter 8x8 leaf (32181/32189) | 8x8 inter leaf | `(2, 2)` | ok | | ||
| 67 | + | ||
| 68 | +Consumers of the map, all reading through the two single points | ||
| 69 | +`segment_id_at` / `block_q_idx` (which is why only the WRITE side was wrong): | ||
| 70 | +`spatial_seg_pred`, `predicted_segment_id`, `block_q_idx` (`SEG_LVL_ALT_Q`), | ||
| 71 | +the deblocker's per-segment `lf_level`. No second write path exists. | ||
| 72 | + | ||
| 73 | +## Witness | ||
| 74 | + | ||
| 75 | +`stream::tests::a_segmented_key_frame_with_sub_8x8_intra_leaves_decodes_exactly` | ||
| 76 | +(new, in the existing `stream::` test binary, no fixture committed): | ||
| 77 | +`color=c=gray:s=384x152 , noise=alls=80:all_seed=7:allf=t+u` -> ffmpeg | ||
| 78 | +`libaom-av1 -cpu-used 2 -b:v 0 -crf 5 -aq-mode 1 -g 4`, 4 frames, decoded by | ||
| 79 | +ffmpeg and by us, all three planes, plus `segment_ids_seen() >= 2` so a | ||
| 80 | +one-segment (vacuous) run cannot pass. | ||
| 81 | + | ||
| 82 | +- green at HEAD: `4 frames sample-exact, 1963 segment_id symbols, 3 distinct ids`, 2.16 s | ||
| 83 | +- red with the fix reverted: `FAILED. 0 passed; 1 failed` (measured 134464 | ||
| 84 | + samples off pre-fix, 134082 off with only the first half of the fix) | ||
| 85 | + | ||
| 86 | +`-cpu-used 2` is load-bearing: at `-cpu-used 6` (the straddle gate's recipe) | ||
| 87 | +libaom answers this source with no sub-8x8 intra partition and the row passes | ||
| 88 | +with the defect in — measured on four probe recipes. | ||
| 89 | + | ||
| 90 | +## Ladder (12 frames, all planes, vs ffmpeg; streams from lane-golomb2) | ||
| 91 | + | ||
| 92 | +| stream | pre-fix | after `098e5e1c` | HEAD | | ||
| 93 | +| --- | --- | --- | --- | | ||
| 94 | +| film B 1920x1024 libaom crf 5 / 20 / 35 / 45, `-aq-mode 1` | 4x DIFF | 2 EXACT, 2 DIFF | **4/4 EXACT** | | ||
| 95 | +| film B 1920x1024 rav1e q 50 / 100 / 150 / 200 | 4/4 EXACT | 4/4 EXACT | **4/4 EXACT** | | ||
| 96 | +| film A 1920x792 libaom crf 5 / 20 / 35 / 45 | 4/4 EXACT | — | **4/4 EXACT** | | ||
| 97 | +| film A 1920x792 rav1e q 50 / 100 / 150 / 200 | 4/4 EXACT | — | **4/4 EXACT** | | ||
| 98 | + | ||
| 99 | +## Instruments added (kept) | ||
| 100 | + | ||
| 101 | +- `EC_TRACE_SEG=1` on BOTH decoders: `EC_SEG mi_row= mi_col= cdf= pred= coded= id= rng=` | ||
| 102 | + (libaom side patched in `~/.cache/aom-oracle/src/av1/decoder/decodemv.c`, | ||
| 103 | + rebuilt in place). | ||
| 104 | +- `EC_HDR=1` also prints `EC_SEGHDR enabled/update_map/temporal/preskip/last_active/data`. | ||
| 105 | +- `EC_TRACE_MODE_STEP=1` now prints the `skip`/`cdef`/`dq`/`mode` ladder for | ||
| 106 | + sub-8x8 leaves too, which is what separated "segment id" from "cdef". | ||