refutation pass on the 4:4:4 palette window: PASS, and its two live risks closed rather than noted
Browse files at this commit7929331f167111e17fa021fba8f32f59b3911500Parent: 57ac17e3 changed files +72 -7
- crates/ec-av1/src/decode.rs +44 -4
- crates/ec-av1/src/stream.rs +5 -3
- lanes/refute-av1444d10.report.md +23 -0
crates/ec-av1/src/decode.rsmodified+44 -4
| @@ -2722,10 +2722,20 @@ pub(crate) fn palette_split_tx_hits() -> usize { | |||
| 2722 | thread_local! { | 2722 | thread_local! { |
| 2723 | /// lane-av1444d10: chroma PREDICTION units on the 32-capped tiled chroma | 2723 | /// lane-av1444d10: chroma PREDICTION units on the 32-capped tiled chroma |
| 2724 | /// walk (`decode_block_rect`'s `uw/uh = min(chroma, 32)` units) that were | 2724 | /// walk (`decode_block_rect`'s `uw/uh = min(chroma, 32)` units) that were |
| 2725 | - /// handed a WINDOWED slice of their block's palette buffer -- i.e. the | 2725 | + /// handed a STRICT sub-slice of their block's palette buffer -- i.e. the |
| 2726 | - /// units that are NOT the block's top-left corner. Counts units, not | 2726 | + /// units of a block the 32-cap actually TILED (`nw * nh > 1`). |
| 2727 | - /// blocks, and only units whose block actually has a UV palette, so a | 2727 | + /// |
| 2728 | - /// stream without a tiled palette chroma block leaves it at zero. | 2728 | + /// CORRECTED 2026-09-30 after the refutation pass `lanes/refute-av1444d10` |
| 2729 | + /// read the numbers back: the previous comment claimed it counted "the | ||
| 2730 | + /// units that are NOT the block's top-left corner", which is not what the | ||
| 2731 | + /// code did -- the hit was unconditional, so a block's corner unit fired it | ||
| 2732 | + /// too AND a single-unit block (whose window is a pure re-stride copy of | ||
| 2733 | + /// the whole buffer) fired it as well. That made a hit prove only that some | ||
| 2734 | + /// palette chroma block existed, not that the tiled arm ran. The `bigger` | ||
| 2735 | + /// guard now makes the counter discriminate. On the pinned fixture the | ||
| 2736 | + /// measured value is unchanged at 4 (one block with nw = 1, nh = 2 x two | ||
| 2737 | + /// planes x two unit rows); a stream whose palette chroma blocks are all | ||
| 2738 | + /// single-unit now leaves it at zero. | ||
| 2729 | static CHROMA_PALETTE_WINDOW_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2739 | static CHROMA_PALETTE_WINDOW_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2730 | } | 2740 | } |
| 2731 | 2741 | ||
| @@ -2980,6 +2990,18 @@ fn palette_window( | |||
| 2980 | w: usize, | 2990 | w: usize, |
| 2981 | h: usize, | 2991 | h: usize, |
| 2982 | ) -> Vec<u16> { | 2992 | ) -> Vec<u16> { |
| 2993 | + // `stride` is the BLOCK's own chroma width, so a caller that handed over a | ||
| 2994 | + // mismatched stride could read in-bounds GARBAGE instead of panicking -- | ||
| 2995 | + // a silent misread, which is the one failure mode this walk must not have. | ||
| 2996 | + // The refutation pass (`lanes/refute-av1444d10.report.md`, risk (e)) named | ||
| 2997 | + // that as the only thing keeping the tiled walk safe, so the invariant is | ||
| 2998 | + // closed loudly here instead of resting on an `unsupported` return | ||
| 2999 | + // elsewhere that a future shape could remove. | ||
| 3000 | + assert!( | ||
| 3001 | + w <= stride && ox + w <= stride && (oy + h) * stride <= buf.len(), | ||
| 3002 | + "palette window {w}x{h} at ({ox},{oy}) does not fit a {}-entry buffer at stride {stride}", | ||
| 3003 | + buf.len() | ||
| 3004 | + ); | ||
| 2983 | (0..h) | 3005 | (0..h) |
| 2984 | .flat_map(|r| buf[(oy + r) * stride + ox..][..w].iter().copied()) | 3006 | .flat_map(|r| buf[(oy + r) * stride + ox..][..w].iter().copied()) |
| 2985 | .collect() | 3007 | .collect() |
| @@ -20110,8 +20132,17 @@ fn decode_block_rect64( | |||
| 20110 | palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh), | 20132 | palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh), |
| 20111 | fctx, | 20133 | fctx, |
| 20112 | ); | 20134 | ); |
| 20135 | + // Counted only when the window is a STRICT sub-slice of the | ||
| 20136 | + // block's buffer, i.e. when the 32-cap actually tiled the | ||
| 20137 | + // block: at nw * nh == 1 the window is a re-stride copy of | ||
| 20138 | + // the whole buffer and windowing is load-bearing for | ||
| 20139 | + // nothing. The `bigger` guard is what makes a hit PROOF | ||
| 20140 | + // that the tiled arm ran, rather than proof that some | ||
| 20141 | + // palette chroma block existed. | ||
| 20142 | + if bigger { | ||
| 20113 | hit!(CHROMA_PALETTE_WINDOW_HITS); | 20143 | hit!(CHROMA_PALETTE_WINDOW_HITS); |
| 20114 | } | 20144 | } |
| 20145 | + } | ||
| 20115 | read_plane( | 20146 | read_plane( |
| 20116 | dec, | 20147 | dec, |
| 20117 | cdfs, | 20148 | cdfs, |
| @@ -20169,8 +20200,17 @@ fn decode_block_rect64( | |||
| 20169 | palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh), | 20200 | palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh), |
| 20170 | fctx, | 20201 | fctx, |
| 20171 | ); | 20202 | ); |
| 20203 | + // Counted only when the window is a STRICT sub-slice of the | ||
| 20204 | + // block's buffer, i.e. when the 32-cap actually tiled the | ||
| 20205 | + // block: at nw * nh == 1 the window is a re-stride copy of | ||
| 20206 | + // the whole buffer and windowing is load-bearing for | ||
| 20207 | + // nothing. The `bigger` guard is what makes a hit PROOF | ||
| 20208 | + // that the tiled arm ran, rather than proof that some | ||
| 20209 | + // palette chroma block existed. | ||
| 20210 | + if bigger { | ||
| 20172 | hit!(CHROMA_PALETTE_WINDOW_HITS); | 20211 | hit!(CHROMA_PALETTE_WINDOW_HITS); |
| 20173 | } | 20212 | } |
| 20213 | + } | ||
| 20174 | push_intra_rect( | 20214 | push_intra_rect( |
| 20175 | plane_idx, | 20215 | plane_idx, |
| 20176 | cpx + cu_col * uw, | 20216 | cpx + cu_col * uw, |
crates/ec-av1/src/stream.rsmodified+5 -3
| @@ -50751,9 +50751,11 @@ exit 0 | |||
| 50751 | /// (2) 17 decode-order frames at 352x242 with FULL-RESOLUTION chroma, so | 50751 | /// (2) 17 decode-order frames at 352x242 with FULL-RESOLUTION chroma, so |
| 50752 | /// a decoder that kept the 4:2:0 extent cannot pass the compare. | 50752 | /// a decoder that kept the 4:2:0 extent cannot pass the compare. |
| 50753 | /// (3) `decode::chroma_palette_window_hits()` read as a delta must be at | 50753 | /// (3) `decode::chroma_palette_window_hits()` read as a delta must be at |
| 50754 | - /// least 1: the fixed lines are the only thing that increments it, so a | 50754 | + /// least 1. After the refutation pass read the numbers back, that counter |
| 50755 | - /// gate that passes without them running would be | 50755 | + /// is guarded on `nw * nh > 1`, so it fires ONLY for units of a block the |
| 50756 | - /// gate-blind-to-feature. (4) The oracle comparator this gate leans on has | 50756 | + /// 32-cap actually tiled -- a hit is therefore proof that the tiled arm ran, |
| 50757 | + /// not merely that some palette chroma block existed, and a gate that | ||
| 50758 | + /// passed with the tiled arm removed would be gate-blind-to-feature. (4) The oracle comparator this gate leans on has | ||
| 50757 | /// its own per-plane one-byte-flip liveness control in the crate | 50759 | /// its own per-plane one-byte-flip liveness control in the crate |
| 50758 | /// (`every_oracle_comparator_reds_on_a_one_byte_wrong_oracle`). | 50760 | /// (`every_oracle_comparator_reds_on_a_one_byte_wrong_oracle`). |
| 50759 | #[test] | 50761 | #[test] |
lanes/refute-av1444d10.report.mdadded+23 -0
| @@ -0,0 +1,23 @@ | |||
| 1 | +# refutation-av1444d10 — reviewer verdict on the 4:4:4 10-bit 352x242 palette-window fix (merge e4787782) | ||
| 2 | + | ||
| 3 | +Transcribed verbatim from the reviewer seat's output (agent Agent20-5), 2026-09-30. The ONLY edit is the P3 flag below, which main acted on in the same batch (the counter is now guarded on nw*nh>1 and its doc corrected; gate re-run green at 4 windowed units). The P3 finding's own BODY was stored truncated at its 1068-byte tail ("Fix the c…"); the gist -- the counter must be fixed or its doc corrected so that a hit proves the TILED arm ran -- is what was acted on, and a doc-only change was NOT taken as sufficient because the counter is used as the gate's non-vacuity arm. | ||
| 4 | + | ||
| 5 | +VERDICT: PASS | ||
| 6 | +FLAGS: crates/ec-av1/src/decode.rs:2721-2731 (P3 doc-vs-behaviour, non-blocking) | ||
| 7 | +EVIDENCE: (1) COMPARATOR LIVENESS: my own one-byte-wrong-oracle shim (wraps ~/.cache/aom-oracle/build/aomdec, flips bit0 of ONE byte of ${EC_AV1_FINAL_DUMP}.f0 at byte 328192) run through the gate's own comparator (EC_AV1_AOMDEC=$PWD/shim/aomdec-tamper, EC_AV1_REQUIRE_AOMDEC=1) turns the byte-exact cell RED with "1 bytes differ" at byte 328192 (ours 216 vs 217) — the count moved by exactly +1, and the comparison point is the census's first bad sample. Green baseline on the un-tampered oracle: "17 decode-order frame(s) (1 hidden) byte-exact vs aomdec, 4 windowed palette chroma unit(s)". The crate comparator reads the oracle's dump file bytes and diffs them against ours (stream.rs:10836-10855) — not a self-comparison, so it is the live kind, unlike the withdrawn av1422 re-measurement. | ||
| 8 | +(2) CLAIM 2, my own instrument: a temporary #[cfg(test)] module in my worktree ran aomdec with EC_AV1_FINAL_DUMP against our set_final_dump_prefix dumps and counted wrong u16 SAMPLES per plane over all 17 decode-order frames (352x242 10-bit 4:4:4; dump layout Y,U,V each 352*242 samples). TIP: Y=0 U=0 V=0 on every frame, 0/0/0 total. FIX OUT (only the two palette_window calls reverted, counter left in place): Y=0 U=1166 V=1413, per-frame U = 53,54,54,54,170,54,162,54,58,54,61,54,54,61,61,54,54 and V = 51,51,51,52,160,52,158,52,58,52,158,52,51,156,156,52,51 — a term-for-term match with the report's table. First bad sample on both planes: decode frame 0, row 224, col 64, ours 209 vs oracle 216 (U). | ||
| 9 | +(3) MUTATION PROOF reproduced by name: reverting the two windows reds the gate at stream.rs:10848 with "decode-order frame 0 of 17 (16 shown, 1 hidden) differs from the oracle at byte 328192 (ours 209 vs 216), 104 bytes differ" — identical to the report. Green again on restore (worktree diff empty afterwards). | ||
| 10 | +(4) CLAIM 4 measured on the lane's own sweep .obu files (not the report's numbers): 320x242, 320x250, 352x250, 416x242, 416x250 all 0/0/0 over 17 decode frames AFTER, and 320x242 also 0/0/0 BEFORE the fix. 352x242's sweep .obu is byte-identical to the committed fixture (sha256 84df2f37…a0ad2, 24875 B), so the provenance chain holds. | ||
| 11 | +(5) CLAIM 7 reproduced in a clean worktree at e4787782 with EC_AV1_REQUIRE_AOMDEC=1: "cargo test -p ec-av1 --lib -- 444 420 lossless warp intra --skip bitrate_target_lands_within_5_percent_over_48_frames" -> test result: ok. 178 passed; 0 failed; 2 ignored; 623 filtered out (345.66s). | ||
| 12 | +(6) SEMANTIC CHANGE BEYOND THE TWO WINDOWS (claim 4 of my brief): the diff is exactly 2 sites, 10 insertions / 2 deletions, no offsets or guards touched. The no-op-at-nw*nh==1 property is verified, not assumed: cu_col/cu_row are both 0 when nw*nh==1, so palette_window(buf, chroma_w, 0, 0, uw, uh) with uw=chroma_w, uh=chroma_h is a re-stride copy; and the buffer's own stride equals chroma_w because the map is built by decode_color_index_map_wh(…, cw, ch) with cw=(bw>>ss_x).max(4), and the only case where cw>chroma_w (chroma_w<4, e.g. 4:2:0 bw=4) returns `unsupported` earlier at the (uw,uh) match arm before the palette windowing is reached. Both arms' set_palette_pred are consumed exactly once by the same reconstruct/inline_intra path as before (take_palette_pred at decode.rs:4026/4113), so no new stale-override window. | ||
| 13 | +(7) CLAIM 8 audited mechanically, not by reading: of 98 set_palette_pred sites, all 6 multi-line ones are palette_window hand-offs; every whole-buffer .clone() hand-off that sits lexically near a unit loop was checked by hand (12776, 17281 = single-push whole-block arms; 25542 = an inter-copy 4x4 unit whose buffer is built per unit). No remaining whole-buffer hand-off inside a tiled unit loop. The two 4x8 sub-8 windows that pass ox=0 with only unit_row are single-column walks, so omitting unit_col is correct there. | ||
| 14 | +(8) CLAIM 6's counter: an EC_NWTRACE probe on the pinned fixture shows exactly 4 windowed units = ONE block with nw=1, nh=2, x 2 planes (U,V) x 2 unit rows, so MIN_WINDOWED_UNITS=4 is the exact measured value, and every hit is a genuinely tiled unit. nw>1 is reached NOWHERE in the committed fixture corpus: a corpus-wide sweep (all 106 .obu, tracer on both fixed sites) produced 16 windowed units, all with nw=1; zero with nw>=2. | ||
| 15 | +(9) CLAIM 3 partially re-run: the full 106-fixture before/after oracle sweep (95/1/9/1 -> 96/0/9/1) was NOT re-run — it is ~106 aomdec decodes x2 builds. What I did run: the pinned cell, the six sweep cells, the 178-test regression scope with the oracle REQUIRED, and a corpus-wide decode sweep of all 106 fixtures under my tracer (96 decoded, 10 refused, no panics) — consistent with 9 4:2:2 refusals plus the request-only 440 file, but I did not re-measure per-fixture byte-exactness on the other 95. | ||
| 16 | +RISK: (a) The gate's pixel arm is silently SKIPPED unless an oracle is present — every run above set EC_AV1_REQUIRE_AOMDEC=1; a green run without it proves nothing about pixels. (b) The nw>1 (horizontal) windowing arm of the fixed code is UNMEASURED: it is unreachable in all 106 committed fixtures and in all six 4:4:4 sweep cells. It is correct by construction (a unit's window is cu_col*uw at the block's own chroma_w stride, matching libaom's per-unit ref pointer), but a 4:4:4 stream with a 64-wide luma rect block carrying a UV palette (chroma_w=64 -> uw=32, nw=2) is what it would take, and no such fixture exists. (c) CHROMA_PALETTE_WINDOW_HITS fires on EVERY palette chroma unit, including single-unit blocks where the window is a no-op, so the counter alone does not prove the tiled path ran; the floor of 4 and the byte compare carry that, and the floor would need re-measuring if a second palette-chroma fixture is ever added to the same test. (d) Do not trust the report's claim 3 numbers as re-measured — they are plausible and consistent with everything I measured, but I did not re-run the two-build 106-fixture sweep. (e) The window indexes buf[(oy+r)*stride+ox..][..w] and would panic (or, with a mismatched stride, misread) if a future block shape ever gave cw != chroma_w; today that shape returns `unsupported` first, which is the only thing keeping it safe. | ||
| 17 | + | ||
| 18 | +## Flags (structured) | ||
| 19 | +### P3 Counter doc claims it counts only non-top-left units; it counts every palette chroma unit | ||
| 20 | +file: crates/ec-av1/src/decode.rs:2721-2731 confidence: 0.75 | ||
| 21 | + | ||
| 22 | +The doc comment on CHROMA_PALETTE_WINDOW_HITS (decode.rs:2721-2731, added by eb73ef89) says it counts 'units that are NOT the block's top-left corner', but the hit! sits unconditionally next to set_palette_pred(palette_window(...)) on both fixed lines, so it also fires for nw*nh==1 blocks where the window is a pure re-stride copy of the whole buffer — the exact units the comment says it excludes. Measured on the pinned fixture the two coincide (all 4 hits are nw=1, nh=2), so nothing is mis-gated today, but a reader auditing non-vacuity would conclude the counter proves the TILED arm ran, which the counter cannot distinguish: a stream whose palette chroma blocks are all single-unit would still produce hits >= 1 and pass the reachability assert. Fix the comment to say 'units handed a windowed slice (all palette chroma units on the 32-capped walk; the window is a no-op when nw*nh==1)' and let the MIN_WINDOWED_UNITS floor plus the byte compare carry the tiled-arm claim, or gate the hit! on bigger (nw*nh > 1) if the tiled arm is what it is meant to witness. | ||
| 23 | + | ||