av1h5: lane report (H5 444 lossless 128-root 10-bit entropy fork)
Browse files at this commit19967ac991920c7e3b44f582c8039b91f1750279Parent: e772a721 changed file +188 -0
- lanes/av1h5.report.md +188 -0
lanes/av1h5.report.mdadded+188 -0
| @@ -0,0 +1,188 @@ | ||
| 1 | +# lane-av1h5 — 4:4:4 lossless 10-bit, 128-root partition: localized, NOT fixed | |
| 2 | + | |
| 3 | +Handoff of H5 from `lanes/av1formatsweep.report.md`. Worktree | |
| 4 | +`~/.cache/wt/av1h5`, branch `lane-av1h5`, base `4155c7c7`. **Nothing | |
| 5 | +committed, nothing pushed** — the budget ran out mid-localization and the | |
| 6 | +defect is NOT fixed. Everything below is measured, not inferred. | |
| 7 | + | |
| 8 | +## 1. Witness | |
| 9 | + | |
| 10 | +``` | |
| 11 | +ffmpeg -y -v error -f lavfi -i testsrc2=s=128x96:r=25 -frames:v 6 \ | |
| 12 | + -pix_fmt yuv444p10le -strict -1 -f yuv4mpegpipe /tmp/h5.y4m | |
| 13 | +~/.cache/aom-oracle/build/aomenc --codec=av1 --profile=1 \ | |
| 14 | + --input-bit-depth=10 --bit-depth=10 --lossless=1 --enable-palette=0 \ | |
| 15 | + --enable-intrabc=0 --cq-level=20 --cpu-used=0 --passes=1 --end-usage=q \ | |
| 16 | + --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=6 \ | |
| 17 | + --obu -o /tmp/h5.obu /tmp/h5.y4m | |
| 18 | +``` | |
| 19 | + | |
| 20 | +63429 bytes, **sha256 `bbffb979d20d581deb271aac75b7ee779dde57c024524ed6b1389356f55ca0fa`**, | |
| 21 | +6 frames, 128x96, `ss (0,0)` at 10-bit, lossless. | |
| 22 | + | |
| 23 | +## 2. The control arm (this is what makes the rest a decoder verdict) | |
| 24 | + | |
| 25 | +Same recipe, one flag changed: | |
| 26 | + | |
| 27 | +| arm | bytes | verdict vs `aomdec --rawvideo` | | |
| 28 | +|---|---|---| | |
| 29 | +| `--max-partition-size=64` (no 128 root) | 61494 | **EXACT**, all 6 frames | | |
| 30 | +| default (128 root reachable) | 63429 | **DIVERGES**, first at byte 74769 | | |
| 31 | + | |
| 32 | +So the comparison harness is sound on this exact content, and the 128x128 | |
| 33 | +unsplit root is **necessary** for the defect. The sibling at `--cpu-used=2` | |
| 34 | +(gate B, `a_lossless_444_10bit_inter_stream_decodes_pixel_exact`) never reaches | |
| 35 | +the 128 root and is exact. | |
| 36 | + | |
| 37 | +## 3. First divergence | |
| 38 | + | |
| 39 | +Whole-stream `dump_yuv` (u16 LE) concatenated, compared byte-for-byte with | |
| 40 | +`aomdec --rawvideo`: | |
| 41 | + | |
| 42 | +* first differing byte: **74769** of the concatenation | |
| 43 | +* frame size is 128*96*3*2 = 73728 bytes, so this is **decode-order frame 1**, | |
| 44 | + offset 1040 bytes = sample 520 | |
| 45 | +* 520 = row 4, col 8 of the 128-wide luma plane → **first wrong sample Y(4, 8)** | |
| 46 | + | |
| 47 | +(`av1formatsweep.report.md` recorded this site as `Y(8,4)`; same site, row and | |
| 48 | +column transposed.) | |
| 49 | + | |
| 50 | +## 4. EC_SYMR ladder — entropy fork, not reconstruction | |
| 51 | + | |
| 52 | +Paired `EC_SYMR` traces (ours `msac.rs`, oracle `aom_dsp/bitreader.h`), aligned | |
| 53 | +on `(range, post_rng, s, n)`; the CDF convention reconciles as | |
| 54 | +`32768 - ours_icdf0 == oracle_cdf0` (verified over the first 2000 reads). | |
| 55 | + | |
| 56 | +| index | oracle | ours | | | |
| 57 | +|---|---|---|---| | |
| 58 | +| 43834-43839 | `decodetxb.c:158` n=2 s=1, cdf0 32717..32729 | icdf0 51..39, mirror matches | agree | | |
| 59 | +| **43840** | `decodetxb.c:158` n=2 s=1 **cdf0=32731** | icdf0=63 → mirror **32705** | **first CDF-state divergence** | | |
| 60 | +| 43841-43842 | cdf0 32732, 32733 | mirror 32708, 32711 | diverging | | |
| 61 | +| **43843** | `decodetxb.c:242` n=5 **s=3** | **s=4** | **first SYMBOL divergence** | | |
| 62 | + | |
| 63 | +* `decodetxb.c:158` is the `txb_skip` / `all_zero` read: | |
| 64 | + `aom_read_symbol(r, ec_ctx->txb_skip_cdf[txs_ctx][txb_ctx->txb_skip_ctx], 2, ...)`. | |
| 65 | +* `decodetxb.c:242` is the EOB pass-count read, `eob_flag_cdf16[plane][ctx]`, 5 symbols. | |
| 66 | +* Both sides at the fork: `ph=inter`, `mi=(0,0)`, identical pre-state | |
| 67 | + (`pre=(49549, 65280, …)`, range 65280). | |
| 68 | + | |
| 69 | +**Verdict: entropy fork.** The decoder selects a different `txb_skip` CDF ROW | |
| 70 | +for a chroma unit; the symbols happen to survive three reads and then diverge. | |
| 71 | +Nothing here is reconstruction arithmetic — the two decoders are reading | |
| 72 | +different probability distributions from the same bit position. | |
| 73 | + | |
| 74 | +## 5. Where the row selection goes wrong (the handoff) | |
| 75 | + | |
| 76 | +libaom, `get_txb_ctx_general` (`av1/common/txb_common.h:353-359`), chroma arm: | |
| 77 | + | |
| 78 | +```c | |
| 79 | +const int ctx_base = get_entropy_context(tx_size, a, l); | |
| 80 | +const int ctx_offset = (num_pels_log2_lookup[plane_bsize] > | |
| 81 | + num_pels_log2_lookup[txsize_to_bsize[tx_size]]) ? 10 : 7; | |
| 82 | +txb_ctx->txb_skip_ctx = ctx_base + ctx_offset; | |
| 83 | +``` | |
| 84 | + | |
| 85 | +Two rows of the port's chroma table matter and the oracle census says both | |
| 86 | +fire. `EC_DBGCTX` on the oracle, whole stream, 9216 chroma units: | |
| 87 | + | |
| 88 | +``` | |
| 89 | +off=7 520 units off=10 8696 units | |
| 90 | +``` | |
| 91 | + | |
| 92 | +and at the fork site itself (`mi=0,0`, the first inter block) every chroma unit | |
| 93 | +is `tx=0` (TX_4X4 — lossless forces it) with **`off=7`**: | |
| 94 | + | |
| 95 | +``` | |
| 96 | +EC_DBGCTX mi=0,0 plane=1 tx=0 above0=0 left0=0 base=0 off=7 ctx=7 cellsA=0, cellsL=0, | |
| 97 | +EC_DBGCTX mi=0,0 plane=2 tx=0 above0=0 left0=0 base=0 off=7 ctx=7 cellsA=0, cellsL=0, | |
| 98 | +``` | |
| 99 | + | |
| 100 | +`read_plane` (`decode.rs:19627-19636`) picks the band like this: | |
| 101 | + | |
| 102 | +```rust | |
| 103 | +let skip_ctx = if plane_idx == 0 { | |
| 104 | + luma_skip_ctx.unwrap_or(0) | |
| 105 | +} else { | |
| 106 | + usize::from(around.0) + usize::from(around.1) + luma_skip_ctx.unwrap_or(0) | |
| 107 | +}; | |
| 108 | +``` | |
| 109 | + | |
| 110 | +and `luma_skip_ctx` / `luma_skip_ctx_rect` (`decode.rs:9361-9411`) return the | |
| 111 | +**luma** formula `SKIP_CONTEXTS[top][left]` — a value that is being used here | |
| 112 | +as the chroma **offset band**. Its own doc comment says the `+3` that reaches | |
| 113 | +the offset-10 rows applies "only [to] a 128x128 block's TX_32X32 chroma units, | |
| 114 | +lane-sb128b r3". **H5 is a 128x128 root with TX_4X4 units**, i.e. exactly the | |
| 115 | +combination that comment does not cover, and it is the only committed-free cell | |
| 116 | +where a 128-root meets lossless. That is where to look first: whether the | |
| 117 | +offset-10 band is being selected (or the offset-7 band) for a 128-root's | |
| 118 | +lossless chroma units, and whether `ctx_base` should be | |
| 119 | +`get_entropy_context` rather than the luma `SKIP_CONTEXTS` table. | |
| 120 | + | |
| 121 | +Note the port's table is **reindexed**: our chroma rows 0..2 stand for libaom's | |
| 122 | +7..9 and our 3..5 for libaom's 10..12, so a raw `ctx` comparison between the | |
| 123 | +two traces is meaningless without that `+7`. Verified on the first two | |
| 124 | +coefficient units of the stream (ours `ctx=0` ↔ oracle `ctx=7`). | |
| 125 | + | |
| 126 | +## 6. Is this Agent04's H1 class? | |
| 127 | + | |
| 128 | +**No — different site, different trigger.** H1 is 4:4:4 **lossy** + a **rect** | |
| 129 | +partition, and its fork is a unit-ordering bug: the rect walk emits a second | |
| 130 | +luma unit where the oracle moves to the chroma plane (the `EC_COEFF_STEP` | |
| 131 | +`plane=0` label on our side is a label bug there). H5 is 4:4:4 **lossless** + | |
| 132 | +a **square 128 root**, and its fork is a single wrong `txb_skip` CDF row inside | |
| 133 | +one unit — the unit walk itself is aligned (the `all_zero` reads pair up with | |
| 134 | +identical `rng` on both sides for the whole prefix). Same broad neighbourhood | |
| 135 | +(4:4:4 chroma coefficient context), different defect. Notified | |
| 136 | +`agent://Agent04-2` so it is not fixed twice. | |
| 137 | + | |
| 138 | +### 6b. The H1/H5 split is formula-halves, and the arms are disjoint | |
| 139 | + | |
| 140 | +`Agent04-2`'s H1 root cause (confirmed to me directly): the 1:4-pair chroma | |
| 141 | +gather runs at the 4:2:0 PAIR extent (16x8 / 8x16), where | |
| 142 | +`is_chroma_reference` reduces both parity clauses to `!ss_y` / `!ss_x`, so the | |
| 143 | +strip is its own chroma reference and the gather reads one extra luma mi row of | |
| 144 | +LEFT context. Their `ctx_base` came out 1 (0 above + 1 left) where the oracle | |
| 145 | +read offset-7 row 7 (= `ctx_base` 0). Pinned fixture 6441 B, | |
| 146 | +sha256 `77f727e7...`, now byte-exact on their branch. | |
| 147 | + | |
| 148 | +The two lanes split ONE formula along its two terms: | |
| 149 | + | |
| 150 | +``` | |
| 151 | +txb_skip_ctx = get_entropy_context(tx_size, a, l) <-- H1: the ctx_base term | |
| 152 | + + (plane_bsize > tx block ? 10 : 7) <-- H5: the BAND/OFFSET term | |
| 153 | +``` | |
| 154 | + | |
| 155 | +**The arms are structurally disjoint, not merely different.** Agent04's fix is | |
| 156 | +the match arm `Some(_) if ss_x(fctx) == 0 => around` inside `match | |
| 157 | +strip_chroma`, and `strip_chroma` is `Some` only from the single setter | |
| 158 | +(`decode.rs:50852`) that the `PARTITION_HORZ_4` / `VERT_4` 16x4 / 4x16 | |
| 159 | +`inter_piece` loop runs. A `BLOCK_128X128` unsplit root never reaches that | |
| 160 | +loop, so `mi(0,0)` on this 128-root stream cannot move through Agent04's gate. | |
| 161 | +They are re-running this exact recipe (63429 B, sha256 `bbffb979...`) against | |
| 162 | +base and their tip to turn that argument into a measured "unchanged". | |
| 163 | + | |
| 164 | +**Caveat for whoever measures:** H5 was characterized on a tree that does NOT | |
| 165 | +contain Agent04's fix. The `--max-partition-size=64` control being byte-exact | |
| 166 | +proves the 128 root is necessary, but on its own it says nothing about the | |
| 167 | +`ctx_base` half at that root. Take the re-measurement above as the authority. | |
| 168 | + | |
| 169 | +## 7. What a follow-up lane should do, in order | |
| 170 | + | |
| 171 | +1. Instrument the band selection in `read_plane` (a one-line | |
| 172 | + `EC_DBGCTX`-shaped rung on our side: plane, tx_size, plane_bsize, the chosen | |
| 173 | + offset) and diff it against the oracle's `EC_DBGCTX` for the first inter | |
| 174 | + block. That single run should name the wrong term. | |
| 175 | +2. Fix one class: the 128-root lossless chroma band. Do **not** touch the rect | |
| 176 | + unit walk (H1's territory). | |
| 177 | +3. Re-run the two arms of §2. Both must be byte-exact. | |
| 178 | +4. Then arm a gate: the recipe above at `--cpu-used=0`, `ss (0,0)` + 10-bit | |
| 179 | + header assert, plus a counter on the corrected route so the gate is not | |
| 180 | + blind, and a mutation proof (flip the band back → the gate must go red on | |
| 181 | + the first inter frame, byte 74769). | |
| 182 | +5. Re-measure the committed 4:4:4 / 4:2:0 pins afterwards. | |
| 183 | + | |
| 184 | +## 8. State | |
| 185 | + | |
| 186 | +No commit. `~/.cache/wt/av1h5` carries no source edits — the work was | |
| 187 | +measurement only (EC_SYMR / EC_TRACE_COEFF / EC_DBGCTX traces, all env-gated | |
| 188 | +and pre-existing). No `EC_AV1_ALLOW_422_PROBE` bypass was applied or needed. |