From 61c5b15bb8fe7eb895ac3a61d869e177a962da0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 1 Oct 2026 20:25:48 +0300 Subject: [PATCH] ec-av1: four comments claiming more than their own evidence 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.rs | 89 ++++++++++++++++++---------- crates/ec-av1/src/stream.rs | 6 +- lanes/av1docrot.report.md | 114 ++++++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+), 32 deletions(-) create mode 100644 lanes/av1docrot.report.md diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 531e2c08..7704d7cb 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -21136,18 +21136,14 @@ pub(crate) fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { /// /// (`round_ss` is the rounding the decoder's own plane extents use; at ss = 1 it /// is `div_ceil(2)`, so every 4:2:0 dump is byte-for-byte unchanged by this.) -/// lane-mc64 r1: the decode-order index the stage dumps below key their file -/// name on. `PREFILT_PICTURE_IDX` is bumped once per frame just BEFORE the -/// deblock/CDEF stages run, so the frame being dumped here is `idx - 1` -- -/// without this every frame overwrote `.f0` and a per-frame bisection silently -/// compared the LAST decoded frame (ledger, class stale-output-faked-measurement). -#[allow(dead_code)] // gate counter accessor with no reader yet; the counter itself is live -fn stage_dump_idx() -> usize { - PREFILT_PICTURE_IDX - .load(std::sync::atomic::Ordering::SeqCst) - .saturating_sub(1) -} - +/// lane-mc64 r1: the file name is keyed on [`dump_stage_idx`], a per-var +/// decode-order counter -- both dumps used to write `.f0` unconditionally, so +/// every frame overwrote the previous one and only the LAST frame survived, +/// which silently defeats any per-frame filter-stage bisection (ledger, class +/// stale-output-faked-measurement). A sibling accessor `stage_dump_idx()`, which +/// derived the same number from `PREFILT_PICTURE_IDX`, had no caller and was +/// deleted: `PREFILT_PICTURE_IDX` is bumped after this point, not before it, so +/// the counter that names these files is the per-var map. fn dump_stage16( var: &str, y: &PlaneBuf<'_>, @@ -21271,20 +21267,33 @@ fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { } } -/// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): at -/// each frame's pre-deblock point, print an -/// EXACT census of the samples the tile walk never wrote -- with -/// it, every plane still holding [`PLANE_SENTINEL`] at -/// this point is a sample no block reconstructed, and no legal sample can -/// equal `0xDEAD` (reconstruction clamps to `(1 << bit_depth) - 1`). +/// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): print +/// an EXACT census of the samples the tile walk never wrote -- with it, every +/// plane still holding [`PLANE_SENTINEL`] at this point is a sample no block +/// reconstructed, and no legal sample can equal `0xDEAD` (reconstruction clamps +/// to `(1 << bit_depth) - 1`). +/// +/// Coverage, stated as the code has it: this census runs at TWO of the four +/// places [`apply_deblock`] is entered from -- the key-frame path and the +/// non-pipelined inter path, both immediately before that frame's deblock. The +/// two it does NOT cover are the encoder's filter search ([`replay_filters`], +/// which runs the filters over a CAPTURED copy, not a live decode) and the +/// pipelined inter branch, where deblock has already run band by band inside +/// `par` by the time this tail is reached. A zero count therefore means "no hole +/// on the paths that reach this call", not "no hole on any path". It is EXACT +/// over the extent it scans -- the scan itself reads every sample of that +/// extent, unlike the older [`dump_stage`] pair, which truncates to `as u8`. /// /// This is the shipped form of the four-line temporary scan the /// `lane/av1422seed` census used: it replaces a wrong-sample diff (which says /// where the OUTPUT is wrong, not whether the block was written at all) with a /// direct count plus the coordinates of every hole, grouped into per-row /// spans so a large hole stays readable. Scans each plane over its own -/// `true_width` x `true_height` extent: past that is the padded coding -/// surface's invented tail, which no decoder ever reads. +/// `true_width` x `true_height` extent, PER AXIS (`true_width.min(p.width)`), so +/// a 4:2:2 frame's chroma is scanned at its own `fw/2 x fh` shape rather than +/// the 4:2:0 `div_ceil(2)` crop the older [`dump_stage16`] used: past that +/// extent is the padded coding surface's invented tail, which no decoder ever +/// reads. fn census_unwritten(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { if !plane_sentinel_on() { return; @@ -21410,19 +21419,39 @@ fn plane_sentinel_on() -> bool { /// content. /// /// What led here was the observation that this decoder's output for such a -/// witness DEPENDS ON UNWRITTEN PLANE CONTENT. Measured on `8d6998d7` by two -/// independent builds (`EC_AV1_FINAL_DUMP=/x`, the directory created -/// FIRST -- the dump writes nothing if it does not exist): five runs with -/// uninitialised planes give TWO different output hashes, five runs with -/// `EC_AV1_PLANE_SENTINEL=1` give ONE hash, and the sentinel output differs +/// witness DEPENDS ON UNWRITTEN PLANE CONTENT. Measured on lane/av1unwritten's +/// branch point `8d6998d7` by two independent builds (`EC_AV1_FINAL_DUMP=/x`, +/// the directory created FIRST -- the dump writes nothing if it does not exist): +/// five runs with uninitialised planes gave TWO different output hashes, five runs +/// with `EC_AV1_PLANE_SENTINEL=1` gave ONE hash, and the sentinel output differs /// from the plain one. At 8-bit the sentinel survives in the dump as the single /// byte `0xAD`, not the pair `DE AD` -- `PLANE_SENTINEL`'s u16 narrows in /// [`crate::stream`]'s u8 write path, so counting a two-byte `0xDEAD` in an -/// 8-bit dump cannot find it. The lane's own pre-deblock census -/// ([`census_unwritten`]) then localised the unwritten samples on THIS lane's -/// tree: 112 per chroma plane on the witness, 224 total. That census number is a -/// lane-tree measurement with a lane-only instrument and is cited as such; -/// (1) and (2) are what make the refusal correct. +/// 8-bit dump cannot find it. +/// +/// That hash observation is HISTORICAL and its hash half did NOT reproduce: on +/// the same `8d6998d7`, five plain runs of `440_request_is_422` gave ONE hash, +/// `a761118c8dd5c8d0` (`lanes/unwritten-dep.report.md` §10, which also states in +/// §13 that this pre-deblock census still has no committed reader on `main`). +/// Ambient allocator content is machine-dependent, so a stable value on one host +/// and a varying one on another would be the same defect; the hash spread is +/// cited as measured-on-`8d6998d7`, not as a standing property. +/// +/// What the census localised: the lane's own pre-deblock census +/// ([`census_unwritten`]) found 112 unwritten samples per chroma plane on the +/// witness, 224 total -- on that lane's tree, with a lane-only instrument. That +/// count is a lane-tree measurement and is cited as such. +/// +/// Which witness behaviour is CURRENT: `main` REFUSES this witness. The pin +/// `440_request_is_422.obu` is exercised by +/// `stream::tests::a_422_header_over_a_420_tile_refuses_the_subsize_libaom_calls_corrupt`, +/// which asserts the decode ERRORS with libaom's own "invalid with this +/// subsampling mode" wording, so `440_request_is_422` is not sweepable on the +/// merge tree (`lanes/unwritten-dep.report.md` §10). The run-to-run hashes above +/// are what the tree did BEFORE that refusal and cannot be re-measured on +/// `main`. Facts (1) and (2) above -- libaom refusing the shape, and libaom's own +/// encoder never emitting it -- are what make the refusal correct; the +/// measurement history is why it was looked for. /// /// `av1_ss_size_lookup`'s `BLOCK_INVALID` cells, transcribed verbatim: /// `(common_data.c:17-41`, rows in `BLOCK_SIZES_ALL` order, indexed diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 0dd92dd4..f5ebc70c 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -2196,8 +2196,10 @@ fn decode_frame( // (`scratch_isolate_pinned_mismatch`) only ever compares *shown* // frames, so a hidden reference (altref/bwdref) that DPB-corrupts a // later shown frame is otherwise invisible; diff this byte-for-byte - // against `EC_AV1_POSTFILT_DUMP.fN` from the instrumented aomdec - // build to isolate whether the defect is in a hidden frame's own + // against `EC_AV1_POSTDEBLOCK_DUMP.fN` from the instrumented aomdec build + // (rung 6, `scripts/instrument-aom-oracle.sh`; 1 byte per sample, so it is + // byte-comparable only at 8-bit -- for HBD use rung 12 `EC_AV1_FINAL_DUMP`) + // to isolate whether the defect is in a hidden frame's own // reconstruction or downstream of it. if let Ok(path) = std::env::var("EC_AV1_DECODE_ORDER_DUMP") { use std::io::Write; diff --git a/lanes/av1docrot.report.md b/lanes/av1docrot.report.md new file mode 100644 index 00000000..4133185b --- /dev/null +++ b/lanes/av1docrot.report.md @@ -0,0 +1,114 @@ +# lane/av1docrot — four comments that claimed more than their own evidence + +Base: `main` = `1f4fcc84`. Comments only: no behaviour change, plus the deletion +of one `#[allow(dead_code)]` function with no callers. Scoped proof: +`cargo check -p ec-av1 --tests` clean; `cargo doc -p ec-av1 --no-deps` produces no +new broken-link warning; `cargo test -p ec-av1 --lib -- --test-threads=1 dump census 422` +green. + +## Row 1 — `decode.rs` `census_unwritten` doc: coverage claim + +**Was:** "at each frame's pre-deblock point … an EXACT census", stated as though +every frame is scanned. + +**Now:** the coverage is named and bounded. The census runs at **two of the four** +places `apply_deblock` is entered from — the key-frame path and the +non-pipelined inter path, each immediately before that frame's deblock. The two +it does not cover are named as well: the encoder's filter search +(`replay_filters`, which runs the filters over a *captured copy*, not a live +decode) and the pipelined inter branch, where deblock has already run band by +band inside `par` before this tail is reached. The comment says a zero count +means "no hole on the paths that reach this call", not "no hole on any path". + +The **exactness** claim is kept, and narrowed to what is true of the scan: exact +over the extent it scans — every sample of `true_width.min(p.width)` x +`true_height`, per axis. The claim that this differs from the older +`dump_stage`/`dump_stage16` is stated per axis (`true_width.min(p.width)` and +`round_ss`), which is what the code at the scan does. + +**Evidence:** the call sites themselves — `census_unwritten` has exactly two +callers in the crate (key path, inter path), and `apply_deblock` has four +entries (`replay_filters`, key path, and the inter path's `pipelined` / +non-pipelined arms, where the pipelined arm calls `cdef_scan_counters` instead +and deblock has run inside `par` via `deblock_span`). + +## Row 2 — `decode.rs` `stage_dump_idx`: dead function deleted + +**Decision: deleted**, rather than repointing the doc. `stage_dump_idx()` was +`#[allow(dead_code)]` with zero callers in the crate; its doc was a duplicate +description of the mechanism that is actually live. + +The doc it carried had two parts, and both now live where they are true: + +* the lane-hgkf / lane-unwritten-dep byte-shape and per-axis crop description + stays on `dump_stage16`, which is what it describes, unchanged; +* the lane-mc64 r1 "decode-order index" paragraph is rewritten to name the live + mechanism — [`dump_stage_idx`], the per-var decode-order counter that + `dump_stage`/`dump_stage16`/`dump_prefilter_wide` name their files from. + +The rewritten paragraph also records *why* the deleted accessor could not have +been the mechanism: `PREFILT_PICTURE_IDX` is bumped **after** the dumps run (the +dump sites `fetch_add` it immediately below the `census_unwritten` call), so a +`load() - 1` accessor would have named the previous frame. The live per-var map +is what indexes the files. + +**Evidence:** `grep stage_dump_idx` over the whole repo → only its own +definition, before this change. `dump_stage_idx` call sites: `dump_stage16`, +`dump_stage`, `dump_prefilter_wide`. + +## Row 3 — `stream.rs` `EC_AV1_DECODE_ORDER_DUMP` comment: dangling oracle rung + +**Was:** "diff this byte-for-byte against `EC_AV1_POSTFILT_DUMP.fN` from the +instrumented aomdec build". No such rung: `scripts/instrument-aom-oracle.sh` +defines `PREFILT` (1), `PREFILT_WIDE` (7), `POSTDEBLOCK` (6), `POSTCDEF` (15), +`FINAL` (12) — no `POSTFILT`. + +**Now:** names `EC_AV1_POSTDEBLOCK_DUMP.fN` (rung 6), the post-deblock rung that +matches what this dump holds, with the rung's own depth caveat stated (1 byte per +sample, so byte-comparable only at 8-bit; rung 12 `EC_AV1_FINAL_DUMP` for HBD). +The rung number is cited so a future bisect can find it, and the comment 16 lines +below naming `EC_AV1_FINAL_DUMP` (rung 12) was already correct and is untouched. + +**Evidence:** `scripts/instrument-aom-oracle.sh` header (rungs 1/6/7/12/15) and +the rung-6 block at :328-338, whose `DEPTH ASSUMPTION` block states the 1-byte +per-sample pairing with our own `EC_AV1_POSTDEBLOCK_DUMP`. + +## Row 4 — `decode.rs` `chroma_plane_block_codable`: the "what led here" history + +The historical measurement is **kept**, with three corrections layered on: + +1. **The tree it was taken on.** `8d6998d7` is now named as lane/av1unwritten's + branch point, not a bare sha that reads like `main`. +2. **The non-reproduction.** The comment now states plainly that the hash half did + not reproduce: five plain runs on the same `8d6998d7` gave **one** hash, + `a761118c8dd5c8d0` — citing `lanes/unwritten-dep.report.md` §10 (and §13 for + the census's still-absent committed reader). The spread is presented as + measured on that tree, not as a standing property, with the machine-dependence + caveat the report itself makes. +3. **Which witness behaviour is current.** `main` **refuses** the witness. The + comment names the test that pins that + (`stream::tests::a_422_header_over_a_420_tile_refuses_the_subsize_libaom_calls_corrupt`, + which asserts the decode errors with libaom's "invalid with this subsampling + mode" wording) and says the run-to-run hashes are what the tree did *before* + that refusal and cannot be re-measured on `main`. + +The `0xAD`-not-`DE AD` narrowing detail and the 224-sample census count are +unchanged; the census count keeps its "lane-tree measurement with a lane-only +instrument" qualifier. The closing line is retargeted: facts (1) libaom refusing +the shape and (2) libaom's own encoder never emitting it are what make the +refusal correct — the measurement history is only why it was looked for. + +**Evidence:** `lanes/unwritten-dep.report.md` §10 (both the `440_request_is_422` += REFUSED line and the `a761118c8dd5c8d0` non-reproduction) and §13 (no committed +reader for `take_unwritten_samples` on `main`); the refusal test named above. + +## What this lane did not touch + +`decode.rs`'s allocation path (`fresh_plane`) — peer lane `av1uballoc` owns it. +Every hunk here is a doc comment, except the row-2 deletion at old +`decode.rs:21144-21149`. + +## Files + +* `crates/ec-av1/src/decode.rs` — rows 1, 2, 4 (comments; one dead-fn deletion) +* `crates/ec-av1/src/stream.rs` — row 3 (comment) \ No newline at end of file