diff --git a/crates/ec-hw/tests/common/mod.rs b/crates/ec-hw/tests/common/mod.rs new file mode 100644 index 00000000..75cad5f3 --- /dev/null +++ b/crates/ec-hw/tests/common/mod.rs @@ -0,0 +1,13 @@ +use std::rc::Rc; + +use ec_va::Display; + +pub fn display() -> Option> { + match ec_va::open() { + Ok(display) => Some(display), + Err(e) => { + eprintln!("skipped: no VA display ({e})"); + None + } + } +} diff --git a/crates/ec-hw/tests/film_grain.rs b/crates/ec-hw/tests/film_grain.rs index 9621042c..89f7713a 100644 --- a/crates/ec-hw/tests/film_grain.rs +++ b/crates/ec-hw/tests/film_grain.rs @@ -14,18 +14,12 @@ use std::rc::Rc; use ec_hw::{Codec, Decoder, I420}; use ec_va::Display; +mod common; +use common::display; + /// Frames in the grain fixture (every one of them is shown). const FRAMES: usize = 90; -fn display() -> Option> { - match ec_va::open() { - Ok(display) => Some(display), - Err(e) => { - eprintln!("skipped: no VA display ({e})"); - None - } - } -} /// Split an IVF container into its frames (temporal units). fn split_ivf(data: &[u8]) -> Vec<&[u8]> { diff --git a/crates/ec-hw/tests/idr_counting.rs b/crates/ec-hw/tests/idr_counting.rs index 1f36bd41..adaf6770 100644 --- a/crates/ec-hw/tests/idr_counting.rs +++ b/crates/ec-hw/tests/idr_counting.rs @@ -10,24 +10,16 @@ use std::path::{Path, PathBuf}; use std::process::Stdio; -use std::rc::Rc; use ec_hw::{EncCodec, Encoder, EncoderConfig, FrameMetadata, I420, RateControlMode}; -use ec_va::Display; + +mod common; +use common::display; const WIDTH: u32 = 384; const HEIGHT: u32 = 256; const FPS: u32 = 30; -fn display() -> Option> { - match ec_va::open() { - Ok(display) => Some(display), - Err(e) => { - eprintln!("skipped: no VA display ({e})"); - None - } - } -} fn scratch(name: &str) -> PathBuf { let dir = std::env::temp_dir().join(format!("ec-hw-idr-{name}"));