forge
Explore
Log in

Don't you dare go Hollow

Merge lane/av1422ibcrect: the unwitnessed 64-root chroma gather is entered and inert

Browse files at this commit

12fd6d300d5ee8560a72e25bf7402d13f91a2fd3Ahmet Kaan GümüşParent: 3973273b1b8a39
decode_intrabc_owned_rect's non-split chroma gather is reachable at 4:2:2 on
a 64x32 strip, not a 128-root. A 384x288 frame forces the last superblock
row to code HORZ as one bit. That stream enters the arm 24 times and is
byte-exact vs ffmpeg. The square gather doubles the vote magnitude, and
dc_sign_ctx is a signum, so the row does not move (0 of 24). An inverted
vote moves 24 of 24, so the zero is a measurement. The census's cited
branch needs TX_MODE_SELECT leaves; this witness is TX_MODE_LARGEST and
hits the leaves==None twin. No decode change. The stream is reproducible
from the recipe and sha in the report; it is not pinned.
lanes/av1422ibcrect.report.mdadded+234 -0
@@ -0,0 +1,234 @@
1+# lane-av1422ibcrect — the non-split chroma gather of `decode_intrabc_owned_rect` is
2+# WITNESSED at ss (1, 0): a 4:2:2 64x32 intraBC strip enters it, 24 times, byte-exact
3+
4+Base `main` = `5824d7ce` (branch `lane/av1422ibcrect`, worktree
5+`~/.cache/wt/av1422ibcrect`). Local only, no push, no merge, no source change.
6+
7+`lanes/av1422gathercensus.report.md` closed the ss (1, 0) chroma-gather
8+enumeration with one row left **STOP — unwitnessed**: `decode_intrabc_owned_rect`
9+(`decode.rs:18022/18061` at that report's main), reached 0 times by any committed
10+4:2:2 cell. This lane asked the complementary question — can a stream be *made*
11+to enter it, and what happens when it does — and answered it with four aomenc
12+encodes.
13+
14+## Verdict
15+
16+**entered, 24 entries, 0 divergences.** One of the four streams (recipe A1)
17+enters the non-split chroma arm of `decode_intrabc_owned_rect` at ss (1, 0)
18+**24 times** (6 strips x 4 frames) with `bw=64 bh=32 cw=32 ch=32 skip=false`,
19+and decodes **byte-exact against ffmpeg on all four frames**. No first wrong
20+sample exists to name on this stream, and the reason is measured, not assumed
21+(section 4): on every one of the 24 entries the luma-span gather and the pair
22+rule produce the **same `dc_sign_ctx`**.
23+
24+This is neither of the ticket's two nominal verdicts (`entered, first sample
25+named` / `4 attempts, 0 entries`) — the site is *entered* and *inert*. Both
26+halves are measurements; section 5 records the second finding the entry
27+produced (the census's named site is the *other* branch of the same `if`, and
28+that branch is structurally out of reach under `TX_MODE_LARGEST`).
29+
30+## 1. Entry condition, and the frame shape that reaches the non-split arm
31+
32+`decode_intrabc_owned_rect` has exactly one caller — `decode_block_rect64`
33+(`decode.rs:20076`), itself called only from the superblock-level partition
34+dispatch at the 64 root (`decode.rs:38506`, `38530`, `38552`, `38576`, `38649`,
35+`38724`). The non-split chroma gather sits in the `else` of
36+`if cw.min(32) != cw || ch.min(32) != ch` — in **both** of that block's residual
37+branches (the `leaves.is_some()` one and its `leaves == None` twin, section 5).
38+The condition is
39+
40+ cw = bw >> ss_x(fctx) <= 32 AND ch = bh >> ss_y(fctx) <= 32
41+
42+with `leaves.is_some()` (non-lossless) and `skip == false`. At ss (1, 0) that is
43+`bw <= 64 && bh <= 32`; `decode_block_rect64`'s only such shapes are **64x32**
44+(`PARTITION_HORZ`, and the 64x32 strip of `HORZ_A`/`HORZ_B`) and **64x16**
45+(`PARTITION_HORZ_4`). A 32x64 / 16x64 strip gives `ch = 64 > 32` and takes the
46+split arm; a 128-root strip never reaches this function at all (it goes to
47+`decode_block_128rect`).
48+
49+So the frame shape is: **4:2:2, `--sb-size=64`, a 64x32 intraBC (screen-content,
50+`use_intrabc` on) HORZ strip, lossy, not all-zero residual** — the shape the
51+committed 4:2:2 corpus does not code. The cheapest way to force the 64x32 HORZ
52+at the 64 root is the frame edge: a frame whose last superblock row has only its
53+top 32 rows coded has `has_rows == false`, and the 64-root partition is then a
54+single gathered bit (HORZ or SPLIT) — no alphabet symbol (`decode.rs:36997-37045`).
55+Recipe A1 below is exactly that: 384x288 = 4x64 + 32.
56+
57+## 2. The four recipes (aomenc count: 4, all <= 180 s)
58+
59+Common flags (all four): `--codec=av1 --i422 --profile=2 --passes=1 --end-usage=q
60+--cpu-used=0 --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=1
61+--tile-columns=0 --sb-size=64 --min-partition-size=32 --max-partition-size=64
62+--enable-rect-partitions=1 --enable-ab-partitions=1 --enable-1to4-partitions=0
63+--enable-palette=0 --tune-content=screen --enable-intrabc=1 --deltaq-mode=0
64+--enable-tx-size-search=1 --obu`.
65+
66+| id | source (ffmpeg lavfi) | cq | limit | obu bytes | sha256 |
67+|---|---|---|---|---|---|
68+| **A1** | `nullsrc=size=384x288:rate=25,format=yuv420p,geq=lum='128+90*sin((X+2*N)/37)+30*sin(Y/29)':cb='128+30*sin(X/23)':cr='128+30*sin((Y+N)/19)'` -> `-pix_fmt yuv422p` | 32 | 4 | 1244 | `fd36bae423dab071c6cc964d954003a75f80c8c4cf96680181ada8c773b397db` |
69+| A2 | same content as A1 | 6 | 4 | 4567 | `1a165ef9d3d040a5ed29bd2cf41a16178f6cdd44dfff1b5f5596cb993118953b` |
70+| A3 | `geq=lum='128+90*sin((X+2*N)/37)+30*sin(Y/29)':cb='128+70*sin(X/5)':cr='128+70*sin(X/3+2*N)'` at 384x288 | 32 | 4 | 1516 | `1fcb27bb133310fb93164275a11c38a70ca3ce2a518f09deb9e21022e1c75176` |
71+| A4 | `testsrc2=size=128x112:rate=25` + `-vf tile=2x2` = 256x224 | 30 | 3 | 30937 | `e680b6386a8a3a961f45424dfe7a8b7faa0e43789cce38eb92f4264af20e036e` |
72+
73+A1 is the 4:2:2 re-cut of `lane-av1ibc128chunk`'s `geq` sb128 intrabc recipe
74+(`lanes/av1ibc128chunk.report.md`), at `--sb-size=64` and a frame height that
75+puts the last superblock row half outside the frame. A3 changed only the chroma
76+frequencies (aimed at a sign-flipping above context); A4 is the ordinary
77+screen-content `testsrc2` tile recipe. Every encode finished in under 0.6 s.
78+
79+## 3. Result per stream
80+
81+Probe: a temporary env-gated `eprintln!` (`EC_IBCNS422`) at the first statement
82+of each non-split chroma arm, plus the pre-existing `EC_HALVSWEEP` at function
83+entry. Both were removed before commit (`git diff` on `decode.rs` is empty).
84+
85+| id | `EC_HALVSWEEP` (function entries) | non-split chroma arm entries | decode | vs ffmpeg (yuv422p rawvideo) |
86+|---|---|---|---|---|
87+| **A1** | **24** (6/frame x 4) | **24** — all `bw=64 bh=32 cw=32 ch=32 ss=(1,0) skip=false` | 4/4 frames | **byte-exact, 4/4** (`cmp` per frame) |
88+| A2 | 3 | 3 | **REFUSED** mid-tile | n/a (no complete output) |
89+| A3 | 0 | 0 | 4/4 frames | (not compared — no entry, out of this lane's scope) |
90+| A4 | 0 | 0 | **REFUSED** mid-tile | n/a |
91+
92+A2 and A4 both stop at the same pre-existing refusal, unrelated to this site:
93+`a block size 4x8, 8x16 or 16x4 ... has no chroma plane block at this frame's
94+subsampling mode` (the documented libaom `decodeframe.c:1456` rule). A2 entered
95+the site 3 times before the refusal; its output is incomplete, so it is not
96+offered as a pixel witness. A3's higher-frequency chroma moved the encoder off
97+`use_intrabc` on the edge strip entirely.
98+
99+A1 detail: `SEQ: use_128x128_superblock=false ... max_frame=384x288`; entries at
100+`mi=(64,0) (64,16) (64,32) (64,48) (64,64) (64,80)` — mi row 64 = pixel row 256,
101+the half-coded last superblock row — repeated on all four frames.
102+
103+## 4. Why A1 is byte-exact (measured, not inferred)
104+
105+The arm computes `around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh)` —
106+the block's **luma** span (64x32 px = 16x8 mi) — and hands `around[1]`,
107+`around[2]` to `read_inter_plane_rect` for planes 1 and 2, whose coefficient
108+context is `dc_sign_ctx(around[plane].2)` (`decode.rs:8254`: the plain
109+`signum` of the summed above+left dc votes). The pair rule
110+(`around_mi_422_chroma`, `decode.rs:10555`) samples every second above cell,
111+which is libaom's one-vote-per-chroma-4px-cell sum.
112+
113+The probe therefore computed **both** gathers at every entry and printed the
114+votes, the `coded` OR-bits, and both `dc_sign_ctx` values:
115+
116+| quantity over the 24 A1 entries | result |
117+|---|---|
118+| `dc_sign_ctx(full) != dc_sign_ctx(pair rule)` | **0 of 24** |
119+| `coded(full) != coded(pair rule)` | **0 of 24** |
120+| votes | mixed: `V full=-16 sampled=-8 ctx=1/1`, `V full=8 sampled=8 ctx=2/2`, `U 0/0` |
121+
122+So the double count is real and visible in the magnitudes (the 16-cell sum is
123+twice the 8-cell sum where the extra cells are coded) but it never changes the
124+**sign**, and `dc_sign_ctx` is a sign — hence no symbol, no bitstream position,
125+no pixel differs on this stream. That is the whole reason A1 is exact.
126+
127+Comparator liveness: the same print, fed a deliberately inverted vote
128+(`dc_sign_ctx(-vote)`), reports a difference on **24 of 24** entries — the zero
129+above is a measurement on this stream, not a print that cannot move. (A
130+narrower-span control, `around_mi_rect(bw/2)`, also read 0/24: on this stream
131+all above votes share one sign, so no sub-span keeps or loses a sign either.)
132+
133+Scan of the cache, for context: **366** cached 4:2:2 `.obu` files
134+(`~/.cache/census422b`, `~/.cache/cells`, `~/.cache/lane-av1422ctintrabc`,
135+`~/.cache/av1muchunk422b`, `~/.cache/av1422sb128wit`, `~/.cache/av1422lrless`,
136+`~/.cache/av1422warp`, `~/.cache/av1422grain`) were decoded with the same probe:
137+**0 of them enters this site at all**. A1 is the only stream anyone has measured
138+in it.
139+
140+## 5. Second finding: the census's cited pair is the *other* branch
141+
142+The census's table row cites `decode.rs:18022/18061` at its base `2ca9e4e9`,
143+which on **this** base (the census's own 15-line comment sits above them) are the
144+pair inside `else if let Some(ls) = leaves.as_ref()` — the var-tx-tree branch:
145+`around_mi_rect` at **18037**, feeding `read_inter_plane_rect` plane 1 at
146+**18045** and plane 2 at **18062**.
147+
148+The branch A1 enters is the twin in the `else` of the *same* `if cw.min(32) != cw
149+|| ch.min(32) != ch`, i.e. the branch taken when `read_block_tx_size_rect`
150+returned `None` (one transform unit, no var-tx tree): `around_mi_rect` (luma) at
151+**18076**, chroma gathers at **18125 (plane 1)** and **18142 (plane 2)**. Both
152+branches make the identical call — the whole block's luma span
153+`around_mi_rect((mi_r, mi_c), bw, bh)` into `read_inter_plane_rect` planes 1/2 —
154+so this is the same defect class. The census's §"The one remaining site" prose
155+describes the `leaves.is_none()` condition (the twin), while its table row cites
156+the tree branch's lines; the two call sites are distinct and only the no-leaves
157+one is entered by any stream measured here.
158+
159+Measured on A1: the tree branch (its own probe line) fired **0 times**, because
160+`read_block_tx_size_rect` returns `Ok(None)` before it can return leaves whenever
161+the frame is not `TX_MODE_SELECT` (`decode.rs:31847-31855`), and A1's frames are
162+`txsel=false` (`TX_MODE_LARGEST`) — the probe printed `txsel=false` on all 24
163+entries. Under `TX_MODE_LARGEST` a <=64 block can never produce `leaves`, so:
164+
165+* for a 64-root 64x32 strip, the reachable non-split chroma gather is the
166+ **no-leaves twin** (`18076`/`18125`/`18142`), which A1 enters;
167+* the tree-branch pair additionally requires `TX_MODE_SELECT` plus a
168+ `txfm_partition` split on the strip — a conjunction no measured stream has
169+ produced. (A 128-root strip *does* get `leaves` under `TX_MODE_LARGEST`, from
170+ the `bw.max(bh) > 64` arm at `decode.rs:31812`, which is why the r512 4:4:4
171+ evidence in the census is about the tree branch at another root.)
172+
173+## 6. Disposition
174+
175+* **Entered, inert on the only witness.** The site is no longer unwitnessed;
176+ it is entered at ss (1, 0) by a real aomenc 4:2:2 stream and that stream is
177+ byte-exact. No source change is made (the ticket forbids fixing here, and the
178+ one stream that enters the site gives no evidence a fix would be
179+ discriminated by it: 0/24 context differences, 0 coded-bit differences).
180+* **Not a "0 entries" verdict.** The ticket's second nominal verdict does not
181+ apply — A1 enters 24 times.
182+* **Do not re-derive from this that the class is harmless.** A1's neighbours
183+ happen to keep every vote's sign. The class is real where the sign flips
184+ (that is how the sibling sites were found); this lane only shows this *one
185+ 64x32-edge-strip* stream does not flip it.
186+* **The twin call sites (`18076`/`18125`/`18142`) are the ones a future 64-root
187+ witness enters**; the census's cited `18022/18061` pair (this base:
188+ `18037`/`18045`/`18062`) needs `TX_MODE_SELECT`.
189+* No fixture is committed. The witness is reproducible from the A1 recipe and
190+ its sha256 in section 2 without adding a file the fixture-library manifest
191+ (`scripts/fixture-library.tsv`) does not know about.
192+* `decode.rs` at this lane's tip is identical to `5824d7ce` (`git diff` empty);
193+ the only commit is this report.
194+
195+## 7. Repro
196+
197+```text
198+git worktree add -b lane/av1422ibcrect ~/.cache/wt/av1422ibcrect 5824d7ce
199+cd ~/.cache/wt/av1422ibcrect
200+# re-add the env-gated probe at decode.rs:18126 (print `around` vs
201+# `neighbours.around_mi_422_chroma((mi_r, mi_c), bw, bh)` under EC_IBCNS422)
202+CARGO_TARGET_DIR=~/.cache/tgt-av1422ibcrect cargo build -p ec-av1 --example decode_probe
203+
204+# A1 content + encode (the recipe in section 2; aomenc = ~/.cache/aom-oracle/build/aomenc)
205+ffmpeg -v error -f lavfi -i "nullsrc=size=384x288:rate=25,format=yuv420p,\
206+ geq=lum='128+90*sin((X+2*N)/37)+30*sin(Y/29)':cb='128+30*sin(X/23)':\
207+ cr='128+30*sin((Y+N)/19)'" -frames:v 4 -pix_fmt yuv422p -strict -1 \
208+ -f yuv4mpegpipe -y A1.y4m
209+aomenc <section 2 common flags> --cq-level=32 --limit=4 --obu -o A1.obu A1.y4m
210+sha256sum A1.obu # fd36bae423dab071c6cc964d954003a75f80c8c4cf96680181ada8c773b397db
211+
212+EC_IBCNS422=1 EC_HALVSWEEP=1 ~/.cache/tgt-av1422ibcrect/debug/examples/decode_probe A1.obu
213+# 24x EC_HALV ibc_owned ... bw=64 bh=32 skip=false
214+# 24x EC_IBCNS422 (no-leaves) ... ss=(1,0) skip=false txsel=false | ... ctx=N/N
215+
216+# byte-exactness, display order, 4 frames
217+dump_yuv A1.obu ours
218+ffmpeg -v error -i A1.obu -pix_fmt yuv422p -f rawvideo ref.yuv
219+# 4 x 221184 B per frame, cmp each -> identical (evidence in section 3)
220+```
221+
222+## 8. Evidence summary
223+
224+| item | value |
225+|---|---|
226+| aomenc encodes attempted | 4 (A1 cq32 / A2 cq6 / A3 high-chroma cq32 / A4 testsrc2, all <=0.6 s) |
227+| streams entering the site | 1 (A1: 24 entries) |
228+| non-split chroma arm entries, A1 | 24 of 24 with `bw=64 bh=32 cw=32 ch=32 ss=(1,0) skip=false txsel=false` |
229+| tree-branch (census's `18022/18061`) entries | 0 (A1 is `TX_MODE_LARGEST`) |
230+| A1 vs ffmpeg | byte-exact, 4/4 frames (`cmp`, 221184 B/frame) |
231+| context differences (full vs pair rule), A1 | 0/24 `dc_sign_ctx`, 0/24 `coded` |
232+| comparator control (inverted vote) | moves 24/24 |
233+| cached 4:2:2 streams scanned | 366, 0 entries |
234+| source changes | none (`decode.rs` == `5824d7ce`) |