//! Helpers shared by the integration-test modules in this binary. use ec_core::frame::VideoFrame; pub(crate) fn chunk(id: &[u8; 4], body: &[u8]) -> Vec { let mut v = id.to_vec(); v.extend((body.len() as u32).to_le_bytes()); v.extend(body); if body.len() % 2 == 1 { v.push(0); } v } pub(crate) fn list(kind: &[u8; 4], body: &[u8]) -> Vec { let mut b = kind.to_vec(); b.extend(body); chunk(b"LIST", &b) } pub(crate) fn ffmpeg(args: &[&str]) { let ok = ec_testkit::ffmpeg() .args(["-v", "error", "-y", "-nostdin"]) .args(args) .status() .map(|s| s.success()) .unwrap_or(false); assert!(ok, "ffmpeg {args:?} failed"); } pub(crate) fn frame_bytes(f: &VideoFrame) -> Vec { let mut out = Vec::new(); for (p, (row, rows)) in f .planes .iter() .zip(f.format.plane_geometry(f.width, f.height)) { for y in 0..rows { out.extend_from_slice(p.row(y, row).unwrap()); } } out }