forge
Explore
Log in

Don't you dare go Hollow

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

Browse files at this commit

5c9a50762a218c2f878f62b81b10542578d37d4cAhmet Kaan GümüşParent: 7929331
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.mdadded+303 -0
@@ -0,0 +1,303 @@
1+# lane-av1golomb320 — the mixed-lossless Golomb-tail refusal is DOWNSTREAM geometry, not a parser bug; and Agent25-3's fix REGRESSES a 640x480 cell
2+
3+Base `main` = `32d944bf`. Worktree `/home/user/.cache/wt/av1golomb320`, target dir
4+`$HOME/.cache/cargo-target-av1golomb320`, `EC_NOMEMGUARD=1`. Oracle
5+`~/.cache/aom-oracle/build/{aomdec,aomenc}` (shared, untouched).
6+**No source change authored in this lane.** Branch tip is `a49460c6` = `32d944bf` +
7+a clean cherry-pick of Agent25-3's `658d37fa` (needed to re-measure the refusal on the
8+fixed base). Every `decode.rs` line in that commit is Agent25-3's.
9+
10+---
11+
12+## 0. Verdict
13+
14+Two findings, both measured, neither a fix of mine.
15+
16+1. **The Golomb-tail refusal in this class is DOWNSTREAM of a block-GEOMETRY
17+ walk defect, not a distinct parser bug.** Paired `EC_SYMR` shows frame 0 is
18+ **bit-identical to the oracle for all 25 792 reads**, then we emit **40 extra
19+ reads at `mi=(32,32)`** the oracle never makes. The abort arrives **11 970
20+ reads later**. It cannot be the first symptom.
21+2. **Agent25-3's `658d37fa` removes the refusal on the cells I had, and INTRODUCES
22+ one on 640x480.** `mix_640x480_5.obu` (87 537 B) and `mix_640x480_6.obu`
23+ (115 615 B) decode fully at `8705034f` (== `32d944bf` for `decode.rs`, empty
24+ diff) and **REFUSE with `658d37fa` applied**. That is a supported 4:2:0 8-bit
25+ cell going decode → refusal: a red-before/green-after in the wrong direction.
26+ Reported to Agent25-3 over IRC; **not mine to fix** (its hunks are its own).
27+
28+Also: **the 320x240 arm named in the brief does not refuse** on this tip — see §2.
29+
30+---
31+
32+## 1. The cells
33+
34+Recipe (all arms): `testsrc2`, 6 frames, `--passes=1 --cpu-used=4 --end-usage=q
35+--cq-level=0 --aq-mode=1`. Per-size source: `ffmpeg -f lavfi -i
36+testsrc2=size=<S>:rate=25 -frames:v 6 -pix_fmt yuv420p`. ffmpeg 8.1.3, shared
37+oracle aomenc.
38+
39+| cell | bytes | sha256 (full) |
40+|---|---:|---|
41+| `mix_176x144_6.obu` | 20 069 | `02b15d0d5b08aa5aebf139aee94c31b4f8363d14649c238cd7a19a9785ef124a` |
42+| `mix_176x144_5.obu` | 16 090 | `08fdbbb6566d4d51…` (prefix) |
43+| `mix_320x240_5.obu` | 28 716 | `40d613fd0ced7b90facdaf71f62501acad90fb789738851a2b59c92bd6a64149` |
44+| `mix_320x240_6.obu` | 38 686 | `37fbe7cb9235980d…` |
45+| `mix_352x288_6.obu` | 46 490 | `e43c74b8d847e701…` |
46+| `mix_640x480_5.obu` | 87 537 | `3d505fd2e0bbb7ca…` |
47+| `mix_640x480_6.obu` | 115 615 | `c82ba4d793d378cc…` |
48+
49+On this content `--limit=8` produces the **same bytes** as `--limit=6` (sha
50+identical) for 176x144, 320x240, 352x288 and 640x480, so frame count is not a
51+variable; `--limit=6` is the minimal refusing arm where it refuses.
52+
53+Exact refusal string, verbatim from `decode_probe`:
54+
55+```text
56+REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads)
57+```
58+
59+## 2. The 320x240 premise is FALSE on this tip
60+
61+At **both** `32d944bf` (main) and `8705034f` (the framecount report's base),
62+`mix_320x240_5.obu` decodes **6/6 decode-order dumps** with **zero** refusal
63+lines — it DIVERGES (f0 exact, f1..f5 differ, 90 813 / 85 821 / 99 314 / 90 572
64+/ 91 598 of 115 200 bytes). The framecount report's claim that the 320x240 arm
65+of this recipe refuses does not reproduce. Recorded, not chased.
66+
67+## 3. The class sweep — refusal is content/size dependent
68+
69+`--limit=6`, dual decode + per-frame `cmp`, `testsrc2`:
70+
71+| size | bytes | at `8705034f` | at `658d37fa` (Agent25-3) |
72+|---|---|---|---|
73+| 176x144 | 20 069 | **REFUSED** (1/7 dumps) | decodes 7/7, f0 EXACT, f1..f6 red |
74+| 352x288 | 46 490 | **REFUSED** (3/7 dumps) | decodes 7/7, **7/7 EXACT** |
75+| 320x240 | 38 686 | decodes 7/7 (6 exact, 1 red) | decodes 7/7 (6 exact, 1 red) |
76+| 640x480 | 115 615 | decodes 7/7 | **REFUSED** (5/7 dumps) |
77+
78+`--limit=5` on 640x480 (87 537 B) behaves the same: decoded at base, **REFUSED**
79+with `658d37fa`.
80+
81+**So Agent25-3's 2-line change fixes 176x144 and 352x288 outright and breaks
82+640x480.** That asymmetry is the headline: the change is right about the
83+`!lossless` conjunct but incomplete, and there is at least one site where adding
84+`&& !lossless(fctx)` removes a read that libaom does make.
85+
86+## 4. Lockstep measurement — the refusal is the SECOND symptom
87+
88+Paired `EC_SYMR` (`EC_SYMR=1` both sides) on `mix_176x144_6.obu`. Compared on
89+`pre[0]`, `pre[1]`, `n`, `s`, `post_rng`; `pre[2]` (bit counter) carries the
90+known per-site constant offset and `cdf0` the ICDF-mirroring convention — neither
91+is the signal.
92+
93+Frame boundaries = range-coder inits (`pre[1] == 32768`):
94+
95+```text
96+ORACLE frame starts: 0, 25792, 41982, 55299, 70069, 83608, 85411 (7 frames)
97+OURS frame starts: 0, 25832 (1 frame, then REFUSED)
98+```
99+
100+**Frame 0 — bit-identical, then 40 extra reads:**
101+
102+| reads | result |
103+|---|---|
104+| 0 … 25 791 | **identical** on all five compared fields |
105+| 25 792 … 25 831 | **ours only** — 40 extra reads, **all stamped `mi=(32,32)`** |
106+
107+At read 25 792 the **oracle** does a range-coder init (`pre=(4399,32768,0)`) = the
108+frame ended; we are still reading. `mi=(32,32)` in 4×4-MI units is pixel
109+**(128,128)** — the **48×16 bottom-right sliver** of a 176×144 frame. Every extra
110+read is `tag=all_zero side=4 ctx=1`, i.e. a `txb_skip` **all_zero** flag on a
111+side-4 (chroma) transform, with the bit position **frozen** (`bit=36288`,
112+`post_bit=36288`, `range` decaying 509/read): these reads consume no data at all.
113+They are the signature of a walk that has run off the end of the tile and keeps
114+emitting units.
115+
116+Frame 0's **pixels are byte-exact** despite the 40 extra reads — the defect is
117+the walk, not the reconstruction.
118+
119+**Frame 1 — lockstep with the +40 offset, then the fork (at `8705034f`):**
120+
121+```text
122+aligned oracle 25792+k vs ours 25832+k for k = 0 … 3618 → IDENTICAL
123+oracle read 29411: decodetxb.c:158 mi=(9,14) pre=(41839,52168) n=2 s=0 post_rng=38760
124+ours read 29451: ph=inter8 mi=(8,12) pre=(41839,52168) n=2 s=0 post_rng=35823
125+```
126+
127+Same input `rng`, same `n=2`, same symbol `s=0`, different `post_rng` → different
128+CDF row for the same `txb_skip`. The preceding read is `decodemv.c:1036`
129+`cdf=mv_hp` on both sides.
130+
131+**Distance from the fork to the abort: 11 970 reads.** The last symbol read
132+before the refusal is ours 41 381 at `mi=(24,40)`, `tell=24112`, frozen.
133+
134+**On `658d37fa` the frame-1 fork moves from 29 411 to 41 913** (oracle
135+`mi=(28,40)` vs ours `mi=(32,0)`), and frame 0's 40 extra reads at `mi=(32,32)`
136+are **unchanged**. So Agent25-3's fix does not touch my site.
137+
138+## 5. 640x480 under `658d37fa` — the regression, measured
139+
140+`mix_640x480_5.obu`, paired `EC_SYMR` on Agent25-3's commit:
141+
142+```text
143+ours 521 856 reads, oracle 457 696 reads
144+first divergence at read 179 378
145+ O 179378 pre=(24163,32784) n=2 s=0 post_rng=59748 mi=(85,100)
146+ U 179378 pre=(24163,32784) n=2 s=0 post_rng=43411 mi=(80,108)
147+```
148+
149+Same `rng`, same `n`, same `s`, different `post_rng` — a geometry walk difference
150+at `mi=(85,100)` (pixel 340,400) vs our `mi=(80,108)`. Our read count **exceeds
151+the oracle's by 64 160**, so we decode ~64 k reads past where the oracle stops,
152+which is what eventually trips the Golomb cap. **Not diagnosed further**: the
153+hunks are Agent25-3's, the change is its own, and per the charter I report the
154+overlap rather than race it. Sent to Agent25-3 with the recipe, both sizes and the
155+fork read.
156+
157+## 6. Where the Golomb tail length is computed vs consumed, and what libaom does
158+
159+| | ours | libaom |
160+|---|---|---|
161+| **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 |
162+| **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` |
163+| **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 |
164+
165+**Measured: the refusal fires in the SQUARE reader**, not the rect one.
166+`EC_TRACE_COEFF=1` ladder on `mix_176x144_6.obu`:
167+
168+```text
169+EC_COEFF_STEP tag=base c=2 pos=1 ctx=4 level=0 rng=62656
170+EC_COEFF_STEP tag=after_bases rng=57408
171+EC_COEFF_STEP tag=sign c=4 sign=0 rng=57464
172+EC_COEFF_STEP tag=post_golomb c=4 level=3 rng=57464 <- last successful golomb
173+EC_COEFF_STEP tag=sign c=6 sign=0 rng=57576
174+EC_COEFF_STEP tag=post_golomb c=6 level=2 rng=57576
175+EC_COEFF_STEP tag=sign c=7 sign=0 rng=57800
176+REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads)
177+```
178+
179+The block is `mi=(24,40)` (pixel 96,160, the right edge), `c=7` is a
180+high-frequency coefficient past `MAX_BR_LEVEL`, and the bit position is frozen at
181+`tell=24112`. **The tail is counted out of no data at all**, which is why it runs
182+past 20: `dec.literal(1)` returns 0 forever once the reader is exhausted.
183+
184+**The cap is bit-identical to libaom's, and the tail is not a decoder limit
185+there.** The two loops are the same loop. The one real difference is what happens
186+on overflow: libaom's `aom_internal_error` (`aom/src/aom_codec.c:158-166`)
187+records the error and `longjmp`s to the caller's `setjmp` — that PICTURE is
188+abandoned but the decoder object survives; ours returns a hard `Err` that unwinds
189+`decode_stream` and takes the whole stream with it (1 dump instead of 7).
190+**Closing the read-side geometry removes the tail; widening or softening the cap
191+would only trade a clean refusal for silent corruption** — the existing comment
192+at `decode.rs:7990-8005` records exactly that from lane-scaledref r1 (commit
193+`ee1f980`, reverted in `314ee08`).
194+
195+## 7. Relation to Agent25-3's fork
196+
197+**Same class, different site.** Both are block-GEOMETRY divergences in the same
198+mixed-lossless + altref class and both land on a `txb_skip` read
199+(`decodetxb.c:158`) with the parse healthy up to that point. The 40 extra
200+all-zero reads at `mi=(32,32)` here are the mirror image of Agent25-3's missing
201+2-unit luma transform at `mi=(6,1)` on the 256x128 cell.
202+
203+Agent25-3's fix does not move read 25 792 and does not change the `mi=(32,32)` walk
204+(§4), which is the direct evidence that the two sites are independent: his change
205+removes exactly one spurious `tx_size_cat1` read per lossless sub-8 leaf, which
206+would shift an index by a variable amount, not by the constant 40 measured here.
207+**A single fix closing both is NOT claimed.**
208+
209+## 8. Hunk scope
210+
211+* **Authored by me: zero lines of `decode.rs`.** The branch tip `a49460c6` is
212+ Agent25-3's `658d37fa` cherry-picked onto `32d944bf`, unmodified.
213+* Agent25-3's frozen hunks: `decode.rs:27140` and `decode.rs:48259` (both
214+ `&& !lossless(fctx)`), plus the `SUB8_LOSSLESS_NO_VARTX` counter. Not touched.
215+* The Golomb/tile read path was measurement-only throughout; no probe bypass was
216+ added, committed or left in the tree. Only env-gated rungs (`EC_SYMR`,
217+ `EC_AV1_TELL`, `EC_TRACE_COEFF`, `EC_ECDUMP_IN`, `EC_PROBE_HDR`,
218+ `EC_AV1_FINAL_DUMP`) were used, all read-only.
219+* Worktree `~/.cache/wt/av1golomb320`, private `CARGO_TARGET_DIR`, primary
220+ checkout never edited. `git status` in the primary checkout: clean.
221+
222+## 9. Regression
223+
224+Scoped 4:2:0 / 4:4:4 / 4:2:2 / lossless / stream families:
225+
226+```
227+cargo test -p ec-av1 --lib -- 420 444 422 lossless stream \
228+ --skip bitrate_target_lands_within_5_percent_over_48_frames
229+```
230+
231+Run on `a49460c6` (= main + Agent25-3's commit). Result in §11.
232+
233+**Note the scope limit this run cannot cover:** the 640x480 regression in §5 is a
234+*decode* of a stream this lane generated on the fly; it is not in the fixture
235+corpus and no committed gate exercises it. A green §9 therefore does **not**
236+contradict §5, and §5 is the stronger evidence.
237+
238+## 10. What is NOT measured
239+
240+* **No fix, no gate, no fixture committed by this lane.** The reduction is handed
241+ over; nothing here may be described as gated.
242+* **The `mi=(32,32)` geometry owner is not identified.** Only that we emit 40
243+ all-zero chroma `txb_skip` reads the oracle does not, at the bottom-right
244+ sliver, consuming no data, with frame 0's pixels byte-exact regardless.
245+* **The 640x480 regression is measured but NOT root-caused.** Fork read 179 378
246+ and the mi pair are given; the owning code is not identified, and I did not
247+ chase it because it is inside Agent25-3's declared hunks.
248+* **Whether Agent25-3's fix closes the 176x144 fork entirely is NOT measured** — it
249+ removes the refusal but f1..f6 remain red (811 / 949 / 630 / 969 / 811 /
250+ 24 105 of 115 200 bytes).
251+* **Only `testsrc2` content was swept** (4 sizes × 2 frame counts). No other
252+ generator, no 10-bit, no odd dimensions, no 4:4:4. The class may be wider.
253+* **No mutation proof** — there is no change of mine to mutate.
254+* The 320x240 and 176x144 pixel divergences are **not** diagnosed here beyond
255+ "same class as Agent25-3's, see §7".
256+
257+## 11. Regression result
258+
259+Run on `a49460c6` (= `32d944bf` + Agent25-3's `658d37fa`), `EC_NOMEMGUARD=1`, log at
260+`/tmp/g320/regress2.txt`:
261+
262+```text
263+test result: ok. 374 passed; 0 failed; 7 ignored; 0 measured; 422 filtered out;
264+ finished in 1634.56s
265+```
266+
267+Green — and **not** evidence against §5: the 640x480 cells are generated, not
268+committed fixtures, so nothing in this gate set decodes them. The sweep in §3 is
269+the only detector for that regression, which is why §3 is the load-bearing
270+evidence of this report and §9 is a no-delta confirmation.
271+
272+## 12. Fix-now | deferred | accepted
273+
274+* **fix-now:** nothing in this lane. The tree carries no change of mine.
275+* **deferred(unblock: Agent25-3 addressing §5):** the 640x480 cells are a REGRESSION,
276+ not a disposition — `mix_640x480_5.obu` must decode again. Owner: Agent25-3.
277+* **deferred(unblock: identification of the `mi=(32,32)` walk owner):** the 40
278+ extra reads and the residual f1..f6 on 176x144.
279+* **accepted:** the `length > 20` cap stays exactly as libaom has it (§6). The
280+ Golomb tail is the symptom; the read-side geometry is the cause.
281+
282+## 13. Reproduction
283+
284+```bash
285+cd /tmp/g320/sweep
286+ENC=~/.cache/aom-oracle/build/aomenc; DEC=~/.cache/aom-oracle/build/aomdec
287+P=$HOME/.cache/cargo-target-av1golomb320/debug/examples/decode_probe # main + 658d37fa
288+PB=$HOME/.cache/cargo-target-av1golomb320-base/debug/examples/decode_probe # 8705034f
289+
290+# the refusal, at the pre-fix base
291+EC_NOMEMGUARD=1 $PB mix_176x144_6.obu 2>&1 | grep REFUSED
292+# REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads)
293+
294+# the regression: decoded at base, refused after Agent25-3's commit
295+EC_NOMEMGUARD=1 $PB mix_640x480_5.obu 2>&1 | grep -E 'OK:|REFUSED' # OK: 5 frames decoded, 640x480
296+EC_NOMEMGUARD=1 $P mix_640x480_5.obu 2>&1 | grep -E 'OK:|REFUSED' # REFUSED: ... Golomb tail ...
297+
298+# the 40 extra reads
299+EC_NOMEMGUARD=1 EC_SYMR=1 $P mix_176x144_6.obu 2>&1 >/dev/null | grep -c '^EC_SYMR' # 105219
300+EC_NOMEMGUARD=1 EC_SYMR=1 $DEC --codec=av1 -o /dev/null mix_176x144_6.obu 2>&1 >/dev/null \
301+ | grep -c '^EC_SYMR' # 106606
302+# reads 0..25791 identical; ours 25792..25831 are the extra mi=(32,32) all_zero reads
303+```
\ No newline at end of file\ No newline at end of file
lanes/av1mixllfork.report.mdadded+360 -0
@@ -0,0 +1,360 @@
1+# 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)
2+
3+Base `main` = `32d944bf`. Worktree `/home/user/.cache/wt/av1mixllfork`, target dir
4+`$HOME/.cache/cargo-target-av1mixllfork`, `EC_NOMEMGUARD=1`. Oracle:
5+`~/.cache/aom-oracle/build/{aomdec,aomenc}` (shared, untouched). ffmpeg 8.1.3.
6+**This commit adds only this report. `git status --porcelain` is empty apart from
7+it, the tree is byte-identical to `32d944bf`, no probe bypass and no env-gated
8+trace is left behind.** The candidate fix was measured, shown to regress a larger
9+cell, and reverted — §4 has the numbers, §5 says what is still unknown.
10+
11+---
12+
13+## 0. Verdict
14+
15+| | |
16+|---|---|
17+| Fork reproduced | **yes** — read **30889** of f1, byte-identical to `lanes/av1framecount.report.md` §5 |
18+| Fork **shape** corrected | it is **not** a wrong-CDF-row fork (§2) |
19+| Owning block identified | **yes** — a sub-8 4x8/8x4 inter leaf's var-tx gate, `decode.rs:48259`; second site `decode.rs:27140` |
20+| Root cause named | libaom puts `!xd->lossless[mbmi->segment_id]` **in** the var-tx condition; ours put `lossless(fctx)` in the `else if` |
21+| Candidate fix | 2 lines; **green on 4 cells, REGRESSION on 2** → **reverted, unproven** |
22+| Regression | 640x480 4:2:0 8-bit mixed-lossless+altref goes **decode → `REFUSED: AV1 tile (a Golomb tail longer than this decoder reads)`** |
23+| Fixture / gate | **none committed** — a gate that asserts a cell the tree still fails is not landable |
24+| Class sweep | done on the **source** (9 var-tx call sites, 2 broken) and on **streams at base**; HBD not synthesized (§7) |
25+
26+## 1. Reproduction
27+
28+The encoder side reproduces **byte-exact** on the first try:
29+
30+```text
31+ffmpeg -f lavfi -i testsrc2=size=256x128:rate=25 -frames:v 5 -pix_fmt yuv420p src5b.y4m
32+aomenc --codec=av1 --obu -o c_mix5.obu --passes=1 --cpu-used=4 \
33+ --limit=5 --end-usage=q --cq-level=0 --aq-mode=1 src5b.y4m
34+```
35+
36+`c_mix5.obu` = **18 525 B**, sha256
37+**`3e06b5641e6a0f5a3f4ac8f114d4ee48c88638429e9eaafe6b4483e24f1dbc3a`** — the
38+sha the inherited report names. ffmpeg, rebuilt 2026-09-30, still picks the same
39+AQ decisions. Decode-order dumps vs the oracle at `32d944bf`:
40+
41+| frame | diff bytes (of 49 152) |
42+|---|---:|
43+| f0 (key) | 0 |
44+| f1 | **33 724** |
45+| f2 | **34 251** |
46+| f3 | **44 500** |
47+| f4 | **36 688** |
48+| f5 | **37 462** |
49+
50+## 2. Two corrections to the inherited frame
51+
52+### 2a. "The oracle makes no block origin at mi=(6,1)" is false
53+
54+Claimed by `lanes/av1framecount.report.md` §5 and relayed by the parent. The
55+oracle's own `EC_ECDUMP_IN` rung says otherwise:
56+
57+```text
58+EC_ECDUMP_IN plane=0 mi=(6,0) bc=0 br=0 tx=0 ctx=1 ECIN=(55806,57232,2608)
59+EC_ECDUMP_IN plane=0 mi=(6,0) bc=0 br=1 tx=0 ctx=3 ECIN=(8271,57096,2646)
60+EC_ECDUMP_IN plane=0 mi=(6,1) bc=0 br=0 tx=0 ctx=3 ECIN=(35995,39325,2653) <- the fork
61+EC_ECDUMP_IN plane=0 mi=(6,1) bc=0 br=1 tx=0 ctx=3 ECIN=(5855,55048,2690)
62+EC_ECDUMP_IN plane=1 mi=(6,1) bc=0 br=0 tx=0 ctx=8 ECIN=(11710,48168,2691)
63+EC_ECDUMP_IN plane=2 mi=(6,1) bc=0 br=0 tx=0 ctx=8 ECIN=(11129,49928,2749)
64+```
65+
66+The oracle has **two** TX_4X4 luma units at `mi=(6,1)` (`br=0`, `br=1`) plus one
67+chroma unit per plane — a 4x8 luma transform on a sub-8 leaf, the **lossless**
68+shape. It is **our** decoder that lacks that geometry. The "open geometry
69+question" is therefore not open: it is a *consequence* of the missing lossless
70+branch, and the sibling observation (odd-column origins appear in 7 other rows)
71+stays true.
72+
73+### 2b. It is not a wrong-`txs_ctx` / wrong-`txb_skip_ctx` fork
74+
75+The inherited report reads the `cdf0` difference as a context bug. Measured, the
76+`32768 - x` ICDF mirror between the two sides' `cdf0` **holds at every agreeing
77+read**, including the three immediately before the fork (`8580↔24188`,
78+`30886↔1882`, `16138↔1882`'s neighbour `16138↔16630`), and **breaks exactly at
79+the fork** (`15299` vs `22401`; `32768 - 15299 = 17469 ≠ 22401`).
80+
81+So the two sides are reading **different symbols**, not one symbol out of a
82+different row. A wrong `txs_ctx` or `txb_skip_ctx` can never produce that. The
83+read is one step out of sync with a symbol that libaom does not read at all.
84+
85+**How our read was identified** (this is the part that is easy to get wrong).
86+Our `EC_SYMR` prints no site, and `ph=` is **sticky** — it names whichever reader
87+last called `set_symr_phase`, so a coefficient read shows the enclosing block's
88+phase and a sub-8 read that never sets one inherits an older value. `mi=` is
89+likewise stale. I tagged every `intra_inter` / `new_mv` / `drl_mode` / `zero_mv` /
90+`ref_mv` / `obmc` / `switchable_interp` read with `set_symr_cdf` in **all four**
91+inter-mode-info copies, rebuilt, and re-ran:
92+
93+```text
94+read 30888 cdf=refmvB pre=(49935,53265,2668) cdf0=24188 n=2 s=0 post_rng=39325
95+read 30889 cdf= pre=(35995,39325,2668) cdf0=22401 n=2 s=0 post_rng=54010
96+```
97+
98+`refmvB` fired — the block is a sub-8 piece (`decode.rs:48185`) and `s=0` is
99+NEARESTMV on **both** sides (same `ref_mv` row, mirrored). Read 30889 carries
100+**no** tag, so it is none of the six inter mode-info reads; the one read a block
101+makes between its `ref_mv` and its coefficients is the var-tx tree's
102+`tx_size_cat1`. (Our `EC_ECDUMP_IN` also fires for every `read_coeffs` /
103+`read_coeffs_rect` call, and the fork's entry state `(35995, 39325, …)` is
104+absent from it — so the read is not a `txb_skip` at all.) The tags were
105+**reverted**; they are a finding, not an artefact.
106+
107+Oracle at the same index:
108+
109+```text
110+read 30888 site=decodemv.c:191 mi=(6,1) pre=(49935,53265,2653) cdf0=8580 n=2 s=0 post_rng=39325
111+read 30889 site=decodetxb.c:158 mi=(6,1) pre=(35995,39325,2653) cdf0=15299 n=2 s=0 post_rng=42076
112+read 30890 site=decodetxb.c:242 mi=(6,1) ... n=5
113+```
114+
115+libaom goes straight from `refmv` to the luma `txb_skip`. **It reads no
116+`tx_size` symbol at all.**
117+
118+## 3. Root cause
119+
120+`decodeframe.c:1237`, `parse_decode_block`:
121+
122+```c
123+if (cm->features.tx_mode == TX_MODE_SELECT && block_signals_txsize(bsize) &&
124+ !mbmi->skip_txfm && inter_block_tx && !xd->lossless[mbmi->segment_id]) {
125+ ... read_tx_size_vartx ...
126+} else {
127+ mbmi->tx_size = read_tx_size(xd, ...); // decodeframe.c:1208:
128+} // if (xd->lossless[seg]) return TX_4X4;
129+```
130+
131+`!xd->lossless[mbmi->segment_id]` is a **conjunct of the tree condition**, and
132+`read_tx_size` answers `TX_4X4` on the same flag. A lossless *segment* of a
133+mixed-lossless frame codes no `tx_size_cat1` symbol and lands on TX_4X4 per
134+plane.
135+
136+Ours, at `32d944bf` (`decode.rs:48231-48247`, the sub-8 4x8/8x4 inter leaf):
137+
138+```rust
139+if fctx.tx_select_inter.with(Cell::get) && !skip { // no lossless conjunct
140+ read_var_tx_size(..) // reads tx_size_cat1
141+} else if lossless(fctx) && !skip { // one branch too late
142+ for row in 0..bh / MI { for col in 0..bw / MI { leaves.push((row, col, MI, MI)); } }
143+```
144+
145+`lossless(fctx)` is already per-segment (`decode.rs:453-456`,
146+`lossless_per_seg[cur_segment_id]`), so it answers correctly — one branch too
147+late. Everything the tree reads after the spurious `tx_size_cat1` is then offset
148+by one symbol and the **next** block's `txb_skip` is the first visible fork.
149+That is exactly the reported signature: a correct pre-state, the same alphabet,
150+a different result.
151+
152+**Defect class, named:** *a per-segment flag consulted as a branch alternative
153+instead of as a conjunct of the condition it gates.*
154+
155+## 4. The candidate fix, and why it is reverted
156+
157+```diff
158+@@ decode.rs:27140 (intrabc 4x8 / 8x4 rect leaf)
159+- if tx_select && !skip {
160++ if tx_select && !skip && !lossless(fctx) {
161+@@ decode.rs:48259 (sub-8 4x8 / 8x4 inter leaf)
162+- if fctx.tx_select_inter.with(Cell::get) && !skip {
163++ if fctx.tx_select_inter.with(Cell::get) && !skip && !lossless(fctx) {
164+```
165+
166+plus a `SUB8_LOSSLESS_NO_VARTX` route counter for non-vacuity. It was committed
167+as `658d37fa` and **then reverted** (`git reset --hard 32d944bf`).
168+
169+**Green** (measured on `658d37fa`):
170+
171+| cell | at base | with the fix |
172+|---|---|---|
173+| `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** |
174+| `s_arf8` 256x128 `--limit=8` | RED f1–f5 | **6/6** |
175+| `s444_8` **4:4:4** `--profile=1 --limit=8` | **RED f1–f8** | **9/9** |
176+| `s176` 176x144 `--limit=6` | `REFUSED` | 7/7 dumps, refusal removed (still red — see §6) |
177+| `s352` 352x288 `--limit=6` | `REFUSED` | 7/7 **exact** (per lane-av1golomb320) |
178+
179+Mutation proof on the pinned fixture, fix surgically reverted from the working
180+tree, gate run:
181+
182+```text
183+test stream::tests::a_420_mixed_lossless_alt_ref_sub8_vartx_witness_... ... FAILED
184+panicked at crates/ec-av1/src/stream.rs:10935:17:
185+...: decode-order frame 1 of 6 (5 shown, 1 hidden) differs from the oracle at
186+byte 33 (ours 82 vs 81), 33724 bytes differ
187+test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 802 filtered out
188+```
189+
190+**33 724 — the same number as the hand-measured red.**
191+
192+**Regression** (found by lane-av1golomb320, reproduced and confirmed here):
193+
194+```text
195+cell: testsrc2 640x480, 6 frames, --passes=1 --cpu-used=4 --limit=6 \
196+ --end-usage=q --cq-level=0 --aq-mode=1 -> 115615 B
197+
198+ 32d944bf (base) : OK: 6 frames decoded, 640x480
199+ 658d37fa (fix) : REFUSED: unsupported: AV1 tile (a Golomb tail longer than this decoder reads)
200+```
201+
202+`--limit=5` (87 537 B) behaves identically (base decodes 5, fix refuses). I
203+isolated which of the two hunks does it: reverting **only** `27140` and keeping
204+`48259` still refuses, so the regression comes from the **sub-8 inter** hunk.
205+Locating it, the first divergence on `m640_6` with the fix is at read **184 328**,
206+where the oracle reads `decodeframe.c:1186` — the `txfm_partition` split inside
207+`read_tx_size_vartx` — and we read a different `n=2` symbol from the identical
208+pre-state `(30248, 45616)`:
209+
210+```text
211+ORC 184328 decodeframe.c:1186 mi=(91,106) pre=(30248,45616) n=2 s=0 post_rng=62032
212+OUR 184328 (untagged) mi=(88,108) pre=(30248,45616) n=2 s=0 post_rng=58828
213+```
214+
215+and the oracle's `EC_ECDUMP_IN` for that block is a single `tx=0` (TX_4X4) luma
216+unit at `mi=(91,106)`. So at that leaf the oracle **does** walk the var-tx tree
217+and does **not** consider its segment lossless, while our `lossless(fctx)`
218+returned true and suppressed the tree. Instrumenting the gate
219+(`EC_MIXLLDBG`, since removed) shows the flag is genuinely reporting `true` on
220+many sub-8 leaves of this stream (145 of 160 leaves), with `cur_segment_id`
221+values 0, 1, 4 and 5 in play.
222+
223+**Conclusion:** the ordering defect is real and the fix is right *at the leaf*,
224+but our per-segment lossless answer is **wrong somewhere in the 640x480 stream**
225+— over-reporting on a block whose segment libaom treats as lossy. Adding the
226+conjunct therefore converts one wrong-symbol fork into a *missing*-symbol fork on
227+that cell. Per the lane contract ("a change you cannot make red first is not a
228+fix — report it as unproven instead") and because a decode → refusal flip is a
229+refusal-inventory regression in its own right, the change is **reverted and no
230+fixture or gate is committed**: a gate asserting a cell the tree still fails is
231+not landable.
232+
233+## 5. Class sweep (on the reverted tree, i.e. at `32d944bf`)
234+
235+**(a) Source — every var-tx gate, re-derived against libaom's own `if`.**
236+`read_var_tx_size` has 9 call sites:
237+
238+| site | shape | verdict |
239+|---|---|---|
240+| `decode.rs:18229` | `if skip \|\| (!lossless && !tx_select) … else if lossless` | lossless first — **correct** |
241+| `decode.rs:21973` | `… && tx_select && !skip && !lossless(fctx)` | conjunct — **correct** |
242+| `decode.rs:23868` | `… && !skip && !lossless(fctx)` | conjunct — **correct** |
243+| `decode.rs:14042`, `15504`, `16143`, `16709`, `18720`, `19697` | `tx_select && !lossless(fctx)` | conjunct — **correct** |
244+| `decode.rs:29708` (`read_block_tx_size`) | `if lossless(fctx) { … return }` before the tree | early return — **correct** |
245+| `decode.rs:30235` (`read_block_tx_size_rect`) | same early return | early return — **correct** |
246+| **`decode.rs:27140`** (intrabc 4x8/8x4 rect) | `tx_select && !skip` … `else if lossless && !skip` | **this class** |
247+| **`decode.rs:48231`** (sub-8 4x8/8x4 inter) | `tx_select_inter && !skip` … `else if lossless && !skip` | **this class** |
248+
249+The other six `else if lossless(fctx)` sites (`12790`, `25689`, `42365`,
250+`44172`, `48549`, `18186`) are **chroma unit-grid** selection, not var-tx symbol
251+reads — a different concern, not this class. **Exactly 2 sites.**
252+
253+**(b) Streams — at base, so the numbers are the tree's real state.** All arms
254+`testsrc2`, `--passes=1 --cpu-used=4 --end-usage=q`, decode-order dumps vs the
255+oracle:
256+
257+| cell | flags | base |
258+|---|---|---|
259+| `c_mix5` | `--limit=5 --cq-level=0 --aq-mode=1` | RED f1–f5 |
260+| `s_arf8` | `--limit=8 --cq-level=0 --aq-mode=1` | RED f1–f5 |
261+| `s444_8` | `--profile=1` (4:4:4) `--limit=8 --cq-level=0 --aq-mode=1` | RED f1–f8 |
262+| `s_noarf5` | `--auto-alt-ref=0 --cq-level=0 --aq-mode=1` | 5/5 exact |
263+| `s_cq20` | `--cq-level=20 --aq-mode=1` | 6/6 exact |
264+| `s_ll` | `--lossless=1` | 6/6 exact |
265+| `s_aq0` | `--cq-level=0 --aq-mode=0` | 6/6 exact |
266+| `s176` | 176x144 `--limit=6` | **REFUSED** |
267+| `m640_5` / `m640_6` | 640x480 `--limit=5` / `--limit=6` | decodes (redness not measured) |
268+
269+The four exact arms confirm the trigger really is the conjunction (per-segment
270+mixed lossless **and** an alt-ref structure) the inherited report described.
271+
272+## 6. Not this lane's defect
273+
274+* **Agent02-3's `mi=(32,32)` fork at read 25792** on the 176x144 cell is a
275+ **separate** extra-geometry defect. Measured here on both sides of my change:
276+ the first divergence is **25792 with and without the fix**, so the two-line
277+ ordering change does not move it at all. Handed to lane-av1golomb320.
278+* The 320x240 Golomb-tail refusal of the same recipe was not reproduced here.
279+
280+## 7. What is NOT measured
281+
282+* **The next step is not taken, and it is the whole remaining question:** *why
283+ does `lossless(fctx)` return true on a 640x480 sub-8 leaf whose segment libaom
284+ treats as lossy?* Two candidates, neither tested: `fctx.cur_segment_id` is
285+ stale at some sub-8 leaf (`inter_segment_id` is called per piece at
286+ `decode.rs:48026` / `46262`, and the sub-8 reader has its own skip-then-
287+ segment order), or `lossless_per_seg` itself is wrong for some segment. The
288+ instrumentation that would settle it is one env-gated line at
289+ `decode.rs:48231` printing `(rmi, cmi, cur_segment_id, lossless)`, paired with
290+ the oracle's `EC_ECDUMP_IN` for the same `mi`. **I ran that instrumentation and
291+ it shows the flag is true (145/160 leaves) but I did not finish the pairing,
292+ so I cannot say which candidate it is.**
293+* **10/12-bit arms: NOT synthesized.** This ffmpeg (8.1.3) cannot emit a
294+ >8-bit y4m at all — `Conversion failed!` for `yuv420p10le`, `yuv420p12le`,
295+ `yuv444p10le` and `gray10le`, from both a lavfi source and a y4m input — and a
296+ hand-built 16-bit-LE y4m is rejected by the shared `aomenc` with
297+ `Loss of framing in Y4M input data` (0-byte output). The committed HBD corpus
298+ is covered by the scoped regression, but that is a **regression, not a sweep of
299+ this class at HBD**, and I do not claim it as one.
300+* Whether the 640x480 base decode is red or exact — I measured that it *decodes*,
301+ not that it is correct.
302+* `mixll` is content-dependent. I re-measured only `testsrc2` at 256x128, plus
303+ the 4:4:4 256x128, 176x144, 352x288 and 640x480 arms; I did **not** re-run the
304+ inherited report's three-generator x three-size matrix.
305+* Pre-fix, f1 is wrong from pixel 0 at whole-frame scale. I did not bisect which
306+ reconstruction stage first diverges: with the entropy ladder bit-identical end
307+ to end under the candidate fix, the parse was the whole story.
308+
309+## 8. Regression
310+
311+Exact command, run in the lane worktree on the reverted tree:
312+
313+```text
314+CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1mixllfork EC_NOMEMGUARD=1 \
315+ cargo test -p ec-av1 --lib -- 420 444 422 lossless stream \
316+ --skip bitrate_target_lands_within_5_percent_over_48_frames
317+```
318+
319+```text
320+test result: ok. 373 passed; 0 failed; 7 ignored; 0 measured; 422 filtered out;
321+ finished in 1623.93s
322+```
323+
324+**373 / 0 / 7 / 422 — the identical numbers `lanes/av1framecount.report.md` §6
325+records**, which is the expected result for a report-only change: this tree
326+carries no source delta from `32d944bf`. It is a no-delta confirmation, not
327+evidence for any fix, because there is no fix in the tree.
328+
329+This is the inherited report's scope, so the two are comparable: the 4:2:0,
330+4:4:4 and 4:2:2 fixtures, the lossless cells, the sub-8 and inter chroma
331+identity gates, and the whole `stream` module where the oracle-compared fixture
332+gates live.
333+
334+**The coverage hole this run exposes.** I ran the same command on the candidate
335+fix `658d37fa` before reverting it: **236 tests, 0 failures, still running** when
336+I terminated it — and it never went red, while that commit turns 640x480 from
337+decoding into a `REFUSED`. **The suite contains no 640x480-class cell**, so a
338+refusal-inventory regression of exactly this kind is invisible to it. Any lane
339+that lands a mixed-lossless + altref change needs a >= 640x480 cell of that
340+recipe in `fixtures/`, or the green run is not evidence.
341+
342+## 9. Fix-now | deferred(<unblock>) | accepted
343+
344+* **fix-now** — nothing in the tree. The change is reverted; this commit is the
345+ report alone.
346+* **deferred(identify whether `fctx.cur_segment_id` is stale at the sub-8 leaf,
347+ or `lossless_per_seg` is wrong, on a 640x480 mixed-lossless+altref cell)** —
348+ the whole remaining fix. §7 names the one env-gated line that settles it and
349+ the oracle rung to pair it with. Until that is answered, adding
350+ `&& !lossless(fctx)` trades one fork for another.
351+* **deferred(a >8-bit y4m source, or a hand-built one the shared `aomenc`
352+ accepts)** — the HBD arm of the class sweep, §7.
353+* **deferred(a separate lane)** — the `mi=(32,32)` extra-geometry fork at read
354+ 25792 and the 320x240 Golomb-tail refusal. §6.
355+* **accepted** — the diagnostic `set_symr_cdf` tags and the `EC_MIXLLDBG` print.
356+ Both identified the reads and both are reverted; the permanent artefacts are
357+ this report and the measurements in it. If a future lane needs to name an
358+ untagged inter read again: `refmvB`-style tags at all **four**
359+ inter-mode-info copies are the lines to re-add, and `ph=`/`mi=` must not be
360+ trusted to do it.