diff --git a/crates/engine/src/edith.rs b/crates/engine/src/edith.rs index a3e9b87..e9505df 100644 --- a/crates/engine/src/edith.rs +++ b/crates/engine/src/edith.rs @@ -1,11 +1,12 @@ //! The project file: a line of text per thing, and nothing else. //! //! ```text -//! edith 11 +//! edith 12 //! playhead 90 //! resolution 1920 1080 //! fps 30.0 //! tonemap vivid +//! proxy on //! limiter -1.0 on //! source 0 test_av.mp4 //! source 1 /elsewhere/test_av2.mp4 @@ -44,6 +45,13 @@ //! project holding no HDR media, and one whose owner never picked, are the bytes //! they were. //! +//! The `proxy` line is whether this project is cut on the stand-ins +//! ([`crate::proxy`]) rather than on the films themselves, spelled `on` or +//! `off`. Left out when it is off, which is what every dialect before v12 was. +//! *Which* sources have a stand-in is not written: a proxy is found by the +//! film's own path, length and modification time, so the cache is the only +//! answer and a project file cannot go stale about it. +//! //! The `limiter` line is the master limiter over the whole mix //! ([`crate::limiter`]): its ceiling in dBFS and whether it is in circuit, //! spelled `on` or `off`. Left out when it is the default, which is off. @@ -100,7 +108,9 @@ //! is the only way an empty lane could still be there on the way back. A lane //! number may not skip one of its kind. //! -//! **Version 10** was this without the `tonemap` line: such a project is shown +//! **Version 11** was this without the `proxy` line: such a project is cut on +//! its films themselves, which is all any project could do. +//! **Version 10** was that without the `tonemap` line: such a project is shown //! in the reference rendition, which is the only one there was. //! **Version 9** was that without the `subtitle` lines: such a project shows no //! subtitles, which is all any project could do. @@ -159,7 +169,8 @@ use crate::subtitle::SubtitleTrack; /// What [`save`] writes. Read support goes back to `edith 1`; see the module /// docs for what those dialects looked like. -const MAGIC: &[u8] = b"edith 11"; +const MAGIC: &[u8] = b"edith 12"; +const MAGIC_V11: &[u8] = b"edith 11"; const MAGIC_V10: &[u8] = b"edith 10"; const MAGIC_V9: &[u8] = b"edith 9"; const MAGIC_V8: &[u8] = b"edith 8"; @@ -214,6 +225,11 @@ pub struct Document { /// for a v11 file that leaves the line out, which both mean the published /// conversion -- the only one those projects had. pub tone: crate::tonemap::Preset, + /// Whether the films are cut on their stand-ins ([`crate::proxy`]). `false` + /// for every dialect before v12 and for a v12 file that leaves the line + /// out, which both mean the films themselves -- the only thing those + /// projects could do. + pub proxy: bool, pub playhead: u32, } @@ -233,6 +249,7 @@ pub fn save( resolution: (u32, u32), fps: Option, tone: crate::tonemap::Preset, + proxy: bool, limiter: Limiter, playhead: u32, ) -> crate::Result<()> { @@ -247,7 +264,7 @@ pub fn save( let result = std::fs::File::create(&part) .and_then(|mut f| { f.write_all(&emit( - &dir, sources, lanes, gains, subtitles, eq, color, resolution, fps, tone, + &dir, sources, lanes, gains, subtitles, eq, color, resolution, fps, tone, proxy, limiter, playhead, ))?; f.sync_all() @@ -291,6 +308,7 @@ fn emit( resolution: (u32, u32), fps: Option, tone: crate::tonemap::Preset, + proxy: bool, limiter: Limiter, playhead: u32, ) -> Vec { @@ -310,6 +328,11 @@ fn emit( if tone != crate::tonemap::Preset::default() { out.extend_from_slice(format!("tonemap {}\n", tone.name()).as_bytes()); } + // Beside it and by the same rule: a project cut on the films themselves -- + // every project before there were stand-ins -- says nothing here. + if proxy { + out.extend_from_slice(b"proxy on\n"); + } // Written only when it is not the default, so a project nobody has limited // is the same bytes it was in v8 bar the version line. if limiter != Limiter::default() { @@ -439,8 +462,10 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result { // The dialects that wrote a source line without its stream field. Reading // one is the whole of what "an old project still opens" means here. let streamless = v1 || first == MAGIC_V2; - // The one that carries an HDR rendition... - let v11 = first == MAGIC; + // The one that says whether it is cut on stand-ins... + let v12 = first == MAGIC; + // ...the ones that carry an HDR rendition... + let v11 = v12 || first == MAGIC_V11; // ...the ones that carry subtitle tracks... let v10 = v11 || first == MAGIC_V10; // ...the ones that carry the mix -- lane volumes, the master limiter and @@ -487,6 +512,7 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result { subtitles: Vec::new(), limiter: Limiter::default(), tone: crate::tonemap::Preset::default(), + proxy: false, fps: None, playhead: 0, }; @@ -557,6 +583,25 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result { ) })?; } + b"proxy" if v12 => { + if !doc.sources.is_empty() { + return Err( + format!("line {n}: proxy belongs once, before the sources").into() + ); + } + let f = fields(rest, 1, "proxy", n)?; + doc.proxy = match f[0] { + b"on" => true, + b"off" => false, + other => { + return Err(format!( + "line {n}: proxy is on or off, not {:?}", + String::from_utf8_lossy(other) + ) + .into()); + } + }; + } b"limiter" if v9 => { if !doc.sources.is_empty() { return Err( @@ -1076,6 +1121,7 @@ mod tests { resolution, None, crate::tonemap::Preset::default(), + false, Limiter::default(), playhead, ) @@ -1119,6 +1165,7 @@ mod tests { (1280, 720), None, crate::tonemap::Preset::default(), + false, Limiter::default(), 0, ); @@ -1147,7 +1194,7 @@ mod tests { video 1 0 0 30 0 - - - fit 1000\n"; let old = parse(v9, &dir).expect("v9 still loads"); assert_eq!(old.subtitles, Vec::new()); - assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 11\n")); + assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 12\n")); // ...and the line itself is not a v9 line: a dialect may not be mixed. let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir) .unwrap_err() @@ -1163,6 +1210,65 @@ mod tests { } } + /// The v12 line: whether the project is cut on the stand-ins, written only + /// when it is -- and the dialect before it, which had no stand-ins and + /// whose bytes are therefore unchanged bar the version. + #[test] + fn the_proxy_switch_round_trips_and_a_v11_file_is_cut_on_its_films() { + let dir = PathBuf::from("/proj"); + let (_, sources, lanes) = doc(); + let bytes = |proxy| { + super::emit( + &dir, + &sources, + &lanes, + &[], + &[], + &[], + &[], + (1280, 720), + None, + crate::tonemap::Preset::default(), + proxy, + Limiter::default(), + 0, + ) + }; + let on = bytes(true); + assert!( + String::from_utf8_lossy(&on).contains("proxy on\n"), + "{}", + String::from_utf8_lossy(&on) + ); + assert!(parse(&on, &dir).expect("v12 parses").proxy); + let off = bytes(false); + assert!( + !String::from_utf8_lossy(&off).contains("proxy"), + "off is the line left out" + ); + assert!(!parse(&off, &dir).expect("v12 parses").proxy); + + // A v11 project is one cut on the films themselves, and it still loads. + let v11 = b"edith 11\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + video 1 0 0 30 0 - - - fit 1000\n"; + let old = parse(v11, &dir).expect("v11 still loads"); + assert!(!old.proxy); + assert_eq!(old.sources.len(), 1, "the rest of it came back too"); + // ...and the line is not a v11 line: a dialect may not be mixed. + let mixed = parse(b"edith 11\nsource 0 a.mp4\nproxy on\n", &dir) + .unwrap_err() + .to_string(); + assert_eq!(mixed, "line 3: unknown keyword \"proxy\""); + // Anything but on or off is a corrupt line, by name. + for line in ["proxy\n", "proxy yes\n", "proxy On\n"] { + let file = format!("edith 12\nsource 0 a.mp4\n{line}"); + assert!( + parse(file.as_bytes(), &dir).is_err(), + "{line:?} is not a proxy line" + ); + } + } + /// The v11 line: the HDR rendition, written by name, read back as the very /// preset -- and the dialect before it, which had no way to say one and /// meant the published conversion. @@ -1182,6 +1288,7 @@ mod tests { (1280, 720), None, preset, + false, Limiter::default(), 0, ); @@ -1276,7 +1383,7 @@ mod tests { let bytes = flat(&dir, &sources, &lanes, 12); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 11\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 12\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ source 2 /elsewhere/b.mp4\n\ video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\ audio 1 0 0 30 0 0 - - fit 1000\n", @@ -1313,7 +1420,7 @@ mod tests { let bytes = flat(&dir, &sources, &lanes, 7); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 11\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 12\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\ video 1 0 0 30 0 4 - - fit 1000\naudio 1\n\ video 2 40 0 10 0 - - - fit 1000\naudio 2 0 0 30 0 4 - - fit 1000\n", "an empty lane is a line of its own; everything else is its clips" @@ -1421,7 +1528,7 @@ mod tests { let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 11\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 12\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\ eq 16777215.0:-0.1:3.918315e-39:hs\n\ eq\n\ @@ -1525,7 +1632,7 @@ mod tests { let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 11\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 12\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ color 0.1:1.2:0.9:-0.3\n\ color -1e-7:16777215.0:3.918315e-39:-0.0\n\ color 0.0:1.0:1.0:0.0\n\ @@ -1590,7 +1697,7 @@ mod tests { (1280, 720), old.playhead )), - "edith 11\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 12\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ eq 80.0:-3.0:0.707:ls\n\ video 1 0 0 30 0 0 0 - fit 1000\naudio 1 0 0 30 0 0 - - fit 1000\n" ); @@ -1628,7 +1735,7 @@ mod tests { let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 11\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 12\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ video 1 0 0 30 0 - - - fit 2000\nvideo 1 15 30 40 0 - - - fit 250\n\ audio 1 0 0 30 0 - - - fit 2000\n", "the rate is the clip line's last field, in thousandths" @@ -1657,7 +1764,7 @@ mod tests { (1280, 720), old.playhead )), - "edith 11\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 12\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ video 1 0 0 30 0 0 - - fit 1000\naudio 1 0 0 30 0 0 - - fit 1000\n" ); // A rate outside what the editor can set is a corrupt line, by name. @@ -1698,12 +1805,13 @@ mod tests { (1280, 720), Some(23.976023976023978), crate::tonemap::Preset::default(), + false, limiter, 0, ); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 11\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\ + "edith 12\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\ limiter -1.5 on\nsource 0 a.mp4\n\ video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n\ audio 2 0 0 30 0 - - - fit 1000\n\ @@ -1735,7 +1843,7 @@ mod tests { (1280, 720), old.playhead )), - "edith 11\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 12\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n" ); @@ -1899,7 +2007,7 @@ mod tests { assert!(old.eq.is_empty(), "nothing before v5 equalizes anything"); assert_eq!( String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)), - "edith 11\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 12\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ source 2 /elsewhere/b.mp4\n\ video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\ audio 1 0 0 30 0 0 - - fit 1000\n" @@ -1952,7 +2060,7 @@ mod tests { let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); assert_eq!( String::from_utf8_lossy(&v5), - "edith 11\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 12\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ source 0 /elsewhere/b.mp4\n\ video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\ audio 1 0 0 30 0 0 - - fit 1000\n", @@ -1984,7 +2092,7 @@ mod tests { // Saved again it is the current version, which round-trips to the // same document. let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); - assert!(v5.starts_with(b"edith 11\n")); + assert!(v5.starts_with(b"edith 12\n")); let again = parse(&v5, &dir).expect("v5 parses"); assert_eq!(again.lanes, back.lanes); // A dialect may not be mixed: lane lines under v1, `clip` under v2. @@ -2082,6 +2190,7 @@ mod tests { (1280, 720), None, crate::tonemap::Preset::default(), + false, Limiter::default(), 0, ) @@ -2089,7 +2198,7 @@ mod tests { let bytes = std::fs::read(&path).expect("read back"); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 11\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\ + "edith 12\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\ video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n" ); // Loading rejoins the *given* directory, so the file is reached by the @@ -2134,10 +2243,10 @@ mod tests { #[test] fn a_wrong_first_line_is_refused_by_name() { let dir = PathBuf::from("/proj"); - let err = parse(b"edith 12\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir) + let err = parse(b"edith 13\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir) .unwrap_err() .to_string(); - assert_eq!(err, "line 1: unsupported version 12"); + assert_eq!(err, "line 1: unsupported version 13"); for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] { assert_eq!( parse(junk, &dir).unwrap_err().to_string(), diff --git a/crates/engine/src/export.rs b/crates/engine/src/export.rs index b06091f..9d30bb3 100644 --- a/crates/engine/src/export.rs +++ b/crates/engine/src/export.rs @@ -402,6 +402,15 @@ pub fn start( part.push(".part"); let part = PathBuf::from(part); let spawned = thread::Builder::new().name("export".into()).spawn(move || { + // Every file this export will read, named before a byte of one is. + // These are the project's own sources and can be nothing else: a + // stand-in ([`crate::proxy`]) is a substitution playback makes when it + // opens a span, and nothing here knows such a thing exists. Printed so + // that "the delivery came off the film itself" is a grep rather than a + // belief. + for source in project.sources() { + eprintln!("export source: {}", source.path.display()); + } // The rename is the last step and the only one that publishes a file // under the name the caller asked for; it stays on the same directory, // so it is atomic. diff --git a/crates/engine/src/playback.rs b/crates/engine/src/playback.rs index adc56de..b7e2f2c 100644 --- a/crates/engine/src/playback.rs +++ b/crates/engine/src/playback.rs @@ -11,7 +11,7 @@ //! Drift policy stays with the caller -- this type answers "what time is it", //! the renderer decides which frame that means. -use std::path::Path; +use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU64, AtomicUsize, Ordering}; use std::sync::mpsc::{Receiver, TryRecvError}; use std::sync::{Arc, Mutex}; @@ -311,6 +311,16 @@ pub struct PlaybackSession { /// of a restart is never counted as timeline time. See /// [`Audio::content_at`]. priming: bool, + /// Whether the picture is decoded from the stand-ins rather than from the + /// films ([`crate::proxy`]). One switch for the whole project, saved with + /// it, and *only* the picture: the sound is always the film's own, and so + /// is everything an export reads. + /// + /// Which sources have a stand-in is not kept here -- it is asked of the + /// cache when a span opens ([`Self::picture_path`]), one `stat` against a + /// file open that already costs milliseconds, so a proxy made (or deleted) + /// mid-session is picked up at the next seek and nothing can go stale. + proxies: bool, } /// What an edit dirtied -- which half of the pipeline has to be rebuilt for the @@ -423,6 +433,8 @@ impl PlaybackSession { eos: false, mix: None, priming: false, + // A file just opened is a project nobody has picked stand-ins for. + proxies: false, }) } @@ -533,6 +545,8 @@ impl PlaybackSession { eos: false, mix: None, priming: false, + // A file just opened is a project nobody has picked stand-ins for. + proxies: false, }) } @@ -607,6 +621,8 @@ impl PlaybackSession { eos: false, mix: None, priming: false, + // A file just opened is a project nobody has picked stand-ins for. + proxies: false, }) } @@ -898,6 +914,9 @@ impl PlaybackSession { eos: false, mix: None, priming: false, + // What the file says, and `false` for every dialect before v12: + // a project cut on the films themselves opens on them. + proxies: doc.proxy, }; // The scaffolding above opened source 0 from its first frame and the // whole of its audio; this puts both onto the clip the playhead is @@ -1149,6 +1168,10 @@ impl PlaybackSession { // reason: a picked look that vanished on a reload is a look nobody // could keep. self.project.tone(), + // ...and whether it is cut on the stand-ins, for the same reason. + // *Which* files have one is not saved: [`crate::proxy`] finds that + // out from the film itself, so nothing here can go stale. + self.proxies, self.project.limiter(), playhead, ) @@ -1328,7 +1351,11 @@ impl PlaybackSession { from: Some((source, in_frame)), .. }) => Ok(DecodeSession::open_worker_deferred( - &self.project.sources()[source].path, + // The stand-in where there is one and the switch is on, the + // film itself otherwise -- the one place the picture's file is + // decided ([`Self::picture_path`]). The sound is opened + // elsewhere and is always the film's. + &self.picture_path(source), // The file's own frames, which is the only place they exist: // a clip counts the timeline's ([`Rate`]). self.span_rate.source_at(in_frame), @@ -1743,6 +1770,50 @@ impl PlaybackSession { .map_or(Rate::REAL_TIME, |i| self.rates[i]) } + /// Which file this source's **picture** is decoded from: its stand-in when + /// the project is cut on stand-ins and one has been made for it, and the + /// film itself in every other case ([`crate::proxy`]). + /// + /// One `stat` per span open, against a decoder open that costs milliseconds + /// -- so a proxy that appeared (or was deleted) since the last seek is + /// picked up at this one, and no table of attachments exists to disagree + /// with the cache. + /// + /// The sound never comes through here: [`open_audio`] is given the + /// project's own source path, so a mix is the film's however this answers. + pub fn picture_path(&self, source: usize) -> PathBuf { + let path = &self.project.sources()[source].path; + let Some(proxy) = self.proxies.then(|| crate::proxy::cached(path)).flatten() else { + return path.clone(); + }; + // Said out loud, once per span opened, because "the picture came off + // the stand-in and the delivery did not" is a claim somebody has to be + // able to check: `export` prints the file *it* reads by the same rule. + eprintln!("picture: proxy {}", proxy.display()); + proxy + } + + /// Whether the picture comes off the stand-ins ([`Self::set_proxies`]). + pub fn proxies(&self) -> bool { + self.proxies + } + + /// Cut on the stand-ins, or on the films themselves. Reseeks, so the very + /// next picture comes from the other file -- which is what makes this a + /// switch a person can flip while watching. + /// + /// Says nothing about *which* films have one: a source with no stand-in + /// keeps playing its own pictures either way, and one made while this is on + /// is picked up at the next seek. + pub fn set_proxies(&mut self, on: bool) { + if self.proxies == on { + return; + } + self.proxies = on; + let now = self.now(); + self.seek(now); + } + /// Which source `path` is, canonicalising only if it has to: a source's own /// path is canonical ([`Source::new`]), so a caller handing one back from /// [`sources`](Self::sources) -- which is every library row -- hits on the diff --git a/crates/engine/tests/export.rs b/crates/engine/tests/export.rs index c59aeb7..08902cd 100644 --- a/crates/engine/tests/export.rs +++ b/crates/engine/tests/export.rs @@ -930,6 +930,48 @@ fn a_proxy_is_picture_only_every_frame_a_starting_point_and_cached() { let session = PlaybackSession::open(&made).expect("play the proxy"); assert_eq!(session.meta().frame_count, source_meta.frame_count); + // ...and a session on the *film* plays it instead once the switch is on, + // while the film is still the only thing the project names -- which is what + // an export reads and why an export can never come off a stand-in. + let mut session = PlaybackSession::open(&source).expect("open the film"); + // The film as the project names it: canonical ([`Source::new`]), which the + // proxy key resolves to as well -- the same file under two names is one + // stand-in. + let film = session.sources()[0].path.clone(); + assert_eq!(session.picture_path(0), film, "off: the film itself"); + session.set_proxies(true); + assert!(session.proxies()); + assert_eq!(session.picture_path(0), made, "on: the stand-in"); + assert_eq!( + session.sources()[0].path, + film, + "the project still names the film, and that is what an export reads" + ); + // A frame really arrives from it: the switch reseeks, so the picture after + // it is the proxy's. + let started = Instant::now(); + while session.try_frame().is_none() { + assert!( + started.elapsed() < Duration::from_secs(10), + "no picture after switching to the stand-in" + ); + std::thread::sleep(Duration::from_millis(10)); + } + session.set_proxies(false); + assert_eq!(session.picture_path(0), film, "and back again"); + + // The switch survives a save and a load, and a project written before there + // were stand-ins opens on its films. + let project = Scratch::file("ve_proxy_switch", "edith"); + session.set_proxies(true); + session.save_project(&project).expect("save"); + let text = std::fs::read_to_string(&project).expect("read the project back"); + assert!(text.starts_with("edith 12\n"), "{text}"); + assert!(text.contains("\nproxy on\n"), "{text}"); + let reopened = PlaybackSession::open_project(&project).expect("load"); + assert!(reopened.proxies(), "the switch came back on"); + assert_eq!(reopened.picture_path(0), made, "and it is substituting"); + // Asked again, it is the file already there: no second encode. let again = engine::proxy::generate(&source).expect("ask again"); assert!(again.is_finished(), "a cached proxy is done on the spot"); diff --git a/crates/engine/tests/saveload.rs b/crates/engine/tests/saveload.rs index 10d52fd..fa70bb9 100644 --- a/crates/engine/tests/saveload.rs +++ b/crates/engine/tests/saveload.rs @@ -208,7 +208,7 @@ fn a_version_1_project_loads_fully_grouped_and_saves_as_version_7() { let v2 = dir.join("new.edith"); loaded.save_project(&v2).expect("save"); let text = std::fs::read_to_string(&v2).expect("read back"); - assert!(text.starts_with("edith 11\n"), "{text}"); + assert!(text.starts_with("edith 12\n"), "{text}"); assert!( text.contains("\nresolution 1280 720\n"), "a project with no resolution of its own is saved at source 0's: {text}" @@ -296,7 +296,7 @@ fn a_version_4_project_holds_more_than_two_lanes() { loaded.save_project(&again).expect("save"); assert_eq!( std::fs::read_to_string(&again).expect("read back"), - "edith 11\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\ + "edith 12\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\ video 1 0 0 30 0 3 - - fit 1000\naudio 1\n\ video 2 40 0 20 0 - - - fit 1000\naudio 2 0 0 30 0 3 - - fit 1000\n", "a four-lane project is written as it was read, three versions on" @@ -326,7 +326,7 @@ fn a_version_5_project_carries_per_clip_equalizers() { loaded.save_project(&again).expect("save"); assert_eq!( std::fs::read_to_string(&again).expect("read back"), - "edith 11\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\ + "edith 12\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\ eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\ eq 12000.0:6.25:0.5:hs\n\ video 1 0 0 30 0 - 0 - fit 1000\nvideo 1 30 30 60 0 - 1 - fit 1000\n\ @@ -361,7 +361,7 @@ fn a_version_6_project_carries_per_clip_colours() { loaded.save_project(&again).expect("save"); assert_eq!( std::fs::read_to_string(&again).expect("read back"), - "edith 11\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\ + "edith 12\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\ eq 80.0:-3.0:0.707:ls\n\ color 0.1:1.2:0.9:-0.3\n\ color -0.25:1.0:0.0:0.5\n\ @@ -411,7 +411,7 @@ fn a_version_7_project_carries_a_resolution_and_fit_policies() { loaded.save_project(&again).expect("save"); assert_eq!( std::fs::read_to_string(&again).expect("read back"), - "edith 11\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\ + "edith 12\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\ video 1 0 0 30 0 - - - fill 1000\nvideo 1 30 30 60 0 - - - center 1000\n\ audio 1 0 0 60 0 - - - fit 1000\n", "a v7 project is written back as the v8 it now is: the same clips, each \ @@ -669,7 +669,7 @@ fn malformed_files_are_numbered_errors_and_never_panics() { for (text, want) in [ ( - "edith 12\nsource 0 test_av.mp4\nvideo 1 0 0 30 0 - - - fit\n", + "edith 13\nsource 0 test_av.mp4\nvideo 1 0 0 30 0 - - - fit\n", "line 1", ), // An eq index the table does not hold, and a band shape there is none. diff --git a/crates/engine/tests/silence.rs b/crates/engine/tests/silence.rs index 9134bbf..fe52fd9 100644 --- a/crates/engine/tests/silence.rs +++ b/crates/engine/tests/silence.rs @@ -376,13 +376,14 @@ fn scanning_a_clip_and_cutting_what_it_finds() { (1920, 1080), None, p.tone(), + false, p.limiter(), 0, ) .expect("save"); let text = std::fs::read_to_string(&file).expect("read it back"); assert!( - text.starts_with("edith 11"), + text.starts_with("edith 12"), "{:?}", &text[..16.min(text.len())] ); diff --git a/crates/engine/tests/subtitles.rs b/crates/engine/tests/subtitles.rs index dd41649..8aa9805 100644 --- a/crates/engine/tests/subtitles.rs +++ b/crates/engine/tests/subtitles.rs @@ -259,7 +259,7 @@ fn a_project_keeps_its_subtitles_across_a_save() { let project = dir.join("cut.edith"); session.save_project(&project).expect("save"); let text = std::fs::read_to_string(&project).expect("read the project back"); - assert!(text.starts_with("edith 11\n"), "{text}"); + assert!(text.starts_with("edith 12\n"), "{text}"); assert!( text.contains("\nsubtitle - test_subs.srt\n"), "the reference is written relative, and no cue is: {text}"