forge
Explore
Log in

Don't you dare go Hollow

A 1:4 strip read its neighbour MODE from a 16px-coarse band -- four 8px strips alias onto one cell, and the tile-edge cell holds a sibling

Browse files at this commit

8029745ffb9ff8713e6064990745f192e4d3f579Ahmet Kaan GümüşParent: c8cc7ef
  • fix
    • a 1:4 strip read its neighbour MODE from a 16px-coarse band -- four 8px strips alias onto one cell, and the tile-edge cell holds a sibling
Show full message
fix(av1): a 1:4 strip read its neighbour MODE from a 16px-coarse band -- four 8px strips alias onto one cell, and the tile-edge cell holds a sibling

lane-rectsplitx r2. The r1 "the depth-1 rect transform unit mismatches
ffmpeg" premise is DISPROVED: the rect unit itself is right. The band
fixture's desync starts at the `mode` symbol of mi(4,8) (8-bit, cq 12,
seed 42), where the entry range matches aomdec (38331) but the value
differs (ours 11 / rng 52576, libaom 12 / rng 34624) -- a different
`kf_y_mode` CDF row, i.e. a wrong neighbour mode, not a wrong transform.

Two causes, both in the neighbour bands:
  * `decode_block_rect4` never recorded the mi-exact mode/uv_mode maps in
    its UNSPLIT arm (only the split arm did, through
    `record_mi_luma_rect`), so `mode_left_mi` answered None and the coarse
    16x16 cell -- holding the LAST of the four 32x8 strips -- stood in for
    the strip at the reader's own mi row.
  * the coarse band is also read where libaom has NO neighbour at all: at
    tile column 0 the four strips of one HORZ_4 share one `left_mode`
    cell, so strip 2 read strip 1's mode as its "left". New
    `Neighbours::modes_above_left_mi` is mi-exact AND availability-correct
    (`mi_r > tile_row0_mi` / `mi_c > tile_col0_mi` -> DC_PRED), and the
    class is swept into `decode_leaf_rect` and `decode_leaf8` too.
  * `decode_block_rect4` asked `smooth_uv_neighbour` at the SUB cell's
    top-left mi, not the strip's real mi -- a chroma-only defect (chroma
    edge-filter strength) that seed 43's VERT_4 exposed with luma
    bit-exact.

With all three, the depth-1 rect unit decodes BIT-EXACT vs aomdec on both
orientations of the fixture (seed 42 HORZ_4 and seed 43 VERT_4, 8-bit
cq 12/17, tx-size-search on, luma+U+V). The refusals are lifted and the
gate now HARD-asserts both split depths.

MEASURED RESIDUE, reported not hidden: seed 46 (8-bit, cq 12,
tx-size-search on) still mismatches CHROMA ONLY (luma bit-exact, U 32 /
V 173 samples off by +-1..2, first at chroma (16,8) = the 32x8 strip at
luma (32,16)), so this gate is RED as committed. See
lanes/rectsplitx-r2.report.md for the reproducer and the one-command
fallback to green.
crates/ec-av1/src/decode.rsmodified+65 -34
@@ -3975,6 +3975,33 @@ impl Neighbours {
39753975 /// strip path ([`decode_leaf_rect`] took this override in r4; a 32x16 strip
39763976 /// whose left neighbour was a 16x8 leaf still read the stale row and picked
39773977 /// a different CDF for the same mode value).
3978+ /// lane-rectsplitx r2: availability-correct above/left luma modes for a
3979+ /// block whose top-left mi is `(mi_r, mi_c)`. libaom reads `above_mbmi`
3980+ /// only when `up_available` and `left_mbmi` only when `left_available`;
3981+ /// the coarse [`SUB`] bands cannot express that, and with 8-px strips they
3982+ /// actively lie -- four 32x8 strips of one `HORZ_4` share ONE 16x16
3983+ /// `left_mode` cell, so the second strip at tile column 0 read the FIRST
3984+ /// strip's mode as its "left neighbour" (measured on the band fixture at
3985+ /// mi(10,0): mode 2 where libaom has DC, a different `kf_y_mode` row).
3986+ fn modes_above_left_mi(
3987+ &self,
3988+ mi_r: usize,
3989+ mi_c: usize,
3990+ fallback: (usize, usize),
3991+ ) -> (usize, usize) {
3992+ let above = if mi_r > self.tile_row0_mi {
3993+ self.mode_above_mi(mi_r, mi_c).unwrap_or(fallback.0)
3994+ } else {
3995+ DC_PRED
3996+ };
3997+ let left = if mi_c > self.tile_col0_mi {
3998+ self.mode_left_mi(mi_r, mi_c).unwrap_or(fallback.1)
3999+ } else {
4000+ DC_PRED
4001+ };
4002+ (above, left)
4003+ }
4004+
39784005 fn modes_above_left(&self, r: usize, c: usize) -> (usize, usize) {
39794006 let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
39804007 let above = self.mode_above_mi(mi_r, mi_c).unwrap_or(self.above_mode[c]);
@@ -4892,12 +4919,6 @@ fn decode_rect_split(
48924919 // 32-level 1:4 band fixture (8-bit, cq 12, seed 42). The tables and the
48934920 // per-unit rect walk stay wired above/below; the round that finds that
48944921 // defect deletes this refusal and nothing else.
4895- if tx_w != tx_h {
4896- return Err(unsupported(format!(
4897- "a split intra strip whose transform unit is the rect {tx_w}x{tx_h} (the depth-1 \
4898- step of a 1:4 strip; measured wrong pixels, refused rather than shipped)"
4899- )));
4900- }
49014922 let luma_set = txbset_for(tx_w.min(tx_h), reduced_tx_set);
49024923 let luma_scan = default_scan(tx_w.min(tx_h));
49034924 let zero_tu = vec![0i32; tx_w * tx_h];
@@ -5572,12 +5593,12 @@ fn decode_leaf_rect(
55725593 // cannot hold the modes a split (or a pair of strips) leaves behind, so
55735594 // when the map holds the block at exactly this strip's above/left mi it
55745595 // is the neighbour libaom's `above_mi`/`left_mi` reads.
5575- if let Some(m) = neighbours.mode_above_mi(leaf_mi.0, leaf_mi.1) {
5576- above_mode = m;
5577- }
5578- if let Some(m) = neighbours.mode_left_mi(leaf_mi.0, leaf_mi.1) {
5579- left_mode = m;
5580- }
5596+ // lane-rectsplitx r2 (same class as the 1:4 fix): mi-exact AND
5597+ // availability-correct -- four 16x8 strips share one coarse 16x16
5598+ // `left_mode` cell too, so the fallback must not stand in for an absent
5599+ // tile-edge neighbour.
5600+ let (above_mode, left_mode) =
5601+ neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode));
55815602 let smooth_neighbor =
55825603 is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
55835604 if smooth_neighbor {
@@ -5813,6 +5834,12 @@ fn decode_block_rect4(
58135834 left_mode = pmode;
58145835 }
58155836 }
5837+ // lane-rectsplitx r2, ROOT CAUSE of the 1:4 mismatch: mi-exact +
5838+ // availability-correct neighbour modes (see
5839+ // [`Neighbours::modes_above_left_mi`]). The coarse 16x16 bands alias every
5840+ // 8-px strip of a `HORZ_4`/`VERT_4` onto one cell.
5841+ let (above_mode, left_mode) =
5842+ neighbours.modes_above_left_mi(mi_r, mi_c, (above_mode, left_mode));
58165843 let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra) =
58175844 read_intra_mode_rect(
58185845 dec,
@@ -5832,8 +5859,13 @@ fn decode_block_rect4(
58325859 if smooth_neighbor {
58335860 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
58345861 }
5835- let smooth_neighbor_uv =
5836- neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c);
5862+ // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's
5863+ // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so
5864+ // `r * (SUB / MI)` names a different mi column and the chroma
5865+ // edge-filter strength was read from the wrong neighbour (measured:
5866+ // seed 43, the last 8x32 strip at luma (152,32), chroma-only mismatch
5867+ // with luma bit-exact).
5868+ let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c);
58375869 if filter_intra.is_some() {
58385870 FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
58395871 }
@@ -5856,20 +5888,11 @@ fn decode_block_rect4(
58565888 // both interleave in every real stream.
58575889 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
58585890 let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
5859- // lane-rectsplitx r1 MEASURED (gate below, 8-bit band fixture, cq
5860- // 12..28): depth 1 -- the 2:1 RECT unit -- fires FIRST in every
5861- // attempt that splits at all, and its per-unit walk mismatched
5862- // ffmpeg, so no attempt ever reaches a pixel-compared depth-2 strip.
5863- // A depth-2-only lift is therefore ungatable (the handoff predicted
5864- // exactly this: the two depths interleave and must land together),
5865- // and an ungated lift is not a lift -- both refuse by name until the
5866- // rect-unit defect is found.
5867- if tx_w != tx_h {
5868- return Err(unsupported(format!(
5869- "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is \
5870- not ported, depth={depth})"
5871- )));
5872- }
5891+ // lane-rectsplitx r2: both depths ship together, as the r1 handoff
5892+ // predicted -- depth 1 fires FIRST in every attempt that splits at
5893+ // all, so a depth-2-only lift could never be gated. The r1 mismatch
5894+ // was never the rect unit: it was the neighbour MODE the strip reads
5895+ // (see `modes_above_left_mi`).
58735896 let which = if depth == 1 {
58745897 &RECT4_SPLIT_DEPTH1_HITS
58755898 } else {
@@ -5928,6 +5951,14 @@ fn decode_block_rect4(
59285951 neighbours.left_uv_mode[r + cell] = uv_predict_mode;
59295952 neighbours.left_side[r + cell] = bh;
59305953 }
5954+ // ...and the mi-EXACT maps the coarse cells alias away, exactly as
5955+ // [`decode_leaf_rect`] does (the split arm above records these through
5956+ // `record_mi_luma_rect`). Without this an unsplit 32x8 strip left
5957+ // `sub8_mode_row` holding the previous block, and the next 32x32's
5958+ // strips read a stale `kf_y_mode` row (measured: mi(4,8) on the band
5959+ // fixture).
5960+ neighbours.record_mode_mi(mi_r, mi_c, mi_w, mi_h, mode);
5961+ neighbours.record_uv_mode_mi(mi_r, mi_c, mi_w, mi_h, uv_predict_mode);
59315962 let (px, py) = (mi_c * MI, mi_r * MI);
59325963 let (cpx, cpy) = (px / 2, py / 2);
59335964 let (chroma_w, chroma_h) = (bw / 2, bh / 2);
@@ -7878,12 +7909,12 @@ fn decode_leaf8(
78787909 // `prev_leaf`: one 16x16 slot cannot hold the two different modes its
78797910 // two 8x8 (or four 4x4) columns leave behind, so a leaf whose above/left
78807911 // neighbour sits in a split cell read the wrong `kf_y_mode` row.
7881- if let Some(m) = neighbours.mode_above_mi(leaf_mi.0, leaf_mi.1) {
7882- above_mode = m;
7883- }
7884- if let Some(m) = neighbours.mode_left_mi(leaf_mi.0, leaf_mi.1) {
7885- left_mode = m;
7886- }
7912+ // lane-rectsplitx r2 swept this arm into
7913+ // [`Neighbours::modes_above_left_mi`]: the mi-exact map ALSO has to answer
7914+ // "no neighbour" at a tile edge, where the coarse cell holds the block
7915+ // above/left of it inside the same 16x16.
7916+ let (above_mode, left_mode) =
7917+ neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode));
78877918 let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode);
78887919 // Chroma's edge-filter type reads the CHROMA neighbour's `uv_mode`
78897920 // (`get_intra_edge_filter_type`, reconintra.c:974), never the luma mode
crates/ec-av1/src/refusal_inventory.rsmodified+0 -2
@@ -34,13 +34,11 @@ const REFUSALS: &[&str] = &[
3434 "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)",
3535 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
3636 "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)",
37- "a split intra strip whose transform unit is the rect {tx_w}x{tx_h} (the depth-1 step of a 1:4 strip; measured wrong pixels, refused rather than shipped)",
3837 "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)",
3938 "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)",
4039 "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4140 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
4241 "a 32x32 partition type this decoder does not code (value={part32})",
43- "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is not ported, depth={depth})",
4442 "a Golomb tail longer than this decoder reads",
4543 "a tx_type symbol outside its CDF's own set: {t}",
4644 "an INTER 32x32 partition type this decoder does not code (value={part32})",
crates/ec-av1/src/stream.rsmodified+13 -16
@@ -11697,7 +11697,7 @@ mod tests {
1169711697 /// `encode::tests::every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock`
1169811698 /// against libaom's own `has_tr_*`/`has_bl_*` arrays.
1169911699 #[test]
11700- #[ignore = "lane-rectsplitx r1: the sub16 split-transform refusal is lifted and the stream now decodes, but seed 700 cq 45 mismatches ffmpeg on LUMA with 4 strips and 0 of them reaching -- a defect that refusal was hiding, not this gate's own subject"]
11700+ #[ignore = "lane-rectsplitx r2 (re-measured after the neighbour-mode fix): every seed 700..739 attempt now stops at another lane's refusal 'a HORZ_A/HORZ_B/VERT_A partition below 16x16', so the gate reaches no strip at all -- blocked on AB partitions below 16x16, not on this lane"]
1170111701 fn a_directional_16x8_strip_reads_the_right_above_right_samples() {
1170211702 const NAME: &str = "a_directional_16x8_strip_reads_the_right_above_right_samples";
1170311703 if !have_ffmpeg() {
@@ -14960,7 +14960,7 @@ mod tests {
1496014960 /// arm's 10-bit encode is a different stream, so they are a widening, not
1496114961 /// a measured firing set for this recipe -- the round that un-ignores
1496214962 /// this gate must re-measure which 10-bit seeds fire it).
14963- #[ignore = "lane-rectsplitx r1: the sub16 split-transform refusal is lifted (the pinned 16x8 fixture now decodes its whole frame pixel-exact), but seed 55 mismatches ffmpeg on the U plane -- a chroma defect that refusal was hiding, open"]
14963+ #[ignore = "lane-rectsplitx r2 (re-measured after the neighbour-mode fix): still a CHROMA-only defect behind the lifted split refusal -- 10-bit seed 49 frame 0 plane V first diff at row 4 col 60, ours 510 vs ffmpeg 509, filter_intra_rect_sub16_hits=2; sub-16 filter-intra chroma prediction, open"]
1496414964 #[test]
1496514965 fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() {
1496614966 const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact";
@@ -15104,7 +15104,7 @@ mod tests {
1510415104 /// itself is pinned by
1510515105 /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`], whose
1510615106 /// `expect_err` must become a pixel compare in that same round.
15107- #[ignore = "lane-rectsplitx r1: the sub16 split-transform refusal is lifted (the pinned 16x8 fixture now decodes its whole frame pixel-exact), but seed 55 mismatches ffmpeg on the U plane -- a chroma defect that refusal was hiding, open"]
15107+ #[ignore = "lane-rectsplitx r2 (re-measured after the neighbour-mode fix): still a CHROMA-only defect behind the lifted split refusal -- 10-bit seed 49 frame 0 plane V first diff at row 4 col 60, ours 510 vs ffmpeg 509, filter_intra_rect_sub16_hits=2; sub-16 filter-intra chroma prediction, open"]
1510815108 #[test]
1510915109 fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() {
1511015110 const NAME: &str =
@@ -16402,19 +16402,16 @@ mod tests {
1640216402 // have fired inside an attempt that then compared pixel-exact
1640316403 // (class counter-from-refused-stream -- a global counter would
1640416404 // count strips of attempts that later refused).
16405- // depth 2 (square TX_8X8 units) is what this round ported and what
16406- // the ReelB extract needed; depth 1 (the 2:1 rect unit) is
16407- // refused by name, so it can only show up here as a refusal.
16408- // Both 1:4 split depths are refused by name (the rect-unit
16409- // measurement above), so these counters are REPORTED, never
16410- // asserted: the tx-size-search half of the window exists to keep
16411- // that refusal honest -- the attempts must refuse, never mismatch.
16412- assert_eq!(
16413- depth1_proved + depth2_proved,
16414- 0,
16415- "{NAME}: {bit_depth}-bit: a 1:4 split-transform strip decoded \
16416- (depth1={depth1_proved}, depth2={depth2_proved}) although both depths are \
16417- refused -- the refusal above is dead"
16405+ // lane-rectsplitx r2: BOTH depths are now decoded, so both are
16406+ // HARD-asserted -- depth 1 is the 2:1 rect unit
16407+ // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square
16408+ // TX_8X8, and they interleave across the window; a run that only
16409+ // reached one of them proves half the walk.
16410+ assert!(
16411+ depth1_proved > 0 && depth2_proved > 0,
16412+ "{NAME}: {bit_depth}-bit: a 1:4 split-transform depth never fired inside a \
16413+ pixel-exact attempt (depth1={depth1_proved}, depth2={depth2_proved}) -- the \
16414+ tx-size-search half of the window proved nothing"
1641816415 );
1641916416 eprintln!(
1642016417 "{NAME}: {bit_depth}-bit split-transform 1:4 strips: depth1={depth1_proved}, \
lanes/COMMON-20260901.mdmodified+11 -0
@@ -89,3 +89,14 @@ NEVER wait with a foreground `until/while ... sleep` loop or `tail --pid`.
8989 ## NEVER pkill BY BINARY NAME (2026-09-02: one lane's `pkill -f ec_av1-<hash>` killed another lane's suite)
9090 The test binary hash is identical across worktrees. Kill only by PID you own (`$!`, or the systemd unit
9191 name you started). `pkill -f`/`killall` on cargo/ec_av1 patterns is forbidden.
92+
93+## NEVER `cargo fmt` IN A LANE (3 lanes lost their diffs to it on 2026-09-02)
94+main is not rustfmt-clean (~6000 lines of churn). Hand-indent; `cargo test --no-run` is the check.
95+If you ran it: extract your own hunks, `git checkout -- crates/`, re-apply.
96+
97+## MEMORY (user order 2026-09-02: an unsteady box fails the job)
98+30 GB box shared by ~10 agents. Every decode/encode/probe invocation runs under
99+`systemd-run --user --scope -q -p MemoryMax=6G <cmd>`; suites under a unit with `-p MemoryMax=10G`;
100+never two suites per lane; film extracts ≤2 s; a watchdog (`ec-memwatch` user unit, log
101+`$HOME/.cache/ec-memwatch.log`) SIGKILLs any codec/test process above 6 GiB RSS or the largest one
102+when MemAvailable < 3 GiB — a killed run means YOUR command exceeded the budget: bound it, do not retry as-is.