forge
Explore
Log in

Don't you dare go Hollow

debug(av1): localise the square-only silent pixel drift to one 64x64 PARTITION_NONE intra-in-inter block

Browse files at this commit

f359f69212e834b827f6d5175f010eef85cd764fAhmet Kaan GümüşParent: 9ae16b3
A 192x128 8-bit real-aomenc stream encoded with rect/AB/1:4 partitions, cdef,
restoration, obmc, warp, order-hint and every compound tool disabled decodes
frames 0-3 byte-exact (pre-filter AND post-filter) and then puts 3540 wrong luma
samples (max |d| 6, chroma exact) into decode-order frame 4 -- confined to the
single superblock the frame codes as PARTITION_NONE at 64x64, an intra block
inside an inter frame. Frames 5-7 then drift via the adapted CDFs.

Measurements: aomdec's own partition histogram shows the stream contains no rect,
AB or 1:4 partition at all, so the "intra-coded 1:4 rect strip" refusal this
stream stops at on main is read out of an already-diverged stream; the msac range
before that block's partition symbol matches aomdec's exactly (33730), so the
divergence is inside the block; and the block's five non-zero levels pushed
through real libaom av1_inv_txfm2d_add_64x64_c reproduce our residual with 0
mismatches, exonerating the TX_64X64 dequant and inverse transform.

Two env-gated rungs added, no decode behaviour changed: partition_w64's trace now
carries the pre-read msac range (directly comparable to aomdec's EC_PART rng), and
EC_IIS prints the square intra-in-inter y_mode read.
crates/ec-av1/src/decode.rsmodified+8 -1
@@ -18464,6 +18464,12 @@ fn decode_inter_block(
18464 return Ok(());18464 return Ok(());
18465 }18465 }
18466 let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]);18466 let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]);
18467+ if std::env::var_os("EC_IIS").is_some() {
18468+ eprintln!(
18469+ "TRACE iis px={px} py={py} side={side} w={write_w} h={write_h} sg={} mode={mode} skip={skip}",
18470+ size_group_wh(write_w, write_h)
18471+ );
18472+ }
18467 if mode >= 13 {18473 if mode >= 13 {
18468 return Err(unsupported(18474 return Err(unsupported(
18469 "an intra mode this decoder does not code (round 2)",18475 "an intra mode this decoder does not code (round 2)",
@@ -20929,10 +20935,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
20929 // instead of silently decoding as SPLIT and desyncing.20935 // instead of silently decoding as SPLIT and desyncing.
20930 let part64 = match (has_cols, has_rows) {20936 let part64 = match (has_cols, has_rows) {
20931 (true, true) => {20937 (true, true) => {
20938+ let pre_rng = dec.debug_state().0;
20932 let p = dec.symbol(&mut cdfs.partition_w64[sb_ctx]);20939 let p = dec.symbol(&mut cdfs.partition_w64[sb_ctx]);
20933 if std::env::var_os("EC_AV1_TRACE").is_some() {20940 if std::env::var_os("EC_AV1_TRACE").is_some() {
20934 eprintln!(20941 eprintln!(
20935- "TRACE partition_w64 mi=({},{}) ctx={sb_ctx} value={p}",20942+ "TRACE partition_w64 mi=({},{}) ctx={sb_ctx} value={p} pre_rng={pre_rng}",
20936 sb_r * SB_MI,20943 sb_r * SB_MI,
20937 sb_c * SB_MI20944 sb_c * SB_MI
20938 );20945 );
lanes/COMMON-20260901.mdmodified+6 -0
@@ -100,3 +100,9 @@ If you ran it: extract your own hunks, `git checkout -- crates/`, re-apply.
100 never two suites per lane; film extracts ≤2 s; a watchdog (`ec-memwatch` user unit, log100 never two suites per lane; film extracts ≤2 s; a watchdog (`ec-memwatch` user unit, log
101 `$HOME/.cache/ec-memwatch.log`) SIGKILLs any codec/test process above 6 GiB RSS or the largest one101 `$HOME/.cache/ec-memwatch.log`) SIGKILLs any codec/test process above 6 GiB RSS or the largest one
102 when MemAvailable < 3 GiB — a killed run means YOUR command exceeded the budget: bound it, do not retry as-is.102 when MemAvailable < 3 GiB — a killed run means YOUR command exceeded the budget: bound it, do not retry as-is.
103+
104+## WORKTREE SETUP (2026-09-02, three lanes lost a round to this)
105+A new worktree needs the TOP-LEVEL fixtures symlink: `ln -s /home/user/Documents/Code/Rust/edith_codecs/fixtures <worktree>/fixtures`.
106+Without it exactly one gate fails: a_real_aomenc_stream_with_film_grain_decodes_pixel_exact with Os NotFound — it is NOT a decode defect.
107+New files under crates/ec-av1/fixtures/ need `git add -f` (bare `fixtures` in .gitignore); verify with `git ls-files`.
108+Commit-msg hook rejects film titles / home paths: describe streams by codec/resolution/bit depth.
lanes/sqdrift-r1.report.mdadded+100 -0
@@ -0,0 +1,100 @@
1+# lane-sqdrift r1 -- the square-only silent pixel drift, localised to ONE block
2+
3+## Verdict: RED (defect localised and bounded, not yet fixed). No refusal lifted.
4+
5+## The stream (pinned, reproducible)
6+
7+`/home/user/.cache/sqdrift/gen.sh` (kept; recipe = lane-intra14's gate recipe with
8+`--enable-rect-partitions=0`): 192x128 8-bit `mandelbrot start_scale=4.76 end_scale=0.004
9+end_pts=8 rate=25`, hue=s=0, `-t 0.32`, real `~/.cache/aom-oracle/build/aomenc`
10+`--cpu-used=1 --cq-level=55 --min-partition-size=16 --max-partition-size=64
11+--enable-tx-size-search=0 --kf-min/max-dist=1000 --threads=1 --row-mt=0`, order-hint /
12+warped / obmc / masked / interintra / dist-wtd / diff-wtd / onesided / ab / 1to4 /
13+filter-intra / smooth-intra / paeth-intra / directional-intra / angle-delta / cdef /
14+restoration / palette / intrabc / cfl / ref-frame-mvs ALL `=0`.
15+sha256 `c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55`, hashed twice
16+from two independent encodes -- reproducible.
17+
18+## What is actually wrong (measured, not reasoned)
19+
20+1. `aomdec EC_TRACE=1` partition histogram over the whole stream: only
21+ `value=0 (NONE)` and `value=3 (SPLIT)` at bsize 12/9/6. **No rect, no AB, no 1:4
22+ partition exists in this stream at all** -- so main's refusal
23+ "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", which this
24+ stream stops at on `main@85887c7`, is a PHANTOM read out of an already-diverged
25+ bitstream (class `refusal-from-own-desync`).
26+2. Pre-loop-filter dumps, our `EC_AV1_PREFILT_DUMP` vs aomdec's, per decode-order frame:
27+ f0..f3 **byte-exact (luma AND chroma)**; f4 luma 3540 samples wrong, max |d| = 6,
28+ **chroma exact**. Post-filter reference dumps (`EC_AV1_FINAL_DUMP`) f0..f3 exact too,
29+ so no reference frame is poisoned going into f4.
30+3. The f4 damage is EXACTLY one superblock: bbox x 128..191, y 64..127 -- the last SB,
31+ mi (16,32), which frame 4 codes as `PARTITION_NONE` at 64x64. It is the ONLY
32+ 64x64 PARTITION_NONE block in any inter frame of this stream.
33+4. Range ladder at that block's entry: our pre-read msac range for its `partition_w64`
34+ symbol is **33730**, identical to aomdec's `EC_PART mi_row=16 mi_col=32 bsize=12
35+ ctx=15 tell=25598 rng=33730`, and the ctx matches too (aomdec prints `bsl*4+ctx`
36+ = 12+3, ours `ctx=3`). **We enter that block bit-exactly in sync.**
37+5. The divergence is INSIDE that block. aomdec prints neither `EC_MODE` (=
38+ `read_inter_block_mode_info`) nor `EC_IMODE`, i.e. libaom takes
39+ `read_intra_block_mode_info` -- an INTRA block inside an inter frame. Our decoder
40+ takes the same arm and reads `y_mode[size_group=3] = 0 (DC_PRED)`
41+ (new `EC_IIS=1` rung: `TRACE iis px=128 py=64 side=64 w=64 h=64 sg=3 mode=0 skip=false`).
42+ Our reconstruction there is a FLAT 93, which is exactly
43+ `(sum(above 64) + sum(left 64) + 64) >> 7` -- textbook DC_PRED. aomdec's
44+ reconstruction is not flat.
45+6. The luma residual is NOT the defect. The block's 5 non-zero levels were pushed
46+ through libaom itself (`av1_inv_txfm2d_add_64x64_c`, real `libaom.a`, dequant
47+ replicated from `decodetxb.c:361-374` with `av1_dc/ac_quant_QTX(80,0,8)` = 74/87 and
48+ `av1_get_tx_scale` shift 2): **0 mismatches** against our own `residual` for those
49+ levels (and 2171 with the axes swapped, so the layout is right too). Our TX_64X64
50+ dequant + inverse transform is exact.
51+7. Everything after that block drifts: frame 5's SB0 `partition_w64` still reads 3, SB1
52+ reads 8 where aomdec reads 3 -- a CDF-state divergence carried across the frame
53+ boundary (frame 5 restarts its own msac, so only the adapted CDFs can carry the
54+ damage). f5..f7 then drift to ~24k samples / max |d| ~220 as they predict from f4.
55+
56+So: **the first divergent symbol is in the mode-info or coefficient read of a 64x64
57+PARTITION_NONE intra-in-inter block, after `partition_w64` and at/after `y_mode`.**
58+The candidate set is now tiny: `skip`, `read_delta_q_params` (this is the ONE block in
59+the stream where `bsize == sb_size`, the exact case libaom's
60+`read_delta_q_params` special-cases), `is_inter`, `y_mode[3]`, `uv_mode_cfl[0]`,
61+`tx_depth` (`--enable-tx-size-search=0`, so a TX_64X64 must code no depth symbol), or the
62+64x64 coefficient read itself. `base_q_idx` in our trace takes three values (80/110/168)
63+across the stream, i.e. **delta_q IS present in this stream** -- that makes the
64+`bsize == sb_size` delta-q exception a first-class suspect.
65+
66+## What changed (all env-gated instrumentation, no decode behaviour)
67+
68+* `crates/ec-av1/src/decode.rs` (`decode_inter_frame_tile_with_cdfs`'s `partition_w64`
69+ read) -- the `EC_AV1_TRACE` line now carries `pre_rng=`, the msac range BEFORE the
70+ symbol, which is what makes it directly comparable to aomdec's `EC_PART ... rng=`
71+ (class `compare-range-not-tell`). This is the measurement that proved fact 4.
72+* `crates/ec-av1/src/decode.rs` (square intra-in-inter `y_mode` read) -- new `EC_IIS=1`
73+ rung printing `px/py/side/w/h/size_group/mode/skip` for every intra block in an inter
74+ frame. That is fact 5.
75+
76+## Gate
77+
78+None added -- there is no fix to gate yet. Adding a gate now would pin the defect, not a
79+capability; the reproducing recipe is `scripts`-free and lives in this report plus
80+`/home/user/.cache/sqdrift/gen.sh`.
81+
82+## EVIDENCE
83+
84+EVIDENCE: /home/user/.cache/sqdrift/{op,aom}.f0..f4 | our EC_AV1_PREFILT_DUMP vs aomdec EC_AV1_PREFILT_DUMP on the pinned stream, every decode-order frame compared Y/U/V | f0-f3 0 bad samples; f4 luma 3540 bad, max |d| 6, chroma 0 bad, bbox exactly x128-191 y64-127
85+EVIDENCE: /home/user/.cache/sqdrift/{of,af}.f0..f4 | EC_AV1_FINAL_DUMP (post-filter reference buffers) both decoders | f0-f3 0 bad; f4 first bad (145,58), 3848 bad, max 6 -- deblocking only spreads the f4 damage, no reference is poisoned earlier
86+EVIDENCE: /home/user/.cache/sqdrift/aom.trace | aomdec EC_TRACE=1 partition histogram, whole stream | bsize12 {0:2, 3:46}, bsize9 {0:58, 3:126}, bsize6 {0:504} -- zero rect/AB/1:4 partitions, so main's 1:4-strip refusal on this stream is a phantom
87+EVIDENCE: our EC_AV1_TRACE pre_rng vs /home/user/.cache/sqdrift/aom.both | range ladder at frame 4 SB (16,32) | ours pre_rng=33730 ctx=3, aomdec rng=33730 ctx=15(=12+3) -- in sync at block entry, so the defect is inside the block
88+EVIDENCE: /home/user/.cache/sqdrift/{h.c,aomres1.txt,ourres.txt} | the block's 5 non-zero levels through real libaom av1_inv_txfm2d_add_64x64_c vs our residual | 0/4096 mismatches (swapped-axis control: 2171) -- TX_64X64 dequant+inverse is exact
89+EVIDENCE: EC_IIS=1 rung on the pinned stream | our intra-in-inter mode read at the failing block | `TRACE iis px=128 py=64 side=64 w=64 h=64 sg=3 mode=0 skip=false`, reconstruction flat 93 = DC_PRED of the true neighbours; aomdec's is not flat (SMOOTH/SMOOTH_V/SMOOTH_H/PAETH all rejected numerically too, so aomdec's coefficients differ as well -- the divergence is a SYMBOL, not a predictor)
90+
91+## Residue
92+
93+* fix-now (next round, r2): bisect the ~6 remaining symbols of that one block. The
94+ cheapest decisive instrument is a `pre_rng` print on every symbol of
95+ `read_inter_frame_mode_info`'s square intra arm plus an aomdec-side `rng` print at the
96+ same points in `read_intra_block_mode_info` / `read_delta_q_params` (the oracle has no
97+ print there today -- add one to `scripts/instrument-aom-oracle.sh`, do NOT rebuild the
98+ shared aomdec in place). Start with `read_delta_q_params`' `bsize == sb_size` exception.
99+* deferred: 10-bit arm -- unblocked by the fix; there is nothing to gate yet.
100+* accepted: the two `EC_*` trace rungs ship as permanent debug instrumentation.