EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge main into M10.2 (render queue + VP9 inter)
Brandon Thomasad0f821fa8e7
diff --cc crates/engine/src/commands/render_queue.rsindex fcf088ac3,bb2b8ce5a..365d7e555--- a/crates/engine/src/commands/render_queue.rs+++ b/crates/engine/src/commands/render_queue.rs@@@ -705,8 -506,7 +705,9 @@@ fn save_current_preview(s: &mut Sessionaccel: s.accel.as_deref(),item: &item,path: &path,+ storage: s.storage_quota.as_deref(),+ label: "Save Current Preview".into(),+ nested_switches: s.prefs.general.switches_affect_nested_comps,};let r = exporter.export(&job, &mut |_, _| true).map_err(EngineError::Other)?;s.toast(format!("Saved preview to {}", r.path));diff --cc crates/engine/src/render_queue.rsindex 3de9d8e5f,c01d8513a..5e77131c4--- a/crates/engine/src/render_queue.rs+++ b/crates/engine/src/render_queue.rs@@@ -27,10 -27,8 +27,12 @@@ pub struct ExportJob<'a>pub accel: Option<&'a dyn effectcraft_render::Accelerator>,/// Resolved output path (templates expanded except the `#` frame-number run).pub path: &'a str,+ /// Free-space hook (Use Storage Overflow).+ pub storage: Option<&'a dyn effectcraft_project::render_queue::StorageQuota>,+ /// "#n Comp Name", for the render log.+ pub label: String,+ /// Settings ▸ General ▸ Switches Affect Nested Comps.+ pub nested_switches: bool,}/// What an export wrote.@@@ -137,9 -129,56 +139,57 @@@ struct Workexpr: Option<Arc<dyn ExprHost>>,accel: Option<Arc<dyn effectcraft_render::Accelerator>>,exporter: Arc<dyn Exporter>,+ storage: Option<Arc<dyn effectcraft_project::render_queue::StorageQuota>>,- /// Per queue item: one (item with that output module, resolved path) per output module.+ /// Per queue item: one (item with that output module, resolved path) per output module+ /// (and per segment, see [`Session::segments`]).items: Vec<Vec<(RenderQueueItem, String)>>,+ /// Settings ▸ General ▸ Switches Affect Nested Comps.+ nested_switches: bool,+ }++ /// Bits per channel an output format writes for a project bit depth (named in the file when+ /// Settings ▸ Export ▸ Append Bit Depth to File Name is on).+ pub fn output_bits(format: OutputFormat, depth: effectcraft_project::BitDepth) -> u32 {+ use effectcraft_project::BitDepth;+ let project = match depth {+ BitDepth::Bpc8 => 8,+ BitDepth::Bpc16 => 16,+ BitDepth::Bpc32 => 32,+ };+ match format {+ OutputFormat::ExrSequence => 32,+ OutputFormat::PngSequence | OutputFormat::TiffSequence => project.min(16),+ OutputFormat::ProRes => 10,+ OutputFormat::Wav | OutputFormat::Aiff => 16,+ _ => 8,+ }+ }++ /// The bytes an output writes per frame, estimated from its data rate (H.264 bitrate, Apple's+ /// published ProRes target rates at 1080p29.97 scaled by frame size, typical rates otherwise).+ pub fn bytes_per_frame(om: &OutputModule, w: u32, h: u32, fps: f64) -> f64 {+ use effectcraft_project::render_queue::ProResProfile::*;+ let fps = fps.max(1.0);+ let px = (w as f64 * h as f64) / (1920.0 * 1080.0);+ let mbps = |m: f64| m * 1_000_000.0 / 8.0;+ match om.format {+ OutputFormat::H264 => om.bitrate_kbps as f64 * 1000.0 / 8.0 / fps,+ OutputFormat::ProRes => {+ let rate = match om.prores_profile {+ Proxy => 45.0,+ Lt => 102.0,+ Standard => 147.0,+ Hq => 220.0,+ P4444 => 330.0,+ P4444Xq => 500.0,+ };+ mbps(rate) * px / 29.97+ }+ OutputFormat::WebM => mbps(8.0) * px / fps,+ OutputFormat::Gif => w as f64 * h as f64 * 0.5,+ OutputFormat::Wav | OutputFormat::Aiff => om.audio_sample_rate as f64 * 4.0 / fps,+ _ => w as f64 * h as f64 * 3.0,+ }}fn unix_now() -> u64 {@@@ -160,8 -199,8 +210,9 @@@ pub(crate) fn run_itemsexpr: s.expr.clone(),accel: s.accel.clone(),exporter,+ storage: s.storage_quota.clone(),items,+ nested_switches: s.prefs.general.switches_affect_nested_comps,};run_work(work, shared, notify);}@@@ -202,8 -239,7 +253,9 @@@ fn run_work(w: Work, shared: &JobSharedaccel: w.accel.as_deref(),item: mitem,path,+ storage: w.storage.as_deref(),+ label: format!("#{index} {name} (output module {})", mi + 1),+ nested_switches: w.nested_switches,};let rr = w.exporter.export(&job, &mut |done, total| {{@@@ -364,8 -453,8 +468,9 @@@ impl Sessionexpr: self.expr.clone(),accel: self.accel.clone(),exporter,+ storage: self.storage_quota.clone(),items,+ nested_switches: self.prefs.general.switches_affect_nested_comps,};let shared = Arc::new(JobShared::default());if wait {diff --cc crates/export/src/lib.rsindex 74b12c764,1f0c44072..f1e3269fd--- a/crates/export/src/lib.rs+++ b/crates/export/src/lib.rs@@@ -79,21 -69,8 +79,23 @@@ pub struct Job<'a>pub path: &'a str,/// Hand finished files to this instead of writing them to disk (web downloads, tests).pub sink: Option<&'a Sink>,+ /// Settings ▸ General ▸ Switches Affect Nested Comps (see `RenderOpts::nested_switches`).+ pub nested_switches: bool,+ /// Render log, storage overflow.+ pub options: JobOptions<'a>,+}++/// Job options beyond the Render Settings and Output Module.+#[derive(Default)]+pub struct JobOptions<'a> {+ /// The render log written next to the output.+ pub log: RenderLog,+ /// What the log calls the job (e.g. "#2 Main Comp").+ pub label: String,+ /// Free-space hook for Use Storage Overflow (`None`: never full).+ pub storage: Option<&'a dyn StorageQuota>,+ /// Overflow folders, in order.+ pub overflow: Vec<String>,}/// Progress after a batch of frames.diff --cc crates/export/src/pipeline.rsindex 76087f2a0,000000000..d1ad01bf4mode 100644,000000..100644--- a/crates/export/src/pipeline.rs+++ b/crates/export/src/pipeline.rs@@@ -1,327 -1,0 +1,329 @@@+//! The frame pipeline shared by every output format: Render Settings overrides (effects, solo,+//! guide layers, frame blending, motion blur), field rendering with 3:2 pulldown, colour depth,+//! the Output Module's crop and resize, alpha handling, storage overflow and the render log.++use std::sync::Mutex;++use effectcraft_project::render_queue::{+ AlphaMode, Channels, ColorDepth, CurrentOrOff, EffectsMode, FrameSample, RenderLog, ResizeQuality, SwitchOverride, log_path,+};+use effectcraft_project::{Comp, Project};+use effectcraft_raster::Image;+use effectcraft_render::{RenderOpts, Renderer};+use effectcraft_time::Tick;+use web_time::Instant;++use crate::{Job, RenderQuality, out};++/// A job being exported: the job, the project with the Render Settings overrides applied, and+/// per-frame timing for the render log.+pub(crate) struct Cx<'a> {+ pub job: &'a Job<'a>,+ pub project: Project,+ /// (output frame, seconds) of every rendered frame (Plus Per Frame Info logs).+ pub frame_times: Option<Mutex<Vec<(u64, f64)>>>,+ /// Files written to an overflow folder.+ pub overflowed: Mutex<Vec<String>>,+}++impl<'a> std::ops::Deref for Cx<'a> {+ type Target = Job<'a>;+ fn deref(&self) -> &Job<'a> {+ self.job+ }+}++/// The project as the Render Settings render it: Effects All On / All Off, Solo Switches All+/// Off, Frame Blending and Motion Blur "On for Checked Layers" (the composition switches on).+pub(crate) fn apply_overrides(p: &mut Project, job: &Job) {+ let s = job.settings;+ let ids: Vec<_> = p.comps().map(|(i, _)| *i).collect();+ for id in ids {+ let Some(c) = p.comp_mut(id) else { continue };+ match s.frame_blending {+ SwitchOverride::Current => {}+ SwitchOverride::OnForChecked => c.enable_frame_blending = true,+ SwitchOverride::OffForAll => c.enable_frame_blending = false,+ }+ match s.motion_blur_override() {+ SwitchOverride::Current => {}+ SwitchOverride::OnForChecked => c.enable_motion_blur = true,+ SwitchOverride::OffForAll => c.enable_motion_blur = false,+ }+ for l in c.layers.iter_mut() {+ match s.effects {+ EffectsMode::Current => {}+ EffectsMode::AllOn => l.switches.effects = true,+ EffectsMode::AllOff => l.switches.effects = false,+ }+ if s.solo == CurrentOrOff::AllOff {+ l.switches.solo = false;+ }+ }+ }+}++impl<'a> Cx<'a> {+ pub fn new(job: &'a Job<'a>) -> Cx<'a> {+ let mut project = job.project.clone();+ apply_overrides(&mut project, job);+ let frame_times = (job.options.log == RenderLog::PlusPerFrameInfo).then(|| Mutex::new(Vec::new()));+ Cx { job, project, frame_times, overflowed: Mutex::new(vec![]) }+ }++ pub fn comp(&self) -> Option<&Comp> {+ self.project.comp(self.job.comp)+ }++ fn render_at(&self, t: Tick) -> Image {+ let s = self.job.settings;+ let opts = RenderOpts {+ scale: s.resolution.clamp(0.01, 4.0),+ motion_blur: s.motion_blur_override() != SwitchOverride::OffForAll,+ guides: s.guide_layers == CurrentOrOff::Current,+ draft: s.quality == RenderQuality::Draft,+ // Output renders always look through the comp's active camera.+ view: None,+ backend: effectcraft_render::Backend::Auto,+ roi: None,++ nested_switches: self.job.nested_switches,++ draft_shadows: true,+ proxy: s.proxy_use,+ };+ let mut r = Renderer::new(&self.project, self.job.footage, opts);+ r.expr = self.job.expr;+ r.accel = self.job.accel;+ r.comp_frame(self.job.comp, t)+ }++ /// Output frame `i`: sampled (fields, pulldown), at the colour depth, cropped and resized.+ pub fn frame(&self, comp: &Comp, i: u64) -> Image {+ let t0 = Instant::now();+ let img = match self.job.settings.sample(comp, i) {+ FrameSample::Progressive(t) => self.render_at(t),+ FrameSample::Fields { first, second, upper_first } => {+ let a = self.render_at(first);+ if second == first { a } else { interleave(&a, &self.render_at(second), upper_first) }+ }+ };+ let mut img = img;+ // Color Depth: renders run at the project's depth; another depth quantises the frame.+ let depth = self.job.settings.color_depth;+ if depth != ColorDepth::Current+ && let Some(levels) = depth.resolve(self.project.settings.bit_depth).levels()+ {+ img.quantize(levels);+ }+ let img = self.crop_resize(img);+ if let Some(ft) = &self.frame_times {+ ft.lock().unwrap_or_else(|e| e.into_inner()).push((i, t0.elapsed().as_secs_f64()));+ }+ img+ }++ /// Output Module ▸ Crop, then Resize.+ fn crop_resize(&self, img: Image) -> Image {+ let om = self.job.output;+ let scale = self.job.settings.resolution.clamp(0.01, 4.0);+ let (t, l, b, r) = om.crop.edges(img.width, img.height, scale);+ let img = if (t, l, b, r) == (0, 0, 0, 0) { img } else { crop(&img, t, l, b, r) };+ if !om.resize.enabled {+ return img;+ }+ let (w, h) = om.frame_size(img.width, img.height, 1.0);+ if (w, h) == (img.width, img.height) {+ return img;+ }+ match om.resize.quality {+ ResizeQuality::Low => effectcraft_raster::warp::resample(&img, w, h),+ ResizeQuality::High => bicubic(&img, w, h),+ }+ }++ /// 8-bit RGBA of the requested channels cropped/padded to `w`×`h` (codec rounding): RGB over+ /// the comp background (opaque), RGB + Alpha straight or premultiplied, or the alpha matte.+ pub fn pixels(&self, img: &Image, comp: &Comp, channels: Channels, w: u32, h: u32) -> Vec<u8> {+ let px = match channels {+ Channels::Rgb => img.to_rgba8_over(comp.background),+ Channels::Rgba => match self.job.output.alpha_mode {+ AlphaMode::Straight => img.to_rgba8(),+ AlphaMode::Premultiplied => premultiplied8(img),+ },+ Channels::Alpha => img+ .data+ .iter()+ .flat_map(|p| {+ let a = (p[3].clamp(0.0, 1.0) * 255.0 + 0.5) as u8;+ [a, a, a, 255]+ })+ .collect(),+ };+ crate::fit(px, img.width, img.height, w, h)+ }++ /// Where a file goes: `path`, or (Use Storage Overflow) the first overflow folder with room+ /// for `bytes` when the quota hook says the output volume is full.+ pub fn place(&self, path: &str, bytes: u64) -> String {+ let Some(q) = self.job.options.storage else { return path.to_string() };+ if !self.job.settings.storage_overflow || q.has_room(path, bytes) {+ return path.to_string();+ }+ let name = std::path::Path::new(path).file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| path.to_string());+ for dir in &self.job.options.overflow {+ let p = std::path::Path::new(dir).join(&name).to_string_lossy().to_string();+ if q.has_room(&p, bytes) {+ self.overflowed.lock().unwrap_or_else(|e| e.into_inner()).push(p.clone());+ return p;+ }+ }+ path.to_string()+ }++ /// Write the render log next to the output, as the Log setting asks. Returns its path.+ pub fn write_log(&self, result: &Result<crate::Report, crate::ExportError>, seconds: f64) -> Option<String> {+ let level = self.job.options.log;+ // Errors Only: a log for failures (a user stop is not an error).+ if level == RenderLog::ErrorsOnly && matches!(result, Ok(_) | Err(crate::ExportError::Cancelled)) {+ return None;+ }+ let comp = self.comp();+ let path = log_path(self.job.path);+ let mut s = String::new();+ s.push_str("EffectCraft Render Log\n");+ s.push_str(&format!("Item: {}\n", if self.job.options.label.is_empty() { "(render)" } else { &self.job.options.label }));+ s.push_str(&format!("Output: {}\n", self.job.path));+ match result {+ Ok(r) => s.push_str(&format!("Result: Done ({} frames, {}×{}, {} bytes) in {seconds:.2} s\n", r.frames, r.width, r.height, r.bytes)),+ Err(e) => s.push_str(&format!("Result: Failed\nError: {e}\n")),+ }+ let over = self.overflowed.lock().unwrap_or_else(|e| e.into_inner());+ if !over.is_empty() {+ s.push_str(&format!("Storage overflow: {} file(s) written to overflow folders (first: {})\n", over.len(), over[0]));+ }+ if level != RenderLog::ErrorsOnly {+ s.push_str("\nRender Settings:\n");+ for (k, v) in self.job.settings.describe(comp) {+ s.push_str(&format!(" {k}: {v}\n"));+ }+ s.push_str("\nOutput Module:\n");+ for (k, v) in self.job.output.describe() {+ s.push_str(&format!(" {k}: {v}\n"));+ }+ }+ if let (RenderLog::PlusPerFrameInfo, Some(ft), Some(c)) = (level, &self.frame_times, comp) {+ let mut v = ft.lock().unwrap_or_else(|e| e.into_inner()).clone();+ v.sort_by_key(|(i, _)| *i);+ s.push_str("\nFrames:\n");+ let f0 = self.job.settings.first_frame(c);+ for (i, secs) in v {+ let t = self.job.settings.frame_time(c, i);+ s.push_str(&format!(" Frame {} ({:.3} s): rendered in {:.1} ms\n", f0 + i as i64, t.seconds(), secs * 1000.0));+ }+ }+ let mut f = out::create(self.job.sink, &path).ok()?;+ std::io::Write::write_all(&mut f, s.as_bytes()).ok()?;+ f.finish().ok()?;+ Some(path)+ }+}++/// Weave two fields: the dominant field's lines (even lines when `upper_first`) from `first`.+pub(crate) fn interleave(first: &Image, second: &Image, upper_first: bool) -> Image {+ let mut out = first.clone();+ let w = out.width as usize;+ for y in 0..out.height as usize {+ let from_first = (y % 2 == 0) == upper_first;+ if !from_first && y < second.height as usize && second.width as usize == w {+ out.data[y * w..(y + 1) * w].copy_from_slice(&second.data[y * w..(y + 1) * w]);+ }+ }+ out+}++/// Remove `t`/`l`/`b`/`r` pixels from the edges (negative values add transparent pixels).+pub(crate) fn crop(img: &Image, t: i32, l: i32, b: i32, r: i32) -> Image {+ let w = (img.width as i32 - l - r).max(1) as u32;+ let h = (img.height as i32 - t - b).max(1) as u32;+ let mut out = Image::new(w, h);+ for y in 0..h as i32 {+ let sy = y + t;+ if sy < 0 || sy >= img.height as i32 {+ continue;+ }+ for x in 0..w as i32 {+ let sx = x + l;+ if sx >= 0 && sx < img.width as i32 {+ let o = out.idx(x as u32, y as u32);+ out.data[o] = img.data[img.idx(sx as u32, sy as u32)];+ }+ }+ }+ out+}++/// Bicubic resize (Resize Quality: High).+fn bicubic(src: &Image, w: u32, h: u32) -> Image {+ // Shrinking a lot: bilinear with its box pre-filter first, then bicubic for the last step.+ if src.width > w * 2 && src.height > h * 2 {+ let mid = effectcraft_raster::warp::resample(src, w * 2, h * 2);+ return bicubic(&mid, w, h);+ }+ let mut out = Image::new(w, h);+ let (sx, sy) = (src.width as f64 / w as f64, src.height as f64 / h as f64);+ for y in 0..h {+ for x in 0..w {+ let o = out.idx(x, y);+ // Clamp to the edge so borders stay opaque.+ let fx = ((x as f64 + 0.5) * sx).clamp(0.5, src.width as f64 - 0.5);+ let fy = ((y as f64 + 0.5) * sy).clamp(0.5, src.height as f64 - 0.5);+ let mut p = src.sample_bicubic(fx, fy);+ p[3] = p[3].min(1.0);+ out.data[o] = p;+ }+ }+ out+}++/// Premultiplied 8-bit RGBA (colour matted with black).+fn premultiplied8(img: &Image) -> Vec<u8> {+ img.data+ .iter()+ .flat_map(|p| {+ let a = p[3].clamp(0.0, 1.0);+ [0, 1, 2].map(|c| (p[c].clamp(0.0, a) * 255.0 + 0.5) as u8).into_iter().chain([(a * 255.0 + 0.5) as u8])+ })+ .collect()+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn interleave_takes_alternate_lines() {+ let a = Image::filled(3, 4, [1.0, 0.0, 0.0, 1.0]);+ let b = Image::filled(3, 4, [0.0, 0.0, 1.0, 1.0]);+ let up = interleave(&a, &b, true);+ let lo = interleave(&a, &b, false);+ for y in 0..4u32 {+ assert_eq!(up.data[up.idx(1, y)][0], if y % 2 == 0 { 1.0 } else { 0.0 }, "upper first: line {y}");+ assert_eq!(lo.data[lo.idx(1, y)][0], if y % 2 == 1 { 1.0 } else { 0.0 }, "lower first: line {y}");+ }+ }++ #[test]+ fn crop_and_pad() {+ let mut img = Image::new(4, 3);+ for (i, p) in img.data.iter_mut().enumerate() {+ *p = [i as f32, 0.0, 0.0, 1.0];+ }+ let c = crop(&img, 1, 1, 0, 1);+ assert_eq!((c.width, c.height), (2, 2));+ assert_eq!(c.data[0][0], 5.0);+ let p = crop(&img, -1, 0, 0, 0);+ assert_eq!((p.width, p.height), (4, 4));+ assert_eq!(p.data[0], [0.0; 4]);+ assert_eq!(p.data[4][0], 0.0);+ assert_eq!(p.data[5][0], 1.0);+ }+}diff --cc crates/export/tests/render_settings.rsindex 3347efe16,000000000..c59411b35mode 100644,000000..100644--- a/crates/export/tests/render_settings.rs+++ b/crates/export/tests/render_settings.rs@@@ -1,310 -1,0 +1,322 @@@+//! Render Settings and Output Module features end to end (through a [`Sink`], so nothing touches+//! the disk): field rendering and 3:2 pulldown, crop / region of interest / resize, alpha-only+//! and premultiplied output, the solo and guide-layer overrides, the render log, storage+//! overflow and PCM audio formats.++use std::sync::{Arc, Mutex};++use effectcraft_color::Label;+use effectcraft_export::render_queue::*;+use effectcraft_export::{Job, JobOptions, Report, Sink, StorageQuota, export};+use effectcraft_keyframe::{Keyframe, Value};+use effectcraft_project::{Comp, ItemId, ItemKind, LayerSource, Project, Solid, build};+use effectcraft_render::NoFootage;+use effectcraft_time::{FrameRate, Tick};++const W: u32 = 64;+const H: u32 = 48;++/// A comp at `rate`, black, with a white bar 8 px wide sweeping left to right (64 px/s) and a+/// static red block at the bottom left; `extra` adds layers.+fn project(rate: FrameRate, extra: impl FnOnce(&mut Project, &mut Comp)) -> (Project, ItemId) {+ let mut p = Project::default();+ let mut comp = Comp::new(W, H, rate, Tick::from_seconds_f64(2.0));+ comp.background = [0.0, 0.0, 0.0];+ let bar = p.add_item("Bar", Label::Red, None, ItemKind::Solid(Solid { color: [1.0, 1.0, 1.0], width: 8, height: 32, pixel_aspect: 1.0 }));+ let mut l = build::layer(&mut p, &comp, "Bar", LayerSource::Solid { item: bar }, (8, 32), None);+ l.props.prop_mut("transform/position").unwrap().keys =+ vec![Keyframe::new(Tick::ZERO, Value::Vec3([0.0, 16.0, 0.0])), Keyframe::new(Tick::from_seconds_f64(1.0), Value::Vec3([64.0, 16.0, 0.0]))];+ comp.layers.push(l);+ let red = p.add_item("Block", Label::Red, None, ItemKind::Solid(Solid { color: [1.0, 0.0, 0.0], width: 16, height: 8, pixel_aspect: 1.0 }));+ let mut b = build::layer(&mut p, &comp, "Block", LayerSource::Solid { item: red }, (16, 8), None);+ b.props.prop_mut("transform/position").unwrap().value = Value::Vec3([8.0, 44.0, 0.0]);+ comp.layers.push(b);+ extra(&mut p, &mut comp);+ let cid = p.add_item("Comp", Label::Sandstone, None, ItemKind::Comp(comp.into()));+ (p, cid)+}++type Files = Arc<Mutex<Vec<(String, Vec<u8>)>>>;++fn custom(start: f64, end: f64) -> RenderSettings {+ RenderSettings { time_span: TimeSpan::Custom { start: Tick::from_seconds_f64(start), end: Tick::from_seconds_f64(end) }, ..Default::default() }+}++fn run_with(p: &Project, cid: ItemId, s: &RenderSettings, om: &OutputModule, path: &str, options: JobOptions, cancel: bool) -> (Result<Report, String>, Files) {+ let files: Files = Default::default();+ let f = files.clone();+ let sink: Box<Sink> = Box::new(move |path: &str, data: Vec<u8>| f.lock().unwrap().push((path.to_string(), data)));- let job = Job { project: p, footage: &NoFootage, expr: None, accel: None, comp: cid, settings: s, output: om, path, sink: Some(&*sink), options };++ let job = Job {++ project: p,++ footage: &NoFootage,++ expr: None,++ accel: None,++ comp: cid,++ settings: s,++ output: om,++ path,++ sink: Some(&*sink),++ options,++ nested_switches: true,++ };+ let r = export(&job, &mut |pr| !(cancel && pr.done > 0)).map_err(|e| e.to_string());+ (r, files)+}++fn run(p: &Project, cid: ItemId, s: &RenderSettings, om: &OutputModule, path: &str) -> Files {+ let (r, files) = run_with(p, cid, s, om, path, JobOptions::default(), false);+ r.expect("export");+ files+}++fn png(files: &Files, i: usize) -> image::RgbaImage {+ let f = files.lock().unwrap();+ let pngs: Vec<&(String, Vec<u8>)> = f.iter().filter(|(p, _)| p.ends_with(".png")).collect();+ let mut pngs = pngs;+ pngs.sort_by(|a, b| a.0.cmp(&b.0));+ image::load_from_memory(&pngs[i].1).expect("png").to_rgba8()+}++fn row(img: &image::RgbaImage, y: u32) -> Vec<u8> {+ (0..img.width()).flat_map(|x| img.get_pixel(x, y).0).collect()+}++#[test]+fn field_render_interleaves_two_times() {+ let (p, cid) = project(FrameRate::new(25, 1), |_, _| {});+ let om = OutputModule::for_format(OutputFormat::PngSequence);+ // Frame 10 at 25 fps with fields: 0.40 s and 0.42 s.+ for (fr, upper) in [(FieldRender::UpperFirst, true), (FieldRender::LowerFirst, false)] {+ let s = RenderSettings { field_render: fr, ..custom(0.4, 0.44) };+ let fields = png(&run(&p, cid, &s, &om, "/f/field_[#####].png"), 0);+ // Progressive references at 50 fps: frames 20 (0.40 s) and 21 (0.42 s).+ let r = RenderSettings { frame_rate: Some(FrameRate::new(50, 1)), ..custom(0.4, 0.44) };+ let refs = run(&p, cid, &r, &om, "/f/ref_[#####].png");+ let (a, b) = (png(&refs, 0), png(&refs, 1));+ assert_ne!(row(&a, 10), row(&b, 10), "the bar moved between the fields");+ for y in 0..H {+ let first = (y % 2 == 0) == upper;+ assert_eq!(row(&fields, y), row(if first { &a } else { &b }, y), "{fr:?}: line {y}");+ }+ }+}++#[test]+fn pulldown_follows_the_cadence() {+ let ntsc = FrameRate::new(30000, 1001);+ let (p, cid) = project(ntsc, |_, _| {});+ let om = OutputModule::for_format(OutputFormat::PngSequence);+ let five = 5.0 * 1001.0 / 30000.0;+ let s = RenderSettings { field_render: FieldRender::UpperFirst, pulldown: Pulldown::Wssww, ..custom(0.0, five) };+ let out = run(&p, cid, &s, &om, "/p/pd_[#####].png");+ assert_eq!(out.lock().unwrap().len(), 5);+ // Film frames at 23.976 fps.+ let r = RenderSettings { frame_rate: Some(FrameRate::new(24000, 1001)), ..custom(0.0, 0.2) };+ let film = run(&p, cid, &r, &om, "/p/film_[#####].png");+ let mut pattern = String::new();+ for k in 0..5 {+ let (a, b) = Pulldown::Wssww.fields(k as u64).unwrap();+ pattern.push(if a == b { 'W' } else { 'S' });+ let img = png(&out, k);+ let (fa, fb) = (png(&film, a as usize), png(&film, b as usize));+ for y in 0..H {+ assert_eq!(row(&img, y), row(if y % 2 == 0 { &fa } else { &fb }, y), "frame {k} line {y}");+ }+ }+ assert_eq!(pattern, "WSSWW");+}++#[test]+fn crop_roi_and_resize() {+ let (p, cid) = project(FrameRate::new(25, 1), |_, _| {});+ let s = custom(0.4, 0.44);+ let full = png(&run(&p, cid, &s, &OutputModule::for_format(OutputFormat::PngSequence), "/c/full_[#####].png"), 0);+ let mut om = OutputModule::for_format(OutputFormat::PngSequence);+ om.crop = Crop { enabled: true, top: 4, left: 10, bottom: 6, right: 2, ..Default::default() };+ let c = png(&run(&p, cid, &s, &om, "/c/crop_[#####].png"), 0);+ assert_eq!((c.width(), c.height()), (52, 38));+ for (x, y) in [(0, 0), (20, 11), (51, 37), (3, 30)] {+ assert_eq!(c.get_pixel(x, y), full.get_pixel(x + 10, y + 4), "({x}, {y})");+ }+ // Region of interest at half resolution.+ om.crop = Crop { enabled: true, use_roi: true, roi: Some([16.0, 8.0, 32.0, 32.0]), ..Default::default() };+ let half = RenderSettings { resolution: 0.5, ..s.clone() };+ let r = png(&run(&p, cid, &half, &om, "/c/roi_[#####].png"), 0);+ assert_eq!((r.width(), r.height()), (16, 16));+ // Resize (fixed size, low and high quality) after the crop.+ om.crop = Crop::default();+ for q in [ResizeQuality::Low, ResizeQuality::High] {+ om.resize = Resize { enabled: true, width: 32, height: 20, lock_aspect: false, quality: q };+ let z = png(&run(&p, cid, &s, &om, "/c/resize_[#####].png"), 0);+ assert_eq!((z.width(), z.height()), (32, 20));+ // The red block (bottom left) survives the resize.+ let px = z.get_pixel(4, 18).0;+ assert!(px[0] > 150 && px[1] < 80, "{q:?}: {px:?}");+ }+ om.resize.lock_aspect = true;+ let z = png(&run(&p, cid, &s, &om, "/c/aspect_[#####].png"), 0);+ assert_eq!((z.width(), z.height()), (32, 24));+}++#[test]+fn alpha_only_and_premultiplied() {+ let (p, cid) = project(FrameRate::new(25, 1), |p, comp| {+ // A half-transparent green layer over the right half.+ let g = p.add_item("Green", Label::Green, None, ItemKind::Solid(Solid { color: [0.0, 1.0, 0.0], width: 32, height: 48, pixel_aspect: 1.0 }));+ let mut l = build::layer(p, comp, "Green", LayerSource::Solid { item: g }, (32, 48), None);+ l.props.prop_mut("transform/position").unwrap().value = Value::Vec3([48.0, 24.0, 0.0]);+ l.props.prop_mut("transform/opacity").unwrap().value = Value::Scalar(50.0);+ comp.layers.insert(0, l);+ });+ let s = custom(0.0, 0.04);+ let mut om = OutputModule::for_format(OutputFormat::PngSequence);+ om.channels = Channels::Alpha;+ let a = png(&run(&p, cid, &s, &om, "/a/alpha_[#####].png"), 0);+ assert_eq!(a.get_pixel(60, 2).0[0], 128, "half-opaque green");+ assert_eq!(a.get_pixel(20, 2).0[0], 0, "transparent");+ assert_eq!(a.get_pixel(8, 44).0[0], 255, "opaque block");+ om.channels = Channels::Rgba;+ let straight = png(&run(&p, cid, &s, &om, "/a/s_[#####].png"), 0);+ om.alpha_mode = AlphaMode::Premultiplied;+ let premul = png(&run(&p, cid, &s, &om, "/a/p_[#####].png"), 0);+ assert_eq!(straight.get_pixel(60, 2).0, [0, 255, 0, 128]);+ assert_eq!(premul.get_pixel(60, 2).0, [0, 128, 0, 128]);+}++#[test]+fn solo_and_guide_layer_overrides() {+ let (p, cid) = project(FrameRate::new(25, 1), |p, comp| {+ let g = p.add_item("Guide", Label::Green, None, ItemKind::Solid(Solid { color: [0.0, 0.0, 1.0], width: 8, height: 8, pixel_aspect: 1.0 }));+ let mut l = build::layer(p, comp, "Guide", LayerSource::Solid { item: g }, (8, 8), None);+ l.props.prop_mut("transform/position").unwrap().value = Value::Vec3([56.0, 44.0, 0.0]);+ l.switches.guide = true;+ comp.layers.insert(0, l);+ // Solo the moving bar.+ comp.layers[1].switches.solo = true;+ });+ let om = OutputModule::for_format(OutputFormat::PngSequence);+ let s = custom(0.4, 0.44);+ let cur = png(&run(&p, cid, &s, &om, "/s/cur_[#####].png"), 0);+ assert_eq!(cur.get_pixel(8, 44).0[0], 0, "solo: the red block is hidden");+ assert_eq!(cur.get_pixel(56, 44).0[2], 0, "guide layers off by default");+ let off = RenderSettings { solo: CurrentOrOff::AllOff, guide_layers: CurrentOrOff::Current, ..s.clone() };+ let all = png(&run(&p, cid, &off, &om, "/s/off_[#####].png"), 0);+ assert_eq!(all.get_pixel(8, 44).0[0], 255, "Solo Switches: All Off");+ // (with solo off the guide renders too: Guide Layers: Current Settings)+ assert_eq!(all.get_pixel(56, 44).0[2], 255);+}++#[test]+fn render_logs() {+ let (p, cid) = project(FrameRate::new(25, 1), |_, _| {});+ let om = OutputModule::for_format(OutputFormat::PngSequence);+ let s = RenderSettings { field_render: FieldRender::UpperFirst, name: "DV-ish".into(), ..custom(0.0, 0.2) };+ let log_of = |files: &Files| {+ files.lock().unwrap().iter().find(|(p, _)| p.ends_with("_RenderLog.txt")).map(|(p, d)| (p.clone(), String::from_utf8(d.clone()).unwrap()))+ };+ // Errors Only + success: no log.+ let (r, files) = run_with(&p, cid, &s, &om, "/l/a_[#####].png", JobOptions::default(), false);+ assert!(r.unwrap().log.is_none());+ assert!(log_of(&files).is_none());+ // Plus Per Frame Info: settings and one line per frame.+ let opts = JobOptions { log: RenderLog::PlusPerFrameInfo, label: "#1 Comp".into(), ..Default::default() };+ let (r, files) = run_with(&p, cid, &s, &om, "/l/b_[#####].png", opts, false);+ let r = r.unwrap();+ let (path, text) = log_of(&files).expect("log");+ assert_eq!(r.log.as_deref(), Some(path.as_str()));+ assert_eq!(path, "/l/b_RenderLog.txt");+ assert!(text.contains("Item: #1 Comp") && text.contains("Result: Done (5 frames"), "{text}");+ assert!(text.contains("Field Render: Upper Field First") && text.contains("Template: DV-ish") && text.contains("Format: PNG Sequence"), "{text}");+ assert_eq!(text.lines().filter(|l| l.contains("rendered in")).count(), 5, "{text}");+ assert!(text.contains("Frame 0 (0.000 s): rendered in") && text.contains("Frame 4 (0.160 s)"), "{text}");+ // Plus Settings: no per-frame lines.+ let opts = JobOptions { log: RenderLog::PlusSettings, ..Default::default() };+ let (_, files) = run_with(&p, cid, &s, &om, "/l/c.gif", opts, false);+ let (_, text) = log_of(&files).expect("log");+ assert!(text.contains("Render Settings:") && !text.contains("rendered in"), "{text}");+ // Errors Only + failure (the composition is gone): the error is logged.+ let gif = OutputModule::for_format(OutputFormat::Gif);+ let (r, files) = run_with(&p, ItemId(424_242), &s, &gif, "/l/d.gif", JobOptions::default(), false);+ assert!(r.is_err());+ let (path, text) = log_of(&files).expect("error log");+ assert_eq!(path, "/l/d_RenderLog.txt");+ assert!(text.contains("Result: Failed") && text.contains("Error: composition not found") && !text.contains("Render Settings:"), "{text}");+ // A user stop is not an error: no log.+ let (r, files) = run_with(&p, cid, &s, &gif, "/l/e.gif", JobOptions::default(), true);+ assert!(r.is_err());+ assert!(log_of(&files).is_none());+}++/// The primary folder holds `limit` bytes; overflow folders are unlimited.+struct Quota {+ limit: u64,+ used: Mutex<u64>,+}++impl StorageQuota for Quota {+ fn has_room(&self, path: &str, bytes: u64) -> bool {+ if !path.starts_with("/primary/") {+ return true;+ }+ let mut u = self.used.lock().unwrap();+ if *u + bytes > self.limit {+ return false;+ }+ *u += bytes;+ true+ }+}++#[test]+fn storage_overflow_moves_files_to_the_overflow_folder() {+ let (p, cid) = project(FrameRate::new(25, 1), |_, _| {});+ let om = OutputModule::for_format(OutputFormat::PngSequence);+ let s = RenderSettings { skip_existing: false, ..custom(0.0, 0.4) };+ let q = Quota { limit: 1, used: Mutex::new(0) };+ let opts = JobOptions { storage: Some(&q), overflow: vec!["/overflow".into()], log: RenderLog::PlusSettings, ..Default::default() };+ let (r, files) = run_with(&p, cid, &s, &om, "/primary/seq_[#####].png", opts, false);+ let r = r.unwrap();+ assert_eq!(r.overflow.len(), 10, "{:?}", r.overflow);+ let f = files.lock().unwrap();+ assert_eq!(f.iter().filter(|(p, _)| p.starts_with("/overflow/seq_") && p.ends_with(".png")).count(), 10);+ let log = f.iter().find(|(p, _)| p.ends_with("_RenderLog.txt")).map(|(_, d)| String::from_utf8_lossy(d).to_string()).unwrap();+ assert!(log.contains("Storage overflow: 10 file(s)"), "{log}");+ drop(f);+ // Use Storage Overflow off: everything stays in place.+ let off = RenderSettings { storage_overflow: false, ..s };+ let q = Quota { limit: 1, used: Mutex::new(0) };+ let opts = JobOptions { storage: Some(&q), overflow: vec!["/overflow".into()], ..Default::default() };+ let (r, files) = run_with(&p, cid, &off, &om, "/primary/seq_[#####].png", opts, false);+ assert!(r.unwrap().overflow.is_empty());+ assert!(files.lock().unwrap().iter().all(|(p, _)| p.starts_with("/primary/")));+}++#[test]+fn wav_and_aiff_channels_and_formats() {+ let (p, cid) = project(FrameRate::new(25, 1), |_, _| {});+ let s = custom(0.0, 0.5);+ let mut om = OutputModule::for_format(OutputFormat::Wav);+ om.audio_channels = 1;+ om.audio_format = AudioFormat::S24;+ om.audio_sample_rate = 44_100;+ let files = run(&p, cid, &s, &om, "/w/a.wav");+ let d = files.lock().unwrap()[0].1.clone();+ assert_eq!(&d[..4], b"RIFF");+ let u16_at = |o: usize| u16::from_le_bytes([d[o], d[o + 1]]);+ let u32_at = |o: usize| u32::from_le_bytes([d[o], d[o + 1], d[o + 2], d[o + 3]]);+ assert_eq!((u16_at(20), u16_at(22), u32_at(24), u16_at(32), u16_at(34)), (1, 1, 44_100, 3, 24));+ assert_eq!(u32_at(40), 22_050 * 3, "half a second of mono 24-bit");+ om.audio_channels = 2;+ om.audio_format = AudioFormat::F32;+ let files = run(&p, cid, &s, &om, "/w/b.wav");+ let d = files.lock().unwrap()[0].1.clone();+ let u16_at = |o: usize| u16::from_le_bytes([d[o], d[o + 1]]);+ assert_eq!((u16_at(20), u16_at(22), u16_at(32), u16_at(34)), (3, 2, 8, 32), "IEEE float stereo");+ // AIFF has no float: 24-bit.+ let mut aiff = OutputModule::for_format(OutputFormat::Aiff);+ aiff.audio_format = AudioFormat::F32;+ let files = run(&p, cid, &s, &aiff, "/w/c.aif");+ let d = files.lock().unwrap()[0].1.clone();+ assert_eq!(&d[8..12], b"AIFF");+ assert_eq!(u16::from_be_bytes([d[26], d[27]]), 24, "sample size");+}diff --cc crates/export/tests/roundtrip.rsindex c6810cb0b,f8bef9f25..4c2f6bb49--- a/crates/export/tests/roundtrip.rs+++ b/crates/export/tests/roundtrip.rs@@@ -55,7 -55,7 +55,19 @@@ fn settings() -> RenderSettingsfn run(p: &Project, cid: ItemId, footage: &dyn FootageSource, om: &OutputModule, path: &Path) -> effectcraft_export::Report {let s = settings();let path = path.to_string_lossy().to_string();- let job = Job { project: p, footage, expr: None, accel: None, comp: cid, settings: &s, output: om, path: &path, sink: None, options: Default::default() };- let job = Job { project: p, footage, expr: None, accel: None, comp: cid, settings: &s, output: om, path: &path, sink: None, nested_switches: true };++ let job = Job {++ project: p,++ footage,++ expr: None,++ accel: None,++ comp: cid,++ settings: &s,++ output: om,++ path: &path,++ sink: None,++ options: Default::default(),++ nested_switches: true,++ };let mut last = Progress::default();let mut calls = 0;let r = export(&job, &mut |pr| {@@@ -167,18 -167,8 +179,19 @@@ fn h264_odd_size_is_cropped_even()let comp = p.comp(cid).expect("comp");assert_eq!(s.output_size(comp).0 % 2, 1);let path = d.join("odd.mp4").to_string_lossy().to_string();- let job =- Job { project: &p, footage: &NoFootage, expr: None, accel: None, comp: cid, settings: &s, output: &om, path: &path, sink: None, nested_switches: true };+ let job = Job {+ project: &p,+ footage: &NoFootage,+ expr: None,+ accel: None,+ comp: cid,+ settings: &s,+ output: &om,+ path: &path,+ sink: None,+ options: Default::default(),++ nested_switches: true,+ };let r = export(&job, &mut |_| true).expect("export");assert_eq!((r.width % 2, r.height % 2), (0, 0));}@@@ -298,18 -288,8 +311,19 @@@ fn cancel_stops_early()let om = OutputModule::for_format(OutputFormat::PngSequence);let s = settings();let path = d.join("c_[#####].png").to_string_lossy().to_string();- let job =- Job { project: &p, footage: &NoFootage, expr: None, accel: None, comp: cid, settings: &s, output: &om, path: &path, sink: None, nested_switches: true };+ let job = Job {+ project: &p,+ footage: &NoFootage,+ expr: None,+ accel: None,+ comp: cid,+ settings: &s,+ output: &om,+ path: &path,+ sink: None,+ options: Default::default(),++ nested_switches: true,+ };let r = export(&job, &mut |_| false);assert!(matches!(r, Err(effectcraft_export::ExportError::Cancelled)));let written = std::fs::read_dir(&d).map(|r| r.count()).unwrap_or(0);diff --cc crates/host/src/lib.rsindex 4161abc7c,cfa5f8250..41ece11e9--- a/crates/host/src/lib.rs+++ b/crates/host/src/lib.rs@@@ -40,25 -40,10 +40,26 @@@ impl Exporter for FileExporteroutput: &job.item.output,path: job.path,sink: self.sink.as_deref(),+ options: effectcraft_export::JobOptions {+ log: job.item.log,+ label: job.label.clone(),+ storage: job.storage,+ overflow: job.project.render_prefs.overflow_folders.clone(),+ },+ nested_switches: job.nested_switches,};match effectcraft_export::export(&j, &mut |p| progress(p.done, p.total)) {- Ok(r) => Ok(ExportResult { path: r.path, frames: r.frames, width: r.width, height: r.height, bytes: r.bytes, seconds: r.seconds, audio: r.audio }),+ Ok(r) => Ok(ExportResult {+ path: r.path,+ frames: r.frames,+ width: r.width,+ height: r.height,+ bytes: r.bytes,+ seconds: r.seconds,+ audio: r.audio,+ log: r.log,+ overflow: r.overflow,+ }),Err(effectcraft_export::ExportError::Cancelled) => Err(effectcraft_engine::render_queue::CANCELLED.into()),Err(e) => Err(e.to_string()),}diff --cc crates/ui-egui/src/panels/mod.rsindex 740ced109,d9a9864ad..a3179a8b1--- a/crates/ui-egui/src/panels/mod.rs+++ b/crates/ui-egui/src/panels/mod.rs@@@ -28,7 -33,7 +33,8 @@@ pub mod propertiespub mod puppet_tool;pub mod render_queue;pub mod roto_tool;+pub mod rq_templates;+ pub mod scopes_panel;pub mod script_console;pub mod settings;pub mod shortcut_editor;diff --cc docs/parity.mdindex 2b30c5764,3974630f0..43d93b126--- a/docs/parity.md+++ b/docs/parity.md@@@ -20,12 -20,9 +20,9 @@@ Animation 94%, Masks 94%, Preview 94%,Tracking 88%, Effects 85%, Web 65%.What is left, in priority order: the web app's depth (threads, storage, audio, non-blocking- renders); stroke taper/wave and multi-segment dashes; variable mask feather points; camera iris/bokeh and focus-link commands; GPU- rendering of 3D runs and adjustment layers;- approximated effects (Subspace Warp, Key Cleaner) and Liquify's viewer brush; OpenType features and variable- font axes; AI/EPS/PDF import; more codecs; 59 preferences not yet wired; ScriptUI;- Lumetri Scopes, Footage, Media Browser and Metadata panels; Content-Aware Fill; face tracking; and- the "better than After Effects" items (a plug-in API, branching history, GPU particles).-renders); stroke taper/wave and multi-segment dashes; variable mask feather points; camera iris/bokeh and focus-link commands; Render Queue field render, crop/resize and templates;++renders); stroke taper/wave and multi-segment dashes; variable mask feather points; camera iris/bokeh and focus-link commands;+ approximated effects (Subspace Warp, Key Cleaner) and Liquify's viewer brush; text in imported+ PDF/AI files and Illustrator procset EPS; more codecs; 59 preferences not yet wired; ScriptUI; face tracking; and the "better than After Effects" items (a plug-in API, branching history; GPU particles landed in M12.7).The sections below are the original audit (morning of 2 October, ≈ 64%) and its updates, kept forhistory.@@@ -110,9 -107,9 +107,9 @@@ the disk cache in the formats wave; th| Area | Weighted parity | Remaining (agent-hours) | Biggest gaps ||---|---|---|---|| Layers | 88% | 4.8 | frame blending, collapse transformations, slip edit |-| Output | 90% | 3.0 | multiple output modules, pre-render (WebM with VP9 alpha + Opus and WAV/AIFF audio-only landed: VP9 is intra-only, Opus CELT-only) |+| Output | 97% | 0.8 | Render Settings complete (field render + 3:2 pulldown, effects/solo/guide/depth/blending/blur overrides, time sampling, storage overflow), Output Module crop/ROI/resize, alpha modes, post-render actions, PCM formats, templates with defaults, render logs, Notify (M10.2); WebM VP9 key + inter frames with motion search, loop filter and rate control. Left: Opus is CELT-only, Photoshop sequence output, overflow for movies only checks at file creation || Audio | 85% | 0.5 | audio to keyframes |- | Import | 88% | 2.0 | AI/EPS/PDF vector footage, PSD smart objects and 3D layers (PSD as footage/composition/retain layer sizes, SVG footage and Create Shapes from Vector Layer landed) |+ | Import | 94% | 1.0 | text and images inside PDF/AI files, Illustrator EPS relying on Adobe procsets, smart-object perspective/warps, PSD 3D layers (PDF / PDF-compatible AI / EPS vector footage with Continuously Rasterize, layered composition import and Create Shapes from Vector Layer, and PSD smart objects with embedded files landed in M13.2; PSD as footage/composition/retain layer sizes, SVG footage earlier) || Automation | ≈ 90% | 0.8 | scripting covers the documented core object model (AUT-2, M14.4: `app`, project items, comps, layers, properties and keyframes, text documents, markers, render queue, Script Console, `effectcraft-cli script`, MCP `run_script`); still missing: ScriptUI panels/dialogs, `.jsxbin`, sockets || Shapes | ≈ 80% | 1.5 | Lottie can't carry stroke taper/wave (stroke Taper and Wave, Dash 2/Gap 2/Dash 3/Gap 3 and radial-gradient Highlight Length/Angle landed in M13.5; pen tool for shape paths and vertex editing in M6.5) || Compositions | ≈ 80% | 3.5 | Mocha-style planar tracks for templates, Essential Graphics' rare controls (font menus, mirrored properties) (the marker dialog, Composition Flowchart, Essential Graphics with master properties, `.ectemplate` templates and Responsive Design — Time landed: CMP-6, CMP-7) |