diff --git a/.github/workflows/ebur128.yml b/.github/workflows/ebur128.yml index 00ac847..b9ddfb2 100644 --- a/.github/workflows/ebur128.yml +++ b/.github/workflows/ebur128.yml @@ -114,3 +114,28 @@ jobs: QUICKCHECK_TESTS: 2 run: | cargo test --features c-tests,internal-tests,reference-tests + + msrv-ubuntu-tests: + + runs-on: ubuntu-latest + + strategy: + matrix: + toolchain: ['1.60'] + + steps: + - uses: actions/checkout@v2 + + - name: Install ${{ matrix.toolchain }} + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.toolchain }} + override: true + + - name: Use MSRV Cargo.lock + run: cp Cargo.lock.msrv Cargo.lock + + - name: Run cargo check + run: | + cargo check diff --git a/Cargo.lock.msrv b/Cargo.lock.msrv new file mode 100644 index 0000000..e121c36 --- /dev/null +++ b/Cargo.lock.msrv @@ -0,0 +1,863 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cc" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + +[[package]] +name = "clap" +version = "3.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +dependencies = [ + "bitflags", + "clap_lex", + "indexmap", + "textwrap", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "criterion" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" +dependencies = [ + "anes", + "atty", + "cast", + "ciborium", + "clap", + "criterion-plot", + "itertools", + "lazy_static", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "dasp_frame" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a3937f5fe2135702897535c8d4a5553f8b116f76c1529088797f2eee7c5cd6" +dependencies = [ + "dasp_sample", +] + +[[package]] +name = "dasp_sample" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + +[[package]] +name = "ebur128" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e077e29310bf97aabb3cddffdbe408e1a1e32e65d27c97f5a463d57f91a36c" +dependencies = [ + "bitflags", + "cc", +] + +[[package]] +name = "ebur128" +version = "0.1.8" +dependencies = [ + "bitflags", + "cc", + "criterion", + "dasp_frame", + "dasp_sample", + "ebur128 0.1.1", + "float_eq", + "hound", + "quickcheck", + "quickcheck_macros", + "rand", + "smallvec", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "float_eq" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28a80e3145d8ad11ba0995949bbcf48b9df2be62772b3d351ef017dff6ecb853" + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "half" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" +dependencies = [ + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hound" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f" + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "memchr" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76fc44e2588d5b436dbc3c6cf62aef290f90dab6235744a93dfe1cc18f451e2c" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.9", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + +[[package]] +name = "os_str_bytes" +version = "6.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" + +[[package]] +name = "plotters" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" + +[[package]] +name = "plotters-svg" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quickcheck" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f" +dependencies = [ + "env_logger", + "log", + "rand", + "rand_core", +] + +[[package]] +name = "quickcheck_macros" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608c156fd8e97febc07dc9c2e2c80bf74cfc6ef26893eae3daf8bc2bc94a4b7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rayon" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "regex" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.67", +] + +[[package]] +name = "serde_json" +version = "1.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.67", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.67", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/Cargo.toml b/Cargo.toml index 3fb45f7..5e8262a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ repository = "https://github.com/sdroege/ebur128" homepage = "https://github.com/sdroege/ebur128" license = "MIT" readme = "README.md" +rust-version = "1.60" [dependencies] bitflags = "1.0" diff --git a/benches/ebur128.rs b/benches/ebur128.rs index 6a53349..2205c98 100644 --- a/benches/ebur128.rs +++ b/benches/ebur128.rs @@ -139,7 +139,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { data.chunks_exact_mut(2), Iterator::zip(fst.iter_mut(), snd.iter_mut()), ) { - let val = f32::sin(accumulator) * std::i16::MAX as f32; + let val = f32::sin(accumulator) * i16::MAX as f32; out[0] = val as i16; out[1] = val as i16; *fst = val as i16; @@ -191,7 +191,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { data.chunks_exact_mut(2), Iterator::zip(fst.iter_mut(), snd.iter_mut()), ) { - let val = f32::sin(accumulator) * std::i32::MAX as f32; + let val = f32::sin(accumulator) * i32::MAX as f32; out[0] = val as i32; out[1] = val as i32; *fst = val as i32; diff --git a/benches/filter.rs b/benches/filter.rs index 54e794e..d6bb78e 100644 --- a/benches/filter.rs +++ b/benches/filter.rs @@ -51,7 +51,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { data.chunks_exact_mut(2), Iterator::zip(fst.iter_mut(), snd.iter_mut()), ) { - let val = f32::sin(accumulator) * std::i16::MAX as f32; + let val = f32::sin(accumulator) * i16::MAX as f32; out[0] = val as i16; out[1] = val as i16; *fst = val as i16; @@ -115,7 +115,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { data.chunks_exact_mut(2), Iterator::zip(fst.iter_mut(), snd.iter_mut()), ) { - let val = f32::sin(accumulator) * std::i32::MAX as f32; + let val = f32::sin(accumulator) * i32::MAX as f32; out[0] = val as i32; out[1] = val as i32; *fst = val as i32; diff --git a/benches/true_peak.rs b/benches/true_peak.rs index bb55c70..c899660 100644 --- a/benches/true_peak.rs +++ b/benches/true_peak.rs @@ -12,7 +12,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { data.chunks_exact_mut(2), Iterator::zip(fst.iter_mut(), snd.iter_mut()), ) { - let val = f32::sin(accumulator) * std::i16::MAX as f32; + let val = f32::sin(accumulator) * i16::MAX as f32; out[0] = val as i16; out[1] = val as i16; *fst = val as i16; @@ -75,7 +75,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { data.chunks_exact_mut(2), Iterator::zip(fst.iter_mut(), snd.iter_mut()), ) { - let val = f32::sin(accumulator) * std::i32::MAX as f32; + let val = f32::sin(accumulator) * i32::MAX as f32; out[0] = val as i32; out[1] = val as i32; *fst = val as i32; diff --git a/src/capi.rs b/src/capi.rs index 041e12f..34142a4 100644 --- a/src/capi.rs +++ b/src/capi.rs @@ -79,7 +79,10 @@ pub unsafe extern "C" fn ebur128_set_channel( let s = &mut *state; let e = &mut *s.internal; - match e.set_channel(channel_number, mem::transmute(value)) { + match e.set_channel( + channel_number, + mem::transmute::(value), + ) { Err(err) => err.into(), Ok(_) => 0, } diff --git a/src/ebur128.rs b/src/ebur128.rs index 93d337f..9b316a2 100644 --- a/src/ebur128.rs +++ b/src/ebur128.rs @@ -297,7 +297,7 @@ impl EbuR128 { let sample_peak = vec![0.0; channels as usize]; let true_peak = vec![0.0; channels as usize]; - let history = std::usize::MAX; + let history = usize::MAX; let samples_in_100ms = (rate as usize + 5) / 10; let window = if mode.contains(Mode::S) { @@ -814,7 +814,7 @@ impl EbuR128 { let energy = self.energy_in_interval(self.samples_in_100ms * 4)?; if energy <= 0.0 { - return Ok(-std::f64::INFINITY); + return Ok(-f64::INFINITY); } Ok(energy_to_loudness(energy)) @@ -829,7 +829,7 @@ impl EbuR128 { let energy = self.energy_shortterm()?; if energy <= 0.0 { - return Ok(-std::f64::INFINITY); + return Ok(-f64::INFINITY); } Ok(energy_to_loudness(energy)) @@ -847,7 +847,7 @@ impl EbuR128 { let energy = self.energy_in_interval(interval_frames)?; if energy <= 0.0 { - return Ok(-std::f64::INFINITY); + return Ok(-f64::INFINITY); } Ok(energy_to_loudness(energy)) @@ -1009,7 +1009,7 @@ mod tests { let mut accumulator = 0.0; let step = 2.0 * std::f32::consts::PI * 440.0 / 48_000.0; for out in data.chunks_exact_mut(2) { - let val = f32::sin(accumulator) * (std::i16::MAX - 1) as f32; + let val = f32::sin(accumulator) * (i16::MAX - 1) as f32; out[0] = val as i16; out[1] = val as i16; accumulator += step; @@ -1092,22 +1092,22 @@ mod tests { assert_float_eq!( ebu.loudness_global().unwrap(), - -std::f64::INFINITY, + -f64::INFINITY, abs <= 0.000001 ); assert_float_eq!( ebu.loudness_momentary().unwrap(), - -std::f64::INFINITY, + -f64::INFINITY, abs <= 0.000001 ); assert_float_eq!( ebu.loudness_shortterm().unwrap(), - -std::f64::INFINITY, + -f64::INFINITY, abs <= 0.000001 ); assert_float_eq!( ebu.loudness_window(1).unwrap(), - -std::f64::INFINITY, + -f64::INFINITY, abs <= 0.000001 ); assert_float_eq!(ebu.loudness_range().unwrap(), 0.0, abs <= 0.000001); @@ -1131,7 +1131,7 @@ mod tests { let mut accumulator = 0.0; let step = 2.0 * std::f32::consts::PI * 440.0 / 48_000.0; for out in data.chunks_exact_mut(2) { - let val = f32::sin(accumulator) * (std::i32::MAX - 1) as f32; + let val = f32::sin(accumulator) * (i32::MAX - 1) as f32; out[0] = val as i32; out[1] = val as i32; accumulator += step; @@ -1341,7 +1341,7 @@ mod tests { let mut accumulator = 0.0; let step = 2.0 * std::f32::consts::PI * 440.0 / 48_000.0; for out in data.chunks_exact_mut(2) { - let val = f32::sin(accumulator) * (std::i16::MAX - 1) as f32; + let val = f32::sin(accumulator) * (i16::MAX - 1) as f32; out[0] = val as i16; out[1] = val as i16; accumulator += step; @@ -1431,7 +1431,7 @@ mod tests { let mut accumulator = 0.0; let step = 2.0 * std::f32::consts::PI * 440.0 / 48_000.0; for out in data.chunks_exact_mut(2) { - let val = f32::sin(accumulator) * (std::i32::MAX - 1) as f32; + let val = f32::sin(accumulator) * (i32::MAX - 1) as f32; out[0] = val as i32; out[1] = val as i32; accumulator += step; @@ -1654,7 +1654,7 @@ mod tests { let step = 2.0 * std::f32::consts::PI * 440.0 / 48_000.0; let (fst, snd) = data.split_at_mut(48_000 * 5); for (fst, snd) in Iterator::zip(fst.iter_mut(), snd.iter_mut()) { - let val = f32::sin(accumulator) * (std::i16::MAX - 1) as f32; + let val = f32::sin(accumulator) * (i16::MAX - 1) as f32; *fst = val as i16; *snd = val as i16; accumulator += step; @@ -1745,7 +1745,7 @@ mod tests { let step = 2.0 * std::f32::consts::PI * 440.0 / 48_000.0; let (fst, snd) = data.split_at_mut(48_000 * 5); for (fst, snd) in Iterator::zip(fst.iter_mut(), snd.iter_mut()) { - let val = f32::sin(accumulator) * (std::i32::MAX - 1) as f32; + let val = f32::sin(accumulator) * (i32::MAX - 1) as f32; *fst = val as i32; *snd = val as i32; accumulator += step; @@ -2328,4 +2328,75 @@ mod tests { compare_results(&ebu, &ebu_c, signal.channels); } + + #[test] + fn infinity_handling() { + let mut data = vec![0.0f32; 44_100 * 80]; + for out in data.chunks_exact_mut(2) { + out[0] = f32::INFINITY; + out[1] = f32::NEG_INFINITY; + } + + let mut ebu = EbuR128::new(2, 44_100, Mode::all() - Mode::HISTOGRAM).unwrap(); + assert!(ebu.add_frames_f32(&data).is_ok()); + assert_eq!(ebu.sample_peak(0).unwrap().abs(), f64::INFINITY); + assert_eq!(ebu.true_peak(0).unwrap().abs(), f64::INFINITY); + assert!(ebu.loudness_global().unwrap().is_nan()); + assert!(ebu.loudness_momentary().unwrap().is_nan()); + assert!(ebu.energy_shortterm().unwrap().is_nan()); + assert!(ebu.loudness_shortterm().unwrap().is_nan()); + assert!(ebu.loudness_range().unwrap().is_nan()); + assert!(ebu.relative_threshold().unwrap().is_nan()); + + // With histogram mode the first bin is taken for NaN + let mut ebu = EbuR128::new(2, 44_100, Mode::all()).unwrap(); + assert!(ebu.add_frames_f32(&data).is_ok()); + assert_eq!(ebu.sample_peak(0).unwrap().abs(), f64::INFINITY); + assert_eq!(ebu.true_peak(0).unwrap().abs(), f64::INFINITY); + assert_float_eq!(ebu.loudness_global().unwrap(), -69.95, abs <= 0.000_000_1); + assert!(ebu.loudness_momentary().unwrap().is_nan()); + assert!(ebu.energy_shortterm().unwrap().is_nan()); + assert!(ebu.loudness_shortterm().unwrap().is_nan(),); + assert_float_eq!(ebu.loudness_range().unwrap(), 0.0, abs <= 0.000_000_1); + assert_float_eq!( + ebu.relative_threshold().unwrap(), + -79.95, + abs <= 0.000_000_1 + ); + } + + #[test] + fn nan_handling() { + let mut data = vec![0.0f32; 44_100 * 80]; + for out in data.chunks_exact_mut(2) { + out[0] = f32::NAN; + out[1] = f32::NAN; + } + + let mut ebu = EbuR128::new(2, 44_100, Mode::all() - Mode::HISTOGRAM).unwrap(); + assert!(ebu.add_frames_f32(&data).is_ok()); + assert_float_eq!(ebu.sample_peak(0).unwrap(), 0.0, abs <= f64::EPSILON); + assert_float_eq!(ebu.true_peak(0).unwrap(), 0.0, abs <= f64::EPSILON); + assert!(ebu.loudness_global().unwrap().is_nan()); + assert!(ebu.loudness_momentary().unwrap().is_nan()); + assert!(ebu.energy_shortterm().unwrap().is_nan()); + assert!(ebu.loudness_shortterm().unwrap().is_nan()); + assert!(ebu.relative_threshold().unwrap().is_nan()); + + // With histogram mode the first bin is taken for NaN + let mut ebu = EbuR128::new(2, 44_100, Mode::all()).unwrap(); + assert!(ebu.add_frames_f32(&data).is_ok()); + assert_float_eq!(ebu.sample_peak(0).unwrap(), 0.0, abs <= f64::EPSILON); + assert_float_eq!(ebu.true_peak(0).unwrap(), 0.0, abs <= f64::EPSILON); + assert_float_eq!(ebu.loudness_global().unwrap(), -69.95, abs <= 0.000_000_1); + assert!(ebu.loudness_momentary().unwrap().is_nan()); + assert!(ebu.energy_shortterm().unwrap().is_nan()); + assert!(ebu.loudness_shortterm().unwrap().is_nan(),); + assert_float_eq!(ebu.loudness_range().unwrap(), 0.0, abs <= 0.000_000_1); + assert_float_eq!( + ebu.relative_threshold().unwrap(), + -79.95, + abs <= 0.000_000_1 + ); + } } diff --git a/src/filter.rs b/src/filter.rs index a0745dc..86b9270 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -237,7 +237,7 @@ impl Filter { if ftz.is_none() { for v in filter_state { - if v.abs() < std::f64::EPSILON { + if v.abs() < f64::EPSILON { *v = 0.0; } } @@ -290,7 +290,7 @@ impl Filter { if ftz.is_none() { for v in filter_state { - if v.abs() < std::f64::EPSILON { + if v.abs() < f64::EPSILON { *v = 0.0; } } @@ -379,13 +379,16 @@ impl Filter { ))] mod ftz { #[cfg(target_arch = "x86")] + #[allow(deprecated)] use std::arch::x86::{_mm_getcsr, _mm_setcsr, _MM_FLUSH_ZERO_ON}; #[cfg(target_arch = "x86_64")] + #[allow(deprecated)] use std::arch::x86_64::{_mm_getcsr, _mm_setcsr, _MM_FLUSH_ZERO_ON}; pub struct Ftz(u32); impl Ftz { + #[allow(deprecated)] unsafe fn new() -> Self { let csr = _mm_getcsr(); _mm_setcsr(csr | _MM_FLUSH_ZERO_ON); @@ -394,6 +397,7 @@ mod ftz { } impl Drop for Ftz { + #[allow(deprecated)] fn drop(&mut self) { unsafe { _mm_setcsr(self.0); diff --git a/src/history.rs b/src/history.rs index 0e8c225..435a749 100644 --- a/src/history.rs +++ b/src/history.rs @@ -97,6 +97,10 @@ impl Histogram { return 0.0; } + if power.is_nan() { + return f64::NAN; + } + power /= size as f64; let minus_twenty_decibels = f64::powf(10.0, -20.0 / 10.0); let integrated = minus_twenty_decibels * power; @@ -285,7 +289,11 @@ impl History { }); if above_thresh_counter == 0 { - return -std::f64::INFINITY; + return -f64::INFINITY; + } + + if relative_threshold.is_nan() { + return f64::NAN; } let relative_gate = -10.0; @@ -330,7 +338,7 @@ impl History { } if above_thresh_counter == 0 { - return -std::f64::INFINITY; + return -f64::INFINITY; } energy_to_loudness(gated_loudness / above_thresh_counter as f64) @@ -343,6 +351,10 @@ impl History { return -70.0; } + if relative_threshold.is_nan() { + return f64::NAN; + } + let relative_gate = -10.0; let relative_gate_factor = f64::powf(10.0, relative_gate / 10.0); let relative_threshold = @@ -410,7 +422,20 @@ impl History { } } - combined.sort_unstable_by(|a, b| a.partial_cmp(b).unwrap()); + let mut contains_nan = false; + combined.sort_unstable_by(|a, b| { + if let Some(ord) = a.partial_cmp(b) { + ord + } else { + contains_nan = true; + + a.is_nan().cmp(&b.is_nan()) + } + }); + + if contains_nan { + return Ok(f64::NAN); + } Ok(Queue::loudness_range(&combined)) }