Merge branch 'lane-interedge' (9920c36): inter 32-level HORZ/VERT second-strip frame-edge guard
Browse files at this commit4 changed files +322 -113
- crates/ec-av1/examples/decode_probe.rs +5 -0
- crates/ec-av1/src/decode.rs +38 -0
- crates/ec-av1/src/stream.rs +179 -113
- lanes/interedge-r1.report.md +100 -0
crates/ec-av1/examples/decode_probe.rsmodified+5 -0
| @@ -49,6 +49,11 @@ fn main() { | ||
| 49 | 49 | // asserts -- printed here so a recipe sweep can see it fire without a |
| 50 | 50 | // test-binary rebuild. |
| 51 | 51 | println!("skip_split_tx: {}", ec_av1::decode::skip_split_tx_hits()); |
| 52 | + let es = ec_av1::decode::inter_edge_strip_hits(); | |
| 53 | + println!( | |
| 54 | + "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}", | |
| 55 | + es[0], es[1], es[2], es[3], es[4], es[5] | |
| 56 | + ); | |
| 52 | 57 | let ir = ec_av1::stream::inter_rect_counters(); |
| 53 | 58 | println!( |
| 54 | 59 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
crates/ec-av1/src/decode.rsmodified+38 -0
| @@ -1162,6 +1162,36 @@ pub(crate) fn edge_rect_strip_hits() -> usize { | ||
| 1162 | 1162 | EDGE_RECT_STRIP_HITS.with(|c| c.get()) |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | +// lane-interedge r1: frame-edge half strips on the INTER path, per partition | |
| 1166 | +// level (64/32/16) x axis (HORZ at a bottom edge, VERT at a right edge). The | |
| 1167 | +// index is `level_idx * 2 + axis` with `level_idx` 0=64, 1=32, 2=16 and | |
| 1168 | +// `axis` 0=HORZ (`!has_rows`), 1=VERT (`!has_cols`). Both of the user's films | |
| 1169 | +// are height mod 16 == 8, so every inter frame crosses these nodes. | |
| 1170 | +thread_local! { | |
| 1171 | + static INTER_EDGE_STRIP_HITS: std::cell::Cell<[usize; 6]> = | |
| 1172 | + const { std::cell::Cell::new([0; 6]) }; | |
| 1173 | +} | |
| 1174 | + | |
| 1175 | +/// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`]. | |
| 1176 | +pub(crate) fn bump_inter_edge_strip(idx: usize) { | |
| 1177 | + INTER_EDGE_STRIP_HITS.with(|c| { | |
| 1178 | + let mut v = c.get(); | |
| 1179 | + v[idx] += 1; | |
| 1180 | + c.set(v); | |
| 1181 | + }); | |
| 1182 | +} | |
| 1183 | + | |
| 1184 | +/// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). | |
| 1185 | +pub fn inter_edge_strip_hits() -> [usize; 6] { | |
| 1186 | + INTER_EDGE_STRIP_HITS.with(|c| c.get()) | |
| 1187 | +} | |
| 1188 | + | |
| 1189 | +/// Resets [`INTER_EDGE_STRIP_HITS`] -- a refused attempt must not carry hits | |
| 1190 | +/// into the next one (class `counter-from-refused-stream`). | |
| 1191 | +pub fn reset_inter_edge_strip_hits() { | |
| 1192 | + INTER_EDGE_STRIP_HITS.with(|c| c.set([0; 6])); | |
| 1193 | +} | |
| 1194 | + | |
| 1165 | 1195 | // How many HORZ/VERT intra strips resolved a SPLIT luma transform |
| 1166 | 1196 | // (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) -- |
| 1167 | 1197 | // the case every rect path here refused by name before, and the first |
| @@ -22099,6 +22129,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 22099 | 22129 | bw, |
| 22100 | 22130 | bh |
| 22101 | 22131 | ); |
| 22132 | + if !four && i == 0 && ((horz && !has_rows) || (!horz && !has_cols)) { | |
| 22133 | + bump_inter_edge_strip(if horz { 0 } else { 1 }); | |
| 22134 | + } | |
| 22102 | 22135 | match (horz, four) { |
| 22103 | 22136 | (true, false) => INTER_SB_HORZ_HITS.with(|c| c.set(c.get() + 1)), |
| 22104 | 22137 | (false, false) => INTER_SB_VERT_HITS.with(|c| c.set(c.get() + 1)), |
| @@ -22372,6 +22405,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 22372 | 22405 | && (piece_mi.0 >= mi_rows as usize |
| 22373 | 22406 | || piece_mi.1 >= mi_cols as usize) |
| 22374 | 22407 | { |
| 22408 | + bump_inter_edge_strip(if horz { 4 } else { 5 }); | |
| 22375 | 22409 | break; |
| 22376 | 22410 | } |
| 22377 | 22411 | decode_inter_block( |
| @@ -22952,6 +22986,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 22952 | 22986 | allow_screen_content_tools, |
| 22953 | 22987 | frame_width as usize, |
| 22954 | 22988 | )?; |
| 22989 | + } else { | |
| 22990 | + bump_inter_edge_strip(2); | |
| 22955 | 22991 | } |
| 22956 | 22992 | } |
| 22957 | 22993 | PARTITION_VERT => { |
| @@ -23063,6 +23099,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 23063 | 23099 | allow_screen_content_tools, |
| 23064 | 23100 | frame_width as usize, |
| 23065 | 23101 | )?; |
| 23102 | + } else { | |
| 23103 | + bump_inter_edge_strip(3); | |
| 23066 | 23104 | } |
| 23067 | 23105 | } |
| 23068 | 23106 | PARTITION_HORZ_A => { |
crates/ec-av1/src/stream.rsmodified+179 -113
| @@ -966,17 +966,142 @@ mod tests { | ||
| 966 | 966 | ); |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | - /// lane-oddh r2 GATE: the frame-edge half-strip arms r1 added (a 64x32 / | |
| 970 | - /// 32x64 superblock-level or 16x8 / 8x16 16-level INTER block where the | |
| 971 | - /// frame's true edge cuts the strip in half) actually fire and decode | |
| 972 | - /// pixel-exact, at both bit depths. 160 = two full superblock rows plus | |
| 973 | - /// 32 pixels, so every superblock in the last row is a half strip; without | |
| 974 | - /// r1's arms these attempts refused outright, which is why this gate | |
| 975 | - /// asserts a nonzero `edge_rect_strip_hits` DELTA on attempts that were | |
| 976 | - /// actually compared -- a refused attempt's hits would prove nothing | |
| 977 | - /// (class "counter from refused stream"). | |
| 969 | + /// lane-interedge r1: one attempt of the inter frame-edge half-strip gate -- | |
| 970 | + /// encode `width x height` with real aomenc (rect partitions ON, every other | |
| 971 | + /// lane's open tool pinned off), decode it, and return | |
| 972 | + /// `(inter_edge_strip hits, frames whose LUMA differs, frames whose CHROMA | |
| 973 | + /// differs)` against ffmpeg. A refusal or a decode error is a hard failure: | |
| 974 | + /// this recipe reached every size without one (measured r1). | |
| 975 | + fn inter_edge_strip_attempt( | |
| 976 | + name: &str, | |
| 977 | + width: usize, | |
| 978 | + height: usize, | |
| 979 | + bit_depth: u32, | |
| 980 | + cq: u32, | |
| 981 | + frames: usize, | |
| 982 | + ) -> ([usize; 6], usize, usize) { | |
| 983 | + let duration = format!("{}", frames as f64 / 25.0); | |
| 984 | + let source = format!("mandelbrot=size={width}x{height}:rate=25"); | |
| 985 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 986 | + let y4m = Command::new("ffmpeg") | |
| 987 | + .args([ | |
| 988 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration, "-pix_fmt", | |
| 989 | + pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 990 | + ]) | |
| 991 | + .stdin(Stdio::null()) | |
| 992 | + .stdout(Stdio::piped()) | |
| 993 | + .stderr(Stdio::piped()) | |
| 994 | + .output() | |
| 995 | + .expect("ffmpeg failed to run"); | |
| 996 | + assert!( | |
| 997 | + y4m.status.success(), | |
| 998 | + "{name}: ffmpeg refused the {width}x{height} {bit_depth}-bit fixture: {}", | |
| 999 | + String::from_utf8_lossy(&y4m.stderr) | |
| 1000 | + ); | |
| 1001 | + let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 1002 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 1003 | + let cq_arg = format!("--cq-level={cq}"); | |
| 1004 | + let limit_arg = format!("--limit={frames}"); | |
| 1005 | + let mut child = Command::new(aomenc_path()) | |
| 1006 | + .args([ | |
| 1007 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, | |
| 1008 | + // cpu-used >= 1 keeps libaom on 64x64 superblocks at these | |
| 1009 | + // sizes (`av1_select_sb_size`). | |
| 1010 | + "--cpu-used=4", "--threads=1", "--row-mt=0", "--kf-max-dist=9999", | |
| 1011 | + &limit_arg, | |
| 1012 | + // decode order == display order, so the compare below covers | |
| 1013 | + // every frame the stream carries (class gate-blind-to-hidden-frames). | |
| 1014 | + "--lag-in-frames=0", &depth_arg, &input_depth_arg, | |
| 1015 | + // Rect partitions stay ON: the frame-edge strip is a FORCED | |
| 1016 | + // (gathered) HORZ/VERT, but with rect coding off the encoder | |
| 1017 | + // answers that gathered symbol SPLIT every time and no edge | |
| 1018 | + // strip ever fires (lane-oddh r2's finding, re-measured r1). | |
| 1019 | + "--enable-rect-partitions=1", "--enable-ab-partitions=0", | |
| 1020 | + "--enable-1to4-partitions=0", "--min-partition-size=8", | |
| 1021 | + "--max-partition-size=64", | |
| 1022 | + // Other lanes' open gaps this recipe must not trip. | |
| 1023 | + "--enable-palette=0", "--enable-intrabc=0", "--enable-warped-motion=0", | |
| 1024 | + "--enable-obmc=0", "--enable-masked-comp=0", "--enable-interintra-comp=0", | |
| 1025 | + "--enable-onesided-comp=0", "--enable-interintra-wedge=0", | |
| 1026 | + "--enable-smooth-interintra=0", "--enable-ref-frame-mvs=0", | |
| 1027 | + "--enable-angle-delta=0", "--enable-cfl-intra=0", | |
| 1028 | + "--enable-directional-intra=0", "--enable-smooth-intra=0", | |
| 1029 | + "--enable-paeth-intra=0", "--enable-filter-intra=0", | |
| 1030 | + "--enable-tx-size-search=0", | |
| 1031 | + "--obu", "-o", "-", "-", | |
| 1032 | + ]) | |
| 1033 | + .stdin(Stdio::piped()) | |
| 1034 | + .stdout(Stdio::piped()) | |
| 1035 | + .stderr(Stdio::piped()) | |
| 1036 | + .spawn() | |
| 1037 | + .expect("aomenc failed to start"); | |
| 1038 | + child | |
| 1039 | + .stdin | |
| 1040 | + .take() | |
| 1041 | + .expect("aomenc stdin") | |
| 1042 | + .write_all(&y4m.stdout) | |
| 1043 | + .expect("write y4m"); | |
| 1044 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 1045 | + assert!( | |
| 1046 | + out.status.success(), | |
| 1047 | + "aomenc refused: {}", | |
| 1048 | + String::from_utf8_lossy(&out.stderr) | |
| 1049 | + ); | |
| 1050 | + let stream = out.stdout; | |
| 1051 | + | |
| 1052 | + // Reset, never a delta: a refused attempt's hits must not leak into the | |
| 1053 | + // next one (class counter-from-refused-stream). | |
| 1054 | + crate::decode::reset_inter_edge_strip_hits(); | |
| 1055 | + let decoded = decode_stream(&stream).unwrap_or_else(|e| { | |
| 1056 | + panic!("{name}: {width}x{height} {bit_depth}-bit cq {cq} did not decode: {e}") | |
| 1057 | + }); | |
| 1058 | + let hits = crate::decode::inter_edge_strip_hits(); | |
| 1059 | + let reference = if bit_depth == 10 { | |
| 1060 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | |
| 1061 | + } else { | |
| 1062 | + ffmpeg_decode_sequence(&stream, width, height, frames) | |
| 1063 | + }; | |
| 1064 | + assert_eq!( | |
| 1065 | + decoded.len(), | |
| 1066 | + reference.len(), | |
| 1067 | + "{name}: {width}x{height} {bit_depth}-bit cq {cq} frame count" | |
| 1068 | + ); | |
| 1069 | + assert!( | |
| 1070 | + decoded.len() >= frames, | |
| 1071 | + "{name}: {width}x{height} {bit_depth}-bit cq {cq} decoded only {} frames", | |
| 1072 | + decoded.len() | |
| 1073 | + ); | |
| 1074 | + let (mut luma_bad, mut chroma_bad) = (0usize, 0usize); | |
| 1075 | + for (ours, theirs) in decoded.iter().zip(&reference) { | |
| 1076 | + if ours.y != theirs.y { | |
| 1077 | + luma_bad += 1; | |
| 1078 | + } | |
| 1079 | + if ours.u != theirs.u || ours.v != theirs.v { | |
| 1080 | + chroma_bad += 1; | |
| 1081 | + } | |
| 1082 | + } | |
| 1083 | + (hits, luma_bad, chroma_bad) | |
| 1084 | + } | |
| 1085 | + | |
| 1086 | + /// lane-interedge r1 GATE (was lane-oddh r2's `#[ignore]`d twin): the INTER | |
| 1087 | + /// frame-edge half strips -- a `PARTITION_HORZ`/`PARTITION_VERT` forced by | |
| 1088 | + /// the gathered edge symbol at the 64, 32 or 16 level whose second half lies | |
| 1089 | + /// outside the true frame. Both of the user's films are height mod 16 == 8 | |
| 1090 | + /// (1920x792, 3840x1608), so every inter frame crosses these nodes. | |
| 1091 | + /// | |
| 1092 | + /// r1 root cause: the inter tile's 32-level `PARTITION_HORZ`/`PARTITION_VERT` | |
| 1093 | + /// decoded the SECOND strip unconditionally, while libaom `decode_partition` | |
| 1094 | + /// (decodeframe.c, PARTITION_HORZ) guards it with `has_rows`/`has_cols` -- | |
| 1095 | + /// so at the edge we read symbols the encoder never wrote. With that guard | |
| 1096 | + /// removed this gate's 72x192 cq 32 arm refuses outright and its 104x192 arm | |
| 1097 | + /// decodes luma rows 127..191 of frame 5 wrong (measured r1). | |
| 1098 | + /// | |
| 1099 | + /// The compare is LUMA-exact per frame plus a CONTROL size with no edge node | |
| 1100 | + /// at all: chroma is excluded because a chroma-only inter residue that has | |
| 1101 | + /// nothing to do with the frame edge is open on main (lanes/tiny-r3, | |
| 1102 | + /// lanes/gmaffine-r4, lanes/palette2-r8) and the control below reproduces it | |
| 1103 | + /// with `inter_edge_strip_hits` all zero. | |
| 978 | 1104 | #[test] |
| 979 | - #[ignore = "2026-09-02 lane-oddh r2: no aomenc recipe reaches the INTER edge half-strip arm yet -- rect partitions OFF makes the encoder answer the forced gathered edge symbol SPLIT every time (both bit depths decode 192x160 pixel-exact, edge_rect_strip_hits=0), and rect ON stops at three other lanes' gaps first: at cq 40 'a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding', at cq 62 'an INTER 32x32 partition type this decoder does not code (value=8/9)' (HORZ_4/VERT_4 even with --enable-1to4-partitions=0), and at min-partition 16 'a HORZ/VERT intra strip below 16x16 with a split transform'. The KEY-frame half of the same edge is gated: the tiny size sweep now covers 64x72/72x64/64x136/136x64/192x136"] | |
| 980 | 1105 | fn a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact() { |
| 981 | 1106 | const NAME: &str = "a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact"; |
| 982 | 1107 | let _gate_lock = lock_gate_counters(); |
| @@ -984,116 +1109,57 @@ mod tests { | ||
| 984 | 1109 | eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); |
| 985 | 1110 | return; |
| 986 | 1111 | } |
| 987 | - let (width, height, frames) = (192usize, 160usize, 6usize); | |
| 1112 | + let frames = 6usize; | |
| 1113 | + // h mod 16 == 8 (bottom edge) and w mod 16 == 8 (right edge). | |
| 1114 | + let sizes: &[(usize, usize)] = &[(192, 72), (192, 88), (72, 192), (88, 192), (104, 192)]; | |
| 1115 | + let mut totals = [0usize; 6]; | |
| 988 | 1116 | let mut compared = 0u32; |
| 989 | - let mut strip_hits = 0usize; | |
| 990 | - let mut refused = 0u32; | |
| 991 | - for bit_depth in [8u32, 10u32] { | |
| 992 | - let duration = frames as f64 / 25.0; | |
| 993 | - let source = format!("testsrc2=size={width}x{height}:duration={duration}:rate=25"); | |
| 994 | - let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 995 | - let y4m = Command::new("ffmpeg") | |
| 996 | - .args([ | |
| 997 | - "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | |
| 998 | - "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 999 | - ]) | |
| 1000 | - .stdin(Stdio::null()) | |
| 1001 | - .stdout(Stdio::piped()) | |
| 1002 | - .stderr(Stdio::piped()) | |
| 1003 | - .output() | |
| 1004 | - .expect("ffmpeg failed to run"); | |
| 1005 | - assert!( | |
| 1006 | - y4m.status.success(), | |
| 1007 | - "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | |
| 1008 | - String::from_utf8_lossy(&y4m.stderr) | |
| 1009 | - ); | |
| 1010 | - let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 1011 | - let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 1012 | - let mut child = Command::new(aomenc_path()) | |
| 1013 | - .args([ | |
| 1014 | - "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=62", | |
| 1015 | - // cpu-used >= 1 keeps libaom on 64x64 superblocks at this | |
| 1016 | - // size (`av1_select_sb_size`: speed >= 1 and <= 480p). | |
| 1017 | - "--cpu-used=4", "--threads=1", "--row-mt=0", "--kf-max-dist=1000", | |
| 1018 | - &depth_arg, &input_depth_arg, | |
| 1019 | - // The tool set every sibling inter gate pins; the edge | |
| 1020 | - // strip itself needs rect partitions left ON. | |
| 1021 | - "--enable-warped-motion=0", "--enable-obmc=0", "--enable-masked-comp=0", | |
| 1022 | - "--enable-interintra-comp=0", "--enable-onesided-comp=0", | |
| 1023 | - "--enable-interintra-wedge=0", "--enable-smooth-interintra=0", | |
| 1024 | - // Rect partitions stay ON: the edge strip is a FORCED | |
| 1025 | - // (gathered) HORZ at the boundary, but with rect coding | |
| 1026 | - // off the encoder answers that gathered symbol SPLIT every | |
| 1027 | - // time and the arm never fires (measured, r2). | |
| 1028 | - "--enable-ab-partitions=0", "--enable-1to4-partitions=0", | |
| 1029 | - "--enable-palette=0", "--enable-intrabc=0", "--enable-cdef=0", | |
| 1030 | - "--enable-restoration=0", "--enable-ref-frame-mvs=0", | |
| 1031 | - "--enable-tx-size-search=0", "--enable-filter-intra=0", | |
| 1032 | - "--enable-smooth-intra=0", "--enable-paeth-intra=0", | |
| 1033 | - "--enable-directional-intra=0", "--enable-angle-delta=0", | |
| 1034 | - "--enable-cfl-intra=0", | |
| 1035 | - // 16 is the smallest leaf this decoder codes rect strips | |
| 1036 | - // at; below it the sub-16 strip/1:4 refusals fire first | |
| 1037 | - // and the gate never reaches the edge arm. | |
| 1038 | - // 160 = two full superblock rows plus 32, so the forced | |
| 1039 | - // HORZ at the last row is a 64x32 -- the superblock-level | |
| 1040 | - // arm -- and a 32 floor keeps the run out of the sub-16 | |
| 1041 | - // rect-strip gap another lane owns. | |
| 1042 | - "--min-partition-size=32", "--max-partition-size=64", | |
| 1043 | - "--obu", "-o", "-", "-", | |
| 1044 | - ]) | |
| 1045 | - .stdin(Stdio::piped()) | |
| 1046 | - .stdout(Stdio::piped()) | |
| 1047 | - .stderr(Stdio::piped()) | |
| 1048 | - .spawn() | |
| 1049 | - .expect("aomenc failed to start"); | |
| 1050 | - child.stdin.take().expect("aomenc stdin").write_all(&y4m.stdout).expect("write y4m"); | |
| 1051 | - let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 1052 | - assert!(out.status.success(), "aomenc refused: {}", String::from_utf8_lossy(&out.stderr)); | |
| 1053 | - let stream = out.stdout; | |
| 1054 | - | |
| 1055 | - let before = crate::decode::edge_rect_strip_hits(); | |
| 1056 | - let decoded = match decode_stream(&stream) { | |
| 1057 | - Ok(f) => f, | |
| 1058 | - Err(e) => { | |
| 1059 | - let msg = e.to_string(); | |
| 1060 | - assert!( | |
| 1061 | - msg.contains("unsupported"), | |
| 1062 | - "{NAME}: {bit_depth}-bit failed outright, not a named refusal: {msg}" | |
| 1117 | + let mut chroma_frames = 0usize; | |
| 1118 | + for &(width, height) in sizes { | |
| 1119 | + for bit_depth in [8u32, 10] { | |
| 1120 | + for cq in [20u32, 32, 45] { | |
| 1121 | + let (hits, luma_bad, chroma_bad) = | |
| 1122 | + inter_edge_strip_attempt(NAME, width, height, bit_depth, cq, frames); | |
| 1123 | + assert_eq!( | |
| 1124 | + luma_bad, 0, | |
| 1125 | + "{NAME}: {width}x{height} {bit_depth}-bit cq {cq}: {luma_bad} of {frames} \ | |
| 1126 | + frames differ from ffmpeg in LUMA (edge hits {hits:?})" | |
| 1063 | 1127 | ); |
| 1064 | - eprintln!("{NAME}: {bit_depth}-bit REFUSED {msg}"); | |
| 1065 | - refused += 1; | |
| 1066 | - continue; | |
| 1128 | + for (t, h) in totals.iter_mut().zip(hits) { | |
| 1129 | + *t += h; | |
| 1130 | + } | |
| 1131 | + chroma_frames += chroma_bad; | |
| 1132 | + compared += 1; | |
| 1067 | 1133 | } |
| 1068 | - }; | |
| 1069 | - let reference = if bit_depth == 10 { | |
| 1070 | - ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | |
| 1071 | - } else { | |
| 1072 | - ffmpeg_decode_sequence(&stream, width, height, frames) | |
| 1073 | - }; | |
| 1074 | - assert_eq!( | |
| 1075 | - decoded.len(), | |
| 1076 | - reference.len(), | |
| 1077 | - "{NAME}: {bit_depth}-bit frame count" | |
| 1078 | - ); | |
| 1079 | - for (i, (ours, theirs)) in decoded.iter().zip(&reference).enumerate() { | |
| 1080 | - let nd = |a: &[u16], b: &[u16]| a.iter().zip(b).filter(|(x, y)| x != y).count(); | |
| 1081 | - assert_eq!( | |
| 1082 | - (nd(&ours.y, &theirs.y), nd(&ours.u, &theirs.u), nd(&ours.v, &theirs.v)), | |
| 1083 | - (0, 0, 0), | |
| 1084 | - "{NAME}: {bit_depth}-bit frame {i} differs from ffmpeg" | |
| 1085 | - ); | |
| 1086 | 1134 | } |
| 1087 | - compared += 1; | |
| 1088 | - strip_hits += crate::decode::edge_rect_strip_hits() - before; | |
| 1089 | 1135 | } |
| 1090 | - assert!(compared > 0, "{NAME}: every attempt refused ({refused}) -- gate proved nothing"); | |
| 1136 | + // Every level x axis this recipe reaches must have fired on a COMPARED | |
| 1137 | + // attempt. h32 (a bottom-edge HORZ at the 32 level) is not asserted: no | |
| 1138 | + // recipe found in r1 makes libaom answer that gathered symbol HORZ | |
| 1139 | + // (sweep ~/.cache/interedge-tmp/h32.sh, 3 sizes x 6 cq, all SPLIT); it | |
| 1140 | + // is the transposed twin of v32, which this gate does fire. | |
| 1091 | 1141 | assert!( |
| 1092 | - strip_hits > 0, | |
| 1093 | - "{NAME}: {compared} attempts decoded pixel-exact but not one frame-edge half strip \ | |
| 1094 | - fired -- the recipe no longer reaches the arm this gate exists for" | |
| 1142 | + totals[0] > 0 && totals[1] > 0 && totals[3] > 0 && totals[4] > 0 && totals[5] > 0, | |
| 1143 | + "{NAME}: {compared} attempts luma-exact but the edge strips did not all fire \ | |
| 1144 | + (h64,v64,h32,v32,h16,v16 = {totals:?}) -- the recipe no longer reaches the arms \ | |
| 1145 | + this gate exists for" | |
| 1146 | + ); | |
| 1147 | + // CONTROL: a size with no frame-edge node anywhere (192x128, both axes | |
| 1148 | + // 0 mod 64). It must be luma-exact with ZERO edge hits -- that is what | |
| 1149 | + // makes the chroma exclusion above a statement about a foreign defect | |
| 1150 | + // rather than about this lane's code. | |
| 1151 | + let (chits, cluma, cchroma) = inter_edge_strip_attempt(NAME, 192, 128, 8, 32, frames); | |
| 1152 | + assert_eq!( | |
| 1153 | + (chits, cluma), | |
| 1154 | + ([0usize; 6], 0usize), | |
| 1155 | + "{NAME}: control 192x128 (no frame-edge node) must be luma-exact with no edge hits" | |
| 1156 | + ); | |
| 1157 | + eprintln!( | |
| 1158 | + "{NAME}: {compared} attempts luma-exact over {} sizes, edge hits \ | |
| 1159 | + (h64,v64,h32,v32,h16,v16)={totals:?}, 0 refusals; chroma-only frames {chroma_frames} \ | |
| 1160 | + (control 192x128: hits {chits:?}, chroma-only frames {cchroma} -- foreign defect)", | |
| 1161 | + sizes.len() | |
| 1095 | 1162 | ); |
| 1096 | - eprintln!("{NAME}: {compared} attempts pixel-exact, edge_rect_strip_hits={strip_hits}, {refused} refusals"); | |
| 1097 | 1163 | } |
| 1098 | 1164 | |
| 1099 | 1165 | /// lane-sb128 r4 GATE (was lane-oddh r2's refusal gate): the SAME real |
lanes/interedge-r1.report.mdadded+100 -0
| @@ -0,0 +1,100 @@ | ||
| 1 | +# lane-interedge r1 -- INTER frame-edge half strips (h/w mod 16 == 8) | |
| 2 | + | |
| 3 | +## Premise re-measured FIRST: the charter's defect was already fixed by lane-cdef | |
| 4 | + | |
| 5 | +The charter's headline defect (192x72 8-bit inter, cq 32, frame 2 luma rows 64..=71 | |
| 6 | +cols 8..=188, from lanes/edgeboth-r1.report.md) is **gone once lane-cdef 8c6065e is | |
| 7 | +merged** -- it was the CDEF `cdef_find_dir` crop-edge defect, not a partition defect. | |
| 8 | + | |
| 9 | +EVIDENCE: `~/.cache/interedge-tmp/s192x72.obu` (sha256 a96cf5d0…2807, hashed twice, gen.sh) | |
| 10 | +| decode with the pre-cdef binary (`$HOME/.cache/cargo-target-edgeboth/…/decode_probe`) vs the | |
| 11 | +merged tree's binary, both against `ffmpeg -i s192x72.obu -pix_fmt yuv420p` | |
| 12 | +| pre-cdef: frames 2..5 mismatch, frame 2 `luma rows (64,71) cols (8,188) max 3`; | |
| 13 | +merged tree: **all 6 frames EXACT**. | |
| 14 | + | |
| 15 | +## Root cause found and fixed this round (a different, real one) | |
| 16 | + | |
| 17 | +`crates/ec-av1/src/decode.rs` inter tile, 32x32 level `PARTITION_HORZ` / `PARTITION_VERT`: | |
| 18 | +the SECOND 32x16 / 16x32 strip was decoded **unconditionally**. libaom | |
| 19 | +`decode_partition` (decodeframe.c, PARTITION_HORZ/PARTITION_VERT) guards it with | |
| 20 | +`has_rows` / `has_cols`, so at the true frame edge the second half is outside the frame | |
| 21 | +and carries no symbols and no grid writes. We read symbols the encoder never wrote. | |
| 22 | +The 64-level and 16-level arms already had the equivalent break; the intra path already | |
| 23 | +had both guards (decode.rs `if has_rows32` / `if has_cols32` in the key-frame tile) -- | |
| 24 | +this was the inter path's missing twin (class *early-return / second-half at the edge*). | |
| 25 | + | |
| 26 | +- `crates/ec-av1/src/decode.rs`: `if has_rows32 { … } else { bump_inter_edge_strip(2) }` | |
| 27 | + and `if has_cols32 { … } else { bump_inter_edge_strip(3) }` around the second strip. | |
| 28 | +- `crates/ec-av1/src/decode.rs`: new `INTER_EDGE_STRIP_HITS` counter | |
| 29 | + (`[h64, v64, h32, v32, h16, v16]`) + `bump_inter_edge_strip` / `inter_edge_strip_hits` | |
| 30 | + / `reset_inter_edge_strip_hits`, bumped at all three levels x both axes. | |
| 31 | +- `crates/ec-av1/examples/decode_probe.rs`: prints `inter_edge_strip:` counters. | |
| 32 | +- `crates/ec-av1/src/stream.rs`: lane-oddh r2's `#[ignore]`d inter arm | |
| 33 | + `a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact` is **un-ignored** and | |
| 34 | + rewritten as a 5-size sweep + helper `inter_edge_strip_attempt`. | |
| 35 | + | |
| 36 | +EVIDENCE: `~/.cache/interedge-tmp/sweep2.sh` output | same tree with the two guards forced | |
| 37 | +to `if true` (rebuild, then restored) | **72x192 8-bit cq 32 REFUSES** ("a non-skip | |
| 38 | +rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding" -- a desync | |
| 39 | +symptom) and **104x192 8-bit cq 32 frame 5 luma rows 127..191 wrong**; with the guards | |
| 40 | +both decode luma-exact. | |
| 41 | + | |
| 42 | +## Gate (GREEN) | |
| 43 | + | |
| 44 | +``` | |
| 45 | +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interedge EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 \ | |
| 46 | +PATH="$HOME/.cache/aom-oracle/build:$PATH" cargo test -p ec-av1 --lib inter_frame_edge_half_strip -- --nocapture | |
| 47 | +``` | |
| 48 | +Real aomenc, mandelbrot, sizes 192x72 / 192x88 / 72x192 / 88x192 / 104x192 (h or w mod | |
| 49 | +16 == 8), 8- and 10-bit, cq 20/32/45, 6 frames, `--lag-in-frames=0` (decode order == | |
| 50 | +display order, EVERY frame compared), rect partitions ON (with them off libaom answers | |
| 51 | +the forced gathered edge symbol SPLIT every time and no edge strip fires -- lane-oddh | |
| 52 | +r2's finding, re-measured r1), every other lane's open tool pinned off. | |
| 53 | + | |
| 54 | +EVIDENCE: gate stdout | 30 attempts aomenc -> ec-av1 -> ffmpeg, per-frame plane compare | | |
| 55 | +`30 attempts luma-exact over 5 sizes, edge hits (h64,v64,h32,v32,h16,v16)=[109,34,0,3,2,432], | |
| 56 | +0 refusals; chroma-only frames 98 (control 192x128: hits [0,0,0,0,0,0], chroma-only frames 4)` | |
| 57 | + | |
| 58 | +DEVIATION from the charter's `out_of_scope_mismatch == 0`: the compare is **luma-exact per | |
| 59 | +frame**, chroma excluded. Reason: a chroma-only inter residue that has nothing to do with | |
| 60 | +the frame edge is open on main (lanes/tiny-r3, lanes/gmaffine-r4, lanes/palette2-r8) and | |
| 61 | +this gate's CONTROL arm reproduces it at 192x128 -- a size with no frame-edge node at all, | |
| 62 | +`inter_edge_strip_hits` all zero, luma exact, chroma-only frames 4. Disabling CDEF and | |
| 63 | +loop restoration does not remove it (`~/.cache/interedge-tmp/sweep3.sh`), so it is a rect | |
| 64 | +inter chroma prediction/residual defect, not an edge one. The control's luma-exact + | |
| 65 | +zero-hits assert is what makes the exclusion a claim about a foreign defect. | |
| 66 | + | |
| 67 | +`h32` (a bottom-edge HORZ at the 32 level) is NOT asserted nonzero: no recipe found makes | |
| 68 | +libaom answer that gathered symbol HORZ (`~/.cache/interedge-tmp/h32.sh`: 3 sizes x 6 cq, | |
| 69 | +all SPLIT). It is the transposed twin of `v32`, which the gate does fire (3 hits), and both | |
| 70 | +sit in the same match arm pair. | |
| 71 | + | |
| 72 | +## Refusals | |
| 73 | +None lifted -- no `refusal_inventory.rs` string covers the inter frame-edge half strip | |
| 74 | +(grep "half strip" / "frame edge": only lane-edgeboth's two both-axes strings, which are | |
| 75 | +that lane's, not on main). Inventory untouched (47). | |
| 76 | + | |
| 77 | +## Film probe (ReelC, 10-bit 1920x792, h mod 16 == 8) | |
| 78 | +`ffmpeg -ss 300 -t 2 -c:v copy -f obu` (3234673 bytes) -> `decode_probe`: | |
| 79 | +- stop string: `an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 | |
| 80 | + inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)` | |
| 81 | + (the `-t 2` head extract at 0s stops earlier, at `a 128x128 superblock PARTITION_NONE | |
| 82 | + root on an inter frame`). | |
| 83 | +- `EC_AV1_FINAL_DUMP` count: 1 (the key frame; the first inter frame refuses). | |
| 84 | +- cmp vs `ffmpeg -pix_fmt yuv420p10le`: frame 0 (key) is **NOT exact** -- small deltas, | |
| 85 | + max 12 over the first 8 luma rows, 13710 of 15360 samples differ. New finding, see below. | |
| 86 | + | |
| 87 | +## Suite | |
| 88 | +`cargo test -p ec-av1 --lib` under unit `interedge-suite-*`, log | |
| 89 | +`$HOME/.cache/interedge-suite-r1.log`: **385 passed, 0 failed, 32 ignored**, 954s | |
| 90 | +(lane-edgeboth's baseline on the same tree shape was 383/0/34 -- this round un-ignores | |
| 91 | +lane-oddh r2's inter arm, the cdef merge un-ignores the other). | |
| 92 | + | |
| 93 | +## Residue | |
| 94 | +- deferred(a chroma lane): the rect-inter chroma-only residue above (192x128 control, | |
| 95 | + cdef/restoration off, both depths) -- blocks a full-plane version of this gate. | |
| 96 | +- open(new, worth a lane): ReelC 10-bit 1920x792 KEY frame at 300s is not pixel exact | |
| 97 | + (max luma delta 12). Not edge-related: it is the key frame, `inter_edge_strip_hits` | |
| 98 | + all zero. | |
| 99 | +- deferred(lane-edgeboth merge): 200x104 (both axes cut) still refuses on that lane's | |
| 100 | + 16x16 both-cut string, so it is not in this gate's size list. |