forge
Explore
Log in

Don't you dare go Hollow

ec-av1: four comments claiming more than their own evidence

Browse files at this commit

61c5b15bb8fe7eb895ac3a61d869e177a962da0dAhmet Kaan GümüşParent: 0cd363d
Comment-only, plus one #[allow(dead_code)] function with no callers.

census_unwritten: the doc said "at each frame's pre-deblock point". It runs
at two of the four apply_deblock entries -- the key path and the
non-pipelined inter path. The encoder's filter search (replay_filters, over a
captured copy) and the pipelined inter branch (deblock already ran band by band
inside par) are not covered, and the doc now says so. The exactness claim is
kept and narrowed to the extent the scan actually reads, per axis.

stage_dump_idx(): deleted, no callers in the crate. Its doc duplicated the live
mechanism; the mc64 index paragraph now names dump_stage_idx, the per-var
counter the dumps really name their files from, and records that PREFILT_PICTURE_IDX
is bumped AFTER the dump sites, so load()-1 would have named the previous frame.

EC_AV1_DECODE_ORDER_DUMP: the doc pointed at EC_AV1_POSTFILT_DUMP, a rung that
does not exist in instrument-aom-oracle.sh. Now names EC_AV1_POSTDEBLOCK_DUMP
(rung 6) with its 1-byte depth caveat.

chroma_plane_block_codable "what led here": the hash measurement is kept and
annotated -- taken on 8d6998d7, not reproduced (five plain runs, one hash
a761118c8dd5c8d0, unwritten-dep.report.md s10/s13), and main now REFUSES the
witness, so those hashes are pre-refusal history. Facts (1) and (2) remain what
make the refusal correct.

Report: lanes/av1docrot.report.md
crates/ec-av1/src/decode.rsmodified+59 -30
@@ -21136,18 +21136,14 @@ pub(crate) fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 {
2113621136 ///
2113721137 /// (`round_ss` is the rounding the decoder's own plane extents use; at ss = 1 it
2113821138 /// is `div_ceil(2)`, so every 4:2:0 dump is byte-for-byte unchanged by this.)
21139-/// lane-mc64 r1: the decode-order index the stage dumps below key their file
21140-/// name on. `PREFILT_PICTURE_IDX` is bumped once per frame just BEFORE the
21141-/// deblock/CDEF stages run, so the frame being dumped here is `idx - 1` --
21142-/// without this every frame overwrote `.f0` and a per-frame bisection silently
21143-/// compared the LAST decoded frame (ledger, class stale-output-faked-measurement).
21144-#[allow(dead_code)] // gate counter accessor with no reader yet; the counter itself is live
21145-fn stage_dump_idx() -> usize {
21146- PREFILT_PICTURE_IDX
21147- .load(std::sync::atomic::Ordering::SeqCst)
21148- .saturating_sub(1)
21149-}
21150-
21139+/// lane-mc64 r1: the file name is keyed on [`dump_stage_idx`], a per-var
21140+/// decode-order counter -- both dumps used to write `.f0` unconditionally, so
21141+/// every frame overwrote the previous one and only the LAST frame survived,
21142+/// which silently defeats any per-frame filter-stage bisection (ledger, class
21143+/// stale-output-faked-measurement). A sibling accessor `stage_dump_idx()`, which
21144+/// derived the same number from `PREFILT_PICTURE_IDX`, had no caller and was
21145+/// deleted: `PREFILT_PICTURE_IDX` is bumped after this point, not before it, so
21146+/// the counter that names these files is the per-var map.
2115121147 fn dump_stage16(
2115221148 var: &str,
2115321149 y: &PlaneBuf<'_>,
@@ -21271,20 +21267,33 @@ fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) {
2127121267 }
2127221268 }
2127321269
21274-/// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): at
21275-/// each frame's pre-deblock point, print an
21276-/// EXACT census of the samples the tile walk never wrote -- with
21277-/// it, every plane still holding [`PLANE_SENTINEL`] at
21278-/// this point is a sample no block reconstructed, and no legal sample can
21279-/// equal `0xDEAD` (reconstruction clamps to `(1 << bit_depth) - 1`).
21270+/// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): print
21271+/// an EXACT census of the samples the tile walk never wrote -- with it, every
21272+/// plane still holding [`PLANE_SENTINEL`] at this point is a sample no block
21273+/// reconstructed, and no legal sample can equal `0xDEAD` (reconstruction clamps
21274+/// to `(1 << bit_depth) - 1`).
21275+///
21276+/// Coverage, stated as the code has it: this census runs at TWO of the four
21277+/// places [`apply_deblock`] is entered from -- the key-frame path and the
21278+/// non-pipelined inter path, both immediately before that frame's deblock. The
21279+/// two it does NOT cover are the encoder's filter search ([`replay_filters`],
21280+/// which runs the filters over a CAPTURED copy, not a live decode) and the
21281+/// pipelined inter branch, where deblock has already run band by band inside
21282+/// `par` by the time this tail is reached. A zero count therefore means "no hole
21283+/// on the paths that reach this call", not "no hole on any path". It is EXACT
21284+/// over the extent it scans -- the scan itself reads every sample of that
21285+/// extent, unlike the older [`dump_stage`] pair, which truncates to `as u8`.
2128021286 ///
2128121287 /// This is the shipped form of the four-line temporary scan the
2128221288 /// `lane/av1422seed` census used: it replaces a wrong-sample diff (which says
2128321289 /// where the OUTPUT is wrong, not whether the block was written at all) with a
2128421290 /// direct count plus the coordinates of every hole, grouped into per-row
2128521291 /// spans so a large hole stays readable. Scans each plane over its own
21286-/// `true_width` x `true_height` extent: past that is the padded coding
21287-/// surface's invented tail, which no decoder ever reads.
21292+/// `true_width` x `true_height` extent, PER AXIS (`true_width.min(p.width)`), so
21293+/// a 4:2:2 frame's chroma is scanned at its own `fw/2 x fh` shape rather than
21294+/// the 4:2:0 `div_ceil(2)` crop the older [`dump_stage16`] used: past that
21295+/// extent is the padded coding surface's invented tail, which no decoder ever
21296+/// reads.
2128821297 fn census_unwritten(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) {
2128921298 if !plane_sentinel_on() {
2129021299 return;
@@ -21410,19 +21419,39 @@ fn plane_sentinel_on() -> bool {
2141021419 /// content.
2141121420 ///
2141221421 /// What led here was the observation that this decoder's output for such a
21413-/// witness DEPENDS ON UNWRITTEN PLANE CONTENT. Measured on `8d6998d7` by two
21414-/// independent builds (`EC_AV1_FINAL_DUMP=<dir>/x`, the directory created
21415-/// FIRST -- the dump writes nothing if it does not exist): five runs with
21416-/// uninitialised planes give TWO different output hashes, five runs with
21417-/// `EC_AV1_PLANE_SENTINEL=1` give ONE hash, and the sentinel output differs
21422+/// witness DEPENDS ON UNWRITTEN PLANE CONTENT. Measured on lane/av1unwritten's
21423+/// branch point `8d6998d7` by two independent builds (`EC_AV1_FINAL_DUMP=<dir>/x`,
21424+/// the directory created FIRST -- the dump writes nothing if it does not exist):
21425+/// five runs with uninitialised planes gave TWO different output hashes, five runs
21426+/// with `EC_AV1_PLANE_SENTINEL=1` gave ONE hash, and the sentinel output differs
2141821427 /// from the plain one. At 8-bit the sentinel survives in the dump as the single
2141921428 /// byte `0xAD`, not the pair `DE AD` -- `PLANE_SENTINEL`'s u16 narrows in
2142021429 /// [`crate::stream`]'s u8 write path, so counting a two-byte `0xDEAD` in an
21421-/// 8-bit dump cannot find it. The lane's own pre-deblock census
21422-/// ([`census_unwritten`]) then localised the unwritten samples on THIS lane's
21423-/// tree: 112 per chroma plane on the witness, 224 total. That census number is a
21424-/// lane-tree measurement with a lane-only instrument and is cited as such;
21425-/// (1) and (2) are what make the refusal correct.
21430+/// 8-bit dump cannot find it.
21431+///
21432+/// That hash observation is HISTORICAL and its hash half did NOT reproduce: on
21433+/// the same `8d6998d7`, five plain runs of `440_request_is_422` gave ONE hash,
21434+/// `a761118c8dd5c8d0` (`lanes/unwritten-dep.report.md` §10, which also states in
21435+/// §13 that this pre-deblock census still has no committed reader on `main`).
21436+/// Ambient allocator content is machine-dependent, so a stable value on one host
21437+/// and a varying one on another would be the same defect; the hash spread is
21438+/// cited as measured-on-`8d6998d7`, not as a standing property.
21439+///
21440+/// What the census localised: the lane's own pre-deblock census
21441+/// ([`census_unwritten`]) found 112 unwritten samples per chroma plane on the
21442+/// witness, 224 total -- on that lane's tree, with a lane-only instrument. That
21443+/// count is a lane-tree measurement and is cited as such.
21444+///
21445+/// Which witness behaviour is CURRENT: `main` REFUSES this witness. The pin
21446+/// `440_request_is_422.obu` is exercised by
21447+/// `stream::tests::a_422_header_over_a_420_tile_refuses_the_subsize_libaom_calls_corrupt`,
21448+/// which asserts the decode ERRORS with libaom's own "invalid with this
21449+/// subsampling mode" wording, so `440_request_is_422` is not sweepable on the
21450+/// merge tree (`lanes/unwritten-dep.report.md` §10). The run-to-run hashes above
21451+/// are what the tree did BEFORE that refusal and cannot be re-measured on
21452+/// `main`. Facts (1) and (2) above -- libaom refusing the shape, and libaom's own
21453+/// encoder never emitting it -- are what make the refusal correct; the
21454+/// measurement history is why it was looked for.
2142621455 ///
2142721456 /// `av1_ss_size_lookup`'s `BLOCK_INVALID` cells, transcribed verbatim:
2142821457 /// `(common_data.c:17-41`, rows in `BLOCK_SIZES_ALL` order, indexed
crates/ec-av1/src/stream.rsmodified+4 -2
@@ -2196,8 +2196,10 @@ fn decode_frame(
21962196 // (`scratch_isolate_pinned_mismatch`) only ever compares *shown*
21972197 // frames, so a hidden reference (altref/bwdref) that DPB-corrupts a
21982198 // later shown frame is otherwise invisible; diff this byte-for-byte
2199- // against `EC_AV1_POSTFILT_DUMP.fN` from the instrumented aomdec
2200- // build to isolate whether the defect is in a hidden frame's own
2199+ // against `EC_AV1_POSTDEBLOCK_DUMP.fN` from the instrumented aomdec build
2200+ // (rung 6, `scripts/instrument-aom-oracle.sh`; 1 byte per sample, so it is
2201+ // byte-comparable only at 8-bit -- for HBD use rung 12 `EC_AV1_FINAL_DUMP`)
2202+ // to isolate whether the defect is in a hidden frame's own
22012203 // reconstruction or downstream of it.
22022204 if let Ok(path) = std::env::var("EC_AV1_DECODE_ORDER_DUMP") {
22032205 use std::io::Write;
lanes/av1docrot.report.mdadded+114 -0
@@ -0,0 +1,114 @@
1+# lane/av1docrot — four comments that claimed more than their own evidence
2+
3+Base: `main` = `1f4fcc84`. Comments only: no behaviour change, plus the deletion
4+of one `#[allow(dead_code)]` function with no callers. Scoped proof:
5+`cargo check -p ec-av1 --tests` clean; `cargo doc -p ec-av1 --no-deps` produces no
6+new broken-link warning; `cargo test -p ec-av1 --lib -- --test-threads=1 dump census 422`
7+green.
8+
9+## Row 1 — `decode.rs` `census_unwritten` doc: coverage claim
10+
11+**Was:** "at each frame's pre-deblock point … an EXACT census", stated as though
12+every frame is scanned.
13+
14+**Now:** the coverage is named and bounded. The census runs at **two of the four**
15+places `apply_deblock` is entered from — the key-frame path and the
16+non-pipelined inter path, each immediately before that frame's deblock. The two
17+it does not cover are named as well: the encoder's filter search
18+(`replay_filters`, which runs the filters over a *captured copy*, not a live
19+decode) and the pipelined inter branch, where deblock has already run band by
20+band inside `par` before this tail is reached. The comment says a zero count
21+means "no hole on the paths that reach this call", not "no hole on any path".
22+
23+The **exactness** claim is kept, and narrowed to what is true of the scan: exact
24+over the extent it scans — every sample of `true_width.min(p.width)` x
25+`true_height`, per axis. The claim that this differs from the older
26+`dump_stage`/`dump_stage16` is stated per axis (`true_width.min(p.width)` and
27+`round_ss`), which is what the code at the scan does.
28+
29+**Evidence:** the call sites themselves — `census_unwritten` has exactly two
30+callers in the crate (key path, inter path), and `apply_deblock` has four
31+entries (`replay_filters`, key path, and the inter path's `pipelined` /
32+non-pipelined arms, where the pipelined arm calls `cdef_scan_counters` instead
33+and deblock has run inside `par` via `deblock_span`).
34+
35+## Row 2 — `decode.rs` `stage_dump_idx`: dead function deleted
36+
37+**Decision: deleted**, rather than repointing the doc. `stage_dump_idx()` was
38+`#[allow(dead_code)]` with zero callers in the crate; its doc was a duplicate
39+description of the mechanism that is actually live.
40+
41+The doc it carried had two parts, and both now live where they are true:
42+
43+* the lane-hgkf / lane-unwritten-dep byte-shape and per-axis crop description
44+ stays on `dump_stage16`, which is what it describes, unchanged;
45+* the lane-mc64 r1 "decode-order index" paragraph is rewritten to name the live
46+ mechanism — [`dump_stage_idx`], the per-var decode-order counter that
47+ `dump_stage`/`dump_stage16`/`dump_prefilter_wide` name their files from.
48+
49+The rewritten paragraph also records *why* the deleted accessor could not have
50+been the mechanism: `PREFILT_PICTURE_IDX` is bumped **after** the dumps run (the
51+dump sites `fetch_add` it immediately below the `census_unwritten` call), so a
52+`load() - 1` accessor would have named the previous frame. The live per-var map
53+is what indexes the files.
54+
55+**Evidence:** `grep stage_dump_idx` over the whole repo → only its own
56+definition, before this change. `dump_stage_idx` call sites: `dump_stage16`,
57+`dump_stage`, `dump_prefilter_wide`.
58+
59+## Row 3 — `stream.rs` `EC_AV1_DECODE_ORDER_DUMP` comment: dangling oracle rung
60+
61+**Was:** "diff this byte-for-byte against `EC_AV1_POSTFILT_DUMP.fN` from the
62+instrumented aomdec build". No such rung: `scripts/instrument-aom-oracle.sh`
63+defines `PREFILT` (1), `PREFILT_WIDE` (7), `POSTDEBLOCK` (6), `POSTCDEF` (15),
64+`FINAL` (12) — no `POSTFILT`.
65+
66+**Now:** names `EC_AV1_POSTDEBLOCK_DUMP.fN` (rung 6), the post-deblock rung that
67+matches what this dump holds, with the rung's own depth caveat stated (1 byte per
68+sample, so byte-comparable only at 8-bit; rung 12 `EC_AV1_FINAL_DUMP` for HBD).
69+The rung number is cited so a future bisect can find it, and the comment 16 lines
70+below naming `EC_AV1_FINAL_DUMP` (rung 12) was already correct and is untouched.
71+
72+**Evidence:** `scripts/instrument-aom-oracle.sh` header (rungs 1/6/7/12/15) and
73+the rung-6 block at :328-338, whose `DEPTH ASSUMPTION` block states the 1-byte
74+per-sample pairing with our own `EC_AV1_POSTDEBLOCK_DUMP`.
75+
76+## Row 4 — `decode.rs` `chroma_plane_block_codable`: the "what led here" history
77+
78+The historical measurement is **kept**, with three corrections layered on:
79+
80+1. **The tree it was taken on.** `8d6998d7` is now named as lane/av1unwritten's
81+ branch point, not a bare sha that reads like `main`.
82+2. **The non-reproduction.** The comment now states plainly that the hash half did
83+ not reproduce: five plain runs on the same `8d6998d7` gave **one** hash,
84+ `a761118c8dd5c8d0` — citing `lanes/unwritten-dep.report.md` §10 (and §13 for
85+ the census's still-absent committed reader). The spread is presented as
86+ measured on that tree, not as a standing property, with the machine-dependence
87+ caveat the report itself makes.
88+3. **Which witness behaviour is current.** `main` **refuses** the witness. The
89+ comment names the test that pins that
90+ (`stream::tests::a_422_header_over_a_420_tile_refuses_the_subsize_libaom_calls_corrupt`,
91+ which asserts the decode errors with libaom's "invalid with this subsampling
92+ mode" wording) and says the run-to-run hashes are what the tree did *before*
93+ that refusal and cannot be re-measured on `main`.
94+
95+The `0xAD`-not-`DE AD` narrowing detail and the 224-sample census count are
96+unchanged; the census count keeps its "lane-tree measurement with a lane-only
97+instrument" qualifier. The closing line is retargeted: facts (1) libaom refusing
98+the shape and (2) libaom's own encoder never emitting it are what make the
99+refusal correct — the measurement history is only why it was looked for.
100+
101+**Evidence:** `lanes/unwritten-dep.report.md` §10 (both the `440_request_is_422`
102+= REFUSED line and the `a761118c8dd5c8d0` non-reproduction) and §13 (no committed
103+reader for `take_unwritten_samples` on `main`); the refusal test named above.
104+
105+## What this lane did not touch
106+
107+`decode.rs`'s allocation path (`fresh_plane`) — peer lane `av1uballoc` owns it.
108+Every hunk here is a doc comment, except the row-2 deletion at old
109+`decode.rs:21144-21149`.
110+
111+## Files
112+
113+* `crates/ec-av1/src/decode.rs` — rows 1, 2, 4 (comments; one dead-fn deletion)
114+* `crates/ec-av1/src/stream.rs` — row 3 (comment)
\ No newline at end of file