Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Merge pull request #765 from vangel76/gap-dpx-import

Brandon Thomas3d02e65f2b53
diff --cc crates/engine/src/media_browser.rs
index a3519e4f1,24cb4f3ab..5edd67ca3
--- a/crates/engine/src/media_browser.rs
+++ b/crates/engine/src/media_browser.rs
@@@ -194,10 -194,10 +194,10 @@@ pub struct Entry
}
const VIDEO: &[&str] = &["mp4", "m4v", "mov", "webm", "mkv", "avi", "mxf", "gif"];
- const IMAGE: &[&str] = &["png", "jpg", "jpeg", "tif", "tiff", "exr", "bmp", "webp", "psd", "psb", "svg", "tga", "dpx", "hdr"];
+ const IMAGE: &[&str] = &["png", "jpg", "jpeg", "tif", "tiff", "exr", "bmp", "webp", "psd", "psb", "svg", "tga", "dpx", "cin", "hdr"];
const AUDIO: &[&str] = &["wav", "aif", "aiff", "mp3", "m4a", "aac", "flac", "ogg", "opus"];
const DATA: &[&str] = &["json", "csv", "tsv", "mgjson"];
-const MODEL: &[&str] = &["gltf", "glb", "obj"];
+const MODEL: &[&str] = &["gltf", "glb", "obj", "stl", "fbx"];
/// Kind of file from its extension.
pub fn kind_of(path: &str) -> Option<&'static str> {
diff --cc crates/media/tests/footage.rs
index f988ff0c4,f842171a9..faab38f91
--- a/crates/media/tests/footage.rs
+++ b/crates/media/tests/footage.rs
@@@ -747,12 -675,122 +747,132 @@@ fn conformed_flac_audio_reads_back_like
let _ = std::fs::remove_dir_all(&folder);
}
+/// File ▸ Import of an STL part: importable by extension and probed as a 3D model item.
+#[test]
+fn stl_imports_as_a_model() {
+ assert!(effectcraft_media::is_importable(Path::new("part.stl")));
+ let ascii = "solid part\nfacet normal 0 0 1\nouter loop\nvertex 0 0 0\nvertex 1 0 0\nvertex 0 1 0\nendloop\nendfacet\nendsolid part\n";
+ let f = effectcraft_media::probe_bytes("part.stl", Arc::from(ascii.as_bytes())).expect("probe");
+ assert_eq!(f.kind, FootageKind::Model);
+ assert_eq!(f.codec, "STL (1 meshes, 1 triangles)");
+}
++
+ /// `src` decoded by ffmpeg to 8-bit (`deep`: 16-bit) RGBA, premultiplied like the pool's frames.
+ fn ffmpeg_rgba(src: &Path, deep: bool) -> Vec<[f32; 4]> {
+ let out = Command::new("ffmpeg")
+ .args(["-hide_banner", "-loglevel", "error", "-i"])
+ .arg(src)
+ .args(["-sws_flags", "accurate_rnd+full_chroma_int+bitexact", "-f", "rawvideo", "-pix_fmt", if deep { "rgba64le" } else { "rgba" }, "-"])
+ .output()
+ .expect("run ffmpeg");
+ assert!(out.status.success(), "ffmpeg decode of {}", src.display());
+ let px = |v: [f32; 4]| [v[0] * v[3], v[1] * v[3], v[2] * v[3], v[3]];
+ if !deep {
+ return out.stdout.as_chunks::<4>().0.iter().map(|p| px(p.map(|v| v as f32 / 255.0))).collect();
+ }
+ out.stdout.as_chunks::<8>().0.iter().map(|p| px(std::array::from_fn(|i| u16::from_le_bytes([p[2 * i], p[2 * i + 1]]) as f32 / 65535.0))).collect()
+ }
+
+ /// #756: DPX stills in every layout and depth ffmpeg's encoder writes (8-bit luma / RGB / RGBA /
+ /// ABGR, 10- and 12-bit filled RGB, 16-bit luma / RGB / RGBA, big- and little-endian, lines
+ /// padded to 32-bit words) import and decode as ffmpeg decodes them.
+ #[test]
+ fn dpx_stills_match_ffmpeg() {
+ let Some(png) = alpha_png() else { return };
+ let src = png.to_str().expect("utf8");
+ let formats = [
+ ("rgb24", "DPX 8-bit RGB", false),
+ ("rgba", "DPX 8-bit RGBA", true),
+ ("abgr", "DPX 8-bit ABGR", true),
+ ("gray", "DPX 8-bit luma", false),
+ ("gray16be", "DPX 16-bit luma", false),
+ ("gbrp10be", "DPX 10-bit RGB", false),
+ ("gbrp10le", "DPX 10-bit RGB", false),
+ ("gbrp12be", "DPX 12-bit RGB", false),
+ ("gbrp12le", "DPX 12-bit RGB", false),
+ ("rgb48be", "DPX 16-bit RGB", false),
+ ("rgba64le", "DPX 16-bit RGBA", true),
+ ];
+ for (pf, codec, alpha) in formats {
+ // 250 px wide: 8-bit and 10-bit lines need padding to a 32-bit word.
+ let Some(p) = ffmpeg_fixture(&format!("dpx-{pf}.dpx"), &["-i", src, "-vf", "scale=250:100", "-pix_fmt", pf]) else { return };
+ assert!(effectcraft_media::is_importable(&p));
+ let f = probe(&p).expect(pf);
+ assert_eq!(f.kind, FootageKind::Still);
+ assert_eq!((f.width, f.height, f.codec.as_str()), (250, 100, codec), "{pf}");
+ assert_eq!(f.alpha, if alpha { AlphaMode::Straight } else { AlphaMode::Ignore }, "{pf}");
+ let img = MediaPool::new().frame_at(&f, Tick::ZERO).expect(pf);
+ let want = ffmpeg_rgba(&p, !codec.contains("8-bit"));
+ assert_eq!(want.len(), img.data.len(), "{pf}");
+ let worst = img.data.iter().zip(&want).flat_map(|(a, b)| (0..4).map(move |k| (a[k] - b[k]).abs())).fold(0.0f32, f32::max);
+ // (within one 16-bit step: ffmpeg widens 10/12-bit samples by bit replication)
+ assert!(worst < 2.0 / 65535.0, "{pf}: worst difference {worst}");
+ }
+ }
+
+ /// #756: a numbered run of DPX files plays as an image sequence.
+ #[test]
+ fn dpx_sequence_plays() {
+ let Some(first) = ffmpeg_fixture("dpxseq/plate.0001.dpx", &["-f", "lavfi", "-i", "color=c=0x202020:size=32x16", "-frames:v", "1", "-pix_fmt", "gbrp10le"])
+ else {
+ return;
+ };
+ let Some(second) = ffmpeg_fixture("dpxseq/plate.0002.dpx", &["-f", "lavfi", "-i", "color=c=0xe0e0e0:size=32x16", "-frames:v", "1", "-pix_fmt", "gbrp10le"])
+ else {
+ return;
+ };
+ let mut f = probe(&first).expect("probe");
+ f.kind = FootageKind::Sequence;
+ f.sequence = [&first, &second].iter().map(|p| p.to_string_lossy().to_string()).collect();
+ f.sync_sequence_duration();
+ let pool = MediaPool::new();
+ let level = |n| pool.frame_at(&f, t_of(f.frame_rate, n)).expect("frame").data[0][0];
+ assert!((level(0) - 32.0 / 255.0).abs() < 0.01 && (level(1) - 224.0 / 255.0).abs() < 0.01, "{} {}", level(0), level(1));
+ }
+
+ /// #756: a Kodak Cineon file (no ffmpeg encoder: written here from the spec, 10-bit RGB
+ /// left-justified in big-endian 32-bit words; checked against ImageMagick's reader when written)
+ /// shows its log code values as stored; a truncated one is refused, never a panic.
+ #[test]
+ fn cineon_still_shows_code_values() {
+ let (w, h) = (5u32, 3u32);
+ let code = |x: u32, y: u32| [(x * 37 + y * 101) % 1024, (x * 11 + y * 7 + 300) % 1024, (x * 3 + y * 251 + 700) % 1024];
+ let mut b = vec![0u8; 1024];
+ b[..4].copy_from_slice(&[0x80, 0x2a, 0x5f, 0xd7]);
+ b[4..8].copy_from_slice(&1024u32.to_be_bytes());
+ b[8..12].copy_from_slice(&1024u32.to_be_bytes());
+ b[24..28].copy_from_slice(b"V4.5");
+ b[193] = 3;
+ for c in 0..3 {
+ let o = 196 + 28 * c;
+ b[o + 1] = c as u8 + 1;
+ b[o + 2] = 10;
+ b[o + 4..o + 8].copy_from_slice(&w.to_be_bytes());
+ b[o + 8..o + 12].copy_from_slice(&h.to_be_bytes());
+ }
+ b[681] = 5;
+ for y in 0..h {
+ for x in 0..w {
+ let [r, g, bl] = code(x, y);
+ b.extend_from_slice(&((r << 22) | (g << 12) | (bl << 2)).to_be_bytes());
+ }
+ }
+ let bytes: Arc<[u8]> = b.clone().into();
+ let f = effectcraft_media::probe_bytes("scan.cin", bytes.clone()).expect("probe");
+ assert_eq!((f.kind, f.width, f.height, f.codec.as_str(), f.alpha), (FootageKind::Still, 5, 3, "Cineon 10-bit RGB, log", AlphaMode::Ignore));
+ assert!(effectcraft_media::is_importable(Path::new("scan.cin")));
+ let pool = MediaPool::new();
+ pool.add_bytes("scan.cin", bytes);
+ let img = pool.frame_at(&f, Tick::ZERO).expect("frame");
+ for y in 0..h {
+ for x in 0..w {
+ let want = code(x, y).map(|v| v as f32 / 1023.0);
+ let got = img.get(i64::from(x), i64::from(y));
+ assert!((0..3).all(|k| (got[k] - want[k]).abs() < 1e-4) && got[3] == 1.0, "{x},{y}: {got:?} vs {want:?}");
+ }
+ }
+ for n in [3, 100, 700, 1024, b.len() - 1] {
+ let cut: Arc<[u8]> = b.get(..n).expect("cut").into();
+ assert!(effectcraft_media::probe_bytes("cut.cin", cut).is_err(), "{n}");
+ }
+ }
diff --cc crates/ui-egui/src/menus.rs
index c34b98b1c,a134b2488..e2bf0f1a3
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@@ -1236,8 -1225,8 +1236,8 @@@ fn file_dialog(app: &mut EffectcraftApp
return None;
}
const MEDIA: &[&str] = &[
- "mp4", "mov", "m4v", "mkv", "webm", "png", "jpg", "jpeg", "gif", "webp", "tif", "tiff", "bmp", "exr", "wav", "aif", "aiff", "mp3", "flac", "ogg",
- "opus", "svg", "pdf", "ai", "eps", "psd", "psb", "tga", "hdr", "gltf", "glb", "obj", "stl", "fbx", "json", "csv", "tsv",
+ "mp4", "mov", "m4v", "mkv", "webm", "png", "jpg", "jpeg", "gif", "webp", "tif", "tiff", "bmp", "exr", "dpx", "cin", "wav", "aif", "aiff", "mp3",
- "flac", "ogg", "opus", "svg", "pdf", "ai", "eps", "psd", "psb", "gltf", "glb", "obj", "json", "csv", "tsv",
++ "flac", "ogg", "opus", "svg", "pdf", "ai", "eps", "psd", "psb", "tga", "hdr", "gltf", "glb", "obj", "stl", "fbx", "json", "csv", "tsv",
];
// A host whose modal dialogs would run a nested event loop inside this frame (macOS: a
// drag over the window then re-entered winit's event handler and aborted, #511) shows the
diff --cc docs/file-format-parity.md
index 29eedc0ce,338cdae18..14266cc83
--- a/docs/file-format-parity.md
+++ b/docs/file-format-parity.md
@@@ -48,9 -48,9 +48,9 @@@ trips and renders, checked by tests, no
| GIF | R/W | yes | yes (animated) | good |
| BMP | R | yes | — | good |
| WebP | — | yes | — | beyond After Effects |
-| Targa `.tga` | R/W | none | none | Media Browser lists it but import refuses (gap 17) |
+| Targa `.tga` | R/W | yes (still and sequence; alpha interpreted on import) | none | good for import (#745); no Targa output |
- | DPX / Cineon `.dpx` `.cin` | R/W | none | none | Media Browser lists it but import refuses (gap 17); common in film VFX |
+ | DPX / Cineon `.dpx` `.cin` | R/W | yes (still and sequence; 8/10/12/16-bit luma, RGB, RGBA, both byte orders; log code values shown as stored) | none | partial: import (#756); no Interpret Footage ▸ Cineon Settings (log to linear), no DPX output; common in film VFX |
-| Radiance `.hdr` | R/W | none | none | Same |
+| Radiance `.hdr` | R/W | yes (still and sequence, 32-bit linear float like OpenEXR) | none | good for import (#745); no Radiance output |
| SGI, PICT, ElectricImage, RLA/RPF images | R | none | none | Legacy; RPF camera data import exists (`keys.rpfCameraImport`) |
| Camera Raw (DNG, CR3, NEF…) | R (Camera Raw) | none | none | LightCraft has decoders that could be shared |
| HEIF / AVIF | R (platform) | none | none | — |
diff --cc docs/gaps.md
index 7711b960b,445ebe61f..7eadbcb34
--- a/docs/gaps.md
+++ b/docs/gaps.md
@@@ -73,7 -73,7 +73,7 @@@ are grouped by area; the issue tracker
| 14 | **Object Matte** (26.2, disk cache in 26.5) | Not present; MobileSAM is already in `effectcraft-segment` and could back it | The new one-click roto; Roto Brush covers part of it | 15–30 h | G7 · [target-app-parity.md](target-app-parity.md) |
| 15 | **Hardware video decode and encode** | No VideoToolbox, NVENC, Quick Sync or VA-API; #498 asks for it; FilmCraft has VideoToolbox / NVENC / VA-API paths to borrow | 4K playback and export speed | 25–45 h | G5/G6 · [hardware-parity.md](hardware-parity.md) |
| 16 | **Localization depth** | Menus in 6 languages; panels in 4; effect names and ~1,650 effect parameter names untranslated; French, German, Korean, Italian, Russian (After Effects ships them) absent; #599 Hangul boxes on macOS | After Effects is used heavily in Japan, China, Korea, Brazil, Europe | 60–110 h + native review | G9 · [localization-parity.md](localization-parity.md) |
- | 17 | **Media Browser lists files import refuses** | `media_browser.rs` lists DPX, AVI, MXF; `media::is_importable` has none of them (Targa and Radiance HDR import since #745); #431 any image imports as a sequence; #324 MP3 goes silent | Confusing failures on common VFX formats (DPX) | 15–30 h | G6 · [file-format-parity.md](file-format-parity.md) |
-| 17 | **Media Browser lists files import refuses** | `media_browser.rs` lists TGA, HDR, AVI, MXF; `media::is_importable` has none of them (DPX and Cineon import since #756, log shown as stored: no Cineon Settings conversion yet); #431 any image imports as a sequence; #324 MP3 goes silent | Confusing failures on common VFX formats (TGA) | 15–30 h | G6 · [file-format-parity.md](file-format-parity.md) |
++| 17 | **Media Browser lists files import refuses** | `media_browser.rs` lists AVI, MXF; `media::is_importable` has none of them (Targa and Radiance HDR import since #745; DPX and Cineon since #756, log shown as stored: no Cineon Settings conversion yet); #431 any image imports as a sequence; #324 MP3 goes silent | Confusing failures on common VFX formats | 15–30 h | G6 · [file-format-parity.md](file-format-parity.md) |
| 18 | **Relative paths and relinking** | Projects store absolute footage paths; no relink when a project moves | Moving or sharing a project breaks it | 6–12 h | G4 · [file-format-parity.md](file-format-parity.md) |
| 19 | **Plug-in ecosystem** | No After Effects SDK hosting (#600, #327 OpenFX, #334, #376 plug-in manager); our WebAssembly API has no third-party plug-ins | Many pro projects depend on Trapcode, Element, Saber… | 40–80 h for API growth; SDK hosting needs an owner decision | G8 · [scripting-parity.md](scripting-parity.md) |
| 20 | **Multi-monitor and video output** | #486 multi-screen, floating panels on other screens, Mercury Transmit to video hardware (we have a second preview window only) | Two-screen setups are standard for professionals | 10–20 h | G2 · [hardware-parity.md](hardware-parity.md) |