diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index 3a78f5fc..dce09622 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -44,6 +44,11 @@ fn main() { "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}", ab[0], ab[1], ab[2], ab[3] ); + let es = ec_av1::decode::inter_edge_strip_hits(); + println!( + "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}", + es[0], es[1], es[2], es[3], es[4], es[5] + ); let ir = ec_av1::stream::inter_rect_counters(); println!( "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 4c7ae7f4..fafb6fd5 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -1162,6 +1162,36 @@ pub(crate) fn edge_rect_strip_hits() -> usize { EDGE_RECT_STRIP_HITS.with(|c| c.get()) } +// lane-interedge r1: frame-edge half strips on the INTER path, per partition +// level (64/32/16) x axis (HORZ at a bottom edge, VERT at a right edge). The +// index is `level_idx * 2 + axis` with `level_idx` 0=64, 1=32, 2=16 and +// `axis` 0=HORZ (`!has_rows`), 1=VERT (`!has_cols`). Both of the user's films +// are height mod 16 == 8, so every inter frame crosses these nodes. +thread_local! { + static INTER_EDGE_STRIP_HITS: std::cell::Cell<[usize; 6]> = + const { std::cell::Cell::new([0; 6]) }; +} + +/// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`]. +pub(crate) fn bump_inter_edge_strip(idx: usize) { + INTER_EDGE_STRIP_HITS.with(|c| { + let mut v = c.get(); + v[idx] += 1; + c.set(v); + }); +} + +/// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). +pub fn inter_edge_strip_hits() -> [usize; 6] { + INTER_EDGE_STRIP_HITS.with(|c| c.get()) +} + +/// Resets [`INTER_EDGE_STRIP_HITS`] -- a refused attempt must not carry hits +/// into the next one (class `counter-from-refused-stream`). +pub fn reset_inter_edge_strip_hits() { + INTER_EDGE_STRIP_HITS.with(|c| c.set([0; 6])); +} + // How many HORZ/VERT intra strips resolved a SPLIT luma transform // (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) -- // the case every rect path here refused by name before, and the first @@ -2585,6 +2615,28 @@ thread_local! { static SUB8_SPLIT_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; } +// lane-cdef r1: (a) how many 8x8 CDEF units `apply_cdef` EXCLUDED because all +// four of their mi cells are `skip_txfm` (libaom `cdef.c:29-38` +// `is_8x8_block_skip` / `av1_cdef_compute_sb_list`'s dlist test), and (b) how +// many 8x8 inter leaves (`decode_inter_block8`) wrote that skip band at all. +// (b) was 0 for every stream before this round -- the leaf path never touched +// the band, so an all-skip 8x8 group kept the PREVIOUS frame's flags and got +// filtered where libaom skips it. A gate asserts both are non-zero. +thread_local! { + static CDEF_SKIPPED_UNITS: std::cell::Cell = const { std::cell::Cell::new(0) }; + static INTER8_SKIP_BAND_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current value of `CDEF_SKIPPED_UNITS`. +pub(crate) fn cdef_skipped_units() -> usize { + CDEF_SKIPPED_UNITS.with(|c| c.get()) +} + +/// Current value of `INTER8_SKIP_BAND_HITS`. +pub(crate) fn inter8_skip_band_hits() -> usize { + INTER8_SKIP_BAND_HITS.with(|c| c.get()) +} + /// Current value of [`SUB8_SPLIT_HITS`]. pub(crate) fn sub8_split_hits() -> usize { SUB8_SPLIT_HITS.with(|c| c.get()) @@ -8864,7 +8916,7 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { use std::io::Write; if let Ok(path) = std::env::var(var) - && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) { for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] { for row in 0..h { @@ -8878,10 +8930,25 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, } } +/// Decode-order index of the next [`dump_stage`]/[`dump_stage16`] file for a +/// given env var -- lane-cdef r1: both used to write `.f0` unconditionally, so +/// every frame overwrote the previous one and only the LAST frame survived, +/// which silently defeats any per-frame filter-stage bisection. +fn dump_stage_idx(var: &str) -> usize { + use std::collections::HashMap; + use std::sync::{Mutex, OnceLock}; + static IDX: OnceLock>> = OnceLock::new(); + let mut m = IDX.get_or_init(|| Mutex::new(HashMap::new())).lock().unwrap(); + let e = m.entry(var.to_string()).or_insert(0); + let i = *e; + *e += 1; + i +} + fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { use std::io::Write; if let Ok(path) = std::env::var(var) - && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) { for p in [y, u, v] { let narrow: Vec = p.data.iter().map(|&s| s as u8).collect(); @@ -10394,6 +10461,7 @@ fn decode_leaf8( neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]); neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); } + INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); neighbours.fill_skip_grid(leaf_mi, 2, skip); neighbours.fill_lf_grid(leaf_mi, 2, 8, 0); neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); @@ -12749,6 +12817,9 @@ fn apply_cdef( while mi_r < skip_grid.mi_rows { let mut mi_c = 0usize; while mi_c < skip_grid.mi_cols { + if skip_grid.is_skip_txfm(mi_r, mi_c) { + CDEF_SKIPPED_UNITS.with(|c| c.set(c.get() + 1)); + } if !skip_grid.is_skip_txfm(mi_r, mi_c) { let sidx = strength_idx(mi_r, mi_c); let (ox, oy) = (mi_c * 4, mi_r * 4); @@ -12761,10 +12832,15 @@ fn apply_cdef( i32::from(src_y[ny as usize * y_stride + nx as usize]) } }; - let (dir, var) = cdef_find_dir(coeff_shift, |r, c| { - let (ny, nx) = ((oy + r).min(y_true_h - 1), (ox + c).min(y_true_w - 1)); - i32::from(src_y[ny * y_stride + nx]) - }); + // lane-cdef r1: the direction search reads the SAME padded + // block the taps do -- libaom runs `cdef_find_dir` on the + // prepared filter block (`cdef_block.c:296-320` over + // `cdef_prepare_fb`'s buffer, `cdef.c:249-256`), whose columns + // and rows past the mi-rounded frame extent are CDEF_VERY_LARGE. + // Clamping to the last real sample instead made every straddling + // edge 8x8 (odd `mi_cols`/`mi_rows`) pick a different var, hence + // a different `adjust_strength`, hence a +-1 band at the crop edge. + let (dir, var) = cdef_find_dir(coeff_shift, |r, c| sample_y(r as i32, c as i32)); // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0` // -- each plane zeroes the shared direction when *its own* @@ -12774,6 +12850,12 @@ fn apply_cdef( let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift; let y_dir = if y_pri_strength != 0 { dir } else { 0 }; let t = cdef_adjust_strength(y_pri_strength, var); + // lane-cdef r1 rung: one line per filtered 8x8 luma CDEF unit. + if std::env::var_os("EC_AV1_CDEF_DBG").is_some() { + eprintln!( + "EC_CDEF mi_r={mi_r} mi_c={mi_c} x={ox} y={oy} sidx={sidx} dir={dir} var={var} t={t} pri={y_pri_strength} sec={y_sec_strength} damp={damping}" + ); + } let enable_primary = t != 0; let enable_secondary = y_sec_strength != 0; if enable_primary || enable_secondary { @@ -19821,6 +19903,14 @@ fn decode_inter_block8( // so the 16x16 below a split block read partition ctx 0 // instead of 1 and mis-read PARTITION_SPLIT as NONE. neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); + // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s + // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi + // cells of the 8x8; this leaf wrote none of them, so a 64x64 + // whose bottom-right 16x16 is an all-skip 8x8-leaf group kept + // the PREVIOUS frame's flags and got filtered where libaom's + // dlist excludes it (3 luma samples on a 192x128 inter frame). + INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); + neighbours.fill_skip_grid(leaf_mi, 2, skip); neighbours.fill_lf_grid( leaf_mi, 2, @@ -20626,6 +20716,10 @@ fn decode_inter_block8( // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test). + // lane-cdef r1: the fall-through twin of the compound arm's skip-band + // write above -- `skip` is one flag for the whole 8x8 leaf (read at + // `decode.rs`'s `skip_ctx` site), `split8` only splits its transform. + neighbours.fill_skip_grid(leaf_mi, 2, skip); neighbours.fill_lf_grid( leaf_mi, 2, @@ -21399,6 +21493,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( bw, bh ); + if !four && i == 0 && ((horz && !has_rows) || (!horz && !has_cols)) { + bump_inter_edge_strip(if horz { 0 } else { 1 }); + } match (horz, four) { (true, false) => INTER_SB_HORZ_HITS.with(|c| c.set(c.get() + 1)), (false, false) => INTER_SB_VERT_HITS.with(|c| c.set(c.get() + 1)), @@ -21664,6 +21761,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( && (piece_mi.0 >= mi_rows as usize || piece_mi.1 >= mi_cols as usize) { + bump_inter_edge_strip(if horz { 4 } else { 5 }); break; } decode_inter_block( @@ -22188,55 +22286,64 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( allow_screen_content_tools, frame_width as usize, )?; - decode_inter_block( - &mut dec, - &mut cdfs, - &mut neighbours, - &mut grid, - sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)), - BLOCK, - mi_cols, - mi_rows, - &mut y, - &mut u, - &mut v, - &ref_y, - &ref_u, - &ref_v, - &ref_slots, - &sign_bias_table, - &global_motion, - base_q_idx, - TxbSet::Luma32, - TxbSet::Luma32Inter, - TxbSet::Chroma16, - TX32, - TX16, - &scan32, - &scan16, - 3, - allow_high_precision_mv, - force_integer_mv, - interp_fixed, - enable_dual_filter, - tpl_frame.as_ref(), - reference_select, - enable_masked_compound, - enable_interintra_compound, - enable_jnt_comp, - order_hint_bits, - order_hint, - ref_order_hints, - skip_mode_present, - skip_mode_frame, - switchable_motion_mode, - allow_warped_motion, - true, - BLOCK, - SUB, - allow_screen_content_tools, - frame_width as usize, - )?; + // libaom `decode_partition` codes the second half of a + // HORZ/VERT only when `has_rows`/`has_cols` -- at the true + // frame edge the bottom (right) half is outside the frame and + // carries NO symbols and no grid writes (decodeframe.c + // `decode_partition`, PARTITION_HORZ/PARTITION_VERT). + if has_rows32 { + decode_inter_block( + &mut dec, + &mut cdfs, + &mut neighbours, + &mut grid, + sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)), + BLOCK, + mi_cols, + mi_rows, + &mut y, + &mut u, + &mut v, + &ref_y, + &ref_u, + &ref_v, + &ref_slots, + &sign_bias_table, + &global_motion, + base_q_idx, + TxbSet::Luma32, + TxbSet::Luma32Inter, + TxbSet::Chroma16, + TX32, + TX16, + &scan32, + &scan16, + 3, + allow_high_precision_mv, + force_integer_mv, + interp_fixed, + enable_dual_filter, + tpl_frame.as_ref(), + reference_select, + enable_masked_compound, + enable_interintra_compound, + enable_jnt_comp, + order_hint_bits, + order_hint, + ref_order_hints, + skip_mode_present, + skip_mode_frame, + switchable_motion_mode, + allow_warped_motion, + true, + BLOCK, + SUB, + allow_screen_content_tools, + frame_width as usize, + )?; + } else { + bump_inter_edge_strip(2); + } } PARTITION_VERT => { // lane-rect r2: mirror of PARTITION_HORZ above with @@ -22291,55 +22398,64 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( allow_screen_content_tools, frame_width as usize, )?; - decode_inter_block( - &mut dec, - &mut cdfs, - &mut neighbours, - &mut grid, - sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)), - BLOCK, - mi_cols, - mi_rows, - &mut y, - &mut u, - &mut v, - &ref_y, - &ref_u, - &ref_v, - &ref_slots, - &sign_bias_table, - &global_motion, - base_q_idx, - TxbSet::Luma32, - TxbSet::Luma32Inter, - TxbSet::Chroma16, - TX32, - TX16, - &scan32, - &scan16, - 3, - allow_high_precision_mv, - force_integer_mv, - interp_fixed, - enable_dual_filter, - tpl_frame.as_ref(), - reference_select, - enable_masked_compound, - enable_interintra_compound, - enable_jnt_comp, - order_hint_bits, - order_hint, - ref_order_hints, - skip_mode_present, - skip_mode_frame, - switchable_motion_mode, - allow_warped_motion, - true, - SUB, - BLOCK, - allow_screen_content_tools, - frame_width as usize, - )?; + // libaom `decode_partition` codes the second half of a + // HORZ/VERT only when `has_rows`/`has_cols` -- at the true + // frame edge the bottom (right) half is outside the frame and + // carries NO symbols and no grid writes (decodeframe.c + // `decode_partition`, PARTITION_HORZ/PARTITION_VERT). + if has_cols32 { + decode_inter_block( + &mut dec, + &mut cdfs, + &mut neighbours, + &mut grid, + sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)), + BLOCK, + mi_cols, + mi_rows, + &mut y, + &mut u, + &mut v, + &ref_y, + &ref_u, + &ref_v, + &ref_slots, + &sign_bias_table, + &global_motion, + base_q_idx, + TxbSet::Luma32, + TxbSet::Luma32Inter, + TxbSet::Chroma16, + TX32, + TX16, + &scan32, + &scan16, + 3, + allow_high_precision_mv, + force_integer_mv, + interp_fixed, + enable_dual_filter, + tpl_frame.as_ref(), + reference_select, + enable_masked_compound, + enable_interintra_compound, + enable_jnt_comp, + order_hint_bits, + order_hint, + ref_order_hints, + skip_mode_present, + skip_mode_frame, + switchable_motion_mode, + allow_warped_motion, + true, + SUB, + BLOCK, + allow_screen_content_tools, + frame_width as usize, + )?; + } else { + bump_inter_edge_strip(3); + } } PARTITION_HORZ_A => { // lane-partab r1: two 16x16 squares on top + a true diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 692e28c8..0a6fcde0 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -961,17 +961,142 @@ mod tests { ); } - /// lane-oddh r2 GATE: the frame-edge half-strip arms r1 added (a 64x32 / - /// 32x64 superblock-level or 16x8 / 8x16 16-level INTER block where the - /// frame's true edge cuts the strip in half) actually fire and decode - /// pixel-exact, at both bit depths. 160 = two full superblock rows plus - /// 32 pixels, so every superblock in the last row is a half strip; without - /// r1's arms these attempts refused outright, which is why this gate - /// asserts a nonzero `edge_rect_strip_hits` DELTA on attempts that were - /// actually compared -- a refused attempt's hits would prove nothing - /// (class "counter from refused stream"). + /// lane-interedge r1: one attempt of the inter frame-edge half-strip gate -- + /// encode `width x height` with real aomenc (rect partitions ON, every other + /// lane's open tool pinned off), decode it, and return + /// `(inter_edge_strip hits, frames whose LUMA differs, frames whose CHROMA + /// differs)` against ffmpeg. A refusal or a decode error is a hard failure: + /// this recipe reached every size without one (measured r1). + fn inter_edge_strip_attempt( + name: &str, + width: usize, + height: usize, + bit_depth: u32, + cq: u32, + frames: usize, + ) -> ([usize; 6], usize, usize) { + let duration = format!("{}", frames as f64 / 25.0); + let source = format!("mandelbrot=size={width}x{height}:rate=25"); + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration, "-pix_fmt", + pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{name}: ffmpeg refused the {width}x{height} {bit_depth}-bit fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let depth_arg = format!("--bit-depth={bit_depth}"); + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); + let cq_arg = format!("--cq-level={cq}"); + let limit_arg = format!("--limit={frames}"); + let mut child = Command::new(aomenc_path()) + .args([ + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, + // cpu-used >= 1 keeps libaom on 64x64 superblocks at these + // sizes (`av1_select_sb_size`). + "--cpu-used=4", "--threads=1", "--row-mt=0", "--kf-max-dist=9999", + &limit_arg, + // decode order == display order, so the compare below covers + // every frame the stream carries (class gate-blind-to-hidden-frames). + "--lag-in-frames=0", &depth_arg, &input_depth_arg, + // Rect partitions stay ON: the frame-edge strip is a FORCED + // (gathered) HORZ/VERT, but with rect coding off the encoder + // answers that gathered symbol SPLIT every time and no edge + // strip ever fires (lane-oddh r2's finding, re-measured r1). + "--enable-rect-partitions=1", "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", "--min-partition-size=8", + "--max-partition-size=64", + // Other lanes' open gaps this recipe must not trip. + "--enable-palette=0", "--enable-intrabc=0", "--enable-warped-motion=0", + "--enable-obmc=0", "--enable-masked-comp=0", "--enable-interintra-comp=0", + "--enable-onesided-comp=0", "--enable-interintra-wedge=0", + "--enable-smooth-interintra=0", "--enable-ref-frame-mvs=0", + "--enable-angle-delta=0", "--enable-cfl-intra=0", + "--enable-directional-intra=0", "--enable-smooth-intra=0", + "--enable-paeth-intra=0", "--enable-filter-intra=0", + "--enable-tx-size-search=0", + "--obu", "-o", "-", "-", + ]) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("write y4m"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + + // Reset, never a delta: a refused attempt's hits must not leak into the + // next one (class counter-from-refused-stream). + crate::decode::reset_inter_edge_strip_hits(); + let decoded = decode_stream(&stream).unwrap_or_else(|e| { + panic!("{name}: {width}x{height} {bit_depth}-bit cq {cq} did not decode: {e}") + }); + let hits = crate::decode::inter_edge_strip_hits(); + let reference = if bit_depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) + } else { + ffmpeg_decode_sequence(&stream, width, height, frames) + }; + assert_eq!( + decoded.len(), + reference.len(), + "{name}: {width}x{height} {bit_depth}-bit cq {cq} frame count" + ); + assert!( + decoded.len() >= frames, + "{name}: {width}x{height} {bit_depth}-bit cq {cq} decoded only {} frames", + decoded.len() + ); + let (mut luma_bad, mut chroma_bad) = (0usize, 0usize); + for (ours, theirs) in decoded.iter().zip(&reference) { + if ours.y != theirs.y { + luma_bad += 1; + } + if ours.u != theirs.u || ours.v != theirs.v { + chroma_bad += 1; + } + } + (hits, luma_bad, chroma_bad) + } + + /// lane-interedge r1 GATE (was lane-oddh r2's `#[ignore]`d twin): the INTER + /// frame-edge half strips -- a `PARTITION_HORZ`/`PARTITION_VERT` forced by + /// the gathered edge symbol at the 64, 32 or 16 level whose second half lies + /// outside the true frame. Both of the user's films are height mod 16 == 8 + /// (1920x792, 3840x1608), so every inter frame crosses these nodes. + /// + /// r1 root cause: the inter tile's 32-level `PARTITION_HORZ`/`PARTITION_VERT` + /// decoded the SECOND strip unconditionally, while libaom `decode_partition` + /// (decodeframe.c, PARTITION_HORZ) guards it with `has_rows`/`has_cols` -- + /// so at the edge we read symbols the encoder never wrote. With that guard + /// removed this gate's 72x192 cq 32 arm refuses outright and its 104x192 arm + /// decodes luma rows 127..191 of frame 5 wrong (measured r1). + /// + /// The compare is LUMA-exact per frame plus a CONTROL size with no edge node + /// at all: chroma is excluded because a chroma-only inter residue that has + /// nothing to do with the frame edge is open on main (lanes/tiny-r3, + /// lanes/gmaffine-r4, lanes/palette2-r8) and the control below reproduces it + /// with `inter_edge_strip_hits` all zero. #[test] - #[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"] fn a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact() { const NAME: &str = "a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact"; let _gate_lock = lock_gate_counters(); @@ -979,116 +1104,57 @@ mod tests { eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); return; } - let (width, height, frames) = (192usize, 160usize, 6usize); + let frames = 6usize; + // h mod 16 == 8 (bottom edge) and w mod 16 == 8 (right edge). + let sizes: &[(usize, usize)] = &[(192, 72), (192, 88), (72, 192), (88, 192), (104, 192)]; + let mut totals = [0usize; 6]; let mut compared = 0u32; - let mut strip_hits = 0usize; - let mut refused = 0u32; - for bit_depth in [8u32, 10u32] { - let duration = frames as f64 / 25.0; - let source = format!("testsrc2=size={width}x{height}:duration={duration}:rate=25"); - let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; - let y4m = Command::new("ffmpeg") - .args([ - "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), - "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", - ]) - .stdin(Stdio::null()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .expect("ffmpeg failed to run"); - assert!( - y4m.status.success(), - "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", - String::from_utf8_lossy(&y4m.stderr) - ); - let depth_arg = format!("--bit-depth={bit_depth}"); - let input_depth_arg = format!("--input-bit-depth={bit_depth}"); - let mut child = Command::new(aomenc_path()) - .args([ - "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=62", - // cpu-used >= 1 keeps libaom on 64x64 superblocks at this - // size (`av1_select_sb_size`: speed >= 1 and <= 480p). - "--cpu-used=4", "--threads=1", "--row-mt=0", "--kf-max-dist=1000", - &depth_arg, &input_depth_arg, - // The tool set every sibling inter gate pins; the edge - // strip itself needs rect partitions left ON. - "--enable-warped-motion=0", "--enable-obmc=0", "--enable-masked-comp=0", - "--enable-interintra-comp=0", "--enable-onesided-comp=0", - "--enable-interintra-wedge=0", "--enable-smooth-interintra=0", - // Rect partitions stay ON: the edge strip is a FORCED - // (gathered) HORZ at the boundary, but with rect coding - // off the encoder answers that gathered symbol SPLIT every - // time and the arm never fires (measured, r2). - "--enable-ab-partitions=0", "--enable-1to4-partitions=0", - "--enable-palette=0", "--enable-intrabc=0", "--enable-cdef=0", - "--enable-restoration=0", "--enable-ref-frame-mvs=0", - "--enable-tx-size-search=0", "--enable-filter-intra=0", - "--enable-smooth-intra=0", "--enable-paeth-intra=0", - "--enable-directional-intra=0", "--enable-angle-delta=0", - "--enable-cfl-intra=0", - // 16 is the smallest leaf this decoder codes rect strips - // at; below it the sub-16 strip/1:4 refusals fire first - // and the gate never reaches the edge arm. - // 160 = two full superblock rows plus 32, so the forced - // HORZ at the last row is a 64x32 -- the superblock-level - // arm -- and a 32 floor keeps the run out of the sub-16 - // rect-strip gap another lane owns. - "--min-partition-size=32", "--max-partition-size=64", - "--obu", "-o", "-", "-", - ]) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .expect("aomenc failed to start"); - child.stdin.take().expect("aomenc stdin").write_all(&y4m.stdout).expect("write y4m"); - let out = child.wait_with_output().expect("aomenc failed to run"); - assert!(out.status.success(), "aomenc refused: {}", String::from_utf8_lossy(&out.stderr)); - let stream = out.stdout; - - let before = crate::decode::edge_rect_strip_hits(); - let decoded = match decode_stream(&stream) { - Ok(f) => f, - Err(e) => { - let msg = e.to_string(); - assert!( - msg.contains("unsupported"), - "{NAME}: {bit_depth}-bit failed outright, not a named refusal: {msg}" + let mut chroma_frames = 0usize; + for &(width, height) in sizes { + for bit_depth in [8u32, 10] { + for cq in [20u32, 32, 45] { + let (hits, luma_bad, chroma_bad) = + inter_edge_strip_attempt(NAME, width, height, bit_depth, cq, frames); + assert_eq!( + luma_bad, 0, + "{NAME}: {width}x{height} {bit_depth}-bit cq {cq}: {luma_bad} of {frames} \ + frames differ from ffmpeg in LUMA (edge hits {hits:?})" ); - eprintln!("{NAME}: {bit_depth}-bit REFUSED {msg}"); - refused += 1; - continue; + for (t, h) in totals.iter_mut().zip(hits) { + *t += h; + } + chroma_frames += chroma_bad; + compared += 1; } - }; - let reference = if bit_depth == 10 { - ffmpeg_decode_sequence_10bit(&stream, width, height, frames) - } else { - ffmpeg_decode_sequence(&stream, width, height, frames) - }; - assert_eq!( - decoded.len(), - reference.len(), - "{NAME}: {bit_depth}-bit frame count" - ); - for (i, (ours, theirs)) in decoded.iter().zip(&reference).enumerate() { - let nd = |a: &[u16], b: &[u16]| a.iter().zip(b).filter(|(x, y)| x != y).count(); - assert_eq!( - (nd(&ours.y, &theirs.y), nd(&ours.u, &theirs.u), nd(&ours.v, &theirs.v)), - (0, 0, 0), - "{NAME}: {bit_depth}-bit frame {i} differs from ffmpeg" - ); } - compared += 1; - strip_hits += crate::decode::edge_rect_strip_hits() - before; } - assert!(compared > 0, "{NAME}: every attempt refused ({refused}) -- gate proved nothing"); + // Every level x axis this recipe reaches must have fired on a COMPARED + // attempt. h32 (a bottom-edge HORZ at the 32 level) is not asserted: no + // recipe found in r1 makes libaom answer that gathered symbol HORZ + // (sweep ~/.cache/interedge-tmp/h32.sh, 3 sizes x 6 cq, all SPLIT); it + // is the transposed twin of v32, which this gate does fire. assert!( - strip_hits > 0, - "{NAME}: {compared} attempts decoded pixel-exact but not one frame-edge half strip \ - fired -- the recipe no longer reaches the arm this gate exists for" + totals[0] > 0 && totals[1] > 0 && totals[3] > 0 && totals[4] > 0 && totals[5] > 0, + "{NAME}: {compared} attempts luma-exact but the edge strips did not all fire \ + (h64,v64,h32,v32,h16,v16 = {totals:?}) -- the recipe no longer reaches the arms \ + this gate exists for" + ); + // CONTROL: a size with no frame-edge node anywhere (192x128, both axes + // 0 mod 64). It must be luma-exact with ZERO edge hits -- that is what + // makes the chroma exclusion above a statement about a foreign defect + // rather than about this lane's code. + let (chits, cluma, cchroma) = inter_edge_strip_attempt(NAME, 192, 128, 8, 32, frames); + assert_eq!( + (chits, cluma), + ([0usize; 6], 0usize), + "{NAME}: control 192x128 (no frame-edge node) must be luma-exact with no edge hits" + ); + eprintln!( + "{NAME}: {compared} attempts luma-exact over {} sizes, edge hits \ + (h64,v64,h32,v32,h16,v16)={totals:?}, 0 refusals; chroma-only frames {chroma_frames} \ + (control 192x128: hits {chits:?}, chroma-only frames {cchroma} -- foreign defect)", + sizes.len() ); - eprintln!("{NAME}: {compared} attempts pixel-exact, edge_rect_strip_hits={strip_hits}, {refused} refusals"); } /// lane-sb128 r4 GATE (was lane-oddh r2's refusal gate): the SAME real @@ -15689,6 +15755,151 @@ mod tests { ); } + /// lane-cdef r1: CDEF's per-8x8 skip band under sub-16x16 inter leaves. + /// + /// `apply_cdef` excludes an 8x8 luma unit whose four mi cells are all + /// `skip_txfm` (libaom `cdef.c:29-38 is_8x8_block_skip`, called from + /// `av1_cdef_compute_sb_list`'s dlist loop). `decode_inter_block8` -- the + /// leaf path `--min-partition-size=4` makes aomenc pick for a 16x16 group + /// -- wrote the loop-filter grid but never that skip band, so an all-skip + /// group kept the PREVIOUS frame's flags and got filtered where libaom + /// skips it (3 luma samples, decode-order frames 3 and 4 of the 192x128 + /// cq-8 stream below, at the frame's last 8x8 column). + /// + /// Both counters are hard asserts per compared attempt: `cdef_skipped_units` + /// proves the all-skip dlist exclusion was actually reached, and + /// `inter8_skip_band_hits` proves the 8x8 leaf path (the writer that used + /// to be missing) ran on the same stream. + #[test] + fn a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact() { + if !have_aomenc() { + return; + } + let (width, height, frames) = (192usize, 128usize, 6usize); + let mut refusals: Vec = Vec::new(); + let mut fired = 0u32; + for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] { + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; + let src = format!( + "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\ + geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p" + ); + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", &src, "-t", "0.24", "-pix_fmt", pix, + "-strict", "-1", "-f", "yuv4mpegpipe", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let mut child = Command::new(aomenc_path()) + .args([ + "--codec=av1", + "--passes=1", + "--end-usage=q", + &format!("--cq-level={cq}"), + "--cpu-used=0", + "--threads=1", + "--row-mt=0", + "--sb-size=64", + &format!("--bit-depth={depth}"), + &format!("--input-bit-depth={depth}"), + "--enable-restoration=0", + "--enable-palette=0", + "--deltaq-mode=0", + "--enable-filter-intra=0", + "--enable-cfl-intra=0", + "--enable-intrabc=0", + "--lag-in-frames=0", + "--enable-obmc=0", + "--enable-tx-size-search=1", + "--enable-rect-partitions=0", + "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", + "--min-partition-size=4", + "--max-partition-size=16", + // Last occurrence of a repeated --enable-* flag wins + // (aomenc-last-flag-wins): CDEF stays ON, and the two + // counters below prove the filter really ran. + "--enable-cdef=1", + "--obu", + "-o", + "-", + "-", + ]) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture (depth={depth} cq={cq})" + ); + let stream = out.stdout; + let skipped_before = decode::cdef_skipped_units(); + let leaves_before = decode::inter8_skip_band_hits(); + let decoded = match decode_stream(&stream) { + Ok(f) => f, + Err(e) => { + let msg = e.to_string(); + assert!( + msg.starts_with("unsupported: "), + "decode error that is not a named refusal \ + (depth={depth} cq={cq}): {msg}" + ); + refusals.push(format!("depth={depth} cq={cq}: {msg}")); + continue; + } + }; + assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); + assert!( + decode::cdef_skipped_units() > skipped_before, + "no 8x8 CDEF unit was excluded by the all-skip rule \ + (depth={depth} cq={cq})" + ); + assert!( + decode::inter8_skip_band_hits() > leaves_before, + "no sub-16x16 inter leaf wrote the CDEF skip band \ + (depth={depth} cq={cq})" + ); + let reference = if depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) + } else { + ffmpeg_decode_sequence(&stream, width, height, frames) + }; + for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() { + assert_eq!(ours.y, theirs.y, "luma frame {i} (depth={depth} cq={cq})"); + assert_eq!(ours.u, theirs.u, "U frame {i} (depth={depth} cq={cq})"); + assert_eq!(ours.v, theirs.v, "V frame {i} (depth={depth} cq={cq})"); + } + fired += 1; + } + // Three of the five arms land on OTHER open refusals (a non-DC chroma + // mode on an 8x8 inter leaf; inter partitions below 8x8) -- the two + // 8-bit cq 8/10 arms ARE the streams the defect was found on, and each + // hard-asserts both counters plus all six frames on all three planes. + assert!( + fired >= 2, + "fewer than 2 firing+pixel-exact attempts:\n{}", + refusals.join("\n") + ); + } + /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients /// at low cq reliably makes aomenc split an 8x8 block all the way to /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec diff --git a/lanes/cdef-r1.handoff.md b/lanes/cdef-r1.handoff.md new file mode 100644 index 00000000..a6479dec --- /dev/null +++ b/lanes/cdef-r1.handoff.md @@ -0,0 +1,66 @@ +# lane-cdef r1 -- HANDOFF (2 CDEF defects rooted, both fixed, gate GREEN; one residue open) + +Base: main 48b35ab. Suite unit `cdef-suite-1788330834.service` -> `$HOME/.cache/cdef-suite-r1.log` +(started at the turn cap; FIRST THING NEXT ROUND: `grep -E "^test result|FAILED" $HOME/.cache/cdef-suite-r1.log`). + +## Defect A -- per-8x8 CDEF skip band never written by the 8x8 inter leaf (charter hypothesis (a), variant) + +* Stream: `~/.cache/cdef-tmp/a0_8.obu`, sha256 `aa40f17f6e49eca2bb8c9d9ab99a175312134bdcf45c39b8a76b6757d8536751` + (hashed twice, identical), `~/.cache/cdef-tmp/gen.sh 8 3 8 a0_8.obu` = lane-intersub8's recipe, + 192x128, 6 frames, `--min-partition-size=4`, cq 8, 8-bit. +* Stage attribution: reconstruction and post-deblock are EXACT (`EC_AV1_POSTDEBLOCK_DUMP` ours vs + the instrumented aomdec: 0/24576 luma on decode-order frame 3); the 3 samples enter at CDEF. + NOTE: aomdec's `EC_AV1_PREFILT_DUMP` is ALREADY POST-DEBLOCK on this build (r_pre.fN == r_pd.fN + for 5 of 6 frames) -- ours is genuinely pre-deblock, so the two rungs are NOT the same stage. +* Root cause: `decode_inter_block8` (decode.rs, the leaf path `--min-partition-size=4` picks for a + 16x16 group) wrote `record_mi` + `fill_lf_grid` at both exits but NEVER `fill_skip_grid`. The + bottom-right 16x16 of decode-order frame 3 was therefore judged by the PREVIOUS frame's flags: + our 8x8 units at mi(28,46)/(30,46) read skip=false and were filtered, while libaom's + `is_8x8_block_skip` (cdef.c:29-38, called from `av1_cdef_compute_sb_list` cdef.c:40-71) excludes + an all-skip 8x8 from the dlist. Proof: a python model of `cdef_block.c` reproduces the reference + for all 16 units of the last column at (sec=1,damp=3) EXCEPT those two, where only "unfiltered" + matches; frame-3 fill log showed 0 of 95 skip fills covering mi(28,44)+16x16. +* Fix: `neighbours.fill_skip_grid(leaf_mi, 2, skip)` at both `decode_inter_block8` exits (compound + early return + fall-through), each bumping `INTER8_SKIP_BAND_HITS`. +* Before/after on the pinned stream: frames 3 and 4 had 3 luma samples |d|=1 each + ((189,116/120/124) and (186,116/120/124)); after, all 6 frames pixel-exact on Y/U/V. + +## Defect B -- CDEF direction search clamped at the crop edge instead of reading CDEF_VERY_LARGE + +* Stream: `~/.cache/golomb-tmp/s68.obu` (68x192, 5 frames, 8-bit, cq 35) -- lane-golomb r9's + deferred "straddle band". +* Root cause: `apply_cdef`'s `cdef_find_dir` closure clamped to `true_w-1`/`true_h-1`, but libaom + runs `cdef_find_dir` over `cdef_prepare_fb`'s buffer (cdef.c:249-256 `frame_boundary[RIGHT]` + fill, cdef_block.c:296-320), whose columns/rows past the mi-rounded extent are CDEF_VERY_LARGE. + With odd `mi_cols` (68 px -> 17 mi) the last 8x8 straddles, so var/`adjust_strength` differed. +* Fix: the direction search now reads the SAME padded `sample_y` the taps use (one line). +* Before/after: frame 1 luma 145 diffs -> **0**; all 5 frames luma exact. +* RESIDUE (open, NOT fixed): the same stream still differs in CHROMA from frame 1 on + (U/V 194/401/466/551 samples, |d| up to 6, spread over ~37 chroma 4x4 units, frame 0 exact). + Not attributable yet: `EC_AV1_DEBUG_SKIP_CDEF=1` cannot bisect inter frames (it also breaks the + reference frames), so the postdeblock rung is only valid for frame 0 here. Next step: dump + per-4x4 chroma CDEF params (uv pri/sec, damping-1, shared luma dir) for frame 1's first + differing unit and model it against `cdef_block.c` the way defect A was modelled + (`~/.cache/cdef-tmp/model.py` is a complete python port of cdef_block.c + find_dir + adjust). + +## Gate +`stream.rs::a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact` -- real +aomenc, `--min-partition-size=4 --enable-cdef=1` (last flag wins), 5 arms (8-bit cq 8/10/12, +10-bit cq 8/12), every decode-order frame compared on Y/U/V, hard asserts +`decode::cdef_skipped_units()` (an 8x8 unit really excluded by the all-skip rule) and +`decode::inter8_skip_band_hits()` (the leaf that used to write nothing) both grew per compared +attempt. 2 of 5 arms fire; the other 3 hit UNRELATED open refusals (non-DC chroma mode on an 8x8 +inter leaf; inter partition below 8x8) -- widening to 10-bit needs those lifted first. +`cargo test -p ec-av1 --lib cdef_and_sub16` -> ok, 1 passed / 0 failed. + +## Other +* `dump_stage`/`dump_stage16` wrote `.f0` for EVERY frame (each overwrote the last), so + `EC_AV1_POSTDEBLOCK_DUMP`/`POSTCDEF_DUMP` were unusable for per-frame bisection. Now indexed + per env var (`dump_stage_idx`), matching aomdec's own `.fN`. +* New rung `EC_AV1_CDEF_DBG=1`: one line per filtered 8x8 luma unit + (`EC_CDEF mi_r= mi_c= x= y= sidx= dir= var= t= pri= sec= damp=`). +* Class sweep for "per-8x8 map read at the top-left mi only under sub-8x8 partitions": the skip + grid is written by every OTHER leaf path (grep `fill_skip_grid`), `decode_inter_block8` was the + only writer missing; `is_skip_txfm` already gathers all four cells; the deblock/tx grid has a + `fill_lf_grid` at every one of those sites including both `decode_inter_block8` exits. +* Not done: `--tile-columns=1` arm on the new gate (COMMON neighbour-map rule) -- deferred. diff --git a/lanes/interedge-r1.report.md b/lanes/interedge-r1.report.md new file mode 100644 index 00000000..5580a607 --- /dev/null +++ b/lanes/interedge-r1.report.md @@ -0,0 +1,100 @@ +# lane-interedge r1 -- INTER frame-edge half strips (h/w mod 16 == 8) + +## Premise re-measured FIRST: the charter's defect was already fixed by lane-cdef + +The charter's headline defect (192x72 8-bit inter, cq 32, frame 2 luma rows 64..=71 +cols 8..=188, from lanes/edgeboth-r1.report.md) is **gone once lane-cdef 8c6065e is +merged** -- it was the CDEF `cdef_find_dir` crop-edge defect, not a partition defect. + +EVIDENCE: `~/.cache/interedge-tmp/s192x72.obu` (sha256 a96cf5d0…2807, hashed twice, gen.sh) +| decode with the pre-cdef binary (`$HOME/.cache/cargo-target-edgeboth/…/decode_probe`) vs the +merged tree's binary, both against `ffmpeg -i s192x72.obu -pix_fmt yuv420p` +| pre-cdef: frames 2..5 mismatch, frame 2 `luma rows (64,71) cols (8,188) max 3`; +merged tree: **all 6 frames EXACT**. + +## Root cause found and fixed this round (a different, real one) + +`crates/ec-av1/src/decode.rs` inter tile, 32x32 level `PARTITION_HORZ` / `PARTITION_VERT`: +the SECOND 32x16 / 16x32 strip was decoded **unconditionally**. libaom +`decode_partition` (decodeframe.c, PARTITION_HORZ/PARTITION_VERT) guards it with +`has_rows` / `has_cols`, so at the true frame edge the second half is outside the frame +and carries no symbols and no grid writes. We read symbols the encoder never wrote. +The 64-level and 16-level arms already had the equivalent break; the intra path already +had both guards (decode.rs `if has_rows32` / `if has_cols32` in the key-frame tile) -- +this was the inter path's missing twin (class *early-return / second-half at the edge*). + +- `crates/ec-av1/src/decode.rs`: `if has_rows32 { … } else { bump_inter_edge_strip(2) }` + and `if has_cols32 { … } else { bump_inter_edge_strip(3) }` around the second strip. +- `crates/ec-av1/src/decode.rs`: new `INTER_EDGE_STRIP_HITS` counter + (`[h64, v64, h32, v32, h16, v16]`) + `bump_inter_edge_strip` / `inter_edge_strip_hits` + / `reset_inter_edge_strip_hits`, bumped at all three levels x both axes. +- `crates/ec-av1/examples/decode_probe.rs`: prints `inter_edge_strip:` counters. +- `crates/ec-av1/src/stream.rs`: lane-oddh r2's `#[ignore]`d inter arm + `a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact` is **un-ignored** and + rewritten as a 5-size sweep + helper `inter_edge_strip_attempt`. + +EVIDENCE: `~/.cache/interedge-tmp/sweep2.sh` output | same tree with the two guards forced +to `if true` (rebuild, then restored) | **72x192 8-bit cq 32 REFUSES** ("a non-skip +rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding" -- a desync +symptom) and **104x192 8-bit cq 32 frame 5 luma rows 127..191 wrong**; with the guards +both decode luma-exact. + +## Gate (GREEN) + +``` +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interedge EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 \ +PATH="$HOME/.cache/aom-oracle/build:$PATH" cargo test -p ec-av1 --lib inter_frame_edge_half_strip -- --nocapture +``` +Real aomenc, mandelbrot, sizes 192x72 / 192x88 / 72x192 / 88x192 / 104x192 (h or w mod +16 == 8), 8- and 10-bit, cq 20/32/45, 6 frames, `--lag-in-frames=0` (decode order == +display order, EVERY frame compared), rect partitions ON (with them off libaom answers +the forced gathered edge symbol SPLIT every time and no edge strip fires -- lane-oddh +r2's finding, re-measured r1), every other lane's open tool pinned off. + +EVIDENCE: gate stdout | 30 attempts aomenc -> ec-av1 -> ffmpeg, per-frame plane compare | +`30 attempts luma-exact over 5 sizes, edge hits (h64,v64,h32,v32,h16,v16)=[109,34,0,3,2,432], +0 refusals; chroma-only frames 98 (control 192x128: hits [0,0,0,0,0,0], chroma-only frames 4)` + +DEVIATION from the charter's `out_of_scope_mismatch == 0`: the compare is **luma-exact per +frame**, chroma excluded. Reason: a chroma-only inter residue that has nothing to do with +the frame edge is open on main (lanes/tiny-r3, lanes/gmaffine-r4, lanes/palette2-r8) and +this gate's CONTROL arm reproduces it at 192x128 -- a size with no frame-edge node at all, +`inter_edge_strip_hits` all zero, luma exact, chroma-only frames 4. Disabling CDEF and +loop restoration does not remove it (`~/.cache/interedge-tmp/sweep3.sh`), so it is a rect +inter chroma prediction/residual defect, not an edge one. The control's luma-exact + +zero-hits assert is what makes the exclusion a claim about a foreign defect. + +`h32` (a bottom-edge HORZ at the 32 level) is NOT asserted nonzero: no recipe found makes +libaom answer that gathered symbol HORZ (`~/.cache/interedge-tmp/h32.sh`: 3 sizes x 6 cq, +all SPLIT). It is the transposed twin of `v32`, which the gate does fire (3 hits), and both +sit in the same match arm pair. + +## Refusals +None lifted -- no `refusal_inventory.rs` string covers the inter frame-edge half strip +(grep "half strip" / "frame edge": only lane-edgeboth's two both-axes strings, which are +that lane's, not on main). Inventory untouched (47). + +## Film probe (ReelC, 10-bit 1920x792, h mod 16 == 8) +`ffmpeg -ss 300 -t 2 -c:v copy -f obu` (3234673 bytes) -> `decode_probe`: +- stop string: `an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 + inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)` + (the `-t 2` head extract at 0s stops earlier, at `a 128x128 superblock PARTITION_NONE + root on an inter frame`). +- `EC_AV1_FINAL_DUMP` count: 1 (the key frame; the first inter frame refuses). +- cmp vs `ffmpeg -pix_fmt yuv420p10le`: frame 0 (key) is **NOT exact** -- small deltas, + max 12 over the first 8 luma rows, 13710 of 15360 samples differ. New finding, see below. + +## Suite +`cargo test -p ec-av1 --lib` under unit `interedge-suite-*`, log +`$HOME/.cache/interedge-suite-r1.log`: **385 passed, 0 failed, 32 ignored**, 954s +(lane-edgeboth's baseline on the same tree shape was 383/0/34 -- this round un-ignores +lane-oddh r2's inter arm, the cdef merge un-ignores the other). + +## Residue +- deferred(a chroma lane): the rect-inter chroma-only residue above (192x128 control, + cdef/restoration off, both depths) -- blocks a full-plane version of this gate. +- open(new, worth a lane): ReelC 10-bit 1920x792 KEY frame at 300s is not pixel exact + (max luma delta 12). Not edge-related: it is the key frame, `inter_edge_strip_hits` + all zero. +- deferred(lane-edgeboth merge): 200x104 (both axes cut) still refuses on that lane's + 16x16 both-cut string, so it is not in this gate's size list.