summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2017-12-21 13:32:02 +0100
committerEven Rouault <even.rouault@spatialys.com>2017-12-21 13:32:02 +0100
commit62b9df5d2af68262fa6fcfb66086bf128f7d67c3 (patch)
tree92e37acfbaad84520c6b89e9479653820511d3ea /tools
parent5848777bd7e4f465681a7c4d0acf96a1dbd5b75c (diff)
downloadlibtiff-git-62b9df5d2af68262fa6fcfb66086bf128f7d67c3.tar.gz
Add ZSTD compression codec
From https://github.com/facebook/zstd "Zstandard, or zstd as short version, is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios. It's backed by a very fast entropy stage, provided by Huff0 and FSE library." We require libzstd >= 1.0.0 so as to be able to use streaming compression and decompression methods. The default compression level we have selected is 9 (range goes from 1 to 22), which experimentally offers equivalent or better compression ratio than the default deflate/ZIP level of 6, and much faster compression. For example on a 6600x4400 16bit image, tiffcp -c zip runs in 10.7 seconds, while tiffcp -c zstd runs in 5.3 seconds. Decompression time for zip is 840 ms, and for zstd 650 ms. File size is 42735936 for zip, and 42586822 for zstd. Similar findings on other images. On a 25894x16701 16bit image, Compression time Decompression time File size ZSTD 35 s 3.2 s 399 700 498 ZIP/Deflate 1m 20 s 4.9 s 419 622 336
Diffstat (limited to 'tools')
-rw-r--r--tools/tiffcp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
index 08df56d5..482f5f4f 100644
--- a/tools/tiffcp.c
+++ b/tools/tiffcp.c
@@ -389,6 +389,9 @@ processCompressOptions(char* opt)
} else if (strneq(opt, "lzma", 4)) {
processZIPOptions(opt);
defcompression = COMPRESSION_LZMA;
+ } else if (strneq(opt, "zstd", 4)) {
+ processZIPOptions(opt);
+ defcompression = COMPRESSION_ZSTD;
} else if (strneq(opt, "jbig", 4)) {
defcompression = COMPRESSION_JBIG;
} else if (strneq(opt, "sgilog", 6)) {
@@ -427,6 +430,7 @@ char* stuff[] = {
" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding",
" -c zip[:opts] compress output with deflate encoding",
" -c lzma[:opts] compress output with LZMA2 encoding",
+" -c zstd[:opts] compress output with ZSTD encoding",
" -c jpeg[:opts] compress output with JPEG encoding",
" -c jbig compress output with ISO JBIG encoding",
" -c packbits compress output with packbits encoding",
@@ -446,7 +450,7 @@ char* stuff[] = {
" r output color image as RGB rather than YCbCr",
"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality",
"",
-"LZW, Deflate (ZIP) and LZMA2 options:",
+"LZW, Deflate (ZIP), LZMA2 and ZSTD options:",
" # set predictor value",
" p# set compression level (preset)",
"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing,",
@@ -731,6 +735,7 @@ tiffcp(TIFF* in, TIFF* out)
case COMPRESSION_ADOBE_DEFLATE:
case COMPRESSION_DEFLATE:
case COMPRESSION_LZMA:
+ case COMPRESSION_ZSTD:
if (predictor != (uint16)-1)
TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
else
@@ -741,6 +746,8 @@ tiffcp(TIFF* in, TIFF* out)
TIFFSetField(out, TIFFTAG_ZIPQUALITY, preset);
else if (compression == COMPRESSION_LZMA)
TIFFSetField(out, TIFFTAG_LZMAPRESET, preset);
+ else if (compression == COMPRESSION_ZSTD)
+ TIFFSetField(out, TIFFTAG_ZSTD_LEVEL, preset);
}
break;
case COMPRESSION_CCITTFAX3: