//! N lanes, composited: what a timeline with a `V2` over its `V1` and an `A2` //! over its `A1` plays, and that an export of it is the same thing. //! //! The fixtures are the two video assets, which differ picture for picture, so //! "which lane is showing" is answered by comparing the decoded frame against //! each source rather than by trusting the edit list. //! //! ```text //! cargo test -p engine --release --test lanes -- --nocapture //! ``` use std::path::{Path, PathBuf}; use std::sync::Once; use std::time::{Duration, Instant}; use engine::export::{ExportSettings, Format}; use engine::project::{Clip, Lane, LaneKind, Source, Speed}; use engine::scale::FitPolicy; use engine::scratch::Scratch; use engine::{DecodeSession, ExportHandle, PlaybackSession, Project}; const FPS: f64 = 30.0; /// `test_av.mp4` is 150 frames, `test_av2.mp4` 120; the top lane covers the /// middle third of the first. const TOTAL: u32 = 150; const TOP_IN: u32 = 50; const TOP_OUT: u32 = 100; fn asset(name: &str) -> PathBuf { PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("../../assets") .join(name) } /// Software on both halves, so this suite proves the composite on any machine /// rather than whatever the local VA-API driver does. fn pin_software() { static PIN: Once = Once::new(); PIN.call_once(|| { engine::envcfg::set("VE_SW", "1"); engine::envcfg::set("VE_SW_ENC", "1"); }); } /// Its own directory, gone with the value: two suites at once must not write /// each other's files, and nothing may outlive the test that wrote it. fn out_path(name: &str, ext: &str) -> Scratch { Scratch::file(&format!("ve_lanes_{name}"), ext) } /// A hand-written v4 project: `V1` the whole of `test_av`, `V2` the middle /// third playing `test_av2` from its own frame 0, `A1` the whole of `test_av`. /// Exactly the file a user would write by hand, parsed by the real loader. /// /// `name` is the caller's own, because [`out_path`] is unique per *run* and not /// per test: two tests sharing one name run in parallel over one file, and the /// first to finish deletes it out from under the second -- which then fails on /// a file that is simply not there any more. fn three_lane_file(name: &str) -> Scratch { let path = out_path(name, "edith"); // `source