c - How can I modify zlib MIN_MATCH value? -


i'm working zlib 1.2.8 source code http://zlib.net/
in code, minimum match value 'min_match' '3' (in zutil.h)

now want modify value 3 4, modified zutil.h

and there code in deflate.c

    /* initialize hash value have input: */     if (s->lookahead + s->insert >= min_match) {         uint str = s->strstart - s->insert;         s->ins_h = s->window[str];         update_hash(s, s->ins_h, s->window[str + 1]); #if min_match != 3         call update_hash() min_match-3 more times #endif         while (s->insert) {             update_hash(s, s->ins_h, s->window[str + min_match-1]); #ifndef fastest             s->prev[str & s->w_mask] = s->head[s->ins_h]; #endif             s->head[s->ins_h] = (pos)str;             str++;             s->insert--;             if (s->lookahead + s->insert < min_match)                 break;         }     } 

and

            s->strstart += s->match_length;             s->match_length = 0;             s->ins_h = s->window[s->strstart];             update_hash(s, s->ins_h, s->window[s->strstart+1]); #if min_match != 3             call update_hash() min_match-3 more times #endif             /* if lookahead < min_match, ins_h garbage, not              * matter since recomputed @ next deflate call.              */ 

so modified code below

    /* initialize hash value have input: */     if (s->lookahead + s->insert >= min_match) {         uint str = s->strstart - s->insert;         s->ins_h = s->window[str];         update_hash(s, s->ins_h, s->window[str + 1]); #if min_match != 3         //call update_hash() min_match-3 more times         update_hash(s, s->ins_h, s->window[str + 1]); #endif         while (s->insert) {             update_hash(s, s->ins_h, s->window[str + min_match-1]); #ifndef fastest             s->prev[str & s->w_mask] = s->head[s->ins_h]; #endif             s->head[s->ins_h] = (pos)str;             str++;             s->insert--;             if (s->lookahead + s->insert < min_match)                 break;         }     } 

and

            s->strstart += s->match_length;             s->match_length = 0;             s->ins_h = s->window[s->strstart];             update_hash(s, s->ins_h, s->window[s->strstart+1]); #if min_match != 3             //call update_hash() min_match-3 more times             update_hash(s, s->ins_h, s->window[s->strstart+1]); #endif             /* if lookahead < min_match, ins_h garbage, not              * matter since recomputed @ next deflate call.              */ 

(i put update_hash() function under 'if min_match != 3' line)

and compile, run 'minigzip' test program canterbury corpus benchmark file

compress works without error, decompress not working 'incorrect data check' error message

how should modify code? have idea?

thanks

the min_match of 3 built code, 1 comment repeating update doesn't represent changes required. have read , understand algorithms used, make fair number of changes, , test them extensively make sure did right.

if you're trying emit literal instead of match of 3, change if (s->match_length >= min_match) if (s->match_length >= 4).


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -