diff --git a/spikes/capture-speed/001a-grim-rs/.gitignore b/spikes/capture-speed/001a-grim-rs/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/spikes/capture-speed/001a-grim-rs/.gitignore @@ -0,0 +1 @@ +/target diff --git a/spikes/capture-speed/001a-grim-rs/Cargo.lock b/spikes/capture-speed/001a-grim-rs/Cargo.lock new file mode 100644 index 0000000..e5a11e2 --- /dev/null +++ b/spikes/capture-speed/001a-grim-rs/Cargo.lock @@ -0,0 +1,1658 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aligned" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee4508988c62edf04abd8d92897fca0c2995d907ce1dfeaf369dac3716a40685" +dependencies = [ + "as-slice", +] + +[[package]] +name = "aligned-vec" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" +dependencies = [ + "equator", +] + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "arbitrary" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed" + +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "arrayvec" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" + +[[package]] +name = "as-slice" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "av-scenechange" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f321d77c20e19b92c39e7471cf986812cbb46659d2af674adc4331ef3f18394" +dependencies = [ + "aligned", + "anyhow", + "arg_enum_proc_macro", + "arrayvec", + "log", + "num-rational", + "num-traits", + "pastey", + "rayon", + "thiserror", + "v_frame", + "y4m", +] + +[[package]] +name = "av1-grain" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cfddb07216410377231960af4fcab838eaa12e013417781b78bd95ee22077f8" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom", + "num-rational", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7178fe5f7d460b13895ebb9dcb28a3a6216d2df2574a0806cb51b555d297f38" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "bit_field" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "bitstream-io" +version = "4.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eff00be299a18769011411c9def0d827e8f2d7bf0c3dbf53633147a8867fd1f" +dependencies = [ + "no_std_io2", +] + +[[package]] +name = "built" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9" + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" + +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + +[[package]] +name = "cc" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6651c9ed80effdc7db0ff72512157f901af5e3549e341e24b1dd4887d836d838" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crc32fast" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "equator" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" +dependencies = [ + "equator-macro", +] + +[[package]] +name = "equator-macro" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "exr" +version = "1.74.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711fe42c9964295e01ee3fba3f9fe0e1d24b98886950d68efe81b1c76e21adf3" +dependencies = [ + "bit_field", + "half", + "lebe", + "miniz_oxide 0.8.9", + "num-complex", + "pulp", + "rayon-core", + "smallvec", + "zune-inflate", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "fax" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a" + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" + +[[package]] +name = "flate2" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" +dependencies = [ + "crc32fast", + "miniz_oxide 0.9.1", + "zlib-rs", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] + +[[package]] +name = "gif" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] +name = "grim-rs" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95cc72e15c2039b8d8958731a66bcf2d970d39c145e955c858001cd4c663242a" +dependencies = [ + "chrono", + "image", + "jpeg-encoder", + "log", + "memmap2", + "png 0.17.16", + "tempfile", + "thiserror", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", + "windows", +] + +[[package]] +name = "grimrs-capture" +version = "0.1.0" +dependencies = [ + "grim-rs", + "libc", + "serde_json", +] + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "zerocopy", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core 0.62.2", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "color_quant", + "exr", + "gif", + "image-webp", + "moxcms", + "num-traits", + "png 0.18.1", + "qoi", + "ravif", + "rayon", + "rgb", + "tiff", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "imgref" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e44b0a4eaa4c82f441d50a963f2d5f05a787240aeee097597033e72accfd22f" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "jpeg-encoder" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0370574b86f7eca156b9f298392b5e69a23f8c86f3f865add60bbc2e79467a6" + +[[package]] +name = "js-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "lebe" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" + +[[package]] +name = "libc" +version = "0.2.190" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78" + +[[package]] +name = "libfuzzer-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9fd2f41a1cba099f79a0b6b6c35656cf7c03351a7bae8ff0f28f25270f929d2" +dependencies = [ + "arbitrary", + "cc", +] + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "memmap2" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0" +dependencies = [ + "libc", +] + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "no_std_io2" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418abd1b6d34fbf6cae440dc874771b0525a604428704c76e48b29a5e67b8003" +dependencies = [ + "memchr", +] + +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + +[[package]] +name = "num-bigint" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "bytemuck", + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pastey" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "png" +version = "0.17.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "png" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" +dependencies = [ + "bitflags 2.13.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "profiling" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4488a4a36b9a4ba6b9334a32a39971f77c1436ec82c38707bce707699cc3bbcb" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "pulp" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046aa45b989642ec2e4717c8e72d677b13edd831a4d3b6cf37d9a3e54912496a" +dependencies = [ + "bytemuck", + "cfg-if", + "libm", + "num-complex", + "paste", + "pulp-wasm-simd-flag", + "raw-cpuid", + "reborrow", + "version_check", +] + +[[package]] +name = "pulp-wasm-simd-flag" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8f70e07b9c3962945a74e59ca1c511bba65b6419468acc217c457d93f3c740" + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rav1e" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b6dd56e85d9483277cde964fd1bdb0428de4fec5ebba7540995639a21cb32b" +dependencies = [ + "aligned-vec", + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av-scenechange", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "paste", + "profiling", + "rand", + "rand_chacha", + "simd_helpers", + "thiserror", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e52310197d971b0f5be7fe6b57530dcd27beb35c1b013f29d66c1ad73fbbcc45" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rayon", + "rgb", +] + +[[package]] +name = "raw-cpuid" +version = "11.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "reborrow" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03251193000f4bd3b042892be858ee50e8b3719f2b08e5833ac4353724632430" + +[[package]] +name = "rgb" +version = "0.8.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4" + +[[package]] +name = "rustix" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.7", +] + +[[package]] +name = "serde_json" +version = "1.0.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa62079d232416ecf7b2f938d389e28bbcd3677bcdb67b42e2f29c2433552176" +dependencies = [ + "indexmap", + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d62a2e0561533f2ca2561d0cf27fd9fedb640a1bf2616ff5d5c80d99017faadc" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.7", +] + +[[package]] +name = "tiff" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg", +] + +[[package]] +name = "unicode-ident" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" + +[[package]] +name = "v_frame" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.7", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wayland-backend" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" +dependencies = [ + "cc", + "downcast-rs", + "rustix", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" +dependencies = [ + "bitflags 2.13.2", + "rustix", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0" +dependencies = [ + "proc-macro2", + "quick-xml", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "weezl" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + +[[package]] +name = "windows" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core 0.58.0", + "windows-targets", +] + +[[package]] +name = "windows-core" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings 0.1.0", + "windows-targets", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement 0.60.2", + "windows-interface 0.59.3", + "windows-link", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result 0.2.0", + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "y4m" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448" + +[[package]] +name = "zerocopy" +version = "0.8.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86502bf56ac7c77571a32e2647bb2a15894565e981fb2a48d7bde2d91c965a9d" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5457206954b06561e2608c7e19cf58b1926586d999c246eebe4502f7e2039d1a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] diff --git a/spikes/capture-speed/001a-grim-rs/Cargo.toml b/spikes/capture-speed/001a-grim-rs/Cargo.toml new file mode 100644 index 0000000..9c5c2ec --- /dev/null +++ b/spikes/capture-speed/001a-grim-rs/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "grimrs-capture" +version = "0.1.0" +edition = "2021" +publish = false +description = "Long-lived grim-rs capture producer for the frozen HARNESS.md contract" + +[[bin]] +name = "grimrs-capture" +path = "src/main.rs" + +[dependencies] +# Exact: the raw-mode stop point depends on what 0.2.0 does inside capture_*. +grim-rs = "=0.2.0" +libc = "0.2" +serde_json = { version = "1", features = ["preserve_order"] } diff --git a/spikes/capture-speed/001a-grim-rs/run-cells.sh b/spikes/capture-speed/001a-grim-rs/run-cells.sh new file mode 100755 index 0000000..4931a97 --- /dev/null +++ b/spikes/capture-speed/001a-grim-rs/run-cells.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Eight measured cells, still screen, two runs each. +# Stdout of each cell is one JSON line. Progress goes to runs/progress.log. +# Does not set XDG_RUNTIME_DIR. The caller must export WAYLAND_DISPLAY to the +# absolute socket path. +set -u +cd "$(dirname "$0")" +if [ "${WAYLAND_DISPLAY:-}" != "/run/hypr-stream/wayland-1" ]; then + echo "WAYLAND_DISPLAY must be /run/hypr-stream/wayland-1" >&2 + exit 2 +fi +if [ "${XDG_RUNTIME_DIR:-}" = "/run/hypr-stream" ]; then + echo "refusing XDG_RUNTIME_DIR=/run/hypr-stream" >&2 + exit 2 +fi +OUTPUT=${1:?usage: run-cells.sh OUTPUT_NAME} +BIN=./target/release/grimrs-capture +if [ ! -x "$BIN" ]; then + echo "missing $BIN; build with nix-shell --run 'cargo build --release'" >&2 + exit 2 +fi +mkdir -p runs +LOG=runs/progress.log +: > "$LOG" +# The frame server is a system unit. Do not stop it. Record that it was +# capturing during the run so the numbers are not read as an idle compositor. +ps -eo pid,user,cmd > runs/ps-at-start.txt +echo "BEGIN runner $(date -Is) WAYLAND_DISPLAY=$WAYLAND_DISPLAY XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR-}" >> "$LOG" +fail=0 +run() { + name=$1 + shift + echo "BEGIN $name $(date -Is)" >> "$LOG" + start=$(date +%s) + "$BIN" "$@" > "runs/$name.stdout" 2> "runs/$name.stderr" + rc=$? + end=$(date +%s) + echo "END $name rc=$rc elapsed=$((end - start)) $(date -Is)" >> "$LOG" + if [ "$rc" -ne 0 ]; then + echo "CELL_FAIL $name rc=$rc" >> "$LOG" + fail=1 + fi +} +run output-raw-1 --output "$OUTPUT" --frames 300 --warmup 10 --mode raw --json +run output-raw-2 --output "$OUTPUT" --frames 300 --warmup 10 --mode raw --json +run output-jpeg-1 --output "$OUTPUT" --frames 300 --warmup 10 --mode jpeg --json +run output-jpeg-2 --output "$OUTPUT" --frames 300 --warmup 10 --mode jpeg --json +run all-raw-1 --all --frames 300 --warmup 10 --mode raw --json +run all-raw-2 --all --frames 300 --warmup 10 --mode raw --json +run all-jpeg-1 --all --frames 300 --warmup 10 --mode jpeg --json +run all-jpeg-2 --all --frames 300 --warmup 10 --mode jpeg --json +echo "ALL_DONE fail=$fail $(date -Is)" >> "$LOG" +exit "$fail" diff --git a/spikes/capture-speed/001a-grim-rs/shell.nix b/spikes/capture-speed/001a-grim-rs/shell.nix new file mode 100644 index 0000000..5195414 --- /dev/null +++ b/spikes/capture-speed/001a-grim-rs/shell.nix @@ -0,0 +1,13 @@ +# Spike-local toolchain for route 001a. Rust stays out of the repository flake +# on purpose: this shell is the only place this spike gets rustc and cargo. +# +# Do not set WAYLAND_DISPLAY or XDG_RUNTIME_DIR here. The run commands in +# README.md set WAYLAND_DISPLAY to the absolute socket path. Pointing +# XDG_RUNTIME_DIR at /run/hypr-stream makes libwayland reject the runtime dir. +{ pkgs ? import { } }: +pkgs.mkShell { + packages = with pkgs; [ + rustc # 1.98 from the machine's nixpkgs + cargo + ]; +} diff --git a/spikes/capture-speed/001a-grim-rs/src/main.rs b/spikes/capture-speed/001a-grim-rs/src/main.rs new file mode 100644 index 0000000..d987381 --- /dev/null +++ b/spikes/capture-speed/001a-grim-rs/src/main.rs @@ -0,0 +1,641 @@ +//! Long-lived capture producer for the frozen measurement contract. +//! +//! One Wayland connection (`Grim::new_wlr`, so the crate cannot pick +//! `ext-image-copy-capture-v1`), then warmup frames, then N measured frames. +//! Stdout is exactly one JSON object, on the last line. Everything else goes +//! to stderr. + +use std::env; +use std::io::{self, Write}; +use std::process::ExitCode; +use std::time::Instant; + +use grim_rs::Grim; + +const ROUTE: &str = "grim-rs"; +const JPEG_QUALITY: u8 = 80; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +enum Mode { + Raw, + Jpeg, +} + +impl Mode { + fn as_str(self) -> &'static str { + match self { + Mode::Raw => "raw", + Mode::Jpeg => "jpeg", + } + } +} + +#[derive(Clone, Debug)] +enum Target { + Output(String), + All, +} + +impl Target { + fn label(&self) -> &str { + match self { + Target::Output(name) => name, + Target::All => "all", + } + } +} + +struct Args { + target: Target, + frames: u32, + warmup: u32, + mode: Mode, +} + +struct Held { + width: u32, + height: u32, + /// JPEG byte length. `None` in raw mode. + jpeg_len: Option, + /// Pixel or JPEG bytes. Kept alive until the caller drops it, so the + /// frame timer can stop when the bytes are complete and not when they + /// are freed. + bytes: Vec, +} + +fn main() -> ExitCode { + match run() { + Ok(()) => ExitCode::SUCCESS, + Err(err) => { + eprintln!("grimrs-capture: {err}"); + ExitCode::from(1) + } + } +} + +fn run() -> Result<(), String> { + let args = parse_args(env::args().skip(1))?; + // Absolute WAYLAND_DISPLAY is required. Leaving XDG_RUNTIME_DIR alone is + // also required: this process does not own /run/hypr-stream. + match env::var("WAYLAND_DISPLAY") { + Ok(value) if !value.is_empty() => {} + _ => { + return Err( + "WAYLAND_DISPLAY is empty. Set it to the absolute socket \ + path /run/hypr-stream/wayland-1 and do not set \ + XDG_RUNTIME_DIR=/run/hypr-stream" + .to_string(), + ); + } + } + if env::var("XDG_RUNTIME_DIR").ok().as_deref() == Some("/run/hypr-stream") { + return Err( + "XDG_RUNTIME_DIR=/run/hypr-stream is set. Unset it; libwayland \ + refuses a runtime dir the caller does not own" + .to_string(), + ); + } + + // Force zwlr-screencopy. Grim::new() prefers ext-image-copy-capture-v1, + // which is the dma-buf-capable path this machine must not take. + let mut grim = Grim::new_wlr().map_err(|err| { + format!( + "Grim::new_wlr failed ({err}). Refusing to fall back to \ + ext-image-copy-capture-v1" + ) + })?; + + let outputs = grim.get_outputs().map_err(|err| err.to_string())?; + if outputs.is_empty() { + return Err("compositor advertised no outputs".to_string()); + } + let layout = describe_outputs(&outputs); + if let Target::Output(name) = &args.target { + if !outputs.iter().any(|output| output.name() == name) { + return Err(format!( + "output {name:?} not found. Outputs: {layout}" + )); + } + } + + eprintln!( + "grimrs-capture: route {ROUTE} protocol zwlr-screencopy-v1 \ + mode {} target {} warmup {} frames {}", + args.mode.as_str(), + args.target.label(), + args.warmup, + args.frames + ); + eprintln!("grimrs-capture: outputs {layout}"); + + let mut last_warmup_nonzero: Option = None; + let mut last_warmup_jpeg_ok = true; + for i in 0..args.warmup { + let held = grab(&mut grim, &args.target, args.mode)?; + if args.mode == Mode::Jpeg && !held.bytes.starts_with(&[0xFF, 0xD8]) { + last_warmup_jpeg_ok = false; + } + last_warmup_nonzero = Some(count_nonzero(&held.bytes)); + eprintln!( + "grimrs-capture: warmup {}/{} {}x{} bytes {} nonzero {}", + i + 1, + args.warmup, + held.width, + held.height, + held.bytes.len(), + last_warmup_nonzero.unwrap_or(0) + ); + } + if args.mode == Mode::Jpeg && !last_warmup_jpeg_ok { + return Err( + "warmup JPEG did not start with FF D8; refusing to measure" + .to_string(), + ); + } + + let cpu_before = process_cpu_ms()?; + let wall_start = Instant::now(); + let mut samples_ms: Vec = Vec::with_capacity(args.frames as usize); + let mut jpeg_sizes: Vec = Vec::new(); + let mut geometry: Option<(u32, u32)> = None; + for _ in 0..args.frames { + let tick = Instant::now(); + let held = grab(&mut grim, &args.target, args.mode)?; + // Touch the length so the buffer is complete before the clock stops. + // Do not read pixels: the contract puts stride and checksum outside + // the measurement. + std::hint::black_box(held.bytes.len()); + let ms = tick.elapsed().as_secs_f64() * 1000.0; + match geometry { + None => geometry = Some((held.width, held.height)), + Some((w, h)) if w != held.width || h != held.height => { + return Err(format!( + "geometry changed during the run: {w}x{h} then {}x{}", + held.width, held.height + )); + } + Some(_) => {} + } + if let Some(len) = held.jpeg_len { + jpeg_sizes.push(len as u64); + } + samples_ms.push(ms); + // Free between frames, outside the frame timer. wall_ms includes it. + drop(held); + } + let wall_ms = wall_start.elapsed().as_secs_f64() * 1000.0; + let cpu_after = process_cpu_ms()?; + let (width, height) = geometry.ok_or("no measured frames")?; + + let cpu_ms_per_frame = match (cpu_before, cpu_after) { + (Some(before), Some(after)) if after >= before => { + Some((after - before) / f64::from(args.frames)) + } + _ => None, + }; + + let mut notes = format!( + "grim-rs 0.2.0 via Grim::new_wlr(); copy target is a wl_shm buffer \ + created inside each capture_* call, not a dma-buf the producer \ + imports. Cursor not overlaid (the frozen argv has no cursor flag; \ + hhstream-live's grim command passes -c). JPEG is Grim::to_jpeg, \ + quality {JPEG_QUALITY}, the crate default and the live-stream \ + setting. Raw timer stops when capture_* returns, which is after \ + the crate copies the mapping into a Vec and swizzles XRGB/ARGB to \ + RGBA (and applies any output transform or y-invert). The public \ + API does not expose the mapped buffer before that, so raw includes \ + work the contract says to leave outside the timer. Percentiles are \ + linear interpolation on the sorted samples. cpu_ms_per_frame is \ + getrusage(RUSAGE_SELF) utime+stime over the measured loop only, \ + divided by frames. Frame buffers are freed between frames; that \ + free is inside wall_ms and outside frame_ms. Outputs: {layout}. \ + No GPU on this machine; dma-buf was not used and is not claimed. \ + This process does not move the pointer and does not start or stop \ + a session; the pixels are whatever the compositor is already \ + showing." + ); + if let Some(nonzero) = last_warmup_nonzero { + notes.push_str(&format!( + " Last warmup frame nonzero bytes: {nonzero}." + )); + if nonzero == 0 { + notes.push_str(" WARNING: last warmup frame was all zeros."); + } + } + + let report = Report { + route: ROUTE, + language: "rust", + protocol: "zwlr-screencopy-v1", + output: args.target.label().to_string(), + geometry: [width, height], + mode: args.mode.as_str(), + warmup: args.warmup, + frames: args.frames, + frame_ms: summarize(&samples_ms), + fps_sustained: sustained_fps(&samples_ms), + wall_ms, + cpu_ms_per_frame, + bytes_p50: if args.mode == Mode::Jpeg { + Some(percentile_u64(&jpeg_sizes, 0.50)) + } else { + None + }, + persistent: true, + notes, + }; + + let line = serde_json::to_string(&report.to_json()) + .map_err(|err| err.to_string())?; + let mut stdout = io::stdout().lock(); + writeln!(stdout, "{line}").map_err(|err| err.to_string())?; + stdout.flush().map_err(|err| err.to_string())?; + Ok(()) +} + +fn grab(grim: &mut Grim, target: &Target, mode: Mode) -> Result { + let captured = match target { + Target::Output(name) => grim.capture_output(name), + Target::All => grim.capture_all(), + } + .map_err(|err| err.to_string())?; + let width = captured.width(); + let height = captured.height(); + if width == 0 || height == 0 { + return Err(format!("capture returned {width}x{height}")); + } + match mode { + Mode::Raw => Ok(Held { + width, + height, + jpeg_len: None, + bytes: captured.into_data(), + }), + Mode::Jpeg => { + let jpeg = grim + .to_jpeg_with_quality(captured.data(), width, height, JPEG_QUALITY) + .map_err(|err| err.to_string())?; + let jpeg_len = jpeg.len(); + Ok(Held { + width, + height, + jpeg_len: Some(jpeg_len), + bytes: jpeg, + }) + } + } +} + +fn describe_outputs(outputs: &[grim_rs::Output]) -> String { + let mut ordered: Vec<_> = outputs.iter().collect(); + ordered.sort_by(|a, b| { + let ag = a.geometry(); + let bg = b.geometry(); + ag.x() + .cmp(&bg.x()) + .then(ag.y().cmp(&bg.y())) + .then(a.name().cmp(b.name())) + }); + ordered + .into_iter() + .map(|output| { + let geometry = output.geometry(); + format!( + "{}@{},{} {}x{} scale {}", + output.name(), + geometry.x(), + geometry.y(), + geometry.width(), + geometry.height(), + output.scale() + ) + }) + .collect::>() + .join("; ") +} + +fn count_nonzero(bytes: &[u8]) -> u64 { + bytes.iter().filter(|byte| **byte != 0).count() as u64 +} + +fn process_cpu_ms() -> Result, String> { + let mut usage: libc::rusage = unsafe { std::mem::zeroed() }; + let rc = unsafe { libc::getrusage(libc::RUSAGE_SELF, &mut usage) }; + if rc != 0 { + return Ok(None); + } + Ok(Some(timeval_ms(usage.ru_utime) + timeval_ms(usage.ru_stime))) +} + +fn timeval_ms(value: libc::timeval) -> f64 { + value.tv_sec as f64 * 1000.0 + value.tv_usec as f64 / 1000.0 +} + +struct Summary { + min: f64, + p50: f64, + mean: f64, + p95: f64, + max: f64, +} + +fn summarize(samples: &[f64]) -> Summary { + let mut sorted = samples.to_vec(); + sorted.sort_by(|a, b| a.total_cmp(b)); + let sum: f64 = sorted.iter().sum(); + Summary { + min: sorted[0], + p50: percentile_linear(&sorted, 0.50), + mean: sum / sorted.len() as f64, + p95: percentile_linear(&sorted, 0.95), + max: *sorted.last().expect("at least one sample"), + } +} + +fn sustained_fps(samples: &[f64]) -> f64 { + let sum = samples.iter().sum::(); + if sum <= 0.0 { + return 0.0; + } + samples.len() as f64 / (sum / 1000.0) +} + +/// Linear interpolation between closest ranks. `samples` must be sorted and +/// non-empty. This is the same definition as numpy's default percentile. +fn percentile_linear(sorted: &[f64], p: f64) -> f64 { + if sorted.len() == 1 { + return sorted[0]; + } + let rank = p * (sorted.len() - 1) as f64; + let lo = rank.floor() as usize; + let hi = rank.ceil() as usize; + let frac = rank - lo as f64; + sorted[lo] * (1.0 - frac) + sorted[hi] * frac +} + +fn percentile_u64(samples: &[u64], p: f64) -> f64 { + let as_f64: Vec = samples.iter().map(|value| *value as f64).collect(); + let mut sorted = as_f64; + sorted.sort_by(|a, b| a.total_cmp(b)); + percentile_linear(&sorted, p) +} + +struct Report { + route: &'static str, + language: &'static str, + protocol: &'static str, + output: String, + geometry: [u32; 2], + mode: &'static str, + warmup: u32, + frames: u32, + frame_ms: Summary, + fps_sustained: f64, + wall_ms: f64, + cpu_ms_per_frame: Option, + bytes_p50: Option, + persistent: bool, + notes: String, +} + +impl Report { + fn to_json(&self) -> serde_json::Value { + serde_json::json!({ + "route": self.route, + "language": self.language, + "protocol": self.protocol, + "output": self.output, + "geometry": self.geometry, + "mode": self.mode, + "warmup": self.warmup, + "frames": self.frames, + "frame_ms": { + "min": round3(self.frame_ms.min), + "p50": round3(self.frame_ms.p50), + "mean": round3(self.frame_ms.mean), + "p95": round3(self.frame_ms.p95), + "max": round3(self.frame_ms.max), + }, + "fps_sustained": round3(self.fps_sustained), + "wall_ms": round3(self.wall_ms), + "cpu_ms_per_frame": self.cpu_ms_per_frame.map(round3), + "bytes_p50": self.bytes_p50.map(round3), + "persistent": self.persistent, + "notes": self.notes, + }) + } +} + +fn round3(value: f64) -> f64 { + (value * 1000.0).round() / 1000.0 +} + +fn parse_args(args: impl IntoIterator) -> Result { + let args: Vec = args.into_iter().collect(); + let mut output: Option = None; + let mut all = false; + let mut frames: Option = None; + let mut warmup: Option = None; + let mut mode: Option = None; + let mut json = false; + let mut index = 0; + while index < args.len() { + let arg = &args[index]; + match arg.as_str() { + "--json" => { + if json { + return Err("repeated --json".to_string()); + } + json = true; + } + "--all" => { + if all { + return Err("repeated --all".to_string()); + } + all = true; + } + "--output" => { + output = Some(need_value(&args, &mut index, "--output")?); + } + "--frames" => { + frames = Some(parse_u32(&need_value(&args, &mut index, "--frames")?, "--frames")?); + } + "--warmup" => { + warmup = Some(parse_u32(&need_value(&args, &mut index, "--warmup")?, "--warmup")?); + } + "--mode" => { + let value = need_value(&args, &mut index, "--mode")?; + mode = Some(match value.as_str() { + "raw" => Mode::Raw, + "jpeg" => Mode::Jpeg, + other => { + return Err(format!( + "--mode must be raw or jpeg, got {other:?}" + )) + } + }); + } + "--help" | "-h" => { + return Err(usage()); + } + other => { + return Err(format!("unknown argument {other}. {}", usage())); + } + } + index += 1; + } + if !json { + return Err(format!("--json is required. {}", usage())); + } + if all && output.is_some() { + return Err("--all and --output are mutually exclusive".to_string()); + } + let target = if all { + Target::All + } else if let Some(name) = output { + if name.is_empty() { + return Err("--output name is empty".to_string()); + } + Target::Output(name) + } else { + return Err(format!("one of --output or --all is required. {}", usage())); + }; + let frames = frames.ok_or_else(|| format!("--frames is required. {}", usage()))?; + if frames == 0 { + return Err("--frames must be at least 1".to_string()); + } + let warmup = warmup.ok_or_else(|| format!("--warmup is required. {}", usage()))?; + let mode = mode.ok_or_else(|| format!("--mode is required. {}", usage()))?; + Ok(Args { + target, + frames, + warmup, + mode, + }) +} + +fn need_value(args: &[String], index: &mut usize, flag: &str) -> Result { + let next = index.checked_add(1).and_then(|i| args.get(i)); + match next { + Some(value) if !value.starts_with("--") => { + *index += 1; + Ok(value.clone()) + } + _ => Err(format!("{flag} needs a value")), + } +} + +fn parse_u32(value: &str, flag: &str) -> Result { + value + .parse::() + .map_err(|_| format!("{flag} must be a non-negative integer, got {value:?}")) +} + +fn usage() -> String { + "usage: grimrs-capture (--output NAME | --all) --frames N --warmup W \ + --mode raw|jpeg --json" + .to_string() +} + +#[cfg(test)] +mod tests { + use super::*; + + fn parse(line: &str) -> Result { + parse_args(line.split_whitespace().map(str::to_string)) + } + + #[test] + fn accepts_the_contract_forms() { + let output = parse( + "--output hh-chromium-yrfadn --frames 300 --warmup 10 --mode raw --json", + ) + .unwrap(); + assert!(matches!(output.target, Target::Output(name) if name == "hh-chromium-yrfadn")); + assert_eq!(output.frames, 300); + assert_eq!(output.warmup, 10); + assert_eq!(output.mode, Mode::Raw); + + let all = parse("--all --frames 300 --warmup 10 --mode jpeg --json").unwrap(); + assert!(matches!(all.target, Target::All)); + assert_eq!(all.mode, Mode::Jpeg); + } + + #[test] + fn rejects_mixed_targets_and_missing_json() { + assert!(parse("--all --output x --frames 1 --warmup 0 --mode raw --json").is_err()); + assert!(parse("--output x --frames 1 --warmup 0 --mode raw").is_err()); + assert!(parse("--output x --frames 0 --warmup 0 --mode raw --json").is_err()); + assert!(parse("--frames 1 --warmup 0 --mode raw --json").is_err()); + assert!(parse("--output x --frames 1 --warmup 0 --mode png --json").is_err()); + } + + #[test] + fn percentile_matches_linear_interpolation() { + let samples = [1.0, 2.0, 3.0, 4.0]; + assert_eq!(percentile_linear(&samples, 0.50), 2.5); + assert_eq!(percentile_linear(&samples, 0.0), 1.0); + assert_eq!(percentile_linear(&samples, 1.0), 4.0); + // rank = 0.95 * 3 = 2.85 -> 3.0 * 0.15 + 4.0 * 0.85 + let p95 = percentile_linear(&samples, 0.95); + assert!((p95 - 3.85).abs() < 1e-9); + } + + #[test] + fn sustained_fps_uses_the_sum_of_frame_times() { + // Two frames of 100 ms -> 2 / 0.2 = 10 fps. + let fps = sustained_fps(&[100.0, 100.0]); + assert!((fps - 10.0).abs() < 1e-9); + } + + #[test] + fn json_object_has_the_contract_keys() { + let report = Report { + route: ROUTE, + language: "rust", + protocol: "zwlr-screencopy-v1", + output: "hh-chromium-yrfadn".to_string(), + geometry: [1280, 720], + mode: "jpeg", + warmup: 10, + frames: 300, + frame_ms: Summary { + min: 1.0, + p50: 2.0, + mean: 3.0, + p95: 4.0, + max: 5.0, + }, + fps_sustained: 10.0, + wall_ms: 20.0, + cpu_ms_per_frame: None, + bytes_p50: Some(100.5), + persistent: true, + notes: "n".to_string(), + }; + let value = report.to_json(); + for key in [ + "route", + "language", + "protocol", + "output", + "geometry", + "mode", + "warmup", + "frames", + "frame_ms", + "fps_sustained", + "wall_ms", + "cpu_ms_per_frame", + "bytes_p50", + "persistent", + "notes", + ] { + assert!(value.get(key).is_some(), "missing {key}"); + } + assert!(value["cpu_ms_per_frame"].is_null()); + assert_eq!(value["bytes_p50"], 100.5); + assert_eq!(value["persistent"], true); + assert_eq!(value["geometry"][0], 1280); + } +}