Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Merge remote-tracking branch 'origin/main' into HEAD

bflatasticf2773f68acbb
diff --cc crates/project/src/render_queue.rs
index 3afbb06bb,2e1e6bc4e..1a829630c
--- a/crates/project/src/render_queue.rs
+++ b/crates/project/src/render_queue.rs
@@@ -1666,44 -1682,28 +1685,66 @@@ mod tests
assert_eq!(m.output_size(&c, &half), (400, 200));
}
+ #[test]
+ fn output_size_never_exceeds_the_comp_limit() {
+ // The effective scale is clamped so neither side exceeds the limit (exporter
+ // `w * h * 4` would overflow at 120 000 px sides); the pipeline renders at the
+ // same scale, so it never requests a frame larger than this reports.
+ let rs = RenderSettings { resolution: 4.0, ..Default::default() };
+ let m = OutputModule::for_format(OutputFormat::PngSequence);
+ let square = Comp::new(30_000, 30_000, FrameRate::new(30, 1), Tick::from_seconds_f64(1.0));
+ assert_eq!(rs.effective_scale(&square), 1.0);
+ assert_eq!(rs.output_size(&square), (30_000, 30_000));
+ assert_eq!(m.output_size(&square, &rs), (30_000, 30_000));
+ // Wide comps keep their aspect ratio instead of clamping each side on its own.
+ let wide = Comp::new(30_000, 15_000, FrameRate::new(30, 1), Tick::from_seconds_f64(1.0));
+ assert_eq!(rs.effective_scale(&wide), 1.0);
+ assert_eq!(rs.output_size(&wide), (30_000, 15_000));
+ assert_eq!(m.output_size(&wide, &rs), (30_000, 15_000));
+ // A mid-size comp renders at the largest scale that still fits.
+ let mid = Comp::new(20_000, 10_000, FrameRate::new(30, 1), Tick::from_seconds_f64(1.0));
+ assert_eq!(mid.width as f64 * rs.effective_scale(&mid), 30_000.0);
+ assert_eq!(rs.output_size(&mid), (30_000, 15_000));
+ }
+
+ #[test]
+ fn valid_wide_roi_endpoints_are_preserved() {
+ // A supported 30 000 x 100 frame at scale 1: ROI [10000, 0, 20000, 100] spans x 10 000..30 000
+ // and must give 20 000 x 100 (the absolute right edge 30 000 exceeds the old +/-20 000 clamp).
+ let c = Comp::new(30_000, 100, FrameRate::new(30, 1), Tick::from_seconds_f64(1.0));
+ let rs = RenderSettings::default();
+ let mut m = OutputModule::for_format(OutputFormat::PngSequence);
+ m.crop = Crop { enabled: true, use_roi: true, roi: Some([10_000.0, 0.0, 20_000.0, 100.0]), ..Default::default() };
+ assert_eq!(m.output_size(&c, &rs), (20_000, 100));
+ assert_eq!(m.crop.edges(30_000, 100, 1.0), (0, 10_000, 0, 0));
+ // Scale 4.0 pushes a valid edge to 120 000 px (30 000 x 4); the left edge 40 000 and the
+ // right edge 120 000 are both beyond 20 000 and must survive.
+ assert_eq!(m.crop.edges(120_000, 400, 4.0), (0, 40_000, 0, 0));
+ assert_eq!(m.frame_size(120_000, 400, 4.0), (80_000, 400));
+ // Hostile quads stay inside the frame: never empty, never larger than the frame, so the
+ // export can't be asked for an unbounded crop (an ROI reaching far outside the comp
+ // used to pad the frame instead).
+ let (fw, fh) = (1920, 1080);
+ let hostile = [
+ [1e300, 1e300, 1e300, 1e300],
+ [-1e300, -1e300, 1e300, 1e300],
+ [-1e6, -1e6, 2e6 + 1920.0, 2e6 + 1080.0],
+ [-1e12, -1e12, -1e12, -1e12],
+ [f64::NAN, f64::INFINITY, f64::NEG_INFINITY, f64::NAN],
+ [f64::NEG_INFINITY, f64::NEG_INFINITY, f64::INFINITY, f64::INFINITY],
+ ];
+ for roi in hostile {
+ m.crop.roi = Some(roi);
+ let (t, l, b, r) = m.crop.edges(fw, fh, 1.0);
+ assert!([t, l, b, r].iter().all(|e| *e >= 0), "{roi:?}: an edge pads the frame: {:?}", (t, l, b, r));
+ let (w, h) = m.frame_size(fw, fh, 1.0);
+ assert!((1..=fw).contains(&w) && (1..=fh).contains(&h), "{roi:?}: {w}x{h} is outside 1x1..={fw}x{fh}");
+ }
+ // An ROI covering more than the frame is the whole frame.
+ m.crop.roi = Some([-1e6, -1e6, 2e6 + 1920.0, 2e6 + 1080.0]);
+ assert_eq!(m.frame_size(fw, fh, 1.0), (fw, fh));
+ }
+
#[test]
fn uncompressed_quicktime_format() {
let f = OutputFormat::from_name("uncompressed").unwrap();