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
Browse files at this commit8525fddeb6b96ef77db4b78b1e423ff1e0a0e6d0Parent: de1790d5 changed files +5 -98
- crates/ec-av1/Cargo.toml +1 -1
- crates/ec-av1/examples/enc_probe.rs +0 -93
- crates/ec-av1/src/encode/mod.rs +0 -1
- crates/ec-av1/src/lib.rs +2 -1
- scripts/fixtures.sh +2 -2
crates/ec-av1/Cargo.tomlmodified+1 -1
| @@ -7,7 +7,6 @@ license.workspace = true | ||
| 7 | 7 | authors.workspace = true |
| 8 | 8 | |
| 9 | 9 | [dependencies] |
| 10 | -ec-testkit.workspace = true | |
| 11 | 10 | ec-core.workspace = true |
| 12 | 11 | ec-av1-syntax.workspace = true |
| 13 | 12 | archmage = "=0.9.31-beta.1" |
| @@ -22,6 +21,7 @@ default = ["gate-counters"] | ||
| 22 | 21 | gate-counters = [] |
| 23 | 22 | |
| 24 | 23 | [dev-dependencies] |
| 24 | +ec-testkit.workspace = true | |
| 25 | 25 | # `nightly` only makes StatsAlloc::new const, so it can be a #[global_allocator] static. |
| 26 | 26 | stats_alloc = { version = "0.1.10", features = ["nightly"] } |
| 27 | 27 | tracking-allocator = "0.4.0" |
crates/ec-av1/examples/enc_probe.rsdeleted+0 -93
| @@ -1,93 +0,0 @@ | ||
| 1 | -//! Encode-side profiling driver: the BD gate's own ladder, without ffmpeg's | |
| 2 | -//! decode side or the reference encoders, so `perf record` attributes only | |
| 3 | -//! our encoder. Also the byte-exactness gate for encoder-internal rewrites: | |
| 4 | -//! it prints each point's stream length and a hash of its bytes. | |
| 5 | -//! | |
| 6 | -//! Usage: `enc_probe <clip> <width|gate> <height> <frames> [q,q,..]` | |
| 7 | -//! | |
| 8 | -//! `gate` as the width takes the native BD gate's own window on the clip | |
| 9 | -//! (`probe::gate_crop`, superblock-aligned centre crop) and ignores the height | |
| 10 | -//! argument; `EC_ENC_SS` is the gate's seek and `EC_ENC_VF` overrides the | |
| 11 | -//! filter chain. Without both of those the probe measures different pixels | |
| 12 | -//! than the gate it reports on. | |
| 13 | - | |
| 14 | -fn main() { | |
| 15 | - let a: Vec<String> = std::env::args().skip(1).collect(); | |
| 16 | - let clip = a[0].clone(); | |
| 17 | - let frames: usize = a[3].parse().unwrap(); | |
| 18 | - let gate = a[1] == "gate"; | |
| 19 | - let (width, height) = match gate { | |
| 20 | - true => (0, 0), | |
| 21 | - false => (a[1].parse().unwrap(), a[2].parse().unwrap()), | |
| 22 | - }; | |
| 23 | - let qs: Vec<u8> = a.get(4).map_or_else( | |
| 24 | - || vec![150, 120, 90, 60], | |
| 25 | - |s| s.split(',').map(|q| q.parse().unwrap()).collect(), | |
| 26 | - ); | |
| 27 | - | |
| 28 | - // lane-census/lane-probe: the BD gate's native rows CROP (`EC_ENC_VF`) and | |
| 29 | - // SEEK (`EC_ENC_SS`) -- without the seek this probe read film B's black | |
| 30 | - // leader and every census off it was probe-relative. | |
| 31 | - let (vf, width, height) = match gate { | |
| 32 | - true => ec_av1::probe::gate_crop(&clip), | |
| 33 | - false => ( | |
| 34 | - std::env::var("EC_ENC_VF").unwrap_or_else(|_| format!("scale={width}:{height}")), | |
| 35 | - width, | |
| 36 | - height, | |
| 37 | - ), | |
| 38 | - }; | |
| 39 | - let vf = match gate { | |
| 40 | - true => std::env::var("EC_ENC_VF").unwrap_or(vf), | |
| 41 | - false => vf, | |
| 42 | - }; | |
| 43 | - eprintln!("probe: {width}x{height} vf={vf}"); | |
| 44 | - let skip = std::env::var("EC_ENC_SS").unwrap_or_else(|_| "0".into()); | |
| 45 | - let source = ec_av1::probe::source(&clip, &skip, &vf, width, height, frames); | |
| 46 | - | |
| 47 | - let start = std::time::Instant::now(); | |
| 48 | - for q in qs { | |
| 49 | - let e = ec_av1::encode::encode_sequence(&source, q, 0.5).unwrap(); | |
| 50 | - // FNV-1a over the stream: a byte-exactness witness, not a checksum | |
| 51 | - // with any other job. | |
| 52 | - let mut h: u64 = 0xcbf2_9ce4_8422_2325; | |
| 53 | - for &b in &e.stream { | |
| 54 | - h = (h ^ u64::from(b)).wrapping_mul(0x0000_0100_0000_01b3); | |
| 55 | - } | |
| 56 | - println!("q={q} bytes={} fnv1a={h:016x}", e.stream.len()); | |
| 57 | - // lane-census: keep the stream itself when asked, so `syntax_census` | |
| 58 | - // can read the very bytes this point measured. | |
| 59 | - if let Ok(dir) = std::env::var("EC_ENC_OUT") { | |
| 60 | - std::fs::write(format!("{dir}/ours-q{q}.obu"), &e.stream).expect("stream out"); | |
| 61 | - } | |
| 62 | - if ec_av1::encode::census_on() { | |
| 63 | - let (kinds, luma_rank, chroma_rank) = ec_av1::encode::take_census(); | |
| 64 | - for (name, n) in ec_av1::encode::CENSUS_KINDS.iter().zip(kinds) { | |
| 65 | - println!(" census {name}: {n}"); | |
| 66 | - } | |
| 67 | - let pct = |h: &[usize]| { | |
| 68 | - let total: usize = h.iter().sum::<usize>().max(1); | |
| 69 | - h.iter() | |
| 70 | - .map(|n| format!("{:.1}%", 100.0 * *n as f64 / total as f64)) | |
| 71 | - .collect::<Vec<_>>() | |
| 72 | - .join(" ") | |
| 73 | - }; | |
| 74 | - println!(" census luma SAD rank of RD winner: {}", pct(&luma_rank)); | |
| 75 | - println!( | |
| 76 | - " census chroma SAD rank of RD winner: {}", | |
| 77 | - pct(&chroma_rank) | |
| 78 | - ); | |
| 79 | - } | |
| 80 | - // lane-arfmode: the engagement counter of the top ARF's offer-set | |
| 81 | - // lever, taken once per point so an armed run PRINTS a non-zero count | |
| 82 | - // (class gate-blind-to-feature; a BD number over a counter of zero | |
| 83 | - // proves nothing). Zeros when `EC_AV1_ARFMODE` is unset, which is the | |
| 84 | - // control's own expectation. | |
| 85 | - let hits = ec_av1::encode::take_arfmode_hits(); | |
| 86 | - println!(" arfmode hits: {} {} {}", hits[0], hits[1], hits[2]); | |
| 87 | - // lane-av1recipehunt: the gate's own precondition number -- how many | |
| 88 | - // blocks this point's search picked a DRL index the write-time stack | |
| 89 | - // could not carry. | |
| 90 | - println!(" drl_clamp: {}", ec_av1::tile::drl_clamp_hits()); | |
| 91 | - } | |
| 92 | - println!("wall {:.3}s", start.elapsed().as_secs_f64()); | |
| 93 | -} |
crates/ec-av1/src/encode/mod.rsmodified+0 -1
| @@ -41,7 +41,6 @@ use crate::tile::{ | ||
| 41 | 41 | BlockCoeffs, Coeff, INTRA_MODE_CTX, InterInfo, InterMode, Quadrant, Superblock, partition_bits, |
| 42 | 42 | }; |
| 43 | 43 | #[cfg(test)] |
| 44 | -use crate::transform::forward_and_quantize; | |
| 45 | 44 | use crate::transform::{ |
| 46 | 45 | TxType, dequant_and_inverse_typed_wh, forward_and_quantize_typed, |
| 47 | 46 | forward_and_quantize_typed_scaled, |
crates/ec-av1/src/lib.rsmodified+2 -1
| @@ -46,7 +46,8 @@ pub mod msac; | ||
| 46 | 46 | pub mod mvstack; |
| 47 | 47 | pub mod obu; |
| 48 | 48 | mod par; |
| 49 | -pub mod probe; | |
| 49 | +#[cfg(test)] | |
| 50 | +mod probe; | |
| 50 | 51 | pub mod qm; |
| 51 | 52 | pub mod quant; |
| 52 | 53 | mod restoration; |
scripts/fixtures.shmodified+2 -2
| @@ -22,9 +22,9 @@ sha() { sha256sum "$1" | cut -d' ' -f1; } | ||
| 22 | 22 | have() { [ -s "$FX/$1" ] && { [ "$MODE" = record ] || [ "${WANT[$1]:-}" = "$(sha "$FX/$1")" ]; }; } |
| 23 | 23 | chk() { [ "$MODE" = record ] && return 0; [ -n "${WANT[$1]:-}" ] || die "unlisted $1 (run: fixtures.sh record)"; [ "${WANT[$1]}" = "$(sha "$FX/$1")" ] || die "NONDETERMINISTIC $1"; } |
| 24 | 24 | mk() { local rel=$1; shift; have "$rel" && return 0; need_ff; mkdir -p "$FX/$(dirname "$rel")" |
| 25 | - local t="$FX/$(dirname "$rel")/.tmp.$(basename "$rel")"; ff "$@" $OUT "$t" && mv "$t" "$FX/$rel"; chk "$rel"; } | |
| 25 | + local t="$FX/$(dirname "$rel")/.tmp.$(basename "$rel")"; ff "$@" $OUT "$t" || die "ffmpeg failed: $rel"; mv "$t" "$FX/$rel"; chk "$rel"; } | |
| 26 | 26 | get() { local rel=$1 url=$2; have "$rel" && return 0; mkdir -p "$FX/$(dirname "$rel")" |
| 27 | - curl -fsSL --retry 2 --connect-timeout 20 --max-time 900 -o "$FX/$rel.tmp" "$url" && mv "$FX/$rel.tmp" "$FX/$rel"; chk "$rel"; } | |
| 27 | + 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"; } | |
| 28 | 28 | missing_under() { local p; for p in "${!WANT[@]}"; do [[ $p == "$1"/* && ! -e "$FX/$p" ]] && return 0; done; [ "$MODE" = record ] && [ ! -d "$FX/$1" ]; } |
| 29 | 29 | unz() { missing_under "$2" && { mkdir -p "$FX/$2"; unzip -qo "$FX/$1" -d "$FX/$2"; } || true; } |
| 30 | 30 | untar() { missing_under "$2" && tar -xzf "$FX/$1" -C "$FX/$(dirname "$2")" || true; } |