Save_GIF(): fix update of nb_bits after writing last code
fixes http://pulkomandy.tk/projects/GrafX2/ticket/125
This commit is contained in:
parent
a0b60f2e49
commit
2680ee40a0
@ -5313,10 +5313,20 @@ void Save_GIF(T_IO_Context * context)
|
|||||||
// Write the last code (before EOF)
|
// Write the last code (before EOF)
|
||||||
GIF_set_code(GIF_file, &GIF, GIF_buffer, current_string);
|
GIF_set_code(GIF_file, &GIF, GIF_buffer, current_string);
|
||||||
|
|
||||||
// We think we don't need to update GIF.nb_bits here because
|
// we need to update alphabet_free / GIF.nb_bits here because
|
||||||
// we are writing a string already in the table,
|
// the decoder will update them after each code,
|
||||||
// but we may be wrong as the table grow for each code...
|
// so in very rare cases there might be a problem if we
|
||||||
// So in very rare cases there might be a problem.
|
// don't do it.
|
||||||
|
// see http://pulkomandy.tk/projects/GrafX2/ticket/125
|
||||||
|
if(alphabet_free < 4096)
|
||||||
|
{
|
||||||
|
alphabet_free++;
|
||||||
|
if ((alphabet_free > alphabet_max+1) && (GIF.nb_bits < 12))
|
||||||
|
{
|
||||||
|
GIF.nb_bits++;
|
||||||
|
alphabet_max = (1 << GIF.nb_bits) - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GIF_set_code(GIF_file, &GIF, GIF_buffer, eof); // 257 for 8bpp // Code de End d'image
|
GIF_set_code(GIF_file, &GIF, GIF_buffer, eof); // 257 for 8bpp // Code de End d'image
|
||||||
if (GIF.remainder_bits!=0)
|
if (GIF.remainder_bits!=0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user