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;
14 use ec_hw::{Codec, Decoder, I420};14 use ec_hw::{Codec, Decoder, I420};
15 use ec_va::Display;15 use ec_va::Display;
16 16
17+mod common;
18+use common::display;
19+
17 /// Frames in the grain fixture (every one of them is shown).20 /// Frames in the grain fixture (every one of them is shown).
18 const FRAMES: usize = 90;21 const FRAMES: usize = 90;
19 22
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-}
29 23
30 /// Split an IVF container into its frames (temporal units).24 /// Split an IVF container into its frames (temporal units).
31 fn split_ivf(data: &[u8]) -> Vec<&[u8]> {25 fn split_ivf(data: &[u8]) -> Vec<&[u8]> {
crates/ec-hw/tests/idr_counting.rsmodified+3 -11
@@ -10,24 +10,16 @@
10 10
11 use std::path::{Path, PathBuf};11 use std::path::{Path, PathBuf};
12 use std::process::Stdio;12 use std::process::Stdio;
13-use std::rc::Rc;
14 13
15 use ec_hw::{EncCodec, Encoder, EncoderConfig, FrameMetadata, I420, RateControlMode};14 use ec_hw::{EncCodec, Encoder, EncoderConfig, FrameMetadata, I420, RateControlMode};
16-use ec_va::Display;15+
16+mod common;
17+use common::display;
17 18
18 const WIDTH: u32 = 384;19 const WIDTH: u32 = 384;
19 const HEIGHT: u32 = 256;20 const HEIGHT: u32 = 256;
20 const FPS: u32 = 30;21 const FPS: u32 = 30;
21 22
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-}
31 23
32 fn scratch(name: &str) -> PathBuf {24 fn scratch(name: &str) -> PathBuf {
33 let dir = std::env::temp_dir().join(format!("ec-hw-idr-{name}"));25 let dir = std::env::temp_dir().join(format!("ec-hw-idr-{name}"));