diff --git a/Cargo.lock b/Cargo.lock index 09c2bb55..880144fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,7 +29,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -189,7 +189,7 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.42" +version = "0.2.43" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -208,7 +208,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -263,12 +263,12 @@ name = "num_cpus" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "oxipng" -version = "2.1.0" +version = "2.1.1" dependencies = [ "bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -328,7 +328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -370,7 +370,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -472,7 +472,7 @@ dependencies = [ "checksum inflate 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6f53b811ee8e2057ccf9643ca6b4277de90efaf5e61e55fd5254576926bb4245" "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" "checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" -"checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" +"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" "checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum miniz_oxide 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9ba430291c9d6cedae28bcd2d49d1c32fc57d60cd49086646c5dd5673a870eb5" diff --git a/Cargo.toml b/Cargo.toml index e08ce047..82abf330 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ homepage = "https://github.com/shssoichiro/oxipng" license = "MIT" name = "oxipng" repository = "https://github.com/shssoichiro/oxipng" -version = "2.1.0" +version = "2.1.1" [badges] travis-ci = { repository = "shssoichiro/oxipng", branch = "master" } diff --git a/README.md b/README.md index c4963f76..9b852377 100644 --- a/README.md +++ b/README.md @@ -94,39 +94,39 @@ Oxipng is open-source software, distributed under the MIT license. ## Benchmarks -Tested oxipng 2.1.0 (compiled on rustc 1.29.0-nightly (6a1c0637c 2018-07-23)) against OptiPNG version 0.7.7 on Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz with 8 logical cores +Tested oxipng 2.1.1 (compiled on rustc 1.30.0-nightly (73c78734b 2018-08-05)) against OptiPNG version 0.7.7 on Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz with 8 logical cores Benchmark #1: ./target/release/oxipng -P ./tests/files/rgb_16_should_be_grayscale_8.png - Time (mean ± σ): 91.5 ms ± 2.8 ms [User: 174.2 ms, System: 23.5 ms] + Time (mean ± σ): 91.0 ms ± 1.9 ms [User: 173.7 ms, System: 25.7 ms] - Range (min … max): 87.8 ms … 96.9 ms + Range (min … max): 88.1 ms … 96.2 ms Benchmark #2: optipng -simulate ./tests/files/rgb_16_should_be_grayscale_8.png - Time (mean ± σ): 280.6 ms ± 2.9 ms [User: 279.0 ms, System: 1.5 ms] + Time (mean ± σ): 276.1 ms ± 3.8 ms [User: 274.1 ms, System: 1.9 ms] - Range (min … max): 277.3 ms … 286.1 ms + Range (min … max): 271.1 ms … 283.4 ms Summary './target/release/oxipng -P ./tests/files/rgb_16_should_be_grayscale_8.png' ran - 3.07x faster than 'optipng -simulate ./tests/files/rgb_16_should_be_grayscale_8.png' + 3.03x faster than 'optipng -simulate ./tests/files/rgb_16_should_be_grayscale_8.png' Benchmark #1: ./target/release/oxipng -o4 -P ./tests/files/rgb_16_should_be_grayscale_8.png - Time (mean ± σ): 118.1 ms ± 3.1 ms [User: 449.8 ms, System: 29.6 ms] + Time (mean ± σ): 118.4 ms ± 2.7 ms [User: 449.4 ms, System: 23.5 ms] - Range (min … max): 113.0 ms … 124.6 ms + Range (min … max): 114.5 ms … 124.3 ms Benchmark #2: optipng -o 4 -simulate ./tests/files/rgb_16_should_be_grayscale_8.png - Time (mean ± σ): 955.3 ms ± 13.0 ms [User: 953.2 ms, System: 1.7 ms] + Time (mean ± σ): 932.1 ms ± 8.6 ms [User: 928.2 ms, System: 3.2 ms] - Range (min … max): 940.1 ms … 986.0 ms + Range (min … max): 923.9 ms … 952.9 ms Summary './target/release/oxipng -o4 -P ./tests/files/rgb_16_should_be_grayscale_8.png' ran - 8.09x faster than 'optipng -o 4 -simulate ./tests/files/rgb_16_should_be_grayscale_8.png' + 7.88x faster than 'optipng -o 4 -simulate ./tests/files/rgb_16_should_be_grayscale_8.png' diff --git a/scripts/compare.sh b/scripts/compare.sh index dd95f166..307132a3 100755 --- a/scripts/compare.sh +++ b/scripts/compare.sh @@ -4,7 +4,7 @@ cp README.template.md README.md CORES=$(sysctl -n hw.ncpu 2>/dev/null || grep -c ^processor /proc/cpuinfo) CPU=$(sysctl -n machdep.cpu.brand_string 2>/dev/null || grep '^model name' /proc/cpuinfo | sed 's/model name.\+: //g' | head -n 1) -OXIPNG_VERSION=$(oxipng -V) +OXIPNG_VERSION=$(./target/release/oxipng -V) OPTIPNG_VERSION=$(optipng -v | head -n 1) RUST_VERSION=$(rustc -V) echo "Tested $OXIPNG_VERSION (compiled on $RUST_VERSION) against $OPTIPNG_VERSION on $CPU with $CORES logical cores" >> README.md diff --git a/src/interlace.rs b/src/interlace.rs index eabb518f..cdf20a2d 100644 --- a/src/interlace.rs +++ b/src/interlace.rs @@ -94,8 +94,8 @@ pub fn deinterlace_image(png: &mut PngData) { for line in png.scan_lines() { let bit_vec = BitVec::from_bytes(&line.data); let bits_in_line = ((png.ihdr_data.width - u32::from(pass_constants.x_shift)) as f32 - / f32::from(pass_constants.x_step)) - .ceil() as usize * bits_per_pixel as usize; + / f32::from(pass_constants.x_step)).ceil() as usize + * bits_per_pixel as usize; for (i, bit) in bit_vec.iter().enumerate() { // Avoid moving padded 0's into new image if i >= bits_in_line { diff --git a/src/lib.rs b/src/lib.rs index edeb8a62..38c872ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -560,8 +560,7 @@ fn optimize_png(png: &mut PngData, original_data: &[u8], opts: &Options) -> PngR .map(|f| { let png = png.clone(); (*f, png.filter_image(*f)) - }) - .collect(); + }).collect(); let original_len = original_png.idat_data.len(); let added_interlacing = opts.interlace == Some(1) && original_png.ihdr_data.interlaced == 0; diff --git a/src/png/mod.rs b/src/png/mod.rs index 33803c76..eb1cbdcc 100644 --- a/src/png/mod.rs +++ b/src/png/mod.rs @@ -286,8 +286,7 @@ impl PngData { let signed = x as i8; acc + i16::from(signed).abs() as u64 }) - }) - .unwrap(); + }).unwrap(); filtered.push(*best_filter); filtered.extend_from_slice(best_line); } @@ -364,8 +363,7 @@ impl PngData { let mut pixel = pixel.to_owned(); pixel.push(*trns); pixel - }) - .collect() + }).collect() } else { self.palette.clone().unwrap() }; @@ -374,8 +372,7 @@ impl PngData { 4 } else { 3 - }) - .collect(); + }).collect(); // A map of old indexes to new ones, for any moved let mut index_map: HashMap = HashMap::new(); @@ -616,16 +613,14 @@ impl PngData { STD_WINDOW, &best_size, ).ok() - .as_ref() - .map(|l| { - best_size.set_min(l.len()); - l.len() - }) - }) - .min() + .as_ref() + .map(|l| { + best_size.set_min(l.len()); + l.len() + }) + }).min() .map(|size| (size, image)) - }) - .min_by_key(|&(size, _)| size); + }).min_by_key(|&(size, _)| size); if let Some(best) = best { self.raw_data = best.1.raw_data;