forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1422remeasure: the 4:2:2 refusal is no longer a correctness guard (18/18 reachable cells byte-exact, report only)

Browse files at this commit

59edf7ddf62cb7837b93659a30422e515a362196Ahmet Kaan GümüşParent: 73a4a77cc6c623
Re-measured on main after lane-av1422warp (ebeac9c7) landed: every reachable 4:2:2 cell -- 6
already-committed pins plus freshly encoded testsrc2/mandelbrot cells at cpu-used 0 and 6 -- decodes
BYTE-EXACT against the instrumented aomdec, 0 wrong samples on any plane of any frame (up to 16/16
frames exact, 614400 samples). The recorded blocker (the dc-sign rect-path desync) is fixed and no
longer load-bearing. Recommendation: the refusal is not earning its keep as a correctness guard;
keep it only as a named-cell guard for 12-bit 4:2:2, which the local aomenc cannot produce. The
sequence-header refusal itself is NOT changed here -- that is a shipped-capability call. No source
change: git diff main..HEAD -- crates/ is empty, and the EC_AV1_ALLOW_422_PROBE bypass was
patch-run-restored, in no commit.
lanes/av1422remeasure.report.mdadded+328 -0
@@ -0,0 +1,328 @@
1+# lane-av1422remeasure — the 4:2:2 capability gap, re-measured on `6d564cd6`
2+
3+Base `6d564cd6`, worktree `~/.cache/wt/av1422remeasure`, branch
4+`lane-av1422remeasure`. Report-only: **no source change is committed**, and the
5+`EC_AV1_ALLOW_422_PROBE` bypass was patch-run-restore and is **not** in any
6+commit. Every number below was measured on `6d564cd6`, as chartered.
7+
8+**Main moved under the lane** (two commits, `lane-av1odd440` → `0ea32904`,
9+merged in after the measurements). It does not disturb any conclusion: the
10+4:2:2 guard is the same single `subsampling_x != subsampling_y` test on the
11+same line, with only the message extended to also name 4:4:0 as uncodable, and
12+`440_request_is_422.obu` is a hand-built header probe, not a decodable cell.
13+Re-verified on the merged tip: the four committed 4:2:2 refusal-by-name gates,
14+`a_non_420_subsampled_sequence_header_is_refused_by_name`,
15+`decode::tests::a_422_reference_claims_the_full_chroma_height` and
16+`decode::chroma422_pair_plane_matches_the_ss_size_lookup_cells` — **7 passed /
17+0 failed**.
18+
19+## Verdict
20+
21+**The debt's blocker line is stale twice over, and the refusal is no longer
22+earning its keep as a correctness guard.**
23+
24+1. The named blocker — "the dc-sign vote on the rect path taking luma-unit
25+ neighbour counts" — **is fixed on main and is now non-load-bearing**. It is
26+ present, it is reached, and with it surgically reverted the pinned stream is
27+ *still* 16/16 pixel-exact. See "The dc-sign symptom".
28+2. **Every 4:2:2 cell I could reach decodes byte-exact against the instrumented
29+ `aomdec`**: 6 committed fixtures + 12 freshly encoded ones = **18 cells,
30+ 18/18 exact, 0 wrong samples on Y, U and V, every frame, no panic, no
31+ desync.** That includes two axes the committed corpus had never touched —
32+ **10-bit 4:2:2** and **odd width (322x242) 4:2:2** — plus a second
33+ independent encoder recipe, which was the other standing lift objection.
34+
35+Recommendation, at the end, is therefore **lift the blanket refusal and replace
36+it with a named-cell refusal for the one shape still unreached (12-bit 4:2:2,
37+which the local `aomenc` cannot even produce)** — with the one caveat and the
38+one named anomaly stated in full.
39+
40+## Method
41+
42+Two independent comparisons, both against
43+`$HOME/.cache/aom-oracle/build/aomdec` (the Sep 29 05:44 instrumented build):
44+
45+- **presented output** — `decode_stream` → `pack_rawvideo` (the committed
46+ `assert_rawvideo_matches` helper's own packing) vs `aomdec --rawvideo`,
47+ counting wrong samples **per plane** rather than panicking on the first
48+ mismatch, so one run classifies every cell.
49+- **decode-order output** — `EC_AV1_FINAL_DUMP` on both sides (ours inside
50+ `decode_frame`, the oracle's rung 12), compared frame by frame. This is the
51+ only view that sees hidden alt-ref frames, which `decode_stream` never
52+ returns.
53+
54+**Oracle soundness established first**, per the standing rule, on the clean
55+tree with no 4:2:2 bypass in play:
56+`a_real_aomenc_quantisation_matrix_stream_decodes_pixel_exact`,
57+`the_rawvideo_helper_compares_real_samples_at_the_streams_own_bit_depth` and
58+`a_non_420_subsampled_sequence_header_is_refused_by_name` — **3 passed**.
59+
60+## The per-cell table
61+
62+Classification is four-way: **REFUSED** (sequence header), **PANIC**,
63+**DIVERGES**, **EXACT**. "wrong" is per-plane differing samples over all
64+decoded frames. Every cell below REFUSES on committed `6d564cd6`; the decode
65+columns are measured under the local bypass.
66+
67+### Committed fixtures (pinned on main)
68+
69+| cell | bytes | sha256 (first 16) | fnv1a64 | class | wrong Y | wrong U | wrong V | frames exact |
70+|---|---|---|---|---|---|---|---|---|
71+| `422_allskip_2f.obu` | 62 | `ba4932c14f959 71b` | `0x7e4d69d3c728c55f` | REFUSED → EXACT | 0/32768 | 0/16384 | 0/16384 | 2/2 |
72+| `422_sb128_3f.obu` | 12543 | `0b851799d99cb4d1` | `0x5171e0aab8000da7` | REFUSED → EXACT | 0/49152 | 0/24576 | 0/24576 | 3/3 |
73+| `422_intrabc_sb128_strip.obu` | 1672 | `f92000db86df7acc` | `0x50f5cfc576e4cd00` | REFUSED → EXACT | 0/614400 | 0/307200 | 0/307200 | 5/5 |
74+| `422_intrabc_sb128_strip_notxsearch.obu` | 1675 | `80dd0d4e93fd6c3d` | `0xd4936f252ff8cff0` | REFUSED → EXACT | 0/614400 | 0/307200 | 0/307200 | 5/5 |
75+| `422_residual_compound_warp_16f.obu` | 38845 | `d78e2afb43ce311d` | `0x0e73a51e2cc0c424` | REFUSED → EXACT | 0/1179648 | 0/589824 | 0/589824 | 16/16 |
76+| `422_residual_compound_warp_nolr_16f.obu` | 38538 | `8bed368f7ec4bca7` | `0x4b8ff761701e2bef` | REFUSED → EXACT | 0/1179648 | 0/589824 | 0/589824 | 16/16 |
77+
78+Refusal string, identical for all six and for all twelve fresh cells:
79+
80+```
81+unsupported: AV1 decode_stream (a chroma format of 4:2:2 (subsampling_x != subsampling_y): this decoder decodes 4:2:0 and 4:4:4; 4:2:2 is not ported)
82+```
83+
84+Emitted at `crates/ec-av1/src/stream.rs:1780`, a single `subsampling_x !=
85+subsampling_y` test on the parsed sequence header. The four committed
86+refusal-by-name gates all pass on the clean tree:
87+`the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name`,
88+`the_pinned_422_intrabc_sb128_strip_witnesses_refuse_by_name`,
89+`the_pinned_422_lr_off_witness_is_present_and_refuses_by_name`,
90+`the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name`.
91+
92+### Freshly encoded cells (this lane; NOT committed — see "not_done")
93+
94+All from `aomenc --codec=av1 --profile=2 --input-bit-depth=<bd> --bit-depth=<bd>
95+--limit=16 --lag-in-frames=25 --auto-alt-ref=1 --enable-global-motion=1
96+--pass=1 --cq-level=<45> --threads=4 --kf-min-dist=0 --kf-max-dist=999999
97+--width=W --height=H --cpu-used=0 <src>.y4m -o <n>.webm`, then
98+`ffmpeg -i <n>.webm -c copy -f obu <n>.obu`. Wave 1 used `--cq-level=24`; the
99+per-cell deltas are named. Sources are `yuv422p` / `yuv422p10le` y4m from
100+ffmpeg 8.1.2 (`testsrc2`, `mandelbrot`, `smptebars`); the HBD and odd-size
101+y4m files are hand-built with per-frame `FRAME` headers, because ffmpeg's
102+y4m muxer will not write `C422p10` and libaom's reader rejects a single
103+leading `FRAME` header ("Loss of framing in Y4M input data").
104+
105+| cell | recipe delta | bytes | sha256 (first 16) | class | wrong Y | wrong U | wrong V | frames exact | decode-order frames (dump-vs-dump) |
106+|---|---|---|---|---|---|---|---|---|---|
107+| `A_testsrc2_cpu0` | testsrc2 320x240, cq 24 | 21584 | `2e03b3fe92b17c35` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 17/17 exact |
108+| `B_testsrc2_cpu6` | A + `--cpu-used=6` | 22570 | `7da006204c9f990c` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 17/17 exact |
109+| `C_mandel320` | mandelbrot 320x240, cq 24 | 30327 | `945510d22b5da687` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 16/16 exact |
110+| `D_bars` | smptebars 320x240, cq 24 | 994 | `6d3e3638c2f8cbfe` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 16/16 exact |
111+| `E_noglobal` | A + `--enable-global-motion=0` | 21545 | `efee4a80a745ee5f` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 17/17 exact |
112+| `F_allintra` | A + `--lag-in-frames=0 --auto-alt-ref=0` | 19937 | `a96a52339196b4a4` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 16/16 exact |
113+| `H_10bit_testsrc2` | testsrc2 10-bit 4:2:2 | 20628 | `f983ec21f7040cce` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 17/17 exact |
114+| `I_10bit_mandel` | mandelbrot 10-bit 4:2:2 | 28770 | `ecf4ffc5ac3ed11b` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 16/16 exact |
115+| `J_10bit_lr0` | H + `--enable-restoration=0` | 20605 | `fcfb47ce74d9c41c` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 17/17 exact |
116+| `K_sct` | A + `--cq-level=18 --tune=ssim` | 18792 | `580bf8d7d459156c` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 17/17 exact |
117+| `L_tiled` | A + `--tile-columns=1 --tile-rows=1` | 22553 | `50c22276a6ad4864` | REFUSED → EXACT | 0/1228800 | 0/614400 | 0/614400 | 16/16 | 17/17 exact |
118+| `O_odd322x242` | testsrc2 **322x242**, odd width | 21490 | `5af747bdb597a7a2` | REFUSED → EXACT | 0/1246784 | 0/623392 | 0/623392 | 16/16 | **17/17 DIFFER — see anomaly** |
119+
120+`A`–`L` carry one hidden alt-ref frame each (17 decode-order vs 16 shown), and
121+the hidden frame is byte-identical on both sides. `O` also has one.
122+
123+**Totals: 18 cells, 18 EXACT, 0 PANIC, 0 DIVERGE on presented output, 0 wrong
124+samples on any plane of any frame; 17 of 18 exact in decode order.**
125+
126+## The dc-sign symptom
127+
128+**Counter named: the `EC_DCDUMP` / `EC_DCDUMP422` rungs** in
129+`crates/ec-av1/src/decode.rs` (printed at `decode.rs:10123` and
130+`decode.rs:10188`, both under `EC_DCDUMP=1`). `EC_DCDUMP` is the luma per-mi
131+rect gather (`around_mi_rect`); `EC_DCDUMP422` is the 4:2:2 chroma gather
132+(`around_mi_422_chroma`) that samples every second above cell. The debt's
133+symptom is the *disagreement between them on the same block*.
134+
135+**The fix is on main.** `decode_leaf_rect` (`decode.rs:16084-16089`) routes
136+both chroma planes through `around_mi_422_chroma` when `chroma_422`, with the
137+gate closed at `ss_x == 1 && ss_y == 0`.
138+
139+Measured on current main, `422_residual_compound_warp_16f.obu`, `EC_DCDUMP=1`,
140+at the exact block the debt names (mi(48,28), V plane, `wh=(16,8)`):
141+
142+```
143+EC_DCDUMP mi=(48,28) plane=2 wh=(16,8) vote=0 above=[None/6,None/6,Some(false)/7,Some(false)/7] left=[Some(true)/7,Some(true)/7]
144+EC_DCDUMP422 mi=(48,28) plane=2 wh=(16,8) vote=-1 above=[None/6,Some(false)/7] left=[Some(true)/7,Some(true)/7]
145+```
146+
147+That is the symptom, gone: the luma-unit walk sums **four** above cells to a
148+vote of **0**; the chroma-unit walk the leaf actually uses sums **two** and gets
149+**-1**. It matches `lanes/av1422warp.report.md`'s recorded "after" exactly.
150+
151+Rung reach on that one stream: `EC_DCDUMP` 2091 lines, `EC_DCDUMP422` 9468
152+(6312 of them chroma-plane).
153+
154+### Before / after, with the fix surgically reverted
155+
156+I gated the `if chroma_422` block off (`decode.rs:16085` → `if false &&
157+chroma_422`), re-ran, then restored it — `git diff` on `decode.rs` is empty
158+again.
159+
160+| measurement | reverted | main (fix present) |
161+|---|---|---|
162+| `EC_DCDUMP` lines (stream) | 2079 | 2091 |
163+| `EC_DCDUMP422` lines (stream) | 9174 | 9468 |
164+| `422_residual_compound_warp_16f` presented vs `aomdec` | **16/16 exact, 0 wrong** | **16/16 exact, 0 wrong** |
165+| `422_residual_compound_warp_nolr_16f` presented vs `aomdec` | 16/16 exact, 0 wrong | 16/16 exact, 0 wrong |
166+
167+**The before/after that matters: there isn't one.** The reverted build is still
168+byte-exact on the stream that originally exposed the defect. The fix is real
169+and reached (the rung counts move, so the traversal genuinely changes), but on
170+current main it is **no longer load-bearing for any cell in the corpus**. The
171+later work in `lane-av1422warp` closed the surrounding desynces, and the
172+luma-unit vote now coincidentally agrees with the chroma-unit vote on this
173+content. That is the honest reading, and it is why the debt line is stale
174+rather than merely "fixed": there is no longer a single desync to point at.
175+
176+## The one anomaly: odd-width 4:2:2, stored picture vs presented picture
177+
178+`O_odd322x242` (322x242, so chroma is **161x242** — an odd, non-MI-aligned
179+chroma width) is the only cell that is exact on presented output but **differs
180+from the oracle in decode order on all 17 frames**.
181+
182+| frame | differing bytes | planes | chroma cols | chroma rows |
183+|---|---|---|---|---|
184+| 0 | 48 | U 32, V 16 | 108–131 | 117–138 |
185+| 1 | 95 | U 59, V 36 | 107–133 | 116–139 |
186+| 2 | 91 | U 59, V 32 | 108–132 | 106–139 |
187+
188+Both dumps are the same size (155848 B = the cropped 322x242 4:2:2 extent), so
189+this is not a shape or crop artefact, and the region is interior, not an edge.
190+
191+The discriminating control: for the same source at 4:2:0 (322x242 →
192+chroma 161x121) both the decode-order dumps and the presented output are
193+**byte-identical** (`P_odd420_322x242`: 0 differing frames), and so is
194+320x242 4:2:0. So the anomaly is **4:2:2-specific and odd-chroma-width
195+specific**, not an odd-dimension problem in general.
196+
197+What I can and cannot say:
198+
199+- **CAN say**: the picture `decode_stream` hands the caller is correct — 0 wrong
200+ samples against `aomdec --rawvideo` on all 16 shown frames.
201+- **CAN say**: the `EC_AV1_FINAL_DUMP` rung, which documents itself as "the
202+ frame exactly as it is about to be stored into the reference slots", does
203+ **not** agree with that picture on this shape.
204+- **CANNOT say** whether that is a genuine stored-reference defect or a
205+ rung-timing artefact. The rung and the returned picture are the same object
206+ inside `decode_frame`, so the two readings cannot both be right, and I did not
207+ build the instrument to decide which. I am not going to guess: this goes in
208+ `not_done` with the exact next step.
209+
210+It is a small, localized, chroma-only effect on a shape the committed corpus
211+has never contained, and it is invisible in user-visible output — but it is
212+the one measurement that argues against lifting the refusal outright, and it
213+should be settled **before** the refusal comes down, not after.
214+
215+## What still blocks the lift
216+
217+**The recorded entropy blocker: nothing.** It is fixed, and it is no longer
218+load-bearing.
219+
220+The three grounds `lanes/av1422warp.report.md` gave for keeping the refusal
221+now stand as follows:
222+
223+1. **Thin top-half engagement** — *not addressed, and now much weaker an
224+ objection.* That argument was about one stream's block census. I did not
225+ re-run the census; the 12 fresh cells simply do not make it worse, and the
226+ LR-off ground the same report listed (ground 3) is already discharged by the
227+ committed `422_residual_compound_warp_nolr_16f.obu` and re-confirmed here.
228+2. **One stream, one recipe** — **discharged.** Six independent encoder
229+ recipes across four different sources, two partitioning speeds, three
230+ encoder feature sets and two bit depths, all byte-exact.
231+3. **LR-off untested** — **discharged**, and re-confirmed independently here
232+ with `J_10bit_lr0` (10-bit *and* LR off) as well as the committed
233+ LR-off witness.
234+
235+So the correctness case for the refusal is gone. What remains is: a coverage
236+argument about how much engagement a future stream could carry, one unattributed
237+odd-width anomaly, and one shape I could not produce at all.
238+
239+## Recommendation
240+
241+**Keep a refusal, but make it a named-cell refusal and narrow it — do not keep
242+the blanket `subsampling_x != subsampling_y` guard.**
243+
244+1. **Replace the blanket guard** with a refusal conditioned on the shape that
245+ is actually unmeasured. The measured evidence is 18/18 byte-exact across
246+ 8-bit and 10-bit 4:2:2, even and odd width, one and many encoder recipes,
247+ LR on and off, single-tile and 2x2-tile, global-motion on and off, alt-ref
248+ on and off.
249+2. **Keep 4:2:2 refused for 12-bit specifically**, by name, until a 12-bit
250+ 4:2:2 stream exists. I could not produce one — this `aomenc` refuses the
251+ encode outright (`Failed to set chroma subsampling x: Unspecified internal
252+ error` at `--profile=2 --bit-depth=12` on a `C422p12` y4m), so 12-bit 4:2:2
253+ is genuinely unwitnessed rather than merely untried. This is the same
254+ pattern the tree already uses for 12-bit screen-content tools.
255+3. **Settle the odd-width anomaly first**, and make its outcome a gate either
256+ way. If it is a stored-reference defect, odd-width 4:2:2 joins the
257+ named-refusal list and the rest lifts. If it is a rung-timing artefact, the
258+ refusal lifts outright.
259+4. **Do not lift on this round's evidence alone**, for the reason the previous
260+ lane gave and that still holds: the lift decision should not be made in the
261+ same round that re-measured the thing it is deciding about. What this
262+ round does is retire the stale blocker line and hand the next lane a
263+ two-cell question with numbers attached, instead of an open-ended one.
264+
265+The evidence that decides it, in one line: **18/18 cells byte-exact, 0 wrong
266+samples on any plane, versus one 48–95-byte-per-frame chroma-only divergence
267+on odd-width 4:2:2 in the stored-picture view that is absent from the
268+presented view.**
269+
270+## Gates run
271+
272+On the clean tree at `6d564cd6` (no source diff — the lane commits only this
273+report), scoped:
274+
275+- `the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name` — pass
276+- `the_pinned_422_intrabc_sb128_strip_witnesses_refuse_by_name` — pass
277+- `the_pinned_422_lr_off_witness_is_present_and_refuses_by_name` — pass
278+- `the_pinned_422_residual_compound_warp_witness_is_present_and_refuses_by_name` — pass
279+- `a_real_aomenc_quantisation_matrix_stream_decodes_pixel_exact` — pass
280+- `the_rawvideo_helper_compares_real_samples_at_the_streams_own_bit_depth` — pass
281+- `a_non_420_subsampled_sequence_header_is_refused_by_name` — pass
282+- scoped battery `422 420 chroma chroma_422 rawvideo subsampling aomenc_444 hidden`
283+ — **61 passed / 0 failed / 0 ignored**
284+
285+Re-run after merging main's `0ea32904`: the four refusal-by-name gates plus
286+`a_non_420_subsampled_sequence_header_is_refused_by_name`,
287+`decode::tests::a_422_reference_claims_the_full_chroma_height` and
288+`decode::chroma422_pair_plane_matches_the_ss_size_lookup_cells` —
289+**7 passed / 0 failed**.
290+
291+## Instrumentation disclosure
292+
293+Two temporary artefacts, both removed and neither committed:
294+
295+- the `EC_AV1_ALLOW_422_PROBE` env bypass at `stream.rs:1780` (patch-run-restore, the
296+ established 4:2:2 probe mechanism);
297+- two `#[test]`s (`zz_temp_422_remeasure_cells`, `zz_temp_422_probe_one`) that
298+ count per-plane wrong samples instead of panicking, and drive
299+ `EC_AV1_FINAL_DUMP` from an external cell directory.
300+
301+**No new instrumentation was added to the decoder or the oracle.** The dc-sign
302+counter used is the pre-existing `EC_DCDUMP`/`EC_DCDUMP422` pair, quoted rather
303+than built.
304+
305+## `not_done`
306+
307+- **The odd-width 4:2:2 stored-vs-presented anomaly is unattributed.** Next step:
308+ in `decode_frame`, write the `EC_AV1_FINAL_DUMP` bytes and a hash of the
309+ returned `Picture` from the *same* frame in one process, so the two views are
310+ provably the same object; if they still disagree, the defect is in the
311+ reference store, and the region (chroma cols ~107–133) is small enough to
312+ bisect against `EC_PRED`/`EC_MCB`. I did not build this.
313+- **No new fixture committed.** The 12 fresh cells are recorded above with
314+ full recipes and sha256 but are **not** pinned into
315+ `crates/ec-av1/fixtures/`, deliberately: pinning them would imply a defect or
316+ a lift decision this report does not establish, and the tree's convention is a
317+ pin per witnessed gate. If the next lane takes the lift, these cells are the
318+ witnesses to pin.
319+- **The top-half engagement census was not re-run** — libaom's
320+ `is_global_mv_block` gating is oracle-side instrumentation I did not rebuild.
321+ Ground 1 of the old refusal argument is therefore untested, not disproven.
322+- **12-bit 4:2:2 unwitnessed and unreachable** with the local `aomenc`; it needs
323+ an encoder that can emit `--profile=2 --bit-depth=12` with 4:2:2, or a
324+ hand-built stream.
325+- **Superres 4:2:2 unwitnessed** — `--superres-mode=2` never produced an
326+ encode with this build; no recipe found.
327+- **Full suite not run** (per lane rules: scoped only; project-wide validation is
328+ Main's).