diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 9db77bf6..2b08f958 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -4515,6 +4515,23 @@ pub(crate) fn affine_gm_hits() -> usize { AFFINE_GM_HITS.with(|c| c.get()) } +// lane-av1gwarp12: how many 16x16+ blocks built their SINGLE-reference +// prediction through `crate::warp::global_warp_params` with a FOUR-parameter +// (`ROTZOOM`) model. Vanilla aomenc pins its global-motion search to ROTZOOM +// (`global_motion_facade.c:24`), so this is the only >TRANSLATION single-ref +// global-warp arm a real aomenc stream can reach (AFFINE needs the widened +// side build and its own counter, [`AFFINE_GM_HITS`]). +thread_local! { + static ROTZOOM_GM_WARP_HITS: std::cell::Cell = + const { std::cell::Cell::new(0) }; +} + +/// Current value of [`ROTZOOM_GM_WARP_HITS`]. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub(crate) fn rotzoom_gm_warp_hits() -> usize { + ROTZOOM_GM_WARP_HITS.with(|c| c.get()) +} + // lane-t900 r9: rect blocks whose warp-sample top-right probe answers // differently at the block's WIDTH than at libaom's // `AOMMAX(xd->width, xd->height)` -- each one is a `num_proj_ref` that could @@ -34731,6 +34748,12 @@ fn decode_inter_block( if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine { hit!(AFFINE_GM_HITS); } + // lane-av1gwarp12: the ROTZOOM sibling -- the only + // >TRANSLATION model vanilla aomenc can emit for a single-ref + // global-motion block (encoder search pinned to ROTZOOM). + if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Rotzoom { + hit!(ROTZOOM_GM_WARP_HITS); + } } // lane-av112bitw: a local `WARPED_CAUSAL` projection (set above) // or a global warp model both land here with `warp_params` set -- diff --git a/crates/ec-av1/src/gate_coverage.rs b/crates/ec-av1/src/gate_coverage.rs index 087cfb69..d1835d40 100644 --- a/crates/ec-av1/src/gate_coverage.rs +++ b/crates/ec-av1/src/gate_coverage.rs @@ -119,15 +119,50 @@ enum On { /// only a gate that spells an on-value at that bit depth retires an entry. #[cfg(test)] const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[ - ("enable-tx-size-search", &["enable-tx-size-search"], "1", On::NonZero), - ("enable-directional-intra", &["enable-directional-intra"], "1", On::NonZero), - ("enable-smooth-interintra", &["enable-smooth-interintra"], "1", On::NonZero), - ("enable-interintra-wedge", &["enable-interintra-wedge"], "1", On::NonZero), - ("enable-diff-wtd-comp", &["enable-diff-wtd-comp"], "1", On::NonZero), - ("enable-onesided-comp", &["enable-onesided-comp"], "1", On::NonZero), + ( + "enable-tx-size-search", + &["enable-tx-size-search"], + "1", + On::NonZero, + ), + ( + "enable-directional-intra", + &["enable-directional-intra"], + "1", + On::NonZero, + ), + ( + "enable-smooth-interintra", + &["enable-smooth-interintra"], + "1", + On::NonZero, + ), + ( + "enable-interintra-wedge", + &["enable-interintra-wedge"], + "1", + On::NonZero, + ), + ( + "enable-diff-wtd-comp", + &["enable-diff-wtd-comp"], + "1", + On::NonZero, + ), + ( + "enable-onesided-comp", + &["enable-onesided-comp"], + "1", + On::NonZero, + ), ("enable-fwd-kf", &["enable-fwd-kf"], "0", On::NonZero), ("deblocking", &["loopfilter-control"], "1", On::NonZero), - ("multi-tile", &["tile-columns", "tile-rows"], "0", On::NonZero), + ( + "multi-tile", + &["tile-columns", "tile-rows"], + "0", + On::NonZero, + ), ("intrabc-search", &["cpu-used"], "0", On::AtMost(2)), ]; @@ -167,10 +202,14 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ "enable-flip-idtx", "never spelled; the flip/identity transform types are unproven by a real stream", ), - ( - "enable-global-motion", - "off in 5 gates, on in none at 8 bits; lane-gm owns the global-warp prediction that is still missing", - ), + // `enable-global-motion` LEFT this list on 2026-09-25 (lane-av1gwarp12 r2): + // `a_real_affine_global_motion_stream_decodes_pixel_exact` loops + // `for depth in [8u32, 10u32]` passing `--enable-global-motion=1` and + // pixel-compares both depths, so the 8-bit hole has been closed since + // lane-gmaffine r1 -- the entry survived because no suite ran a tree + // containing both the gate and this test until the ROTZOOM suite. + // The 12-bit ROTZOOM gate rides the high-depth bucket via `encode_12bit(` + // in `is_ten_bit`, so it plays no part in this retirement. ( "enable-rect-tx", "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool", @@ -178,7 +217,8 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ ]; #[cfg(test)] -const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit compound-global-warp gate closed `enable-global-motion` +const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ + // lane-cwarp's 10-bit compound-global-warp gate closed `enable-global-motion` // and `enable-dist-wtd-comp` at 10 bits without deleting their entries here, // so this list was already stale (and this test already red) at main 9c35ecc; // lane-tiles r11's multi-tile 10-bit gates then closed `enable-ab-partitions`, @@ -240,8 +280,8 @@ const NEVER_ON_10BIT: &[(&str, &str)] = &[]; #[cfg(test)] mod tests { use super::{ - ALIASES, DEFAULT_ON_TOOLS, NEVER_EXERCISED, NEVER_EXERCISED_8BIT, NEVER_EXERCISED_10BIT, - NEVER_ON_10BIT, NEVER_ON_8BIT, On, TOOL_UNIVERSE, + On, ALIASES, DEFAULT_ON_TOOLS, NEVER_EXERCISED, NEVER_EXERCISED_10BIT, + NEVER_EXERCISED_8BIT, NEVER_ON_10BIT, NEVER_ON_8BIT, TOOL_UNIVERSE, }; use std::collections::{BTreeMap, BTreeSet}; @@ -438,11 +478,19 @@ mod tests { } fn is_ten_bit(body: &str) -> bool { + // The lists pin two buckets, 8-bit and high-bit-depth; 12-bit gates + // count in the high-depth bucket (lane-av1gwarp12's ROTZOOM gate was + // the first 12-bit gate to positively enable a listed tool, and the + // 10-bit-only spellings mis-filed it as 8-bit). body.contains("encode_10bit_gradients") || body.contains("ten_bit_tool_gate(") || body.contains("--bit-depth=10") || body.contains("--input-bit-depth=10") || body.contains("yuv420p10le") + || body.contains("encode_12bit(") + || body.contains("--bit-depth=12") + || body.contains("--input-bit-depth=12") + || body.contains("yuv420p12le") } /// Flags a gate positively enables (`=1`), at gates of the given depth. @@ -534,7 +582,9 @@ mod tests { } /// [`DEFAULT_ON_TOOLS`] per depth: `tool -> (off in N gates, on in N, defaulted in N)`. - fn default_on_settings(ten_bit: bool) -> (usize, BTreeMap<&'static str, (usize, usize, usize)>) { + fn default_on_settings( + ten_bit: bool, + ) -> (usize, BTreeMap<&'static str, (usize, usize, usize)>) { let gates: Vec<&str> = gate_bodies() .into_iter() .filter(|b| covers_depth(b, ten_bit)) diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index a1dcb11e..bb2b8912 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -9779,6 +9779,54 @@ pub(crate) mod tests { y4m } + /// lane-av1gwarp12 fixture: rotating + uniformly zooming mandelbrot as a + /// C420p12 y4m. Rotation composed with a UNIFORM scale is a similarity + /// transform -- exactly the family a 4-parameter ROTZOOM global model + /// expresses (the affine gate needs the anisotropic stretch to force + /// 6 parameters; this lane needs the model vanilla aomenc actually + /// searches, ROTZOOM). + fn y4m_12bit_rotzoom_gm_source(frames: usize) -> Vec { + const W: usize = 128; + const H: usize = 128; + let source = format!( + "mandelbrot=size=192x192:rate=25,rotate=a=0.12*t:c=black,\ + scale=w='ceil(192*(1+0.04*n)/2)*2':h='ceil(192*(1+0.04*n)/2)*2':eval=frame,\ + crop={W}:{H}" + ); + let duration = (frames as f64 / 25.0).to_string(); + let ff_args: Vec<&str> = vec![ + "-v", + "error", + "-f", + "lavfi", + "-i", + &source, + "-pix_fmt", + "yuv420p12le", + // y4m has no official 12-bit tag, same as the 10-bit gate. + "-strict", + "-1", + "-t", + &duration, + "-f", + "yuv4mpegpipe", + "-", + ]; + let out = Command::new("ffmpeg") + .args(&ff_args) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + out.status.success(), + "ffmpeg fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + out.stdout + } + /// The 12-bit coding recipe shared by the witness gates (cpu-used=0 so /// every search runs; explicit CDEF/restoration ON). Warp/global-motion /// are deliberately NOT spelled here: this aomenc honours the LAST @@ -21426,6 +21474,99 @@ pub(crate) mod tests { } } + /// lane-av1gwarp12: the SINGLE-reference GLOBAL-warp witness at 12 bits + /// -- the open half lane-av112bitw recorded (engagement 0 on every prior + /// 12-bit content). The decode path is the same `warp_affine` with + /// `warp_round_0(12)` the local-warp witness proved, fed by + /// `global_warp_params(gm_ref.params)` at `decode_inter_block`'s + /// single-ref arm -- but composition had no stream: the travelling-box + /// source fits only TRANSLATION global models (excluded by + /// `is_global_mv_block`), and the rotating mandelbrot reached the global + /// models only on compound blocks. This recipe closes it: rotation + + /// uniform zoom (a similarity transform, ROTZOOM's exact family), the + /// compound tools off so a global model can only ride a single-reference + /// GLOBALMV block, and partitions pinned to 32 so the 8x8 leaf arm is + /// structurally out of the stream. Vanilla aomenc pins its gm search to + /// ROTZOOM (`global_motion_facade.c:24`), so every >TRANSLATION model a + /// real aomenc emits is ROTZOOM; AFFINE needs the widened side build + /// (`a_real_affine_global_motion_stream_decodes_pixel_exact`). + /// + /// Non-vacuous by construction: `rotzoom_gm_warp_hits()` hard-asserts a + /// 16x16+ block was really predicted through the global warp with a + /// ROTZOOM model, the zero `compound_warp_hits` delta keeps the + /// single-reference premise honest, and every plane of every frame + /// compares against ffmpeg. + #[test] + fn a_real_rotzoom_global_warp_12bit_stream_decodes_pixel_exact() { + const NAME: &str = "a_real_rotzoom_global_warp_12bit_stream_decodes_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 W: usize = 128; + const H: usize = 128; + const FRAMES: usize = 16; + let y4m = y4m_12bit_rotzoom_gm_source(FRAMES); + let stream = encode_12bit( + &y4m, + FRAMES, + &[ + "--enable-global-motion=1", + "--enable-warped-motion=0", + "--enable-obmc=0", + "--enable-masked-comp=0", + "--enable-interintra-comp=0", + "--enable-onesided-comp=0", + "--enable-ref-frame-mvs=0", + "--min-partition-size=32", + "--max-partition-size=32", + ], + ); + assert_12bit_sequence_header(&stream, NAME); + let (before_rotzoom, before_affine, before_selected, before_compound) = ( + decode::rotzoom_gm_warp_hits(), + decode::affine_gm_hits(), + decode::warp_selected_hits(), + decode::compound_warp_hits(), + ); + let frames = decode_stream(&stream).unwrap_or_else(|e| { + panic!("{NAME}: decode_stream refused a real 12-bit global-warp stream: {e}") + }); + assert_eq!(frames.len(), FRAMES); + let (delta_rotzoom, delta_affine, delta_selected) = ( + decode::rotzoom_gm_warp_hits() - before_rotzoom, + decode::affine_gm_hits() - before_affine, + decode::warp_selected_hits() - before_selected, + ); + eprintln!( + "{NAME}: gm_warp_engagement rotzoom(single-ref global warp)={delta_rotzoom} \ + affine={delta_affine} selected_local_warp={delta_selected}" + ); + assert!( + delta_rotzoom > 0, + "{NAME}: decoded but no single-reference ROTZOOM global-warp block fired -- \ + the 12-bit single-ref global-warp path is unexercised and the pixel \ + compare would prove nothing" + ); + assert_eq!( + decode::compound_warp_hits() - before_compound, + 0, + "{NAME}: a compound warp block ran -- the single-reference premise is gone" + ); + let ffmpeg_frames = ffmpeg_decode_sequence_12bit(&stream, W, H, FRAMES); + for (i, (ours, reference)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!(ours.y, reference.y, "{NAME} frame {i} luma vs ffmpeg"); + assert_eq!(ours.u, reference.u, "{NAME} frame {i} U vs ffmpeg"); + assert_eq!(ours.v, reference.v, "{NAME} frame {i} V vs ffmpeg"); + } + eprintln!("{NAME}: {FRAMES} frames pixel-exact vs ffmpeg, rotzoom_gm_warp_hits={delta_rotzoom}"); + } + /// lane-gmaffine r1: the two 8x8-LEAF motion gates. `decode_inter_block8` /// is a separate function from [`decode_inter_block`], and until this /// round it refused both `GLOBALMV` ("GLOBALMV (round 3)") and diff --git a/lanes/av1gwarp12.report.md b/lanes/av1gwarp12.report.md new file mode 100644 index 00000000..1d543af6 --- /dev/null +++ b/lanes/av1gwarp12.report.md @@ -0,0 +1,94 @@ +# lane-av1-gwarp12 — the single-ref GLOBAL-warp witness at 12 bits + +Base fe3e8418, worktree `edith_codecs-av1gwarp12`, branch `lane-av1-gwarp12`. +The charter: close lane-av112bitw's open half — "single-ref GLOBAL-warp at 12 +bits has no stream of its own" — with a real `aomenc --bit-depth=12` stream +whose single-reference inter blocks are predicted through +`warp::global_warp_params` under a ROTZOOM model, decoded against BOTH pixel +oracles, or an honest miss table. + +## Result: FOUND, first recipe, pixel-exact against both oracles + +Encode attempts aimed at the target: **2** (budget 8). Attempt 1 (the gate +itself) fired and was already byte-exact vs ffmpeg; attempt 2 re-encoded the +same recipe standalone for the aomdec oracle. + +1. `aomdec == ffmpeg` on the probe stream + (`/tmp/gwarp12probe/probe.obu`, sha256 + `3c6102cd0dd9bbccb5d15b2f3605a7dcea9e3189c1efc7d0317b16fc481af5fe`, + 37194 bytes; 16x 128x128 frames, 786432 raw bytes each decoder, + `cmp`-equal payloads). Since the gate proves our decode == ffmpeg on the + live re-encode, all three decoders agree on the firing stream. +2. Engagement: `rotzoom_gm_warp_hits = 152` (16x16+ single-ref blocks + predicted through `global_warp_params` with a ROTZOOM model), affine 0 + (vanilla aomenc cannot emit it, see below), local-warp symbol 0 + (`--enable-warped-motion=0` isolates the global arm), + `compound_warp_hits` delta 0 (hard-asserted; single-ref premise held). + +## Why the recipe works when the prior ones didn't + +Every prior 12-bit content fit TRANSLATION global models (excluded by +`is_global_mv_block`) or reached >TRANSLATION models only on compound blocks. +The lever is composition, not the encoder: + +- **Content**: rotation + UNIFORM zoom — a similarity transform, exactly the + family the 4-parameter ROTZOOM model expresses (`mandelbrot` + + `rotate=a=0.12*t` + symmetric `scale` over `n`, cropped 128x128). +- **Compound tools OFF** (`--enable-masked-comp=0 --enable-interintra-comp=0 + --enable-onesided-comp=0`, plus lag 0 / alt-ref 0 so all refs are + forward): a global model can then only ride a single-reference GLOBALMV + block. +- **`--enable-warped-motion=0`**: no local WARPED_CAUSAL can take + `warp_params` first; the `warp_params.is_none()` guard at the single-ref + arm makes every hit unambiguously a global-warp hit. +- **`--min/--max-partition-size=32`**: every inter leaf is 16x16+, so the + 8x8-leaf arm (`decode_inter_block8`, leaf8 lane's file region) is + structurally out of the stream and my counter proves MY site, not a twin. +- **Model bound is encoder-side**: `global_motion_facade.c:24` pins the gm + search to ROTZOOM, so every >TRANSLATION single-ref model a real aomenc + can emit IS ROTZOOM. (AFFINE needs the widened side build and has its own + gate + `affine_gm_hits` at 8/10 bits.) + +Exact flags: the `encode_12bit` witness base (cq 20, cpu-used 0, sb 64, +profile 2, cdef/restoration ON) plus the extras above and +`--enable-global-motion=1 --enable-obmc=0 --enable-ref-frame-mvs=0`. +Fixture: `y4m_12bit_rotzoom_gm_source` (ffmpeg lavfi, C420p12 y4m, 16 +frames). The gate re-encodes live; engagement reproduced identically across +three runs (152/152/152). + +## What changed + +- **decode.rs** — one new counter pair at the single-ref global-warp arm + (`decode_inter_block`, the lane's own site): `ROTZOOM_GM_WARP_HITS` + + `rotzoom_gm_warp_hits()`, bumped when `global_warp_params` resolves AND + `gm_ref.model == Rotzoom`, mirroring the `AFFINE_GM_HITS` twin. The 8x8 + leaf arm's copy was deliberately NOT touched (leaf8 lane). +- **stream.rs** — `y4m_12bit_rotzoom_gm_source` fixture helper + the gate + `a_real_rotzoom_global_warp_12bit_stream_decodes_pixel_exact`: + `assert_12bit_sequence_header` preflight, hard `delta_rotzoom > 0` (a + warpless stream cannot pass), hard `compound_warp_hits` delta == 0, and + every plane of every frame byte-equal vs ffmpeg + (`ffmpeg_decode_sequence_12bit`). + +No decoder arithmetic changed: the single-ref path was lifted by +lane-av112bitw (parameterised `warp_round_0`) and the composition argument +held — the stream proves it instead of arguing it. Non-vacuity is by +construction (counter assert), and the gate FAILED-category risk (silent +skip) is closed: encode/ffmpeg presence is hard-asserted inside the gate. + +## Verification + +- New gate green (encode attempt 1): 16 frames pixel-exact vs ffmpeg, + 152 rotzoom hits. +- aomdec oracle probe (encode attempt 2): aomdec == ffmpeg, sha256 above. +- Scoped sweep of the 12-bit family the counter addition touches: 9/9 green + (`12bit` filter) including `a_12bit_warped_motion_stream_decodes_pixel_exact` + (engagement still 7/1/0), both compound global-warp 12-bit gates (16x16+ + and 8x8 leaf), grain refusal, screen refusal. +- `cargo check -p ec-av1 --all-targets`: clean, no warnings. + +## Create-list audit + +One new file: this report. Touched: `decode.rs` (counter), `stream.rs` +(helper + gate). No fixture committed (gate encodes live), no junk files; +probe artifacts under /tmp are throwaway.