forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

common.rs53 lines, 1.2 KiBHistoryRawDownload
1//! Helpers shared by the integration-test modules in this binary.
2
3use std::process::Command;
4
5use ec_core::frame::VideoFrame;
6
7pub(crate) fn chunk(id: &[u8; 4], body: &[u8]) -> Vec<u8> {
8 let mut v = id.to_vec();
9 v.extend((body.len() as u32).to_le_bytes());
10 v.extend(body);
11 if body.len() % 2 == 1 {
12 v.push(0);
13 }
14 v
15}
16
17pub(crate) fn list(kind: &[u8; 4], body: &[u8]) -> Vec<u8> {
18 let mut b = kind.to_vec();
19 b.extend(body);
20 chunk(b"LIST", &b)
21}
22
23pub(crate) fn tool_ok(name: &str) -> bool {
24 Command::new(name)
25 .arg("-version")
26 .output()
27 .map(|o| o.status.success())
28 .unwrap_or(false)
29}
30
31pub(crate) fn ffmpeg(args: &[&str]) {
32 let ok = Command::new("ffmpeg")
33 .args(["-v", "error", "-y", "-nostdin"])
34 .args(args)
35 .status()
36 .map(|s| s.success())
37 .unwrap_or(false);
38 assert!(ok, "ffmpeg {args:?} failed");
39}
40
41pub(crate) fn frame_bytes(f: &VideoFrame) -> Vec<u8> {
42 let mut out = Vec::new();
43 for (p, (row, rows)) in f
44 .planes
45 .iter()
46 .zip(f.format.plane_geometry(f.width, f.height))
47 {
48 for y in 0..rows {
49 out.extend_from_slice(p.row(y, row).unwrap());
50 }
51 }
52 out
53}