Skip to content

Commit

Permalink
Refactor aux chunk handling (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrews05 authored May 21, 2023
1 parent a583270 commit ea5f188
Show file tree
Hide file tree
Showing 32 changed files with 619 additions and 699 deletions.
16 changes: 8 additions & 8 deletions benches/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
extern crate oxipng;
extern crate test;

use oxipng::internal_tests::*;
use oxipng::*;
use std::path::PathBuf;
use test::Bencher;

use oxipng::internal_tests::*;

#[bench]
fn deflate_16_bits(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
let min = AtomicMin::new(None);
Expand All @@ -22,7 +22,7 @@ fn deflate_16_bits(b: &mut Bencher) {
#[bench]
fn deflate_8_bits(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
let min = AtomicMin::new(None);
Expand All @@ -35,7 +35,7 @@ fn deflate_4_bits(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_4_should_be_palette_4.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
let min = AtomicMin::new(None);
Expand All @@ -48,7 +48,7 @@ fn deflate_2_bits(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_2_should_be_palette_2.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
let min = AtomicMin::new(None);
Expand All @@ -61,7 +61,7 @@ fn deflate_1_bits(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_1_should_be_palette_1.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
let min = AtomicMin::new(None);
Expand All @@ -72,7 +72,7 @@ fn deflate_1_bits(b: &mut Bencher) {
#[bench]
fn inflate_generic(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| inflate(png.idat_data.as_ref(), png.raw.ihdr.raw_data_size()));
}
63 changes: 32 additions & 31 deletions benches/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
extern crate oxipng;
extern crate test;

use oxipng::{internal_tests::*, RowFilter};
use oxipng::internal_tests::*;
use oxipng::*;
use std::path::PathBuf;
use test::Bencher;

#[bench]
fn filters_16_bits_filter_0(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::None, false);
Expand All @@ -20,7 +21,7 @@ fn filters_16_bits_filter_0(b: &mut Bencher) {
#[bench]
fn filters_8_bits_filter_0(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::None, false);
Expand All @@ -32,7 +33,7 @@ fn filters_4_bits_filter_0(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_4_should_be_palette_4.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::None, false);
Expand All @@ -44,7 +45,7 @@ fn filters_2_bits_filter_0(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_2_should_be_palette_2.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::None, false);
Expand All @@ -56,7 +57,7 @@ fn filters_1_bits_filter_0(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_1_should_be_palette_1.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::None, false);
Expand All @@ -66,7 +67,7 @@ fn filters_1_bits_filter_0(b: &mut Bencher) {
#[bench]
fn filters_16_bits_filter_1(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Sub, false);
Expand All @@ -76,7 +77,7 @@ fn filters_16_bits_filter_1(b: &mut Bencher) {
#[bench]
fn filters_8_bits_filter_1(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Sub, false);
Expand All @@ -88,7 +89,7 @@ fn filters_4_bits_filter_1(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_4_should_be_palette_4.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Sub, false);
Expand All @@ -100,7 +101,7 @@ fn filters_2_bits_filter_1(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_2_should_be_palette_2.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Sub, false);
Expand All @@ -112,7 +113,7 @@ fn filters_1_bits_filter_1(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_1_should_be_palette_1.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Sub, false);
Expand All @@ -122,7 +123,7 @@ fn filters_1_bits_filter_1(b: &mut Bencher) {
#[bench]
fn filters_16_bits_filter_2(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Up, false);
Expand All @@ -132,7 +133,7 @@ fn filters_16_bits_filter_2(b: &mut Bencher) {
#[bench]
fn filters_8_bits_filter_2(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Up, false);
Expand All @@ -144,7 +145,7 @@ fn filters_4_bits_filter_2(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_4_should_be_palette_4.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Up, false);
Expand All @@ -156,7 +157,7 @@ fn filters_2_bits_filter_2(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_2_should_be_palette_2.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Up, false);
Expand All @@ -168,7 +169,7 @@ fn filters_1_bits_filter_2(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_1_should_be_palette_1.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Up, false);
Expand All @@ -178,7 +179,7 @@ fn filters_1_bits_filter_2(b: &mut Bencher) {
#[bench]
fn filters_16_bits_filter_3(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Average, false);
Expand All @@ -188,7 +189,7 @@ fn filters_16_bits_filter_3(b: &mut Bencher) {
#[bench]
fn filters_8_bits_filter_3(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Average, false);
Expand All @@ -200,7 +201,7 @@ fn filters_4_bits_filter_3(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_4_should_be_palette_4.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Average, false);
Expand All @@ -212,7 +213,7 @@ fn filters_2_bits_filter_3(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_2_should_be_palette_2.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Average, false);
Expand All @@ -224,7 +225,7 @@ fn filters_1_bits_filter_3(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_1_should_be_palette_1.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Average, false);
Expand All @@ -234,7 +235,7 @@ fn filters_1_bits_filter_3(b: &mut Bencher) {
#[bench]
fn filters_16_bits_filter_4(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Paeth, false);
Expand All @@ -244,7 +245,7 @@ fn filters_16_bits_filter_4(b: &mut Bencher) {
#[bench]
fn filters_8_bits_filter_4(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Paeth, false);
Expand All @@ -256,7 +257,7 @@ fn filters_4_bits_filter_4(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_4_should_be_palette_4.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Paeth, false);
Expand All @@ -268,7 +269,7 @@ fn filters_2_bits_filter_4(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_2_should_be_palette_2.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Paeth, false);
Expand All @@ -280,7 +281,7 @@ fn filters_1_bits_filter_4(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_1_should_be_palette_1.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Paeth, false);
Expand All @@ -290,7 +291,7 @@ fn filters_1_bits_filter_4(b: &mut Bencher) {
#[bench]
fn filters_16_bits_filter_5(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
Expand All @@ -300,7 +301,7 @@ fn filters_16_bits_filter_5(b: &mut Bencher) {
#[bench]
fn filters_8_bits_filter_5(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
Expand All @@ -312,7 +313,7 @@ fn filters_4_bits_filter_5(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_4_should_be_palette_4.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
Expand All @@ -324,7 +325,7 @@ fn filters_2_bits_filter_5(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_2_should_be_palette_2.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
Expand All @@ -336,7 +337,7 @@ fn filters_1_bits_filter_5(b: &mut Bencher) {
let input = test::black_box(PathBuf::from(
"tests/files/palette_1_should_be_palette_1.png",
));
let png = PngData::new(&input, false).unwrap();
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
Expand Down
Loading

0 comments on commit ea5f188

Please sign in to comment.