Add safe Rust Zstd decoding option
This commit is contained in:
1 parent
37578add53
commit
d9d4f0a905
3 files changed
+7
-1
No files matched your search
@@ -25,6 +25,7 @@ fax34 = { package = "fax", version = "0.2.6", optional = true }
|
|||||||
flate2 = { version = "1.0.20", optional = true }
|
flate2 = { version = "1.0.20", optional = true }
|
||||||
weezl = { version = "0.1.10", optional = true }
|
weezl = { version = "0.1.10", optional = true }
|
||||||
zstd = { version = "0.13", optional = true }
|
zstd = { version = "0.13", optional = true }
|
||||||
|
ruzstd = { version = "0.8.2", optional = true }
|
||||||
zune-jpeg = { version = "0.5.1", optional = true }
|
zune-jpeg = { version = "0.5.1", optional = true }
|
||||||
image-webp = {version = "0.2.4", optional = true }
|
image-webp = {version = "0.2.4", optional = true }
|
||||||
|
|
||||||
@@ -45,6 +46,9 @@ jpeg = ["dep:zune-jpeg"]
|
|||||||
lzw = ["dep:weezl"]
|
lzw = ["dep:weezl"]
|
||||||
webp = ["dep:image-webp"]
|
webp = ["dep:image-webp"]
|
||||||
zstd = ["dep:zstd"]
|
zstd = ["dep:zstd"]
|
||||||
|
# Fully safe Rust but much slower Zstd decoding.
|
||||||
|
# When both zstd and safe-rust-zstd are enabled, zstd takes precedence.
|
||||||
|
safe-rust-zstd = ["dep:ruzstd"]
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "lzw"
|
name = "lzw"
|
||||||
|
|||||||
@@ -659,6 +659,8 @@ impl Image {
|
|||||||
)),
|
)),
|
||||||
#[cfg(feature = "zstd")]
|
#[cfg(feature = "zstd")]
|
||||||
CompressionMethod::ZSTD => Box::new(zstd::Decoder::new(reader)?),
|
CompressionMethod::ZSTD => Box::new(zstd::Decoder::new(reader)?),
|
||||||
|
#[cfg(all(not(feature = "zstd"), feature = "safe-rust-zstd"))]
|
||||||
|
CompressionMethod::ZSTD => Box::new(ruzstd::decoding::StreamingDecoder::new(reader).unwrap()), // TODO: Error handling
|
||||||
CompressionMethod::PackBits => Box::new(PackBitsReader::new(reader, compressed_length)),
|
CompressionMethod::PackBits => Box::new(PackBitsReader::new(reader, compressed_length)),
|
||||||
#[cfg(feature = "deflate")]
|
#[cfg(feature = "deflate")]
|
||||||
CompressionMethod::Deflate | CompressionMethod::OldDeflate => {
|
CompressionMethod::Deflate | CompressionMethod::OldDeflate => {
|
||||||
|
|||||||
@@ -569,7 +569,7 @@ fn test_predictor_3_gray_f32() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "zstd")]
|
#[cfg(any(feature = "zstd", feature = "safe-rust-zstd"))]
|
||||||
fn test_zstd_compression() {
|
fn test_zstd_compression() {
|
||||||
// gdal_translate -co COMPRESS=ZSTD -co ZSTD_LEVEL=20 int16.tif int16_zstd.tif
|
// 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);
|
test_image_sum_i16("int16_zstd.tif", ColorType::Gray(16), 354396);
|
||||||
|
|||||||
Reference in new issue
Block a user