diff --git a/crates/engine/src/decode.rs b/crates/engine/src/decode.rs index 710b820..f87b753 100644 --- a/crates/engine/src/decode.rs +++ b/crates/engine/src/decode.rs @@ -630,7 +630,7 @@ impl DecodeSession { transform: TransformParams, canvas: Composer, flags: u8, - paint: u32, + paint: u64, ) -> crate::Result { let (tx, rx) = sync_channel(2); let cancel = Arc::new(AtomicBool::new(false)); @@ -1447,9 +1447,18 @@ pub fn viz_ink_rgb(hue: u8) -> (u8, u8, u8) { } /// Azure + sat 160 + 8 strands + glow 2. What `viz_paint == 0` means. -pub const VIZ_PAINT_AZURE: u32 = 150 | (160 << 8) | (8 << 16) | (2 << 24); - -pub fn viz_materialize(paint: u32) -> u32 { +pub const VIZ_PAINT_AZURE: u64 = 150 | (160 << 8) | (8 << 16) | (2 << 24); + +/// Where the strand colour sits above the clip's own four bytes: hue at 32 +/// and sat at 40, with bit 63 as the flag that says a clip chose one +/// ([`viz_strand_set`]). A clear flag means the automatic complement the +/// ring has always painted -- so a v22 value, whose top half is empty, is +/// nothing new. +const VIZ_STRAND_HUE_SHIFT: u32 = 32; +const VIZ_STRAND_SAT_SHIFT: u32 = 40; +const VIZ_STRAND_CHOSEN: u64 = 1 << 63; + +pub fn viz_materialize(paint: u64) -> u64 { if paint == 0 { VIZ_PAINT_AZURE } else { @@ -1457,42 +1466,42 @@ pub fn viz_materialize(paint: u32) -> u32 { } } -pub fn viz_ink_from_paint(paint: u32) -> (u8, u8, u8) { +pub fn viz_ink_from_paint(paint: u64) -> (u8, u8, u8) { let p = viz_materialize(paint); let hue = (p & 0xFF) as f32 * 360.0 / 256.0; let sat = f32::from(((p >> 8) & 0xFF) as u8) / 255.0; hsv_to_rgb(hue, sat, 0.84) } -pub fn viz_strands_of(paint: u32) -> u8 { +pub fn viz_strands_of(paint: u64) -> u8 { (((viz_materialize(paint) >> 16) & 0xFF) as u8).clamp(1, 32) } -pub fn viz_glow_of(paint: u32) -> u8 { +pub fn viz_glow_of(paint: u64) -> u8 { ((viz_materialize(paint) >> 24) & 0xFF) as u8 } -pub fn with_viz_paint_hue(paint: u32, hue: u8) -> u32 { - (viz_materialize(paint) & !0xFF) | u32::from(hue) +pub fn with_viz_paint_hue(paint: u64, hue: u8) -> u64 { + (viz_materialize(paint) & !0xFF) | u64::from(hue) } -pub fn with_viz_paint_sat(paint: u32, sat: u8) -> u32 { - (viz_materialize(paint) & !(0xFF << 8)) | (u32::from(sat) << 8) +pub fn with_viz_paint_sat(paint: u64, sat: u8) -> u64 { + (viz_materialize(paint) & !(0xFF << 8)) | (u64::from(sat) << 8) } -pub fn with_viz_paint_strands(paint: u32, n: u8) -> u32 { - (viz_materialize(paint) & !(0xFF << 16)) | (u32::from(n.clamp(1, 32)) << 16) +pub fn with_viz_paint_strands(paint: u64, n: u8) -> u64 { + (viz_materialize(paint) & !(0xFF << 16)) | (u64::from(n.clamp(1, 32)) << 16) } -pub fn with_viz_paint_glow(paint: u32, n: u8) -> u32 { - (viz_materialize(paint) & !(0xFF << 24)) | (u32::from(n.min(16)) << 24) +pub fn with_viz_paint_glow(paint: u64, n: u8) -> u64 { + (viz_materialize(paint) & !(0xFF << 24)) | (u64::from(n.min(16)) << 24) } -pub fn viz_hue_ui(paint: u32) -> u8 { +pub fn viz_hue_ui(paint: u64) -> u8 { if paint == 0 { 150 } else { (paint & 0xFF) as u8 } } -pub fn viz_sat_ui(paint: u32) -> u8 { +pub fn viz_sat_ui(paint: u64) -> u8 { if paint == 0 { 160 } else { @@ -1503,6 +1512,135 @@ pub fn viz_sat_ui(paint: u32) -> u8 { } } +/// Whether the clip chose a strand colour of its own (the top bit), rather +/// than taking the automatic complement a ring's dual half has always +/// painted. +pub fn viz_strand_set(paint: u64) -> bool { + paint & VIZ_STRAND_CHOSEN != 0 +} + +/// The chosen strand hue, 0-255 on the wheel [`viz_hue_ui`] reads. +pub fn viz_strand_hue_ui(paint: u64) -> u8 { + ((paint >> VIZ_STRAND_HUE_SHIFT) & 0xFF) as u8 +} + +/// The chosen strand sat, 0-255. A stored zero stays zero here, unlike +/// [`viz_sat_ui`]'s: a grey strand is a colour someone picked, and the flag +/// -- not the byte -- is what says whether there is one. +pub fn viz_strand_sat_ui(paint: u64) -> u8 { + ((paint >> VIZ_STRAND_SAT_SHIFT) & 0xFF) as u8 +} + +/// Set the strand hue and mark the colour chosen, so a ring's dual half +/// inks it instead of the automatic complement. +pub fn with_viz_paint_strand_hue(paint: u64, hue: u8) -> u64 { + let p = viz_materialize(paint) & !(0xFF_u64 << VIZ_STRAND_HUE_SHIFT); + (p | (u64::from(hue) << VIZ_STRAND_HUE_SHIFT)) | VIZ_STRAND_CHOSEN +} + +/// Set the strand sat and mark the colour chosen, as +/// [`with_viz_paint_strand_hue`] does. +pub fn with_viz_paint_strand_sat(paint: u64, sat: u8) -> u64 { + let p = viz_materialize(paint) & !(0xFF_u64 << VIZ_STRAND_SAT_SHIFT); + (p | (u64::from(sat) << VIZ_STRAND_SAT_SHIFT)) | VIZ_STRAND_CHOSEN +} + +/// Drop the chosen strand colour: the dual half of a ring goes back to the +/// automatic complement, and both strand bytes go with the flag. +pub fn viz_strand_clear(paint: u64) -> u64 { + paint & !(VIZ_STRAND_CHOSEN + | (0xFF_u64 << VIZ_STRAND_HUE_SHIFT) + | (0xFF_u64 << VIZ_STRAND_SAT_SHIFT)) +} + +/// `#RRGGBB` for an ink, at the same fixed value the painter draws at, so +/// the swatch a front-end shows is the colour that reaches the picture. +/// The inverse of [`viz_color_from_text`] for the colours a round trip +/// through bytes can carry back. +pub fn viz_color_hex(hue: u8, sat: u8) -> String { + let (r, g, b) = hsv_to_rgb(f32::from(hue) * 360.0 / 256.0, f32::from(sat) / 255.0, 0.84); + format!("#{r:02X}{g:02X}{b:02X}") +} + +/// A colour someone typed -- `#4F8FD6`, `4f8fd6`, `rgb(79,143,214)` or +/// `rgba(79,143,214,255)`, any case, commas or `/` between the channels, +/// alpha ignored -- as the `(hue, sat)` pair the sliders and the paint +/// field speak. `None` for everything else rather than a guess: the wrong +/// number of digits, a channel outside 0-255, parentheses missing. +/// +/// Brightness is dropped, not carried: the painter draws every ink at its +/// own fixed value, so a typed colour is kept by its hue and saturation. +pub fn viz_color_from_text(text: &str) -> Option<(u8, u8)> { + let t = text.trim(); + let (r, g, b) = if let Some(inner) = t.strip_suffix(')') { + let body = if starts_ci(inner, b"rgb(") { + &inner[4..] + } else if starts_ci(inner, b"rgba(") { + &inner[5..] + } else { + return None; + }; + let mut channels = body.split(['/', ',']).map(str::trim); + let r = channel(channels.next()?)?; + let g = channel(channels.next()?)?; + let b = channel(channels.next()?)?; + // Alpha, when it is spelled: read so a bad one is refused like a + // channel is, and dropped -- the paint field has no room for it. + if let Some(a) = channels.next() { + channel(a)?; + } + if channels.next().is_some() { + return None; + } + (r, g, b) + } else { + let hex = t.strip_prefix('#').unwrap_or(t); + if hex.len() != 6 || !hex.bytes().all(|c| c.is_ascii_hexdigit()) { + return None; + } + ( + u8::from_str_radix(&hex[0..2], 16).ok()?, + u8::from_str_radix(&hex[2..4], 16).ok()?, + u8::from_str_radix(&hex[4..6], 16).ok()?, + ) + }; + Some(rgb_to_hue_sat(r, g, b)) +} + +fn starts_ci(text: &str, prefix: &[u8]) -> bool { + text.len() >= prefix.len() && text.as_bytes()[..prefix.len()].eq_ignore_ascii_case(prefix) +} + +/// One 0-255 channel of a typed colour: digits only, so neither a sign nor +/// an exponent slips in the way `u8`'s own parse would take them. +fn channel(text: &str) -> Option { + if text.is_empty() || !text.bytes().all(|b| b.is_ascii_digit()) { + return None; + } + text.parse().ok() +} + +/// What a byte RGB is on the paint field's wheel: hue on [`viz_hue_ui`]'s +/// 0-255 scale, sat 0-255, brightness dropped for the same reason +/// [`viz_color_from_text`] drops the typed one. +fn rgb_to_hue_sat(r: u8, g: u8, b: u8) -> (u8, u8) { + let (r, g, b) = (f32::from(r), f32::from(g), f32::from(b)); + let (max, min) = (r.max(g).max(b), r.min(g).min(b)); + let delta = max - min; + let hue = if delta == 0.0 { + 0.0 + } else if max == r { + 60.0 * ((g - b) / delta).rem_euclid(6.0) + } else if max == g { + 60.0 * ((b - r) / delta + 2.0) + } else { + 60.0 * ((r - g) / delta + 4.0) + }; + let hue = ((hue * 256.0 / 360.0).round() as i64).rem_euclid(256) as u8; + let sat = if max == 0.0 { 0.0 } else { delta / max }; + (hue, (sat * 255.0).round() as u8) +} + pub fn viz_hsv_rgb(h: f32, s: f32, v: f32) -> (u8, u8, u8) { hsv_to_rgb(h, s, v) } @@ -1654,14 +1792,14 @@ fn viz_line( /// One visualizer picture in tightly packed I420. Three looks, picked by /// [`viz_style`]: a bipolar sample trace (Audacity), a filled min/max /// envelope at pixel resolution, or a multi-strand ribbon. Ink is -/// [`viz_ink_rgb`]. A frame always exists; silence is the zero line. +/// [`viz_ink_from_paint`]. A frame always exists; silence is the zero line. pub(crate) fn visualizer_i420( peaks: &[(f32, f32)], t_secs: f64, width: u32, height: u32, flags: u8, - paint: u32, + paint: u64, ) -> (Vec, Vec, Vec) { let width = width & !1; let height = height & !1; @@ -1789,11 +1927,22 @@ pub(crate) fn visualizer_i420( let glow = viz_glow_of(paint); for strand in 0..strands { let dual = strands >= 2 && strand >= strands / 2; - let (ir, ig, ib) = viz_ink_from_paint(if dual { - with_viz_paint_hue(paint, viz_hue_ui(paint).wrapping_add(128)) + // The dual half takes the clip's own strand colour when it + // chose one; without one it is the wheel half a turn from + // the clip's hue, at the clip's own saturation, which is + // the complement every earlier project paints. + let (ir, ig, ib) = if dual && viz_strand_set(paint) { + let hue = f32::from(viz_strand_hue_ui(paint)) * 360.0 / 256.0; + let sat = f32::from(viz_strand_sat_ui(paint)) / 255.0; + hsv_to_rgb(hue, sat, 0.84) + } else if dual { + viz_ink_from_paint(with_viz_paint_hue( + paint, + viz_hue_ui(paint).wrapping_add(128), + )) } else { - paint - }); + viz_ink_from_paint(paint) + }; let (iy, iu, iv) = rgb_yuv(ir as i32, ig as i32, ib as i32); let scale = 0.65 + 0.35 * f32::from(strand % 4) / 3.0; let phase = f32::from(strand) * 0.35; @@ -2211,6 +2360,126 @@ mod tests { } assert!(shifted > 2, "hue 8 did not leave blue"); } + + /// The paint's byte layout: the strand colour lives above the clip's own + /// four bytes and the top bit is the flag, so either strand setter marks + /// the colour chosen and clearing drops both bytes with the flag. + #[test] + fn the_paint_packs_the_strand_colour_above_the_v22_halves() { + let p = with_viz_paint_strand_sat(with_viz_paint_strand_hue(VIZ_PAINT_AZURE, 0xAB), 0xCD); + assert_eq!(p & 0xFFFF_FFFF, VIZ_PAINT_AZURE, "the low half never moves"); + assert_eq!((p >> 32) & 0xFF, 0xAB); + assert_eq!((p >> 40) & 0xFF, 0xCD); + assert!(viz_strand_set(p)); + assert_eq!(viz_strand_hue_ui(p), 0xAB); + assert_eq!(viz_strand_sat_ui(p), 0xCD); + assert_eq!(viz_strand_clear(p), VIZ_PAINT_AZURE); + assert!(!viz_strand_set(viz_strand_clear(p))); + } + + /// The shapes a colour is typed in all mean the same ink, and everything + /// else is refused rather than guessed at. + #[test] + fn typed_colours_read_as_hex_rgb_and_rgba() { + let want = viz_color_from_text("#4F8FD6").expect("a hex colour"); + assert_eq!(want, (150, 161), "hue and sat on the field's own scales"); + for text in [ + "#4F8FD6", + "4f8fd6", + " #4f8fd6 ", + "rgb(79,143,214)", + "rgb(79/143/214)", + "RGBA(79, 143, 214, 255)", + ] { + assert_eq!(viz_color_from_text(text), Some(want), "{text}"); + } + for text in [ + "#12345", + "zz", + "rgb(300,0,0)", + "rgb(1,2)", + "", + "rgb 79,143,214)", + "rgb(79,143,214", + "#4F8FD", + "#4F8FD67", + "#GGGGGG", + "rgb(79,143,214,255,0)", + "rgb(79;143;214)", + ] { + assert_eq!(viz_color_from_text(text), None, "{text}"); + } + } + + /// A colour's hex is the ink the painter draws, and reading it back + /// gives the sliders their own value again -- for the 47053 of the 65536 + /// hues and saturations a trip through bytes can carry. The rest land on + /// a neighbour: their smallest channel rounds to a byte whose ratio is + /// not the one that was asked for. Full saturation is where that channel + /// is the one the value sets exactly, and it survives at every hue. + #[test] + fn a_sampled_palette_round_trips_through_its_hex() { + for hue in (0..=255u8).step_by(8) { + let hex = viz_color_hex(hue, 255); + assert_eq!(viz_color_from_text(&hex), Some((hue, 255)), "{hex}"); + } + // The achromatic end, where hue is not a colour at all. + assert_eq!(viz_color_from_text(&viz_color_hex(0, 0)), Some((0, 0))); + assert_eq!(viz_color_from_text(&viz_color_hex(200, 0)), Some((0, 0))); + // ...and the whole grid, so a change that quietly shrinks what the + // trip can carry cannot pass by leaving the sample above green. + let exact = (0..=255u8) + .flat_map(|hue| (0..=255u8).map(move |sat| (hue, sat))) + .filter(|&(hue, sat)| viz_color_from_text(&viz_color_hex(hue, sat)) == Some((hue, sat))) + .count(); + assert_eq!(exact, 47_053, "the colours a hex round trip keeps"); + } + + /// The dual half of a ring takes the clip's own strand colour when it has + /// one: a choice that names the automatic complement paints the same + /// frame, another repaints the dual strands in it, and a paint whose flag + /// is clear is the picture it has always been -- strand bytes or no. + #[test] + fn a_chosen_strand_colour_repaints_only_the_dual_half_of_a_ring() { + let mut peaks = vec![(0.0, 0.0); 12_000]; + for (i, p) in peaks.iter_mut().enumerate() { + let a = ((i as f32 / 400.0) * std::f32::consts::TAU).sin() * 0.8; + *p = (-a.abs(), a.abs()); + } + let ring = with_viz_style(1, VIZ_STYLE_RING); + let auto = VIZ_PAINT_AZURE; + let (y0, u0, v0) = visualizer_i420(&peaks, 1.0, 320, 180, ring, auto); + + // The automatic dual is half a wheel from the clip's hue at the + // clip's own saturation; choosing exactly that colour changes + // nothing at all. + let same = with_viz_paint_strand_sat( + with_viz_paint_strand_hue(auto, viz_hue_ui(auto).wrapping_add(128)), + viz_sat_ui(auto), + ); + assert!(viz_strand_set(same)); + let (ys, us, vs) = visualizer_i420(&peaks, 1.0, 320, 180, ring, same); + assert_eq!(ys, y0, "the automatic complement, spelled out, is the same frame"); + assert_eq!(us, u0); + assert_eq!(vs, v0); + + // A colour of its own repaints the dual strands in it. + let red = with_viz_paint_strand_sat(with_viz_paint_strand_hue(auto, 0), 255); + let (_, u1, v1) = visualizer_i420(&peaks, 1.0, 320, 180, ring, red); + let red_px = (0..u1.len()).filter(|&i| u1[i] < 110 && v1[i] > 200).count(); + let auto_px = (0..u0.len()).filter(|&i| u0[i] < 110 && v0[i] > 200).count(); + assert!(red_px > 20, "the chosen colour did not reach the frame: {red_px}"); + assert_eq!(auto_px, 0, "the automatic ring already painted red: {auto_px}"); + + // ...and the flag is what decides: strand bytes with it clear are + // the unset picture, byte for byte. + let stale = auto | (77u64 << 32) | (9u64 << 40); + assert!(!viz_strand_set(stale)); + let (yt, ut, vt) = visualizer_i420(&peaks, 1.0, 320, 180, ring, stale); + assert_eq!(yt, y0, "an unset strand colour is the frame it always was"); + assert_eq!(ut, u0); + assert_eq!(vt, v0); + } } fn run( diff --git a/crates/engine/src/edith.rs b/crates/engine/src/edith.rs index c6575f5..980ba08 100644 --- a/crates/engine/src/edith.rs +++ b/crates/engine/src/edith.rs @@ -134,9 +134,12 @@ //! ([`crate::project::Clip::transition_out`], `0` for a hard cut), and last of //! all the transform line it is placed, sized, turned and cropped by, on top //! of everything its fit policy already did (`-` for a clip left at its fit -//! policy's own spot, [`crate::project::Clip::transform`]), and a visualizer +//! policy's own spot, [`crate::project::Clip::transform`]), a visualizer //! flags byte (`0` for an ordinary picture, bit 0 for a waveform of the -//! source's sound, the rest outline/smooth/fast/tint). +//! source's sound, the rest outline/smooth/fast/tint) and that waveform's +//! packed look ([`crate::project::Clip::viz_paint`]): hue, sat, strands and +//! glow in the low four bytes, then the strand colour's own hue and sat, +//! with the top bit set once a clip has chosen one. //! Timeline placement is //! explicit, so a *gap* is simply a stretch no line covers -- there is nothing //! to write for one, and nothing that can disagree about its length. The `` @@ -162,6 +165,9 @@ //! track 3 of a two-track palette is refused here, as a clip naming a source //! that is not there is. //! +//! **Version 22** was this with a 32-bit packed look: such a project's clips +//! chose no strand colour, which is what the top bit still clear means, and +//! their value is the low half of the one v23 writes. //! **Version 19** was this without the clip's transform field: such a project //! places no clip anywhere but its fit policy's own spot, which is what `-` //! still means. **Version 18** was that without the clip's transition field: @@ -205,7 +211,7 @@ //! nothing, and an older one plays everything at real time, and an older one //! mixes flat, and an older one shows no subtitles, and an older one is shown //! in the reference rendition, and an older one places none of the words it -//! names -- and saving any of them writes v22. An older +//! names -- and saving any of them writes v23. An older //! reader refuses a newer file by name. //! //! Text because an edit list is a few integers and a path, and a path is @@ -242,7 +248,8 @@ use crate::transform::TransformParams; /// 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 22"; +const MAGIC: &[u8] = b"edith 23"; +const MAGIC_V22: &[u8] = b"edith 22"; const MAGIC_V21: &[u8] = b"edith 21"; const MAGIC_V20: &[u8] = b"edith 20"; const MAGIC_V19: &[u8] = b"edith 19"; @@ -650,8 +657,11 @@ 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 a strand colour of its own above the packed + // visualizer paint (hue/sat, with the top bit as the flag)... + let v23 = first == MAGIC; // The one that carries packed visualizer paint (hue/sat/strands/glow)... - let v22 = first == MAGIC; + let v22 = v23 || first == MAGIC_V22; // The one that carries per-clip visualizer flags... let v21 = v22 || first == MAGIC_V21; // The one that carries a per-clip transform (position/scale/rotate/crop)... @@ -1206,7 +1216,7 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result { fade_out: number(f.get(10).copied().unwrap_or(b"0"), n)?.min(frames), transition_out: number(f.get(11).copied().unwrap_or(b"0"), n)?.min(frames), visualizer: number(f.get(13).copied().unwrap_or(b"0"), n)? as u8, - viz_paint: number(f.get(14).copied().unwrap_or(b"0"), n)? as u32, + viz_paint: number64(f.get(14).copied().unwrap_or(b"0"), n)?, start: number(f[0], n)?, in_frame, out_frame, @@ -1473,6 +1483,19 @@ fn number(field: &[u8], line: usize) -> crate::Result { } } +/// [`number`] for the one field wider than a `u32`: the clip's packed +/// visualizer look, whose strand-colour half needs the width (v23). +fn number64(field: &[u8], line: usize) -> crate::Result { + match std::str::from_utf8(field).ok().and_then(|s| s.parse().ok()) { + Some(n) => Ok(n), + None => Err(format!( + "line {line}: {:?} is not a number", + String::from_utf8_lossy(field) + ) + .into()), + } +} + /// A `sub` line's window field: microseconds, which is the clock a cue is timed /// in ([`crate::subtitle::Cue`]) and the one thing in this format counted in /// something other than frames. Signed as the cues are, and the negative half @@ -1636,7 +1659,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 22\n")); + assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 23\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() @@ -2116,7 +2139,7 @@ mod tests { let bytes = flat(&dir, &sources, &lanes, 12); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 22\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\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 0 0 0 - 0 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 - 0 0\n\ audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n", @@ -2153,7 +2176,7 @@ mod tests { let bytes = flat(&dir, &sources, &lanes, 7); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 22\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\ video 1 0 0 30 0 4 - - fit 1000 0 0 0 - 0 0\naudio 1\n\ video 2 40 0 10 0 - - - fit 1000 0 0 0 - 0 0\naudio 2 0 0 30 0 4 - - fit 1000 0 0 0 - 0 0\n", "an empty lane is a line of its own; everything else is its clips" @@ -2281,7 +2304,7 @@ mod tests { let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\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\ @@ -2405,7 +2428,7 @@ mod tests { let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\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\ @@ -2470,7 +2493,7 @@ mod tests { (1280, 720), old.playhead )), - "edith 22\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\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 0 0 0 - 0 0\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n" ); @@ -2514,7 +2537,7 @@ mod tests { let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ video 1 0 0 30 0 - - - fit 2000 0 0 0 - 0 0\nvideo 1 15 30 40 0 - - - fit 250 0 0 0 - 0 0\n\ audio 1 0 0 30 0 - - - fit 2000 0 0 0 - 0 0\n", "the rate is the clip line's last field, in thousandths" @@ -2543,7 +2566,7 @@ mod tests { (1280, 720), old.playhead )), - "edith 22\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n" ); // A rate outside what the editor can set is a corrupt line, by name. @@ -2594,7 +2617,7 @@ mod tests { let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ video 1 0 0 30 0 - - - fit 1000 5 7 0 - 0 0\n", "the fades are the clip line's last two fields" ); @@ -2647,7 +2670,7 @@ mod tests { let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ video 1 0 0 30 0 - - - fit 1000 0 0 9 - 0 0\n", "the dissolve is the clip line's own last field" ); @@ -2658,6 +2681,54 @@ mod tests { ); } + /// The clip's packed look (v23): a chosen strand colour rides in the + /// field's own bytes under the top bit and comes back bit-exact, a v22 + /// file's 32-bit value is the low half of that field with no strand + /// colour, and a file older than the field itself is the zero it always + /// was. + #[test] + fn a_strand_colour_round_trips_and_a_v22_look_stays_32_bit() { + use crate::decode::{ + viz_hue_ui, viz_sat_ui, viz_strand_set, with_viz_paint_strand_hue, + with_viz_paint_strand_sat, VIZ_PAINT_AZURE, + }; + let (dir, sources, lanes) = doc(); + let mut painted = lanes.clone(); + // Azure, its dual half a chosen green rather than the automatic + // complement of the clip's own hue. + let chosen = with_viz_paint_strand_sat(with_viz_paint_strand_hue(VIZ_PAINT_AZURE, 64), 200); + assert!(viz_strand_set(chosen)); + painted[0].1[0].viz_paint = chosen; + let bytes = flat(&dir, &sources, &painted, 0); + assert!( + bytes.starts_with(b"edith 23\n"), + "a project with a strand colour saves as v23: {}", + String::from_utf8_lossy(&bytes) + ); + let back = parse(&bytes, &dir).expect("v23 parses"); + assert_eq!(back.lanes, painted, "the look round-trips bit-exactly"); + + // A v22 file's field is a u32: the value lands in the low half + // untouched, and a strand colour it cannot carry reads as auto. + let look = VIZ_PAINT_AZURE as u32; + let v22 = format!( + "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 {look}\n" + ); + let old = parse(v22.as_bytes(), &dir).expect("v22 still loads"); + let paint = old.lanes[0].1[0].viz_paint; + assert_eq!(paint, u64::from(look), "the low half is the v22 value"); + assert!(!viz_strand_set(paint), "a v22 look chose no strand colour"); + assert_eq!(viz_hue_ui(paint), 150); + assert_eq!(viz_sat_ui(paint), 160); + // ...and a file older than the field is the zero that means the + // azure default, as it was before the field was widened. + let v21 = b"edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\n"; + let older = parse(v21, &dir).expect("v21 still loads"); + assert_eq!(older.lanes[0].1[0].viz_paint, 0); + } + /// A v19 file is a v20 one that places no clip anywhere but its fit /// policy's own spot: it loads with every clip's [`Clip::transform`] at /// `None`, which is what a v19 file's missing field still means. @@ -2785,7 +2856,7 @@ mod tests { ); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ transform 0.1:-0.2:1.5:90.0:0.1:0.0:0.0:0.05\n\ transform -1e-7:16777215.0:3.918315e-39:-0.0:0.0:0.0:0.0:0.0\n\ transform 0.0:0.0:1.0:0.0:0.0:0.0:0.0:0.0\n\ @@ -2865,7 +2936,7 @@ mod tests { ); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 22\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\ + "edith 23\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 0 0 0 - 0 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\n\ audio 2 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\n\ @@ -2897,7 +2968,7 @@ mod tests { (1280, 720), old.playhead )), - "edith 22\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ video 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\n" ); @@ -3061,7 +3132,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 22\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\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 0 0 0 - 0 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 - 0 0\n\ audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n" @@ -3114,7 +3185,7 @@ mod tests { let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); assert_eq!( String::from_utf8_lossy(&v5), - "edith 22\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ + "edith 23\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 0 0 0 - 0 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 - 0 0\n\ audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n", @@ -3146,7 +3217,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 22\n")); + assert!(v5.starts_with(b"edith 23\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. @@ -3257,7 +3328,7 @@ mod tests { let bytes = std::fs::read(&path).expect("read back"); assert_eq!( String::from_utf8_lossy(&bytes), - "edith 22\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\ + "edith 23\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\ video 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\n" ); // Loading rejoins the *given* directory, so the file is reached by the @@ -3302,10 +3373,10 @@ mod tests { #[test] fn a_wrong_first_line_is_refused_by_name() { let dir = PathBuf::from("/proj"); - let err = parse(b"edith 23\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir) + let err = parse(b"edith 24\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir) .unwrap_err() .to_string(); - assert_eq!(err, "line 1: unsupported version 23"); + assert_eq!(err, "line 1: unsupported version 24"); 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 41411c3..e8843b8 100644 --- a/crates/engine/src/export.rs +++ b/crates/engine/src/export.rs @@ -4426,7 +4426,7 @@ enum ClipDecoder { fps: f64, next: u32, flags: u8, - paint: u32, + paint: u64, y: Vec, u: Vec, v: Vec, @@ -4540,7 +4540,7 @@ impl ClipDecoder { height: u32, fps: f64, flags: u8, - paint: u32, + paint: u64, ) -> crate::Result { let peaks = crate::waveform::peaks(path, stream, crate::decode::VIZ_BUCKETS_PER_SEC) .ok() diff --git a/crates/engine/src/playback.rs b/crates/engine/src/playback.rs index 392b765..213bc9a 100644 --- a/crates/engine/src/playback.rs +++ b/crates/engine/src/playback.rs @@ -2984,10 +2984,18 @@ impl PlaybackSession { self.edit(Dirty::Picture, |p| p.set_visualizer(lane, idx, flags)) } - pub fn set_viz_paint(&mut self, lane: Lane, idx: usize, paint: u32) -> bool { + pub fn set_viz_paint(&mut self, lane: Lane, idx: usize, paint: u64) -> bool { self.edit(Dirty::Picture, |p| p.set_viz_paint(lane, idx, paint)) } + /// The same look and the same repaint without the undo step + /// ([`Project::set_viz_paint_live`]): what the samples inside one drag + /// across the colour wheel go through, so the picture follows the hand and + /// the whole gesture is still a single `z`. + pub fn set_viz_paint_live(&mut self, lane: Lane, idx: usize, paint: u64) -> bool { + self.edit(Dirty::Picture, |p| p.set_viz_paint_live(lane, idx, paint)) + } + /// Timeline frames of ramp-up from silence at the start of the clip at /// `idx` of `lane`. `0` for an index that is not there. pub fn fade_in_of(&self, lane: Lane, idx: usize) -> u32 { @@ -4795,5 +4803,27 @@ mod tests { assert_eq!(before, s.restarts(), "a live transform edit must reuse the worker"); assert_eq!(next.index, first.index, "paused: same timeline position before and after"); } + + /// The session's live look samples leave its history exactly where the + /// press left it -- the colour-wheel drag's twin for the packed look, and + /// what lets the app drive one from a pointer: `z` after a drag lands + /// before the press, not one sample back down the drag. + #[test] + fn a_live_look_drag_is_one_step_of_the_sessions_history() { + let mut s = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture"); + let (lane, idx) = s.video_clip_at(s.now()).expect("a clip under the playhead"); + let look = |hue: u8| crate::decode::with_viz_paint_hue(crate::decode::VIZ_PAINT_AZURE, hue); + assert!(s.set_viz_paint(lane, idx, look(1)), "the press"); + for hue in 2..=6u8 { + assert!(s.set_viz_paint_live(lane, idx, look(hue)), "a sample"); + } + assert_eq!(s.project.lane(lane)[idx].viz_paint, look(6)); + assert!(s.undo(), "the drag's own step"); + assert_eq!( + s.project.lane(lane)[idx].viz_paint, + 0, + "one undo is the whole drag" + ); + } } diff --git a/crates/engine/src/project.rs b/crates/engine/src/project.rs index 644b4f9..66d8f51 100644 --- a/crates/engine/src/project.rs +++ b/crates/engine/src/project.rs @@ -461,10 +461,15 @@ pub struct Clip { /// Zero is an ordinary picture. Older project files have no field and /// mean zero. pub visualizer: u8, - /// Packed look: hue 0-255, sat 0-255, strands 0-255, glow 0-255. - /// All-zero is the default (timeline azure, full sat, 8 strands, glow 2). - /// Older files have no field and mean zero. - pub viz_paint: u32, + /// Packed look: hue 0-255, sat 0-255, strands 0-255, glow 0-255 in the + /// low four bytes as they have been since v22, then the strand colour's + /// own bytes above them -- its hue at 32 and sat at 40 + /// ([`crate::decode::viz_strand_hue_ui`]) -- with the top bit as + /// [`crate::decode::viz_strand_set`]. All-zero is the default (timeline + /// azure, full sat, 8 strands, glow 2, no strand colour of its own). + /// Older files have no field and mean zero; a v22 file's 32-bit value + /// is the low half of this one, byte for byte. + pub viz_paint: u64, } impl Clip { @@ -2653,11 +2658,28 @@ impl Project { true } - pub fn set_viz_paint(&mut self, lane: Lane, idx: usize, paint: u32) -> bool { + /// Give the clip at `idx` of `lane` this packed look: one undo step, and + /// `false` (with no history) for an index that is not there, the way every + /// other setter refuses. + pub fn set_viz_paint(&mut self, lane: Lane, idx: usize, paint: u64) -> bool { + self.write_viz_paint(lane, idx, paint, true) + } + + /// [`set_viz_paint`](Self::set_viz_paint) without the undo step: the + /// samples *inside* one pointer drag across the colour wheel, whose first + /// write (a plain `set_viz_paint`) already took the snapshot the gesture + /// rolls back to. One drag is one undo, not one per sample. + pub fn set_viz_paint_live(&mut self, lane: Lane, idx: usize, paint: u64) -> bool { + self.write_viz_paint(lane, idx, paint, false) + } + + fn write_viz_paint(&mut self, lane: Lane, idx: usize, paint: u64, snapshot: bool) -> bool { if idx >= self.lane(lane).len() { return false; } - self.snapshot(); + if snapshot { + self.snapshot(); + } self.lane_mut(lane).expect("checked above")[idx].viz_paint = paint; true } @@ -3049,7 +3071,10 @@ impl Project { .unwrap_or(0) } - pub fn composite_viz_paint_at(&self, timeline_frame: u32) -> u32 { + /// Packed look ([`Clip::viz_paint`]) of the topmost video clip at + /// `timeline_frame`, or zero over a gap / a picture that is not a + /// visualizer. + pub fn composite_viz_paint_at(&self, timeline_frame: u32) -> u64 { self.composite_clip_at(timeline_frame) .map(|(lane, idx)| self.lane(lane)[idx].viz_paint) .unwrap_or(0) @@ -7225,13 +7250,17 @@ mod tests { /// The transform index is a third `Option`, same reason as the eq and /// colour ones before it -- it lands in bytes already spent on padding, so /// the struct still costs 56. + /// The visualizer look is the first field whose own width outgrows the + /// padding it lands in: it is a `u64` (a strand colour needs bytes above + /// the clip's own four), so the words after it come to 60 and the + /// alignment rounds them to 64 -- one word more than a clip used to cost. /// This is the assert that says so: a clip that grows a word grows every /// undo snapshot and every clipboard copy with it. #[test] fn a_fit_policy_costs_the_clip_no_word() { assert_eq!( std::mem::size_of::(), - 56, + 64, "Clip changed size: {} bytes", std::mem::size_of::() ); @@ -8893,6 +8922,40 @@ mod tests { ); } + /// A drag across the colour wheel is one gesture -- the look's twin of + /// [`a_whole_colour_drag_undoes_in_one_step`]: the press snapshots, every + /// sample after it only repaints, and the single undo lands on the look + /// the clip had *before* the hand touched it. The committing setter is + /// still exactly one step, refusals included. + #[test] + fn a_whole_look_drag_undoes_in_one_step() { + let look = |hue: u8| crate::decode::with_viz_paint_hue(crate::decode::VIZ_PAINT_AZURE, hue); + let mut p = three(); + assert!(p.set_viz_paint(Lane::V1, 0, look(1)), "the press"); + for hue in 2..=8u8 { + assert!(p.set_viz_paint_live(Lane::V1, 0, look(hue)), "a sample"); + } + assert_eq!(p.lane(Lane::V1)[0].viz_paint, look(8)); + assert!(p.undo()); + assert_eq!( + p.lane(Lane::V1)[0].viz_paint, + 0, + "one undo is the whole gesture, back to the default look" + ); + + // The live write refuses an index that is not there -- and a refusal + // costs no history -- while one committing write is one step back. + assert!(!p.set_viz_paint_live(Lane::V1, 99, look(1))); + assert!(p.set_viz_paint(Lane::V1, 0, look(1)), "a click, not a drag"); + assert_eq!(p.lane(Lane::V1)[0].viz_paint, look(1)); + assert!(p.undo()); + assert_eq!( + p.lane(Lane::V1)[0].viz_paint, + 0, + "the committing setter is one undo step, no more" + ); + } + /// The colour table is append-only within a session, exactly as the eq one /// is -- and a save is where an undone grade goes. #[test] @@ -9052,12 +9115,15 @@ mod tests { /// colour one did not, and the struct grew a word. The transform index is /// a third `Option`, and it fits the padding the fit policy and the /// transition byte already left behind, so the struct did not grow again. + /// The packed visualizer look is a `u64` -- the strand colour has bytes + /// above the clip's own four -- and nothing left in the struct is wide + /// enough to hold it, so it grew a word again. #[test] fn a_clip_is_still_a_small_copy() { assert_eq!( std::mem::size_of::(), - 56, - "Clip changed size -- 32 before the colour index, 40 before the fades, 48 after, 56 with the transition, still 56 with the transform index" + 64, + "Clip changed size -- 32 before the colour index, 40 before the fades, 48 after, 56 with the transition, still 56 with the transform index, 64 once the look was a u64" ); } diff --git a/crates/engine/tests/export.rs b/crates/engine/tests/export.rs index fa876c4..881ccd1 100644 --- a/crates/engine/tests/export.rs +++ b/crates/engine/tests/export.rs @@ -1253,7 +1253,7 @@ fn a_proxy_is_picture_only_every_frame_a_starting_point_and_cached() { 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 20\n"), "{text}"); + assert!(text.starts_with("edith 23\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"); diff --git a/crates/engine/tests/saveload.rs b/crates/engine/tests/saveload.rs index 2e892e6..68993f3 100644 --- a/crates/engine/tests/saveload.rs +++ b/crates/engine/tests/saveload.rs @@ -292,7 +292,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 20\n"), "{text}"); + assert!(text.starts_with("edith 23\n"), "{text}"); assert!( text.contains("\nresolution 1280 720\n"), "a project with no resolution of its own is saved at source 0's: {text}" @@ -380,9 +380,9 @@ 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 20\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\ - video 1 0 0 30 0 3 - - fit 1000 0 0 0 -\naudio 1\n\ - video 2 40 0 20 0 - - - fit 1000 0 0 0 -\naudio 2 0 0 30 0 3 - - fit 1000 0 0 0 -\n", + "edith 23\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\ + video 1 0 0 30 0 3 - - fit 1000 0 0 0 - 0 0\naudio 1\n\ + video 2 40 0 20 0 - - - fit 1000 0 0 0 - 0 0\naudio 2 0 0 30 0 3 - - fit 1000 0 0 0 - 0 0\n", "a four-lane project is written as it was read, three versions on" ); } @@ -410,11 +410,11 @@ 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 20\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\ + "edith 23\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 0 0 0 -\nvideo 1 30 30 60 0 - 1 - fit 1000 0 0 0 -\n\ - audio 1 0 0 30 0 - 0 - fit 1000 0 0 0 -\naudio 1 30 30 60 0 - - - fit 1000 0 0 0 -\n", + video 1 0 0 30 0 - 0 - fit 1000 0 0 0 - 0 0\nvideo 1 30 30 60 0 - 1 - fit 1000 0 0 0 - 0 0\n\ + audio 1 0 0 30 0 - 0 - fit 1000 0 0 0 - 0 0\naudio 1 30 30 60 0 - - - fit 1000 0 0 0 - 0 0\n", "the equalizer table and every clip's index survive a round trip" ); } @@ -445,12 +445,12 @@ 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 20\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\ + "edith 23\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\ - video 1 0 0 30 0 - 0 0 fit 1000 0 0 0 -\nvideo 1 30 30 60 0 - - 1 fit 1000 0 0 0 -\n\ - audio 1 0 0 30 0 - - 0 fit 1000 0 0 0 -\naudio 1 30 30 60 0 - - - fit 1000 0 0 0 -\n", + video 1 0 0 30 0 - 0 0 fit 1000 0 0 0 - 0 0\nvideo 1 30 30 60 0 - - 1 fit 1000 0 0 0 - 0 0\n\ + audio 1 0 0 30 0 - - 0 fit 1000 0 0 0 - 0 0\naudio 1 30 30 60 0 - - - fit 1000 0 0 0 - 0 0\n", "the colour table and every clip's index survive a round trip" ); // A dialect that could not say either one means the defaults, and those are @@ -495,9 +495,9 @@ 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 20\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\ - video 1 0 0 30 0 - - - fill 1000 0 0 0 -\nvideo 1 30 30 60 0 - - - center 1000 0 0 0 -\n\ - audio 1 0 0 60 0 - - - fit 1000 0 0 0 -\n", + "edith 23\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\ + video 1 0 0 30 0 - - - fill 1000 0 0 0 - 0 0\nvideo 1 30 30 60 0 - - - center 1000 0 0 0 - 0 0\n\ + audio 1 0 0 60 0 - - - fit 1000 0 0 0 - 0 0\n", "a v7 project is written back as the v8 it now is: the same clips, each \ saying it plays at real time, which is what it always played at" ); diff --git a/crates/engine/tests/silence.rs b/crates/engine/tests/silence.rs index 5ddfce9..77f618d 100644 --- a/crates/engine/tests/silence.rs +++ b/crates/engine/tests/silence.rs @@ -400,7 +400,7 @@ fn scanning_a_clip_and_cutting_what_it_finds() { .expect("save"); let text = std::fs::read_to_string(&file).expect("read it back"); assert!( - text.starts_with("edith 20"), + text.starts_with("edith 23"), "{:?}", &text[..16.min(text.len())] ); diff --git a/crates/engine/tests/subtitles.rs b/crates/engine/tests/subtitles.rs index abdbdca..51ea6bb 100644 --- a/crates/engine/tests/subtitles.rs +++ b/crates/engine/tests/subtitles.rs @@ -260,7 +260,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 20\n"), "{text}"); + assert!(text.starts_with("edith 23\n"), "{text}"); assert!( text.contains("\nsubtitle - test_subs.srt\n"), "the reference is written relative, and no cue is: {text}" @@ -1251,7 +1251,7 @@ fn subtitle_lanes_and_their_captions_survive_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 20\n"), "{text}"); + assert!(text.starts_with("edith 23\n"), "{text}"); assert!( text.contains("\nsub 1 10 45 0 500000 1500000\n"), "the placement is one line: where it sits, how long, whose words, and \ @@ -1317,7 +1317,7 @@ fn a_version_14_project_keeps_its_palette_and_places_nothing() { let now = dir.join("new.edith"); loaded.save_project(&now).expect("save"); let text = std::fs::read_to_string(&now).expect("read back"); - assert!(text.starts_with("edith 20\n"), "{text}"); + assert!(text.starts_with("edith 23\n"), "{text}"); assert!( text.contains("\nsubtitle - test_subs.srt\n"), "the row survives the migration: {text}"