forge
Explore
Log in

Don't you dare go Hollow

U16: share the VA display helper through tests/common

Browse files at this commit

a84394acaf8f11f0a024d9d51764f00cfa7c879dAhmet Kaan GümüşParent: 70cc0ea
crates/ec-hw/tests/common/mod.rsadded+13 -0
@@ -0,0 +1,13 @@
1+use std::rc::Rc;
2+
3+use ec_va::Display;
4+
5+pub fn display() -> Option<Rc<Display>> {
6+ match ec_va::open() {
7+ Ok(display) => Some(display),
8+ Err(e) => {
9+ eprintln!("skipped: no VA display ({e})");
10+ None
11+ }
12+ }
13+}
crates/ec-hw/tests/film_grain.rsmodified+3 -9
@@ -14,18 +14,12 @@ use std::rc::Rc;
1414 use ec_hw::{Codec, Decoder, I420};
1515 use ec_va::Display;
1616
17+mod common;
18+use common::display;
19+
1720 /// Frames in the grain fixture (every one of them is shown).
1821 const FRAMES: usize = 90;
1922
20-fn display() -> Option<Rc<Display>> {
21- match ec_va::open() {
22- Ok(display) => Some(display),
23- Err(e) => {
24- eprintln!("skipped: no VA display ({e})");
25- None
26- }
27- }
28-}
2923
3024 /// Split an IVF container into its frames (temporal units).
3125 fn split_ivf(data: &[u8]) -> Vec<&[u8]> {
crates/ec-hw/tests/idr_counting.rsmodified+3 -11
@@ -10,24 +10,16 @@
1010
1111 use std::path::{Path, PathBuf};
1212 use std::process::Stdio;
13-use std::rc::Rc;
1413
1514 use ec_hw::{EncCodec, Encoder, EncoderConfig, FrameMetadata, I420, RateControlMode};
16-use ec_va::Display;
15+
16+mod common;
17+use common::display;
1718
1819 const WIDTH: u32 = 384;
1920 const HEIGHT: u32 = 256;
2021 const FPS: u32 = 30;
2122
22-fn display() -> Option<Rc<Display>> {
23- match ec_va::open() {
24- Ok(display) => Some(display),
25- Err(e) => {
26- eprintln!("skipped: no VA display ({e})");
27- None
28- }
29- }
30-}
3123
3224 fn scratch(name: &str) -> PathBuf {
3325 let dir = std::env::temp_dir().join(format!("ec-hw-idr-{name}"));