Support ZSTD compression method for reading (#256)
This commit is contained in:
1 parent
ff52aea06e
commit
a19cf37587
6 files changed
+20
-1
No files matched your search
@@ -20,10 +20,14 @@ exclude = ["tests/images/*", "tests/fuzz_images/*"]
|
||||
weezl = "0.1.0"
|
||||
jpeg = { package = "jpeg-decoder", version = "0.3.0", default-features = false }
|
||||
flate2 = "1.0.20"
|
||||
zstd = { version = "0.13", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3.1"
|
||||
|
||||
[features]
|
||||
zstd = ["dep:zstd"]
|
||||
|
||||
[[bench]]
|
||||
name = "lzw"
|
||||
harness = false
|
||||
@@ -36,6 +36,7 @@ This table lists photometric interpretations and sample formats which are suppor
|
||||
| Deflate | ✓ | ✓ |
|
||||
| PackBits | ✓ | ✓ |
|
||||
| JPEG | ✓ | not yet |
|
||||
| ZSTD | ✓ | not yet |
|
||||
|
||||
|
||||
## Not yet supported
|
||||
|
||||
@@ -378,7 +378,11 @@ impl Image {
|
||||
CompressionMethod::None => Box::new(reader),
|
||||
CompressionMethod::LZW => {
|
||||
Box::new(LZWReader::new(reader, usize::try_from(compressed_length)?))
|
||||
}
|
||||
},
|
||||
#[cfg(feature = "zstd")]
|
||||
CompressionMethod::ZSTD => {
|
||||
Box::new(zstd::Decoder::new(reader)?)
|
||||
},
|
||||
CompressionMethod::PackBits => Box::new(PackBitsReader::new(reader, compressed_length)),
|
||||
CompressionMethod::Deflate | CompressionMethod::OldDeflate => {
|
||||
Box::new(DeflateReader::new(reader))
|
||||
|
||||
@@ -184,6 +184,9 @@ pub enum CompressionMethod(u16) unknown("A custom compression method") {
|
||||
Deflate = 8,
|
||||
OldDeflate = 0x80B2,
|
||||
PackBits = 0x8005,
|
||||
|
||||
// Self-assigned by libtiff
|
||||
ZSTD = 0xC350,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -515,3 +515,10 @@ fn test_predictor_3_rgb_f32() {
|
||||
fn test_predictor_3_gray_f32() {
|
||||
test_image_sum_f32("predictor-3-gray-f32.tif", ColorType::Gray(32), 20008.275);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "zstd")]
|
||||
fn test_zstd_compression() {
|
||||
// gdal_translate -co COMPRESS=ZSTD -co ZSTD_LEVEL=20 int16.tif int16_zstd.tif
|
||||
test_image_sum_i16("int16_zstd.tif", ColorType::Gray(16), 354396);
|
||||
}
|
||||
Binary file not shown.
Reference in new issue
Block a user