Skip to content

Commit

Permalink
Fix GIF compression when a clear code would be emitted right after a …
Browse files Browse the repository at this point in the history
…code size increase
  • Loading branch information
aaaaaa123456789 committed Jan 21, 2022
1 parent 3e6fd55 commit dcb401b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/gifcompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ unsigned char * compress_GIF_data (struct context * context, const unsigned char
else if (shortchains)
shortchains --;
chain = 1;
if (shortchains > 8) {
if (max_code > 4095) max_code = 4095;
if (max_code == (1 << current_codesize)) current_codesize ++;
if (shortchains > (codesize + 8)) {
codeword |= 1 << (bits + codesize);
bits += current_codesize;
max_code = (1 << codesize) + 1;
current_codesize = codesize + 1;
shortchains = 0;
} else {
if (max_code > 4095) max_code = 4095;
if (max_code == (1 << current_codesize)) current_codesize ++;
}
}
while (bits >= 8) {
Expand Down

0 comments on commit dcb401b

Please sign in to comment.