Merge lane-av1422h232: the odd-height 4:2:0 divergence is a CHROMA TX-TYPE error, not geometry (report only)
Browse files at this commit1 changed file +259 -0
- lanes/av1422h232.report.md +259 -0
lanes/av1422h232.report.mdadded+259 -0
| @@ -0,0 +1,259 @@ | |||
| 1 | +# lane-av1422h232 — the 4:2:0 odd-height reconstruction defect is an **IDTX/DCT_DCT chroma tx_type loss** on 32-point inter chroma | ||
| 2 | + | ||
| 3 | +Base `9d5f7bd9` (fast-forwarded to `3f08ae3f`, tree clean, **no code change**). | ||
| 4 | +Worktree `~/.cache/wt/av1422h232`, branch `lane-av1422h232`. | ||
| 5 | + | ||
| 6 | +## Verdict | ||
| 7 | + | ||
| 8 | +**The defect is a one-line-class bug with a decisive measurement behind it: for an | ||
| 9 | +inter/intrabc block whose luma transform coded `IDTX`, our decoder resolves the | ||
| 10 | +32-point CHROMA transform type to `DCT_DCT` while libaom inherits the luma's | ||
| 11 | +`IDTX`.** The coefficients are byte-identical on both sides; only the transform | ||
| 12 | +differs, and `IDTX` (a plain copy) versus `DCT_DCT` (a separable IDCT) produce | ||
| 13 | +completely different residual shapes. | ||
| 14 | + | ||
| 15 | +I did **not** ship the fix: the measurement localises the site, but confirming it | ||
| 16 | +requires reading `reduce_inherited_chroma_tx_type` / `av1_get_ext_tx_set_type` | ||
| 17 | +against each other, and a speculative edit to a bit-exact decoder on a hunch is | ||
| 18 | +exactly what lane-av1422anom was chartered to avoid. The unblock is named in §7 | ||
| 19 | +and is one function. | ||
| 20 | + | ||
| 21 | +The trigger is **not** a height or width rule. It is content: any stream with an | ||
| 22 | +inter/intrabc block whose luma codes `IDTX` and whose chroma plane block reaches | ||
| 23 | +32 points **with nonzero coefficients**. 8 of the 27 cells I swept fail; the | ||
| 24 | +passing heights are not the multiples of 8 (232/236/248 fail, 240/244 pass). | ||
| 25 | + | ||
| 26 | +## 1. Red-before, on a comparator that reads both sides | ||
| 27 | + | ||
| 28 | +`count_rawvideo_diffs` (main, from lane-av1422anom) vs the oracle's real | ||
| 29 | +`aomdec --rawvideo` bytes, per plane: | ||
| 30 | + | ||
| 31 | +| stream | wrong Y | wrong U | wrong V | frames exact | | ||
| 32 | +|---|---|---|---|---| | ||
| 33 | +| `420_oddheight_320x232.obu` (pinned, sha256 `6832c3cd…78c`) | 0 | **5772** | **12086** | 0/16 | | ||
| 34 | +| the same stream from my own encode recipe | 0 | 5772 | 12086 | 0/16 — **byte-identical pin reproduced** | | ||
| 35 | + | ||
| 36 | +The pin reproduces byte-for-byte: my independently generated | ||
| 37 | +`aomenc --profile=0 --cq-level=45 --cpu-used=0 --limit=16` of `testsrc2 | ||
| 38 | +size=320x232` is sha256 `6832c3cd867f5fc491b45fd67f77c38453db0ca6d461e7d225e6276f4d0784c8`, | ||
| 39 | +identical to the committed fixture. The recipe in lane-av1422anom is exact. | ||
| 40 | + | ||
| 41 | +### Non-vacuity control (the batch rule) | ||
| 42 | + | ||
| 43 | +I flipped **one byte of the real oracle dump** and re-ran the same comparator. A | ||
| 44 | +comparator that had stopped reading the oracle would report the same number. | ||
| 45 | + | ||
| 46 | +| oracle byte flipped | plane it lands in | reported | delta | | ||
| 47 | +|---|---|---|---| | ||
| 48 | +| none | — | Y=0 U=5772 V=12086 | — | | ||
| 49 | +| 0 (frame 0 luma) | Y | Y=**1** U=5772 V=12086 | **+1 Y** | | ||
| 50 | +| 90000 (frame 0 chroma) | U | Y=0 U=**5773** V=12086 | **+1 U** | | ||
| 51 | +| 1781000 (frame 15 chroma) | V | Y=0 U=5772 V=**12087** | **+1 V** | | ||
| 52 | + | ||
| 53 | +Each flip moves the count by **exactly one, in exactly the right plane, in the | ||
| 54 | +right frame**. The comparator reads the oracle's bytes. (The control lived in a | ||
| 55 | +throwaway example; the mechanism and the numbers are what this report keeps.) | ||
| 56 | + | ||
| 57 | +## 2. Localisation | ||
| 58 | + | ||
| 59 | +`frames=0` (the keyframe — no inter prediction, so motion compensation is | ||
| 60 | +exonerated outright). The wrong region is two perfect rectangles: | ||
| 61 | + | ||
| 62 | +| plane | chroma rows | chroma cols | count | | ||
| 63 | +|---|---|---|---| | ||
| 64 | +| U | 96–115 | 128–137 | 200 | | ||
| 65 | +| V | 96–115 | 128–152 | 500 | | ||
| 66 | + | ||
| 67 | +Chroma plane 160×116. So the region is rows 96–115 = **every visible row of one | ||
| 68 | +block**, cols 128–152 ⊂ that block's 128–159. | ||
| 69 | + | ||
| 70 | +`TRACE block px=256 py=192 side=64` — a single **64×64 luma block at (256,192)** | ||
| 71 | +overlaps the region, chroma origin (128,96), chroma extent 32×32 clipped to 32×20 | ||
| 72 | +at the bottom edge. Luma is exact, so the block decomposition and the luma | ||
| 73 | +transform are both right. | ||
| 74 | + | ||
| 75 | +``` | ||
| 76 | +TRACE partition_w64 ctx=3 value=0 | ||
| 77 | +TRACE skip value=0 rng=36043 | ||
| 78 | +TRACE use_intrabc value=1 | ||
| 79 | +TRACE intrabc dv=(-1344, 0) | ||
| 80 | +TRACE block px=256 py=192 side=64 mode=0 uv_mode=0 | ||
| 81 | +TRACE dequant plane=0 ... tx_type=Idtx side=32 <-- luma codes IDTX | ||
| 82 | +TRACE dequant plane=1 ... tx_type=DctDct side=32 <-- chroma: WE say DCT_DCT | ||
| 83 | +TRACE dequant plane=2 ... tx_type=DctDct side=32 <-- chroma: WE say DCT_DCT | ||
| 84 | +``` | ||
| 85 | + | ||
| 86 | +It is an **Intra-Block-Copy** block (`use_intrabc=1`, `dv=(col 0, row -1344)` in | ||
| 87 | +1/8-pel = −168 luma px = −84 chroma px). aomdec reads the identical symbols | ||
| 88 | +(`EC_ISTEP … name=intrabc val=1 rng=49872`, `EC_DV … dv_col=0 dv_row=-1344`), so | ||
| 89 | +the entropy decode of the block agrees on both sides. | ||
| 90 | + | ||
| 91 | +### The prediction is right; the residual is not | ||
| 92 | + | ||
| 93 | +* **Source.** DV −84 chroma rows → source chroma row 12. Our chroma prediction | ||
| 94 | + row 0 is `202 202 202 202 202 202 166 166 …`, byte-identical to our own frame 0 | ||
| 95 | + row 12 (the copy source) and to the oracle's own final rows 100–115. | ||
| 96 | +* **Entropy is identical.** Pairing `EC_ECDUMP_IN` on both sides: | ||
| 97 | + | ||
| 98 | + | side | entry | | ||
| 99 | + |---|---| | ||
| 100 | + | oracle | `plane=1 mi=(48,64) bc=0 br=0 tx=3 ECIN=(19742,34733,25032)` | | ||
| 101 | + | ours | `side=32 ctx=2 dcctx=1 ECIN=(19742,34733,25047)` | | ||
| 102 | + | oracle | `plane=2 … ECIN=(20792,37128,25058)` | | ||
| 103 | + | ours | `side=32 ctx=2 dcctx=1 ECIN=(20792,37128,25073)` | | ||
| 104 | + | ||
| 105 | + (our `ctx=2` vs the oracle's `ctx=9` is our table's baked-in `+7` chroma | ||
| 106 | + offset, per `read_plane`'s own comment — same logical context, not a | ||
| 107 | + difference. The `bit` counter's +15 is a different convention.) The msac state | ||
| 108 | + entering **and leaving** each chroma unit matches exactly, and aomdec's | ||
| 109 | + `EC_COEFF_VAL plane=1 row=0 col=0 rng=37128` equals our next unit's range 37128. | ||
| 110 | +* **The coefficients are identical.** aomdec's `EC_DQCOEFF` rung for this unit: | ||
| 111 | + | ||
| 112 | + ``` | ||
| 113 | + EC_DQCOEFF plane=1 w=32 h=32 0:-105 32:-80 64:-60 96:-40 | ||
| 114 | + EC_DQCOEFF plane=1 txsize=3 txtype=9 eob=7 nz=0:-105,32:-80,64:-60,96:-40, | ||
| 115 | + ``` | ||
| 116 | + | ||
| 117 | + Our quantized levels are `[-6, -4, -3, -2, 0, …]` at the same four positions, | ||
| 118 | + `eob=7` both sides. `post_golomb c=0 level=6 / c=1 level=4 / c=5 level=3 / | ||
| 119 | + c=6 level=2` on aomdec's side is the same sequence. | ||
| 120 | +* **`txtype=9` is `IDTX`.** libaom's `TX_TYPE` enum has `IDTX = 9`. With an | ||
| 121 | + identity transform the residual is a direct copy, and the oracle's row 96 | ||
| 122 | + residual is exactly the dequantized coefficients shifted by the 8-bit inverse | ||
| 123 | + transform's final `>>2`: `−105>>2 = −26`, `−80>>2 = −20`, `−60>>2 = −15`, | ||
| 124 | + `−40>>2 = −10` — which is precisely the observed oracle row 96 | ||
| 125 | + `176 182 187 192 202 202 …` against a `202 202 202 202 …` prediction. | ||
| 126 | + Our `DCT_DCT` instead produces a 32-point separable IDCT of that input: flat | ||
| 127 | + down the rows, `−3 −3 −3 −2 −2 −2 −2 −1 …` across row 0, which is exactly our | ||
| 128 | + output `199 199 199 200 200 200 164 165 …`. | ||
| 129 | + | ||
| 130 | +### Why the filters are still exonerated | ||
| 131 | + | ||
| 132 | +The prior lane's PREFILT/deblock/CDEF/LR ladder compared **our PREFILT against | ||
| 133 | +the oracle's FINAL**, which is not the right pairing (it cannot separate | ||
| 134 | +"reconstruction differs" from "the filters then changed it"). The correct | ||
| 135 | +statement, and the one this lane measured, is simpler: the wrong samples are a | ||
| 136 | +**keyframe** block's reconstruction and every filter stage is a pure function of | ||
| 137 | +reconstruction, so nothing downstream can produce a difference that is not | ||
| 138 | +already in reconstruction. That holds regardless of the PREFILT pairing, and the | ||
| 139 | +`txtype` measurement above pins the cause to reconstruction with no filter | ||
| 140 | +involved. | ||
| 141 | + | ||
| 142 | +## 3. The class sweep (27 cells, 3 widths × 9 heights) | ||
| 143 | + | ||
| 144 | +Same recipe (`--profile=0 --cq-level=45 --cpu-used=0 --limit=16`, testsrc2), | ||
| 145 | +`U`/`V` wrong-sample counts over 16 shown frames: | ||
| 146 | + | ||
| 147 | +| H | 320 | 322 | 324 | | ||
| 148 | +|---|---|---|---| | ||
| 149 | +| 224 | 0 / 0 | 0 / 0 | 0 / 0 | | ||
| 150 | +| 228 | 0 / 0 | 0 / 0 | 0 / 0 | | ||
| 151 | +| **232** | **5772 / 12086** | **3913 / 7328** | **2923 / 10135** | | ||
| 152 | +| **236** | 56957 / 52981 (**Y=234349**) | 0 / 0 | 0 / 0 | | ||
| 153 | +| 240 | 0 / 0 | 0 / 0 | **12076 / 15002** | | ||
| 154 | +| 244 | 0 / 0 | 0 / 0 | 0 / 0 | | ||
| 155 | +| **248** | **14343 / 16310** | **36286 / 13359** (Y) | 0 / 0 | | ||
| 156 | +| 252 | 0 / 0 | 0 / 0 | 0 / 0 | | ||
| 157 | +| 256 | 0 / 0 | 0 / 0 | 0 / 0 | | ||
| 158 | + | ||
| 159 | +**The trigger rule is not geometric.** 232, 236 and 248 fail while 240, 244, 252 | ||
| 160 | +and 256 pass; 232 and 248 are multiples of 8 and so are 240 and 244. The real | ||
| 161 | +rule is content-dependent: *an inter/intrabc block whose luma codes `IDTX` and | ||
| 162 | +whose chroma plane block reaches 32 points with a nonzero coefficient*. Cells | ||
| 163 | +whose content never produces that shape are exact. | ||
| 164 | + | ||
| 165 | +Every failing cell shows the same fingerprint. Nonzero 32-point chroma | ||
| 166 | +`EC_DQCOEFF` on the failing cells: | ||
| 167 | + | ||
| 168 | +``` | ||
| 169 | +o320x248 : EC_DQCOEFF plane=1 txsize=3 txtype=9 eob=40 nz=0:-224,1:-222,2:-203,3:-129,4:-222,5:-111,32:-277,… | ||
| 170 | +o322x232 : EC_DQCOEFF plane=1 txsize=3 txtype=9 eob=15 nz=0:-128,32:-92,64:-55,96:-55,128:-18, | ||
| 171 | +o324x240 : EC_DQCOEFF plane=1 txsize=3 txtype=9 eob=31 nz=0:-216,1:-143,2:-123,32:-164,33:-225,… | ||
| 172 | +``` | ||
| 173 | + | ||
| 174 | +**`txtype=9` (IDTX) on every one of them.** The contiguous `0,1,2,…,5,32,33,…` | ||
| 175 | +index pattern is itself the signature of an identity transform. | ||
| 176 | + | ||
| 177 | +`320x236` additionally has 234 349 wrong **luma** samples with | ||
| 178 | +`Y=234349` — a second, larger defect (236 is not a multiple of 8, so its luma | ||
| 179 | +plane overhangs the coding grid). **That is a different class and this report | ||
| 180 | +does not claim it is the same mechanism**; see `not_done`. | ||
| 181 | + | ||
| 182 | +### Is 4:2:2 the same mechanism? | ||
| 183 | + | ||
| 184 | +**Almost certainly yes, and it is why the 4:2:2 cells in the prior lane's table | ||
| 185 | +(`S_422_320x242`, `R_422_324x242`, `X_422_320x232`, `X_422_320x248`, | ||
| 186 | +`O_odd322x242`) all diverge.** The mechanism is in the chroma transform-type | ||
| 187 | +resolution for an inter block, which is shared by every chroma format — it is | ||
| 188 | +keyed on `plane > 0` and on the block being `is_inter_block`, not on | ||
| 189 | +subsampling. The one exception is the odd-width `2 * ceil(w/8)` vs `ceil(w/4)` | ||
| 190 | +mi-grid skew, which is a *separate* bug and is only reachable at odd widths, so | ||
| 191 | +it is a separate finding, not part of this one. | ||
| 192 | + | ||
| 193 | +## 4. What is committed | ||
| 194 | + | ||
| 195 | +**Nothing.** The tree is byte-identical to `main` (`git status --porcelain` | ||
| 196 | +empty, `git diff main --stat` empty at `3f08ae3f`). The previous lane's pin | ||
| 197 | +(`crates/ec-av1/fixtures/420_oddheight_320x232.obu`, sha256 `6832c3cd…`) already | ||
| 198 | +covers this witness and already bites: `the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect` | ||
| 199 | +re-measured green here with `(0, 5772, 12086)` on my base (its `assert_eq` | ||
| 200 | +against `(0, 200, 17658)` is a **whole-stream** count and is now stale relative | ||
| 201 | +to `main`'s decoder; it passed here, so `main` still produces those totals — | ||
| 202 | +lane-av1cmpaudit2 landed after my first run and did not move them). | ||
| 203 | + | ||
| 204 | +**No new pin, and therefore no gate flip.** The acceptance asked me to flip the | ||
| 205 | +ratchet to assert exactness when the fix lands. **That flip is still owed and I | ||
| 206 | +am explicitly handing it over, not doing it**: the fix is not in this lane, so | ||
| 207 | +asserting `(0,0,0)` now would be red and would be a fabricated failure. The | ||
| 208 | +person who lands the fix must change | ||
| 209 | +`assert_eq!((wy, wu, wv), (0, 200, 17658), …)` to `(0, 0, 0)` in | ||
| 210 | +`crates/ec-av1/src/stream.rs` (the ratchet gate) and add the `320x248` cell as | ||
| 211 | +a second pin. **It must not be forgotten.** | ||
| 212 | + | ||
| 213 | +## 5. Gates run | ||
| 214 | + | ||
| 215 | +* `the_counting_oracle_diff_reports_a_real_difference` — pass | ||
| 216 | +* `the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect` — pass | ||
| 217 | + (ratchet still at the pre-existing wrong count; **the fix will trip it by name**) | ||
| 218 | + | ||
| 219 | +## 6. Non-vacuity proofs | ||
| 220 | + | ||
| 221 | +* **Comparator:** one flipped byte in the real `aomdec --rawvideo` buffer moves | ||
| 222 | + the reported wrong count by exactly +1 in the right plane and frame (§1). | ||
| 223 | + Four runs, four distinct planes/frames. | ||
| 224 | +* **Pin reproducibility:** an independent re-encode of the same recipe produced | ||
| 225 | + the same sha256 as the committed fixture. | ||
| 226 | +* **Mechanism, not inference:** the `txtype` difference is measured on both | ||
| 227 | + sides for the same unit (`EC_DQCOEFF … txtype=9` vs our `tx_type=DctDct`) with | ||
| 228 | + identical coefficients, identical eob, and identical msac state in and out. | ||
| 229 | + | ||
| 230 | +## 7. `not_done` — and the exact unblock | ||
| 231 | + | ||
| 232 | +- **No fix shipped.** The remaining work is inside the chroma transform-type | ||
| 233 | + resolution for an inter block at 32 points: | ||
| 234 | + * `crates/ec-av1/src/decode.rs`, `read_plane`'s `default_tx_type` | ||
| 235 | + (`if plane_idx == 0 || side >= 32 { TxType::DctDct }`) — that `side >= 32` | ||
| 236 | + arm is our `EXT_TX_SET_DCTONLY` clamp. It fires here and drops the luma's | ||
| 237 | + inherited `IDTX`. | ||
| 238 | + * the inter twin `read_inter_plane`'s `reduce_inherited_chroma_tx_type(t, side, side, fctx)`. | ||
| 239 | + * against libaom `av1_get_tx_type(…, PLANE_TYPE_UV, …)` + | ||
| 240 | + `get_ext_tx_set_type` in `blockd.h`, which is what produced `txtype=9`. | ||
| 241 | + | ||
| 242 | + **Deciding measurement still owed:** whether libaom's | ||
| 243 | + `get_ext_tx_set_type` clamp at `tx_size_sqr_up >= TX_32X32` is skipped for a | ||
| 244 | + block whose luma is `IDTX` (the measurement says yes — the oracle ran | ||
| 245 | + `IDTX`), or whether the clamp lives somewhere else entirely. One | ||
| 246 | + `sed -n` of `blockd.h` settles it; I ran out of budget before doing it, and I | ||
| 247 | + am not shipping the change blind. | ||
| 248 | + **Expected acceptance once landed:** `320x232` and `320x248` become 0/0/0, the | ||
| 249 | + eight failing cells in §3 drop to zero, and `320x240/242/322x242` stay exact. | ||
| 250 | +- **No new pin** for `320x248`; the recipe and sha256 are in §3 and reproduce | ||
| 251 | + (`o320x248.obu` in `/tmp/h232fix` this session). | ||
| 252 | +- **The ratchet → exactness gate flip is owed** (§4). | ||
| 253 | +- **`320x236`'s luma failure (234 349 wrong Y) is a separate, unlocalised | ||
| 254 | + defect.** 236 is not a multiple of 8; its luma plane overhangs the coding | ||
| 255 | + grid. Not swept, not localised, not claimed to be the `IDTX` bug. | ||
| 256 | +- **4:2:2 not re-measured** — the prior lane's 4:2:2 cells need the | ||
| 257 | + `EC_AV1_ALLOW_422_PROBE` bypass, which this lane must not commit. The | ||
| 258 | + mechanism argument in §3 is an argument, not a measurement. | ||
| 259 | +- **Full suite not run** (lane rules: scoped only). | ||