diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 90a9ae8f..a79877bf 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -18399,7 +18399,7 @@ fn decode_inter_block( } let mut inter0_y = vec![0i32; side * side]; - mc::predict_compound_intermediate( + mc::predict_compound_intermediate_kern( &py0.data, py0.width, py0.true_width, @@ -18409,6 +18409,8 @@ fn decode_inter_block( scale0, side, side, + write_w, + write_h, h_filter, v_filter, &mut inter0_y, @@ -18424,7 +18426,7 @@ fn decode_inter_block( ); } let mut inter1_y = vec![0i32; side * side]; - mc::predict_compound_intermediate( + mc::predict_compound_intermediate_kern( &py1.data, py1.width, py1.true_width, @@ -18434,6 +18436,8 @@ fn decode_inter_block( scale1, side, side, + write_w, + write_h, h_filter, v_filter, &mut inter1_y, @@ -18471,7 +18475,7 @@ fn decode_inter_block( } let mut inter0_u = vec![0i32; chroma_side * chroma_side]; - mc::predict_compound_intermediate( + mc::predict_compound_intermediate_kern( &pu0.data, pu0.width, pu0.true_width, @@ -18481,6 +18485,8 @@ fn decode_inter_block( scale0, chroma_side, chroma_side, + write_chroma_w, + write_chroma_h, h_filter, v_filter, &mut inter0_u, @@ -18498,7 +18504,7 @@ fn decode_inter_block( } } let mut inter1_u = vec![0i32; chroma_side * chroma_side]; - mc::predict_compound_intermediate( + mc::predict_compound_intermediate_kern( &pu1.data, pu1.width, pu1.true_width, @@ -18508,6 +18514,8 @@ fn decode_inter_block( scale1, chroma_side, chroma_side, + write_chroma_w, + write_chroma_h, h_filter, v_filter, &mut inter1_u, @@ -18541,7 +18549,7 @@ fn decode_inter_block( } let mut inter0_v = vec![0i32; chroma_side * chroma_side]; - mc::predict_compound_intermediate( + mc::predict_compound_intermediate_kern( &pv0.data, pv0.width, pv0.true_width, @@ -18551,6 +18559,8 @@ fn decode_inter_block( scale0, chroma_side, chroma_side, + write_chroma_w, + write_chroma_h, h_filter, v_filter, &mut inter0_v, @@ -18568,7 +18578,7 @@ fn decode_inter_block( } } let mut inter1_v = vec![0i32; chroma_side * chroma_side]; - mc::predict_compound_intermediate( + mc::predict_compound_intermediate_kern( &pv1.data, pv1.width, pv1.true_width, @@ -18578,6 +18588,8 @@ fn decode_inter_block( scale1, chroma_side, chroma_side, + write_chroma_w, + write_chroma_h, h_filter, v_filter, &mut inter1_v, @@ -19489,7 +19501,7 @@ fn decode_inter_block( let mut pred_u = vec![0u16; chroma_side * chroma_side]; let mut pred_v = vec![0u16; chroma_side * chroma_side]; if luma_scale == mc::REF_NO_SCALE { - mc::predict_with_filters( + mc::predict_with_filters_kern( &py_ref.data, py_ref.width, py_ref.true_width, @@ -19498,11 +19510,13 @@ fn decode_inter_block( mv_to_q4(py, mv.0, true), side, side, + write_w, + write_h, h_filter, v_filter, &mut pred_y, ); - mc::predict_with_filters( + mc::predict_with_filters_kern( &pu_ref.data, pu_ref.width, pu_ref.true_width, @@ -19511,11 +19525,13 @@ fn decode_inter_block( mv_to_q4(cpy, mv.0, false), chroma_side, chroma_side, + write_chroma_w, + write_chroma_h, h_filter, v_filter, &mut pred_u, ); - mc::predict_with_filters( + mc::predict_with_filters_kern( &pv_ref.data, pv_ref.width, pv_ref.true_width, @@ -19524,12 +19540,14 @@ fn decode_inter_block( mv_to_q4(cpy, mv.0, false), chroma_side, chroma_side, + write_chroma_w, + write_chroma_h, h_filter, v_filter, &mut pred_v, ); } else { - mc::predict_scaled( + mc::predict_scaled_kern( &py_ref.data, py_ref.width, py_ref.true_width, @@ -19539,11 +19557,13 @@ fn decode_inter_block( luma_scale, side, side, + write_w, + write_h, h_filter, v_filter, &mut pred_y, ); - mc::predict_scaled( + mc::predict_scaled_kern( &pu_ref.data, pu_ref.width, pu_ref.true_width, @@ -19553,11 +19573,13 @@ fn decode_inter_block( luma_scale, chroma_side, chroma_side, + write_chroma_w, + write_chroma_h, h_filter, v_filter, &mut pred_u, ); - mc::predict_scaled( + mc::predict_scaled_kern( &pv_ref.data, pv_ref.width, pv_ref.true_width, @@ -19567,6 +19589,8 @@ fn decode_inter_block( luma_scale, chroma_side, chroma_side, + write_chroma_w, + write_chroma_h, h_filter, v_filter, &mut pred_v, diff --git a/crates/ec-av1/src/mc.rs b/crates/ec-av1/src/mc.rs index b57f1b35..5d57d0d8 100644 --- a/crates/ec-av1/src/mc.rs +++ b/crates/ec-av1/src/mc.rs @@ -333,6 +333,36 @@ pub fn predict_with_filters( h_kind: InterpFilterKind, v_kind: InterpFilterKind, dst: &mut [u16], +) { + predict_with_filters_kern( + reference, stride, true_width, true_height, x_q4, y_q4, block_w, + block_h, block_w, block_h, h_kind, v_kind, dst, + ); +} + +/// [`predict_with_filters`] with the 4-tap decision taken from the block's +/// TRUE width/height (`kern_w`/`kern_h`) rather than the destination buffer's. +/// libaom's `av1_get_interp_filter_params_with_block_size` (reconinter.h, +/// called per axis from `inter_predictor` with `w` then `h`) picks the narrow +/// kernel from the PREDICTION block's own dimensions; our inter path predicts +/// a rectangular block over its enclosing square buffer, so a rect block whose +/// chroma is 4 wide or 4 tall (luma 8x16 / 16x8 and taller kin) must still ask +/// for the 4-tap kernel on that axis -- lane-rectchroma2 r1. +#[allow(clippy::too_many_arguments)] +pub fn predict_with_filters_kern( + reference: &[u16], + stride: usize, + true_width: usize, + true_height: usize, + x_q4: i32, + y_q4: i32, + block_w: usize, + block_h: usize, + kern_w: usize, + kern_h: usize, + h_kind: InterpFilterKind, + v_kind: InterpFilterKind, + dst: &mut [u16], ) { assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); assert!(!reference.is_empty(), "a reference plane has samples"); @@ -374,12 +404,13 @@ pub fn predict_with_filters( let (h_wide, h_narrow) = h_kind.tables(); let (v_wide, v_narrow) = v_kind.tables(); - let h_filter = if block_w <= 4 { + note_narrow_kern(block_w, block_h, kern_w, kern_h); + let h_filter = if kern_w <= 4 { &h_narrow[xfrac] } else { &h_wide[xfrac] }; - let v_filter = if block_h <= 4 { + let v_filter = if kern_h <= 4 { &v_narrow[yfrac] } else { &v_wide[yfrac] @@ -452,6 +483,32 @@ thread_local! { /// only intra blocks cannot pass it by construction (class /// `gate-blind-to-feature`). static INTER_PRED_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; + + /// lane-rectchroma2 r1: how often the 4-tap decision came out DIFFERENT + /// from what the destination buffer's own dimensions would have given -- + /// i.e. how often a rectangular block predicted over its enclosing square + /// buffer asked for libaom's narrow kernel on an axis. Zero means a gate + /// never exercised the rect-chroma shape at all. + static RECT_NARROW_KERN_HITS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +/// Current value of [`RECT_NARROW_KERN_HITS`]. +pub fn rect_narrow_kern_hits() -> usize { + RECT_NARROW_KERN_HITS.with(|c| c.get()) +} + +/// Resets [`RECT_NARROW_KERN_HITS`] (per-attempt counting, class +/// `counter-from-refused-stream`). +pub fn reset_rect_narrow_kern_hits() { + RECT_NARROW_KERN_HITS.with(|c| c.set(0)); +} + +/// Bumps [`RECT_NARROW_KERN_HITS`] when the block's true dims pick a kernel +/// the destination buffer's dims would not have. +fn note_narrow_kern(block_w: usize, block_h: usize, kern_w: usize, kern_h: usize) { + if (kern_w <= 4) != (block_w <= 4) || (kern_h <= 4) != (block_h <= 4) { + RECT_NARROW_KERN_HITS.with(|c| c.set(c.get() + 1)); + } } /// Current value of [`INTER_PRED_HITS`]. @@ -498,6 +555,7 @@ fn horizontal_scaled_pass( y0: i32, x_scale_fp: i64, block_w: usize, + kern_w: usize, rows: usize, h_kind: InterpFilterKind, intermediate: &mut [i32], @@ -510,7 +568,7 @@ fn horizontal_scaled_pass( let x_qn = pos_x_q10 + c as i64 * x_step_qn; let int_pel = (x_qn >> 10) as i32; let filter_idx = ((x_qn & 1023) >> 6) as usize; - let h_filter = if block_w <= 4 { + let h_filter = if kern_w <= 4 { &h_narrow[filter_idx] } else { &h_wide[filter_idx] @@ -555,6 +613,31 @@ pub fn predict_scaled( h_kind: InterpFilterKind, v_kind: InterpFilterKind, dst: &mut [u16], +) { + predict_scaled_kern( + reference, stride, true_width, true_height, x_q4, y_q4, x_scale_fp, + block_w, block_h, block_w, block_h, h_kind, v_kind, dst, + ); +} + +/// [`predict_scaled`] with the 4-tap decision from the block's true dims +/// (see [`predict_with_filters_kern`]). +#[allow(clippy::too_many_arguments)] +pub fn predict_scaled_kern( + reference: &[u16], + stride: usize, + true_width: usize, + true_height: usize, + x_q4: i32, + y_q4: i32, + x_scale_fp: i64, + block_w: usize, + block_h: usize, + kern_w: usize, + kern_h: usize, + h_kind: InterpFilterKind, + v_kind: InterpFilterKind, + dst: &mut [u16], ) { assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); assert!(!reference.is_empty(), "a reference plane has samples"); @@ -568,7 +651,8 @@ pub fn predict_scaled( // Q10; off/pos_x_q10 fold the block's own x_q4 (Q4) into that same Q10 // grid (spec 7.11.3.3's `dec_calc_subpel_params`). let (v_wide, v_narrow) = v_kind.tables(); - let v_filter = if block_h <= 4 { + note_narrow_kern(block_w, block_h, kern_w, kern_h); + let v_filter = if kern_h <= 4 { &v_narrow[yfrac] } else { &v_wide[yfrac] @@ -585,6 +669,7 @@ pub fn predict_scaled( y0, x_scale_fp, block_w, + kern_w, rows, h_kind, &mut intermediate, @@ -648,6 +733,31 @@ pub fn predict_compound_intermediate( h_kind: InterpFilterKind, v_kind: InterpFilterKind, dst: &mut [i32], +) { + predict_compound_intermediate_kern( + reference, stride, true_width, true_height, x_q4, y_q4, x_scale_fp, + block_w, block_h, block_w, block_h, h_kind, v_kind, dst, + ); +} + +/// [`predict_compound_intermediate`] with the 4-tap decision from the block's +/// true dims (see [`predict_with_filters_kern`]). +#[allow(clippy::too_many_arguments)] +pub fn predict_compound_intermediate_kern( + reference: &[u16], + stride: usize, + true_width: usize, + true_height: usize, + x_q4: i32, + y_q4: i32, + x_scale_fp: i64, + block_w: usize, + block_h: usize, + kern_w: usize, + kern_h: usize, + h_kind: InterpFilterKind, + v_kind: InterpFilterKind, + dst: &mut [i32], ) { assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); assert!(!reference.is_empty(), "a reference plane has samples"); @@ -661,7 +771,8 @@ pub fn predict_compound_intermediate( let yfrac = y_q4.rem_euclid(16) as usize; let (v_wide, v_narrow) = v_kind.tables(); - let v_filter = if block_h <= 4 { + note_narrow_kern(block_w, block_h, kern_w, kern_h); + let v_filter = if kern_h <= 4 { &v_narrow[yfrac] } else { &v_wide[yfrac] @@ -678,6 +789,7 @@ pub fn predict_compound_intermediate( y0, x_scale_fp, block_w, + kern_w, rows, h_kind, &mut intermediate, diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 8b7ce7c3..63b677af 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -26618,4 +26618,202 @@ mod tests { // instead; this counter is reported, not gated. eprintln!("{NAME}: {skip_split_tx_total} skipped 8x8 TX_4X4 leaves across compared attempts"); } + + /// lane-rectchroma2 r1, the defect this gate exists for: our inter path + /// predicts a RECTANGULAR block over its enclosing SQUARE buffer + /// (`side`x`side`, `chroma_side`x`chroma_side` -- see + /// [`crate::decode`]'s `write_w`/`write_h` corner-cut), and + /// [`crate::mc::predict_with_filters`] took libaom's narrow-block 4-tap + /// decision from that buffer's dimensions. libaom + /// (`av1_get_interp_filter_params_with_block_size`, called per axis from + /// `inter_predictor` with `w` then `h`) takes it from the PREDICTION + /// block's own dimensions, so an 8x16 / 16x8 inter block -- whose chroma + /// is 4x8 / 8x4 -- must use the 4-tap kernel on the short axis. Luma is + /// never <= 4 wide here, which is exactly why every such stream decoded + /// LUMA EXACT and differed by +-1 on scattered chroma samples of those + /// blocks (lane-interedge r1's 192x128 control, a size with no frame-edge + /// node at all). + /// + /// Full-plane (Y+U+V) compare of EVERY decode-order frame + /// (`--lag-in-frames=0`), both orientations (192x128 and its transposed + /// twin, so the 4x8 and 8x4 chroma shapes both fire -- class + /// `scan-weights-cross-axis`), 8 AND 10 bit (his films are yuv420p10le), + /// cq 20/32/45, CDEF and loop restoration left ON. The counter is reset + /// per attempt and read only on an attempt that decoded and compared + /// (class `counter-from-refused-stream`); it counts predictions whose + /// kernel choice DIFFERS from what the square buffer would have given, so + /// a zero means the recipe lost the shape this gate pins. + #[test] + fn a_real_aomenc_rect_inter_block_predicts_chroma_with_the_narrow_kernel_pixel_exact() { + const NAME: &str = + "a_real_aomenc_rect_inter_block_predicts_chroma_with_the_narrow_kernel_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); + return; + } + const FRAMES: usize = 6; + let mut compared = 0usize; + let mut narrow_by_depth = [0usize; 2]; + let mut narrow_by_shape = [0usize; 2]; + for (si, (width, height)) in [(192usize, 128usize), (128usize, 192usize)] + .into_iter() + .enumerate() + { + for (di, depth) in [8usize, 10].into_iter().enumerate() { + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", + &format!("mandelbrot=size={width}x{height}:rate=25"), + "-pix_fmt", pix, "-strict", "-1", "-vframes", &FRAMES.to_string(), + "-f", "yuv4mpegpipe", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{NAME}: ffmpeg fixture ({width}x{height}, depth={depth}): {}", + String::from_utf8_lossy(&y4m.stderr) + ); + for cq in [20usize, 32, 45] { + let encode = || { + let mut child = Command::new(aomenc_path()) + .args([ + "--codec=av1", "--passes=1", "--end-usage=q", + &format!("--cq-level={cq}"), + "--cpu-used=4", "--threads=1", "--row-mt=0", + "--kf-max-dist=9999", &format!("--limit={FRAMES}"), + "--lag-in-frames=0", + &format!("--bit-depth={depth}"), + &format!("--input-bit-depth={depth}"), + // Rect partitions ON is the whole point; every + // other tool below is another lane's open gap + // that would refuse before a pixel compare. + "--enable-rect-partitions=1", "--enable-ab-partitions=0", + "--enable-1to4-partitions=0", "--min-partition-size=8", + "--max-partition-size=64", "--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("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture ({width}x{height}, depth={depth}, \ + cq={cq}): {}", + String::from_utf8_lossy(&out.stderr) + ); + out.stdout + }; + let stream = encode(); + assert_eq!( + stream, + encode(), + "{NAME}: aomenc output is not reproducible ({width}x{height}, \ + depth={depth}, cq={cq})" + ); + crate::mc::reset_rect_narrow_kern_hits(); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{NAME}: decode failed ({width}x{height}, depth={depth}, \ + cq={cq}): {msg}" + ); + eprintln!( + "{NAME}: {width}x{height} depth={depth} cq={cq} arm refused \ + (not compared): {msg}" + ); + continue; + } + }; + let narrow = crate::mc::rect_narrow_kern_hits(); + let ffmpeg_frames = if depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) + } else { + ffmpeg_decode_sequence(&stream, width, height, frames.len()) + }; + assert_eq!( + ffmpeg_frames.len(), + frames.len(), + "{NAME}: ffmpeg frame count ({width}x{height}, depth={depth}, cq={cq})" + ); + assert_eq!( + frames.len(), + FRAMES, + "{NAME}: not every coded frame was decoded ({width}x{height}, \ + depth={depth}, cq={cq})" + ); + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!( + got.y, want.y, + "{NAME} frame {i} luma vs ffmpeg ({width}x{height}, depth={depth}, \ + cq={cq}, narrow-kernel hits {narrow})" + ); + assert_eq!( + got.u, want.u, + "{NAME} frame {i} U vs ffmpeg ({width}x{height}, depth={depth}, \ + cq={cq}, narrow-kernel hits {narrow})" + ); + assert_eq!( + got.v, want.v, + "{NAME} frame {i} V vs ffmpeg ({width}x{height}, depth={depth}, \ + cq={cq}, narrow-kernel hits {narrow})" + ); + } + compared += 1; + narrow_by_depth[di] += narrow; + narrow_by_shape[si] += narrow; + eprintln!( + "{NAME}: {width}x{height} depth={depth} cq={cq} {} frames full-plane \ + exact, narrow-kernel hits {narrow}", + frames.len() + ); + } + } + } + assert_eq!( + compared, 12, + "{NAME}: only {compared} of 12 arms were pixel-compared -- a refusal makes this \ + gate vacuous" + ); + assert!( + narrow_by_depth[0] > 0 && narrow_by_depth[1] > 0, + "{NAME}: no rect-chroma narrow kernel fired at 8-bit ({}) or 10-bit ({}) -- the \ + recipe lost the shape this gate pins", + narrow_by_depth[0], narrow_by_depth[1] + ); + assert!( + narrow_by_shape[0] > 0 && narrow_by_shape[1] > 0, + "{NAME}: the shape fired in only one orientation (192x128 {}, 128x192 {})", + narrow_by_shape[0], narrow_by_shape[1] + ); + } } diff --git a/lanes/rectchroma2-r1.report.md b/lanes/rectchroma2-r1.report.md new file mode 100644 index 00000000..14e1cb8c --- /dev/null +++ b/lanes/rectchroma2-r1.report.md @@ -0,0 +1,87 @@ +# lane-rectchroma2 r1 -- rect INTER blocks predicted chroma with the WIDE kernel + +## Premise re-measured first + +lane-interedge r1's residue reproduced on this tree (main 2c04819 + lane-cdef + lane-golomb +173b793): mandelbrot 192x128 (the CONTROL size -- zero frame-edge nodes), 6 frames, +`--enable-rect-partitions=1 --min-partition-size=8 --enable-tx-size-search=0 --lag-in-frames=0`, +intra tools off, cq 20/32/45, 8- and 10-bit: **luma exact, chroma differs on frames 2..5 in all +six arms**. Streams hashed twice, identical. + +EVIDENCE: `~/.cache/rectchroma2-tmp/c192-128-{8,10}-{20,32,45}.obu` (each sha256 twice, equal) +| `decode_probe` with `EC_AV1_FINAL_DUMP` vs `ffmpeg -pix_fmt yuv420p[10le]`, every decode-order +frame, per plane | e.g. cq32 8-bit: `[(2,'chroma (0,32)..(1,40) n=17'), (4,...), (5,...)]`, luma +exact in all 6 arms. + +## Stage bisect + +Regenerated the same recipe with `--loopfilter-control=0` (deblock off; CDEF/LR already off in +that recipe): **the chroma mismatch survives unchanged** -> not a filter-stage defect, so the +charter's suspect (d) (chroma deblock levels / uv tx grid for rect inter blocks) is exonerated. +The surviving diffs are +-1 on scattered samples inside 4-wide-by-8-tall and 8-wide-by-4-tall +CHROMA regions (e.g. frame 4: chroma x32..35 rows 26..39, and x48..55 rows 16..19) -- i.e. the +chroma halves of 8x16 and 16x8 LUMA blocks. + +EVIDENCE: `~/.cache/rectchroma2-tmp/n192-128-8-32.obu` (`gen_nolf.sh`) | decode + full-plane +compare | `MISMATCH [(2,'chroma ... n=15'), (4,...n=36), (5,...n=45)]`, luma exact. + +## Root cause (charter suspect (a), confirmed) + +`crates/ec-av1/src/decode.rs` `decode_inter_block` predicts a RECTANGULAR block over its +enclosing SQUARE buffer (`side`x`side`, chroma `chroma_side`x`chroma_side`; `write_w`/`write_h` +govern only the pixel write -- the lane-partitions r1 corner-cut). The 4-tap decision lived +inside `mc::predict_with_filters` and read that BUFFER's dimensions. libaom +`av1_get_interp_filter_params_with_block_size` (reconinter.h, called per axis from +`inter_predictor` with `w` then `h`) reads the PREDICTION BLOCK's dimensions: `w <= 4` -> +`av1_interp_4tap[0]` (SHARP and REGULAR both) / `[1]` (SMOOTH). Luma is never <= 4 wide on this +path, so only chroma of a rect block (4x8 / 8x4 / 4x16 ...) was affected -- exactly the +"luma exact, chroma wrong" signature. + +- `crates/ec-av1/src/mc.rs`: `predict_with_filters_kern` / `predict_scaled_kern` / + `predict_compound_intermediate_kern` -- the existing three entry points keep their signatures + and delegate with `kern = block dims`; `horizontal_scaled_pass` takes `kern_w`. +- `crates/ec-av1/src/mc.rs`: `RECT_NARROW_KERN_HITS` + `rect_narrow_kern_hits()` / + `reset_rect_narrow_kern_hits()` / `note_narrow_kern()` -- counts predictions whose kernel + choice DIFFERS from what the square buffer would have given (one bump per prediction). +- `crates/ec-av1/src/decode.rs`: the 12 prediction calls inside `decode_inter_block` now pass + `write_w/write_h` (luma) and `write_chroma_w/write_chroma_h` (chroma) as the kernel dims. + +Class sweep: every other `mc::predict*` call site passes a buffer whose dims ARE the block's +(`obmc_neighbour_pred` takes the neighbour's true w/h; the 8x8 leaf path is square, chroma 4x4; +the CfL bilinear path is unrelated), so no sibling site needed the change. + +## Gate (GREEN) + +``` +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-rectchroma2 EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 \ +PATH="$HOME/.cache/aom-oracle/build:$PATH" cargo test -p ec-av1 --lib narrow_kernel -- --nocapture +``` +`a_real_aomenc_rect_inter_block_predicts_chroma_with_the_narrow_kernel_pixel_exact` +(`crates/ec-av1/src/stream.rs`): real aomenc, mandelbrot 192x128 AND its transposed twin +128x192 (so 4x8 and 8x4 chroma both fire), 8- and 10-bit, cq 20/32/45, 6 frames, +`--lag-in-frames=0` so decode order == display order and EVERY frame is compared on Y, U AND V +against ffmpeg. CDEF and loop restoration left ON. Streams encoded twice and asserted equal. +`compared == 12` is a hard assert (a refusal fails the gate, never SKIPs), and the narrow-kernel +counter -- reset per attempt, read only on compared attempts -- must be nonzero at BOTH depths +and in BOTH orientations. + +EVIDENCE: gate stdout | 12 aomenc -> ec-av1 -> ffmpeg attempts, 6 frames each, all three planes +| `12/12 arms 6 frames full-plane exact; narrow-kernel hits 24/4/16 (192x128 8-bit cq20/32/45), +18/26/36 (10-bit), 42/20/18 and 36/36/34 for 128x192` -- 0 refusals, 0 out-of-scope mismatches. + +Before the fix the SAME recipe mismatched chroma in every arm (the premise sweep above), so the +gate is not vacuous. + +## Refusals +None lifted (no inventory string covers this defect -- it was a wrong-pixels defect behind an +already-accepted path). `refusal_inventory.rs`/`gate_coverage.rs` untouched by intent, both green +in the suite below. + +## Suite +`$HOME/.cache/rectchroma2-suite-r1.log`: **388 passed, 0 failed, 35 ignored** (1668s), including the new gate. Baseline before this round on the same tree shape was 387/0/35 (this round adds one gate). + +## Residue +- accepted: `predict_scaled_kern` (scaled reference / superres) got the same fix by construction + but is not exercised by this gate -- superres rect-chroma has no aomenc recipe on this lane. +- deferred(lane-interedge merge): that lane's frame-edge gate can now become a FULL-PLANE arm; + its luma-only compare was a workaround for exactly this defect.