forge
Explore
Log in

Don't you dare go Hollow

The stand-ins are made when a project asks, not whenever a big film arrives

Browse files at this commit

269b0c24bc2f5462dadf11598cee2fcb86500fa6Ahmet Kaan GümüşParent: db032d5
  • feat
    • the stand-ins are made when a project asks, not whenever a big film arrives
Show full message
✨ feat(app): the stand-ins are made when a project asks, not whenever a big film arrives

A project now says whether an import makes a proxy by itself. On is the
default and the line left out, so every project that came before behaves
exactly as it did; off makes nothing at all, and turning Proxies on is
what asks for the ones the project is missing -- the only ask there is,
since no per-source item exists.

The file grows an `autoproxy` line and the version goes to 13: a v12
project makes them by itself, which is all any project could do.

The switch is a button beside Proxies in the PROJECT panel, ctrl+o, and
a row on the actions card -- the three doors together, as the two
sync tests require.
crates/app/src/keymap.rsmodified+18 -1
@@ -115,6 +115,11 @@ actions! {
115115 /// else -- the sound and every export stay the film's whichever way it
116116 /// is set.
117117 ToggleProxies,
118+ /// Whether a film that wants a stand-in gets one made as it is imported
119+ /// ([`engine::proxy::wanted`]): what is *encoded*, where the switch above
120+ /// is what is decoded. With it off the switch above is also the ask -- it
121+ /// starts the ones the project is missing.
122+ ToggleAutoProxies,
118123 /// The window's own colours, which belong to the person looking at them and
119124 /// not to the project: a list of the palettes, opened here and from the
120125 /// toolbar's Theme button. It was a build feature once, which made it a
@@ -179,6 +184,7 @@ impl ActionId {
179184 ActionId::ToggleSnap => "Snap on / off (edges, the playhead, the start)",
180185 ActionId::ToggleSubtitles => "Subtitles on / off over the picture",
181186 ActionId::ToggleProxies => "Proxies on / off for the picture",
187+ ActionId::ToggleAutoProxies => "Make proxies on import: on / off",
182188 ActionId::Theme => "Theme: the window's colours…",
183189 ActionId::CancelExport => "Cancel export",
184190 ActionId::ShowActions => "All actions and their keys…",
@@ -234,6 +240,7 @@ impl ActionId {
234240 ActionId::ToggleSnap => "toggle-snap",
235241 ActionId::ToggleSubtitles => "toggle-subtitles",
236242 ActionId::ToggleProxies => "toggle-proxies",
243+ ActionId::ToggleAutoProxies => "toggle-auto-proxies",
237244 ActionId::Theme => "theme",
238245 ActionId::CancelExport => "cancel-export",
239246 ActionId::ShowActions => "show-actions",
@@ -290,6 +297,10 @@ impl ActionId {
290297 // nothing that is saved and nothing that is exported: a stand-in
291298 // is what one watches while cutting, not what one delivers.
292299 | ActionId::ToggleProxies
300+ // ...and whether those stand-ins are made without being asked: the
301+ // other half of the same switch, filed beside it so a card reader
302+ // meets the pair the panel shows as a pair.
303+ | ActionId::ToggleAutoProxies
293304 // ...and what the whole window is painted in: it edits nothing at
294305 // all, it is what one is looking *with*.
295306 | ActionId::Theme => Category::View,
@@ -827,6 +838,11 @@ impl Keymap {
827838 // thrown once for a whole session rather than one wanted under
828839 // a hand -- the theme takes ctrl+h for that reason.
829840 b(ActionId::ToggleProxies, "p", true),
841+ // Making them takes the key next to it, ctrl+o: the pair is one
842+ // subject and the two chords are under the same finger, and
843+ // every letter of the word itself is spoken for ("a" adds an
844+ // audio lane, ctrl+a removes one).
845+ b(ActionId::ToggleAutoProxies, "o", true),
830846 // The theme takes ctrl+h -- the h of the word, since "t" is the
831847 // subtitles and ctrl+t takes one off -- and a ctrl chord because
832848 // it is a preference set once, not a stroke wanted under a hand
@@ -1101,8 +1117,9 @@ mod tests {
11011117 #[test]
11021118 fn every_default_stroke_reaches_its_action() {
11031119 let k = Keymap::defaults();
1104- assert_eq!(k.entries().len(), 50);
1120+ assert_eq!(k.entries().len(), 51);
11051121 assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies));
1122+ assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies));
11061123 assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions));
11071124 assert_eq!(k.lookup("h", true), Some(ActionId::Theme));
11081125 assert_eq!(k.lookup("space", false), Some(ActionId::Play));
crates/app/src/player/actions.rsmodified+1 -0
@@ -88,6 +88,7 @@ impl Player {
8888 ActionId::ToggleSnap => self.toggle_snap(cx),
8989 ActionId::ToggleSubtitles => self.toggle_subtitles(cx),
9090 ActionId::ToggleProxies => self.toggle_proxies(cx),
91+ ActionId::ToggleAutoProxies => self.toggle_auto_proxies(cx),
9192 // The keyboard's door to the same list the toolbar button opens.
9293 // At the window's corner, since a stroke names no place -- and
9394 // [`menu_at`] keeps it on screen from there.
crates/app/src/player/export.rsmodified+13 -1
@@ -117,7 +117,19 @@ impl Player {
117117 // walk above is -- the decision reads the same header -- and the encode
118118 // itself is the engine's own worker, so what comes back here is a
119119 // handle to poll and not a wait.
120- for path in unseen_paths(session.sources(), &self.proxies) {
120+ //
121+ // ...unless this project makes none by itself
122+ // ([`engine::PlaybackSession::auto_proxies`]), and then the Proxies
123+ // switch is the ask: turning it on brings the films that want a
124+ // stand-in through here at the next repaint, which is the only door
125+ // there is. Left unseen meanwhile, so nothing is missed by having been
126+ // imported while the switch was off.
127+ for path in proxies_to_start(
128+ session.auto_proxies(),
129+ session.proxies(),
130+ session.sources(),
131+ &self.proxies,
132+ ) {
121133 // Two at a time, and the rest at the next repaint: a stand-in is a
122134 // whole film re-encoded, and a library of ten dropped at once would
123135 // otherwise start ten encodes fighting over the one hardware seat.
crates/app/src/player/library.rsmodified+23 -0
@@ -414,6 +414,29 @@ impl Player {
414414 cx.notify();
415415 }
416416
417+ /// Makes the stand-ins as the films arrive, or makes none until they are
418+ /// asked for. The other half of the switch above: this one decides what is
419+ /// *encoded*, that one what is *watched*.
420+ ///
421+ /// With it off nothing is started by an import at all -- turning Proxies on
422+ /// is what asks for the ones this project needs ([`Player::cache_media`]),
423+ /// which is said here because a switch whose only effect is elsewhere is a
424+ /// switch that reads as doing nothing.
425+ pub(crate) fn toggle_auto_proxies(&mut self, cx: &mut Context<Self>) {
426+ let Some(session) = &mut self.session else {
427+ return;
428+ };
429+ let on = !session.auto_proxies();
430+ session.set_auto_proxies(on);
431+ let text = match on {
432+ true => "AUTO PROXIES ON — a film that wants a stand-in gets one as it arrives",
433+ false => "AUTO PROXIES OFF — no import makes one; Proxies on is what asks for them",
434+ };
435+ eprintln!("{text}");
436+ self.notify_user(text.into());
437+ cx.notify();
438+ }
439+
417440 pub(crate) fn poll_import(&mut self, cx: &mut Context<Self>) {
418441 match &mut self.importing {
419442 Some(import) => {
crates/app/src/subs.rsmodified+20 -0
@@ -579,6 +579,26 @@ pub(crate) fn unseen_paths<V>(sources: &[Source], seen: &HashMap<PathBuf, V>) ->
579579 out
580580 }
581581
582+/// The films a repaint may start a stand-in for ([`engine::proxy`]): the unseen
583+/// ones while this project makes them by itself, and **none at all** while it
584+/// does not -- until the Proxies switch is thrown, which is the ask, since
585+/// nothing else offers to make one.
586+///
587+/// A film left out here stays out of the map it was checked against, which is
588+/// what brings it back the moment either switch says yes: an import made while
589+/// both were off is not a film that missed its turn.
590+pub(crate) fn proxies_to_start<V>(
591+ auto: bool,
592+ cut_on_them: bool,
593+ sources: &[Source],
594+ seen: &HashMap<PathBuf, V>,
595+) -> Vec<PathBuf> {
596+ match auto || cut_on_them {
597+ true => unseen_paths(sources, seen),
598+ false => Vec::new(),
599+ }
600+}
601+
582602 /// Which timeline frame the playhead is on, by the rule the engine's own edits
583603 /// use (playback.rs `secs_to_frame`): the frame that has started, with the
584604 /// epsilon that keeps a clock sitting exactly on a boundary from reading as the
crates/app/src/tests/editing.rsmodified+30 -0
@@ -1516,6 +1516,36 @@ fn a_source_is_only_ever_asked_for_its_peaks_once() {
15161516 assert_eq!(unseen_paths(&sources, &streams).len(), 1);
15171517 }
15181518
1519+/// The auto switch, which is the whole of what an import asks: with it off no
1520+/// film is handed to [`engine::proxy`] at all, and turning Proxies on is what
1521+/// asks for the ones the project is missing -- there is no other door, so a
1522+/// project that never wants a stand-in never spends a minute encoding one.
1523+#[test]
1524+fn a_project_that_makes_no_proxies_by_itself_starts_none_until_it_is_cut_on_them() {
1525+ let sources = [Source {
1526+ path: asset("test_av.mp4"),
1527+ audio_stream: 0,
1528+ }];
1529+ let none: HashMap<PathBuf, ()> = HashMap::new();
1530+ let one = vec![asset("test_av.mp4")];
1531+ // Today's behaviour, both ways round: auto on starts them whether or not
1532+ // the picture is cut on them -- the cache is warmed for later.
1533+ assert_eq!(proxies_to_start(true, false, &sources, &none), one);
1534+ assert_eq!(proxies_to_start(true, true, &sources, &none), one);
1535+ // Auto off and not cut on them: nothing is started at all.
1536+ assert!(
1537+ proxies_to_start(false, false, &sources, &none).is_empty(),
1538+ "an import started a stand-in the project asked it not to"
1539+ );
1540+ // ...and the switch is the ask: the film comes through the moment Proxies
1541+ // goes on, because it was left unseen rather than marked done.
1542+ assert_eq!(proxies_to_start(false, true, &sources, &none), one);
1543+ // One start per film either way: a film already in the map is one already
1544+ // asked about, sixty repaints a second notwithstanding.
1545+ let seen: HashMap<PathBuf, ()> = HashMap::from([(asset("test_av.mp4"), ())]);
1546+ assert!(proxies_to_start(true, true, &sources, &seen).is_empty());
1547+}
1548+
15191549 #[test]
15201550 fn the_add_button_is_dead_unless_it_would_do_something() {
15211551 let picked = (PathBuf::from("/m/0.mp4"), 0);
crates/app/src/tests/mod.rsmodified+1 -1
@@ -34,7 +34,7 @@ use super::{
3434 SUB_PLAN_CHARS, source_tint, span_partner, speed_at, sub_pick_after_removal, subtitle_plan, summary_head, summary_tail, timecode, transport,
3535 EXPORT_DONE, NOTICES_MAX, STATUS_ERROR, TIMELINE_FIXED_H, TIMELINE_SHARE, lanes_shown,
3636 px_below, rows_below, STATUS_SUCCESS, STATUS_WARNING, notice_tone,
37- push_notice, typed, unseen_paths, unseen_sources,
37+ proxies_to_start, push_notice, typed, unseen_paths, unseen_sources,
3838 whole_take, window_title,
3939 };
4040
crates/app/src/ui/inspector.rsmodified+19 -0
@@ -302,6 +302,25 @@ impl Player {
302302 ActionId::ToggleProxies,
303303 cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_proxies(cx)),
304304 ))
305+ // Beside it, because the two are one subject: that one is
306+ // what the picture is decoded from, this one is whether the
307+ // stand-in is ever made. Two states and no cycle, the rule
308+ // the switch beside it keeps.
309+ .child(self.action_control(
310+ "auto-proxies",
311+ TONE_SLOT_W,
312+ BG_RAISED(),
313+ None,
314+ match self.session.as_ref().map(PlaybackSession::auto_proxies) {
315+ Some(true) => "Auto proxies on",
316+ Some(false) => "Auto proxies off",
317+ None => "Auto proxies",
318+ },
319+ "makes a stand-in for every big film as it is imported; with it off, \
320+ turning Proxies on is what asks for them",
321+ ActionId::ToggleAutoProxies,
322+ cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_auto_proxies(cx)),
323+ ))
305324 .child(self.action_control(
306325 "inspect-mix",
307326 0.,
crates/engine/src/edith.rsmodified+144 -24
@@ -1,12 +1,13 @@
11 //! The project file: a line of text per thing, and nothing else.
22 //!
33 //! ```text
4-//! edith 12
4+//! edith 13
55 //! playhead 90
66 //! resolution 1920 1080
77 //! fps 30.0
88 //! tonemap vivid
99 //! proxy on
10+//! autoproxy off
1011 //! limiter -1.0 on
1112 //! source 0 test_av.mp4
1213 //! source 1 /elsewhere/test_av2.mp4
@@ -52,6 +53,14 @@
5253 //! film's own path, length and modification time, so the cache is the only
5354 //! answer and a project file cannot go stale about it.
5455 //!
56+//! The `autoproxy` line is whether a film this machine cuts slowly gets a
57+//! stand-in made for it the moment it is imported ([`crate::proxy::wanted`]),
58+//! spelled `on` or `off`. Left out when it is on, which is what every dialect
59+//! before v13 did and could not be told not to. With it off an import makes
60+//! nothing at all, and turning the `proxy` switch on is what asks for the
61+//! stand-ins this project is missing -- which is the only way to ask, so a
62+//! project that never wants them never spends a minute of encode on one.
63+//!
5564 //! The `limiter` line is the master limiter over the whole mix
5665 //! ([`crate::limiter`]): its ceiling in dBFS and whether it is in circuit,
5766 //! spelled `on` or `off`. Left out when it is the default, which is off.
@@ -108,7 +117,10 @@
108117 //! is the only way an empty lane could still be there on the way back. A lane
109118 //! number may not skip one of its kind.
110119 //!
111-//! **Version 11** was this without the `proxy` line: such a project is cut on
120+//! **Version 12** was this without the `autoproxy` line: such a project makes a
121+//! stand-in for every film that wants one the moment it arrives, which is all
122+//! any project could do.
123+//! **Version 11** was that without the `proxy` line: such a project is cut on
112124 //! its films themselves, which is all any project could do.
113125 //! **Version 10** was that without the `tonemap` line: such a project is shown
114126 //! in the reference rendition, which is the only one there was.
@@ -133,7 +145,7 @@
133145 //! what a v1 timeline meant, and an older file simply equalizes and grades
134146 //! nothing, and an older one plays everything at real time, and an older one
135147 //! mixes flat, and an older one shows no subtitles, and an older one is shown
136-//! in the reference rendition -- and saving any of them writes v11. An older
148+//! in the reference rendition -- and saving any of them writes v13. An older
137149 //! reader refuses a newer file by name.
138150 //!
139151 //! Text because an edit list is a few integers and a path, and a path is
@@ -169,7 +181,8 @@ use crate::subtitle::SubtitleTrack;
169181
170182 /// What [`save`] writes. Read support goes back to `edith 1`; see the module
171183 /// docs for what those dialects looked like.
172-const MAGIC: &[u8] = b"edith 12";
184+const MAGIC: &[u8] = b"edith 13";
185+const MAGIC_V12: &[u8] = b"edith 12";
173186 const MAGIC_V11: &[u8] = b"edith 11";
174187 const MAGIC_V10: &[u8] = b"edith 10";
175188 const MAGIC_V9: &[u8] = b"edith 9";
@@ -230,6 +243,11 @@ pub struct Document {
230243 /// out, which both mean the films themselves -- the only thing those
231244 /// projects could do.
232245 pub proxy: bool,
246+ /// Whether an import makes a stand-in for a film that wants one by itself
247+ /// ([`crate::proxy`]). `true` for every dialect before v13 and for a v13
248+ /// file that leaves the line out, which both mean by itself -- the only
249+ /// thing those projects did.
250+ pub auto_proxy: bool,
233251 pub playhead: u32,
234252 }
235253
@@ -250,6 +268,7 @@ pub fn save(
250268 fps: Option<f64>,
251269 tone: crate::tonemap::Preset,
252270 proxy: bool,
271+ auto_proxy: bool,
253272 limiter: Limiter,
254273 playhead: u32,
255274 ) -> crate::Result<()> {
@@ -265,7 +284,7 @@ pub fn save(
265284 .and_then(|mut f| {
266285 f.write_all(&emit(
267286 &dir, sources, lanes, gains, subtitles, eq, color, resolution, fps, tone, proxy,
268- limiter, playhead,
287+ auto_proxy, limiter, playhead,
269288 ))?;
270289 f.sync_all()
271290 })
@@ -309,6 +328,7 @@ fn emit(
309328 fps: Option<f64>,
310329 tone: crate::tonemap::Preset,
311330 proxy: bool,
331+ auto_proxy: bool,
312332 limiter: Limiter,
313333 playhead: u32,
314334 ) -> Vec<u8> {
@@ -333,6 +353,12 @@ fn emit(
333353 if proxy {
334354 out.extend_from_slice(b"proxy on\n");
335355 }
356+ // Beside it and by the same rule the other way up: making them by itself is
357+ // what every project before this line did, so only a project told to stop
358+ // has anything to say here.
359+ if !auto_proxy {
360+ out.extend_from_slice(b"autoproxy off\n");
361+ }
336362 // Written only when it is not the default, so a project nobody has limited
337363 // is the same bytes it was in v8 bar the version line.
338364 if limiter != Limiter::default() {
@@ -462,8 +488,10 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
462488 // The dialects that wrote a source line without its stream field. Reading
463489 // one is the whole of what "an old project still opens" means here.
464490 let streamless = v1 || first == MAGIC_V2;
465- // The one that says whether it is cut on stand-ins...
466- let v12 = first == MAGIC;
491+ // The one that says whether the stand-ins are made by themselves...
492+ let v13 = first == MAGIC;
493+ // ...the ones that say whether it is cut on stand-ins...
494+ let v12 = v13 || first == MAGIC_V12;
467495 // ...the ones that carry an HDR rendition...
468496 let v11 = v12 || first == MAGIC_V11;
469497 // ...the ones that carry subtitle tracks...
@@ -513,6 +541,10 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
513541 limiter: Limiter::default(),
514542 tone: crate::tonemap::Preset::default(),
515543 proxy: false,
544+ // ...and nothing before v13 could be told *not* to make one: an import
545+ // that wanted a stand-in got one, which is what leaving the line out
546+ // still means.
547+ auto_proxy: true,
516548 fps: None,
517549 playhead: 0,
518550 };
@@ -602,6 +634,25 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
602634 }
603635 };
604636 }
637+ b"autoproxy" if v13 => {
638+ if !doc.sources.is_empty() {
639+ return Err(
640+ format!("line {n}: autoproxy belongs once, before the sources").into(),
641+ );
642+ }
643+ let f = fields(rest, 1, "autoproxy", n)?;
644+ doc.auto_proxy = match f[0] {
645+ b"on" => true,
646+ b"off" => false,
647+ other => {
648+ return Err(format!(
649+ "line {n}: autoproxy is on or off, not {:?}",
650+ String::from_utf8_lossy(other)
651+ )
652+ .into());
653+ }
654+ };
655+ }
605656 b"limiter" if v9 => {
606657 if !doc.sources.is_empty() {
607658 return Err(
@@ -1122,6 +1173,7 @@ mod tests {
11221173 None,
11231174 crate::tonemap::Preset::default(),
11241175 false,
1176+ true,
11251177 Limiter::default(),
11261178 playhead,
11271179 )
@@ -1166,6 +1218,7 @@ mod tests {
11661218 None,
11671219 crate::tonemap::Preset::default(),
11681220 false,
1221+ true,
11691222 Limiter::default(),
11701223 0,
11711224 );
@@ -1194,7 +1247,7 @@ mod tests {
11941247 video 1 0 0 30 0 - - - fit 1000\n";
11951248 let old = parse(v9, &dir).expect("v9 still loads");
11961249 assert_eq!(old.subtitles, Vec::new());
1197- assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 12\n"));
1250+ assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 13\n"));
11981251 // ...and the line itself is not a v9 line: a dialect may not be mixed.
11991252 let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir)
12001253 .unwrap_err()
@@ -1230,6 +1283,7 @@ mod tests {
12301283 None,
12311284 crate::tonemap::Preset::default(),
12321285 proxy,
1286+ true,
12331287 Limiter::default(),
12341288 0,
12351289 )
@@ -1261,7 +1315,7 @@ mod tests {
12611315 assert_eq!(mixed, "line 3: unknown keyword \"proxy\"");
12621316 // Anything but on or off is a corrupt line, by name.
12631317 for line in ["proxy\n", "proxy yes\n", "proxy On\n"] {
1264- let file = format!("edith 12\nsource 0 a.mp4\n{line}");
1318+ let file = format!("edith 13\nsource 0 a.mp4\n{line}");
12651319 assert!(
12661320 parse(file.as_bytes(), &dir).is_err(),
12671321 "{line:?} is not a proxy line"
@@ -1269,6 +1323,69 @@ mod tests {
12691323 }
12701324 }
12711325
1326+ /// The v13 line: whether an import makes a stand-in by itself. Written the
1327+ /// other way up from every other switch here -- on is the default and the
1328+ /// line left out -- because that is what every dialect before it did, and a
1329+ /// v12 file must come back doing it.
1330+ #[test]
1331+ fn the_auto_proxy_switch_round_trips_and_a_v12_file_makes_them_by_itself() {
1332+ let dir = PathBuf::from("/proj");
1333+ let (_, sources, lanes) = doc();
1334+ let bytes = |proxy, auto| {
1335+ super::emit(
1336+ &dir,
1337+ &sources,
1338+ &lanes,
1339+ &[],
1340+ &[],
1341+ &[],
1342+ &[],
1343+ (1280, 720),
1344+ None,
1345+ crate::tonemap::Preset::default(),
1346+ proxy,
1347+ auto,
1348+ Limiter::default(),
1349+ 0,
1350+ )
1351+ };
1352+ // The default is the line left out, and the two switches are two lines:
1353+ // a project cut on stand-ins it does not make writes both.
1354+ let on = bytes(false, true);
1355+ assert!(
1356+ !String::from_utf8_lossy(&on).contains("autoproxy"),
1357+ "on is the line left out: {}",
1358+ String::from_utf8_lossy(&on)
1359+ );
1360+ assert!(parse(&on, &dir).expect("v13 parses").auto_proxy);
1361+ let off = bytes(true, false);
1362+ let text = String::from_utf8_lossy(&off).to_string();
1363+ assert!(text.contains("proxy on\nautoproxy off\n"), "{text}");
1364+ let back = parse(&off, &dir).expect("v13 parses");
1365+ assert!(back.proxy, "the other switch came back too");
1366+ assert!(!back.auto_proxy);
1367+
1368+ // A v12 project made them by itself and could not be told otherwise.
1369+ let v12 = b"edith 12\nplayhead 0\nresolution 1280 720\nproxy on\nsource 0 a.mp4\n\
1370+ video 1 0 0 30 0 - - - fit 1000\n";
1371+ let old = parse(v12, &dir).expect("v12 still loads");
1372+ assert!(old.auto_proxy, "a v12 project made its stand-ins by itself");
1373+ assert!(old.proxy, "the rest of it came back too");
1374+ // ...and the line is not a v12 line: a dialect may not be mixed.
1375+ let mixed = parse(b"edith 12\nsource 0 a.mp4\nautoproxy off\n", &dir)
1376+ .unwrap_err()
1377+ .to_string();
1378+ assert_eq!(mixed, "line 3: unknown keyword \"autoproxy\"");
1379+ // Anything but on or off is a corrupt line, by name.
1380+ for line in ["autoproxy\n", "autoproxy no\n", "autoproxy Off\n"] {
1381+ let file = format!("edith 13\nsource 0 a.mp4\n{line}");
1382+ assert!(
1383+ parse(file.as_bytes(), &dir).is_err(),
1384+ "{line:?} is not an autoproxy line"
1385+ );
1386+ }
1387+ }
1388+
12721389 /// The v11 line: the HDR rendition, written by name, read back as the very
12731390 /// preset -- and the dialect before it, which had no way to say one and
12741391 /// meant the published conversion.
@@ -1289,6 +1406,7 @@ mod tests {
12891406 None,
12901407 preset,
12911408 false,
1409+ true,
12921410 Limiter::default(),
12931411 0,
12941412 );
@@ -1383,7 +1501,7 @@ mod tests {
13831501 let bytes = flat(&dir, &sources, &lanes, 12);
13841502 assert_eq!(
13851503 String::from_utf8_lossy(&bytes),
1386- "edith 12\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
1504+ "edith 13\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
13871505 source 2 /elsewhere/b.mp4\n\
13881506 video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\
13891507 audio 1 0 0 30 0 0 - - fit 1000\n",
@@ -1420,7 +1538,7 @@ mod tests {
14201538 let bytes = flat(&dir, &sources, &lanes, 7);
14211539 assert_eq!(
14221540 String::from_utf8_lossy(&bytes),
1423- "edith 12\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\
1541+ "edith 13\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\
14241542 video 1 0 0 30 0 4 - - fit 1000\naudio 1\n\
14251543 video 2 40 0 10 0 - - - fit 1000\naudio 2 0 0 30 0 4 - - fit 1000\n",
14261544 "an empty lane is a line of its own; everything else is its clips"
@@ -1528,7 +1646,7 @@ mod tests {
15281646 let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0);
15291647 assert_eq!(
15301648 String::from_utf8_lossy(&bytes),
1531- "edith 12\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
1649+ "edith 13\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
15321650 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\
15331651 eq 16777215.0:-0.1:3.918315e-39:hs\n\
15341652 eq\n\
@@ -1632,7 +1750,7 @@ mod tests {
16321750 let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0);
16331751 assert_eq!(
16341752 String::from_utf8_lossy(&bytes),
1635- "edith 12\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
1753+ "edith 13\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
16361754 color 0.1:1.2:0.9:-0.3\n\
16371755 color -1e-7:16777215.0:3.918315e-39:-0.0\n\
16381756 color 0.0:1.0:1.0:0.0\n\
@@ -1697,7 +1815,7 @@ mod tests {
16971815 (1280, 720),
16981816 old.playhead
16991817 )),
1700- "edith 12\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
1818+ "edith 13\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
17011819 eq 80.0:-3.0:0.707:ls\n\
17021820 video 1 0 0 30 0 0 0 - fit 1000\naudio 1 0 0 30 0 0 - - fit 1000\n"
17031821 );
@@ -1735,7 +1853,7 @@ mod tests {
17351853 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);
17361854 assert_eq!(
17371855 String::from_utf8_lossy(&bytes),
1738- "edith 12\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
1856+ "edith 13\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
17391857 video 1 0 0 30 0 - - - fit 2000\nvideo 1 15 30 40 0 - - - fit 250\n\
17401858 audio 1 0 0 30 0 - - - fit 2000\n",
17411859 "the rate is the clip line's last field, in thousandths"
@@ -1764,7 +1882,7 @@ mod tests {
17641882 (1280, 720),
17651883 old.playhead
17661884 )),
1767- "edith 12\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
1885+ "edith 13\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
17681886 video 1 0 0 30 0 0 - - fit 1000\naudio 1 0 0 30 0 0 - - fit 1000\n"
17691887 );
17701888 // A rate outside what the editor can set is a corrupt line, by name.
@@ -1806,12 +1924,13 @@ mod tests {
18061924 Some(23.976023976023978),
18071925 crate::tonemap::Preset::default(),
18081926 false,
1927+ true,
18091928 limiter,
18101929 0,
18111930 );
18121931 assert_eq!(
18131932 String::from_utf8_lossy(&bytes),
1814- "edith 12\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\
1933+ "edith 13\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\
18151934 limiter -1.5 on\nsource 0 a.mp4\n\
18161935 video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n\
18171936 audio 2 0 0 30 0 - - - fit 1000\n\
@@ -1843,7 +1962,7 @@ mod tests {
18431962 (1280, 720),
18441963 old.playhead
18451964 )),
1846- "edith 12\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
1965+ "edith 13\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
18471966 video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n"
18481967 );
18491968
@@ -2007,7 +2126,7 @@ mod tests {
20072126 assert!(old.eq.is_empty(), "nothing before v5 equalizes anything");
20082127 assert_eq!(
20092128 String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)),
2010- "edith 12\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
2129+ "edith 13\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
20112130 source 2 /elsewhere/b.mp4\n\
20122131 video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\
20132132 audio 1 0 0 30 0 0 - - fit 1000\n"
@@ -2060,7 +2179,7 @@ mod tests {
20602179 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);
20612180 assert_eq!(
20622181 String::from_utf8_lossy(&v5),
2063- "edith 12\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
2182+ "edith 13\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
20642183 source 0 /elsewhere/b.mp4\n\
20652184 video 1 0 0 30 0 0 - - fit 1000\nvideo 1 30 10 20 1 1 - - fit 1000\n\
20662185 audio 1 0 0 30 0 0 - - fit 1000\n",
@@ -2092,7 +2211,7 @@ mod tests {
20922211 // Saved again it is the current version, which round-trips to the
20932212 // same document.
20942213 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);
2095- assert!(v5.starts_with(b"edith 12\n"));
2214+ assert!(v5.starts_with(b"edith 13\n"));
20962215 let again = parse(&v5, &dir).expect("v5 parses");
20972216 assert_eq!(again.lanes, back.lanes);
20982217 // A dialect may not be mixed: lane lines under v1, `clip` under v2.
@@ -2191,6 +2310,7 @@ mod tests {
21912310 None,
21922311 crate::tonemap::Preset::default(),
21932312 false,
2313+ true,
21942314 Limiter::default(),
21952315 0,
21962316 )
@@ -2198,7 +2318,7 @@ mod tests {
21982318 let bytes = std::fs::read(&path).expect("read back");
21992319 assert_eq!(
22002320 String::from_utf8_lossy(&bytes),
2201- "edith 12\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\
2321+ "edith 13\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\
22022322 video 1 0 0 30 0 - - - fit 1000\naudio 1 0 0 30 0 - - - fit 1000\n"
22032323 );
22042324 // Loading rejoins the *given* directory, so the file is reached by the
@@ -2243,10 +2363,10 @@ mod tests {
22432363 #[test]
22442364 fn a_wrong_first_line_is_refused_by_name() {
22452365 let dir = PathBuf::from("/proj");
2246- let err = parse(b"edith 13\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir)
2366+ let err = parse(b"edith 14\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir)
22472367 .unwrap_err()
22482368 .to_string();
2249- assert_eq!(err, "line 1: unsupported version 13");
2369+ assert_eq!(err, "line 1: unsupported version 14");
22502370 for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] {
22512371 assert_eq!(
22522372 parse(junk, &dir).unwrap_err().to_string(),
crates/engine/src/playback.rsmodified+29 -0
@@ -388,6 +388,12 @@ pub struct PlaybackSession {
388388 /// file open that already costs milliseconds, so a proxy made (or deleted)
389389 /// mid-session is picked up at the next seek and nothing can go stale.
390390 proxies: bool,
391+ /// Whether a source that wants a stand-in gets one made for it as it
392+ /// arrives ([`crate::proxy::wanted`]). On unless a project says otherwise,
393+ /// which is what every project did before the switch existed. Saved with
394+ /// the project like the one above it, and read by the front end: the engine
395+ /// starts no encode of its own.
396+ auto_proxies: bool,
391397 }
392398
393399 /// What an edit dirtied -- which half of the pipeline has to be rebuilt for the
@@ -505,6 +511,7 @@ impl PlaybackSession {
505511 drop_late: false,
506512 // A file just opened is a project nobody has picked stand-ins for.
507513 proxies: false,
514+ auto_proxies: true,
508515 })
509516 }
510517
@@ -620,6 +627,7 @@ impl PlaybackSession {
620627 drop_late: false,
621628 // A file just opened is a project nobody has picked stand-ins for.
622629 proxies: false,
630+ auto_proxies: true,
623631 })
624632 }
625633
@@ -699,6 +707,7 @@ impl PlaybackSession {
699707 drop_late: false,
700708 // A file just opened is a project nobody has picked stand-ins for.
701709 proxies: false,
710+ auto_proxies: true,
702711 })
703712 }
704713
@@ -996,6 +1005,9 @@ impl PlaybackSession {
9961005 // What the file says, and `false` for every dialect before v12:
9971006 // a project cut on the films themselves opens on them.
9981007 proxies: doc.proxy,
1008+ // ...and what it says about making them, which is "yes" for every
1009+ // dialect before v13 and for one that leaves the line out.
1010+ auto_proxies: doc.auto_proxy,
9991011 };
10001012 // The scaffolding above opened source 0 from its first frame and the
10011013 // whole of its audio; this puts both onto the clip the playhead is
@@ -1251,6 +1263,10 @@ impl PlaybackSession {
12511263 // *Which* files have one is not saved: [`crate::proxy`] finds that
12521264 // out from the film itself, so nothing here can go stale.
12531265 self.proxies,
1266+ // ...and whether it makes them by itself, which is a different
1267+ // question from whether it cuts on them and the only one an import
1268+ // asks ([`Self::auto_proxies`]).
1269+ self.auto_proxies,
12541270 self.project.limiter(),
12551271 playhead,
12561272 )
@@ -1998,6 +2014,19 @@ impl PlaybackSession {
19982014 self.seek(now);
19992015 }
20002016
2017+ /// Whether an imported film that wants a stand-in gets one made for it
2018+ /// there and then ([`Self::set_auto_proxies`]).
2019+ pub fn auto_proxies(&self) -> bool {
2020+ self.auto_proxies
2021+ }
2022+
2023+ /// Make the stand-ins on import, or make none until asked. Nothing to
2024+ /// reseek: this decides what is *started*, never what is decoded -- a proxy
2025+ /// already in the cache is still cut on while [`Self::proxies`] is on.
2026+ pub fn set_auto_proxies(&mut self, on: bool) {
2027+ self.auto_proxies = on;
2028+ }
2029+
20012030 /// Which source `path` is, canonicalising only if it has to: a source's own
20022031 /// path is canonical ([`Source::new`]), so a caller handing one back from
20032032 /// [`sources`](Self::sources) -- which is every library row -- hits on the
crates/engine/tests/export.rsmodified+1 -1
@@ -985,7 +985,7 @@ fn a_proxy_is_picture_only_every_frame_a_starting_point_and_cached() {
985985 session.set_proxies(true);
986986 session.save_project(&project).expect("save");
987987 let text = std::fs::read_to_string(&project).expect("read the project back");
988- assert!(text.starts_with("edith 12\n"), "{text}");
988+ assert!(text.starts_with("edith 13\n"), "{text}");
989989 assert!(text.contains("\nproxy on\n"), "{text}");
990990 let reopened = PlaybackSession::open_project(&project).expect("load");
991991 assert!(reopened.proxies(), "the switch came back on");
crates/engine/tests/saveload.rsmodified+43 -6
@@ -97,6 +97,43 @@ fn a_picked_audio_stream_lands_saves_and_comes_back() {
9797 std::fs::remove_dir_all(&dir).expect("cleanup");
9898 }
9999
100+/// Both stand-in switches through the front door: what the picture is cut on
101+/// and whether an import makes one at all are two settings, saved and reopened
102+/// as the pair they are -- and a session that was never told keeps making them,
103+/// which is what every project did before there was a switch.
104+#[test]
105+fn both_proxy_switches_survive_a_save_and_a_reopen() {
106+ let dir = scratch("proxyswitches");
107+ let media = copy_in(&dir, "test_av.mp4");
108+ let mut session = PlaybackSession::open(&media).expect("open the fixture");
109+ session.set_gain(0.0);
110+ assert!(session.auto_proxies(), "a fresh project makes them by itself");
111+ assert!(!session.proxies(), "and is cut on the film itself");
112+
113+ session.set_proxies(true);
114+ session.set_auto_proxies(false);
115+ let path = dir.join("switches.edith");
116+ session.save_project(&path).expect("save");
117+ let text = std::fs::read_to_string(&path).expect("read back");
118+ assert!(text.contains("proxy on\nautoproxy off\n"), "{text}");
119+
120+ let loaded = PlaybackSession::open_project(&path).expect("reopen");
121+ assert!(loaded.proxies(), "cut on the stand-ins came back");
122+ assert!(!loaded.auto_proxies(), "and so did making none of them");
123+
124+ // ...and the default is the line left out, which is what a v12 file is.
125+ session.set_auto_proxies(true);
126+ session.save_project(&path).expect("save");
127+ let text = std::fs::read_to_string(&path).expect("read back");
128+ assert!(!text.contains("autoproxy"), "on is written by saying nothing");
129+ assert!(
130+ PlaybackSession::open_project(&path)
131+ .expect("reopen")
132+ .auto_proxies()
133+ );
134+ std::fs::remove_dir_all(&dir).expect("cleanup");
135+}
136+
100137 /// Why a trim's tail stops where the file ends: a clip reaching past the last
101138 /// frame of its source is a project that will not open again (`open_project`
102139 /// refuses it by name). Pulled in on both ends and then dragged out as far as
@@ -208,7 +245,7 @@ fn a_version_1_project_loads_fully_grouped_and_saves_as_version_7() {
208245 let v2 = dir.join("new.edith");
209246 loaded.save_project(&v2).expect("save");
210247 let text = std::fs::read_to_string(&v2).expect("read back");
211- assert!(text.starts_with("edith 12\n"), "{text}");
248+ assert!(text.starts_with("edith 13\n"), "{text}");
212249 assert!(
213250 text.contains("\nresolution 1280 720\n"),
214251 "a project with no resolution of its own is saved at source 0's: {text}"
@@ -296,7 +333,7 @@ fn a_version_4_project_holds_more_than_two_lanes() {
296333 loaded.save_project(&again).expect("save");
297334 assert_eq!(
298335 std::fs::read_to_string(&again).expect("read back"),
299- "edith 12\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
336+ "edith 13\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
300337 video 1 0 0 30 0 3 - - fit 1000\naudio 1\n\
301338 video 2 40 0 20 0 - - - fit 1000\naudio 2 0 0 30 0 3 - - fit 1000\n",
302339 "a four-lane project is written as it was read, three versions on"
@@ -326,7 +363,7 @@ fn a_version_5_project_carries_per_clip_equalizers() {
326363 loaded.save_project(&again).expect("save");
327364 assert_eq!(
328365 std::fs::read_to_string(&again).expect("read back"),
329- "edith 12\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
366+ "edith 13\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
330367 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\
331368 eq 12000.0:6.25:0.5:hs\n\
332369 video 1 0 0 30 0 - 0 - fit 1000\nvideo 1 30 30 60 0 - 1 - fit 1000\n\
@@ -361,7 +398,7 @@ fn a_version_6_project_carries_per_clip_colours() {
361398 loaded.save_project(&again).expect("save");
362399 assert_eq!(
363400 std::fs::read_to_string(&again).expect("read back"),
364- "edith 12\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
401+ "edith 13\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
365402 eq 80.0:-3.0:0.707:ls\n\
366403 color 0.1:1.2:0.9:-0.3\n\
367404 color -0.25:1.0:0.0:0.5\n\
@@ -411,7 +448,7 @@ fn a_version_7_project_carries_a_resolution_and_fit_policies() {
411448 loaded.save_project(&again).expect("save");
412449 assert_eq!(
413450 std::fs::read_to_string(&again).expect("read back"),
414- "edith 12\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\
451+ "edith 13\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\
415452 video 1 0 0 30 0 - - - fill 1000\nvideo 1 30 30 60 0 - - - center 1000\n\
416453 audio 1 0 0 60 0 - - - fit 1000\n",
417454 "a v7 project is written back as the v8 it now is: the same clips, each \
@@ -669,7 +706,7 @@ fn malformed_files_are_numbered_errors_and_never_panics() {
669706
670707 for (text, want) in [
671708 (
672- "edith 13\nsource 0 test_av.mp4\nvideo 1 0 0 30 0 - - - fit\n",
709+ "edith 14\nsource 0 test_av.mp4\nvideo 1 0 0 30 0 - - - fit\n",
673710 "line 1",
674711 ),
675712 // An eq index the table does not hold, and a band shape there is none.
crates/engine/tests/silence.rsmodified+2 -1
@@ -377,13 +377,14 @@ fn scanning_a_clip_and_cutting_what_it_finds() {
377377 None,
378378 p.tone(),
379379 false,
380+ true,
380381 p.limiter(),
381382 0,
382383 )
383384 .expect("save");
384385 let text = std::fs::read_to_string(&file).expect("read it back");
385386 assert!(
386- text.starts_with("edith 12"),
387+ text.starts_with("edith 13"),
387388 "{:?}",
388389 &text[..16.min(text.len())]
389390 );
crates/engine/tests/subtitles.rsmodified+1 -1
@@ -259,7 +259,7 @@ fn a_project_keeps_its_subtitles_across_a_save() {
259259 let project = dir.join("cut.edith");
260260 session.save_project(&project).expect("save");
261261 let text = std::fs::read_to_string(&project).expect("read the project back");
262- assert!(text.starts_with("edith 12\n"), "{text}");
262+ assert!(text.starts_with("edith 13\n"), "{text}");
263263 assert!(
264264 text.contains("\nsubtitle - test_subs.srt\n"),
265265 "the reference is written relative, and no cue is: {text}"