Merge main into i778/effectcraft-opus-craft-audio

Keep workspace craft-libs pins at 5a7a63a2 (#1593), which already includes
main's older exr and lottie revisions. Retain the craft-cms pin at 9fd926dc
from #3744; SPI1D landed on craft-libs main after #1593.
This commit is contained in:
FredApps committed 2026-11-16 09:05:56 +01:00
commit a32f16f25d
7 files changed
+8922 -8969

No files matched your search

Generated
+8486 -8462
View File
File diff suppressed because it is too large. Load diff
+248 -248
View File
@@ -1,248 +1,248 @@
[workspace]
resolver = "3"
members = ["crates/*", "apps/*", "xtask"]
default-members = ["crates/*", "apps/*"]
[workspace.package]
version = "0.24.1"
edition = "2024"
license = "MIT OR Apache-2.0"
rust-version = "1.95"
repository = "https://github.com/storytold/effectcraft"
[workspace.dependencies]
craft-mime = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", version = "=0.1.0", default-features = false, features = ["read"] }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-quit = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-ecproj-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-dpx = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-eps = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-exr = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-gif = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-psd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-webp = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-lottie = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-mesh = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", default-features = false, features = ["stl", "obj", "gltf", "fbx"] }
craft-aep = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-doc = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-vectorcraft-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
# 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 = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", features = ["egui"] }
# internal
effectcraft-time = { path = "crates/time" }
effectcraft-geom = { path = "crates/geom" }
effectcraft-color = { path = "crates/color" }
effectcraft-raster = { path = "crates/raster" }
effectcraft-path = { path = "crates/path" }
effectcraft-keyframe = { path = "crates/keyframe" }
effectcraft-project = { path = "crates/project" }
effectcraft-text = { path = "crates/text" }
effectcraft-effects = { path = "crates/effects" }
effectcraft-track = { path = "crates/track" }
effectcraft-segment = { path = "crates/segment" }
effectcraft-sam2 = { path = "crates/sam2" }
effectcraft-model = { path = "crates/model" }
effectcraft-render = { path = "crates/render" }
effectcraft-gpu = { path = "crates/gpu" }
effectcraft-media = { path = "crates/media" }
effectcraft-export = { path = "crates/export" }
effectcraft-expr = { path = "crates/expr" }
effectcraft-lottie = { path = "crates/lottie" }
effectcraft-interchange = { path = "crates/interchange" }
effectcraft-pdf = { path = "crates/pdf" }
effectcraft-psd = { path = "crates/psd" }
effectcraft-aep = { path = "crates/aep" }
effectcraft-svg = { path = "crates/svg" }
effectcraft-engine = { path = "crates/engine" }
effectcraft-host = { path = "crates/host" }
effectcraft-ui-egui = { path = "crates/ui-egui" }
effectcraft-automation = { path = "crates/automation" }
effectcraft-script = { path = "crates/script" }
effectcraft-plugin = { path = "crates/plugin" }
effectcraft-helper-host = { path = "crates/helper-host" }
# foundation
thiserror = "2"
serde = { version = "1", features = ["derive", "rc"] }
serde_json = { version = "1", features = ["float_roundtrip"] }
log = "0.4"
# All date/time conversion goes through chrono (no hand-rolled calendar code beyond the 400-year range extension; AGENTS.md).
chrono = { version = "0.4.45", default-features = false, features = ["std"] }
rayon = "1"
# std::time::Instant/SystemTime on native; the browser clock on wasm32 (std's panic there).
web-time = "1"
gif = "0.14"
proptest = "1"
# scripting (expressions)
boa_engine = { version = "0.22", default-features = false }
# WebAssembly effect plug-ins (sandboxed interpreter; MIT/Apache-2.0, pure Rust)
wasmi = { version = "2", default-features = false, features = ["std", "validate", "wat", "deterministic", "portable-dispatch"] }
# geometry / fonts
kurbo = { version = "0.13", features = ["serde"] }
tiny-skia = { version = "0.12", default-features = false, features = ["std", "simd"] }
skrifa = { version = "0.44", default-features = false, features = ["std"] }
harfrust = { version = "0.12", default-features = false, features = ["std"] }
exr = "1.74"
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }
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 = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", default-features = false, features = ["isobmff", "matroska"] }
craft-audio = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", default-features = false, features = ["aac-decode", "aac-encode", "opus-decode", "opus-encode"] }
craft-video = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", 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.
filmcraft-codecs = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-media = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-frame = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-color = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-time = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
# MPEG TS / PS headers read for AAC channel layouts (crates/media); craft-media has no MPEG TS reader
filmcraft-mpegts = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
# decoders used as the round-trip oracles of craft-video's VP9, HEVC and AV1 encoders (crates/export
# dev-dependencies only); craft-video has no decoder for them
filmcraft-vp9 = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-hevc = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-av1 = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
# timeline interchange (EDL, FCP7 XML, FCPXML, OTIO) for Premiere Pro interop (crates/interchange only)
filmcraft-interchange = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-project = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-geom = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
# gpu (the same wgpu eframe / egui-wgpu use)
wgpu = { version = "30.0.1", features = ["fragile-send-sync-non-atomic-wasm"] }
bytemuck = "1"
pollster = "1"
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 = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", 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"] }
eframe = { version = "0.37", default-features = false }
# Resizable table columns (About ▸ Contributors / Models); no image loaders.
egui_extras = { version = "0.37", default-features = false }
egui_kittest = "0.37"
rfd = "0.17"
cpal = "0.16"
# The operating system's interface language (MIT/Apache-2.0, no dependencies on desktop).
sys-locale = "0.3"
# Local co-development against a FilmCraft checkout next to this repo: uncomment.
# [patch."https://github.com/storytold/filmcraft"]
# filmcraft-codecs = { path = "../filmcraft/crates/codecs" }
# filmcraft-media = { path = "../filmcraft/crates/media" }
# filmcraft-frame = { path = "../filmcraft/crates/frame" }
# filmcraft-color = { path = "../filmcraft/crates/color" }
# filmcraft-time = { path = "../filmcraft/crates/time" }
# filmcraft-mpegts = { path = "../filmcraft/crates/mpegts" }
[workspace.lints.rust]
unsafe_code = "forbid"
[workspace.lints.clippy]
cognitive_complexity = "deny"
too_many_arguments = "deny"
wildcard_imports = "deny"
dbg_macro = "warn"
todo = "warn"
needless_range_loop = "allow"
type_complexity = "allow"
[profile.dev.package."*"]
opt-level = 2
debug = false
[profile.dev]
opt-level = 1
# Panics and backtraces keep file and line; full debug info only made the many test binaries large.
debug = "line-tables-only"
# Same settings as `dev`, but with full debug info for interactive debugger sessions: local
# variables, parameters and column breakpoints work. Use `--profile dev-full` when debugging;
# everything else stays on the fast default. See CONTRIBUTING.md, "Setup".
[profile.dev-full]
inherits = "dev"
debug = true
# Pixel hot loops: keep debug builds interactive.
[profile.dev.package.effectcraft-raster]
opt-level = 3
[profile.dev.package.effectcraft-render]
opt-level = 3
[profile.dev.package.effectcraft-gpu]
opt-level = 3
[profile.dev.package.effectcraft-effects]
opt-level = 3
[profile.dev.package.effectcraft-track]
opt-level = 3
[profile.dev.package.effectcraft-path]
opt-level = 3
[profile.dev.package.effectcraft-media]
opt-level = 3
[profile.dev.package.effectcraft-export]
opt-level = 3
# craft-libs codec hot loops.
[profile.dev.package.craft-video]
opt-level = 3
[profile.dev.package.craft-audio]
opt-level = 3
[profile.dev.package.craft-media]
opt-level = 3
# FilmCraft codec hot loops (same settings as FilmCraft's own workspace).
[profile.dev.package.filmcraft-h264]
opt-level = 3
[profile.dev.package.filmcraft-hevc]
opt-level = 3
[profile.dev.package.filmcraft-vp9]
opt-level = 3
[profile.dev.package.filmcraft-dnx]
opt-level = 3
[profile.dev.package.filmcraft-av1]
opt-level = 3
[profile.release]
lto = "thin"
codegen-units = 1
[patch.crates-io]
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", version = "=0.7.2" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", 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" }
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
eframe = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
# Patch a crate only together with the dependency that needs it: an unused patch makes the Nix
# build, which uses vendored sources, fail (`cargo xtask lock-patches`).
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
[workspace]
resolver = "3"
members = ["crates/*", "apps/*", "xtask"]
default-members = ["crates/*", "apps/*"]
[workspace.package]
version = "0.24.1"
edition = "2024"
license = "MIT OR Apache-2.0"
rust-version = "1.95"
repository = "https://github.com/storytold/effectcraft"
[workspace.dependencies]
craft-mime = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", version = "=0.1.0", default-features = false, features = ["read"] }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-quit = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-ecproj-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-dpx = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-eps = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-exr = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-gif = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-psd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-webp = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-lottie = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-mesh = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", default-features = false, features = ["stl", "obj", "gltf", "fbx"] }
craft-aep = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-doc = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
craft-vectorcraft-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" }
# 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 = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", features = ["egui"] }
# internal
effectcraft-time = { path = "crates/time" }
effectcraft-geom = { path = "crates/geom" }
effectcraft-color = { path = "crates/color" }
effectcraft-raster = { path = "crates/raster" }
effectcraft-path = { path = "crates/path" }
effectcraft-keyframe = { path = "crates/keyframe" }
effectcraft-project = { path = "crates/project" }
effectcraft-text = { path = "crates/text" }
effectcraft-effects = { path = "crates/effects" }
effectcraft-track = { path = "crates/track" }
effectcraft-segment = { path = "crates/segment" }
effectcraft-sam2 = { path = "crates/sam2" }
effectcraft-model = { path = "crates/model" }
effectcraft-render = { path = "crates/render" }
effectcraft-gpu = { path = "crates/gpu" }
effectcraft-media = { path = "crates/media" }
effectcraft-export = { path = "crates/export" }
effectcraft-expr = { path = "crates/expr" }
effectcraft-lottie = { path = "crates/lottie" }
effectcraft-interchange = { path = "crates/interchange" }
effectcraft-pdf = { path = "crates/pdf" }
effectcraft-psd = { path = "crates/psd" }
effectcraft-aep = { path = "crates/aep" }
effectcraft-svg = { path = "crates/svg" }
effectcraft-engine = { path = "crates/engine" }
effectcraft-host = { path = "crates/host" }
effectcraft-ui-egui = { path = "crates/ui-egui" }
effectcraft-automation = { path = "crates/automation" }
effectcraft-script = { path = "crates/script" }
effectcraft-plugin = { path = "crates/plugin" }
effectcraft-helper-host = { path = "crates/helper-host" }
# foundation
thiserror = "2"
serde = { version = "1", features = ["derive", "rc"] }
serde_json = { version = "1", features = ["float_roundtrip"] }
log = "0.4"
# All date/time conversion goes through chrono (no hand-rolled calendar code beyond the 400-year range extension; AGENTS.md).
chrono = { version = "0.4.45", default-features = false, features = ["std"] }
rayon = "1"
# std::time::Instant/SystemTime on native; the browser clock on wasm32 (std's panic there).
web-time = "1"
gif = "0.14"
proptest = "1"
# scripting (expressions)
boa_engine = { version = "0.22", default-features = false }
# WebAssembly effect plug-ins (sandboxed interpreter; MIT/Apache-2.0, pure Rust)
wasmi = { version = "2", default-features = false, features = ["std", "validate", "wat", "deterministic", "portable-dispatch"] }
# geometry / fonts
kurbo = { version = "0.13", features = ["serde"] }
tiny-skia = { version = "0.12", default-features = false, features = ["std", "simd"] }
skrifa = { version = "0.44", default-features = false, features = ["std"] }
harfrust = { version = "0.12", default-features = false, features = ["std"] }
exr = "1.74"
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }
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 = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", default-features = false, features = ["isobmff", "matroska"] }
craft-audio = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", default-features = false, features = ["aac-decode", "aac-encode", "opus-decode", "opus-encode"] }
craft-video = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", 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.
filmcraft-codecs = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-media = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-frame = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-color = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-time = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
# MPEG TS / PS headers read for AAC channel layouts (crates/media); craft-media has no MPEG TS reader
filmcraft-mpegts = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
# decoders used as the round-trip oracles of craft-video's VP9, HEVC and AV1 encoders (crates/export
# dev-dependencies only); craft-video has no decoder for them
filmcraft-vp9 = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-hevc = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-av1 = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
# timeline interchange (EDL, FCP7 XML, FCPXML, OTIO) for Premiere Pro interop (crates/interchange only)
filmcraft-interchange = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-project = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
filmcraft-geom = { git = "https://github.com/storytold/filmcraft", rev = "d5ead4ba1ee2f1cd13cb86a4239aee2730a3d9f5" }
# gpu (the same wgpu eframe / egui-wgpu use)
wgpu = { version = "30.0.1", features = ["fragile-send-sync-non-atomic-wasm"] }
bytemuck = "1"
pollster = "1"
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 = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", 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"] }
eframe = { version = "0.37", default-features = false }
# Resizable table columns (About ▸ Contributors / Models); no image loaders.
egui_extras = { version = "0.37", default-features = false }
egui_kittest = "0.37"
rfd = "0.17"
cpal = "0.16"
# The operating system's interface language (MIT/Apache-2.0, no dependencies on desktop).
sys-locale = "0.3"
# Local co-development against a FilmCraft checkout next to this repo: uncomment.
# [patch."https://github.com/storytold/filmcraft"]
# filmcraft-codecs = { path = "../filmcraft/crates/codecs" }
# filmcraft-media = { path = "../filmcraft/crates/media" }
# filmcraft-frame = { path = "../filmcraft/crates/frame" }
# filmcraft-color = { path = "../filmcraft/crates/color" }
# filmcraft-time = { path = "../filmcraft/crates/time" }
# filmcraft-mpegts = { path = "../filmcraft/crates/mpegts" }
[workspace.lints.rust]
unsafe_code = "forbid"
[workspace.lints.clippy]
cognitive_complexity = "deny"
too_many_arguments = "deny"
wildcard_imports = "deny"
dbg_macro = "warn"
todo = "warn"
needless_range_loop = "allow"
type_complexity = "allow"
[profile.dev.package."*"]
opt-level = 2
debug = false
[profile.dev]
opt-level = 1
# Panics and backtraces keep file and line; full debug info only made the many test binaries large.
debug = "line-tables-only"
# Same settings as `dev`, but with full debug info for interactive debugger sessions: local
# variables, parameters and column breakpoints work. Use `--profile dev-full` when debugging;
# everything else stays on the fast default. See CONTRIBUTING.md, "Setup".
[profile.dev-full]
inherits = "dev"
debug = true
# Pixel hot loops: keep debug builds interactive.
[profile.dev.package.effectcraft-raster]
opt-level = 3
[profile.dev.package.effectcraft-render]
opt-level = 3
[profile.dev.package.effectcraft-gpu]
opt-level = 3
[profile.dev.package.effectcraft-effects]
opt-level = 3
[profile.dev.package.effectcraft-track]
opt-level = 3
[profile.dev.package.effectcraft-path]
opt-level = 3
[profile.dev.package.effectcraft-media]
opt-level = 3
[profile.dev.package.effectcraft-export]
opt-level = 3
# craft-libs codec hot loops.
[profile.dev.package.craft-video]
opt-level = 3
[profile.dev.package.craft-audio]
opt-level = 3
[profile.dev.package.craft-media]
opt-level = 3
# FilmCraft codec hot loops (same settings as FilmCraft's own workspace).
[profile.dev.package.filmcraft-h264]
opt-level = 3
[profile.dev.package.filmcraft-hevc]
opt-level = 3
[profile.dev.package.filmcraft-vp9]
opt-level = 3
[profile.dev.package.filmcraft-dnx]
opt-level = 3
[profile.dev.package.filmcraft-av1]
opt-level = 3
[profile.release]
lto = "thin"
codegen-units = 1
[patch.crates-io]
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", version = "=0.7.2" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", 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" }
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
eframe = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
# Patch a crate only together with the dependency that needs it: an unused patch makes the Nix
# build, which uses vendored sources, fail (`cargo xtask lock-patches`).
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
+1
View File
@@ -10,6 +10,7 @@ rust-version.workspace = true
workspace = true
[dependencies]
craft-cms = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "9fd926dc93be7d4723e6eb4f484c7233d91d3e94" }
effectcraft-geom = { workspace = true }
effectcraft-color = { workspace = true }
effectcraft-keyframe = { workspace = true }
+2 -33
View File
@@ -35,39 +35,8 @@ pub fn parse_spimtx(text: &str) -> Option<FileXform> {
/// Parse a Sony Imageworks `.spi1d` 1D LUT: `From <min> <max>`, `Length <n>`, `Components
/// <1 | 3>`, then `{` the values `}`.
pub fn parse_spi1d(text: &str) -> Option<Lut> {
let (mut from, mut len, mut comps) = ([0.0f32, 1.0], 0usize, 1usize);
let mut values: Vec<f32> = vec![];
let mut body = false;
for line in text.lines().map(str::trim).filter(|l| !l.is_empty()) {
if body {
if line.starts_with('}') {
break;
}
for t in line.split_whitespace() {
values.push(t.parse().ok()?);
}
continue;
}
let mut t = line.split_whitespace();
match t.next()? {
"{" => body = true,
"From" => from = [t.next()?.parse().ok()?, t.next()?.parse().ok()?],
"Length" => len = t.next()?.parse().ok()?,
"Components" => comps = t.next()?.parse().ok()?,
_ => {}
}
}
// A 1D table is interpolated by index, so cap it like the lattices (2²⁴ entries).
if !(2..=MAX_1D).contains(&len)
|| !matches!(comps, 1 | 3)
|| values.len() != len.checked_mul(comps)?
|| from[1] <= from[0]
|| from.iter().any(|v| !v.is_finite())
{
return None;
}
let d1 = values.chunks_exact(comps).map(|c| if comps == 3 { [c[0], c[1], c[2]] } else { [c[0]; 3] }).collect();
Some(Lut { n1: len, d1, n3: 0, d3: vec![], dmin: [from[0]; 3], dmax: [from[1]; 3] })
let table = craft_cms::spi1d::parse(text)?;
Some(Lut { n1: table.values.len(), d1: table.values, n3: 0, d3: vec![], dmin: [table.domain[0]; 3], dmax: [table.domain[1]; 3] })
}
/// Parse a Sony Imageworks `.spi3d` lattice: `SPILUT 1.0`, `3 3`, the sizes, then one
+7
View File
@@ -116,6 +116,13 @@ fn spi_files_parse() {
assert!((back[0] - 1.0).abs() < 1e-5 && (back[2] - 2.0).abs() < 1e-5, "{back:?}");
let three = parse_spi1d("Version 1\nFrom 0 1\nLength 2\nComponents 3\n{\n0 0 0\n1 0.5 2\n}\n").unwrap();
assert_eq!(three.d1, vec![[0.0; 3], [1.0, 0.5, 2.0]]);
let eof = parse_spi1d("Length 2\nFrom -1 2\n{\n0 1").unwrap();
assert_eq!(eof.n1, 2);
assert_eq!(eof.dmin, [-1.0; 3]);
assert_eq!(eof.dmax, [2.0; 3]);
assert_eq!(eof.n3, 0);
assert!(eof.d3.is_empty());
assert!(parse_spi1d("Length 2\n{\n0 1 2").is_none());
let mut spi3d = String::from("SPILUT 1.0\n3 3\n2 2 2\n");
for (r, g, b) in (0..8).map(|i| (i & 1, (i >> 1) & 1, i >> 2)) {
spi3d += &format!("{r} {g} {b} {} {} {}\n", r as f32 * 0.5, g, b);
+2 -2
View File
@@ -23,7 +23,7 @@ effectcraft-model = { workspace = true }
filmcraft-codecs = { workspace = true }
filmcraft-media = { workspace = true }
craft-dpx = { workspace = true }
craft-exr = { workspace = true }
craft-exr = { workspace = true, features = ["decode"] }
craft-gif = { workspace = true }
craft-webp = { workspace = true }
craft-audio = { workspace = true }
@@ -32,7 +32,6 @@ filmcraft-mpegts = { workspace = true }
filmcraft-frame = { workspace = true }
filmcraft-color = { workspace = true }
filmcraft-time = { workspace = true }
exr = { workspace = true }
image = { workspace = true, features = ["gif", "webp", "tiff", "bmp", "exr", "tga", "hdr"] }
rayon = { workspace = true }
serde_json = { workspace = true }
@@ -40,6 +39,7 @@ thiserror = { workspace = true }
log = { workspace = true }
[dev-dependencies]
exr = { workspace = true }
# Writes the animated GIFs of the tests.
gif = { workspace = true }
tempfile = { workspace = true }
+176 -224
View File
@@ -1,5 +1,5 @@
//! Auxiliary channels from multi-layer OpenEXR files (depth, object / material IDs, normals,
//! Cryptomatte, …) for the 3D Channel effects, read with the pure-Rust `exr` crate.
//! Cryptomatte, …) for the 3D Channel effects, read through the shared `craft-exr` decoder.
//!
//! Every channel of every layer becomes a plane named `layer.channel` (or just `channel` for
//! the unnamed layer), placed in the display window (pixels outside a layer's data window are
@@ -18,12 +18,6 @@ use std::sync::{Arc, Mutex, OnceLock, PoisonError};
use effectcraft_raster::channels3d::{BACKGROUND_DEPTH, split_channel};
use effectcraft_raster::{AuxChannels, Image};
use effectcraft_render::reads::{ReadFile, ReadFiles};
use exr::block::UncompressedBlock;
use exr::block::chunk::TileCoordinates;
use exr::image::read::image::ReadImage;
use exr::image::read::layers::{ChannelsReader, ReadAllLayers, ReadChannels};
use exr::meta::attribute::SampleType;
use exr::meta::header::Header;
use crate::convert::{AlphaOp, float_to_image};
@@ -35,179 +29,20 @@ const MAX_DISPLAY_PIXELS: usize = 1 << 28;
use craft_exr::channels::{is_depth, part_channel_name as channel_name};
pub use craft_exr::cryptomatte::parse_manifest;
/// The part name channels are prefixed with (`None`: unnamed).
fn part_name(header: &Header) -> Option<String> {
header.own_attributes.layer_name.as_ref().map(|t| t.to_string()).filter(|s| !s.is_empty())
}
/// Why an OpenEXR file's pixels can't be decoded when its headers name a compression this build
/// can't decompress (HTJ2K, OpenEXR 3.4's High-Throughput JPEG 2000): the decoders only said
/// "no non-deep rgb channels" or showed a transparent frame (#482). `None` for other files.
pub fn unsupported_compression(bytes: &[u8]) -> Option<&'static str> {
use exr::compression::Compression;
let meta = exr::meta::MetaData::read_from_buffered(std::io::Cursor::new(bytes), false).ok()?;
meta.headers
let mut limits = craft_exr::decode::Limits::default();
limits.max_pixels = u64::MAX;
limits.max_bytes = u64::MAX;
craft_exr::decode::parts(bytes, &limits)
.ok()?
.iter()
.any(|h| matches!(h.compression, Compression::HTJ2K32 | Compression::HTJ2K256))
.any(|part| matches!(part.compression.as_str(), "HTJ2K32" | "HTJ2K256"))
.then_some("OpenEXR HTJ2K compression isn't supported yet: re-save the file with ZIP, PIZ or DWAA compression")
}
/// Which channels a decode keeps, by plane name, and the display window they are placed in
/// (the first part's, as the `exr` crate reports the image's).
struct Planes<'k> {
keep: &'k dyn Fn(&str) -> bool,
display: exr::meta::attribute::IntegerBounds,
}
/// One part's kept channels while it is decoded: each line of samples goes straight into its
/// channel's display-window plane (no copy of the part's samples in their own type first).
struct PlanesReader {
/// Per channel of the part: its plane name, sample type and plane (`None`: not kept).
planes: Vec<Option<(String, SampleType, Vec<f32>)>>,
/// The data window's position in the display window, and the data window's and display
/// window's sizes.
offset: (i64, i64),
layer: (usize, usize),
display: (usize, usize),
f16s: Vec<exr::prelude::f16>,
u32s: Vec<u32>,
f32s: Vec<f32>,
/// The part's channel indices of exact `R`, `G`, `B` and `A`, when it has R, G and B.
rgb: Option<([usize; 3], Option<usize>)>,
/// The part's display window differs from the first part's.
own_display: bool,
}
/// A decoded part: its kept planes (in channel order) and what [`PlanesReader`] found.
struct PartPlanes {
planes: Vec<(String, Vec<f32>)>,
/// Positions in `planes` of the part's R, G, B (and A) channels, when it has them and keeps
/// them all.
rgb: Option<([usize; 3], Option<usize>)>,
has_rgb: bool,
exact: bool,
}
impl<'s> ReadChannels<'s> for Planes<'_> {
type Reader = PlanesReader;
fn create_channels_reader(&'s self, header: &Header) -> exr::error::Result<PlanesReader> {
if header.deep {
return Err(exr::error::Error::NotSupported("deep data".into()));
}
let dw = self.display;
let display = (dw.size.0, dw.size.1);
// Each channel is a display-window plane: a 60000² window over a 1×1 data window was a
// multi-gigabyte allocation per channel (#2141).
let n = display.0.checked_mul(display.1).filter(|n| *n > 0 && *n <= MAX_DISPLAY_PIXELS).ok_or(exr::error::Error::Invalid("display window".into()))?;
let prefix = part_name(header);
let pos = header.own_attributes.layer_position;
let offset = (i64::from(pos.0) - i64::from(dw.position.0), i64::from(pos.1) - i64::from(dw.position.1));
let planes = header
.channels
.list
.iter()
.map(|ch| {
let name = channel_name(prefix.as_deref(), &ch.name.to_string());
let fill = if is_depth(&name) { BACKGROUND_DEPTH } else { 0.0 };
(self.keep)(&name).then(|| (name, ch.sample_type, vec![fill; n]))
})
.collect();
let find = |c: &str| header.channels.find_index_of_channel(&exr::meta::attribute::Text::from(c));
let rgb = match (find("R"), find("G"), find("B")) {
(Some(r), Some(g), Some(b)) => Some(([r, g, b], find("A"))),
_ => None,
};
Ok(PlanesReader {
planes,
offset,
layer: (header.layer_size.0, header.layer_size.1),
display,
f16s: vec![],
u32s: vec![],
f32s: vec![],
rgb,
own_display: header.shared_attributes.display_window != dw,
})
}
}
impl ChannelsReader for PlanesReader {
type Channels = PartPlanes;
fn filter_block(&self, tile: TileCoordinates) -> bool {
tile.is_largest_resolution_level() && self.planes.iter().any(Option::is_some)
}
fn read_block(&mut self, header: &Header, block: UncompressedBlock) -> exr::error::UnitResult {
let ((lw, lh), (w, h)) = (self.layer, self.display);
for line in block.lines(&header.channels) {
let Some(Some((_, kind, plane))) = self.planes.get_mut(line.location.channel) else { continue };
let (x0, y, count) = (line.location.position.0, line.location.position.1, line.location.sample_count);
// The samples of data-window row `y`, columns `x0..x0 + count`, at display row `ty`
// from display column `tx0`; clipped to the display window.
if y >= lh || x0.checked_add(count).is_none_or(|end| end > lw) {
continue;
}
let Some(ty) = usize::try_from(y as i64 + self.offset.1).ok().filter(|ty| *ty < h) else { continue };
let tx0 = x0 as i64 + self.offset.0;
let skip = usize::try_from(-tx0).unwrap_or(0).min(count);
let tx = usize::try_from(tx0.max(0)).unwrap_or(usize::MAX);
let take = (count - skip).min(w.saturating_sub(tx));
let start = ty.checked_mul(w).and_then(|row| row.checked_add(tx));
let Some(dst) = start.filter(|_| take > 0).and_then(|s| plane.get_mut(s..s.checked_add(take)?)) else { continue };
match kind {
SampleType::F16 => {
self.f16s.resize(count, exr::prelude::f16::ZERO);
line.read_samples_into_slice(&mut self.f16s)?;
for (d, s) in dst.iter_mut().zip(self.f16s.iter().skip(skip)) {
*d = s.to_f32();
}
}
SampleType::F32 => {
self.f32s.resize(count, 0.0);
line.read_samples_into_slice(&mut self.f32s)?;
for (d, s) in dst.iter_mut().zip(self.f32s.iter().skip(skip)) {
*d = *s;
}
}
SampleType::U32 => {
self.u32s.resize(count, 0);
line.read_samples_into_slice(&mut self.u32s)?;
for (d, s) in dst.iter_mut().zip(self.u32s.iter().skip(skip)) {
*d = *s as f32;
}
}
}
}
Ok(())
}
fn into_channels(self) -> PartPlanes {
// Positions of the kept channels among the kept planes.
let mut at = vec![None; self.planes.len()];
let mut planes = Vec::with_capacity(self.planes.len());
for (i, p) in self.planes.into_iter().enumerate() {
if let Some((name, _, data)) = p {
if let Some(slot) = at.get_mut(i) {
*slot = Some(planes.len());
}
planes.push((name, data));
}
}
let kept = |i: usize| at.get(i).copied().flatten();
let has_rgb = self.rgb.is_some();
let rgb = self.rgb.and_then(|([r, g, b], a)| {
let a = match a {
Some(a) => Some(kept(a)?),
None => None,
};
Some(([kept(r)?, kept(g)?, kept(b)?], a))
});
PartPlanes { planes, rgb, has_rgb, exact: !self.own_display }
}
}
/// How the `image` crate's OpenEXR decoder would show a file: the first part with exact `R`, `G`
/// and `B` channels (alpha `A` when it has one, else opaque), placed in the display window with
/// 0 outside the data window.
@@ -253,73 +88,117 @@ enum Refused {
TooLarge(String),
}
/// Bytes the planes of the channels `keep` names would take (`None`: not a readable header).
fn planes_bytes(meta: &exr::meta::MetaData, keep: &dyn Fn(&str) -> bool) -> Option<usize> {
let dw = meta.headers.first()?.shared_attributes.display_window;
let n = dw.size.0.checked_mul(dw.size.1)?;
let mut kept = 0usize;
for header in meta.headers.iter() {
let prefix = part_name(header);
kept = kept.saturating_add(header.channels.list.iter().filter(|ch| keep(&channel_name(prefix.as_deref(), &ch.name.to_string()))).count());
}
Some(n.saturating_mul(kept).saturating_mul(std::mem::size_of::<f32>()))
/// Bytes the selected channels occupy in each part's own display window. The channel cache
/// reserves this before decoding so concurrent imports cannot exceed its soft budget.
fn planes_bytes(infos: &[craft_exr::decode::PartInfo], keep: &dyn Fn(&str) -> bool) -> Option<usize> {
infos.first()?;
let total = infos.iter().try_fold(0u64, |total, part| {
let count = part.channels.iter().filter(|channel| keep(&channel_name(part.name.as_deref(), &channel.name))).count() as u64;
if count == 0 {
return Some(total);
}
let pixels = u64::from(part.display_window.width).checked_mul(u64::from(part.display_window.height))?;
total.checked_add(pixels.checked_mul(count)?.checked_mul(4)?)
})?;
usize::try_from(total).ok()
}
/// Decode the channels of an EXR file's bytes that `keep` names (by plane name).
/// Decode selected EXR channels through craft-exr, which places each selected block directly
/// into its bounded display-window plane.
fn decode(bytes: &[u8], keep: &dyn Fn(&str) -> bool) -> Result<Decoded, Refused> {
let meta = exr::meta::MetaData::read_from_buffered(std::io::Cursor::new(bytes), false).map_err(|_| Refused::Unreadable)?;
let display = meta.headers.first().ok_or(Refused::Unreadable)?.shared_attributes.display_window;
let need = planes_bytes(&meta, keep).ok_or(Refused::Unreadable)?;
if need > MAX_DECODE_BYTES {
let gb = |b: usize| b as f64 / f64::from(1u32 << 30);
use craft_exr::decode::{self, Error as ExrError, Limits};
let mut limits = Limits::default();
limits.max_pixels = MAX_DISPLAY_PIXELS as u64;
limits.max_bytes = MAX_DECODE_BYTES as u64;
// Header-only checks must not charge channels this caller does not decode. The shared display
// decoder independently checks the exact selected display planes before allocating them. It
// also bounds a selected part's data window across all of its channels (decoded blocks carry
// every channel before the unused ones are dropped), so a part whose full channel set exceeds
// `max_bytes` is refused even when the kept planes alone would fit.
let mut header_limits = limits;
header_limits.max_width = u32::MAX;
header_limits.max_height = u32::MAX;
header_limits.max_pixels = u64::MAX;
header_limits.max_bytes = u64::MAX;
let infos = decode::parts(bytes, &header_limits).map_err(|e| match e {
ExrError::LimitExceeded(message) => Refused::TooLarge(message),
_ => Refused::Unreadable,
})?;
let display = infos.first().ok_or(Refused::Unreadable)?.display_window;
let needed = planes_bytes(&infos, keep).filter(|bytes| *bytes > 0).ok_or(Refused::Unreadable)?;
if needed > MAX_DECODE_BYTES {
let gb = |b: u64| b as f64 / f64::from(1u32 << 30);
return Err(Refused::TooLarge(format!(
"its {}×{} OpenEXR channels need {:.1} GB of memory, more than the {:.1} GB one file may use",
display.size.0,
display.size.1,
gb(need),
gb(MAX_DECODE_BYTES)
display.width,
display.height,
gb(needed as u64),
gb(MAX_DECODE_BYTES as u64),
)));
}
let read = ReadImage::new(ReadAllLayers { read_channels: Planes { keep, display } }, |_| {});
let img = read.from_buffered(std::io::Cursor::new(bytes)).map_err(|_| Refused::Unreadable)?;
let dw = img.attributes.display_window;
let mut aux = AuxChannels::new(dw.size.0 as u32, dw.size.1 as u32, 1.0);
let mut aux = AuxChannels::new(display.width, display.height, 1.0);
let mut crypto: HashMap<String, (Option<String>, Option<String>)> = HashMap::new();
let mut collect_meta = |other: &HashMap<exr::meta::attribute::Text, exr::meta::attribute::AttributeValue>| {
for (k, v) in other {
let key = k.to_string();
let mut rgb = Rgb::None;
for info in infos {
for (key, value) in &info.text_attributes {
let Some(rest) = key.strip_prefix("cryptomatte/") else { continue };
let Some((id, field)) = rest.split_once('/') else { continue };
let exr::meta::attribute::AttributeValue::Text(t) = v else { continue };
let e = crypto.entry(id.to_string()).or_default();
let entry = crypto.entry(id.to_string()).or_default();
match field {
"name" => e.0 = Some(t.to_string()),
"manifest" => e.1 = Some(t.to_string()),
"name" => entry.0 = Some(value.clone()),
"manifest" => entry.1 = Some(value.clone()),
_ => {}
}
}
};
collect_meta(&img.attributes.other);
let mut rgb = Rgb::None;
for layer in img.layer_data {
collect_meta(&layer.attributes.other);
let part = layer.channel_data;
if rgb == Rgb::None && part.has_rgb {
let prefix = info.name.as_deref();
let exact = info.display_window == display;
let rgb_indices = ["R", "G", "B"].map(|wanted| info.channels.iter().position(|channel| channel.name == wanted));
let has_rgb = rgb_indices.iter().all(Option::is_some);
let alpha_index = info.channels.iter().position(|channel| channel.name == "A");
// Metadata above still belongs to the file, but an ignored part must not allocate or
// impose its pixel/deep-data limits on the selected picture channels.
if !info.channels.iter().any(|channel| keep(&channel_name(prefix, &channel.name))) {
if rgb == Rgb::None && has_rgb {
rgb = Rgb::Unsupported;
}
continue;
}
let mut part = decode::decode_display_part(
bytes,
info.index,
keep,
&|name| {
if is_depth(name) { BACKGROUND_DEPTH } else { 0.0 }
},
&limits,
)
.map_err(|error| match error {
ExrError::LimitExceeded(message) => Refused::TooLarge(message),
_ => Refused::Unreadable,
})?;
if rgb == Rgb::None && has_rgb {
let base = aux.channels.len();
rgb = match part.rgb {
Some(([r, g, b], a)) if part.exact => {
let picked = [Some(r), Some(g), Some(b), a];
let depth = picked.iter().flatten().any(|i| part.planes.get(*i).is_some_and(|(n, _)| is_depth(n)));
if depth { Rgb::Unsupported } else { Rgb::Planes([base + r, base + g, base + b], a.map(|a| base + a)) }
let locate = |raw: usize| {
let name = channel_name(prefix, &info.channels.get(raw)?.name);
part.channels.iter().position(|channel| channel.name == name)
};
rgb = match (rgb_indices[0].and_then(locate), rgb_indices[1].and_then(locate), rgb_indices[2].and_then(locate)) {
(Some(r), Some(g), Some(b)) if exact => {
let a = alpha_index.and_then(locate);
let depth =
[Some(r), Some(g), Some(b), a].into_iter().flatten().any(|i| part.channels.get(i).is_some_and(|channel| is_depth(&channel.name)));
if depth { Rgb::Unsupported } else { Rgb::Planes([base + r, base + g, base + b], a.map(|i| base + i)) }
}
_ => Rgb::Unsupported,
};
}
aux.channels.extend(part.planes);
aux.channels.extend(part.channels.drain(..).map(|channel| (channel.name, channel.samples)));
}
for (_, (name, manifest)) in crypto {
if let (Some(n), Some(m)) = (name, manifest) {
aux.manifests.push((n, parse_manifest(&m)));
if let (Some(name), Some(manifest)) = (name, manifest) {
aux.manifests.push((name, parse_manifest(&manifest)));
}
}
aux.manifests.sort();
@@ -389,11 +268,16 @@ fn picture_names(aux: &AuxChannels) -> Option<([String; 3], Option<String>)> {
/// headers, then only those channels decoded; in a multi-part file the other parts' pixels are
/// not even decompressed), with the names of its planes.
fn picture_only(bytes: &[u8]) -> Result<(Decoded, [String; 3], Option<String>), Refused> {
let meta = exr::meta::MetaData::read_from_buffered(std::io::Cursor::new(bytes), false).map_err(|_| Refused::Unreadable)?;
let mut limits = craft_exr::decode::Limits::default();
limits.max_width = u32::MAX;
limits.max_height = u32::MAX;
limits.max_pixels = u64::MAX;
limits.max_bytes = u64::MAX;
let meta = craft_exr::decode::parts(bytes, &limits).map_err(|_| Refused::Unreadable)?;
let mut names = AuxChannels::new(0, 0, 1.0);
for header in meta.headers.iter() {
let prefix = part_name(header);
names.channels.extend(header.channels.list.iter().map(|ch| (channel_name(prefix.as_deref(), &ch.name.to_string()), vec![])));
for part in meta {
let prefix = part.name.as_deref();
names.channels.extend(part.channels.iter().map(|ch| (channel_name(prefix, &ch.name), vec![])));
}
let (rgb, a) = picture_names(&names).ok_or(Refused::Unreadable)?;
// Planes are looked up by name ignoring case, so every channel that could answer is kept.
@@ -679,8 +563,13 @@ impl ChannelCache {
/// Decode the file at `path` whose bytes are `bytes` for `slot` (see [`ChannelCache::get`]).
fn decode_file(&self, path: &str, slot: &Slot, bytes: &[u8]) -> Option<Arc<Decoded>> {
// The planes it will allocate count against the budget while it decodes.
if let Ok(meta) = exr::meta::MetaData::read_from_buffered(std::io::Cursor::new(bytes), false)
&& let Some(need) = planes_bytes(&meta, &|_| true)
let mut limits = craft_exr::decode::Limits::default();
limits.max_width = u32::MAX;
limits.max_height = u32::MAX;
limits.max_pixels = u64::MAX;
limits.max_bytes = u64::MAX;
if let Ok(infos) = craft_exr::decode::parts(bytes, &limits)
&& let Some(need) = planes_bytes(&infos, &|_| true)
{
self.account(slot, need.min(MAX_DECODE_BYTES));
}
@@ -1264,6 +1153,69 @@ mod tests {
assert!(aux.get("ViewLayer.Combined.R").is_some());
}
#[test]
fn multipart_fallback_filters_channels_and_reserves_display_planes() {
use exr::prelude::*;
let part = |name: &str, pos: (i32, i32), size: (usize, usize), channels: Vec<AnyChannel<FlatSamples>>| {
let attrs = LayerAttributes { layer_name: Some(Text::from(name)), layer_position: Vec2(pos.0, pos.1), ..Default::default() };
Layer::new(size, attrs, Encoding::FAST_LOSSLESS, AnyChannels::sort(channels.into()))
};
let (w, h) = (2usize, 1usize);
let bytes = file(
vec![
part("Depth", (0, 0), (1, 1), vec![AnyChannel::new("Z", FlatSamples::F32(vec![7.0]))]),
part(
"Beauty",
(1, 1),
(w, h),
vec![
AnyChannel::new("R", FlatSamples::F32(vec![0.1; w * h])),
AnyChannel::new("G", FlatSamples::F32(vec![0.2; w * h])),
AnyChannel::new("B", FlatSamples::F32(vec![0.3; w * h])),
],
),
],
IntegerBounds::from_dimensions((3, 2)),
);
let mut limits = craft_exr::decode::Limits::default();
limits.max_width = u32::MAX;
limits.max_height = u32::MAX;
limits.max_pixels = u64::MAX;
limits.max_bytes = u64::MAX;
let parts = craft_exr::decode::parts(&bytes, &limits).unwrap();
assert_eq!(planes_bytes(&parts, &|name| name == "Beauty.R"), Some(3 * 2 * 4));
assert_eq!(planes_bytes(&parts, &|_| false), Some(0));
// Different display windows must not reserve every part at the first part's size.
let mut varied = parts.clone();
varied[0].display_window.width = 1;
varied[0].display_window.height = 1;
varied[1].display_window.width = 10;
varied[1].display_window.height = 20;
assert_eq!(planes_bytes(&varied, &|_| true), Some(4 + 10 * 20 * 3 * 4));
assert_eq!(planes_bytes(&varied, &|name| name == "Beauty.R"), Some(10 * 20 * 4));
varied[1].display_window.width = u32::MAX;
varied[1].display_window.height = u32::MAX;
assert_eq!(planes_bytes(&varied, &|_| true), None);
assert_eq!(planes_bytes(&varied, &|name| name == "Depth.Z"), Some(4));
// Skipping the RGB part preserves the first-RGB fallback state and depth samples.
let depth = decode(&bytes, &|name| name == "Depth.Z").unwrap();
assert_eq!(depth.rgb, Rgb::Unsupported);
assert_eq!(depth.aux.channels.len(), 1);
assert_eq!(depth.aux.get("Depth.Z").unwrap()[0], 7.0);
let selected = decode(&bytes, &|name| name == "Beauty.R").unwrap();
assert_eq!(selected.aux.channels.iter().map(|(name, _)| name.as_str()).collect::<Vec<_>>(), ["Beauty.R"]);
assert_eq!(selected.aux.get("Beauty.R").unwrap(), [0.0, 0.0, 0.0, 0.0, 0.1, 0.1]);
// The old app decoder selected the named beauty part when the first part was depth-only,
// and placed its data into the shared display window; retain that layered-picture result.
let image = layered_image(&bytes).unwrap().to_rgba32f();
assert_eq!(image.get_pixel(1, 1).0, [0.1, 0.2, 0.3, 1.0]);
assert_eq!(image.get_pixel(0, 0).0, [0.0, 0.0, 0.0, 1.0]);
}
/// Straight RGBA of [`layered_image`] at pixel 0 for a file of single-value channels.
fn picture<S: AsRef<str>>(channels: &[(S, f32)]) -> Vec<f32> {
use exr::prelude::*;