From dfeea8c19b303755e28a5bdb1a3f7fa036c8f2de Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Fri, 29 Nov 2013 19:47:57 +0530 Subject: [PATCH] Avoid Delta2,LZP for TIFF files. Negatively impacts compression. --- pcompress.c | 7 +++++-- utils/phash/extensions.h | 2 ++ utils/phash/extensions.txt | 2 ++ utils/phash/phash.c | 14 +++++++------- utils/phash/phash.h | 2 +- utils/utils.h | 3 ++- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/pcompress.c b/pcompress.c index 5730be1..f7cb3f1 100644 --- a/pcompress.c +++ b/pcompress.c @@ -237,7 +237,9 @@ preproc_compress(pc_ctx_t *pctx, compress_func_ptr cmp_func, void *src, uint64_t } } - if (pctx->lzp_preprocess && PC_SUBTYPE(btype) != TYPE_BMP) { + if (pctx->lzp_preprocess && + PC_SUBTYPE(btype) != TYPE_BMP && + PC_SUBTYPE(btype) != TYPE_TIFF) { int hashsize; hashsize = lzp_hash_size(level); @@ -254,7 +256,8 @@ preproc_compress(pc_ctx_t *pctx, compress_func_ptr cmp_func, void *src, uint64_t } if (pctx->enable_delta2_encode && props->delta2_span > 0 && - PC_SUBTYPE(btype) != TYPE_DNA_SEQ && PC_SUBTYPE(btype) != TYPE_BMP) { + PC_SUBTYPE(btype) != TYPE_DNA_SEQ && PC_SUBTYPE(btype) != TYPE_BMP && + PC_SUBTYPE(btype) != TYPE_TIFF) { _dstlen = fromlen; result = delta2_encode((uchar_t *)from, fromlen, to, &_dstlen, props->delta2_span); diff --git a/utils/phash/extensions.h b/utils/phash/extensions.h index 7174e59..4aac8e2 100644 --- a/utils/phash/extensions.h +++ b/utils/phash/extensions.h @@ -89,6 +89,8 @@ struct ext_entry { {"mom" , TYPE_TEXT, 3}, {"tmac" , TYPE_TEXT, 4}, {"pdf" , TYPE_BINARY, 3}, + {"tif" , TYPE_BINARY|TYPE_TIFF, 3}, + {"tiff" , TYPE_BINARY|TYPE_TIFF, 4}, {"jpg" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_JPEG, 3}, {"jpeg" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_JPEG, 4}, {"mjpeg" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_MJPEG, 5}, diff --git a/utils/phash/extensions.txt b/utils/phash/extensions.txt index 32a86a2..5a3642a 100644 --- a/utils/phash/extensions.txt +++ b/utils/phash/extensions.txt @@ -79,6 +79,8 @@ upp,TYPE_TEXT mom,TYPE_TEXT tmac,TYPE_TEXT pdf,TYPE_BINARY +tif,TYPE_BINARY|TYPE_TIFF +tiff,TYPE_BINARY|TYPE_TIFF jpg,TYPE_BINARY|TYPE_COMPRESSED|TYPE_JPEG jpeg,TYPE_BINARY|TYPE_COMPRESSED|TYPE_JPEG mjpeg,TYPE_BINARY|TYPE_COMPRESSED|TYPE_MJPEG diff --git a/utils/phash/phash.c b/utils/phash/phash.c index 742254e..bea3bcc 100644 --- a/utils/phash/phash.c +++ b/utils/phash/phash.c @@ -12,14 +12,14 @@ /* small adjustments to _a_ to make values distinct */ ub1 tab[] = { -125,0,0,87,7,113,82,120,113,0,0,113,0,0,113,125, -0,0,7,113,0,113,0,0,0,7,0,131,0,85,0,22, +125,0,0,82,125,113,82,87,113,0,0,113,0,0,113,125, +0,0,7,113,0,113,0,0,0,125,0,131,0,85,125,22, 0,113,0,0,85,0,0,113,0,113,125,113,0,7,22,0, -82,0,0,113,125,125,0,0,0,0,0,113,22,0,0,125, -0,87,0,0,113,0,125,183,82,0,124,88,40,125,0,0, -124,0,168,125,0,125,0,40,0,82,125,113,113,125,116,0, -0,0,113,85,0,88,0,0,42,27,0,0,0,40,183,61, -0,0,0,0,0,111,0,0,87,125,0,0,127,91,0,0, +82,0,0,113,125,125,0,0,0,0,113,7,74,0,0,125, +0,87,0,0,113,0,125,183,82,0,124,40,40,183,0,0, +124,0,55,85,0,125,0,32,0,82,125,74,0,125,0,0, +0,0,113,113,0,40,0,0,42,27,0,0,0,40,183,4, +0,0,0,0,0,24,0,0,114,124,0,0,103,200,0,0, }; /* The hash function */ diff --git a/utils/phash/phash.h b/utils/phash/phash.h index 7d4bc16..e422e47 100644 --- a/utils/phash/phash.h +++ b/utils/phash/phash.h @@ -8,7 +8,7 @@ extern ub1 tab[]; #define PHASHLEN 0x80 /* length of hash mapping table */ -#define PHASHNKEYS 132 /* How many keys were hashed */ +#define PHASHNKEYS 134 /* How many keys were hashed */ #define PHASHRANGE 256 /* Range any input might map to */ #define PHASHSALT 0x9e3779b9 /* internal, initialize normal hash */ diff --git a/utils/utils.h b/utils/utils.h index 9726163..ca5c7b7 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -271,7 +271,8 @@ typedef enum { TYPE_MJPEG = 176, TYPE_AUDIO_COMPRESSED = 184, TYPE_EXE64 = 192, - TYPE_BMP = 200 + TYPE_BMP = 200, + TYPE_TIFF = 208 } data_type_t; /*