forge
Explore
Log in

Don't you dare go Hollow

🔀 merge(colorapi): the packed look widens to u64 behind the panel work

Browse files at this commit

7de7b97f0bb9c8a78743109bc293e17cc9047aa1Ahmet Kaan GümüşParent: ed847d41973da2
crates/engine/src/decode.rsmodified+292 -23
@@ -630,7 +630,7 @@ impl DecodeSession {
630 transform: TransformParams,630 transform: TransformParams,
631 canvas: Composer,631 canvas: Composer,
632 flags: u8,632 flags: u8,
633- paint: u32,633+ paint: u64,
634 ) -> crate::Result<FrameStream> {634 ) -> crate::Result<FrameStream> {
635 let (tx, rx) = sync_channel(2);635 let (tx, rx) = sync_channel(2);
636 let cancel = Arc::new(AtomicBool::new(false));636 let cancel = Arc::new(AtomicBool::new(false));
@@ -1447,9 +1447,18 @@ pub fn viz_ink_rgb(hue: u8) -> (u8, u8, u8) {
1447 }1447 }
1448 1448
1449 /// Azure + sat 160 + 8 strands + glow 2. What `viz_paint == 0` means.1449 /// Azure + sat 160 + 8 strands + glow 2. What `viz_paint == 0` means.
1450-pub const VIZ_PAINT_AZURE: u32 = 150 | (160 << 8) | (8 << 16) | (2 << 24);1450+pub const VIZ_PAINT_AZURE: u64 = 150 | (160 << 8) | (8 << 16) | (2 << 24);
1451-1451+
1452-pub fn viz_materialize(paint: u32) -> u32 {1452+/// Where the strand colour sits above the clip's own four bytes: hue at 32
1453+/// and sat at 40, with bit 63 as the flag that says a clip chose one
1454+/// ([`viz_strand_set`]). A clear flag means the automatic complement the
1455+/// ring has always painted -- so a v22 value, whose top half is empty, is
1456+/// nothing new.
1457+const VIZ_STRAND_HUE_SHIFT: u32 = 32;
1458+const VIZ_STRAND_SAT_SHIFT: u32 = 40;
1459+const VIZ_STRAND_CHOSEN: u64 = 1 << 63;
1460+
1461+pub fn viz_materialize(paint: u64) -> u64 {
1453 if paint == 0 {1462 if paint == 0 {
1454 VIZ_PAINT_AZURE1463 VIZ_PAINT_AZURE
1455 } else {1464 } else {
@@ -1457,42 +1466,42 @@ pub fn viz_materialize(paint: u32) -> u32 {
1457 }1466 }
1458 }1467 }
1459 1468
1460-pub fn viz_ink_from_paint(paint: u32) -> (u8, u8, u8) {1469+pub fn viz_ink_from_paint(paint: u64) -> (u8, u8, u8) {
1461 let p = viz_materialize(paint);1470 let p = viz_materialize(paint);
1462 let hue = (p & 0xFF) as f32 * 360.0 / 256.0;1471 let hue = (p & 0xFF) as f32 * 360.0 / 256.0;
1463 let sat = f32::from(((p >> 8) & 0xFF) as u8) / 255.0;1472 let sat = f32::from(((p >> 8) & 0xFF) as u8) / 255.0;
1464 hsv_to_rgb(hue, sat, 0.84)1473 hsv_to_rgb(hue, sat, 0.84)
1465 }1474 }
1466 1475
1467-pub fn viz_strands_of(paint: u32) -> u8 {1476+pub fn viz_strands_of(paint: u64) -> u8 {
1468 (((viz_materialize(paint) >> 16) & 0xFF) as u8).clamp(1, 32)1477 (((viz_materialize(paint) >> 16) & 0xFF) as u8).clamp(1, 32)
1469 }1478 }
1470 1479
1471-pub fn viz_glow_of(paint: u32) -> u8 {1480+pub fn viz_glow_of(paint: u64) -> u8 {
1472 ((viz_materialize(paint) >> 24) & 0xFF) as u81481 ((viz_materialize(paint) >> 24) & 0xFF) as u8
1473 }1482 }
1474 1483
1475-pub fn with_viz_paint_hue(paint: u32, hue: u8) -> u32 {1484+pub fn with_viz_paint_hue(paint: u64, hue: u8) -> u64 {
1476- (viz_materialize(paint) & !0xFF) | u32::from(hue)1485+ (viz_materialize(paint) & !0xFF) | u64::from(hue)
1477 }1486 }
1478 1487
1479-pub fn with_viz_paint_sat(paint: u32, sat: u8) -> u32 {1488+pub fn with_viz_paint_sat(paint: u64, sat: u8) -> u64 {
1480- (viz_materialize(paint) & !(0xFF << 8)) | (u32::from(sat) << 8)1489+ (viz_materialize(paint) & !(0xFF << 8)) | (u64::from(sat) << 8)
1481 }1490 }
1482 1491
1483-pub fn with_viz_paint_strands(paint: u32, n: u8) -> u32 {1492+pub fn with_viz_paint_strands(paint: u64, n: u8) -> u64 {
1484- (viz_materialize(paint) & !(0xFF << 16)) | (u32::from(n.clamp(1, 32)) << 16)1493+ (viz_materialize(paint) & !(0xFF << 16)) | (u64::from(n.clamp(1, 32)) << 16)
1485 }1494 }
1486 1495
1487-pub fn with_viz_paint_glow(paint: u32, n: u8) -> u32 {1496+pub fn with_viz_paint_glow(paint: u64, n: u8) -> u64 {
1488- (viz_materialize(paint) & !(0xFF << 24)) | (u32::from(n.min(16)) << 24)1497+ (viz_materialize(paint) & !(0xFF << 24)) | (u64::from(n.min(16)) << 24)
1489 }1498 }
1490 1499
1491-pub fn viz_hue_ui(paint: u32) -> u8 {1500+pub fn viz_hue_ui(paint: u64) -> u8 {
1492 if paint == 0 { 150 } else { (paint & 0xFF) as u8 }1501 if paint == 0 { 150 } else { (paint & 0xFF) as u8 }
1493 }1502 }
1494 1503
1495-pub fn viz_sat_ui(paint: u32) -> u8 {1504+pub fn viz_sat_ui(paint: u64) -> u8 {
1496 if paint == 0 {1505 if paint == 0 {
1497 1601506 160
1498 } else {1507 } else {
@@ -1503,6 +1512,135 @@ pub fn viz_sat_ui(paint: u32) -> u8 {
1503 }1512 }
1504 }1513 }
1505 1514
1515+/// Whether the clip chose a strand colour of its own (the top bit), rather
1516+/// than taking the automatic complement a ring's dual half has always
1517+/// painted.
1518+pub fn viz_strand_set(paint: u64) -> bool {
1519+ paint & VIZ_STRAND_CHOSEN != 0
1520+}
1521+
1522+/// The chosen strand hue, 0-255 on the wheel [`viz_hue_ui`] reads.
1523+pub fn viz_strand_hue_ui(paint: u64) -> u8 {
1524+ ((paint >> VIZ_STRAND_HUE_SHIFT) & 0xFF) as u8
1525+}
1526+
1527+/// The chosen strand sat, 0-255. A stored zero stays zero here, unlike
1528+/// [`viz_sat_ui`]'s: a grey strand is a colour someone picked, and the flag
1529+/// -- not the byte -- is what says whether there is one.
1530+pub fn viz_strand_sat_ui(paint: u64) -> u8 {
1531+ ((paint >> VIZ_STRAND_SAT_SHIFT) & 0xFF) as u8
1532+}
1533+
1534+/// Set the strand hue and mark the colour chosen, so a ring's dual half
1535+/// inks it instead of the automatic complement.
1536+pub fn with_viz_paint_strand_hue(paint: u64, hue: u8) -> u64 {
1537+ let p = viz_materialize(paint) & !(0xFF_u64 << VIZ_STRAND_HUE_SHIFT);
1538+ (p | (u64::from(hue) << VIZ_STRAND_HUE_SHIFT)) | VIZ_STRAND_CHOSEN
1539+}
1540+
1541+/// Set the strand sat and mark the colour chosen, as
1542+/// [`with_viz_paint_strand_hue`] does.
1543+pub fn with_viz_paint_strand_sat(paint: u64, sat: u8) -> u64 {
1544+ let p = viz_materialize(paint) & !(0xFF_u64 << VIZ_STRAND_SAT_SHIFT);
1545+ (p | (u64::from(sat) << VIZ_STRAND_SAT_SHIFT)) | VIZ_STRAND_CHOSEN
1546+}
1547+
1548+/// Drop the chosen strand colour: the dual half of a ring goes back to the
1549+/// automatic complement, and both strand bytes go with the flag.
1550+pub fn viz_strand_clear(paint: u64) -> u64 {
1551+ paint & !(VIZ_STRAND_CHOSEN
1552+ | (0xFF_u64 << VIZ_STRAND_HUE_SHIFT)
1553+ | (0xFF_u64 << VIZ_STRAND_SAT_SHIFT))
1554+}
1555+
1556+/// `#RRGGBB` for an ink, at the same fixed value the painter draws at, so
1557+/// the swatch a front-end shows is the colour that reaches the picture.
1558+/// The inverse of [`viz_color_from_text`] for the colours a round trip
1559+/// through bytes can carry back.
1560+pub fn viz_color_hex(hue: u8, sat: u8) -> String {
1561+ let (r, g, b) = hsv_to_rgb(f32::from(hue) * 360.0 / 256.0, f32::from(sat) / 255.0, 0.84);
1562+ format!("#{r:02X}{g:02X}{b:02X}")
1563+}
1564+
1565+/// A colour someone typed -- `#4F8FD6`, `4f8fd6`, `rgb(79,143,214)` or
1566+/// `rgba(79,143,214,255)`, any case, commas or `/` between the channels,
1567+/// alpha ignored -- as the `(hue, sat)` pair the sliders and the paint
1568+/// field speak. `None` for everything else rather than a guess: the wrong
1569+/// number of digits, a channel outside 0-255, parentheses missing.
1570+///
1571+/// Brightness is dropped, not carried: the painter draws every ink at its
1572+/// own fixed value, so a typed colour is kept by its hue and saturation.
1573+pub fn viz_color_from_text(text: &str) -> Option<(u8, u8)> {
1574+ let t = text.trim();
1575+ let (r, g, b) = if let Some(inner) = t.strip_suffix(')') {
1576+ let body = if starts_ci(inner, b"rgb(") {
1577+ &inner[4..]
1578+ } else if starts_ci(inner, b"rgba(") {
1579+ &inner[5..]
1580+ } else {
1581+ return None;
1582+ };
1583+ let mut channels = body.split(['/', ',']).map(str::trim);
1584+ let r = channel(channels.next()?)?;
1585+ let g = channel(channels.next()?)?;
1586+ let b = channel(channels.next()?)?;
1587+ // Alpha, when it is spelled: read so a bad one is refused like a
1588+ // channel is, and dropped -- the paint field has no room for it.
1589+ if let Some(a) = channels.next() {
1590+ channel(a)?;
1591+ }
1592+ if channels.next().is_some() {
1593+ return None;
1594+ }
1595+ (r, g, b)
1596+ } else {
1597+ let hex = t.strip_prefix('#').unwrap_or(t);
1598+ if hex.len() != 6 || !hex.bytes().all(|c| c.is_ascii_hexdigit()) {
1599+ return None;
1600+ }
1601+ (
1602+ u8::from_str_radix(&hex[0..2], 16).ok()?,
1603+ u8::from_str_radix(&hex[2..4], 16).ok()?,
1604+ u8::from_str_radix(&hex[4..6], 16).ok()?,
1605+ )
1606+ };
1607+ Some(rgb_to_hue_sat(r, g, b))
1608+}
1609+
1610+fn starts_ci(text: &str, prefix: &[u8]) -> bool {
1611+ text.len() >= prefix.len() && text.as_bytes()[..prefix.len()].eq_ignore_ascii_case(prefix)
1612+}
1613+
1614+/// One 0-255 channel of a typed colour: digits only, so neither a sign nor
1615+/// an exponent slips in the way `u8`'s own parse would take them.
1616+fn channel(text: &str) -> Option<u8> {
1617+ if text.is_empty() || !text.bytes().all(|b| b.is_ascii_digit()) {
1618+ return None;
1619+ }
1620+ text.parse().ok()
1621+}
1622+
1623+/// What a byte RGB is on the paint field's wheel: hue on [`viz_hue_ui`]'s
1624+/// 0-255 scale, sat 0-255, brightness dropped for the same reason
1625+/// [`viz_color_from_text`] drops the typed one.
1626+fn rgb_to_hue_sat(r: u8, g: u8, b: u8) -> (u8, u8) {
1627+ let (r, g, b) = (f32::from(r), f32::from(g), f32::from(b));
1628+ let (max, min) = (r.max(g).max(b), r.min(g).min(b));
1629+ let delta = max - min;
1630+ let hue = if delta == 0.0 {
1631+ 0.0
1632+ } else if max == r {
1633+ 60.0 * ((g - b) / delta).rem_euclid(6.0)
1634+ } else if max == g {
1635+ 60.0 * ((b - r) / delta + 2.0)
1636+ } else {
1637+ 60.0 * ((r - g) / delta + 4.0)
1638+ };
1639+ let hue = ((hue * 256.0 / 360.0).round() as i64).rem_euclid(256) as u8;
1640+ let sat = if max == 0.0 { 0.0 } else { delta / max };
1641+ (hue, (sat * 255.0).round() as u8)
1642+}
1643+
1506 pub fn viz_hsv_rgb(h: f32, s: f32, v: f32) -> (u8, u8, u8) {1644 pub fn viz_hsv_rgb(h: f32, s: f32, v: f32) -> (u8, u8, u8) {
1507 hsv_to_rgb(h, s, v)1645 hsv_to_rgb(h, s, v)
1508 }1646 }
@@ -1654,14 +1792,14 @@ fn viz_line(
1654 /// One visualizer picture in tightly packed I420. Three looks, picked by1792 /// One visualizer picture in tightly packed I420. Three looks, picked by
1655 /// [`viz_style`]: a bipolar sample trace (Audacity), a filled min/max1793 /// [`viz_style`]: a bipolar sample trace (Audacity), a filled min/max
1656 /// envelope at pixel resolution, or a multi-strand ribbon. Ink is1794 /// envelope at pixel resolution, or a multi-strand ribbon. Ink is
1657-/// [`viz_ink_rgb`]. A frame always exists; silence is the zero line.1795+/// [`viz_ink_from_paint`]. A frame always exists; silence is the zero line.
1658 pub(crate) fn visualizer_i420(1796 pub(crate) fn visualizer_i420(
1659 peaks: &[(f32, f32)],1797 peaks: &[(f32, f32)],
1660 t_secs: f64,1798 t_secs: f64,
1661 width: u32,1799 width: u32,
1662 height: u32,1800 height: u32,
1663 flags: u8,1801 flags: u8,
1664- paint: u32,1802+ paint: u64,
1665 ) -> (Vec<u8>, Vec<u8>, Vec<u8>) {1803 ) -> (Vec<u8>, Vec<u8>, Vec<u8>) {
1666 let width = width & !1;1804 let width = width & !1;
1667 let height = height & !1;1805 let height = height & !1;
@@ -1789,11 +1927,22 @@ pub(crate) fn visualizer_i420(
1789 let glow = viz_glow_of(paint);1927 let glow = viz_glow_of(paint);
1790 for strand in 0..strands {1928 for strand in 0..strands {
1791 let dual = strands >= 2 && strand >= strands / 2;1929 let dual = strands >= 2 && strand >= strands / 2;
1792- let (ir, ig, ib) = viz_ink_from_paint(if dual {1930+ // The dual half takes the clip's own strand colour when it
1793- with_viz_paint_hue(paint, viz_hue_ui(paint).wrapping_add(128))1931+ // chose one; without one it is the wheel half a turn from
1932+ // the clip's hue, at the clip's own saturation, which is
1933+ // the complement every earlier project paints.
1934+ let (ir, ig, ib) = if dual && viz_strand_set(paint) {
1935+ let hue = f32::from(viz_strand_hue_ui(paint)) * 360.0 / 256.0;
1936+ let sat = f32::from(viz_strand_sat_ui(paint)) / 255.0;
1937+ hsv_to_rgb(hue, sat, 0.84)
1938+ } else if dual {
1939+ viz_ink_from_paint(with_viz_paint_hue(
1940+ paint,
1941+ viz_hue_ui(paint).wrapping_add(128),
1942+ ))
1794 } else {1943 } else {
1795- paint1944+ viz_ink_from_paint(paint)
1796- });1945+ };
1797 let (iy, iu, iv) = rgb_yuv(ir as i32, ig as i32, ib as i32);1946 let (iy, iu, iv) = rgb_yuv(ir as i32, ig as i32, ib as i32);
1798 let scale = 0.65 + 0.35 * f32::from(strand % 4) / 3.0;1947 let scale = 0.65 + 0.35 * f32::from(strand % 4) / 3.0;
1799 let phase = f32::from(strand) * 0.35;1948 let phase = f32::from(strand) * 0.35;
@@ -2211,6 +2360,126 @@ mod tests {
2211 }2360 }
2212 assert!(shifted > 2, "hue 8 did not leave blue");2361 assert!(shifted > 2, "hue 8 did not leave blue");
2213 }2362 }
2363+
2364+ /// The paint's byte layout: the strand colour lives above the clip's own
2365+ /// four bytes and the top bit is the flag, so either strand setter marks
2366+ /// the colour chosen and clearing drops both bytes with the flag.
2367+ #[test]
2368+ fn the_paint_packs_the_strand_colour_above_the_v22_halves() {
2369+ let p = with_viz_paint_strand_sat(with_viz_paint_strand_hue(VIZ_PAINT_AZURE, 0xAB), 0xCD);
2370+ assert_eq!(p & 0xFFFF_FFFF, VIZ_PAINT_AZURE, "the low half never moves");
2371+ assert_eq!((p >> 32) & 0xFF, 0xAB);
2372+ assert_eq!((p >> 40) & 0xFF, 0xCD);
2373+ assert!(viz_strand_set(p));
2374+ assert_eq!(viz_strand_hue_ui(p), 0xAB);
2375+ assert_eq!(viz_strand_sat_ui(p), 0xCD);
2376+ assert_eq!(viz_strand_clear(p), VIZ_PAINT_AZURE);
2377+ assert!(!viz_strand_set(viz_strand_clear(p)));
2378+ }
2379+
2380+ /// The shapes a colour is typed in all mean the same ink, and everything
2381+ /// else is refused rather than guessed at.
2382+ #[test]
2383+ fn typed_colours_read_as_hex_rgb_and_rgba() {
2384+ let want = viz_color_from_text("#4F8FD6").expect("a hex colour");
2385+ assert_eq!(want, (150, 161), "hue and sat on the field's own scales");
2386+ for text in [
2387+ "#4F8FD6",
2388+ "4f8fd6",
2389+ " #4f8fd6 ",
2390+ "rgb(79,143,214)",
2391+ "rgb(79/143/214)",
2392+ "RGBA(79, 143, 214, 255)",
2393+ ] {
2394+ assert_eq!(viz_color_from_text(text), Some(want), "{text}");
2395+ }
2396+ for text in [
2397+ "#12345",
2398+ "zz",
2399+ "rgb(300,0,0)",
2400+ "rgb(1,2)",
2401+ "",
2402+ "rgb 79,143,214)",
2403+ "rgb(79,143,214",
2404+ "#4F8FD",
2405+ "#4F8FD67",
2406+ "#GGGGGG",
2407+ "rgb(79,143,214,255,0)",
2408+ "rgb(79;143;214)",
2409+ ] {
2410+ assert_eq!(viz_color_from_text(text), None, "{text}");
2411+ }
2412+ }
2413+
2414+ /// A colour's hex is the ink the painter draws, and reading it back
2415+ /// gives the sliders their own value again -- for the 47053 of the 65536
2416+ /// hues and saturations a trip through bytes can carry. The rest land on
2417+ /// a neighbour: their smallest channel rounds to a byte whose ratio is
2418+ /// not the one that was asked for. Full saturation is where that channel
2419+ /// is the one the value sets exactly, and it survives at every hue.
2420+ #[test]
2421+ fn a_sampled_palette_round_trips_through_its_hex() {
2422+ for hue in (0..=255u8).step_by(8) {
2423+ let hex = viz_color_hex(hue, 255);
2424+ assert_eq!(viz_color_from_text(&hex), Some((hue, 255)), "{hex}");
2425+ }
2426+ // The achromatic end, where hue is not a colour at all.
2427+ assert_eq!(viz_color_from_text(&viz_color_hex(0, 0)), Some((0, 0)));
2428+ assert_eq!(viz_color_from_text(&viz_color_hex(200, 0)), Some((0, 0)));
2429+ // ...and the whole grid, so a change that quietly shrinks what the
2430+ // trip can carry cannot pass by leaving the sample above green.
2431+ let exact = (0..=255u8)
2432+ .flat_map(|hue| (0..=255u8).map(move |sat| (hue, sat)))
2433+ .filter(|&(hue, sat)| viz_color_from_text(&viz_color_hex(hue, sat)) == Some((hue, sat)))
2434+ .count();
2435+ assert_eq!(exact, 47_053, "the colours a hex round trip keeps");
2436+ }
2437+
2438+ /// The dual half of a ring takes the clip's own strand colour when it has
2439+ /// one: a choice that names the automatic complement paints the same
2440+ /// frame, another repaints the dual strands in it, and a paint whose flag
2441+ /// is clear is the picture it has always been -- strand bytes or no.
2442+ #[test]
2443+ fn a_chosen_strand_colour_repaints_only_the_dual_half_of_a_ring() {
2444+ let mut peaks = vec![(0.0, 0.0); 12_000];
2445+ for (i, p) in peaks.iter_mut().enumerate() {
2446+ let a = ((i as f32 / 400.0) * std::f32::consts::TAU).sin() * 0.8;
2447+ *p = (-a.abs(), a.abs());
2448+ }
2449+ let ring = with_viz_style(1, VIZ_STYLE_RING);
2450+ let auto = VIZ_PAINT_AZURE;
2451+ let (y0, u0, v0) = visualizer_i420(&peaks, 1.0, 320, 180, ring, auto);
2452+
2453+ // The automatic dual is half a wheel from the clip's hue at the
2454+ // clip's own saturation; choosing exactly that colour changes
2455+ // nothing at all.
2456+ let same = with_viz_paint_strand_sat(
2457+ with_viz_paint_strand_hue(auto, viz_hue_ui(auto).wrapping_add(128)),
2458+ viz_sat_ui(auto),
2459+ );
2460+ assert!(viz_strand_set(same));
2461+ let (ys, us, vs) = visualizer_i420(&peaks, 1.0, 320, 180, ring, same);
2462+ assert_eq!(ys, y0, "the automatic complement, spelled out, is the same frame");
2463+ assert_eq!(us, u0);
2464+ assert_eq!(vs, v0);
2465+
2466+ // A colour of its own repaints the dual strands in it.
2467+ let red = with_viz_paint_strand_sat(with_viz_paint_strand_hue(auto, 0), 255);
2468+ let (_, u1, v1) = visualizer_i420(&peaks, 1.0, 320, 180, ring, red);
2469+ let red_px = (0..u1.len()).filter(|&i| u1[i] < 110 && v1[i] > 200).count();
2470+ let auto_px = (0..u0.len()).filter(|&i| u0[i] < 110 && v0[i] > 200).count();
2471+ assert!(red_px > 20, "the chosen colour did not reach the frame: {red_px}");
2472+ assert_eq!(auto_px, 0, "the automatic ring already painted red: {auto_px}");
2473+
2474+ // ...and the flag is what decides: strand bytes with it clear are
2475+ // the unset picture, byte for byte.
2476+ let stale = auto | (77u64 << 32) | (9u64 << 40);
2477+ assert!(!viz_strand_set(stale));
2478+ let (yt, ut, vt) = visualizer_i420(&peaks, 1.0, 320, 180, ring, stale);
2479+ assert_eq!(yt, y0, "an unset strand colour is the frame it always was");
2480+ assert_eq!(ut, u0);
2481+ assert_eq!(vt, v0);
2482+ }
2214 }2483 }
2215 2484
2216 fn run(2485 fn run(
crates/engine/src/edith.rsmodified+96 -25
@@ -134,9 +134,12 @@
134 //! ([`crate::project::Clip::transition_out`], `0` for a hard cut), and last of134 //! ([`crate::project::Clip::transition_out`], `0` for a hard cut), and last of
135 //! all the transform line it is placed, sized, turned and cropped by, on top135 //! all the transform line it is placed, sized, turned and cropped by, on top
136 //! of everything its fit policy already did (`-` for a clip left at its fit136 //! of everything its fit policy already did (`-` for a clip left at its fit
137-//! policy's own spot, [`crate::project::Clip::transform`]), and a visualizer137+//! policy's own spot, [`crate::project::Clip::transform`]), a visualizer
138 //! flags byte (`0` for an ordinary picture, bit 0 for a waveform of the138 //! flags byte (`0` for an ordinary picture, bit 0 for a waveform of the
139-//! source's sound, the rest outline/smooth/fast/tint).139+//! source's sound, the rest outline/smooth/fast/tint) and that waveform's
140+//! packed look ([`crate::project::Clip::viz_paint`]): hue, sat, strands and
141+//! glow in the low four bytes, then the strand colour's own hue and sat,
142+//! with the top bit set once a clip has chosen one.
140 //! Timeline placement is143 //! Timeline placement is
141 //! explicit, so a *gap* is simply a stretch no line covers -- there is nothing144 //! explicit, so a *gap* is simply a stretch no line covers -- there is nothing
142 //! to write for one, and nothing that can disagree about its length. The `<in>`145 //! to write for one, and nothing that can disagree about its length. The `<in>`
@@ -162,6 +165,9 @@
162 //! track 3 of a two-track palette is refused here, as a clip naming a source165 //! track 3 of a two-track palette is refused here, as a clip naming a source
163 //! that is not there is.166 //! that is not there is.
164 //!167 //!
168+//! **Version 22** was this with a 32-bit packed look: such a project's clips
169+//! chose no strand colour, which is what the top bit still clear means, and
170+//! their value is the low half of the one v23 writes.
165 //! **Version 19** was this without the clip's transform field: such a project171 //! **Version 19** was this without the clip's transform field: such a project
166 //! places no clip anywhere but its fit policy's own spot, which is what `-`172 //! places no clip anywhere but its fit policy's own spot, which is what `-`
167 //! still means. **Version 18** was that without the clip's transition field:173 //! still means. **Version 18** was that without the clip's transition field:
@@ -205,7 +211,7 @@
205 //! nothing, and an older one plays everything at real time, and an older one211 //! nothing, and an older one plays everything at real time, and an older one
206 //! mixes flat, and an older one shows no subtitles, and an older one is shown212 //! mixes flat, and an older one shows no subtitles, and an older one is shown
207 //! in the reference rendition, and an older one places none of the words it213 //! in the reference rendition, and an older one places none of the words it
208-//! names -- and saving any of them writes v22. An older214+//! names -- and saving any of them writes v23. An older
209 //! reader refuses a newer file by name.215 //! reader refuses a newer file by name.
210 //!216 //!
211 //! Text because an edit list is a few integers and a path, and a path is217 //! Text because an edit list is a few integers and a path, and a path is
@@ -242,7 +248,8 @@ use crate::transform::TransformParams;
242 248
243 /// What [`save`] writes. Read support goes back to `edith 1`; see the module249 /// What [`save`] writes. Read support goes back to `edith 1`; see the module
244 /// docs for what those dialects looked like.250 /// docs for what those dialects looked like.
245-const MAGIC: &[u8] = b"edith 22";251+const MAGIC: &[u8] = b"edith 23";
252+const MAGIC_V22: &[u8] = b"edith 22";
246 const MAGIC_V21: &[u8] = b"edith 21";253 const MAGIC_V21: &[u8] = b"edith 21";
247 const MAGIC_V20: &[u8] = b"edith 20";254 const MAGIC_V20: &[u8] = b"edith 20";
248 const MAGIC_V19: &[u8] = b"edith 19";255 const MAGIC_V19: &[u8] = b"edith 19";
@@ -650,8 +657,11 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
650 // The dialects that wrote a source line without its stream field. Reading657 // The dialects that wrote a source line without its stream field. Reading
651 // one is the whole of what "an old project still opens" means here.658 // one is the whole of what "an old project still opens" means here.
652 let streamless = v1 || first == MAGIC_V2;659 let streamless = v1 || first == MAGIC_V2;
660+ // The one that carries a strand colour of its own above the packed
661+ // visualizer paint (hue/sat, with the top bit as the flag)...
662+ let v23 = first == MAGIC;
653 // The one that carries packed visualizer paint (hue/sat/strands/glow)...663 // The one that carries packed visualizer paint (hue/sat/strands/glow)...
654- let v22 = first == MAGIC;664+ let v22 = v23 || first == MAGIC_V22;
655 // The one that carries per-clip visualizer flags...665 // The one that carries per-clip visualizer flags...
656 let v21 = v22 || first == MAGIC_V21;666 let v21 = v22 || first == MAGIC_V21;
657 // The one that carries a per-clip transform (position/scale/rotate/crop)...667 // The one that carries a per-clip transform (position/scale/rotate/crop)...
@@ -1206,7 +1216,7 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> {
1206 fade_out: number(f.get(10).copied().unwrap_or(b"0"), n)?.min(frames),1216 fade_out: number(f.get(10).copied().unwrap_or(b"0"), n)?.min(frames),
1207 transition_out: number(f.get(11).copied().unwrap_or(b"0"), n)?.min(frames),1217 transition_out: number(f.get(11).copied().unwrap_or(b"0"), n)?.min(frames),
1208 visualizer: number(f.get(13).copied().unwrap_or(b"0"), n)? as u8,1218 visualizer: number(f.get(13).copied().unwrap_or(b"0"), n)? as u8,
1209- viz_paint: number(f.get(14).copied().unwrap_or(b"0"), n)? as u32,1219+ viz_paint: number64(f.get(14).copied().unwrap_or(b"0"), n)?,
1210 start: number(f[0], n)?,1220 start: number(f[0], n)?,
1211 in_frame,1221 in_frame,
1212 out_frame,1222 out_frame,
@@ -1473,6 +1483,19 @@ fn number(field: &[u8], line: usize) -> crate::Result<u32> {
1473 }1483 }
1474 }1484 }
1475 1485
1486+/// [`number`] for the one field wider than a `u32`: the clip's packed
1487+/// visualizer look, whose strand-colour half needs the width (v23).
1488+fn number64(field: &[u8], line: usize) -> crate::Result<u64> {
1489+ match std::str::from_utf8(field).ok().and_then(|s| s.parse().ok()) {
1490+ Some(n) => Ok(n),
1491+ None => Err(format!(
1492+ "line {line}: {:?} is not a number",
1493+ String::from_utf8_lossy(field)
1494+ )
1495+ .into()),
1496+ }
1497+}
1498+
1476 /// A `sub` line's window field: microseconds, which is the clock a cue is timed1499 /// A `sub` line's window field: microseconds, which is the clock a cue is timed
1477 /// in ([`crate::subtitle::Cue`]) and the one thing in this format counted in1500 /// in ([`crate::subtitle::Cue`]) and the one thing in this format counted in
1478 /// something other than frames. Signed as the cues are, and the negative half1501 /// something other than frames. Signed as the cues are, and the negative half
@@ -1636,7 +1659,7 @@ mod tests {
1636 video 1 0 0 30 0 - - - fit 1000\n";1659 video 1 0 0 30 0 - - - fit 1000\n";
1637 let old = parse(v9, &dir).expect("v9 still loads");1660 let old = parse(v9, &dir).expect("v9 still loads");
1638 assert_eq!(old.subtitles, Vec::new());1661 assert_eq!(old.subtitles, Vec::new());
1639- assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 22\n"));1662+ assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 23\n"));
1640 // ...and the line itself is not a v9 line: a dialect may not be mixed.1663 // ...and the line itself is not a v9 line: a dialect may not be mixed.
1641 let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir)1664 let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir)
1642 .unwrap_err()1665 .unwrap_err()
@@ -2116,7 +2139,7 @@ mod tests {
2116 let bytes = flat(&dir, &sources, &lanes, 12);2139 let bytes = flat(&dir, &sources, &lanes, 12);
2117 assert_eq!(2140 assert_eq!(
2118 String::from_utf8_lossy(&bytes),2141 String::from_utf8_lossy(&bytes),
2119- "edith 22\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\2142+ "edith 23\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
2120 source 2 /elsewhere/b.mp4\n\2143 source 2 /elsewhere/b.mp4\n\
2121 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\2144 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\
2122 audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n",2145 audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n",
@@ -2153,7 +2176,7 @@ mod tests {
2153 let bytes = flat(&dir, &sources, &lanes, 7);2176 let bytes = flat(&dir, &sources, &lanes, 7);
2154 assert_eq!(2177 assert_eq!(
2155 String::from_utf8_lossy(&bytes),2178 String::from_utf8_lossy(&bytes),
2156- "edith 22\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\2179+ "edith 23\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\
2157 video 1 0 0 30 0 4 - - fit 1000 0 0 0 - 0 0\naudio 1\n\2180 video 1 0 0 30 0 4 - - fit 1000 0 0 0 - 0 0\naudio 1\n\
2158 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",2181 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",
2159 "an empty lane is a line of its own; everything else is its clips"2182 "an empty lane is a line of its own; everything else is its clips"
@@ -2281,7 +2304,7 @@ mod tests {
2281 let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0);2304 let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0);
2282 assert_eq!(2305 assert_eq!(
2283 String::from_utf8_lossy(&bytes),2306 String::from_utf8_lossy(&bytes),
2284- "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2307+ "edith 23\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2285 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\2308 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\
2286 eq 16777215.0:-0.1:3.918315e-39:hs\n\2309 eq 16777215.0:-0.1:3.918315e-39:hs\n\
2287 eq\n\2310 eq\n\
@@ -2405,7 +2428,7 @@ mod tests {
2405 let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0);2428 let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0);
2406 assert_eq!(2429 assert_eq!(
2407 String::from_utf8_lossy(&bytes),2430 String::from_utf8_lossy(&bytes),
2408- "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2431+ "edith 23\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2409 color 0.1:1.2:0.9:-0.3\n\2432 color 0.1:1.2:0.9:-0.3\n\
2410 color -1e-7:16777215.0:3.918315e-39:-0.0\n\2433 color -1e-7:16777215.0:3.918315e-39:-0.0\n\
2411 color 0.0:1.0:1.0:0.0\n\2434 color 0.0:1.0:1.0:0.0\n\
@@ -2470,7 +2493,7 @@ mod tests {
2470 (1280, 720),2493 (1280, 720),
2471 old.playhead2494 old.playhead
2472 )),2495 )),
2473- "edith 22\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\2496+ "edith 23\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
2474 eq 80.0:-3.0:0.707:ls\n\2497 eq 80.0:-3.0:0.707:ls\n\
2475 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"2498 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"
2476 );2499 );
@@ -2514,7 +2537,7 @@ mod tests {
2514 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);2537 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);
2515 assert_eq!(2538 assert_eq!(
2516 String::from_utf8_lossy(&bytes),2539 String::from_utf8_lossy(&bytes),
2517- "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2540+ "edith 23\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2518 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\2541 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\
2519 audio 1 0 0 30 0 - - - fit 2000 0 0 0 - 0 0\n",2542 audio 1 0 0 30 0 - - - fit 2000 0 0 0 - 0 0\n",
2520 "the rate is the clip line's last field, in thousandths"2543 "the rate is the clip line's last field, in thousandths"
@@ -2543,7 +2566,7 @@ mod tests {
2543 (1280, 720),2566 (1280, 720),
2544 old.playhead2567 old.playhead
2545 )),2568 )),
2546- "edith 22\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\2569+ "edith 23\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
2547 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"2570 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"
2548 );2571 );
2549 // A rate outside what the editor can set is a corrupt line, by name.2572 // A rate outside what the editor can set is a corrupt line, by name.
@@ -2594,7 +2617,7 @@ mod tests {
2594 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);2617 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);
2595 assert_eq!(2618 assert_eq!(
2596 String::from_utf8_lossy(&bytes),2619 String::from_utf8_lossy(&bytes),
2597- "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2620+ "edith 23\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2598 video 1 0 0 30 0 - - - fit 1000 5 7 0 - 0 0\n",2621 video 1 0 0 30 0 - - - fit 1000 5 7 0 - 0 0\n",
2599 "the fades are the clip line's last two fields"2622 "the fades are the clip line's last two fields"
2600 );2623 );
@@ -2647,7 +2670,7 @@ mod tests {
2647 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);2670 let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0);
2648 assert_eq!(2671 assert_eq!(
2649 String::from_utf8_lossy(&bytes),2672 String::from_utf8_lossy(&bytes),
2650- "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2673+ "edith 23\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2651 video 1 0 0 30 0 - - - fit 1000 0 0 9 - 0 0\n",2674 video 1 0 0 30 0 - - - fit 1000 0 0 9 - 0 0\n",
2652 "the dissolve is the clip line's own last field"2675 "the dissolve is the clip line's own last field"
2653 );2676 );
@@ -2658,6 +2681,54 @@ mod tests {
2658 );2681 );
2659 }2682 }
2660 2683
2684+ /// The clip's packed look (v23): a chosen strand colour rides in the
2685+ /// field's own bytes under the top bit and comes back bit-exact, a v22
2686+ /// file's 32-bit value is the low half of that field with no strand
2687+ /// colour, and a file older than the field itself is the zero it always
2688+ /// was.
2689+ #[test]
2690+ fn a_strand_colour_round_trips_and_a_v22_look_stays_32_bit() {
2691+ use crate::decode::{
2692+ viz_hue_ui, viz_sat_ui, viz_strand_set, with_viz_paint_strand_hue,
2693+ with_viz_paint_strand_sat, VIZ_PAINT_AZURE,
2694+ };
2695+ let (dir, sources, lanes) = doc();
2696+ let mut painted = lanes.clone();
2697+ // Azure, its dual half a chosen green rather than the automatic
2698+ // complement of the clip's own hue.
2699+ let chosen = with_viz_paint_strand_sat(with_viz_paint_strand_hue(VIZ_PAINT_AZURE, 64), 200);
2700+ assert!(viz_strand_set(chosen));
2701+ painted[0].1[0].viz_paint = chosen;
2702+ let bytes = flat(&dir, &sources, &painted, 0);
2703+ assert!(
2704+ bytes.starts_with(b"edith 23\n"),
2705+ "a project with a strand colour saves as v23: {}",
2706+ String::from_utf8_lossy(&bytes)
2707+ );
2708+ let back = parse(&bytes, &dir).expect("v23 parses");
2709+ assert_eq!(back.lanes, painted, "the look round-trips bit-exactly");
2710+
2711+ // A v22 file's field is a u32: the value lands in the low half
2712+ // untouched, and a strand colour it cannot carry reads as auto.
2713+ let look = VIZ_PAINT_AZURE as u32;
2714+ let v22 = format!(
2715+ "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2716+ video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 {look}\n"
2717+ );
2718+ let old = parse(v22.as_bytes(), &dir).expect("v22 still loads");
2719+ let paint = old.lanes[0].1[0].viz_paint;
2720+ assert_eq!(paint, u64::from(look), "the low half is the v22 value");
2721+ assert!(!viz_strand_set(paint), "a v22 look chose no strand colour");
2722+ assert_eq!(viz_hue_ui(paint), 150);
2723+ assert_eq!(viz_sat_ui(paint), 160);
2724+ // ...and a file older than the field is the zero that means the
2725+ // azure default, as it was before the field was widened.
2726+ let v21 = b"edith 21\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2727+ video 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0\n";
2728+ let older = parse(v21, &dir).expect("v21 still loads");
2729+ assert_eq!(older.lanes[0].1[0].viz_paint, 0);
2730+ }
2731+
2661 /// A v19 file is a v20 one that places no clip anywhere but its fit2732 /// A v19 file is a v20 one that places no clip anywhere but its fit
2662 /// policy's own spot: it loads with every clip's [`Clip::transform`] at2733 /// policy's own spot: it loads with every clip's [`Clip::transform`] at
2663 /// `None`, which is what a v19 file's missing field still means.2734 /// `None`, which is what a v19 file's missing field still means.
@@ -2785,7 +2856,7 @@ mod tests {
2785 );2856 );
2786 assert_eq!(2857 assert_eq!(
2787 String::from_utf8_lossy(&bytes),2858 String::from_utf8_lossy(&bytes),
2788- "edith 22\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\2859+ "edith 23\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\
2789 transform 0.1:-0.2:1.5:90.0:0.1:0.0:0.0:0.05\n\2860 transform 0.1:-0.2:1.5:90.0:0.1:0.0:0.0:0.05\n\
2790 transform -1e-7:16777215.0:3.918315e-39:-0.0:0.0:0.0:0.0:0.0\n\2861 transform -1e-7:16777215.0:3.918315e-39:-0.0:0.0:0.0:0.0:0.0\n\
2791 transform 0.0:0.0:1.0:0.0:0.0:0.0:0.0:0.0\n\2862 transform 0.0:0.0:1.0:0.0:0.0:0.0:0.0:0.0\n\
@@ -2865,7 +2936,7 @@ mod tests {
2865 );2936 );
2866 assert_eq!(2937 assert_eq!(
2867 String::from_utf8_lossy(&bytes),2938 String::from_utf8_lossy(&bytes),
2868- "edith 22\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\2939+ "edith 23\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\
2869 limiter -1.5 on\nsource 0 a.mp4\n\2940 limiter -1.5 on\nsource 0 a.mp4\n\
2870 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\2941 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\
2871 audio 2 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\n\2942 audio 2 0 0 30 0 - - - fit 1000 0 0 0 - 0 0\n\
@@ -2897,7 +2968,7 @@ mod tests {
2897 (1280, 720),2968 (1280, 720),
2898 old.playhead2969 old.playhead
2899 )),2970 )),
2900- "edith 22\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\2971+ "edith 23\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\
2901 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"2972 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"
2902 );2973 );
2903 2974
@@ -3061,7 +3132,7 @@ mod tests {
3061 assert!(old.eq.is_empty(), "nothing before v5 equalizes anything");3132 assert!(old.eq.is_empty(), "nothing before v5 equalizes anything");
3062 assert_eq!(3133 assert_eq!(
3063 String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)),3134 String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)),
3064- "edith 22\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\3135+ "edith 23\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
3065 source 2 /elsewhere/b.mp4\n\3136 source 2 /elsewhere/b.mp4\n\
3066 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\3137 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\
3067 audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n"3138 audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n"
@@ -3114,7 +3185,7 @@ mod tests {
3114 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);3185 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);
3115 assert_eq!(3186 assert_eq!(
3116 String::from_utf8_lossy(&v5),3187 String::from_utf8_lossy(&v5),
3117- "edith 22\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\3188+ "edith 23\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\
3118 source 0 /elsewhere/b.mp4\n\3189 source 0 /elsewhere/b.mp4\n\
3119 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\3190 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\
3120 audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n",3191 audio 1 0 0 30 0 0 - - fit 1000 0 0 0 - 0 0\n",
@@ -3146,7 +3217,7 @@ mod tests {
3146 // Saved again it is the current version, which round-trips to the3217 // Saved again it is the current version, which round-trips to the
3147 // same document.3218 // same document.
3148 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);3219 let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead);
3149- assert!(v5.starts_with(b"edith 22\n"));3220+ assert!(v5.starts_with(b"edith 23\n"));
3150 let again = parse(&v5, &dir).expect("v5 parses");3221 let again = parse(&v5, &dir).expect("v5 parses");
3151 assert_eq!(again.lanes, back.lanes);3222 assert_eq!(again.lanes, back.lanes);
3152 // A dialect may not be mixed: lane lines under v1, `clip` under v2.3223 // A dialect may not be mixed: lane lines under v1, `clip` under v2.
@@ -3257,7 +3328,7 @@ mod tests {
3257 let bytes = std::fs::read(&path).expect("read back");3328 let bytes = std::fs::read(&path).expect("read back");
3258 assert_eq!(3329 assert_eq!(
3259 String::from_utf8_lossy(&bytes),3330 String::from_utf8_lossy(&bytes),
3260- "edith 22\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\3331+ "edith 23\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\
3261 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"3332 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"
3262 );3333 );
3263 // Loading rejoins the *given* directory, so the file is reached by the3334 // Loading rejoins the *given* directory, so the file is reached by the
@@ -3302,10 +3373,10 @@ mod tests {
3302 #[test]3373 #[test]
3303 fn a_wrong_first_line_is_refused_by_name() {3374 fn a_wrong_first_line_is_refused_by_name() {
3304 let dir = PathBuf::from("/proj");3375 let dir = PathBuf::from("/proj");
3305- let err = parse(b"edith 23\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir)3376+ let err = parse(b"edith 24\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir)
3306 .unwrap_err()3377 .unwrap_err()
3307 .to_string();3378 .to_string();
3308- assert_eq!(err, "line 1: unsupported version 23");3379+ assert_eq!(err, "line 1: unsupported version 24");
3309 for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] {3380 for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] {
3310 assert_eq!(3381 assert_eq!(
3311 parse(junk, &dir).unwrap_err().to_string(),3382 parse(junk, &dir).unwrap_err().to_string(),
crates/engine/src/export.rsmodified+2 -2
@@ -4426,7 +4426,7 @@ enum ClipDecoder {
4426 fps: f64,4426 fps: f64,
4427 next: u32,4427 next: u32,
4428 flags: u8,4428 flags: u8,
4429- paint: u32,4429+ paint: u64,
4430 y: Vec<u8>,4430 y: Vec<u8>,
4431 u: Vec<u8>,4431 u: Vec<u8>,
4432 v: Vec<u8>,4432 v: Vec<u8>,
@@ -4540,7 +4540,7 @@ impl ClipDecoder {
4540 height: u32,4540 height: u32,
4541 fps: f64,4541 fps: f64,
4542 flags: u8,4542 flags: u8,
4543- paint: u32,4543+ paint: u64,
4544 ) -> crate::Result<Self> {4544 ) -> crate::Result<Self> {
4545 let peaks = crate::waveform::peaks(path, stream, crate::decode::VIZ_BUCKETS_PER_SEC)4545 let peaks = crate::waveform::peaks(path, stream, crate::decode::VIZ_BUCKETS_PER_SEC)
4546 .ok()4546 .ok()
crates/engine/src/playback.rsmodified+31 -1
@@ -2984,10 +2984,18 @@ impl PlaybackSession {
2984 self.edit(Dirty::Picture, |p| p.set_visualizer(lane, idx, flags))2984 self.edit(Dirty::Picture, |p| p.set_visualizer(lane, idx, flags))
2985 }2985 }
2986 2986
2987- pub fn set_viz_paint(&mut self, lane: Lane, idx: usize, paint: u32) -> bool {2987+ pub fn set_viz_paint(&mut self, lane: Lane, idx: usize, paint: u64) -> bool {
2988 self.edit(Dirty::Picture, |p| p.set_viz_paint(lane, idx, paint))2988 self.edit(Dirty::Picture, |p| p.set_viz_paint(lane, idx, paint))
2989 }2989 }
2990 2990
2991+ /// The same look and the same repaint without the undo step
2992+ /// ([`Project::set_viz_paint_live`]): what the samples inside one drag
2993+ /// across the colour wheel go through, so the picture follows the hand and
2994+ /// the whole gesture is still a single `z`.
2995+ pub fn set_viz_paint_live(&mut self, lane: Lane, idx: usize, paint: u64) -> bool {
2996+ self.edit(Dirty::Picture, |p| p.set_viz_paint_live(lane, idx, paint))
2997+ }
2998+
2991 /// Timeline frames of ramp-up from silence at the start of the clip at2999 /// Timeline frames of ramp-up from silence at the start of the clip at
2992 /// `idx` of `lane`. `0` for an index that is not there.3000 /// `idx` of `lane`. `0` for an index that is not there.
2993 pub fn fade_in_of(&self, lane: Lane, idx: usize) -> u32 {3001 pub fn fade_in_of(&self, lane: Lane, idx: usize) -> u32 {
@@ -4795,5 +4803,27 @@ mod tests {
4795 assert_eq!(before, s.restarts(), "a live transform edit must reuse the worker");4803 assert_eq!(before, s.restarts(), "a live transform edit must reuse the worker");
4796 assert_eq!(next.index, first.index, "paused: same timeline position before and after");4804 assert_eq!(next.index, first.index, "paused: same timeline position before and after");
4797 }4805 }
4806+
4807+ /// The session's live look samples leave its history exactly where the
4808+ /// press left it -- the colour-wheel drag's twin for the packed look, and
4809+ /// what lets the app drive one from a pointer: `z` after a drag lands
4810+ /// before the press, not one sample back down the drag.
4811+ #[test]
4812+ fn a_live_look_drag_is_one_step_of_the_sessions_history() {
4813+ let mut s = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
4814+ let (lane, idx) = s.video_clip_at(s.now()).expect("a clip under the playhead");
4815+ let look = |hue: u8| crate::decode::with_viz_paint_hue(crate::decode::VIZ_PAINT_AZURE, hue);
4816+ assert!(s.set_viz_paint(lane, idx, look(1)), "the press");
4817+ for hue in 2..=6u8 {
4818+ assert!(s.set_viz_paint_live(lane, idx, look(hue)), "a sample");
4819+ }
4820+ assert_eq!(s.project.lane(lane)[idx].viz_paint, look(6));
4821+ assert!(s.undo(), "the drag's own step");
4822+ assert_eq!(
4823+ s.project.lane(lane)[idx].viz_paint,
4824+ 0,
4825+ "one undo is the whole drag"
4826+ );
4827+ }
4798 }4828 }
4799 4829
crates/engine/src/project.rsmodified+75 -9
@@ -461,10 +461,15 @@ pub struct Clip {
461 /// Zero is an ordinary picture. Older project files have no field and461 /// Zero is an ordinary picture. Older project files have no field and
462 /// mean zero.462 /// mean zero.
463 pub visualizer: u8,463 pub visualizer: u8,
464- /// Packed look: hue 0-255, sat 0-255, strands 0-255, glow 0-255.464+ /// Packed look: hue 0-255, sat 0-255, strands 0-255, glow 0-255 in the
465- /// All-zero is the default (timeline azure, full sat, 8 strands, glow 2).465+ /// low four bytes as they have been since v22, then the strand colour's
466- /// Older files have no field and mean zero.466+ /// own bytes above them -- its hue at 32 and sat at 40
467- pub viz_paint: u32,467+ /// ([`crate::decode::viz_strand_hue_ui`]) -- with the top bit as
468+ /// [`crate::decode::viz_strand_set`]. All-zero is the default (timeline
469+ /// azure, full sat, 8 strands, glow 2, no strand colour of its own).
470+ /// Older files have no field and mean zero; a v22 file's 32-bit value
471+ /// is the low half of this one, byte for byte.
472+ pub viz_paint: u64,
468 }473 }
469 474
470 impl Clip {475 impl Clip {
@@ -2653,11 +2658,28 @@ impl Project {
2653 true2658 true
2654 }2659 }
2655 2660
2656- pub fn set_viz_paint(&mut self, lane: Lane, idx: usize, paint: u32) -> bool {2661+ /// Give the clip at `idx` of `lane` this packed look: one undo step, and
2662+ /// `false` (with no history) for an index that is not there, the way every
2663+ /// other setter refuses.
2664+ pub fn set_viz_paint(&mut self, lane: Lane, idx: usize, paint: u64) -> bool {
2665+ self.write_viz_paint(lane, idx, paint, true)
2666+ }
2667+
2668+ /// [`set_viz_paint`](Self::set_viz_paint) without the undo step: the
2669+ /// samples *inside* one pointer drag across the colour wheel, whose first
2670+ /// write (a plain `set_viz_paint`) already took the snapshot the gesture
2671+ /// rolls back to. One drag is one undo, not one per sample.
2672+ pub fn set_viz_paint_live(&mut self, lane: Lane, idx: usize, paint: u64) -> bool {
2673+ self.write_viz_paint(lane, idx, paint, false)
2674+ }
2675+
2676+ fn write_viz_paint(&mut self, lane: Lane, idx: usize, paint: u64, snapshot: bool) -> bool {
2657 if idx >= self.lane(lane).len() {2677 if idx >= self.lane(lane).len() {
2658 return false;2678 return false;
2659 }2679 }
2680+ if snapshot {
2660 self.snapshot();2681 self.snapshot();
2682+ }
2661 self.lane_mut(lane).expect("checked above")[idx].viz_paint = paint;2683 self.lane_mut(lane).expect("checked above")[idx].viz_paint = paint;
2662 true2684 true
2663 }2685 }
@@ -3049,7 +3071,10 @@ impl Project {
3049 .unwrap_or(0)3071 .unwrap_or(0)
3050 }3072 }
3051 3073
3052- pub fn composite_viz_paint_at(&self, timeline_frame: u32) -> u32 {3074+ /// Packed look ([`Clip::viz_paint`]) of the topmost video clip at
3075+ /// `timeline_frame`, or zero over a gap / a picture that is not a
3076+ /// visualizer.
3077+ pub fn composite_viz_paint_at(&self, timeline_frame: u32) -> u64 {
3053 self.composite_clip_at(timeline_frame)3078 self.composite_clip_at(timeline_frame)
3054 .map(|(lane, idx)| self.lane(lane)[idx].viz_paint)3079 .map(|(lane, idx)| self.lane(lane)[idx].viz_paint)
3055 .unwrap_or(0)3080 .unwrap_or(0)
@@ -7225,13 +7250,17 @@ mod tests {
7225 /// The transform index is a third `Option<u16>`, same reason as the eq and7250 /// The transform index is a third `Option<u16>`, same reason as the eq and
7226 /// colour ones before it -- it lands in bytes already spent on padding, so7251 /// colour ones before it -- it lands in bytes already spent on padding, so
7227 /// the struct still costs 56.7252 /// the struct still costs 56.
7253+ /// The visualizer look is the first field whose own width outgrows the
7254+ /// padding it lands in: it is a `u64` (a strand colour needs bytes above
7255+ /// the clip's own four), so the words after it come to 60 and the
7256+ /// alignment rounds them to 64 -- one word more than a clip used to cost.
7228 /// This is the assert that says so: a clip that grows a word grows every7257 /// This is the assert that says so: a clip that grows a word grows every
7229 /// undo snapshot and every clipboard copy with it.7258 /// undo snapshot and every clipboard copy with it.
7230 #[test]7259 #[test]
7231 fn a_fit_policy_costs_the_clip_no_word() {7260 fn a_fit_policy_costs_the_clip_no_word() {
7232 assert_eq!(7261 assert_eq!(
7233 std::mem::size_of::<Clip>(),7262 std::mem::size_of::<Clip>(),
7234- 56,7263+ 64,
7235 "Clip changed size: {} bytes",7264 "Clip changed size: {} bytes",
7236 std::mem::size_of::<Clip>()7265 std::mem::size_of::<Clip>()
7237 );7266 );
@@ -8893,6 +8922,40 @@ mod tests {
8893 );8922 );
8894 }8923 }
8895 8924
8925+ /// A drag across the colour wheel is one gesture -- the look's twin of
8926+ /// [`a_whole_colour_drag_undoes_in_one_step`]: the press snapshots, every
8927+ /// sample after it only repaints, and the single undo lands on the look
8928+ /// the clip had *before* the hand touched it. The committing setter is
8929+ /// still exactly one step, refusals included.
8930+ #[test]
8931+ fn a_whole_look_drag_undoes_in_one_step() {
8932+ let look = |hue: u8| crate::decode::with_viz_paint_hue(crate::decode::VIZ_PAINT_AZURE, hue);
8933+ let mut p = three();
8934+ assert!(p.set_viz_paint(Lane::V1, 0, look(1)), "the press");
8935+ for hue in 2..=8u8 {
8936+ assert!(p.set_viz_paint_live(Lane::V1, 0, look(hue)), "a sample");
8937+ }
8938+ assert_eq!(p.lane(Lane::V1)[0].viz_paint, look(8));
8939+ assert!(p.undo());
8940+ assert_eq!(
8941+ p.lane(Lane::V1)[0].viz_paint,
8942+ 0,
8943+ "one undo is the whole gesture, back to the default look"
8944+ );
8945+
8946+ // The live write refuses an index that is not there -- and a refusal
8947+ // costs no history -- while one committing write is one step back.
8948+ assert!(!p.set_viz_paint_live(Lane::V1, 99, look(1)));
8949+ assert!(p.set_viz_paint(Lane::V1, 0, look(1)), "a click, not a drag");
8950+ assert_eq!(p.lane(Lane::V1)[0].viz_paint, look(1));
8951+ assert!(p.undo());
8952+ assert_eq!(
8953+ p.lane(Lane::V1)[0].viz_paint,
8954+ 0,
8955+ "the committing setter is one undo step, no more"
8956+ );
8957+ }
8958+
8896 /// The colour table is append-only within a session, exactly as the eq one8959 /// The colour table is append-only within a session, exactly as the eq one
8897 /// is -- and a save is where an undone grade goes.8960 /// is -- and a save is where an undone grade goes.
8898 #[test]8961 #[test]
@@ -9052,12 +9115,15 @@ mod tests {
9052 /// colour one did not, and the struct grew a word. The transform index is9115 /// colour one did not, and the struct grew a word. The transform index is
9053 /// a third `Option<u16>`, and it fits the padding the fit policy and the9116 /// a third `Option<u16>`, and it fits the padding the fit policy and the
9054 /// transition byte already left behind, so the struct did not grow again.9117 /// transition byte already left behind, so the struct did not grow again.
9118+ /// The packed visualizer look is a `u64` -- the strand colour has bytes
9119+ /// above the clip's own four -- and nothing left in the struct is wide
9120+ /// enough to hold it, so it grew a word again.
9055 #[test]9121 #[test]
9056 fn a_clip_is_still_a_small_copy() {9122 fn a_clip_is_still_a_small_copy() {
9057 assert_eq!(9123 assert_eq!(
9058 std::mem::size_of::<Clip>(),9124 std::mem::size_of::<Clip>(),
9059- 56,9125+ 64,
9060- "Clip changed size -- 32 before the colour index, 40 before the fades, 48 after, 56 with the transition, still 56 with the transform index"9126+ "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"
9061 );9127 );
9062 }9128 }
9063 9129
crates/engine/tests/export.rsmodified+1 -1
@@ -1253,7 +1253,7 @@ fn a_proxy_is_picture_only_every_frame_a_starting_point_and_cached() {
1253 session.set_proxies(true);1253 session.set_proxies(true);
1254 session.save_project(&project).expect("save");1254 session.save_project(&project).expect("save");
1255 let text = std::fs::read_to_string(&project).expect("read the project back");1255 let text = std::fs::read_to_string(&project).expect("read the project back");
1256- assert!(text.starts_with("edith 20\n"), "{text}");1256+ assert!(text.starts_with("edith 23\n"), "{text}");
1257 assert!(text.contains("\nproxy on\n"), "{text}");1257 assert!(text.contains("\nproxy on\n"), "{text}");
1258 let reopened = PlaybackSession::open_project(&project).expect("load");1258 let reopened = PlaybackSession::open_project(&project).expect("load");
1259 assert!(reopened.proxies(), "the switch came back on");1259 assert!(reopened.proxies(), "the switch came back on");
crates/engine/tests/saveload.rsmodified+13 -13
@@ -292,7 +292,7 @@ fn a_version_1_project_loads_fully_grouped_and_saves_as_version_7() {
292 let v2 = dir.join("new.edith");292 let v2 = dir.join("new.edith");
293 loaded.save_project(&v2).expect("save");293 loaded.save_project(&v2).expect("save");
294 let text = std::fs::read_to_string(&v2).expect("read back");294 let text = std::fs::read_to_string(&v2).expect("read back");
295- assert!(text.starts_with("edith 20\n"), "{text}");295+ assert!(text.starts_with("edith 23\n"), "{text}");
296 assert!(296 assert!(
297 text.contains("\nresolution 1280 720\n"),297 text.contains("\nresolution 1280 720\n"),
298 "a project with no resolution of its own is saved at source 0's: {text}"298 "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() {
380 loaded.save_project(&again).expect("save");380 loaded.save_project(&again).expect("save");
381 assert_eq!(381 assert_eq!(
382 std::fs::read_to_string(&again).expect("read back"),382 std::fs::read_to_string(&again).expect("read back"),
383- "edith 20\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\383+ "edith 23\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
384- video 1 0 0 30 0 3 - - fit 1000 0 0 0 -\naudio 1\n\384+ video 1 0 0 30 0 3 - - fit 1000 0 0 0 - 0 0\naudio 1\n\
385- video 2 40 0 20 0 - - - fit 1000 0 0 0 -\naudio 2 0 0 30 0 3 - - fit 1000 0 0 0 -\n",385+ 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",
386 "a four-lane project is written as it was read, three versions on"386 "a four-lane project is written as it was read, three versions on"
387 );387 );
388 }388 }
@@ -410,11 +410,11 @@ fn a_version_5_project_carries_per_clip_equalizers() {
410 loaded.save_project(&again).expect("save");410 loaded.save_project(&again).expect("save");
411 assert_eq!(411 assert_eq!(
412 std::fs::read_to_string(&again).expect("read back"),412 std::fs::read_to_string(&again).expect("read back"),
413- "edith 20\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\413+ "edith 23\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
414 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\414 eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\
415 eq 12000.0:6.25:0.5:hs\n\415 eq 12000.0:6.25:0.5:hs\n\
416- 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\416+ 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\
417- audio 1 0 0 30 0 - 0 - fit 1000 0 0 0 -\naudio 1 30 30 60 0 - - - fit 1000 0 0 0 -\n",417+ 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",
418 "the equalizer table and every clip's index survive a round trip"418 "the equalizer table and every clip's index survive a round trip"
419 );419 );
420 }420 }
@@ -445,12 +445,12 @@ fn a_version_6_project_carries_per_clip_colours() {
445 loaded.save_project(&again).expect("save");445 loaded.save_project(&again).expect("save");
446 assert_eq!(446 assert_eq!(
447 std::fs::read_to_string(&again).expect("read back"),447 std::fs::read_to_string(&again).expect("read back"),
448- "edith 20\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\448+ "edith 23\nplayhead 0\nresolution 1280 720\nfps 30.0\nsource 0 test_av.mp4\n\
449 eq 80.0:-3.0:0.707:ls\n\449 eq 80.0:-3.0:0.707:ls\n\
450 color 0.1:1.2:0.9:-0.3\n\450 color 0.1:1.2:0.9:-0.3\n\
451 color -0.25:1.0:0.0:0.5\n\451 color -0.25:1.0:0.0:0.5\n\
452- 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\452+ 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\
453- audio 1 0 0 30 0 - - 0 fit 1000 0 0 0 -\naudio 1 30 30 60 0 - - - fit 1000 0 0 0 -\n",453+ 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",
454 "the colour table and every clip's index survive a round trip"454 "the colour table and every clip's index survive a round trip"
455 );455 );
456 // A dialect that could not say either one means the defaults, and those are456 // 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() {
495 loaded.save_project(&again).expect("save");495 loaded.save_project(&again).expect("save");
496 assert_eq!(496 assert_eq!(
497 std::fs::read_to_string(&again).expect("read back"),497 std::fs::read_to_string(&again).expect("read back"),
498- "edith 20\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\498+ "edith 23\nplayhead 0\nresolution 960 720\nfps 30.0\nsource 0 test_av.mp4\n\
499- video 1 0 0 30 0 - - - fill 1000 0 0 0 -\nvideo 1 30 30 60 0 - - - center 1000 0 0 0 -\n\499+ 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\
500- audio 1 0 0 60 0 - - - fit 1000 0 0 0 -\n",500+ audio 1 0 0 60 0 - - - fit 1000 0 0 0 - 0 0\n",
501 "a v7 project is written back as the v8 it now is: the same clips, each \501 "a v7 project is written back as the v8 it now is: the same clips, each \
502 saying it plays at real time, which is what it always played at"502 saying it plays at real time, which is what it always played at"
503 );503 );
crates/engine/tests/silence.rsmodified+1 -1
@@ -400,7 +400,7 @@ fn scanning_a_clip_and_cutting_what_it_finds() {
400 .expect("save");400 .expect("save");
401 let text = std::fs::read_to_string(&file).expect("read it back");401 let text = std::fs::read_to_string(&file).expect("read it back");
402 assert!(402 assert!(
403- text.starts_with("edith 20"),403+ text.starts_with("edith 23"),
404 "{:?}",404 "{:?}",
405 &text[..16.min(text.len())]405 &text[..16.min(text.len())]
406 );406 );
crates/engine/tests/subtitles.rsmodified+3 -3
@@ -260,7 +260,7 @@ fn a_project_keeps_its_subtitles_across_a_save() {
260 let project = dir.join("cut.edith");260 let project = dir.join("cut.edith");
261 session.save_project(&project).expect("save");261 session.save_project(&project).expect("save");
262 let text = std::fs::read_to_string(&project).expect("read the project back");262 let text = std::fs::read_to_string(&project).expect("read the project back");
263- assert!(text.starts_with("edith 20\n"), "{text}");263+ assert!(text.starts_with("edith 23\n"), "{text}");
264 assert!(264 assert!(
265 text.contains("\nsubtitle - test_subs.srt\n"),265 text.contains("\nsubtitle - test_subs.srt\n"),
266 "the reference is written relative, and no cue is: {text}"266 "the reference is written relative, and no cue is: {text}"
@@ -1251,7 +1251,7 @@ fn subtitle_lanes_and_their_captions_survive_a_save() {
1251 let project = dir.join("cut.edith");1251 let project = dir.join("cut.edith");
1252 session.save_project(&project).expect("save");1252 session.save_project(&project).expect("save");
1253 let text = std::fs::read_to_string(&project).expect("read the project back");1253 let text = std::fs::read_to_string(&project).expect("read the project back");
1254- assert!(text.starts_with("edith 20\n"), "{text}");1254+ assert!(text.starts_with("edith 23\n"), "{text}");
1255 assert!(1255 assert!(
1256 text.contains("\nsub 1 10 45 0 500000 1500000\n"),1256 text.contains("\nsub 1 10 45 0 500000 1500000\n"),
1257 "the placement is one line: where it sits, how long, whose words, and \1257 "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() {
1317 let now = dir.join("new.edith");1317 let now = dir.join("new.edith");
1318 loaded.save_project(&now).expect("save");1318 loaded.save_project(&now).expect("save");
1319 let text = std::fs::read_to_string(&now).expect("read back");1319 let text = std::fs::read_to_string(&now).expect("read back");
1320- assert!(text.starts_with("edith 20\n"), "{text}");1320+ assert!(text.starts_with("edith 23\n"), "{text}");
1321 assert!(1321 assert!(
1322 text.contains("\nsubtitle - test_subs.srt\n"),1322 text.contains("\nsubtitle - test_subs.srt\n"),
1323 "the row survives the migration: {text}"1323 "the row survives the migration: {text}"