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 commit8029745ffb9ff8713e6064990745f192e4d3f579Parent: 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
4 changed files +89 -52
- crates/ec-av1/src/decode.rs +65 -34
- crates/ec-av1/src/refusal_inventory.rs +0 -2
- crates/ec-av1/src/stream.rs +13 -16
- lanes/COMMON-20260901.md +11 -0
crates/ec-av1/src/decode.rsmodified+65 -34
| @@ -3975,6 +3975,33 @@ impl Neighbours { | ||
| 3975 | 3975 | /// strip path ([`decode_leaf_rect`] took this override in r4; a 32x16 strip |
| 3976 | 3976 | /// whose left neighbour was a 16x8 leaf still read the stale row and picked |
| 3977 | 3977 | /// 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 | + | |
| 3978 | 4005 | fn modes_above_left(&self, r: usize, c: usize) -> (usize, usize) { |
| 3979 | 4006 | let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); |
| 3980 | 4007 | let above = self.mode_above_mi(mi_r, mi_c).unwrap_or(self.above_mode[c]); |
| @@ -4892,12 +4919,6 @@ fn decode_rect_split( | ||
| 4892 | 4919 | // 32-level 1:4 band fixture (8-bit, cq 12, seed 42). The tables and the |
| 4893 | 4920 | // per-unit rect walk stay wired above/below; the round that finds that |
| 4894 | 4921 | // 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 | - } | |
| 4901 | 4922 | let luma_set = txbset_for(tx_w.min(tx_h), reduced_tx_set); |
| 4902 | 4923 | let luma_scan = default_scan(tx_w.min(tx_h)); |
| 4903 | 4924 | let zero_tu = vec![0i32; tx_w * tx_h]; |
| @@ -5572,12 +5593,12 @@ fn decode_leaf_rect( | ||
| 5572 | 5593 | // cannot hold the modes a split (or a pair of strips) leaves behind, so |
| 5573 | 5594 | // when the map holds the block at exactly this strip's above/left mi it |
| 5574 | 5595 | // 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)); | |
| 5581 | 5602 | let smooth_neighbor = |
| 5582 | 5603 | is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 5583 | 5604 | if smooth_neighbor { |
| @@ -5813,6 +5834,12 @@ fn decode_block_rect4( | ||
| 5813 | 5834 | left_mode = pmode; |
| 5814 | 5835 | } |
| 5815 | 5836 | } |
| 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)); | |
| 5816 | 5843 | let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra) = |
| 5817 | 5844 | read_intra_mode_rect( |
| 5818 | 5845 | dec, |
| @@ -5832,8 +5859,13 @@ fn decode_block_rect4( | ||
| 5832 | 5859 | if smooth_neighbor { |
| 5833 | 5860 | SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); |
| 5834 | 5861 | } |
| 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); | |
| 5837 | 5869 | if filter_intra.is_some() { |
| 5838 | 5870 | FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); |
| 5839 | 5871 | } |
| @@ -5856,20 +5888,11 @@ fn decode_block_rect4( | ||
| 5856 | 5888 | // both interleave in every real stream. |
| 5857 | 5889 | TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); |
| 5858 | 5890 | 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`). | |
| 5873 | 5896 | let which = if depth == 1 { |
| 5874 | 5897 | &RECT4_SPLIT_DEPTH1_HITS |
| 5875 | 5898 | } else { |
| @@ -5928,6 +5951,14 @@ fn decode_block_rect4( | ||
| 5928 | 5951 | neighbours.left_uv_mode[r + cell] = uv_predict_mode; |
| 5929 | 5952 | neighbours.left_side[r + cell] = bh; |
| 5930 | 5953 | } |
| 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); | |
| 5931 | 5962 | let (px, py) = (mi_c * MI, mi_r * MI); |
| 5932 | 5963 | let (cpx, cpy) = (px / 2, py / 2); |
| 5933 | 5964 | let (chroma_w, chroma_h) = (bw / 2, bh / 2); |
| @@ -7878,12 +7909,12 @@ fn decode_leaf8( | ||
| 7878 | 7909 | // `prev_leaf`: one 16x16 slot cannot hold the two different modes its |
| 7879 | 7910 | // two 8x8 (or four 4x4) columns leave behind, so a leaf whose above/left |
| 7880 | 7911 | // 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)); | |
| 7887 | 7918 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 7888 | 7919 | // Chroma's edge-filter type reads the CHROMA neighbour's `uv_mode` |
| 7889 | 7920 | // (`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] = &[ | ||
| 34 | 34 | "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)", |
| 35 | 35 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 36 | 36 | "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)", | |
| 38 | 37 | "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)", |
| 39 | 38 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", |
| 40 | 39 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 41 | 40 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 42 | 41 | "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})", | |
| 44 | 42 | "a Golomb tail longer than this decoder reads", |
| 45 | 43 | "a tx_type symbol outside its CDF's own set: {t}", |
| 46 | 44 | "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 { | ||
| 11697 | 11697 | /// `encode::tests::every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock` |
| 11698 | 11698 | /// against libaom's own `has_tr_*`/`has_bl_*` arrays. |
| 11699 | 11699 | #[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"] | |
| 11701 | 11701 | fn a_directional_16x8_strip_reads_the_right_above_right_samples() { |
| 11702 | 11702 | const NAME: &str = "a_directional_16x8_strip_reads_the_right_above_right_samples"; |
| 11703 | 11703 | if !have_ffmpeg() { |
| @@ -14960,7 +14960,7 @@ mod tests { | ||
| 14960 | 14960 | /// arm's 10-bit encode is a different stream, so they are a widening, not |
| 14961 | 14961 | /// a measured firing set for this recipe -- the round that un-ignores |
| 14962 | 14962 | /// 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"] | |
| 14964 | 14964 | #[test] |
| 14965 | 14965 | fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() { |
| 14966 | 14966 | const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact"; |
| @@ -15104,7 +15104,7 @@ mod tests { | ||
| 15104 | 15104 | /// itself is pinned by |
| 15105 | 15105 | /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`], whose |
| 15106 | 15106 | /// `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"] | |
| 15108 | 15108 | #[test] |
| 15109 | 15109 | fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() { |
| 15110 | 15110 | const NAME: &str = |
| @@ -16402,19 +16402,16 @@ mod tests { | ||
| 16402 | 16402 | // have fired inside an attempt that then compared pixel-exact |
| 16403 | 16403 | // (class counter-from-refused-stream -- a global counter would |
| 16404 | 16404 | // 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" | |
| 16418 | 16415 | ); |
| 16419 | 16416 | eprintln!( |
| 16420 | 16417 | "{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`. | ||
| 89 | 89 | ## NEVER pkill BY BINARY NAME (2026-09-02: one lane's `pkill -f ec_av1-<hash>` killed another lane's suite) |
| 90 | 90 | The test binary hash is identical across worktrees. Kill only by PID you own (`$!`, or the systemd unit |
| 91 | 91 | 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. |