From 5c9a50762a218c2f878f62b81b10542578d37d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 30 Sep 2026 17:02:17 +0300 Subject: [PATCH] two lanes on the mixed-lossless class: the root cause is a var-tx conjunct, the candidate fix was measured and REVERTED as unproven, and both lanes' corrections to the record are landed Both lanes are report-only; neither left a source delta behind. Landing their two reports plus the state of the question, because the earlier debt line's reading was WRONG and two lanes independently corrected it. lane-av1mixllfork (7e90b5b4, merged here; source delta verified empty against its base 32d944bf): the fork at read 30889 is a VAR-TX ORDERING defect, not a wrong txb_skip_ctx CDF row. libaom puts !xd->lossless[mbmi->segment_id] IN the var-tx condition (decodeframe.c:1237) and read_tx_size answers TX_4X4 on the same flag (:1208); ours tested tx_select && !skip and left lossless(fctx) in the `else if`, one branch too late (decode.rs:48259 sub-8 inter leaf, :27140 intrabc rect). Two inherited claims corrected: the oracle DOES have geometry at mi=(6,1) (its EC_ECDUMP_IN prints two TX_4X4 luma units plus one chroma unit per plane; it is ours that lacks it), and a broken ICDF mirror at the fork (15299 vs 22401; 32768-15299=17469) means DIFFERENT SYMBOLS read one step out of sync -- which a wrong CDF row cannot produce. The candidate fix was measured: c_mix5 6/6 byte-exact with the paired EC_SYMR ladder bit-identical over the WHOLE stream (96997 reads, 96997 paired, zero divergence), s_arf8 red->6/6, 4:4:4 arm red->9/9, 176x144 and 352x288 refusals removed, gate red without it at byte 33 with 33724 differing bytes. It was still REVERTED, correctly, because it regressed a supported 4:2:0 8-bit cell: testsrc2 640x480 (5 and 6 frames, same recipe) decodes at base and REFUSES with the fix, first divergence at read 184328 where the oracle reads decodeframe.c:1186 (the txfm_partition split inside read_tx_size_vartx) and we read a different n=2 symbol from the identical pre-state -- at that point our per-segment lossless(fctx) said true and suppressed the tree libaom walked. Isolated to the sub-8 hunk. lane-av1golomb320 (report landed here; its branch had ZERO lines of decode.rs -- a clean cherry-pick of the candidate was needed to re-measure): the 320x240 refusal premise does NOT reproduce at this tip (that cell decodes 6/6 and DIVERGES); the refusal reproduces at 176x144 and 352x288; it is DOWNSTREAM (first divergence is 40 extra reads stamped mi=(32,32) = the 48x16 bottom-right sliver of 176x144, every one tag=all_zero side=4 chroma txb_skip with the BIT POSITION FROZEN at 36288, i.e. a walk that ran off the end of the tile, while the abort fires 11970 reads later); and it independently reproduced the 640x480 regression. It also established that our read_golomb has the same length>20 cap as libaom (decodetxb.c:22-43) and that the difference is overflow handling: aom_internal_error abandons the PICTURE via longjmp, our Err unwinds the whole stream (1 dump instead of 7) -- so the cap is not the bug and stays. Two follow-up lanes are running: Agent05 (make our per-segment lossless answer agree with libaom's xd->lossless[segment_id] so the conjunct can land without the 640x480 regression) and Agent23 (the off-tile walk at the bottom-right partial superblock). --- lanes/av1golomb320.report.md | 303 +++++++++++++++++++++++++++++ lanes/av1mixllfork.report.md | 360 +++++++++++++++++++++++++++++++++++ 2 files changed, 663 insertions(+) create mode 100644 lanes/av1golomb320.report.md create mode 100644 lanes/av1mixllfork.report.md diff --git a/lanes/av1golomb320.report.md b/lanes/av1golomb320.report.md new file mode 100644 index 00000000..9507e6f7 --- /dev/null +++ b/lanes/av1golomb320.report.md @@ -0,0 +1,303 @@ +# lane-av1golomb320 — the mixed-lossless Golomb-tail refusal is DOWNSTREAM geometry, not a parser bug; and Agent25-3's fix REGRESSES a 640x480 cell + +Base `main` = `32d944bf`. Worktree `/home/user/.cache/wt/av1golomb320`, target dir +`$HOME/.cache/cargo-target-av1golomb320`, `EC_NOMEMGUARD=1`. Oracle +`~/.cache/aom-oracle/build/{aomdec,aomenc}` (shared, untouched). +**No source change authored in this lane.** Branch tip is `a49460c6` = `32d944bf` + +a clean cherry-pick of Agent25-3's `658d37fa` (needed to re-measure the refusal on the +fixed base). Every `decode.rs` line in that commit is Agent25-3's. + +--- + +## 0. Verdict + +Two findings, both measured, neither a fix of mine. + +1. **The Golomb-tail refusal in this class is DOWNSTREAM of a block-GEOMETRY + walk defect, not a distinct parser bug.** Paired `EC_SYMR` shows frame 0 is + **bit-identical to the oracle for all 25 792 reads**, then we emit **40 extra + reads at `mi=(32,32)`** the oracle never makes. The abort arrives **11 970 + reads later**. It cannot be the first symptom. +2. **Agent25-3's `658d37fa` removes the refusal on the cells I had, and INTRODUCES + one on 640x480.** `mix_640x480_5.obu` (87 537 B) and `mix_640x480_6.obu` + (115 615 B) decode fully at `8705034f` (== `32d944bf` for `decode.rs`, empty + diff) and **REFUSE with `658d37fa` applied**. That is a supported 4:2:0 8-bit + cell going decode → refusal: a red-before/green-after in the wrong direction. + Reported to Agent25-3 over IRC; **not mine to fix** (its hunks are its own). + +Also: **the 320x240 arm named in the brief does not refuse** on this tip — see §2. + +--- + +## 1. The cells + +Recipe (all arms): `testsrc2`, 6 frames, `--passes=1 --cpu-used=4 --end-usage=q +--cq-level=0 --aq-mode=1`. Per-size source: `ffmpeg -f lavfi -i +testsrc2=size=:rate=25 -frames:v 6 -pix_fmt yuv420p`. ffmpeg 8.1.3, shared +oracle aomenc. + +| cell | bytes | sha256 (full) | +|---|---:|---| +| `mix_176x144_6.obu` | 20 069 | `02b15d0d5b08aa5aebf139aee94c31b4f8363d14649c238cd7a19a9785ef124a` | +| `mix_176x144_5.obu` | 16 090 | `08fdbbb6566d4d51…` (prefix) | +| `mix_320x240_5.obu` | 28 716 | `40d613fd0ced7b90facdaf71f62501acad90fb789738851a2b59c92bd6a64149` | +| `mix_320x240_6.obu` | 38 686 | `37fbe7cb9235980d…` | +| `mix_352x288_6.obu` | 46 490 | `e43c74b8d847e701…` | +| `mix_640x480_5.obu` | 87 537 | `3d505fd2e0bbb7ca…` | +| `mix_640x480_6.obu` | 115 615 | `c82ba4d793d378cc…` | + +On this content `--limit=8` produces the **same bytes** as `--limit=6` (sha +identical) for 176x144, 320x240, 352x288 and 640x480, so frame count is not a +variable; `--limit=6` is the minimal refusing arm where it refuses. + +Exact refusal string, verbatim from `decode_probe`: + +```text +REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads) +``` + +## 2. The 320x240 premise is FALSE on this tip + +At **both** `32d944bf` (main) and `8705034f` (the framecount report's base), +`mix_320x240_5.obu` decodes **6/6 decode-order dumps** with **zero** refusal +lines — it DIVERGES (f0 exact, f1..f5 differ, 90 813 / 85 821 / 99 314 / 90 572 +/ 91 598 of 115 200 bytes). The framecount report's claim that the 320x240 arm +of this recipe refuses does not reproduce. Recorded, not chased. + +## 3. The class sweep — refusal is content/size dependent + +`--limit=6`, dual decode + per-frame `cmp`, `testsrc2`: + +| size | bytes | at `8705034f` | at `658d37fa` (Agent25-3) | +|---|---|---|---| +| 176x144 | 20 069 | **REFUSED** (1/7 dumps) | decodes 7/7, f0 EXACT, f1..f6 red | +| 352x288 | 46 490 | **REFUSED** (3/7 dumps) | decodes 7/7, **7/7 EXACT** | +| 320x240 | 38 686 | decodes 7/7 (6 exact, 1 red) | decodes 7/7 (6 exact, 1 red) | +| 640x480 | 115 615 | decodes 7/7 | **REFUSED** (5/7 dumps) | + +`--limit=5` on 640x480 (87 537 B) behaves the same: decoded at base, **REFUSED** +with `658d37fa`. + +**So Agent25-3's 2-line change fixes 176x144 and 352x288 outright and breaks +640x480.** That asymmetry is the headline: the change is right about the +`!lossless` conjunct but incomplete, and there is at least one site where adding +`&& !lossless(fctx)` removes a read that libaom does make. + +## 4. Lockstep measurement — the refusal is the SECOND symptom + +Paired `EC_SYMR` (`EC_SYMR=1` both sides) on `mix_176x144_6.obu`. Compared on +`pre[0]`, `pre[1]`, `n`, `s`, `post_rng`; `pre[2]` (bit counter) carries the +known per-site constant offset and `cdf0` the ICDF-mirroring convention — neither +is the signal. + +Frame boundaries = range-coder inits (`pre[1] == 32768`): + +```text +ORACLE frame starts: 0, 25792, 41982, 55299, 70069, 83608, 85411 (7 frames) +OURS frame starts: 0, 25832 (1 frame, then REFUSED) +``` + +**Frame 0 — bit-identical, then 40 extra reads:** + +| reads | result | +|---|---| +| 0 … 25 791 | **identical** on all five compared fields | +| 25 792 … 25 831 | **ours only** — 40 extra reads, **all stamped `mi=(32,32)`** | + +At read 25 792 the **oracle** does a range-coder init (`pre=(4399,32768,0)`) = the +frame ended; we are still reading. `mi=(32,32)` in 4×4-MI units is pixel +**(128,128)** — the **48×16 bottom-right sliver** of a 176×144 frame. Every extra +read is `tag=all_zero side=4 ctx=1`, i.e. a `txb_skip` **all_zero** flag on a +side-4 (chroma) transform, with the bit position **frozen** (`bit=36288`, +`post_bit=36288`, `range` decaying 509/read): these reads consume no data at all. +They are the signature of a walk that has run off the end of the tile and keeps +emitting units. + +Frame 0's **pixels are byte-exact** despite the 40 extra reads — the defect is +the walk, not the reconstruction. + +**Frame 1 — lockstep with the +40 offset, then the fork (at `8705034f`):** + +```text +aligned oracle 25792+k vs ours 25832+k for k = 0 … 3618 → IDENTICAL +oracle read 29411: decodetxb.c:158 mi=(9,14) pre=(41839,52168) n=2 s=0 post_rng=38760 +ours read 29451: ph=inter8 mi=(8,12) pre=(41839,52168) n=2 s=0 post_rng=35823 +``` + +Same input `rng`, same `n=2`, same symbol `s=0`, different `post_rng` → different +CDF row for the same `txb_skip`. The preceding read is `decodemv.c:1036` +`cdf=mv_hp` on both sides. + +**Distance from the fork to the abort: 11 970 reads.** The last symbol read +before the refusal is ours 41 381 at `mi=(24,40)`, `tell=24112`, frozen. + +**On `658d37fa` the frame-1 fork moves from 29 411 to 41 913** (oracle +`mi=(28,40)` vs ours `mi=(32,0)`), and frame 0's 40 extra reads at `mi=(32,32)` +are **unchanged**. So Agent25-3's fix does not touch my site. + +## 5. 640x480 under `658d37fa` — the regression, measured + +`mix_640x480_5.obu`, paired `EC_SYMR` on Agent25-3's commit: + +```text +ours 521 856 reads, oracle 457 696 reads +first divergence at read 179 378 + O 179378 pre=(24163,32784) n=2 s=0 post_rng=59748 mi=(85,100) + U 179378 pre=(24163,32784) n=2 s=0 post_rng=43411 mi=(80,108) +``` + +Same `rng`, same `n`, same `s`, different `post_rng` — a geometry walk difference +at `mi=(85,100)` (pixel 340,400) vs our `mi=(80,108)`. Our read count **exceeds +the oracle's by 64 160**, so we decode ~64 k reads past where the oracle stops, +which is what eventually trips the Golomb cap. **Not diagnosed further**: the +hunks are Agent25-3's, the change is its own, and per the charter I report the +overlap rather than race it. Sent to Agent25-3 with the recipe, both sizes and the +fork read. + +## 6. Where the Golomb tail length is computed vs consumed, and what libaom does + +| | ours | libaom | +|---|---|---| +| **computed** | `read_golomb`, `crates/ec-av1/src/decode.rs:7989-8018` — counts the unary prefix with `dec.literal(1)`, `length += 1` per zero bit | `read_golomb`, `src/av1/decoder/decodetxb.c:22-43` — the identical loop | +| **cap** | `length > 20` → `Err(unsupported("a Golomb tail longer than this decoder reads"))` | `length > 20` → `aom_internal_error(xd->error_info, AOM_CODEC_CORRUPT_FRAME, "Invalid length in read_golomb")`, then `break` | +| **consumed** | `decode.rs:8469` (square TU) and `decode.rs:8747` (rect TU), each `if level > MAX_BR_LEVEL { level + read_golomb()? }` | `read_coeffs_txb` / `read_coeffs_txb_rect`, same file | + +**Measured: the refusal fires in the SQUARE reader**, not the rect one. +`EC_TRACE_COEFF=1` ladder on `mix_176x144_6.obu`: + +```text +EC_COEFF_STEP tag=base c=2 pos=1 ctx=4 level=0 rng=62656 +EC_COEFF_STEP tag=after_bases rng=57408 +EC_COEFF_STEP tag=sign c=4 sign=0 rng=57464 +EC_COEFF_STEP tag=post_golomb c=4 level=3 rng=57464 <- last successful golomb +EC_COEFF_STEP tag=sign c=6 sign=0 rng=57576 +EC_COEFF_STEP tag=post_golomb c=6 level=2 rng=57576 +EC_COEFF_STEP tag=sign c=7 sign=0 rng=57800 +REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads) +``` + +The block is `mi=(24,40)` (pixel 96,160, the right edge), `c=7` is a +high-frequency coefficient past `MAX_BR_LEVEL`, and the bit position is frozen at +`tell=24112`. **The tail is counted out of no data at all**, which is why it runs +past 20: `dec.literal(1)` returns 0 forever once the reader is exhausted. + +**The cap is bit-identical to libaom's, and the tail is not a decoder limit +there.** The two loops are the same loop. The one real difference is what happens +on overflow: libaom's `aom_internal_error` (`aom/src/aom_codec.c:158-166`) +records the error and `longjmp`s to the caller's `setjmp` — that PICTURE is +abandoned but the decoder object survives; ours returns a hard `Err` that unwinds +`decode_stream` and takes the whole stream with it (1 dump instead of 7). +**Closing the read-side geometry removes the tail; widening or softening the cap +would only trade a clean refusal for silent corruption** — the existing comment +at `decode.rs:7990-8005` records exactly that from lane-scaledref r1 (commit +`ee1f980`, reverted in `314ee08`). + +## 7. Relation to Agent25-3's fork + +**Same class, different site.** Both are block-GEOMETRY divergences in the same +mixed-lossless + altref class and both land on a `txb_skip` read +(`decodetxb.c:158`) with the parse healthy up to that point. The 40 extra +all-zero reads at `mi=(32,32)` here are the mirror image of Agent25-3's missing +2-unit luma transform at `mi=(6,1)` on the 256x128 cell. + +Agent25-3's fix does not move read 25 792 and does not change the `mi=(32,32)` walk +(§4), which is the direct evidence that the two sites are independent: his change +removes exactly one spurious `tx_size_cat1` read per lossless sub-8 leaf, which +would shift an index by a variable amount, not by the constant 40 measured here. +**A single fix closing both is NOT claimed.** + +## 8. Hunk scope + +* **Authored by me: zero lines of `decode.rs`.** The branch tip `a49460c6` is + Agent25-3's `658d37fa` cherry-picked onto `32d944bf`, unmodified. +* Agent25-3's frozen hunks: `decode.rs:27140` and `decode.rs:48259` (both + `&& !lossless(fctx)`), plus the `SUB8_LOSSLESS_NO_VARTX` counter. Not touched. +* The Golomb/tile read path was measurement-only throughout; no probe bypass was + added, committed or left in the tree. Only env-gated rungs (`EC_SYMR`, + `EC_AV1_TELL`, `EC_TRACE_COEFF`, `EC_ECDUMP_IN`, `EC_PROBE_HDR`, + `EC_AV1_FINAL_DUMP`) were used, all read-only. +* Worktree `~/.cache/wt/av1golomb320`, private `CARGO_TARGET_DIR`, primary + checkout never edited. `git status` in the primary checkout: clean. + +## 9. Regression + +Scoped 4:2:0 / 4:4:4 / 4:2:2 / lossless / stream families: + +``` +cargo test -p ec-av1 --lib -- 420 444 422 lossless stream \ + --skip bitrate_target_lands_within_5_percent_over_48_frames +``` + +Run on `a49460c6` (= main + Agent25-3's commit). Result in §11. + +**Note the scope limit this run cannot cover:** the 640x480 regression in §5 is a +*decode* of a stream this lane generated on the fly; it is not in the fixture +corpus and no committed gate exercises it. A green §9 therefore does **not** +contradict §5, and §5 is the stronger evidence. + +## 10. What is NOT measured + +* **No fix, no gate, no fixture committed by this lane.** The reduction is handed + over; nothing here may be described as gated. +* **The `mi=(32,32)` geometry owner is not identified.** Only that we emit 40 + all-zero chroma `txb_skip` reads the oracle does not, at the bottom-right + sliver, consuming no data, with frame 0's pixels byte-exact regardless. +* **The 640x480 regression is measured but NOT root-caused.** Fork read 179 378 + and the mi pair are given; the owning code is not identified, and I did not + chase it because it is inside Agent25-3's declared hunks. +* **Whether Agent25-3's fix closes the 176x144 fork entirely is NOT measured** — it + removes the refusal but f1..f6 remain red (811 / 949 / 630 / 969 / 811 / + 24 105 of 115 200 bytes). +* **Only `testsrc2` content was swept** (4 sizes × 2 frame counts). No other + generator, no 10-bit, no odd dimensions, no 4:4:4. The class may be wider. +* **No mutation proof** — there is no change of mine to mutate. +* The 320x240 and 176x144 pixel divergences are **not** diagnosed here beyond + "same class as Agent25-3's, see §7". + +## 11. Regression result + +Run on `a49460c6` (= `32d944bf` + Agent25-3's `658d37fa`), `EC_NOMEMGUARD=1`, log at +`/tmp/g320/regress2.txt`: + +```text +test result: ok. 374 passed; 0 failed; 7 ignored; 0 measured; 422 filtered out; + finished in 1634.56s +``` + +Green — and **not** evidence against §5: the 640x480 cells are generated, not +committed fixtures, so nothing in this gate set decodes them. The sweep in §3 is +the only detector for that regression, which is why §3 is the load-bearing +evidence of this report and §9 is a no-delta confirmation. + +## 12. Fix-now | deferred | accepted + +* **fix-now:** nothing in this lane. The tree carries no change of mine. +* **deferred(unblock: Agent25-3 addressing §5):** the 640x480 cells are a REGRESSION, + not a disposition — `mix_640x480_5.obu` must decode again. Owner: Agent25-3. +* **deferred(unblock: identification of the `mi=(32,32)` walk owner):** the 40 + extra reads and the residual f1..f6 on 176x144. +* **accepted:** the `length > 20` cap stays exactly as libaom has it (§6). The + Golomb tail is the symptom; the read-side geometry is the cause. + +## 13. Reproduction + +```bash +cd /tmp/g320/sweep +ENC=~/.cache/aom-oracle/build/aomenc; DEC=~/.cache/aom-oracle/build/aomdec +P=$HOME/.cache/cargo-target-av1golomb320/debug/examples/decode_probe # main + 658d37fa +PB=$HOME/.cache/cargo-target-av1golomb320-base/debug/examples/decode_probe # 8705034f + +# the refusal, at the pre-fix base +EC_NOMEMGUARD=1 $PB mix_176x144_6.obu 2>&1 | grep REFUSED +# REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads) + +# the regression: decoded at base, refused after Agent25-3's commit +EC_NOMEMGUARD=1 $PB mix_640x480_5.obu 2>&1 | grep -E 'OK:|REFUSED' # OK: 5 frames decoded, 640x480 +EC_NOMEMGUARD=1 $P mix_640x480_5.obu 2>&1 | grep -E 'OK:|REFUSED' # REFUSED: ... Golomb tail ... + +# the 40 extra reads +EC_NOMEMGUARD=1 EC_SYMR=1 $P mix_176x144_6.obu 2>&1 >/dev/null | grep -c '^EC_SYMR' # 105219 +EC_NOMEMGUARD=1 EC_SYMR=1 $DEC --codec=av1 -o /dev/null mix_176x144_6.obu 2>&1 >/dev/null \ + | grep -c '^EC_SYMR' # 106606 +# reads 0..25791 identical; ours 25792..25831 are the extra mi=(32,32) all_zero reads +``` \ No newline at end of file diff --git a/lanes/av1mixllfork.report.md b/lanes/av1mixllfork.report.md new file mode 100644 index 00000000..4655f2b2 --- /dev/null +++ b/lanes/av1mixllfork.report.md @@ -0,0 +1,360 @@ +# lane-av1mixllfork — the mix5 fork at read 30889 is LOCALISED to a var-tx **ordering** defect; the candidate fix is **reverted as unproven** (it regresses 640x480 from decode to refusal) + +Base `main` = `32d944bf`. Worktree `/home/user/.cache/wt/av1mixllfork`, target dir +`$HOME/.cache/cargo-target-av1mixllfork`, `EC_NOMEMGUARD=1`. Oracle: +`~/.cache/aom-oracle/build/{aomdec,aomenc}` (shared, untouched). ffmpeg 8.1.3. +**This commit adds only this report. `git status --porcelain` is empty apart from +it, the tree is byte-identical to `32d944bf`, no probe bypass and no env-gated +trace is left behind.** The candidate fix was measured, shown to regress a larger +cell, and reverted — §4 has the numbers, §5 says what is still unknown. + +--- + +## 0. Verdict + +| | | +|---|---| +| Fork reproduced | **yes** — read **30889** of f1, byte-identical to `lanes/av1framecount.report.md` §5 | +| Fork **shape** corrected | it is **not** a wrong-CDF-row fork (§2) | +| Owning block identified | **yes** — a sub-8 4x8/8x4 inter leaf's var-tx gate, `decode.rs:48259`; second site `decode.rs:27140` | +| Root cause named | libaom puts `!xd->lossless[mbmi->segment_id]` **in** the var-tx condition; ours put `lossless(fctx)` in the `else if` | +| Candidate fix | 2 lines; **green on 4 cells, REGRESSION on 2** → **reverted, unproven** | +| Regression | 640x480 4:2:0 8-bit mixed-lossless+altref goes **decode → `REFUSED: AV1 tile (a Golomb tail longer than this decoder reads)`** | +| Fixture / gate | **none committed** — a gate that asserts a cell the tree still fails is not landable | +| Class sweep | done on the **source** (9 var-tx call sites, 2 broken) and on **streams at base**; HBD not synthesized (§7) | + +## 1. Reproduction + +The encoder side reproduces **byte-exact** on the first try: + +```text +ffmpeg -f lavfi -i testsrc2=size=256x128:rate=25 -frames:v 5 -pix_fmt yuv420p src5b.y4m +aomenc --codec=av1 --obu -o c_mix5.obu --passes=1 --cpu-used=4 \ + --limit=5 --end-usage=q --cq-level=0 --aq-mode=1 src5b.y4m +``` + +`c_mix5.obu` = **18 525 B**, sha256 +**`3e06b5641e6a0f5a3f4ac8f114d4ee48c88638429e9eaafe6b4483e24f1dbc3a`** — the +sha the inherited report names. ffmpeg, rebuilt 2026-09-30, still picks the same +AQ decisions. Decode-order dumps vs the oracle at `32d944bf`: + +| frame | diff bytes (of 49 152) | +|---|---:| +| f0 (key) | 0 | +| f1 | **33 724** | +| f2 | **34 251** | +| f3 | **44 500** | +| f4 | **36 688** | +| f5 | **37 462** | + +## 2. Two corrections to the inherited frame + +### 2a. "The oracle makes no block origin at mi=(6,1)" is false + +Claimed by `lanes/av1framecount.report.md` §5 and relayed by the parent. The +oracle's own `EC_ECDUMP_IN` rung says otherwise: + +```text +EC_ECDUMP_IN plane=0 mi=(6,0) bc=0 br=0 tx=0 ctx=1 ECIN=(55806,57232,2608) +EC_ECDUMP_IN plane=0 mi=(6,0) bc=0 br=1 tx=0 ctx=3 ECIN=(8271,57096,2646) +EC_ECDUMP_IN plane=0 mi=(6,1) bc=0 br=0 tx=0 ctx=3 ECIN=(35995,39325,2653) <- the fork +EC_ECDUMP_IN plane=0 mi=(6,1) bc=0 br=1 tx=0 ctx=3 ECIN=(5855,55048,2690) +EC_ECDUMP_IN plane=1 mi=(6,1) bc=0 br=0 tx=0 ctx=8 ECIN=(11710,48168,2691) +EC_ECDUMP_IN plane=2 mi=(6,1) bc=0 br=0 tx=0 ctx=8 ECIN=(11129,49928,2749) +``` + +The oracle has **two** TX_4X4 luma units at `mi=(6,1)` (`br=0`, `br=1`) plus one +chroma unit per plane — a 4x8 luma transform on a sub-8 leaf, the **lossless** +shape. It is **our** decoder that lacks that geometry. The "open geometry +question" is therefore not open: it is a *consequence* of the missing lossless +branch, and the sibling observation (odd-column origins appear in 7 other rows) +stays true. + +### 2b. It is not a wrong-`txs_ctx` / wrong-`txb_skip_ctx` fork + +The inherited report reads the `cdf0` difference as a context bug. Measured, the +`32768 - x` ICDF mirror between the two sides' `cdf0` **holds at every agreeing +read**, including the three immediately before the fork (`8580↔24188`, +`30886↔1882`, `16138↔1882`'s neighbour `16138↔16630`), and **breaks exactly at +the fork** (`15299` vs `22401`; `32768 - 15299 = 17469 ≠ 22401`). + +So the two sides are reading **different symbols**, not one symbol out of a +different row. A wrong `txs_ctx` or `txb_skip_ctx` can never produce that. The +read is one step out of sync with a symbol that libaom does not read at all. + +**How our read was identified** (this is the part that is easy to get wrong). +Our `EC_SYMR` prints no site, and `ph=` is **sticky** — it names whichever reader +last called `set_symr_phase`, so a coefficient read shows the enclosing block's +phase and a sub-8 read that never sets one inherits an older value. `mi=` is +likewise stale. I tagged every `intra_inter` / `new_mv` / `drl_mode` / `zero_mv` / +`ref_mv` / `obmc` / `switchable_interp` read with `set_symr_cdf` in **all four** +inter-mode-info copies, rebuilt, and re-ran: + +```text +read 30888 cdf=refmvB pre=(49935,53265,2668) cdf0=24188 n=2 s=0 post_rng=39325 +read 30889 cdf= pre=(35995,39325,2668) cdf0=22401 n=2 s=0 post_rng=54010 +``` + +`refmvB` fired — the block is a sub-8 piece (`decode.rs:48185`) and `s=0` is +NEARESTMV on **both** sides (same `ref_mv` row, mirrored). Read 30889 carries +**no** tag, so it is none of the six inter mode-info reads; the one read a block +makes between its `ref_mv` and its coefficients is the var-tx tree's +`tx_size_cat1`. (Our `EC_ECDUMP_IN` also fires for every `read_coeffs` / +`read_coeffs_rect` call, and the fork's entry state `(35995, 39325, …)` is +absent from it — so the read is not a `txb_skip` at all.) The tags were +**reverted**; they are a finding, not an artefact. + +Oracle at the same index: + +```text +read 30888 site=decodemv.c:191 mi=(6,1) pre=(49935,53265,2653) cdf0=8580 n=2 s=0 post_rng=39325 +read 30889 site=decodetxb.c:158 mi=(6,1) pre=(35995,39325,2653) cdf0=15299 n=2 s=0 post_rng=42076 +read 30890 site=decodetxb.c:242 mi=(6,1) ... n=5 +``` + +libaom goes straight from `refmv` to the luma `txb_skip`. **It reads no +`tx_size` symbol at all.** + +## 3. Root cause + +`decodeframe.c:1237`, `parse_decode_block`: + +```c +if (cm->features.tx_mode == TX_MODE_SELECT && block_signals_txsize(bsize) && + !mbmi->skip_txfm && inter_block_tx && !xd->lossless[mbmi->segment_id]) { + ... read_tx_size_vartx ... +} else { + mbmi->tx_size = read_tx_size(xd, ...); // decodeframe.c:1208: +} // if (xd->lossless[seg]) return TX_4X4; +``` + +`!xd->lossless[mbmi->segment_id]` is a **conjunct of the tree condition**, and +`read_tx_size` answers `TX_4X4` on the same flag. A lossless *segment* of a +mixed-lossless frame codes no `tx_size_cat1` symbol and lands on TX_4X4 per +plane. + +Ours, at `32d944bf` (`decode.rs:48231-48247`, the sub-8 4x8/8x4 inter leaf): + +```rust +if fctx.tx_select_inter.with(Cell::get) && !skip { // no lossless conjunct + read_var_tx_size(..) // reads tx_size_cat1 +} else if lossless(fctx) && !skip { // one branch too late + for row in 0..bh / MI { for col in 0..bw / MI { leaves.push((row, col, MI, MI)); } } +``` + +`lossless(fctx)` is already per-segment (`decode.rs:453-456`, +`lossless_per_seg[cur_segment_id]`), so it answers correctly — one branch too +late. Everything the tree reads after the spurious `tx_size_cat1` is then offset +by one symbol and the **next** block's `txb_skip` is the first visible fork. +That is exactly the reported signature: a correct pre-state, the same alphabet, +a different result. + +**Defect class, named:** *a per-segment flag consulted as a branch alternative +instead of as a conjunct of the condition it gates.* + +## 4. The candidate fix, and why it is reverted + +```diff +@@ decode.rs:27140 (intrabc 4x8 / 8x4 rect leaf) +- if tx_select && !skip { ++ if tx_select && !skip && !lossless(fctx) { +@@ decode.rs:48259 (sub-8 4x8 / 8x4 inter leaf) +- if fctx.tx_select_inter.with(Cell::get) && !skip { ++ if fctx.tx_select_inter.with(Cell::get) && !skip && !lossless(fctx) { +``` + +plus a `SUB8_LOSSLESS_NO_VARTX` route counter for non-vacuity. It was committed +as `658d37fa` and **then reverted** (`git reset --hard 32d944bf`). + +**Green** (measured on `658d37fa`): + +| cell | at base | with the fix | +|---|---|---| +| `c_mix5` 256x128 `--limit=5` (the pin) | RED f1–f5 | **6/6 decode-order byte-exact**, 5/5 shown byte-exact, **96 997/96 997 entropy reads bit-identical, zero divergence over the whole stream** | +| `s_arf8` 256x128 `--limit=8` | RED f1–f5 | **6/6** | +| `s444_8` **4:4:4** `--profile=1 --limit=8` | **RED f1–f8** | **9/9** | +| `s176` 176x144 `--limit=6` | `REFUSED` | 7/7 dumps, refusal removed (still red — see §6) | +| `s352` 352x288 `--limit=6` | `REFUSED` | 7/7 **exact** (per lane-av1golomb320) | + +Mutation proof on the pinned fixture, fix surgically reverted from the working +tree, gate run: + +```text +test stream::tests::a_420_mixed_lossless_alt_ref_sub8_vartx_witness_... ... FAILED +panicked at crates/ec-av1/src/stream.rs:10935:17: +...: decode-order frame 1 of 6 (5 shown, 1 hidden) differs from the oracle at +byte 33 (ours 82 vs 81), 33724 bytes differ +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 802 filtered out +``` + +**33 724 — the same number as the hand-measured red.** + +**Regression** (found by lane-av1golomb320, reproduced and confirmed here): + +```text +cell: testsrc2 640x480, 6 frames, --passes=1 --cpu-used=4 --limit=6 \ + --end-usage=q --cq-level=0 --aq-mode=1 -> 115615 B + + 32d944bf (base) : OK: 6 frames decoded, 640x480 + 658d37fa (fix) : REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads) +``` + +`--limit=5` (87 537 B) behaves identically (base decodes 5, fix refuses). I +isolated which of the two hunks does it: reverting **only** `27140` and keeping +`48259` still refuses, so the regression comes from the **sub-8 inter** hunk. +Locating it, the first divergence on `m640_6` with the fix is at read **184 328**, +where the oracle reads `decodeframe.c:1186` — the `txfm_partition` split inside +`read_tx_size_vartx` — and we read a different `n=2` symbol from the identical +pre-state `(30248, 45616)`: + +```text +ORC 184328 decodeframe.c:1186 mi=(91,106) pre=(30248,45616) n=2 s=0 post_rng=62032 +OUR 184328 (untagged) mi=(88,108) pre=(30248,45616) n=2 s=0 post_rng=58828 +``` + +and the oracle's `EC_ECDUMP_IN` for that block is a single `tx=0` (TX_4X4) luma +unit at `mi=(91,106)`. So at that leaf the oracle **does** walk the var-tx tree +and does **not** consider its segment lossless, while our `lossless(fctx)` +returned true and suppressed the tree. Instrumenting the gate +(`EC_MIXLLDBG`, since removed) shows the flag is genuinely reporting `true` on +many sub-8 leaves of this stream (145 of 160 leaves), with `cur_segment_id` +values 0, 1, 4 and 5 in play. + +**Conclusion:** the ordering defect is real and the fix is right *at the leaf*, +but our per-segment lossless answer is **wrong somewhere in the 640x480 stream** +— over-reporting on a block whose segment libaom treats as lossy. Adding the +conjunct therefore converts one wrong-symbol fork into a *missing*-symbol fork on +that cell. Per the lane contract ("a change you cannot make red first is not a +fix — report it as unproven instead") and because a decode → refusal flip is a +refusal-inventory regression in its own right, the change is **reverted and no +fixture or gate is committed**: a gate asserting a cell the tree still fails is +not landable. + +## 5. Class sweep (on the reverted tree, i.e. at `32d944bf`) + +**(a) Source — every var-tx gate, re-derived against libaom's own `if`.** +`read_var_tx_size` has 9 call sites: + +| site | shape | verdict | +|---|---|---| +| `decode.rs:18229` | `if skip \|\| (!lossless && !tx_select) … else if lossless` | lossless first — **correct** | +| `decode.rs:21973` | `… && tx_select && !skip && !lossless(fctx)` | conjunct — **correct** | +| `decode.rs:23868` | `… && !skip && !lossless(fctx)` | conjunct — **correct** | +| `decode.rs:14042`, `15504`, `16143`, `16709`, `18720`, `19697` | `tx_select && !lossless(fctx)` | conjunct — **correct** | +| `decode.rs:29708` (`read_block_tx_size`) | `if lossless(fctx) { … return }` before the tree | early return — **correct** | +| `decode.rs:30235` (`read_block_tx_size_rect`) | same early return | early return — **correct** | +| **`decode.rs:27140`** (intrabc 4x8/8x4 rect) | `tx_select && !skip` … `else if lossless && !skip` | **this class** | +| **`decode.rs:48231`** (sub-8 4x8/8x4 inter) | `tx_select_inter && !skip` … `else if lossless && !skip` | **this class** | + +The other six `else if lossless(fctx)` sites (`12790`, `25689`, `42365`, +`44172`, `48549`, `18186`) are **chroma unit-grid** selection, not var-tx symbol +reads — a different concern, not this class. **Exactly 2 sites.** + +**(b) Streams — at base, so the numbers are the tree's real state.** All arms +`testsrc2`, `--passes=1 --cpu-used=4 --end-usage=q`, decode-order dumps vs the +oracle: + +| cell | flags | base | +|---|---|---| +| `c_mix5` | `--limit=5 --cq-level=0 --aq-mode=1` | RED f1–f5 | +| `s_arf8` | `--limit=8 --cq-level=0 --aq-mode=1` | RED f1–f5 | +| `s444_8` | `--profile=1` (4:4:4) `--limit=8 --cq-level=0 --aq-mode=1` | RED f1–f8 | +| `s_noarf5` | `--auto-alt-ref=0 --cq-level=0 --aq-mode=1` | 5/5 exact | +| `s_cq20` | `--cq-level=20 --aq-mode=1` | 6/6 exact | +| `s_ll` | `--lossless=1` | 6/6 exact | +| `s_aq0` | `--cq-level=0 --aq-mode=0` | 6/6 exact | +| `s176` | 176x144 `--limit=6` | **REFUSED** | +| `m640_5` / `m640_6` | 640x480 `--limit=5` / `--limit=6` | decodes (redness not measured) | + +The four exact arms confirm the trigger really is the conjunction (per-segment +mixed lossless **and** an alt-ref structure) the inherited report described. + +## 6. Not this lane's defect + +* **Agent02-3's `mi=(32,32)` fork at read 25792** on the 176x144 cell is a + **separate** extra-geometry defect. Measured here on both sides of my change: + the first divergence is **25792 with and without the fix**, so the two-line + ordering change does not move it at all. Handed to lane-av1golomb320. +* The 320x240 Golomb-tail refusal of the same recipe was not reproduced here. + +## 7. What is NOT measured + +* **The next step is not taken, and it is the whole remaining question:** *why + does `lossless(fctx)` return true on a 640x480 sub-8 leaf whose segment libaom + treats as lossy?* Two candidates, neither tested: `fctx.cur_segment_id` is + stale at some sub-8 leaf (`inter_segment_id` is called per piece at + `decode.rs:48026` / `46262`, and the sub-8 reader has its own skip-then- + segment order), or `lossless_per_seg` itself is wrong for some segment. The + instrumentation that would settle it is one env-gated line at + `decode.rs:48231` printing `(rmi, cmi, cur_segment_id, lossless)`, paired with + the oracle's `EC_ECDUMP_IN` for the same `mi`. **I ran that instrumentation and + it shows the flag is true (145/160 leaves) but I did not finish the pairing, + so I cannot say which candidate it is.** +* **10/12-bit arms: NOT synthesized.** This ffmpeg (8.1.3) cannot emit a + >8-bit y4m at all — `Conversion failed!` for `yuv420p10le`, `yuv420p12le`, + `yuv444p10le` and `gray10le`, from both a lavfi source and a y4m input — and a + hand-built 16-bit-LE y4m is rejected by the shared `aomenc` with + `Loss of framing in Y4M input data` (0-byte output). The committed HBD corpus + is covered by the scoped regression, but that is a **regression, not a sweep of + this class at HBD**, and I do not claim it as one. +* Whether the 640x480 base decode is red or exact — I measured that it *decodes*, + not that it is correct. +* `mixll` is content-dependent. I re-measured only `testsrc2` at 256x128, plus + the 4:4:4 256x128, 176x144, 352x288 and 640x480 arms; I did **not** re-run the + inherited report's three-generator x three-size matrix. +* Pre-fix, f1 is wrong from pixel 0 at whole-frame scale. I did not bisect which + reconstruction stage first diverges: with the entropy ladder bit-identical end + to end under the candidate fix, the parse was the whole story. + +## 8. Regression + +Exact command, run in the lane worktree on the reverted tree: + +```text +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1mixllfork EC_NOMEMGUARD=1 \ + cargo test -p ec-av1 --lib -- 420 444 422 lossless stream \ + --skip bitrate_target_lands_within_5_percent_over_48_frames +``` + +```text +test result: ok. 373 passed; 0 failed; 7 ignored; 0 measured; 422 filtered out; + finished in 1623.93s +``` + +**373 / 0 / 7 / 422 — the identical numbers `lanes/av1framecount.report.md` §6 +records**, which is the expected result for a report-only change: this tree +carries no source delta from `32d944bf`. It is a no-delta confirmation, not +evidence for any fix, because there is no fix in the tree. + +This is the inherited report's scope, so the two are comparable: the 4:2:0, +4:4:4 and 4:2:2 fixtures, the lossless cells, the sub-8 and inter chroma +identity gates, and the whole `stream` module where the oracle-compared fixture +gates live. + +**The coverage hole this run exposes.** I ran the same command on the candidate +fix `658d37fa` before reverting it: **236 tests, 0 failures, still running** when +I terminated it — and it never went red, while that commit turns 640x480 from +decoding into a `REFUSED`. **The suite contains no 640x480-class cell**, so a +refusal-inventory regression of exactly this kind is invisible to it. Any lane +that lands a mixed-lossless + altref change needs a >= 640x480 cell of that +recipe in `fixtures/`, or the green run is not evidence. + +## 9. Fix-now | deferred() | accepted + +* **fix-now** — nothing in the tree. The change is reverted; this commit is the + report alone. +* **deferred(identify whether `fctx.cur_segment_id` is stale at the sub-8 leaf, + or `lossless_per_seg` is wrong, on a 640x480 mixed-lossless+altref cell)** — + the whole remaining fix. §7 names the one env-gated line that settles it and + the oracle rung to pair it with. Until that is answered, adding + `&& !lossless(fctx)` trades one fork for another. +* **deferred(a >8-bit y4m source, or a hand-built one the shared `aomenc` + accepts)** — the HBD arm of the class sweep, §7. +* **deferred(a separate lane)** — the `mi=(32,32)` extra-geometry fork at read + 25792 and the 320x240 Golomb-tail refusal. §6. +* **accepted** — the diagnostic `set_symr_cdf` tags and the `EC_MIXLLDBG` print. + Both identified the reads and both are reverted; the permanent artefacts are + this report and the measurements in it. If a future lane needs to name an + untagged inter read again: `refmvB`-style tags at all **four** + inter-mode-info copies are the lines to re-add, and `ph=`/`mi=` must not be + trusted to do it.