lanes/av1f44diverge: both 4:4:4 witnesses are ALREADY FIXED on main; class is an ENTROPY fork (H1, f92776ba)
Browse files at this commitcdb836b50fa2bd2ee5b70aba6a5ff74c348bf0e3Parent: bd8cc171 changed file +214 -0
- lanes/av1f44diverge.report.md +214 -0
lanes/av1f44diverge.report.mdadded+214 -0
| @@ -0,0 +1,214 @@ | ||
| 1 | +# lane-av1f44diverge — the two 4:4:4 "divergences with witnesses but no diagnosis" | |
| 2 | + | |
| 3 | +**Base / branch** `57834ee2` (main) → `lane-av1f44diverge`, worktree | |
| 4 | +`~/.cache/wt/av1f44diverge`. **No decode-path change is left on this branch** — | |
| 5 | +the report is the deliverable. Every number below was measured in this | |
| 6 | +worktree; nothing is quoted from a sibling report without being re-run. | |
| 7 | + | |
| 8 | +--- | |
| 9 | + | |
| 10 | +## 0. Verdict first | |
| 11 | + | |
| 12 | +**Both recorded divergences are already fixed on current main, and the class is | |
| 13 | +an ENTROPY fork, not a reconstruction one.** | |
| 14 | + | |
| 15 | +| witness | recorded on `4155c7c7` | measured on `57834ee2` (this lane) | | |
| 16 | +|---|---|---| | |
| 17 | +| (a) 4:4:4 "superres" 256x128 | DIVERGENT f2, first `Y(192,0)` ours 92 / oracle 106 | **0 / 0 / 0 mismatching samples on all three planes, all 4 decode-order frames** | | |
| 18 | +| (b) 4:4:4 odd 130x122 | DIVERGENT f3, first `Y(128,16)` ours 134 / oracle 170 | **0 / 0 / 0, all 4 frames** | | |
| 19 | +| (b-control) 4:4:4 odd 66x66 | EXACT | **0 / 0 / 0** (and exact on the pre-fix tree too, §5) | | |
| 20 | + | |
| 21 | +The cause is `f92776ba` (lane-av1444rect, "H1"), **already merged into main** | |
| 22 | +(`git merge-base --is-ancestor f92776ba HEAD` → yes), plus its follow-up | |
| 23 | +`e10a3b25`. I reproduced the old numbers by reverting exactly that one `match` | |
| 24 | +arm (§3), which makes the red-before mine rather than inherited, and classified | |
| 25 | +the fork with the `EC_SYMR` ladder (§4). | |
| 26 | + | |
| 27 | +--- | |
| 28 | + | |
| 29 | +## 1. Witnesses, rebuilt on current main | |
| 30 | + | |
| 31 | +Recipe — the chroma-format sweep's §6.2 recipe, re-run here, `W`/`H` per arm | |
| 32 | +(`rate=25` is load-bearing: `testsrc2`'s pattern is time-parameterised): | |
| 33 | + | |
| 34 | +```text | |
| 35 | +ffmpeg -f lavfi -i "testsrc2=size=<W>x<H>:rate=25" -frames:v 4 \ | |
| 36 | + -pix_fmt yuv444p -strict -1 -f yuv4mpegpipe - | | |
| 37 | +aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 \ | |
| 38 | + --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 \ | |
| 39 | + --limit=4 --obu -o - - | |
| 40 | +``` | |
| 41 | + | |
| 42 | +| cell | bytes | sha256 | committed pin | | |
| 43 | +|---|---|---|---| | |
| 44 | +| 130x122 | 8945 | `c87ac65b77579afd2938669b0cbe3ec44c3abf775c0223cacb9d14b8c2eee27c` | `444_lossy_rect4_odd_130x122.obu` (byte-identical) | | |
| 45 | +| 256x128 | 15239 | `06621606c11ae805f784a1c9736db6301a925a4fa3154e2fc38db1df7ad9b826` | `444_lossy_rect4_wide_256x128.obu` (byte-identical) | | |
| 46 | +| 66x66 | 5938 | `973eddf4aa6b0bf18ba8bdf7c16ef8173fe51438ae5c42f5c5863e93444181ca` | unpinned (live-encode gate) | | |
| 47 | + | |
| 48 | +The encodes took **1.4 s total on this box**, so the idle server | |
| 49 | +(`user@host-b`) was not needed. | |
| 50 | + | |
| 51 | +**Witness (a) is not a superres cell — measured here, not inherited.** Encoding | |
| 52 | +256x128 with and without `--superres-mode=1` gives **byte-identical** OBU | |
| 53 | +(15239 B, `06621606…` both), and `ffprobe` reports `width=256 coded_width=256` | |
| 54 | +(an active superres would show a smaller `coded_width`). The cell is a plain | |
| 55 | +4:4:4 lossy cq-20 stream; the crate already names its gate for the geometry | |
| 56 | +(`a_444_lossy_256x128_stream_decodes_pixel_exact`) rather than for a flag. | |
| 57 | + | |
| 58 | +## 2. Per-plane measurement method (independent of the gates) | |
| 59 | + | |
| 60 | +The gates already compare byte-for-byte, but a gate result cannot produce | |
| 61 | +*per-plane* counts, so I measured with the tools directly: | |
| 62 | + | |
| 63 | +- oracle: `EC_AV1_FINAL_DUMP=<dir>/aom aomdec --codec=av1 -o out.y4m <cell>.obu` | |
| 64 | + → `aom.f0..f3`, decode order, u8, `Y|U|V` planar, 3·W·H bytes | |
| 65 | + (256x128 → 98304, 130x122 → 47580, 66x66 → 13068; all four frames equal size). | |
| 66 | +- ours: `cargo run -p ec-av1 --example dump_yuv -- <cell>.obu <dir>/ours` | |
| 67 | + → `ours.f0..f3.yuv`, same layout, depth parsed from the sequence header | |
| 68 | + (8-bit). No altrefs in these recipes (0 hidden frames, `kf-max-dist=100`), | |
| 69 | + so display index == decode index. | |
| 70 | +- compare: a 30-line python per-plane walk (kept in `~/.cache/f44div/cmp.py`, | |
| 71 | + outside the repo) that counts per plane per frame and names the first | |
| 72 | + divergent sample as `plane(x,y) ours A oracle B`. | |
| 73 | + | |
| 74 | +## 3. Red-before, measured by me (the pre-H1 `around_c` arm) | |
| 75 | + | |
| 76 | +`crates/ec-av1/src/decode.rs:42457` `let around_c = match strip_chroma {` — | |
| 77 | +the green arm is | |
| 78 | + | |
| 79 | +```rust | |
| 80 | +Some(_) if ss_x(fctx) == 0 => { hit!(RECT4_INTER_OWN_CHROMA444_HITS); around } | |
| 81 | +``` | |
| 82 | + | |
| 83 | +Red arm = the pre-`f92776ba` state of that one arm: the `ss_x == 0` arm deleted | |
| 84 | +and the `pw/ph` choice restored to `if ss_x == 1 && ss_y == 0 { (16,4) } else | |
| 85 | +{ (16,8) }`. Nothing else touched; `git status --porcelain` on the main | |
| 86 | +checkout was empty after every batch. | |
| 87 | + | |
| 88 | +| cell | frames 0-1 | f2 | f3 | total | | |
| 89 | +|---|---|---|---|---| | |
| 90 | +| 256x128 (red) | 0 | **Y 9085/32768 first `Y(192,0)` ours 92 oracle 106; U 7985 first `U(211,0)`; V 8226 first `V(211,0)`** | Y 19818, U 15398, V 15892 | **76 404** | | |
| 91 | +| 130x122 (red) | 0, 0 | 0 | **Y 2975/15860 first `Y(128,16)` ours 134 oracle 170; U 4491 first `U(129,15)`; V 4055 first `V(102,32)`** | **11 521** | | |
| 92 | +| 66x66 (red) | 0 | 0 | 0 | **0** | | |
| 93 | + | |
| 94 | +Both recorded first-wrong samples and both recorded counts reproduce **to the | |
| 95 | +byte** (11521 and the `Y(192,0)`/`Y(128,16)` firsts). Green tree, same cells, | |
| 96 | +same method: **0 / 0 / 0 everywhere** (§2), and the 4:4:4 gate family is | |
| 97 | +17/17 green. | |
| 98 | + | |
| 99 | +## 4. Classification: ENTROPY fork (both witnesses) | |
| 100 | + | |
| 101 | +`EC_SYMR=1` on both sides, one line per symbol read in decode order, aligned on | |
| 102 | +`(value, range, n, s, post_rng)` with the CDF-row convention reconciled | |
| 103 | +(`32768 - ours_cdf0 == oracle_cdf0`; verified by that predicate holding on every | |
| 104 | +paired read except the fork itself). Oracle lines come from the instrumented | |
| 105 | +`aom_dsp/bitreader.h` rung, which carries `site=<file>:<line>`. | |
| 106 | + | |
| 107 | +| cell (red tree) | reads ours / oracle | first divergent read | mi (4-px MI) | what differs | | |
| 108 | +|---|---|---|---|---| | |
| 109 | +| 130x122 | 43 700 / 43 700 | **41 166** (frame 3) | **(12, 23)** | `pre=(32638, 36058)` **identical both sides**; `n=2 s=0`; `cdf0` ours 32310 (→ 458) vs oracle 2357 | | |
| 110 | +| 256x128 | 63 275 / 74 192 | **55 192** (frame 2) | **(11, 36)** | `pre=(38795, 44892)` **identical both sides**; `n=2 s=0`; `cdf0` ours 26963 (→ 5805) vs oracle 3789 | | |
| 111 | +| 66x66 | 28 294 / 28 294 | **none** | — | all 28 294 reads agree, CDF convention included | | |
| 112 | + | |
| 113 | +Green tree, same ladder: **43 700 / 74 192 / 28 294 reads, zero divergence** on | |
| 114 | +all three cells. | |
| 115 | + | |
| 116 | +**This is a CDF-row selection error, not a bit-position error.** At the fork the | |
| 117 | +two decoders hold *the same* `(value, range)` and differ only in which row of the | |
| 118 | +CDF they selected — i.e. the coder state is identical and the *context* is not. | |
| 119 | +The `pre` third field (our msac bit position) sits at a constant +15 to the | |
| 120 | +oracle's, the documented offset, and the CDF convention reconciles on every read | |
| 121 | +after the fork (+1: `32768-9909 == 22859` = the oracle's `cdf0`). So the fork is | |
| 122 | +one symbol read choosing a different neighbour-context row, and everything after | |
| 123 | +it is downstream damage. | |
| 124 | + | |
| 125 | +**The fork site is a 1:4 inter strip, located from the block trace.** | |
| 126 | +`EC_MC_TRACE=1` prints every inter block's origin and write size | |
| 127 | +(`EC_IB px=.. py=.. w=.. h=..`): | |
| 128 | + | |
| 129 | +- 130x122, mi(12,23) → pixel **(92, 48)**: `EC_IB px=92 py=48 side=16 w=4 h=16` | |
| 130 | + — a **VERT_4 (4x16)** strip. | |
| 131 | +- 256x128, mi(11,36) → pixel **(144, 44)**: `EC_IB px=144 py=44 side=16 w=16 h=4` | |
| 132 | + — a **HORZ_4 (16x4)** strip. | |
| 133 | + | |
| 134 | +Both are the shapes whose pre-H1 gather used the 4:2:0 pair extent | |
| 135 | +(`(8,16)` / `(16,8)`) where 4:4:4 `is_chroma_reference` means no pair exists. The | |
| 136 | +damage profile agrees: on 256x128 f2 the chroma planes are wrong by more | |
| 137 | +samples than luma (U 7985, V 8226 vs Y 9085 of a 32768-sample plane, and the first | |
| 138 | +wrong U/V samples are *inside* the strip's own rows), which is what a wrong | |
| 139 | +*chroma* context predicts. | |
| 140 | + | |
| 141 | +**Class, in one sentence:** at `ss (0,0)` a 1:4 inter strip's chroma | |
| 142 | +coefficient context was gathered over the 4:2:0 pair extent instead of the | |
| 143 | +strip's own extent, so the U unit's `get_txb_ctx` saw a left/above neighbour | |
| 144 | +libaom does not have and the arithmetic coder forked at the strip's first | |
| 145 | +2-symbol chroma read. | |
| 146 | + | |
| 147 | +## 5. The 66x66 control: exact in BOTH arms, and why that is not a geometry fact | |
| 148 | + | |
| 149 | +Quoted as asked: at the same settings (`cq 20`, `cpu-used 2`, yuv444p, same | |
| 150 | +oracle) 66x66 is **0 / 0 / 0 on all 4 frames, on the pre-fix tree as well as on | |
| 151 | +main**; entropy is bit-identical there in both arms (28 294 reads, no fork). | |
| 152 | + | |
| 153 | +The interesting part is that the site **is** reached at 66x66 — the live gate | |
| 154 | +counts 13 own-extent 1:4 gathers there — so its immunity is not "the route never | |
| 155 | +ran". Two extra measurements narrow what it is: | |
| 156 | + | |
| 157 | +| counterfactual stream (same encode flags) | 1:4 inter strips | pre-H1 verdict | | |
| 158 | +|---|---|---| | |
| 159 | +| 66x66 from `testsrc2` (the sweep's control) | 24 of 48 inter-block reads are 1:4 strips (px 0/8/12/16/32/44, both orientations) | **exact, 0/0/0** | | |
| 160 | +| 66x66 from `geq=random` (13482 B, sha `a0718b30…`) | 8 of 18 | **exact, 0/0/0** | | |
| 161 | +| 130x122 from `geq=random` (53042 B, sha `871882bd…`) | 8 of 100 | **exact, 0/0/0** | | |
| 162 | + | |
| 163 | +So 66x66's immunity is **neither content-dependent** (a noise-sourced 66x66 is | |
| 164 | +also exact) **nor "no 1:4 strips"** (it has them, 8–13 by counter). What separates | |
| 165 | +the cells is whether the pre-H1 pair-extent gather returns a *different* second | |
| 166 | +neighbour row/column at some site — on 66x66 it never does. | |
| 167 | + | |
| 168 | +**What I could not separate:** *why* the extra neighbour coincides at every 66x66 | |
| 169 | +site (most likely the two 4-px cells the pair extent adds are covered by the | |
| 170 | +same neighbouring block, so the gather duplicates one descriptor). The | |
| 171 | +discriminating measurement is a per-site dump of both gathers' results | |
| 172 | +(`pair_mi`, `has_chroma`, orientation, and the two returned context vectors) at | |
| 173 | +the 13 66x66 sites — I did not add that instrumentation, because the class and | |
| 174 | +the fix are already settled and the question no longer gates anything. | |
| 175 | + | |
| 176 | +## 6. Gates and state | |
| 177 | + | |
| 178 | +Both witness cells and the control are **already gated on main** and were | |
| 179 | +re-quoted here (17 tests, all green, `cargo test -p ec-av1 --lib -- 444_lossy | |
| 180 | +rect4 444_rect --test-threads=1`): | |
| 181 | + | |
| 182 | +| gate | cell | this lane's run | | |
| 183 | +|---|---|---| | |
| 184 | +| `a_444_lossy_odd_66x66_stream_decodes_pixel_exact` | 66x66 | ok — 13 own-extent gathers | | |
| 185 | +| `a_444_lossy_odd_130x122_stream_decodes_pixel_exact` | 130x122 | ok — 12 gathers | | |
| 186 | +| `a_444_lossy_256x128_stream_decodes_pixel_exact` | 256x128 | ok — 24 gathers | | |
| 187 | +| `a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries` | both pinned cells | ok | | |
| 188 | +| `a_444_lossy_rect4_inter_stream_decodes_pixel_exact` | the 128x96 H1 pin | ok | | |
| 189 | + | |
| 190 | +Nothing to add: each gate already (a) compares every decode-order frame against | |
| 191 | +`aomdec` with the length asserted first, (b) asserts the 4:4:4 full-resolution | |
| 192 | +chroma shape, and (c) asserts `rect4_inter_own_chroma444_hits() > 0`, so none of | |
| 193 | +them can pass vacuously. | |
| 194 | + | |
| 195 | +**The non-vacuity proof, measured here.** With the same one-arm revert as §3 all | |
| 196 | +three gates go red — `test result: FAILED. 0 passed; 3 failed` — but each fails | |
| 197 | +on assert **(c)**, not on pixels: `no 4:4:4 1:4 inter strip read its chroma | |
| 198 | +context over its own extent`. The `hit!(RECT4_INTER_OWN_CHROMA444_HITS)` sits | |
| 199 | +inside the deleted arm, so the counter reads 0 and the assert fires *before* the | |
| 200 | +oracle compare. That is worth knowing when reading a red here: the pixel red is | |
| 201 | +the direct `dump_yuv`-vs-`aomdec` measurement of §3, not the gate's message. | |
| 202 | +Green again after `git checkout -- crates/ec-av1/src/decode.rs`: 3 passed. | |
| 203 | + | |
| 204 | +**Recommendation for the debt list:** drop (a) and (b) as open items; they are | |
| 205 | +closed by `f92776ba`/`e10a3b25` with gates. The only residue worth carrying is | |
| 206 | +§5's last paragraph, and even that is a measurement request, not a defect. | |
| 207 | + | |
| 208 | +## 7. Files | |
| 209 | + | |
| 210 | +- Branch diff vs `57834ee2`: **this report only** (`lanes/av1f44diverge.report.md`). | |
| 211 | +- Throwaway instruments, outside the repo: `~/.cache/f44div/cmp.py` (per-plane | |
| 212 | + compare), `~/.cache/f44div/symr.py` (EC_SYMR aligner), | |
| 213 | + `~/.cache/f44div/{cmp,symr,mctrace}-*.log`, encodes in `~/.cache/f44div/*.obu`. | |
| 214 | +- Build: `CARGO_TARGET_DIR=/home/user/.cache/tgt-f44div` (private). |