Merge pull request #398 from Shnatsel/safe-rust-zstd-2

Add safe Rust zstd decoding backend
This commit is contained in:
Sergey "Shnatsel" Davidoff authored and GitHub committed 2026-07-20 00:33:05 +01:00
commit f3f9ff1244
3 files changed
+7 -1

No files matched your search

+4
View File
@@ -25,6 +25,7 @@ fax34 = { package = "fax", version = "0.2.6", optional = true }
flate2 = { version = "1.0.20", optional = true }
weezl = { version = "0.2.1", optional = true }
zstd = { version = "0.13", optional = true }
zrip-decode = { version = "0.8.2", features = ["paranoid"], optional = true }
zune-jpeg = { version = "0.5.1", optional = true }
image-webp = {version = "0.2.4", optional = true }
@@ -45,6 +46,9 @@ jpeg = ["dep:zune-jpeg"]
lzw = ["dep:weezl"]
webp = ["dep:image-webp"]
zstd = ["dep:zstd"]
# Fully safe Rust but somewhat slower Zstd decoding.
# When both zstd and zstd-safe-rust are enabled, zstd takes precedence.
zstd-safe-rust = ["dep:zrip-decode"]
[[bench]]
name = "lzw"
+2
View File
@@ -720,6 +720,8 @@ impl Image {
)),
#[cfg(feature = "zstd")]
CompressionMethod::ZSTD => Box::new(zstd::Decoder::new(reader)?),
#[cfg(all(not(feature = "zstd"), feature = "zstd-safe-rust"))]
CompressionMethod::ZSTD => Box::new(zrip_decode::streaming::FrameDecoder::new(reader)),
CompressionMethod::PackBits => Box::new(PackBitsReader::new(reader, compressed_length)),
#[cfg(feature = "deflate")]
CompressionMethod::Deflate | CompressionMethod::OldDeflate => {
+1 -1
View File
@@ -827,7 +827,7 @@ fn test_predictor_3_gray_f32() {
}
#[test]
#[cfg(feature = "zstd")]
#[cfg(any(feature = "zstd", feature = "zstd-safe-rust"))]
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);