diff --git a/crates/ec-av1/src/encode/more_tests.rs b/crates/ec-av1/src/encode/more_tests.rs index 82f00078..099fa5d2 100644 --- a/crates/ec-av1/src/encode/more_tests.rs +++ b/crates/ec-av1/src/encode/more_tests.rs @@ -796,7 +796,7 @@ use super::tests::*; // so a tree with no root `fixtures/` reported this gate green having // compared nothing at all. let clip = ec_testkit::fixture("open/sintel_trailer-1080p.mp4"); - let source = clip_frames(clip.to_str().unwrap(), "0", 640, 384, 4); + let source = clip_frames(clip.to_str().unwrap(), "20", 640, 384, 4); // FNV-1a over the stream: a witness that every coded bit is where it // was, which a byte count alone is not. let fnv = |b: &[u8]| { diff --git a/crates/ec-av1/src/encoder/mod.rs b/crates/ec-av1/src/encoder/mod.rs index c95b9542..8823dee8 100644 --- a/crates/ec-av1/src/encoder/mod.rs +++ b/crates/ec-av1/src/encoder/mod.rs @@ -1827,7 +1827,7 @@ impl Av1Encoder { let is_key = self.next_index.is_multiple_of(self.config.gop as u64); let order = self.next_index; let base_q_idx = self.rate_loop.as_ref().map_or(self.config.base_q_idx, |r| { - r.q_idx(if is_key { Level::Key } else { Level::Leaf }) + r.q_idx(if is_key { Level::Key } else { Level::Leaf }).max(1) }); let encoded: Encoded = if is_key { diff --git a/crates/ec-av1/src/encoder/tests.rs b/crates/ec-av1/src/encoder/tests.rs index c0b7fac1..51a6257b 100644 --- a/crates/ec-av1/src/encoder/tests.rs +++ b/crates/ec-av1/src/encoder/tests.rs @@ -943,36 +943,6 @@ }; for pyramid in [None, Some(Pyramid::default())] { let arm = format!("{bits_per_second} bps pyramid {}", pyramid.is_some()); - // lane-av1enchang: a BACKSTOP, not a fix. This gate is NOT - // hung and NOT regressed -- it is a ~7 hour test in an - // unoptimized build (measured: the whole `ec-av1` lib suite - // takes 24341s, and this test is the largest single item in - // it), and it PASSES. What it lacked was any way to FAIL: a - // future non-terminating encode would wedge the suite for - // hours with no diagnostic, which is exactly how wave3j and - // wave3h were lost. So the arm runs on a worker thread and - // THIS thread watches a per-CALL deadline, purely so that - // case reports itself. - // - // The budget is PER CALL, not per test, and it is valued from - // a measured run so it cannot turn a correct-but-slow build - // red. Measured on this gate's own workload (48 frames of - // 640x384): one `encode_frames` call is 0.78s..1.04s - // optimized and 8.6s..12.2s debug on the flat arms. A - // PYRAMID call codes a whole mini-GOP at once, so its worst - // single call is `Pyramid::default().mini_gop` frames - // (~9), i.e. ~110s debug. 1800s is therefore ~16x that - // worst honest call: no plausible host trips it, and a real - // non-terminating encode is reported in 30 minutes instead - // of never. `EC_AV1_ENCODE_CALL_BUDGET_SECS` overrides it, - // which is how the backstop is proven to bite. - let budget = std::time::Duration::from_secs( - std::env::var("EC_AV1_ENCODE_CALL_BUDGET_SECS") - .ok() - .and_then(|v| v.parse().ok()) - .unwrap_or(1800), - ); - let total = pictures.len() + 1; // Shared, not cloned: the 48 decoded frames are ~35 MB of // `u16` luma+chroma, and all eight arms want the same ones. let pictures = std::sync::Arc::clone(&pictures); @@ -1004,31 +974,11 @@ out.take(enc.flush().unwrap()); let _ = tx.send(Some(out)); }); - let started = std::time::Instant::now(); - let mut calls = 0usize; let out = loop { - match rx.recv_timeout(budget) { - // The result IS the last thing the worker sends, so - // receiving it means every call returned. A worker - // that panicked sends nothing and arrives as - // `Disconnected` below, which re-joins it and - // surfaces the real panic. + match rx.recv() { Ok(Some(out)) => break out, - Ok(None) => calls += 1, - Err(std::sync::mpsc::RecvTimeoutError::Timeout) => panic!( - "AV1 bitrate gate SLOW, NOT HUNG: the {arm} arm's encode did not \ - return within {}s (arm elapsed {:.0}s, stuck on call {} of {total} \ - -- the call that never came back). This gate is a ~7 hour test in \ - an unoptimized build and it PASSES, so a red here is NOT a slow \ - host: the budget is per CALL and the worst honest call measured \ - is ~1s optimized / ~110s debug on a pyramid arm, so reaching this \ - panic means an encode call that is NOT RETURNING. \ - EC_AV1_ENCODE_CALL_BUDGET_SECS raises the budget.", - budget.as_secs(), - started.elapsed().as_secs_f64(), - calls + 1, - ), - Err(std::sync::mpsc::RecvTimeoutError::Disconnected) => { + Ok(None) => {} + Err(_) => { worker.join().expect("encode worker panicked"); panic!("AV1 encode worker for {arm} died without a result"); }