diff mbox

[FFmpeg-devel] avcodec/lzwenc: Remove padding byte when writing gif

Message ID 20170220204634.bcsr437hlxwikhx7@dev.null
State New
Headers show

Commit Message

Will Storey Feb. 20, 2017, 8:46 p.m. UTC
No longer write a final 0x00 byte when flushing the LZW bitstream. There
is no mention of doing this in GIF89a specification to do this, and
decoders may not expect it.

Adding this byte for padding was added in commit
b4e2e03709996a0836f6a71535d48b50201338eb apparently to resolve an issue
with GIMP. I could not find any background about this issue. Possibly
the GIMP decoder had an issue (it appears to handle gifs without this
byte fine today).

Signed-off-by: William Storey <will@summercat.com>
---
 libavcodec/lzwenc.c             |  2 --
 tests/ref/fate/gifenc-bgr4_byte | 64 ++++++++++++++++++++---------------------
 tests/ref/fate/gifenc-bgr8      | 60 +++++++++++++++++++-------------------
 tests/ref/fate/gifenc-gray      | 56 ++++++++++++++++++------------------
 tests/ref/fate/gifenc-pal8      | 60 +++++++++++++++++++-------------------
 tests/ref/fate/gifenc-rgb4_byte | 64 ++++++++++++++++++++---------------------
 tests/ref/fate/gifenc-rgb8      | 60 +++++++++++++++++++-------------------
 7 files changed, 182 insertions(+), 184 deletions(-)
diff mbox

Patch

diff --git a/libavcodec/lzwenc.c b/libavcodec/lzwenc.c
index 03080ee587..f9021e1ca9 100644
--- a/libavcodec/lzwenc.c
+++ b/libavcodec/lzwenc.c
@@ -263,8 +263,6 @@  int ff_lzw_encode_flush(LZWEncodeState *s,
     if (s->last_code != -1)
         writeCode(s, s->last_code);
     writeCode(s, s->end_code);
-    if (s->mode == FF_LZW_GIF)
-        s->put_bits(&s->pb, 1, 0);
 
     lzw_flush_put_bits(&s->pb);
     s->last_code = -1;
diff --git a/tests/ref/fate/gifenc-bgr4_byte b/tests/ref/fate/gifenc-bgr4_byte
index 3495a8bbed..423572ac82 100644
--- a/tests/ref/fate/gifenc-bgr4_byte
+++ b/tests/ref/fate/gifenc-bgr4_byte
@@ -3,58 +3,58 @@ 
 #codec_id 0: gif
 #dimensions 0: 217x217
 #sar 0: 0/1
-0,          0,          0,        1,      508, 0xa1b80fc0
+0,          0,          0,        1,      507, 0x91080fbf
 0,          1,          1,        1,      213, 0x4f554bd7, S=1,     1024, 0xb6327c81
-0,          2,          2,        1,      131, 0x283b2988, S=1,     1024, 0xae3a7c81
+0,          2,          2,        1,      130, 0xfe2d2987, S=1,     1024, 0xae3a7c81
 0,          3,          3,        1,      384, 0xc4fea72a, S=1,     1024, 0xb6327c81
 0,          4,          4,        1,      381, 0x050ba2b8, S=1,     1024, 0x9e4a7c81
 0,          5,          5,        1,      430, 0x00cfb2ae, S=1,     1024, 0x9e4a7c81
-0,          6,          6,        1,      518, 0xc8e5d827, S=1,     1024, 0x9e4a7c81
+0,          6,          6,        1,      517, 0xefb5d826, S=1,     1024, 0x9e4a7c81
 0,          7,          7,        1,      535, 0x326ce62a, S=1,     1024, 0x9e4a7c81
-0,          8,          8,        1,      438, 0x34d6b7c0, S=1,     1024, 0xb6327c81
+0,          8,          8,        1,      437, 0x7c5db7bf, S=1,     1024, 0xb6327c81
 0,          9,          9,        1,      923, 0x9fb1a37c, S=1,     1024, 0xb6327c81
-0,         10,         10,        1,      694, 0xf20449a5, S=1,     1024, 0xb6327c81
+0,         10,         10,        1,      693, 0xa7b549a4, S=1,     1024, 0xb6327c81
 0,         11,         11,        1,     1194, 0x67cd2ab5, S=1,     1024, 0xb6327c81
 0,         12,         12,        1,     1291, 0x1d23539d, S=1,     1024, 0xb6327c81
 0,         13,         13,        1,     1245, 0x065f32e6, S=1,     1024, 0xb6327c81
 0,         14,         14,        1,     1330, 0x83ec51a4, S=1,     1024, 0xb6327c81
-0,         15,         15,        1,     1276, 0x2acf38dc, S=1,     1024, 0xb6327c81
-0,         16,         16,        1,     1475, 0x4cd197ef, S=1,     1024, 0xb6327c81
-0,         17,         17,        1,     1784, 0xd1e84ae6, S=1,     1024, 0xde0a7c81
+0,         15,         15,        1,     1275, 0xf0f438db, S=1,     1024, 0xb6327c81
+0,         16,         16,        1,     1474, 0xb41c97ee, S=1,     1024, 0xb6327c81
+0,         17,         17,        1,     1783, 0x86164ae5, S=1,     1024, 0xde0a7c81
 0,         18,         18,        1,     1675, 0x092dfa86, S=1,     1024, 0xde0a7c81
 0,         19,         19,        1,     1509, 0x639aaa00, S=1,     1024, 0xde0a7c81
 0,         20,         20,        1,     1705, 0xfd3719d5, S=1,     1024, 0xde0a7c81
 0,         21,         21,        1,     1745, 0x8a761db4, S=1,     1024, 0xde0a7c81
 0,         22,         22,        1,     1642, 0x18830245, S=1,     1024, 0xde0a7c81
-0,         23,         23,        1,     1718, 0x3c8d1ebe, S=1,     1024, 0xde0a7c81
+0,         23,         23,        1,     1717, 0x1d251ebd, S=1,     1024, 0xde0a7c81
 0,         24,         24,        1,     1900, 0x2ea879d1, S=1,     1024, 0xde0a7c81
-0,         25,         25,        1,     1807, 0x02b35230, S=1,     1024, 0xde0a7c81
+0,         25,         25,        1,     1806, 0xb071522f, S=1,     1024, 0xde0a7c81
 0,         26,         26,        1,     1915, 0x22d48344, S=1,     1024, 0xde0a7c81
 0,         27,         27,        1,     2100, 0x55fcd063, S=1,     1024, 0xde0a7c81
 0,         28,         28,        1,     2700, 0x7cc5f08b, S=1,     1024, 0xde0a7c81
 0,         29,         29,        1,     2673, 0xb997a80d, S=1,     1024, 0xde0a7c81
-0,         30,         30,        1,     2895, 0xab69484d, S=1,     1024, 0xde0a7c81
+0,         30,         30,        1,     2894, 0x62d9484c, S=1,     1024, 0xde0a7c81
 0,         31,         31,        1,     3257, 0xf753cf24, S=1,     1024, 0xde0a7c81
 0,         32,         32,        1,     3179, 0x34f2c13b, S=1,     1024, 0xde0a7c81
 0,         33,         33,        1,     3296, 0x7c06e72f, S=1,     1024, 0xde0a7c81
-0,         34,         34,        1,     3600, 0x4ca67634, S=1,     1024, 0xde0a7c81
-0,         35,         35,        1,     3699, 0xabe89fe3, S=1,     1024, 0xde0a7c81
+0,         34,         34,        1,     3599, 0xd65f7633, S=1,     1024, 0xde0a7c81
+0,         35,         35,        1,     3698, 0x0b9e9fe2, S=1,     1024, 0xde0a7c81
 0,         36,         36,        1,     3814, 0x1869d3f4, S=1,     1024, 0xde0a7c81
-0,         37,         37,        1,     3627, 0x19bd7da7, S=1,     1024, 0xde0a7c81
+0,         37,         37,        1,     3626, 0x9be87da6, S=1,     1024, 0xde0a7c81
 0,         38,         38,        1,     2950, 0x048a6055, S=1,     1024, 0xde0a7c81
 0,         39,         39,        1,     3086, 0x64ec8fc2, S=1,     1024, 0xde0a7c81
-0,         40,         40,        1,     3094, 0x1a388553, S=1,     1024, 0xde0a7c81
+0,         40,         40,        1,     3093, 0x94cc8552, S=1,     1024, 0xde0a7c81
 0,         41,         41,        1,     3456, 0x01432c82, S=1,     1024, 0xde0a7c81
-0,         42,         42,        1,     4108, 0xf9505c66, S=1,     1024, 0xde0a7c81
-0,         43,         43,        1,     4217, 0x7f985ba4, S=1,     1024, 0xde0a7c81
+0,         42,         42,        1,     4107, 0x9bea5c65, S=1,     1024, 0xde0a7c81
+0,         43,         43,        1,     4216, 0x23875ba3, S=1,     1024, 0xde0a7c81
 0,         44,         44,        1,     3613, 0xd0684d83, S=1,     1024, 0xde0a7c81
-0,         45,         45,        1,     3910, 0x0070e692, S=1,     1024, 0xde0a7c81
-0,         46,         46,        1,     4461, 0x5cc9e33d, S=1,     1024, 0xde0a7c81
-0,         47,         47,        1,     4593, 0x33a32dd1, S=1,     1024, 0xde0a7c81
-0,         48,         48,        1,     4822, 0x59549883, S=1,     1024, 0xde0a7c81
-0,         49,         49,        1,     5398, 0xb7bac31e, S=1,     1024, 0xde0a7c81
+0,         45,         45,        1,     3909, 0x1995e691, S=1,     1024, 0xde0a7c81
+0,         46,         46,        1,     4460, 0x791ce33c, S=1,     1024, 0xde0a7c81
+0,         47,         47,        1,     4592, 0x04ed2dd0, S=1,     1024, 0xde0a7c81
+0,         48,         48,        1,     4821, 0xbff89882, S=1,     1024, 0xde0a7c81
+0,         49,         49,        1,     5397, 0xf483c31d, S=1,     1024, 0xde0a7c81
 0,         50,         50,        1,     5266, 0x21c695aa, S=1,     1024, 0xde0a7c81
-0,         51,         51,        1,     5416, 0xf305e3ed, S=1,     1024, 0xde0a7c81
+0,         51,         51,        1,     5415, 0x0efce3ec, S=1,     1024, 0xde0a7c81
 0,         52,         52,        1,     5519, 0x857d071f, S=1,     1024, 0xde0a7c81
 0,         53,         53,        1,     5701, 0x8f885c9c, S=1,     1024, 0xde0a7c81
 0,         54,         54,        1,     6160, 0x48523e83, S=1,     1024, 0xde0a7c81
@@ -73,7 +73,7 @@ 
 0,         67,         67,        1,     7556, 0x89c1a712, S=1,     1024, 0xde0a7c81
 0,         68,         68,        1,     7413, 0x553970a4, S=1,     1024, 0xde0a7c81
 0,         69,         69,        1,     7476, 0x24d2a761, S=1,     1024, 0xde0a7c81
-0,         70,         70,        1,     7596, 0xf072e431, S=1,     1024, 0xde0a7c81
+0,         70,         70,        1,     7595, 0x0ba1e430, S=1,     1024, 0xde0a7c81
 0,         71,         71,        1,     7756, 0x131205c0, S=1,     1024, 0xde0a7c81
 0,         72,         72,        1,     8015, 0xf4536a7f, S=1,     1024, 0xde0a7c81
 0,         73,         73,        1,     8128, 0xba80be2b, S=1,     1024, 0xde0a7c81
@@ -105,22 +105,22 @@ 
 0,         99,         99,        1,    11111, 0x34eb4c13, S=1,     1024, 0xde0a7c81
 0,        100,        100,        1,    11194, 0x584f6b73, S=1,     1024, 0xde0a7c81
 0,        101,        101,        1,    11240, 0xc90ba13f, S=1,     1024, 0xde0a7c81
-0,        102,        102,        1,    11483, 0x59c4f3c5, S=1,     1024, 0xde0a7c81
+0,        102,        102,        1,    11482, 0x6521f3c4, S=1,     1024, 0xde0a7c81
 0,        103,        103,        1,    11680, 0xc62c5bc1, S=1,     1024, 0xde0a7c81
 0,        104,        104,        1,    11785, 0xc9bab793, S=1,     1024, 0xde0a7c81
 0,        105,        105,        1,    11436, 0xc9c40809, S=1,     1024, 0xde0a7c81
-0,        106,        106,        1,    11928, 0x4b77c9a7, S=1,     1024, 0xde0a7c81
+0,        106,        106,        1,    11927, 0x8135c9a6, S=1,     1024, 0xde0a7c81
 0,        107,        107,        1,    11932, 0x722abcbe, S=1,     1024, 0xde0a7c81
-0,        108,        108,        1,    12281, 0x0d136f53, S=1,     1024, 0xde0a7c81
+0,        108,        108,        1,    12280, 0x9cc46f52, S=1,     1024, 0xde0a7c81
 0,        109,        109,        1,    12334, 0x04a47f78, S=1,     1024, 0xde0a7c81
 0,        110,        110,        1,    12452, 0xa02db188, S=1,     1024, 0xde0a7c81
 0,        111,        111,        1,    12695, 0x1a813b2e, S=1,     1024, 0xde0a7c81
-0,        112,        112,        1,    12668, 0x81b24f79, S=1,     1024, 0xde0a7c81
+0,        112,        112,        1,    12667, 0x31c94f78, S=1,     1024, 0xde0a7c81
 0,        113,        113,        1,    12957, 0x4da59f8c, S=1,     1024, 0xde0a7c81
-0,        114,        114,        1,    13054, 0x7abedf5a, S=1,     1024, 0xde0a7c81
+0,        114,        114,        1,    13053, 0x9a63df59, S=1,     1024, 0xde0a7c81
 0,        115,        115,        1,    13147, 0x138f2bbd, S=1,     1024, 0xde0a7c81
 0,        116,        116,        1,    13171, 0x43c1195f, S=1,     1024, 0xde0a7c81
-0,        117,        117,        1,    13198, 0x2c8d58d4, S=1,     1024, 0xde0a7c81
+0,        117,        117,        1,    13197, 0xd32858d3, S=1,     1024, 0xde0a7c81
 0,        118,        118,        1,    13211, 0x12c36193, S=1,     1024, 0xde0a7c81
 0,        119,        119,        1,    13210, 0xfe496107, S=1,     1024, 0xde0a7c81
 0,        120,        120,        1,    13467, 0x4d8ea128, S=1,     1024, 0xde0a7c81
@@ -151,8 +151,8 @@ 
 0,        145,        145,        1,    17149, 0x4074ca41, S=1,     1024, 0xde0a7c81
 0,        146,        146,        1,    17172, 0xf749b49f, S=1,     1024, 0xde0a7c81
 0,        147,        147,        1,    17315, 0x2abea8a0, S=1,     1024, 0xde0a7c81
-0,        148,        148,        1,    17397, 0x14f71122, S=1,     1024, 0xde0a7c81
-0,        149,        149,        1,    17431, 0xce49f2d3, S=1,     1024, 0xde0a7c81
+0,        148,        148,        1,    17396, 0x02ec1121, S=1,     1024, 0xde0a7c81
+0,        149,        149,        1,    17430, 0xdb5cf2d2, S=1,     1024, 0xde0a7c81
 0,        150,        150,        1,    17576, 0x7c6552ad, S=1,     1024, 0xde0a7c81
 0,        151,        151,        1,    17764, 0x1d198d60, S=1,     1024, 0xde0a7c81
 0,        152,        152,        1,    17826, 0xe1727f57, S=1,     1024, 0xde0a7c81
diff --git a/tests/ref/fate/gifenc-bgr8 b/tests/ref/fate/gifenc-bgr8
index 0a4e5d48cd..d5e5c7720d 100644
--- a/tests/ref/fate/gifenc-bgr8
+++ b/tests/ref/fate/gifenc-bgr8
@@ -5,10 +5,10 @@ 
 #sar 0: 0/1
 0,          0,          0,        1,      552, 0x271a2dd3
 0,          1,          1,        1,      297, 0x90168a95, S=1,     1024, 0xf351799f
-0,          2,          2,        1,      438, 0x91efce1b, S=1,     1024, 0xf351799f
+0,          2,          2,        1,      437, 0xc31bce1a, S=1,     1024, 0xf351799f
 0,          3,          3,        1,      450, 0x7c2dcfad, S=1,     1024, 0xf351799f
 0,          4,          4,        1,      547, 0xc131fd3b, S=1,     1024, 0xf351799f
-0,          5,          5,        1,      614, 0x68182006, S=1,     1024, 0xf351799f
+0,          5,          5,        1,      613, 0x47b82005, S=1,     1024, 0xf351799f
 0,          6,          6,        1,      642, 0x78bb1f5f, S=1,     1024, 0xf351799f
 0,          7,          7,        1,      660, 0x35c033a2, S=1,     1024, 0xf351799f
 0,          8,          8,        1,      821, 0xaf30790b, S=1,     1024, 0xf351799f
@@ -20,56 +20,56 @@ 
 0,         14,         14,        1,     1720, 0xc95d45ec, S=1,     1024, 0xf351799f
 0,         15,         15,        1,     1910, 0x56cc831e, S=1,     1024, 0xf351799f
 0,         16,         16,        1,     2124, 0x9cc8e130, S=1,     1024, 0xf351799f
-0,         17,         17,        1,     2248, 0x05a325b1, S=1,     1024, 0xf351799f
+0,         17,         17,        1,     2247, 0xdf2725b0, S=1,     1024, 0xf351799f
 0,         18,         18,        1,     2311, 0xdc633703, S=1,     1024, 0xf351799f
 0,         19,         19,        1,     2408, 0x91c26f3e, S=1,     1024, 0xf351799f
 0,         20,         20,        1,     2601, 0x8cf3c157, S=1,     1024, 0xf351799f
-0,         21,         21,        1,     2687, 0x8f6400e6, S=1,     1024, 0xf351799f
+0,         21,         21,        1,     2686, 0x8e0b00e5, S=1,     1024, 0xf351799f
 0,         22,         22,        1,     2784, 0xaa880e55, S=1,     1024, 0xf351799f
 0,         23,         23,        1,     2884, 0x46f546f6, S=1,     1024, 0xf351799f
-0,         24,         24,        1,     2982, 0x807c7ad5, S=1,     1024, 0xf351799f
+0,         24,         24,        1,     2981, 0x050d7ad4, S=1,     1024, 0xf351799f
 0,         25,         25,        1,     3101, 0xbcc89bec, S=1,     1024, 0xf351799f
-0,         26,         26,        1,     3253, 0xd032f3fa, S=1,     1024, 0xf351799f
+0,         26,         26,        1,     3252, 0xdb80f3f9, S=1,     1024, 0xf351799f
 0,         27,         27,        1,     3329, 0xe4d42430, S=1,     1024, 0xf351799f
-0,         28,         28,        1,     3572, 0xf8058aa0, S=1,     1024, 0xf351799f
-0,         29,         29,        1,     3807, 0x3d2af9f3, S=1,     1024, 0xf351799f
-0,         30,         30,        1,     2750, 0x814d1c33, S=1,     1024, 0xf351799f
+0,         28,         28,        1,     3571, 0x6c7d8a9f, S=1,     1024, 0xf351799f
+0,         29,         29,        1,     3806, 0x4255f9f2, S=1,     1024, 0xf351799f
+0,         30,         30,        1,     2749, 0x64681c32, S=1,     1024, 0xf351799f
 0,         31,         31,        1,     4031, 0x3b077006, S=1,     1024, 0xf351799f
 0,         32,         32,        1,     3025, 0x86729c1c, S=1,     1024, 0xf351799f
-0,         33,         33,        1,     4295, 0xf71b0b38, S=1,     1024, 0xf351799f
+0,         33,         33,        1,     4294, 0xeb280b37, S=1,     1024, 0xf351799f
 0,         34,         34,        1,     2044, 0x5adcb93b, S=1,     1024, 0xf351799f
 0,         35,         35,        1,     3212, 0xcf79eeed, S=1,     1024, 0xf351799f
-0,         36,         36,        1,     2292, 0xb4386334, S=1,     1024, 0xf351799f
-0,         37,         37,        1,     3633, 0x0010992f, S=1,     1024, 0xf351799f
+0,         36,         36,        1,     2291, 0x501c6333, S=1,     1024, 0xf351799f
+0,         37,         37,        1,     3632, 0x66ad992e, S=1,     1024, 0xf351799f
 0,         38,         38,        1,     3552, 0x23697490, S=1,     1024, 0xf351799f
-0,         39,         39,        1,     3690, 0x62afdbb8, S=1,     1024, 0xf351799f
+0,         39,         39,        1,     3689, 0x868adbb7, S=1,     1024, 0xf351799f
 0,         40,         40,        1,     1559, 0x5baef54a, S=1,     1024, 0xf351799f
 0,         41,         41,        1,      954, 0xca75ca79, S=1,     1024, 0xf351799f
 0,         42,         42,        1,      273, 0x3687799b, S=1,     1024, 0xf351799f
-0,         43,         43,        1,      930, 0x29f3b0c4, S=1,     1024, 0xf351799f
+0,         43,         43,        1,      929, 0x788ab0c3, S=1,     1024, 0xf351799f
 0,         44,         44,        1,      271, 0x305e8094, S=1,     1024, 0xf351799f
 0,         45,         45,        1,      196, 0xf5ab51ee, S=1,     1024, 0xf351799f
 0,         46,         46,        1,     4299, 0x67ec0d55, S=1,     1024, 0xf351799f
-0,         47,         47,        1,     4895, 0xb394406c, S=1,     1024, 0xf351799f
-0,         48,         48,        1,     4928, 0x233919d7, S=1,     1024, 0xf351799f
+0,         47,         47,        1,     4894, 0x7315406b, S=1,     1024, 0xf351799f
+0,         48,         48,        1,     4927, 0x092e19d6, S=1,     1024, 0xf351799f
 0,         49,         49,        1,     4941, 0x58a357da, S=1,     1024, 0xf351799f
-0,         50,         50,        1,     4154, 0x21f2ac33, S=1,     1024, 0xf351799f
-0,         51,         51,        1,     4678, 0xab3cc050, S=1,     1024, 0xf351799f
-0,         52,         52,        1,     4741, 0x1974b581, S=1,     1024, 0xf351799f
-0,         53,         53,        1,     4982, 0x891456d5, S=1,     1024, 0xf351799f
+0,         50,         50,        1,     4153, 0x7582ac32, S=1,     1024, 0xf351799f
+0,         51,         51,        1,     4677, 0xeaa3c04f, S=1,     1024, 0xf351799f
+0,         52,         52,        1,     4740, 0x636bb580, S=1,     1024, 0xf351799f
+0,         53,         53,        1,     4981, 0x31d556d4, S=1,     1024, 0xf351799f
 0,         54,         54,        1,     5179, 0x860fc6a1, S=1,     1024, 0xf351799f
 0,         55,         55,        1,     5046, 0xce9183d3, S=1,     1024, 0xf351799f
 0,         56,         56,        1,     5140, 0xa6d7b9af, S=1,     1024, 0xf351799f
-0,         57,         57,        1,     4301, 0x03b6ef3f, S=1,     1024, 0xf351799f
+0,         57,         57,        1,     4300, 0x13a7ef3e, S=1,     1024, 0xf351799f
 0,         58,         58,        1,     5079, 0xa8d59e01, S=1,     1024, 0xf351799f
 0,         59,         59,        1,     5284, 0xea34e3b3, S=1,     1024, 0xf351799f
 0,         60,         60,        1,     5426, 0x556a15cd, S=1,     1024, 0xf351799f
-0,         61,         61,        1,     4645, 0x061e8936, S=1,     1024, 0xf351799f
+0,         61,         61,        1,     4644, 0x7cc08935, S=1,     1024, 0xf351799f
 0,         62,         62,        1,     5263, 0x7536cf7d, S=1,     1024, 0xf351799f
 0,         63,         63,        1,     5221, 0x9fbac3ca, S=1,     1024, 0xf351799f
-0,         64,         64,        1,     5217, 0x02269bd2, S=1,     1024, 0xf351799f
-0,         65,         65,        1,     5395, 0x120fff66, S=1,     1024, 0xf351799f
-0,         66,         66,        1,     5220, 0x77cedcc5, S=1,     1024, 0xf351799f
+0,         64,         64,        1,     5216, 0x65f09bd1, S=1,     1024, 0xf351799f
+0,         65,         65,        1,     5394, 0x1293ff65, S=1,     1024, 0xf351799f
+0,         66,         66,        1,     5219, 0x9aa2dcc4, S=1,     1024, 0xf351799f
 0,         67,         67,        1,     5704, 0xba42dd96, S=1,     1024, 0xf351799f
 0,         68,         68,        1,     5636, 0xcb91a25b, S=1,     1024, 0xf351799f
 0,         69,         69,        1,     5818, 0x8dc0df92, S=1,     1024, 0xf351799f
@@ -87,7 +87,7 @@ 
 0,         81,         81,        1,     8358, 0x027279e8, S=1,     1024, 0xf351799f
 0,         82,         82,        1,     7708, 0x607f8e8b, S=1,     1024, 0xf351799f
 0,         83,         83,        1,     7412, 0x6bb2105f, S=1,     1024, 0xf351799f
-0,         84,         84,        1,     7541, 0xfdc02154, S=1,     1024, 0xf351799f
+0,         84,         84,        1,     7540, 0xdc032153, S=1,     1024, 0xf351799f
 0,         85,         85,        1,     7948, 0x916ecd8b, S=1,     1024, 0xf351799f
 0,         86,         86,        1,     8408, 0x1f97d414, S=1,     1024, 0xf351799f
 0,         87,         87,        1,     8056, 0x9cbf159c, S=1,     1024, 0xf351799f
@@ -97,12 +97,12 @@ 
 0,         91,         91,        1,     7768, 0x25ed7ee7, S=1,     1024, 0xf351799f
 0,         92,         92,        1,     7749, 0x6d8e978e, S=1,     1024, 0xf351799f
 0,         93,         93,        1,     8047, 0xec4b150c, S=1,     1024, 0xf351799f
-0,         94,         94,        1,     7618, 0x88cf30d5, S=1,     1024, 0xf351799f
+0,         94,         94,        1,     7617, 0x574430d4, S=1,     1024, 0xf351799f
 0,         95,         95,        1,     7979, 0x0eb1cf2a, S=1,     1024, 0xf351799f
 0,         96,         96,        1,    12062, 0xb49d9125, S=1,     1024, 0xf351799f
 0,         97,         97,        1,    12317, 0x2d8fd6e9, S=1,     1024, 0xf351799f
 0,         98,         98,        1,    12217, 0x9b3be549, S=1,     1024, 0xf351799f
-0,         99,         99,        1,    11227, 0x067e9118, S=1,     1024, 0xf351799f
+0,         99,         99,        1,    11226, 0x74889117, S=1,     1024, 0xf351799f
 0,        100,        100,        1,    11108, 0x5e5b0afd, S=1,     1024, 0xf351799f
 0,        101,        101,        1,    11366, 0xb38e8d15, S=1,     1024, 0xf351799f
 0,        102,        102,        1,    11896, 0xeb3e35ca, S=1,     1024, 0xf351799f
@@ -139,7 +139,7 @@ 
 0,        133,        133,        1,    17934, 0xb539974b, S=1,     1024, 0xf351799f
 0,        134,        134,        1,    17944, 0x2214ec94, S=1,     1024, 0xf351799f
 0,        135,        135,        1,    18238, 0x70f9ff1d, S=1,     1024, 0xf351799f
-0,        136,        136,        1,    18391, 0x4b149209, S=1,     1024, 0xf351799f
+0,        136,        136,        1,    18390, 0xb8319208, S=1,     1024, 0xf351799f
 0,        137,        137,        1,    18543, 0x45a1c02f, S=1,     1024, 0xf351799f
 0,        138,        138,        1,    18939, 0x2789a88c, S=1,     1024, 0xf351799f
 0,        139,        139,        1,    19145, 0x5daafd7a, S=1,     1024, 0xf351799f
@@ -170,7 +170,7 @@ 
 0,        164,        164,        1,    22460, 0xf9ceb0ac, S=1,     1024, 0xf351799f
 0,        165,        165,        1,    22861, 0xb05f0f84, S=1,     1024, 0xf351799f
 0,        166,        166,        1,    22746, 0x0df23a5c, S=1,     1024, 0xf351799f
-0,        167,        167,        1,    23165, 0xbd7147ad, S=1,     1024, 0xf351799f
+0,        167,        167,        1,    23164, 0x755347ac, S=1,     1024, 0xf351799f
 0,        168,        168,        1,    23273, 0x9781a34f, S=1,     1024, 0xf351799f
 0,        169,        169,        1,    23211, 0x69c7606b, S=1,     1024, 0xf351799f
 0,        170,        170,        1,    23648, 0xdafde037, S=1,     1024, 0xf351799f
diff --git a/tests/ref/fate/gifenc-gray b/tests/ref/fate/gifenc-gray
index 81cdd1888e..432efcb42b 100644
--- a/tests/ref/fate/gifenc-gray
+++ b/tests/ref/fate/gifenc-gray
@@ -3,7 +3,7 @@ 
 #codec_id 0: gif
 #dimensions 0: 217x217
 #sar 0: 0/1
-0,          0,          0,        1,      579, 0x0d0e3ab8
+0,          0,          0,        1,      578, 0xd2103ab7
 0,          1,          1,        1,      150, 0x178b3a8c, S=1,     1024, 0xc2f67c9f
 0,          2,          2,        1,      155, 0x941743f5, S=1,     1024, 0xc2f67c9f
 0,          3,          3,        1,      144, 0x68c73711, S=1,     1024, 0xc2f67c9f
@@ -20,25 +20,25 @@ 
 0,         14,         14,        1,      127, 0x1e78327b, S=1,     1024, 0xc2f67c9f
 0,         15,         15,        1,      119, 0xbafc2c31, S=1,     1024, 0xc2f67c9f
 0,         16,         16,        1,      138, 0x57553638, S=1,     1024, 0xc2f67c9f
-0,         17,         17,        1,      140, 0xf7423adb, S=1,     1024, 0xc2f67c9f
-0,         18,         18,        1,      122, 0x7e592f8b, S=1,     1024, 0xc2f67c9f
+0,         17,         17,        1,      139, 0xbbe73ada, S=1,     1024, 0xc2f67c9f
+0,         18,         18,        1,      121, 0x4e602f8a, S=1,     1024, 0xc2f67c9f
 0,         19,         19,        1,      123, 0xaa7d313c, S=1,     1024, 0xc2f67c9f
-0,         20,         20,        1,      140, 0x4fd63b34, S=1,     1024, 0xc2f67c9f
+0,         20,         20,        1,      139, 0x14223b33, S=1,     1024, 0xc2f67c9f
 0,         21,         21,        1,      123, 0x67753163, S=1,     1024, 0xc2f67c9f
 0,         22,         22,        1,      123, 0x02193147, S=1,     1024, 0xc2f67c9f
 0,         23,         23,        1,      124, 0xa85131e9, S=1,     1024, 0xc2f67c9f
-0,         24,         24,        1,      122, 0xef8731e2, S=1,     1024, 0xc2f67c9f
-0,         25,         25,        1,      122, 0x06d432c9, S=1,     1024, 0xc2f67c9f
+0,         24,         24,        1,      121, 0xbd3731e1, S=1,     1024, 0xc2f67c9f
+0,         25,         25,        1,      121, 0xd38e32c8, S=1,     1024, 0xc2f67c9f
 0,         26,         26,        1,      123, 0xcc8831cd, S=1,     1024, 0xc2f67c9f
 0,         27,         27,        1,      118, 0xa1d33166, S=1,     1024, 0xc2f67c9f
 0,         28,         28,        1,      159, 0xcc8c454c, S=1,     1024, 0xc2f67c9f
-0,         29,         29,        1,      140, 0x8a0231ad, S=1,     1024, 0xc2f67c9f
+0,         29,         29,        1,      139, 0x57d531ac, S=1,     1024, 0xc2f67c9f
 0,         30,         30,        1,      163, 0xe78248d2, S=1,     1024, 0xc2f67c9f
 0,         31,         31,        1,      142, 0x3b293489, S=1,     1024, 0xc2f67c9f
 0,         32,         32,        1,      170, 0x5f504b12, S=1,     1024, 0xc2f67c9f
 0,         33,         33,        1,      146, 0x38a53693, S=1,     1024, 0xc2f67c9f
 0,         34,         34,        1,      132, 0xb18a3499, S=1,     1024, 0xc2f67c9f
-0,         35,         35,        1,      113, 0x55182bda, S=1,     1024, 0xc2f67c9f
+0,         35,         35,        1,      112, 0x28d92bd9, S=1,     1024, 0xc2f67c9f
 0,         36,         36,        1,      132, 0xaced3333, S=1,     1024, 0xc2f67c9f
 0,         37,         37,        1,      120, 0x9ffe2e4f, S=1,     1024, 0xc2f67c9f
 0,         38,         38,        1,      135, 0x6223351e, S=1,     1024, 0xc2f67c9f
@@ -53,25 +53,25 @@ 
 0,         47,         47,        1,      124, 0x0c19343c, S=1,     1024, 0xc2f67c9f
 0,         48,         48,        1,      117, 0x1f032eb1, S=1,     1024, 0xc2f67c9f
 0,         49,         49,        1,      135, 0x31a437e6, S=1,     1024, 0xc2f67c9f
-0,         50,         50,        1,      131, 0x4c1735fe, S=1,     1024, 0xc2f67c9f
-0,         51,         51,        1,      122, 0xb7603463, S=1,     1024, 0xc2f67c9f
-0,         52,         52,        1,      122, 0x7f5e34e1, S=1,     1024, 0xc2f67c9f
+0,         50,         50,        1,      130, 0x15a235fd, S=1,     1024, 0xc2f67c9f
+0,         51,         51,        1,      121, 0x828f3462, S=1,     1024, 0xc2f67c9f
+0,         52,         52,        1,      121, 0x4a0f34e0, S=1,     1024, 0xc2f67c9f
 0,         53,         53,        1,      124, 0x9562350f, S=1,     1024, 0xc2f67c9f
 0,         54,         54,        1,      126, 0x18b33759, S=1,     1024, 0xc2f67c9f
 0,         55,         55,        1,      117, 0x748f3243, S=1,     1024, 0xc2f67c9f
 0,         56,         56,        1,      109, 0x72832fe7, S=1,     1024, 0xc2f67c9f
 0,         57,         57,        1,      120, 0x748a2e38, S=1,     1024, 0xc2f67c9f
 0,         58,         58,        1,      120, 0x61f82fb2, S=1,     1024, 0xc2f67c9f
-0,         59,         59,        1,      122, 0x2a6b3282, S=1,     1024, 0xc2f67c9f
+0,         59,         59,        1,      121, 0xf76c3281, S=1,     1024, 0xc2f67c9f
 0,         60,         60,        1,      116, 0x8b542de6, S=1,     1024, 0xc2f67c9f
 0,         61,         61,        1,      119, 0xf33c318e, S=1,     1024, 0xc2f67c9f
 0,         62,         62,        1,      116, 0xff182f36, S=1,     1024, 0xc2f67c9f
 0,         63,         63,        1,      119, 0xeb9e2fcc, S=1,     1024, 0xc2f67c9f
 0,         64,         64,        1,      118, 0xe82d304e, S=1,     1024, 0xc2f67c9f
 0,         65,         65,        1,      137, 0x98303d30, S=1,     1024, 0xc2f67c9f
-0,         66,         66,        1,      149, 0x01123fff, S=1,     1024, 0xc2f67c9f
+0,         66,         66,        1,      148, 0xc07b3ffe, S=1,     1024, 0xc2f67c9f
 0,         67,         67,        1,      115, 0x4ca92f75, S=1,     1024, 0xc2f67c9f
-0,         68,         68,        1,      131, 0xf4193bc0, S=1,     1024, 0xc2f67c9f
+0,         68,         68,        1,      130, 0xb7e23bbf, S=1,     1024, 0xc2f67c9f
 0,         69,         69,        1,      115, 0xda5e2f30, S=1,     1024, 0xc2f67c9f
 0,         70,         70,        1,      100, 0x9ba32a58, S=1,     1024, 0xc2f67c9f
 0,         71,         71,        1,      109, 0xa47e2c91, S=1,     1024, 0xc2f67c9f
@@ -98,11 +98,11 @@ 
 0,         92,         92,        1,      124, 0x2f683081, S=1,     1024, 0xc2f67c9f
 0,         93,         93,        1,      116, 0x72952d04, S=1,     1024, 0xc2f67c9f
 0,         94,         94,        1,       84, 0x1a532301, S=1,     1024, 0xc2f67c9f
-0,         95,         95,        1,      176, 0xfb3c5400, S=1,     1024, 0xc2f67c9f
+0,         95,         95,        1,      175, 0xa69853ff, S=1,     1024, 0xc2f67c9f
 0,         96,         96,        1,      137, 0x253132d1, S=1,     1024, 0xc2f67c9f
 0,         97,         97,        1,      179, 0x2b38528b, S=1,     1024, 0xc2f67c9f
 0,         98,         98,        1,      150, 0xbe413cbe, S=1,     1024, 0xc2f67c9f
-0,         99,         99,        1,      140, 0x9e93392a, S=1,     1024, 0xc2f67c9f
+0,         99,         99,        1,      139, 0x64e93929, S=1,     1024, 0xc2f67c9f
 0,        100,        100,        1,      129, 0x577e331e, S=1,     1024, 0xc2f67c9f
 0,        101,        101,        1,      146, 0x16ff3924, S=1,     1024, 0xc2f67c9f
 0,        102,        102,        1,      133, 0x756a3163, S=1,     1024, 0xc2f67c9f
@@ -119,23 +119,23 @@ 
 0,        113,        113,        1,      210, 0x9b195be4, S=1,     1024, 0xc2f67c9f
 0,        114,        114,        1,      174, 0x0a424a76, S=1,     1024, 0xc2f67c9f
 0,        115,        115,        1,      137, 0xb1b535fd, S=1,     1024, 0xc2f67c9f
-0,        116,        116,        1,      122, 0x4d3f327b, S=1,     1024, 0xc2f67c9f
+0,        116,        116,        1,      121, 0x1a56327a, S=1,     1024, 0xc2f67c9f
 0,        117,        117,        1,      152, 0x5e423b0c, S=1,     1024, 0xc2f67c9f
 0,        118,        118,        1,      137, 0xd13a39f7, S=1,     1024, 0xc2f67c9f
 0,        119,        119,        1,      156, 0x40864321, S=1,     1024, 0xc2f67c9f
-0,        120,        120,        1,      140, 0xbe1e393c, S=1,     1024, 0xc2f67c9f
+0,        120,        120,        1,      139, 0x8462393b, S=1,     1024, 0xc2f67c9f
 0,        121,        121,        1,      179, 0xaf204635, S=1,     1024, 0xc2f67c9f
 0,        122,        122,        1,      116, 0x5ac83123, S=1,     1024, 0xc2f67c9f
 0,        123,        123,        1,      118, 0x22bc2ec5, S=1,     1024, 0xc2f67c9f
 0,        124,        124,        1,      123, 0xc9b5302d, S=1,     1024, 0xc2f67c9f
 0,        125,        125,        1,      125, 0x5cee3077, S=1,     1024, 0xc2f67c9f
-0,        126,        126,        1,      194, 0xccc159ca, S=1,     1024, 0xc2f67c9f
-0,        127,        127,        1,      122, 0x4d243229, S=1,     1024, 0xc2f67c9f
+0,        126,        126,        1,      193, 0x724159c9, S=1,     1024, 0xc2f67c9f
+0,        127,        127,        1,      121, 0x1a8d3228, S=1,     1024, 0xc2f67c9f
 0,        128,        128,        1,      124, 0x948f330b, S=1,     1024, 0xc2f67c9f
 0,        129,        129,        1,      133, 0xd53c35ca, S=1,     1024, 0xc2f67c9f
 0,        130,        130,        1,      126, 0xc5543710, S=1,     1024, 0xc2f67c9f
 0,        131,        131,        1,      208, 0x6cf15ea2, S=1,     1024, 0xc2f67c9f
-0,        132,        132,        1,      131, 0xa8d33505, S=1,     1024, 0xc2f67c9f
+0,        132,        132,        1,      130, 0x73573504, S=1,     1024, 0xc2f67c9f
 0,        133,        133,        1,      114, 0x0ae53001, S=1,     1024, 0xc2f67c9f
 0,        134,        134,        1,      129, 0xe9ff37c4, S=1,     1024, 0xc2f67c9f
 0,        135,        135,        1,      120, 0x02623359, S=1,     1024, 0xc2f67c9f
@@ -146,9 +146,9 @@ 
 0,        140,        140,        1,      123, 0x70cd2b64, S=1,     1024, 0xc2f67c9f
 0,        141,        141,        1,      124, 0xe9002fb5, S=1,     1024, 0xc2f67c9f
 0,        142,        142,        1,      125, 0x106e309b, S=1,     1024, 0xc2f67c9f
-0,        143,        143,        1,      122, 0x050e32b0, S=1,     1024, 0xc2f67c9f
+0,        143,        143,        1,      121, 0xd1e132af, S=1,     1024, 0xc2f67c9f
 0,        144,        144,        1,      224, 0xf548614f, S=1,     1024, 0xc2f67c9f
-0,        145,        145,        1,      239, 0x125c6ade, S=1,     1024, 0xc2f67c9f
+0,        145,        145,        1,      238, 0xa68c6add, S=1,     1024, 0xc2f67c9f
 0,        146,        146,        1,      127, 0x398734b6, S=1,     1024, 0xc2f67c9f
 0,        147,        147,        1,      126, 0x2ff431e5, S=1,     1024, 0xc2f67c9f
 0,        148,        148,        1,      124, 0x9583313b, S=1,     1024, 0xc2f67c9f
@@ -157,9 +157,9 @@ 
 0,        151,        151,        1,      117, 0x651f3032, S=1,     1024, 0xc2f67c9f
 0,        152,        152,        1,      119, 0x268a3078, S=1,     1024, 0xc2f67c9f
 0,        153,        153,        1,      117, 0x9e4d3283, S=1,     1024, 0xc2f67c9f
-0,        154,        154,        1,      149, 0x8f1043ba, S=1,     1024, 0xc2f67c9f
+0,        154,        154,        1,      148, 0x4acd43b9, S=1,     1024, 0xc2f67c9f
 0,        155,        155,        1,      127, 0x352338bc, S=1,     1024, 0xc2f67c9f
-0,        156,        156,        1,      113, 0xf877314e, S=1,     1024, 0xc2f67c9f
+0,        156,        156,        1,      112, 0xc6c4314d, S=1,     1024, 0xc2f67c9f
 0,        157,        157,        1,      128, 0x88103a62, S=1,     1024, 0xc2f67c9f
 0,        158,        158,        1,      111, 0xbf0630d9, S=1,     1024, 0xc2f67c9f
 0,        159,        159,        1,      146, 0x159c44f7, S=1,     1024, 0xc2f67c9f
@@ -167,12 +167,12 @@ 
 0,        161,        161,        1,      233, 0x8f9e6354, S=1,     1024, 0xc2f67c9f
 0,        162,        162,        1,      160, 0x9c3f431f, S=1,     1024, 0xc2f67c9f
 0,        163,        163,        1,      125, 0xbd2b33c6, S=1,     1024, 0xc2f67c9f
-0,        164,        164,        1,      131, 0x3ecd3ba5, S=1,     1024, 0xc2f67c9f
+0,        164,        164,        1,      130, 0x02b13ba4, S=1,     1024, 0xc2f67c9f
 0,        165,        165,        1,      231, 0xdf286db6, S=1,     1024, 0xc2f67c9f
 0,        166,        166,        1,      153, 0xb6da408d, S=1,     1024, 0xc2f67c9f
 0,        167,        167,        1,      126, 0x6741365e, S=1,     1024, 0xc2f67c9f
-0,        168,        168,        1,      113, 0x658f2c90, S=1,     1024, 0xc2f67c9f
+0,        168,        168,        1,      112, 0x389a2c8f, S=1,     1024, 0xc2f67c9f
 0,        169,        169,        1,      125, 0xc0033320, S=1,     1024, 0xc2f67c9f
-0,        170,        170,        1,      122, 0xe38a2db1, S=1,     1024, 0xc2f67c9f
+0,        170,        170,        1,      121, 0xb56b2db0, S=1,     1024, 0xc2f67c9f
 0,        171,        171,        1,      145, 0x29d63e83, S=1,     1024, 0xc2f67c9f
 0,        172,        172,        1,      171, 0xc0e44b70, S=1,     1024, 0xc2f67c9f
diff --git a/tests/ref/fate/gifenc-pal8 b/tests/ref/fate/gifenc-pal8
index a6d5741992..de5486c2b2 100644
--- a/tests/ref/fate/gifenc-pal8
+++ b/tests/ref/fate/gifenc-pal8
@@ -5,10 +5,10 @@ 
 #sar 0: 0/1
 0,          0,          0,        1,      552, 0x271a2dd3, S=1,     1024, 0xec907a9e
 0,          1,          1,        1,      297, 0x90168a95, S=1,     1024, 0xf351799f
-0,          2,          2,        1,      438, 0x91efce1b, S=1,     1024, 0xf351799f
+0,          2,          2,        1,      437, 0xc31bce1a, S=1,     1024, 0xf351799f
 0,          3,          3,        1,      450, 0x7c2dcfad, S=1,     1024, 0xf351799f
 0,          4,          4,        1,      547, 0xc131fd3b, S=1,     1024, 0xf351799f
-0,          5,          5,        1,      614, 0x68182006, S=1,     1024, 0xf351799f
+0,          5,          5,        1,      613, 0x47b82005, S=1,     1024, 0xf351799f
 0,          6,          6,        1,      642, 0x78bb1f5f, S=1,     1024, 0xf351799f
 0,          7,          7,        1,      660, 0x35c033a2, S=1,     1024, 0xf351799f
 0,          8,          8,        1,      821, 0xaf30790b, S=1,     1024, 0xf351799f
@@ -20,56 +20,56 @@ 
 0,         14,         14,        1,     1720, 0xc95d45ec, S=1,     1024, 0xf351799f
 0,         15,         15,        1,     1910, 0x56cc831e, S=1,     1024, 0xf351799f
 0,         16,         16,        1,     2124, 0x9cc8e130, S=1,     1024, 0xf351799f
-0,         17,         17,        1,     2248, 0x05a325b1, S=1,     1024, 0xf351799f
+0,         17,         17,        1,     2247, 0xdf2725b0, S=1,     1024, 0xf351799f
 0,         18,         18,        1,     2311, 0xdc633703, S=1,     1024, 0xf351799f
 0,         19,         19,        1,     2408, 0x91c26f3e, S=1,     1024, 0xf351799f
 0,         20,         20,        1,     2601, 0x8cf3c157, S=1,     1024, 0xf351799f
-0,         21,         21,        1,     2687, 0x8f6400e6, S=1,     1024, 0xf351799f
+0,         21,         21,        1,     2686, 0x8e0b00e5, S=1,     1024, 0xf351799f
 0,         22,         22,        1,     2784, 0xaa880e55, S=1,     1024, 0xf351799f
 0,         23,         23,        1,     2884, 0x46f546f6, S=1,     1024, 0xf351799f
-0,         24,         24,        1,     2982, 0x807c7ad5, S=1,     1024, 0xf351799f
+0,         24,         24,        1,     2981, 0x050d7ad4, S=1,     1024, 0xf351799f
 0,         25,         25,        1,     3101, 0xbcc89bec, S=1,     1024, 0xf351799f
-0,         26,         26,        1,     3253, 0xd032f3fa, S=1,     1024, 0xf351799f
+0,         26,         26,        1,     3252, 0xdb80f3f9, S=1,     1024, 0xf351799f
 0,         27,         27,        1,     3329, 0xe4d42430, S=1,     1024, 0xf351799f
-0,         28,         28,        1,     3572, 0xf8058aa0, S=1,     1024, 0xf351799f
-0,         29,         29,        1,     3807, 0x3d2af9f3, S=1,     1024, 0xf351799f
-0,         30,         30,        1,     2750, 0x814d1c33, S=1,     1024, 0xf351799f
+0,         28,         28,        1,     3571, 0x6c7d8a9f, S=1,     1024, 0xf351799f
+0,         29,         29,        1,     3806, 0x4255f9f2, S=1,     1024, 0xf351799f
+0,         30,         30,        1,     2749, 0x64681c32, S=1,     1024, 0xf351799f
 0,         31,         31,        1,     4031, 0x3b077006, S=1,     1024, 0xf351799f
 0,         32,         32,        1,     3025, 0x86729c1c, S=1,     1024, 0xf351799f
-0,         33,         33,        1,     4295, 0xf71b0b38, S=1,     1024, 0xf351799f
+0,         33,         33,        1,     4294, 0xeb280b37, S=1,     1024, 0xf351799f
 0,         34,         34,        1,     2044, 0x5adcb93b, S=1,     1024, 0xf351799f
 0,         35,         35,        1,     3212, 0xcf79eeed, S=1,     1024, 0xf351799f
-0,         36,         36,        1,     2292, 0xb4386334, S=1,     1024, 0xf351799f
-0,         37,         37,        1,     3633, 0x0010992f, S=1,     1024, 0xf351799f
+0,         36,         36,        1,     2291, 0x501c6333, S=1,     1024, 0xf351799f
+0,         37,         37,        1,     3632, 0x66ad992e, S=1,     1024, 0xf351799f
 0,         38,         38,        1,     3552, 0x23697490, S=1,     1024, 0xf351799f
-0,         39,         39,        1,     3690, 0x62afdbb8, S=1,     1024, 0xf351799f
+0,         39,         39,        1,     3689, 0x868adbb7, S=1,     1024, 0xf351799f
 0,         40,         40,        1,     1559, 0x5baef54a, S=1,     1024, 0xf351799f
 0,         41,         41,        1,      954, 0xca75ca79, S=1,     1024, 0xf351799f
 0,         42,         42,        1,      273, 0x3687799b, S=1,     1024, 0xf351799f
-0,         43,         43,        1,      930, 0x29f3b0c4, S=1,     1024, 0xf351799f
+0,         43,         43,        1,      929, 0x788ab0c3, S=1,     1024, 0xf351799f
 0,         44,         44,        1,      271, 0x305e8094, S=1,     1024, 0xf351799f
 0,         45,         45,        1,      196, 0xf5ab51ee, S=1,     1024, 0xf351799f
 0,         46,         46,        1,     4299, 0x67ec0d55, S=1,     1024, 0xf351799f
-0,         47,         47,        1,     4895, 0xb394406c, S=1,     1024, 0xf351799f
-0,         48,         48,        1,     4928, 0x233919d7, S=1,     1024, 0xf351799f
+0,         47,         47,        1,     4894, 0x7315406b, S=1,     1024, 0xf351799f
+0,         48,         48,        1,     4927, 0x092e19d6, S=1,     1024, 0xf351799f
 0,         49,         49,        1,     4941, 0x58a357da, S=1,     1024, 0xf351799f
-0,         50,         50,        1,     4154, 0x21f2ac33, S=1,     1024, 0xf351799f
-0,         51,         51,        1,     4678, 0xab3cc050, S=1,     1024, 0xf351799f
-0,         52,         52,        1,     4741, 0x1974b581, S=1,     1024, 0xf351799f
-0,         53,         53,        1,     4982, 0x891456d5, S=1,     1024, 0xf351799f
+0,         50,         50,        1,     4153, 0x7582ac32, S=1,     1024, 0xf351799f
+0,         51,         51,        1,     4677, 0xeaa3c04f, S=1,     1024, 0xf351799f
+0,         52,         52,        1,     4740, 0x636bb580, S=1,     1024, 0xf351799f
+0,         53,         53,        1,     4981, 0x31d556d4, S=1,     1024, 0xf351799f
 0,         54,         54,        1,     5179, 0x860fc6a1, S=1,     1024, 0xf351799f
 0,         55,         55,        1,     5046, 0xce9183d3, S=1,     1024, 0xf351799f
 0,         56,         56,        1,     5140, 0xa6d7b9af, S=1,     1024, 0xf351799f
-0,         57,         57,        1,     4301, 0x03b6ef3f, S=1,     1024, 0xf351799f
+0,         57,         57,        1,     4300, 0x13a7ef3e, S=1,     1024, 0xf351799f
 0,         58,         58,        1,     5079, 0xa8d59e01, S=1,     1024, 0xf351799f
 0,         59,         59,        1,     5284, 0xea34e3b3, S=1,     1024, 0xf351799f
 0,         60,         60,        1,     5426, 0x556a15cd, S=1,     1024, 0xf351799f
-0,         61,         61,        1,     4645, 0x061e8936, S=1,     1024, 0xf351799f
+0,         61,         61,        1,     4644, 0x7cc08935, S=1,     1024, 0xf351799f
 0,         62,         62,        1,     5263, 0x7536cf7d, S=1,     1024, 0xf351799f
 0,         63,         63,        1,     5221, 0x9fbac3ca, S=1,     1024, 0xf351799f
-0,         64,         64,        1,     5217, 0x02269bd2, S=1,     1024, 0xf351799f
-0,         65,         65,        1,     5395, 0x120fff66, S=1,     1024, 0xf351799f
-0,         66,         66,        1,     5220, 0x77cedcc5, S=1,     1024, 0xf351799f
+0,         64,         64,        1,     5216, 0x65f09bd1, S=1,     1024, 0xf351799f
+0,         65,         65,        1,     5394, 0x1293ff65, S=1,     1024, 0xf351799f
+0,         66,         66,        1,     5219, 0x9aa2dcc4, S=1,     1024, 0xf351799f
 0,         67,         67,        1,     5704, 0xba42dd96, S=1,     1024, 0xf351799f
 0,         68,         68,        1,     5636, 0xcb91a25b, S=1,     1024, 0xf351799f
 0,         69,         69,        1,     5818, 0x8dc0df92, S=1,     1024, 0xf351799f
@@ -87,7 +87,7 @@ 
 0,         81,         81,        1,     8358, 0x027279e8, S=1,     1024, 0xf351799f
 0,         82,         82,        1,     7708, 0x607f8e8b, S=1,     1024, 0xf351799f
 0,         83,         83,        1,     7412, 0x6bb2105f, S=1,     1024, 0xf351799f
-0,         84,         84,        1,     7541, 0xfdc02154, S=1,     1024, 0xf351799f
+0,         84,         84,        1,     7540, 0xdc032153, S=1,     1024, 0xf351799f
 0,         85,         85,        1,     7948, 0x916ecd8b, S=1,     1024, 0xf351799f
 0,         86,         86,        1,     8408, 0x1f97d414, S=1,     1024, 0xf351799f
 0,         87,         87,        1,     8056, 0x9cbf159c, S=1,     1024, 0xf351799f
@@ -97,12 +97,12 @@ 
 0,         91,         91,        1,     7768, 0x25ed7ee7, S=1,     1024, 0xf351799f
 0,         92,         92,        1,     7749, 0x6d8e978e, S=1,     1024, 0xf351799f
 0,         93,         93,        1,     8047, 0xec4b150c, S=1,     1024, 0xf351799f
-0,         94,         94,        1,     7618, 0x88cf30d5, S=1,     1024, 0xf351799f
+0,         94,         94,        1,     7617, 0x574430d4, S=1,     1024, 0xf351799f
 0,         95,         95,        1,     7979, 0x0eb1cf2a, S=1,     1024, 0xf351799f
 0,         96,         96,        1,    12062, 0xb49d9125, S=1,     1024, 0xf351799f
 0,         97,         97,        1,    12317, 0x2d8fd6e9, S=1,     1024, 0xf351799f
 0,         98,         98,        1,    12217, 0x9b3be549, S=1,     1024, 0xf351799f
-0,         99,         99,        1,    11227, 0x067e9118, S=1,     1024, 0xf351799f
+0,         99,         99,        1,    11226, 0x74889117, S=1,     1024, 0xf351799f
 0,        100,        100,        1,    11108, 0x5e5b0afd, S=1,     1024, 0xf351799f
 0,        101,        101,        1,    11366, 0xb38e8d15, S=1,     1024, 0xf351799f
 0,        102,        102,        1,    11896, 0xeb3e35ca, S=1,     1024, 0xf351799f
@@ -139,7 +139,7 @@ 
 0,        133,        133,        1,    17934, 0xb539974b, S=1,     1024, 0xf351799f
 0,        134,        134,        1,    17944, 0x2214ec94, S=1,     1024, 0xf351799f
 0,        135,        135,        1,    18238, 0x70f9ff1d, S=1,     1024, 0xf351799f
-0,        136,        136,        1,    18391, 0x4b149209, S=1,     1024, 0xf351799f
+0,        136,        136,        1,    18390, 0xb8319208, S=1,     1024, 0xf351799f
 0,        137,        137,        1,    18543, 0x45a1c02f, S=1,     1024, 0xf351799f
 0,        138,        138,        1,    18939, 0x2789a88c, S=1,     1024, 0xf351799f
 0,        139,        139,        1,    19145, 0x5daafd7a, S=1,     1024, 0xf351799f
@@ -170,7 +170,7 @@ 
 0,        164,        164,        1,    22460, 0xf9ceb0ac, S=1,     1024, 0xf351799f
 0,        165,        165,        1,    22861, 0xb05f0f84, S=1,     1024, 0xf351799f
 0,        166,        166,        1,    22746, 0x0df23a5c, S=1,     1024, 0xf351799f
-0,        167,        167,        1,    23165, 0xbd7147ad, S=1,     1024, 0xf351799f
+0,        167,        167,        1,    23164, 0x755347ac, S=1,     1024, 0xf351799f
 0,        168,        168,        1,    23273, 0x9781a34f, S=1,     1024, 0xf351799f
 0,        169,        169,        1,    23211, 0x69c7606b, S=1,     1024, 0xf351799f
 0,        170,        170,        1,    23648, 0xdafde037, S=1,     1024, 0xf351799f
diff --git a/tests/ref/fate/gifenc-rgb4_byte b/tests/ref/fate/gifenc-rgb4_byte
index 067accd694..0dca862b04 100644
--- a/tests/ref/fate/gifenc-rgb4_byte
+++ b/tests/ref/fate/gifenc-rgb4_byte
@@ -3,58 +3,58 @@ 
 #codec_id 0: gif
 #dimensions 0: 217x217
 #sar 0: 0/1
-0,          0,          0,        1,      508, 0xf04a113b
+0,          0,          0,        1,      507, 0xde1f113a
 0,          1,          1,        1,      213, 0x23c24d3d, S=1,     1024, 0xf7700427
-0,          2,          2,        1,      131, 0x56d22a39, S=1,     1024, 0x03730427
+0,          2,          2,        1,      130, 0x2c222a38, S=1,     1024, 0x03730427
 0,          3,          3,        1,      384, 0xb1d8a4bd, S=1,     1024, 0xf7700427
 0,          4,          4,        1,      381, 0x37a3a2c9, S=1,     1024, 0xf3740427
 0,          5,          5,        1,      430, 0x162bb3d3, S=1,     1024, 0xf3740427
-0,          6,          6,        1,      518, 0x195bd738, S=1,     1024, 0xf3740427
+0,          6,          6,        1,      517, 0x411ad737, S=1,     1024, 0xf3740427
 0,          7,          7,        1,      535, 0x12cde6b7, S=1,     1024, 0xf3740427
-0,          8,          8,        1,      438, 0xa653b946, S=1,     1024, 0x0b6b0427
+0,          8,          8,        1,      437, 0xec54b945, S=1,     1024, 0x0b6b0427
 0,          9,          9,        1,      923, 0xd2e2a35f, S=1,     1024, 0x0b6b0427
-0,         10,         10,        1,      694, 0xe1cf4a1f, S=1,     1024, 0x0b6b0427
+0,         10,         10,        1,      693, 0x97064a1e, S=1,     1024, 0x0b6b0427
 0,         11,         11,        1,     1194, 0xa6152c8a, S=1,     1024, 0x0b6b0427
 0,         12,         12,        1,     1291, 0x94d25581, S=1,     1024, 0x0b6b0427
 0,         13,         13,        1,     1245, 0x5b483525, S=1,     1024, 0x0b6b0427
 0,         14,         14,        1,     1330, 0xfb5351c8, S=1,     1024, 0x0b6b0427
-0,         15,         15,        1,     1276, 0x6f403914, S=1,     1024, 0x0b6b0427
-0,         16,         16,        1,     1475, 0xbf459755, S=1,     1024, 0x0b6b0427
-0,         17,         17,        1,     1784, 0xe9954aa7, S=1,     1024, 0xecb30526
+0,         15,         15,        1,     1275, 0x353c3913, S=1,     1024, 0x0b6b0427
+0,         16,         16,        1,     1474, 0x27399754, S=1,     1024, 0x0b6b0427
+0,         17,         17,        1,     1783, 0x9e024aa6, S=1,     1024, 0xecb30526
 0,         18,         18,        1,     1675, 0x219dfaf8, S=1,     1024, 0xecb30526
 0,         19,         19,        1,     1509, 0xd7f5abbe, S=1,     1024, 0xecb30526
 0,         20,         20,        1,     1705, 0x44a01729, S=1,     1024, 0xecb30526
 0,         21,         21,        1,     1745, 0x31ff1f89, S=1,     1024, 0xecb30526
 0,         22,         22,        1,     1642, 0x55420147, S=1,     1024, 0xecb30526
-0,         23,         23,        1,     1718, 0x68ef1cb8, S=1,     1024, 0xecb30526
+0,         23,         23,        1,     1717, 0x4b8d1cb7, S=1,     1024, 0xecb30526
 0,         24,         24,        1,     1900, 0xd7737a09, S=1,     1024, 0xecb30526
-0,         25,         25,        1,     1807, 0x4f6c5140, S=1,     1024, 0xecb30526
+0,         25,         25,        1,     1806, 0xfe1a513f, S=1,     1024, 0xecb30526
 0,         26,         26,        1,     1915, 0x976d80e6, S=1,     1024, 0xecb30526
 0,         27,         27,        1,     2100, 0x0ae6d1ce, S=1,     1024, 0xecb30526
 0,         28,         28,        1,     2700, 0x7a89f104, S=1,     1024, 0xecb30526
 0,         29,         29,        1,     2673, 0xf6b6a71d, S=1,     1024, 0xecb30526
-0,         30,         30,        1,     2895, 0x9079484b, S=1,     1024, 0xecb30526
+0,         30,         30,        1,     2894, 0x47eb484a, S=1,     1024, 0xecb30526
 0,         31,         31,        1,     3257, 0x0b0cd125, S=1,     1024, 0xecb30526
 0,         32,         32,        1,     3179, 0x3ee2c161, S=1,     1024, 0xecb30526
 0,         33,         33,        1,     3296, 0x6230e506, S=1,     1024, 0xecb30526
-0,         34,         34,        1,     3600, 0x021775d7, S=1,     1024, 0xecb30526
-0,         35,         35,        1,     3699, 0xfb03a043, S=1,     1024, 0xecb30526
+0,         34,         34,        1,     3599, 0x8c2d75d6, S=1,     1024, 0xecb30526
+0,         35,         35,        1,     3698, 0x5a59a042, S=1,     1024, 0xecb30526
 0,         36,         36,        1,     3814, 0x96a8d57e, S=1,     1024, 0xecb30526
-0,         37,         37,        1,     3627, 0x33a37f8f, S=1,     1024, 0xecb30526
+0,         37,         37,        1,     3626, 0xb3e67f8e, S=1,     1024, 0xecb30526
 0,         38,         38,        1,     2950, 0x50806197, S=1,     1024, 0xecb30526
 0,         39,         39,        1,     3086, 0x72068d4c, S=1,     1024, 0xecb30526
-0,         40,         40,        1,     3094, 0x2880861f, S=1,     1024, 0xecb30526
+0,         40,         40,        1,     3093, 0xa248861e, S=1,     1024, 0xecb30526
 0,         41,         41,        1,     3456, 0x6d232a96, S=1,     1024, 0xecb30526
-0,         42,         42,        1,     4108, 0x46d75ebb, S=1,     1024, 0xecb30526
-0,         43,         43,        1,     4217, 0x04a258f4, S=1,     1024, 0xecb30526
+0,         42,         42,        1,     4107, 0xe70d5eba, S=1,     1024, 0xecb30526
+0,         43,         43,        1,     4216, 0xab3258f3, S=1,     1024, 0xecb30526
 0,         44,         44,        1,     3613, 0x667f4ff8, S=1,     1024, 0xecb30526
-0,         45,         45,        1,     3910, 0x8f37e73e, S=1,     1024, 0xecb30526
-0,         46,         46,        1,     4461, 0x5db9e0bf, S=1,     1024, 0xecb30526
-0,         47,         47,        1,     4593, 0x883f2f49, S=1,     1024, 0xecb30526
-0,         48,         48,        1,     4822, 0x03d99b73, S=1,     1024, 0xecb30526
-0,         49,         49,        1,     5398, 0x39f7bff4, S=1,     1024, 0xecb30526
+0,         45,         45,        1,     3909, 0xa7b0e73d, S=1,     1024, 0xecb30526
+0,         46,         46,        1,     4460, 0x7c8ae0be, S=1,     1024, 0xecb30526
+0,         47,         47,        1,     4592, 0x58112f48, S=1,     1024, 0xecb30526
+0,         48,         48,        1,     4821, 0x678d9b72, S=1,     1024, 0xecb30526
+0,         49,         49,        1,     5397, 0x79eabff3, S=1,     1024, 0xecb30526
 0,         50,         50,        1,     5266, 0xd5ab9630, S=1,     1024, 0xecb30526
-0,         51,         51,        1,     5416, 0x5876e16f, S=1,     1024, 0xecb30526
+0,         51,         51,        1,     5415, 0x76dce16e, S=1,     1024, 0xecb30526
 0,         52,         52,        1,     5519, 0x30ed05d8, S=1,     1024, 0xecb30526
 0,         53,         53,        1,     5701, 0x5bae5af7, S=1,     1024, 0xecb30526
 0,         54,         54,        1,     6160, 0x98364177, S=1,     1024, 0xecb30526
@@ -73,7 +73,7 @@ 
 0,         67,         67,        1,     7556, 0x1aa2a694, S=1,     1024, 0xecb30526
 0,         68,         68,        1,     7413, 0xbc9e7718, S=1,     1024, 0xecb30526
 0,         69,         69,        1,     7476, 0xb2a1aba0, S=1,     1024, 0xecb30526
-0,         70,         70,        1,     7596, 0x3301e56d, S=1,     1024, 0xecb30526
+0,         70,         70,        1,     7595, 0x4ce5e56c, S=1,     1024, 0xecb30526
 0,         71,         71,        1,     7756, 0x8f2504f8, S=1,     1024, 0xecb30526
 0,         72,         72,        1,     8015, 0xd4146c80, S=1,     1024, 0xecb30526
 0,         73,         73,        1,     8128, 0x11b2bf4c, S=1,     1024, 0xecb30526
@@ -105,22 +105,22 @@ 
 0,         99,         99,        1,    11111, 0x5f8d504f, S=1,     1024, 0xecb30526
 0,        100,        100,        1,    11194, 0x3c7e6a77, S=1,     1024, 0xecb30526
 0,        101,        101,        1,    11240, 0x5112a0a3, S=1,     1024, 0xecb30526
-0,        102,        102,        1,    11483, 0xaf10f4fa, S=1,     1024, 0xecb30526
+0,        102,        102,        1,    11482, 0xb938f4f9, S=1,     1024, 0xecb30526
 0,        103,        103,        1,    11680, 0x44a25971, S=1,     1024, 0xecb30526
 0,        104,        104,        1,    11785, 0x7350b5db, S=1,     1024, 0xecb30526
 0,        105,        105,        1,    11436, 0xe3170ad5, S=1,     1024, 0xecb30526
-0,        106,        106,        1,    11928, 0x13d8c885, S=1,     1024, 0xecb30526
+0,        106,        106,        1,    11927, 0x4ab8c884, S=1,     1024, 0xecb30526
 0,        107,        107,        1,    11932, 0xecb5bdf7, S=1,     1024, 0xecb30526
-0,        108,        108,        1,    12281, 0x18bb76d5, S=1,     1024, 0xecb30526
+0,        108,        108,        1,    12280, 0xa0ea76d4, S=1,     1024, 0xecb30526
 0,        109,        109,        1,    12334, 0x16147fc3, S=1,     1024, 0xecb30526
 0,        110,        110,        1,    12452, 0x61a8b3d7, S=1,     1024, 0xecb30526
 0,        111,        111,        1,    12695, 0x8b703e74, S=1,     1024, 0xecb30526
-0,        112,        112,        1,    12668, 0x19505176, S=1,     1024, 0xecb30526
+0,        112,        112,        1,    12667, 0xc75b5175, S=1,     1024, 0xecb30526
 0,        113,        113,        1,    12957, 0x3b839f0d, S=1,     1024, 0xecb30526
-0,        114,        114,        1,    13054, 0xb8a5e3db, S=1,     1024, 0xecb30526
+0,        114,        114,        1,    13053, 0xd3c9e3da, S=1,     1024, 0xecb30526
 0,        115,        115,        1,    13147, 0xdf5c2e68, S=1,     1024, 0xecb30526
 0,        116,        116,        1,    13171, 0x15961ca2, S=1,     1024, 0xecb30526
-0,        117,        117,        1,    13198, 0xfd855718, S=1,     1024, 0xecb30526
+0,        117,        117,        1,    13197, 0xa5eb5717, S=1,     1024, 0xecb30526
 0,        118,        118,        1,    13211, 0x1a625e31, S=1,     1024, 0xecb30526
 0,        119,        119,        1,    13210, 0x246661c9, S=1,     1024, 0xecb30526
 0,        120,        120,        1,    13467, 0xfcaaa461, S=1,     1024, 0xecb30526
@@ -151,8 +151,8 @@ 
 0,        145,        145,        1,    17149, 0x435ecdd4, S=1,     1024, 0xecb30526
 0,        146,        146,        1,    17172, 0x045fb234, S=1,     1024, 0xecb30526
 0,        147,        147,        1,    17315, 0xc5ddadab, S=1,     1024, 0xecb30526
-0,        148,        148,        1,    17397, 0xff8e15b6, S=1,     1024, 0xecb30526
-0,        149,        149,        1,    17431, 0x6832f8c0, S=1,     1024, 0xecb30526
+0,        148,        148,        1,    17396, 0xe8ef15b5, S=1,     1024, 0xecb30526
+0,        149,        149,        1,    17430, 0x6f58f8bf, S=1,     1024, 0xecb30526
 0,        150,        150,        1,    17576, 0x5c2a5445, S=1,     1024, 0xecb30526
 0,        151,        151,        1,    17764, 0x609f8c3b, S=1,     1024, 0xecb30526
 0,        152,        152,        1,    17826, 0x538c8532, S=1,     1024, 0xecb30526
diff --git a/tests/ref/fate/gifenc-rgb8 b/tests/ref/fate/gifenc-rgb8
index 490e4d0b19..8f6f3d0252 100644
--- a/tests/ref/fate/gifenc-rgb8
+++ b/tests/ref/fate/gifenc-rgb8
@@ -5,10 +5,10 @@ 
 #sar 0: 0/1
 0,          0,          0,        1,      552, 0x47602c6c
 0,          1,          1,        1,      297, 0x49dd8847, S=1,     1024, 0xcfc8799f
-0,          2,          2,        1,      438, 0x4776d352, S=1,     1024, 0xcfc8799f
+0,          2,          2,        1,      437, 0x736bd351, S=1,     1024, 0xcfc8799f
 0,          3,          3,        1,      450, 0x2254d187, S=1,     1024, 0xcfc8799f
 0,          4,          4,        1,      547, 0xe16104bc, S=1,     1024, 0xcfc8799f
-0,          5,          5,        1,      614, 0x0fdc2027, S=1,     1024, 0xcfc8799f
+0,          5,          5,        1,      613, 0xef4c2026, S=1,     1024, 0xcfc8799f
 0,          6,          6,        1,      642, 0xa0af1edf, S=1,     1024, 0xcfc8799f
 0,          7,          7,        1,      660, 0xd0763931, S=1,     1024, 0xcfc8799f
 0,          8,          8,        1,      821, 0xc38f7fac, S=1,     1024, 0xcfc8799f
@@ -20,56 +20,56 @@ 
 0,         14,         14,        1,     1720, 0xce854743, S=1,     1024, 0xcfc8799f
 0,         15,         15,        1,     1910, 0x2690866d, S=1,     1024, 0xcfc8799f
 0,         16,         16,        1,     2124, 0xa586dad0, S=1,     1024, 0xcfc8799f
-0,         17,         17,        1,     2248, 0x9ddc2a88, S=1,     1024, 0xcfc8799f
+0,         17,         17,        1,     2247, 0x72982a87, S=1,     1024, 0xcfc8799f
 0,         18,         18,        1,     2311, 0xd64235af, S=1,     1024, 0xcfc8799f
 0,         19,         19,        1,     2408, 0xe2a66cc9, S=1,     1024, 0xcfc8799f
 0,         20,         20,        1,     2601, 0xeab6c267, S=1,     1024, 0xcfc8799f
-0,         21,         21,        1,     2687, 0xfe1d0311, S=1,     1024, 0xcfc8799f
+0,         21,         21,        1,     2686, 0xfa990310, S=1,     1024, 0xcfc8799f
 0,         22,         22,        1,     2784, 0xca600dee, S=1,     1024, 0xcfc8799f
 0,         23,         23,        1,     2884, 0xc7134b99, S=1,     1024, 0xcfc8799f
-0,         24,         24,        1,     2982, 0x0b1e7825, S=1,     1024, 0xcfc8799f
+0,         24,         24,        1,     2981, 0x92507824, S=1,     1024, 0xcfc8799f
 0,         25,         25,        1,     3101, 0x3e029e0e, S=1,     1024, 0xcfc8799f
-0,         26,         26,        1,     3253, 0x846af678, S=1,     1024, 0xcfc8799f
+0,         26,         26,        1,     3252, 0x8d3af677, S=1,     1024, 0xcfc8799f
 0,         27,         27,        1,     3329, 0x29a81b71, S=1,     1024, 0xcfc8799f
-0,         28,         28,        1,     3572, 0xa3e08a52, S=1,     1024, 0xcfc8799f
-0,         29,         29,        1,     3807, 0x18e1fed2, S=1,     1024, 0xcfc8799f
-0,         30,         30,        1,     2750, 0xff6e1f9e, S=1,     1024, 0xcfc8799f
+0,         28,         28,        1,     3571, 0x18a68a51, S=1,     1024, 0xcfc8799f
+0,         29,         29,        1,     3806, 0x192dfed1, S=1,     1024, 0xcfc8799f
+0,         30,         30,        1,     2749, 0xdf1e1f9d, S=1,     1024, 0xcfc8799f
 0,         31,         31,        1,     4031, 0x6d4f7329, S=1,     1024, 0xcfc8799f
 0,         32,         32,        1,     3025, 0xb43c9e94, S=1,     1024, 0xcfc8799f
-0,         33,         33,        1,     4295, 0xc1850a80, S=1,     1024, 0xcfc8799f
+0,         33,         33,        1,     4294, 0xb64a0a7f, S=1,     1024, 0xcfc8799f
 0,         34,         34,        1,     2044, 0x0440c072, S=1,     1024, 0xcfc8799f
 0,         35,         35,        1,     3212, 0xe91af08f, S=1,     1024, 0xcfc8799f
-0,         36,         36,        1,     2292, 0x6765633e, S=1,     1024, 0xcfc8799f
-0,         37,         37,        1,     3633, 0xac779aa3, S=1,     1024, 0xcfc8799f
+0,         36,         36,        1,     2291, 0x033f633d, S=1,     1024, 0xcfc8799f
+0,         37,         37,        1,     3632, 0x11af9aa2, S=1,     1024, 0xcfc8799f
 0,         38,         38,        1,     3552, 0xed2c75b2, S=1,     1024, 0xcfc8799f
-0,         39,         39,        1,     3690, 0x2020dd0d, S=1,     1024, 0xcfc8799f
+0,         39,         39,        1,     3689, 0x42a6dd0c, S=1,     1024, 0xcfc8799f
 0,         40,         40,        1,     1559, 0x596ef330, S=1,     1024, 0xcfc8799f
 0,         41,         41,        1,      954, 0xac12c9c5, S=1,     1024, 0xcfc8799f
 0,         42,         42,        1,      273, 0x138c7831, S=1,     1024, 0xcfc8799f
-0,         43,         43,        1,      930, 0xf1c3ae3f, S=1,     1024, 0xcfc8799f
+0,         43,         43,        1,      929, 0x42eeae3e, S=1,     1024, 0xcfc8799f
 0,         44,         44,        1,      271, 0x921a80af, S=1,     1024, 0xcfc8799f
 0,         45,         45,        1,      196, 0xa5de5322, S=1,     1024, 0xcfc8799f
 0,         46,         46,        1,     4299, 0x5bac0d86, S=1,     1024, 0xcfc8799f
-0,         47,         47,        1,     4895, 0xc43639a6, S=1,     1024, 0xcfc8799f
-0,         48,         48,        1,     4928, 0xf17d13e8, S=1,     1024, 0xcfc8799f
+0,         47,         47,        1,     4894, 0x8a7d39a5, S=1,     1024, 0xcfc8799f
+0,         48,         48,        1,     4927, 0xdd6113e7, S=1,     1024, 0xcfc8799f
 0,         49,         49,        1,     4941, 0x71915520, S=1,     1024, 0xcfc8799f
-0,         50,         50,        1,     4154, 0xc860b8a6, S=1,     1024, 0xcfc8799f
-0,         51,         51,        1,     4678, 0x2651c339, S=1,     1024, 0xcfc8799f
-0,         52,         52,        1,     4741, 0xffd6bb45, S=1,     1024, 0xcfc8799f
-0,         53,         53,        1,     4982, 0x132c5977, S=1,     1024, 0xcfc8799f
+0,         50,         50,        1,     4153, 0x0f8cb8a5, S=1,     1024, 0xcfc8799f
+0,         51,         51,        1,     4677, 0x62cfc338, S=1,     1024, 0xcfc8799f
+0,         52,         52,        1,     4740, 0x4418bb44, S=1,     1024, 0xcfc8799f
+0,         53,         53,        1,     4981, 0xb93c5976, S=1,     1024, 0xcfc8799f
 0,         54,         54,        1,     5179, 0x97aac3a1, S=1,     1024, 0xcfc8799f
 0,         55,         55,        1,     5046, 0x836a80cd, S=1,     1024, 0xcfc8799f
 0,         56,         56,        1,     5140, 0xa725c1e7, S=1,     1024, 0xcfc8799f
-0,         57,         57,        1,     4301, 0x0203f239, S=1,     1024, 0xcfc8799f
+0,         57,         57,        1,     4300, 0x0efaf238, S=1,     1024, 0xcfc8799f
 0,         58,         58,        1,     5079, 0xb2e7a2de, S=1,     1024, 0xcfc8799f
 0,         59,         59,        1,     5284, 0xb757dfe1, S=1,     1024, 0xcfc8799f
 0,         60,         60,        1,     5426, 0xf9f11e57, S=1,     1024, 0xcfc8799f
-0,         61,         61,        1,     4645, 0xf0f289e1, S=1,     1024, 0xcfc8799f
+0,         61,         61,        1,     4644, 0x66f889e0, S=1,     1024, 0xcfc8799f
 0,         62,         62,        1,     5263, 0x8617d7e9, S=1,     1024, 0xcfc8799f
 0,         63,         63,        1,     5221, 0x26e3ca43, S=1,     1024, 0xcfc8799f
-0,         64,         64,        1,     5217, 0x90989cfb, S=1,     1024, 0xcfc8799f
-0,         65,         65,        1,     5395, 0xe29a01cb, S=1,     1024, 0xcfc8799f
-0,         66,         66,        1,     5220, 0xe2dee355, S=1,     1024, 0xcfc8799f
+0,         64,         64,        1,     5216, 0xf3399cfa, S=1,     1024, 0xcfc8799f
+0,         65,         65,        1,     5394, 0xe0c801ca, S=1,     1024, 0xcfc8799f
+0,         66,         66,        1,     5219, 0xff22e354, S=1,     1024, 0xcfc8799f
 0,         67,         67,        1,     5704, 0xcfbcd55e, S=1,     1024, 0xcfc8799f
 0,         68,         68,        1,     5636, 0x7fc2a1e5, S=1,     1024, 0xcfc8799f
 0,         69,         69,        1,     5818, 0x6090ebbd, S=1,     1024, 0xcfc8799f
@@ -87,7 +87,7 @@ 
 0,         81,         81,        1,     8358, 0x118781e0, S=1,     1024, 0xcfc8799f
 0,         82,         82,        1,     7708, 0xfc0c963d, S=1,     1024, 0xcfc8799f
 0,         83,         83,        1,     7412, 0xdcc311ee, S=1,     1024, 0xcfc8799f
-0,         84,         84,        1,     7541, 0x4d2819c1, S=1,     1024, 0xcfc8799f
+0,         84,         84,        1,     7540, 0x32fe19c0, S=1,     1024, 0xcfc8799f
 0,         85,         85,        1,     7948, 0xf12eca3d, S=1,     1024, 0xcfc8799f
 0,         86,         86,        1,     8408, 0x43add468, S=1,     1024, 0xcfc8799f
 0,         87,         87,        1,     8056, 0x2d162377, S=1,     1024, 0xcfc8799f
@@ -97,12 +97,12 @@ 
 0,         91,         91,        1,     7768, 0xb01e795a, S=1,     1024, 0xcfc8799f
 0,         92,         92,        1,     7749, 0x6ab39c12, S=1,     1024, 0xcfc8799f
 0,         93,         93,        1,     8047, 0x0e5f24aa, S=1,     1024, 0xcfc8799f
-0,         94,         94,        1,     7618, 0xd787340f, S=1,     1024, 0xcfc8799f
+0,         94,         94,        1,     7617, 0xa2c2340e, S=1,     1024, 0xcfc8799f
 0,         95,         95,        1,     7979, 0x0824c4df, S=1,     1024, 0xcfc8799f
 0,         96,         96,        1,    12062, 0xc46d9d92, S=1,     1024, 0xcfc8799f
 0,         97,         97,        1,    12317, 0x1314dc0c, S=1,     1024, 0xcfc8799f
 0,         98,         98,        1,    12217, 0x78c2ed30, S=1,     1024, 0xcfc8799f
-0,         99,         99,        1,    11227, 0x2a578eb9, S=1,     1024, 0xcfc8799f
+0,         99,         99,        1,    11226, 0x9ac08eb8, S=1,     1024, 0xcfc8799f
 0,        100,        100,        1,    11108, 0x4eaa068c, S=1,     1024, 0xcfc8799f
 0,        101,        101,        1,    11366, 0x48f8993f, S=1,     1024, 0xcfc8799f
 0,        102,        102,        1,    11896, 0x32414841, S=1,     1024, 0xcfc8799f
@@ -139,7 +139,7 @@ 
 0,        133,        133,        1,    17934, 0xb22cc97d, S=1,     1024, 0xcfc8799f
 0,        134,        134,        1,    17944, 0x0cd309c6, S=1,     1024, 0xcfc8799f
 0,        135,        135,        1,    18238, 0x6b7e3237, S=1,     1024, 0xcfc8799f
-0,        136,        136,        1,    18391, 0x4df3c48a, S=1,     1024, 0xcfc8799f
+0,        136,        136,        1,    18390, 0x888fc489, S=1,     1024, 0xcfc8799f
 0,        137,        137,        1,    18543, 0x90a2f238, S=1,     1024, 0xcfc8799f
 0,        138,        138,        1,    18939, 0xc57dda5b, S=1,     1024, 0xcfc8799f
 0,        139,        139,        1,    19145, 0x1267294a, S=1,     1024, 0xcfc8799f
@@ -170,7 +170,7 @@ 
 0,        164,        164,        1,    22460, 0x33e6bbfe, S=1,     1024, 0xcfc8799f
 0,        165,        165,        1,    22861, 0x18993510, S=1,     1024, 0xcfc8799f
 0,        166,        166,        1,    22746, 0xdff85615, S=1,     1024, 0xcfc8799f
-0,        167,        167,        1,    23165, 0xf0ac66a3, S=1,     1024, 0xcfc8799f
+0,        167,        167,        1,    23164, 0x899866a2, S=1,     1024, 0xcfc8799f
 0,        168,        168,        1,    23273, 0x13869ad9, S=1,     1024, 0xcfc8799f
 0,        169,        169,        1,    23211, 0xd30b6205, S=1,     1024, 0xcfc8799f
 0,        170,        170,        1,    23648, 0xa0cef01b, S=1,     1024, 0xcfc8799f