From 8525fddeb6b96ef77db4b78b1e423ff1e0a0e6d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 05:06:40 +0300 Subject: [PATCH] ec-av1 probe is test-only (ec-testkit is a dev-dependency), enc_probe example removed; fixtures.sh dies on a failed ffmpeg or download --- crates/ec-av1/Cargo.toml | 2 +- crates/ec-av1/examples/enc_probe.rs | 93 ----------------------------- crates/ec-av1/src/encode/mod.rs | 1 - crates/ec-av1/src/lib.rs | 3 +- scripts/fixtures.sh | 4 +- 5 files changed, 5 insertions(+), 98 deletions(-) delete mode 100644 crates/ec-av1/examples/enc_probe.rs diff --git a/crates/ec-av1/Cargo.toml b/crates/ec-av1/Cargo.toml index 809f70b1..21a37242 100644 --- a/crates/ec-av1/Cargo.toml +++ b/crates/ec-av1/Cargo.toml @@ -7,7 +7,6 @@ license.workspace = true authors.workspace = true [dependencies] -ec-testkit.workspace = true ec-core.workspace = true ec-av1-syntax.workspace = true archmage = "=0.9.31-beta.1" @@ -22,6 +21,7 @@ default = ["gate-counters"] gate-counters = [] [dev-dependencies] +ec-testkit.workspace = true # `nightly` only makes StatsAlloc::new const, so it can be a #[global_allocator] static. stats_alloc = { version = "0.1.10", features = ["nightly"] } tracking-allocator = "0.4.0" diff --git a/crates/ec-av1/examples/enc_probe.rs b/crates/ec-av1/examples/enc_probe.rs deleted file mode 100644 index 11c05543..00000000 --- a/crates/ec-av1/examples/enc_probe.rs +++ /dev/null @@ -1,93 +0,0 @@ -//! Encode-side profiling driver: the BD gate's own ladder, without ffmpeg's -//! decode side or the reference encoders, so `perf record` attributes only -//! our encoder. Also the byte-exactness gate for encoder-internal rewrites: -//! it prints each point's stream length and a hash of its bytes. -//! -//! Usage: `enc_probe [q,q,..]` -//! -//! `gate` as the width takes the native BD gate's own window on the clip -//! (`probe::gate_crop`, superblock-aligned centre crop) and ignores the height -//! argument; `EC_ENC_SS` is the gate's seek and `EC_ENC_VF` overrides the -//! filter chain. Without both of those the probe measures different pixels -//! than the gate it reports on. - -fn main() { - let a: Vec = std::env::args().skip(1).collect(); - let clip = a[0].clone(); - let frames: usize = a[3].parse().unwrap(); - let gate = a[1] == "gate"; - let (width, height) = match gate { - true => (0, 0), - false => (a[1].parse().unwrap(), a[2].parse().unwrap()), - }; - let qs: Vec = a.get(4).map_or_else( - || vec![150, 120, 90, 60], - |s| s.split(',').map(|q| q.parse().unwrap()).collect(), - ); - - // lane-census/lane-probe: the BD gate's native rows CROP (`EC_ENC_VF`) and - // SEEK (`EC_ENC_SS`) -- without the seek this probe read film B's black - // leader and every census off it was probe-relative. - let (vf, width, height) = match gate { - true => ec_av1::probe::gate_crop(&clip), - false => ( - std::env::var("EC_ENC_VF").unwrap_or_else(|_| format!("scale={width}:{height}")), - width, - height, - ), - }; - let vf = match gate { - true => std::env::var("EC_ENC_VF").unwrap_or(vf), - false => vf, - }; - eprintln!("probe: {width}x{height} vf={vf}"); - let skip = std::env::var("EC_ENC_SS").unwrap_or_else(|_| "0".into()); - let source = ec_av1::probe::source(&clip, &skip, &vf, width, height, frames); - - let start = std::time::Instant::now(); - for q in qs { - let e = ec_av1::encode::encode_sequence(&source, q, 0.5).unwrap(); - // FNV-1a over the stream: a byte-exactness witness, not a checksum - // with any other job. - let mut h: u64 = 0xcbf2_9ce4_8422_2325; - for &b in &e.stream { - h = (h ^ u64::from(b)).wrapping_mul(0x0000_0100_0000_01b3); - } - println!("q={q} bytes={} fnv1a={h:016x}", e.stream.len()); - // lane-census: keep the stream itself when asked, so `syntax_census` - // can read the very bytes this point measured. - if let Ok(dir) = std::env::var("EC_ENC_OUT") { - std::fs::write(format!("{dir}/ours-q{q}.obu"), &e.stream).expect("stream out"); - } - if ec_av1::encode::census_on() { - let (kinds, luma_rank, chroma_rank) = ec_av1::encode::take_census(); - for (name, n) in ec_av1::encode::CENSUS_KINDS.iter().zip(kinds) { - println!(" census {name}: {n}"); - } - let pct = |h: &[usize]| { - let total: usize = h.iter().sum::().max(1); - h.iter() - .map(|n| format!("{:.1}%", 100.0 * *n as f64 / total as f64)) - .collect::>() - .join(" ") - }; - println!(" census luma SAD rank of RD winner: {}", pct(&luma_rank)); - println!( - " census chroma SAD rank of RD winner: {}", - pct(&chroma_rank) - ); - } - // lane-arfmode: the engagement counter of the top ARF's offer-set - // lever, taken once per point so an armed run PRINTS a non-zero count - // (class gate-blind-to-feature; a BD number over a counter of zero - // proves nothing). Zeros when `EC_AV1_ARFMODE` is unset, which is the - // control's own expectation. - let hits = ec_av1::encode::take_arfmode_hits(); - println!(" arfmode hits: {} {} {}", hits[0], hits[1], hits[2]); - // lane-av1recipehunt: the gate's own precondition number -- how many - // blocks this point's search picked a DRL index the write-time stack - // could not carry. - println!(" drl_clamp: {}", ec_av1::tile::drl_clamp_hits()); - } - println!("wall {:.3}s", start.elapsed().as_secs_f64()); -} diff --git a/crates/ec-av1/src/encode/mod.rs b/crates/ec-av1/src/encode/mod.rs index 2ba0a425..dc4b38a4 100644 --- a/crates/ec-av1/src/encode/mod.rs +++ b/crates/ec-av1/src/encode/mod.rs @@ -41,7 +41,6 @@ use crate::tile::{ BlockCoeffs, Coeff, INTRA_MODE_CTX, InterInfo, InterMode, Quadrant, Superblock, partition_bits, }; #[cfg(test)] -use crate::transform::forward_and_quantize; use crate::transform::{ TxType, dequant_and_inverse_typed_wh, forward_and_quantize_typed, forward_and_quantize_typed_scaled, diff --git a/crates/ec-av1/src/lib.rs b/crates/ec-av1/src/lib.rs index 2d5675dc..28b9c83a 100644 --- a/crates/ec-av1/src/lib.rs +++ b/crates/ec-av1/src/lib.rs @@ -46,7 +46,8 @@ pub mod msac; pub mod mvstack; pub mod obu; mod par; -pub mod probe; +#[cfg(test)] +mod probe; pub mod qm; pub mod quant; mod restoration; diff --git a/scripts/fixtures.sh b/scripts/fixtures.sh index 7ce92e44..8182b125 100755 --- a/scripts/fixtures.sh +++ b/scripts/fixtures.sh @@ -22,9 +22,9 @@ sha() { sha256sum "$1" | cut -d' ' -f1; } have() { [ -s "$FX/$1" ] && { [ "$MODE" = record ] || [ "${WANT[$1]:-}" = "$(sha "$FX/$1")" ]; }; } chk() { [ "$MODE" = record ] && return 0; [ -n "${WANT[$1]:-}" ] || die "unlisted $1 (run: fixtures.sh record)"; [ "${WANT[$1]}" = "$(sha "$FX/$1")" ] || die "NONDETERMINISTIC $1"; } mk() { local rel=$1; shift; have "$rel" && return 0; need_ff; mkdir -p "$FX/$(dirname "$rel")" - local t="$FX/$(dirname "$rel")/.tmp.$(basename "$rel")"; ff "$@" $OUT "$t" && mv "$t" "$FX/$rel"; chk "$rel"; } + local t="$FX/$(dirname "$rel")/.tmp.$(basename "$rel")"; ff "$@" $OUT "$t" || die "ffmpeg failed: $rel"; mv "$t" "$FX/$rel"; chk "$rel"; } get() { local rel=$1 url=$2; have "$rel" && return 0; mkdir -p "$FX/$(dirname "$rel")" - curl -fsSL --retry 2 --connect-timeout 20 --max-time 900 -o "$FX/$rel.tmp" "$url" && mv "$FX/$rel.tmp" "$FX/$rel"; chk "$rel"; } + curl -fsSL --retry 2 --connect-timeout 20 --max-time 900 -o "$FX/$rel.tmp" "$url" || die "download failed: $url"; mv "$FX/$rel.tmp" "$FX/$rel"; chk "$rel"; } missing_under() { local p; for p in "${!WANT[@]}"; do [[ $p == "$1"/* && ! -e "$FX/$p" ]] && return 0; done; [ "$MODE" = record ] && [ ! -d "$FX/$1" ]; } unz() { missing_under "$2" && { mkdir -p "$FX/$2"; unzip -qo "$FX/$1" -d "$FX/$2"; } || true; } untar() { missing_under "$2" && tar -xzf "$FX/$1" -C "$FX/$(dirname "$2")" || true; }