From 678a6a2da465b519c43af91bc10582e4190d7d33 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Sat, 17 Jan 2015 20:03:06 +0530 Subject: [PATCH] A few small fixes. Effect same compression algo for Jpeg and PackJPG output. Fix compiler warning in PackPNM. Allow unknown type (0) to be specified for Dispack output (for analyzer). --- archive/pc_arc_filter.c | 7 +++---- archive/pc_archive.c | 9 ++++++--- filters/packpnm/packpnm.cpp | 9 +++++++-- utils/utils.c | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/archive/pc_arc_filter.c b/archive/pc_arc_filter.c index bc4b859..82889e3 100644 --- a/archive/pc_arc_filter.c +++ b/archive/pc_arc_filter.c @@ -81,7 +81,7 @@ add_filters_by_type(struct type_data *typetab, struct filter_flags *ff) typetab[slot].filter_private = sdat; typetab[slot].filter_func = packjpg_filter; typetab[slot].filter_name = "packJPG"; - typetab[slot].result_type = TYPE_BINARY; + typetab[slot].result_type = -1; slot = TYPE_BMP >> 3; typetab[slot].filter_private = sdat; @@ -115,14 +115,14 @@ add_filters_by_type(struct type_data *typetab, struct filter_flags *ff) if (!sdat) { sdat = (struct scratch_buffer *)malloc(sizeof (struct scratch_buffer)); sdat->in_buff = NULL; - sdat->in_bufflen = 0; + sdat->in_bufflen = -1; } slot = TYPE_WAV >> 3; typetab[slot].filter_private = sdat; typetab[slot].filter_func = wavpack_filter; typetab[slot].filter_name = "WavPack"; - typetab[slot].result_type = 0; + typetab[slot].result_type = -1; } #endif } @@ -593,7 +593,6 @@ dispack_filter(struct filter_info *fi, void *filter_private) fi->fout->out = out; fi->fout->out_size = len; fi->fout->hdr_valid = 0; - *(fi->type_ptr) = TYPE_UNKNOWN; return (ARCHIVE_OK); } diff --git a/archive/pc_archive.c b/archive/pc_archive.c index 7bd85d7..d2d698d 100644 --- a/archive/pc_archive.c +++ b/archive/pc_archive.c @@ -1043,8 +1043,9 @@ process_by_filter(int fd, int *typ, struct archive *target_arc, log_msg(LOG_ERR, 0, "Warning: Error invoking filter: %s (skipping)", typetab[(*typ >> 3)].filter_name); } else if (wrtn != FILTER_RETURN_SKIP) { - if (typetab[(*typ >> 3)].result_type != 0) + if (typetab[(*typ >> 3)].result_type > -1) { *typ = typetab[(*typ >> 3)].result_type; + } } return (wrtn); } @@ -1978,6 +1979,7 @@ detect_type_by_data(uchar_t *buf, size_t len) return (TYPE_BINARY); } } + if (buf[1] == 'Z') { // Check for MSDOS/Windows Exe types if (buf[0] == 'L') { @@ -2002,10 +2004,11 @@ detect_type_by_data(uchar_t *buf, size_t len) if (id == 0x010b || id == 0x020b) { off = LE32(U32_P(buf + 0x3c))+4; id = LE16(U16_P(buf + off)); - if (id == 0x8664) + if (id == 0x8664) { return (TYPE_BINARY|TYPE_EXE64); - else + } else { return (TYPE_BINARY|TYPE_EXE32_PE); + } } else { return (TYPE_BINARY); } diff --git a/filters/packpnm/packpnm.cpp b/filters/packpnm/packpnm.cpp index f896b07..23282d1 100644 --- a/filters/packpnm/packpnm.cpp +++ b/filters/packpnm/packpnm.cpp @@ -2288,8 +2288,13 @@ INTERN inline void rgb_process( unsigned int* rgb ) { rgb[c] -= ( rgb[1] >> ( cmask[1]->s - cmask[c]->s ) ); rgb[c] &= cmask[c]->m; } else { - rgb[c] -= rgb[1]; - if ( rgb[c] < 0 ) rgb[c] += pnmax + 1; + int64_t rg; + + rg = rgb[c]; + rg -= rgb[1]; + if (rg < 0) + rg += pnmax + 1; + rgb[c] = rg; } } } diff --git a/utils/utils.c b/utils/utils.c index a5da950..810b99c 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -643,7 +643,7 @@ is_incompressible(int type) int ic = 0; int st = PC_SUBTYPE(type); - ic = (st == TYPE_JPEG) | (st == TYPE_PACKJPG) | (st == TYPE_AUDIO_COMPRESSED); + ic = (st == TYPE_PACKJPG) | (st == TYPE_AUDIO_COMPRESSED); return (ic); }