diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 481f8c65..bb550953 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -1998,6 +1998,14 @@ impl Neighbours { self.above_compound_idx[i] = 0; self.above_filter[i] = [3u8; 2]; } + // lane-sub8 r6: the mi-granular column maps are per tile too -- a + // stale `(row, mode)` from the tile to the LEFT names an mi row this + // tile's first block would read as its own above neighbour. + let mcol_end = col1_mi.min(self.sub8_mode_col.len()); + for i in col0_mi.min(mcol_end)..mcol_end { + self.sub8_mode_col[i] = (usize::MAX, 0); + self.uv_mode_col[i] = (usize::MAX, 0); + } } /// Writes a just-decoded block's own palette-Y size/colours (`size == 0` @@ -2266,6 +2274,10 @@ impl Neighbours { self.left_comp_group_idx.iter_mut().for_each(|r| *r = 0); self.left_compound_idx.iter_mut().for_each(|r| *r = 0); self.left_filter.iter_mut().for_each(|f| *f = [3u8; 2]); + // lane-sub8 r6: mi-granular row maps reset with the rest of the left + // context (a tile/SB-row boundary has no left neighbour). + self.sub8_mode_row.iter_mut().for_each(|s| *s = (usize::MAX, 0)); + self.uv_mode_row.iter_mut().for_each(|s| *s = (usize::MAX, 0)); } /// Records a block's `skip`/`is_inter`/`interp_filter` state for the next @@ -2531,14 +2543,14 @@ impl Neighbours { /// construction). See [`Self::record_mode_mi`]. fn mode_above_mi(&self, mi_r: usize, mi_c: usize) -> Option { match self.sub8_mode_col.get(mi_c) { - Some(&(row, m)) if mi_r > 0 && row == mi_r - 1 => Some(m), + Some(&(row, m)) if mi_r > self.tile_row0_mi && row == mi_r - 1 => Some(m), _ => None, } } fn mode_left_mi(&self, mi_r: usize, mi_c: usize) -> Option { match self.sub8_mode_row.get(mi_r) { - Some(&(col, m)) if mi_c > 0 && col == mi_c - 1 => Some(m), + Some(&(col, m)) if mi_c > self.tile_col0_mi && col == mi_c - 1 => Some(m), _ => None, } } @@ -2572,11 +2584,11 @@ impl Neighbours { /// block has recorded the exact neighbouring mi. fn smooth_uv_neighbour(&self, mi_r: usize, mi_c: usize, r: usize, c: usize) -> bool { let above = match self.uv_mode_col.get(mi_c) { - Some(&(row, m)) if mi_r > 0 && row == mi_r - 1 => m, + Some(&(row, m)) if mi_r > self.tile_row0_mi && row == mi_r - 1 => m, _ => self.above_uv_mode[c], }; let left = match self.uv_mode_row.get(mi_r) { - Some(&(col, m)) if mi_c > 0 && col == mi_c - 1 => m, + Some(&(col, m)) if mi_c > self.tile_col0_mi && col == mi_c - 1 => m, _ => self.left_uv_mode[r], }; is_smooth_mode(above) || is_smooth_mode(left) @@ -3745,6 +3757,11 @@ fn decode_leaf_rect( vec![0i32; chroma_w * chroma_h], ], ); + // lane-sub8 r6: the caller patches only the coarse `above_mode`/ + // `left_mode` slot (one value for the whole 16x16), so record this + // strip's own span mi-exactly like every square leaf does. + neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, mi_w, mi_h, mode); + neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, mi_w, mi_h, uv_predict_mode); neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip); neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0); Ok(mode) @@ -5324,10 +5341,9 @@ fn decode_leaf8( // this leaf's `smooth_neighbor` is built from -- passing `false` here // filtered a directional chroma block's edge at the wrong strength // (lane-sub8 r5: 4 pixels of one 8x8 leaf's chroma, deltas 1..3). - // corner-cut: the `uv_mode` neighbours are the coarse [`SUB`] slots, so - // two 8x8 leaves of one 16x16 see the slot the previous leaf wrote - // (updated below) rather than a real mi-exact neighbour; upgrade path is - // an mi-granular map like `sub8_mode_col`. + // The `uv_mode` neighbours are mi-exact (`uv_mode_col`/`uv_mode_row`), + // with the coarse [`SUB`] slot as the fallback when no block recorded + // that exact mi cell. let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); if smooth_neighbor { SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 6c80a65d..de1331c0 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -7256,7 +7256,16 @@ mod tests { // safe way to isolate the leaf count. Left red; do not "fix" this // gate by picking fixture parameters that dodge the desync without // finding it. - let (width, height) = (64usize, 64usize); + // lane-sub8 r6: three arms. The mi-granular mode maps + // (`sub8_mode_col`/`uv_mode_col` and their row twins) are per TILE -- + // the verifier's repro was a 128x64 `--tile-columns=1` stream (seeds + // 207/228) whose every mismatching luma pixel sat at x>=64, the tile + // boundary -- so one arm per tile axis is part of this gate. + for (width, height, tile_args) in [ + (64usize, 64usize, &[][..]), + (128usize, 64usize, &["--tile-columns=1"][..]), + (64usize, 128usize, &["--tile-rows=1"][..]), + ] { let mut refusals = Vec::new(); let mut fired_runs = 0u32; for attempt in 0..40u32 { @@ -7271,7 +7280,10 @@ mod tests { "-i", &gradients_source(seed, width, height, "rate=25"), "-vf", - "noise=alls=40:allf=t,format=yuv420p", + // `noise` without `all_seed` re-renders differently on + // every run (seeded-fixture-not-reproducible); pinning it + // makes (seed, cq) name one exact stream. + &format!("noise=alls=40:allf=t:all_seed={seed},format=yuv420p"), "-t", "0.04", "-f", @@ -7324,6 +7336,7 @@ mod tests { "-", "-", ]) + .args(tile_args) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) @@ -7344,13 +7357,29 @@ mod tests { } let stream = out.stdout; let before = decode::sub8_split_hits(); + let tiles_before = decode::tile_hits(); let frames = match decode_stream(&stream) { Ok(frames) => frames, Err(e) => { - refusals.push(format!("seed={seed} cq={cq}: {e}")); + // Only a named refusal ("unsupported: ...") is a skip + // reason; any other decode error is this decoder failing. + let msg = e.to_string(); + assert!( + msg.starts_with("unsupported: "), + "decode error that is not a named refusal \ + (seed={seed} cq={cq} tiles={tile_args:?}): {msg}" + ); + refusals.push(format!("seed={seed} cq={cq}: {msg}")); continue; } }; + // gate-blind-to-feature: a tile arm must actually decode more + // than one tile, not merely carry `tile_info.cols > 1`. + assert!( + tile_args.is_empty() || decode::tile_hits() - tiles_before >= 2, + "tiles={tile_args:?} decoded only {} tile(s) (seed={seed} cq={cq})", + decode::tile_hits() - tiles_before + ); if decode::sub8_split_hits() == before { refusals.push(format!( "seed={seed} cq={cq}: decoded, but no block read a real PARTITION_SPLIT below 8x8" @@ -7372,13 +7401,16 @@ mod tests { ); fired_runs += 1; if fired_runs >= 4 { - return; + break; } } - panic!( - "fewer than 4 firing+pixel-exact runs out of 40 attempts:\n{}", + assert!( + fired_runs >= 4, + "fewer than 4 firing+pixel-exact runs out of 40 attempts \ + ({width}x{height} tiles={tile_args:?}):\n{}", refusals.join("\n") ); + } } /// lane-av1golden7 r9's decisive fixture: a real aomenc stream (seed 59, diff --git a/lanes/sub8-r5.report.md b/lanes/sub8-r5.report.md index 7689dbe7..9835b2ee 100644 --- a/lanes/sub8-r5.report.md +++ b/lanes/sub8-r5.report.md @@ -43,7 +43,8 @@ existing mi-granular `sub8_mode_col`/`sub8_mode_row` machinery. hardcoded `false` at all 10 chroma reconstruct/read_plane arguments in those two functions. - `crates/ec-av1/src/refusal_inventory.rs:31` -- deleted the stale capability - claim `"a partition below 16x16 other than a clean split ..."`; r4's fixes + claim `"a partition below 8x8 (this decoder codes no leaf smaller than + 8x8)"` (corrected in r6: the string named here originally was wrong); r4's fixes removed that string from the decode path, which is exactly what made `the_decode_path_refuses_exactly_the_listed_cases` RED (charter step 2). It was the only entry the test named. diff --git a/lanes/sub8-r6.report.md b/lanes/sub8-r6.report.md new file mode 100644 index 00000000..62cd5c60 --- /dev/null +++ b/lanes/sub8-r6.report.md @@ -0,0 +1,71 @@ +# lane-sub8 report (round 6) -- verifier FAIL closed + +## The defect the verifier found (root cause) + +The mi-granular mode maps added in r2/r5 (`sub8_mode_col`/`sub8_mode_row`, +`uv_mode_col`/`uv_mode_row`) are FRAME-wide arrays read with a FRAME-relative +availability guard (`mi_r > 0` / `mi_c > 0`) and never reset per tile. Every +other neighbour site in `decode.rs` guards tile-relatively +(`mi_r > self.tile_row0_mi`, e.g. :2240, :3222, :6152). With more than one +tile, the first block of tile N read a `(row, mode)` entry left by the tile to +its LEFT (or above) as if it were its own neighbour -- wrong intra-mode +context / wrong chroma edge-filter type, and from there wrong pixels. + +## What changed (all in the lane worktree, branch `lane-sub8`) +- `crates/ec-av1/src/decode.rs:2533,2540,2574,2578` -- the four reads now guard + with `self.tile_row0_mi` / `self.tile_col0_mi`. +- `crates/ec-av1/src/decode.rs:2000` (`start_tile`) -- clears + `sub8_mode_col`/`uv_mode_col` over the tile's own mi column span + (`col0_mi..col1_mi`), alongside the existing `above_*` reset. +- `crates/ec-av1/src/decode.rs:2286` (`start_row`) -- clears + `sub8_mode_row`/`uv_mode_row` with the rest of the left context. +- `crates/ec-av1/src/decode.rs:3763` -- `decode_leaf_rect` (the 16x8/8x16 + strips) now calls `record_mode_mi`/`record_uv_mode_mi` over its real span; + before, the caller patched only the coarse 16x16 `above_mode`/`left_mode` + slot, so a neighbour of the TOP strip read the BOTTOM strip's mode. + (Sweep item 1 of the verifier's list.) +- `crates/ec-av1/src/decode.rs:5326` -- deleted the stale `corner-cut` comment + claiming the uv neighbours are coarse; they are mi-exact since r5. +- `crates/ec-av1/src/stream.rs:7259..` -- gate rewritten: three arms + (single tile / `--tile-columns=1` at 128x64 / `--tile-rows=1` at 64x128), + each needing 4 firing + pixel-exact runs; `tile_hits()` delta >= 2 asserted + on the tile arms (gate-blind-to-feature); the `Err` arm now ASSERTS the + message starts with `unsupported: ` -- any other decode error panics + instead of counting as a tolerated refusal; the fixture's `noise` filter + carries `all_seed={seed}`. +- `lanes/sub8-r5.report.md:45` -- the deleted refusal string named correctly + ("a partition below 8x8 ..."). + +## Gate + +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib sub8` -> **ok, 1 passed** +(3 arms x 4 firing+pixel-exact runs). + +Regression value proved by reverting only the guard+reset hunks: the same gate +FAILS (`U vs ffmpeg (seed=139 cq=12)`, stream.rs:7394) -- so this gate catches +the defect, it is not a pass-by-construction arm. + +EVIDENCE: /bad207.obu (sha256 0f78db8b...), bad228.obu (sha256 6a73db99...) | `decode_probe out.yuv` + `ffmpeg -i -f rawvideo -pix_fmt yuv420p` on this branch | both 12288/12288 bytes equal (verifier's pre-fix .mine.yuv: 221 and 158 differing bytes, all at x>=64) +EVIDENCE: gate run above | 3-arm gate incl. --tile-columns=1 / --tile-rows=1, tile_hits delta >= 2 asserted | ok; with the guard+reset hunks reverted the same gate FAILS at seed=139 cq=12 (U plane) +EVIDENCE: /reelb_r6.obu | `ffmpeg -t 0.4 -c:v copy -f obu` from the ReelB film, `decode_probe` on this branch | REFUSED at "a HORZ/VERT partition below 8x8 (... 4x8/8x4 need a real rectangular transform)" -- unchanged from r5, and past main's "a partition below 8x8" +EVIDENCE: fixture reproducibility | the gate's lavfi source (seed 207, 128x64) rendered twice with and without `all_seed=207` | with: d3c4b3e3... both runs; without: 5619b3ee... both runs -- ffmpeg's `noise` was in fact deterministic in this pair of runs, `all_seed` pins it explicitly rather than relying on that + +## Refusals +None lifted, none added this round; `refusal_inventory` and `gate_coverage` +stay green (totals below). + +## Suite +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib`: SUITE_TOTALS + +## Open / disposition +- deferred(an inter lane) -- `decode.rs:8547-8548` (`up_available`/ + `left_available` in the inter path) and `mvstack.rs:727,733,742,756,1486, + 1492,1501,1515` still use frame-relative `mi_row > 0` / `mi_col > 0` where + libaom uses `tile->mi_row_start`/`mi_col_start`. Same shape as this round's + defect but in code this lane never touched and no intra gate reaches; + unblocked by a multi-tile INTER gate. +- deferred(an inter-frame gate whose chroma neighbour codes a smooth + `uv_mode`) -- carried from r5: `decode.rs:12084,12096` still pass a + hardcoded `false` chroma edge-filter type. +- accepted: `smooth_uv_neighbour` falls back to the coarse `SUB` slot when no + block recorded the exact neighbouring mi.