From 5e484f06943575d4682a84211e4f28e7c644920c Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Wed, 4 Dec 2013 20:07:52 +0530 Subject: [PATCH] Use libbsc for AVI and MP4 files. --- adaptive_compress.c | 3 ++- pcompress.c | 12 ++++++------ utils/phash/extensions.h | 5 +++-- utils/phash/extensions.txt | 5 +++-- utils/phash/phash.c | 14 +++++++------- utils/phash/phash.h | 2 +- utils/utils.h | 4 ++-- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/adaptive_compress.c b/adaptive_compress.c index e72806a..86f8c20 100644 --- a/adaptive_compress.c +++ b/adaptive_compress.c @@ -215,7 +215,8 @@ is_bsc_type(int btype) { int stype = PC_SUBTYPE(btype); return ((stype == TYPE_MARKUP) | (stype == TYPE_BMP) | (stype == TYPE_DNA_SEQ) | - (stype == TYPE_TIFF) | (stype == TYPE_MP4) | (stype == TYPE_FLAC)); + (stype == TYPE_TIFF) | (stype == TYPE_MP4) | (stype == TYPE_FLAC) | + (stype == TYPE_AVI)); } int diff --git a/pcompress.c b/pcompress.c index 81e2fc2..724d661 100644 --- a/pcompress.c +++ b/pcompress.c @@ -212,6 +212,7 @@ preproc_compress(pc_ctx_t *pctx, compress_func_ptr cmp_func, void *src, uint64_t int64_t result; uint64_t _dstlen, fromlen; uchar_t *from, *to; + int stype; DEBUG_STAT_EN(double strt, en); _dstlen = *dstlen; @@ -219,12 +220,13 @@ preproc_compress(pc_ctx_t *pctx, compress_func_ptr cmp_func, void *src, uint64_t to = dst; fromlen = srclen; result = 0; + stype = PC_SUBTYPE(btype); /* * If Dispack is enabled it has to be done first since Dispack analyses the * x86 instruction stream in the raw data. */ - if (pctx->dispack_preprocess && PC_SUBTYPE(btype) == TYPE_EXE32) { + if (pctx->dispack_preprocess && stype == TYPE_EXE32) { _dstlen = fromlen; result = dispack_encode((uchar_t *)from, fromlen, to, &_dstlen); if (result != -1) { @@ -237,9 +239,7 @@ preproc_compress(pc_ctx_t *pctx, compress_func_ptr cmp_func, void *src, uint64_t } } - if (pctx->lzp_preprocess && - PC_SUBTYPE(btype) != TYPE_BMP && - PC_SUBTYPE(btype) != TYPE_TIFF) { + if (pctx->lzp_preprocess && stype != TYPE_BMP && stype != TYPE_TIFF) { int hashsize; hashsize = lzp_hash_size(level); @@ -256,8 +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_TIFF) { + stype != TYPE_DNA_SEQ && stype != TYPE_BMP && + stype != TYPE_TIFF && stype != TYPE_MP4) { _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 12d5c39..f16aab1 100644 --- a/utils/phash/extensions.h +++ b/utils/phash/extensions.h @@ -106,6 +106,7 @@ struct ext_entry { {"ofs" , TYPE_BINARY|TYPE_COMPRESSED, 3}, {"ofr" , TYPE_BINARY|TYPE_COMPRESSED, 3}, {"flac" , TYPE_BINARY|TYPE_FLAC, 4}, + {"avi" , TYPE_BINARY|TYPE_AVI, 3}, {"pac" , TYPE_BINARY|TYPE_COMPRESSED, 3}, {"gif" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZW, 3}, {"jp2" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_JPEG, 3}, @@ -125,7 +126,7 @@ struct ext_entry { {"lzo" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZO, 3}, {"dmg" , TYPE_BINARY, 3}, {"7z" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZMA, 2}, - {"uha" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_UHARC, 3}, + {"uha" , TYPE_BINARY|TYPE_COMPRESSED, 3}, {"alz" , TYPE_BINARY|TYPE_COMPRESSED, 3}, {"ace" , TYPE_BINARY|TYPE_COMPRESSED, 3}, {"rar" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_RAR, 3}, @@ -139,7 +140,7 @@ struct ext_entry { {"pyc" , TYPE_BINARY, 3}, {"wav" , TYPE_BINARY, 3}, {"tta" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_AUDIO_COMPRESSED, 3}, - {"wv" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_AUDIO_COMPRESSED, 2}, + {"wv" , TYPE_BINARY|TYPE_COMPRESSED, 2}, {"swf" , TYPE_BINARY, 3}, {"SVGZ" , TYPE_BINARY, 4}, {"ODT" , TYPE_BINARY, 3}, diff --git a/utils/phash/extensions.txt b/utils/phash/extensions.txt index 884ac56..0b6c62b 100644 --- a/utils/phash/extensions.txt +++ b/utils/phash/extensions.txt @@ -96,6 +96,7 @@ m4p,TYPE_BINARY|TYPE_COMPRESSED ofs,TYPE_BINARY|TYPE_COMPRESSED ofr,TYPE_BINARY|TYPE_COMPRESSED flac,TYPE_BINARY|TYPE_FLAC +avi,TYPE_BINARY|TYPE_AVI pac,TYPE_BINARY|TYPE_COMPRESSED gif,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZW jp2,TYPE_BINARY|TYPE_COMPRESSED|TYPE_JPEG @@ -115,7 +116,7 @@ lzma,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZMA lzo,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZO dmg,TYPE_BINARY 7z,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZMA -uha,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_UHARC +uha,TYPE_BINARY|TYPE_COMPRESSED alz,TYPE_BINARY|TYPE_COMPRESSED ace,TYPE_BINARY|TYPE_COMPRESSED rar,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_RAR @@ -129,7 +130,7 @@ pyo,TYPE_BINARY pyc,TYPE_BINARY wav,TYPE_BINARY tta,TYPE_BINARY|TYPE_COMPRESSED|TYPE_AUDIO_COMPRESSED -wv,TYPE_BINARY|TYPE_COMPRESSED|TYPE_AUDIO_COMPRESSED +wv,TYPE_BINARY|TYPE_COMPRESSED swf,TYPE_BINARY SVGZ,TYPE_BINARY,TYPE_COMPRESSED|TYPE_COMPRESSED_GZ ODT,TYPE_BINARY,TYPE_COMPRESSED|TYPE_COMPRESSED_ZIP diff --git a/utils/phash/phash.c b/utils/phash/phash.c index 57453cd..1dd8ad6 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,82,125,113,82,87,113,0,0,7,0,0,113,125, +125,0,0,220,125,113,82,82,113,0,0,7,0,0,113,125, 0,0,7,87,0,113,0,0,0,125,0,131,0,7,125,22, -0,0,0,0,85,0,0,0,0,113,85,113,0,7,22,0, -82,0,124,113,125,125,0,0,0,0,113,7,85,0,0,85, -0,82,0,0,113,0,125,183,82,55,124,88,58,183,0,0, -124,0,113,85,0,125,0,116,0,82,125,74,0,125,0,32, -0,0,113,124,0,85,0,0,42,61,0,87,0,40,183,4, -0,0,0,0,0,24,0,0,169,11,0,0,127,200,0,0, +0,0,0,0,85,0,0,0,0,113,87,113,0,7,22,0, +82,0,113,113,125,125,0,0,0,0,113,7,85,0,0,85, +0,82,0,0,113,0,125,183,82,85,124,88,58,183,0,0, +124,0,113,125,0,125,0,116,0,82,125,74,0,125,0,32, +0,113,113,124,0,85,0,0,42,61,0,87,0,40,183,61, +0,0,0,0,0,61,0,0,56,11,0,0,164,200,0,0, }; /* The hash function */ diff --git a/utils/phash/phash.h b/utils/phash/phash.h index 53c0431..74e2f2f 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 135 /* How many keys were hashed */ +#define PHASHNKEYS 136 /* 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 64ba780..dbac54f 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -246,7 +246,7 @@ typedef enum { /* * Sub-types. */ -#define NUM_SUB_TYPES 24 +#define NUM_SUB_TYPES 26 TYPE_EXE32 = 8, TYPE_JPEG = 16, TYPE_MARKUP = 24, @@ -259,7 +259,7 @@ typedef enum { TYPE_COMPRESSED_LH = 80, TYPE_COMPRESSED_LZMA = 88, TYPE_COMPRESSED_LZO = 96, - TYPE_COMPRESSED_UHARC = 104, + TYPE_AVI = 104, TYPE_MP4 = 112, TYPE_FLAC = 120, TYPE_COMPRESSED_RAR = 128,