From 0c76a0ca11f9322bc51d44e60f81b2e694c3b250 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 12 Apr 2023 19:35:48 +0200 Subject: [PATCH 01/46] Added libavif-sys crate --- Cargo.lock | 520 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 521 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 3c135219..f6c23c88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,11 +74,37 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "anyhow" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" + +[[package]] +name = "arbitrary" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db55d72333851e17d572bec876e390cd3b11eb1ef53ae821dd9f3b653d2b4569" + +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c29b43ee8654590587cd033b3eca2f9c4f8cdff945ec0e6ee91ceb057d87f3" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "arrayvec" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +dependencies = [ + "serde", +] [[package]] name = "atty" @@ -97,12 +123,34 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "av1-grain" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f6ca6f0c18c02c2fbfc119df551b8aeb8a385f6d5980f1475ba0255f1e97f1e" +dependencies = [ + "anyhow", + "arrayvec", + "itertools", + "log", + "nom", + "num-rational", + "serde", + "v_frame", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitstream-io" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d28070975aaf4ef1fd0bd1f29b739c06c2cdd9972e090617fb6dca3b2cb564e" + [[package]] name = "bitvec" version = "1.0.1" @@ -115,6 +163,15 @@ dependencies = [ "wyz", ] +[[package]] +name = "built" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9c056b9ed43aee5e064b683aa1ec783e19c6acec7559e3ae931b7490472fbe" +dependencies = [ + "cargo-lock", +] + [[package]] name = "bumpalo" version = "3.12.0" @@ -133,6 +190,18 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "cargo-lock" +version = "8.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031718ddb8f78aa5def78a09e90defe30151d1f6c672f937af4dd916429ed996" +dependencies = [ + "semver", + "serde", + "toml 0.5.11", + "url", +] + [[package]] name = "cast" version = "0.3.0" @@ -148,6 +217,15 @@ dependencies = [ "jobserver", ] +[[package]] +name = "cfg-expr" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a35b255461940a32985c627ce82900867c61db1659764d3675ea81963f72a4c6" +dependencies = [ + "smallvec", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -247,6 +325,15 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -281,6 +368,12 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "const_fn_assert" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27d614f23f34f7b5165a77dc1591f497e2518f9cec4b4f4b92bfc4dc6cf7a190" + [[package]] name = "crc32fast" version = "1.3.2" @@ -452,12 +545,32 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "funty" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +[[package]] +name = "getrandom" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "glob" version = "0.3.1" @@ -524,6 +637,16 @@ dependencies = [ "quick-error", ] +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "image" version = "0.24.5" @@ -576,6 +699,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "interpolate_name" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4b35f4a811037cfdcd44c5db40678464b2d5d248fc1abeeaaa125b370d47f17" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "io-lifetimes" version = "1.0.9" @@ -638,12 +772,30 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "libavif-sys" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c7b9293d221c7d4b4290d4479c491a09b877943208593f1563d8521c4b55930" +dependencies = [ + "cmake", + "libc", + "libdav1d-sys", + "rav1e", +] + [[package]] name = "libc" version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +[[package]] +name = "libdav1d-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2449c0cf51b69ae65edb12fa071063e5a51034a8b2347269b5a40aefe2071fcf" + [[package]] name = "libdeflate-sys" version = "0.11.0" @@ -662,6 +814,16 @@ dependencies = [ "libdeflate-sys", ] +[[package]] +name = "libfuzzer-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf184a4b6b274f82a5df6b357da6055d3e82272327bba281c28bbba6f1664ef" +dependencies = [ + "arbitrary", + "cc", +] + [[package]] name = "libwebp" version = "0.1.2" @@ -699,6 +861,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", +] + [[package]] name = "memchr" version = "2.5.0" @@ -714,6 +885,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.6.2" @@ -752,6 +929,15 @@ name = "nasm-rs" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce095842aee9aa3ecbda7a5d2a4df680375fd128a8596b6b56f8e497e231f483" +dependencies = [ + "rayon", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" [[package]] name = "noisy_float" @@ -762,6 +948,44 @@ dependencies = [ "num-traits", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -779,6 +1003,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", + "num-bigint", "num-integer", "num-traits", ] @@ -850,6 +1075,18 @@ dependencies = [ "zopfli", ] +[[package]] +name = "paste" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + [[package]] name = "pkg-config" version = "0.3.26" @@ -902,6 +1139,12 @@ version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "pretty_env_logger" version = "0.4.0" @@ -942,6 +1185,75 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rav1e" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be22fc799d8dc5573ba290fd436cea91ccfc0c6b7e121750ea5939cc786429ec" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io", + "built", + "cc", + "cfg-if", + "const_fn_assert", + "interpolate_name", + "itertools", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "nasm-rs", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "rand", + "rand_chacha", + "rust_hawktracer", + "rustc_version", + "scan_fmt", + "simd_helpers", + "system-deps", + "thiserror", + "v_frame", +] + [[package]] name = "rayon" version = "1.7.0" @@ -1018,6 +1330,7 @@ dependencies = [ "criterion", "imagequant", "indicatif", + "libavif-sys", "libwebp", "log", "mozjpeg", @@ -1033,6 +1346,28 @@ dependencies = [ "wild", ] +[[package]] +name = "rust_hawktracer" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3480a29b927f66c6e06527be7f49ef4d291a01d694ec1fe85b0de71d6b02ac1" +dependencies = [ + "rust_hawktracer_normal_macro", + "rust_hawktracer_proc_macro", +] + +[[package]] +name = "rust_hawktracer_normal_macro" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a570059949e1dcdc6f35228fa389f54c2c84dfe0c94c05022baacd56eacd2e9" + +[[package]] +name = "rust_hawktracer_proc_macro" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb626abdbed5e93f031baae60d72032f56bc964e11ac2ff65f2ba3ed98d6d3e1" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -1077,6 +1412,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scan_fmt" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b53b0a5db882a8e2fdaae0a43f7b39e7e9082389e978398bdf223a55b581248" + [[package]] name = "scopeguard" version = "1.1.0" @@ -1088,6 +1429,9 @@ name = "semver" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +dependencies = [ + "serde", +] [[package]] name = "serde" @@ -1120,18 +1464,42 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +dependencies = [ + "serde", +] + [[package]] name = "simd-adler32" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + [[package]] name = "simple-error" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8542b68b8800c3cda649d2c72d688b6907b30f1580043135d61669d4aad1c175" +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + [[package]] name = "stderrlog" version = "0.5.4" @@ -1172,6 +1540,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "system-deps" +version = "6.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "555fc8147af6256f3931a36bb83ad0023240ce9cf2b319dec8236fd1f220b05f" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml 0.7.3", + "version-compare", +] + [[package]] name = "tap" version = "1.0.1" @@ -1193,6 +1574,26 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.9", +] + [[package]] name = "thread_local" version = "1.1.7" @@ -1222,36 +1623,140 @@ dependencies = [ "serde_json", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "toml" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "typed-arena" version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + [[package]] name = "unicode-ident" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-width" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "utf8parse" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "v_frame" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "148c23ce3c8dae5562911cba1c264eaa5e31e133e0d5d08455409de9dd540358" +dependencies = [ + "cfg-if", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "rust_hawktracer", +] + [[package]] name = "vcpkg" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version-compare" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" + [[package]] name = "version_check" version = "0.9.4" @@ -1268,6 +1773,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.84" @@ -1453,6 +1964,15 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "winnow" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +dependencies = [ + "memchr", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 9f396230..49de69c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,7 @@ simple-error = "0.3.0" wild = "2.1.0" resize = "0.7.4" libwebp = "0.1.2" +libavif-sys = "0.14.3" [dev-dependencies] criterion = { version = "0.4.0", features = ["html_reports"] } From 5e919373338a0cccff6005fc157a1ba36d15c57a Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 12 Apr 2023 19:36:04 +0200 Subject: [PATCH 02/46] Added decode_avif function --- src/lib.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index b001c604..f80e30aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -433,6 +433,42 @@ impl<'a> Decoder<'a> { buf.to_owned(), )) } + + fn decode_avif(&self) -> Result { + use libavif_sys::*; + unsafe { + let image = avifImageCreateEmpty(); + let decoder = avifDecoderCreate(); + let decode_result = + avifDecoderReadMemory(decoder, image, self.raw_data, self.raw_data.len()); + avifDecoderDestroy(decoder); + + let mut result = Err(DecodingError::Parsing(Box::new(SimpleError::new( + "Failed to decode avif", + )))); + + if (decode_result == AVIF_RESULT_OK) { + let rgb: avifRGBImage; + avifRGBImageSetDefaults(&rgb, image); + rgb.depth = 8; + + avifRGBImageAllocatePixels(&rgb); + avifImageYUVToRGB(image, &rgb); + + result = Ok(ImageData::new( + rgb.width as usize, + rgb.height as usize, + rgb.pixels.to_owned(), + )); + + avifRGBImageFreePixels(&rgb); + } + + avifImageDestroy(image); + + result + } + } } /// Encoder for images From 667d4540e475ac3f99facd0bc582fe3f9d975011 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 12 Apr 2023 19:36:13 +0200 Subject: [PATCH 03/46] Added avif test cases --- tests/files/basi0g01.avif | Bin 0 -> 341 bytes tests/files/basi0g02.avif | Bin 0 -> 335 bytes tests/files/basi0g04.avif | Bin 0 -> 418 bytes tests/files/basi0g08.avif | Bin 0 -> 688 bytes tests/files/basi0g16.avif | Bin 0 -> 618 bytes tests/files/basi2c08.avif | Bin 0 -> 771 bytes tests/files/basi2c16.avif | Bin 0 -> 957 bytes tests/files/basi3p01.avif | Bin 0 -> 333 bytes tests/files/basi3p02.avif | Bin 0 -> 357 bytes tests/files/basi3p04.avif | Bin 0 -> 653 bytes tests/files/basi3p08.avif | Bin 0 -> 848 bytes tests/files/basi4a08.avif | Bin 0 -> 528 bytes tests/files/basi4a16.avif | Bin 0 -> 694 bytes tests/files/basi6a08.avif | Bin 0 -> 1020 bytes tests/files/basi6a16.avif | Bin 0 -> 1655 bytes 15 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/files/basi0g01.avif create mode 100644 tests/files/basi0g02.avif create mode 100644 tests/files/basi0g04.avif create mode 100644 tests/files/basi0g08.avif create mode 100644 tests/files/basi0g16.avif create mode 100644 tests/files/basi2c08.avif create mode 100644 tests/files/basi2c16.avif create mode 100644 tests/files/basi3p01.avif create mode 100644 tests/files/basi3p02.avif create mode 100644 tests/files/basi3p04.avif create mode 100644 tests/files/basi3p08.avif create mode 100644 tests/files/basi4a08.avif create mode 100644 tests/files/basi4a16.avif create mode 100644 tests/files/basi6a08.avif create mode 100644 tests/files/basi6a16.avif diff --git a/tests/files/basi0g01.avif b/tests/files/basi0g01.avif new file mode 100644 index 0000000000000000000000000000000000000000..cba0ff14671c20cf32f94edebeb86c0da530ac69 GIT binary patch literal 341 zcmZQzU{FXasVqn=%S>Yc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|-$vG7aOhCxi02C6>EXYj+$pHb-VJwVH%`8Bsb8bpvi4X%9 zr-Y#WKMw%`69pq3pwrK!*dL8dyJKj}<8U9YuY9|0F*GBsQ literal 0 HcmV?d00001 diff --git a/tests/files/basi0g02.avif b/tests/files/basi0g02.avif new file mode 100644 index 0000000000000000000000000000000000000000..ad7b367383a85055f556e24d93ebc33c19da388e GIT binary patch literal 335 zcmZQzU{FXasVqn=%S>Yc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|-$vG7aOhCxi02C6>EXYj+$pHb-VJwVH%`8BsZEi|pi4X%9 zr-Y#WKMw%`69pqRpwo2^Jki{^m*?@0MR!kpbJf4e+0GJ>vAq1WX=LPNF712~v5gJ@ Dp&~*f literal 0 HcmV?d00001 diff --git a/tests/files/basi0g04.avif b/tests/files/basi0g04.avif new file mode 100644 index 0000000000000000000000000000000000000000..662cc6ab7a12bb284a0b21fefe93847b3b6c20f2 GIT binary patch literal 418 zcmZQzU{FXasVqn=%S>Yc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|-$vG7aOhCxi02C6>EXYj+$pHb-VJwVH%`8CXgxr+G5+MdI zP6?{vhU>CS3SE%l*`CjU)Y8}u#v z^wk)rdpfK3yzPzTds#P!*YEaPW3$)^mD6*(4+y!wO3z&o{X0DMMoV$@B|e82spgp~ m;q~8Fdp5i{FFu2*{@Vk8hULFz{IYE;eO(Yc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|UY>mv!Jh0th87Uwq zl?kL6s3x(@z|c8ACm(EOR%Ss_0Z`mKvmiMiNQ-0^7o>s|0)YY)3lwBlWP${kIXF0g z6i;HAp>rbx4@gKjIX|Z;FFB`zfe8rN8h}FLnFYCtAUPlaI*f&pshI`HnwOiBSR%y0 z#VH|Z|Ib4}z(m2Qjah(!;lz@xYeu^?Ph=a;wP@w7<|wX@G?6cQS$;Mnw5Z`<#(9Ya z&onyEs(h8&^}OTS=F;yx2MUd*b_wpn+dI(PfggfQ`g z!48G{3`8Sx+iiE0ecf`>WXiqX_a*^~`dRv0FFWb$X0rto*IjD5ea&L~6us<)^QCXu>zQRMy@|ch^RqFA zKTNkmeEXh*O>E+4ws}2%y8G<9g;DO$cG*Vs|M~fGXYl{IV$6>geH1IV^zXFzu)IJ! zW!FUI=NakK57oT-9$y-Lz&f9IWhQ6*#*+PWxILG!HCOwb&N%VF^EbyX{W(SFG=!B_ M9XcB=`D0fs01X-NPyhe` literal 0 HcmV?d00001 diff --git a/tests/files/basi0g16.avif b/tests/files/basi0g16.avif new file mode 100644 index 0000000000000000000000000000000000000000..968a6b0d767c578963dca1704ac5a3d73dc46d7e GIT binary patch literal 618 zcmZQzU{FXasVqn=%S>Yc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|9!5(dzCX8<-~8j;%tgP?dx%Th zNMHK9`V8Z$8>#$xM-7xW9aLYkNc->3KP8X7KkfPW{fM>oGtYZPGOByZKHY125|=G4 zzGgw}jq;vWx5>GB>xxfNc`r_hnXvbz!PoD*Vm&?77qmW7 zathHcQ++*@`(q}!OEmxh!OzjT literal 0 HcmV?d00001 diff --git a/tests/files/basi2c08.avif b/tests/files/basi2c08.avif new file mode 100644 index 0000000000000000000000000000000000000000..c5c04aacc7e804e582698d1f1aaa8d0dee04c126 GIT binary patch literal 771 zcmZQzU{FXasVqn=%S>Yc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|mv!Jh0th87Uwq zl?kL6s3x(@z|c8ACm(EOR%Ss_0Z`mKvmiMiNQ-0^7o>s|0)YY)3lwBlWP${kIXF0g z6i;HAp>rbx4@gKjIX|Z;FFB`zfe8rN8h}FLnFYCtAUPlaI*f&pshI`H`k0%NSR%y0 z#VH|Z|Ib4}z(m35CbIwo!{r{Uh4+{_r9Xuyu6jKy+O$jHbqjm{7vsybUOy31_)_ED zvx4Q0QmOj;XOUMnsQx+;S!*QoMwvfJKd4UhM~2ZG^TV?qJ?=R2Z@Y+TT=k)j8I@nM z(?z(>STx1Qeu!Ii>esm*>6D{qrX9%86j~7KYo&KvyKR$WP3A)Gn0J4Qc6qQ}e(svK zexd{Snflk;zW(&}{@!rzy`zPde4$-bi1WYGzy2)Ks#cpJqd(6tDSgjtLmOu8gTH5P zDV6Nml-TlW_Qjb@M<3q4+WUE)%f9lr$;nY`+L)%U<2=0Z5c8a9+w}`ASyOx!O6Meg ze<0nI_wBJ>-dwE*91}mWYgaw}xh`b6J;|)eht}~Op4Be3V$SBz`%}-?dn{R-)?f4> zLZYc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|1git>_kDj1l6kgWkIB%WE2n+TEv0-(cK7@3+`fUa7do03=} z#K6TVA!z^4LqNbp!Duq800YBy^|qWnak>{=`ugF0O2wNeytQ~ybDK@-#Oa2fDkY%_&bNMv{CAz= zVPbhe+2RA6$LpKBT2AxtH9>O=;RV{ADootlezuR)>^p&T7 zDO#3Azd18)yDr0)1;tww^gmwt>Uj9$o?K1uBay3bKdmkJ=)fnrJU~4)&WcOo)Vqb( z$~DpogN5R2mc2NV+c95ONxoJ7r`gh({Av$pRp?1qFV_xzfBlo$w|zldeu-aEF7()$ zeq=+z8_6U0JXr3ou?b>|Sgks%c$q-&si}tqZZ%dsS==KlS)0&ge*L4(Q!b^eGB3<- zuH3zOZnU4O)N$MWM&Hgv{YhRCCvPM9caG}1M`uEcC=oM}Q;6WbHlKV>7f? zCzxGHa{Dmp!sfPw#~lr<1`{qlu9(LpyZtAxie$F<9uBXD1KMBf?Oz$ZIP9O+(SJTR zMq!%wXO6Y$XZ;hGPEWhxx9>I2?{dj>KB@WBj%D$M`A=Tc{%K46Il)iX>za7KUt0CW p^Wd82O+m}Kk_=`4XsYk86AZB2{8YeG)0RJA?p4icmJ|210|55Rdo%z5 literal 0 HcmV?d00001 diff --git a/tests/files/basi3p01.avif b/tests/files/basi3p01.avif new file mode 100644 index 0000000000000000000000000000000000000000..7006d5f3cd0b075dce553a2e8ed9b214a2daccee GIT binary patch literal 333 zcmZQzU{FXasVqn=%S>Yc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|-$vG7aOhCxi02C6>EXYj+$pHb-VJwVH%`8Bsb#6*xi4X%9 zr-Y#WKMw%`69pp`pwo3b8JkwYc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|mgoKmxbBgkkb1E2^fRL>LC?uX)kedjS0|KDKSQwd_S%A#o+?2!;AqFl^ z2|@dR9s&X;3Pv_Sr|TX{4Rd}kT_Is|U*xCg42S6!TJg7%Wb?w6%C0_tcf-RYc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|_THPu~1K`uwtbw%m=v zJu0OpocvNXzZl%tNvWROaOtvyy1(pIx8Q@ar#Nysy+oPKBe^OnU*&Y{zE=|vTlQhP zzrmRqCLeCq-gZsgDgFD={Np*(I^TBvZ8AOjW>?eWJsd8@Ut)Y8n)V0%XL}+cFY%Dc zB&l%~Z-`t*?OoQX^&b@@;4_?P!7=4@j($#`%>4$*dZ&xg}`YW_~O^IZ+F;{!_kxN-DJkb$>4^DMH)_czv z5iR@X%lxmUVm~M)8Vr}Rc|m}+p|9UMCy`*tq@6%hhQ2wC0NQve1)1nOk`KscF literal 0 HcmV?d00001 diff --git a/tests/files/basi3p08.avif b/tests/files/basi3p08.avif new file mode 100644 index 0000000000000000000000000000000000000000..3b636cb18347a1bfa872bd5cb1b3ce3b59ea10b7 GIT binary patch literal 848 zcmZQzU{FXasVqn=%S>Yc0uY^>nP!-qnV9D5Xy^nK`jnemk_eIm0*#E6oFWL5fuSHX zxdg@r(K(q(Fk|=%GD~v7a*RMyE;A=T8N_p8U|rB82-^Si5D+j?Fj~eUz`$_+M9`D}zuBzX+U0vr2L2XGbO; z-nDBow@zqXd})W|@4y4A_eHY3em!SDx2{A}^H+7=sl}H+J~);V{QCdHx~#Bx2ces7 zf&zkbZcYu0&%66+^_ja|n{4WiUs_e?!@;H&v1a4i>U>B4RkP0(iCIX8ZkzDg!EE!) zUw(Uz*k3)WGO=WPbLYeV(Ji<2*F;{_ePmgRAr8r#t#`E1bWu?c?P1g#L?c zxsNW%)^?O%wM^(t41Z!>_y6>Z1f7|i4z?D*O0(g1W|?Ja&|U3Uk&~AU2=NJS{G{e#ZMhIBffE zzs~!=vuNb2{e{d|j;Tbh+teO)_Hm%{Vzq5Y_pHzOv3>5j#LbK)|7>VsEI?p#x)_uwsJ~QQ2YT4vD zJ*_kJ4?XN%;+5&X_3qa=wndrxf-4R#-uGI9@lC6e*`Z}i+oo;({&d}gdvAoMHSCz; z$6-{S`POKQazoUDmL$1!7lRJI_V@+7+tfN`51AWBGyizRYkd3bGj*4x8+AUbPcwK^ d#5K)r@0wYqMQnVoo7syO?SI(5)?2wq001uyOIZK_ literal 0 HcmV?d00001 diff --git a/tests/files/basi4a08.avif b/tests/files/basi4a08.avif new file mode 100644 index 0000000000000000000000000000000000000000..1ce2fc98c1fc0cff8d9f86bf367ee64c41843cbe GIT binary patch literal 528 zcmYjN%}WAN5T7+IH4*KDL_$0i6&R>=sJ-}k?GW`3yw)`b-nx%<6}?$OmyixYwy@=ll`zvo>OPLk#ktIj44 z6D3ENDYAk!lBt5pO=p2WhG@y;xTr9h8AVI)bpQymdXqad<TtI=W!6O(8n8m#+LvmUqA+jV?%|ZdFx7 z=o`+HS2fgxT5Hv8-KeRQgB+RFQdxif7z)F=gG%YM+=^@44KBCh*%_jUW|Wvc0)9^< zocS70ha=gEo=!%x!-=bBcvTwHgmJf=2n|O-ez#~ literal 0 HcmV?d00001 diff --git a/tests/files/basi4a16.avif b/tests/files/basi4a16.avif new file mode 100644 index 0000000000000000000000000000000000000000..249d3626626e5c1988a1fc2159e71c764cefb99e GIT binary patch literal 694 zcmZQzU{FXasVqn=%S>Yc0uY^>nP!-qnV9D5Xz0Yiz}TCcT9OEo0|JeVl$;_6lYyZi zGr0uD2GKd0Nibvh3NlM_!E%g1QYSMfKN-YxVPIfl0EqxG;~OA-3do1>wgPE$Aa=^k z%mcdwEF%Tvq=J-ybR?D;7&_>5r80|BAto>|@FkX3+a_rh^G5tK`h&0;}T6;*!+d zVk@AU%$&@`qDreonDgZ_3v$8!0BQvW77HU&GYbO~3nObAJ1`VDb5jyagc!J3B?Rri zi5lrhIOuF-aGP7dD(g>fTW%7o&c;s0Stpz4#;!QJnxXd0pM$UcPrdG7ZHkO9F#u}g z1Zm?C5HL|N+Qlg0z^$|C2m_yz@3)N$y7a@hMl1}8S3Sd^(KS`;Qw7)Bf`HJLh0`q( z9N!v7p4*dZ5!q7moH?(0^|hO)&ow1Eelxmtv|zKTm?C%KQu%4-O}jJ>A6@&Bb6-lH zed^U!LepdYKe=}92wZVndfmb~c}n}fF;}WAK6&h`oB;qI Co5E}W literal 0 HcmV?d00001 diff --git a/tests/files/basi6a08.avif b/tests/files/basi6a08.avif new file mode 100644 index 0000000000000000000000000000000000000000..ff20aeb654d77c2f1e384ae5bc2160d083e2a86a GIT binary patch literal 1020 zcmZQzU{FXasVqn=%S>Yc0uY^>nP!-qnV9D5Xz0Yiz}TCcT9OEo0|JeVl$;_6lYyZi zGr0uD2GKd0Nibvh3NlM_!E%g1QYSMfKN-YxVPIfl0EqxG<4+)m8OVq5wnC&CoH8@> zz%BvHNC7#iASECjiDd?c&iOg{Uq7AVN9$OH*6b8v6~DW1eKL+3^Y9*~f5a(+%x zUUE(a&_pH%wg#XO(4!FLj7W-QK#DDZRy%_jrA2vGxdo}|V8Y2NIWxJys<^VaBsI6# z3aBPCCo{3A(kc<=e7VemT(CcYT7iMZ!pPLj!obAB$lAsZ6!6bYNh}d!;9`{!wEq`s zWGTSVq;#Y3@!@6VS?|T(iFZ8y>3I0P$W@Wsd9qpy?S2_vNNo?RS4j1o^lW0(c@=gq zJ{I{?Ji^-RzW~kP1exI>AYh_k^qE zjOJfSbJ`R3cmKnO7P>Q!ysM}`{UWFGZTtqQv});zy|<2T$x&boy%xvGq^;4~8vohl z^}E!ti(h~8jG+D0+Q+CTQuWMZ#v=*?%Hzj)^l=DRy=)Fve) zSLE|v)aYEL;kSPA-T=k#*KPky$vHXUvgx54ZdKORJ||j?lykq`N!OZl%jnB@^Nov@ z_);a;o|?4(&>Dr_oSfb*dg`Lk`Gm>9A?sK2hYsDI2%VVOkX<3xK ztd8WA6`S2N`qnLAn8K2@=gG1y|IP%iD1J71Lrr%5CANSs6P-@zMYcXPt$q-AGg!31e+*0u87n5_ zPZd^f1KIQ+9RNU<8XC?N%@j^;0UJAy#{x&BTNVu{`XUxhzQ9D$4z2aw_ji3Cab!#Y^LR4xXP zlE7}X_{YVd0D%Tt5wjAWJVU{G-Pd9%k@sZzRciJZv_92qL%}{2{*BA|eMNbslL@-& zLt^P`X{PQd{jA&)npEJcYrnj|KZ6h;dZU$Ye-tC>OQ)~ySP0AvY(Mty@Fj~(KeMLE zIh=iEo{=KSbN^t?r^yXd=|w)~xifFRd29Q6s3@TBo=(kg7#+qmxt~8ecEp>4(n!d2 zoRV^rG_Kq=x1gubT8*2yz0VuocfD|58#LNb*&r5$27vA^yzAQ9_v1F+7~^!@ZsH_j zcb!8saSW#?SdoKIbDp8nk?m%MugCG7x3=PV=8RR3#|n`XBrT8`rbjU%T%j!b=UNu{ zm+}j`ZiZr~y~lUltUB_#GYp3xuzleb;ixF%t)H7$|Hjql(O}np#-+q&mQ?D3Y>N}+ zt`+uahVSb0%Z;X*QTMH#`1b93zVpw~?7+;l{%}b0Z9~w~tlVd&gWu+@OH_A9`*DR= z&&Dv^Y;0kGziaFI(hRrQu1DR;%iB}$fDH%^Q#UjP(~&gN^GMhE@K?Df#Is@bV2 z5S@4Sy(W_sRqHomtyZ48X!N)HErq;?hqaB$_oBiva=Yuw?gq?VI(1>TKIn^OWFpi* zG&)pJ_A+PoT*^$i&6eR#^XbN*R%ffHA+-@DM$v+Vkr|3-$AEn0b@w&`GhByZv5T(p zjI1uH_J_^1UYM!kTkAJmnd6e1tjkX-Mib3!y1ZQPb+jY#nAWtN<4DhvfuasCieZCW z7DM*3b!eW}gz}98t2Gw3@xMogd{&EY*wv&&bh{E}mrJ&r$yBL{Vq7PWn~a{=RLctB zZ+xFAefg|6<{7sCVI8|3B+zT@vnzJGgz%!KwEAAPIZ9~VsBe|l`hK&1AJ+V!;-@R(rRwuST-yXSM{LJn9QrjuWmB)@XnoWy4Y6mC&7yJ~x=bXhP+{wq#R zKH}wp3~hr;dv1lHpKx0`^q0-KDiu!sSkk%Wv5e|9dDB?+FKmOtb7?B!k7cBbFBa$f zxy%=oDK_+o!)d-_mYQ?FbLj%LQMX2xxl zFIrL{C;$2IG*;l8prdoqc~wc(cbD ziTa+t11q6hgJ+}`EK^?UC&l}Yc@|65iFIY2{Rpk0Yksf_O zt-~otllZSD#M@hz4MV144GtYW+b&&Rk%L=L4%k3;dJt(*{jq>ydSVlz$1rlAZQ6zE zcXr}uCg0i$^7#`iwrquFmmtSqwaEi-hBo<4qt9m5%`@X4*%Id-R}WJ1#h6e#p5}sM*oncIb&_w__^1?F`Cs Wo0HYay#eVSTjTXsnk@ Date: Wed, 12 Apr 2023 20:09:57 +0200 Subject: [PATCH 04/46] now avif is optional feature --- Cargo.toml | 5 ++++- src/lib.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 49de69c5..139a35fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,9 @@ codegen-units = 1 inherits = "release" debug = 1 +[features] +avif = ["dep:libavif-sys"] + [dependencies] bytemuck = "1.13.1" clap = { version = "4.2.1", features = ["derive"] } @@ -38,7 +41,7 @@ simple-error = "0.3.0" wild = "2.1.0" resize = "0.7.4" libwebp = "0.1.2" -libavif-sys = "0.14.3" +libavif-sys = {version = "0.14.3", optional = true} [dev-dependencies] criterion = { version = "0.4.0", features = ["html_reports"] } diff --git a/src/lib.rs b/src/lib.rs index f80e30aa..d6e016b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -434,6 +434,7 @@ impl<'a> Decoder<'a> { )) } + #[cfg(feature = "avif")] fn decode_avif(&self) -> Result { use libavif_sys::*; unsafe { From 90666ce777c15e937b991305db5f16a4146d4a03 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 12 Apr 2023 20:17:55 +0200 Subject: [PATCH 05/46] Updated metadata --- CHANGELOG.md | 4 ++++ CONTRIBUTING.md | 3 ++- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 22 +++++++++++++++------- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cda281f..9cd13125 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.7.0 + +- [Added] AVIF decoding and encoding + ## v0.6.0 - [Added] WebP decoding and encoding diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0c21c624..2044e1f5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,8 @@ To get started with contributing, you'll need to: 1. Fork the repository on GitHub 2. Clone your fork locally 3. Install Rust and Cargo (if you haven't already) -4. Run `cargo build` to ensure everything builds properly +4. Also you will need to install cmake, nasm and ninja/meson for avif development +5. Run `cargo build` to ensure everything builds properly ## Making Changes diff --git a/Cargo.lock b/Cargo.lock index f6c23c88..c4743357 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1323,7 +1323,7 @@ dependencies = [ [[package]] name = "rimage" -version = "0.6.0" +version = "0.7.0" dependencies = [ "bytemuck", "clap 4.2.1", diff --git a/Cargo.toml b/Cargo.toml index 139a35fc..9daaccb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ exclude = ["tests/*", ".*"] repository = "https://github.com/SalOne22/rimage" license = "MIT OR Apache-2.0" -version = "0.6.0" +version = "0.7.0" edition = "2021" [profile.release] diff --git a/README.md b/README.md index cd0bfd74..0f17c225 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,7 @@ Rimage currently supports three codecs, mozjpeg, oxipng and webp, and aims to ad ## Installation -If you have cargo you can use this - -``` -cargo install rimage -``` - -or from [Releases](https://github.com/SalOne22/rimage/releases) on GitHub +You can download latest release from [Releases](https://github.com/SalOne22/rimage/releases) tab on GitHub ## Usage @@ -45,6 +39,20 @@ rimage -q 75 *.jpg Read changelog [here](CHANGELOG.md) +## Building from source + +For building rimage from source you will need to run this command: + +``` +cargo install rimage +``` + +If you want to include AVIF support you will need to install cmake, nasm and ninja/meson, then you can run this command: + +``` +cargo install rimage -F avif +``` + ## Development Please read the [contribution guide](CONTRIBUTING.md) From 475faa255e8477ba287ac5f3fda123b5ab20ce55 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 12 Apr 2023 20:22:26 +0200 Subject: [PATCH 06/46] Revert "now avif is optional feature" This reverts commit 8fc214ec67f2828126c5a1b08f523a34dc64ae8d. --- Cargo.toml | 5 +---- src/lib.rs | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9daaccb5..1ea468fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,6 @@ codegen-units = 1 inherits = "release" debug = 1 -[features] -avif = ["dep:libavif-sys"] - [dependencies] bytemuck = "1.13.1" clap = { version = "4.2.1", features = ["derive"] } @@ -41,7 +38,7 @@ simple-error = "0.3.0" wild = "2.1.0" resize = "0.7.4" libwebp = "0.1.2" -libavif-sys = {version = "0.14.3", optional = true} +libavif-sys = "0.14.3" [dev-dependencies] criterion = { version = "0.4.0", features = ["html_reports"] } diff --git a/src/lib.rs b/src/lib.rs index d6e016b0..f80e30aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -434,7 +434,6 @@ impl<'a> Decoder<'a> { )) } - #[cfg(feature = "avif")] fn decode_avif(&self) -> Result { use libavif_sys::*; unsafe { From 4e18541a4e2d1533bf3ae840b7dfb8b1ec4214e2 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:07:27 +0200 Subject: [PATCH 07/46] Fixed avif decoding and added test for it --- src/lib.rs | 101 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 29 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f80e30aa..f935c602 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -343,6 +343,7 @@ impl<'a> Decoder<'a> { Some("jpg") | Some("jpeg") => self.decode_jpeg(), Some("png") => self.decode_png(), Some("webp") => self.decode_webp(), + Some("avif") => self.decode_avif(), Some(ext) => Err(DecodingError::Format(Box::new(SimpleError::new(format!( "{} not supported", ext @@ -436,38 +437,52 @@ impl<'a> Decoder<'a> { fn decode_avif(&self) -> Result { use libavif_sys::*; - unsafe { - let image = avifImageCreateEmpty(); - let decoder = avifDecoderCreate(); - let decode_result = - avifDecoderReadMemory(decoder, image, self.raw_data, self.raw_data.len()); - avifDecoderDestroy(decoder); - - let mut result = Err(DecodingError::Parsing(Box::new(SimpleError::new( - "Failed to decode avif", - )))); - - if (decode_result == AVIF_RESULT_OK) { - let rgb: avifRGBImage; - avifRGBImageSetDefaults(&rgb, image); - rgb.depth = 8; - - avifRGBImageAllocatePixels(&rgb); - avifImageYUVToRGB(image, &rgb); - - result = Ok(ImageData::new( - rgb.width as usize, - rgb.height as usize, - rgb.pixels.to_owned(), - )); - - avifRGBImageFreePixels(&rgb); - } + let image = unsafe { avifImageCreateEmpty() }; + let decoder = unsafe { avifDecoderCreate() }; + let decode_result = unsafe { + avifDecoderReadMemory(decoder, image, self.raw_data.as_ptr(), self.raw_data.len()) + }; + unsafe { avifDecoderDestroy(decoder) }; + + let mut result = Err(DecodingError::Parsing(Box::new(SimpleError::new( + "Failed to decode avif", + )))); + + if decode_result == AVIF_RESULT_OK { + let mut rgb: avifRGBImage = Default::default(); + unsafe { avifRGBImageSetDefaults(&mut rgb, image) }; + rgb.depth = 8; + + unsafe { + avifRGBImageAllocatePixels(&mut rgb); + avifImageYUVToRGB(image, &mut rgb); + }; + + let pixels = unsafe { + Vec::from_raw_parts( + rgb.pixels as *mut u8, + rgb.width as usize * rgb.height as usize * 4, + rgb.width as usize * rgb.height as usize * 4, + ) + }; + + result = Ok(ImageData::new( + rgb.width as usize, + rgb.height as usize, + pixels.clone(), + )); + + std::mem::forget(pixels); + + unsafe { avifRGBImageFreePixels(&mut rgb) }; + } + + unsafe { avifImageDestroy(image); + }; - result - } + result } } @@ -1006,6 +1021,34 @@ mod tests { }) } + #[test] + fn decode_avif() { + let files: Vec = fs::read_dir("tests/files/") + .unwrap() + .map(|entry| { + let entry = entry.unwrap(); + entry.path() + }) + .filter(|path| { + let re = Regex::new(r"^tests/files/.+.avif$").unwrap(); + re.is_match(path.to_str().unwrap_or("")) + }) + .collect(); + + files.iter().for_each(|path| { + println!("{path:?}"); + let data = fs::read(path).unwrap(); + let d = Decoder::new(path, &data); + + let img = d.decode().unwrap(); + println!("{:?}", img.size()); + println!("{:?}", img.data().len()); + + assert_ne!(img.data().len(), 0); + assert_ne!(img.size(), (0, 0)); + }) + } + #[test] fn encode_jpeg() { let files: Vec = fs::read_dir("tests/files/") From a20507e7559482aa6cdc366d4d1feaebdb126780 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:17:03 +0200 Subject: [PATCH 08/46] Updated build instructions --- CONTRIBUTING.md | 1 + README.md | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2044e1f5..892d4846 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,6 +15,7 @@ To get started with contributing, you'll need to: 3. Install Rust and Cargo (if you haven't already) 4. Also you will need to install cmake, nasm and ninja/meson for avif development 5. Run `cargo build` to ensure everything builds properly +> note: On windows use Visual Studio build environment like developer PowerShell for VS 2019 ## Making Changes diff --git a/README.md b/README.md index 0f17c225..4b2aa327 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,9 @@ For building rimage from source you will need to run this command: cargo install rimage ``` -If you want to include AVIF support you will need to install cmake, nasm and ninja/meson, then you can run this command: +This app requires cmake, nasm and ninja/meson installed on system -``` -cargo install rimage -F avif -``` +> note: On windows use Visual Studio build environment like developer PowerShell for VS 2019 ## Development From 013a108026cb1bb6bee7f0535af8849789179e36 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Fri, 14 Apr 2023 16:52:56 +0200 Subject: [PATCH 09/46] Added avif encoding --- src/image.rs | 4 ++ src/lib.rs | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) diff --git a/src/image.rs b/src/image.rs index 7316a167..36dde02f 100644 --- a/src/image.rs +++ b/src/image.rs @@ -53,6 +53,8 @@ pub enum OutputFormat { Oxipng, /// WebP image WebP, + /// AVIF image + Avif, } impl std::str::FromStr for OutputFormat { @@ -64,6 +66,7 @@ impl std::str::FromStr for OutputFormat { "png" => Ok(OutputFormat::Png), "oxipng" => Ok(OutputFormat::Oxipng), "webp" => Ok(OutputFormat::WebP), + "avif" => Ok(OutputFormat::Avif), _ => Err(format!("{} is not a valid output format", s).into()), } } @@ -76,6 +79,7 @@ impl fmt::Display for OutputFormat { OutputFormat::Png => write!(f, "png"), OutputFormat::Oxipng => write!(f, "png"), OutputFormat::WebP => write!(f, "webp"), + OutputFormat::Avif => write!(f, "avif"), } } } diff --git a/src/lib.rs b/src/lib.rs index f935c602..5cf82dd7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -555,6 +555,7 @@ impl<'a> Encoder<'a> { OutputFormat::Oxipng => self.encode_oxipng(), OutputFormat::MozJpeg => self.encode_mozjpeg(), OutputFormat::WebP => self.encode_webp(), + OutputFormat::Avif => self.encode_avif(), } } @@ -617,6 +618,7 @@ impl<'a> Encoder<'a> { OutputFormat::Oxipng => self.encode_oxipng(), OutputFormat::MozJpeg => self.encode_mozjpeg(), OutputFormat::WebP => self.encode_webp(), + OutputFormat::Avif => self.encode_avif(), } } @@ -761,6 +763,124 @@ impl<'a> Encoder<'a> { Ok(data.to_owned()) } + + fn encode_avif(&mut self) -> Result, EncodingError> { + use libavif_sys::*; + + info!("Encoding with AVIF"); + let (width, height) = self.image_data.size(); + + let mut output = avifRWData::default(); + let depth = 8; + let format = AVIF_PIXEL_FORMAT_YUV444; + + // map quality from 0 to 100 to 63 to 0 + let quality = (63.0 - (self.config.quality / 100.0) * 63.0) as u32; + let lossless = quality == AVIF_QUANTIZER_LOSSLESS; + + let image = unsafe { avifImageCreate(width as u32, height as u32, depth, format) }; + + if lossless { + unsafe { + (*image).matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_IDENTITY as u16; + } + } else { + unsafe { + (*image).matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT601 as u16; + } + } + + let rgba = self.image_data.data_mut().as_mut_ptr(); + + let mut src_rgb = avifRGBImage::default(); + unsafe { avifRGBImageSetDefaults(&mut src_rgb, image) } + + src_rgb.pixels = rgba; + src_rgb.rowBytes = width as u32 * 4; + unsafe { avifImageRGBToYUV(image, &mut src_rgb) }; + + let encoder = unsafe { avifEncoderCreate() }; + + if lossless { + unsafe { + (*encoder).minQuantizer = AVIF_QUANTIZER_LOSSLESS as i32; + (*encoder).maxQuantizer = AVIF_QUANTIZER_LOSSLESS as i32; + (*encoder).minQuantizerAlpha = AVIF_QUANTIZER_LOSSLESS as i32; + (*encoder).maxQuantizerAlpha = AVIF_QUANTIZER_LOSSLESS as i32; + }; + } else { + unsafe { + (*encoder).minQuantizer = AVIF_QUANTIZER_BEST_QUALITY as i32; + (*encoder).maxQuantizer = AVIF_QUANTIZER_WORST_QUALITY as i32; + (*encoder).minQuantizerAlpha = AVIF_QUANTIZER_BEST_QUALITY as i32; + (*encoder).maxQuantizerAlpha = AVIF_QUANTIZER_WORST_QUALITY as i32; + + // avifEncoderSetCodecSpecificOption( + // encoder, + // b"end-usage\0".as_ptr() as *const i8, + // b"q\0".as_ptr() as *const i8, + // ); + // avifEncoderSetCodecSpecificOption( + // encoder, + // b"cq-level\0".as_ptr() as *const i8, + // quality.to_string().as_bytes().as_ptr() as *const i8, + // ); + // avifEncoderSetCodecSpecificOption( + // encoder, + // b"sharpness\0".as_ptr() as *const i8, + // b"0\0".as_ptr() as *const i8, + // ); + + // if quality <= 32 { + // avifEncoderSetCodecSpecificOption( + // encoder, + // b"tune\0".as_ptr() as *const i8, + // b"ssim\0".as_ptr() as *const i8, + // ); + // } + + // avifEncoderSetCodecSpecificOption( + // encoder, + // b"color:denoise-noise-level\0".as_ptr() as *const i8, + // b"0\0".as_ptr() as *const i8, + // ); + }; + } + + unsafe { + (*encoder).maxThreads = num_cpus::get() as i32; + (*encoder).tileRowsLog2 = 0; + (*encoder).tileColsLog2 = 0; + (*encoder).speed = 6; + } + + let encode_result = unsafe { avifEncoderWrite(encoder, image, &mut output) }; + + let result: Vec = vec![0; output.size]; + if encode_result == AVIF_RESULT_OK { + unsafe { + std::ptr::copy_nonoverlapping(output.data, result.as_ptr() as *mut u8, output.size); + } + + unsafe { + avifImageDestroy(image); + avifEncoderDestroy(encoder); + avifRWDataFree(&mut output); + }; + + Ok(result) + } else { + unsafe { + avifImageDestroy(image); + avifEncoderDestroy(encoder); + avifRWDataFree(&mut output); + }; + + Err(EncodingError::Encoding(Box::new(SimpleError::new( + format!("Encoding avif failed with error code {}", encode_result), + )))) + } + } } #[cfg(test)] @@ -1169,6 +1289,39 @@ mod tests { }) } + #[test] + fn encode_avif() { + let files: Vec = fs::read_dir("tests/files/") + .unwrap() + .map(|entry| { + let entry = entry.unwrap(); + entry.path() + }) + .filter(|path| { + let re = Regex::new(r"^tests/files/[^x].+\.png").unwrap(); + re.is_match(path.to_str().unwrap_or("")) + }) + .collect(); + + files.iter().for_each(|path| { + println!("{path:?}"); + let data = fs::read(path).unwrap(); + let image = Decoder::new(path, &data).decode().unwrap(); + + let conf = Config::build(75.0, OutputFormat::Avif, None, None, None).unwrap(); + + let encoder = Encoder::new(&conf, image); + let result = encoder.encode(); + + assert!(result.is_ok()); + let result = result.unwrap(); + assert!(!result.is_empty()); + let mut path = path.clone(); + path.set_extension("avif"); + fs::write(path, result).unwrap(); + }) + } + #[test] fn encode_quantized() { let path = path::PathBuf::from("tests/files/basi2c08.png"); From 99a7a56d5d3d492acd2626f46133a9b8c785747a Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Sat, 15 Apr 2023 16:26:26 +0200 Subject: [PATCH 10/46] Replaced encoding to ravif --- Cargo.lock | 342 +++++++++++++++++++++++++++++++++++++++++++++++++---- Cargo.toml | 1 + src/lib.rs | 124 ++----------------- 3 files changed, 332 insertions(+), 135 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c4743357..a69eaf50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,6 +123,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "av-metrics" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13638b394190295622c0d2493d0c8c39210b92c2110895bfb14c58db213c2b39" +dependencies = [ + "crossbeam", + "itertools", + "lab", + "num-traits", + "rayon", + "thiserror", + "v_frame", +] + [[package]] name = "av1-grain" version = "0.2.2" @@ -139,6 +154,15 @@ dependencies = [ "v_frame", ] +[[package]] +name = "avif-serialize" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876c75a42f6364451a033496a14c44bffe41f5f4a8236f697391f11024e596d2" +dependencies = [ + "arrayvec", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -170,6 +194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b9c056b9ed43aee5e064b683aa1ec783e19c6acec7559e3ae931b7490472fbe" dependencies = [ "cargo-lock", + "git2", ] [[package]] @@ -296,6 +321,16 @@ dependencies = [ "bitflags", "clap_lex 0.4.1", "strsim", + "terminal_size", +] + +[[package]] +name = "clap_complete" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c22dcfb410883764b29953103d9ef7bb8fe21b3fa1158bc99986c2067294bd" +dependencies = [ + "clap 4.2.1", ] [[package]] @@ -419,6 +454,20 @@ dependencies = [ "itertools", ] +[[package]] +name = "crossbeam" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" +dependencies = [ + "cfg-if", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + [[package]] name = "crossbeam-channel" version = "0.5.7" @@ -453,6 +502,16 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.15" @@ -504,6 +563,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "errno-dragonfly" version = "0.1.2" @@ -523,6 +593,15 @@ dependencies = [ "hashbrown 0.13.2", ] +[[package]] +name = "fern" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee" +dependencies = [ + "log", +] + [[package]] name = "filetime" version = "0.2.20" @@ -571,6 +650,19 @@ dependencies = [ "wasi", ] +[[package]] +name = "git2" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2994bee4a3a6a51eb90c218523be382fd7ea09b16380b9312e9dbe955ff7c7d1" +dependencies = [ + "bitflags", + "libc", + "libgit2-sys", + "log", + "url", +] + [[package]] name = "glob" version = "0.3.1" @@ -634,7 +726,7 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" dependencies = [ - "quick-error", + "quick-error 1.2.3", ] [[package]] @@ -676,6 +768,12 @@ dependencies = [ "thread_local", ] +[[package]] +name = "imgref" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2cf49df1085dcfb171460e4592597b84abe50d900fb83efb6e41b20fefd6c2c" + [[package]] name = "indexmap" version = "1.9.2" @@ -729,7 +827,7 @@ checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix", + "rustix 0.36.11", "windows-sys 0.45.0", ] @@ -748,6 +846,15 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +[[package]] +name = "ivf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fb01c64361a3a67b511439f0dcd54fa3aa5581c861a17e2ede76e46b9c5b7e2" +dependencies = [ + "bitstream-io", +] + [[package]] name = "jobserver" version = "0.1.26" @@ -766,6 +873,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "lab" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf36173d4167ed999940f804952e6b08197cae5ad5d572eb4db150ce8ad5d58f" + [[package]] name = "lazy_static" version = "1.4.0" @@ -824,6 +937,18 @@ dependencies = [ "cc", ] +[[package]] +name = "libgit2-sys" +version = "0.14.2+1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f3d95f6b51075fe9810a7ae22c7095f12b98005ab364d8544797a825ce946a4" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + [[package]] name = "libwebp" version = "0.1.2" @@ -846,12 +971,30 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libz-sys" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +[[package]] +name = "linux-raw-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" + [[package]] name = "log" version = "0.4.17" @@ -861,6 +1004,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "loop9" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a703804431e5927454bcaf2b2a162595e95db931130c2728c18d050090f69940" +dependencies = [ + "imgref", +] + [[package]] name = "maybe-rayon" version = "0.1.1" @@ -868,6 +1020,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" dependencies = [ "cfg-if", + "rayon", ] [[package]] @@ -1170,6 +1323,12 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quote" version = "1.0.26" @@ -1217,27 +1376,34 @@ dependencies = [ [[package]] name = "rav1e" -version = "0.6.4" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be22fc799d8dc5573ba290fd436cea91ccfc0c6b7e121750ea5939cc786429ec" +checksum = "277898094f0d03c6a609e491324102daf5080e71c06b4b25e5acf8b89d26c945" dependencies = [ "arbitrary", "arg_enum_proc_macro", "arrayvec", + "av-metrics", "av1-grain", "bitstream-io", "built", "cc", "cfg-if", + "clap 4.2.1", + "clap_complete", + "console", "const_fn_assert", + "fern", "interpolate_name", "itertools", + "ivf", "libc", "libfuzzer-sys", "log", "maybe-rayon", "nasm-rs", "new_debug_unreachable", + "nom", "noop_proc_macro", "num-derive", "num-traits", @@ -1248,10 +1414,28 @@ dependencies = [ "rust_hawktracer", "rustc_version", "scan_fmt", + "signal-hook", "simd_helpers", "system-deps", "thiserror", "v_frame", + "wasm-bindgen", + "y4m", +] + +[[package]] +name = "ravif" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26cda034bd7ec1f4e799b207ef0444dd28b2fb310877378a5bb5b8b6ef6c4158" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error 2.0.1", + "rav1e", + "rayon", + "rgb", ] [[package]] @@ -1338,6 +1522,7 @@ dependencies = [ "oxipng", "png", "pretty_env_logger", + "ravif", "regex", "resize", "rgb", @@ -1390,10 +1575,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" dependencies = [ "bitflags", - "errno", + "errno 0.2.8", + "io-lifetimes", + "libc", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", +] + +[[package]] +name = "rustix" +version = "0.37.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aae838e49b3d63e9274e1c01833cc8139d3fec468c3b84688c628f44b1ae11d" +dependencies = [ + "bitflags", + "errno 0.3.1", "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.3.1", "windows-sys 0.45.0", ] @@ -1473,6 +1672,25 @@ dependencies = [ "serde", ] +[[package]] +name = "signal-hook" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "732768f1176d21d09e076c23a93123d40bba92d50c4058da34d45c8de8e682b9" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "simd-adler32" version = "0.3.5" @@ -1568,6 +1786,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +dependencies = [ + "rustix 0.37.7", + "windows-sys 0.48.0", +] + [[package]] name = "textwrap" version = "0.16.0" @@ -1889,13 +2117,13 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -1904,7 +2132,16 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", ] [[package]] @@ -1913,13 +2150,28 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] @@ -1928,42 +2180,84 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "winnow" version = "0.4.1" @@ -1982,6 +2276,12 @@ dependencies = [ "tap", ] +[[package]] +name = "y4m" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a72a9921af8237fe25097a1ae31c92a05c1d39b2454653ad48f2f407cf7a0dae" + [[package]] name = "zopfli" version = "0.7.2" diff --git a/Cargo.toml b/Cargo.toml index 1ea468fd..22f46f28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ wild = "2.1.0" resize = "0.7.4" libwebp = "0.1.2" libavif-sys = "0.14.3" +ravif = "0.11.1" [dev-dependencies] criterion = { version = "0.4.0", features = ["html_reports"] } diff --git a/src/lib.rs b/src/lib.rs index 5cf82dd7..3d180dcc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -764,122 +764,18 @@ impl<'a> Encoder<'a> { Ok(data.to_owned()) } - fn encode_avif(&mut self) -> Result, EncodingError> { - use libavif_sys::*; - + fn encode_avif(&self) -> Result, EncodingError> { info!("Encoding with AVIF"); - let (width, height) = self.image_data.size(); - - let mut output = avifRWData::default(); - let depth = 8; - let format = AVIF_PIXEL_FORMAT_YUV444; - - // map quality from 0 to 100 to 63 to 0 - let quality = (63.0 - (self.config.quality / 100.0) * 63.0) as u32; - let lossless = quality == AVIF_QUANTIZER_LOSSLESS; - - let image = unsafe { avifImageCreate(width as u32, height as u32, depth, format) }; - - if lossless { - unsafe { - (*image).matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_IDENTITY as u16; - } - } else { - unsafe { - (*image).matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT601 as u16; - } - } - - let rgba = self.image_data.data_mut().as_mut_ptr(); - - let mut src_rgb = avifRGBImage::default(); - unsafe { avifRGBImageSetDefaults(&mut src_rgb, image) } - - src_rgb.pixels = rgba; - src_rgb.rowBytes = width as u32 * 4; - unsafe { avifImageRGBToYUV(image, &mut src_rgb) }; - let encoder = unsafe { avifEncoderCreate() }; - - if lossless { - unsafe { - (*encoder).minQuantizer = AVIF_QUANTIZER_LOSSLESS as i32; - (*encoder).maxQuantizer = AVIF_QUANTIZER_LOSSLESS as i32; - (*encoder).minQuantizerAlpha = AVIF_QUANTIZER_LOSSLESS as i32; - (*encoder).maxQuantizerAlpha = AVIF_QUANTIZER_LOSSLESS as i32; - }; - } else { - unsafe { - (*encoder).minQuantizer = AVIF_QUANTIZER_BEST_QUALITY as i32; - (*encoder).maxQuantizer = AVIF_QUANTIZER_WORST_QUALITY as i32; - (*encoder).minQuantizerAlpha = AVIF_QUANTIZER_BEST_QUALITY as i32; - (*encoder).maxQuantizerAlpha = AVIF_QUANTIZER_WORST_QUALITY as i32; - - // avifEncoderSetCodecSpecificOption( - // encoder, - // b"end-usage\0".as_ptr() as *const i8, - // b"q\0".as_ptr() as *const i8, - // ); - // avifEncoderSetCodecSpecificOption( - // encoder, - // b"cq-level\0".as_ptr() as *const i8, - // quality.to_string().as_bytes().as_ptr() as *const i8, - // ); - // avifEncoderSetCodecSpecificOption( - // encoder, - // b"sharpness\0".as_ptr() as *const i8, - // b"0\0".as_ptr() as *const i8, - // ); - - // if quality <= 32 { - // avifEncoderSetCodecSpecificOption( - // encoder, - // b"tune\0".as_ptr() as *const i8, - // b"ssim\0".as_ptr() as *const i8, - // ); - // } - - // avifEncoderSetCodecSpecificOption( - // encoder, - // b"color:denoise-noise-level\0".as_ptr() as *const i8, - // b"0\0".as_ptr() as *const i8, - // ); - }; - } - - unsafe { - (*encoder).maxThreads = num_cpus::get() as i32; - (*encoder).tileRowsLog2 = 0; - (*encoder).tileColsLog2 = 0; - (*encoder).speed = 6; - } - - let encode_result = unsafe { avifEncoderWrite(encoder, image, &mut output) }; - - let result: Vec = vec![0; output.size]; - if encode_result == AVIF_RESULT_OK { - unsafe { - std::ptr::copy_nonoverlapping(output.data, result.as_ptr() as *mut u8, output.size); - } - - unsafe { - avifImageDestroy(image); - avifEncoderDestroy(encoder); - avifRWDataFree(&mut output); - }; - - Ok(result) - } else { - unsafe { - avifImageDestroy(image); - avifEncoderDestroy(encoder); - avifRWDataFree(&mut output); - }; - - Err(EncodingError::Encoding(Box::new(SimpleError::new( - format!("Encoding avif failed with error code {}", encode_result), - )))) - } + let (width, height) = self.image_data.size(); + let data = ravif::Img::new(self.image_data.data().as_rgba(), width, height); + + Ok(ravif::Encoder::new() + .with_quality(self.config.quality) + .with_speed(6) + .encode_rgba(data) + .map_err(|e| EncodingError::Encoding(Box::new(e)))? + .avif_file) } } From 58ea18cb34959c6df409549840967f46a3abbe20 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Sun, 16 Apr 2023 14:35:03 +0200 Subject: [PATCH 11/46] Replaced system allocator with mimalloc --- Cargo.lock | 20 ++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index a69eaf50..4484f7f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -949,6 +949,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libmimalloc-sys" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a558e3d911bc3c7bfc8c78bc580b404d6e51c1cefbf656e176a94b49b0df40" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "libwebp" version = "0.1.2" @@ -1038,6 +1048,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mimalloc" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d88dad3f985ec267a3fcb7a1726f5cb1a7e8cad8b646e70a84f967210df23da" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -1517,6 +1536,7 @@ dependencies = [ "libavif-sys", "libwebp", "log", + "mimalloc", "mozjpeg", "num_cpus", "oxipng", diff --git a/Cargo.toml b/Cargo.toml index 22f46f28..c0e7b637 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,7 @@ resize = "0.7.4" libwebp = "0.1.2" libavif-sys = "0.14.3" ravif = "0.11.1" +mimalloc = "0.1.36" [dev-dependencies] criterion = { version = "0.4.0", features = ["html_reports"] } diff --git a/src/main.rs b/src/main.rs index 63b2cf6c..ad91609c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,9 +3,13 @@ use std::{fs, io, path, process}; use clap::Parser; use indicatif::{ProgressBar, ProgressStyle}; use log::{error, info}; +use mimalloc::MiMalloc; use rimage::{image::OutputFormat, Config, Decoder, Encoder}; use threadpool::ThreadPool; +#[global_allocator] +static GLOBAL: MiMalloc = MiMalloc; + #[derive(Parser)] #[command(author, about, version, long_about = None)] struct Args { From acdd5653dc8b00f2fd988745f6f6a527d0ac38a0 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Tue, 25 Apr 2023 17:57:31 +0200 Subject: [PATCH 12/46] Fixed merge errors --- Cargo.lock | 335 +++++++++++++++++++++++++++++++--------------------- src/lib.rs | 26 ++-- src/main.rs | 3 - 3 files changed, 213 insertions(+), 151 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 562c3002..d50c3bc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,9 +36,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" +checksum = "6342bd4f5a1205d7f41e94a41a901f5647c938cdfa96036338e8533c9d6c2450" dependencies = [ "anstyle", "anstyle-parse", @@ -75,14 +75,37 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", "windows-sys 0.48.0", ] +[[package]] +name = "anyhow" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" + +[[package]] +name = "arbitrary" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db55d72333851e17d572bec876e390cd3b11eb1ef53ae821dd9f3b653d2b4569" + +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c29b43ee8654590587cd033b3eca2f9c4f8cdff945ec0e6ee91ceb057d87f3" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "arrayvec" version = "0.7.2" @@ -111,9 +134,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "av-metrics" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13638b394190295622c0d2493d0c8c39210b92c2110895bfb14c58db213c2b39" +checksum = "996ce95bbdb0203e5b91d4a0c9b81c0d67d11c80f884482a0c1ea19e732e3530" dependencies = [ "crossbeam", "itertools", @@ -185,9 +208,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" [[package]] name = "bytemuck" @@ -230,11 +253,12 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35b255461940a32985c627ce82900867c61db1659764d3675ea81963f72a4c6" +checksum = "c8790cf1286da485c72cf5fc7aeba308438800036ec67d89425924c4807268c9" dependencies = [ "smallvec", + "target-lexicon", ] [[package]] @@ -307,6 +331,16 @@ dependencies = [ "bitflags", "clap_lex 0.4.1", "strsim", + "terminal_size", +] + +[[package]] +name = "clap_complete" +version = "4.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a19591b2ab0e3c04b588a0e04ddde7b9eaa423646d1b4a8092879216bf47473" +dependencies = [ + "clap 4.2.4", ] [[package]] @@ -318,7 +352,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.9", + "syn 2.0.15", ] [[package]] @@ -437,9 +471,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -490,9 +524,9 @@ dependencies = [ [[package]] name = "dunce" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd4b30a6560bbd9b4620f4de34c3f14f60848e58a9b7216801afcb4c7b31c3c" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "either" @@ -519,17 +553,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - [[package]] name = "errno" version = "0.3.1" @@ -580,14 +603,14 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" +checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" dependencies = [ "cfg-if", "libc", "redox_syscall", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -600,6 +623,15 @@ dependencies = [ "miniz_oxide 0.6.2", ] +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "funty" version = "2.0.0" @@ -708,9 +740,9 @@ dependencies = [ [[package]] name = "image" -version = "0.24.5" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b7ea949b537b0fd0af141fff8c77690f2ce96f4f41f042ccb6c69c6c965945" +checksum = "527909aa81e20ac3a44803521443a765550f09b5130c2c2fa1ea59c2f8f50a3a" dependencies = [ "bytemuck", "byteorder", @@ -743,9 +775,9 @@ checksum = "b2cf49df1085dcfb171460e4592597b84abe50d900fb83efb6e41b20fefd6c2c" [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -777,25 +809,25 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "is-terminal" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix 0.36.11", - "windows-sys 0.45.0", + "rustix", + "windows-sys 0.48.0", ] [[package]] @@ -866,9 +898,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.140" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "libdav1d-sys" @@ -926,16 +958,6 @@ dependencies = [ "libc", ] -[[package]] -name = "libmimalloc-sys" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a558e3d911bc3c7bfc8c78bc580b404d6e51c1cefbf656e176a94b49b0df40" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "libwebp" version = "0.1.2" @@ -972,15 +994,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" - -[[package]] -name = "linux-raw-sys" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" +checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" [[package]] name = "log" @@ -1040,15 +1056,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "mimalloc" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d88dad3f985ec267a3fcb7a1726f5cb1a7e8cad8b646e70a84f967210df23da" -dependencies = [ - "libmimalloc-sys", -] - [[package]] name = "miniz_oxide" version = "0.6.2" @@ -1094,9 +1101,9 @@ dependencies = [ [[package]] name = "nasm-rs" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce095842aee9aa3ecbda7a5d2a4df680375fd128a8596b6b56f8e497e231f483" +checksum = "fe4d98d0065f4b1daf164b3eafb11974c94662e5e2396cf03f32d0bb5c17da51" dependencies = [ "rayon", ] @@ -1326,9 +1333,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.53" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -1360,6 +1367,100 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rav1e" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "277898094f0d03c6a609e491324102daf5080e71c06b4b25e5acf8b89d26c945" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av-metrics", + "av1-grain", + "bitstream-io", + "built", + "cc", + "cfg-if", + "clap 4.2.4", + "clap_complete", + "console", + "const_fn_assert", + "fern", + "interpolate_name", + "itertools", + "ivf", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "nasm-rs", + "new_debug_unreachable", + "nom", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "rand", + "rand_chacha", + "rust_hawktracer", + "rustc_version", + "scan_fmt", + "signal-hook", + "simd_helpers", + "system-deps", + "thiserror", + "v_frame", + "wasm-bindgen", + "y4m", +] + +[[package]] +name = "ravif" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26cda034bd7ec1f4e799b207ef0444dd28b2fb310877378a5bb5b8b6ef6c4158" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error 2.0.1", + "rav1e", + "rayon", + "rgb", +] + [[package]] name = "rayon" version = "1.7.0" @@ -1494,30 +1595,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" -dependencies = [ - "bitflags", - "errno 0.2.8", - "io-lifetimes", - "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.45.0", -] - -[[package]] -name = "rustix" -version = "0.37.7" +version = "0.37.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aae838e49b3d63e9274e1c01833cc8139d3fec468c3b84688c628f44b1ae11d" +checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" dependencies = [ "bitflags", - "errno 0.3.1", + "errno", "io-lifetimes", "libc", - "linux-raw-sys 0.3.1", - "windows-sys 0.45.0", + "linux-raw-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1558,29 +1645,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.158" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.158" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" +checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.9", + "syn 2.0.15", ] [[package]] name = "serde_json" -version = "1.0.94" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -1673,9 +1760,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.9" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da4a3c17e109f700685ec577c0f85efd9b19bcf15c913985f14dc1ac01775aa" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", @@ -1684,9 +1771,9 @@ dependencies = [ [[package]] name = "system-deps" -version = "6.0.4" +version = "6.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555fc8147af6256f3931a36bb83ad0023240ce9cf2b319dec8236fd1f220b05f" +checksum = "d0fe581ad25d11420b873cf9aedaca0419c2b411487b134d4d21065f3d092055" dependencies = [ "cfg-expr", "heck", @@ -1701,6 +1788,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "target-lexicon" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" + [[package]] name = "termcolor" version = "1.1.3" @@ -1716,7 +1809,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" dependencies = [ - "rustix 0.37.7", + "rustix", "windows-sys 0.48.0", ] @@ -1743,7 +1836,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.9", + "syn 2.0.15", ] [[package]] @@ -2070,37 +2163,13 @@ dependencies = [ "windows_x86_64_msvc 0.42.2", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets", ] [[package]] @@ -2211,12 +2280,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - [[package]] name = "wyz" version = "0.5.1" diff --git a/src/lib.rs b/src/lib.rs index c9705f44..94802ade 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,7 +98,7 @@ use rgb::{ AsPixels, ComponentBytes, FromSlice, RGB8, RGBA, RGBA8, }; use simple_error::SimpleError; -use std::{fs, io::Read, panic, path}; +use std::{ffi::CString, fs, io::Read, panic, path}; pub use image::{ImageData, OutputFormat, ResizeType}; @@ -454,7 +454,13 @@ impl<'a> Decoder<'a> { let image = unsafe { avifImageCreateEmpty() }; let decoder = unsafe { avifDecoderCreate() }; let decode_result = unsafe { - avifDecoderReadMemory(decoder, image, self.raw_data.as_ptr(), self.raw_data.len()) + avifDecoderReadFile( + decoder, + image, + CString::new(self.path.to_str().unwrap()) + .map_err(|e| DecodingError::Parsing(Box::new(e)))? + .as_ptr(), + ) }; unsafe { avifDecoderDestroy(decoder) }; @@ -473,17 +479,13 @@ impl<'a> Decoder<'a> { }; let pixels = unsafe { - Vec::from_raw_parts( - rgb.pixels as *mut u8, - rgb.width as usize * rgb.height as usize * 4, - rgb.width as usize * rgb.height as usize * 4, - ) + std::slice::from_raw_parts(rgb.pixels, (rgb.width * rgb.height) as usize) }; result = Ok(ImageData::new( rgb.width as usize, rgb.height as usize, - pixels.clone(), + pixels, )); std::mem::forget(pixels); @@ -1064,8 +1066,8 @@ mod tests { files.iter().for_each(|path| { println!("{path:?}"); - let data = fs::read(path).unwrap(); - let d = Decoder::new(path, &data); + let file = fs::File::open(path).unwrap(); + let d = Decoder::new(path, file); let img = d.decode().unwrap(); println!("{:?}", img.size()); @@ -1212,8 +1214,8 @@ mod tests { files.iter().for_each(|path| { println!("{path:?}"); - let data = fs::read(path).unwrap(); - let image = Decoder::new(path, &data).decode().unwrap(); + let file = fs::File::open(path).unwrap(); + let image = Decoder::new(path, file).decode().unwrap(); let conf = Config::build(75.0, OutputFormat::Avif, None, None, None).unwrap(); diff --git a/src/main.rs b/src/main.rs index a7b70490..aaf86721 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,9 +17,6 @@ static GLOBAL: Jemalloc = Jemalloc; #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; -#[global_allocator] -static GLOBAL: MiMalloc = MiMalloc; - #[derive(Parser)] #[command(author, about, version, long_about = None)] struct Args { From f16f1ff7e76816dcf40a76394bcf4afa887239dc Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Fri, 2 Jun 2023 15:25:58 +0200 Subject: [PATCH 13/46] Updated Cargo.lock --- Cargo.lock | 79 +++++++++++++++++++++--------------------------------- 1 file changed, 30 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d50c3bc4..e32941fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -311,9 +311,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.4" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ac1f6381d8d82ab4684768f89c0ea3afe66925ceadb4eeb3fc452ffc55d62" +checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" dependencies = [ "clap_builder", "clap_derive", @@ -322,14 +322,14 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.4" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84080e799e54cff944f4b4a4b0e71630b0e0443b25b985175c7dddc1a859b749" +checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" dependencies = [ "anstream", "anstyle", "bitflags", - "clap_lex 0.4.1", + "clap_lex 0.5.0", "strsim", "terminal_size", ] @@ -340,14 +340,14 @@ version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a19591b2ab0e3c04b588a0e04ddde7b9eaa423646d1b4a8092879216bf47473" dependencies = [ - "clap 4.2.4", + "clap 4.3.0", ] [[package]] name = "clap_derive" -version = "4.2.0" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" +checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b" dependencies = [ "heck", "proc-macro2", @@ -366,9 +366,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "cmake" @@ -542,12 +542,12 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "env_logger" -version = "0.7.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" dependencies = [ - "atty", "humantime", + "is-terminal", "log", "regex", "termcolor", @@ -721,12 +721,9 @@ checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "humantime" -version = "1.3.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error 1.2.3", -] +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "idna" @@ -754,12 +751,11 @@ dependencies = [ [[package]] name = "imagequant" -version = "4.1.1" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f332f82fc531b53cffa3181c14f7beb5b6c33932d68bb0c2fa4fd583553fca64" +checksum = "fc3c62f251799ae51bbd7a94fc00a83fcb796d8dd14876280e3063e8341138dc" dependencies = [ "arrayvec", - "noisy_float", "num_cpus", "once_cell", "rayon", @@ -950,9 +946,9 @@ dependencies = [ [[package]] name = "libmimalloc-sys" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a558e3d911bc3c7bfc8c78bc580b404d6e51c1cefbf656e176a94b49b0df40" +checksum = "f4ac0e912c8ef1b735e92369695618dc5b1819f5a7bf3f167301a3ba1cea515e" dependencies = [ "cc", "libc", @@ -1043,9 +1039,9 @@ dependencies = [ [[package]] name = "mimalloc" -version = "0.1.36" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d88dad3f985ec267a3fcb7a1726f5cb1a7e8cad8b646e70a84f967210df23da" +checksum = "4e2894987a3459f3ffb755608bd82188f8ed00d0ae077f1edea29c068d639d98" dependencies = [ "libmimalloc-sys", ] @@ -1114,15 +1110,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" -[[package]] -name = "noisy_float" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978fe6e6ebc0bf53de533cd456ca2d9de13de13856eda1518a285d7705a213af" -dependencies = [ - "num-traits", -] - [[package]] name = "nom" version = "7.1.3" @@ -1323,9 +1310,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "pretty_env_logger" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" +checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c" dependencies = [ "env_logger", "log", @@ -1340,12 +1327,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quick-error" version = "2.0.1" @@ -1412,7 +1393,7 @@ dependencies = [ "built", "cc", "cfg-if", - "clap 4.2.4", + "clap 4.3.0", "clap_complete", "console", "const_fn_assert", @@ -1455,7 +1436,7 @@ dependencies = [ "avif-serialize", "imgref", "loop9", - "quick-error 2.0.1", + "quick-error", "rav1e", "rayon", "rgb", @@ -1494,9 +1475,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.1" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" dependencies = [ "aho-corasick", "memchr", @@ -1505,9 +1486,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "resize" @@ -1533,7 +1514,7 @@ name = "rimage" version = "0.7.0" dependencies = [ "bytemuck", - "clap 4.2.4", + "clap 4.3.0", "criterion", "imagequant", "indicatif", From 2af8b2dadd47f879028c9faa9628c71b7e1f2cfb Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Fri, 2 Jun 2023 15:30:27 +0200 Subject: [PATCH 14/46] Removed output files from tests --- src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 94802ade..5037014f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1225,9 +1225,6 @@ mod tests { assert!(result.is_ok()); let result = result.unwrap(); assert!(!result.is_empty()); - let mut path = path.clone(); - path.set_extension("avif"); - fs::write(path, result).unwrap(); }) } From 0c84eaf3591cea8b92d354a07d084ec4f0a5d6e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jun 2023 16:02:38 +0000 Subject: [PATCH 15/46] Bump indicatif from 0.17.4 to 0.17.5 Bumps [indicatif](https://github.com/console-rs/indicatif) from 0.17.4 to 0.17.5. - [Release notes](https://github.com/console-rs/indicatif/releases) - [Commits](https://github.com/console-rs/indicatif/compare/0.17.4...0.17.5) --- updated-dependencies: - dependency-name: indicatif dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66341920..b1156495 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -571,9 +571,9 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.4" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db45317f37ef454e6519b6c3ed7d377e5f23346f0823f86e65ca36912d1d0ef8" +checksum = "8ff8cc23a7393a397ed1d7f56e6365cba772aba9f9912ab968b03043c395d057" dependencies = [ "console", "instant", diff --git a/Cargo.toml b/Cargo.toml index 233e2ce6..f5145699 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ debug = 1 bytemuck = "1.13.1" clap = { version = "4.3.0", features = ["derive"] } imagequant = "4.2.0" -indicatif = "0.17.4" +indicatif = "0.17.5" log = "0.4.18" mozjpeg = "0.9.4" num_cpus = "1.15.0" From 3942c6d43878161a5f2c571647b5b8e070975784 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Jun 2023 16:01:37 +0000 Subject: [PATCH 16/46] Bump clap from 4.3.0 to 4.3.3 Bumps [clap](https://github.com/clap-rs/clap) from 4.3.0 to 4.3.3. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.3.0...v4.3.3) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66341920..3f6b59e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -207,9 +207,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.0" +version = "4.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" +checksum = "ca8f255e4b8027970e78db75e78831229c9815fdbfa67eb1a1b777a62e24b4a0" dependencies = [ "clap_builder", "clap_derive", @@ -218,9 +218,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.0" +version = "4.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" +checksum = "acd4f3c17c83b0ba34ffbc4f8bbd74f079413f747f84a6f89292f138057e36ab" dependencies = [ "anstream", "anstyle", @@ -231,9 +231,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.0" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b" +checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" dependencies = [ "heck", "proc-macro2", @@ -1041,7 +1041,7 @@ name = "rimage" version = "0.6.0" dependencies = [ "bytemuck", - "clap 4.3.0", + "clap 4.3.3", "criterion", "imagequant", "indicatif", diff --git a/Cargo.toml b/Cargo.toml index 233e2ce6..ae10b44f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ debug = 1 [dependencies] bytemuck = "1.13.1" -clap = { version = "4.3.0", features = ["derive"] } +clap = { version = "4.3.3", features = ["derive"] } imagequant = "4.2.0" indicatif = "0.17.4" log = "0.4.18" From bf2b8747d2164d650720fdfe7a1122d27e60c380 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 18:24:24 +0200 Subject: [PATCH 17/46] Replaced output_format with format --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index aaf86721..ee785a1f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,7 @@ struct Args { quality: f32, /// Output format of the output image #[arg(short, long, default_value = "jpg")] - output_format: OutputFormat, + format: OutputFormat, /// Print image info #[arg(short, long)] info: bool, @@ -78,7 +78,7 @@ fn main() { let conf = Arc::new( Config::build( args.quality, - args.output_format, + args.format, args.width, args.height, args.filter, @@ -165,7 +165,7 @@ fn main() { ); let mut new_path = path.clone(); - let ext = args.output_format.to_string(); + let ext = args.format.to_string(); let suffix = suffix.clone().unwrap_or_default(); new_path.set_file_name(format!( @@ -232,7 +232,7 @@ fn main() { ); let mut new_path = path.clone(); - let ext = args.output_format.to_string(); + let ext = args.format.to_string(); let suffix = suffix.clone().unwrap_or_default(); new_path.set_file_name(format!( From c3e65d591c7c3f007ca46ef324988f1ee3f7cfaf Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 18:24:38 +0200 Subject: [PATCH 18/46] Added common_path function --- src/lib.rs | 3 +++ src/utils.rs | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/utils.rs diff --git a/src/lib.rs b/src/lib.rs index 5037014f..b3bafdf4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -115,6 +115,9 @@ pub mod error; /// Image data structs pub mod image; +/// Some utils functions +mod utils; + /// Config for image encoding /// /// # Example diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 00000000..98aaf141 --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,39 @@ +use std::path::{Path, PathBuf}; + +/// Gets common path inside a array of paths +pub fn common_path(paths: I) -> Option +where + I: IntoIterator, + P: AsRef, +{ + let mut iter = paths.into_iter(); + let mut ret = iter.next()?.as_ref().to_path_buf(); + for path in iter { + if let Some(r) = common(ret, path.as_ref()) { + ret = r; + } else { + return None; + } + } + Some(ret) +} + +fn common, B: AsRef>(a: A, b: B) -> Option { + let a = a.as_ref().components(); + let b = b.as_ref().components(); + let mut ret = PathBuf::new(); + let mut found = false; + for (one, two) in a.zip(b) { + if one == two { + ret.push(one); + found = true; + } else { + break; + } + } + if found { + Some(ret) + } else { + None + } +} From e6699c9efd0ff42f6f894df0269c213b99bac2ea Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:51:07 +0200 Subject: [PATCH 19/46] Update deploy.yml Updated deploy to support avif --- .github/workflows/deploy.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1c277323..21f41c66 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,6 +14,16 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Install python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install meson / ninja + shell: bash + run: pip install meson ninja + - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -71,6 +81,16 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Install python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install meson / ninja + shell: bash + run: pip install meson ninja + - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -158,6 +178,16 @@ jobs: steps: - uses: actions/checkout@v3 + + - name: Install python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install meson / ninja + shell: bash + run: pip install meson ninja - name: Install Rust uses: actions-rs/toolchain@v1 From 0b03aa0a25e982d9d6cb4950a985cd8ee0c031d6 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:52:30 +0200 Subject: [PATCH 20/46] Update rimage.yml Added support for avif --- .github/workflows/rimage.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/rimage.yml b/.github/workflows/rimage.yml index 524855a4..328d8f39 100644 --- a/.github/workflows/rimage.yml +++ b/.github/workflows/rimage.yml @@ -25,6 +25,16 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Install python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install meson / ninja + shell: bash + run: pip install meson ninja + - run: | rustup set auto-self-update disable rustup toolchain install stable --profile minimal From 241cdffc6fb7fcd32609d23b383ddbd9cd66b2e7 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:53:39 +0200 Subject: [PATCH 21/46] Update rust-clippy.yml Added support for avif --- .github/workflows/rust-clippy.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/rust-clippy.yml b/.github/workflows/rust-clippy.yml index 6198c99e..4975e0b4 100644 --- a/.github/workflows/rust-clippy.yml +++ b/.github/workflows/rust-clippy.yml @@ -29,6 +29,16 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + + - name: Install python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install meson / ninja + shell: bash + run: pip install meson ninja - name: Install Rust toolchain uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1 From 96fbf4f886bfe0e20a7cd59615823a35287c7f99 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:54:31 +0200 Subject: [PATCH 22/46] Update deploy.yml --- .github/workflows/deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 21f41c66..c0d80b8e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,7 +18,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.11' - cache: 'pip' - name: Install meson / ninja shell: bash From 8b891aa923a0e49f52f0455c19bf89a5afb02c94 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:55:24 +0200 Subject: [PATCH 23/46] Update rimage.yml --- .github/workflows/rimage.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/rimage.yml b/.github/workflows/rimage.yml index 328d8f39..6a558a69 100644 --- a/.github/workflows/rimage.yml +++ b/.github/workflows/rimage.yml @@ -29,7 +29,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.11' - cache: 'pip' - name: Install meson / ninja shell: bash From a989c331923d0c7b7831e58a843532da84e8a60f Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:55:46 +0200 Subject: [PATCH 24/46] Update rust-clippy.yml --- .github/workflows/rust-clippy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/rust-clippy.yml b/.github/workflows/rust-clippy.yml index 4975e0b4..4b04df6f 100644 --- a/.github/workflows/rust-clippy.yml +++ b/.github/workflows/rust-clippy.yml @@ -34,7 +34,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.11' - cache: 'pip' - name: Install meson / ninja shell: bash From ae1e4c84e7445cb4a8acc34706a5e97893ef2226 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 20:06:55 +0200 Subject: [PATCH 25/46] Update deploy.yml Added nasm --- .github/workflows/deploy.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c0d80b8e..0a772096 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,6 +14,8 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: ilammy/setup-nasm@v1 + - name: Install python uses: actions/setup-python@v4 with: @@ -80,6 +82,8 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: ilammy/setup-nasm@v1 + - name: Install python uses: actions/setup-python@v4 with: @@ -178,6 +182,8 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: ilammy/setup-nasm@v1 + - name: Install python uses: actions/setup-python@v4 with: From fc1ff23d7159e32937ec57d0d5ebc18dc7d9c4d8 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 20:07:50 +0200 Subject: [PATCH 26/46] Update rimage.yml Added nasm --- .github/workflows/rimage.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rimage.yml b/.github/workflows/rimage.yml index 6a558a69..112ba84f 100644 --- a/.github/workflows/rimage.yml +++ b/.github/workflows/rimage.yml @@ -25,6 +25,8 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: ilammy/setup-nasm@v1 + - name: Install python uses: actions/setup-python@v4 with: From c462a37db65ad29cc0270a2e32b232f280bf95c4 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Tue, 13 Jun 2023 20:08:16 +0200 Subject: [PATCH 27/46] Update rust-clippy.yml Added nasm --- .github/workflows/rust-clippy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rust-clippy.yml b/.github/workflows/rust-clippy.yml index 4b04df6f..cc39c692 100644 --- a/.github/workflows/rust-clippy.yml +++ b/.github/workflows/rust-clippy.yml @@ -30,6 +30,8 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - uses: ilammy/setup-nasm@v1 + - name: Install python uses: actions/setup-python@v4 with: From d9ebe7daf9ffd4b6067d4847fcbce316470ff87a Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:58:45 +0200 Subject: [PATCH 28/46] Fixed Cargo.lock --- Cargo.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b222bd1..38625691 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -793,6 +793,15 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + [[package]] name = "interpolate_name" version = "0.2.3" @@ -804,15 +813,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "io-lifetimes" version = "1.0.10" From dc8505dd40407b1fcc94678107162abc215c5199 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:08:38 +0200 Subject: [PATCH 29/46] Removed clippy issues --- src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5037014f..3966938a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -488,8 +488,6 @@ impl<'a> Decoder<'a> { pixels, )); - std::mem::forget(pixels); - unsafe { avifRGBImageFreePixels(&mut rgb) }; } From cb3afeae8e867bb97589e285c132233ee66f4605 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:16:14 +0200 Subject: [PATCH 30/46] Update feature_request.md Removed "Required libraries" from template --- .github/ISSUE_TEMPLATE/feature_request.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 6f8d9f6d..43de9e06 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -13,10 +13,6 @@ assignees: '' **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -## Required libraries: -**If you know any libraries that can help, write it here like so** -- lib (link) - ## Expected Behavior: **Describe the solution you'd like** A clear and concise description of what you want to happen. From d5ec675cac0022b1550df20e9dcd43ee3807f145 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:17:52 +0200 Subject: [PATCH 31/46] Update bug_report.md Removed "small description" field from template --- .github/ISSUE_TEMPLATE/bug_report.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 45bda52d..77802e8a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,8 +7,6 @@ assignees: '' --- -**Write small description of bug** - ## Description: **Describe the bug** A clear and concise description of what the bug is. From d187259071f91529da752ea5f6104acc303b34a3 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:37:10 +0200 Subject: [PATCH 32/46] Update rimage.yml Updated installing dependencies for libavif --- .github/workflows/rimage.yml | 45 +++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rimage.yml b/.github/workflows/rimage.yml index 112ba84f..618a0523 100644 --- a/.github/workflows/rimage.yml +++ b/.github/workflows/rimage.yml @@ -25,16 +25,26 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: ilammy/setup-nasm@v1 + - name: Install dependencies (linux) + if: (matrix.os || 'ubuntu-latest') == 'ubuntu-latest' + run: | + DEBIAN_FRONTEND=noninteractive sudo apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ninja-build nasm meson - - name: Install python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Install meson / ninja - shell: bash - run: pip install meson ninja + - name: Install dependencies (macOS) + if: matrix.os == 'macOS-latest' + run: | + brew install ninja nasm meson + + - name: Install dependencies (windows) + if: matrix.os == 'windows-latest' + run: | + choco install -y ninja + pip install meson + + - name: Install nasm (windows) + if: matrix.os == 'windows-latest' + uses: ilammy/setup-nasm@v1 - run: | rustup set auto-self-update disable @@ -42,8 +52,17 @@ jobs: - name: Rust Cache uses: Swatinem/rust-cache@v2.2.1 + + - name: Check/Test (Windows) + if: matrix.os == 'windows-latest' + shell: cmd + run: | + call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + cargo check --verbose + cargo test --verbose - - name: Check - run: cargo check --verbose - - name: Run tests - run: cargo test --verbose + - name: Test (Linux, macOS) + if: ${{ matrix.os != 'windows-latest' }} + run: | + cargo check --verbose + cargo test --verbose From 6ef6aa5313566ac6860f084b0ac69b1a21edb697 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:40:55 +0200 Subject: [PATCH 33/46] Update deploy.yml Update install dependencies for libavif --- .github/workflows/deploy.yml | 38 +++++++++++++++++------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0a772096..6c3af96d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,16 +14,12 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: ilammy/setup-nasm@v1 + - name: Install dependencies + run: | + choco install -y ninja + pip install meson - - name: Install python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Install meson / ninja - shell: bash - run: pip install meson ninja + - uses: ilammy/setup-nasm@v1 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -37,7 +33,10 @@ jobs: uses: Swatinem/rust-cache@v2.2.1 - name: Build rimage - run: cargo build --release --target x86_64-pc-windows-msvc --verbose + shell: cmd + run: | + call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" + cargo build --release --target x86_64-pc-windows-msvc --verbose - name: Get the version shell: bash @@ -82,17 +81,16 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: ilammy/setup-nasm@v1 + - name: Install dependencies (linux) + if: matrix.os == 'ubuntu-latest' + run: | + DEBIAN_FRONTEND=noninteractive sudo apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ninja-build nasm meson - - name: Install python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - cache: 'pip' - - - name: Install meson / ninja - shell: bash - run: pip install meson ninja + - name: Install dependencies (macOS) + if: matrix.os == 'macOS-latest' + run: | + brew install ninja nasm meson - name: Install Rust uses: actions-rs/toolchain@v1 From f2628e476525f5c2ce05f7e666069bde52b37d54 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:45:15 +0200 Subject: [PATCH 34/46] Update deploy.yml Changed windows version to 2019 --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6c3af96d..3fcb9e93 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,7 +9,7 @@ env: jobs: build-win-binaries: - runs-on: windows-latest + runs-on: windows-2019 steps: - uses: actions/checkout@v3 From e4204b20a00d1ed858f3e3fe5ffad0db8d055aa6 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:46:03 +0200 Subject: [PATCH 35/46] Update rimage.yml Changed windows version to 2019 --- .github/workflows/rimage.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rimage.yml b/.github/workflows/rimage.yml index 618a0523..4d3da508 100644 --- a/.github/workflows/rimage.yml +++ b/.github/workflows/rimage.yml @@ -14,7 +14,7 @@ jobs: build: strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest, windows-2019] name: Test `cargo check/test` on ${{ matrix.os }} runs-on: ${{ matrix.os }} @@ -26,24 +26,24 @@ jobs: - uses: actions/checkout@v3 - name: Install dependencies (linux) - if: (matrix.os || 'ubuntu-latest') == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' run: | DEBIAN_FRONTEND=noninteractive sudo apt-get update DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ninja-build nasm meson - name: Install dependencies (macOS) - if: matrix.os == 'macOS-latest' + if: matrix.os == 'macos-latest' run: | brew install ninja nasm meson - name: Install dependencies (windows) - if: matrix.os == 'windows-latest' + if: matrix.os == 'windows-2019' run: | choco install -y ninja pip install meson - name: Install nasm (windows) - if: matrix.os == 'windows-latest' + if: matrix.os == 'windows-2019' uses: ilammy/setup-nasm@v1 - run: | @@ -54,7 +54,7 @@ jobs: uses: Swatinem/rust-cache@v2.2.1 - name: Check/Test (Windows) - if: matrix.os == 'windows-latest' + if: matrix.os == 'windows-2019' shell: cmd run: | call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" @@ -62,7 +62,7 @@ jobs: cargo test --verbose - name: Test (Linux, macOS) - if: ${{ matrix.os != 'windows-latest' }} + if: ${{ matrix.os != 'windows-2019' }} run: | cargo check --verbose cargo test --verbose From c5fc6abf950724ac86d4d576af578d76b81dd982 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:46:49 +0200 Subject: [PATCH 36/46] Update rust-clippy.yml Updated install dependencies --- .github/workflows/rust-clippy.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/rust-clippy.yml b/.github/workflows/rust-clippy.yml index cc39c692..1e90cd52 100644 --- a/.github/workflows/rust-clippy.yml +++ b/.github/workflows/rust-clippy.yml @@ -30,16 +30,11 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - uses: ilammy/setup-nasm@v1 - - - name: Install python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Install meson / ninja - shell: bash - run: pip install meson ninja + - name: Install dependencies (linux) + if: matrix.os == 'ubuntu-latest' + run: | + DEBIAN_FRONTEND=noninteractive sudo apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ninja-build nasm meson - name: Install Rust toolchain uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1 From e12712d8a0bf345cc004e88440294d5465da8fec Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:35:14 +0200 Subject: [PATCH 37/46] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4b2aa327..dfe46952 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![License](https://img.shields.io/crates/l/rimage?style=flat-square)](https://github.com/SalOne22/rimage) This is CLI tool inspired by [squoosh!](https://squoosh.app/) -Rimage currently supports three codecs, mozjpeg, oxipng and webp, and aims to add support for AVIF and JPEG XL in the future. +Rimage currently supports several codecs - mozjpeg, oxipng, webp and avif. More will be added later. ## Installation @@ -32,8 +32,7 @@ rimage -q 75 *.jpg ## To-Do -- Support for AVIF and JPEG XL -- And allot of bugfixes and optimizations +- Support for JPEG XL ## Changelog @@ -47,7 +46,7 @@ For building rimage from source you will need to run this command: cargo install rimage ``` -This app requires cmake, nasm and ninja/meson installed on system +This app requires cmake, nasm, ninja and meson installed on system > note: On windows use Visual Studio build environment like developer PowerShell for VS 2019 From 54faacef9be741390220a7026a16c9fbf3c76579 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 18:04:25 +0200 Subject: [PATCH 38/46] Added output dir feature --- src/lib.rs | 3 --- src/main.rs | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++-- src/utils.rs | 19 ++++++++------ 3 files changed, 82 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b3bafdf4..5037014f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -115,9 +115,6 @@ pub mod error; /// Image data structs pub mod image; -/// Some utils functions -mod utils; - /// Config for image encoding /// /// # Example diff --git a/src/main.rs b/src/main.rs index ee785a1f..62c064de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,8 @@ use threadpool::ThreadPool; #[cfg(not(target_env = "msvc"))] use tikv_jemallocator::Jemalloc; +use crate::utils::common_path; + #[cfg(not(target_env = "msvc"))] #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; @@ -17,11 +19,17 @@ static GLOBAL: Jemalloc = Jemalloc; #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; +/// Some utils functions +mod utils; + #[derive(Parser)] #[command(author, about, version, long_about = None)] struct Args { /// Input file(s) input: Vec, + /// Output directory + #[arg(short, long)] + output: Option, /// Quality of the output image (0-100) #[arg(short, long, default_value = "75")] quality: f32, @@ -90,6 +98,9 @@ fn main() { ); info!("Using config: {:?}", conf); + let common_path = common_path(&args.input); + info!("Found common path: {:?}", common_path); + pb.set_style( ProgressStyle::with_template("{bar:40.green/blue} {pos}/{len}") .unwrap() @@ -117,6 +128,15 @@ fn main() { } }; + println!("Full path: {:?}", &path); + + if let Some(common_path) = &common_path { + println!( + "Relative path: {:?}", + &path.strip_prefix(common_path.parent().unwrap()).unwrap() + ); + } + println!("{:?}", &path.file_name().unwrap()); println!("Size: {:?}", img.size()); println!("Data length: {:?}", img.data().len()); @@ -138,6 +158,9 @@ fn main() { let pb = pb.clone(); let conf = conf.clone(); let suffix = args.suffix.clone(); + let common_path = common_path.clone(); + let destination_dir = args.output.clone(); + pool.execute(move || { pb.set_message(path.file_name().unwrap().to_str().unwrap().to_owned()); info!("Decoding {}", &path.file_name().unwrap().to_str().unwrap()); @@ -165,6 +188,21 @@ fn main() { ); let mut new_path = path.clone(); + + if let Some(destination_dir) = &destination_dir { + let empty_path = path::Path::new(""); + + let relative_path = if let Some(common_path) = &common_path { + new_path + .strip_prefix(common_path.parent().unwrap_or(empty_path)) + .unwrap_or(empty_path) + } else { + empty_path + }; + + new_path = destination_dir.join(relative_path); + } + let ext = args.format.to_string(); let suffix = suffix.clone().unwrap_or_default(); @@ -176,7 +214,7 @@ fn main() { new_path.set_extension(ext); match fs::write( - new_path, + &new_path, match e.encode_quantized(quantization, dithering) { Ok(data) => data, Err(e) => { @@ -192,6 +230,7 @@ fn main() { } }; info!("{} done", &path.file_name().unwrap().to_str().unwrap()); + info!("Saved to {:?}", new_path); pb.inc(1); }); } @@ -205,6 +244,9 @@ fn main() { let pb = pb.clone(); let conf = conf.clone(); let suffix = args.suffix.clone(); + let common_path = common_path.clone(); + let destination_dir = args.output.clone(); + pool.execute(move || { info!("Decoding {}", &path.file_name().unwrap().to_str().unwrap()); pb.set_message(path.file_name().unwrap().to_str().unwrap().to_owned()); @@ -232,6 +274,25 @@ fn main() { ); let mut new_path = path.clone(); + + if let Some(destination_dir) = &destination_dir { + let file_name = path::Path::new(new_path.file_name().unwrap()); + + let relative_path = if let Some(common_path) = &common_path { + new_path.strip_prefix(common_path).unwrap_or(file_name) + } else { + file_name + }; + + println!("Destination: {:?}", destination_dir); + println!("Common path: {:?}", common_path); + println!("Relative path: {:?}", relative_path); + + new_path = destination_dir.join(relative_path); + + println!("Final path: {:?}", new_path); + } + let ext = args.format.to_string(); let suffix = suffix.clone().unwrap_or_default(); @@ -242,8 +303,15 @@ fn main() { )); new_path.set_extension(ext); + match fs::create_dir_all(new_path.parent().unwrap()) { + Ok(_) => (), + Err(e) => { + error!("{} {e}", &path.file_name().unwrap().to_str().unwrap()); + } + } + match fs::write( - new_path, + &new_path, match e.encode() { Ok(data) => data, Err(e) => { @@ -259,6 +327,7 @@ fn main() { } }; info!("{} done", &path.file_name().unwrap().to_str().unwrap()); + info!("Saved to {:?}", new_path); pb.inc(1); }); } diff --git a/src/utils.rs b/src/utils.rs index 98aaf141..f091080d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,21 +1,24 @@ use std::path::{Path, PathBuf}; /// Gets common path inside a array of paths -pub fn common_path(paths: I) -> Option -where - I: IntoIterator, - P: AsRef, -{ +pub fn common_path(paths: &[PathBuf]) -> Option { + if paths.len() < 2 { + return None; + } + let mut iter = paths.into_iter(); - let mut ret = iter.next()?.as_ref().to_path_buf(); + + let mut ret = iter.next()?.clone(); + for path in iter { - if let Some(r) = common(ret, path.as_ref()) { + if let Some(r) = common(ret, path) { ret = r; } else { return None; } } - Some(ret) + + Some(ret.to_owned()) } fn common, B: AsRef>(a: A, b: B) -> Option { From ab2a8a93ef46d2f616718b6cbd5700a77234b223 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 18:06:46 +0200 Subject: [PATCH 39/46] Added documentation for output dir --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b2aa327..340250a9 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ rimage -q 75 *.jpg ``` - Quality: `-q 0` through `-q 100`, higher is better -- Output format: `-o png`, currently supported only jpg, png, oxipng and webp +- Output format: `-f png`, currently supported only jpg, png, oxipng and webp +- Output directory: `-o /somewhere`, saves all processed files in this directory, also saves files directory structure - Suffix for output: `-s _updated`, adds suffix in file name ("input.jpg" -> "input_updated.jpg") - Info: `-i`, flag used to get info about images (size and data length) - Threads: `-t 4`, number of threads to use From 70c8355afc006a3fbaf2876513376cc0a0a1da72 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 18:08:30 +0200 Subject: [PATCH 40/46] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93ba872b..0955b073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ - [Changed] ImageData now stores bytes as Box<[u8]> - [Changed] Global allocator now is Jemalloc on unix and MiMalloc on Windows - [Changed] Reduced peak heap usage twice! +- [Changed] Now output format option is named just format - [Added] AVIF decoding and encoding +- [Added] Output dir option for saving in different locations ## v0.6.0 From b1e66c1e0602676333a33a941fc70ee1ddce634d Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 18:18:42 +0200 Subject: [PATCH 41/46] Removed debug print lines, fixed quantization and dithering output path --- src/main.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index 62c064de..29169e34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -190,14 +190,12 @@ fn main() { let mut new_path = path.clone(); if let Some(destination_dir) = &destination_dir { - let empty_path = path::Path::new(""); + let file_name = path::Path::new(new_path.file_name().unwrap()); let relative_path = if let Some(common_path) = &common_path { - new_path - .strip_prefix(common_path.parent().unwrap_or(empty_path)) - .unwrap_or(empty_path) + new_path.strip_prefix(common_path).unwrap_or(file_name) } else { - empty_path + file_name }; new_path = destination_dir.join(relative_path); @@ -213,9 +211,16 @@ fn main() { )); new_path.set_extension(ext); + match fs::create_dir_all(new_path.parent().unwrap()) { + Ok(_) => (), + Err(e) => { + error!("{} {e}", &path.file_name().unwrap().to_str().unwrap()); + } + } + match fs::write( &new_path, - match e.encode_quantized(quantization, dithering) { + match e.encode() { Ok(data) => data, Err(e) => { error!("{} {e}", &path.file_name().unwrap().to_str().unwrap()); @@ -284,13 +289,7 @@ fn main() { file_name }; - println!("Destination: {:?}", destination_dir); - println!("Common path: {:?}", common_path); - println!("Relative path: {:?}", relative_path); - new_path = destination_dir.join(relative_path); - - println!("Final path: {:?}", new_path); } let ext = args.format.to_string(); From afc89e95b714f5e1ed99a5f2e83fe8a146d946e7 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 18:19:51 +0200 Subject: [PATCH 42/46] Fix clippy dependencies --- .github/workflows/rust-clippy.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust-clippy.yml b/.github/workflows/rust-clippy.yml index 1e90cd52..9afc3199 100644 --- a/.github/workflows/rust-clippy.yml +++ b/.github/workflows/rust-clippy.yml @@ -11,12 +11,12 @@ name: rust-clippy analyze on: push: - branches: [ "main" ] + branches: ["main"] pull_request: # The branches below must be a subset of the branches above - branches: [ "main" ] + branches: ["main"] schedule: - - cron: '18 14 * * 4' + - cron: "18 14 * * 4" jobs: rust-clippy-analyze: @@ -29,9 +29,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - + - name: Install dependencies (linux) - if: matrix.os == 'ubuntu-latest' run: | DEBIAN_FRONTEND=noninteractive sudo apt-get update DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ninja-build nasm meson @@ -48,8 +47,7 @@ jobs: run: cargo install clippy-sarif sarif-fmt - name: Run rust-clippy - run: - cargo clippy + run: cargo clippy --all-features --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt continue-on-error: true From 334a5f62a5f8140c2b1cadb0ec1b3cac10d6b76a Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 19:00:37 +0200 Subject: [PATCH 43/46] Fixed clippy warnings --- src/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index f091080d..6d07aa72 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -6,7 +6,7 @@ pub fn common_path(paths: &[PathBuf]) -> Option { return None; } - let mut iter = paths.into_iter(); + let mut iter = paths.iter(); let mut ret = iter.next()?.clone(); @@ -18,7 +18,7 @@ pub fn common_path(paths: &[PathBuf]) -> Option { } } - Some(ret.to_owned()) + Some(ret) } fn common, B: AsRef>(a: A, b: B) -> Option { From eac8a3afa47bbe0e66a17e5337c370c40ddeb813 Mon Sep 17 00:00:00 2001 From: SalOne22 <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 19:29:06 +0200 Subject: [PATCH 44/46] Fixed avif decoding image size --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 3966938a..78033170 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -479,7 +479,7 @@ impl<'a> Decoder<'a> { }; let pixels = unsafe { - std::slice::from_raw_parts(rgb.pixels, (rgb.width * rgb.height) as usize) + std::slice::from_raw_parts(rgb.pixels, (rgb.width * rgb.height * 4) as usize) }; result = Ok(ImageData::new( From 991d451b9cde9c31a562df4c60dd73a95cf66483 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 19:41:53 +0200 Subject: [PATCH 45/46] Update deploy.yml Fixed publish dependencies --- .github/workflows/deploy.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3fcb9e93..e9ca0895 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -180,17 +180,10 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: ilammy/setup-nasm@v1 - - - name: Install python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - cache: 'pip' - - - name: Install meson / ninja - shell: bash - run: pip install meson ninja + - name: Install dependencies + run: | + DEBIAN_FRONTEND=noninteractive sudo apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ninja-build nasm meson - name: Install Rust uses: actions-rs/toolchain@v1 From 463ff97852ddd2b47b054c99527f3a73eed6c1c9 Mon Sep 17 00:00:00 2001 From: Vladyslav Vladinov <111443297+SalOne22@users.noreply.github.com> Date: Wed, 14 Jun 2023 20:39:34 +0200 Subject: [PATCH 46/46] Update deploy.yml --- .github/workflows/deploy.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e9ca0895..a2e3cc18 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -72,7 +72,7 @@ jobs: os: [ubuntu-latest, macos-latest] include: - os: ubuntu-latest - target: x86_64-unknown-linux-musl + target: x86_64-unknown-linux-gnu - os: macos-latest target: x86_64-apple-darwin @@ -100,11 +100,6 @@ jobs: target: ${{ matrix.target }} override: true - - name: Install musl - if: contains(matrix.target, 'linux-musl') - run: | - sudo apt-get install musl-tools - - name: Rust Cache uses: Swatinem/rust-cache@v2.2.1