forge
Explore
Log in

Don't you dare go Hollow

Merge lane/av1docrot: four comments that asserted mechanisms that are not there

Browse files at this commit

04f62dad6bb1ab1bcf8ce350d355242c10e2a0deAhmet Kaan GümüşParent: 0cd363d61c5b15
An independent sweep of measurement-stating comments found these; each fix states the true
claim and cites the evidence for it.

- census_unwritten's doc claimed "each frame's pre-deblock point" while the call sits at 2
  of the 4 apply_deblock entries (key path, non-pipelined inter path), and its "exact"
  claim was unbounded. Coverage is now named, the exactness is kept and narrowed to the
  per-axis extent it actually scans, and the uncovered paths are listed -- zero now means
  "no hole on the paths that reach this call".
- stage_dump_idx() is deleted rather than repointed: no callers, and the live per-var
  counter has its own doc.
- stream.rs no longer tells the reader to diff against EC_AV1_POSTFILT_DUMP, a rung the
  oracle script never defined; it names EC_AV1_POSTDEBLOCK_DUMP and its depth caveat.
- chroma_plane_block_codable's "what led here" keeps its historical measurement and now
  names the tree it was taken on, records that a later measurement did not reproduce it,
  and states the current behaviour (the witness is refused on main).
crates/ec-av1/src/decode.rsmodified+59 -30
@@ -21136,18 +21136,14 @@ pub(crate) fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 {
21136 ///21136 ///
21137 /// (`round_ss` is the rounding the decoder's own plane extents use; at ss = 1 it21137 /// (`round_ss` is the rounding the decoder's own plane extents use; at ss = 1 it
21138 /// is `div_ceil(2)`, so every 4:2:0 dump is byte-for-byte unchanged by this.)21138 /// 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 file21139+/// lane-mc64 r1: the file name is keyed on [`dump_stage_idx`], a per-var
21140-/// name on. `PREFILT_PICTURE_IDX` is bumped once per frame just BEFORE the21140+/// decode-order counter -- both dumps used to write `.f0` unconditionally, so
21141-/// deblock/CDEF stages run, so the frame being dumped here is `idx - 1` --21141+/// every frame overwrote the previous one and only the LAST frame survived,
21142-/// without this every frame overwrote `.f0` and a per-frame bisection silently21142+/// which silently defeats any per-frame filter-stage bisection (ledger, class
21143-/// compared the LAST decoded frame (ledger, class stale-output-faked-measurement).21143+/// stale-output-faked-measurement). A sibling accessor `stage_dump_idx()`, which
21144-#[allow(dead_code)] // gate counter accessor with no reader yet; the counter itself is live21144+/// derived the same number from `PREFILT_PICTURE_IDX`, had no caller and was
21145-fn stage_dump_idx() -> usize {21145+/// deleted: `PREFILT_PICTURE_IDX` is bumped after this point, not before it, so
21146- PREFILT_PICTURE_IDX21146+/// the counter that names these files is the per-var map.
21147- .load(std::sync::atomic::Ordering::SeqCst)
21148- .saturating_sub(1)
21149-}
21150-
21151 fn dump_stage16(21147 fn dump_stage16(
21152 var: &str,21148 var: &str,
21153 y: &PlaneBuf<'_>,21149 y: &PlaneBuf<'_>,
@@ -21271,20 +21267,33 @@ fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) {
21271 }21267 }
21272 }21268 }
21273 21269
21274-/// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): at21270+/// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): print
21275-/// each frame's pre-deblock point, print an21271+/// an EXACT census of the samples the tile walk never wrote -- with it, every
21276-/// EXACT census of the samples the tile walk never wrote -- with21272+/// plane still holding [`PLANE_SENTINEL`] at this point is a sample no block
21277-/// it, every plane still holding [`PLANE_SENTINEL`] at21273+/// reconstructed, and no legal sample can equal `0xDEAD` (reconstruction clamps
21278-/// this point is a sample no block reconstructed, and no legal sample can21274+/// to `(1 << bit_depth) - 1`).
21279-/// equal `0xDEAD` (reconstruction clamps 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`.
21280 ///21286 ///
21281 /// This is the shipped form of the four-line temporary scan the21287 /// This is the shipped form of the four-line temporary scan the
21282 /// `lane/av1422seed` census used: it replaces a wrong-sample diff (which says21288 /// `lane/av1422seed` census used: it replaces a wrong-sample diff (which says
21283 /// where the OUTPUT is wrong, not whether the block was written at all) with a21289 /// where the OUTPUT is wrong, not whether the block was written at all) with a
21284 /// direct count plus the coordinates of every hole, grouped into per-row21290 /// direct count plus the coordinates of every hole, grouped into per-row
21285 /// spans so a large hole stays readable. Scans each plane over its own21291 /// 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 coding21292+/// `true_width` x `true_height` extent, PER AXIS (`true_width.min(p.width)`), so
21287-/// surface's invented tail, which no decoder ever reads.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.
21288 fn census_unwritten(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) {21297 fn census_unwritten(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) {
21289 if !plane_sentinel_on() {21298 if !plane_sentinel_on() {
21290 return;21299 return;
@@ -21410,19 +21419,39 @@ fn plane_sentinel_on() -> bool {
21410 /// content.21419 /// content.
21411 ///21420 ///
21412 /// What led here was the observation that this decoder's output for such a21421 /// 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 two21422+/// witness DEPENDS ON UNWRITTEN PLANE CONTENT. Measured on lane/av1unwritten's
21414-/// independent builds (`EC_AV1_FINAL_DUMP=<dir>/x`, the directory created21423+/// branch point `8d6998d7` by two independent builds (`EC_AV1_FINAL_DUMP=<dir>/x`,
21415-/// FIRST -- the dump writes nothing if it does not exist): five runs with21424+/// the directory created FIRST -- the dump writes nothing if it does not exist):
21416-/// uninitialised planes give TWO different output hashes, five runs with21425+/// five runs with uninitialised planes gave TWO different output hashes, five runs
21417-/// `EC_AV1_PLANE_SENTINEL=1` give ONE hash, and the sentinel output differs21426+/// with `EC_AV1_PLANE_SENTINEL=1` gave ONE hash, and the sentinel output differs
21418 /// from the plain one. At 8-bit the sentinel survives in the dump as the single21427 /// from the plain one. At 8-bit the sentinel survives in the dump as the single
21419 /// byte `0xAD`, not the pair `DE AD` -- `PLANE_SENTINEL`'s u16 narrows in21428 /// byte `0xAD`, not the pair `DE AD` -- `PLANE_SENTINEL`'s u16 narrows in
21420 /// [`crate::stream`]'s u8 write path, so counting a two-byte `0xDEAD` in an21429 /// [`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 census21430+/// 8-bit dump cannot find it.
21422-/// ([`census_unwritten`]) then localised the unwritten samples on THIS lane's21431+///
21423-/// tree: 112 per chroma plane on the witness, 224 total. That census number is a21432+/// That hash observation is HISTORICAL and its hash half did NOT reproduce: on
21424-/// lane-tree measurement with a lane-only instrument and is cited as such;21433+/// the same `8d6998d7`, five plain runs of `440_request_is_422` gave ONE hash,
21425-/// (1) and (2) are what make the refusal correct.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.
21426 ///21455 ///
21427 /// `av1_ss_size_lookup`'s `BLOCK_INVALID` cells, transcribed verbatim:21456 /// `av1_ss_size_lookup`'s `BLOCK_INVALID` cells, transcribed verbatim:
21428 /// `(common_data.c:17-41`, rows in `BLOCK_SIZES_ALL` order, indexed21457 /// `(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(
2196 // (`scratch_isolate_pinned_mismatch`) only ever compares *shown*2196 // (`scratch_isolate_pinned_mismatch`) only ever compares *shown*
2197 // frames, so a hidden reference (altref/bwdref) that DPB-corrupts a2197 // frames, so a hidden reference (altref/bwdref) that DPB-corrupts a
2198 // later shown frame is otherwise invisible; diff this byte-for-byte2198 // later shown frame is otherwise invisible; diff this byte-for-byte
2199- // against `EC_AV1_POSTFILT_DUMP.fN` from the instrumented aomdec2199+ // against `EC_AV1_POSTDEBLOCK_DUMP.fN` from the instrumented aomdec build
2200- // build to isolate whether the defect is in a hidden frame's own2200+ // (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
2201 // reconstruction or downstream of it.2203 // reconstruction or downstream of it.
2202 if let Ok(path) = std::env::var("EC_AV1_DECODE_ORDER_DUMP") {2204 if let Ok(path) = std::env::var("EC_AV1_DECODE_ORDER_DUMP") {
2203 use std::io::Write;2205 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\ No newline at end of file