652c652 < * two codes of non zero frequency. --- > * two codes of non zero frequency. Well, no longer... 654,660c654,662 < while (s->heap_len < 2) { < node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); < tree[node].Freq = 1; < s->depth[node] = 0; < s->opt_len--; if (stree) s->static_len -= stree[node].Len; < /* node is 0 or 1 so it does not have extra bits */ < } --- > // while (s->heap_len < 2) { > // node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); > // tree[node].Freq = 1; > // s->depth[node] = 0; > // s->opt_len--; if (stree) s->static_len -= stree[node].Len; > // /* node is 0 or 1 so it does not have extra bits */ > // } > > if (s->heap_len > 1) { 704a707,730 > } > else if (s->heap_len == 0) { // no code at all, create a dummy zero code > desc->max_code = 0; > tree[0].Len = 0; // gen_bitlen shortcut > tree[0].Code = 0; // gen_codes shortcut probably useless > } > else { // heap_len == 1 only one code, create a single one bit code > const intf *extra = desc->stat_desc->extra_bits; > int base = desc->stat_desc->extra_base; > int xbits; /* extra bits */ > ush f; /* frequency */ > > desc->max_code = max_code; > for (n = 0; n < max_code; n++) { // gen_bitlen shortcut > tree[n].Len = 0; > } > tree[max_code].Len = 1; > xbits = 0; > if (max_code >= base) xbits = extra[max_code-base]; > f = tree[max_code].Freq; > s->opt_len += (ulg)f * (1 + xbits); > if (stree) s->static_len += (ulg)f * (stree[max_code].Len + xbits); > tree[max_code].Code = 0; // gen_codes shortcut, not set earlier since it replaces .Freq > } 959,960c985,986 < opt_lenb = (s->opt_len+3+7)>>3; < static_lenb = (s->static_len+3+7)>>3; --- > opt_lenb = s->opt_len+3; > static_lenb = s->static_len+3; 962,963c988,990 < Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", < opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, --- > Tracev((stderr, "\nopt %lu (%lu bits) stat %lu (%lu bits) stored %lu (%lu bits) lit %u ", > (opt_lenb+7)>>3, opt_lenb, (static_lenb+7)>>3, static_lenb, > (stored_len+4), ((stored_len+4)<<3) + ((s->bi_valid+10) & (ulg)~7L) - s->bi_valid, 970c997 < opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ --- > opt_lenb = static_lenb = (stored_len + 6)<<3; /* force a stored block */ 976c1003 < if (stored_len+4 <= opt_lenb && buf != (char*)0) { --- > if ((((stored_len+4)<<3) + ((s->bi_valid+3+7) & (ulg)~7L) - s->bi_valid) <= opt_lenb && buf != (char*)0) {