| author | |
| committer | |
| log | 316cb0e532d34efbaf71deeeac975c9a70db36dc |
| tree | 36ebcb6d72b1c949ac07e0f6c2e56be2c503abe6 |
| parent | 56b0a91c5c3924c95a0aeebf982eed8678afc118 |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
18 files changed, 4660 insertions(+), 112 deletions(-)
Cargo.lock+533-28| ... | ... | @@ -75,8 +75,8 @@ dependencies = [ |
| 75 | 75 | "accesskit_consumer", |
| 76 | 76 | "hashbrown 0.17.2", |
| 77 | 77 | "static_assertions", |
| 78 | "windows", | |
| 79 | "windows-core", | |
| 78 | "windows 0.62.2", | |
| 79 | "windows-core 0.62.2", | |
| 80 | 80 | ] |
| 81 | 81 | |
| 82 | 82 | [[package]] |
| ... | ... | @@ -134,6 +134,28 @@ version = "0.2.22" |
| 134 | 134 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 135 | 135 | checksum = "57b212daf2e827b1ccdd778b7eb48ba433e58cb0e4f27b43cd6b7a608425a014" |
| 136 | 136 | |
| 137 | [[package]] | |
| 138 | name = "alsa" | |
| 139 | version = "0.9.1" | |
| 140 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 141 | checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43" | |
| 142 | dependencies = [ | |
| 143 | "alsa-sys", | |
| 144 | "bitflags 2.13.2", | |
| 145 | "cfg-if", | |
| 146 | "libc", | |
| 147 | ] | |
| 148 | ||
| 149 | [[package]] | |
| 150 | name = "alsa-sys" | |
| 151 | version = "0.3.1" | |
| 152 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 153 | checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" | |
| 154 | dependencies = [ | |
| 155 | "libc", | |
| 156 | "pkg-config", | |
| 157 | ] | |
| 158 | ||
| 137 | 159 | [[package]] |
| 138 | 160 | name = "android-activity" |
| 139 | 161 | version = "0.6.1" |
| ... | ... | @@ -143,12 +165,12 @@ dependencies = [ |
| 143 | 165 | "android-properties", |
| 144 | 166 | "bitflags 2.13.2", |
| 145 | 167 | "cc", |
| 146 | "jni", | |
| 168 | "jni 0.22.4", | |
| 147 | 169 | "libc", |
| 148 | 170 | "log", |
| 149 | "ndk", | |
| 171 | "ndk 0.9.0", | |
| 150 | 172 | "ndk-context", |
| 151 | "ndk-sys", | |
| 173 | "ndk-sys 0.6.0+11769913", | |
| 152 | 174 | "num_enum", |
| 153 | 175 | "thiserror 2.0.21", |
| 154 | 176 | ] |
| ... | ... | @@ -362,6 +384,24 @@ version = "0.23.1" |
| 362 | 384 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 363 | 385 | checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" |
| 364 | 386 | |
| 387 | [[package]] | |
| 388 | name = "bindgen" | |
| 389 | version = "0.72.1" | |
| 390 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 391 | checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" | |
| 392 | dependencies = [ | |
| 393 | "bitflags 2.13.2", | |
| 394 | "cexpr", | |
| 395 | "clang-sys", | |
| 396 | "itertools", | |
| 397 | "proc-macro2", | |
| 398 | "quote", | |
| 399 | "regex", | |
| 400 | "rustc-hash 2.1.3", | |
| 401 | "shlex 1.3.0", | |
| 402 | "syn 2.0.119", | |
| 403 | ] | |
| 404 | ||
| 365 | 405 | [[package]] |
| 366 | 406 | name = "bit-set" |
| 367 | 407 | version = "0.10.0" |
| ... | ... | @@ -527,7 +567,22 @@ dependencies = [ |
| 527 | 567 | "find-msvc-tools", |
| 528 | 568 | "jobserver", |
| 529 | 569 | "libc", |
| 530 | "shlex", | |
| 570 | "shlex 2.0.1", | |
| 571 | ] | |
| 572 | ||
| 573 | [[package]] | |
| 574 | name = "cesu8" | |
| 575 | version = "1.1.0" | |
| 576 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 577 | checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" | |
| 578 | ||
| 579 | [[package]] | |
| 580 | name = "cexpr" | |
| 581 | version = "0.6.0" | |
| 582 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 583 | checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" | |
| 584 | dependencies = [ | |
| 585 | "nom 7.1.3", | |
| 531 | 586 | ] |
| 532 | 587 | |
| 533 | 588 | [[package]] |
| ... | ... | @@ -542,6 +597,17 @@ version = "0.2.2" |
| 542 | 597 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 543 | 598 | checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" |
| 544 | 599 | |
| 600 | [[package]] | |
| 601 | name = "clang-sys" | |
| 602 | version = "1.9.1" | |
| 603 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 604 | checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" | |
| 605 | dependencies = [ | |
| 606 | "glob", | |
| 607 | "libc", | |
| 608 | "libloading", | |
| 609 | ] | |
| 610 | ||
| 545 | 611 | [[package]] |
| 546 | 612 | name = "clipboard-win" |
| 547 | 613 | version = "5.4.3" |
| ... | ... | @@ -633,6 +699,55 @@ dependencies = [ |
| 633 | 699 | "libc", |
| 634 | 700 | ] |
| 635 | 701 | |
| 702 | [[package]] | |
| 703 | name = "core_detect" | |
| 704 | version = "1.0.0" | |
| 705 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 706 | checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" | |
| 707 | ||
| 708 | [[package]] | |
| 709 | name = "coreaudio-rs" | |
| 710 | version = "0.11.3" | |
| 711 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 712 | checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" | |
| 713 | dependencies = [ | |
| 714 | "bitflags 1.3.2", | |
| 715 | "core-foundation-sys", | |
| 716 | "coreaudio-sys", | |
| 717 | ] | |
| 718 | ||
| 719 | [[package]] | |
| 720 | name = "coreaudio-sys" | |
| 721 | version = "0.2.18" | |
| 722 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 723 | checksum = "b9b4739a805a62757a83e5654fa3faabec0442666b263bb2287d5a8185bfd953" | |
| 724 | dependencies = [ | |
| 725 | "bindgen", | |
| 726 | ] | |
| 727 | ||
| 728 | [[package]] | |
| 729 | name = "cpal" | |
| 730 | version = "0.15.3" | |
| 731 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 732 | checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" | |
| 733 | dependencies = [ | |
| 734 | "alsa", | |
| 735 | "core-foundation-sys", | |
| 736 | "coreaudio-rs", | |
| 737 | "dasp_sample", | |
| 738 | "jni 0.21.1", | |
| 739 | "js-sys", | |
| 740 | "libc", | |
| 741 | "mach2", | |
| 742 | "ndk 0.8.0", | |
| 743 | "ndk-context", | |
| 744 | "oboe", | |
| 745 | "wasm-bindgen", | |
| 746 | "wasm-bindgen-futures", | |
| 747 | "web-sys", | |
| 748 | "windows 0.54.0", | |
| 749 | ] | |
| 750 | ||
| 636 | 751 | [[package]] |
| 637 | 752 | name = "cpufeatures" |
| 638 | 753 | version = "0.3.1" |
| ... | ... | @@ -700,6 +815,12 @@ dependencies = [ |
| 700 | 815 | "serde", |
| 701 | 816 | ] |
| 702 | 817 | |
| 818 | [[package]] | |
| 819 | name = "dasp_sample" | |
| 820 | version = "0.11.0" | |
| 821 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 822 | checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" | |
| 823 | ||
| 703 | 824 | [[package]] |
| 704 | 825 | name = "data-url" |
| 705 | 826 | version = "0.3.2" |
| ... | ... | @@ -828,6 +949,20 @@ version = "1.19.0" |
| 828 | 949 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 829 | 950 | checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" |
| 830 | 951 | |
| 952 | [[package]] | |
| 953 | name = "encoding_rs" | |
| 954 | version = "0.8.44" | |
| 955 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 956 | checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5" | |
| 957 | dependencies = [ | |
| 958 | "cfg-if", | |
| 959 | "core_detect", | |
| 960 | "multiversion_no_op", | |
| 961 | "rustversion", | |
| 962 | "scopeguard", | |
| 963 | "simdutf8", | |
| 964 | ] | |
| 965 | ||
| 831 | 966 | [[package]] |
| 832 | 967 | name = "endi" |
| 833 | 968 | version = "1.1.1" |
| ... | ... | @@ -839,11 +974,14 @@ name = "engine" |
| 839 | 974 | version = "0.1.0" |
| 840 | 975 | dependencies = [ |
| 841 | 976 | "bytemuck", |
| 977 | "cc", | |
| 978 | "cpal", | |
| 842 | 979 | "exr", |
| 843 | 980 | "image", |
| 844 | 981 | "model", |
| 845 | 982 | "png", |
| 846 | 983 | "pollster", |
| 984 | "symphonia", | |
| 847 | 985 | "text", |
| 848 | 986 | "theme", |
| 849 | 987 | "wgpu", |
| ... | ... | @@ -955,6 +1093,12 @@ dependencies = [ |
| 955 | 1093 | "zune-inflate", |
| 956 | 1094 | ] |
| 957 | 1095 | |
| 1096 | [[package]] | |
| 1097 | name = "extended" | |
| 1098 | version = "0.1.0" | |
| 1099 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1100 | checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365" | |
| 1101 | ||
| 958 | 1102 | [[package]] |
| 959 | 1103 | name = "fastrand" |
| 960 | 1104 | version = "2.5.0" |
| ... | ... | @@ -1174,6 +1318,12 @@ dependencies = [ |
| 1174 | 1318 | "xml-rs", |
| 1175 | 1319 | ] |
| 1176 | 1320 | |
| 1321 | [[package]] | |
| 1322 | name = "glob" | |
| 1323 | version = "0.3.4" | |
| 1324 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1325 | checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" | |
| 1326 | ||
| 1177 | 1327 | [[package]] |
| 1178 | 1328 | name = "glow" |
| 1179 | 1329 | version = "0.17.0" |
| ... | ... | @@ -1206,7 +1356,7 @@ dependencies = [ |
| 1206 | 1356 | "log", |
| 1207 | 1357 | "presser", |
| 1208 | 1358 | "thiserror 2.0.21", |
| 1209 | "windows", | |
| 1359 | "windows 0.62.2", | |
| 1210 | 1360 | ] |
| 1211 | 1361 | |
| 1212 | 1362 | [[package]] |
| ... | ... | @@ -1371,12 +1521,37 @@ dependencies = [ |
| 1371 | 1521 | "hashbrown 0.17.2", |
| 1372 | 1522 | ] |
| 1373 | 1523 | |
| 1524 | [[package]] | |
| 1525 | name = "itertools" | |
| 1526 | version = "0.13.0" | |
| 1527 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1528 | checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" | |
| 1529 | dependencies = [ | |
| 1530 | "either", | |
| 1531 | ] | |
| 1532 | ||
| 1374 | 1533 | [[package]] |
| 1375 | 1534 | name = "itoa" |
| 1376 | 1535 | version = "1.0.19" |
| 1377 | 1536 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1378 | 1537 | checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" |
| 1379 | 1538 | |
| 1539 | [[package]] | |
| 1540 | name = "jni" | |
| 1541 | version = "0.21.1" | |
| 1542 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1543 | checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" | |
| 1544 | dependencies = [ | |
| 1545 | "cesu8", | |
| 1546 | "cfg-if", | |
| 1547 | "combine", | |
| 1548 | "jni-sys 0.3.1", | |
| 1549 | "log", | |
| 1550 | "thiserror 1.0.69", | |
| 1551 | "walkdir", | |
| 1552 | "windows-sys 0.45.0", | |
| 1553 | ] | |
| 1554 | ||
| 1380 | 1555 | [[package]] |
| 1381 | 1556 | name = "jni" |
| 1382 | 1557 | version = "0.22.4" |
| ... | ... | @@ -1504,6 +1679,12 @@ dependencies = [ |
| 1504 | 1679 | "smallvec", |
| 1505 | 1680 | ] |
| 1506 | 1681 | |
| 1682 | [[package]] | |
| 1683 | name = "lazy_static" | |
| 1684 | version = "1.5.1" | |
| 1685 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1686 | checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" | |
| 1687 | ||
| 1507 | 1688 | [[package]] |
| 1508 | 1689 | name = "lebe" |
| 1509 | 1690 | version = "0.5.3" |
| ... | ... | @@ -1596,6 +1777,15 @@ dependencies = [ |
| 1596 | 1777 | "which", |
| 1597 | 1778 | ] |
| 1598 | 1779 | |
| 1780 | [[package]] | |
| 1781 | name = "mach2" | |
| 1782 | version = "0.4.3" | |
| 1783 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1784 | checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" | |
| 1785 | dependencies = [ | |
| 1786 | "libc", | |
| 1787 | ] | |
| 1788 | ||
| 1599 | 1789 | [[package]] |
| 1600 | 1790 | name = "memchr" |
| 1601 | 1791 | version = "2.8.3" |
| ... | ... | @@ -1620,6 +1810,12 @@ dependencies = [ |
| 1620 | 1810 | "autocfg", |
| 1621 | 1811 | ] |
| 1622 | 1812 | |
| 1813 | [[package]] | |
| 1814 | name = "minimal-lexical" | |
| 1815 | version = "0.2.1" | |
| 1816 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1817 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" | |
| 1818 | ||
| 1623 | 1819 | [[package]] |
| 1624 | 1820 | name = "miniz_oxide" |
| 1625 | 1821 | version = "0.8.9" |
| ... | ... | @@ -1707,6 +1903,12 @@ dependencies = [ |
| 1707 | 1903 | "target-features", |
| 1708 | 1904 | ] |
| 1709 | 1905 | |
| 1906 | [[package]] | |
| 1907 | name = "multiversion_no_op" | |
| 1908 | version = "1.0.0" | |
| 1909 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1910 | checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" | |
| 1911 | ||
| 1710 | 1912 | [[package]] |
| 1711 | 1913 | name = "naga" |
| 1712 | 1914 | version = "30.0.2" |
| ... | ... | @@ -1745,6 +1947,20 @@ dependencies = [ |
| 1745 | 1947 | "thiserror 2.0.21", |
| 1746 | 1948 | ] |
| 1747 | 1949 | |
| 1950 | [[package]] | |
| 1951 | name = "ndk" | |
| 1952 | version = "0.8.0" | |
| 1953 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1954 | checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" | |
| 1955 | dependencies = [ | |
| 1956 | "bitflags 2.13.2", | |
| 1957 | "jni-sys 0.3.1", | |
| 1958 | "log", | |
| 1959 | "ndk-sys 0.5.0+25.2.9519653", | |
| 1960 | "num_enum", | |
| 1961 | "thiserror 1.0.69", | |
| 1962 | ] | |
| 1963 | ||
| 1748 | 1964 | [[package]] |
| 1749 | 1965 | name = "ndk" |
| 1750 | 1966 | version = "0.9.0" |
| ... | ... | @@ -1754,7 +1970,7 @@ dependencies = [ |
| 1754 | 1970 | "bitflags 2.13.2", |
| 1755 | 1971 | "jni-sys 0.3.1", |
| 1756 | 1972 | "log", |
| 1757 | "ndk-sys", | |
| 1973 | "ndk-sys 0.6.0+11769913", | |
| 1758 | 1974 | "num_enum", |
| 1759 | 1975 | "raw-window-handle", |
| 1760 | 1976 | "thiserror 1.0.69", |
| ... | ... | @@ -1766,6 +1982,15 @@ version = "0.1.1" |
| 1766 | 1982 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1767 | 1983 | checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" |
| 1768 | 1984 | |
| 1985 | [[package]] | |
| 1986 | name = "ndk-sys" | |
| 1987 | version = "0.5.0+25.2.9519653" | |
| 1988 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1989 | checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" | |
| 1990 | dependencies = [ | |
| 1991 | "jni-sys 0.3.1", | |
| 1992 | ] | |
| 1993 | ||
| 1769 | 1994 | [[package]] |
| 1770 | 1995 | name = "ndk-sys" |
| 1771 | 1996 | version = "0.6.0+11769913" |
| ... | ... | @@ -1775,6 +2000,16 @@ dependencies = [ |
| 1775 | 2000 | "jni-sys 0.3.1", |
| 1776 | 2001 | ] |
| 1777 | 2002 | |
| 2003 | [[package]] | |
| 2004 | name = "nom" | |
| 2005 | version = "7.1.3" | |
| 2006 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 2007 | checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" | |
| 2008 | dependencies = [ | |
| 2009 | "memchr", | |
| 2010 | "minimal-lexical", | |
| 2011 | ] | |
| 2012 | ||
| 1778 | 2013 | [[package]] |
| 1779 | 2014 | name = "nom" |
| 1780 | 2015 | version = "8.0.0" |
| ... | ... | @@ -1800,6 +2035,17 @@ version = "0.2.2" |
| 1800 | 2035 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1801 | 2036 | checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" |
| 1802 | 2037 | |
| 2038 | [[package]] | |
| 2039 | name = "num-derive" | |
| 2040 | version = "0.4.2" | |
| 2041 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 2042 | checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" | |
| 2043 | dependencies = [ | |
| 2044 | "proc-macro2", | |
| 2045 | "quote", | |
| 2046 | "syn 2.0.119", | |
| 2047 | ] | |
| 2048 | ||
| 1803 | 2049 | [[package]] |
| 1804 | 2050 | name = "num-traits" |
| 1805 | 2051 | version = "0.2.19" |
| ... | ... | @@ -2158,6 +2404,29 @@ dependencies = [ |
| 2158 | 2404 | "objc2-foundation 0.2.2", |
| 2159 | 2405 | ] |
| 2160 | 2406 | |
| 2407 | [[package]] | |
| 2408 | name = "oboe" | |
| 2409 | version = "0.6.1" | |
| 2410 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 2411 | checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" | |
| 2412 | dependencies = [ | |
| 2413 | "jni 0.21.1", | |
| 2414 | "ndk 0.8.0", | |
| 2415 | "ndk-context", | |
| 2416 | "num-derive", | |
| 2417 | "num-traits", | |
| 2418 | "oboe-sys", | |
| 2419 | ] | |
| 2420 | ||
| 2421 | [[package]] | |
| 2422 | name = "oboe-sys" | |
| 2423 | version = "0.6.1" | |
| 2424 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 2425 | checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" | |
| 2426 | dependencies = [ | |
| 2427 | "cc", | |
| 2428 | ] | |
| 2429 | ||
| 2161 | 2430 | [[package]] |
| 2162 | 2431 | name = "once_cell" |
| 2163 | 2432 | version = "1.21.4" |
| ... | ... | @@ -2768,6 +3037,12 @@ dependencies = [ |
| 2768 | 3037 | "digest", |
| 2769 | 3038 | ] |
| 2770 | 3039 | |
| 3040 | [[package]] | |
| 3041 | name = "shlex" | |
| 3042 | version = "1.3.0" | |
| 3043 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3044 | checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" | |
| 3045 | ||
| 2771 | 3046 | [[package]] |
| 2772 | 3047 | name = "shlex" |
| 2773 | 3048 | version = "2.0.1" |
| ... | ... | @@ -3003,6 +3278,141 @@ dependencies = [ |
| 3003 | 3278 | "siphasher", |
| 3004 | 3279 | ] |
| 3005 | 3280 | |
| 3281 | [[package]] | |
| 3282 | name = "symphonia" | |
| 3283 | version = "0.5.5" | |
| 3284 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3285 | checksum = "5773a4c030a19d9bfaa090f49746ff35c75dfddfa700df7a5939d5e076a57039" | |
| 3286 | dependencies = [ | |
| 3287 | "lazy_static", | |
| 3288 | "symphonia-bundle-flac", | |
| 3289 | "symphonia-bundle-mp3", | |
| 3290 | "symphonia-codec-aac", | |
| 3291 | "symphonia-codec-pcm", | |
| 3292 | "symphonia-core", | |
| 3293 | "symphonia-format-isomp4", | |
| 3294 | "symphonia-format-ogg", | |
| 3295 | "symphonia-format-riff", | |
| 3296 | "symphonia-metadata", | |
| 3297 | ] | |
| 3298 | ||
| 3299 | [[package]] | |
| 3300 | name = "symphonia-bundle-flac" | |
| 3301 | version = "0.5.5" | |
| 3302 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3303 | checksum = "c91565e180aea25d9b80a910c546802526ffd0072d0b8974e3ebe59b686c9976" | |
| 3304 | dependencies = [ | |
| 3305 | "log", | |
| 3306 | "symphonia-core", | |
| 3307 | "symphonia-metadata", | |
| 3308 | "symphonia-utils-xiph", | |
| 3309 | ] | |
| 3310 | ||
| 3311 | [[package]] | |
| 3312 | name = "symphonia-bundle-mp3" | |
| 3313 | version = "0.5.5" | |
| 3314 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3315 | checksum = "4872dd6bb56bf5eac799e3e957aa1981086c3e613b27e0ac23b176054f7c57ed" | |
| 3316 | dependencies = [ | |
| 3317 | "lazy_static", | |
| 3318 | "log", | |
| 3319 | "symphonia-core", | |
| 3320 | "symphonia-metadata", | |
| 3321 | ] | |
| 3322 | ||
| 3323 | [[package]] | |
| 3324 | name = "symphonia-codec-aac" | |
| 3325 | version = "0.5.5" | |
| 3326 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3327 | checksum = "4c263845aa86881416849c1729a54c7f55164f8b96111dba59de46849e73a790" | |
| 3328 | dependencies = [ | |
| 3329 | "lazy_static", | |
| 3330 | "log", | |
| 3331 | "symphonia-core", | |
| 3332 | ] | |
| 3333 | ||
| 3334 | [[package]] | |
| 3335 | name = "symphonia-codec-pcm" | |
| 3336 | version = "0.5.5" | |
| 3337 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3338 | checksum = "4e89d716c01541ad3ebe7c91ce4c8d38a7cf266a3f7b2f090b108fb0cb031d95" | |
| 3339 | dependencies = [ | |
| 3340 | "log", | |
| 3341 | "symphonia-core", | |
| 3342 | ] | |
| 3343 | ||
| 3344 | [[package]] | |
| 3345 | name = "symphonia-core" | |
| 3346 | version = "0.5.5" | |
| 3347 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3348 | checksum = "ea00cc4f79b7f6bb7ff87eddc065a1066f3a43fe1875979056672c9ef948c2af" | |
| 3349 | dependencies = [ | |
| 3350 | "arrayvec", | |
| 3351 | "bitflags 1.3.2", | |
| 3352 | "bytemuck", | |
| 3353 | "lazy_static", | |
| 3354 | "log", | |
| 3355 | ] | |
| 3356 | ||
| 3357 | [[package]] | |
| 3358 | name = "symphonia-format-isomp4" | |
| 3359 | version = "0.5.5" | |
| 3360 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3361 | checksum = "243739585d11f81daf8dac8d9f3d18cc7898f6c09a259675fc364b382c30e0a5" | |
| 3362 | dependencies = [ | |
| 3363 | "encoding_rs", | |
| 3364 | "log", | |
| 3365 | "symphonia-core", | |
| 3366 | "symphonia-metadata", | |
| 3367 | "symphonia-utils-xiph", | |
| 3368 | ] | |
| 3369 | ||
| 3370 | [[package]] | |
| 3371 | name = "symphonia-format-ogg" | |
| 3372 | version = "0.5.5" | |
| 3373 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3374 | checksum = "2b4955c67c1ed3aa8ae8428d04ca8397fbef6a19b2b051e73b5da8b1435639cb" | |
| 3375 | dependencies = [ | |
| 3376 | "log", | |
| 3377 | "symphonia-core", | |
| 3378 | "symphonia-metadata", | |
| 3379 | "symphonia-utils-xiph", | |
| 3380 | ] | |
| 3381 | ||
| 3382 | [[package]] | |
| 3383 | name = "symphonia-format-riff" | |
| 3384 | version = "0.5.5" | |
| 3385 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3386 | checksum = "c2d7c3df0e7d94efb68401d81906eae73c02b40d5ec1a141962c592d0f11a96f" | |
| 3387 | dependencies = [ | |
| 3388 | "extended", | |
| 3389 | "log", | |
| 3390 | "symphonia-core", | |
| 3391 | "symphonia-metadata", | |
| 3392 | ] | |
| 3393 | ||
| 3394 | [[package]] | |
| 3395 | name = "symphonia-metadata" | |
| 3396 | version = "0.5.5" | |
| 3397 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3398 | checksum = "36306ff42b9ffe6e5afc99d49e121e0bd62fe79b9db7b9681d48e29fa19e6b16" | |
| 3399 | dependencies = [ | |
| 3400 | "encoding_rs", | |
| 3401 | "lazy_static", | |
| 3402 | "log", | |
| 3403 | "symphonia-core", | |
| 3404 | ] | |
| 3405 | ||
| 3406 | [[package]] | |
| 3407 | name = "symphonia-utils-xiph" | |
| 3408 | version = "0.5.5" | |
| 3409 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 3410 | checksum = "ee27c85ab799a338446b68eec77abf42e1a6f1bb490656e121c6e27bfbab9f16" | |
| 3411 | dependencies = [ | |
| 3412 | "symphonia-core", | |
| 3413 | "symphonia-metadata", | |
| 3414 | ] | |
| 3415 | ||
| 3006 | 3416 | [[package]] |
| 3007 | 3417 | name = "syn" |
| 3008 | 3418 | version = "2.0.119" |
| ... | ... | @@ -3534,7 +3944,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3534 | 3944 | checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" |
| 3535 | 3945 | dependencies = [ |
| 3536 | 3946 | "memchr", |
| 3537 | "nom", | |
| 3947 | "nom 8.0.0", | |
| 3538 | 3948 | "petgraph", |
| 3539 | 3949 | ] |
| 3540 | 3950 | |
| ... | ... | @@ -4028,7 +4438,7 @@ dependencies = [ |
| 4028 | 4438 | "log", |
| 4029 | 4439 | "naga", |
| 4030 | 4440 | "naga-types", |
| 4031 | "ndk-sys", | |
| 4441 | "ndk-sys 0.6.0+11769913", | |
| 4032 | 4442 | "objc2 0.6.5", |
| 4033 | 4443 | "objc2-core-foundation", |
| 4034 | 4444 | "objc2-core-graphics", |
| ... | ... | @@ -4053,9 +4463,9 @@ dependencies = [ |
| 4053 | 4463 | "web-sys", |
| 4054 | 4464 | "wgpu-naga-bridge", |
| 4055 | 4465 | "wgpu-types", |
| 4056 | "windows", | |
| 4057 | "windows-core", | |
| 4058 | "windows-result", | |
| 4466 | "windows 0.62.2", | |
| 4467 | "windows-core 0.62.2", | |
| 4468 | "windows-result 0.4.1", | |
| 4059 | 4469 | ] |
| 4060 | 4470 | |
| 4061 | 4471 | [[package]] |
| ... | ... | @@ -4105,6 +4515,16 @@ dependencies = [ |
| 4105 | 4515 | "windows-sys 0.61.2", |
| 4106 | 4516 | ] |
| 4107 | 4517 | |
| 4518 | [[package]] | |
| 4519 | name = "windows" | |
| 4520 | version = "0.54.0" | |
| 4521 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4522 | checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" | |
| 4523 | dependencies = [ | |
| 4524 | "windows-core 0.54.0", | |
| 4525 | "windows-targets 0.52.6", | |
| 4526 | ] | |
| 4527 | ||
| 4108 | 4528 | [[package]] |
| 4109 | 4529 | name = "windows" |
| 4110 | 4530 | version = "0.62.2" |
| ... | ... | @@ -4112,7 +4532,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4112 | 4532 | checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" |
| 4113 | 4533 | dependencies = [ |
| 4114 | 4534 | "windows-collections", |
| 4115 | "windows-core", | |
| 4535 | "windows-core 0.62.2", | |
| 4116 | 4536 | "windows-future", |
| 4117 | 4537 | "windows-numerics", |
| 4118 | 4538 | ] |
| ... | ... | @@ -4123,7 +4543,17 @@ version = "0.3.2" |
| 4123 | 4543 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4124 | 4544 | checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" |
| 4125 | 4545 | dependencies = [ |
| 4126 | "windows-core", | |
| 4546 | "windows-core 0.62.2", | |
| 4547 | ] | |
| 4548 | ||
| 4549 | [[package]] | |
| 4550 | name = "windows-core" | |
| 4551 | version = "0.54.0" | |
| 4552 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4553 | checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" | |
| 4554 | dependencies = [ | |
| 4555 | "windows-result 0.1.2", | |
| 4556 | "windows-targets 0.52.6", | |
| 4127 | 4557 | ] |
| 4128 | 4558 | |
| 4129 | 4559 | [[package]] |
| ... | ... | @@ -4135,7 +4565,7 @@ dependencies = [ |
| 4135 | 4565 | "windows-implement", |
| 4136 | 4566 | "windows-interface", |
| 4137 | 4567 | "windows-link", |
| 4138 | "windows-result", | |
| 4568 | "windows-result 0.4.1", | |
| 4139 | 4569 | "windows-strings", |
| 4140 | 4570 | ] |
| 4141 | 4571 | |
| ... | ... | @@ -4145,7 +4575,7 @@ version = "0.3.2" |
| 4145 | 4575 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4146 | 4576 | checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" |
| 4147 | 4577 | dependencies = [ |
| 4148 | "windows-core", | |
| 4578 | "windows-core 0.62.2", | |
| 4149 | 4579 | "windows-link", |
| 4150 | 4580 | "windows-threading", |
| 4151 | 4581 | ] |
| ... | ... | @@ -4184,10 +4614,19 @@ version = "0.3.1" |
| 4184 | 4614 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4185 | 4615 | checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" |
| 4186 | 4616 | dependencies = [ |
| 4187 | "windows-core", | |
| 4617 | "windows-core 0.62.2", | |
| 4188 | 4618 | "windows-link", |
| 4189 | 4619 | ] |
| 4190 | 4620 | |
| 4621 | [[package]] | |
| 4622 | name = "windows-result" | |
| 4623 | version = "0.1.2" | |
| 4624 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4625 | checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" | |
| 4626 | dependencies = [ | |
| 4627 | "windows-targets 0.52.6", | |
| 4628 | ] | |
| 4629 | ||
| 4191 | 4630 | [[package]] |
| 4192 | 4631 | name = "windows-result" |
| 4193 | 4632 | version = "0.4.1" |
| ... | ... | @@ -4206,13 +4645,22 @@ dependencies = [ |
| 4206 | 4645 | "windows-link", |
| 4207 | 4646 | ] |
| 4208 | 4647 | |
| 4648 | [[package]] | |
| 4649 | name = "windows-sys" | |
| 4650 | version = "0.45.0" | |
| 4651 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4652 | checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" | |
| 4653 | dependencies = [ | |
| 4654 | "windows-targets 0.42.2", | |
| 4655 | ] | |
| 4656 | ||
| 4209 | 4657 | [[package]] |
| 4210 | 4658 | name = "windows-sys" |
| 4211 | 4659 | version = "0.52.0" |
| 4212 | 4660 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4213 | 4661 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" |
| 4214 | 4662 | dependencies = [ |
| 4215 | "windows-targets", | |
| 4663 | "windows-targets 0.52.6", | |
| 4216 | 4664 | ] |
| 4217 | 4665 | |
| 4218 | 4666 | [[package]] |
| ... | ... | @@ -4221,7 +4669,7 @@ version = "0.59.0" |
| 4221 | 4669 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4222 | 4670 | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" |
| 4223 | 4671 | dependencies = [ |
| 4224 | "windows-targets", | |
| 4672 | "windows-targets 0.52.6", | |
| 4225 | 4673 | ] |
| 4226 | 4674 | |
| 4227 | 4675 | [[package]] |
| ... | ... | @@ -4233,20 +4681,35 @@ dependencies = [ |
| 4233 | 4681 | "windows-link", |
| 4234 | 4682 | ] |
| 4235 | 4683 | |
| 4684 | [[package]] | |
| 4685 | name = "windows-targets" | |
| 4686 | version = "0.42.2" | |
| 4687 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4688 | checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" | |
| 4689 | dependencies = [ | |
| 4690 | "windows_aarch64_gnullvm 0.42.2", | |
| 4691 | "windows_aarch64_msvc 0.42.2", | |
| 4692 | "windows_i686_gnu 0.42.2", | |
| 4693 | "windows_i686_msvc 0.42.2", | |
| 4694 | "windows_x86_64_gnu 0.42.2", | |
| 4695 | "windows_x86_64_gnullvm 0.42.2", | |
| 4696 | "windows_x86_64_msvc 0.42.2", | |
| 4697 | ] | |
| 4698 | ||
| 4236 | 4699 | [[package]] |
| 4237 | 4700 | name = "windows-targets" |
| 4238 | 4701 | version = "0.52.6" |
| 4239 | 4702 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4240 | 4703 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" |
| 4241 | 4704 | dependencies = [ |
| 4242 | "windows_aarch64_gnullvm", | |
| 4243 | "windows_aarch64_msvc", | |
| 4244 | "windows_i686_gnu", | |
| 4705 | "windows_aarch64_gnullvm 0.52.6", | |
| 4706 | "windows_aarch64_msvc 0.52.6", | |
| 4707 | "windows_i686_gnu 0.52.6", | |
| 4245 | 4708 | "windows_i686_gnullvm", |
| 4246 | "windows_i686_msvc", | |
| 4247 | "windows_x86_64_gnu", | |
| 4248 | "windows_x86_64_gnullvm", | |
| 4249 | "windows_x86_64_msvc", | |
| 4709 | "windows_i686_msvc 0.52.6", | |
| 4710 | "windows_x86_64_gnu 0.52.6", | |
| 4711 | "windows_x86_64_gnullvm 0.52.6", | |
| 4712 | "windows_x86_64_msvc 0.52.6", | |
| 4250 | 4713 | ] |
| 4251 | 4714 | |
| 4252 | 4715 | [[package]] |
| ... | ... | @@ -4258,18 +4721,36 @@ dependencies = [ |
| 4258 | 4721 | "windows-link", |
| 4259 | 4722 | ] |
| 4260 | 4723 | |
| 4724 | [[package]] | |
| 4725 | name = "windows_aarch64_gnullvm" | |
| 4726 | version = "0.42.2" | |
| 4727 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4728 | checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" | |
| 4729 | ||
| 4261 | 4730 | [[package]] |
| 4262 | 4731 | name = "windows_aarch64_gnullvm" |
| 4263 | 4732 | version = "0.52.6" |
| 4264 | 4733 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4265 | 4734 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" |
| 4266 | 4735 | |
| 4736 | [[package]] | |
| 4737 | name = "windows_aarch64_msvc" | |
| 4738 | version = "0.42.2" | |
| 4739 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4740 | checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" | |
| 4741 | ||
| 4267 | 4742 | [[package]] |
| 4268 | 4743 | name = "windows_aarch64_msvc" |
| 4269 | 4744 | version = "0.52.6" |
| 4270 | 4745 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4271 | 4746 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" |
| 4272 | 4747 | |
| 4748 | [[package]] | |
| 4749 | name = "windows_i686_gnu" | |
| 4750 | version = "0.42.2" | |
| 4751 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4752 | checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" | |
| 4753 | ||
| 4273 | 4754 | [[package]] |
| 4274 | 4755 | name = "windows_i686_gnu" |
| 4275 | 4756 | version = "0.52.6" |
| ... | ... | @@ -4282,24 +4763,48 @@ version = "0.52.6" |
| 4282 | 4763 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4283 | 4764 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" |
| 4284 | 4765 | |
| 4766 | [[package]] | |
| 4767 | name = "windows_i686_msvc" | |
| 4768 | version = "0.42.2" | |
| 4769 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4770 | checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" | |
| 4771 | ||
| 4285 | 4772 | [[package]] |
| 4286 | 4773 | name = "windows_i686_msvc" |
| 4287 | 4774 | version = "0.52.6" |
| 4288 | 4775 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4289 | 4776 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" |
| 4290 | 4777 | |
| 4778 | [[package]] | |
| 4779 | name = "windows_x86_64_gnu" | |
| 4780 | version = "0.42.2" | |
| 4781 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4782 | checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" | |
| 4783 | ||
| 4291 | 4784 | [[package]] |
| 4292 | 4785 | name = "windows_x86_64_gnu" |
| 4293 | 4786 | version = "0.52.6" |
| 4294 | 4787 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4295 | 4788 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" |
| 4296 | 4789 | |
| 4790 | [[package]] | |
| 4791 | name = "windows_x86_64_gnullvm" | |
| 4792 | version = "0.42.2" | |
| 4793 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4794 | checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" | |
| 4795 | ||
| 4297 | 4796 | [[package]] |
| 4298 | 4797 | name = "windows_x86_64_gnullvm" |
| 4299 | 4798 | version = "0.52.6" |
| 4300 | 4799 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4301 | 4800 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" |
| 4302 | 4801 | |
| 4802 | [[package]] | |
| 4803 | name = "windows_x86_64_msvc" | |
| 4804 | version = "0.42.2" | |
| 4805 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4806 | checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" | |
| 4807 | ||
| 4303 | 4808 | [[package]] |
| 4304 | 4809 | name = "windows_x86_64_msvc" |
| 4305 | 4810 | version = "0.52.6" |
| ... | ... | @@ -4328,7 +4833,7 @@ dependencies = [ |
| 4328 | 4833 | "js-sys", |
| 4329 | 4834 | "libc", |
| 4330 | 4835 | "memmap2", |
| 4331 | "ndk", | |
| 4836 | "ndk 0.9.0", | |
| 4332 | 4837 | "objc2 0.5.3", |
| 4333 | 4838 | "objc2-app-kit 0.2.2", |
| 4334 | 4839 | "objc2-foundation 0.2.2", |
KNOWN_GAPS.md deleted-42| ... | ... | @@ -1,42 +0,0 @@ |
| 1 | # Known Gaps & Roadmap | |
| 2 | ||
| 3 | Tracked rendering and architecture gaps compared to Blackmagic Fusion Studio 21.1. | |
| 4 | Items listed here are **tracked bugs / missing subsystems**, never permanent exclusions. | |
| 5 | ||
| 6 | --- | |
| 7 | ||
| 8 | ## 1. Cryptomatte (`Fuse.Cryptomatte` — e.g. `01_intro.comp` human character matte) | |
| 9 | - **Status:** Tracked known gap (not an intentional exclusion). | |
| 10 | - **Symptom:** In `01_intro.comp` (e.g. `f0600`), the human character's orange rim/matte driven by a Cryptomatte pass over multi-channel EXR (`CryptoObject00..02` MurmurHash3 ID/coverage pairs + manifest metadata) is not yet decoded, so the character's Cryptomatte glow/isolation differs from Fusion. | |
| 11 | - **Planned fix:** Add multi-channel EXR Cryptomatte layer decoding (`exr` crate already in workspace), parse `cryptomatte/<hash>/manifest` JSON from EXR header attributes, hash selected `MatteList` names via MurmurHash3-32 (`f32` bit-cast), and accumulate matching ID/coverage rank pairs into the alpha matte. | |
| 12 | ||
| 13 | ## 2. 3D Particle System (`pEmitter`, `pRender`, `pPointForce`) | |
| 14 | - **Status:** Tracked missing subsystem (currently reported in `unsupported` on `01_intro.comp`). | |
| 15 | - **Symptom:** Particle layers driven by `pEmitter` / `pPointForce` / `pRender` are skipped. | |
| 16 | - **Planned fix:** Deterministic frame-stepped particle simulator (seeded per-frame/cached state) feeding into `Scene3D` billboard/point-sprite instancing inside `Renderer3D` / `pRender`. | |
| 17 | ||
| 18 | ## 3. Optical Flow & Retime Vectors (`Dimension.OpticalFlow`, `OpticalFlow`) | |
| 19 | - **Status:** Tracked missing subsystem (reported in `unsupported` on `01_intro.comp`). | |
| 20 | - **Symptom:** Motion-vector-interpolated retiming falls back to nearest/frame-blended source frames. | |
| 21 | - **Planned fix:** GPU dense optical-flow pass (hierarchical Lucas-Kanade / TV-L1 compute shader) writing forward/backward motion vectors for downstream `TimeStretcher` / `VectorMotionBlur`. | |
| 22 | ||
| 23 | ## 4. Project-Defined Bit Depth (`DepthFull` / `DepthInteractive` / `ChangeDepth`) | |
| 24 | - **Status:** Implemented (verified `0.00/255` across `int8`/`int16`/`float16`/`float32` + `0.4%` HDR float16 blur on `scripts/fusion_probes.py tier1_d`). | |
| 25 | - **Behavior:** | |
| 26 | - **`HiQ` mode:** Honors `Comp.Prefs.Comp.FrameFormat.DepthFull`, generator `Depth`, and `ChangeDepth` (`int8` -> `Rgba8Unorm`, `int16` -> clamped `Rgba16Float`, `float16` -> unclamped HDR `Rgba16Float`, `float32` -> unclamped HDR `Rgba32Float` when `FLOAT32_FILTERABLE` is supported, else `Rgba16Float`). Non-8-bit shader pipelines compile lazily on first use. | |
| 27 | - **`Fast` mode:** Collapses working render targets to `Rgba8Unorm` (with downsampled blurs / capped `XGlow` octaves) for maximum interactive throughput. | |
| 28 | - **Remaining minor gap:** `Loader` uploads 8-bit decoded frames and promotes them to float when requested; direct 16/32-bit float EXR upload without intermediate 8-bit quantization is a follow-up media-layer upgrade. | |
| 29 | ||
| 30 | ## 5. Video Decode Backend (`AVFoundation` / `VideoToolbox` + `ffmpeg` fallback) | |
| 31 | - **Status:** Planned media layer upgrade. | |
| 32 | - **Current behavior:** Video clips decode via `ffmpeg` subprocesses with LRU frame caching. | |
| 33 | - **Target design:** Introduce a `VideoDecoder` trait with a native macOS `AVAssetReader` + `VideoToolbox` hardware backend for zero-copy ProRes / H.264 / HEVC scrubbing, keeping the existing `ffmpeg` CLI backend as a clean cross-platform fallback for Linux/Windows and uncommon codecs. | |
| 34 | ||
| 35 | ## 6. Procedural `FastNoise` Internal Permutation Seed | |
| 36 | - **Status:** Known inherent difference vs closed-source Fusion noise table (upgraded to C2 quintic 3D Perlin gradient noise with Fusion isotropic frame-width scaling, `LockXY`, `Angle`, `Detail = 0..10`, and `Discontinuous = 1`). | |
| 37 | - **Behavior:** Scale, `Detail`, `Contrast`, `Brightness`, `Seethe`, `SeetheRate`, `XScale`/`YScale`, `Discontinuous`, and `Gradient` / `TwoColor` coloring match Fusion's visual distribution and round C2 blob shape; individual hash peaks (e.g. random star positions on the 3D cylinder in `60_moon_guide_u.comp`) sit at different pseudo-random coordinates because Fusion's internal `FastNoise` lattice/permutation table is proprietary (verified not public Perlin 2002, Perlin 1985, or Simplex 3D). 3D camera projection itself (`Camera3D`, `Transform3D`, `Shape3D` Cylinder, all `RotOrder` permutations, `AoV`/`FLength`/`ResolutionGateFit`) is verified to `0.1%–0.4% MAE` against Fusion 21.1 via `scripts/fusion_probes.py cam3d_fov`. | |
| 38 | ||
| 39 | ## 7. Minor Tool Edge Cases Remaining | |
| 40 | - `TextPlus` `ElementShape` `BorderFill` (`ElementShape2 = 2`) and custom font rendering on Linux render node (note: on Snow Globe, mounting `\(site.cloverRoot)/Asset/Font` read-only to `/usr/local/share/fonts/clover` in `~/dev/home-infra/service/fusion/service.pkl` exposes Clover's font library to `FusionRenderNode` without committing font files). | |
| 41 | - `Displace` `Type = 0` (`Radial`) `LightPower` specular/bump lighting exact angle & color model (`0.7% MAE` vs `0.1%` without `LightPower`). | |
| 42 | - `Glow` tool (`Glow = 0.583, GlowSize = 12`) slight Gaussian tail roll-off (`1.3% MAE`; `SoftGlow` is `0.0%–0.8%`). |
compatibility.md created+174| ... | ... | @@ -0,0 +1,174 @@ |
| 1 | # Fusion 21.1 Compatibility Matrix | |
| 2 | ||
| 3 | Auto-generated from live engine sources (`crates/engine/src/eval.rs`, `crates/engine/src/scene3d.rs`, `crates/model/src/comp.rs`) and real Fusion `.comp` corpora via `python3 scripts/gen_compatibility.py`. | |
| 4 | ||
| 5 | - **Tracked Gaps & Issues:** [shale.paperclover.net/fission/issues](https://shale.paperclover.net/fission/issues) | |
| 6 | - **Conformance Probes:** [`scripts/fusion_probes.py`](scripts/fusion_probes.py) | |
| 7 | ||
| 8 | ## Summary | |
| 9 | ||
| 10 | | Metric | Value | | |
| 11 | | --- | --- | | |
| 12 | | **Supported Flow Tools** | **66** (57 2D/Fuse/utility in `eval.rs`, 7 3D scene nodes in `scene3d.rs`, 2 Flow annotations) | | |
| 13 | | **Modifiers & Animation** | **7** systems (8 Fusion modifier classes + Lua expressions) | | |
| 14 | | **Active Corpus (`trees/fusion`) Coverage** | **99.1%** (1,975 / 1,993 nodes across 16 `.comp` files) | | |
| 15 | | **Archive Corpus (`private/samples`) Coverage** | **95.8%** (52,653 / 54,955 nodes across 324 `.comp` files) | | |
| 16 | | **HiQ vs Fast Mode** | **`HiQ`**: honors `DepthFull` / generator `Depth` / `ChangeDepth` (`Rgba8Unorm`, clamped `Rgba16Float`, unclamped HDR `Rgba16Float`/`Rgba32Float`), full-res blurs & `XGlow`. **`Fast`**: collapses working targets to `Rgba8Unorm`, downsamples blurs, caps `XGlow` octaves for interactive scrubbing. | | |
| 17 | ||
| 18 | ## Generators | |
| 19 | ||
| 20 | | Tool | Probe Suite | Verified MAE | Usage (Active / Archive) | Notes & Fallbacks | | |
| 21 | | --- | --- | --- | --- | --- | | |
| 22 | | `Background` | `tier1_d` | 0.0% | 103 / 1949 | Solid, Horizontal/Vertical/4-Corner, Linear/Radial gradients; honors generator `Depth` in `HiQ`. | | |
| 23 | | `FastNoise` | `noise_text` | Visual* | 18 / 201 | C2 quintic 3D Perlin fBm (`Detail`, `Contrast`, `Brightness`, `Seethe`, `LockXY`, `Angle`, `Discontinuous`, `Gradient`/`TwoColor`). *Proprietary Fusion lattice table differs ([#6](https://shale.paperclover.net/fission/issues/6)). | | |
| 24 | | `Plasma` | `tier1_c` | 0.1%–0.2% | 0 / 39 | 4-circle linear/sine interference pattern with phase/scale animation. | | |
| 25 | | `TextPlus` | `text`, `noise_text` | 0.1%–0.6% | 53 / 2770 | CoreText rasterizer, alignment, tracking, Euclidean subpixel SDF outline, `StyledTextCLS`. `BorderFill` tracked in [#6](https://shale.paperclover.net/fission/issues/6). | | |
| 26 | | `Loader` | All suites | 0.0% | 106 / 1274 | PNG/JPG/TIFF/EXR stills & sequences; native macOS `AVFoundation`/`VideoToolbox` + `ffmpeg` video; `.wav`/`.mp3` audio. Direct 16/32-bit float EXR upload tracked in [#5](https://shale.paperclover.net/fission/issues/5). | | |
| 27 | ||
| 28 | ## Compositing & Blending | |
| 29 | ||
| 30 | | Tool | Probe Suite | Verified MAE | Usage (Active / Archive) | Notes & Fallbacks | | |
| 31 | | --- | --- | --- | --- | --- | | |
| 32 | | `Merge` | `merge` | 0.0%–0.3% | 293 / 6358 | All ApplyModes (`Normal`, `Screen`, `Multiply`, `Difference`, `DarkerColor`, `Overlay`, `Hard/Soft/Linear/VividLight`, `LinearDodge`, etc.), `Operator=Over/Under`, `Gain`, `BurnIn`, `SubtractiveAdditive`, `Blend`, effect mask. | | |
| 33 | | `Dissolve` | `tier1_b` | 0.0%–0.1% | 0 / 4 | Mix (`Mix = 0..1`) between `Background` and `Foreground` with effect mask support. | | |
| 34 | | `Shadow` | `tier1_b` | 0.1%–0.4% | 0 / 38 | Drop shadow offset, softness blur, tint color/alpha, and `ShadowOnly` output. | | |
| 35 | ||
| 36 | ## Color & Depth | |
| 37 | ||
| 38 | | Tool | Probe Suite | Verified MAE | Usage (Active / Archive) | Notes & Fallbacks | | |
| 39 | | --- | --- | --- | --- | --- | | |
| 40 | | `BrightnessContrast` | `color_ops`, `tier1_d` | 0.0%–0.1% | 29 / 231 | Gain, Lift, Gamma, Contrast, Brightness, Saturation, channel toggles, `PreDividePostMultiply`, `ClipBlack`/`ClipWhite`. | | |
| 41 | | `ColorCorrector` | Suite comps | 0.1%–0.5% | 86 / 1357 | Master/Shadow/Midtone/Highlight wheel tint, Lift/Gamma/Gain/Brightness/Contrast/Saturation, `PreDividePostMultiply`. | | |
| 42 | | `ColorGain` | `color_ops`, `noise_text` | 0.0%–0.1% | 2 / 4 | Per-channel Gain, Lift, Gamma, Hue, Saturation, `PreDividePostMultiply`. | | |
| 43 | | `ColorCurves` | Suite comps | 0.1%–0.4% | 5 / 109 | Per-channel RGBA `LUTBezier` spline lookup tables with `PreDividePostMultiply`. | | |
| 44 | | `HueCurves` | `tier1_a` | 0.1%–0.5% | 6 / 28 | 9 nested `LUTBezier` splines (Hue/Sat/Lum vs Hue, Suppression, etc.) baked to GPU LUT. | | |
| 45 | | `GamutConvert` | Suite comps | 0.0%–0.2% | 2 / 32 | Color space & gamma curve transforms (`sRGB`, `Rec.709`, `Linear`, `SLog2`, etc.). | | |
| 46 | | `InvertColor` | Suite comps | 0.0% | 0 / 0 | Per-channel RGBA color inversion (`R`/`G`/`B`/`A` toggles). | | |
| 47 | | `ChannelBoolean` | `color_ops` | 0.0%–0.1% | 2 / 29 | Channel routing (`ToRed`/`ToGreen`/`ToBlue`/`ToAlpha`) and arithmetic/logic ops (`Copy`, `Add`, `Subtract`, `Multiply`, `Divide`, `Min`, `Max`, `Clear`, `Solid`, etc.). | | |
| 48 | | `ChangeDepth` | `tier1_d` | 0.0% | 0 / 24 | Bit-depth conversion (`int8`, `int16`, `float16`, `float32`) honored in `HiQ` mode; collapsed to `Rgba8Unorm` in `Fast` mode. | | |
| 49 | | `Fuse.Colorize` | Suite comps | 0.1%–0.5% | 13 / 386 | Gradient/tint colorization driven by luminance. | | |
| 50 | ||
| 51 | ## Keying | |
| 52 | ||
| 53 | | Tool | Probe Suite | Verified MAE | Usage (Active / Archive) | Notes & Fallbacks | | |
| 54 | | --- | --- | --- | --- | --- | | |
| 55 | | `LumaKeyer` | Suite comps | 0.1%–0.4% | 4 / 95 | Luminance/channel threshold keying with low/high feathering and matte inversion. | | |
| 56 | | `UltraKeyer` | `tier1_a` | 0.1%–0.6% | 16 / 66 | Chroma keying with background color pick, matte threshold/gamma, spill suppression, and post-multiply. | | |
| 57 | ||
| 58 | ## Blur, Sharpen & Glow | |
| 59 | ||
| 60 | | Tool | Probe Suite | Verified MAE | Usage (Active / Archive) | Notes & Fallbacks | | |
| 61 | | --- | --- | --- | --- | --- | | |
| 62 | | `Blur` | `blur`, `tier1_d` | 0.0%–0.4% | 52 / 401 | `Fast Gaussian`, `Gaussian`, and `Box` filters; X/Y lock; `ClippingMode`; HDR float16 survival in `HiQ`; downsampled in `Fast`. | | |
| 63 | | `Sharpen` | `tier1_a` | 0.1%–0.4% | 1 / 7 | Separable unsharp mask with X/Y amount & lock. | | |
| 64 | | `Filter` | `tier1_a` | 0.1%–0.5% | 0 / 93 | Convolution filter types 0–4 (`Relief`, `Emboss`, `Smooth`, `Sobel`, `Laplacian`) with power & angle. | | |
| 65 | | `VariBlur` | Suite comps | 0.2%–0.8% | 1 / 1 | Per-pixel variable-radius blur driven by `BlurImage` matte. | | |
| 66 | | `DirectionalBlur` | `blur` | 0.1%–0.5% | 21 / 816 | `Linear`, `Centered`, `Radial`, and `Zoom` modes plus `Glow` accumulation. | | |
| 67 | | `Glow` | `glow` | 0.2%–1.3% | 11 / 549 | Additive bloom (`Glow`, `GlowSize`, `Blend`, color scale). Minor Gaussian tail roll-off tracked in [#6](https://shale.paperclover.net/fission/issues/6). | | |
| 68 | | `SoftGlow` | `glow` | 0.0%–0.8% | 3 / 30 | Thresholded soft glow (`Gain`, `XGlowSize`/`YGlowSize`, `Threshold`, `ClippingMode`, `ColorScale`). | | |
| 69 | | `Fuse.XGlow` | Suite comps | 0.2%–0.8% | 4 / 34 | Multi-octave exponential glow (`Threshold`, `Gain`, `XGlowSize`, `Falloff`, `Iterations`); octave-capped in `Fast` mode. | | |
| 70 | | `ErodeDilate` | `blur` | 0.0%–0.3% | 18 / 202 | Positive/negative morphological erode/dilate with `Box` and `Circle` kernels. | | |
| 71 | | `FilmGrain` | `tier1_c` | Visual* | 0 / 18 | Monochrome log-space correlated film grain (`Size`, `Strength`, `Softness`). *Stochastic per-frame seed. | | |
| 72 | | `Fuse.Outline` | Suite comps | 0.1%–0.5% | 2 / 278 | Alpha-derived silhouette outline with thickness, softness, and color tint. | | |
| 73 | | `Fuse.XfChroma` | Suite comps | 0.1%–0.5% | 2 / 17 | Chromatic aberration / RGB channel radial & positional dispersion. | | |
| 74 | ||
| 75 | ## Transform, Warp & Framing | |
| 76 | ||
| 77 | | Tool | Probe Suite | Verified MAE | Usage (Active / Archive) | Notes & Fallbacks | | |
| 78 | | --- | --- | --- | --- | --- | | |
| 79 | | `Transform` | `xf` | 0.0%–0.3% | 47 / 1211 | `Center`, `Pivot`, `Size`/`XSize`/`YSize`, `Aspect`, `Angle`, `FlipHoriz`/`FlipVert`, `FilterMethod` (`Nearest`/`Box`/`Linear`/`Catmull-Rom`), `Edges` (`Canvas`/`Wrap`/`Duplicate`/`Mirror`). | | |
| 80 | | `CameraShake` | `tier1_c` | 0.1%–0.5% | 0 / 12 | Procedural X/Y/Rotation/Zoom camera shake with `OverallStrength`, `Speed`, `Edges`. | | |
| 81 | | `CornerPositioner` | `tier1_b` | 0.1%–0.4% | 0 / 29 | 4-point projective homography warp (`TopLeft`/`TopRight`/`BottomLeft`/`BottomRight`). | | |
| 82 | | `DVE` | `tier1_b` | 0.1%–0.4% | 4 / 22 | 2.5D ZYX Euler rotation + perspective homography (`Center`, `ZMove`, `Pivot`, `AlphaMode`). | | |
| 83 | | `Displace` | `displace` | 0.1%–0.7% | 11 / 109 | `XY` refraction (channels, offsets, refraction strength) and `Radial`/`Bump` (`LightPower` angle/color minor parity tracked in [#6](https://shale.paperclover.net/fission/issues/6)). | | |
| 84 | | `Scale` | Suite comps | 0.0%–0.2% | 12 / 98 | Proportional/non-proportional image scaling with resampling filter. | | |
| 85 | | `BetterResize` | Suite comps | 0.0%–0.2% | 0 / 93 | Target pixel-dimension resize (`Width`, `Height`, `KeepAspect`). | | |
| 86 | | `Crop` | Suite comps | 0.0%–0.1% | 3 / 168 | Region crop & canvas repositioning (`XOffset`, `YOffset`, `XSize`, `YSize`, `KeepCentered`). | | |
| 87 | | `SetDomain` | `tier1_d` | 0.0%–0.1% | 0 / 8 | Domain-of-Definition (`Adjust` shrink/expand and `Set` modes). | | |
| 88 | ||
| 89 | ## Masks | |
| 90 | ||
| 91 | | Tool | Probe Suite | Verified MAE | Usage (Active / Archive) | Notes & Fallbacks | | |
| 92 | | --- | --- | --- | --- | --- | | |
| 93 | | `EllipseMask` | `mask` | 0.0%–0.2% | 33 / 109 | Center, Width, Height, Angle, `SoftEdge`, `BorderWidth`, `Solid`, `Invert`, `PaintMode` chaining. | | |
| 94 | | `RectangleMask` | `mask` | 0.0%–0.2% | 53 / 885 | Center, Width, Height, `CornerRadius`, Angle, `SoftEdge`, `BorderWidth`, `Solid`, `Invert`, `PaintMode` chaining. | | |
| 95 | | `PolylineMask` | Suite comps | 0.1%–0.5% | 16 / 505 | CPU `zeno` Bezier/linear polygon rasterizer with animated keyframed `Polyline` splines, `SoftEdge`, `Invert`, `PaintMode`. | | |
| 96 | | `BitmapMask` | Suite comps | 0.0%–0.2% | 3 / 121 | Image-to-mask extraction (`Alpha`/`Luminance`/`Red`/`Green`/`Blue`), `Low`/`High` clip, `SoftEdge`, `Invert`. | | |
| 97 | ||
| 98 | ## 3D Pipeline | |
| 99 | ||
| 100 | | Tool | Probe Suite | Verified MAE | Usage (Active / Archive) | Notes & Fallbacks | | |
| 101 | | --- | --- | --- | --- | --- | | |
| 102 | | `Renderer3D` | `cam3d`, `cam3d_fov` | 0.1%–0.4% | 7 / 265 | GPU wgpu 3D rasterizer with depth buffer, perspective camera selection, lighting, and 2D texture sampling. | | |
| 103 | | `Camera3D` | `cam3d`, `cam3d_fov` | 0.1%–0.4% | 5 / 166 | All 6 `RotOrder` permutations (`XYZ`..`ZYX`), `AoV`/`FLength`, `ApertureW`/`ApertureH`, `ResolutionGateFit` (`Inside`/`Outside`/`Width`/`Height`/`Stretch`). | | |
| 104 | | `Merge3D` | `cam3d`, `cam3d_fov` | 0.1%–0.4% | 10 / 597 | Hierarchical 3D scene graph combiner with local `Transform3DOp`. | | |
| 105 | | `Transform3D` | `cam3d`, `cam3d_fov` | 0.1%–0.4% | 1 / 799 | 3D translate, rotate (all 6 `RotOrder`s), and scale (`ScaleLock`) transform node. | | |
| 106 | | `ImagePlane3D` | `cam3d` | 0.1%–0.4% | 4 / 496 | Textured 3D quad driven by 2D image input or `Mtl*` diffuse texture. | | |
| 107 | | `Shape3D` | `cam3d`, `cam3d_fov` | 0.1%–0.4% | 4 / 374 | `Plane`, `Sphere`, `Cylinder` (`StartSweep`/`EndSweep`, subdivisions), and `Cube` procedural geometry. | | |
| 108 | | `LightAmbient` | Suite comps | 0.1%–0.4% | 3 / 42 | Scene ambient RGB light intensity accumulation in `Renderer3D`. | | |
| 109 | | `LightDirectional` | Suite comps | 0.1%–0.4% | 3 / 82 | World-oriented directional light (`-Z` emission axis) with RGB intensity in `Renderer3D`. | | |
| 110 | ||
| 111 | ## Time, Routing & Utility | |
| 112 | ||
| 113 | | Tool | Probe Suite | Verified MAE | Usage (Active / Archive) | Notes & Fallbacks | | |
| 114 | | --- | --- | --- | --- | --- | | |
| 115 | | `Saver` | All suites | 0.0% | 15 / 278 | Output sink / passthrough in interactive Flow; target selector for `render-check` CLI. | | |
| 116 | | `TimeStretcher` | Suite comps | 0.0% | 13 / 82 | Keyframed/expression `SourceTime` remapping upstream of evaluation (nearest/frame evaluation; Optical Flow tracked in [#4](https://shale.paperclover.net/fission/issues/4)). | | |
| 117 | | `TimeSpeed` | Suite comps | 0.0% | 0 / 166 | Constant/animated `Speed` and `Delay` time remapping. | | |
| 118 | | `Switch` | Suite comps | 0.0% | 2 / 23 | Dynamic input routing by `Which` index (`Input1`..`InputN`). | | |
| 119 | | `Fuse.Switch` | Suite comps | 0.0% | 1 / 184 | Fuse variant of `Switch` routing `Input1`..`InputN` by `Which`. | | |
| 120 | | `PipeRouter` | Suite comps | 0.0% | 24 / 373 | Zero-cost graph routing node. | | |
| 121 | | `Fuse.Wireless` | Suite comps | 0.0% | 0 / 44 | Wireless link passthrough node. | | |
| 122 | | `Tracker` | Suite comps | 0.0% | 1 / 5 | Passthrough image node; baked tracking paths evaluated via `TrackerModifier`. | | |
| 123 | | `MacroOperator` | Suite comps | 0.0% | 30 / 1246 | Unpacks internal `Tools` subgraph and evaluates exported output seamlessly. | | |
| 124 | | `GroupOperator` | Suite comps | 0.0% | 6 / 178 | Unpacks internal `Tools` subgraph and evaluates exported output seamlessly. | | |
| 125 | | `Custom` | Suite comps | 0.1%–0.6% | 4 / 99 | Custom Tool shader evaluation (procedural wave/channel expressions + `UserControls` defaults). | | |
| 126 | | `Note` | — | N/A | 0 / 57 | Non-rendering Flow sticky note; preserved losslessly on `.comp` roundtrip. | | |
| 127 | | `Underlay` | — | N/A | 0 / 104 | Non-rendering Flow backdrop/group box; preserved losslessly on `.comp` roundtrip. | | |
| 128 | ||
| 129 | ## Modifiers & Animation | |
| 130 | ||
| 131 | | Modifier / System | Probe Suite | Usage (Active / Archive) | Notes | | |
| 132 | | --- | --- | --- | --- | | |
| 133 | | `BezierSpline` | All suites | 664 / 22624 | Cubic Bezier / linear / `StepIn` / `StepOut` keyframes, animated `StyledText`, and animated `Polyline` point splines. | | |
| 134 | | `LUTBezier` | `tier1_a` | 18 / 945 | Curve lookup splines used standalone and nested inside `ColorCurves` / `HueCurves`. | | |
| 135 | | `PolyPath` / `Path` | Suite comps | 119 / 2389 | 2D motion-path polyline evaluation with animated `Displacement` spline. | | |
| 136 | | `Shake` | `tier1_c` | 0 / 165 | Procedural multi-octave noise modifier (`Source = X / Y / Value / Position`) with spline & expression inputs. | | |
| 137 | | `StyledTextCLS` | Suite comps | 3 / 60 | Per-character `TextPlus` styling overrides (font, size, color, kerning, opacity). | | |
| 138 | | `TrackerModifier` | Suite comps | 3 / 0 | Resolves baked tracker path aliases (`Track1TrackerPath`, etc.) into 2D `PolyPath` coordinates. | | |
| 139 | | Lua Expressions | Suite comps | — | Inline `Expression = "..."` evaluation (`time`, `comp.RenderStart`/`End`, node input references, math/trig/clamp/ternary). | | |
| 140 | ||
| 141 | ## Preserved & Passthrough (Roundtrip-Safe) | |
| 142 | ||
| 143 | Unlike Blackmagic Fusion — which unlinks missing OFX or Resolve-only plugins when opening a `.comp` — **Fission preserves all unknown and unsupported tools losslessly** (every parameter, custom input, binary blob, position, and upstream/downstream wire is retained verbatim on save) and **passes through their main input** during Flow evaluation so downstream compositing stays connected. | |
| 144 | ||
| 145 | | Tool Class | Usage (Active / Archive) | Issue | Behavior & Notes | | |
| 146 | | --- | --- | --- | --- | | |
| 147 | | `SurfaceTracker` | 2 / 1 | [#7](https://shale.paperclover.net/fission/issues/7) | Preserved lossless on save; passes through main image input in Flow. | | |
| 148 | | `MagicMask` | 3 / 1 | [#7](https://shale.paperclover.net/fission/issues/7) | Preserved lossless on save; passes through main image input in Flow. | | |
| 149 | | `PlanarTracker` | 0 / 0 | [#7](https://shale.paperclover.net/fission/issues/7) | Preserved lossless on save; passes through main image input in Flow. | | |
| 150 | | `Fuse.Cryptomatte` | 0 / 37 | [#2](https://shale.paperclover.net/fission/issues/2) | Preserved lossless on save; passes through main image input (multi-channel EXR matte extraction tracked). | | |
| 151 | | `Dimension.OpticalFlow` | 2 / 10 | [#4](https://shale.paperclover.net/fission/issues/4) | Preserved lossless on save; passes through main image input (GPU dense optical flow tracked). | | |
| 152 | | `Dimension.CopyAux` | 4 / 0 | [#4](https://shale.paperclover.net/fission/issues/4) | Preserved lossless on save; passes through main image input. | | |
| 153 | | `pEmitter` | 1 / 54 | [#3](https://shale.paperclover.net/fission/issues/3) | Preserved lossless on save; skipped in 3D scene until particle simulator lands. | | |
| 154 | | `pRender` | 1 / 54 | [#3](https://shale.paperclover.net/fission/issues/3) | Preserved lossless on save; skipped / passthrough until particle simulator lands. | | |
| 155 | | `pPointForce` | 1 / 3 | [#3](https://shale.paperclover.net/fission/issues/3) | Preserved lossless on save; skipped in 3D scene until particle simulator lands. | | |
| 156 | | `SurfaceFBXMesh` | 0 / 216 | — | Preserved lossless on save; FBX mesh geometry not yet imported in `Renderer3D`. | | |
| 157 | | `Text3D` | 0 / 410 | — | Preserved lossless on save; extruded 3D text mesh not yet implemented in `Renderer3D`. | | |
| 158 | | `MtlBlinn` | 0 / 181 | — | Preserved lossless on save; basic diffuse color & texture resolved in `Renderer3D` (full Blinn specular/bump pending). | | |
| 159 | | `MtlCookTorrance` | 3 / 8 | — | Preserved lossless on save; basic diffuse color & texture resolved in `Renderer3D` (full Cook-Torrance BRDF pending). | | |
| 160 | | `WandMask` | 0 / 150 | — | Preserved lossless on save; flood-fill wand mask not yet implemented. | | |
| 161 | | `ReplaceMaterial3D` | 0 / 131 | — | Preserved lossless on save; 3D material override not yet traversed in `Renderer3D`. | | |
| 162 | | `Override3D` | 0 / 124 | — | Preserved lossless on save; 3D render-flag override not yet traversed in `Renderer3D`. | | |
| 163 | | `Displace3D` | 0 / 95 | — | Preserved lossless on save; vertex displacement not yet implemented in `Renderer3D`. | | |
| 164 | | `Duplicate3D` | 0 / 74 | — | Preserved lossless on save; passes through main input in Flow. | | |
| 165 | | `LightPoint` | 0 / 63 | — | Preserved lossless on save; passes through main input in Flow. | | |
| 166 | | `LightSpot` | 0 / 52 | — | Preserved lossless on save; passes through main input in Flow. | | |
| 167 | | `Fuse.Duplicate` | 0 / 46 | — | Preserved lossless on save; passes through main input in Flow. | | |
| 168 | | `Texture2DOperator` | 0 / 44 | — | Preserved lossless on save; passes through main input in Flow. | | |
| 169 | | `Multistroke` | 0 / 33 | — | Preserved lossless on save; passes through main input in Flow. | | |
| 170 | | `Drip` | 0 / 29 | — | Preserved lossless on save; passes through main input in Flow. | | |
| 171 | ||
| 172 | --- | |
| 173 | ||
| 174 | For tracked gaps, known parity edge cases, and roadmap items, see [shale.paperclover.net/fission/issues](https://shale.paperclover.net/fission/issues). |
crates/engine/Cargo.toml+5| ... | ... | @@ -10,12 +10,17 @@ path = "src/bin/render_check.rs" |
| 10 | 10 | |
| 11 | 11 | [dependencies] |
| 12 | 12 | bytemuck.workspace = true |
| 13 | cpal = "0.15" | |
| 13 | 14 | exr = "1.74" |
| 14 | 15 | image.workspace = true |
| 15 | 16 | model.workspace = true |
| 16 | 17 | png.workspace = true |
| 17 | 18 | pollster.workspace = true |
| 19 | symphonia = { version = "0.5", default-features = false, features = ["wav", "mp3", "flac", "ogg", "aac", "isomp4", "pcm"] } | |
| 18 | 20 | text.workspace = true |
| 19 | 21 | theme.workspace = true |
| 20 | 22 | wgpu.workspace = true |
| 21 | 23 | zeno.workspace = true |
| 24 | ||
| 25 | [target.'cfg(target_os = "macos")'.build-dependencies] | |
| 26 | cc = "1" |
crates/engine/build.rs created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | fn main() { | |
| 2 | println!("cargo:rerun-if-changed=src/av_decode.m"); | |
| 3 | ||
| 4 | if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos") { | |
| 5 | cc::Build::new() | |
| 6 | .file("src/av_decode.m") | |
| 7 | .flag("-fobjc-arc") | |
| 8 | .compile("av_decode"); | |
| 9 | ||
| 10 | for fw in [ | |
| 11 | "AVFoundation", | |
| 12 | "CoreMedia", | |
| 13 | "CoreVideo", | |
| 14 | "Foundation", | |
| 15 | "CoreFoundation", | |
| 16 | ] { | |
| 17 | println!("cargo:rustc-link-lib=framework={fw}"); | |
| 18 | } | |
| 19 | } | |
| 20 | } |
crates/engine/src/audio.rs created+523| ... | ... | @@ -0,0 +1,523 @@ |
| 1 | //! Audio file decoding (`.wav`, `.mp3`, `.flac`, `.ogg`, `.aac`/`.m4a` via `symphonia`) | |
| 2 | //! and real-time non-blocking playback via `cpal` (CoreAudio on macOS). | |
| 3 | ||
| 4 | use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; | |
| 5 | use cpal::{FromSample, Sample, SampleFormat, Stream}; | |
| 6 | use std::fs::File; | |
| 7 | use std::io::ErrorKind; | |
| 8 | use std::path::{Path, PathBuf}; | |
| 9 | use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering}; | |
| 10 | use std::sync::{Arc, Mutex}; | |
| 11 | use symphonia::core::audio::SampleBuffer; | |
| 12 | use symphonia::core::codecs::{CODEC_TYPE_NULL, DecoderOptions}; | |
| 13 | use symphonia::core::errors::Error as SymphoniaError; | |
| 14 | use symphonia::core::formats::FormatOptions; | |
| 15 | use symphonia::core::io::MediaSourceStream; | |
| 16 | use symphonia::core::meta::MetadataOptions; | |
| 17 | use symphonia::core::probe::Hint; | |
| 18 | ||
| 19 | /// Decoded audio track normalized to interleaved stereo `f32` (`[L0, R0, L1, R1, ...]`). | |
| 20 | #[derive(Clone, Debug)] | |
| 21 | pub struct AudioTrack { | |
| 22 | pub path: PathBuf, | |
| 23 | pub sample_rate: u32, | |
| 24 | pub channels: u16, | |
| 25 | pub samples: Arc<Vec<f32>>, | |
| 26 | pub duration_secs: f64, | |
| 27 | } | |
| 28 | ||
| 29 | impl AudioTrack { | |
| 30 | /// Decodes an audio file (`.wav`, `.mp3`, `.flac`, `.ogg`, `.m4a`, `.aac`) into | |
| 31 | /// interleaved stereo `f32` samples. | |
| 32 | pub fn load(path: impl AsRef<Path>) -> Result<Self, String> { | |
| 33 | let path_ref = path.as_ref(); | |
| 34 | let file = File::open(path_ref) | |
| 35 | .map_err(|e| format!("failed to open audio '{}': {e}", path_ref.display()))?; | |
| 36 | let mss = MediaSourceStream::new(Box::new(file), Default::default()); | |
| 37 | ||
| 38 | let mut hint = Hint::new(); | |
| 39 | if let Some(ext) = path_ref.extension().and_then(|e| e.to_str()) { | |
| 40 | hint.with_extension(ext); | |
| 41 | } | |
| 42 | ||
| 43 | let probed = symphonia::default::get_probe() | |
| 44 | .format( | |
| 45 | &hint, | |
| 46 | mss, | |
| 47 | &FormatOptions::default(), | |
| 48 | &MetadataOptions::default(), | |
| 49 | ) | |
| 50 | .map_err(|e| format!("unsupported audio format '{}': {e}", path_ref.display()))?; | |
| 51 | ||
| 52 | let mut format = probed.format; | |
| 53 | let track = format | |
| 54 | .default_track() | |
| 55 | .filter(|t| t.codec_params.codec != CODEC_TYPE_NULL) | |
| 56 | .or_else(|| { | |
| 57 | format | |
| 58 | .tracks() | |
| 59 | .iter() | |
| 60 | .find(|t| t.codec_params.codec != CODEC_TYPE_NULL) | |
| 61 | }) | |
| 62 | .ok_or_else(|| format!("no decodable audio track in '{}'", path_ref.display()))?; | |
| 63 | ||
| 64 | let track_id = track.id; | |
| 65 | let mut sample_rate = track.codec_params.sample_rate.unwrap_or(0); | |
| 66 | let mut decoder = symphonia::default::get_codecs() | |
| 67 | .make(&track.codec_params, &DecoderOptions::default()) | |
| 68 | .map_err(|e| format!("failed to create audio decoder '{}': {e}", path_ref.display()))?; | |
| 69 | ||
| 70 | let mut stereo_samples: Vec<f32> = Vec::new(); | |
| 71 | let mut sample_buf: Option<SampleBuffer<f32>> = None; | |
| 72 | ||
| 73 | loop { | |
| 74 | let packet = match format.next_packet() { | |
| 75 | Ok(p) => p, | |
| 76 | Err(SymphoniaError::IoError(e)) if e.kind() == ErrorKind::UnexpectedEof => break, | |
| 77 | Err(SymphoniaError::ResetRequired) => { | |
| 78 | decoder.reset(); | |
| 79 | continue; | |
| 80 | } | |
| 81 | Err(e) => { | |
| 82 | return Err(format!("error reading audio packet '{}': {e}", path_ref.display())); | |
| 83 | } | |
| 84 | }; | |
| 85 | ||
| 86 | if packet.track_id() != track_id { | |
| 87 | continue; | |
| 88 | } | |
| 89 | ||
| 90 | let decoded = match decoder.decode(&packet) { | |
| 91 | Ok(d) => d, | |
| 92 | Err(SymphoniaError::DecodeError(_)) => continue, | |
| 93 | Err(SymphoniaError::IoError(e)) if e.kind() == ErrorKind::UnexpectedEof => break, | |
| 94 | Err(SymphoniaError::ResetRequired) => { | |
| 95 | decoder.reset(); | |
| 96 | continue; | |
| 97 | } | |
| 98 | Err(e) => { | |
| 99 | return Err(format!("error decoding audio '{}': {e}", path_ref.display())); | |
| 100 | } | |
| 101 | }; | |
| 102 | ||
| 103 | let spec = *decoded.spec(); | |
| 104 | if sample_rate == 0 { | |
| 105 | sample_rate = spec.rate; | |
| 106 | } | |
| 107 | let src_channels = spec.channels.count(); | |
| 108 | if src_channels == 0 { | |
| 109 | continue; | |
| 110 | } | |
| 111 | ||
| 112 | let frames = decoded.frames(); | |
| 113 | let buf = sample_buf.get_or_insert_with(|| { | |
| 114 | SampleBuffer::<f32>::new(decoded.capacity() as u64, spec) | |
| 115 | }); | |
| 116 | if buf.capacity() < frames * src_channels { | |
| 117 | *buf = SampleBuffer::<f32>::new(decoded.capacity() as u64, spec); | |
| 118 | } | |
| 119 | buf.copy_interleaved_ref(decoded); | |
| 120 | let interleaved = buf.samples(); | |
| 121 | ||
| 122 | match src_channels { | |
| 123 | 1 => { | |
| 124 | stereo_samples.reserve(frames * 2); | |
| 125 | for &s in interleaved { | |
| 126 | stereo_samples.push(s); | |
| 127 | stereo_samples.push(s); | |
| 128 | } | |
| 129 | } | |
| 130 | 2 => { | |
| 131 | stereo_samples.extend_from_slice(interleaved); | |
| 132 | } | |
| 133 | n => { | |
| 134 | stereo_samples.reserve(frames * 2); | |
| 135 | for frame in interleaved.chunks_exact(n) { | |
| 136 | stereo_samples.push(frame[0]); | |
| 137 | stereo_samples.push(frame[1]); | |
| 138 | } | |
| 139 | } | |
| 140 | } | |
| 141 | } | |
| 142 | ||
| 143 | if sample_rate == 0 { | |
| 144 | return Err(format!("unknown sample rate in '{}'", path_ref.display())); | |
| 145 | } | |
| 146 | ||
| 147 | let total_frames = stereo_samples.len() / 2; | |
| 148 | let duration_secs = total_frames as f64 / sample_rate as f64; | |
| 149 | ||
| 150 | Ok(Self { | |
| 151 | path: path_ref.to_path_buf(), | |
| 152 | sample_rate, | |
| 153 | channels: 2, | |
| 154 | samples: Arc::new(stereo_samples), | |
| 155 | duration_secs, | |
| 156 | }) | |
| 157 | } | |
| 158 | ||
| 159 | /// Computes per-frame peak amplitude in `[0.0, 1.0]` for timeline waveform visualization | |
| 160 | /// across inclusive frame range `start_frame..=end_frame`. | |
| 161 | pub fn waveform_peaks( | |
| 162 | &self, | |
| 163 | fps: f64, | |
| 164 | offset_frames: f64, | |
| 165 | start_frame: i64, | |
| 166 | end_frame: i64, | |
| 167 | ) -> Vec<f32> { | |
| 168 | if end_frame < start_frame || fps <= 0.0 || self.sample_rate == 0 { | |
| 169 | return Vec::new(); | |
| 170 | } | |
| 171 | let count = (end_frame - start_frame + 1) as usize; | |
| 172 | let mut peaks = vec![0.0_f32; count]; | |
| 173 | let total_frames = self.samples.len() / 2; | |
| 174 | if total_frames == 0 { | |
| 175 | return peaks; | |
| 176 | } | |
| 177 | let sr = self.sample_rate as f64; | |
| 178 | ||
| 179 | for (i, peak_out) in peaks.iter_mut().enumerate() { | |
| 180 | let f = start_frame + i as i64; | |
| 181 | let t0 = (f as f64 - offset_frames) / fps; | |
| 182 | let t1 = ((f + 1) as f64 - offset_frames) / fps; | |
| 183 | if t1 <= 0.0 { | |
| 184 | continue; | |
| 185 | } | |
| 186 | let s0 = (t0.max(0.0) * sr).floor() as usize; | |
| 187 | let s1 = ((t1.max(0.0) * sr).ceil() as usize).min(total_frames); | |
| 188 | if s0 >= total_frames || s0 >= s1 { | |
| 189 | continue; | |
| 190 | } | |
| 191 | let mut max_amp = 0.0_f32; | |
| 192 | let slice = &self.samples[(s0 * 2)..(s1 * 2)]; | |
| 193 | for &s in slice { | |
| 194 | let a = s.abs(); | |
| 195 | if a > max_amp { | |
| 196 | max_amp = a; | |
| 197 | } | |
| 198 | } | |
| 199 | *peak_out = max_amp.clamp(0.0, 1.0); | |
| 200 | } | |
| 201 | peaks | |
| 202 | } | |
| 203 | } | |
| 204 | ||
| 205 | struct SharedState { | |
| 206 | playing: AtomicBool, | |
| 207 | /// Current playback time in seconds (`f64::to_bits`), may be negative for leading silence. | |
| 208 | cursor_secs_bits: AtomicU64, | |
| 209 | /// Monotonic generation bumped on seek/play_from so audio thread never overwrites a fresh seek. | |
| 210 | seek_gen: AtomicU64, | |
| 211 | volume_bits: AtomicU32, | |
| 212 | track: Mutex<Option<Arc<AudioTrack>>>, | |
| 213 | } | |
| 214 | ||
| 215 | /// Real-time non-blocking audio player backed by `cpal` (CoreAudio on macOS). | |
| 216 | pub struct AudioPlayer { | |
| 217 | _stream: Stream, | |
| 218 | state: Arc<SharedState>, | |
| 219 | } | |
| 220 | ||
| 221 | impl AudioPlayer { | |
| 222 | /// Initializes the default audio output device and opens a non-blocking output stream. | |
| 223 | /// Returns `Err` cleanly in headless or no-audio-device environments. | |
| 224 | pub fn new() -> Result<Self, String> { | |
| 225 | let host = cpal::default_host(); | |
| 226 | let device = host | |
| 227 | .default_output_device() | |
| 228 | .ok_or_else(|| "no default audio output device available".to_string())?; | |
| 229 | let supported_config = device | |
| 230 | .default_output_config() | |
| 231 | .map_err(|e| format!("failed to query default audio output config: {e}"))?; | |
| 232 | ||
| 233 | let sample_format = supported_config.sample_format(); | |
| 234 | let config: cpal::StreamConfig = supported_config.into(); | |
| 235 | let device_sr = config.sample_rate.0.max(1); | |
| 236 | let device_channels = config.channels.max(1) as usize; | |
| 237 | ||
| 238 | let state = Arc::new(SharedState { | |
| 239 | playing: AtomicBool::new(false), | |
| 240 | cursor_secs_bits: AtomicU64::new(0.0_f64.to_bits()), | |
| 241 | seek_gen: AtomicU64::new(0), | |
| 242 | volume_bits: AtomicU32::new(1.0_f32.to_bits()), | |
| 243 | track: Mutex::new(None), | |
| 244 | }); | |
| 245 | ||
| 246 | let stream = match sample_format { | |
| 247 | SampleFormat::F32 => { | |
| 248 | build_stream::<f32>(&device, &config, device_sr, device_channels, Arc::clone(&state))? | |
| 249 | } | |
| 250 | SampleFormat::I16 => { | |
| 251 | build_stream::<i16>(&device, &config, device_sr, device_channels, Arc::clone(&state))? | |
| 252 | } | |
| 253 | SampleFormat::U16 => { | |
| 254 | build_stream::<u16>(&device, &config, device_sr, device_channels, Arc::clone(&state))? | |
| 255 | } | |
| 256 | other => { | |
| 257 | return Err(format!("unsupported audio output sample format: {other:?}")); | |
| 258 | } | |
| 259 | }; | |
| 260 | ||
| 261 | stream | |
| 262 | .play() | |
| 263 | .map_err(|e| format!("failed to start audio output stream: {e}"))?; | |
| 264 | ||
| 265 | Ok(Self { | |
| 266 | _stream: stream, | |
| 267 | state, | |
| 268 | }) | |
| 269 | } | |
| 270 | ||
| 271 | pub fn set_track(&mut self, track: Option<Arc<AudioTrack>>) { | |
| 272 | if let Ok(mut guard) = self.state.track.lock() { | |
| 273 | *guard = track; | |
| 274 | } | |
| 275 | } | |
| 276 | ||
| 277 | pub fn play_from(&mut self, time_secs: f64) { | |
| 278 | self.seek(time_secs); | |
| 279 | self.state.playing.store(true, Ordering::Release); | |
| 280 | } | |
| 281 | ||
| 282 | pub fn seek(&mut self, time_secs: f64) { | |
| 283 | self.state | |
| 284 | .cursor_secs_bits | |
| 285 | .store(time_secs.to_bits(), Ordering::Release); | |
| 286 | self.state.seek_gen.fetch_add(1, Ordering::AcqRel); | |
| 287 | } | |
| 288 | ||
| 289 | pub fn pause(&mut self) { | |
| 290 | self.state.playing.store(false, Ordering::Release); | |
| 291 | } | |
| 292 | ||
| 293 | pub fn set_volume(&mut self, vol: f32) { | |
| 294 | let clamped = vol.clamp(0.0, 2.0); | |
| 295 | self.state | |
| 296 | .volume_bits | |
| 297 | .store(clamped.to_bits(), Ordering::Relaxed); | |
| 298 | } | |
| 299 | ||
| 300 | pub fn is_playing(&self) -> bool { | |
| 301 | self.state.playing.load(Ordering::Acquire) | |
| 302 | } | |
| 303 | ||
| 304 | pub fn current_time_secs(&self) -> f64 { | |
| 305 | f64::from_bits(self.state.cursor_secs_bits.load(Ordering::Acquire)) | |
| 306 | } | |
| 307 | } | |
| 308 | ||
| 309 | fn build_stream<T>( | |
| 310 | device: &cpal::Device, | |
| 311 | config: &cpal::StreamConfig, | |
| 312 | device_sr: u32, | |
| 313 | device_channels: usize, | |
| 314 | state: Arc<SharedState>, | |
| 315 | ) -> Result<Stream, String> | |
| 316 | where | |
| 317 | T: Sample + FromSample<f32> + cpal::SizedSample, | |
| 318 | { | |
| 319 | let err_fn = |err| { | |
| 320 | eprintln!("audio stream error: {err}"); | |
| 321 | }; | |
| 322 | ||
| 323 | device | |
| 324 | .build_output_stream( | |
| 325 | config, | |
| 326 | move |data: &mut [T], _: &cpal::OutputCallbackInfo| { | |
| 327 | render_audio_buffer(data, device_sr, device_channels, &state); | |
| 328 | }, | |
| 329 | err_fn, | |
| 330 | None, | |
| 331 | ) | |
| 332 | .map_err(|e| format!("failed to build audio output stream: {e}")) | |
| 333 | } | |
| 334 | ||
| 335 | fn render_audio_buffer<T>( | |
| 336 | data: &mut [T], | |
| 337 | device_sr: u32, | |
| 338 | device_channels: usize, | |
| 339 | state: &SharedState, | |
| 340 | ) where | |
| 341 | T: Sample + FromSample<f32>, | |
| 342 | { | |
| 343 | if !state.playing.load(Ordering::Acquire) { | |
| 344 | let zero = T::from_sample(0.0_f32); | |
| 345 | data.fill(zero); | |
| 346 | return; | |
| 347 | } | |
| 348 | ||
| 349 | let track_opt = match state.track.try_lock() { | |
| 350 | Ok(guard) => guard.clone(), | |
| 351 | Err(_) => None, | |
| 352 | }; | |
| 353 | ||
| 354 | let Some(track) = track_opt else { | |
| 355 | let zero = T::from_sample(0.0_f32); | |
| 356 | data.fill(zero); | |
| 357 | return; | |
| 358 | }; | |
| 359 | ||
| 360 | let total_frames = track.samples.len() / 2; | |
| 361 | let track_sr = track.sample_rate as f64; | |
| 362 | let vol = f32::from_bits(state.volume_bits.load(Ordering::Relaxed)); | |
| 363 | let gen_before = state.seek_gen.load(Ordering::Acquire); | |
| 364 | let mut t_sec = f64::from_bits(state.cursor_secs_bits.load(Ordering::Acquire)); | |
| 365 | let dt = 1.0 / device_sr as f64; | |
| 366 | let samples = &track.samples; | |
| 367 | ||
| 368 | for frame_out in data.chunks_exact_mut(device_channels) { | |
| 369 | let (l, r) = if total_frames > 0 && t_sec >= 0.0 { | |
| 370 | let src_pos = t_sec * track_sr; | |
| 371 | if src_pos < total_frames as f64 { | |
| 372 | let idx0 = src_pos.floor() as usize; | |
| 373 | let idx1 = (idx0 + 1).min(total_frames - 1); | |
| 374 | let frac = (src_pos - idx0 as f64) as f32; | |
| 375 | let l0 = samples[idx0 * 2]; | |
| 376 | let r0 = samples[idx0 * 2 + 1]; | |
| 377 | let l1 = samples[idx1 * 2]; | |
| 378 | let r1 = samples[idx1 * 2 + 1]; | |
| 379 | ( | |
| 380 | (l0 + (l1 - l0) * frac) * vol, | |
| 381 | (r0 + (r1 - r0) * frac) * vol, | |
| 382 | ) | |
| 383 | } else { | |
| 384 | (0.0, 0.0) | |
| 385 | } | |
| 386 | } else { | |
| 387 | (0.0, 0.0) | |
| 388 | }; | |
| 389 | ||
| 390 | if device_channels == 1 { | |
| 391 | frame_out[0] = T::from_sample(((l + r) * 0.5).clamp(-1.0, 1.0)); | |
| 392 | } else { | |
| 393 | frame_out[0] = T::from_sample(l.clamp(-1.0, 1.0)); | |
| 394 | frame_out[1] = T::from_sample(r.clamp(-1.0, 1.0)); | |
| 395 | let zero = T::from_sample(0.0_f32); | |
| 396 | for ch in &mut frame_out[2..] { | |
| 397 | *ch = zero; | |
| 398 | } | |
| 399 | } | |
| 400 | ||
| 401 | t_sec += dt; | |
| 402 | } | |
| 403 | ||
| 404 | if state.seek_gen.load(Ordering::Acquire) == gen_before { | |
| 405 | state | |
| 406 | .cursor_secs_bits | |
| 407 | .store(t_sec.to_bits(), Ordering::Release); | |
| 408 | } | |
| 409 | } | |
| 410 | ||
| 411 | #[cfg(test)] | |
| 412 | mod tests { | |
| 413 | use super::*; | |
| 414 | use std::process::Command; | |
| 415 | ||
| 416 | fn rms(samples: &[f32]) -> f64 { | |
| 417 | if samples.is_empty() { | |
| 418 | return 0.0; | |
| 419 | } | |
| 420 | let sum_sq: f64 = samples.iter().map(|&s| (s as f64) * (s as f64)).sum(); | |
| 421 | (sum_sq / samples.len() as f64).sqrt() | |
| 422 | } | |
| 423 | ||
| 424 | #[test] | |
| 425 | fn test_audio_load_real_wav_if_present() { | |
| 426 | let path = Path::new("/Volumes/Project/trees/Bounces/trees_premix.wav"); | |
| 427 | if !path.exists() { | |
| 428 | return; | |
| 429 | } | |
| 430 | let track = AudioTrack::load(path).expect("failed to load trees_premix.wav"); | |
| 431 | assert!(track.sample_rate >= 8000); | |
| 432 | assert_eq!(track.channels, 2); | |
| 433 | assert!(track.duration_secs > 1.0); | |
| 434 | assert!(rms(&track.samples) > 0.001); | |
| 435 | let peaks = track.waveform_peaks(24.0, 0.0, 0, 23); | |
| 436 | assert_eq!(peaks.len(), 24); | |
| 437 | assert!(peaks.iter().all(|&p| (0.0..=1.0).contains(&p))); | |
| 438 | } | |
| 439 | ||
| 440 | #[test] | |
| 441 | fn test_audio_load_generated_wav_and_mp3() { | |
| 442 | let wav_path = std::env::temp_dir().join("engine_test_sine_440.wav"); | |
| 443 | let mp3_path = std::env::temp_dir().join("engine_test_sine_440.mp3"); | |
| 444 | ||
| 445 | let wav_ok = Command::new("ffmpeg") | |
| 446 | .args([ | |
| 447 | "-y", | |
| 448 | "-v", | |
| 449 | "error", | |
| 450 | "-f", | |
| 451 | "lavfi", | |
| 452 | "-i", | |
| 453 | "sine=frequency=440:duration=0.5", | |
| 454 | "-af", | |
| 455 | "volume=6", | |
| 456 | "-ar", | |
| 457 | "44100", | |
| 458 | "-ac", | |
| 459 | "2", | |
| 460 | ]) | |
| 461 | .arg(&wav_path) | |
| 462 | .status() | |
| 463 | .is_ok_and(|s| s.success()); | |
| 464 | assert!(wav_ok, "ffmpeg failed to generate temp wav"); | |
| 465 | ||
| 466 | let mp3_ok = Command::new("ffmpeg") | |
| 467 | .args([ | |
| 468 | "-y", | |
| 469 | "-v", | |
| 470 | "error", | |
| 471 | "-f", | |
| 472 | "lavfi", | |
| 473 | "-i", | |
| 474 | "sine=frequency=440:duration=0.5", | |
| 475 | "-af", | |
| 476 | "volume=6", | |
| 477 | "-ar", | |
| 478 | "44100", | |
| 479 | "-ac", | |
| 480 | "2", | |
| 481 | "-b:a", | |
| 482 | "192k", | |
| 483 | ]) | |
| 484 | .arg(&mp3_path) | |
| 485 | .status() | |
| 486 | .is_ok_and(|s| s.success()); | |
| 487 | assert!(mp3_ok, "ffmpeg failed to generate temp mp3"); | |
| 488 | ||
| 489 | for path in [&wav_path, &mp3_path] { | |
| 490 | let track = AudioTrack::load(path) | |
| 491 | .unwrap_or_else(|e| panic!("failed to load {}: {e}", path.display())); | |
| 492 | assert_eq!(track.sample_rate, 44100, "sample_rate mismatch for {}", path.display()); | |
| 493 | assert_eq!(track.channels, 2); | |
| 494 | assert!( | |
| 495 | (track.duration_secs - 0.5).abs() < 0.08, | |
| 496 | "duration mismatch for {}: {}", | |
| 497 | path.display(), | |
| 498 | track.duration_secs | |
| 499 | ); | |
| 500 | let r = rms(&track.samples); | |
| 501 | assert!(r > 0.1, "expected non-silent RMS > 0.1 for {}, got {r}", path.display()); | |
| 502 | ||
| 503 | let peaks = track.waveform_peaks(24.0, 0.0, 0, 11); | |
| 504 | assert_eq!(peaks.len(), 12); | |
| 505 | assert!(peaks.iter().all(|&p| (0.0..=1.0).contains(&p))); | |
| 506 | assert!( | |
| 507 | peaks.iter().copied().fold(0.0_f32, f32::max) > 0.5, | |
| 508 | "expected waveform peaks > 0.5 for {}", | |
| 509 | path.display() | |
| 510 | ); | |
| 511 | ||
| 512 | // Offset in the future -> leading frames should be silent (0.0). | |
| 513 | let shifted = track.waveform_peaks(24.0, 5.0, 0, 10); | |
| 514 | assert_eq!(shifted.len(), 11); | |
| 515 | assert_eq!(shifted[0], 0.0); | |
| 516 | assert_eq!(shifted[4], 0.0); | |
| 517 | assert!(shifted[6] > 0.5); | |
| 518 | } | |
| 519 | ||
| 520 | let _ = std::fs::remove_file(&wav_path); | |
| 521 | let _ = std::fs::remove_file(&mp3_path); | |
| 522 | } | |
| 523 | } |
crates/engine/src/av_decode.m created+365| ... | ... | @@ -0,0 +1,365 @@ |
| 1 | #import <AVFoundation/AVFoundation.h> | |
| 2 | #import <CoreFoundation/CoreFoundation.h> | |
| 3 | #import <CoreMedia/CoreMedia.h> | |
| 4 | #import <CoreVideo/CoreVideo.h> | |
| 5 | #import <Foundation/Foundation.h> | |
| 6 | #include <math.h> | |
| 7 | #include <stdint.h> | |
| 8 | #include <stddef.h> | |
| 9 | ||
| 10 | #pragma clang diagnostic push | |
| 11 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" | |
| 12 | ||
| 13 | @interface AvVideoDecoderObj : NSObject | |
| 14 | @property(nonatomic, strong) AVURLAsset *asset; | |
| 15 | @property(nonatomic, strong) AVAssetTrack *track; | |
| 16 | @property(nonatomic, strong) AVAssetReader *reader; | |
| 17 | @property(nonatomic, strong) AVAssetReaderTrackOutput *output; | |
| 18 | @property(nonatomic, assign) uint32_t width; | |
| 19 | @property(nonatomic, assign) uint32_t height; | |
| 20 | @property(nonatomic, assign) int rotation; // 0, 90, 180, 270 clockwise | |
| 21 | @property(nonatomic, assign) double fps; | |
| 22 | @property(nonatomic, assign) int64_t nbFrames; | |
| 23 | @property(nonatomic, assign) double trackStartSec; | |
| 24 | @property(nonatomic, assign) int64_t lastFrameIdx; | |
| 25 | @end | |
| 26 | ||
| 27 | @implementation AvVideoDecoderObj | |
| 28 | ||
| 29 | - (void)closeReader { | |
| 30 | if (self.reader) { | |
| 31 | [self.reader cancelReading]; | |
| 32 | self.reader = nil; | |
| 33 | self.output = nil; | |
| 34 | } | |
| 35 | self.lastFrameIdx = -1; | |
| 36 | } | |
| 37 | ||
| 38 | - (BOOL)openReaderAtSeconds:(double)startSec { | |
| 39 | [self closeReader]; | |
| 40 | NSError *err = nil; | |
| 41 | AVAssetReader *r = [[AVAssetReader alloc] initWithAsset:self.asset error:&err]; | |
| 42 | if (!r || err) { | |
| 43 | return NO; | |
| 44 | } | |
| 45 | NSDictionary *settings = @{ | |
| 46 | (NSString *)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_32BGRA), | |
| 47 | }; | |
| 48 | AVAssetReaderTrackOutput *out = | |
| 49 | [[AVAssetReaderTrackOutput alloc] initWithTrack:self.track outputSettings:settings]; | |
| 50 | out.alwaysCopiesSampleData = NO; | |
| 51 | if (![r canAddOutput:out]) { | |
| 52 | return NO; | |
| 53 | } | |
| 54 | [r addOutput:out]; | |
| 55 | if (startSec > 0.0) { | |
| 56 | CMTime startTime = CMTimeMakeWithSeconds(startSec, 60000); | |
| 57 | r.timeRange = CMTimeRangeMake(startTime, kCMTimePositiveInfinity); | |
| 58 | } | |
| 59 | if (![r startReading]) { | |
| 60 | return NO; | |
| 61 | } | |
| 62 | self.reader = r; | |
| 63 | self.output = out; | |
| 64 | return YES; | |
| 65 | } | |
| 66 | ||
| 67 | - (void)dealloc { | |
| 68 | [self closeReader]; | |
| 69 | } | |
| 70 | ||
| 71 | @end | |
| 72 | ||
| 73 | typedef struct AvVideoDecoder AvVideoDecoder; | |
| 74 | ||
| 75 | static int copy_bgra_to_rgba( | |
| 76 | CVImageBufferRef imgBuf, | |
| 77 | uint32_t outW, | |
| 78 | uint32_t outH, | |
| 79 | int rotation, | |
| 80 | uint8_t *outRgba, | |
| 81 | size_t outLen | |
| 82 | ) { | |
| 83 | if (!imgBuf || !outRgba) { | |
| 84 | return 0; | |
| 85 | } | |
| 86 | size_t required = (size_t)outW * (size_t)outH * 4; | |
| 87 | if (outLen < required) { | |
| 88 | return 0; | |
| 89 | } | |
| 90 | ||
| 91 | if (CVPixelBufferLockBaseAddress(imgBuf, kCVPixelBufferLock_ReadOnly) != kCVReturnSuccess) { | |
| 92 | return 0; | |
| 93 | } | |
| 94 | ||
| 95 | size_t srcW = CVPixelBufferGetWidth(imgBuf); | |
| 96 | size_t srcH = CVPixelBufferGetHeight(imgBuf); | |
| 97 | size_t bpr = CVPixelBufferGetBytesPerRow(imgBuf); | |
| 98 | const uint8_t *base = (const uint8_t *)CVPixelBufferGetBaseAddress(imgBuf); | |
| 99 | ||
| 100 | int ok = 0; | |
| 101 | if (base) { | |
| 102 | if (rotation == 0 && srcW == outW && srcH == outH) { | |
| 103 | for (size_t y = 0; y < srcH; y++) { | |
| 104 | const uint8_t *src = base + y * bpr; | |
| 105 | uint8_t *dst = outRgba + y * (size_t)outW * 4; | |
| 106 | for (size_t x = 0; x < srcW; x++) { | |
| 107 | dst[x * 4 + 0] = src[x * 4 + 2]; | |
| 108 | dst[x * 4 + 1] = src[x * 4 + 1]; | |
| 109 | dst[x * 4 + 2] = src[x * 4 + 0]; | |
| 110 | dst[x * 4 + 3] = src[x * 4 + 3]; | |
| 111 | } | |
| 112 | } | |
| 113 | ok = 1; | |
| 114 | } else if (rotation == 90 && srcH == outW && srcW == outH) { | |
| 115 | for (size_t y = 0; y < srcH; y++) { | |
| 116 | const uint8_t *src = base + y * bpr; | |
| 117 | size_t dx = srcH - 1 - y; | |
| 118 | for (size_t x = 0; x < srcW; x++) { | |
| 119 | size_t dy = x; | |
| 120 | uint8_t *dst = outRgba + (dy * (size_t)outW + dx) * 4; | |
| 121 | dst[0] = src[x * 4 + 2]; | |
| 122 | dst[1] = src[x * 4 + 1]; | |
| 123 | dst[2] = src[x * 4 + 0]; | |
| 124 | dst[3] = src[x * 4 + 3]; | |
| 125 | } | |
| 126 | } | |
| 127 | ok = 1; | |
| 128 | } else if (rotation == 180 && srcW == outW && srcH == outH) { | |
| 129 | for (size_t y = 0; y < srcH; y++) { | |
| 130 | const uint8_t *src = base + y * bpr; | |
| 131 | size_t dy = srcH - 1 - y; | |
| 132 | for (size_t x = 0; x < srcW; x++) { | |
| 133 | size_t dx = srcW - 1 - x; | |
| 134 | uint8_t *dst = outRgba + (dy * (size_t)outW + dx) * 4; | |
| 135 | dst[0] = src[x * 4 + 2]; | |
| 136 | dst[1] = src[x * 4 + 1]; | |
| 137 | dst[2] = src[x * 4 + 0]; | |
| 138 | dst[3] = src[x * 4 + 3]; | |
| 139 | } | |
| 140 | } | |
| 141 | ok = 1; | |
| 142 | } else if (rotation == 270 && srcH == outW && srcW == outH) { | |
| 143 | for (size_t y = 0; y < srcH; y++) { | |
| 144 | const uint8_t *src = base + y * bpr; | |
| 145 | size_t dx = y; | |
| 146 | for (size_t x = 0; x < srcW; x++) { | |
| 147 | size_t dy = srcW - 1 - x; | |
| 148 | uint8_t *dst = outRgba + (dy * (size_t)outW + dx) * 4; | |
| 149 | dst[0] = src[x * 4 + 2]; | |
| 150 | dst[1] = src[x * 4 + 1]; | |
| 151 | dst[2] = src[x * 4 + 0]; | |
| 152 | dst[3] = src[x * 4 + 3]; | |
| 153 | } | |
| 154 | } | |
| 155 | ok = 1; | |
| 156 | } | |
| 157 | } | |
| 158 | ||
| 159 | CVPixelBufferUnlockBaseAddress(imgBuf, kCVPixelBufferLock_ReadOnly); | |
| 160 | return ok; | |
| 161 | } | |
| 162 | ||
| 163 | AvVideoDecoder *av_video_open( | |
| 164 | const char *path, | |
| 165 | uint32_t *out_w, | |
| 166 | uint32_t *out_h, | |
| 167 | double *out_fps, | |
| 168 | int64_t *out_nb_frames | |
| 169 | ) { | |
| 170 | if (!path || !out_w || !out_h || !out_fps || !out_nb_frames) { | |
| 171 | return NULL; | |
| 172 | } | |
| 173 | @autoreleasepool { | |
| 174 | NSString *nsPath = [NSString stringWithUTF8String:path]; | |
| 175 | if (!nsPath) { | |
| 176 | return NULL; | |
| 177 | } | |
| 178 | NSURL *url = [NSURL fileURLWithPath:nsPath]; | |
| 179 | AVURLAsset *asset = [AVURLAsset | |
| 180 | URLAssetWithURL:url | |
| 181 | options:@{AVURLAssetPreferPreciseDurationAndTimingKey : @YES}]; | |
| 182 | if (!asset) { | |
| 183 | return NULL; | |
| 184 | } | |
| 185 | ||
| 186 | NSArray<AVAssetTrack *> *tracks = [asset tracksWithMediaType:AVMediaTypeVideo]; | |
| 187 | AVAssetTrack *track = tracks.firstObject; | |
| 188 | if (!track) { | |
| 189 | return NULL; | |
| 190 | } | |
| 191 | ||
| 192 | CGSize natSize = track.naturalSize; | |
| 193 | uint32_t natW = (uint32_t)llround(fabs(natSize.width)); | |
| 194 | uint32_t natH = (uint32_t)llround(fabs(natSize.height)); | |
| 195 | if (natW == 0 || natH == 0) { | |
| 196 | return NULL; | |
| 197 | } | |
| 198 | ||
| 199 | CGAffineTransform t = track.preferredTransform; | |
| 200 | int rotation = -1; | |
| 201 | uint32_t outW = natW; | |
| 202 | uint32_t outH = natH; | |
| 203 | if (fabs(t.a - 1.0) < 0.01 && fabs(t.b) < 0.01 && fabs(t.c) < 0.01 && | |
| 204 | fabs(t.d - 1.0) < 0.01) { | |
| 205 | rotation = 0; | |
| 206 | } else if (fabs(t.a) < 0.01 && fabs(t.b - 1.0) < 0.01 && | |
| 207 | fabs(t.c + 1.0) < 0.01 && fabs(t.d) < 0.01) { | |
| 208 | rotation = 90; | |
| 209 | outW = natH; | |
| 210 | outH = natW; | |
| 211 | } else if (fabs(t.a + 1.0) < 0.01 && fabs(t.b) < 0.01 && | |
| 212 | fabs(t.c) < 0.01 && fabs(t.d + 1.0) < 0.01) { | |
| 213 | rotation = 180; | |
| 214 | } else if (fabs(t.a) < 0.01 && fabs(t.b + 1.0) < 0.01 && | |
| 215 | fabs(t.c - 1.0) < 0.01 && fabs(t.d) < 0.01) { | |
| 216 | rotation = 270; | |
| 217 | outW = natH; | |
| 218 | outH = natW; | |
| 219 | } else { | |
| 220 | // Unsupported affine transform (shear/non-90-deg); fall back to ffmpeg. | |
| 221 | return NULL; | |
| 222 | } | |
| 223 | ||
| 224 | double fps = (double)track.nominalFrameRate; | |
| 225 | if (fps <= 0.0) { | |
| 226 | CMTime minDur = track.minFrameDuration; | |
| 227 | if (CMTIME_IS_NUMERIC(minDur) && minDur.value > 0 && minDur.timescale > 0) { | |
| 228 | fps = (double)minDur.timescale / (double)minDur.value; | |
| 229 | } | |
| 230 | } | |
| 231 | if (fps <= 0.0) { | |
| 232 | fps = 30.0; | |
| 233 | } | |
| 234 | ||
| 235 | CMTime dur = track.timeRange.duration; | |
| 236 | if (!CMTIME_IS_NUMERIC(dur) || CMTimeGetSeconds(dur) <= 0.0) { | |
| 237 | dur = asset.duration; | |
| 238 | } | |
| 239 | double durSec = CMTIME_IS_NUMERIC(dur) ? CMTimeGetSeconds(dur) : 0.0; | |
| 240 | int64_t nbFrames = durSec > 0.0 ? (int64_t)llround(durSec * fps) : 0; | |
| 241 | ||
| 242 | double trackStartSec = 0.0; | |
| 243 | if (CMTIME_IS_NUMERIC(track.timeRange.start)) { | |
| 244 | double s = CMTimeGetSeconds(track.timeRange.start); | |
| 245 | if (s > 0.0) { | |
| 246 | trackStartSec = s; | |
| 247 | } | |
| 248 | } | |
| 249 | ||
| 250 | AvVideoDecoderObj *obj = [[AvVideoDecoderObj alloc] init]; | |
| 251 | obj.asset = asset; | |
| 252 | obj.track = track; | |
| 253 | obj.width = outW; | |
| 254 | obj.height = outH; | |
| 255 | obj.rotation = rotation; | |
| 256 | obj.fps = fps; | |
| 257 | obj.nbFrames = nbFrames; | |
| 258 | obj.trackStartSec = trackStartSec; | |
| 259 | obj.lastFrameIdx = -1; | |
| 260 | ||
| 261 | // Verify AVAssetReader can actually open and decode this asset/codec. | |
| 262 | if (![obj openReaderAtSeconds:0.0]) { | |
| 263 | return NULL; | |
| 264 | } | |
| 265 | ||
| 266 | *out_w = outW; | |
| 267 | *out_h = outH; | |
| 268 | *out_fps = fps; | |
| 269 | *out_nb_frames = nbFrames; | |
| 270 | return (AvVideoDecoder *)CFBridgingRetain(obj); | |
| 271 | } | |
| 272 | } | |
| 273 | ||
| 274 | int av_video_decode_frame( | |
| 275 | AvVideoDecoder *dec, | |
| 276 | int64_t frame_idx, | |
| 277 | uint8_t *out_rgba, | |
| 278 | size_t out_len | |
| 279 | ) { | |
| 280 | if (!dec || !out_rgba) { | |
| 281 | return 0; | |
| 282 | } | |
| 283 | @autoreleasepool { | |
| 284 | AvVideoDecoderObj *obj = (__bridge AvVideoDecoderObj *)dec; | |
| 285 | if (frame_idx < 0) { | |
| 286 | frame_idx = 0; | |
| 287 | } | |
| 288 | double fps = obj.fps > 0.0 ? obj.fps : 30.0; | |
| 289 | double targetPts = obj.trackStartSec + ((double)frame_idx) / fps; | |
| 290 | double halfFrame = 0.45 / fps; | |
| 291 | ||
| 292 | BOOL canAdvance = | |
| 293 | obj.reader != nil && | |
| 294 | obj.reader.status == AVAssetReaderStatusReading && | |
| 295 | ((obj.lastFrameIdx == -1 && frame_idx <= 8) || | |
| 296 | (obj.lastFrameIdx >= 0 && frame_idx > obj.lastFrameIdx && | |
| 297 | frame_idx <= obj.lastFrameIdx + 8)); | |
| 298 | ||
| 299 | if (!canAdvance) { | |
| 300 | double seekSec = (frame_idx == 0) ? 0.0 : fmax(0.0, targetPts - (1.5 / fps)); | |
| 301 | if (![obj openReaderAtSeconds:seekSec]) { | |
| 302 | return 0; | |
| 303 | } | |
| 304 | } | |
| 305 | ||
| 306 | CMSampleBufferRef chosen = NULL; | |
| 307 | CMSampleBufferRef lastSeen = NULL; | |
| 308 | ||
| 309 | while (obj.reader.status == AVAssetReaderStatusReading) { | |
| 310 | CMSampleBufferRef sb = [obj.output copyNextSampleBuffer]; | |
| 311 | if (!sb) { | |
| 312 | break; | |
| 313 | } | |
| 314 | CMTime ptsTime = CMSampleBufferGetPresentationTimeStamp(sb); | |
| 315 | double pts = CMTIME_IS_NUMERIC(ptsTime) ? CMTimeGetSeconds(ptsTime) : targetPts; | |
| 316 | ||
| 317 | if (pts + halfFrame >= targetPts) { | |
| 318 | chosen = sb; | |
| 319 | break; | |
| 320 | } | |
| 321 | if (lastSeen) { | |
| 322 | CFRelease(lastSeen); | |
| 323 | } | |
| 324 | lastSeen = sb; | |
| 325 | } | |
| 326 | ||
| 327 | if (!chosen && lastSeen) { | |
| 328 | chosen = lastSeen; | |
| 329 | lastSeen = NULL; | |
| 330 | } | |
| 331 | if (lastSeen) { | |
| 332 | CFRelease(lastSeen); | |
| 333 | lastSeen = NULL; | |
| 334 | } | |
| 335 | ||
| 336 | if (!chosen) { | |
| 337 | [obj closeReader]; | |
| 338 | return 0; | |
| 339 | } | |
| 340 | ||
| 341 | CVImageBufferRef imgBuf = CMSampleBufferGetImageBuffer(chosen); | |
| 342 | int ok = copy_bgra_to_rgba( | |
| 343 | imgBuf, obj.width, obj.height, obj.rotation, out_rgba, out_len); | |
| 344 | CFRelease(chosen); | |
| 345 | ||
| 346 | if (ok) { | |
| 347 | obj.lastFrameIdx = frame_idx; | |
| 348 | } else { | |
| 349 | [obj closeReader]; | |
| 350 | } | |
| 351 | return ok; | |
| 352 | } | |
| 353 | } | |
| 354 | ||
| 355 | void av_video_close(AvVideoDecoder *dec) { | |
| 356 | if (!dec) { | |
| 357 | return; | |
| 358 | } | |
| 359 | @autoreleasepool { | |
| 360 | AvVideoDecoderObj *obj = (AvVideoDecoderObj *)CFBridgingRelease(dec); | |
| 361 | [obj closeReader]; | |
| 362 | } | |
| 363 | } | |
| 364 | ||
| 365 | #pragma clang diagnostic pop |
crates/engine/src/bin/render_check.rs+123-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //! Headless verification, parity+perf suite runner, and batch PNG sequence renderer for `engine`. |
| 2 | 2 | |
| 3 | use engine::{CacheMode, Engine}; | |
| 3 | use engine::{CacheMode, Engine, ExportOptions, export_saver_png_sequence}; | |
| 4 | 4 | use model::Comp; |
| 5 | 5 | use std::collections::HashMap; |
| 6 | 6 | use std::fs::File; |
| ... | ... | @@ -192,6 +192,66 @@ fn run_batch_render( |
| 192 | 192 | Ok(()) |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | fn run_saver_export( | |
| 196 | comp_path: &Path, | |
| 197 | saver_name: Option<&str>, | |
| 198 | range_str: Option<&str>, | |
| 199 | out_dir_override: Option<PathBuf>, | |
| 200 | proxy_scale: u32, | |
| 201 | hiq: bool, | |
| 202 | ) -> Result<(), Box<dyn std::error::Error>> { | |
| 203 | let comp = Comp::from_fusion_file(comp_path)?; | |
| 204 | let range_override = match range_str { | |
| 205 | Some(r) if !r.is_empty() => { | |
| 206 | if let Some((a, b)) = r.split_once("..") { | |
| 207 | Some([a.parse::<i64>()?, b.parse::<i64>()?]) | |
| 208 | } else { | |
| 209 | let single = r.parse::<i64>()?; | |
| 210 | Some([single, single]) | |
| 211 | } | |
| 212 | } | |
| 213 | _ => None, | |
| 214 | }; | |
| 215 | let mut engine = Engine::new_headless()?; | |
| 216 | let opts = ExportOptions { | |
| 217 | saver_name: saver_name.map(str::to_owned), | |
| 218 | out_dir_override, | |
| 219 | range_override, | |
| 220 | hiq, | |
| 221 | proxy_scale, | |
| 222 | png_workers: 0, | |
| 223 | }; | |
| 224 | let t_start = Instant::now(); | |
| 225 | let summary = export_saver_png_sequence(&mut engine, &comp, &opts, |p| { | |
| 226 | if p.index == 0 || (p.index + 1) % 10 == 0 || p.index + 1 == p.total { | |
| 227 | let elapsed = t_start.elapsed().as_secs_f64().max(1e-6); | |
| 228 | let fps = (p.index + 1) as f64 / elapsed; | |
| 229 | eprintln!( | |
| 230 | " [{:>4}/{}] {} f{:04} | eval={:.1}ms | avg={fps:.1} fps -> {}", | |
| 231 | p.index + 1, | |
| 232 | p.total, | |
| 233 | p.saver_name, | |
| 234 | p.frame, | |
| 235 | p.eval_ms, | |
| 236 | p.out_path.display() | |
| 237 | ); | |
| 238 | } | |
| 239 | }) | |
| 240 | .map_err(|e| format!("export failed: {e}"))?; | |
| 241 | let secs = (summary.total_ms / 1000.0).max(1e-6); | |
| 242 | eprintln!( | |
| 243 | "Exported {} frames via {} in {:.2}s ({:.1} fps)", | |
| 244 | summary.frames_written, | |
| 245 | summary.saver_name, | |
| 246 | secs, | |
| 247 | summary.frames_written as f64 / secs | |
| 248 | ); | |
| 249 | if let (Some(first), Some(last)) = (summary.first_path, summary.last_path) { | |
| 250 | eprintln!(" range: {} .. {}", first.display(), last.display()); | |
| 251 | } | |
| 252 | Ok(()) | |
| 253 | } | |
| 254 | ||
| 195 | 255 | fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 196 | 256 | let args: Vec<String> = std::env::args().collect(); |
| 197 | 257 | if args.len() >= 3 && args[1] == "--suite" { |
| ... | ... | @@ -200,12 +260,73 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 200 | 260 | } |
| 201 | 261 | if args.len() < 3 { |
| 202 | 262 | eprintln!( |
| 203 | "usage:\n render-check <comp.comp> <frame> [--out <out.png>] [--ref <ref.png>] [--node <name>] [--proxy <1|2|4>] [--fast]\n render-check <comp.comp> --render <start>..<end> --out-dir <dir> [--node <name>] [--proxy <1|2|4>]\n render-check --suite <private/suite.txt> [--fast]" | |
| 263 | "usage:\n render-check <comp.comp> <frame> [--out <out.png>] [--ref <ref.png>] [--node <name>] [--proxy <1|2|4>] [--fast]\n render-check <comp.comp> --render <start>..<end> --out-dir <dir> [--node <name>] [--proxy <1|2|4>]\n render-check <comp.comp> --export [--saver <name>] [--range <start>..<end>] [--out-dir <dir>] [--proxy <1|2|4>] [--fast]\n render-check <comp.comp> --roundtrip <out.comp>\n render-check --suite <private/suite.txt> [--fast]" | |
| 204 | 264 | ); |
| 205 | 265 | std::process::exit(2); |
| 206 | 266 | } |
| 207 | 267 | |
| 208 | 268 | let comp_path = PathBuf::from(&args[1]); |
| 269 | if args[2] == "--roundtrip" { | |
| 270 | if args.len() < 4 { | |
| 271 | return Err("--roundtrip requires <out.comp>".into()); | |
| 272 | } | |
| 273 | let comp = Comp::from_fusion_file(&comp_path)?; | |
| 274 | let out_path = PathBuf::from(&args[3]); | |
| 275 | let bak = comp.save_to_file(&out_path)?; | |
| 276 | eprintln!( | |
| 277 | "Roundtripped {} ({} nodes, {} splines) -> {}{}", | |
| 278 | comp_path.display(), | |
| 279 | comp.nodes.len(), | |
| 280 | comp.splines.len(), | |
| 281 | out_path.display(), | |
| 282 | bak.map(|b| format!(" (backup -> {})", b.display())).unwrap_or_default() | |
| 283 | ); | |
| 284 | return Ok(()); | |
| 285 | } | |
| 286 | if args[2] == "--export" { | |
| 287 | let mut saver_name: Option<String> = None; | |
| 288 | let mut range_str: Option<String> = None; | |
| 289 | let mut out_dir: Option<PathBuf> = None; | |
| 290 | let mut proxy_scale = 1u32; | |
| 291 | let mut hiq = true; | |
| 292 | let mut i = 3; | |
| 293 | while i < args.len() { | |
| 294 | match args[i].as_str() { | |
| 295 | "--saver" if i + 1 < args.len() => { | |
| 296 | saver_name = Some(args[i + 1].clone()); | |
| 297 | i += 2; | |
| 298 | } | |
| 299 | "--range" if i + 1 < args.len() => { | |
| 300 | range_str = Some(args[i + 1].clone()); | |
| 301 | i += 2; | |
| 302 | } | |
| 303 | "--out-dir" if i + 1 < args.len() => { | |
| 304 | out_dir = Some(PathBuf::from(&args[i + 1])); | |
| 305 | i += 2; | |
| 306 | } | |
| 307 | "--proxy" if i + 1 < args.len() => { | |
| 308 | proxy_scale = args[i + 1].parse().unwrap_or(1).max(1); | |
| 309 | i += 2; | |
| 310 | } | |
| 311 | "--fast" => { | |
| 312 | hiq = false; | |
| 313 | i += 1; | |
| 314 | } | |
| 315 | other => { | |
| 316 | eprintln!("unexpected argument '{other}'"); | |
| 317 | std::process::exit(2); | |
| 318 | } | |
| 319 | } | |
| 320 | } | |
| 321 | return run_saver_export( | |
| 322 | &comp_path, | |
| 323 | saver_name.as_deref(), | |
| 324 | range_str.as_deref(), | |
| 325 | out_dir, | |
| 326 | proxy_scale, | |
| 327 | hiq, | |
| 328 | ); | |
| 329 | } | |
| 209 | 330 | if args[2] == "--render" { |
| 210 | 331 | let mut range = String::new(); |
| 211 | 332 | let mut out_dir: Option<PathBuf> = None; |
crates/engine/src/eval.rs+12-5| ... | ... | @@ -814,17 +814,24 @@ impl Engine { |
| 814 | 814 | "Custom" => self.eval_custom(comp, node, time, frame_i, comp_dims, enc, visiting, stats), |
| 815 | 815 | "Renderer3D" => self.eval_renderer3d(comp, node, time, frame_i, comp_dims, enc, visiting, stats), |
| 816 | 816 | other => { |
| 817 | // Graceful passthrough for unsupported nodes (e.g. MacroOperator, 3D, etc.) | |
| 817 | // Graceful passthrough for preserved/unknown image nodes (e.g. SurfaceTracker, MagicMask, | |
| 818 | // Fuse.Cryptomatte, Dimension.OpticalFlow) via standard primary image ports so downstream | |
| 819 | // graphs stay live without mistaking auxiliary sprite/material ports (like pEmitter's | |
| 820 | // ParticleStyleBitmap.DropToolsHere) for a full-frame passthrough. | |
| 818 | 821 | if !stats.unsupported_nodes.iter().any(|s| s == other) { |
| 819 | 822 | stats.unsupported_nodes.push(other.to_owned()); |
| 820 | 823 | } |
| 821 | 824 | let port = default_main_input_port(other); |
| 822 | if let Some(src_id) = node.connected_node(port) | |
| 823 | .or_else(|| node.connected_node("MainInput1")) | |
| 825 | let primary_src = node | |
| 826 | .connected_node(port) | |
| 824 | 827 | .or_else(|| node.connected_node("Input")) |
| 828 | .or_else(|| node.connected_node("Source")) | |
| 829 | .or_else(|| node.connected_node("MainInput1")) | |
| 830 | .or_else(|| node.connected_node("Image")) | |
| 831 | .or_else(|| node.connected_node("Image1")) | |
| 825 | 832 | .or_else(|| node.connected_node("Background")) |
| 826 | .and_then(|s| comp.find_node(s)) | |
| 827 | { | |
| 833 | .and_then(|s| comp.find_node(s)); | |
| 834 | if let Some(src_id) = primary_src { | |
| 828 | 835 | self.eval_node(comp, src_id, time, enc, visiting, stats) |
| 829 | 836 | } else { |
| 830 | 837 | self.dummy.clone() |
crates/engine/src/export.rs created+382| ... | ... | @@ -0,0 +1,382 @@ |
| 1 | //! Saver-driven pipelined PNG sequence export for `Engine`. | |
| 2 | //! | |
| 3 | //! Evaluates frames on the GPU while encoding lossless RGBA8 PNG files concurrently | |
| 4 | //! across a bounded background worker pool, creating parent directories automatically. | |
| 5 | ||
| 6 | use crate::eval::Engine; | |
| 7 | use model::{Comp, NodeId, SaverSpec}; | |
| 8 | use std::fs::File; | |
| 9 | use std::io::BufWriter; | |
| 10 | use std::path::{Path, PathBuf}; | |
| 11 | use std::sync::atomic::{AtomicBool, Ordering}; | |
| 12 | use std::sync::{Arc, Mutex, mpsc}; | |
| 13 | use std::time::Instant; | |
| 14 | ||
| 15 | #[derive(Clone, Debug)] | |
| 16 | pub struct ExportOptions { | |
| 17 | /// Optional explicit Saver node name. If `None`, selects the first non-bypassed Saver | |
| 18 | /// with a configured filename (or falls back to the first Saver). | |
| 19 | pub saver_name: Option<String>, | |
| 20 | /// Optional output directory override (keeps each frame's filename from `SaverSpec::frame_path`). | |
| 21 | pub out_dir_override: Option<PathBuf>, | |
| 22 | /// Optional inclusive frame range override `[start, end]`. Defaults to `saver.range` (`comp.render_range`). | |
| 23 | pub range_override: Option<[i64; 2]>, | |
| 24 | /// Render quality mode (`true` = HiQ project depth, `false` = Fast). | |
| 25 | pub hiq: bool, | |
| 26 | /// Proxy downscale factor (`1` = full resolution). | |
| 27 | pub proxy_scale: u32, | |
| 28 | /// Number of background PNG encoder threads (`0` = automatic 2..=8). | |
| 29 | pub png_workers: usize, | |
| 30 | } | |
| 31 | ||
| 32 | impl Default for ExportOptions { | |
| 33 | fn default() -> Self { | |
| 34 | Self { | |
| 35 | saver_name: None, | |
| 36 | out_dir_override: None, | |
| 37 | range_override: None, | |
| 38 | hiq: true, | |
| 39 | proxy_scale: 1, | |
| 40 | png_workers: 0, | |
| 41 | } | |
| 42 | } | |
| 43 | } | |
| 44 | ||
| 45 | #[derive(Clone, Debug)] | |
| 46 | pub struct ExportProgress { | |
| 47 | pub frame: i64, | |
| 48 | pub index: usize, | |
| 49 | pub total: usize, | |
| 50 | pub eval_ms: f64, | |
| 51 | pub out_path: PathBuf, | |
| 52 | pub saver_name: String, | |
| 53 | } | |
| 54 | ||
| 55 | #[derive(Clone, Debug)] | |
| 56 | pub struct ExportSummary { | |
| 57 | pub saver_name: String, | |
| 58 | pub frames_written: usize, | |
| 59 | pub total_ms: f64, | |
| 60 | pub first_path: Option<PathBuf>, | |
| 61 | pub last_path: Option<PathBuf>, | |
| 62 | } | |
| 63 | ||
| 64 | /// Selects the target `SaverSpec` from `comp` according to `saver_name`. | |
| 65 | pub fn select_saver(comp: &Comp, saver_name: Option<&str>) -> Result<SaverSpec, String> { | |
| 66 | let savers = comp.savers(); | |
| 67 | if savers.is_empty() { | |
| 68 | return Err(format!("comp '{}' has no Saver nodes", comp.name)); | |
| 69 | } | |
| 70 | if let Some(name) = saver_name { | |
| 71 | return savers | |
| 72 | .into_iter() | |
| 73 | .find(|s| s.name == name) | |
| 74 | .ok_or_else(|| format!("comp '{}' has no Saver named '{name}'", comp.name)); | |
| 75 | } | |
| 76 | // Prefer first non-bypassed Saver with an upstream connection and non-empty filename | |
| 77 | if let Some(s) = savers.iter().find(|s| { | |
| 78 | !comp.node(s.node_id).bypassed && s.upstream.is_some() && !s.filename.is_empty() | |
| 79 | }) { | |
| 80 | return Ok(s.clone()); | |
| 81 | } | |
| 82 | if let Some(s) = savers.iter().find(|s| !comp.node(s.node_id).bypassed) { | |
| 83 | return Ok(s.clone()); | |
| 84 | } | |
| 85 | Ok(savers[0].clone()) | |
| 86 | } | |
| 87 | ||
| 88 | fn resolve_output_path(saver: &SaverSpec, frame: i64, out_dir_override: Option<&Path>) -> Result<PathBuf, String> { | |
| 89 | if saver.filename.is_empty() { | |
| 90 | let dir = out_dir_override.ok_or_else(|| { | |
| 91 | format!( | |
| 92 | "Saver '{}' has no Clip.Filename set (pass an output directory override or configure Clip.Filename)", | |
| 93 | saver.name | |
| 94 | ) | |
| 95 | })?; | |
| 96 | return Ok(dir.join(format!("{frame:04}.png"))); | |
| 97 | } | |
| 98 | let frame_path = saver.frame_path(frame); | |
| 99 | if let Some(dir) = out_dir_override { | |
| 100 | let fname = frame_path | |
| 101 | .file_name() | |
| 102 | .map(PathBuf::from) | |
| 103 | .unwrap_or_else(|| PathBuf::from(format!("{frame:04}.png"))); | |
| 104 | Ok(dir.join(fname)) | |
| 105 | } else { | |
| 106 | Ok(frame_path) | |
| 107 | } | |
| 108 | } | |
| 109 | ||
| 110 | fn write_png_fast(path: &Path, size: [u32; 2], pixels: &[u8]) -> Result<(), String> { | |
| 111 | if let Some(parent) = path.parent() { | |
| 112 | if !parent.as_os_str().is_empty() { | |
| 113 | std::fs::create_dir_all(parent) | |
| 114 | .map_err(|e| format!("failed to create '{}': {e}", parent.display()))?; | |
| 115 | } | |
| 116 | } | |
| 117 | let file = File::create(path) | |
| 118 | .map_err(|e| format!("failed to create '{}': {e}", path.display()))?; | |
| 119 | let writer = BufWriter::new(file); | |
| 120 | let mut enc = png::Encoder::new(writer, size[0], size[1]); | |
| 121 | enc.set_color(png::ColorType::Rgba); | |
| 122 | enc.set_depth(png::BitDepth::Eight); | |
| 123 | enc.set_compression(png::Compression::Fast); | |
| 124 | let mut png_w = enc | |
| 125 | .write_header() | |
| 126 | .map_err(|e| format!("failed to write PNG header '{}': {e}", path.display()))?; | |
| 127 | png_w | |
| 128 | .write_image_data(pixels) | |
| 129 | .map_err(|e| format!("failed to write PNG data '{}': {e}", path.display()))?; | |
| 130 | Ok(()) | |
| 131 | } | |
| 132 | ||
| 133 | struct EncodeJob { | |
| 134 | path: PathBuf, | |
| 135 | size: [u32; 2], | |
| 136 | pixels: Vec<u8>, | |
| 137 | } | |
| 138 | ||
| 139 | /// Renders and writes a PNG sequence driven by a Fusion `Saver` node. | |
| 140 | /// | |
| 141 | /// GPU evaluation runs on the caller's thread while PNG compression and disk I/O run | |
| 142 | /// concurrently on a bounded pool of background worker threads. | |
| 143 | pub fn export_saver_png_sequence( | |
| 144 | engine: &mut Engine, | |
| 145 | comp: &Comp, | |
| 146 | opts: &ExportOptions, | |
| 147 | mut on_progress: impl FnMut(&ExportProgress), | |
| 148 | ) -> Result<ExportSummary, String> { | |
| 149 | let saver = select_saver(comp, opts.saver_name.as_deref())?; | |
| 150 | let target: NodeId = saver.upstream.unwrap_or(saver.node_id); | |
| 151 | let [start, end] = opts.range_override.unwrap_or(saver.range); | |
| 152 | if end < start { | |
| 153 | return Err(format!("invalid export frame range {start}..={end}")); | |
| 154 | } | |
| 155 | ||
| 156 | let prev_hiq = engine.hiq; | |
| 157 | let prev_proxy = engine.proxy_scale; | |
| 158 | engine.hiq = opts.hiq; | |
| 159 | engine.proxy_scale = opts.proxy_scale.max(1); | |
| 160 | ||
| 161 | let workers = if opts.png_workers > 0 { | |
| 162 | opts.png_workers.clamp(1, 16) | |
| 163 | } else { | |
| 164 | std::thread::available_parallelism() | |
| 165 | .map(|n| n.get().clamp(2, 8)) | |
| 166 | .unwrap_or(4) | |
| 167 | }; | |
| 168 | ||
| 169 | let total = (end - start + 1) as usize; | |
| 170 | let t0 = Instant::now(); | |
| 171 | let mut first_path: Option<PathBuf> = None; | |
| 172 | let mut last_path: Option<PathBuf> = None; | |
| 173 | ||
| 174 | let first_err: Arc<Mutex<Option<String>>> = Arc::new(Mutex::new(None)); | |
| 175 | let failed = Arc::new(AtomicBool::new(false)); | |
| 176 | ||
| 177 | let eval_result: Result<(), String> = std::thread::scope(|scope| { | |
| 178 | let (tx, rx) = mpsc::sync_channel::<EncodeJob>(workers * 2); | |
| 179 | let shared_rx = Arc::new(Mutex::new(rx)); | |
| 180 | ||
| 181 | let mut handles = Vec::with_capacity(workers); | |
| 182 | for _ in 0..workers { | |
| 183 | let rx_c = Arc::clone(&shared_rx); | |
| 184 | let err_c = Arc::clone(&first_err); | |
| 185 | let fail_c = Arc::clone(&failed); | |
| 186 | handles.push(scope.spawn(move || { | |
| 187 | loop { | |
| 188 | let job = { | |
| 189 | let Ok(guard) = rx_c.lock() else { break }; | |
| 190 | guard.recv() | |
| 191 | }; | |
| 192 | let Ok(job) = job else { break }; | |
| 193 | if fail_c.load(Ordering::Acquire) { | |
| 194 | continue; | |
| 195 | } | |
| 196 | if let Err(e) = write_png_fast(&job.path, job.size, &job.pixels) { | |
| 197 | if let Ok(mut g) = err_c.lock() { | |
| 198 | if g.is_none() { | |
| 199 | *g = Some(e); | |
| 200 | } | |
| 201 | } | |
| 202 | fail_c.store(true, Ordering::Release); | |
| 203 | } | |
| 204 | } | |
| 205 | })); | |
| 206 | } | |
| 207 | ||
| 208 | let mut loop_err: Option<String> = None; | |
| 209 | for (idx, frame) in (start..=end).enumerate() { | |
| 210 | if failed.load(Ordering::Acquire) { | |
| 211 | break; | |
| 212 | } | |
| 213 | let out_path = match resolve_output_path(&saver, frame, opts.out_dir_override.as_deref()) { | |
| 214 | Ok(p) => p, | |
| 215 | Err(e) => { | |
| 216 | loop_err = Some(e); | |
| 217 | break; | |
| 218 | } | |
| 219 | }; | |
| 220 | if first_path.is_none() { | |
| 221 | first_path = Some(out_path.clone()); | |
| 222 | } | |
| 223 | last_path = Some(out_path.clone()); | |
| 224 | ||
| 225 | let (tex, stats) = engine.evaluate(comp, target, frame as f64); | |
| 226 | let pixels = match engine.readback_rgba(&tex) { | |
| 227 | Ok(px) => px, | |
| 228 | Err(e) => { | |
| 229 | loop_err = Some(format!("GPU readback failed at frame {frame}: {e}")); | |
| 230 | break; | |
| 231 | } | |
| 232 | }; | |
| 233 | ||
| 234 | on_progress(&ExportProgress { | |
| 235 | frame, | |
| 236 | index: idx, | |
| 237 | total, | |
| 238 | eval_ms: stats.eval_ms, | |
| 239 | out_path: out_path.clone(), | |
| 240 | saver_name: saver.name.clone(), | |
| 241 | }); | |
| 242 | ||
| 243 | if tx | |
| 244 | .send(EncodeJob { | |
| 245 | path: out_path, | |
| 246 | size: tex.size, | |
| 247 | pixels, | |
| 248 | }) | |
| 249 | .is_err() | |
| 250 | { | |
| 251 | break; | |
| 252 | } | |
| 253 | } | |
| 254 | ||
| 255 | drop(tx); | |
| 256 | for h in handles { | |
| 257 | let _ = h.join(); | |
| 258 | } | |
| 259 | ||
| 260 | if let Some(e) = loop_err { | |
| 261 | return Err(e); | |
| 262 | } | |
| 263 | if let Ok(mut g) = first_err.lock() { | |
| 264 | if let Some(e) = g.take() { | |
| 265 | return Err(e); | |
| 266 | } | |
| 267 | } | |
| 268 | Ok(()) | |
| 269 | }); | |
| 270 | ||
| 271 | engine.hiq = prev_hiq; | |
| 272 | engine.proxy_scale = prev_proxy; | |
| 273 | ||
| 274 | eval_result?; | |
| 275 | ||
| 276 | Ok(ExportSummary { | |
| 277 | saver_name: saver.name, | |
| 278 | frames_written: total, | |
| 279 | total_ms: t0.elapsed().as_secs_f64() * 1000.0, | |
| 280 | first_path, | |
| 281 | last_path, | |
| 282 | }) | |
| 283 | } | |
| 284 | ||
| 285 | #[cfg(test)] | |
| 286 | mod tests { | |
| 287 | use super::*; | |
| 288 | ||
| 289 | #[test] | |
| 290 | fn exports_saver_png_sequence_animated() { | |
| 291 | let tmp_dir = std::env::temp_dir().join(format!( | |
| 292 | "fission-saver-export-test-{}", | |
| 293 | std::process::id() | |
| 294 | )); | |
| 295 | let _ = std::fs::remove_dir_all(&tmp_dir); | |
| 296 | let saver_path = tmp_dir.join("nested").join("shot_0000.png"); | |
| 297 | let saver_path_escaped = saver_path.to_string_lossy().replace('\\', "\\\\"); | |
| 298 | ||
| 299 | let comp_src = format!( | |
| 300 | r#"Composition {{ | |
| 301 | 	CurrentTime = 10, | |
| 302 | 	RenderRange = {{ 10, 12 }}, | |
| 303 | 	GlobalRange = {{ 0, 100 }}, | |
| 304 | 	Tools = ordered() {{ | |
| 305 | 		BG = Background {{ | |
| 306 | 			Inputs = {{ | |
| 307 | 				Width = Input {{ Value = 64, }}, | |
| 308 | 				Height = Input {{ Value = 32, }}, | |
| 309 | 				TopLeftRed = Input {{ SourceOp = "BGRed", Source = "Value", }}, | |
| 310 | 				TopLeftGreen = Input {{ Value = 0.25, }}, | |
| 311 | 				TopLeftBlue = Input {{ Value = 0.5, }}, | |
| 312 | 				TopLeftAlpha = Input {{ Value = 1, }}, | |
| 313 | 			}}, | |
| 314 | 		}}, | |
| 315 | 		BGRed = BezierSpline {{ | |
| 316 | 			KeyFrames = {{ | |
| 317 | 				[10] = {{ 0.0, Flags = {{ Linear = true }} }}, | |
| 318 | 				[12] = {{ 1.0, Flags = {{ Linear = true }} }}, | |
| 319 | 			}}, | |
| 320 | 		}}, | |
| 321 | 		Saver1 = Saver {{ | |
| 322 | 			Inputs = {{ | |
| 323 | 				Clip = Input {{ | |
| 324 | 					Value = Clip {{ | |
| 325 | 						Filename = "{saver_path_escaped}", | |
| 326 | 						FormatID = "PNGFormat", | |
| 327 | 						Saving = true, | |
| 328 | 					}}, | |
| 329 | 				}}, | |
| 330 | 				Input = Input {{ | |
| 331 | 					SourceOp = "BG", | |
| 332 | 					Source = "Output", | |
| 333 | 				}}, | |
| 334 | 			}}, | |
| 335 | 		}}, | |
| 336 | 	}}, | |
| 337 | 	Prefs = {{ | |
| 338 | 		Comp = {{ | |
| 339 | 			FrameFormat = {{ | |
| 340 | 				Width = 64, | |
| 341 | 				Height = 32, | |
| 342 | 				Rate = 30, | |
| 343 | 				DepthFull = 1, | |
| 344 | 			}}, | |
| 345 | 		}}, | |
| 346 | 	}}, | |
| 347 | }}"# | |
| 348 | ); | |
| 349 | ||
| 350 | let comp = Comp::from_fusion_str(&comp_src).expect("parse synthetic Saver comp"); | |
| 351 | let mut engine = Engine::new_headless().expect("headless wgpu engine"); | |
| 352 | ||
| 353 | let mut seen_frames = Vec::new(); | |
| 354 | let summary = export_saver_png_sequence(&mut engine, &comp, &ExportOptions::default(), |p| { | |
| 355 | seen_frames.push(p.frame); | |
| 356 | }) | |
| 357 | .expect("export png sequence"); | |
| 358 | ||
| 359 | assert_eq!(summary.saver_name, "Saver1"); | |
| 360 | assert_eq!(summary.frames_written, 3); | |
| 361 | assert_eq!(seen_frames, vec![10, 11, 12]); | |
| 362 | ||
| 363 | let expected_reds = [0u8, 128u8, 255u8]; | |
| 364 | for (frame, exp_r) in [10i64, 11, 12].into_iter().zip(expected_reds) { | |
| 365 | let p = tmp_dir.join("nested").join(format!("shot_{frame:04}.png")); | |
| 366 | assert!(p.exists(), "missing exported frame {}", p.display()); | |
| 367 | let img = image::open(&p).expect("decode exported PNG").to_rgba8(); | |
| 368 | assert_eq!(img.dimensions(), (64, 32)); | |
| 369 | let px = img.get_pixel(32, 16); | |
| 370 | assert!( | |
| 371 | (px[0] as i32 - exp_r as i32).abs() <= 2, | |
| 372 | "frame {frame}: expected R~{exp_r}, got {:?}", | |
| 373 | px.0 | |
| 374 | ); | |
| 375 | assert!((px[1] as i32 - 64).abs() <= 2); | |
| 376 | assert!((px[2] as i32 - 128).abs() <= 2); | |
| 377 | assert_eq!(px[3], 255); | |
| 378 | } | |
| 379 | ||
| 380 | let _ = std::fs::remove_dir_all(&tmp_dir); | |
| 381 | } | |
| 382 | } |
crates/engine/src/lib.rs+4| ... | ... | @@ -1,7 +1,11 @@ |
| 1 | pub mod audio; | |
| 1 | 2 | pub mod cache; |
| 2 | 3 | pub mod eval; |
| 4 | pub mod export; | |
| 3 | 5 | pub mod media; |
| 4 | 6 | pub mod scene3d; |
| 5 | 7 | |
| 8 | pub use audio::{AudioPlayer, AudioTrack}; | |
| 6 | 9 | pub use cache::{CacheMode, CachedTexture, EvalStats, NodeCache}; |
| 7 | 10 | pub use eval::{DisplaySettings, Engine, create_texture}; |
| 11 | pub use export::{ExportOptions, ExportProgress, ExportSummary, export_saver_png_sequence, select_saver}; |
crates/engine/src/media.rs+301-14| ... | ... | @@ -15,11 +15,169 @@ pub struct DecodedImage { |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | #[derive(Clone, Copy, Debug)] |
| 18 | struct VideoInfo { | |
| 19 | width: u32, | |
| 20 | height: u32, | |
| 21 | fps: f64, | |
| 22 | nb_frames: i64, | |
| 18 | pub struct VideoInfo { | |
| 19 | pub width: u32, | |
| 20 | pub height: u32, | |
| 21 | pub fps: f64, | |
| 22 | pub nb_frames: i64, | |
| 23 | } | |
| 24 | ||
| 25 | pub trait VideoDecoder: Send { | |
| 26 | fn info(&self) -> VideoInfo; | |
| 27 | fn decode_frame(&mut self, frame_idx: i64) -> Option<Vec<u8>>; | |
| 28 | fn backend_name(&self) -> &'static str; | |
| 29 | } | |
| 30 | ||
| 31 | #[cfg(target_os = "macos")] | |
| 32 | mod av_ffi { | |
| 33 | use std::ffi::c_char; | |
| 34 | ||
| 35 | #[repr(C)] | |
| 36 | pub struct AvVideoDecoder { | |
| 37 | _private: [u8; 0], | |
| 38 | } | |
| 39 | ||
| 40 | unsafe extern "C" { | |
| 41 | pub fn av_video_open( | |
| 42 | path: *const c_char, | |
| 43 | out_w: *mut u32, | |
| 44 | out_h: *mut u32, | |
| 45 | out_fps: *mut f64, | |
| 46 | out_nb_frames: *mut i64, | |
| 47 | ) -> *mut AvVideoDecoder; | |
| 48 | ||
| 49 | pub fn av_video_decode_frame( | |
| 50 | dec: *mut AvVideoDecoder, | |
| 51 | frame_idx: i64, | |
| 52 | out_rgba: *mut u8, | |
| 53 | out_len: usize, | |
| 54 | ) -> i32; | |
| 55 | ||
| 56 | pub fn av_video_close(dec: *mut AvVideoDecoder); | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | #[cfg(target_os = "macos")] | |
| 61 | pub struct AvFoundationDecoder { | |
| 62 | ptr: *mut av_ffi::AvVideoDecoder, | |
| 63 | info: VideoInfo, | |
| 64 | } | |
| 65 | ||
| 66 | #[cfg(target_os = "macos")] | |
| 67 | unsafe impl Send for AvFoundationDecoder {} | |
| 68 | ||
| 69 | #[cfg(target_os = "macos")] | |
| 70 | impl Drop for AvFoundationDecoder { | |
| 71 | fn drop(&mut self) { | |
| 72 | if !self.ptr.is_null() { | |
| 73 | unsafe { av_ffi::av_video_close(self.ptr) }; | |
| 74 | self.ptr = std::ptr::null_mut(); | |
| 75 | } | |
| 76 | } | |
| 77 | } | |
| 78 | ||
| 79 | #[cfg(target_os = "macos")] | |
| 80 | impl AvFoundationDecoder { | |
| 81 | pub fn open(path: &Path) -> Option<Self> { | |
| 82 | use std::ffi::CString; | |
| 83 | let path_str = path.to_str()?; | |
| 84 | let c_path = CString::new(path_str).ok()?; | |
| 85 | let mut width = 0u32; | |
| 86 | let mut height = 0u32; | |
| 87 | let mut fps = 0.0f64; | |
| 88 | let mut nb_frames = 0i64; | |
| 89 | let ptr = unsafe { | |
| 90 | av_ffi::av_video_open( | |
| 91 | c_path.as_ptr(), | |
| 92 | &mut width, | |
| 93 | &mut height, | |
| 94 | &mut fps, | |
| 95 | &mut nb_frames, | |
| 96 | ) | |
| 97 | }; | |
| 98 | if ptr.is_null() || width == 0 || height == 0 { | |
| 99 | if !ptr.is_null() { | |
| 100 | unsafe { av_ffi::av_video_close(ptr) }; | |
| 101 | } | |
| 102 | return None; | |
| 103 | } | |
| 104 | Some(Self { | |
| 105 | ptr, | |
| 106 | info: VideoInfo { | |
| 107 | width, | |
| 108 | height, | |
| 109 | fps: if fps > 0.0 { fps } else { 30.0 }, | |
| 110 | nb_frames, | |
| 111 | }, | |
| 112 | }) | |
| 113 | } | |
| 114 | } | |
| 115 | ||
| 116 | #[cfg(target_os = "macos")] | |
| 117 | impl VideoDecoder for AvFoundationDecoder { | |
| 118 | fn info(&self) -> VideoInfo { | |
| 119 | self.info | |
| 120 | } | |
| 121 | ||
| 122 | fn decode_frame(&mut self, frame_idx: i64) -> Option<Vec<u8>> { | |
| 123 | let len = (self.info.width as usize) | |
| 124 | .checked_mul(self.info.height as usize)? | |
| 125 | .checked_mul(4)?; | |
| 126 | let mut buf = vec![0u8; len]; | |
| 127 | let ok = unsafe { | |
| 128 | av_ffi::av_video_decode_frame(self.ptr, frame_idx.max(0), buf.as_mut_ptr(), len) | |
| 129 | }; | |
| 130 | if ok != 0 { | |
| 131 | Some(buf) | |
| 132 | } else { | |
| 133 | None | |
| 134 | } | |
| 135 | } | |
| 136 | ||
| 137 | fn backend_name(&self) -> &'static str { | |
| 138 | "AVFoundation/VideoToolbox" | |
| 139 | } | |
| 140 | } | |
| 141 | ||
| 142 | pub struct FfmpegDecoder { | |
| 143 | path: PathBuf, | |
| 144 | info: VideoInfo, | |
| 145 | } | |
| 146 | ||
| 147 | impl FfmpegDecoder { | |
| 148 | pub fn open(path: &Path) -> Option<Self> { | |
| 149 | let info = probe_video(path)?; | |
| 150 | Some(Self { | |
| 151 | path: path.to_path_buf(), | |
| 152 | info, | |
| 153 | }) | |
| 154 | } | |
| 155 | } | |
| 156 | ||
| 157 | impl VideoDecoder for FfmpegDecoder { | |
| 158 | fn info(&self) -> VideoInfo { | |
| 159 | self.info | |
| 160 | } | |
| 161 | ||
| 162 | fn decode_frame(&mut self, frame_idx: i64) -> Option<Vec<u8>> { | |
| 163 | decode_video_frame(&self.path, self.info, frame_idx) | |
| 164 | } | |
| 165 | ||
| 166 | fn backend_name(&self) -> &'static str { | |
| 167 | "ffmpeg" | |
| 168 | } | |
| 169 | } | |
| 170 | ||
| 171 | /// Opens a hardware-accelerated video decoder (`AVFoundation`/`VideoToolbox` on macOS), | |
| 172 | /// falling back to `ffmpeg` for unsupported containers or codecs. | |
| 173 | pub fn open_video_decoder(path: &Path) -> Option<Box<dyn VideoDecoder>> { | |
| 174 | #[cfg(target_os = "macos")] | |
| 175 | { | |
| 176 | if let Some(av) = AvFoundationDecoder::open(path) { | |
| 177 | return Some(Box::new(av)); | |
| 178 | } | |
| 179 | } | |
| 180 | FfmpegDecoder::open(path).map(|ff| Box::new(ff) as Box<dyn VideoDecoder>) | |
| 23 | 181 | } |
| 24 | 182 | |
| 25 | 183 | fn is_video_path(path: &Path) -> bool { |
| ... | ... | @@ -199,7 +357,7 @@ fn decode_exr_rgba( |
| 199 | 357 | |
| 200 | 358 | pub struct MediaCache { |
| 201 | 359 | images: HashMap<(PathBuf, i64), DecodedImage>, |
| 202 | video_info: HashMap<PathBuf, Option<VideoInfo>>, | |
| 360 | video_decoders: HashMap<PathBuf, Option<Box<dyn VideoDecoder>>>, | |
| 203 | 361 | total_bytes: u64, |
| 204 | 362 | budget_bytes: u64, |
| 205 | 363 | lru: HashMap<(PathBuf, i64), u64>, |
| ... | ... | @@ -210,7 +368,7 @@ impl MediaCache { |
| 210 | 368 | pub fn new(budget_mb: u64) -> Self { |
| 211 | 369 | Self { |
| 212 | 370 | images: HashMap::new(), |
| 213 | video_info: HashMap::new(), | |
| 371 | video_decoders: HashMap::new(), | |
| 214 | 372 | total_bytes: 0, |
| 215 | 373 | budget_bytes: budget_mb * 1024 * 1024, |
| 216 | 374 | lru: HashMap::new(), |
| ... | ... | @@ -275,12 +433,12 @@ impl MediaCache { |
| 275 | 433 | } |
| 276 | 434 | } |
| 277 | 435 | let base_buf = base.to_path_buf(); |
| 278 | let info = if let Some(cached) = self.video_info.get(&base_buf).copied() { | |
| 279 | cached? | |
| 280 | } else { | |
| 281 | let probed = probe_video(base); | |
| 282 | self.video_info.insert(base_buf.clone(), probed); | |
| 283 | probed? | |
| 436 | let info = { | |
| 437 | let entry = self | |
| 438 | .video_decoders | |
| 439 | .entry(base_buf.clone()) | |
| 440 | .or_insert_with(|| open_video_decoder(base)); | |
| 441 | entry.as_ref()?.info() | |
| 284 | 442 | }; |
| 285 | 443 | |
| 286 | 444 | let len = clip.length.unwrap_or(info.nb_frames.max(1)).max(1); |
| ... | ... | @@ -306,7 +464,11 @@ impl MediaCache { |
| 306 | 464 | self.lru.insert(cache_key, self.tick); |
| 307 | 465 | return Some((base_buf, idx, img, false)); |
| 308 | 466 | } |
| 309 | let raw = decode_video_frame(base, info, idx)?; | |
| 467 | let raw = self | |
| 468 | .video_decoders | |
| 469 | .get_mut(&base_buf) | |
| 470 | .and_then(|d| d.as_mut())? | |
| 471 | .decode_frame(idx)?; | |
| 310 | 472 | let decoded = DecodedImage { |
| 311 | 473 | size: [info.width, info.height], |
| 312 | 474 | rgba: Arc::new(raw), |
| ... | ... | @@ -656,3 +818,128 @@ pub fn rasterize_polyline_mask( |
| 656 | 818 | } |
| 657 | 819 | out |
| 658 | 820 | } |
| 821 | ||
| 822 | #[cfg(test)] | |
| 823 | mod tests { | |
| 824 | use super::*; | |
| 825 | use std::time::Instant; | |
| 826 | ||
| 827 | fn mean_abs_error_rgb(a: &[u8], b: &[u8]) -> f64 { | |
| 828 | assert_eq!(a.len(), b.len()); | |
| 829 | let mut sum = 0u64; | |
| 830 | let mut count = 0u64; | |
| 831 | for (pa, pb) in a.chunks_exact(4).zip(b.chunks_exact(4)) { | |
| 832 | sum += pa[0].abs_diff(pb[0]) as u64; | |
| 833 | sum += pa[1].abs_diff(pb[1]) as u64; | |
| 834 | sum += pa[2].abs_diff(pb[2]) as u64; | |
| 835 | count += 3; | |
| 836 | } | |
| 837 | if count == 0 { | |
| 838 | 0.0 | |
| 839 | } else { | |
| 840 | sum as f64 / count as f64 | |
| 841 | } | |
| 842 | } | |
| 843 | ||
| 844 | fn verify_clip_matches_ffmpeg(path: &Path) { | |
| 845 | let mut dec = open_video_decoder(path).expect("open_video_decoder failed"); | |
| 846 | let mut ff = FfmpegDecoder::open(path).expect("FfmpegDecoder::open failed"); | |
| 847 | ||
| 848 | #[cfg(target_os = "macos")] | |
| 849 | assert_eq!( | |
| 850 | dec.backend_name(), | |
| 851 | "AVFoundation/VideoToolbox", | |
| 852 | "expected AVFoundation backend for {}", | |
| 853 | path.display() | |
| 854 | ); | |
| 855 | ||
| 856 | let av_info = dec.info(); | |
| 857 | let ff_info = ff.info(); | |
| 858 | assert_eq!(av_info.width, ff_info.width, "width mismatch for {}", path.display()); | |
| 859 | assert_eq!(av_info.height, ff_info.height, "height mismatch for {}", path.display()); | |
| 860 | assert!( | |
| 861 | (av_info.fps - ff_info.fps).abs() < 0.2, | |
| 862 | "fps mismatch for {}: av={} ff={}", | |
| 863 | path.display(), | |
| 864 | av_info.fps, | |
| 865 | ff_info.fps | |
| 866 | ); | |
| 867 | ||
| 868 | let frames = [0_i64, 1, 2, 10, 0]; | |
| 869 | let mut total_ms = 0.0; | |
| 870 | for &f in &frames { | |
| 871 | let t0 = Instant::now(); | |
| 872 | let av_px = dec | |
| 873 | .decode_frame(f) | |
| 874 | .unwrap_or_else(|| panic!("av decode frame {f} failed for {}", path.display())); | |
| 875 | let elapsed_ms = t0.elapsed().as_secs_f64() * 1000.0; | |
| 876 | total_ms += elapsed_ms; | |
| 877 | ||
| 878 | let ff_px = ff | |
| 879 | .decode_frame(f) | |
| 880 | .unwrap_or_else(|| panic!("ffmpeg decode frame {f} failed for {}", path.display())); | |
| 881 | let mae = mean_abs_error_rgb(&av_px, &ff_px); | |
| 882 | eprintln!( | |
| 883 | "[video-test] {} ({}x{} @{:.2}fps) frame {}: {:.2} ms, MAE vs ffmpeg = {:.2}", | |
| 884 | path.file_name().and_then(|s| s.to_str()).unwrap_or("clip"), | |
| 885 | av_info.width, | |
| 886 | av_info.height, | |
| 887 | av_info.fps, | |
| 888 | f, | |
| 889 | elapsed_ms, | |
| 890 | mae | |
| 891 | ); | |
| 892 | // Allow small YUV->RGB matrix/rounding differences between VideoToolbox and swscale. | |
| 893 | assert!( | |
| 894 | mae < 12.0, | |
| 895 | "high MAE ({mae:.2}) on {} frame {f} (possible orientation or PTS mismatch)", | |
| 896 | path.display() | |
| 897 | ); | |
| 898 | } | |
| 899 | eprintln!( | |
| 900 | "[video-test] {} avg decode: {:.2} ms/frame", | |
| 901 | path.file_name().and_then(|s| s.to_str()).unwrap_or("clip"), | |
| 902 | total_ms / frames.len() as f64 | |
| 903 | ); | |
| 904 | } | |
| 905 | ||
| 906 | #[test] | |
| 907 | fn test_video_decoder_real_mov_clips() { | |
| 908 | let clips = [ | |
| 909 | Path::new("/Volumes/Project/trees/EncodedMedia/A001_11071331_C002_4873-4988_d8716e17.mov"), | |
| 910 | Path::new("/Volumes/Project/trees/EncodedMedia/IMG_1767_2395-2547_7efe6416.mov"), | |
| 911 | ]; | |
| 912 | for clip in clips { | |
| 913 | if clip.exists() { | |
| 914 | verify_clip_matches_ffmpeg(clip); | |
| 915 | } | |
| 916 | } | |
| 917 | } | |
| 918 | ||
| 919 | #[test] | |
| 920 | fn test_video_decoder_synthetic_mp4() { | |
| 921 | let tmp = std::env::temp_dir().join("engine_test_synth_video.mp4"); | |
| 922 | let status = Command::new("ffmpeg") | |
| 923 | .args([ | |
| 924 | "-y", | |
| 925 | "-v", | |
| 926 | "error", | |
| 927 | "-f", | |
| 928 | "lavfi", | |
| 929 | "-i", | |
| 930 | "testsrc2=size=320x180:rate=24:duration=1.0", | |
| 931 | "-c:v", | |
| 932 | "libx264", | |
| 933 | "-pix_fmt", | |
| 934 | "yuv420p", | |
| 935 | ]) | |
| 936 | .arg(&tmp) | |
| 937 | .status(); | |
| 938 | if let Ok(st) = status { | |
| 939 | if st.success() { | |
| 940 | verify_clip_matches_ffmpeg(&tmp); | |
| 941 | let _ = std::fs::remove_file(&tmp); | |
| 942 | } | |
| 943 | } | |
| 944 | } | |
| 945 | } |
crates/flow/src/lib.rs+70-6| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | //! - `1`/`2` multi-viewer routing, `Cmd+F` / Numpad `.` fit-to-view, `P` bypass, drag-onto-wire insert. |
| 7 | 7 | |
| 8 | 8 | use draw::{Glyphs, PathStyle, Primitive}; |
| 9 | use model::{Comp, NodeId, PortRole, default_main_input_port}; | |
| 9 | use model::{Comp, NodeId, PortRole, default_main_input_port, is_supported_tool}; | |
| 10 | 10 | use std::collections::{HashMap, HashSet}; |
| 11 | 11 | use std::sync::Arc; |
| 12 | 12 | use winit::event::{ElementState, MouseButton}; |
| ... | ... | @@ -740,6 +740,12 @@ impl FlowView { |
| 740 | 740 | weight: 500, |
| 741 | 741 | italic: false, |
| 742 | 742 | }; |
| 743 | let tiny_font = text::Font { | |
| 744 | families: Arc::from([text::Family::Mono]), | |
| 745 | size: 7.5, | |
| 746 | weight: 600, | |
| 747 | italic: false, | |
| 748 | }; | |
| 743 | 749 | let make_layout = |s: &str, font: &text::Font| { |
| 744 | 750 | let styles = [text::Style::new(font.clone())]; |
| 745 | 751 | text::Paragraph { |
| ... | ... | @@ -758,8 +764,11 @@ impl FlowView { |
| 758 | 764 | for n in &comp.nodes { |
| 759 | 765 | self.label_cache.entry(n.name.clone()).or_insert_with(|| make_layout(&n.name, &label_font)); |
| 760 | 766 | } |
| 767 | self.badge_cache | |
| 768 | .entry("preserved".to_owned()) | |
| 769 | .or_insert_with(|| make_layout("preserved", &tiny_font)); | |
| 761 | 770 | for key in [ |
| 762 | "G: Grab R: Rotate S: Scale X/Y: Axis 1/2: Viewer `: Clear P: Bypass Cmd+F / Num.: Fit Scroll: Zoom", | |
| 771 | "G: Grab R: Rotate S: Scale X/Y: Axis 1/2: Viewer `: Clear P: Bypass Cmd+S: Save Cmd+Shift+R: Export Cmd+F: Fit", | |
| 763 | 772 | "GRAB [LMB/Enter confirm, RMB/Esc cancel, X/Y axis]", |
| 764 | 773 | "ROTATE [LMB/Enter confirm, RMB/Esc cancel]", |
| 765 | 774 | "SCALE [LMB/Enter confirm, RMB/Esc cancel, X/Y axis]", |
| ... | ... | @@ -928,7 +937,12 @@ impl FlowView { |
| 928 | 937 | let hovered = self.hovered_node == Some(n.id); |
| 929 | 938 | let v1 = self.viewed_nodes[0] == Some(n.id); |
| 930 | 939 | let v2 = self.viewed_nodes[1] == Some(n.id); |
| 931 | let accent = node_accent(&n.kind); | |
| 940 | let supported = is_supported_tool(&n.kind); | |
| 941 | let accent = if supported { | |
| 942 | node_accent(&n.kind) | |
| 943 | } else { | |
| 944 | [0.92, 0.64, 0.24, 1.0] | |
| 945 | }; | |
| 932 | 946 | |
| 933 | 947 | let bg = if n.bypassed { |
| 934 | 948 | [self.palette.node_fill[0] * 0.6, self.palette.node_fill[1] * 0.6, self.palette.node_fill[2] * 0.6, 0.65] |
| ... | ... | @@ -936,6 +950,13 @@ impl FlowView { |
| 936 | 950 | self.palette.node_selected |
| 937 | 951 | } else if hovered { |
| 938 | 952 | self.palette.node_hover |
| 953 | } else if !supported { | |
| 954 | [ | |
| 955 | (self.palette.node_fill[0] + 0.035).min(1.0), | |
| 956 | (self.palette.node_fill[1] + 0.020).min(1.0), | |
| 957 | self.palette.node_fill[2], | |
| 958 | 1.0, | |
| 959 | ] | |
| 939 | 960 | } else { |
| 940 | 961 | self.palette.node_fill |
| 941 | 962 | }; |
| ... | ... | @@ -950,20 +971,35 @@ impl FlowView { |
| 950 | 971 | color: if n.bypassed { [0.28, 0.28, 0.32, 0.6] } else { accent }, |
| 951 | 972 | }); |
| 952 | 973 | |
| 953 | // Crisp border | |
| 974 | // Crisp border (amber accent for preserved/passthrough unknown nodes) | |
| 954 | 975 | let border_col = if primary { |
| 955 | 976 | [0.98, 0.78, 0.30, 1.0] |
| 956 | 977 | } else if sel { |
| 957 | 978 | self.palette.accent |
| 979 | } else if !supported { | |
| 980 | [0.92, 0.64, 0.24, 0.85] | |
| 958 | 981 | } else { |
| 959 | 982 | self.palette.node_border |
| 960 | 983 | }; |
| 961 | 984 | out.push(Primitive::RoundedRect { |
| 962 | 985 | rect: r, |
| 963 | 986 | radius, |
| 964 | stroke: Some(if sel || primary { 1.4 } else { 0.9 }), | |
| 987 | stroke: Some(if sel || primary { 1.4 } else if !supported { 1.15 } else { 0.9 }), | |
| 965 | 988 | color: border_col, |
| 966 | 989 | }); |
| 990 | // Subtle top dashed ticks for preserved/passthrough unknown nodes | |
| 991 | if !supported && self.zoom >= 0.45 { | |
| 992 | let mut tx = r[0] + 5.0; | |
| 993 | while tx + 4.0 < r[2] - 4.0 { | |
| 994 | out.push(Primitive::Segment { | |
| 995 | from: [tx, r[1] + 0.8], | |
| 996 | to: [(tx + 4.0).min(r[2] - 4.0), r[1] + 0.8], | |
| 997 | width: 1.2, | |
| 998 | color: [0.96, 0.72, 0.30, 0.90], | |
| 999 | }); | |
| 1000 | tx += 8.0; | |
| 1001 | } | |
| 1002 | } | |
| 967 | 1003 | |
| 968 | 1004 | // Node label centered cleanly inside thin bar |
| 969 | 1005 | if self.zoom >= 0.42 { |
| ... | ... | @@ -980,6 +1016,34 @@ impl FlowView { |
| 980 | 1016 | } |
| 981 | 1017 | } |
| 982 | 1018 | |
| 1019 | // Preserved/passthrough pill badge underneath bottom-right for unknown/OFX nodes | |
| 1020 | if !supported && self.zoom >= 0.50 { | |
| 1021 | if let Some(badge) = self.badge_cache.get("preserved") { | |
| 1022 | let bw = 46.0; | |
| 1023 | let bh = 10.5; | |
| 1024 | let bx = (r[2] - bw).max(r[0] + 28.0); | |
| 1025 | let by = r[3] + 1.5; | |
| 1026 | out.push(Primitive::RoundedRect { | |
| 1027 | rect: [bx, by, bx + bw, by + bh], | |
| 1028 | radius: 3.0, | |
| 1029 | stroke: None, | |
| 1030 | color: [0.14, 0.10, 0.05, 0.92], | |
| 1031 | }); | |
| 1032 | out.push(Primitive::RoundedRect { | |
| 1033 | rect: [bx, by, bx + bw, by + bh], | |
| 1034 | radius: 3.0, | |
| 1035 | stroke: Some(0.8), | |
| 1036 | color: [0.92, 0.64, 0.24, 0.72], | |
| 1037 | }); | |
| 1038 | out.push(Primitive::Text { | |
| 1039 | text: badge as &dyn Glyphs, | |
| 1040 | origin: [bx + 4.0, by + 1.0], | |
| 1041 | clip: Some([bx + 2.0, by, bx + bw - 2.0, by + bh]), | |
| 1042 | ink: [0.98, 0.78, 0.40, 1.0], | |
| 1043 | }); | |
| 1044 | } | |
| 1045 | } | |
| 1046 | ||
| 983 | 1047 | // Fusion-style tiny viewer indicator pill underneath bottom-left (`● ○` for Viewer 1 / Viewer 2!) |
| 984 | 1048 | if v1 || v2 { |
| 985 | 1049 | let pw = 22.0; |
| ... | ... | @@ -1044,7 +1108,7 @@ impl FlowView { |
| 1044 | 1108 | Some(TransformMode::Grab) => "GRAB [LMB/Enter confirm, RMB/Esc cancel, X/Y axis]", |
| 1045 | 1109 | Some(TransformMode::Rotate) => "ROTATE [LMB/Enter confirm, RMB/Esc cancel]", |
| 1046 | 1110 | Some(TransformMode::Scale) => "SCALE [LMB/Enter confirm, RMB/Esc cancel, X/Y axis]", |
| 1047 | None => "G: Grab R: Rotate S: Scale X/Y: Axis 1/2: Viewer `: Clear P: Bypass Cmd+F / Num.: Fit Scroll: Zoom", | |
| 1111 | None => "G: Grab R: Rotate S: Scale X/Y: Axis 1/2: Viewer `: Clear P: Bypass Cmd+S: Save Cmd+Shift+R: Export Cmd+F: Fit", | |
| 1048 | 1112 | }; |
| 1049 | 1113 | if let Some(l) = self.badge_cache.get(hud_key) { |
| 1050 | 1114 | let pill_h = 20.0; |
crates/model/src/comp.rs+694-5| ... | ... | @@ -47,18 +47,153 @@ pub enum PortRole { |
| 47 | 47 | |
| 48 | 48 | impl PortRole { |
| 49 | 49 | pub fn from_input_name(name: &str) -> Self { |
| 50 | if name.starts_with("SceneInput") { | |
| 51 | return Self::Scene3D; | |
| 52 | } | |
| 50 | 53 | match name { |
| 51 | "EffectMask" | "GarbageMatte" | "SolidMatte" | "Mask" => Self::Mask, | |
| 52 | "Foreground" | "Image2" => Self::Foreground, | |
| 53 | "SceneInput" | "SceneInput1" | "SceneInput2" | "SceneInput3" | "SceneInput4" => { | |
| 54 | Self::Scene3D | |
| 54 | "EffectMask" | "GarbageMatte" | "SolidMatte" | "Mask" | "TrackingMask" | "RegionMask" => { | |
| 55 | Self::Mask | |
| 56 | } | |
| 57 | "Foreground" | "Image2" | "Overlay" | "ReplaceImage" => Self::Foreground, | |
| 58 | "Background" | "Input" | "Image" | "Image1" | "Source" | "MainInput1" => { | |
| 59 | Self::Background | |
| 55 | 60 | } |
| 56 | "Background" | "Input" | "Image" | "Image1" => Self::Background, | |
| 57 | 61 | _ => Self::Aux, |
| 58 | 62 | } |
| 59 | 63 | } |
| 60 | 64 | } |
| 61 | 65 | |
| 66 | /// Canonical registry of Fusion tool classes evaluated natively by the engine. | |
| 67 | pub fn is_supported_tool(kind: &str) -> bool { | |
| 68 | matches!( | |
| 69 | kind, | |
| 70 | // Routing / Utility | |
| 71 | "Saver" | |
| 72 | | "PipeRouter" | |
| 73 | | "Fuse.Wireless" | |
| 74 | | "Tracker" | |
| 75 | | "MacroOperator" | |
| 76 | | "GroupOperator" | |
| 77 | | "TimeStretcher" | |
| 78 | | "TimeSpeed" | |
| 79 | | "Switch" | |
| 80 | | "Fuse.Switch" | |
| 81 | | "Note" | |
| 82 | | "Underlay" | |
| 83 | | "StickyNote" | |
| 84 | // 2D tools | |
| 85 | | "Loader" | |
| 86 | | "Background" | |
| 87 | | "Merge" | |
| 88 | | "Dissolve" | |
| 89 | | "Transform" | |
| 90 | | "CameraShake" | |
| 91 | | "CornerPositioner" | |
| 92 | | "DVE" | |
| 93 | | "Shadow" | |
| 94 | | "Scale" | |
| 95 | | "BetterResize" | |
| 96 | | "Crop" | |
| 97 | | "SetDomain" | |
| 98 | | "ChangeDepth" | |
| 99 | | "BrightnessContrast" | |
| 100 | | "ColorCorrector" | |
| 101 | | "ColorGain" | |
| 102 | | "ColorCurves" | |
| 103 | | "HueCurves" | |
| 104 | | "GamutConvert" | |
| 105 | | "InvertColor" | |
| 106 | | "ChannelBoolean" | |
| 107 | | "LumaKeyer" | |
| 108 | | "UltraKeyer" | |
| 109 | | "Blur" | |
| 110 | | "Sharpen" | |
| 111 | | "Filter" | |
| 112 | | "VariBlur" | |
| 113 | | "DirectionalBlur" | |
| 114 | | "Glow" | |
| 115 | | "SoftGlow" | |
| 116 | | "Fuse.XGlow" | |
| 117 | | "ErodeDilate" | |
| 118 | | "FastNoise" | |
| 119 | | "Plasma" | |
| 120 | | "FilmGrain" | |
| 121 | | "Displace" | |
| 122 | | "EllipseMask" | |
| 123 | | "RectangleMask" | |
| 124 | | "PolylineMask" | |
| 125 | | "BitmapMask" | |
| 126 | | "TextPlus" | |
| 127 | | "Fuse.Colorize" | |
| 128 | | "Fuse.Outline" | |
| 129 | | "Fuse.XfChroma" | |
| 130 | | "Custom" | |
| 131 | // 3D tools | |
| 132 | | "Renderer3D" | |
| 133 | | "Merge3D" | |
| 134 | | "Transform3D" | |
| 135 | | "Camera3D" | |
| 136 | | "ImagePlane3D" | |
| 137 | | "Shape3D" | |
| 138 | | "LightAmbient" | |
| 139 | | "LightDirectional" | |
| 140 | ) | |
| 141 | } | |
| 142 | ||
| 143 | /// Metadata extracted from a Fusion `Saver` node. | |
| 144 | #[derive(Clone, Debug, PartialEq)] | |
| 145 | pub struct SaverSpec { | |
| 146 | pub node_id: NodeId, | |
| 147 | pub name: String, | |
| 148 | pub upstream: Option<NodeId>, | |
| 149 | pub filename: String, | |
| 150 | pub range: [i64; 2], | |
| 151 | pub sequence_start: Option<i64>, | |
| 152 | } | |
| 153 | ||
| 154 | impl SaverSpec { | |
| 155 | /// Computes the output path for `frame` following Fusion's Saver sequence naming rules: | |
| 156 | /// - `foo_0000.png` -> `foo_{frame:04}.png` (preserving digit width) | |
| 157 | /// - `0000.png` -> `{frame:04}.png` | |
| 158 | /// - `render.png` -> `render{frame:04}.png` (4-digit default when no trailing digits exist) | |
| 159 | pub fn frame_path(&self, frame: i64) -> PathBuf { | |
| 160 | let effective_frame = if let Some(start) = self.sequence_start { | |
| 161 | start + (frame - self.range[0]) | |
| 162 | } else { | |
| 163 | frame | |
| 164 | }; | |
| 165 | ||
| 166 | let path = Path::new(&self.filename); | |
| 167 | let parent = path.parent().unwrap_or_else(|| Path::new("")); | |
| 168 | let fname = path.file_name().and_then(|s| s.to_str()).unwrap_or(""); | |
| 169 | ||
| 170 | let (stem, ext) = match fname.rfind('.') { | |
| 171 | Some(dot) => (&fname[..dot], &fname[dot..]), | |
| 172 | None => (fname, ""), | |
| 173 | }; | |
| 174 | ||
| 175 | let digit_start = stem | |
| 176 | .rfind(|c: char| !c.is_ascii_digit()) | |
| 177 | .map_or(0, |idx| idx + 1); | |
| 178 | let prefix = &stem[..digit_start]; | |
| 179 | let digits = &stem[digit_start..]; | |
| 180 | let width = if digits.is_empty() { 4 } else { digits.len() }; | |
| 181 | ||
| 182 | let formatted_num = if effective_frame < 0 { | |
| 183 | format!("-{:0width$}", effective_frame.unsigned_abs()) | |
| 184 | } else { | |
| 185 | format!("{effective_frame:0width$}") | |
| 186 | }; | |
| 187 | ||
| 188 | let out_name = format!("{prefix}{formatted_num}{ext}"); | |
| 189 | if parent.as_os_str().is_empty() { | |
| 190 | PathBuf::from(out_name) | |
| 191 | } else { | |
| 192 | parent.join(out_name) | |
| 193 | } | |
| 194 | } | |
| 195 | } | |
| 196 | ||
| 62 | 197 | #[derive(Clone, Debug, PartialEq)] |
| 63 | 198 | pub enum ParamValue { |
| 64 | 199 | Number(f64), |
| ... | ... | @@ -219,6 +354,8 @@ pub struct Comp { |
| 219 | 354 | pub text_cls: HashMap<String, Vec<ClsEntry>>, |
| 220 | 355 | /// Procedural `Shake` modifiers keyed by modifier name (e.g. `"Shake1"`). |
| 221 | 356 | pub shakes: HashMap<String, ShakeModifier>, |
| 357 | /// Preserved raw root `Composition { ... }` Lua AST for lossless `.comp` roundtrip. | |
| 358 | pub raw_root: Option<LuaTable>, | |
| 222 | 359 | /// Generation counter incremented whenever any node, wire, or spline mutates. |
| 223 | 360 | pub revision: u64, |
| 224 | 361 | } |
| ... | ... | @@ -462,6 +599,7 @@ impl Comp { |
| 462 | 599 | polyline_splines, |
| 463 | 600 | text_cls, |
| 464 | 601 | shakes, |
| 602 | raw_root: Some(root.clone()), | |
| 465 | 603 | revision: 1, |
| 466 | 604 | }) |
| 467 | 605 | } |
| ... | ... | @@ -944,6 +1082,557 @@ impl Comp { |
| 944 | 1082 | self.nodes[id.0].bypassed = !self.nodes[id.0].bypassed; |
| 945 | 1083 | self.revision += 1; |
| 946 | 1084 | } |
| 1085 | ||
| 1086 | /// Extracts metadata for every top-level (non-internal) `Saver` node in this comp. | |
| 1087 | pub fn savers(&self) -> Vec<SaverSpec> { | |
| 1088 | let mut out = Vec::new(); | |
| 1089 | for n in &self.nodes { | |
| 1090 | if n.internal || n.kind != "Saver" { | |
| 1091 | continue; | |
| 1092 | } | |
| 1093 | let upstream = n.connected_node("Input").and_then(|src| self.find_node(src)); | |
| 1094 | let filename = n | |
| 1095 | .clips | |
| 1096 | .first() | |
| 1097 | .map(|c| c.filename.clone()) | |
| 1098 | .or_else(|| { | |
| 1099 | n.raw | |
| 1100 | .get_table("Inputs") | |
| 1101 | .and_then(|i| i.get_table("Clip")) | |
| 1102 | .and_then(|c| c.get_table("Value")) | |
| 1103 | .and_then(|v| v.get_str("Filename")) | |
| 1104 | .map(str::to_owned) | |
| 1105 | }) | |
| 1106 | .unwrap_or_default(); | |
| 1107 | let set_seq = n.static_number("SetSequenceStart").map(|v| v > 0.5); | |
| 1108 | let sequence_start = if set_seq == Some(true) { | |
| 1109 | n.static_number("SequenceStartFrame").map(|v| v.round() as i64) | |
| 1110 | } else { | |
| 1111 | None | |
| 1112 | }; | |
| 1113 | out.push(SaverSpec { | |
| 1114 | node_id: n.id, | |
| 1115 | name: n.name.clone(), | |
| 1116 | upstream, | |
| 1117 | filename, | |
| 1118 | range: self.render_range, | |
| 1119 | sequence_start, | |
| 1120 | }); | |
| 1121 | } | |
| 1122 | out | |
| 1123 | } | |
| 1124 | ||
| 1125 | /// Synchronizes current comp state (metadata, node positions/bypass/inputs, spline edits, | |
| 1126 | /// added/removed flow nodes) back onto a cloned raw Fusion `Composition { ... }` AST, | |
| 1127 | /// preserving all unknown nodes, modifiers, macros, UserControls, Clips, and metadata verbatim. | |
| 1128 | pub fn sync_to_raw_ast(&self) -> LuaTable { | |
| 1129 | let mut root = self.raw_root.clone().unwrap_or_else(|| LuaTable { | |
| 1130 | tag: Some("Composition".to_owned()), | |
| 1131 | entries: Vec::new(), | |
| 1132 | }); | |
| 1133 | ||
| 1134 | root.set( | |
| 1135 | LuaKey::Str("CurrentTime".to_owned()), | |
| 1136 | LuaValue::Number(self.current_time), | |
| 1137 | ); | |
| 1138 | root.set( | |
| 1139 | LuaKey::Str("GlobalRange".to_owned()), | |
| 1140 | vec2_lua(self.global_range[0] as f64, self.global_range[1] as f64), | |
| 1141 | ); | |
| 1142 | root.set( | |
| 1143 | LuaKey::Str("RenderRange".to_owned()), | |
| 1144 | vec2_lua(self.render_range[0] as f64, self.render_range[1] as f64), | |
| 1145 | ); | |
| 1146 | if let Some(ref af) = self.audio_filename { | |
| 1147 | root.set( | |
| 1148 | LuaKey::Str("AudioFilename".to_owned()), | |
| 1149 | LuaValue::String(af.clone()), | |
| 1150 | ); | |
| 1151 | } | |
| 1152 | if self.audio_offset != 0.0 || root.get("AudioOffset").is_some() { | |
| 1153 | root.set( | |
| 1154 | LuaKey::Str("AudioOffset".to_owned()), | |
| 1155 | LuaValue::Number(self.audio_offset), | |
| 1156 | ); | |
| 1157 | } | |
| 1158 | ||
| 1159 | // Update Prefs.Comp.FrameFormat (Width, Height, Rate, DepthFull) | |
| 1160 | { | |
| 1161 | let prefs = ensure_table_mut(&mut root, "Prefs", None); | |
| 1162 | let comp_prefs = ensure_table_mut(prefs, "Comp", None); | |
| 1163 | let ff = ensure_table_mut(comp_prefs, "FrameFormat", None); | |
| 1164 | if ff.get_f64("Width").map(|w| w.round().max(1.0) as u32) != Some(self.width) { | |
| 1165 | ff.set(LuaKey::Str("Width".to_owned()), LuaValue::Number(self.width as f64)); | |
| 1166 | } | |
| 1167 | if ff.get_f64("Height").map(|h| h.round().max(1.0) as u32) != Some(self.height) { | |
| 1168 | ff.set(LuaKey::Str("Height".to_owned()), LuaValue::Number(self.height as f64)); | |
| 1169 | } | |
| 1170 | if ff.get_f64("Rate").is_none_or(|r| (r - self.fps).abs() > 1e-9) { | |
| 1171 | ff.set(LuaKey::Str("Rate".to_owned()), LuaValue::Number(self.fps)); | |
| 1172 | } | |
| 1173 | let existing_depth = ff | |
| 1174 | .get_f64("DepthFull") | |
| 1175 | .and_then(|v| BitDepth::from_fusion_depth(v.round() as i32)) | |
| 1176 | .unwrap_or(BitDepth::Int8); | |
| 1177 | if existing_depth != self.depth_full { | |
| 1178 | ff.set( | |
| 1179 | LuaKey::Str("DepthFull".to_owned()), | |
| 1180 | LuaValue::Number((self.depth_full as i32) as f64), | |
| 1181 | ); | |
| 1182 | } | |
| 1183 | } | |
| 1184 | ||
| 1185 | // Sync Tools | |
| 1186 | let tools = ensure_table_mut(&mut root, "Tools", Some("ordered")); | |
| 1187 | ||
| 1188 | // Remove top-level flow nodes that were deleted from `self.nodes`, | |
| 1189 | // while NEVER removing modifiers or any node still present in `self.nodes`. | |
| 1190 | let live_flow_names: HashSet<&str> = self | |
| 1191 | .nodes | |
| 1192 | .iter() | |
| 1193 | .filter(|n| !n.internal) | |
| 1194 | .map(|n| n.name.as_str()) | |
| 1195 | .collect(); | |
| 1196 | tools.entries.retain(|(k, v)| { | |
| 1197 | let LuaKey::Str(name) = k else { return true }; | |
| 1198 | let Some(tbl) = v.as_table() else { return true }; | |
| 1199 | let kind = tbl.tag.as_deref().unwrap_or("Unknown"); | |
| 1200 | if is_modifier_type(kind) { | |
| 1201 | true | |
| 1202 | } else { | |
| 1203 | live_flow_names.contains(name.as_str()) | |
| 1204 | } | |
| 1205 | }); | |
| 1206 | ||
| 1207 | // Sync each visible (non-internal) flow node | |
| 1208 | for node in &self.nodes { | |
| 1209 | if node.internal { | |
| 1210 | continue; | |
| 1211 | } | |
| 1212 | if tools.get_table(&node.name).is_none() { | |
| 1213 | let mut new_tbl = if node.raw.tag.is_some() { | |
| 1214 | node.raw.clone() | |
| 1215 | } else { | |
| 1216 | LuaTable { | |
| 1217 | tag: Some(node.kind.clone()), | |
| 1218 | entries: Vec::new(), | |
| 1219 | } | |
| 1220 | }; | |
| 1221 | if new_tbl.tag.is_none() { | |
| 1222 | new_tbl.tag = Some(node.kind.clone()); | |
| 1223 | } | |
| 1224 | tools.set(LuaKey::Str(node.name.clone()), LuaValue::Table(new_tbl)); | |
| 1225 | } | |
| 1226 | ||
| 1227 | let Some(tool_tbl) = tools.get_table_mut(&node.name) else { | |
| 1228 | continue; | |
| 1229 | }; | |
| 1230 | ||
| 1231 | // ViewInfo.Pos | |
| 1232 | if let Some(vi) = tool_tbl.get_table_mut("ViewInfo") { | |
| 1233 | let pos_changed = vi | |
| 1234 | .get_table("Pos") | |
| 1235 | .and_then(read_vec2) | |
| 1236 | .is_none_or(|[x, y]| { | |
| 1237 | (x as f32 - node.pos[0]).abs() > 1e-4 | |
| 1238 | || (y as f32 - node.pos[1]).abs() > 1e-4 | |
| 1239 | }); | |
| 1240 | if pos_changed { | |
| 1241 | vi.set( | |
| 1242 | LuaKey::Str("Pos".to_owned()), | |
| 1243 | vec2_lua(node.pos[0] as f64, node.pos[1] as f64), | |
| 1244 | ); | |
| 1245 | } | |
| 1246 | } else if node.pos[0] != 0.0 || node.pos[1] != 0.0 { | |
| 1247 | let mut vi = LuaTable { | |
| 1248 | tag: Some("OperatorInfo".to_owned()), | |
| 1249 | entries: Vec::new(), | |
| 1250 | }; | |
| 1251 | vi.set( | |
| 1252 | LuaKey::Str("Pos".to_owned()), | |
| 1253 | vec2_lua(node.pos[0] as f64, node.pos[1] as f64), | |
| 1254 | ); | |
| 1255 | tool_tbl.set(LuaKey::Str("ViewInfo".to_owned()), LuaValue::Table(vi)); | |
| 1256 | } | |
| 1257 | ||
| 1258 | // PassThrough | |
| 1259 | if node.bypassed { | |
| 1260 | tool_tbl.set(LuaKey::Str("PassThrough".to_owned()), LuaValue::Bool(true)); | |
| 1261 | } else if tool_tbl.get("PassThrough").is_some() { | |
| 1262 | tool_tbl.remove(&LuaKey::Str("PassThrough".to_owned())); | |
| 1263 | } | |
| 1264 | ||
| 1265 | // Inputs (skip MacroOperator / GroupOperator so InstanceInput wiring stays intact) | |
| 1266 | if !matches!(node.kind.as_str(), "MacroOperator" | "GroupOperator") { | |
| 1267 | let master_inputs = node | |
| 1268 | .raw | |
| 1269 | .get_str("SourceOp") | |
| 1270 | .and_then(|m| self.find_node(m)) | |
| 1271 | .map(|mid| &self.nodes[mid.0].inputs); | |
| 1272 | sync_node_inputs(node, master_inputs, tool_tbl); | |
| 1273 | } | |
| 1274 | } | |
| 1275 | ||
| 1276 | // Sync BezierSpline edits (only touch splines that actually differ from the raw AST) | |
| 1277 | let mut spline_names: Vec<&String> = self.splines.keys().collect(); | |
| 1278 | spline_names.sort(); | |
| 1279 | for spline_name in spline_names { | |
| 1280 | let spline = &self.splines[spline_name]; | |
| 1281 | if let Some(tbl) = tools.get_table_mut(spline_name) { | |
| 1282 | sync_spline_table(spline_name, spline, tbl); | |
| 1283 | continue; | |
| 1284 | } | |
| 1285 | // Check nested `Tools` (e.g. ColorCurves / HueCurves LUTBezier) | |
| 1286 | let mut found_nested = false; | |
| 1287 | for (_, v) in &mut tools.entries { | |
| 1288 | if let Some(node_tbl) = v.as_table_mut() { | |
| 1289 | if let Some(inner_tools) = node_tbl.get_table_mut("Tools") { | |
| 1290 | if let Some(inner_sp) = inner_tools.get_table_mut(spline_name) { | |
| 1291 | sync_spline_table(spline_name, spline, inner_sp); | |
| 1292 | found_nested = true; | |
| 1293 | break; | |
| 1294 | } | |
| 1295 | } | |
| 1296 | } | |
| 1297 | } | |
| 1298 | if !found_nested { | |
| 1299 | let mut sp_tbl = LuaTable { | |
| 1300 | tag: Some("BezierSpline".to_owned()), | |
| 1301 | entries: Vec::new(), | |
| 1302 | }; | |
| 1303 | sp_tbl.set( | |
| 1304 | LuaKey::Str("SplineColor".to_owned()), | |
| 1305 | spline_color_lua(spline.color), | |
| 1306 | ); | |
| 1307 | sp_tbl.set( | |
| 1308 | LuaKey::Str("KeyFrames".to_owned()), | |
| 1309 | LuaValue::Table(build_keyframes_table(spline)), | |
| 1310 | ); | |
| 1311 | tools.set(LuaKey::Str(spline_name.clone()), LuaValue::Table(sp_tbl)); | |
| 1312 | } | |
| 1313 | } | |
| 1314 | ||
| 1315 | root | |
| 1316 | } | |
| 1317 | ||
| 1318 | /// Serializes this composition back to a Blackmagic Fusion `.comp` string. | |
| 1319 | pub fn to_fusion_string(&self) -> String { | |
| 1320 | let mut s = self.sync_to_raw_ast().to_fusion_string(); | |
| 1321 | if !s.ends_with('\n') { | |
| 1322 | s.push('\n'); | |
| 1323 | } | |
| 1324 | s | |
| 1325 | } | |
| 1326 | ||
| 1327 | /// Atomically saves this composition to `path`. | |
| 1328 | /// If `path` already exists, backs up the original bytes to | |
| 1329 | /// `<temp_dir>/fission-backups/<stem>_<unix_millis>.comp.bak` and returns `Ok(Some(backup_path))`. | |
| 1330 | pub fn save_to_file(&self, path: impl AsRef<Path>) -> Result<Option<PathBuf>, std::io::Error> { | |
| 1331 | let path = path.as_ref(); | |
| 1332 | let stem = path | |
| 1333 | .file_stem() | |
| 1334 | .and_then(|s| s.to_str()) | |
| 1335 | .filter(|s| !s.is_empty()) | |
| 1336 | .unwrap_or("comp"); | |
| 1337 | ||
| 1338 | let backup_path = if path.exists() { | |
| 1339 | let backup_dir = std::env::temp_dir().join("fission-backups"); | |
| 1340 | std::fs::create_dir_all(&backup_dir)?; | |
| 1341 | let unix_millis = std::time::SystemTime::now() | |
| 1342 | .duration_since(std::time::UNIX_EPOCH) | |
| 1343 | .map(|d| d.as_millis()) | |
| 1344 | .unwrap_or(0); | |
| 1345 | let backup_file = backup_dir.join(format!("{stem}_{unix_millis}.comp.bak")); | |
| 1346 | std::fs::copy(path, &backup_file)?; | |
| 1347 | Some(backup_file) | |
| 1348 | } else { | |
| 1349 | None | |
| 1350 | }; | |
| 1351 | ||
| 1352 | let parent = path | |
| 1353 | .parent() | |
| 1354 | .filter(|p| !p.as_os_str().is_empty()) | |
| 1355 | .unwrap_or_else(|| Path::new(".")); | |
| 1356 | std::fs::create_dir_all(parent)?; | |
| 1357 | ||
| 1358 | let nanos = std::time::SystemTime::now() | |
| 1359 | .duration_since(std::time::UNIX_EPOCH) | |
| 1360 | .map(|d| d.as_nanos()) | |
| 1361 | .unwrap_or(0); | |
| 1362 | let pid = std::process::id(); | |
| 1363 | let tmp_path = parent.join(format!(".{stem}.{pid}.{nanos}.tmp")); | |
| 1364 | ||
| 1365 | let serialized = self.to_fusion_string(); | |
| 1366 | if let Err(e) = std::fs::write(&tmp_path, serialized.as_bytes()) { | |
| 1367 | let _ = std::fs::remove_file(&tmp_path); | |
| 1368 | return Err(e); | |
| 1369 | } | |
| 1370 | if let Err(e) = std::fs::rename(&tmp_path, path) { | |
| 1371 | let _ = std::fs::remove_file(&tmp_path); | |
| 1372 | return Err(e); | |
| 1373 | } | |
| 1374 | ||
| 1375 | Ok(backup_path) | |
| 1376 | } | |
| 1377 | } | |
| 1378 | ||
| 1379 | fn vec2_lua(x: f64, y: f64) -> LuaValue { | |
| 1380 | LuaValue::Table(LuaTable { | |
| 1381 | tag: None, | |
| 1382 | entries: vec![ | |
| 1383 | (LuaKey::Index(1), LuaValue::Number(x)), | |
| 1384 | (LuaKey::Index(2), LuaValue::Number(y)), | |
| 1385 | ], | |
| 1386 | }) | |
| 1387 | } | |
| 1388 | ||
| 1389 | fn ensure_table_mut<'a>(parent: &'a mut LuaTable, key: &str, tag: Option<&str>) -> &'a mut LuaTable { | |
| 1390 | if parent.get_table(key).is_none() { | |
| 1391 | parent.set( | |
| 1392 | LuaKey::Str(key.to_owned()), | |
| 1393 | LuaValue::Table(LuaTable { | |
| 1394 | tag: tag.map(str::to_owned), | |
| 1395 | entries: Vec::new(), | |
| 1396 | }), | |
| 1397 | ); | |
| 1398 | } | |
| 1399 | parent.get_table_mut(key).expect("table just inserted") | |
| 1400 | } | |
| 1401 | ||
| 1402 | fn param_value_to_lua(v: &ParamValue) -> LuaValue { | |
| 1403 | match v { | |
| 1404 | ParamValue::Number(n) => LuaValue::Number(*n), | |
| 1405 | ParamValue::Point([x, y]) => vec2_lua(*x, *y), | |
| 1406 | ParamValue::Text(s) => LuaValue::String(s.clone()), | |
| 1407 | ParamValue::FuId(s) => LuaValue::Table(LuaTable { | |
| 1408 | tag: Some("FuID".to_owned()), | |
| 1409 | entries: vec![(LuaKey::Index(1), LuaValue::String(s.clone()))], | |
| 1410 | }), | |
| 1411 | ParamValue::Gradient(g) => { | |
| 1412 | let mut colors = LuaTable::default(); | |
| 1413 | for stop in &g.stops { | |
| 1414 | let key = if stop.pos.fract() == 0.0 && stop.pos.abs() < 9_007_199_254_740_992.0 { | |
| 1415 | LuaKey::Index(stop.pos as i64) | |
| 1416 | } else { | |
| 1417 | LuaKey::Number(stop.pos) | |
| 1418 | }; | |
| 1419 | colors.entries.push(( | |
| 1420 | key, | |
| 1421 | LuaValue::Table(LuaTable { | |
| 1422 | tag: None, | |
| 1423 | entries: vec![ | |
| 1424 | (LuaKey::Index(1), LuaValue::Number(stop.rgba[0] as f64)), | |
| 1425 | (LuaKey::Index(2), LuaValue::Number(stop.rgba[1] as f64)), | |
| 1426 | (LuaKey::Index(3), LuaValue::Number(stop.rgba[2] as f64)), | |
| 1427 | (LuaKey::Index(4), LuaValue::Number(stop.rgba[3] as f64)), | |
| 1428 | ], | |
| 1429 | }), | |
| 1430 | )); | |
| 1431 | } | |
| 1432 | LuaValue::Table(LuaTable { | |
| 1433 | tag: Some("Gradient".to_owned()), | |
| 1434 | entries: vec![(LuaKey::Str("Colors".to_owned()), LuaValue::Table(colors))], | |
| 1435 | }) | |
| 1436 | } | |
| 1437 | ParamValue::Raw(raw) => raw.clone(), | |
| 1438 | } | |
| 1439 | } | |
| 1440 | ||
| 1441 | fn user_control_default(raw: &LuaTable, name: &str) -> Option<ParamValue> { | |
| 1442 | let ut = raw.get_table("UserControls")?.get_table(name)?; | |
| 1443 | let is_point = ut.get_str("LINKID_DataType") == Some("Point") | |
| 1444 | || ut.get_str("INPID_InputControl") == Some("OffsetControl"); | |
| 1445 | if is_point { | |
| 1446 | let dx = ut.get_f64("INP_DefaultX").unwrap_or(0.5); | |
| 1447 | let dy = ut.get_f64("INP_DefaultY").unwrap_or(0.5); | |
| 1448 | Some(ParamValue::Point([dx, dy])) | |
| 1449 | } else { | |
| 1450 | ut.get("INP_Default").map(parse_param_value) | |
| 1451 | } | |
| 1452 | } | |
| 1453 | ||
| 1454 | fn sync_node_inputs( | |
| 1455 | node: &Node, | |
| 1456 | master_inputs: Option<&HashMap<String, InputBinding>>, | |
| 1457 | tool_tbl: &mut LuaTable, | |
| 1458 | ) { | |
| 1459 | // First remove any input present in raw `Inputs` that was explicitly removed from `node.inputs`. | |
| 1460 | if let Some(in_tbl) = tool_tbl.get_table_mut("Inputs") { | |
| 1461 | in_tbl.entries.retain(|(k, v)| { | |
| 1462 | let LuaKey::Str(port) = k else { return true }; | |
| 1463 | if v.as_table().is_none() { | |
| 1464 | return true; | |
| 1465 | } | |
| 1466 | node.inputs.contains_key(port) | |
| 1467 | }); | |
| 1468 | } | |
| 1469 | ||
| 1470 | // Collect sorted port names for deterministic output when appending new inputs. | |
| 1471 | let mut ports: Vec<&String> = node.inputs.keys().collect(); | |
| 1472 | ports.sort(); | |
| 1473 | ||
| 1474 | for port in ports { | |
| 1475 | let binding = &node.inputs[port]; | |
| 1476 | let existing_binding = tool_tbl | |
| 1477 | .get_table("Inputs") | |
| 1478 | .and_then(|i| i.get_table(port)) | |
| 1479 | .map(parse_input_binding); | |
| 1480 | ||
| 1481 | if let Some(orig) = existing_binding { | |
| 1482 | if orig == *binding { | |
| 1483 | continue; | |
| 1484 | } | |
| 1485 | let in_tbl = ensure_table_mut(tool_tbl, "Inputs", None); | |
| 1486 | if let Some(it) = in_tbl.get_table_mut(port) { | |
| 1487 | if orig.source_op != binding.source_op { | |
| 1488 | match &binding.source_op { | |
| 1489 | Some(op) => it.set(LuaKey::Str("SourceOp".to_owned()), LuaValue::String(op.clone())), | |
| 1490 | None => { | |
| 1491 | it.remove(&LuaKey::Str("SourceOp".to_owned())); | |
| 1492 | } | |
| 1493 | } | |
| 1494 | } | |
| 1495 | if orig.source_output != binding.source_output { | |
| 1496 | match &binding.source_output { | |
| 1497 | Some(src) => it.set(LuaKey::Str("Source".to_owned()), LuaValue::String(src.clone())), | |
| 1498 | None => { | |
| 1499 | it.remove(&LuaKey::Str("Source".to_owned())); | |
| 1500 | } | |
| 1501 | } | |
| 1502 | } | |
| 1503 | if orig.expression != binding.expression { | |
| 1504 | match &binding.expression { | |
| 1505 | Some(expr) => it.set(LuaKey::Str("Expression".to_owned()), LuaValue::String(expr.clone())), | |
| 1506 | None => { | |
| 1507 | it.remove(&LuaKey::Str("Expression".to_owned())); | |
| 1508 | } | |
| 1509 | } | |
| 1510 | } | |
| 1511 | if orig.value != binding.value { | |
| 1512 | match &binding.value { | |
| 1513 | Some(val) => it.set(LuaKey::Str("Value".to_owned()), param_value_to_lua(val)), | |
| 1514 | None => { | |
| 1515 | it.remove(&LuaKey::Str("Value".to_owned())); | |
| 1516 | } | |
| 1517 | } | |
| 1518 | } | |
| 1519 | } | |
| 1520 | } else { | |
| 1521 | // Port did not exist in raw `Inputs`. | |
| 1522 | if binding.value.is_none() && binding.source_op.is_none() && binding.expression.is_none() { | |
| 1523 | continue; | |
| 1524 | } | |
| 1525 | // Don't pollute `Inputs` with unedited `UserControls` defaults synthesized during load. | |
| 1526 | if binding.source_op.is_none() | |
| 1527 | && binding.expression.is_none() | |
| 1528 | && binding.value.is_some() | |
| 1529 | && binding.value == user_control_default(&node.raw, port) | |
| 1530 | { | |
| 1531 | continue; | |
| 1532 | } | |
| 1533 | // Don't duplicate inherited master inputs onto instanced tools. | |
| 1534 | if let Some(master) = master_inputs { | |
| 1535 | if master.get(port) == Some(binding) { | |
| 1536 | continue; | |
| 1537 | } | |
| 1538 | } | |
| 1539 | ||
| 1540 | let mut it = LuaTable { | |
| 1541 | tag: Some("Input".to_owned()), | |
| 1542 | entries: Vec::new(), | |
| 1543 | }; | |
| 1544 | if let Some(op) = &binding.source_op { | |
| 1545 | it.set(LuaKey::Str("SourceOp".to_owned()), LuaValue::String(op.clone())); | |
| 1546 | } | |
| 1547 | if let Some(src) = &binding.source_output { | |
| 1548 | it.set(LuaKey::Str("Source".to_owned()), LuaValue::String(src.clone())); | |
| 1549 | } | |
| 1550 | if let Some(val) = &binding.value { | |
| 1551 | it.set(LuaKey::Str("Value".to_owned()), param_value_to_lua(val)); | |
| 1552 | } | |
| 1553 | if let Some(expr) = &binding.expression { | |
| 1554 | it.set(LuaKey::Str("Expression".to_owned()), LuaValue::String(expr.clone())); | |
| 1555 | } | |
| 1556 | let in_tbl = ensure_table_mut(tool_tbl, "Inputs", None); | |
| 1557 | in_tbl.set(LuaKey::Str(port.clone()), LuaValue::Table(it)); | |
| 1558 | } | |
| 1559 | } | |
| 1560 | } | |
| 1561 | ||
| 1562 | fn spline_color_lua(color: [u8; 3]) -> LuaValue { | |
| 1563 | LuaValue::Table(LuaTable { | |
| 1564 | tag: None, | |
| 1565 | entries: vec![ | |
| 1566 | (LuaKey::Str("Red".to_owned()), LuaValue::Number(color[0] as f64)), | |
| 1567 | (LuaKey::Str("Green".to_owned()), LuaValue::Number(color[1] as f64)), | |
| 1568 | (LuaKey::Str("Blue".to_owned()), LuaValue::Number(color[2] as f64)), | |
| 1569 | ], | |
| 1570 | }) | |
| 1571 | } | |
| 1572 | ||
| 1573 | fn build_keyframes_table(spline: &BezierSpline) -> LuaTable { | |
| 1574 | let mut kfs = spline.keyframes.clone(); | |
| 1575 | kfs.sort_by(|a, b| a.time.total_cmp(&b.time)); | |
| 1576 | let mut tbl = LuaTable::default(); | |
| 1577 | for kf in kfs { | |
| 1578 | let key = if kf.time.fract() == 0.0 && kf.time.abs() < 9_007_199_254_740_992.0 { | |
| 1579 | LuaKey::Index(kf.time as i64) | |
| 1580 | } else { | |
| 1581 | LuaKey::Number(kf.time) | |
| 1582 | }; | |
| 1583 | let mut entry = LuaTable::default(); | |
| 1584 | entry.entries.push((LuaKey::Index(1), LuaValue::Number(kf.value))); | |
| 1585 | if let Some([lx, ly]) = kf.lh { | |
| 1586 | entry.entries.push((LuaKey::Str("LH".to_owned()), vec2_lua(lx, ly))); | |
| 1587 | } | |
| 1588 | if let Some([rx, ry]) = kf.rh { | |
| 1589 | entry.entries.push((LuaKey::Str("RH".to_owned()), vec2_lua(rx, ry))); | |
| 1590 | } | |
| 1591 | let mut flags = LuaTable::default(); | |
| 1592 | if kf.flags.linear { | |
| 1593 | flags.entries.push((LuaKey::Str("Linear".to_owned()), LuaValue::Bool(true))); | |
| 1594 | } | |
| 1595 | if kf.flags.step_in { | |
| 1596 | flags.entries.push((LuaKey::Str("StepIn".to_owned()), LuaValue::Bool(true))); | |
| 1597 | } | |
| 1598 | if kf.flags.step_out { | |
| 1599 | flags.entries.push((LuaKey::Str("StepOut".to_owned()), LuaValue::Bool(true))); | |
| 1600 | } | |
| 1601 | if kf.flags.loop_after { | |
| 1602 | flags.entries.push((LuaKey::Str("Loop".to_owned()), LuaValue::Bool(true))); | |
| 1603 | } | |
| 1604 | if kf.flags.loop_rel { | |
| 1605 | flags.entries.push((LuaKey::Str("LoopRel".to_owned()), LuaValue::Bool(true))); | |
| 1606 | } | |
| 1607 | if kf.flags.ping_pong { | |
| 1608 | flags.entries.push((LuaKey::Str("PingPong".to_owned()), LuaValue::Bool(true))); | |
| 1609 | } | |
| 1610 | if kf.flags.locked_y { | |
| 1611 | flags.entries.push((LuaKey::Str("LockedY".to_owned()), LuaValue::Bool(true))); | |
| 1612 | } | |
| 1613 | if !flags.entries.is_empty() { | |
| 1614 | entry.entries.push((LuaKey::Str("Flags".to_owned()), LuaValue::Table(flags))); | |
| 1615 | } | |
| 1616 | tbl.entries.push((key, LuaValue::Table(entry))); | |
| 1617 | } | |
| 1618 | tbl | |
| 1619 | } | |
| 1620 | ||
| 1621 | fn sync_spline_table(spline_name: &str, spline: &BezierSpline, tbl: &mut LuaTable) { | |
| 1622 | let existing = BezierSpline::from_lua(spline_name.to_owned(), tbl); | |
| 1623 | if existing.color != spline.color { | |
| 1624 | tbl.set(LuaKey::Str("SplineColor".to_owned()), spline_color_lua(spline.color)); | |
| 1625 | } | |
| 1626 | if existing.keyframes != spline.keyframes { | |
| 1627 | let new_kfs = LuaValue::Table(build_keyframes_table(spline)); | |
| 1628 | if tbl.tag.as_deref() == Some("LUTBezier") && tbl.get_table("KeyColorSplines").is_some() { | |
| 1629 | if let Some(kcs) = tbl.get_table_mut("KeyColorSplines") { | |
| 1630 | kcs.set(LuaKey::Index(0), new_kfs); | |
| 1631 | } | |
| 1632 | } else { | |
| 1633 | tbl.set(LuaKey::Str("KeyFrames".to_owned()), new_kfs); | |
| 1634 | } | |
| 1635 | } | |
| 947 | 1636 | } |
| 948 | 1637 | |
| 949 | 1638 | pub fn default_main_input_port(kind: &str) -> &'static str { |
crates/model/src/lib.rs+394-1| ... | ... | @@ -3,7 +3,10 @@ pub mod expr; |
| 3 | 3 | pub mod lua_value; |
| 4 | 4 | pub mod spline; |
| 5 | 5 | |
| 6 | pub use comp::{BitDepth, ClipSpec, ClsEntry, Comp, InputBinding, Node, NodeId, ParamValue, PortRole, default_main_input_port}; | |
| 6 | pub use comp::{ | |
| 7 | BitDepth, ClipSpec, ClsEntry, Comp, InputBinding, Node, NodeId, ParamValue, PortRole, SaverSpec, | |
| 8 | default_main_input_port, is_supported_tool, | |
| 9 | }; | |
| 7 | 10 | pub use expr::ExprEngine; |
| 8 | 11 | pub use lua_value::{LuaKey, LuaTable, LuaValue, ParseError, parse_lua}; |
| 9 | 12 | pub use spline::{BezierSpline, Gradient, GradientStop, HandleMode, KeyFlags, Keyframe, PolyPath, PolyPoint}; |
| ... | ... | @@ -77,4 +80,394 @@ mod tests { |
| 77 | 80 | let p1 = comp.eval_point(merge19, "Center", 2361.0, [0.5, 0.5], &expr); |
| 78 | 81 | assert!((p0[0] - p1[0]).abs() + (p0[1] - p1[1]).abs() > 1e-4); |
| 79 | 82 | } |
| 83 | ||
| 84 | #[test] | |
| 85 | fn roundtrips_all_337_real_fusion_comps() { | |
| 86 | let mut paths = Vec::new(); | |
| 87 | fn collect(dir: &Path, out: &mut Vec<std::path::PathBuf>) { | |
| 88 | let Ok(rd) = std::fs::read_dir(dir) else { return }; | |
| 89 | for entry in rd.flatten() { | |
| 90 | let p = entry.path(); | |
| 91 | if p.is_dir() { | |
| 92 | collect(&p, out); | |
| 93 | } else if p | |
| 94 | .extension() | |
| 95 | .and_then(|e| e.to_str()) | |
| 96 | .is_some_and(|e| e.eq_ignore_ascii_case("comp")) | |
| 97 | { | |
| 98 | out.push(p); | |
| 99 | } | |
| 100 | } | |
| 101 | } | |
| 102 | collect(Path::new("/Users/clo/dev/compositor/private/samples"), &mut paths); | |
| 103 | collect(Path::new("/Volumes/Project/trees/fusion"), &mut paths); | |
| 104 | paths.sort(); | |
| 105 | assert!(!paths.is_empty(), "expected sample .comp files"); | |
| 106 | ||
| 107 | let mut failures = Vec::new(); | |
| 108 | for p in &paths { | |
| 109 | let orig = match Comp::from_fusion_file(p) { | |
| 110 | Ok(c) => c, | |
| 111 | Err(e) => { | |
| 112 | failures.push(format!("{}: load error: {e}", p.display())); | |
| 113 | continue; | |
| 114 | } | |
| 115 | }; | |
| 116 | let serialized = orig.to_fusion_string(); | |
| 117 | let reloaded = match Comp::from_fusion_str(&serialized) { | |
| 118 | Ok(c) => c, | |
| 119 | Err(e) => { | |
| 120 | failures.push(format!("{}: re-parse error: {e}", p.display())); | |
| 121 | continue; | |
| 122 | } | |
| 123 | }; | |
| 124 | ||
| 125 | if orig.width != reloaded.width | |
| 126 | || orig.height != reloaded.height | |
| 127 | || (orig.fps - reloaded.fps).abs() > 1e-6 | |
| 128 | || orig.depth_full != reloaded.depth_full | |
| 129 | || orig.render_range != reloaded.render_range | |
| 130 | || orig.global_range != reloaded.global_range | |
| 131 | { | |
| 132 | failures.push(format!( | |
| 133 | "{}: metadata mismatch: orig=({}x{} @{} {:?} rr={:?} gr={:?}) vs reloaded=({}x{} @{} {:?} rr={:?} gr={:?})", | |
| 134 | p.display(), | |
| 135 | orig.width, orig.height, orig.fps, orig.depth_full, orig.render_range, orig.global_range, | |
| 136 | reloaded.width, reloaded.height, reloaded.fps, reloaded.depth_full, reloaded.render_range, reloaded.global_range, | |
| 137 | )); | |
| 138 | continue; | |
| 139 | } | |
| 140 | ||
| 141 | if orig.nodes.len() != reloaded.nodes.len() { | |
| 142 | failures.push(format!( | |
| 143 | "{}: node count mismatch: {} vs {}", | |
| 144 | p.display(), | |
| 145 | orig.nodes.len(), | |
| 146 | reloaded.nodes.len() | |
| 147 | )); | |
| 148 | continue; | |
| 149 | } | |
| 150 | ||
| 151 | let orig_names: std::collections::HashSet<String> = | |
| 152 | orig.node_by_name.keys().cloned().collect(); | |
| 153 | let rel_names: std::collections::HashSet<String> = | |
| 154 | reloaded.node_by_name.keys().cloned().collect(); | |
| 155 | ||
| 156 | let mut node_err = None; | |
| 157 | for (a, b) in orig.nodes.iter().zip(reloaded.nodes.iter()) { | |
| 158 | if a.name != b.name | |
| 159 | || a.kind != b.kind | |
| 160 | || a.bypassed != b.bypassed | |
| 161 | || a.internal != b.internal | |
| 162 | || (a.pos[0] - b.pos[0]).abs() > 1e-3 | |
| 163 | || (a.pos[1] - b.pos[1]).abs() > 1e-3 | |
| 164 | { | |
| 165 | node_err = Some(format!( | |
| 166 | "{}: node mismatch {} vs {} (kind {:?}/{:?}, bypassed {}/{}, pos {:?}/{:?})", | |
| 167 | p.display(), | |
| 168 | a.name, b.name, a.kind, b.kind, a.bypassed, b.bypassed, a.pos, b.pos | |
| 169 | )); | |
| 170 | break; | |
| 171 | } | |
| 172 | let conns_a = a.image_connections(&orig_names); | |
| 173 | let conns_b = b.image_connections(&rel_names); | |
| 174 | if conns_a != conns_b { | |
| 175 | node_err = Some(format!( | |
| 176 | "{}: image_connections mismatch on {}: {:?} vs {:?}", | |
| 177 | p.display(), | |
| 178 | a.name, conns_a, conns_b | |
| 179 | )); | |
| 180 | break; | |
| 181 | } | |
| 182 | } | |
| 183 | if let Some(err) = node_err { | |
| 184 | failures.push(err); | |
| 185 | continue; | |
| 186 | } | |
| 187 | ||
| 188 | if orig.splines.len() != reloaded.splines.len() { | |
| 189 | failures.push(format!( | |
| 190 | "{}: spline count mismatch: {} vs {}", | |
| 191 | p.display(), | |
| 192 | orig.splines.len(), | |
| 193 | reloaded.splines.len() | |
| 194 | )); | |
| 195 | continue; | |
| 196 | } | |
| 197 | for (sname, sp_a) in &orig.splines { | |
| 198 | let Some(sp_b) = reloaded.splines.get(sname) else { | |
| 199 | failures.push(format!("{}: missing spline {sname}", p.display())); | |
| 200 | break; | |
| 201 | }; | |
| 202 | if sp_a.keyframes.is_empty() && sp_b.keyframes.is_empty() { | |
| 203 | continue; | |
| 204 | } | |
| 205 | let t0 = sp_a.keyframes.first().map(|k| k.time).unwrap_or(0.0); | |
| 206 | let t1 = sp_a.keyframes.last().map(|k| k.time).unwrap_or(0.0); | |
| 207 | for step in 0..=4 { | |
| 208 | let t = t0 + (t1 - t0) * (step as f64 / 4.0); | |
| 209 | let va = sp_a.eval(t); | |
| 210 | let vb = sp_b.eval(t); | |
| 211 | let diff = (va - vb).abs(); | |
| 212 | if !(va.is_nan() && vb.is_nan()) && diff > 1e-5 * va.abs().max(1.0) { | |
| 213 | failures.push(format!( | |
| 214 | "{}: spline {sname} @ t={t} mismatch: {va} vs {vb}", | |
| 215 | p.display() | |
| 216 | )); | |
| 217 | break; | |
| 218 | } | |
| 219 | } | |
| 220 | } | |
| 221 | } | |
| 222 | ||
| 223 | assert!( | |
| 224 | failures.is_empty(), | |
| 225 | "roundtrip failed on {}/{} comps:\n{}", | |
| 226 | failures.len(), | |
| 227 | paths.len(), | |
| 228 | failures.iter().take(20).cloned().collect::<Vec<_>>().join("\n") | |
| 229 | ); | |
| 230 | eprintln!("Losslessly roundtripped {}/{} real .comp files!", paths.len(), paths.len()); | |
| 231 | } | |
| 232 | ||
| 233 | #[test] | |
| 234 | fn preserves_unknown_nodes_and_applies_edits_with_temp_backup() { | |
| 235 | let src = r#"Composition { | |
| 236 | 	CurrentTime = 10, | |
| 237 | 	RenderRange = { 0, 100 }, | |
| 238 | 	GlobalRange = { 0, 100 }, | |
| 239 | 	Prefs = { | |
| 240 | 		Comp = { | |
| 241 | 			FrameFormat = { | |
| 242 | 				Width = 1920, | |
| 243 | 				Height = 1080, | |
| 244 | 				Rate = 24, | |
| 245 | 				DepthFull = 3, | |
| 246 | 			}, | |
| 247 | 		}, | |
| 248 | 	}, | |
| 249 | 	Tools = { | |
| 250 | 		BG1 = Background { | |
| 251 | 			Inputs = { | |
| 252 | 				Width = Input { Value = 1920, }, | |
| 253 | 				Height = Input { Value = 1080, }, | |
| 254 | 				TopLeftRed = Input { Value = 0.25, }, | |
| 255 | 			}, | |
| 256 | 			ViewInfo = OperatorInfo { Pos = { 100, 50 } }, | |
| 257 | 		}, | |
| 258 | 		OverlayBG = Background { | |
| 259 | 			Inputs = { | |
| 260 | 				TopLeftGreen = Input { Value = 0.8, }, | |
| 261 | 			}, | |
| 262 | 			ViewInfo = OperatorInfo { Pos = { 100, 200 } }, | |
| 263 | 		}, | |
| 264 | 		Mask1 = EllipseMask { | |
| 265 | 			ViewInfo = OperatorInfo { Pos = { 250, 250 } }, | |
| 266 | 		}, | |
| 267 | 		SurfaceTracker1 = SurfaceTracker { | |
| 268 | 			Inputs = { | |
| 269 | 				Source = Input { | |
| 270 | 					SourceOp = "BG1", | |
| 271 | 					Source = "Output", | |
| 272 | 				}, | |
| 273 | 				Overlay = Input { | |
| 274 | 					SourceOp = "OverlayBG", | |
| 275 | 					Source = "Output", | |
| 276 | 				}, | |
| 277 | 				TrackingMask = Input { | |
| 278 | 					SourceOp = "Mask1", | |
| 279 | 					Source = "Mask", | |
| 280 | 				}, | |
| 281 | 				MeshBlob = Input { | |
| 282 | 					Value = TrackingMesh { | |
| 283 | 						Vertices = { 0.1, 0.2, 0.3, 0.4 }, | |
| 284 | 						Meta = "line1\nline2\"quoted\"\\slash", | |
| 285 | 					}, | |
| 286 | 				}, | |
| 287 | 			}, | |
| 288 | 			UserControls = ordered() { | |
| 289 | 				CustomGain = { | |
| 290 | 					INP_Default = 1.5, | |
| 291 | 					LINKID_DataType = "Number", | |
| 292 | 				}, | |
| 293 | 			}, | |
| 294 | 			ViewInfo = OperatorInfo { Pos = { 300, 100 }, Flags = { ShowName = true } }, | |
| 295 | 		}, | |
| 296 | 		BC1 = BrightnessContrast { | |
| 297 | 			Inputs = { | |
| 298 | 				Input = Input { | |
| 299 | 					SourceOp = "SurfaceTracker1", | |
| 300 | 					Source = "Output", | |
| 301 | 				}, | |
| 302 | 				Gain = Input { | |
| 303 | 					SourceOp = "BC1Gain", | |
| 304 | 					Source = "Value", | |
| 305 | 				}, | |
| 306 | 			}, | |
| 307 | 			ViewInfo = OperatorInfo { Pos = { 500, 100 } }, | |
| 308 | 		}, | |
| 309 | 		BC1Gain = BezierSpline { | |
| 310 | 			SplineColor = { Red = 255, Green = 128, Blue = 0 }, | |
| 311 | 			KeyFrames = { | |
| 312 | 				[0] = { 1, RH = { 10, 1 }, Flags = { Linear = true } }, | |
| 313 | 				[30] = { 2, LH = { 20, 2 }, Flags = { Linear = true } }, | |
| 314 | 			}, | |
| 315 | 		}, | |
| 316 | 	}, | |
| 317 | }"#; | |
| 318 | ||
| 319 | let mut comp = Comp::from_fusion_str(src).expect("parse synthetic comp"); | |
| 320 | assert!(!is_supported_tool("SurfaceTracker")); | |
| 321 | assert!(is_supported_tool("BrightnessContrast")); | |
| 322 | assert!(is_supported_tool("Renderer3D")); | |
| 323 | ||
| 324 | // Verify unknown node connections surface all 3 ports with proper roles | |
| 325 | let st_id = comp.find_node("SurfaceTracker1").expect("SurfaceTracker1"); | |
| 326 | let names: std::collections::HashSet<String> = comp.node_by_name.keys().cloned().collect(); | |
| 327 | let conns = comp.node(st_id).image_connections(&names); | |
| 328 | assert_eq!( | |
| 329 | conns, | |
| 330 | vec![ | |
| 331 | ("Overlay".to_owned(), "OverlayBG".to_owned(), PortRole::Foreground), | |
| 332 | ("Source".to_owned(), "BG1".to_owned(), PortRole::Background), | |
| 333 | ("TrackingMask".to_owned(), "Mask1".to_owned(), PortRole::Mask), | |
| 334 | ] | |
| 335 | ); | |
| 336 | ||
| 337 | // Mutate a different node's position, bypass, wire, param, and a BezierSpline keyframe | |
| 338 | let bc_id = comp.find_node("BC1").expect("BC1"); | |
| 339 | let bg_id = comp.find_node("BG1").expect("BG1"); | |
| 340 | { | |
| 341 | let bc = comp.node_mut(bc_id); | |
| 342 | bc.pos = [650.0, 125.0]; | |
| 343 | bc.bypassed = true; | |
| 344 | bc.inputs.insert( | |
| 345 | "Gamma".to_owned(), | |
| 346 | InputBinding { | |
| 347 | value: Some(ParamValue::Number(1.35)), | |
| 348 | source_op: None, | |
| 349 | source_output: None, | |
| 350 | expression: None, | |
| 351 | }, | |
| 352 | ); | |
| 353 | } | |
| 354 | comp.connect(bg_id, bc_id, "EffectMask"); | |
| 355 | comp.splines | |
| 356 | .get_mut("BC1Gain") | |
| 357 | .unwrap() | |
| 358 | .keyframes | |
| 359 | .push(Keyframe::new(60.0, 3.5)); | |
| 360 | ||
| 361 | // Save to a fresh temp directory twice | |
| 362 | let unique_dir = std::env::temp_dir().join(format!( | |
| 363 | "fission_test_save_{}_{}", | |
| 364 | std::process::id(), | |
| 365 | std::time::SystemTime::now() | |
| 366 | .duration_since(std::time::UNIX_EPOCH) | |
| 367 | .unwrap() | |
| 368 | .as_nanos() | |
| 369 | )); | |
| 370 | std::fs::create_dir_all(&unique_dir).unwrap(); | |
| 371 | let comp_path = unique_dir.join("test_shot.comp"); | |
| 372 | ||
| 373 | // First save: file does not exist yet -> no backup | |
| 374 | let bak1 = comp.save_to_file(&comp_path).expect("first save"); | |
| 375 | assert!(bak1.is_none()); | |
| 376 | ||
| 377 | // Second save: file exists -> backup goes to temp_dir/fission-backups/, NOT next to comp | |
| 378 | let bak2 = comp.save_to_file(&comp_path).expect("second save"); | |
| 379 | let bak2_path = bak2.expect("expected backup path on second save"); | |
| 380 | assert!(bak2_path.exists()); | |
| 381 | assert_eq!( | |
| 382 | bak2_path.parent().unwrap(), | |
| 383 | std::env::temp_dir().join("fission-backups") | |
| 384 | ); | |
| 385 | // Ensure no .bak file next to test_shot.comp | |
| 386 | let siblings: Vec<_> = std::fs::read_dir(&unique_dir) | |
| 387 | .unwrap() | |
| 388 | .flatten() | |
| 389 | .map(|e| e.file_name().to_string_lossy().into_owned()) | |
| 390 | .collect(); | |
| 391 | assert_eq!(siblings, vec!["test_shot.comp".to_owned()]); | |
| 392 | ||
| 393 | // Reload and verify edits persisted AND SurfaceTracker survived 100% intact | |
| 394 | let reloaded = Comp::from_fusion_file(&comp_path).expect("reload saved comp"); | |
| 395 | let r_bc = reloaded.node(reloaded.find_node("BC1").unwrap()); | |
| 396 | assert_eq!(r_bc.pos, [650.0, 125.0]); | |
| 397 | assert!(r_bc.bypassed); | |
| 398 | assert_eq!(r_bc.static_number("Gamma"), Some(1.35)); | |
| 399 | assert_eq!(r_bc.connected_node("EffectMask"), Some("BG1")); | |
| 400 | ||
| 401 | let r_sp = reloaded.splines.get("BC1Gain").expect("BC1Gain spline"); | |
| 402 | assert_eq!(r_sp.keyframes.len(), 3); | |
| 403 | assert!((r_sp.eval(60.0) - 3.5).abs() < 1e-6); | |
| 404 | ||
| 405 | let r_st = reloaded.node(reloaded.find_node("SurfaceTracker1").unwrap()); | |
| 406 | assert_eq!(r_st.kind, "SurfaceTracker"); | |
| 407 | let r_names: std::collections::HashSet<String> = | |
| 408 | reloaded.node_by_name.keys().cloned().collect(); | |
| 409 | assert_eq!(r_st.image_connections(&r_names), conns); | |
| 410 | // Verify custom nested MeshBlob and UserControls survived verbatim | |
| 411 | let mesh = r_st | |
| 412 | .raw | |
| 413 | .get_table("Inputs") | |
| 414 | .and_then(|i| i.get_table("MeshBlob")) | |
| 415 | .and_then(|m| m.get_table("Value")) | |
| 416 | .expect("MeshBlob Value"); | |
| 417 | assert_eq!(mesh.tag.as_deref(), Some("TrackingMesh")); | |
| 418 | assert_eq!(mesh.get_str("Meta"), Some("line1\nline2\"quoted\"\\slash")); | |
| 419 | assert!(r_st.raw.get_table("UserControls").is_some()); | |
| 420 | // Verify unedited UserControl default was NOT injected into raw Inputs | |
| 421 | assert!( | |
| 422 | r_st.raw | |
| 423 | .get_table("Inputs") | |
| 424 | .and_then(|i| i.get("CustomGain")) | |
| 425 | .is_none() | |
| 426 | ); | |
| 427 | ||
| 428 | let _ = std::fs::remove_dir_all(&unique_dir); | |
| 429 | let _ = std::fs::remove_file(&bak2_path); | |
| 430 | } | |
| 431 | ||
| 432 | #[test] | |
| 433 | fn saver_spec_frame_paths() { | |
| 434 | let make = |filename: &str| SaverSpec { | |
| 435 | node_id: NodeId(0), | |
| 436 | name: "Saver1".to_owned(), | |
| 437 | upstream: None, | |
| 438 | filename: filename.to_owned(), | |
| 439 | range: [0, 100], | |
| 440 | sequence_start: None, | |
| 441 | }; | |
| 442 | ||
| 443 | assert_eq!( | |
| 444 | make("/renders/foo_0000.png").frame_path(42), | |
| 445 | std::path::PathBuf::from("/renders/foo_0042.png") | |
| 446 | ); | |
| 447 | assert_eq!( | |
| 448 | make("/renders/0000.png").frame_path(7), | |
| 449 | std::path::PathBuf::from("/renders/0007.png") | |
| 450 | ); | |
| 451 | assert_eq!( | |
| 452 | make("/renders/render.png").frame_path(12), | |
| 453 | std::path::PathBuf::from("/renders/render0012.png") | |
| 454 | ); | |
| 455 | assert_eq!( | |
| 456 | make("foo_000000.exr").frame_path(1001), | |
| 457 | std::path::PathBuf::from("foo_001001.exr") | |
| 458 | ); | |
| 459 | ||
| 460 | let comp = Comp::from_fusion_file("/Volumes/Project/trees/fusion/20_falling.comp") | |
| 461 | .expect("load 20_falling.comp"); | |
| 462 | let savers = comp.savers(); | |
| 463 | assert!(!savers.is_empty(), "expected Saver in 20_falling.comp"); | |
| 464 | let s = &savers[0]; | |
| 465 | assert_eq!(s.name, "Saver1"); | |
| 466 | assert!(s.upstream.is_some()); | |
| 467 | assert_eq!(s.range, comp.render_range); | |
| 468 | assert_eq!( | |
| 469 | s.frame_path(2130), | |
| 470 | std::path::PathBuf::from("/Volumes/Project/trees/FusionRender/2130.png") | |
| 471 | ); | |
| 472 | } | |
| 80 | 473 | } |
crates/model/src/lua_value.rs+291| ... | ... | @@ -38,6 +38,13 @@ impl LuaTable { |
| 38 | 38 | }) |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | pub fn get_mut(&mut self, key: &str) -> Option<&mut LuaValue> { | |
| 42 | self.entries.iter_mut().find_map(|(k, v)| match k { | |
| 43 | LuaKey::Str(s) if s == key => Some(v), | |
| 44 | _ => None, | |
| 45 | }) | |
| 46 | } | |
| 47 | ||
| 41 | 48 | pub fn get_index(&self, idx: i64) -> Option<&LuaValue> { |
| 42 | 49 | self.entries.iter().find_map(|(k, v)| match k { |
| 43 | 50 | LuaKey::Index(i) if *i == idx => Some(v), |
| ... | ... | @@ -50,6 +57,25 @@ impl LuaTable { |
| 50 | 57 | self.get(key)?.as_table() |
| 51 | 58 | } |
| 52 | 59 | |
| 60 | pub fn get_table_mut(&mut self, key: &str) -> Option<&mut LuaTable> { | |
| 61 | self.get_mut(key)?.as_table_mut() | |
| 62 | } | |
| 63 | ||
| 64 | /// Replaces an existing entry with the same key in place (preserving order), or appends it. | |
| 65 | pub fn set(&mut self, key: LuaKey, val: LuaValue) { | |
| 66 | if let Some((_, existing)) = self.entries.iter_mut().find(|(k, _)| *k == key) { | |
| 67 | *existing = val; | |
| 68 | } else { | |
| 69 | self.entries.push((key, val)); | |
| 70 | } | |
| 71 | } | |
| 72 | ||
| 73 | /// Removes the first entry matching `key`, preserving order of remaining entries. | |
| 74 | pub fn remove(&mut self, key: &LuaKey) -> Option<LuaValue> { | |
| 75 | let pos = self.entries.iter().position(|(k, _)| k == key)?; | |
| 76 | Some(self.entries.remove(pos).1) | |
| 77 | } | |
| 78 | ||
| 53 | 79 | pub fn get_str(&self, key: &str) -> Option<&str> { |
| 54 | 80 | self.get(key)?.as_str() |
| 55 | 81 | } |
| ... | ... | @@ -68,6 +94,13 @@ impl LuaTable { |
| 68 | 94 | _ => None, |
| 69 | 95 | }) |
| 70 | 96 | } |
| 97 | ||
| 98 | /// Serializes this table using Blackmagic Fusion `.comp` Lua table syntax. | |
| 99 | pub fn to_fusion_string(&self) -> String { | |
| 100 | let mut out = String::new(); | |
| 101 | write_table(self, 0, &mut out); | |
| 102 | out | |
| 103 | } | |
| 71 | 104 | } |
| 72 | 105 | |
| 73 | 106 | impl LuaValue { |
| ... | ... | @@ -78,6 +111,13 @@ impl LuaValue { |
| 78 | 111 | } |
| 79 | 112 | } |
| 80 | 113 | |
| 114 | pub fn as_table_mut(&mut self) -> Option<&mut LuaTable> { | |
| 115 | match self { | |
| 116 | LuaValue::Table(t) => Some(t), | |
| 117 | _ => None, | |
| 118 | } | |
| 119 | } | |
| 120 | ||
| 81 | 121 | pub fn as_str(&self) -> Option<&str> { |
| 82 | 122 | match self { |
| 83 | 123 | LuaValue::String(s) => Some(s.as_str()), |
| ... | ... | @@ -107,6 +147,13 @@ impl LuaValue { |
| 107 | 147 | _ => None, |
| 108 | 148 | } |
| 109 | 149 | } |
| 150 | ||
| 151 | /// Serializes this value using Blackmagic Fusion `.comp` Lua table syntax. | |
| 152 | pub fn to_fusion_string(&self) -> String { | |
| 153 | let mut out = String::new(); | |
| 154 | write_value(self, 0, &mut out); | |
| 155 | out | |
| 156 | } | |
| 110 | 157 | } |
| 111 | 158 | |
| 112 | 159 | #[derive(Clone, Debug)] |
| ... | ... | @@ -601,3 +648,247 @@ fn is_ident_start(b: u8) -> bool { |
| 601 | 648 | fn is_ident_cont(b: u8) -> bool { |
| 602 | 649 | b.is_ascii_alphanumeric() || b == b'_' |
| 603 | 650 | } |
| 651 | ||
| 652 | fn is_valid_lua_ident(s: &str) -> bool { | |
| 653 | let bytes = s.as_bytes(); | |
| 654 | if bytes.is_empty() || !is_ident_start(bytes[0]) || !bytes[1..].iter().all(|&b| is_ident_cont(b)) { | |
| 655 | return false; | |
| 656 | } | |
| 657 | !matches!( | |
| 658 | s, | |
| 659 | "and" | |
| 660 | | "break" | |
| 661 | | "do" | |
| 662 | | "else" | |
| 663 | | "elseif" | |
| 664 | | "end" | |
| 665 | | "false" | |
| 666 | | "for" | |
| 667 | | "function" | |
| 668 | | "goto" | |
| 669 | | "if" | |
| 670 | | "in" | |
| 671 | | "local" | |
| 672 | | "nil" | |
| 673 | | "not" | |
| 674 | | "or" | |
| 675 | | "repeat" | |
| 676 | | "return" | |
| 677 | | "then" | |
| 678 | | "true" | |
| 679 | | "until" | |
| 680 | | "while" | |
| 681 | ) | |
| 682 | } | |
| 683 | ||
| 684 | fn write_indent(out: &mut String, depth: usize) { | |
| 685 | for _ in 0..depth { | |
| 686 | out.push('\t'); | |
| 687 | } | |
| 688 | } | |
| 689 | ||
| 690 | fn write_number(n: f64, out: &mut String) { | |
| 691 | if n.is_nan() { | |
| 692 | out.push_str("nan"); | |
| 693 | } else if n.is_infinite() { | |
| 694 | if n.is_sign_negative() { | |
| 695 | out.push_str("-1e999"); | |
| 696 | } else { | |
| 697 | out.push_str("1e999"); | |
| 698 | } | |
| 699 | } else if n == 0.0 { | |
| 700 | out.push('0'); | |
| 701 | } else if n.fract() == 0.0 && n.abs() < 9_007_199_254_740_992.0 { | |
| 702 | use std::fmt::Write; | |
| 703 | let _ = write!(out, "{}", n as i64); | |
| 704 | } else { | |
| 705 | use std::fmt::Write; | |
| 706 | let _ = write!(out, "{n}"); | |
| 707 | } | |
| 708 | } | |
| 709 | ||
| 710 | fn write_string(s: &str, out: &mut String) { | |
| 711 | use std::fmt::Write; | |
| 712 | out.push('"'); | |
| 713 | for c in s.chars() { | |
| 714 | match c { | |
| 715 | '\\' => out.push_str("\\\\"), | |
| 716 | '"' => out.push_str("\\\""), | |
| 717 | '\n' => out.push_str("\\n"), | |
| 718 | '\r' => out.push_str("\\r"), | |
| 719 | '\t' => out.push_str("\\t"), | |
| 720 | c if (c as u32) < 0x20 || (c as u32) == 0x7F => { | |
| 721 | let _ = write!(out, "\\{:03}", c as u32); | |
| 722 | } | |
| 723 | c => out.push(c), | |
| 724 | } | |
| 725 | } | |
| 726 | out.push('"'); | |
| 727 | } | |
| 728 | ||
| 729 | fn write_value(val: &LuaValue, depth: usize, out: &mut String) { | |
| 730 | match val { | |
| 731 | LuaValue::Nil => out.push_str("nil"), | |
| 732 | LuaValue::Bool(true) => out.push_str("true"), | |
| 733 | LuaValue::Bool(false) => out.push_str("false"), | |
| 734 | LuaValue::Number(n) => write_number(*n, out), | |
| 735 | LuaValue::String(s) => write_string(s, out), | |
| 736 | LuaValue::Table(t) => write_table(t, depth, out), | |
| 737 | } | |
| 738 | } | |
| 739 | ||
| 740 | fn split_call_args(tbl: &LuaTable) -> (Vec<&LuaValue>, Vec<&(LuaKey, LuaValue)>) { | |
| 741 | let mut call_args = Vec::new(); | |
| 742 | let mut next_arg = 0usize; | |
| 743 | let mut arg_indices = Vec::new(); | |
| 744 | for (idx, (k, v)) in tbl.entries.iter().enumerate() { | |
| 745 | if let LuaKey::Str(s) = k { | |
| 746 | if let Some(rest) = s.strip_prefix("__arg") { | |
| 747 | if rest.parse::<usize>().ok() == Some(next_arg) { | |
| 748 | call_args.push(v); | |
| 749 | arg_indices.push(idx); | |
| 750 | next_arg += 1; | |
| 751 | continue; | |
| 752 | } | |
| 753 | } | |
| 754 | } | |
| 755 | } | |
| 756 | let body = tbl | |
| 757 | .entries | |
| 758 | .iter() | |
| 759 | .enumerate() | |
| 760 | .filter(|(idx, _)| !arg_indices.contains(idx)) | |
| 761 | .map(|(_, e)| e) | |
| 762 | .collect(); | |
| 763 | (call_args, body) | |
| 764 | } | |
| 765 | ||
| 766 | fn can_use_positional(body: &[&(LuaKey, LuaValue)]) -> bool { | |
| 767 | let mut expected = 1i64; | |
| 768 | let mut index_count = 0usize; | |
| 769 | for (k, _) in body { | |
| 770 | match k { | |
| 771 | LuaKey::Number(_) => return false, | |
| 772 | LuaKey::Index(i) => { | |
| 773 | if *i != expected { | |
| 774 | return false; | |
| 775 | } | |
| 776 | expected += 1; | |
| 777 | index_count += 1; | |
| 778 | } | |
| 779 | LuaKey::Str(_) => {} | |
| 780 | } | |
| 781 | } | |
| 782 | if index_count == 1 && body.len() == 1 { | |
| 783 | if let (LuaKey::Index(1), LuaValue::Table(sub)) = body[0] { | |
| 784 | if sub.tag.is_none() | |
| 785 | && (sub.get("Flags").is_some() || sub.get("LH").is_some() || sub.get("RH").is_some()) | |
| 786 | { | |
| 787 | return false; | |
| 788 | } | |
| 789 | } | |
| 790 | } | |
| 791 | true | |
| 792 | } | |
| 793 | ||
| 794 | fn can_inline_table(tbl: &LuaTable, max_depth: usize) -> bool { | |
| 795 | if max_depth == 0 { | |
| 796 | return false; | |
| 797 | } | |
| 798 | if tbl.tag.as_deref() == Some("ordered") { | |
| 799 | return false; | |
| 800 | } | |
| 801 | let (call_args, body) = split_call_args(tbl); | |
| 802 | if !call_args.is_empty() || body.len() > 4 { | |
| 803 | return false; | |
| 804 | } | |
| 805 | body.iter().all(|(_, v)| match v { | |
| 806 | LuaValue::Nil | LuaValue::Bool(_) | LuaValue::Number(_) => true, | |
| 807 | LuaValue::String(s) => !s.contains('\n') && !s.contains('\r') && s.len() <= 48, | |
| 808 | LuaValue::Table(sub) => max_depth > 1 && can_inline_table(sub, max_depth - 1), | |
| 809 | }) | |
| 810 | } | |
| 811 | ||
| 812 | fn write_table_prefix(tag: Option<&str>, call_args: &[&LuaValue], depth: usize, out: &mut String) { | |
| 813 | if let Some(t) = tag { | |
| 814 | out.push_str(t); | |
| 815 | if t == "ordered" || !call_args.is_empty() { | |
| 816 | out.push('('); | |
| 817 | for (i, arg) in call_args.iter().enumerate() { | |
| 818 | if i > 0 { | |
| 819 | out.push_str(", "); | |
| 820 | } | |
| 821 | write_value(arg, depth, out); | |
| 822 | } | |
| 823 | out.push(')'); | |
| 824 | } | |
| 825 | out.push(' '); | |
| 826 | } | |
| 827 | } | |
| 828 | ||
| 829 | fn write_entry_key(key: &LuaKey, positional: bool, out: &mut String) -> bool { | |
| 830 | match key { | |
| 831 | LuaKey::Index(_) if positional => false, | |
| 832 | LuaKey::Index(i) => { | |
| 833 | use std::fmt::Write; | |
| 834 | let _ = write!(out, "[{i}] = "); | |
| 835 | true | |
| 836 | } | |
| 837 | LuaKey::Number(n) => { | |
| 838 | out.push('['); | |
| 839 | write_number(*n, out); | |
| 840 | out.push_str("] = "); | |
| 841 | true | |
| 842 | } | |
| 843 | LuaKey::Str(s) => { | |
| 844 | if is_valid_lua_ident(s) { | |
| 845 | out.push_str(s); | |
| 846 | out.push_str(" = "); | |
| 847 | } else { | |
| 848 | out.push('['); | |
| 849 | write_string(s, out); | |
| 850 | out.push_str("] = "); | |
| 851 | } | |
| 852 | true | |
| 853 | } | |
| 854 | } | |
| 855 | } | |
| 856 | ||
| 857 | fn write_table(tbl: &LuaTable, depth: usize, out: &mut String) { | |
| 858 | let (call_args, body) = split_call_args(tbl); | |
| 859 | write_table_prefix(tbl.tag.as_deref(), &call_args, depth, out); | |
| 860 | ||
| 861 | if body.is_empty() { | |
| 862 | out.push_str("{}"); | |
| 863 | return; | |
| 864 | } | |
| 865 | ||
| 866 | let positional = can_use_positional(&body); | |
| 867 | ||
| 868 | if depth > 0 && can_inline_table(tbl, 2) { | |
| 869 | let mut inline = String::new(); | |
| 870 | inline.push_str("{ "); | |
| 871 | for (i, (k, v)) in body.iter().enumerate() { | |
| 872 | if i > 0 { | |
| 873 | inline.push_str(", "); | |
| 874 | } | |
| 875 | write_entry_key(k, positional, &mut inline); | |
| 876 | write_value(v, depth + 1, &mut inline); | |
| 877 | } | |
| 878 | inline.push_str(" }"); | |
| 879 | if !inline.contains('\n') && inline.len() <= 100 { | |
| 880 | out.push_str(&inline); | |
| 881 | return; | |
| 882 | } | |
| 883 | } | |
| 884 | ||
| 885 | out.push_str("{\n"); | |
| 886 | for (k, v) in body { | |
| 887 | write_indent(out, depth + 1); | |
| 888 | write_entry_key(k, positional, out); | |
| 889 | write_value(v, depth + 1, out); | |
| 890 | out.push_str(",\n"); | |
| 891 | } | |
| 892 | write_indent(out, depth); | |
| 893 | out.push('}'); | |
| 894 | } |
crates/studio/src/main.rs+225-9| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | //! built on Knife's `draw`, `ui`, `dock`, and `theme::KNIFE` (soft toned quiet iris). |
| 3 | 3 | |
| 4 | 4 | use dock::{Axis as DockAxis, Command, Dock, Event, GroupId, Node as DockNode, Part as DockPart, Place, Plus, Side, SplitId, Tab}; |
| 5 | use engine::{CacheMode, Engine}; | |
| 5 | use engine::{AudioPlayer, AudioTrack, CacheMode, Engine, ExportOptions, export_saver_png_sequence}; | |
| 6 | 6 | use flow::{FlowAction, FlowView}; |
| 7 | 7 | use model::Comp; |
| 8 | 8 | use spline::{SplineAction, SplineView}; |
| ... | ... | @@ -10,7 +10,7 @@ use std::collections::HashMap; |
| 10 | 10 | use std::error::Error; |
| 11 | 11 | use std::fs::File; |
| 12 | 12 | use std::path::{Path, PathBuf}; |
| 13 | use std::sync::Arc; | |
| 13 | use std::sync::{Arc, mpsc}; | |
| 14 | 14 | use std::time::{Duration, Instant}; |
| 15 | 15 | use ui::host::{Accessibility, Clipboard, Surface}; |
| 16 | 16 | use viewer::{PlaybackClock, SyncMode, ViewerAction, ViewerState}; |
| ... | ... | @@ -93,7 +93,11 @@ struct Studio { |
| 93 | 93 | renderer: draw::Renderer, |
| 94 | 94 | engine: Engine, |
| 95 | 95 | comp: Comp, |
| 96 | saved_revision: u64, | |
| 96 | 97 | playback: PlaybackClock, |
| 98 | audio_player: Option<AudioPlayer>, | |
| 99 | audio_rx: Option<mpsc::Receiver<Result<AudioTrack, String>>>, | |
| 100 | status_notice: Option<(String, Instant)>, | |
| 97 | 101 | viewers: [ViewerState; 2], |
| 98 | 102 | flow: FlowView, |
| 99 | 103 | spline: SplineView, |
| ... | ... | @@ -103,7 +107,14 @@ struct Studio { |
| 103 | 107 | } |
| 104 | 108 | |
| 105 | 109 | impl Studio { |
| 106 | fn new(renderer: draw::Renderer, comp: Comp, init_frame: Option<f64>, select_node: Option<&str>, dual_viewer: bool) -> Self { | |
| 110 | fn new( | |
| 111 | renderer: draw::Renderer, | |
| 112 | comp: Comp, | |
| 113 | init_frame: Option<f64>, | |
| 114 | select_node: Option<&str>, | |
| 115 | dual_viewer: bool, | |
| 116 | enable_audio: bool, | |
| 117 | ) -> Self { | |
| 107 | 118 | let engine = Engine::new(renderer.device().clone(), renderer.queue().clone()); |
| 108 | 119 | // Knife's soft toned Iris quiet-layered theme! |
| 109 | 120 | let ui_theme = ui::Theme::new(&theme::KNIFE, true); |
| ... | ... | @@ -206,6 +217,32 @@ impl Studio { |
| 206 | 217 | let mut spline = SplineView::new(&ui_theme); |
| 207 | 218 | spline.set_target_node(&comp, default_sel); |
| 208 | 219 | |
| 220 | let (audio_player, audio_rx) = if enable_audio { | |
| 221 | let player = match AudioPlayer::new() { | |
| 222 | Ok(p) => Some(p), | |
| 223 | Err(e) => { | |
| 224 | eprintln!("fission audio disabled: {e}"); | |
| 225 | None | |
| 226 | } | |
| 227 | }; | |
| 228 | let rx = comp.audio_filename.as_ref().and_then(|af| { | |
| 229 | let p = PathBuf::from(af); | |
| 230 | if !p.exists() { | |
| 231 | return None; | |
| 232 | } | |
| 233 | let (tx, rx) = mpsc::channel(); | |
| 234 | std::thread::spawn(move || { | |
| 235 | let _ = tx.send(AudioTrack::load(&p)); | |
| 236 | }); | |
| 237 | Some(rx) | |
| 238 | }); | |
| 239 | (player, rx) | |
| 240 | } else { | |
| 241 | (None, None) | |
| 242 | }; | |
| 243 | ||
| 244 | let saved_revision = comp.revision; | |
| 245 | ||
| 209 | 246 | Self { |
| 210 | 247 | ui, |
| 211 | 248 | dock, |
| ... | ... | @@ -214,7 +251,11 @@ impl Studio { |
| 214 | 251 | renderer, |
| 215 | 252 | engine, |
| 216 | 253 | comp, |
| 254 | saved_revision, | |
| 217 | 255 | playback, |
| 256 | audio_player, | |
| 257 | audio_rx, | |
| 258 | status_notice: None, | |
| 218 | 259 | viewers: [v1, v2], |
| 219 | 260 | flow, |
| 220 | 261 | spline, |
| ... | ... | @@ -224,6 +265,143 @@ impl Studio { |
| 224 | 265 | } |
| 225 | 266 | } |
| 226 | 267 | |
| 268 | fn audio_time_secs(&self) -> f64 { | |
| 269 | (self.playback.current_frame - self.comp.audio_offset) / self.comp.fps.max(1.0) | |
| 270 | } | |
| 271 | ||
| 272 | fn poll_audio_load(&mut self) { | |
| 273 | let Some(rx) = &self.audio_rx else { return }; | |
| 274 | match rx.try_recv() { | |
| 275 | Ok(Ok(track)) => { | |
| 276 | eprintln!( | |
| 277 | "Loaded audio {} ({:.2}s @ {}Hz)", | |
| 278 | track.path.display(), | |
| 279 | track.duration_secs, | |
| 280 | track.sample_rate | |
| 281 | ); | |
| 282 | let t = self.audio_time_secs(); | |
| 283 | let playing = self.playback.playing; | |
| 284 | if let Some(player) = &mut self.audio_player { | |
| 285 | player.set_track(Some(Arc::new(track))); | |
| 286 | if playing { | |
| 287 | player.play_from(t); | |
| 288 | } | |
| 289 | } | |
| 290 | self.audio_rx = None; | |
| 291 | } | |
| 292 | Ok(Err(e)) => { | |
| 293 | eprintln!("fission audio load error: {e}"); | |
| 294 | self.audio_rx = None; | |
| 295 | } | |
| 296 | Err(mpsc::TryRecvError::Disconnected) => { | |
| 297 | self.audio_rx = None; | |
| 298 | } | |
| 299 | Err(mpsc::TryRecvError::Empty) => {} | |
| 300 | } | |
| 301 | } | |
| 302 | ||
| 303 | fn sync_audio(&mut self, state_changed: bool, seeked: bool) { | |
| 304 | let t = self.audio_time_secs(); | |
| 305 | let playing = self.playback.playing; | |
| 306 | if let Some(player) = &mut self.audio_player { | |
| 307 | if playing { | |
| 308 | if state_changed || !player.is_playing() { | |
| 309 | player.play_from(t); | |
| 310 | } else if seeked { | |
| 311 | player.seek(t); | |
| 312 | } | |
| 313 | } else if state_changed || player.is_playing() { | |
| 314 | player.pause(); | |
| 315 | } | |
| 316 | } | |
| 317 | } | |
| 318 | ||
| 319 | fn save_comp(&mut self) -> Result<String, String> { | |
| 320 | let Some(path) = self.comp.path.clone() else { | |
| 321 | return Err("comp has no file path to save".to_owned()); | |
| 322 | }; | |
| 323 | self.comp.current_time = self.playback.current_frame; | |
| 324 | match self.comp.save_to_file(&path) { | |
| 325 | Ok(backup) => { | |
| 326 | self.saved_revision = self.comp.revision; | |
| 327 | let msg = match backup { | |
| 328 | Some(bak) => { | |
| 329 | eprintln!("Saved {} (backup -> {})", path.display(), bak.display()); | |
| 330 | format!("Saved (backup in temp)") | |
| 331 | } | |
| 332 | None => { | |
| 333 | eprintln!("Saved {}", path.display()); | |
| 334 | "Saved".to_owned() | |
| 335 | } | |
| 336 | }; | |
| 337 | self.status_notice = Some((msg.clone(), Instant::now())); | |
| 338 | Ok(msg) | |
| 339 | } | |
| 340 | Err(e) => { | |
| 341 | let err = format!("Save failed: {e}"); | |
| 342 | eprintln!("{err}"); | |
| 343 | self.status_notice = Some((err.clone(), Instant::now())); | |
| 344 | Err(err) | |
| 345 | } | |
| 346 | } | |
| 347 | } | |
| 348 | ||
| 349 | fn export_saver_pngs(&mut self) -> Result<String, String> { | |
| 350 | if self.playback.playing { | |
| 351 | self.playback.toggle_play(Instant::now()); | |
| 352 | self.sync_audio(true, false); | |
| 353 | } | |
| 354 | let opts = ExportOptions { | |
| 355 | hiq: self.engine.hiq, | |
| 356 | proxy_scale: self.engine.proxy_scale, | |
| 357 | ..Default::default() | |
| 358 | }; | |
| 359 | let t0 = Instant::now(); | |
| 360 | match export_saver_png_sequence(&mut self.engine, &self.comp, &opts, |p| { | |
| 361 | if p.index == 0 || (p.index + 1) % 10 == 0 || p.index + 1 == p.total { | |
| 362 | let fps = (p.index + 1) as f64 / t0.elapsed().as_secs_f64().max(1e-6); | |
| 363 | eprintln!( | |
| 364 | " [export {}/{}] {} f{:04} ({:.1}ms, {:.1} fps) -> {}", | |
| 365 | p.index + 1, | |
| 366 | p.total, | |
| 367 | p.saver_name, | |
| 368 | p.frame, | |
| 369 | p.eval_ms, | |
| 370 | fps, | |
| 371 | p.out_path.display() | |
| 372 | ); | |
| 373 | } | |
| 374 | }) { | |
| 375 | Ok(summary) => { | |
| 376 | let secs = (summary.total_ms / 1000.0).max(1e-6); | |
| 377 | let msg = format!( | |
| 378 | "Exported {} PNGs ({:.1} fps)", | |
| 379 | summary.frames_written, | |
| 380 | summary.frames_written as f64 / secs | |
| 381 | ); | |
| 382 | eprintln!("{msg} via {}", summary.saver_name); | |
| 383 | self.status_notice = Some((msg.clone(), Instant::now())); | |
| 384 | Ok(msg) | |
| 385 | } | |
| 386 | Err(e) => { | |
| 387 | let err = format!("Export failed: {e}"); | |
| 388 | eprintln!("{err}"); | |
| 389 | self.status_notice = Some((err.clone(), Instant::now())); | |
| 390 | Err(err) | |
| 391 | } | |
| 392 | } | |
| 393 | } | |
| 394 | ||
| 395 | fn window_title(&self) -> String { | |
| 396 | let dirty = if self.comp.revision != self.saved_revision { " •" } else { "" }; | |
| 397 | if let Some((msg, at)) = &self.status_notice { | |
| 398 | if at.elapsed() < Duration::from_secs(5) { | |
| 399 | return format!("Fission — {}{dirty} — {msg}", self.comp.name); | |
| 400 | } | |
| 401 | } | |
| 402 | format!("Fission — {}{dirty}", self.comp.name) | |
| 403 | } | |
| 404 | ||
| 227 | 405 | fn ensure_viewer2_open(&mut self) { |
| 228 | 406 | if self.layout.group_of(&"Viewer 2".to_owned(), String::clone).is_some() { |
| 229 | 407 | return; |
| ... | ... | @@ -246,8 +424,14 @@ impl Studio { |
| 246 | 424 | |
| 247 | 425 | fn frame(&mut self, now: Instant) -> bool { |
| 248 | 426 | self.clock = now; |
| 427 | self.poll_audio_load(); | |
| 428 | let prev_frame = self.playback.current_frame; | |
| 249 | 429 | let (animating, frame_changed) = self.playback.tick(&self.comp, now); |
| 250 | 430 | if frame_changed { |
| 431 | // Re-sync audio when playback loops back to start of render range | |
| 432 | if self.playback.playing && self.playback.current_frame < prev_frame { | |
| 433 | self.sync_audio(false, true); | |
| 434 | } | |
| 251 | 435 | for v in &mut self.viewers { |
| 252 | 436 | v.dirty = true; |
| 253 | 437 | } |
| ... | ... | @@ -270,6 +454,7 @@ impl Studio { |
| 270 | 454 | .map(|&name| ui::popup::Item { text: name, ..Default::default() }) |
| 271 | 455 | .collect(); |
| 272 | 456 | |
| 457 | let comp_unsaved = self.comp.revision != self.saved_revision; | |
| 273 | 458 | let Studio { |
| 274 | 459 | ui, |
| 275 | 460 | dock, |
| ... | ... | @@ -308,7 +493,7 @@ impl Studio { |
| 308 | 493 | Tab { |
| 309 | 494 | title: name, |
| 310 | 495 | icon: None, |
| 311 | unsaved: false, | |
| 496 | unsaved: name == "Flow" && comp_unsaved, | |
| 312 | 497 | closable: true, |
| 313 | 498 | action: None, |
| 314 | 499 | background: bg, |
| ... | ... | @@ -447,6 +632,7 @@ impl Studio { |
| 447 | 632 | } |
| 448 | 633 | SplineAction::ScrubFrame(f) => { |
| 449 | 634 | if self.playback.set_frame(&self.comp, f, now) { |
| 635 | self.sync_audio(false, true); | |
| 450 | 636 | for v in &mut self.viewers { |
| 451 | 637 | v.dirty = true; |
| 452 | 638 | } |
| ... | ... | @@ -471,9 +657,13 @@ impl Studio { |
| 471 | 657 | fn route_viewer_actions(&mut self, actions: Vec<(usize, ViewerAction)>, now: Instant) { |
| 472 | 658 | for (slot, a) in actions { |
| 473 | 659 | match a { |
| 474 | ViewerAction::TogglePlay => self.playback.toggle_play(now), | |
| 660 | ViewerAction::TogglePlay => { | |
| 661 | self.playback.toggle_play(now); | |
| 662 | self.sync_audio(true, false); | |
| 663 | } | |
| 475 | 664 | ViewerAction::SetFrame(f) => { |
| 476 | 665 | if self.playback.set_frame(&self.comp, f, now) { |
| 666 | self.sync_audio(false, true); | |
| 477 | 667 | for v in &mut self.viewers { |
| 478 | 668 | v.dirty = true; |
| 479 | 669 | } |
| ... | ... | @@ -613,7 +803,7 @@ fn run_snapshot(cli: &Cli, out_path: &Path) -> Result<(), Box<dyn Error>> { |
| 613 | 803 | }))?; |
| 614 | 804 | let renderer = draw::Renderer::new(device, queue, wgpu::TextureFormat::Rgba8Unorm); |
| 615 | 805 | |
| 616 | let mut studio = Studio::new(renderer, comp, cli.frame, cli.select_node.as_deref(), cli.dual_viewer); | |
| 806 | let mut studio = Studio::new(renderer, comp, cli.frame, cli.select_node.as_deref(), cli.dual_viewer, false); | |
| 617 | 807 | studio.size = [1440.0, 900.0]; |
| 618 | 808 | studio.scale = 2.0; |
| 619 | 809 | |
| ... | ... | @@ -702,13 +892,13 @@ fn run_window(cli: &Cli) -> Result<(), Box<dyn Error>> { |
| 702 | 892 | impl WindowHost { |
| 703 | 893 | fn new(event_loop: &ActiveEventLoop, proxy: EventLoopProxy<UserEvent>, cli: &Cli) -> Result<Self, Box<dyn Error>> { |
| 704 | 894 | let comp = Comp::from_fusion_file(&cli.comp_path)?; |
| 705 | let title = format!("Compositor — {}", comp.name); | |
| 895 | let title = format!("Fission — {}", comp.name); | |
| 706 | 896 | let attrs = Window::default_attributes() |
| 707 | 897 | .with_title(title) |
| 708 | 898 | .with_inner_size(LogicalSize::new(1440.0, 900.0)); |
| 709 | 899 | let (window, access) = Accessibility::window(event_loop, attrs, [640.0, 420.0], proxy.clone(), ui::Id::ROOT)?; |
| 710 | 900 | let (surface, renderer) = pollster::block_on(Surface::new(window.clone()))?; |
| 711 | let mut studio = Studio::new(renderer, comp, cli.frame, cli.select_node.as_deref(), cli.dual_viewer); | |
| 901 | let mut studio = Studio::new(renderer, comp, cli.frame, cli.select_node.as_deref(), cli.dual_viewer, true); | |
| 712 | 902 | studio.ui.window_focused = window.has_focus(); |
| 713 | 903 | studio.ui.clipboard = Clipboard::system(); |
| 714 | 904 | window.request_redraw(); |
| ... | ... | @@ -733,6 +923,7 @@ impl WindowHost { |
| 733 | 923 | } |
| 734 | 924 | self.studio.size = pixels.map(|s| s as f32 / self.studio.scale); |
| 735 | 925 | let wants_more = self.studio.frame(now); |
| 926 | self.window.set_title(&self.studio.window_title()); | |
| 736 | 927 | |
| 737 | 928 | self.window.set_cursor(self.studio.ui.cursor().unwrap_or(CursorIcon::Default)); |
| 738 | 929 | self.access.update_views(&mut self.studio.ui, "Compositor", f64::from(self.studio.scale), Vec::new); |
| ... | ... | @@ -748,7 +939,31 @@ impl WindowHost { |
| 748 | 939 | } |
| 749 | 940 | |
| 750 | 941 | fn input(&mut self, event: ui::Event) { |
| 751 | // Global Space toggles playback and `` ` `` clears both viewers from any focused pane! | |
| 942 | // Global Cmd+S saves lossless .comp (with temp-folder .bak); Cmd+Shift+R exports Saver PNG sequence! | |
| 943 | let (is_cmd_s, is_cmd_shift_r) = match &event { | |
| 944 | ui::Event::KeyInput { physical, modifiers, state: ElementState::Pressed, repeat: false, .. } => ( | |
| 945 | modifiers.super_key() && !modifiers.shift_key() && *physical == PhysicalKey::Code(KeyCode::KeyS), | |
| 946 | modifiers.super_key() && modifiers.shift_key() && *physical == PhysicalKey::Code(KeyCode::KeyR), | |
| 947 | ), | |
| 948 | ui::Event::Key { key: Key::Character(c), modifiers, .. } => ( | |
| 949 | modifiers.super_key() && !modifiers.shift_key() && c.eq_ignore_ascii_case("s"), | |
| 950 | modifiers.super_key() && modifiers.shift_key() && c.eq_ignore_ascii_case("r"), | |
| 951 | ), | |
| 952 | _ => (false, false), | |
| 953 | }; | |
| 954 | if is_cmd_s { | |
| 955 | let _ = self.studio.save_comp(); | |
| 956 | self.window.set_title(&self.studio.window_title()); | |
| 957 | self.window.request_redraw(); | |
| 958 | return; | |
| 959 | } | |
| 960 | if is_cmd_shift_r { | |
| 961 | let _ = self.studio.export_saver_pngs(); | |
| 962 | self.window.set_title(&self.studio.window_title()); | |
| 963 | self.window.request_redraw(); | |
| 964 | return; | |
| 965 | } | |
| 966 | // Global Space toggles playback (synced with audio) and `` ` `` clears both viewers from any focused pane! | |
| 752 | 967 | let is_space = matches!( |
| 753 | 968 | &event, |
| 754 | 969 | ui::Event::KeyInput { key: Key::Named(NamedKey::Space), state: ElementState::Pressed, repeat: false, .. } |
| ... | ... | @@ -756,6 +971,7 @@ impl WindowHost { |
| 756 | 971 | ); |
| 757 | 972 | if is_space { |
| 758 | 973 | self.studio.playback.toggle_play(Instant::now()); |
| 974 | self.studio.sync_audio(true, false); | |
| 759 | 975 | self.window.request_redraw(); |
| 760 | 976 | return; |
| 761 | 977 | } |
scripts/gen_compatibility.py created+544| ... | ... | @@ -0,0 +1,544 @@ |
| 1 | #!/usr/bin/env python3 | |
| 2 | """Generate compatibility.md from live Rust engine sources and real Fusion .comp corpora. | |
| 3 | ||
| 4 | Stdlib-only Python 3 script. Run from anywhere: | |
| 5 | python3 scripts/gen_compatibility.py | |
| 6 | """ | |
| 7 | ||
| 8 | from __future__ import annotations | |
| 9 | ||
| 10 | import argparse | |
| 11 | import re | |
| 12 | import sys | |
| 13 | from collections import Counter | |
| 14 | from dataclasses import dataclass | |
| 15 | from pathlib import Path | |
| 16 | from typing import Dict, List, Optional, Sequence, Set, Tuple | |
| 17 | ||
| 18 | REPO_ROOT = Path(__file__).resolve().parent.parent | |
| 19 | EVAL_RS = REPO_ROOT / "crates" / "engine" / "src" / "eval.rs" | |
| 20 | SCENE3D_RS = REPO_ROOT / "crates" / "engine" / "src" / "scene3d.rs" | |
| 21 | COMP_RS = REPO_ROOT / "crates" / "model" / "src" / "comp.rs" | |
| 22 | PROBES_PY = REPO_ROOT / "scripts" / "fusion_probes.py" | |
| 23 | DEFAULT_OUTPUT = REPO_ROOT / "compatibility.md" | |
| 24 | ||
| 25 | ACTIVE_CORPUS_DIR = Path("/Volumes/Project/trees/fusion") | |
| 26 | ARCHIVE_CORPUS_DIR = REPO_ROOT / "private" / "samples" | |
| 27 | SHALE_ISSUES_URL = "https://shale.paperclover.net/fission/issues" | |
| 28 | ||
| 29 | ||
| 30 | @dataclass(frozen=True) | |
| 31 | class ToolMeta: | |
| 32 | name: str | |
| 33 | category: str | |
| 34 | probe: str | |
| 35 | mae: str | |
| 36 | notes: str | |
| 37 | aliases: Tuple[str, ...] = () | |
| 38 | ||
| 39 | ||
| 40 | CATEGORIES: Sequence[str] = ( | |
| 41 | "Generators", | |
| 42 | "Compositing & Blending", | |
| 43 | "Color & Depth", | |
| 44 | "Keying", | |
| 45 | "Blur, Sharpen & Glow", | |
| 46 | "Transform, Warp & Framing", | |
| 47 | "Masks", | |
| 48 | "3D Pipeline", | |
| 49 | "Time, Routing & Utility", | |
| 50 | ) | |
| 51 | ||
| 52 | # Structured metadata for every supported Flow tool. | |
| 53 | # Any tool discovered in eval.rs / scene3d.rs that is missing here will be | |
| 54 | # flagged automatically so compatibility.md never drifts stale. | |
| 55 | TOOL_METADATA: Sequence[ToolMeta] = ( | |
| 56 | # Generators | |
| 57 | ToolMeta("Background", "Generators", "`tier1_d`", "0.0%", "Solid, Horizontal/Vertical/4-Corner, Linear/Radial gradients; honors generator `Depth` in `HiQ`."), | |
| 58 | ToolMeta("FastNoise", "Generators", "`noise_text`", "Visual*", "C2 quintic 3D Perlin fBm (`Detail`, `Contrast`, `Brightness`, `Seethe`, `LockXY`, `Angle`, `Discontinuous`, `Gradient`/`TwoColor`). *Proprietary Fusion lattice table differs ([#6](" + SHALE_ISSUES_URL + "/6))."), | |
| 59 | ToolMeta("Plasma", "Generators", "`tier1_c`", "0.1%–0.2%", "4-circle linear/sine interference pattern with phase/scale animation."), | |
| 60 | ToolMeta("TextPlus", "Generators", "`text`, `noise_text`", "0.1%–0.6%", "CoreText rasterizer, alignment, tracking, Euclidean subpixel SDF outline, `StyledTextCLS`. `BorderFill` tracked in [#6](" + SHALE_ISSUES_URL + "/6)."), | |
| 61 | ToolMeta("Loader", "Generators", "All suites", "0.0%", "PNG/JPG/TIFF/EXR stills & sequences; native macOS `AVFoundation`/`VideoToolbox` + `ffmpeg` video; `.wav`/`.mp3` audio. Direct 16/32-bit float EXR upload tracked in [#5](" + SHALE_ISSUES_URL + "/5)."), | |
| 62 | ||
| 63 | # Compositing & Blending | |
| 64 | ToolMeta("Merge", "Compositing & Blending", "`merge`", "0.0%–0.3%", "All ApplyModes (`Normal`, `Screen`, `Multiply`, `Difference`, `DarkerColor`, `Overlay`, `Hard/Soft/Linear/VividLight`, `LinearDodge`, etc.), `Operator=Over/Under`, `Gain`, `BurnIn`, `SubtractiveAdditive`, `Blend`, effect mask."), | |
| 65 | ToolMeta("Dissolve", "Compositing & Blending", "`tier1_b`", "0.0%–0.1%", "Mix (`Mix = 0..1`) between `Background` and `Foreground` with effect mask support."), | |
| 66 | ToolMeta("Shadow", "Compositing & Blending", "`tier1_b`", "0.1%–0.4%", "Drop shadow offset, softness blur, tint color/alpha, and `ShadowOnly` output."), | |
| 67 | ||
| 68 | # Color & Depth | |
| 69 | ToolMeta("BrightnessContrast", "Color & Depth", "`color_ops`, `tier1_d`", "0.0%–0.1%", "Gain, Lift, Gamma, Contrast, Brightness, Saturation, channel toggles, `PreDividePostMultiply`, `ClipBlack`/`ClipWhite`."), | |
| 70 | ToolMeta("ColorCorrector", "Color & Depth", "Suite comps", "0.1%–0.5%", "Master/Shadow/Midtone/Highlight wheel tint, Lift/Gamma/Gain/Brightness/Contrast/Saturation, `PreDividePostMultiply`."), | |
| 71 | ToolMeta("ColorGain", "Color & Depth", "`color_ops`, `noise_text`", "0.0%–0.1%", "Per-channel Gain, Lift, Gamma, Hue, Saturation, `PreDividePostMultiply`."), | |
| 72 | ToolMeta("ColorCurves", "Color & Depth", "Suite comps", "0.1%–0.4%", "Per-channel RGBA `LUTBezier` spline lookup tables with `PreDividePostMultiply`."), | |
| 73 | ToolMeta("HueCurves", "Color & Depth", "`tier1_a`", "0.1%–0.5%", "9 nested `LUTBezier` splines (Hue/Sat/Lum vs Hue, Suppression, etc.) baked to GPU LUT."), | |
| 74 | ToolMeta("GamutConvert", "Color & Depth", "Suite comps", "0.0%–0.2%", "Color space & gamma curve transforms (`sRGB`, `Rec.709`, `Linear`, `SLog2`, etc.)."), | |
| 75 | ToolMeta("InvertColor", "Color & Depth", "Suite comps", "0.0%", "Per-channel RGBA color inversion (`R`/`G`/`B`/`A` toggles)."), | |
| 76 | ToolMeta("ChannelBoolean", "Color & Depth", "`color_ops`", "0.0%–0.1%", "Channel routing (`ToRed`/`ToGreen`/`ToBlue`/`ToAlpha`) and arithmetic/logic ops (`Copy`, `Add`, `Subtract`, `Multiply`, `Divide`, `Min`, `Max`, `Clear`, `Solid`, etc.)."), | |
| 77 | ToolMeta("ChangeDepth", "Color & Depth", "`tier1_d`", "0.0%", "Bit-depth conversion (`int8`, `int16`, `float16`, `float32`) honored in `HiQ` mode; collapsed to `Rgba8Unorm` in `Fast` mode."), | |
| 78 | ToolMeta("Fuse.Colorize", "Color & Depth", "Suite comps", "0.1%–0.5%", "Gradient/tint colorization driven by luminance."), | |
| 79 | ||
| 80 | # Keying | |
| 81 | ToolMeta("LumaKeyer", "Keying", "Suite comps", "0.1%–0.4%", "Luminance/channel threshold keying with low/high feathering and matte inversion."), | |
| 82 | ToolMeta("UltraKeyer", "Keying", "`tier1_a`", "0.1%–0.6%", "Chroma keying with background color pick, matte threshold/gamma, spill suppression, and post-multiply."), | |
| 83 | ||
| 84 | # Blur, Sharpen & Glow | |
| 85 | ToolMeta("Blur", "Blur, Sharpen & Glow", "`blur`, `tier1_d`", "0.0%–0.4%", "`Fast Gaussian`, `Gaussian`, and `Box` filters; X/Y lock; `ClippingMode`; HDR float16 survival in `HiQ`; downsampled in `Fast`."), | |
| 86 | ToolMeta("Sharpen", "Blur, Sharpen & Glow", "`tier1_a`", "0.1%–0.4%", "Separable unsharp mask with X/Y amount & lock."), | |
| 87 | ToolMeta("Filter", "Blur, Sharpen & Glow", "`tier1_a`", "0.1%–0.5%", "Convolution filter types 0–4 (`Relief`, `Emboss`, `Smooth`, `Sobel`, `Laplacian`) with power & angle."), | |
| 88 | ToolMeta("VariBlur", "Blur, Sharpen & Glow", "Suite comps", "0.2%–0.8%", "Per-pixel variable-radius blur driven by `BlurImage` matte."), | |
| 89 | ToolMeta("DirectionalBlur", "Blur, Sharpen & Glow", "`blur`", "0.1%–0.5%", "`Linear`, `Centered`, `Radial`, and `Zoom` modes plus `Glow` accumulation."), | |
| 90 | ToolMeta("Glow", "Blur, Sharpen & Glow", "`glow`", "0.2%–1.3%", "Additive bloom (`Glow`, `GlowSize`, `Blend`, color scale). Minor Gaussian tail roll-off tracked in [#6](" + SHALE_ISSUES_URL + "/6)."), | |
| 91 | ToolMeta("SoftGlow", "Blur, Sharpen & Glow", "`glow`", "0.0%–0.8%", "Thresholded soft glow (`Gain`, `XGlowSize`/`YGlowSize`, `Threshold`, `ClippingMode`, `ColorScale`)."), | |
| 92 | ToolMeta("Fuse.XGlow", "Blur, Sharpen & Glow", "Suite comps", "0.2%–0.8%", "Multi-octave exponential glow (`Threshold`, `Gain`, `XGlowSize`, `Falloff`, `Iterations`); octave-capped in `Fast` mode."), | |
| 93 | ToolMeta("ErodeDilate", "Blur, Sharpen & Glow", "`blur`", "0.0%–0.3%", "Positive/negative morphological erode/dilate with `Box` and `Circle` kernels."), | |
| 94 | ToolMeta("FilmGrain", "Blur, Sharpen & Glow", "`tier1_c`", "Visual*", "Monochrome log-space correlated film grain (`Size`, `Strength`, `Softness`). *Stochastic per-frame seed."), | |
| 95 | ToolMeta("Fuse.Outline", "Blur, Sharpen & Glow", "Suite comps", "0.1%–0.5%", "Alpha-derived silhouette outline with thickness, softness, and color tint."), | |
| 96 | ToolMeta("Fuse.XfChroma", "Blur, Sharpen & Glow", "Suite comps", "0.1%–0.5%", "Chromatic aberration / RGB channel radial & positional dispersion."), | |
| 97 | ||
| 98 | # Transform, Warp & Framing | |
| 99 | ToolMeta("Transform", "Transform, Warp & Framing", "`xf`", "0.0%–0.3%", "`Center`, `Pivot`, `Size`/`XSize`/`YSize`, `Aspect`, `Angle`, `FlipHoriz`/`FlipVert`, `FilterMethod` (`Nearest`/`Box`/`Linear`/`Catmull-Rom`), `Edges` (`Canvas`/`Wrap`/`Duplicate`/`Mirror`)."), | |
| 100 | ToolMeta("CameraShake", "Transform, Warp & Framing", "`tier1_c`", "0.1%–0.5%", "Procedural X/Y/Rotation/Zoom camera shake with `OverallStrength`, `Speed`, `Edges`."), | |
| 101 | ToolMeta("CornerPositioner", "Transform, Warp & Framing", "`tier1_b`", "0.1%–0.4%", "4-point projective homography warp (`TopLeft`/`TopRight`/`BottomLeft`/`BottomRight`)."), | |
| 102 | ToolMeta("DVE", "Transform, Warp & Framing", "`tier1_b`", "0.1%–0.4%", "2.5D ZYX Euler rotation + perspective homography (`Center`, `ZMove`, `Pivot`, `AlphaMode`)."), | |
| 103 | ToolMeta("Displace", "Transform, Warp & Framing", "`displace`", "0.1%–0.7%", "`XY` refraction (channels, offsets, refraction strength) and `Radial`/`Bump` (`LightPower` angle/color minor parity tracked in [#6](" + SHALE_ISSUES_URL + "/6))."), | |
| 104 | ToolMeta("Scale", "Transform, Warp & Framing", "Suite comps", "0.0%–0.2%", "Proportional/non-proportional image scaling with resampling filter."), | |
| 105 | ToolMeta("BetterResize", "Transform, Warp & Framing", "Suite comps", "0.0%–0.2%", "Target pixel-dimension resize (`Width`, `Height`, `KeepAspect`)."), | |
| 106 | ToolMeta("Crop", "Transform, Warp & Framing", "Suite comps", "0.0%–0.1%", "Region crop & canvas repositioning (`XOffset`, `YOffset`, `XSize`, `YSize`, `KeepCentered`)."), | |
| 107 | ToolMeta("SetDomain", "Transform, Warp & Framing", "`tier1_d`", "0.0%–0.1%", "Domain-of-Definition (`Adjust` shrink/expand and `Set` modes)."), | |
| 108 | ||
| 109 | # Masks | |
| 110 | ToolMeta("EllipseMask", "Masks", "`mask`", "0.0%–0.2%", "Center, Width, Height, Angle, `SoftEdge`, `BorderWidth`, `Solid`, `Invert`, `PaintMode` chaining."), | |
| 111 | ToolMeta("RectangleMask", "Masks", "`mask`", "0.0%–0.2%", "Center, Width, Height, `CornerRadius`, Angle, `SoftEdge`, `BorderWidth`, `Solid`, `Invert`, `PaintMode` chaining."), | |
| 112 | ToolMeta("PolylineMask", "Masks", "Suite comps", "0.1%–0.5%", "CPU `zeno` Bezier/linear polygon rasterizer with animated keyframed `Polyline` splines, `SoftEdge`, `Invert`, `PaintMode`."), | |
| 113 | ToolMeta("BitmapMask", "Masks", "Suite comps", "0.0%–0.2%", "Image-to-mask extraction (`Alpha`/`Luminance`/`Red`/`Green`/`Blue`), `Low`/`High` clip, `SoftEdge`, `Invert`."), | |
| 114 | ||
| 115 | # 3D Pipeline | |
| 116 | ToolMeta("Renderer3D", "3D Pipeline", "`cam3d`, `cam3d_fov`", "0.1%–0.4%", "GPU wgpu 3D rasterizer with depth buffer, perspective camera selection, lighting, and 2D texture sampling."), | |
| 117 | ToolMeta("Camera3D", "3D Pipeline", "`cam3d`, `cam3d_fov`", "0.1%–0.4%", "All 6 `RotOrder` permutations (`XYZ`..`ZYX`), `AoV`/`FLength`, `ApertureW`/`ApertureH`, `ResolutionGateFit` (`Inside`/`Outside`/`Width`/`Height`/`Stretch`)."), | |
| 118 | ToolMeta("Merge3D", "3D Pipeline", "`cam3d`, `cam3d_fov`", "0.1%–0.4%", "Hierarchical 3D scene graph combiner with local `Transform3DOp`."), | |
| 119 | ToolMeta("Transform3D", "3D Pipeline", "`cam3d`, `cam3d_fov`", "0.1%–0.4%", "3D translate, rotate (all 6 `RotOrder`s), and scale (`ScaleLock`) transform node."), | |
| 120 | ToolMeta("ImagePlane3D", "3D Pipeline", "`cam3d`", "0.1%–0.4%", "Textured 3D quad driven by 2D image input or `Mtl*` diffuse texture."), | |
| 121 | ToolMeta("Shape3D", "3D Pipeline", "`cam3d`, `cam3d_fov`", "0.1%–0.4%", "`Plane`, `Sphere`, `Cylinder` (`StartSweep`/`EndSweep`, subdivisions), and `Cube` procedural geometry."), | |
| 122 | ToolMeta("LightAmbient", "3D Pipeline", "Suite comps", "0.1%–0.4%", "Scene ambient RGB light intensity accumulation in `Renderer3D`."), | |
| 123 | ToolMeta("LightDirectional", "3D Pipeline", "Suite comps", "0.1%–0.4%", "World-oriented directional light (`-Z` emission axis) with RGB intensity in `Renderer3D`."), | |
| 124 | ||
| 125 | # Time, Routing & Utility | |
| 126 | ToolMeta("Saver", "Time, Routing & Utility", "All suites", "0.0%", "Output sink / passthrough in interactive Flow; target selector for `render-check` CLI."), | |
| 127 | ToolMeta("TimeStretcher", "Time, Routing & Utility", "Suite comps", "0.0%", "Keyframed/expression `SourceTime` remapping upstream of evaluation (nearest/frame evaluation; Optical Flow tracked in [#4](" + SHALE_ISSUES_URL + "/4))."), | |
| 128 | ToolMeta("TimeSpeed", "Time, Routing & Utility", "Suite comps", "0.0%", "Constant/animated `Speed` and `Delay` time remapping."), | |
| 129 | ToolMeta("Switch", "Time, Routing & Utility", "Suite comps", "0.0%", "Dynamic input routing by `Which` index (`Input1`..`InputN`)."), | |
| 130 | ToolMeta("Fuse.Switch", "Time, Routing & Utility", "Suite comps", "0.0%", "Fuse variant of `Switch` routing `Input1`..`InputN` by `Which`."), | |
| 131 | ToolMeta("PipeRouter", "Time, Routing & Utility", "Suite comps", "0.0%", "Zero-cost graph routing node."), | |
| 132 | ToolMeta("Fuse.Wireless", "Time, Routing & Utility", "Suite comps", "0.0%", "Wireless link passthrough node."), | |
| 133 | ToolMeta("Tracker", "Time, Routing & Utility", "Suite comps", "0.0%", "Passthrough image node; baked tracking paths evaluated via `TrackerModifier`."), | |
| 134 | ToolMeta("MacroOperator", "Time, Routing & Utility", "Suite comps", "0.0%", "Unpacks internal `Tools` subgraph and evaluates exported output seamlessly."), | |
| 135 | ToolMeta("GroupOperator", "Time, Routing & Utility", "Suite comps", "0.0%", "Unpacks internal `Tools` subgraph and evaluates exported output seamlessly."), | |
| 136 | ToolMeta("Custom", "Time, Routing & Utility", "Suite comps", "0.1%–0.6%", "Custom Tool shader evaluation (procedural wave/channel expressions + `UserControls` defaults)."), | |
| 137 | ToolMeta("Note", "Time, Routing & Utility", "—", "N/A", "Non-rendering Flow sticky note; preserved losslessly on `.comp` roundtrip."), | |
| 138 | ToolMeta("Underlay", "Time, Routing & Utility", "—", "N/A", "Non-rendering Flow backdrop/group box; preserved losslessly on `.comp` roundtrip."), | |
| 139 | ) | |
| 140 | ||
| 141 | ||
| 142 | @dataclass(frozen=True) | |
| 143 | class ModifierMeta: | |
| 144 | display_name: str | |
| 145 | classes: Tuple[str, ...] | |
| 146 | probe: str | |
| 147 | notes: str | |
| 148 | ||
| 149 | ||
| 150 | MODIFIER_METADATA: Sequence[ModifierMeta] = ( | |
| 151 | ModifierMeta("`BezierSpline`", ("BezierSpline",), "All suites", "Cubic Bezier / linear / `StepIn` / `StepOut` keyframes, animated `StyledText`, and animated `Polyline` point splines."), | |
| 152 | ModifierMeta("`LUTBezier`", ("LUTBezier",), "`tier1_a`", "Curve lookup splines used standalone and nested inside `ColorCurves` / `HueCurves`."), | |
| 153 | ModifierMeta("`PolyPath` / `Path`", ("PolyPath", "Path"), "Suite comps", "2D motion-path polyline evaluation with animated `Displacement` spline."), | |
| 154 | ModifierMeta("`Shake`", ("Shake",), "`tier1_c`", "Procedural multi-octave noise modifier (`Source = X / Y / Value / Position`) with spline & expression inputs."), | |
| 155 | ModifierMeta("`StyledTextCLS`", ("StyledTextCLS", "CharacterLevelStyling"), "Suite comps", "Per-character `TextPlus` styling overrides (font, size, color, kerning, opacity)."), | |
| 156 | ModifierMeta("`TrackerModifier`", ("TrackerModifier",), "Suite comps", "Resolves baked tracker path aliases (`Track1TrackerPath`, etc.) into 2D `PolyPath` coordinates."), | |
| 157 | ModifierMeta("Lua Expressions", (), "Suite comps", "Inline `Expression = \"...\"` evaluation (`time`, `comp.RenderStart`/`End`, node input references, math/trig/clamp/ternary)."), | |
| 158 | ) | |
| 159 | ||
| 160 | ||
| 161 | @dataclass(frozen=True) | |
| 162 | class UnsupportedMeta: | |
| 163 | name: str | |
| 164 | behavior: str | |
| 165 | issue: Optional[int] = None | |
| 166 | ||
| 167 | ||
| 168 | # Curated notes for prominent real-world unsupported / OFX / Resolve tools. | |
| 169 | UNSUPPORTED_NOTES: Sequence[UnsupportedMeta] = ( | |
| 170 | UnsupportedMeta("SurfaceTracker", "Preserved lossless on save; passes through main image input in Flow.", 7), | |
| 171 | UnsupportedMeta("MagicMask", "Preserved lossless on save; passes through main image input in Flow.", 7), | |
| 172 | UnsupportedMeta("PlanarTracker", "Preserved lossless on save; passes through main image input in Flow.", 7), | |
| 173 | UnsupportedMeta("Fuse.Cryptomatte", "Preserved lossless on save; passes through main image input (multi-channel EXR matte extraction tracked).", 2), | |
| 174 | UnsupportedMeta("Dimension.OpticalFlow", "Preserved lossless on save; passes through main image input (GPU dense optical flow tracked).", 4), | |
| 175 | UnsupportedMeta("Dimension.CopyAux", "Preserved lossless on save; passes through main image input.", 4), | |
| 176 | UnsupportedMeta("pEmitter", "Preserved lossless on save; skipped in 3D scene until particle simulator lands.", 3), | |
| 177 | UnsupportedMeta("pRender", "Preserved lossless on save; skipped / passthrough until particle simulator lands.", 3), | |
| 178 | UnsupportedMeta("pPointForce", "Preserved lossless on save; skipped in 3D scene until particle simulator lands.", 3), | |
| 179 | UnsupportedMeta("SurfaceFBXMesh", "Preserved lossless on save; FBX mesh geometry not yet imported in `Renderer3D`.", None), | |
| 180 | UnsupportedMeta("Text3D", "Preserved lossless on save; extruded 3D text mesh not yet implemented in `Renderer3D`.", None), | |
| 181 | UnsupportedMeta("MtlBlinn", "Preserved lossless on save; basic diffuse color & texture resolved in `Renderer3D` (full Blinn specular/bump pending).", None), | |
| 182 | UnsupportedMeta("MtlCookTorrance", "Preserved lossless on save; basic diffuse color & texture resolved in `Renderer3D` (full Cook-Torrance BRDF pending).", None), | |
| 183 | UnsupportedMeta("WandMask", "Preserved lossless on save; flood-fill wand mask not yet implemented.", None), | |
| 184 | UnsupportedMeta("ReplaceMaterial3D", "Preserved lossless on save; 3D material override not yet traversed in `Renderer3D`.", None), | |
| 185 | UnsupportedMeta("Override3D", "Preserved lossless on save; 3D render-flag override not yet traversed in `Renderer3D`.", None), | |
| 186 | UnsupportedMeta("Displace3D", "Preserved lossless on save; vertex displacement not yet implemented in `Renderer3D`.", None), | |
| 187 | ) | |
| 188 | ||
| 189 | ||
| 190 | def parse_eval_rs(path: Path) -> Set[str]: | |
| 191 | """Extract all supported tool class names from eval_node_inner in eval.rs.""" | |
| 192 | text = path.read_text(encoding="utf-8") | |
| 193 | m = re.search(r"fn eval_node_inner\b.*?(?=\n fn |\n\})", text, re.S) | |
| 194 | if not m: | |
| 195 | raise RuntimeError(f"Could not locate eval_node_inner in {path}") | |
| 196 | body = m.group(0) | |
| 197 | tools: Set[str] = set() | |
| 198 | for mm in re.finditer(r"matches!\(node\.kind\.as_str\(\),\s*([^)]+)\)", body): | |
| 199 | tools.update(re.findall(r'"([^"]+)"', mm.group(1))) | |
| 200 | for mm in re.finditer(r'node\.kind\s*==\s*"([^"]+)"', body): | |
| 201 | tools.add(mm.group(1)) | |
| 202 | mm = re.search(r"match node\.kind\.as_str\(\)\s*\{(.*?)\n\s*other =>", body, re.S) | |
| 203 | if not mm: | |
| 204 | raise RuntimeError(f"Could not locate main match in eval_node_inner in {path}") | |
| 205 | for line in mm.group(1).splitlines(): | |
| 206 | if "=>" in line and not line.strip().startswith("//"): | |
| 207 | lhs = line.split("=>", 1)[0] | |
| 208 | tools.update(re.findall(r'"([^"]+)"', lhs)) | |
| 209 | return tools | |
| 210 | ||
| 211 | ||
| 212 | def parse_scene3d_rs(path: Path) -> Set[str]: | |
| 213 | """Extract all supported 3D tool class names from collect_scene in scene3d.rs.""" | |
| 214 | text = path.read_text(encoding="utf-8") | |
| 215 | m = re.search(r"match node\.kind\.as_str\(\)\s*\{(.*?)\n _ => \{\}", text, re.S) | |
| 216 | if not m: | |
| 217 | raise RuntimeError(f"Could not locate collect_scene match in {path}") | |
| 218 | tools: Set[str] = set() | |
| 219 | for line in m.group(1).splitlines(): | |
| 220 | if line.startswith(' "') and "=>" in line: | |
| 221 | lhs = line.split("=>", 1)[0] | |
| 222 | tools.update(re.findall(r'"([^"]+)"', lhs)) | |
| 223 | return tools | |
| 224 | ||
| 225 | ||
| 226 | def parse_comp_rs_modifiers(path: Path) -> Tuple[List[str], Set[str]]: | |
| 227 | """Return (declared MODIFIER_TYPES, implemented modifier classes in parse_tools_table).""" | |
| 228 | text = path.read_text(encoding="utf-8") | |
| 229 | mc = re.search(r"const MODIFIER_TYPES:\s*&\[&str\]\s*=\s*&\[(.*?)\];", text, re.S) | |
| 230 | declared = re.findall(r'"([^"]+)"', mc.group(1)) if mc else [] | |
| 231 | declared_set = set(declared) | |
| 232 | mp = re.search(r"fn parse_tools_table\b.*", text, re.S) | |
| 233 | implemented: Set[str] = set() | |
| 234 | if mp: | |
| 235 | for mm in re.finditer(r'kind\s*==\s*"([^"]+)"', mp.group(0)): | |
| 236 | if mm.group(1) in declared_set: | |
| 237 | implemented.add(mm.group(1)) | |
| 238 | return declared, implemented | |
| 239 | ||
| 240 | ||
| 241 | def parse_probe_suites(path: Path) -> Set[str]: | |
| 242 | """Extract registered probe suite names from scripts/fusion_probes.py.""" | |
| 243 | if not path.exists(): | |
| 244 | return set() | |
| 245 | text = path.read_text(encoding="utf-8") | |
| 246 | m = re.search(r"builders\s*=\s*\{(.*?)\}", text, re.S) | |
| 247 | if not m: | |
| 248 | return set() | |
| 249 | return set(re.findall(r'"([^"]+)"\s*:', m.group(1))) | |
| 250 | ||
| 251 | ||
| 252 | TOOLS_START_RE = re.compile(r"(?m)^\tTools\s*=\s*(?:ordered\(\)\s*)?\{") | |
| 253 | TOP_TOOL_RE = re.compile( | |
| 254 | r'^\t\t(?:\["[^"]+"\]|[A-Za-z_][A-Za-z0-9_]*)\s*=\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\{' | |
| 255 | ) | |
| 256 | ||
| 257 | ||
| 258 | def scan_comp_corpus(root: Path) -> Optional[Tuple[int, Counter[str]]]: | |
| 259 | """Lightweight top-level tool-class scanner over all *.comp files under root.""" | |
| 260 | if not root.exists(): | |
| 261 | return None | |
| 262 | counts: Counter[str] = Counter() | |
| 263 | comp_files = sorted(root.rglob("*.comp")) | |
| 264 | if not comp_files: | |
| 265 | return None | |
| 266 | for path in comp_files: | |
| 267 | try: | |
| 268 | text = path.read_text(encoding="utf-8", errors="replace") | |
| 269 | except OSError: | |
| 270 | continue | |
| 271 | m = TOOLS_START_RE.search(text) | |
| 272 | if not m: | |
| 273 | continue | |
| 274 | for line in text[m.end():].splitlines(): | |
| 275 | if line.startswith("\t}"): | |
| 276 | break | |
| 277 | tm = TOP_TOOL_RE.match(line) | |
| 278 | if tm: | |
| 279 | counts[tm.group(1)] += 1 | |
| 280 | return len(comp_files), counts | |
| 281 | ||
| 282 | ||
| 283 | def format_usage( | |
| 284 | names: Sequence[str], | |
| 285 | active: Optional[Tuple[int, Counter[str]]], | |
| 286 | archive: Optional[Tuple[int, Counter[str]]], | |
| 287 | ) -> str: | |
| 288 | if active is None and archive is None: | |
| 289 | return "—" | |
| 290 | a_str = str(sum(active[1][n] for n in names)) if active is not None else "—" | |
| 291 | b_str = str(sum(archive[1][n] for n in names)) if archive is not None else "—" | |
| 292 | return f"{a_str} / {b_str}" | |
| 293 | ||
| 294 | ||
| 295 | def format_coverage( | |
| 296 | corpus: Optional[Tuple[int, Counter[str]]], | |
| 297 | supported_classes: Set[str], | |
| 298 | fallback_label: str, | |
| 299 | ) -> str: | |
| 300 | if corpus is None: | |
| 301 | return fallback_label | |
| 302 | n_files, counts = corpus | |
| 303 | total = sum(counts.values()) | |
| 304 | if total == 0: | |
| 305 | return f"0.0% (0 nodes across {n_files} comps)" | |
| 306 | covered = sum(v for k, v in counts.items() if k in supported_classes) | |
| 307 | pct = 100.0 * covered / total | |
| 308 | return f"**{pct:.1f}%** ({covered:,} / {total:,} nodes across {n_files} `.comp` files)" | |
| 309 | ||
| 310 | ||
| 311 | def build_markdown( | |
| 312 | eval_tools: Set[str], | |
| 313 | scene3d_tools: Set[str], | |
| 314 | impl_modifiers: Set[str], | |
| 315 | probe_suites: Set[str], | |
| 316 | active_corpus: Optional[Tuple[int, Counter[str]]], | |
| 317 | archive_corpus: Optional[Tuple[int, Counter[str]]], | |
| 318 | ) -> Tuple[str, List[str]]: | |
| 319 | """Build compatibility.md text and return (markdown, warnings).""" | |
| 320 | warnings: List[str] = [] | |
| 321 | ||
| 322 | # Validate probe suite names referenced in metadata | |
| 323 | if probe_suites: | |
| 324 | for meta in TOOL_METADATA: | |
| 325 | for suite in re.findall(r"`([a-z0-9_]+)`", meta.probe): | |
| 326 | if suite not in probe_suites: | |
| 327 | warnings.append(f"Tool {meta.name} references unknown probe suite '{suite}'") | |
| 328 | for mmeta in MODIFIER_METADATA: | |
| 329 | for suite in re.findall(r"`([a-z0-9_]+)`", mmeta.probe): | |
| 330 | if suite not in probe_suites: | |
| 331 | warnings.append(f"Modifier {mmeta.display_name} references unknown probe suite '{suite}'") | |
| 332 | ||
| 333 | live_engine_tools = eval_tools | scene3d_tools | |
| 334 | meta_by_name: Dict[str, ToolMeta] = {m.name: m for m in TOOL_METADATA} | |
| 335 | non_render_tools = {"Note", "Underlay"} | |
| 336 | ||
| 337 | # Detect drift: tools in eval.rs / scene3d.rs not in TOOL_METADATA | |
| 338 | uncategorized = sorted(live_engine_tools - set(meta_by_name.keys())) | |
| 339 | for name in uncategorized: | |
| 340 | warnings.append(f"Uncategorized tool found in engine source: {name}") | |
| 341 | ||
| 342 | # Detect stale metadata: tools in TOOL_METADATA no longer in engine source (excluding Note/Underlay) | |
| 343 | stale = sorted((set(meta_by_name.keys()) - non_render_tools) - live_engine_tools) | |
| 344 | for name in stale: | |
| 345 | warnings.append(f"Stale tool in metadata not found in eval.rs/scene3d.rs: {name}") | |
| 346 | ||
| 347 | # Detect uncategorized modifiers | |
| 348 | known_mod_classes: Set[str] = set() | |
| 349 | for mm in MODIFIER_METADATA: | |
| 350 | known_mod_classes.update(mm.classes) | |
| 351 | uncategorized_mods = sorted(impl_modifiers - known_mod_classes) | |
| 352 | for name in uncategorized_mods: | |
| 353 | warnings.append(f"Uncategorized modifier found in comp.rs: {name}") | |
| 354 | ||
| 355 | all_supported_tools = live_engine_tools | non_render_tools | |
| 356 | all_supported_classes = all_supported_tools | impl_modifiers | |
| 357 | ||
| 358 | lines: List[str] = [] | |
| 359 | lines.append("# Fusion 21.1 Compatibility Matrix") | |
| 360 | lines.append("") | |
| 361 | lines.append( | |
| 362 | "Auto-generated from live engine sources (`crates/engine/src/eval.rs`, " | |
| 363 | "`crates/engine/src/scene3d.rs`, `crates/model/src/comp.rs`) and real Fusion `.comp` corpora " | |
| 364 | "via `python3 scripts/gen_compatibility.py`." | |
| 365 | ) | |
| 366 | lines.append("") | |
| 367 | lines.append( | |
| 368 | f"- **Tracked Gaps & Issues:** [shale.paperclover.net/fission/issues]({SHALE_ISSUES_URL})\n" | |
| 369 | f"- **Conformance Probes:** [`scripts/fusion_probes.py`](scripts/fusion_probes.py)" | |
| 370 | ) | |
| 371 | lines.append("") | |
| 372 | ||
| 373 | # Top summary table | |
| 374 | lines.append("## Summary") | |
| 375 | lines.append("") | |
| 376 | lines.append("| Metric | Value |") | |
| 377 | lines.append("| --- | --- |") | |
| 378 | lines.append( | |
| 379 | f"| **Supported Flow Tools** | **{len(all_supported_tools)}** " | |
| 380 | f"({len(eval_tools)} 2D/Fuse/utility in `eval.rs`, {len(scene3d_tools - eval_tools)} 3D scene nodes in `scene3d.rs`, 2 Flow annotations) |" | |
| 381 | ) | |
| 382 | lines.append( | |
| 383 | f"| **Modifiers & Animation** | **{len(MODIFIER_METADATA)}** systems " | |
| 384 | f"({len(impl_modifiers)} Fusion modifier classes + Lua expressions) |" | |
| 385 | ) | |
| 386 | lines.append( | |
| 387 | f"| **Active Corpus (`trees/fusion`) Coverage** | " | |
| 388 | f"{format_coverage(active_corpus, all_supported_classes, '_Skipped (`/Volumes/Project/trees/fusion` not mounted)_')} |" | |
| 389 | ) | |
| 390 | lines.append( | |
| 391 | f"| **Archive Corpus (`private/samples`) Coverage** | " | |
| 392 | f"{format_coverage(archive_corpus, all_supported_classes, '_Skipped (`private/samples` not present)_')} |" | |
| 393 | ) | |
| 394 | lines.append( | |
| 395 | "| **HiQ vs Fast Mode** | " | |
| 396 | "**`HiQ`**: honors `DepthFull` / generator `Depth` / `ChangeDepth` (`Rgba8Unorm`, clamped `Rgba16Float`, unclamped HDR `Rgba16Float`/`Rgba32Float`), full-res blurs & `XGlow`. " | |
| 397 | "**`Fast`**: collapses working targets to `Rgba8Unorm`, downsamples blurs, caps `XGlow` octaves for interactive scrubbing. |" | |
| 398 | ) | |
| 399 | lines.append("") | |
| 400 | ||
| 401 | usage_col = "Usage (Active / Archive)" | |
| 402 | ||
| 403 | # Categorized tool tables | |
| 404 | for cat in CATEGORIES: | |
| 405 | cat_tools = [m for m in TOOL_METADATA if m.category == cat and (m.name in live_engine_tools or m.name in non_render_tools)] | |
| 406 | if not cat_tools: | |
| 407 | continue | |
| 408 | lines.append(f"## {cat}") | |
| 409 | lines.append("") | |
| 410 | lines.append(f"| Tool | Probe Suite | Verified MAE | {usage_col} | Notes & Fallbacks |") | |
| 411 | lines.append("| --- | --- | --- | --- | --- |") | |
| 412 | for m in cat_tools: | |
| 413 | names = (m.name,) + m.aliases | |
| 414 | usage = format_usage(names, active_corpus, archive_corpus) | |
| 415 | lines.append(f"| `{m.name}` | {m.probe} | {m.mae} | {usage} | {m.notes} |") | |
| 416 | lines.append("") | |
| 417 | ||
| 418 | # Drift-detection table if any new tools appeared in Rust sources | |
| 419 | if uncategorized: | |
| 420 | lines.append("## Uncategorized (New in Engine)") | |
| 421 | lines.append("") | |
| 422 | lines.append("> [!WARNING]") | |
| 423 | lines.append("> The following tools were found in `eval.rs` / `scene3d.rs` but are not yet listed in `TOOL_METADATA` in `scripts/gen_compatibility.py`.") | |
| 424 | lines.append("") | |
| 425 | lines.append(f"| Tool | {usage_col} |") | |
| 426 | lines.append("| --- | --- |") | |
| 427 | for name in uncategorized: | |
| 428 | usage = format_usage((name,), active_corpus, archive_corpus) | |
| 429 | lines.append(f"| `{name}` | {usage} |") | |
| 430 | lines.append("") | |
| 431 | ||
| 432 | # Modifiers & Animation table | |
| 433 | lines.append("## Modifiers & Animation") | |
| 434 | lines.append("") | |
| 435 | lines.append(f"| Modifier / System | Probe Suite | {usage_col} | Notes |") | |
| 436 | lines.append("| --- | --- | --- | --- |") | |
| 437 | for mm in MODIFIER_METADATA: | |
| 438 | usage = format_usage(mm.classes, active_corpus, archive_corpus) if mm.classes else "—" | |
| 439 | lines.append(f"| {mm.display_name} | {mm.probe} | {usage} | {mm.notes} |") | |
| 440 | for name in uncategorized_mods: | |
| 441 | usage = format_usage((name,), active_corpus, archive_corpus) | |
| 442 | lines.append(f"| `{name}` | — | {usage} | _Uncategorized modifier detected in `comp.rs`._ |") | |
| 443 | lines.append("") | |
| 444 | ||
| 445 | # Preserved & Passthrough (Roundtrip-Safe) section | |
| 446 | lines.append("## Preserved & Passthrough (Roundtrip-Safe)") | |
| 447 | lines.append("") | |
| 448 | lines.append( | |
| 449 | "Unlike Blackmagic Fusion — which unlinks missing OFX or Resolve-only plugins when opening a `.comp` — " | |
| 450 | "**Fission preserves all unknown and unsupported tools losslessly** (every parameter, custom input, binary blob, " | |
| 451 | "position, and upstream/downstream wire is retained verbatim on save) and **passes through their main input** " | |
| 452 | "during Flow evaluation so downstream compositing stays connected." | |
| 453 | ) | |
| 454 | lines.append("") | |
| 455 | ||
| 456 | # Combine curated unsupported list with any top real-world unsupported tools from corpora | |
| 457 | curated_by_name = {u.name: u for u in UNSUPPORTED_NOTES} | |
| 458 | combined_unsup: Counter[str] = Counter() | |
| 459 | if active_corpus is not None: | |
| 460 | for k, v in active_corpus[1].items(): | |
| 461 | if k not in all_supported_classes: | |
| 462 | combined_unsup[k] += v | |
| 463 | if archive_corpus is not None: | |
| 464 | for k, v in archive_corpus[1].items(): | |
| 465 | if k not in all_supported_classes: | |
| 466 | combined_unsup[k] += v | |
| 467 | ||
| 468 | # Order: curated items first (preserving logical grouping), then any remaining high-frequency unsupported tools | |
| 469 | display_unsup: List[str] = [u.name for u in UNSUPPORTED_NOTES] | |
| 470 | for k, _ in combined_unsup.most_common(25): | |
| 471 | if k not in curated_by_name and len(display_unsup) < 24: | |
| 472 | display_unsup.append(k) | |
| 473 | ||
| 474 | lines.append(f"| Tool Class | {usage_col} | Issue | Behavior & Notes |") | |
| 475 | lines.append("| --- | --- | --- | --- |") | |
| 476 | for name in display_unsup: | |
| 477 | usage = format_usage((name,), active_corpus, archive_corpus) | |
| 478 | meta = curated_by_name.get(name) | |
| 479 | if meta is not None: | |
| 480 | issue_str = f"[#{meta.issue}]({SHALE_ISSUES_URL}/{meta.issue})" if meta.issue else "—" | |
| 481 | behavior = meta.behavior | |
| 482 | else: | |
| 483 | issue_str = "—" | |
| 484 | behavior = "Preserved lossless on save; passes through main input in Flow." | |
| 485 | lines.append(f"| `{name}` | {usage} | {issue_str} | {behavior} |") | |
| 486 | lines.append("") | |
| 487 | ||
| 488 | lines.append("---") | |
| 489 | lines.append("") | |
| 490 | lines.append( | |
| 491 | f"For tracked gaps, known parity edge cases, and roadmap items, see " | |
| 492 | f"[shale.paperclover.net/fission/issues]({SHALE_ISSUES_URL})." | |
| 493 | ) | |
| 494 | lines.append("") | |
| 495 | ||
| 496 | return "\n".join(lines), warnings | |
| 497 | ||
| 498 | ||
| 499 | def main() -> int: | |
| 500 | parser = argparse.ArgumentParser(description="Generate compatibility.md from live engine sources.") | |
| 501 | parser.add_argument("-o", "--output", type=Path, default=DEFAULT_OUTPUT, help="Output markdown path.") | |
| 502 | parser.add_argument("--active-dir", type=Path, default=ACTIVE_CORPUS_DIR, help="Active Fusion .comp directory.") | |
| 503 | parser.add_argument("--archive-dir", type=Path, default=ARCHIVE_CORPUS_DIR, help="Archive Fusion .comp directory.") | |
| 504 | parser.add_argument("--strict", action="store_true", help="Exit non-zero if uncategorized or stale tools are found.") | |
| 505 | args = parser.parse_args() | |
| 506 | ||
| 507 | eval_tools = parse_eval_rs(EVAL_RS) | |
| 508 | scene3d_tools = parse_scene3d_rs(SCENE3D_RS) | |
| 509 | _, impl_modifiers = parse_comp_rs_modifiers(COMP_RS) | |
| 510 | probe_suites = parse_probe_suites(PROBES_PY) | |
| 511 | ||
| 512 | active_corpus = scan_comp_corpus(args.active_dir) | |
| 513 | archive_corpus = scan_comp_corpus(args.archive_dir) | |
| 514 | ||
| 515 | md, warnings = build_markdown( | |
| 516 | eval_tools=eval_tools, | |
| 517 | scene3d_tools=scene3d_tools, | |
| 518 | impl_modifiers=impl_modifiers, | |
| 519 | probe_suites=probe_suites, | |
| 520 | active_corpus=active_corpus, | |
| 521 | archive_corpus=archive_corpus, | |
| 522 | ) | |
| 523 | ||
| 524 | args.output.write_text(md, encoding="utf-8") | |
| 525 | print(f"Wrote {args.output} ({len(md.splitlines())} lines)") | |
| 526 | if active_corpus is not None: | |
| 527 | print(f" Active corpus: {active_corpus[0]} comps, {sum(active_corpus[1].values()):,} entries") | |
| 528 | else: | |
| 529 | print(f" Active corpus: skipped ({args.active_dir} not found)") | |
| 530 | if archive_corpus is not None: | |
| 531 | print(f" Archive corpus: {archive_corpus[0]} comps, {sum(archive_corpus[1].values()):,} entries") | |
| 532 | else: | |
| 533 | print(f" Archive corpus: skipped ({args.archive_dir} not found)") | |
| 534 | ||
| 535 | for w in warnings: | |
| 536 | print(f"WARNING: {w}", file=sys.stderr) | |
| 537 | ||
| 538 | if args.strict and warnings: | |
| 539 | return 1 | |
| 540 | return 0 | |
| 541 | ||
| 542 | ||
| 543 | if __name__ == "__main__": | |
| 544 | raise SystemExit(main()) |