This is an experiment I started a while ago before life happened. It
reduces memory usage of fast evaluation (-o2 and lower), bringing it
inline with normal (slow) evaluation. It does this by not retaining the
filtered image data of the evaluations, but instead retaining the row
filters that were used in each line so it can be quickly re-filtered
when required. This does incur a tiny performance penalty, but it's
negligible even at `-o0`.
Although this is fully functional, there are a few rough spots in the
code so I'm just opening it as a draft for now.
```
PR -sao6
70.08 real 614.36 user 2.66 sys
2024243200 maximum resident set size
1839339520 peak memory footprint
PR -sao2
11.16 real 60.85 user 1.33 sys
1982562304 maximum resident set size
1842173824 peak memory footprint
PR -sao2 -t1
55.11 real 53.85 user 0.76 sys
429457408 maximum resident set size
245008064 peak memory footprint
master -sao6
67.70 real 616.07 user 2.72 sys
2043379712 maximum resident set size
1838340416 peak memory footprint
master -sao2
11.53 real 60.63 user 1.25 sys
2753396736 maximum resident set size
2283741440 peak memory footprint
master -sao2 -t1
54.29 real 53.55 user 0.72 sys
626311168 maximum resident set size
305252544 peak memory footprint
```
Note that this involves some refactoring of `RowFilter` and the new
`FilterStrategy`. These are breaking changes so it will ultimately be
destined for v10. One advantage to this new structure is it opens the
door for future changes such as allowing the Brute strategy to take a
parameter for the number of lines.
854 lines
17 KiB
Rust
854 lines
17 KiB
Rust
use std::{
|
|
fs::remove_file,
|
|
path::{Path, PathBuf},
|
|
};
|
|
|
|
use oxipng::{internal_tests::*, *};
|
|
|
|
const GRAYSCALE: u8 = 0;
|
|
const RGB: u8 = 2;
|
|
const INDEXED: u8 = 3;
|
|
const GRAYSCALE_ALPHA: u8 = 4;
|
|
const RGBA: u8 = 6;
|
|
|
|
fn get_opts(input: &Path) -> (OutFile, oxipng::Options) {
|
|
let options = oxipng::Options {
|
|
force: true,
|
|
filter: indexset! {FilterStrategy::NONE},
|
|
..Default::default()
|
|
};
|
|
(OutFile::from_path(input.with_extension("out.png")), options)
|
|
}
|
|
|
|
fn test_it_converts(
|
|
input: &str,
|
|
filter: FilterStrategy,
|
|
color_type_in: u8,
|
|
bit_depth_in: BitDepth,
|
|
color_type_out: u8,
|
|
bit_depth_out: BitDepth,
|
|
) {
|
|
let input = PathBuf::from(input);
|
|
|
|
let (output, mut opts) = get_opts(&input);
|
|
let png = PngData::new(&input, &opts).unwrap();
|
|
opts.filter = IndexSet::new();
|
|
opts.filter.insert(filter);
|
|
assert_eq!(png.raw.ihdr.color_type.png_header_code(), color_type_in);
|
|
assert_eq!(png.raw.ihdr.bit_depth, bit_depth_in);
|
|
|
|
match oxipng::optimize(&InFile::Path(input), &output, &opts) {
|
|
Ok(_) => (),
|
|
Err(x) => panic!("{}", x),
|
|
};
|
|
let output = output.path().unwrap();
|
|
assert!(output.exists());
|
|
|
|
let png = match PngData::new(output, &opts) {
|
|
Ok(x) => x,
|
|
Err(x) => {
|
|
remove_file(output).ok();
|
|
panic!("{}", x)
|
|
}
|
|
};
|
|
|
|
assert_eq!(png.raw.ihdr.color_type.png_header_code(), color_type_out);
|
|
assert_eq!(png.raw.ihdr.bit_depth, bit_depth_out);
|
|
if let ColorType::Indexed { palette } = &png.raw.ihdr.color_type {
|
|
assert!(palette.len() <= 1 << (png.raw.ihdr.bit_depth as u8));
|
|
}
|
|
|
|
remove_file(output).ok();
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_rgba_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_rgba_16.png",
|
|
FilterStrategy::NONE,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_rgba_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_rgba_16.png",
|
|
FilterStrategy::SUB,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_rgba_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_rgba_16.png",
|
|
FilterStrategy::UP,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_rgba_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_rgba_16.png",
|
|
FilterStrategy::AVERAGE,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_rgba_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_rgba_16.png",
|
|
FilterStrategy::PAETH,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_rgba_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_rgba_16.png",
|
|
FilterStrategy::MinSum,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
RGBA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_rgba_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_rgba_8.png",
|
|
FilterStrategy::NONE,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_rgba_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_rgba_8.png",
|
|
FilterStrategy::SUB,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_rgba_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_rgba_8.png",
|
|
FilterStrategy::UP,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_rgba_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_rgba_8.png",
|
|
FilterStrategy::AVERAGE,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_rgba_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_rgba_8.png",
|
|
FilterStrategy::PAETH,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_rgba_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_rgba_8.png",
|
|
FilterStrategy::MinSum,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
RGBA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_rgb_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_rgb_16.png",
|
|
FilterStrategy::NONE,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_rgb_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_rgb_16.png",
|
|
FilterStrategy::SUB,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_rgb_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_rgb_16.png",
|
|
FilterStrategy::UP,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_rgb_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_rgb_16.png",
|
|
FilterStrategy::AVERAGE,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_rgb_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_rgb_16.png",
|
|
FilterStrategy::PAETH,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_rgb_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_rgb_16.png",
|
|
FilterStrategy::MinSum,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
RGB,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_rgb_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_rgb_8.png",
|
|
FilterStrategy::NONE,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_rgb_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_rgb_8.png",
|
|
FilterStrategy::SUB,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_rgb_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_rgb_8.png",
|
|
FilterStrategy::UP,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_rgb_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_rgb_8.png",
|
|
FilterStrategy::AVERAGE,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_rgb_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_rgb_8.png",
|
|
FilterStrategy::PAETH,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_rgb_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_rgb_8.png",
|
|
FilterStrategy::MinSum,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
RGB,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_grayscale_alpha_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_grayscale_alpha_16.png",
|
|
FilterStrategy::NONE,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_grayscale_alpha_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_grayscale_alpha_16.png",
|
|
FilterStrategy::SUB,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_grayscale_alpha_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_grayscale_alpha_16.png",
|
|
FilterStrategy::UP,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_grayscale_alpha_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_grayscale_alpha_16.png",
|
|
FilterStrategy::AVERAGE,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_grayscale_alpha_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_grayscale_alpha_16.png",
|
|
FilterStrategy::PAETH,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_grayscale_alpha_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_grayscale_alpha_16.png",
|
|
FilterStrategy::MinSum,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_grayscale_alpha_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_grayscale_alpha_8.png",
|
|
FilterStrategy::NONE,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_grayscale_alpha_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_grayscale_alpha_8.png",
|
|
FilterStrategy::SUB,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_grayscale_alpha_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_grayscale_alpha_8.png",
|
|
FilterStrategy::UP,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_grayscale_alpha_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_grayscale_alpha_8.png",
|
|
FilterStrategy::AVERAGE,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_grayscale_alpha_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_grayscale_alpha_8.png",
|
|
FilterStrategy::PAETH,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_grayscale_alpha_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_grayscale_alpha_8.png",
|
|
FilterStrategy::MinSum,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
GRAYSCALE_ALPHA,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_grayscale_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_grayscale_16.png",
|
|
FilterStrategy::NONE,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_grayscale_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_grayscale_16.png",
|
|
FilterStrategy::SUB,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_grayscale_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_grayscale_16.png",
|
|
FilterStrategy::UP,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_grayscale_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_grayscale_16.png",
|
|
FilterStrategy::AVERAGE,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_grayscale_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_grayscale_16.png",
|
|
FilterStrategy::PAETH,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_grayscale_16() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_grayscale_16.png",
|
|
FilterStrategy::MinSum,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
GRAYSCALE,
|
|
BitDepth::Sixteen,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_grayscale_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_grayscale_8.png",
|
|
FilterStrategy::NONE,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_grayscale_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_grayscale_8.png",
|
|
FilterStrategy::SUB,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_grayscale_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_grayscale_8.png",
|
|
FilterStrategy::UP,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_grayscale_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_grayscale_8.png",
|
|
FilterStrategy::AVERAGE,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_grayscale_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_grayscale_8.png",
|
|
FilterStrategy::PAETH,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_grayscale_8() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_grayscale_8.png",
|
|
FilterStrategy::MinSum,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
GRAYSCALE,
|
|
BitDepth::Eight,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_palette_4() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_palette_4.png",
|
|
FilterStrategy::NONE,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_palette_4() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_palette_4.png",
|
|
FilterStrategy::SUB,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_palette_4() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_palette_4.png",
|
|
FilterStrategy::UP,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_palette_4() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_palette_4.png",
|
|
FilterStrategy::AVERAGE,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_palette_4() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_palette_4.png",
|
|
FilterStrategy::PAETH,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_palette_4() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_palette_4.png",
|
|
FilterStrategy::MinSum,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
INDEXED,
|
|
BitDepth::Four,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_palette_2() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_palette_2.png",
|
|
FilterStrategy::NONE,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_palette_2() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_palette_2.png",
|
|
FilterStrategy::SUB,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_palette_2() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_palette_2.png",
|
|
FilterStrategy::UP,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_palette_2() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_palette_2.png",
|
|
FilterStrategy::AVERAGE,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_palette_2() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_palette_2.png",
|
|
FilterStrategy::PAETH,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_palette_2() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_palette_2.png",
|
|
FilterStrategy::MinSum,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
INDEXED,
|
|
BitDepth::Two,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_0_for_palette_1() {
|
|
test_it_converts(
|
|
"tests/files/filter_0_for_palette_1.png",
|
|
FilterStrategy::NONE,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_1_for_palette_1() {
|
|
test_it_converts(
|
|
"tests/files/filter_1_for_palette_1.png",
|
|
FilterStrategy::SUB,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_2_for_palette_1() {
|
|
test_it_converts(
|
|
"tests/files/filter_2_for_palette_1.png",
|
|
FilterStrategy::UP,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_3_for_palette_1() {
|
|
test_it_converts(
|
|
"tests/files/filter_3_for_palette_1.png",
|
|
FilterStrategy::AVERAGE,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_4_for_palette_1() {
|
|
test_it_converts(
|
|
"tests/files/filter_4_for_palette_1.png",
|
|
FilterStrategy::PAETH,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn filter_5_for_palette_1() {
|
|
test_it_converts(
|
|
"tests/files/filter_5_for_palette_1.png",
|
|
FilterStrategy::MinSum,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
INDEXED,
|
|
BitDepth::One,
|
|
);
|
|
}
|