Never crash: Opus and VP9 encoders without expect()

opusenc: the SILK state is used through if-let / let-else instead of expect("SILK state").
vp9enc: the motion-search SAD and inter prediction return early without a reference frame
instead of expect("reference"). Denies the panic lints in both crates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-04 13:23:06 -04:00
co-authored by Claude Opus 5.5
parent 10644a83aa
commit 5cc376a818
4 changed files with 24 additions and 13 deletions
+2
View File
@@ -18,6 +18,8 @@
//! transforms, loop filter), so prediction never drifts; [`Vp9Encoder::reconstruction`] returns
//! it.
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
mod bool;
mod lf;
mod mc;
+3 -2
View File
@@ -599,7 +599,8 @@ impl<'a> Tile<'a> {
}
return s;
}
let refs = self.f.refs.as_ref().expect("reference");
// Inter search only runs on frames with a reference.
let Some(refs) = self.f.refs.as_ref() else { return u32::MAX / 4 };
let mut pred = [0u8; 256];
predict(&refs[0], x16, y16, n, n, &mut pred);
for i in 0..n {
@@ -739,7 +740,7 @@ impl<'a> Tile<'a> {
}
let mode = mode.0;
// Prediction of every plane (written straight into the reconstruction).
let refs = self.f.refs.as_ref().expect("reference");
let Some(refs) = self.f.refs.as_ref() else { return };
for plane in 0..3 {
let ch = plane > 0;
let (row16, col16) = clamp_for_plane(mv, r, c, n8, mi_rows, mi_cols, ch);