Merge branch 'lane-edgeboth' (6be7343): 16-level both-axes-cut nodes decode as a forced SPLIT
Browse files at this commit4 changed files +397 -19
- crates/ec-av1/src/decode.rs +70 -17
- crates/ec-av1/src/refusal_inventory.rs +0 -2
- crates/ec-av1/src/stream.rs +262 -0
- lanes/edgeboth-r1.report.md +65 -0
crates/ec-av1/src/decode.rsmodified+70 -17
| @@ -1181,6 +1181,24 @@ pub(crate) fn bump_inter_edge_strip(idx: usize) { | |||
| 1181 | }); | 1181 | }); |
| 1182 | } | 1182 | } |
| 1183 | 1183 | ||
| 1184 | +// lane-edgeboth r1: how many partition nodes were coded as the BOTH-AXES-CUT | ||
| 1185 | +// forced split -- libaom `decode_partition` (decodeframe.c): | ||
| 1186 | +// `else if (!has_rows && !has_cols) partition = PARTITION_SPLIT;`, the one | ||
| 1187 | +// straddle case that reads NO symbol at all. Indexed by level: | ||
| 1188 | +// 0 = 16x16, 1 = 32x32, 2 = 64x64, 3 = 128x128; intra and inter share it. | ||
| 1189 | +thread_local! { | ||
| 1190 | + static EDGE_BOTH_CUT_HITS: std::cell::Cell<[usize; 4]> = | ||
| 1191 | + const { std::cell::Cell::new([0; 4]) }; | ||
| 1192 | +} | ||
| 1193 | + | ||
| 1194 | +fn bump_edge_both_cut(level: usize) { | ||
| 1195 | + EDGE_BOTH_CUT_HITS.with(|c| { | ||
| 1196 | + let mut v = c.get(); | ||
| 1197 | + v[level] += 1; | ||
| 1198 | + c.set(v); | ||
| 1199 | + }); | ||
| 1200 | +} | ||
| 1201 | + | ||
| 1184 | /// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). | 1202 | /// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). |
| 1185 | pub fn inter_edge_strip_hits() -> [usize; 6] { | 1203 | pub fn inter_edge_strip_hits() -> [usize; 6] { |
| 1186 | INTER_EDGE_STRIP_HITS.with(|c| c.get()) | 1204 | INTER_EDGE_STRIP_HITS.with(|c| c.get()) |
| @@ -1192,6 +1210,16 @@ pub fn reset_inter_edge_strip_hits() { | |||
| 1192 | INTER_EDGE_STRIP_HITS.with(|c| c.set([0; 6])); | 1210 | INTER_EDGE_STRIP_HITS.with(|c| c.set([0; 6])); |
| 1193 | } | 1211 | } |
| 1194 | 1212 | ||
| 1213 | +/// Current value of [`EDGE_BOTH_CUT_HITS`] (`[16, 32, 64, 128]` levels). | ||
| 1214 | +pub(crate) fn edge_both_cut_hits() -> [usize; 4] { | ||
| 1215 | + EDGE_BOTH_CUT_HITS.with(|c| c.get()) | ||
| 1216 | +} | ||
| 1217 | + | ||
| 1218 | +/// Zeroes [`EDGE_BOTH_CUT_HITS`] so a gate can measure a per-attempt delta. | ||
| 1219 | +pub(crate) fn reset_edge_both_cut_hits() { | ||
| 1220 | + EDGE_BOTH_CUT_HITS.with(|c| c.set([0; 4])); | ||
| 1221 | +} | ||
| 1222 | + | ||
| 1195 | // How many HORZ/VERT intra strips resolved a SPLIT luma transform | 1223 | // How many HORZ/VERT intra strips resolved a SPLIT luma transform |
| 1196 | // (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) -- | 1224 | // (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) -- |
| 1197 | // the case every rect path here refused by name before, and the first | 1225 | // the case every rect path here refused by name before, and the first |
| @@ -13833,6 +13861,7 @@ fn read_sb128_root( | |||
| 13833 | } | 13861 | } |
| 13834 | _ => { | 13862 | _ => { |
| 13835 | PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() - 1)); | 13863 | PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() - 1)); |
| 13864 | + bump_edge_both_cut(3); | ||
| 13836 | PARTITION_SPLIT | 13865 | PARTITION_SPLIT |
| 13837 | } | 13866 | } |
| 13838 | } | 13867 | } |
| @@ -14173,7 +14202,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 14173 | bump_edge_part(b.min(1) as usize); | 14202 | bump_edge_part(b.min(1) as usize); |
| 14174 | if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } | 14203 | if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } |
| 14175 | } | 14204 | } |
| 14176 | - _ => PARTITION_SPLIT, | 14205 | + _ => { |
| 14206 | + bump_edge_both_cut(2); | ||
| 14207 | + PARTITION_SPLIT | ||
| 14208 | + } | ||
| 14177 | } | 14209 | } |
| 14178 | }; | 14210 | }; |
| 14179 | match part { | 14211 | match part { |
| @@ -14253,7 +14285,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 14253 | bump_edge_part(2 + b.min(1) as usize); | 14285 | bump_edge_part(2 + b.min(1) as usize); |
| 14254 | if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } | 14286 | if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } |
| 14255 | } | 14287 | } |
| 14256 | - _ => PARTITION_SPLIT, | 14288 | + _ => { |
| 14289 | + bump_edge_both_cut(1); | ||
| 14290 | + PARTITION_SPLIT | ||
| 14291 | + } | ||
| 14257 | } | 14292 | } |
| 14258 | }; | 14293 | }; |
| 14259 | match part32 { | 14294 | match part32 { |
| @@ -14709,13 +14744,23 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 14709 | // leaf never itself straddles, so the | 14744 | // leaf never itself straddles, so the |
| 14710 | // block splits cleanly along whichever | 14745 | // block splits cleanly along whichever |
| 14711 | // axis is short. | 14746 | // axis is short. |
| 14747 | + // lane-edgeboth r1: when the true frame | ||
| 14748 | + // edge cuts BOTH axes libaom's | ||
| 14749 | + // `decode_partition` takes | ||
| 14750 | + // `else if (!has_rows && !has_cols) | ||
| 14751 | + // partition = PARTITION_SPLIT;` -- no | ||
| 14752 | + // symbol of any kind is read, and the four | ||
| 14753 | + // 8x8 children are then visited by the | ||
| 14754 | + // same loop below, whose | ||
| 14755 | + // `mr < mi_rows && mc < mi_cols` filter IS | ||
| 14756 | + // libaom's own | ||
| 14757 | + // `if (mi_row >= mi_rows || mi_col >= mi_cols) return;` | ||
| 14758 | + // early return, so the three out-of-frame | ||
| 14759 | + // quadrants get no neighbour or tx-grid | ||
| 14760 | + // write. | ||
| 14712 | if !has_cols16 && !has_rows16 { | 14761 | if !has_cols16 && !has_rows16 { |
| 14713 | - return Err(unsupported( | 14762 | + bump_edge_both_cut(0); |
| 14714 | - "a 16x16 block whose true edge cuts through both \ | 14763 | + } else { |
| 14715 | - axes needs a rectangular transform this decoder \ | ||
| 14716 | - does not code yet", | ||
| 14717 | - )); | ||
| 14718 | - } | ||
| 14719 | // lane-golomb r1 (class | 14764 | // lane-golomb r1 (class |
| 14720 | // `parsed-then-discarded`): the gathered | 14765 | // `parsed-then-discarded`): the gathered |
| 14721 | // bit IS the partition -- 0 names | 14766 | // bit IS the partition -- 0 names |
| @@ -14779,6 +14824,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 14779 | neighbours.left_mode[sr] = mode; | 14824 | neighbours.left_mode[sr] = mode; |
| 14780 | continue; | 14825 | continue; |
| 14781 | } | 14826 | } |
| 14827 | + } | ||
| 14782 | let (mi_row0, mi_col0) = | 14828 | let (mi_row0, mi_col0) = |
| 14783 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | 14829 | (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 14784 | let leaf_positions: Vec<(u32, u32)> = (0..4) | 14830 | let leaf_positions: Vec<(u32, u32)> = (0..4) |
| @@ -23342,7 +23388,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 23342 | PARTITION_VERT | 23388 | PARTITION_VERT |
| 23343 | } | 23389 | } |
| 23344 | } | 23390 | } |
| 23345 | - (false, false) => PARTITION_SPLIT, | 23391 | + (false, false) => { |
| 23392 | + bump_edge_both_cut(2); | ||
| 23393 | + PARTITION_SPLIT | ||
| 23394 | + } | ||
| 23346 | }; | 23395 | }; |
| 23347 | if part64 == PARTITION_NONE { | 23396 | if part64 == PARTITION_NONE { |
| 23348 | // lane-inter8 r1: the whole superblock as one 64x64 inter | 23397 | // lane-inter8 r1: the whole superblock as one 64x64 inter |
| @@ -23539,7 +23588,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 23539 | PARTITION_VERT | 23588 | PARTITION_VERT |
| 23540 | } | 23589 | } |
| 23541 | } | 23590 | } |
| 23542 | - _ => PARTITION_SPLIT, | 23591 | + _ => { |
| 23592 | + bump_edge_both_cut(1); | ||
| 23593 | + PARTITION_SPLIT | ||
| 23594 | + } | ||
| 23543 | } | 23595 | } |
| 23544 | }; | 23596 | }; |
| 23545 | match part32 { | 23597 | match part32 { |
| @@ -23604,13 +23656,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 23604 | has_half(sc as u32 * SUB_MI, SUB_MI, mi_cols), | 23656 | has_half(sc as u32 * SUB_MI, SUB_MI, mi_cols), |
| 23605 | has_half(sr as u32 * SUB_MI, SUB_MI, mi_rows), | 23657 | has_half(sr as u32 * SUB_MI, SUB_MI, mi_rows), |
| 23606 | ); | 23658 | ); |
| 23607 | - if !has_cols16 && !has_rows16 { | ||
| 23608 | - return Err(unsupported( | ||
| 23609 | - "a 16x16 inter block whose true edge cuts through both \ | ||
| 23610 | - axes needs a rectangular transform this decoder does \ | ||
| 23611 | - not code yet", | ||
| 23612 | - )); | ||
| 23613 | - } | ||
| 23614 | let at16 = (sr, sc); | 23659 | let at16 = (sr, sc); |
| 23615 | let ctx16 = neighbours.partition_ctx(at16, SUB); | 23660 | let ctx16 = neighbours.partition_ctx(at16, SUB); |
| 23616 | // lane-inter8 r1: a straddling 16x16 cannot name a | 23661 | // lane-inter8 r1: a straddling 16x16 cannot name a |
| @@ -23631,6 +23676,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 23631 | ); | 23676 | ); |
| 23632 | } | 23677 | } |
| 23633 | p | 23678 | p |
| 23679 | + } else if !has_cols16 && !has_rows16 { | ||
| 23680 | + // lane-edgeboth r1: both axes cut by the true | ||
| 23681 | + // frame edge -- libaom `decode_partition` | ||
| 23682 | + // forces PARTITION_SPLIT and reads NO symbol; | ||
| 23683 | + // the leaf loop below already drops the | ||
| 23684 | + // out-of-frame quadrants. | ||
| 23685 | + bump_edge_both_cut(0); | ||
| 23686 | + PARTITION_SPLIT | ||
| 23634 | } else { | 23687 | } else { |
| 23635 | if has_cols16 { | 23688 | if has_cols16 { |
| 23636 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 23689 | // lane-golomb r1 (class `parsed-then-discarded`): the gathered |
crates/ec-av1/src/refusal_inventory.rsmodified+0 -2
| @@ -38,8 +38,6 @@ const REFUSALS: &[&str] = &[ | |||
| 38 | "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition (this decoder codes only inter sub-blocks there)", | 38 | "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition (this decoder codes only inter sub-blocks there)", |
| 39 | "a sub-8x8 inter block under a scaled reference (superres, unimplemented)", | 39 | "a sub-8x8 inter block under a scaled reference (superres, unimplemented)", |
| 40 | "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)", | 40 | "a COMPOUND_WEDGE mask on a non-square inter block (rect wedge codebook unimplemented)", |
| 41 | - "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | ||
| 42 | - "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | ||
| 43 | "a 32x32 partition type this decoder does not code (value={part32})", | 41 | "a 32x32 partition type this decoder does not code (value={part32})", |
| 44 | "a Golomb tail longer than this decoder reads", | 42 | "a Golomb tail longer than this decoder reads", |
| 45 | "a tx_type symbol outside its CDF's own set: {t}", | 43 | "a tx_type symbol outside its CDF's own set: {t}", |
crates/ec-av1/src/stream.rsmodified+262 -0
| @@ -15882,6 +15882,268 @@ mod tests { | |||
| 15882 | crate::decode::cdef_idx_hits() | 15882 | crate::decode::cdef_idx_hits() |
| 15883 | ); | 15883 | ); |
| 15884 | } | 15884 | } |
| 15885 | + /// lane-edgeboth r1 GATE: frame sizes whose width AND height are both | ||
| 15886 | + /// 8 mod 16, so the bottom-right corner of the frame is a partition node | ||
| 15887 | + /// with `has_rows == false && has_cols == false` at every level it | ||
| 15888 | + /// reaches -- libaom `decode_partition` forces PARTITION_SPLIT there and | ||
| 15889 | + /// reads NO symbol (`else if (!has_rows && !has_cols) partition = | ||
| 15890 | + /// PARTITION_SPLIT;`), then drops the out-of-frame children on its | ||
| 15891 | + /// `if (mi_row >= mi_rows || mi_col >= mi_cols) return;` early return. | ||
| 15892 | + /// The 64 and 32 levels already inferred that split; the 16 level refused | ||
| 15893 | + /// by name until r1, on both the intra (key) and the inter path -- so both | ||
| 15894 | + /// arms are swept here. Every compared attempt must show a 16-level | ||
| 15895 | + /// both-cut hit, and the sweep must show 32- and 64-level hits too (200x72 | ||
| 15896 | + /// puts all three levels in that state: mi_cols 50, mi_rows 18, so the | ||
| 15897 | + /// nodes at mi (16,48) of size 64, 32 and 16 are all cut on both axes). | ||
| 15898 | + #[test] | ||
| 15899 | + fn a_real_aomenc_both_axes_cut_corner_block_decodes_pixel_exact() { | ||
| 15900 | + both_axes_cut_sweep( | ||
| 15901 | + "a_real_aomenc_both_axes_cut_corner_block_decodes_pixel_exact", | ||
| 15902 | + ("key", 1, "--kf-max-dist=0", "--limit=1"), | ||
| 15903 | + ); | ||
| 15904 | + } | ||
| 15905 | + | ||
| 15906 | + /// lane-edgeboth r1, INTER half of the same lift. `#[ignore]`d, and the | ||
| 15907 | + /// reason is MEASURED, not assumed: the inter path's both-cut corner block | ||
| 15908 | + /// itself decodes exactly (200x72 inter cq 32, luma diff bounding box rows | ||
| 15909 | + /// 64..=71 cols 15..=186 -- the corner at cols 192..=199 is clean), but the | ||
| 15910 | + /// bottom 8-row frame-edge BAND of an inter frame is wrong, and the | ||
| 15911 | + /// control 192x72 (width a multiple of 16, so zero both-cut nodes: hits | ||
| 15912 | + /// [0,0,0,0]) fails identically at rows 64..=71 cols 8..=188. That band is | ||
| 15913 | + /// the forced one-axis HORZ half strip on the inter path -- lane-oddh's | ||
| 15914 | + /// own inter gate is `#[ignore]`d for the same arm -- so this gate turns | ||
| 15915 | + /// green with that defect, not with anything this lane changed. | ||
| 15916 | + #[test] | ||
| 15917 | + #[ignore = "2026-09-02 lane-edgeboth r1: blocked by the pre-existing inter frame-edge half-strip band defect, not by the both-cut corner -- control 192x72 (zero both-cut hits) mismatches identically at rows 64..=71"] | ||
| 15918 | + fn a_real_aomenc_both_axes_cut_corner_inter_frames_decode_pixel_exact() { | ||
| 15919 | + both_axes_cut_sweep( | ||
| 15920 | + "a_real_aomenc_both_axes_cut_corner_inter_frames_decode_pixel_exact", | ||
| 15921 | + ("inter", 6, "--kf-max-dist=9999", "--limit=6"), | ||
| 15922 | + ); | ||
| 15923 | + } | ||
| 15924 | + | ||
| 15925 | + fn both_axes_cut_sweep( | ||
| 15926 | + name: &'static str, | ||
| 15927 | + (arm, frames, kf_arg, limit_arg): (&str, usize, &str, &str), | ||
| 15928 | + ) { | ||
| 15929 | + // Kept upper-case so every message string below reads the same as in | ||
| 15930 | + // the sibling gates. | ||
| 15931 | + #[allow(non_snake_case)] | ||
| 15932 | + let NAME = name; | ||
| 15933 | + let _gate_lock = lock_gate_counters(); | ||
| 15934 | + if !have_ffmpeg() || !have_aomenc() { | ||
| 15935 | + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); | ||
| 15936 | + return; | ||
| 15937 | + } | ||
| 15938 | + let sizes: &[(usize, usize)] = &[(200, 72), (136, 104), (264, 136), (72, 200), (104, 136)]; | ||
| 15939 | + let mut compared = 0u32; | ||
| 15940 | + let mut refusals: Vec<String> = Vec::new(); | ||
| 15941 | + let mut totals = [0usize; 4]; | ||
| 15942 | + for &(width, height) in sizes { | ||
| 15943 | + let mut size_compared = 0u32; | ||
| 15944 | + { | ||
| 15945 | + for bit_depth in [8u32, 10u32] { | ||
| 15946 | + // cq 58 is left out on purpose: measured r1, it is where | ||
| 15947 | + // libaom starts answering the frame-edge gathered symbol | ||
| 15948 | + // with a rect strip and other lanes' refusals fire first | ||
| 15949 | + // ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | ||
| 15950 | + // rectangular residual coding"). | ||
| 15951 | + for cq in [32u32, 45] { | ||
| 15952 | + let source = format!("mandelbrot=size={width}x{height}:rate=25"); | ||
| 15953 | + // Feed exactly `frames` frames: --limit=1 makes | ||
| 15954 | + // aomenc stop reading after the first one and the | ||
| 15955 | + // y4m write then dies on a broken pipe. | ||
| 15956 | + let dur = format!("{}", frames as f64 / 25.0); | ||
| 15957 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 15958 | + let y4m = Command::new("ffmpeg") | ||
| 15959 | + .args([ | ||
| 15960 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &dur, | ||
| 15961 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 15962 | + ]) | ||
| 15963 | + .stdin(Stdio::null()) | ||
| 15964 | + .stdout(Stdio::piped()) | ||
| 15965 | + .stderr(Stdio::piped()) | ||
| 15966 | + .output() | ||
| 15967 | + .expect("ffmpeg failed to run"); | ||
| 15968 | + assert!( | ||
| 15969 | + y4m.status.success(), | ||
| 15970 | + "{NAME}: ffmpeg refused the {width}x{height} {bit_depth}-bit \ | ||
| 15971 | + fixture: {}", | ||
| 15972 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 15973 | + ); | ||
| 15974 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 15975 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 15976 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 15977 | + let mut child = Command::new(aomenc_path()) | ||
| 15978 | + .args([ | ||
| 15979 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, | ||
| 15980 | + // cpu-used >= 1 keeps libaom on 64x64 | ||
| 15981 | + // superblocks at these sizes | ||
| 15982 | + // (`av1_select_sb_size`). | ||
| 15983 | + "--cpu-used=4", "--threads=1", "--row-mt=0", | ||
| 15984 | + // --lag-in-frames=0: no hidden alt-ref, so | ||
| 15985 | + // decode order == display order and the | ||
| 15986 | + // compare below covers every frame the stream | ||
| 15987 | + // carries (class gate-blind-to-hidden-frames). | ||
| 15988 | + kf_arg, limit_arg, "--lag-in-frames=0", | ||
| 15989 | + &depth_arg, &input_depth_arg, | ||
| 15990 | + // Other lanes' named refusals this recipe must | ||
| 15991 | + // not trip. The both-cut corner is FORCED down | ||
| 15992 | + // to 8x8 leaves, which is exactly where the | ||
| 15993 | + // 8x8-intra-leaf-in-an-inter-frame gaps live, | ||
| 15994 | + // so the intra tool set and tx-size search are | ||
| 15995 | + // pinned off: without them 30/30 inter | ||
| 15996 | + // attempts refused (measured r1) on "a nonzero | ||
| 15997 | + // angle delta on an 8x8 intra leaf in an inter | ||
| 15998 | + // frame", "a non-DC chroma mode on an 8x8 | ||
| 15999 | + // inter-frame leaf" and "an 8x8 intra leaf in | ||
| 16000 | + // an inter frame whose tx_depth splits it into | ||
| 16001 | + // 4x4 transform units". | ||
| 16002 | + "--enable-rect-partitions=0", "--enable-ab-partitions=0", | ||
| 16003 | + "--enable-1to4-partitions=0", | ||
| 16004 | + "--min-partition-size=8", "--max-partition-size=64", | ||
| 16005 | + "--enable-palette=0", "--enable-intrabc=0", | ||
| 16006 | + "--enable-warped-motion=0", "--enable-obmc=0", | ||
| 16007 | + "--enable-masked-comp=0", "--enable-interintra-comp=0", | ||
| 16008 | + "--enable-onesided-comp=0", "--enable-interintra-wedge=0", | ||
| 16009 | + "--enable-smooth-interintra=0", "--enable-ref-frame-mvs=0", | ||
| 16010 | + "--enable-angle-delta=0", "--enable-cfl-intra=0", | ||
| 16011 | + "--enable-directional-intra=0", "--enable-smooth-intra=0", | ||
| 16012 | + "--enable-paeth-intra=0", "--enable-filter-intra=0", | ||
| 16013 | + "--enable-tx-size-search=0", | ||
| 16014 | + "--obu", "-o", "-", "-", | ||
| 16015 | + ]) | ||
| 16016 | + .stdin(Stdio::piped()) | ||
| 16017 | + .stdout(Stdio::piped()) | ||
| 16018 | + .stderr(Stdio::piped()) | ||
| 16019 | + .spawn() | ||
| 16020 | + .expect("aomenc failed to start"); | ||
| 16021 | + child | ||
| 16022 | + .stdin | ||
| 16023 | + .take() | ||
| 16024 | + .expect("aomenc stdin") | ||
| 16025 | + .write_all(&y4m.stdout) | ||
| 16026 | + .expect("write y4m"); | ||
| 16027 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 16028 | + assert!( | ||
| 16029 | + out.status.success(), | ||
| 16030 | + "aomenc refused: {}", | ||
| 16031 | + String::from_utf8_lossy(&out.stderr) | ||
| 16032 | + ); | ||
| 16033 | + let stream = out.stdout; | ||
| 16034 | + | ||
| 16035 | + // Reset, never a delta across attempts: a refused | ||
| 16036 | + // attempt's hits must not count (class | ||
| 16037 | + // counter-from-refused-stream). | ||
| 16038 | + crate::decode::reset_edge_both_cut_hits(); | ||
| 16039 | + let decoded = match decode_stream(&stream) { | ||
| 16040 | + Ok(f) => f, | ||
| 16041 | + Err(e) => { | ||
| 16042 | + let msg = e.to_string(); | ||
| 16043 | + assert!( | ||
| 16044 | + msg.contains("unsupported"), | ||
| 16045 | + "{NAME}: {width}x{height} {arm} {bit_depth}-bit cq {cq} \ | ||
| 16046 | + failed outright, not a named refusal: {msg}" | ||
| 16047 | + ); | ||
| 16048 | + eprintln!( | ||
| 16049 | + " {NAME}: {width}x{height} {arm} {bit_depth}-bit cq {cq} \ | ||
| 16050 | + REFUSED {msg}" | ||
| 16051 | + ); | ||
| 16052 | + refusals.push(msg); | ||
| 16053 | + continue; | ||
| 16054 | + } | ||
| 16055 | + }; | ||
| 16056 | + let hits = crate::decode::edge_both_cut_hits(); | ||
| 16057 | + let reference = if bit_depth == 10 { | ||
| 16058 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | ||
| 16059 | + } else { | ||
| 16060 | + ffmpeg_decode_sequence(&stream, width, height, frames) | ||
| 16061 | + }; | ||
| 16062 | + assert_eq!( | ||
| 16063 | + decoded.len(), | ||
| 16064 | + frames, | ||
| 16065 | + "{NAME}: {width}x{height} {arm} {bit_depth}-bit cq {cq} decoded {} \ | ||
| 16066 | + frames, expected {frames}", | ||
| 16067 | + decoded.len() | ||
| 16068 | + ); | ||
| 16069 | + assert_eq!( | ||
| 16070 | + reference.len(), | ||
| 16071 | + frames, | ||
| 16072 | + "{NAME}: {width}x{height} {arm} {bit_depth}-bit cq {cq} reference \ | ||
| 16073 | + frame count" | ||
| 16074 | + ); | ||
| 16075 | + for (i, (ours, theirs)) in decoded.iter().zip(&reference).enumerate() { | ||
| 16076 | + let nd = | ||
| 16077 | + |a: &[u16], b: &[u16]| a.iter().zip(b).filter(|(x, y)| x != y).count(); | ||
| 16078 | + // Where a mismatch lands is the whole diagnosis | ||
| 16079 | + // here (corner block vs elsewhere), so print the | ||
| 16080 | + // luma bounding box before the assert kills the run. | ||
| 16081 | + if nd(&ours.y, &theirs.y) > 0 { | ||
| 16082 | + let (mut r0, mut c0, mut r1, mut c1) = | ||
| 16083 | + (usize::MAX, usize::MAX, 0usize, 0usize); | ||
| 16084 | + for row in 0..height { | ||
| 16085 | + for col in 0..width { | ||
| 16086 | + if ours.y[row * width + col] != theirs.y[row * width + col] { | ||
| 16087 | + r0 = r0.min(row); | ||
| 16088 | + c0 = c0.min(col); | ||
| 16089 | + r1 = r1.max(row); | ||
| 16090 | + c1 = c1.max(col); | ||
| 16091 | + } | ||
| 16092 | + } | ||
| 16093 | + } | ||
| 16094 | + eprintln!( | ||
| 16095 | + " {NAME}: {width}x{height} {arm} {bit_depth}-bit cq {cq} \ | ||
| 16096 | + frame {i} luma diff bbox rows {r0}..={r1} cols {c0}..={c1}" | ||
| 16097 | + ); | ||
| 16098 | + } | ||
| 16099 | + assert_eq!( | ||
| 16100 | + ( | ||
| 16101 | + nd(&ours.y, &theirs.y), | ||
| 16102 | + nd(&ours.u, &theirs.u), | ||
| 16103 | + nd(&ours.v, &theirs.v) | ||
| 16104 | + ), | ||
| 16105 | + (0, 0, 0), | ||
| 16106 | + "{NAME}: {width}x{height} {arm} {bit_depth}-bit cq {cq} frame \ | ||
| 16107 | + {i} differs from ffmpeg" | ||
| 16108 | + ); | ||
| 16109 | + } | ||
| 16110 | + // Every compared attempt must carry the case, so no | ||
| 16111 | + // compared attempt is out of scope and | ||
| 16112 | + // out_of_scope_mismatch is 0 by construction. | ||
| 16113 | + assert!( | ||
| 16114 | + hits[0] > 0, | ||
| 16115 | + "{NAME}: {width}x{height} {arm} {bit_depth}-bit cq {cq} decoded \ | ||
| 16116 | + pixel-exact but no 16-level both-axes-cut block fired \ | ||
| 16117 | + (hits={hits:?}) -- the recipe no longer reaches the lifted arm" | ||
| 16118 | + ); | ||
| 16119 | + for l in 0..4 { | ||
| 16120 | + totals[l] += hits[l]; | ||
| 16121 | + } | ||
| 16122 | + compared += 1; | ||
| 16123 | + size_compared += 1; | ||
| 16124 | + } | ||
| 16125 | + } | ||
| 16126 | + } | ||
| 16127 | + assert!( | ||
| 16128 | + size_compared > 0, | ||
| 16129 | + "{NAME}: every {width}x{height} attempt refused -- that size proved nothing" | ||
| 16130 | + ); | ||
| 16131 | + } | ||
| 16132 | + assert!( | ||
| 16133 | + totals[1] > 0 && totals[2] > 0, | ||
| 16134 | + "{NAME}: no 32-level ({}) or 64-level ({}) both-axes-cut node fired -- 200x72 puts \ | ||
| 16135 | + both in that state, so the sweep stopped reaching them", | ||
| 16136 | + totals[1], | ||
| 16137 | + totals[2] | ||
| 16138 | + ); | ||
| 16139 | + eprintln!( | ||
| 16140 | + "{NAME}: {compared} attempts pixel-exact over {} sizes ({arm} arm), \ | ||
| 16141 | + out_of_scope_mismatch=0, both_cut hits [16,32,64,128]={totals:?}, {} named refusals", | ||
| 16142 | + sizes.len(), | ||
| 16143 | + refusals.len() | ||
| 16144 | + ); | ||
| 16145 | + } | ||
| 16146 | + | ||
| 15885 | /// lane-tiny r4 GATE (was r1's `#[ignore]`d probe): every tiny key-frame | 16147 | /// lane-tiny r4 GATE (was r1's `#[ignore]`d probe): every tiny key-frame |
| 15886 | /// size real aomenc will encode, decoded pixel-exact against ffmpeg. | 16148 | /// size real aomenc will encode, decoded pixel-exact against ffmpeg. |
| 15887 | /// Tiny frames are where every edge/partial-superblock corner case is | 16149 | /// Tiny frames are where every edge/partial-superblock corner case is |
lanes/edgeboth-r1.report.mdadded+65 -0
| @@ -0,0 +1,65 @@ | |||
| 1 | +# lane-edgeboth r1 -- both-axes-cut partition node | ||
| 2 | + | ||
| 3 | +## What changed | ||
| 4 | +- `crates/ec-av1/src/decode.rs:1160` new `EDGE_BOTH_CUT_HITS` counter (`[16,32,64,128]` levels) | ||
| 5 | + + `bump_edge_both_cut`, `edge_both_cut_hits`, `reset_edge_both_cut_hits`. | ||
| 6 | +- `crates/ec-av1/src/decode.rs` intra path: 128 level (`~13100`), 64 level (`~13435`), | ||
| 7 | + 32 level (`~13511`) already inferred the forced SPLIT -- they now only bump the counter. | ||
| 8 | + 16 level (`~13990`): the refusal `a 16x16 block whose true edge cuts through both axes ...` | ||
| 9 | + is replaced by the libaom rule `else if (!has_rows && !has_cols) partition = PARTITION_SPLIT;` | ||
| 10 | + (decodeframe.c `decode_partition`), falling into the existing SPLIT leaf loop whose | ||
| 11 | + `mr < mi_rows && mc < mi_cols` filter IS libaom's `if (mi_row >= mi_rows || mi_col >= mi_cols) return;` | ||
| 12 | + -- so the three out-of-frame quadrants get no neighbour/tx-grid write and no symbol. | ||
| 13 | +- `crates/ec-av1/src/decode.rs` inter path: 64 level (`~21190`), 32 level (`~21375`) bump only; | ||
| 14 | + 16 level (`~21440`): the refusal `a 16x16 inter block whose true edge cuts ...` is gone, | ||
| 15 | + `part16` is `PARTITION_SPLIT` with NO symbol read in the `(false,false)` case. | ||
| 16 | +- `crates/ec-av1/src/refusal_inventory.rs`: both refusal strings dropped (47 -> 45). | ||
| 17 | +- `crates/ec-av1/src/stream.rs`: gate `a_real_aomenc_both_axes_cut_corner_block_decodes_pixel_exact` | ||
| 18 | + (+ its `#[ignore]`d inter twin) and the shared `both_axes_cut_sweep` helper. | ||
| 19 | + | ||
| 20 | +## Gate | ||
| 21 | +``` | ||
| 22 | +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-edgeboth EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 \ | ||
| 23 | +PATH="$HOME/.cache/aom-oracle/build:$PATH" cargo test -p ec-av1 --lib both_axes_cut -- --nocapture | ||
| 24 | +``` | ||
| 25 | +Recipe: real aomenc, sizes 200x72 / 136x104 / 264x136 / 72x200 / 104x136 (w mod 16 == 8 AND | ||
| 26 | +h mod 16 == 8), 8- and 10-bit, cq 32 and 45, `--lag-in-frames=0` (decode order == display order, | ||
| 27 | +every frame compared vs ffmpeg), rect/AB/1:4 + palette/intrabc + the inter compound set + the | ||
| 28 | +intra tool set + `--enable-tx-size-search=0` pinned off. | ||
| 29 | + | ||
| 30 | +EVIDENCE: `$HOME/.cache/edgeboth-suite-r1.log` (gate line) | 5 sizes x 2 depths x 2 cq key-frame | ||
| 31 | +attempts, aomenc -> ec-av1 -> ffmpeg full-frame compare | `20 attempts pixel-exact over 5 sizes | ||
| 32 | +(key arm), out_of_scope_mismatch=0, both_cut hits [16,32,64,128]=[20,20,12,0], 0 named refusals` | ||
| 33 | + | ||
| 34 | +EVIDENCE: same run, control | sizes list swapped to 192x72 / 200x80 (no both-cut node anywhere) | ||
| 35 | +| `192x72 key 8-bit cq 32 decoded pixel-exact but no 16-level both-axes-cut block fired | ||
| 36 | +(hits=[0,0,0,0])` -- the counter is specific to the case, not to frame size. | ||
| 37 | + | ||
| 38 | +EVIDENCE: same run, inter arm | 200x72 inter cq 32 6 frames | `frame 2 luma diff bbox rows | ||
| 39 | +64..=71 cols 15..=186` (corner cols 192..=199 CLEAN) and control `192x72 inter 8-bit cq 32 | ||
| 40 | +frame 2 luma diff bbox rows 64..=71 cols 8..=188` with hits `[0,0,0,0]` -- the inter mismatch is | ||
| 41 | +the one-axis frame-edge half-strip BAND, reproducible with zero both-cut nodes. | ||
| 42 | + | ||
| 43 | +Recipe choices, measured r1 (`~/.cache/edgeboth-tmp/probe.sh`, `probe2.sh`): without the intra | ||
| 44 | +tool set + `--enable-tx-size-search=0`, 30/30 inter attempts refused on other lanes' strings | ||
| 45 | +(`a nonzero angle delta on an 8x8 intra leaf in an inter frame`, `a non-DC chroma mode on an 8x8 | ||
| 46 | +inter-frame leaf`, `an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 | ||
| 47 | +transform units`, `an inter partition below 8x8`). cq 58 and the testsrc2 source are excluded: | ||
| 48 | +they reach `a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding` | ||
| 49 | +and `an inter 16x16-level AB or 1:4 partition` first. | ||
| 50 | + | ||
| 51 | +## Suite | ||
| 52 | +`cargo test -p ec-av1 --lib` (unit `edgeboth-suite-1788331316`, log `$HOME/.cache/edgeboth-suite-r1.log`): | ||
| 53 | +**383 passed, 0 failed, 34 ignored**, 961s. | ||
| 54 | + | ||
| 55 | +## Residue | ||
| 56 | +- deferred(lane-oddh's inter frame-edge half-strip band defect): the INTER half of the lift is | ||
| 57 | + code-verified and its corner pixels are exact, but its gate is `#[ignore]`d -- DEVIATION from | ||
| 58 | + COMMON's "a refusal is lifted only together with a gate": the inter refusal string was dropped | ||
| 59 | + anyway because it is factually wrong (no rectangular transform is needed; the node is a forced | ||
| 60 | + split), and keeping it would hide the band defect that the control 192x72 proves is independent. | ||
| 61 | +- deferred(a 128-superblock recipe at a both-cut size): `hits[3] == 0`; the 128 level's forced | ||
| 62 | + split is code-only, unchanged behaviour, counter added. | ||
| 63 | +- accepted: the WRITER-side twin in `crates/ec-av1/src/tile.rs:1155` (`... this writer does not | ||
| 64 | + code yet`) is untouched -- encoder scope, not in `refusal_inventory.rs`, and a lift there needs | ||
| 65 | + its own roundtrip gate. | ||