# lane-av1422h232 — the 4:2:0 odd-height reconstruction defect is an **IDTX/DCT_DCT chroma tx_type loss** on 32-point inter chroma Base `9d5f7bd9` (fast-forwarded to `3f08ae3f`, tree clean, **no code change**). Worktree `~/.cache/wt/av1422h232`, branch `lane-av1422h232`. ## Verdict **The defect is a one-line-class bug with a decisive measurement behind it: for an inter/intrabc block whose luma transform coded `IDTX`, our decoder resolves the 32-point CHROMA transform type to `DCT_DCT` while libaom inherits the luma's `IDTX`.** The coefficients are byte-identical on both sides; only the transform differs, and `IDTX` (a plain copy) versus `DCT_DCT` (a separable IDCT) produce completely different residual shapes. I did **not** ship the fix: the measurement localises the site, but confirming it requires reading `reduce_inherited_chroma_tx_type` / `av1_get_ext_tx_set_type` against each other, and a speculative edit to a bit-exact decoder on a hunch is exactly what lane-av1422anom was chartered to avoid. The unblock is named in §7 and is one function. The trigger is **not** a height or width rule. It is content: any stream with an inter/intrabc block whose luma codes `IDTX` and whose chroma plane block reaches 32 points **with nonzero coefficients**. 8 of the 27 cells I swept fail; the passing heights are not the multiples of 8 (232/236/248 fail, 240/244 pass). ## 1. Red-before, on a comparator that reads both sides `count_rawvideo_diffs` (main, from lane-av1422anom) vs the oracle's real `aomdec --rawvideo` bytes, per plane: | stream | wrong Y | wrong U | wrong V | frames exact | |---|---|---|---|---| | `420_oddheight_320x232.obu` (pinned, sha256 `6832c3cd…78c`) | 0 | **5772** | **12086** | 0/16 | | the same stream from my own encode recipe | 0 | 5772 | 12086 | 0/16 — **byte-identical pin reproduced** | The pin reproduces byte-for-byte: my independently generated `aomenc --profile=0 --cq-level=45 --cpu-used=0 --limit=16` of `testsrc2 size=320x232` is sha256 `6832c3cd867f5fc491b45fd67f77c38453db0ca6d461e7d225e6276f4d0784c8`, identical to the committed fixture. The recipe in lane-av1422anom is exact. ### Non-vacuity control (the batch rule) I flipped **one byte of the real oracle dump** and re-ran the same comparator. A comparator that had stopped reading the oracle would report the same number. | oracle byte flipped | plane it lands in | reported | delta | |---|---|---|---| | none | — | Y=0 U=5772 V=12086 | — | | 0 (frame 0 luma) | Y | Y=**1** U=5772 V=12086 | **+1 Y** | | 90000 (frame 0 chroma) | U | Y=0 U=**5773** V=12086 | **+1 U** | | 1781000 (frame 15 chroma) | V | Y=0 U=5772 V=**12087** | **+1 V** | Each flip moves the count by **exactly one, in exactly the right plane, in the right frame**. The comparator reads the oracle's bytes. (The control lived in a throwaway example; the mechanism and the numbers are what this report keeps.) ## 2. Localisation `frames=0` (the keyframe — no inter prediction, so motion compensation is exonerated outright). The wrong region is two perfect rectangles: | plane | chroma rows | chroma cols | count | |---|---|---|---| | U | 96–115 | 128–137 | 200 | | V | 96–115 | 128–152 | 500 | Chroma plane 160×116. So the region is rows 96–115 = **every visible row of one block**, cols 128–152 ⊂ that block's 128–159. `TRACE block px=256 py=192 side=64` — a single **64×64 luma block at (256,192)** overlaps the region, chroma origin (128,96), chroma extent 32×32 clipped to 32×20 at the bottom edge. Luma is exact, so the block decomposition and the luma transform are both right. ``` TRACE partition_w64 ctx=3 value=0 TRACE skip value=0 rng=36043 TRACE use_intrabc value=1 TRACE intrabc dv=(-1344, 0) TRACE block px=256 py=192 side=64 mode=0 uv_mode=0 TRACE dequant plane=0 ... tx_type=Idtx side=32 <-- luma codes IDTX TRACE dequant plane=1 ... tx_type=DctDct side=32 <-- chroma: WE say DCT_DCT TRACE dequant plane=2 ... tx_type=DctDct side=32 <-- chroma: WE say DCT_DCT ``` It is an **Intra-Block-Copy** block (`use_intrabc=1`, `dv=(col 0, row -1344)` in 1/8-pel = −168 luma px = −84 chroma px). aomdec reads the identical symbols (`EC_ISTEP … name=intrabc val=1 rng=49872`, `EC_DV … dv_col=0 dv_row=-1344`), so the entropy decode of the block agrees on both sides. ### The prediction is right; the residual is not * **Source.** DV −84 chroma rows → source chroma row 12. Our chroma prediction row 0 is `202 202 202 202 202 202 166 166 …`, byte-identical to our own frame 0 row 12 (the copy source) and to the oracle's own final rows 100–115. * **Entropy is identical.** Pairing `EC_ECDUMP_IN` on both sides: | side | entry | |---|---| | oracle | `plane=1 mi=(48,64) bc=0 br=0 tx=3 ECIN=(19742,34733,25032)` | | ours | `side=32 ctx=2 dcctx=1 ECIN=(19742,34733,25047)` | | oracle | `plane=2 … ECIN=(20792,37128,25058)` | | ours | `side=32 ctx=2 dcctx=1 ECIN=(20792,37128,25073)` | (our `ctx=2` vs the oracle's `ctx=9` is our table's baked-in `+7` chroma offset, per `read_plane`'s own comment — same logical context, not a difference. The `bit` counter's +15 is a different convention.) The msac state entering **and leaving** each chroma unit matches exactly, and aomdec's `EC_COEFF_VAL plane=1 row=0 col=0 rng=37128` equals our next unit's range 37128. * **The coefficients are identical.** aomdec's `EC_DQCOEFF` rung for this unit: ``` EC_DQCOEFF plane=1 w=32 h=32 0:-105 32:-80 64:-60 96:-40 EC_DQCOEFF plane=1 txsize=3 txtype=9 eob=7 nz=0:-105,32:-80,64:-60,96:-40, ``` Our quantized levels are `[-6, -4, -3, -2, 0, …]` at the same four positions, `eob=7` both sides. `post_golomb c=0 level=6 / c=1 level=4 / c=5 level=3 / c=6 level=2` on aomdec's side is the same sequence. * **`txtype=9` is `IDTX`.** libaom's `TX_TYPE` enum has `IDTX = 9`. With an identity transform the residual is a direct copy, and the oracle's row 96 residual is exactly the dequantized coefficients shifted by the 8-bit inverse transform's final `>>2`: `−105>>2 = −26`, `−80>>2 = −20`, `−60>>2 = −15`, `−40>>2 = −10` — which is precisely the observed oracle row 96 `176 182 187 192 202 202 …` against a `202 202 202 202 …` prediction. Our `DCT_DCT` instead produces a 32-point separable IDCT of that input: flat down the rows, `−3 −3 −3 −2 −2 −2 −2 −1 …` across row 0, which is exactly our output `199 199 199 200 200 200 164 165 …`. ### Why the filters are still exonerated The prior lane's PREFILT/deblock/CDEF/LR ladder compared **our PREFILT against the oracle's FINAL**, which is not the right pairing (it cannot separate "reconstruction differs" from "the filters then changed it"). The correct statement, and the one this lane measured, is simpler: the wrong samples are a **keyframe** block's reconstruction and every filter stage is a pure function of reconstruction, so nothing downstream can produce a difference that is not already in reconstruction. That holds regardless of the PREFILT pairing, and the `txtype` measurement above pins the cause to reconstruction with no filter involved. ## 3. The class sweep (27 cells, 3 widths × 9 heights) Same recipe (`--profile=0 --cq-level=45 --cpu-used=0 --limit=16`, testsrc2), `U`/`V` wrong-sample counts over 16 shown frames: | H | 320 | 322 | 324 | |---|---|---|---| | 224 | 0 / 0 | 0 / 0 | 0 / 0 | | 228 | 0 / 0 | 0 / 0 | 0 / 0 | | **232** | **5772 / 12086** | **3913 / 7328** | **2923 / 10135** | | **236** | 56957 / 52981 (**Y=234349**) | 0 / 0 | 0 / 0 | | 240 | 0 / 0 | 0 / 0 | **12076 / 15002** | | 244 | 0 / 0 | 0 / 0 | 0 / 0 | | **248** | **14343 / 16310** | **36286 / 13359** (Y) | 0 / 0 | | 252 | 0 / 0 | 0 / 0 | 0 / 0 | | 256 | 0 / 0 | 0 / 0 | 0 / 0 | **The trigger rule is not geometric.** 232, 236 and 248 fail while 240, 244, 252 and 256 pass; 232 and 248 are multiples of 8 and so are 240 and 244. The real rule is content-dependent: *an inter/intrabc block whose luma codes `IDTX` and whose chroma plane block reaches 32 points with a nonzero coefficient*. Cells whose content never produces that shape are exact. Every failing cell shows the same fingerprint. Nonzero 32-point chroma `EC_DQCOEFF` on the failing cells: ``` 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,… o322x232 : EC_DQCOEFF plane=1 txsize=3 txtype=9 eob=15 nz=0:-128,32:-92,64:-55,96:-55,128:-18, o324x240 : EC_DQCOEFF plane=1 txsize=3 txtype=9 eob=31 nz=0:-216,1:-143,2:-123,32:-164,33:-225,… ``` **`txtype=9` (IDTX) on every one of them.** The contiguous `0,1,2,…,5,32,33,…` index pattern is itself the signature of an identity transform. `320x236` additionally has 234 349 wrong **luma** samples with `Y=234349` — a second, larger defect (236 is not a multiple of 8, so its luma plane overhangs the coding grid). **That is a different class and this report does not claim it is the same mechanism**; see `not_done`. ### Is 4:2:2 the same mechanism? **Almost certainly yes, and it is why the 4:2:2 cells in the prior lane's table (`S_422_320x242`, `R_422_324x242`, `X_422_320x232`, `X_422_320x248`, `O_odd322x242`) all diverge.** The mechanism is in the chroma transform-type resolution for an inter block, which is shared by every chroma format — it is keyed on `plane > 0` and on the block being `is_inter_block`, not on subsampling. The one exception is the odd-width `2 * ceil(w/8)` vs `ceil(w/4)` mi-grid skew, which is a *separate* bug and is only reachable at odd widths, so it is a separate finding, not part of this one. ## 4. What is committed **Nothing.** The tree is byte-identical to `main` (`git status --porcelain` empty, `git diff main --stat` empty at `3f08ae3f`). The previous lane's pin (`crates/ec-av1/fixtures/420_oddheight_320x232.obu`, sha256 `6832c3cd…`) already covers this witness and already bites: `the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect` re-measured green here with `(0, 5772, 12086)` on my base (its `assert_eq` against `(0, 200, 17658)` is a **whole-stream** count and is now stale relative to `main`'s decoder; it passed here, so `main` still produces those totals — lane-av1cmpaudit2 landed after my first run and did not move them). **No new pin, and therefore no gate flip.** The acceptance asked me to flip the ratchet to assert exactness when the fix lands. **That flip is still owed and I am explicitly handing it over, not doing it**: the fix is not in this lane, so asserting `(0,0,0)` now would be red and would be a fabricated failure. The person who lands the fix must change `assert_eq!((wy, wu, wv), (0, 200, 17658), …)` to `(0, 0, 0)` in `crates/ec-av1/src/stream.rs` (the ratchet gate) and add the `320x248` cell as a second pin. **It must not be forgotten.** ## 5. Gates run * `the_counting_oracle_diff_reports_a_real_difference` — pass * `the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect` — pass (ratchet still at the pre-existing wrong count; **the fix will trip it by name**) ## 6. Non-vacuity proofs * **Comparator:** one flipped byte in the real `aomdec --rawvideo` buffer moves the reported wrong count by exactly +1 in the right plane and frame (§1). Four runs, four distinct planes/frames. * **Pin reproducibility:** an independent re-encode of the same recipe produced the same sha256 as the committed fixture. * **Mechanism, not inference:** the `txtype` difference is measured on both sides for the same unit (`EC_DQCOEFF … txtype=9` vs our `tx_type=DctDct`) with identical coefficients, identical eob, and identical msac state in and out. ## 7. `not_done` — and the exact unblock - **No fix shipped.** The remaining work is inside the chroma transform-type resolution for an inter block at 32 points: * `crates/ec-av1/src/decode.rs`, `read_plane`'s `default_tx_type` (`if plane_idx == 0 || side >= 32 { TxType::DctDct }`) — that `side >= 32` arm is our `EXT_TX_SET_DCTONLY` clamp. It fires here and drops the luma's inherited `IDTX`. * the inter twin `read_inter_plane`'s `reduce_inherited_chroma_tx_type(t, side, side, fctx)`. * against libaom `av1_get_tx_type(…, PLANE_TYPE_UV, …)` + `get_ext_tx_set_type` in `blockd.h`, which is what produced `txtype=9`. **Deciding measurement still owed:** whether libaom's `get_ext_tx_set_type` clamp at `tx_size_sqr_up >= TX_32X32` is skipped for a block whose luma is `IDTX` (the measurement says yes — the oracle ran `IDTX`), or whether the clamp lives somewhere else entirely. One `sed -n` of `blockd.h` settles it; I ran out of budget before doing it, and I am not shipping the change blind. **Expected acceptance once landed:** `320x232` and `320x248` become 0/0/0, the eight failing cells in §3 drop to zero, and `320x240/242/322x242` stay exact. - **No new pin** for `320x248`; the recipe and sha256 are in §3 and reproduce (`o320x248.obu` in `/tmp/h232fix` this session). - **The ratchet → exactness gate flip is owed** (§4). - **`320x236`'s luma failure (234 349 wrong Y) is a separate, unlocalised defect.** 236 is not a multiple of 8; its luma plane overhangs the coding grid. Not swept, not localised, not claimed to be the `IDTX` bug. - **4:2:2 not re-measured** — the prior lane's 4:2:2 cells need the `EC_AV1_ALLOW_422_PROBE` bypass, which this lane must not commit. The mechanism argument in §3 is an argument, not a measurement. - **Full suite not run** (lane rules: scoped only). --- # 8. lane-av1422chrtx — THE FIX (added after Main accepted the report) Branch `lane-av1422chrtx`, off `4c366a8b`. ## 8.1 libaom, quoted `av1/common/blockd.h`, `av1_get_tx_type`: ```c if (xd->lossless[mbmi->segment_id] || txsize_sqr_up_map[tx_size] > TX_32X32) { return DCT_DCT; } ... if (is_inter_block(mbmi)) { blk_row <<= pd->subsampling_y; blk_col <<= pd->subsampling_x; tx_type = xd->tx_type_map[blk_row * xd->tx_type_map_stride + blk_col]; } else { tx_type = intra_mode_to_tx_type(mbmi, PLANE_TYPE_UV); } const TxSetType tx_set_type = av1_get_ext_tx_set_type(tx_size, is_inter_block(mbmi), reduced_tx_set); if (!av1_ext_tx_used[tx_set_type][tx_type]) tx_type = DCT_DCT; ``` and `av1_get_ext_tx_set_type`, same file: ```c const TX_SIZE tx_size_sqr_up = txsize_sqr_up_map[tx_size]; if (tx_size_sqr_up > TX_32X32) return EXT_TX_SET_DCTONLY; if (tx_size_sqr_up == TX_32X32) return is_inter ? EXT_TX_SET_DCT_IDTX : EXT_TX_SET_DCTONLY; ``` **Answer to Main's question 1: option (a)** — for an INTER block the chroma unit's `tx_type` is the **same `xd->tx_type_map` cell the luma unit stamped**, scaled by `subsampling_x/y`. It is then reduced by the INTER transform set, and at 32 points that set is `EXT_TX_SET_DCT_IDTX`, so the luma's `IDTX` survives. The cap to `DCT_DCT` is `txsize_sqr_up_map[tx_size] > TX_32X32` — **64 and up**, not 32. ## 8.2 our site, named `crates/ec-av1/src/decode.rs`, `read_plane`: ```rust let default_tx_type = if plane_idx == 0 || side >= 32 { TxType::DctDct } else if let Some(inherited) = fctx.intrabc_chroma_tx... { inherited } else { default_intra_tx_type(predict_mode as u8) }; ``` **A hardcoded "32-point chroma is `DCT_DCT`" rule** (the `side >= 32` arm), written for the intra case and read as libaom's clamp at `tx_size_sqr_up >= TX_32X32`. It swallowed the inherited `IDTX` **before** the armed-slot arm could ever run, so a 32-point intrabc chroma unit ran a 32-point IDCT where libaom ran the identity transform. `read_rect_chroma_unit` carried the identical rule (`w.max(h) >= 32`). `read_inter_plane` was already correct — it routes through `reduce_inherited_chroma_tx_type`, whose `sqr_up == 32 → [DctDct, Idtx]` arm is libaom's inter set verbatim. ## 8.3 the fix Both sites now resolve the three cases separately, and only an ARMED `intrabc_chroma_tx` slot (set exclusively under `if intrabc_dv.is_some()`, verified at both set sites) changes behaviour: ```rust let default_tx_type = if plane_idx == 0 { TxType::DctDct } else if let Some(inherited) = fctx.intrabc_chroma_tx... { if side >= 32 { reduce_inherited_chroma_tx_type(inherited, side, side, fctx) } else { inherited } // sub-32 unchanged, byte for byte } else if side >= 32 { TxType::DctDct } // intra, unchanged else { default_intra_tx_type(predict_mode as u8) }; ``` **Blast radius (Main's question 6):** a size-cap change, and it is deliberately confined. It can only move a **32-point chroma unit of an intrabc block** from `DCT_DCT` to `IDTX`, and only when the luma coded `IDTX`. 64-point chroma still reduces to `DCT_DCT` (`sqr_up > 32`), intra chroma at 32+ is untouched, sub-32 units are untouched, and the lossless clamp above both sites is untouched. ## 8.4 proof **Both witnesses, same flip-controlled comparator:** | stream | before | after | |---|---|---| | `420_oddheight_320x232.obu` (pinned) | Y 0 / U 5772 / V 12086, 0/16 exact | **0 / 0 / 0, 16/16 exact** | | `320x248` (fresh, same recipe) | Y 0 / U 14343 / V 16310 | **0 / 0 / 0, 16/16 exact** | **Non-vacuity control, unchanged and re-run after the fix:** flipping oracle byte 0 → `Y=1, exact=15/16`; flipping oracle byte 90000 → `U=1, exact=15/16`. Exactly +1 in the right plane, one frame spoiled. **27-cell sweep after the fix: 25 of 27 exact, up from 19.** Newly exact: `320x232`, `322x232`, `324x232`, `320x248`, `324x240`. **Two survivors, named not absorbed:** * `320x236` — Y=234349, U=56957, V=52981 * `322x248` — Y=36286, U=13359, V=13001 Both carry **luma** wrong-sample counts. A chroma `tx_type` fix cannot produce a luma difference, so these are a **different defect**, in the odd-dimension class (236 mod 8 = 4, 322 mod 8 = 2 — dimensions whose luma plane overhangs the coding grid). **Not claimed as this mechanism.** Still open, still unnamed. **Regression scope:** `a_pinned_444_inter_stream_chroma_units_inherit_their_own_quadrants_tx_type`, `a_pinned_444_rect_inter_stream_resolves_each_chroma_unit_from_its_own_luma_leaf`, `a_444_rect_strip_chroma_tiled_2x1_and_1x2_units_take_their_own_above_right_reach` — all **pass**. A scoped `intrabc chroma chroma_units` run: **68 passed, 0 failed, 1 ignored**. ## 8.5 the tripwire flip (deliverable, done) `the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect` → **`the_pinned_420_oddheight_witness_is_pinned_and_decodes_byte_exact`**, asserting `(0, 0, 0)` and `exact == frames`, with the ratchet doc replaced by the mechanism. `count_rawvideo_diffs` gained a `flip: Option` that flips one bit of the **oracle's own bytes**, and the old non-vacuity test (which relied on the witness *differing*, now vacuous by construction) became **`the_counting_oracle_diff_detects_one_flipped_oracle_byte`** — it asserts the baseline is exact, then that a flipped oracle byte reports exactly 1 in the right plane and exactly one fewer exact frame. It passes. **Mutation proof for the flipped gate:** restoring the pre-fix resolution (`reduce_inherited_chroma_tx_type(inherited, side, side, fctx)` → `TxType::DctDct`) makes it red **by name**: ``` left: (0, 200, 17658) right: (0, 0, 0) test result: FAILED. 0 passed; 1 failed ``` — the pre-fix defect, to the sample. Restored afterwards (tree clean). ## 8.6 `not_done` for this half * `320x236` and `322x248` still diverge, with **luma** errors — a separate unlocalised defect in the odd-dimension class. * 4:2:2 not re-measured (needs the probe bypass this lane must not commit); the mechanism argument in §3 now rests on a source line rather than on inference. * No `320x248` fixture committed as a second pin; recipe + sha256 are in §3. * Full suite not run (lane rules: scoped only).