Split transform units answered their intra reach as if each were a standalone block -- libaom answers from the unit's row_off/col_off inside its parent, so a D203_PRED 8x8 unit at col_off=2 read bottom-left samples that are not reconstructed yet
Browse files at this commitb4b7e7c8a3d0759ceea2bf15e483f884a9b6f8c8Parent: b49a79b- fix
- split transform units answered their intra reach as if each were a standalone block -- libaom answers from the unit's row_off/col_off inside its parent, so a D203_PRED 8x8 unit at col_off=2 read bottom-left samples that are not reconstructed yet
- seed 46 of the 1:4-strip recipe mismatched ffmpeg on 916 luma samples of frame 0 with a fully exact entropy ladder
5 changed files +407 -8
- crates/ec-av1/src/decode.rs +63 -3
- crates/ec-av1/src/encode.rs +61 -1
- crates/ec-av1/src/gate_coverage.rs +0 -4
- crates/ec-av1/src/stream.rs +192 -0
- lanes/band46-r1.report.md +91 -0
crates/ec-av1/src/decode.rsmodified+63 -3
| @@ -680,6 +680,46 @@ pub(crate) fn smooth_luma_hits() -> usize { | |||
| 680 | SMOOTH_LUMA_HITS.with(|c| c.get()) | 680 | SMOOTH_LUMA_HITS.with(|c| c.get()) |
| 681 | } | 681 | } |
| 682 | 682 | ||
| 683 | +thread_local! { | ||
| 684 | + /// lane-band46 r1: how many split-transform units answered their intra | ||
| 685 | + /// reach DIFFERENTLY under libaom's `row_off`/`col_off` rules than the | ||
| 686 | + /// standalone-block lookup this decoder used to apply to them (class | ||
| 687 | + /// reach-is-per-transform-unit). Every hit is a transform unit whose | ||
| 688 | + /// above-right / below-left reference samples used to be wrong. | ||
| 689 | + static SPLIT_TU_REACH_FIX_HITS: std::cell::Cell<usize> = | ||
| 690 | + const { std::cell::Cell::new(0) }; | ||
| 691 | +} | ||
| 692 | + | ||
| 693 | +/// Current value of [`SPLIT_TU_REACH_FIX_HITS`]. | ||
| 694 | +pub(crate) fn split_tu_reach_fix_hits() -> usize { | ||
| 695 | + SPLIT_TU_REACH_FIX_HITS.with(|c| c.get()) | ||
| 696 | +} | ||
| 697 | + | ||
| 698 | +/// libaom `has_top_right`/`has_bottom_left` for one transform unit of a split | ||
| 699 | +/// transform ([`crate::encode::Reach::of_tu`]), counting how often that answer | ||
| 700 | +/// differs from the standalone-block answer the call sites used before | ||
| 701 | +/// lane-band46 r1 -- the counter a gate asserts on to prove a stream really | ||
| 702 | +/// exercised the fix. | ||
| 703 | +#[allow(clippy::too_many_arguments)] | ||
| 704 | +fn tu_reach( | ||
| 705 | + bw: usize, | ||
| 706 | + bh: usize, | ||
| 707 | + tx: usize, | ||
| 708 | + row_off: usize, | ||
| 709 | + col_off: usize, | ||
| 710 | + px: usize, | ||
| 711 | + py: usize, | ||
| 712 | + width: usize, | ||
| 713 | + height: usize, | ||
| 714 | +) -> Reach { | ||
| 715 | + let fixed = Reach::of_tu(bw, bh, tx, row_off, col_off, px, py, width, height); | ||
| 716 | + let standalone = Reach::of(tx, px + col_off * MI, py + row_off * MI, width, height); | ||
| 717 | + if fixed != standalone { | ||
| 718 | + SPLIT_TU_REACH_FIX_HITS.with(|c| c.set(c.get() + 1)); | ||
| 719 | + } | ||
| 720 | + fixed | ||
| 721 | +} | ||
| 722 | + | ||
| 683 | // How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12), | 723 | // How many `uv_mode` reads resolved to `SMOOTH_PRED..=PAETH_PRED` (9..=12), |
| 684 | // across every call on the current thread -- lane-chroma r3's own before/after | 724 | // across every call on the current thread -- lane-chroma r3's own before/after |
| 685 | // counter, proving a stream actually exercised chroma's smooth/paeth | 725 | // counter, proving a stream actually exercised chroma's smooth/paeth |
| @@ -7218,7 +7258,17 @@ fn decode_block( | |||
| 7218 | let tu_px = px + tu_col * logical_tx; | 7258 | let tu_px = px + tu_col * logical_tx; |
| 7219 | let tu_py = py + tu_row * logical_tx; | 7259 | let tu_py = py + tu_row * logical_tx; |
| 7220 | let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0]; | 7260 | let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0]; |
| 7221 | - let tu_reach = Reach::of(logical_tx, tu_px, tu_py, y.width, y.height); | 7261 | + let tu_reach = tu_reach( |
| 7262 | + side, | ||
| 7263 | + side, | ||
| 7264 | + logical_tx, | ||
| 7265 | + tu_row * (logical_tx / MI), | ||
| 7266 | + tu_col * (logical_tx / MI), | ||
| 7267 | + px, | ||
| 7268 | + py, | ||
| 7269 | + y.width, | ||
| 7270 | + y.height, | ||
| 7271 | + ); | ||
| 7222 | // This transform unit's own bsize (`logical_tx`) is smaller | 7272 | // This transform unit's own bsize (`logical_tx`) is smaller |
| 7223 | // than the block it sits in (`side`), so `txb_skip_ctx` is | 7273 | // than the block it sits in (`side`), so `txb_skip_ctx` is |
| 7224 | // the neighbour-magnitude table, not the lone-TU 0 (spec | 7274 | // the neighbour-magnitude table, not the lone-TU 0 (spec |
| @@ -7576,7 +7626,7 @@ fn decode_leaf8( | |||
| 7576 | let tu_px = px + tu_col * 4; | 7626 | let tu_px = px + tu_col * 4; |
| 7577 | let tu_py = py + tu_row * 4; | 7627 | let tu_py = py + tu_row * 4; |
| 7578 | let tu_around = neighbours.around_mi(tu_mi, 4)[0]; | 7628 | let tu_around = neighbours.around_mi(tu_mi, 4)[0]; |
| 7579 | - let tu_reach = Reach::of(4, tu_px, tu_py, y.width, y.height); | 7629 | + let tu_reach = tu_reach(8, 8, 4, tu_row, tu_col, px, py, y.width, y.height); |
| 7580 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); | 7630 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); |
| 7581 | let tu_grid = read_plane( | 7631 | let tu_grid = read_plane( |
| 7582 | dec, | 7632 | dec, |
| @@ -8104,7 +8154,17 @@ fn decode_leaf_rect8( | |||
| 8104 | }; | 8154 | }; |
| 8105 | let (tu_px, tu_py) = (tu_mi.1 * MI, tu_mi.0 * MI); | 8155 | let (tu_px, tu_py) = (tu_mi.1 * MI, tu_mi.0 * MI); |
| 8106 | let tu_around = neighbours.around_mi(tu_mi, 4)[0]; | 8156 | let tu_around = neighbours.around_mi(tu_mi, 4)[0]; |
| 8107 | - let tu_reach = Reach::of(4, tu_px, tu_py, y.width, y.height); | 8157 | + let tu_reach = tu_reach( |
| 8158 | + bw, | ||
| 8159 | + bh, | ||
| 8160 | + 4, | ||
| 8161 | + if vert { tu } else { 0 }, | ||
| 8162 | + if vert { 0 } else { tu }, | ||
| 8163 | + px, | ||
| 8164 | + py, | ||
| 8165 | + y.width, | ||
| 8166 | + y.height, | ||
| 8167 | + ); | ||
| 8108 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); | 8168 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); |
| 8109 | if skip { | 8169 | if skip { |
| 8110 | // A skipped leaf still predicts per transform unit: the | 8170 | // A skipped leaf still predicts per transform unit: the |
crates/ec-av1/src/encode.rsmodified+61 -1
| @@ -1008,7 +1008,7 @@ struct At { | |||
| 1008 | /// block whose transform covers it whole, whether the samples above its right | 1008 | /// block whose transform covers it whole, whether the samples above its right |
| 1009 | /// (or below its left) are decoded depends only on where the block sits inside | 1009 | /// (or below its left) are decoded depends only on where the block sits inside |
| 1010 | /// its 64x64 superblock, which is a pinned table per block size. | 1010 | /// its 64x64 superblock, which is a pinned table per block size. |
| 1011 | -#[derive(Clone, Copy)] | 1011 | +#[derive(Clone, Copy, PartialEq, Eq)] |
| 1012 | pub(crate) struct Reach { | 1012 | pub(crate) struct Reach { |
| 1013 | pub(crate) above_right: bool, | 1013 | pub(crate) above_right: bool, |
| 1014 | pub(crate) below_left: bool, | 1014 | pub(crate) below_left: bool, |
| @@ -1278,6 +1278,66 @@ impl Reach { | |||
| 1278 | (blk_row << (5 - bw_log2)) + blk_col | 1278 | (blk_row << (5 - bw_log2)) + blk_col |
| 1279 | } | 1279 | } |
| 1280 | 1280 | ||
| 1281 | + /// libaom `has_top_right`/`has_bottom_left` for ONE TRANSFORM UNIT inside | ||
| 1282 | + /// a block whose transform split (`reconintra.c`, the `row_off`/`col_off` | ||
| 1283 | + /// branches that [`Self::of`]/[`Self::of_rect`] never see because they | ||
| 1284 | + /// answer at `row_off == col_off == 0`). class reach-is-per-transform-unit: | ||
| 1285 | + /// a split unit is NOT a standalone block, so asking [`Self::of`] with the | ||
| 1286 | + /// unit's own size and position reads a table row for a block that is not | ||
| 1287 | + /// there -- libaom instead answers from the unit's offset within its | ||
| 1288 | + /// parent, and only the (0, 0) unit ever reaches the table. | ||
| 1289 | + /// | ||
| 1290 | + /// `row_off`/`col_off` are in 4-sample units, `px`/`py` are the PARENT | ||
| 1291 | + /// block's top-left sample. | ||
| 1292 | + #[allow(clippy::too_many_arguments)] | ||
| 1293 | + pub(crate) fn of_tu( | ||
| 1294 | + bw: usize, | ||
| 1295 | + bh: usize, | ||
| 1296 | + tx: usize, | ||
| 1297 | + row_off: usize, | ||
| 1298 | + col_off: usize, | ||
| 1299 | + px: usize, | ||
| 1300 | + py: usize, | ||
| 1301 | + width: usize, | ||
| 1302 | + height: usize, | ||
| 1303 | + ) -> Self { | ||
| 1304 | + let (tu_x, tu_y) = (px + col_off * 4, py + row_off * 4); | ||
| 1305 | + let unit = tx / 4; | ||
| 1306 | + let square = bw == bh; | ||
| 1307 | + Self { | ||
| 1308 | + above_right: (row_off > 0 || py > 0) | ||
| 1309 | + && tu_x + tx < width | ||
| 1310 | + && if row_off > 0 { | ||
| 1311 | + // The top-right samples are inside the row of units | ||
| 1312 | + // above, already reconstructed -- provided they stay | ||
| 1313 | + // within the parent block. | ||
| 1314 | + col_off + unit < bw / 4 | ||
| 1315 | + } else if col_off + unit < bw / 4 { | ||
| 1316 | + true | ||
| 1317 | + } else if square { | ||
| 1318 | + Self::top_right(bw, px, py) | ||
| 1319 | + } else { | ||
| 1320 | + Self::top_right_rect(bw, bh, px, py) | ||
| 1321 | + }, | ||
| 1322 | + below_left: (px > 0) | ||
| 1323 | + && tu_y + tx < height | ||
| 1324 | + // "Bottom-left pixels are in the bottom-left block, which is | ||
| 1325 | + // not available" -- any unit but the leftmost column. | ||
| 1326 | + && col_off == 0 | ||
| 1327 | + && (row_off + unit < bh / 4 | ||
| 1328 | + || if (px % SUPERBLOCK) / bw == 0 { | ||
| 1329 | + // Leftmost column of the superblock: the samples are | ||
| 1330 | + // in the left superblock iff they stay inside its | ||
| 1331 | + // height -- counted from THIS unit, not the block. | ||
| 1332 | + (tu_y % SUPERBLOCK) + tx < SUPERBLOCK | ||
| 1333 | + } else if square { | ||
| 1334 | + Self::bottom_left(bw, px, py) | ||
| 1335 | + } else { | ||
| 1336 | + Self::bottom_left_rect(bw, bh, px, py) | ||
| 1337 | + }), | ||
| 1338 | + } | ||
| 1339 | + } | ||
| 1340 | + | ||
| 1281 | /// libaom `has_bottom_left`, same granularity as [`Self::top_right_rect`]. | 1341 | /// libaom `has_bottom_left`, same granularity as [`Self::top_right_rect`]. |
| 1282 | fn bottom_left_rect(bw: usize, bh: usize, x: usize, y: usize) -> bool { | 1342 | fn bottom_left_rect(bw: usize, bh: usize, x: usize, y: usize) -> bool { |
| 1283 | const SB_MI: usize = SUPERBLOCK / 4; | 1343 | const SB_MI: usize = SUPERBLOCK / 4; |
crates/ec-av1/src/gate_coverage.rsmodified+0 -4
| @@ -280,10 +280,6 @@ const NEVER_ON_10BIT: &[(&str, &str)] = &[ | |||
| 280 | "enable-onesided-comp", | 280 | "enable-onesided-comp", |
| 281 | "hole at both depths, see the 8-bit list (5 pinned off, 10 defaulted)", | 281 | "hole at both depths, see the 8-bit list (5 pinned off, 10 defaulted)", |
| 282 | ), | 282 | ), |
| 283 | - ( | ||
| 284 | - "enable-tx-size-search", | ||
| 285 | - "hole at both depths, see the 8-bit list (11 of 15 pin =0)", | ||
| 286 | - ), | ||
| 287 | ]; | 283 | ]; |
| 288 | 284 | ||
| 289 | #[cfg(test)] | 285 | #[cfg(test)] |
crates/ec-av1/src/stream.rsmodified+192 -0
| @@ -15746,4 +15746,196 @@ mod tests { | |||
| 15746 | ); | 15746 | ); |
| 15747 | } | 15747 | } |
| 15748 | } | 15748 | } |
| 15749 | + | ||
| 15750 | + /// lane-band46 r1: a real `aomenc` band stream whose 16x16 (and 8x8) | ||
| 15751 | + /// intra blocks SPLIT their transform, so every unit but the first | ||
| 15752 | + /// answers `has_top_right`/`has_bottom_left` from its `row_off`/`col_off` | ||
| 15753 | + /// inside the parent block rather than from the standalone-block tables | ||
| 15754 | + /// (libaom `reconintra.c`; class reach-is-per-transform-unit). | ||
| 15755 | + /// | ||
| 15756 | + /// Seed 46 of the sibling 1:4-strip recipe is the stream that found it: | ||
| 15757 | + /// it carries ZERO 1:4 strips, so that gate skipped it as out of scope | ||
| 15758 | + /// while frame 0 luma mismatched ffmpeg over 916 samples -- the first at | ||
| 15759 | + /// (x 14, y 18), the second 8x8 transform unit of the D203_PRED block at | ||
| 15760 | + /// mi (4, 0), whose bottom-left samples sit in a unit that is not | ||
| 15761 | + /// reconstructed yet (`col_off > 0` => `has_bottom_left` is 0). The full | ||
| 15762 | + /// mode-info range ladder matched aomdec element for element, so the | ||
| 15763 | + /// defect was reconstruction, never entropy. | ||
| 15764 | + /// | ||
| 15765 | + /// The gate asserts the fix FIRED (`split_tu_reach_fix_hits`, transform | ||
| 15766 | + /// units whose reach differs from the old standalone answer) on 8 AND 10 | ||
| 15767 | + /// bit, and that seed 46 itself decodes pixel-exact. | ||
| 15768 | + #[test] | ||
| 15769 | + fn a_real_aomenc_band_stream_seed46_decodes_pixel_exact() { | ||
| 15770 | + const NAME: &str = "a_real_aomenc_band_stream_seed46_decodes_pixel_exact"; | ||
| 15771 | + let _gate_lock = lock_gate_counters(); | ||
| 15772 | + if !have_ffmpeg() { | ||
| 15773 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 15774 | + return; | ||
| 15775 | + } | ||
| 15776 | + if !have_aomenc() { | ||
| 15777 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 15778 | + return; | ||
| 15779 | + } | ||
| 15780 | + let (width, height) = (192usize, 128usize); | ||
| 15781 | + let mut matched = 0u32; | ||
| 15782 | + let mut refusals = 0u32; | ||
| 15783 | + let mut fixed_tus = 0usize; | ||
| 15784 | + let mut fixed_tus_10bit = 0usize; | ||
| 15785 | + let mut seed46_compared = [false; 2]; | ||
| 15786 | + for (di, bit_depth) in [8u32, 10].into_iter().enumerate() { | ||
| 15787 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 15788 | + for seed in 42u32..=51 { | ||
| 15789 | + // Byte-identical recipe to the 1:4-strip sibling gate, whose | ||
| 15790 | + // seed-46 attempt is what exposed this defect (that gate | ||
| 15791 | + // classes a no-1:4 stream as out of scope; this one compares | ||
| 15792 | + // it). | ||
| 15793 | + let bands = format!( | ||
| 15794 | + "geq=lum='mod(floor(Y/16),2)*160+48':cb=128:cr=128,noise=alls=10:all_seed={seed}" | ||
| 15795 | + ); | ||
| 15796 | + let source = if seed % 2 == 0 { | ||
| 15797 | + format!("color=c=black:size={width}x{height}:duration=0.04:rate=25,{bands}") | ||
| 15798 | + } else { | ||
| 15799 | + format!( | ||
| 15800 | + "color=c=black:size={height}x{width}:duration=0.04:rate=25,{bands},transpose=1" | ||
| 15801 | + ) | ||
| 15802 | + }; | ||
| 15803 | + let y4m = Command::new("ffmpeg") | ||
| 15804 | + .args([ | ||
| 15805 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", "0.04", "-pix_fmt", | ||
| 15806 | + pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 15807 | + ]) | ||
| 15808 | + .stdin(Stdio::null()) | ||
| 15809 | + .stdout(Stdio::piped()) | ||
| 15810 | + .stderr(Stdio::piped()) | ||
| 15811 | + .output() | ||
| 15812 | + .expect("ffmpeg failed to run"); | ||
| 15813 | + assert!( | ||
| 15814 | + y4m.status.success(), | ||
| 15815 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 15816 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 15817 | + ); | ||
| 15818 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 15819 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 15820 | + let mut child = Command::new(aomenc_path()) | ||
| 15821 | + .args([ | ||
| 15822 | + "--codec=av1", | ||
| 15823 | + "--passes=1", | ||
| 15824 | + "--end-usage=q", | ||
| 15825 | + "--cq-level=32", | ||
| 15826 | + "--cpu-used=0", | ||
| 15827 | + "--threads=1", | ||
| 15828 | + "--row-mt=0", | ||
| 15829 | + "--sb-size=64", | ||
| 15830 | + &depth_arg, | ||
| 15831 | + &input_depth_arg, | ||
| 15832 | + "--enable-rect-partitions=1", | ||
| 15833 | + "--enable-ab-partitions=0", | ||
| 15834 | + "--enable-1to4-partitions=1", | ||
| 15835 | + "--min-partition-size=16", | ||
| 15836 | + "--max-partition-size=64", | ||
| 15837 | + // Left ON: this is what makes a 16x16 block code four | ||
| 15838 | + // 8x8 transform units, the shape the fix is about. | ||
| 15839 | + "--enable-tx-size-search=1", | ||
| 15840 | + "--enable-restoration=0", | ||
| 15841 | + "--enable-palette=0", | ||
| 15842 | + "--deltaq-mode=0", | ||
| 15843 | + "--enable-filter-intra=0", | ||
| 15844 | + "--enable-cfl-intra=0", | ||
| 15845 | + "--enable-intrabc=0", | ||
| 15846 | + "--obu", | ||
| 15847 | + "-o", | ||
| 15848 | + "-", | ||
| 15849 | + "-", | ||
| 15850 | + ]) | ||
| 15851 | + .stdin(Stdio::piped()) | ||
| 15852 | + .stdout(Stdio::piped()) | ||
| 15853 | + .stderr(Stdio::piped()) | ||
| 15854 | + .spawn() | ||
| 15855 | + .expect("aomenc failed to start"); | ||
| 15856 | + child | ||
| 15857 | + .stdin | ||
| 15858 | + .take() | ||
| 15859 | + .expect("aomenc stdin") | ||
| 15860 | + .write_all(&y4m.stdout) | ||
| 15861 | + .expect("writing y4m to aomenc"); | ||
| 15862 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 15863 | + assert!( | ||
| 15864 | + out.status.success(), | ||
| 15865 | + "{NAME}: aomenc refused the fixture: {}", | ||
| 15866 | + String::from_utf8_lossy(&out.stderr) | ||
| 15867 | + ); | ||
| 15868 | + let stream = out.stdout; | ||
| 15869 | + let before = crate::decode::split_tu_reach_fix_hits(); | ||
| 15870 | + let frames = match decode_stream(&stream) { | ||
| 15871 | + Err(e) => { | ||
| 15872 | + let msg = e.to_string(); | ||
| 15873 | + assert!( | ||
| 15874 | + msg.contains("unsupported"), | ||
| 15875 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit seed \ | ||
| 15876 | + {seed}): {msg}" | ||
| 15877 | + ); | ||
| 15878 | + assert!( | ||
| 15879 | + seed != 46, | ||
| 15880 | + "{NAME}: seed 46 ({bit_depth}-bit) must decode -- it is this gate's \ | ||
| 15881 | + pinned stream, and it refused: {msg}" | ||
| 15882 | + ); | ||
| 15883 | + refusals += 1; | ||
| 15884 | + eprintln!("{NAME}: {bit_depth}-bit seed {seed} refusal: {msg}"); | ||
| 15885 | + continue; | ||
| 15886 | + } | ||
| 15887 | + Ok(frames) => frames, | ||
| 15888 | + }; | ||
| 15889 | + let reference = if bit_depth == 10 { | ||
| 15890 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) | ||
| 15891 | + } else { | ||
| 15892 | + ffmpeg_decode_sequence(&stream, width, height, frames.len()) | ||
| 15893 | + }; | ||
| 15894 | + assert_eq!(frames.len(), reference.len(), "{NAME}: frame count"); | ||
| 15895 | + for (i, (got, want)) in frames.iter().zip(&reference).enumerate() { | ||
| 15896 | + assert_eq!( | ||
| 15897 | + got.y, want.y, | ||
| 15898 | + "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit seed {seed})" | ||
| 15899 | + ); | ||
| 15900 | + assert_eq!( | ||
| 15901 | + got.u, want.u, | ||
| 15902 | + "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit seed {seed})" | ||
| 15903 | + ); | ||
| 15904 | + assert_eq!( | ||
| 15905 | + got.v, want.v, | ||
| 15906 | + "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit seed {seed})" | ||
| 15907 | + ); | ||
| 15908 | + } | ||
| 15909 | + let fixed = crate::decode::split_tu_reach_fix_hits() - before; | ||
| 15910 | + fixed_tus += fixed; | ||
| 15911 | + if bit_depth == 10 { | ||
| 15912 | + fixed_tus_10bit += fixed; | ||
| 15913 | + } | ||
| 15914 | + if seed == 46 { | ||
| 15915 | + seed46_compared[di] = true; | ||
| 15916 | + } | ||
| 15917 | + matched += 1; | ||
| 15918 | + } | ||
| 15919 | + } | ||
| 15920 | + eprintln!( | ||
| 15921 | + "{NAME}: {matched} pixel-exact streams, {refusals} named refusals out of 20; \ | ||
| 15922 | + {fixed_tus} split transform units took the per-TU reach ({fixed_tus_10bit} of them \ | ||
| 15923 | + 10-bit)" | ||
| 15924 | + ); | ||
| 15925 | + assert!( | ||
| 15926 | + seed46_compared[0] && seed46_compared[1], | ||
| 15927 | + "{NAME}: seed 46 was not compared on both depths (8-bit {}, 10-bit {})", | ||
| 15928 | + seed46_compared[0], seed46_compared[1] | ||
| 15929 | + ); | ||
| 15930 | + assert!( | ||
| 15931 | + fixed_tus > 0, | ||
| 15932 | + "{NAME}: no split transform unit answered its reach from its offset inside the \ | ||
| 15933 | + parent block -- the recipe lost the shape this gate pins" | ||
| 15934 | + ); | ||
| 15935 | + assert!( | ||
| 15936 | + fixed_tus_10bit > 0, | ||
| 15937 | + "{NAME}: the shape never appeared in a 10-BIT pixel-exact stream (his films are \ | ||
| 15938 | + yuv420p10le)" | ||
| 15939 | + ); | ||
| 15940 | + } | ||
| 15749 | } | 15941 | } |
lanes/band46-r1.report.mdadded+91 -0
| @@ -0,0 +1,91 @@ | |||
| 1 | +# lane-band46 r1 — the seed-46 "out-of-scope" mismatch: split transform units answered their intra reach as standalone blocks | ||
| 2 | + | ||
| 3 | +## Premise, re-measured on main 146896f (not the chartered 8262b99) | ||
| 4 | +`git log --oneline -1` in the worktree = `146896f` (lane-cfl merged after the charter was written). | ||
| 5 | +The defect reproduces there, so it is a main defect, not a rectchroma-branch one. | ||
| 6 | + | ||
| 7 | +Stream: the rectchroma gate recipe verbatim (192x128 bands + `noise=alls=10:all_seed=46`, | ||
| 8 | +`--enable-ab-partitions=0 --enable-1to4-partitions=1 --enable-tx-size-search=1`, cq 32, 8-bit), | ||
| 9 | +pinned twice: `sha256 9952fd31a1d51ccd5e066bd249babf676f6bb59318a1877272fa8fbd060d809b` both runs. | ||
| 10 | + | ||
| 11 | +## Root cause — class `reach-is-per-transform-unit` | ||
| 12 | +`crates/ec-av1/src/decode.rs` computed a split transform unit's intra reach with | ||
| 13 | +`Reach::of(logical_tx, tu_px, tu_py, ..)` — the *standalone-block* `has_top_right`/ | ||
| 14 | +`has_bottom_left` table lookup, asking "what may a block of this size at this superblock | ||
| 15 | +position read". libaom (`av1/common/reconintra.c`) never does that for a unit inside a block: | ||
| 16 | +it answers from the unit's `row_off`/`col_off` within its parent, and only the (0,0) unit ever | ||
| 17 | +reaches the table. | ||
| 18 | + | ||
| 19 | +* `has_bottom_left`: `if (col_off > 0) return 0;` — the bottom-left samples of any unit but the | ||
| 20 | + leftmost column live in a unit that is not reconstructed yet. | ||
| 21 | +* `has_bottom_left`, leftmost-superblock-column branch: counts `row_off + tx_size_high_unit` | ||
| 22 | + from the UNIT, not the block. | ||
| 23 | +* `has_top_right`: `if (row_off > 0) return col_off + tx_size_wide_unit < plane_bw_unit;` — a | ||
| 24 | + lower row of units never consults the table at all. | ||
| 25 | + | ||
| 26 | +Seed 46, frame 0: block at mi (4,0) is `D203_PRED` (mode symbol 7, angle_delta 0) with | ||
| 27 | +`tx_depth=1`, i.e. four 8x8 units. Unit 1 (`col_off = 2`) got `below_left = true` from the | ||
| 28 | +standalone 8x8 table; libaom gives 0. D203 is a zone-3 (left + bottom-left) predictor, so the | ||
| 29 | +unit came out as a lower-right triangle of wrong samples that then propagated right across the | ||
| 30 | +row of blocks. | ||
| 31 | + | ||
| 32 | +## Changed | ||
| 33 | +* `crates/ec-av1/src/encode.rs:1281` — new `Reach::of_tu(bw, bh, tx, row_off, col_off, px, py, w, h)`: | ||
| 34 | + libaom's per-unit ladder, delegating the (0,0) fallback to the existing square/rect block-level | ||
| 35 | + answers. `Reach` gained `PartialEq, Eq` (`encode.rs:1011`) so the counter below can compare. | ||
| 36 | +* `crates/ec-av1/src/decode.rs:683` — `SPLIT_TU_REACH_FIX_HITS` + `split_tu_reach_fix_hits()` and | ||
| 37 | + the `tu_reach(..)` wrapper, which returns the per-TU answer and counts every unit where it | ||
| 38 | + DIFFERS from the old standalone answer (a hit == a unit whose reference samples used to be wrong). | ||
| 39 | +* `crates/ec-av1/src/decode.rs` — three call sites rewired to `tu_reach(..)`: | ||
| 40 | + the multi-TU square-block loop (16x16+ blocks with `tx_depth > 0`), the 8x8 leaf's 2x2 4x4 grid, | ||
| 41 | + and the 4x8/8x4 leaf's depth-1 pair. | ||
| 42 | +* `crates/ec-av1/src/stream.rs` — new gate `a_real_aomenc_band_stream_seed46_decodes_pixel_exact`. | ||
| 43 | + | ||
| 44 | +## Class sweep (`grep -n "Reach::of(" crates/ec-av1/src/decode.rs`) | ||
| 45 | +9 sites. 3 were the defect (fixed above). 1 (`decode.rs:4652`, the rect-strip per-TU loop) already | ||
| 46 | +hand-rolls the correct libaom ladder inline — a previous lane found the same class there; left as | ||
| 47 | +is, gated by its own strip gates. The remaining 5 (`7037`, `7499`, `7920`, `14881`, `16388`) and the | ||
| 48 | +two `group_reach` sites are genuine BLOCK-level questions where the transform covers the block. | ||
| 49 | + | ||
| 50 | +## Gate | ||
| 51 | +`a_real_aomenc_band_stream_seed46_decodes_pixel_exact` (`crates/ec-av1/src/stream.rs`, end of file): | ||
| 52 | +the sibling recipe, seeds 42..=51 on 8 AND 10 bit, every decoded stream compared to ffmpeg | ||
| 53 | +plane by plane, non-`unsupported` errors fail, seed 46 is asserted to decode (never refuse) on | ||
| 54 | +both depths, and `split_tu_reach_fix_hits` must be > 0 overall AND > 0 in a 10-bit pixel-exact | ||
| 55 | +stream (his films are `yuv420p10le`). | ||
| 56 | + | ||
| 57 | +``` | ||
| 58 | +EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-band46 \ | ||
| 59 | + cargo test -p ec-av1 --lib seed46 -- --nocapture | ||
| 60 | +``` | ||
| 61 | +result: `ok. 1 passed` — `10 pixel-exact streams, 10 named refusals out of 20; 22 split transform | ||
| 62 | +units took the per-TU reach (10 of them 10-bit)`. The 10 refusals are the sibling lane's open | ||
| 63 | +1:4-chroma refusal, by name. | ||
| 64 | + | ||
| 65 | +EVIDENCE: /home/user/.cache/band46/s46_1.obu, ourspre.f0 vs aompre.f0 | regenerate seed 46 twice (sha256 identical), decode_probe vs `ffmpeg -f rawvideo` and EC_AV1_PREFILT_DUMP both decoders | BEFORE: 916 luma samples differ, first (x=14,y=18) ours 217 vs 208, bbox x 8..191 y 18..23, U and V exact, and the pre-loop-filter dump differs identically (913) so the defect is reconstruction | ||
| 66 | +EVIDENCE: /home/user/.cache/band46/ours.step vs aom.step | EC_TRACE_MODE_STEP both decoders, `diff` of the range ladders excluding tx_depth print lines | LADDER IDENTICAL, 147 vs 160 lines differing only in tx_depth *printing* (ours prints at 7 of 20 sites) => entropy decode exact, first divergent element = NONE | ||
| 67 | +EVIDENCE: /home/user/.cache/band46/ours.yuv vs ff.yuv | same decode after the fix | `cmp` PIXEL-EXACT (36864 bytes) | ||
| 68 | + | ||
| 69 | +## Suite | ||
| 70 | +`systemd-run --user --unit=band46-suite2-... -p MemoryMax=10G` running | ||
| 71 | +`EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-band46 cargo test -p ec-av1 --lib -j3` | ||
| 72 | +-> `$HOME/.cache/band46-suite.log`: **ok. 323 passed; 0 failed; 30 ignored** (499.87s). | ||
| 73 | +Sibling gates over the same tables (every `stream::tests::a_real_*` intra/strip/split gate, | ||
| 74 | +`encode::tests::reach_matches_libaom_has_top_right_and_has_bottom_left`, | ||
| 75 | +`rect_reach_tables_are_indexed_with_a_32_mi_row_stride`) are in that run and green. | ||
| 76 | + | ||
| 77 | +`gate_coverage::tests::never_on_10bit_matches_the_gate_recipes` failed on the first suite run and | ||
| 78 | +is fixed in the same commit: the new gate is the first 10-bit recipe to spell | ||
| 79 | +`--enable-tx-size-search=1`, so `enable-tx-size-search` left `NEVER_ON_10BIT` | ||
| 80 | +(`crates/ec-av1/src/gate_coverage.rs:283`). No refusal was lifted, so `refusal_inventory` is | ||
| 81 | +unchanged (3 passed). | ||
| 82 | + | ||
| 83 | +## Residue | ||
| 84 | +* accepted: our `EC_TRACE_MODE_STEP` prints `tx_depth` at only 7 of the 20 sites aomdec prints | ||
| 85 | + (and prints `dq` value 0 where aomdec prints 128) — instrument coverage, not a decode | ||
| 86 | + difference; the ladder ranges match at every line. | ||
| 87 | +* deferred(a lane owning the 1:4 chroma shapes): 10 of the 20 gate attempts still stop at | ||
| 88 | + "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here" | ||
| 89 | + (lane-rectchroma's territory). The gate counts and prints them, never skips. | ||
| 90 | +* accepted: `decode.rs:4652` keeps its inline copy of the per-TU ladder rather than calling | ||
| 91 | + `Reach::of_tu`; unifying them would re-open pinned rect-strip gates for no behavioural change. | ||