diff --git a/crates/engine/src/edith.rs b/crates/engine/src/edith.rs index 9bdbcb2..37ef4de 100644 --- a/crates/engine/src/edith.rs +++ b/crates/engine/src/edith.rs @@ -16,9 +16,10 @@ //! subtitle 3 test_av.mp4 //! eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk //! color 0.1:1.2:0.9:-0.3 -//! video 1 0 0 120 0 0 0 0 fit 1000 0 0 -//! audio 1 0 0 120 0 0 0 - fit 1000 30 30 -//! video 2 120 0 120 1 - - - fill 2000 0 0 +//! transform 0.1:-0.1:1.5:90.0:0.0:0.0:0.0:0.0 +//! video 1 0 0 120 0 0 0 0 fit 1000 0 0 0 - +//! audio 1 0 0 120 0 0 0 - fit 1000 30 30 0 - +//! video 2 120 0 120 1 - - - fill 2000 0 0 0 0 //! audio 2 //! sub 1 0 60 0 500000 1500000 //! sub 2 @@ -109,8 +110,16 @@ //! ([`crate::color::ColorParams`]), named by position exactly as an eq line is //! -- the first colour line is color 0 -- printed and refused by the same rules. //! +//! A transform line is `transform ::::: +//! ::` ([`crate::transform::TransformParams`]), named by +//! position exactly as an eq or a colour line is -- the first transform line is +//! transform 0 -- printed and refused by the same rules: how a clip's picture +//! sits, is sized, is turned and is trimmed on the canvas, on top of whatever +//! its fit policy already placed. +//! //! A lane line is ` -//! `: which lane the clip is on -- its kind and its 1-based number +//! `: +//! which lane the clip is on -- its kind and its 1-based number //! among the lanes of that kind, the [`crate::project::Lane::label`] a header //! column shows -- then where the clip sits on the timeline, the half-open //! source range it plays, the file it plays from, its group id, the eq line it @@ -120,9 +129,12 @@ //! in thousandths of real time ([`crate::project::Speed`], `1000` for a clip //! nobody has speeded), and finally its ramp up from silence and ramp down to //! it, in timeline frames ([`crate::project::Clip::fade_in`], -//! [`crate::project::Clip::fade_out`], `0 0` for a clip nobody has faded), and -//! finally its cross-dissolve into whatever abuts its end -//! ([`crate::project::Clip::transition_out`], `0` for a hard cut). +//! [`crate::project::Clip::fade_out`], `0 0` for a clip nobody has faded), its +//! cross-dissolve into whatever abuts its end +//! ([`crate::project::Clip::transition_out`], `0` for a hard cut), and last of +//! all the transform line it is placed, sized, turned and cropped by, on top +//! of everything its fit policy already did (`-` for a clip left at its fit +//! policy's own spot, [`crate::project::Clip::transform`]). //! Timeline placement is //! explicit, so a *gap* is simply a stretch no line covers -- there is nothing //! to write for one, and nothing that can disagree about its length. The `` @@ -148,7 +160,11 @@ //! track 3 of a two-track palette is refused here, as a clip naming a source //! that is not there is. //! -//! **Version 17** was this without the clip's two fade fields: such a project +//! **Version 19** was this without the clip's transform field: such a project +//! places no clip anywhere but its fit policy's own spot, which is what `-` +//! still means. **Version 18** was that without the clip's transition field: +//! such a project dissolves no clip into its neighbor, which is what `0` still +//! means. **Version 17** was this without the clip's two fade fields: such a project //! holds no clip anyone has faded, which is what a `0 0` pair still means. //! **Version 15** was this without the caption's group field: such a project //! holds captions no hand ever grouped, which is every caption there could be. @@ -187,7 +203,7 @@ //! nothing, and an older one plays everything at real time, and an older one //! mixes flat, and an older one shows no subtitles, and an older one is shown //! in the reference rendition, and an older one places none of the words it -//! names -- and saving any of them writes v18. An older +//! names -- and saving any of them writes v20. An older //! reader refuses a newer file by name. //! //! Text because an edit list is a few integers and a path, and a path is @@ -2602,6 +2618,164 @@ mod tests { ); } + /// A v19 file is a v20 one that places no clip anywhere but its fit + /// policy's own spot: it loads with every clip's [`Clip::transform`] at + /// `None`, which is what a v19 file's missing field still means. + #[test] + fn a_v19_file_loads_untransformed() { + let dir = PathBuf::from("/proj"); + // The v19 dialect: twelve clip fields, the last the transition -- no + // transform field after it at all, not even a `-`. + let v19 = b"edith 19\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + video 1 0 0 30 0 - - - fit 1000 0 0 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0\n"; + let old = parse(v19, &dir).expect("v19 parses"); + assert!(old.transform.is_empty(), "nothing before v20 has a table"); + assert!( + old.lanes + .iter() + .flat_map(|(_, clips)| clips) + .all(|c| c.transform.is_none()), + "nothing before v20 had a placement to name" + ); + } + + /// [`colours_round_trip_bit_exactly_and_are_shared`]'s twin: two clips + /// sharing one transform table entry write it once, and both bytes and + /// values come back bit-exact. + #[test] + fn transforms_round_trip_bit_exactly_and_are_shared() { + let dir = PathBuf::from("/proj"); + let sources = vec![source("/proj/a.mp4", 0)]; + let transform = vec![ + TransformParams { + pos_x: 0.1, + pos_y: -0.2, + scale: 1.5, + rotate: 90.0, + crop_l: 0.1, + crop_r: 0.0, + crop_t: 0.0, + crop_b: 0.05, + }, + // The awkward ones again: all 24 mantissa bits, an exponential + // spelling, a subnormal and a negative zero -- and the identity, + // which is a setting like any other. + TransformParams { + pos_x: -0.000_000_1, + pos_y: 16_777_215.0, + scale: f32::MIN_POSITIVE / 3.0, + rotate: -0.0, + crop_l: 0.0, + crop_r: 0.0, + crop_t: 0.0, + crop_b: 0.0, + }, + TransformParams::default(), + ]; + // Two clips share entry 0, so it is written once; one clip is untransformed. + let lanes = two( + vec![ + Clip { + fade_in: 0, + fade_out: 0, + transition_out: 0, + transform: Some(0), + fit: FitPolicy::default(), + speed: Speed::NORMAL, + ..clip(0, 0, 30, 0, Some(0)) + }, + Clip { + fade_in: 0, + fade_out: 0, + transition_out: 0, + transform: Some(1), + fit: FitPolicy::default(), + speed: Speed::NORMAL, + ..clip(30, 10, 20, 0, None) + }, + ], + vec![ + Clip { + fade_in: 0, + fade_out: 0, + transition_out: 0, + transform: Some(0), + fit: FitPolicy::default(), + speed: Speed::NORMAL, + ..clip(0, 0, 30, 0, Some(0)) + }, + Clip { + fade_in: 0, + fade_out: 0, + transition_out: 0, + transform: Some(2), + fit: FitPolicy::default(), + speed: Speed::NORMAL, + ..clip(30, 0, 10, 0, None) + }, + ], + ); + let bytes = super::emit( + &dir, + &sources, + &lanes, + &[], + &[], + &[], + &[], + &[], + &transform, + (1280, 720), + None, + crate::tonemap::Preset::default(), + false, + true, + crate::export::EncoderSeat::default(), + Limiter::default(), + None, + 0, + ); + assert_eq!( + String::from_utf8_lossy(&bytes), + "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + transform 0.1:-0.2:1.5:90.0:0.1:0.0:0.0:0.05\n\ + transform -1e-7:16777215.0:3.918315e-39:-0.0:0.0:0.0:0.0:0.0\n\ + transform 0.0:0.0:1.0:0.0:0.0:0.0:0.0:0.0\n\ + video 1 0 0 30 0 0 - - fit 1000 0 0 0 0\nvideo 1 30 10 20 0 - - - fit 1000 0 0 0 1\n\ + audio 1 0 0 30 0 0 - - fit 1000 0 0 0 0\naudio 1 30 0 10 0 - - - fit 1000 0 0 0 2\n", + "the table comes before the clips, and a clip names a line of it" + ); + + let back = parse(&bytes, &dir).expect("parse"); + assert_eq!(back.lanes, lanes, "every clip keeps the transform it named"); + for (i, (got, want)) in back.transform.iter().zip(&transform).enumerate() { + assert_eq!( + ( + got.pos_x.to_bits(), + got.pos_y.to_bits(), + got.scale.to_bits(), + got.rotate.to_bits(), + got.crop_l.to_bits(), + got.crop_r.to_bits(), + got.crop_t.to_bits(), + got.crop_b.to_bits(), + ), + ( + want.pos_x.to_bits(), + want.pos_y.to_bits(), + want.scale.to_bits(), + want.rotate.to_bits(), + want.crop_l.to_bits(), + want.crop_r.to_bits(), + want.crop_t.to_bits(), + want.crop_b.to_bits(), + ), + "transform {i} came back as other bits" + ); + } + assert_eq!(back.transform.len(), 3); + } + /// The whole of the v9 bump, the speed test's twin: the mix a project was /// left at -- every track's own volume and the master limiter -- plus the /// rate it was cut at, all written, all read back as the very numbers, and diff --git a/crates/engine/src/project.rs b/crates/engine/src/project.rs index 59964f2..8680196 100644 --- a/crates/engine/src/project.rs +++ b/crates/engine/src/project.rs @@ -5330,6 +5330,15 @@ mod tests { } } + /// A recognisable placement, `n` telling two of them apart -- [`grade_at`]'s + /// twin for the transform table. + fn transform_at(n: u32) -> TransformParams { + TransformParams { + pos_x: f64::from(n) as f32 * 0.05, + ..Default::default() + } + } + /// The `V1`, `A1` lane list a two-lane load hands [`Project::from_parts`]. fn two(video: Vec, audio: Vec) -> Vec<(LaneKind, Vec)> { vec![(LaneKind::Video, video), (LaneKind::Audio, audio)] @@ -8104,6 +8113,125 @@ mod tests { assert_eq!((lanes[0].1[0].eq, lanes[0].1[0].color), (Some(0), Some(0))); } + /// [`a_colour_follows_the_clip_through_split_copy_and_undo`]'s twin: a + /// placement is the clip's, through every edit that copies one. + #[test] + fn a_transform_follows_the_clip_through_split_copy_and_undo() { + let mut p = three(); + assert!( + p.transform_of(Lane::V1, 0).is_none(), + "a fresh clip is untransformed" + ); + assert!(p.set_transform(Lane::V1, 0, Some(transform_at(2)))); + assert_eq!(p.transform_of(Lane::V1, 0), Some(&transform_at(2))); + assert!( + p.transform_of(Lane::A1, 0).is_none(), + "one clip, not the lane below" + ); + assert!( + p.color_of(Lane::V1, 0).is_none(), + "and a placement is not a grade" + ); + + // Cutting a transformed clip must not transform half of it: both + // halves inherit. + assert!(p.split(1)); + assert_eq!(p.transform_of(Lane::V1, 0), Some(&transform_at(2))); + assert_eq!(p.transform_of(Lane::V1, 1), Some(&transform_at(2))); + assert!( + p.transform_of(Lane::V1, 2).is_none(), + "the clip after it is untransformed" + ); + + // A clipboard copy carries it -- onto another lane, at that. + let copied = p.lane(Lane::V1)[1]; + assert!(p.place(Lane::A1, 20, copied)); + assert_eq!(p.transform_of(Lane::A1, 4), Some(&transform_at(2))); + assert!(p.undo()); + assert_eq!(p.lane(Lane::A1).len(), 4, "the placement came back off"); + + // ...and a change to one is one undo step, in both directions. + assert!(p.set_transform(Lane::V1, 0, Some(transform_at(5)))); + assert_eq!(p.transform_of(Lane::V1, 0), Some(&transform_at(5))); + assert!(p.undo()); + assert_eq!(p.transform_of(Lane::V1, 0), Some(&transform_at(2))); + assert!( + p.set_transform(Lane::V1, 0, None), + "and taking it off is an edit" + ); + assert!(p.transform_of(Lane::V1, 0).is_none()); + assert!(p.undo()); + assert_eq!(p.transform_of(Lane::V1, 0), Some(&transform_at(2))); + + // Two refusals, neither of which costs an undo step. + let nan = TransformParams { + scale: f32::NAN, + ..transform_at(1) + }; + assert!( + !p.set_transform(Lane::V1, 99, Some(transform_at(1))), + "no clip there" + ); + assert!( + !p.set_transform(Lane::V1, 0, Some(nan)), + "not a finite value" + ); + assert_eq!(p.transform_of(Lane::V1, 0), Some(&transform_at(2))); + assert!(p.undo()); + assert_eq!( + p.lane(Lane::V1).len(), + 3, + "one step back is before the split" + ); + assert!(p.undo()); + assert!( + p.transform_of(Lane::V1, 0).is_none(), + "and the next is before the placement: the refusals pushed none" + ); + } + + /// The transform table is append-only within a session, exactly as the eq + /// and colour ones are -- and a save is where an undone placement goes. + #[test] + fn an_undone_transform_is_pruned_when_the_project_is_saved() { + let mut p = three(); + assert!(p.set_transform(Lane::V1, 0, Some(transform_at(1)))); + assert!(p.set_transform(Lane::V1, 0, Some(transform_at(2)))); + assert!(p.undo(), "back to the first placement"); + assert_eq!(p.transform_of(Lane::V1, 0), Some(&transform_at(1))); + + let (_, lanes, _, _, transform) = p.without_orphan_sources(); + assert_eq!( + transform, + vec![transform_at(1)], + "what nothing plays is not written" + ); + assert_eq!( + lanes[0].1[0].transform, + Some(0), + "and the survivor renumbers" + ); + assert_eq!(lanes[0].1[1].transform, None); + + // One placement on three clips is one entry: settings that are equal + // share. + assert!(p.set_transform(Lane::V1, 1, Some(transform_at(1)))); + assert!(p.set_transform(Lane::A1, 2, Some(transform_at(1)))); + let (_, lanes, _, _, transform) = p.without_orphan_sources(); + assert_eq!(transform.len(), 1, "equal placements share their entry"); + assert_eq!(lanes[1].1[2].transform, Some(0)); + reloads(&p, "a transform that outlived an undo"); + + // A grade and a placement on one clip are two independent tables. + assert!(p.set_color(Lane::V1, 0, Some(grade_at(3)))); + let (_, lanes, _, color, transform) = p.without_orphan_sources(); + assert_eq!((color.len(), transform.len()), (1, 1)); + assert_eq!( + (lanes[0].1[0].color, lanes[0].1[0].transform), + (Some(0), Some(0)) + ); + } + /// Not a claim about correctness but about cost: a clip is copied on every /// paste, every undo snapshot and every lane clone, so its size is worth /// knowing. The eq index fit the padding a `Copy` clip already had; the @@ -8763,8 +8891,8 @@ mod tests { /// handed back to the constructor a load goes through -- every lane of them, /// and the reloaded timeline has to be the same lanes in the same order. fn reloads(p: &Project, what: &str) { - let (sources, lanes, eq, color, _transform) = p.clone().without_orphan_sources(); - match Project::from_parts(sources, lanes, eq, color, Vec::new()) { + let (sources, lanes, eq, color, transform) = p.clone().without_orphan_sources(); + match Project::from_parts(sources, lanes, eq, color, transform) { Err(e) => panic!("{what}: saved but would not load: {e}\n{:?}", p.lanes), Ok(back) => { assert_eq!(back.lanes(), p.lanes(), "{what}: the lane list changed"); @@ -8800,6 +8928,22 @@ mod tests { .collect() }; assert_eq!(colors(&back), colors(p), "{what}: the colours changed"); + // ...and the transform table, by the same claim again. + let transforms = |p: &Project| -> Vec>> { + p.lanes() + .into_iter() + .map(|l| { + (0..p.lane(l).len()) + .map(|i| p.transform_of(l, i).copied()) + .collect() + }) + .collect() + }; + assert_eq!( + transforms(&back), + transforms(p), + "{what}: the transforms changed" + ); } } } diff --git a/crates/engine/src/scale.rs b/crates/engine/src/scale.rs index 088dc7c..a08b7e6 100644 --- a/crates/engine/src/scale.rs +++ b/crates/engine/src/scale.rs @@ -1352,4 +1352,151 @@ mod tests { let (y1, _, _) = blend_i420((&a.0, &a.1, &a.2), (&b.0, &b.1, &b.2), 1.0); assert_eq!(y1, b.0); } + + /// The crop fractions cut a rect out of a 100x100 source at the very + /// pixels the maths says, chroma-grid aligned like every other rect here. + #[test] + fn crop_rect_math() { + let t = TransformParams { + crop_l: 0.1, + crop_r: 0.2, + crop_t: 0.0, + crop_b: 0.0, + ..Default::default() + }; + assert_eq!( + crop_rect(100, 100, &t), + Rect { x: 10, y: 0, w: 70, h: 100 }, + "10% off the left, 20% off the right, nothing off top or bottom" + ); + // Opposing crops clamp to 0.5 a side rather than meeting or crossing. + let extreme = TransformParams { + crop_l: 0.9, + crop_r: 0.9, + ..Default::default() + }; + let r = crop_rect(100, 100, &extreme); + assert!(r.w >= 2, "the smallest surviving rect is one chroma sample"); + // A zero-sized source has nothing to crop. + assert_eq!(crop_rect(0, 100, &TransformParams::default()), Rect { x: 0, y: 0, w: 0, h: 0 }); + } + + /// A placement moved by `pos_x`/`pos_y` (canvas fractions about its own + /// centre) and resized by `scale`, both about that same centre. + #[test] + fn transformed_dst_rect_at_pos_and_scale() { + let dst = Rect { x: 0, y: 0, w: 100, h: 100 }; + // Moved a quarter of the canvas to the right, untouched vertically. + let moved = TransformParams { + pos_x: 0.25, + ..Default::default() + }; + assert_eq!( + transformed_dst_rect(dst, &moved, 200, 200), + Rect { x: 50, y: 0, w: 100, h: 100 }, + "25% of a 200-wide canvas is 50 pixels, about the placement's own centre" + ); + // Doubled in place: the centre stays, the box fills the canvas. + let grown = TransformParams { + scale: 2.0, + ..Default::default() + }; + assert_eq!( + transformed_dst_rect(dst, &grown, 200, 200), + Rect { x: 0, y: 0, w: 200, h: 200 }, + "a 100x100 box doubled about its own centre on a 200x200 canvas fills it" + ); + } + + /// [`nearest_90_steps`] rounds to the closest quarter turn and folds a + /// non-finite value to the identity. + #[test] + fn nearest_90_steps_rounds_and_wraps() { + assert_eq!(nearest_90_steps(0.0), 0); + assert_eq!(nearest_90_steps(89.0), 1); + assert_eq!(nearest_90_steps(91.0), 1); + assert_eq!(nearest_90_steps(180.0), 2); + assert_eq!(nearest_90_steps(-90.0), 3); + assert_eq!(nearest_90_steps(360.0 + 90.0), 1); + assert_eq!(nearest_90_steps(f32::NAN), 0); + } + + /// A marked corner pixel lands where a clockwise quarter turn puts it: + /// top-left to top-right at 90 degrees, to bottom-right at 180, to + /// bottom-left at 270 -- and the plane's own shape swaps at 90 and 270 + /// and stays put at 180. + #[test] + fn rotate_i420_90s_places_a_marked_pixel() { + let (w, h) = (4usize, 3usize); + let mut y = vec![0u8; w * h]; + y[0] = 99; // (x=0, y=0), the top-left corner. + let (u, v) = (vec![128u8; 2 * 2], vec![128u8; 2 * 2]); + + let mark_at = |plane: &[u8], w: u32, x: u32, y: u32| plane[(y * w + x) as usize]; + + let (ry, _, _, rw, rh) = rotate_i420_90s(&y, &u, &v, w as u32, h as u32, 1); + assert_eq!((rw, rh), (h as u32, w as u32), "dims swap at 90 degrees"); + assert_eq!(mark_at(&ry, rw, rw - 1, 0), 99, "top-left moves to top-right"); + + let (ry, _, _, rw, rh) = rotate_i420_90s(&y, &u, &v, w as u32, h as u32, 2); + assert_eq!((rw, rh), (w as u32, h as u32), "dims stay put at 180 degrees"); + assert_eq!( + mark_at(&ry, rw, rw - 1, rh - 1), + 99, + "top-left moves to bottom-right" + ); + + let (ry, _, _, rw, rh) = rotate_i420_90s(&y, &u, &v, w as u32, h as u32, 3); + assert_eq!((rw, rh), (h as u32, w as u32), "dims swap at 270 degrees"); + assert_eq!( + mark_at(&ry, rw, 0, rh - 1), + 99, + "top-left moves to bottom-left" + ); + + // Zero steps, and four of them, are both the identity. + let (ry, ru, rv, rw, rh) = rotate_i420_90s(&y, &u, &v, w as u32, h as u32, 0); + assert_eq!((ry, ru, rv, rw, rh), (y.clone(), u.clone(), v.clone(), w as u32, h as u32)); + let (ry, _, _, rw, rh) = rotate_i420_90s(&y, &u, &v, w as u32, h as u32, 4); + assert_eq!((ry, rw, rh), (y, w as u32, h as u32), "four quarter turns is the identity"); + } + + /// [`Composer::place_transformed`] at compose level: a picture placed with + /// a `pos_x` offset lands its marked pixel shifted by exactly that many + /// canvas pixels, with black everywhere else. + #[test] + fn place_transformed_shifts_a_marked_pixel() { + let (src_w, src_h) = (64u32, 64u32); + let (y, u, v) = ( + vec![200u8; (src_w * src_h) as usize], + vec![NEUTRAL_C; ((src_w / 2) * (src_h / 2)) as usize], + vec![NEUTRAL_C; ((src_w / 2) * (src_h / 2)) as usize], + ); + let mut canvas = Composer::new(src_w, src_h, FitPolicy::Fit); + // Identity: a pass-through-shaped placement, fills the whole canvas. + let (iy, _, _, iw, ih) = canvas.place_transformed(&y, &u, &v, src_w, src_h, &TransformParams::default()); + assert_eq!((iw, ih), (src_w, src_h)); + assert!(iy.iter().all(|&p| p == 200), "identity fills the canvas"); + + // Moved a quarter of the canvas to the right: the left half is black, + // the right half (minus the strip pushed off the edge) is the picture. + let moved = TransformParams { + pos_x: 0.25, + ..Default::default() + }; + let (my, _, _, mw, mh) = canvas.place_transformed(&y, &u, &v, src_w, src_h, &moved); + assert_eq!((mw, mh), (src_w, src_h), "canvas size never changes"); + let shift = (f64::from(src_w) * 0.25).round() as usize; + for row in 0..mh as usize { + let r = &my[row * mw as usize..][..mw as usize]; + assert!( + r[..shift].iter().all(|&p| p == BLACK_Y), + "row {row}: black ahead of the shifted picture" + ); + assert!( + r[shift..].iter().all(|&p| p == 200), + "row {row}: the picture fills the rest, shifted right" + ); + } + } } diff --git a/crates/engine/tests/audio_export.rs b/crates/engine/tests/audio_export.rs index 495d32b..133a5c3 100644 --- a/crates/engine/tests/audio_export.rs +++ b/crates/engine/tests/audio_export.rs @@ -73,6 +73,7 @@ fn mixed_project() -> Project { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }; Project::from_parts( vec![ @@ -98,12 +99,14 @@ fn mixed_project() -> Project { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }], ), (LaneKind::Audio, vec![clip(0, 0), clip(60, 1)]), ], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a two-source project with a hole in the audio lane") } @@ -345,6 +348,7 @@ fn a_still_and_a_song_export_as_an_mp4_with_sound() { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }; // Two seconds of each at the project's own 30 fps: a still has no length of // its own and the song is longer than what is placed. @@ -356,6 +360,7 @@ fn a_still_and_a_song_export_as_an_mp4_with_sound() { ], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a still under a song"); // The project's own picture size and rate: the still decides the one and @@ -412,6 +417,7 @@ fn a_fader_is_one_tracks_own_and_the_limiter_holds_the_sum() { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }; let four = || { Project::from_parts( @@ -425,7 +431,8 @@ fn a_fader_is_one_tracks_own_and_the_limiter_holds_the_sum() { ], Vec::new(), Vec::new(), - ) + Vec::new(), + ) .expect("one second on four audio tracks") }; let write = |project: Project, name: &str| { @@ -651,6 +658,7 @@ fn the_sound_is_written_at_the_rate_that_was_asked_for() { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }], ), ( @@ -668,11 +676,13 @@ fn the_sound_is_written_at_the_rate_that_was_asked_for() { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }], ), ], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a still under a song"); let meta = engine::VideoMeta { @@ -726,6 +736,7 @@ fn a_silent_clip_exports_as_silence_over_its_own_span() { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }; let project = Project::from_parts( vec![ @@ -739,6 +750,7 @@ fn a_silent_clip_exports_as_silence_over_its_own_span() { ], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a project whose middle take is silent"); @@ -821,10 +833,12 @@ fn a_51_ac3_source_round_trips_through_a_wav() { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }], )], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a one-source AC-3 project"); let video = engine::demux::Demuxer::open(&source).expect("open the fixture").0; @@ -951,10 +965,12 @@ fn a_mono_timeline_exports_as_dual_mono_ogg() { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }], )], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a one-source mono project"); diff --git a/crates/engine/tests/eq_audio.rs b/crates/engine/tests/eq_audio.rs index 5c654bb..cb513ff 100644 --- a/crates/engine/tests/eq_audio.rs +++ b/crates/engine/tests/eq_audio.rs @@ -66,6 +66,7 @@ fn clip(start: u32, source: usize, frames: u32) -> Clip { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, } } @@ -80,6 +81,7 @@ fn project(audio: Vec) -> Project { ], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a one-source project") } @@ -245,6 +247,7 @@ fn a_lane_is_equalized_before_the_mix_and_never_after_it() { ], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a two-audio-lane project"); assert_eq!(p.audio_lanes().len(), 2, "both lanes hold something"); diff --git a/crates/engine/tests/export.rs b/crates/engine/tests/export.rs index 69cb986..58bfe76 100644 --- a/crates/engine/tests/export.rs +++ b/crates/engine/tests/export.rs @@ -244,6 +244,7 @@ fn exports_at_the_project_resolution_with_the_watched_geometry() { link: Some(source as u32), eq: None, color: None, + transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, }; @@ -259,6 +260,7 @@ fn exports_at_the_project_resolution_with_the_watched_geometry() { ], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a two-source project"); // The project's own resolution, which is neither source's: this is the @@ -329,6 +331,7 @@ fn exports_the_audio_stream_the_timeline_plays() { link: Some(0), eq: None, color: None, + transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, }; @@ -346,6 +349,7 @@ fn exports_the_audio_stream_the_timeline_plays() { ], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a one-source project on stream 1"); let out = out_path("stream1"); diff --git a/crates/engine/tests/lanes.rs b/crates/engine/tests/lanes.rs index c412caf..06f3008 100644 --- a/crates/engine/tests/lanes.rs +++ b/crates/engine/tests/lanes.rs @@ -245,6 +245,7 @@ fn the_mp4_copy_follows_the_lane_that_holds_the_sound() { link: None, eq: None, color: None, + transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, }; @@ -257,6 +258,7 @@ fn the_mp4_copy_follows_the_lane_that_holds_the_sound() { ], vec![], vec![], + vec![], ) .expect("valid parts"); assert_eq!( @@ -309,14 +311,15 @@ fn two_audio_lanes_are_summed() { link: None, eq: None, color: None, + transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, }; let a2 = project.add_lane(LaneKind::Audio); assert!(project.place(a2, TOP_IN, doubled), "place the second lane"); - let (sources, lanes, eq, color) = project.without_orphan_sources(); + let (sources, lanes, eq, color, transform) = project.without_orphan_sources(); assert_eq!(lanes.len(), 3, "V1, A1 and the new A2"); - let project = Project::from_parts(sources, lanes, eq, color).expect("valid parts"); + let project = Project::from_parts(sources, lanes, eq, color, transform).expect("valid parts"); let (meta, _) = engine::demux::Demuxer::open(&asset("test_av.mp4")).unwrap(); let wav = |name: &str, project: Project| { @@ -507,6 +510,7 @@ fn a_subtitle_lane_is_a_peer_and_every_media_path_refuses_it() { vec![(LaneKind::Subtitle, vec![clip])], Vec::new(), Vec::new(), + Vec::new(), ) .expect_err("a file may not name one either"); assert!( diff --git a/crates/engine/tests/opus_export.rs b/crates/engine/tests/opus_export.rs index dc450fa..23147b0 100644 --- a/crates/engine/tests/opus_export.rs +++ b/crates/engine/tests/opus_export.rs @@ -92,6 +92,7 @@ fn project(video: &Path, sound: &Path, sound_in: u32) -> Project { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }; // The sound is source **0** on purpose: the timeline takes its rate and its // width from the first source that has any, so a project whose first source @@ -109,6 +110,7 @@ fn project(video: &Path, sound: &Path, sound_in: u32) -> Project { ], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a picture lane and an audio lane") } @@ -436,6 +438,7 @@ fn a_copied_picture_names_the_sound_it_was_written_with() { color: None, fit: FitPolicy::default(), speed: Speed::NORMAL, + transform: None, }; // The sound is source 0, for the reason [`project`] gives: the timeline // takes its rate and its width from the first source that has any. @@ -447,6 +450,7 @@ fn a_copied_picture_names_the_sound_it_was_written_with() { ], Vec::new(), Vec::new(), + Vec::new(), ) .expect("a picture lane and an audio lane"); let out = out_path("copy_line"); diff --git a/crates/engine/tests/silence.rs b/crates/engine/tests/silence.rs index 0b034d4..4e4bf43 100644 --- a/crates/engine/tests/silence.rs +++ b/crates/engine/tests/silence.rs @@ -36,8 +36,8 @@ fn fixture() -> Project { /// is one no save could load: this is that check, through the same door a load /// takes. fn loadable(project: &Project) { - let (sources, lanes, eq, color) = project.without_orphan_sources(); - Project::from_parts(sources, lanes, eq, color).expect("the lanes still load"); + let (sources, lanes, eq, color, transform) = project.without_orphan_sources(); + Project::from_parts(sources, lanes, eq, color, transform).expect("the lanes still load"); } fn spans(project: &Project) -> (Vec<(u32, u32)>, Vec<(u32, u32)>) { @@ -150,6 +150,7 @@ fn speed_mode_refuses_a_clip_that_laps_over_a_silence() { color: None, fit: Default::default(), speed: Speed::NORMAL, + transform: None, }; assert!(p.place(lane, 40, broll)); let before = spans(&p); @@ -188,6 +189,7 @@ fn whole(source: usize, frames: u32) -> Clip { color: None, fit: Default::default(), speed: Speed::NORMAL, + transform: None, } } @@ -370,7 +372,7 @@ fn scanning_a_clip_and_cutting_what_it_finds() { // same dialect it always was -- no wire change went with this feature. let dir = Scratch::dir("edith-silence"); let file = dir.join("cut.edith"); - let (sources, lanes, eq, color) = p.without_orphan_sources(); + let (sources, lanes, eq, color, transform) = p.without_orphan_sources(); engine::edith::save( &file, &sources, @@ -380,6 +382,7 @@ fn scanning_a_clip_and_cutting_what_it_finds() { p.subtitles(), &eq, &color, + &transform, (1920, 1080), None, p.tone(),