From 501c5a70c48a5eaff7ffdc571b7a495f3d91cafc Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 14 Nov 2026 03:37:33 +0000 Subject: [PATCH 1/3] wip: wire shared craft-gif animation writer in effectcraft-export --- Cargo.lock | 94 ++++++++++++++++++++--------- Cargo.toml | 42 ++++++------- crates/export/Cargo.toml | 3 +- crates/export/src/lib.rs | 53 ++++++++++------ crates/export/tests/it/roundtrip.rs | 48 +++++++++++++++ xtask/src/pdf_deps.rs | 2 +- 6 files changed, 174 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a525e39c9..aec0de6f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1092,26 +1092,26 @@ dependencies = [ [[package]] name = "craft-aep" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" [[package]] name = "craft-audio" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ - "craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9)", + "craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7)", "thiserror 2.0.21", ] [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" [[package]] name = "craft-dpx" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "thiserror 2.0.21", ] @@ -1119,7 +1119,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "serde", "serde_json", @@ -1129,12 +1129,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" [[package]] name = "craft-exr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "serde_json", ] @@ -1142,17 +1142,20 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" +dependencies = [ + "gif", +] [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "fixed_decimal", "icu_decimal", @@ -1175,8 +1178,9 @@ dependencies = [ [[package]] name = "craft-lottie" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ + "craft-zip", "serde_json", "thiserror 2.0.21", ] @@ -1184,7 +1188,7 @@ dependencies = [ [[package]] name = "craft-media" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "thiserror 2.0.21", ] @@ -1200,7 +1204,7 @@ dependencies = [ [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "miniz_oxide 0.9.1", "serde_json", @@ -1209,7 +1213,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "hayro-syntax", "thiserror 2.0.21", @@ -1218,7 +1222,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "encoding_rs", "flate2", @@ -1229,7 +1233,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "dispatch2", "egui", @@ -1240,19 +1244,21 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "craft-xml", "flate2", "kurbo", "roxmltree", "thiserror 2.0.21", + "vectorcraft-geom", + "vectorcraft-pathops", ] [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "craft-fonts-build", "craft-i18n", @@ -1273,7 +1279,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "chrono", "dunce", @@ -1300,9 +1306,9 @@ dependencies = [ [[package]] name = "craft-video" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ - "craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9)", + "craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7)", "rayon", "thiserror 2.0.21", ] @@ -1310,7 +1316,7 @@ dependencies = [ [[package]] name = "craft-webp" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "thiserror 2.0.21", ] @@ -1318,12 +1324,22 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "quick-xml 0.41.0", "thiserror 2.0.21", ] +[[package]] +name = "craft-zip" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" +dependencies = [ + "flate2", + "thiserror 2.0.21", + "zip 9.1.3", +] + [[package]] name = "crc32fast" version = "1.5.2" @@ -1683,7 +1699,8 @@ name = "effectcraft-export" version = "0.24.1" dependencies = [ "craft-audio", - "craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9)", + "craft-gif", + "craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7)", "craft-video", "effectcraft-color", "effectcraft-effects", @@ -1852,7 +1869,7 @@ dependencies = [ "craft-dpx", "craft-exr", "craft-gif", - "craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9)", + "craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7)", "craft-webp", "effectcraft-color", "effectcraft-effects", @@ -3422,7 +3439,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "hayro-ccitt", ] @@ -3436,7 +3453,7 @@ checksum = "c75ab947623ef4ccaa7acf0579edf7cbb5a73838e3839a7be73335e522f433a1" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9" +source = "git+https://github.com/storytold/craft-libs?rev=948b5c23c12dc8c87c8b1828892b1462113dd5a7#948b5c23c12dc8c87c8b1828892b1462113dd5a7" dependencies = [ "hayro-jbig2", "hayro-jpeg2000", @@ -6683,6 +6700,27 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "vectorcraft-geom" +version = "0.18.0" +source = "git+https://github.com/storytold/vectorcraft.git?rev=6b3a6b8788ebcb420d69449199cbdf323888d27e#6b3a6b8788ebcb420d69449199cbdf323888d27e" +dependencies = [ + "kurbo", + "serde", + "thiserror 2.0.21", +] + +[[package]] +name = "vectorcraft-pathops" +version = "0.18.0" +source = "git+https://github.com/storytold/vectorcraft.git?rev=6b3a6b8788ebcb420d69449199cbdf323888d27e#6b3a6b8788ebcb420d69449199cbdf323888d27e" +dependencies = [ + "kurbo", + "linesweeper", + "thiserror 2.0.21", + "vectorcraft-geom", +] + [[package]] name = "vello_common" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 08e34d741..247ba208e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,22 +11,22 @@ rust-version = "1.95" repository = "https://github.com/storytold/effectcraft" [workspace.dependencies] -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", version = "=0.1.0", default-features = false, features = ["read"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-quit = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-ecproj-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-dpx = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-eps = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-exr = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-gif = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-psd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-webp = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-lottie = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } -craft-mesh = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", default-features = false, features = ["stl", "obj", "gltf", "fbx"] } -craft-aep = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7", version = "=0.1.0", default-features = false, features = ["read"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-quit = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-ecproj-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-dpx = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-eps = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-exr = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-gif = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-psd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-webp = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-lottie = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } +craft-mesh = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7", default-features = false, features = ["stl", "obj", "gltf", "fbx"] } +craft-aep = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7" } # craft-update: app-specific pretend versions apply to startup and manual checks. -craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "47107f660191de2f0b425569506f4daa4faadac9", features = ["egui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7", features = ["egui"] } # internal effectcraft-time = { path = "crates/time" } effectcraft-geom = { path = "crates/geom" } @@ -90,9 +90,9 @@ same-file = "1.0" tempfile = "3.27" # codecs + containers shared by the Craft apps (crates/media, crates/export); keep all three on one rev. -craft-media = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", default-features = false, features = ["isobmff", "matroska"] } -craft-audio = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", default-features = false, features = ["aac-decode", "aac-encode", "opus-decode"] } -craft-video = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", features = ["h264-encode", "prores", "hevc-encode", "vp9-encode", "av1", "threads"] } +craft-media = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7", default-features = false, features = ["isobmff", "matroska"] } +craft-audio = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7", default-features = false, features = ["aac-decode", "aac-encode", "opus-decode"] } +craft-video = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7", features = ["h264-encode", "prores", "hevc-encode", "vp9-encode", "av1", "threads"] } # footage decoding: FilmCraft's pure-Rust crates, pinned to a revision (plan/adr/0001). # Only `crates/media`, `crates/export` and `crates/interchange` may depend on these. @@ -122,7 +122,7 @@ half = "2.7" # ui # Shared frontend components; keep this dependency above the engine boundary. # Shared UI and the complete egui family select reviewed immutable commits below. -craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", features = ["serde"] } +craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7", features = ["serde"] } # `default_fonts` and `monochrome_emoji_fonts` are explicit: the app's `FontDefinitions::default()` # and its `✔`/`▣` chrome glyphs need both, and kittest's own dev-dependencies do not propagate. egui = { version = "0.37", default-features = false, features = ["default_fonts", "monochrome_emoji_fonts"] } @@ -231,8 +231,8 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", version = "=0.7.2" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", version = "=0.3.0" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7", version = "=0.7.2" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "948b5c23c12dc8c87c8b1828892b1462113dd5a7", version = "=0.3.0" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } emath = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } epaint = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } diff --git a/crates/export/Cargo.toml b/crates/export/Cargo.toml index 164b10a7f..f1579686c 100644 --- a/crates/export/Cargo.toml +++ b/crates/export/Cargo.toml @@ -17,16 +17,17 @@ effectcraft-render = { workspace = true } craft-video = { workspace = true } craft-audio = { workspace = true } craft-media = { workspace = true } +craft-gif = { workspace = true } effectcraft-opusenc = { workspace = true } image = { workspace = true, features = ["png", "jpeg", "tiff", "exr", "tga"] } exr = { workspace = true } -gif = { workspace = true } rayon = { workspace = true } web-time = { workspace = true } thiserror = { workspace = true } log = { workspace = true } [dev-dependencies] +gif = { workspace = true } tempfile = { workspace = true } effectcraft-media = { workspace = true } effectcraft-effects = { workspace = true } diff --git a/crates/export/src/lib.rs b/crates/export/src/lib.rs index d9af7b2aa..04603e558 100644 --- a/crates/export/src/lib.rs +++ b/crates/export/src/lib.rs @@ -421,13 +421,22 @@ fn write_still(cx: &Cx, file: &mut W, img: &I } async fn gif_export(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut State<'_>) -> Result { - if w > u16::MAX as u32 || h > u16::MAX as u32 { - return Err(ExportError::Unsupported("GIF frames are limited to 65535 px".into())); - } + use craft_gif::write::{AnimationWriter, Disposal, Options, PreparedFrame}; + + validate_gif_dimensions(w, h)?; let path = job.place(job.path, 1); let mut file = job.create(&path)?; - let mut enc = gif::Encoder::new(&mut file, w as u16, h as u16, &[]).map_err(|e| ExportError::Encode(e.to_string()))?; - enc.set_repeat(if job.output.gif_loop { gif::Repeat::Infinite } else { gif::Repeat::Finite(0) }).map_err(|e| ExportError::Encode(e.to_string()))?; + let mut enc = AnimationWriter::new( + &mut file, + w, + h, + Options { + loop_forever: job.output.gif_loop, + disposal: if job.output.channels == Channels::Rgba { Disposal::Background } else { Disposal::Keep }, + speed: 10, + }, + ) + .map_err(|e| ExportError::Encode(e.to_string()))?; let rate = job.settings.rate(comp); // GIF delays are in 1/100 s: carry the rounding error so long animations keep their timing. let cs_per_frame = 100.0 * rate.den as f64 / rate.num as f64; @@ -437,30 +446,31 @@ async fn gif_export(job: &Cx<'_>, comp: &Comp, w: u32, h: u32, st: &mut State<'_ let mut i = 0; while i < st.total { let end = (i + batch).min(st.total); - let frames: Vec> = job - .frames(comp, (i..end).collect(), |_, img| { - let mut px = job.pixels_with(&img, comp, job.output.channels, w, h, false); - gif::Frame::from_rgba_speed(w as u16, h as u16, &mut px, 10) - }) + let frames: Vec> = job + .frames(comp, (i..end).collect(), |_, img| craft_gif::write::prepare_frame(w, h, job.pixels_with(&img, comp, job.output.channels, w, h, false), 10)) .await; - for mut f in frames { + for frame in frames { clock += cs_per_frame; let d = (clock.round() as u64).saturating_sub(emitted).max(1); emitted += d; - f.delay = d.min(u16::MAX as u64) as u16; - if job.output.channels == Channels::Rgba { - f.dispose = gif::DisposalMethod::Background; - } - enc.write_frame(&f).map_err(|e| ExportError::Encode(e.to_string()))?; + let frame = frame.map_err(|e| ExportError::Encode(e.to_string()))?; + enc.write_prepared_frame(frame, d.min(u16::MAX as u64) as u16).map_err(|e| ExportError::Encode(e.to_string()))?; } st.advance(end - i)?; i = end; } - drop(enc); + let _ = enc.finish().map_err(|e| ExportError::Encode(e.to_string()))?; let bytes = file.finish()?; Ok(Report { path, frames: 0, width: w, height: h, seconds: 0.0, bytes, audio: false, log: None, overflow: vec![] }) } +fn validate_gif_dimensions(w: u32, h: u32) -> Result<()> { + if w > u16::MAX as u32 || h > u16::MAX as u32 { + return Err(ExportError::Unsupported("GIF frames are limited to 65535 px".into())); + } + Ok(()) +} + #[cfg(test)] mod tests { use super::*; @@ -478,4 +488,13 @@ mod tests { assert_eq!(OutputFormat::H264.coded_size(1, 101), (2, 100)); assert_eq!(OutputFormat::Gif.coded_size(1, 101), (1, 101)); } + + #[test] + fn gif_dimension_limit_keeps_the_existing_unsupported_error() { + assert!(validate_gif_dimensions(u16::MAX as u32, u16::MAX as u32).is_ok()); + assert!(matches!( + validate_gif_dimensions(u16::MAX as u32 + 1, 1), + Err(ExportError::Unsupported(message)) if message == "GIF frames are limited to 65535 px" + )); + } } diff --git a/crates/export/tests/it/roundtrip.rs b/crates/export/tests/it/roundtrip.rs index bcf7b9d90..1abed1983 100644 --- a/crates/export/tests/it/roundtrip.rs +++ b/crates/export/tests/it/roundtrip.rs @@ -554,10 +554,12 @@ fn gif_roundtrip() { opts.set_color_output(gif::ColorOutput::RGBA); let mut dec = opts.read_info(std::fs::File::open(&path).expect("open")).expect("gif header"); assert_eq!((dec.width() as u32, dec.height() as u32), (W, H)); + assert_eq!(dec.repeat(), gif::Repeat::Infinite); let mut k = 0; let mut total_delay = 0u32; while let Some(f) = dec.read_next_frame().expect("frame") { assert_eq!((f.width as u32, f.height as u32), (W, H)); + assert_eq!(f.dispose, gif::DisposalMethod::Keep); total_delay += f.delay as u32; let img = Image::from_rgba8(W, H, &f.buffer); check_frame(&img, k, 0.06); @@ -565,11 +567,57 @@ fn gif_roundtrip() { } assert_eq!(k, FRAMES); assert_eq!(total_delay, 120, "1.2 s in centiseconds"); + + // Re-encode the same rendered RGB pixels through the former app-local gif 0.13 path. The + // shared writer must preserve the complete output bytes, including quantization and LZW data. + let reference_dir = out_dir("gif-byte-parity"); + let png_pattern = reference_dir.join("frame_[#####].png"); + let png_module = OutputModule::for_format(OutputFormat::PngSequence); + run(&p, cid, &NoFootage, &png_module, &png_pattern); + let png_pattern = png_pattern.to_string_lossy(); + let mut expected = Vec::new(); + { + let mut encoder = gif::Encoder::new(&mut expected, W as u16, H as u16, &[]).expect("reference GIF encoder"); + encoder.set_repeat(gif::Repeat::Infinite).expect("reference GIF repeat"); + for frame_number in 0..FRAMES { + let png_path = sequence_path(&png_pattern, frame_number as i64); + let mut rgba = image::open(png_path).expect("reference PNG").to_rgba8().into_raw(); + let mut frame = gif::Frame::from_rgba_speed(W as u16, H as u16, &mut rgba, 10); + frame.delay = 10; + encoder.write_frame(&frame).expect("reference GIF frame"); + } + } + let actual = std::fs::read(&path).expect("GIF bytes"); + assert_eq!(actual.len(), expected.len(), "GIF byte length differs: actual {}, reference {}", actual.len(), expected.len()); + let difference = actual.iter().zip(&expected).position(|(a, b)| a != b); + assert!( + difference.is_none(), + "GIF bytes differ at offset {:?}: actual {:#04x}, reference {:#04x}", + difference, + difference.map_or(0, |i| actual[i]), + difference.map_or(0, |i| expected[i]) + ); if let Some(s) = ffprobe(&path) { assert!(s.starts_with("gif|64|48"), "{s}"); } } +#[test] +fn gif_rgba_keeps_background_disposal_and_non_looping() { + let (p, cid) = project(None); + let d = out_dir("gif-rgba"); + let om = OutputModule { channels: Channels::Rgba, gif_loop: false, ..OutputModule::for_format(OutputFormat::Gif) }; + let path = d.join("anim.gif"); + run(&p, cid, &NoFootage, &om, &path); + + let mut opts = gif::DecodeOptions::new(); + opts.set_color_output(gif::ColorOutput::RGBA); + let mut dec = opts.read_info(std::fs::File::open(&path).expect("open")).expect("gif header"); + assert_eq!(dec.repeat(), gif::Repeat::Finite(0)); + let first = dec.read_next_frame().expect("frame").expect("first frame"); + assert_eq!(first.dispose, gif::DisposalMethod::Background); +} + #[test] fn cancel_stops_early() { let (p, cid) = project(None); diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index a4ed9d6dd..eab796342 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "47107f660191de2f0b425569506f4daa4faadac9"; +const REV: &str = "948b5c23c12dc8c87c8b1828892b1462113dd5a7"; const PACKAGES: &[(&str, &str)] = &[("craft-pdf", "0.1.0"), ("hayro-syntax", "0.7.2"), ("hayro-jbig2", "0.3.0")]; pub fn run(root: &Path) -> Result<(), String> { From 07250580e250c0eeb7465790a39823826101b046 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Mon, 16 Nov 2026 08:07:56 +0100 Subject: [PATCH 2/3] test(export): share the GIF render and decode setup between the GIF tests Split the byte-parity check against the former gif 0.13 encoder into its own test, with the reference encode in a helper. --- crates/export/tests/it/roundtrip.rs | 94 +++++++++++++++-------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/crates/export/tests/it/roundtrip.rs b/crates/export/tests/it/roundtrip.rs index 1abed1983..224cbfc43 100644 --- a/crates/export/tests/it/roundtrip.rs +++ b/crates/export/tests/it/roundtrip.rs @@ -543,16 +543,40 @@ fn exr_sequence_values_at_or_below_one_are_unchanged() { assert!((c[0] - 1.0).abs() < 1e-4 && (c[1] - lin(0.4)).abs() < 1e-4 && c[2].abs() < 1e-6, "{channels:?}: {c:?}"); } } -#[test] -fn gif_roundtrip() { +/// Render the test project as a GIF with `om` into `out_dir(name)`, and open it for RGBA decoding. +fn render_gif(name: &str, om: &OutputModule) -> (PathBuf, gif::Decoder) { let (p, cid) = project(None); - let d = out_dir("gif"); - let om = OutputModule::for_format(OutputFormat::Gif); - let path = d.join("anim.gif"); - run(&p, cid, &NoFootage, &om, &path); + let path = out_dir(name).join("anim.gif"); + run(&p, cid, &NoFootage, om, &path); let mut opts = gif::DecodeOptions::new(); opts.set_color_output(gif::ColorOutput::RGBA); - let mut dec = opts.read_info(std::fs::File::open(&path).expect("open")).expect("gif header"); + let dec = opts.read_info(std::fs::File::open(&path).expect("open")).expect("gif header"); + (path, dec) +} + +/// The test project's frames, rendered as PNGs, re-encoded through the former app-local gif 0.13 +/// path (`Frame::from_rgba_speed` at speed 10, 1/10 s per frame, looping). +fn reference_gif() -> Vec { + let (p, cid) = project(None); + let png_pattern = out_dir("gif-byte-parity").join("frame_[#####].png"); + run(&p, cid, &NoFootage, &OutputModule::for_format(OutputFormat::PngSequence), &png_pattern); + let png_pattern = png_pattern.to_string_lossy(); + let mut expected = Vec::new(); + let mut encoder = gif::Encoder::new(&mut expected, W as u16, H as u16, &[]).expect("reference GIF encoder"); + encoder.set_repeat(gif::Repeat::Infinite).expect("reference GIF repeat"); + for frame_number in 0..FRAMES { + let mut rgba = image::open(sequence_path(&png_pattern, frame_number as i64)).expect("reference PNG").to_rgba8().into_raw(); + let mut frame = gif::Frame::from_rgba_speed(W as u16, H as u16, &mut rgba, 10); + frame.delay = 10; + encoder.write_frame(&frame).expect("reference GIF frame"); + } + drop(encoder); + expected +} + +#[test] +fn gif_roundtrip() { + let (path, mut dec) = render_gif("gif", &OutputModule::for_format(OutputFormat::Gif)); assert_eq!((dec.width() as u32, dec.height() as u32), (W, H)); assert_eq!(dec.repeat(), gif::Repeat::Infinite); let mut k = 0; @@ -567,52 +591,30 @@ fn gif_roundtrip() { } assert_eq!(k, FRAMES); assert_eq!(total_delay, 120, "1.2 s in centiseconds"); - - // Re-encode the same rendered RGB pixels through the former app-local gif 0.13 path. The - // shared writer must preserve the complete output bytes, including quantization and LZW data. - let reference_dir = out_dir("gif-byte-parity"); - let png_pattern = reference_dir.join("frame_[#####].png"); - let png_module = OutputModule::for_format(OutputFormat::PngSequence); - run(&p, cid, &NoFootage, &png_module, &png_pattern); - let png_pattern = png_pattern.to_string_lossy(); - let mut expected = Vec::new(); - { - let mut encoder = gif::Encoder::new(&mut expected, W as u16, H as u16, &[]).expect("reference GIF encoder"); - encoder.set_repeat(gif::Repeat::Infinite).expect("reference GIF repeat"); - for frame_number in 0..FRAMES { - let png_path = sequence_path(&png_pattern, frame_number as i64); - let mut rgba = image::open(png_path).expect("reference PNG").to_rgba8().into_raw(); - let mut frame = gif::Frame::from_rgba_speed(W as u16, H as u16, &mut rgba, 10); - frame.delay = 10; - encoder.write_frame(&frame).expect("reference GIF frame"); - } - } - let actual = std::fs::read(&path).expect("GIF bytes"); - assert_eq!(actual.len(), expected.len(), "GIF byte length differs: actual {}, reference {}", actual.len(), expected.len()); - let difference = actual.iter().zip(&expected).position(|(a, b)| a != b); - assert!( - difference.is_none(), - "GIF bytes differ at offset {:?}: actual {:#04x}, reference {:#04x}", - difference, - difference.map_or(0, |i| actual[i]), - difference.map_or(0, |i| expected[i]) - ); if let Some(s) = ffprobe(&path) { assert!(s.starts_with("gif|64|48"), "{s}"); } } #[test] -fn gif_rgba_keeps_background_disposal_and_non_looping() { - let (p, cid) = project(None); - let d = out_dir("gif-rgba"); - let om = OutputModule { channels: Channels::Rgba, gif_loop: false, ..OutputModule::for_format(OutputFormat::Gif) }; - let path = d.join("anim.gif"); - run(&p, cid, &NoFootage, &om, &path); +fn gif_matches_the_former_encoder_byte_for_byte() { + // The shared writer must keep the complete output, quantization and LZW data included. + let (path, _) = render_gif("gif-parity", &OutputModule::for_format(OutputFormat::Gif)); + let actual = std::fs::read(&path).expect("GIF bytes"); + let expected = reference_gif(); + let difference = actual.iter().zip(&expected).position(|(a, b)| a != b); + assert!( + actual.len() == expected.len() && difference.is_none(), + "GIF bytes differ: {} vs {} bytes, first difference at {difference:?}", + actual.len(), + expected.len() + ); +} - let mut opts = gif::DecodeOptions::new(); - opts.set_color_output(gif::ColorOutput::RGBA); - let mut dec = opts.read_info(std::fs::File::open(&path).expect("open")).expect("gif header"); +#[test] +fn gif_rgba_keeps_background_disposal_and_non_looping() { + let om = OutputModule { channels: Channels::Rgba, gif_loop: false, ..OutputModule::for_format(OutputFormat::Gif) }; + let (_, mut dec) = render_gif("gif-rgba", &om); assert_eq!(dec.repeat(), gif::Repeat::Finite(0)); let first = dec.read_next_frame().expect("frame").expect("first frame"); assert_eq!(first.dispose, gif::DisposalMethod::Background); From 089c35759b1301441dd07002c3e3443c2746f1fc Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Mon, 16 Nov 2026 09:04:07 +0100 Subject: [PATCH 3/3] test(export): share write_tone between the export integration tests --- crates/export/tests/it/hevc_av1_roundtrip.rs | 28 +----------------- crates/export/tests/it/main.rs | 1 + crates/export/tests/it/roundtrip.rs | 28 +----------------- crates/export/tests/it/support.rs | 30 ++++++++++++++++++++ crates/export/tests/it/uncompressed_mov.rs | 28 +----------------- 5 files changed, 34 insertions(+), 81 deletions(-) create mode 100644 crates/export/tests/it/support.rs diff --git a/crates/export/tests/it/hevc_av1_roundtrip.rs b/crates/export/tests/it/hevc_av1_roundtrip.rs index 4022da1ca..1cfbc41a9 100644 --- a/crates/export/tests/it/hevc_av1_roundtrip.rs +++ b/crates/export/tests/it/hevc_av1_roundtrip.rs @@ -8,6 +8,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; +use crate::support::write_tone; use effectcraft_color::Label; use effectcraft_export::render_queue::{ AudioOutput, CodecProfile, OpusApplication, OutputFormat, OutputModule, RateControlMode, RenderSettings, TimeSpan, WebmVideoCodec, @@ -299,30 +300,3 @@ fn rms(v: impl Iterator) -> f32 { let (s, n) = v.fold((0.0f64, 0usize), |(s, n), x| (s + (x as f64) * (x as f64), n + 1)); (s / n.max(1) as f64).sqrt() as f32 } - -/// 16-bit stereo WAV with a 440 Hz sine at amplitude 0.5 (left) and silence (right). -fn write_tone(path: &Path, secs: f64) { - let sr = 48_000u32; - let n = (secs * sr as f64) as usize; - let mut data = Vec::with_capacity(n * 4); - for i in 0..n { - let s = (0.5 * (2.0 * std::f64::consts::PI * 440.0 * i as f64 / sr as f64).sin() * 32767.0).round() as i16; - data.extend_from_slice(&s.to_le_bytes()); - data.extend_from_slice(&0i16.to_le_bytes()); - } - let mut w = Vec::new(); - w.extend_from_slice(b"RIFF"); - w.extend_from_slice(&(36 + data.len() as u32).to_le_bytes()); - w.extend_from_slice(b"WAVEfmt "); - w.extend_from_slice(&16u32.to_le_bytes()); - w.extend_from_slice(&1u16.to_le_bytes()); - w.extend_from_slice(&2u16.to_le_bytes()); - w.extend_from_slice(&sr.to_le_bytes()); - w.extend_from_slice(&(sr * 4).to_le_bytes()); - w.extend_from_slice(&4u16.to_le_bytes()); - w.extend_from_slice(&16u16.to_le_bytes()); - w.extend_from_slice(b"data"); - w.extend_from_slice(&(data.len() as u32).to_le_bytes()); - w.extend_from_slice(&data); - std::fs::write(path, w).expect("write wav"); -} diff --git a/crates/export/tests/it/main.rs b/crates/export/tests/it/main.rs index 77dc22b49..545181859 100644 --- a/crates/export/tests/it/main.rs +++ b/crates/export/tests/it/main.rs @@ -18,6 +18,7 @@ mod opus_roundtrip; mod prores_color; mod render_settings; mod roundtrip; +mod support; mod targa_sequence; mod uncompressed_mov; mod vp9_roundtrip; diff --git a/crates/export/tests/it/roundtrip.rs b/crates/export/tests/it/roundtrip.rs index 224cbfc43..65644f071 100644 --- a/crates/export/tests/it/roundtrip.rs +++ b/crates/export/tests/it/roundtrip.rs @@ -9,6 +9,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; +use crate::support::write_tone; use effectcraft_color::Label; use effectcraft_export::render_queue::{AlphaMode, AudioOutput, Channels, OutputFormat, OutputModule, ProResProfile, RenderSettings, TimeSpan, sequence_path}; use effectcraft_export::{Job, Progress, export}; @@ -646,33 +647,6 @@ fn cancel_stops_early() { assert_eq!(written, 0, "cancelled before the first batch"); } -/// 16-bit stereo WAV with a 440 Hz sine at amplitude 0.5 (left) and silence (right). -fn write_tone(path: &Path, secs: f64) { - let sr = 48_000u32; - let n = (secs * sr as f64) as usize; - let mut data = Vec::with_capacity(n * 4); - for i in 0..n { - let s = (0.5 * (2.0 * std::f64::consts::PI * 440.0 * i as f64 / sr as f64).sin() * 32767.0).round() as i16; - data.extend_from_slice(&s.to_le_bytes()); - data.extend_from_slice(&0i16.to_le_bytes()); - } - let mut w = Vec::new(); - w.extend_from_slice(b"RIFF"); - w.extend_from_slice(&(36 + data.len() as u32).to_le_bytes()); - w.extend_from_slice(b"WAVEfmt "); - w.extend_from_slice(&16u32.to_le_bytes()); - w.extend_from_slice(&1u16.to_le_bytes()); - w.extend_from_slice(&2u16.to_le_bytes()); - w.extend_from_slice(&sr.to_le_bytes()); - w.extend_from_slice(&(sr * 4).to_le_bytes()); - w.extend_from_slice(&4u16.to_le_bytes()); - w.extend_from_slice(&16u16.to_le_bytes()); - w.extend_from_slice(b"data"); - w.extend_from_slice(&(data.len() as u32).to_le_bytes()); - w.extend_from_slice(&data); - std::fs::write(path, w).expect("write wav"); -} - fn rms(v: impl Iterator) -> f32 { let (s, n) = v.fold((0.0f64, 0usize), |(s, n), x| (s + (x as f64) * (x as f64), n + 1)); (s / n.max(1) as f64).sqrt() as f32 diff --git a/crates/export/tests/it/support.rs b/crates/export/tests/it/support.rs new file mode 100644 index 000000000..aa5c11098 --- /dev/null +++ b/crates/export/tests/it/support.rs @@ -0,0 +1,30 @@ +//! Helpers shared by the integration test modules. + +use std::path::Path; + +/// 16-bit stereo 48 kHz WAV: a 440 Hz sine at 0.5 on the left, silence on the right. +pub(crate) fn write_tone(path: &Path, secs: f64) { + let sr = 48_000u32; + let n = (secs * sr as f64) as usize; + let mut data = Vec::with_capacity(n * 4); + for i in 0..n { + let s = (0.5 * (2.0 * std::f64::consts::PI * 440.0 * i as f64 / sr as f64).sin() * 32767.0).round() as i16; + data.extend_from_slice(&s.to_le_bytes()); + data.extend_from_slice(&0i16.to_le_bytes()); + } + let mut w = Vec::new(); + w.extend_from_slice(b"RIFF"); + w.extend_from_slice(&(36 + data.len() as u32).to_le_bytes()); + w.extend_from_slice(b"WAVEfmt "); + w.extend_from_slice(&16u32.to_le_bytes()); + w.extend_from_slice(&1u16.to_le_bytes()); + w.extend_from_slice(&2u16.to_le_bytes()); + w.extend_from_slice(&sr.to_le_bytes()); + w.extend_from_slice(&(sr * 4).to_le_bytes()); + w.extend_from_slice(&4u16.to_le_bytes()); + w.extend_from_slice(&16u16.to_le_bytes()); + w.extend_from_slice(b"data"); + w.extend_from_slice(&(data.len() as u32).to_le_bytes()); + w.extend_from_slice(&data); + std::fs::write(path, w).expect("write wav"); +} diff --git a/crates/export/tests/it/uncompressed_mov.rs b/crates/export/tests/it/uncompressed_mov.rs index 200d3116a..1242dbfb4 100644 --- a/crates/export/tests/it/uncompressed_mov.rs +++ b/crates/export/tests/it/uncompressed_mov.rs @@ -8,6 +8,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; +use crate::support::write_tone; use craft_media::isobmff::TrackKind; use effectcraft_color::Label; use effectcraft_export::render_queue::{AudioFormat, AudioOutput, Channels, OutputFormat, OutputModule, RenderSettings, TimeSpan, sequence_path}; @@ -28,33 +29,6 @@ fn out_dir(name: &str) -> PathBuf { d } -/// 16-bit stereo 48 kHz WAV: a 440 Hz sine at 0.5 on the left, silence on the right. -fn write_tone(path: &Path, secs: f64) { - let sr = 48_000u32; - let n = (secs * sr as f64) as usize; - let mut data = Vec::with_capacity(n * 4); - for i in 0..n { - let s = (0.5 * (2.0 * std::f64::consts::PI * 440.0 * i as f64 / sr as f64).sin() * 32767.0).round() as i16; - data.extend_from_slice(&s.to_le_bytes()); - data.extend_from_slice(&0i16.to_le_bytes()); - } - let mut w = Vec::new(); - w.extend_from_slice(b"RIFF"); - w.extend_from_slice(&(36 + data.len() as u32).to_le_bytes()); - w.extend_from_slice(b"WAVEfmt "); - w.extend_from_slice(&16u32.to_le_bytes()); - w.extend_from_slice(&1u16.to_le_bytes()); - w.extend_from_slice(&2u16.to_le_bytes()); - w.extend_from_slice(&sr.to_le_bytes()); - w.extend_from_slice(&(sr * 4).to_le_bytes()); - w.extend_from_slice(&4u16.to_le_bytes()); - w.extend_from_slice(&16u16.to_le_bytes()); - w.extend_from_slice(b"data"); - w.extend_from_slice(&(data.len() as u32).to_le_bytes()); - w.extend_from_slice(&data); - std::fs::write(path, w).expect("write wav"); -} - fn project(audio: Option<&Path>) -> (Project, ItemId) { let mut p = Project::default(); let mut comp = Comp::new(W, H, FrameRate::new(10, 1), Tick::from_seconds_f64(FRAMES as f64 / 10.0));