[FFmpeg-devel,1/2] avcodec: rewrite gif muxing and encoding

Submitted by Paul B Mahol on Dec. 11, 2018, 8:40 p.m.

Details

Message ID 20181211204016.31023-1-onemda@gmail.com
State Accepted
Headers show

Commit Message

Paul B Mahol Dec. 11, 2018, 8:40 p.m.
Now "-c copy" works.
Update FATE files.

Fixes #6640.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/gif.c                | 121 ++++++-----
 libavformat/gif.c               | 242 ++++++++++------------
 tests/ref/fate/gifenc-bgr4_byte | 346 ++++++++++++++++----------------
 tests/ref/fate/gifenc-bgr8      | 346 ++++++++++++++++----------------
 tests/ref/fate/gifenc-gray      | 346 ++++++++++++++++----------------
 tests/ref/fate/gifenc-pal8      | 346 ++++++++++++++++----------------
 tests/ref/fate/gifenc-rgb4_byte | 346 ++++++++++++++++----------------
 tests/ref/fate/gifenc-rgb8      | 346 ++++++++++++++++----------------
 8 files changed, 1211 insertions(+), 1228 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/gif.c b/libavcodec/gif.c
index d9c99d52cf..ef04fabe86 100644
--- a/libavcodec/gif.c
+++ b/libavcodec/gif.c
@@ -39,17 +39,19 @@ 
 
 #include "put_bits.h"
 
+#define DEFAULT_TRANSPARENCY_INDEX 0x1f
+
 typedef struct GIFContext {
     const AVClass *class;
     LZWState *lzw;
     uint8_t *buf;
     int buf_size;
+    int is_first_frame;
     AVFrame *last_frame;
     int flags;
     uint32_t palette[AVPALETTE_COUNT];  ///< local reference palette for !pal8
     int palette_loaded;
     int transparent_index;
-    uint8_t *pal_exdata;
     uint8_t *tmpl;                      ///< temporary line buffer
 } GIFContext;
 
@@ -58,6 +60,24 @@  enum {
     GF_TRANSDIFF  = 1<<1,
 };
 
+static int get_palette_transparency_index(const uint32_t *palette)
+{
+    int transparent_color_index = -1;
+    unsigned i, smallest_alpha = 0xff;
+
+    if (!palette)
+        return -1;
+
+    for (i = 0; i < AVPALETTE_COUNT; i++) {
+        const uint32_t v = palette[i];
+        if (v >> 24 < smallest_alpha) {
+            smallest_alpha = v >> 24;
+            transparent_color_index = i;
+        }
+    }
+    return smallest_alpha < 128 ? transparent_color_index : -1;
+}
+
 static int pick_palette_entry(const uint8_t *buf, int linesize, int w, int h)
 {
     int histogram[AVPALETTE_COUNT] = {0};
@@ -83,7 +103,7 @@  static int gif_image_write_image(AVCodecContext *avctx,
     GIFContext *s = avctx->priv_data;
     int len = 0, height = avctx->height, width = avctx->width, x, y;
     int x_start = 0, y_start = 0, trans = s->transparent_index;
-    int honor_transparency = (s->flags & GF_TRANSDIFF) && s->last_frame && !palette;
+    int bcid = -1, honor_transparency = (s->flags & GF_TRANSDIFF) && s->last_frame && !palette;
     const uint8_t *ptr;
 
     /* Crop image */
@@ -137,6 +157,54 @@  static int gif_image_write_image(AVCodecContext *avctx,
                width, height, x_start, y_start, avctx->width, avctx->height);
     }
 
+    if (s->is_first_frame) { /* GIF header */
+        const uint32_t *global_palette = palette ? palette : s->palette;
+        const AVRational sar = avctx->sample_aspect_ratio;
+        int64_t aspect = 0;
+
+        if (sar.num > 0 && sar.den > 0) {
+            aspect = sar.num * 64LL / sar.den - 15;
+            if (aspect < 0 || aspect > 255)
+                aspect = 0;
+        }
+
+        bytestream_put_buffer(bytestream, gif89a_sig, sizeof(gif89a_sig));
+        bytestream_put_le16(bytestream, avctx->width);
+        bytestream_put_le16(bytestream, avctx->height);
+
+        bcid = get_palette_transparency_index(global_palette);
+
+        bytestream_put_byte(bytestream, 0xf7); /* flags: global clut, 256 entries */
+        bytestream_put_byte(bytestream, bcid < 0 ? DEFAULT_TRANSPARENCY_INDEX : bcid); /* background color index */
+        bytestream_put_byte(bytestream, aspect);
+        for (int i = 0; i < 256; i++) {
+            const uint32_t v = global_palette[i] & 0xffffff;
+            bytestream_put_be24(bytestream, v);
+        }
+
+        s->is_first_frame = 0;
+    }
+
+    if (honor_transparency && trans < 0) {
+        trans = pick_palette_entry(buf + y_start*linesize + x_start,
+                                   linesize, width, height);
+        if (trans < 0) // TODO, patch welcome
+            av_log(avctx, AV_LOG_DEBUG, "No available color, can not use transparency\n");
+    }
+    if (trans < 0)
+        honor_transparency = 0;
+
+    bcid = (honor_transparency && trans >= 0) ? trans : get_palette_transparency_index(palette);
+
+    /* graphic control extension */
+    bytestream_put_byte(bytestream, GIF_EXTENSION_INTRODUCER);
+    bytestream_put_byte(bytestream, GIF_GCE_EXT_LABEL);
+    bytestream_put_byte(bytestream, 0x04); /* block size */
+    bytestream_put_byte(bytestream, 1<<2 | (bcid >= 0));
+    bytestream_put_le16(bytestream, 5); // default delay
+    bytestream_put_byte(bytestream, bcid < 0 ? DEFAULT_TRANSPARENCY_INDEX : bcid);
+    bytestream_put_byte(bytestream, 0x00);
+
     /* image block */
     bytestream_put_byte(bytestream, GIF_IMAGE_SEPARATOR);
     bytestream_put_le16(bytestream, x_start);
@@ -155,24 +223,6 @@  static int gif_image_write_image(AVCodecContext *avctx,
         }
     }
 
-    if (honor_transparency && trans < 0) {
-        trans = pick_palette_entry(buf + y_start*linesize + x_start,
-                                   linesize, width, height);
-        if (trans < 0) { // TODO, patch welcome
-            av_log(avctx, AV_LOG_DEBUG, "No available color, can not use transparency\n");
-        } else {
-            uint8_t *pal_exdata = s->pal_exdata;
-            if (!pal_exdata)
-                pal_exdata = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
-            if (!pal_exdata)
-                return AVERROR(ENOMEM);
-            memcpy(pal_exdata, s->palette, AVPALETTE_SIZE);
-            pal_exdata[trans*4 + 3*!HAVE_BIGENDIAN] = 0x00;
-        }
-    }
-    if (trans < 0)
-        honor_transparency = 0;
-
     bytestream_put_byte(bytestream, 0x08);
 
     ff_lzw_encode_init(s->lzw, s->buf, s->buf_size,
@@ -230,6 +280,7 @@  FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
     s->transparent_index = -1;
+    s->is_first_frame = 1;
 
     s->lzw = av_mallocz(ff_lzw_encode_state_size);
     s->buf_size = avctx->width*avctx->height*2 + 1000;
@@ -244,25 +295,6 @@  FF_ENABLE_DEPRECATION_WARNINGS
     return 0;
 }
 
-/* FIXME: duplicated with lavc */
-static int get_palette_transparency_index(const uint32_t *palette)
-{
-    int transparent_color_index = -1;
-    unsigned i, smallest_alpha = 0xff;
-
-    if (!palette)
-        return -1;
-
-    for (i = 0; i < AVPALETTE_COUNT; i++) {
-        const uint32_t v = palette[i];
-        if (v >> 24 < smallest_alpha) {
-            smallest_alpha = v >> 24;
-            transparent_color_index = i;
-        }
-    }
-    return smallest_alpha < 128 ? transparent_color_index : -1;
-}
-
 static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                             const AVFrame *pict, int *got_packet)
 {
@@ -277,22 +309,12 @@  static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     end        = pkt->data + pkt->size;
 
     if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
-        uint8_t *pal_exdata = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
-        if (!pal_exdata)
-            return AVERROR(ENOMEM);
-        memcpy(pal_exdata, pict->data[1], AVPALETTE_SIZE);
         palette = (uint32_t*)pict->data[1];
 
-        s->pal_exdata = pal_exdata;
-
-        /* The first palette with PAL8 will be used as generic palette by the
-         * muxer so we don't need to write it locally in the packet. We store
-         * it as a reference here in case it changes later. */
         if (!s->palette_loaded) {
             memcpy(s->palette, palette, AVPALETTE_SIZE);
             s->transparent_index = get_palette_transparency_index(palette);
             s->palette_loaded = 1;
-            palette = NULL;
         } else if (!memcmp(s->palette, palette, AVPALETTE_SIZE)) {
             palette = NULL;
         }
@@ -305,6 +327,7 @@  static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         if (!s->last_frame)
             return AVERROR(ENOMEM);
     }
+
     av_frame_unref(s->last_frame);
     ret = av_frame_ref(s->last_frame, (AVFrame*)pict);
     if (ret < 0)
diff --git a/libavformat/gif.c b/libavformat/gif.c
index 62d995a907..cb6aefbe8c 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -27,94 +27,21 @@ 
 #include "libavutil/imgutils.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
+#include "libavcodec/bytestream.h"
 #include "libavcodec/gif.h"
 
-/* XXX: random value that shouldn't be taken into effect if there is no
- * transparent color in the palette (the transparency bit will be set to 0) */
-#define DEFAULT_TRANSPARENCY_INDEX 0x1f
-
-static int get_palette_transparency_index(const uint32_t *palette)
-{
-    int transparent_color_index = -1;
-    unsigned i, smallest_alpha = 0xff;
-
-    if (!palette)
-        return -1;
-
-    for (i = 0; i < AVPALETTE_COUNT; i++) {
-        const uint32_t v = palette[i];
-        if (v >> 24 < smallest_alpha) {
-            smallest_alpha = v >> 24;
-            transparent_color_index = i;
-        }
-    }
-    return smallest_alpha < 128 ? transparent_color_index : -1;
-}
-
-static int gif_image_write_header(AVIOContext *pb, AVStream *st,
-                                  int loop_count, uint32_t *palette)
-{
-    int i;
-    int64_t aspect = 0;
-    const AVRational sar = st->sample_aspect_ratio;
-
-    if (sar.num > 0 && sar.den > 0) {
-        aspect = sar.num * 64LL / sar.den - 15;
-        if (aspect < 0 || aspect > 255)
-            aspect = 0;
-    }
-
-    avio_write(pb, gif89a_sig, sizeof(gif89a_sig));
-    avio_wl16(pb, st->codecpar->width);
-    avio_wl16(pb, st->codecpar->height);
-
-    if (palette) {
-        const int bcid = get_palette_transparency_index(palette);
-
-        avio_w8(pb, 0xf7); /* flags: global clut, 256 entries */
-        avio_w8(pb, bcid < 0 ? DEFAULT_TRANSPARENCY_INDEX : bcid); /* background color index */
-        avio_w8(pb, aspect);
-        for (i = 0; i < 256; i++) {
-            const uint32_t v = palette[i] & 0xffffff;
-            avio_wb24(pb, v);
-        }
-    } else {
-        avio_w8(pb, 0); /* flags */
-        avio_w8(pb, 0); /* background color index */
-        avio_w8(pb, aspect);
-    }
-
-
-    if (loop_count >= 0 ) {
-        /* "NETSCAPE EXTENSION" for looped animation GIF */
-        avio_w8(pb, 0x21); /* GIF Extension code */
-        avio_w8(pb, 0xff); /* Application Extension Label */
-        avio_w8(pb, 0x0b); /* Length of Application Block */
-        avio_write(pb, "NETSCAPE2.0", sizeof("NETSCAPE2.0") - 1);
-        avio_w8(pb, 0x03); /* Length of Data Sub-Block */
-        avio_w8(pb, 0x01);
-        avio_wl16(pb, (uint16_t)loop_count);
-        avio_w8(pb, 0x00); /* Data Sub-block Terminator */
-    }
-
-    avio_flush(pb);
-    return 0;
-}
-
 typedef struct GIFContext {
     AVClass *class;
     int loop;
     int last_delay;
-    AVPacket *prev_pkt;
     int duration;
+    int64_t last_pos;
+    int have_end;
+    AVPacket *prev_pkt;
 } GIFContext;
 
 static int gif_write_header(AVFormatContext *s)
 {
-    GIFContext *gif = s->priv_data;
-    AVCodecParameters *video_par;
-    uint32_t palette[AVPALETTE_COUNT];
-
     if (s->nb_streams != 1 ||
         s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
         s->streams[0]->codecpar->codec_id   != AV_CODEC_ID_GIF) {
@@ -123,92 +50,123 @@  static int gif_write_header(AVFormatContext *s)
         return AVERROR(EINVAL);
     }
 
-    video_par = s->streams[0]->codecpar;
-
     avpriv_set_pts_info(s->streams[0], 64, 1, 100);
-    if (avpriv_set_systematic_pal2(palette, video_par->format) < 0) {
-        av_assert0(video_par->format == AV_PIX_FMT_PAL8);
-        /* delay header writing: we wait for the first palette to put it
-         * globally */
-    } else {
-        gif_image_write_header(s->pb, s->streams[0], gif->loop, palette);
-    }
 
     return 0;
 }
 
-static int flush_packet(AVFormatContext *s, AVPacket *new)
+static int gif_parse_packet(AVFormatContext *s, uint8_t *data, int size)
 {
-    GIFContext *gif = s->priv_data;
-    int size, bcid;
-    AVIOContext *pb = s->pb;
-    const uint32_t *palette;
-    AVPacket *pkt = gif->prev_pkt;
-
-    if (!pkt)
-        return 0;
+    GetByteContext gb;
+    int x;
+
+    bytestream2_init(&gb, data, size);
+
+    while (bytestream2_get_bytes_left(&gb) > 0) {
+        x = bytestream2_get_byte(&gb);
+        if (x != 0x21)
+            return 0;
+
+        x = bytestream2_get_byte(&gb);
+        while (x != 0xf9 && bytestream2_get_bytes_left(&gb) > 0) {
+            int block_size = bytestream2_get_byte(&gb);
+            if (!block_size)
+                break;
+            bytestream2_skip(&gb, block_size);
+        }
 
-    /* Mark one colour as transparent if the input palette contains at least
-     * one colour that is more than 50% transparent. */
-    palette = (uint32_t*)av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size);
-    if (palette && size != AVPALETTE_SIZE) {
-        av_log(s, AV_LOG_ERROR, "Invalid palette extradata\n");
-        return AVERROR_INVALIDDATA;
+        if (x == 0xf9)
+            return bytestream2_tell(&gb) + 2;
     }
-    bcid = get_palette_transparency_index(palette);
 
+    return 0;
+}
+
+static int gif_get_delay(GIFContext *gif, AVPacket *prev, AVPacket *new)
+{
     if (new && new->pts != AV_NOPTS_VALUE)
-        gif->duration = av_clip_uint16(new->pts - gif->prev_pkt->pts);
+        return av_clip_uint16(new->pts - prev->pts);
     else if (!new && gif->last_delay >= 0)
-        gif->duration = gif->last_delay;
-
-    /* graphic control extension block */
-    avio_w8(pb, 0x21);
-    avio_w8(pb, 0xf9);
-    avio_w8(pb, 0x04); /* block size */
-    avio_w8(pb, 1<<2 | (bcid >= 0));
-    avio_wl16(pb, gif->duration);
-    avio_w8(pb, bcid < 0 ? DEFAULT_TRANSPARENCY_INDEX : bcid);
-    avio_w8(pb, 0x00);
+        return gif->last_delay;
 
-    avio_write(pb, pkt->data, pkt->size);
-
-    av_packet_unref(gif->prev_pkt);
-    if (new)
-        av_packet_ref(gif->prev_pkt, new);
-
-    return 0;
+    return 5;
 }
 
-static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
+static int gif_write_packet(AVFormatContext *s, AVPacket *new_pkt)
 {
     GIFContext *gif = s->priv_data;
-    AVStream *video_st = s->streams[0];
+    AVIOContext *pb = s->pb;
+    AVPacket *pkt = gif->prev_pkt;
 
     if (!gif->prev_pkt) {
         gif->prev_pkt = av_packet_alloc();
         if (!gif->prev_pkt)
             return AVERROR(ENOMEM);
+        return av_packet_ref(gif->prev_pkt, new_pkt);
+    }
+
+    gif->last_pos = avio_tell(pb);
+    if (pkt->size > 0)
+        gif->have_end = pkt->data[pkt->size - 1] == GIF_TRAILER;
 
-        /* Write the first palette as global palette */
-        if (video_st->codecpar->format == AV_PIX_FMT_PAL8) {
-            int size;
-            void *palette = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size);
-
-            if (!palette) {
-                av_log(s, AV_LOG_ERROR, "PAL8 packet is missing palette in extradata\n");
-                return AVERROR_INVALIDDATA;
-            }
-            if (size != AVPALETTE_SIZE) {
-                av_log(s, AV_LOG_ERROR, "Invalid palette extradata\n");
-                return AVERROR_INVALIDDATA;
-            }
-            gif_image_write_header(s->pb, video_st, gif->loop, palette);
+    if (!gif->last_pos) {
+        int delay_pos;
+        int off = 13;
+
+        if (pkt->size < 13)
+            return AVERROR(EINVAL);
+
+        if (pkt->data[10] & 0x80)
+            off += 3 * (1 << ((pkt->data[10] & 0x07) + 1));
+
+        if (pkt->size < off + 2)
+            return AVERROR(EINVAL);
+
+        avio_write(pb, pkt->data, off);
+
+        if (pkt->data[off] == 0x21 && pkt->data[off + 1] == 0xff)
+            off += 19;
+
+        if (pkt->size <= off)
+            return AVERROR(EINVAL);
+
+        /* "NETSCAPE EXTENSION" for looped animation GIF */
+        if (gif->loop >= 0) {
+            avio_w8(pb, 0x21); /* GIF Extension code */
+            avio_w8(pb, 0xff); /* Application Extension Label */
+            avio_w8(pb, 0x0b); /* Length of Application Block */
+            avio_write(pb, "NETSCAPE2.0", sizeof("NETSCAPE2.0") - 1);
+            avio_w8(pb, 0x03); /* Length of Data Sub-Block */
+            avio_w8(pb, 0x01);
+            avio_wl16(pb, (uint16_t)gif->loop);
+            avio_w8(pb, 0x00); /* Data Sub-block Terminator */
         }
 
-        return av_packet_ref(gif->prev_pkt, pkt);
+        delay_pos = gif_parse_packet(s, pkt->data + off, pkt->size - off);
+        if (delay_pos > 0 && delay_pos < pkt->size - off - 2) {
+            avio_write(pb, pkt->data + off, delay_pos);
+            avio_wl16(pb, gif_get_delay(gif, pkt, new_pkt));
+            avio_write(pb, pkt->data + off + delay_pos + 2, pkt->size - off - delay_pos - 2);
+        } else {
+            avio_write(pb, pkt->data + off, pkt->size - off);
+        }
+    } else {
+        int delay_pos = gif_parse_packet(s, pkt->data, pkt->size);
+
+        if (delay_pos > 0 && delay_pos < pkt->size - 2) {
+            avio_write(pb, pkt->data, delay_pos);
+            avio_wl16(pb, gif_get_delay(gif, pkt, new_pkt));
+            avio_write(pb, pkt->data + delay_pos + 2, pkt->size - delay_pos - 2);
+        } else {
+            avio_write(pb, pkt->data, pkt->size);
+        }
     }
-    return flush_packet(s, pkt);
+
+    av_packet_unref(gif->prev_pkt);
+    if (new_pkt)
+        return av_packet_ref(gif->prev_pkt, new_pkt);
+
+    return 0;
 }
 
 static int gif_write_trailer(AVFormatContext *s)
@@ -216,9 +174,11 @@  static int gif_write_trailer(AVFormatContext *s)
     GIFContext *gif = s->priv_data;
     AVIOContext *pb = s->pb;
 
-    flush_packet(s, NULL);
-    av_freep(&gif->prev_pkt);
-    avio_w8(pb, 0x3b);
+    gif_write_packet(s, NULL);
+
+    if (!gif->have_end)
+        avio_w8(pb, GIF_TRAILER);
+    av_packet_free(&gif->prev_pkt);
 
     return 0;
 }
diff --git a/tests/ref/fate/gifenc-bgr4_byte b/tests/ref/fate/gifenc-bgr4_byte
index 3495a8bbed..67088c7d78 100644
--- a/tests/ref/fate/gifenc-bgr4_byte
+++ b/tests/ref/fate/gifenc-bgr4_byte
@@ -3,176 +3,176 @@ 
 #codec_id 0: gif
 #dimensions 0: 217x217
 #sar 0: 0/1
-0,          0,          0,        1,      508, 0xa1b80fc0
-0,          1,          1,        1,      213, 0x4f554bd7, S=1,     1024, 0xb6327c81
-0,          2,          2,        1,      131, 0x283b2988, 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,          7,          7,        1,      535, 0x326ce62a, S=1,     1024, 0x9e4a7c81
-0,          8,          8,        1,      438, 0x34d6b7c0, 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,         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,         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,         24,         24,        1,     1900, 0x2ea879d1, S=1,     1024, 0xde0a7c81
-0,         25,         25,        1,     1807, 0x02b35230, 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,         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,         36,         36,        1,     3814, 0x1869d3f4, S=1,     1024, 0xde0a7c81
-0,         37,         37,        1,     3627, 0x19bd7da7, 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,         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,         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,         50,         50,        1,     5266, 0x21c695aa, S=1,     1024, 0xde0a7c81
-0,         51,         51,        1,     5416, 0xf305e3ed, 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
-0,         55,         55,        1,     6233, 0x8fd2511e, S=1,     1024, 0xde0a7c81
-0,         56,         56,        1,     5911, 0x92d4c516, S=1,     1024, 0xde0a7c81
-0,         57,         57,        1,     5997, 0xbd7cfa15, S=1,     1024, 0xde0a7c81
-0,         58,         58,        1,     5946, 0x8f5fedff, S=1,     1024, 0xde0a7c81
-0,         59,         59,        1,     6468, 0x45c0cb8c, S=1,     1024, 0xde0a7c81
-0,         60,         60,        1,     6737, 0x4e1e39ac, S=1,     1024, 0xde0a7c81
-0,         61,         61,        1,     6275, 0x1d5e8f4c, S=1,     1024, 0xde0a7c81
-0,         62,         62,        1,     6641, 0x844b3aad, S=1,     1024, 0xde0a7c81
-0,         63,         63,        1,     6378, 0x52568640, S=1,     1024, 0xde0a7c81
-0,         64,         64,        1,     6257, 0xfabc585f, S=1,     1024, 0xde0a7c81
-0,         65,         65,        1,     6908, 0xf261701c, S=1,     1024, 0xde0a7c81
-0,         66,         66,        1,     7230, 0xb4f524ce, S=1,     1024, 0xde0a7c81
-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,         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
-0,         74,         74,        1,     8101, 0x44ceb3a2, S=1,     1024, 0xde0a7c81
-0,         75,         75,        1,     7863, 0x55043dfd, S=1,     1024, 0xde0a7c81
-0,         76,         76,        1,     7960, 0x38399182, S=1,     1024, 0xde0a7c81
-0,         77,         77,        1,     8238, 0x1d52ecf3, S=1,     1024, 0xde0a7c81
-0,         78,         78,        1,     8321, 0xd8d24a5c, S=1,     1024, 0xde0a7c81
-0,         79,         79,        1,     8562, 0x4a0cc02b, S=1,     1024, 0xde0a7c81
-0,         80,         80,        1,     8746, 0x2db40da7, S=1,     1024, 0xde0a7c81
-0,         81,         81,        1,     8578, 0x46f9a4c1, S=1,     1024, 0xde0a7c81
-0,         82,         82,        1,     8878, 0xf58d5a19, S=1,     1024, 0xde0a7c81
-0,         83,         83,        1,     9077, 0x78de57f6, S=1,     1024, 0xde0a7c81
-0,         84,         84,        1,     9310, 0x8c10f77a, S=1,     1024, 0xde0a7c81
-0,         85,         85,        1,     9394, 0x741f431e, S=1,     1024, 0xde0a7c81
-0,         86,         86,        1,     9161, 0x6f499587, S=1,     1024, 0xde0a7c81
-0,         87,         87,        1,     9462, 0x628936c3, S=1,     1024, 0xde0a7c81
-0,         88,         88,        1,     9650, 0x4cb4936e, S=1,     1024, 0xde0a7c81
-0,         89,         89,        1,     9701, 0x5e069c40, S=1,     1024, 0xde0a7c81
-0,         90,         90,        1,     9523, 0x66a13c83, S=1,     1024, 0xde0a7c81
-0,         91,         91,        1,     9891, 0x43ea0e93, S=1,     1024, 0xde0a7c81
-0,         92,         92,        1,    10005, 0x96a849e7, S=1,     1024, 0xde0a7c81
-0,         93,         93,        1,    10038, 0x68032d25, S=1,     1024, 0xde0a7c81
-0,         94,         94,        1,    10086, 0xef59458d, S=1,     1024, 0xde0a7c81
-0,         95,         95,        1,    10438, 0x3466fed0, S=1,     1024, 0xde0a7c81
-0,         96,         96,        1,    10583, 0x8bdd5477, S=1,     1024, 0xde0a7c81
-0,         97,         97,        1,    10581, 0x69d27fee, S=1,     1024, 0xde0a7c81
-0,         98,         98,        1,    10807, 0xde62d6e3, S=1,     1024, 0xde0a7c81
-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,        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,        107,        107,        1,    11932, 0x722abcbe, S=1,     1024, 0xde0a7c81
-0,        108,        108,        1,    12281, 0x0d136f53, 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,        113,        113,        1,    12957, 0x4da59f8c, S=1,     1024, 0xde0a7c81
-0,        114,        114,        1,    13054, 0x7abedf5a, 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,        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
-0,        121,        121,        1,    13665, 0x94caddde, S=1,     1024, 0xde0a7c81
-0,        122,        122,        1,    13692, 0xe38febd9, S=1,     1024, 0xde0a7c81
-0,        123,        123,        1,    13821, 0xee592e62, S=1,     1024, 0xde0a7c81
-0,        124,        124,        1,    13946, 0xceb09235, S=1,     1024, 0xde0a7c81
-0,        125,        125,        1,    14063, 0x7361d2f5, S=1,     1024, 0xde0a7c81
-0,        126,        126,        1,    14124, 0x226bcac1, S=1,     1024, 0xde0a7c81
-0,        127,        127,        1,    14331, 0x0649512b, S=1,     1024, 0xde0a7c81
-0,        128,        128,        1,    14469, 0x0d7da45b, S=1,     1024, 0xde0a7c81
-0,        129,        129,        1,    14536, 0x73cca242, S=1,     1024, 0xde0a7c81
-0,        130,        130,        1,    14608, 0x1f3dd14e, S=1,     1024, 0xde0a7c81
-0,        131,        131,        1,    14898, 0xd13d258e, S=1,     1024, 0xde0a7c81
-0,        132,        132,        1,    14978, 0xfa049fea, S=1,     1024, 0xde0a7c81
-0,        133,        133,        1,    15142, 0x1dfad60c, S=1,     1024, 0xde0a7c81
-0,        134,        134,        1,    15129, 0x5962bae7, S=1,     1024, 0xde0a7c81
-0,        135,        135,        1,    15243, 0x2c2c113b, S=1,     1024, 0xde0a7c81
-0,        136,        136,        1,    15337, 0x3cab623b, S=1,     1024, 0xde0a7c81
-0,        137,        137,        1,    15638, 0xbff3a100, S=1,     1024, 0xde0a7c81
-0,        138,        138,        1,    15912, 0x13bf1fb2, S=1,     1024, 0xde0a7c81
-0,        139,        139,        1,    16041, 0x01134246, S=1,     1024, 0xde0a7c81
-0,        140,        140,        1,    16228, 0xe2f80035, S=1,     1024, 0xde0a7c81
-0,        141,        141,        1,    16262, 0xc8d3ea51, S=1,     1024, 0xde0a7c81
-0,        142,        142,        1,    16371, 0xe7da07f2, S=1,     1024, 0xde0a7c81
-0,        143,        143,        1,    16661, 0x10ada592, S=1,     1024, 0xde0a7c81
-0,        144,        144,        1,    16917, 0xbfb717e5, S=1,     1024, 0xde0a7c81
-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,        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
-0,        153,        153,        1,    17918, 0xb78d9b9f, S=1,     1024, 0xde0a7c81
-0,        154,        154,        1,    17823, 0xc9fabf19, S=1,     1024, 0xde0a7c81
-0,        155,        155,        1,    18142, 0xeb5b21a9, S=1,     1024, 0xde0a7c81
-0,        156,        156,        1,    18257, 0x7b38822c, S=1,     1024, 0xde0a7c81
-0,        157,        157,        1,    18337, 0xd395c279, S=1,     1024, 0xde0a7c81
-0,        158,        158,        1,    18293, 0x6c3b3766, S=1,     1024, 0xde0a7c81
-0,        159,        159,        1,    18418, 0x2abcbcf8, S=1,     1024, 0xde0a7c81
-0,        160,        160,        1,    18607, 0x79424730, S=1,     1024, 0xde0a7c81
-0,        161,        161,        1,    18916, 0x8707bbc6, S=1,     1024, 0xde0a7c81
-0,        162,        162,        1,    19073, 0xd82c03f6, S=1,     1024, 0xde0a7c81
-0,        163,        163,        1,    19168, 0xb7d6fe27, S=1,     1024, 0xde0a7c81
-0,        164,        164,        1,    19210, 0x79f301eb, S=1,     1024, 0xde0a7c81
-0,        165,        165,        1,    19398, 0x0a5663c6, S=1,     1024, 0xde0a7c81
-0,        166,        166,        1,    19480, 0x4fe09e5b, S=1,     1024, 0xde0a7c81
-0,        167,        167,        1,    19659, 0xab971088, S=1,     1024, 0xde0a7c81
-0,        168,        168,        1,    19672, 0x2e331553, S=1,     1024, 0xde0a7c81
-0,        169,        169,        1,    19936, 0x2eea628a, S=1,     1024, 0xde0a7c81
-0,        170,        170,        1,    19975, 0xd6bb9ab2, S=1,     1024, 0xde0a7c81
-0,        171,        171,        1,    20021, 0xf7e98dc5, S=1,     1024, 0xde0a7c81
-0,        172,        172,        1,    20060, 0x20017807, S=1,     1024, 0xde0a7c81
+0,          0,          0,        1,     1297, 0x53e8b1c1
+0,          1,          1,        1,      221, 0x52d24d05
+0,          2,          2,        1,      139, 0xc9e32ab4
+0,          3,          3,        1,      392, 0x9244a858
+0,          4,          4,        1,      389, 0xc5bea3e0
+0,          5,          5,        1,      438, 0xfa2ab3d6
+0,          6,          6,        1,      526, 0x281ed94f
+0,          7,          7,        1,      543, 0xa53ee752
+0,          8,          8,        1,      446, 0x41d0b8ee
+0,          9,          9,        1,      931, 0xe8efa4aa
+0,         10,         10,        1,      702, 0x2d1c4ad3
+0,         11,         11,        1,     1202, 0xf0cc2be3
+0,         12,         12,        1,     1299, 0x189f54cb
+0,         13,         13,        1,     1253, 0xcb883414
+0,         14,         14,        1,     1338, 0xad6a52d2
+0,         15,         15,        1,     1284, 0x14993a0a
+0,         16,         16,        1,     1483, 0x216c991d
+0,         17,         17,        1,     1792, 0x58eb4c1e
+0,         18,         18,        1,     1683, 0x0b49fbbe
+0,         19,         19,        1,     1517, 0x9b57ab38
+0,         20,         20,        1,     1713, 0x23f21b0d
+0,         21,         21,        1,     1753, 0xe1e21eec
+0,         22,         22,        1,     1650, 0xf258037d
+0,         23,         23,        1,     1726, 0x73111ff6
+0,         24,         24,        1,     1908, 0x430b7b09
+0,         25,         25,        1,     1815, 0xa5af5368
+0,         26,         26,        1,     1923, 0x497f847c
+0,         27,         27,        1,     2108, 0x5e2ed19b
+0,         28,         28,        1,     2708, 0x6064f1c3
+0,         29,         29,        1,     2681, 0x7c4ea945
+0,         30,         30,        1,     2903, 0x7cbf4985
+0,         31,         31,        1,     3265, 0x81f7d05c
+0,         32,         32,        1,     3187, 0x6077c273
+0,         33,         33,        1,     3304, 0x3632e867
+0,         34,         34,        1,     3608, 0x7961776c
+0,         35,         35,        1,     3707, 0x515aa11b
+0,         36,         36,        1,     3822, 0x4a03d52c
+0,         37,         37,        1,     3635, 0x67607edf
+0,         38,         38,        1,     2958, 0x18e8618d
+0,         39,         39,        1,     3094, 0x1f1990fa
+0,         40,         40,        1,     3102, 0xde16868b
+0,         41,         41,        1,     3464, 0x7e6f2dba
+0,         42,         42,        1,     4116, 0x91585d9e
+0,         43,         43,        1,     4225, 0x9c785cdc
+0,         44,         44,        1,     3621, 0x0d0a4ebb
+0,         45,         45,        1,     3918, 0xa70ae7ca
+0,         46,         46,        1,     4469, 0xa318e475
+0,         47,         47,        1,     4601, 0x1ae12f09
+0,         48,         48,        1,     4830, 0x57b999bb
+0,         49,         49,        1,     5406, 0x744cc456
+0,         50,         50,        1,     5274, 0x3d6996e2
+0,         51,         51,        1,     5424, 0xc587e525
+0,         52,         52,        1,     5527, 0xd5870857
+0,         53,         53,        1,     5709, 0xbd715dd4
+0,         54,         54,        1,     6168, 0xa5c13fbb
+0,         55,         55,        1,     6241, 0x46485256
+0,         56,         56,        1,     5919, 0xc0bcc64e
+0,         57,         57,        1,     6005, 0x5443fb4d
+0,         58,         58,        1,     5954, 0xe7efef37
+0,         59,         59,        1,     6476, 0x1aadccc4
+0,         60,         60,        1,     6745, 0x6af23ae4
+0,         61,         61,        1,     6283, 0x07049084
+0,         62,         62,        1,     6649, 0x2c1f3be5
+0,         63,         63,        1,     6386, 0xb9848778
+0,         64,         64,        1,     6265, 0xce725997
+0,         65,         65,        1,     6916, 0xdfac7154
+0,         66,         66,        1,     7238, 0x2ace2606
+0,         67,         67,        1,     7564, 0x8cf9a84a
+0,         68,         68,        1,     7421, 0xaa1a71dc
+0,         69,         69,        1,     7484, 0xc67ba899
+0,         70,         70,        1,     7604, 0x2479e569
+0,         71,         71,        1,     7764, 0x0a1906f8
+0,         72,         72,        1,     8023, 0x27206bb7
+0,         73,         73,        1,     8136, 0x7705bf63
+0,         74,         74,        1,     8109, 0xe05cb4da
+0,         75,         75,        1,     7871, 0xce733f35
+0,         76,         76,        1,     7968, 0x27ef92ba
+0,         77,         77,        1,     8246, 0x5fe7ee2b
+0,         78,         78,        1,     8329, 0x809e4b94
+0,         79,         79,        1,     8570, 0x179fc163
+0,         80,         80,        1,     8754, 0xdb870edf
+0,         81,         81,        1,     8586, 0x280ca5f9
+0,         82,         82,        1,     8886, 0x445e5b51
+0,         83,         83,        1,     9085, 0xba37592e
+0,         84,         84,        1,     9318, 0xe970f8b2
+0,         85,         85,        1,     9402, 0x37ee4456
+0,         86,         86,        1,     9169, 0x171196bf
+0,         87,         87,        1,     9470, 0x793837fb
+0,         88,         88,        1,     9658, 0x489294a6
+0,         89,         89,        1,     9709, 0x980c9d78
+0,         90,         90,        1,     9531, 0xc7a83dbb
+0,         91,         91,        1,     9899, 0x658f0fcb
+0,         92,         92,        1,    10013, 0x434c4b1f
+0,         93,         93,        1,    10046, 0x3cdf2e5d
+0,         94,         94,        1,    10094, 0xfeb546c5
+0,         95,         95,        1,    10446, 0xf0d10017
+0,         96,         96,        1,    10591, 0xf90f55af
+0,         97,         97,        1,    10589, 0xd4948126
+0,         98,         98,        1,    10815, 0x5cb2d81b
+0,         99,         99,        1,    11119, 0x25ca4d4b
+0,        100,        100,        1,    11202, 0xae566cab
+0,        101,        101,        1,    11248, 0x5731a277
+0,        102,        102,        1,    11491, 0x1021f4fd
+0,        103,        103,        1,    11688, 0x6cb05cf9
+0,        104,        104,        1,    11793, 0xf036b8cb
+0,        105,        105,        1,    11444, 0x46d90941
+0,        106,        106,        1,    11936, 0x204acadf
+0,        107,        107,        1,    11940, 0x4bddbdf6
+0,        108,        108,        1,    12289, 0x902d708b
+0,        109,        109,        1,    12342, 0xc85680b0
+0,        110,        110,        1,    12460, 0xf3beb2c0
+0,        111,        111,        1,    12703, 0x96493c66
+0,        112,        112,        1,    12676, 0xdc9250b1
+0,        113,        113,        1,    12965, 0x08dba0c4
+0,        114,        114,        1,    13062, 0xac2ce092
+0,        115,        115,        1,    13155, 0xb6552cf5
+0,        116,        116,        1,    13179, 0x03d61a97
+0,        117,        117,        1,    13206, 0x0d8a5a0c
+0,        118,        118,        1,    13219, 0x039862cb
+0,        119,        119,        1,    13218, 0xede6623f
+0,        120,        120,        1,    13475, 0x7672a260
+0,        121,        121,        1,    13673, 0xaf0ddf16
+0,        122,        122,        1,    13700, 0x1ec9ed11
+0,        123,        123,        1,    13829, 0xc6cb2f9a
+0,        124,        124,        1,    13954, 0x3f89936d
+0,        125,        125,        1,    14071, 0x72d2d42d
+0,        126,        126,        1,    14132, 0x6c34cbf9
+0,        127,        127,        1,    14339, 0x4c695263
+0,        128,        128,        1,    14477, 0xfbcda593
+0,        129,        129,        1,    14544, 0xb3d3a37a
+0,        130,        130,        1,    14616, 0xb704d286
+0,        131,        131,        1,    14906, 0xca9226c6
+0,        132,        132,        1,    14986, 0x54e8a122
+0,        133,        133,        1,    15150, 0x40bed744
+0,        134,        134,        1,    15137, 0x6c4ebc1f
+0,        135,        135,        1,    15251, 0xca081273
+0,        136,        136,        1,    15345, 0x4d266373
+0,        137,        137,        1,    15646, 0x3f64a238
+0,        138,        138,        1,    15920, 0xe12020ea
+0,        139,        139,        1,    16049, 0x6bbb437e
+0,        140,        140,        1,    16236, 0x31a6016d
+0,        141,        141,        1,    16270, 0x40f1eb89
+0,        142,        142,        1,    16379, 0xe4d0092a
+0,        143,        143,        1,    16669, 0x6f22a6ca
+0,        144,        144,        1,    16925, 0x564a191d
+0,        145,        145,        1,    17157, 0xf1c7cb79
+0,        146,        146,        1,    17180, 0xc4b3b5d7
+0,        147,        147,        1,    17323, 0xa670a9d8
+0,        148,        148,        1,    17405, 0xf499125a
+0,        149,        149,        1,    17439, 0xd76af40b
+0,        150,        150,        1,    17584, 0x364d53e5
+0,        151,        151,        1,    17772, 0xbc218e98
+0,        152,        152,        1,    17834, 0xcc19808f
+0,        153,        153,        1,    17926, 0x12639cd7
+0,        154,        154,        1,    17831, 0xb0f9c051
+0,        155,        155,        1,    18150, 0x574022e1
+0,        156,        156,        1,    18265, 0x73458364
+0,        157,        157,        1,    18345, 0x2d31c3b1
+0,        158,        158,        1,    18301, 0x9028389e
+0,        159,        159,        1,    18426, 0xe701be30
+0,        160,        160,        1,    18615, 0x1bfd4868
+0,        161,        161,        1,    18924, 0xa269bcfe
+0,        162,        162,        1,    19081, 0xb2f5052e
+0,        163,        163,        1,    19176, 0x0676ff5f
+0,        164,        164,        1,    19218, 0xfbb40323
+0,        165,        165,        1,    19406, 0x714664fe
+0,        166,        166,        1,    19488, 0x1acf9f93
+0,        167,        167,        1,    19667, 0x50bd11c0
+0,        168,        168,        1,    19680, 0xe322168b
+0,        169,        169,        1,    19944, 0x25b763c2
+0,        170,        170,        1,    19983, 0xfd109bea
+0,        171,        171,        1,    20029, 0x565d8efd
+0,        172,        172,        1,    20068, 0xadee793f
diff --git a/tests/ref/fate/gifenc-bgr8 b/tests/ref/fate/gifenc-bgr8
index 0a4e5d48cd..9dc5144395 100644
--- a/tests/ref/fate/gifenc-bgr8
+++ b/tests/ref/fate/gifenc-bgr8
@@ -3,176 +3,176 @@ 
 #codec_id 0: gif
 #dimensions 0: 217x217
 #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,          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,          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
-0,          9,          9,        1,     1157, 0x741c2da1, S=1,     1024, 0xf351799f
-0,         10,         10,        1,      179, 0x3a27517c, S=1,     1024, 0xf351799f
-0,         11,         11,        1,     1333, 0x5ee76f3c, S=1,     1024, 0xf351799f
-0,         12,         12,        1,     1638, 0x5f640e86, S=1,     1024, 0xf351799f
-0,         13,         13,        1,     1531, 0xccb8e437, S=1,     1024, 0xf351799f
-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,         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,         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,         25,         25,        1,     3101, 0xbcc89bec, S=1,     1024, 0xf351799f
-0,         26,         26,        1,     3253, 0xd032f3fa, 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,         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,         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,         38,         38,        1,     3552, 0x23697490, S=1,     1024, 0xf351799f
-0,         39,         39,        1,     3690, 0x62afdbb8, 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,         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,         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,         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,         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,         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,         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
-0,         70,         70,        1,     5763, 0x51d5d5f0, S=1,     1024, 0xf351799f
-0,         71,         71,        1,     6116, 0x09558b48, S=1,     1024, 0xf351799f
-0,         72,         72,        1,     6069, 0x41926817, S=1,     1024, 0xf351799f
-0,         73,         73,        1,     5796, 0x7fbeda44, S=1,     1024, 0xf351799f
-0,         74,         74,        1,     5999, 0xe07d3770, S=1,     1024, 0xf351799f
-0,         75,         75,        1,     6220, 0x6607b06f, S=1,     1024, 0xf351799f
-0,         76,         76,        1,     6374, 0x7628e533, S=1,     1024, 0xf351799f
-0,         77,         77,        1,     6465, 0xfe956b15, S=1,     1024, 0xf351799f
-0,         78,         78,        1,     7019, 0x6c9a1aef, S=1,     1024, 0xf351799f
-0,         79,         79,        1,     7255, 0x5fa5c1bf, S=1,     1024, 0xf351799f
-0,         80,         80,        1,     8197, 0xf11d6ef2, S=1,     1024, 0xf351799f
-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,         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
-0,         88,         88,        1,     7401, 0x2625addb, S=1,     1024, 0xf351799f
-0,         89,         89,        1,     7494, 0x2877eacb, S=1,     1024, 0xf351799f
-0,         90,         90,        1,     7806, 0xe32574a3, S=1,     1024, 0xf351799f
-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,         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,        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
-0,        103,        103,        1,    11479, 0xbf7581e9, S=1,     1024, 0xf351799f
-0,        104,        104,        1,    13395, 0x415b38d8, S=1,     1024, 0xf351799f
-0,        105,        105,        1,    12913, 0x61544631, S=1,     1024, 0xf351799f
-0,        106,        106,        1,    13864, 0xd39fe768, S=1,     1024, 0xf351799f
-0,        107,        107,        1,    13551, 0x76c167d1, S=1,     1024, 0xf351799f
-0,        108,        108,        1,    14041, 0x2f206888, S=1,     1024, 0xf351799f
-0,        109,        109,        1,    14144, 0x9ec030d3, S=1,     1024, 0xf351799f
-0,        110,        110,        1,    14277, 0xa84b3a9b, S=1,     1024, 0xf351799f
-0,        111,        111,        1,    14424, 0xf5f1e06e, S=1,     1024, 0xf351799f
-0,        112,        112,        1,    14689, 0xbca0adb5, S=1,     1024, 0xf351799f
-0,        113,        113,        1,    14598, 0xc1d45745, S=1,     1024, 0xf351799f
-0,        114,        114,        1,    15213, 0x8f3080fc, S=1,     1024, 0xf351799f
-0,        115,        115,        1,    15425, 0xb0aa8f59, S=1,     1024, 0xf351799f
-0,        116,        116,        1,    15595, 0x1406e5d5, S=1,     1024, 0xf351799f
-0,        117,        117,        1,    15598, 0x48ec7d08, S=1,     1024, 0xf351799f
-0,        118,        118,        1,    15863, 0x5381db7b, S=1,     1024, 0xf351799f
-0,        119,        119,        1,    15717, 0xb87a1b87, S=1,     1024, 0xf351799f
-0,        120,        120,        1,    16078, 0x5bab2453, S=1,     1024, 0xf351799f
-0,        121,        121,        1,    16225, 0xa1f88113, S=1,     1024, 0xf351799f
-0,        122,        122,        1,    16135, 0x6af2f4e1, S=1,     1024, 0xf351799f
-0,        123,        123,        1,    16661, 0xf02a3343, S=1,     1024, 0xf351799f
-0,        124,        124,        1,    16619, 0xc71935a4, S=1,     1024, 0xf351799f
-0,        125,        125,        1,    16829, 0x29849844, S=1,     1024, 0xf351799f
-0,        126,        126,        1,    16944, 0x3423ae77, S=1,     1024, 0xf351799f
-0,        127,        127,        1,    17119, 0x609b4409, S=1,     1024, 0xf351799f
-0,        128,        128,        1,    17150, 0xf85dfd31, S=1,     1024, 0xf351799f
-0,        129,        129,        1,    17321, 0x38eccb10, S=1,     1024, 0xf351799f
-0,        130,        130,        1,    17395, 0x0ba08b85, S=1,     1024, 0xf351799f
-0,        131,        131,        1,    17666, 0x6fbc0264, S=1,     1024, 0xf351799f
-0,        132,        132,        1,    17730, 0x3dcc64a6, S=1,     1024, 0xf351799f
-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,        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
-0,        140,        140,        1,    19120, 0x565f80e6, S=1,     1024, 0xf351799f
-0,        141,        141,        1,    19130, 0xff70cc21, S=1,     1024, 0xf351799f
-0,        142,        142,        1,    19494, 0xbfa284db, S=1,     1024, 0xf351799f
-0,        143,        143,        1,    19534, 0x3d40743b, S=1,     1024, 0xf351799f
-0,        144,        144,        1,    19747, 0x33c9b108, S=1,     1024, 0xf351799f
-0,        145,        145,        1,    20114, 0x9d223e36, S=1,     1024, 0xf351799f
-0,        146,        146,        1,    20257, 0xe7bdaf43, S=1,     1024, 0xf351799f
-0,        147,        147,        1,    20370, 0x0c5f1970, S=1,     1024, 0xf351799f
-0,        148,        148,        1,    20292, 0x6986d20e, S=1,     1024, 0xf351799f
-0,        149,        149,        1,    20491, 0xd88e4c08, S=1,     1024, 0xf351799f
-0,        150,        150,        1,    20647, 0x1aefaffc, S=1,     1024, 0xf351799f
-0,        151,        151,        1,    20666, 0x43e4aaaa, S=1,     1024, 0xf351799f
-0,        152,        152,        1,    21007, 0xa7ca3ef0, S=1,     1024, 0xf351799f
-0,        153,        153,        1,    21058, 0x06814351, S=1,     1024, 0xf351799f
-0,        154,        154,        1,    21153, 0x3c852b10, S=1,     1024, 0xf351799f
-0,        155,        155,        1,    21078, 0x8df15855, S=1,     1024, 0xf351799f
-0,        156,        156,        1,    21458, 0xd3a531d6, S=1,     1024, 0xf351799f
-0,        157,        157,        1,    21669, 0x88baca53, S=1,     1024, 0xf351799f
-0,        158,        158,        1,    21581, 0xd692fa1f, S=1,     1024, 0xf351799f
-0,        159,        159,        1,    21654, 0x30fb9061, S=1,     1024, 0xf351799f
-0,        160,        160,        1,    21987, 0xe7646d8b, S=1,     1024, 0xf351799f
-0,        161,        161,        1,    22205, 0x0fc55b6a, S=1,     1024, 0xf351799f
-0,        162,        162,        1,    22475, 0x4bc4c032, S=1,     1024, 0xf351799f
-0,        163,        163,        1,    22490, 0x58ca23f6, S=1,     1024, 0xf351799f
-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,        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
-0,        171,        171,        1,    23675, 0x2a2147ed, S=1,     1024, 0xf351799f
-0,        172,        172,        1,    23874, 0x12c184b6, S=1,     1024, 0xf351799f
+0,          0,          0,        1,     1341, 0xe4e2af18
+0,          1,          1,        1,      305, 0xefa98bbd
+0,          2,          2,        1,      446, 0x9499cf43
+0,          3,          3,        1,      458, 0x8cb7d0d5
+0,          4,          4,        1,      555, 0x41f2fe63
+0,          5,          5,        1,      622, 0x3651212e
+0,          6,          6,        1,      650, 0x67542087
+0,          7,          7,        1,      668, 0x392934ca
+0,          8,          8,        1,      829, 0x6cd07a33
+0,          9,          9,        1,     1165, 0xb64b2ec9
+0,         10,         10,        1,      187, 0x114a52a4
+0,         11,         11,        1,     1341, 0x6ca57064
+0,         12,         12,        1,     1646, 0xcdd90fae
+0,         13,         13,        1,     1539, 0xbf75e55f
+0,         14,         14,        1,     1728, 0x96b14714
+0,         15,         15,        1,     1918, 0xffd08446
+0,         16,         16,        1,     2132, 0x3d5ae258
+0,         17,         17,        1,     2256, 0x359526d9
+0,         18,         18,        1,     2319, 0x553c382b
+0,         19,         19,        1,     2416, 0x7ac37066
+0,         20,         20,        1,     2609, 0x552bc27f
+0,         21,         21,        1,     2695, 0xbb0c020e
+0,         22,         22,        1,     2792, 0x46670f7d
+0,         23,         23,        1,     2892, 0x5674481e
+0,         24,         24,        1,     2990, 0x015a7bfd
+0,         25,         25,        1,     3109, 0xc73e9d14
+0,         26,         26,        1,     3261, 0x8a77f522
+0,         27,         27,        1,     3337, 0xf6f92558
+0,         28,         28,        1,     3580, 0x23408bc8
+0,         29,         29,        1,     3815, 0x781dfb1b
+0,         30,         30,        1,     2758, 0xf5cd1d5b
+0,         31,         31,        1,     4039, 0x7909712e
+0,         32,         32,        1,     3033, 0x39089d44
+0,         33,         33,        1,     4303, 0x667b0c60
+0,         34,         34,        1,     2052, 0x9edfba63
+0,         35,         35,        1,     3220, 0x5a56f015
+0,         36,         36,        1,     2300, 0x1719645c
+0,         37,         37,        1,     3641, 0x71c49a57
+0,         38,         38,        1,     3560, 0x377575b8
+0,         39,         39,        1,     3698, 0x165adce0
+0,         40,         40,        1,     1567, 0x6ecbf672
+0,         41,         41,        1,      962, 0x21eccba1
+0,         42,         42,        1,      281, 0x7a5a7ac3
+0,         43,         43,        1,      938, 0x659bb1ec
+0,         44,         44,        1,      279, 0x71e181bc
+0,         45,         45,        1,      204, 0xe0765316
+0,         46,         46,        1,     4307, 0xdbdd0e7d
+0,         47,         47,        1,     4903, 0xd8d24194
+0,         48,         48,        1,     4936, 0x6e9f1aff
+0,         49,         49,        1,     4949, 0xb3115902
+0,         50,         50,        1,     4162, 0xee2cad5b
+0,         51,         51,        1,     4686, 0xd583c178
+0,         52,         52,        1,     4749, 0x8c93b6a9
+0,         53,         53,        1,     4990, 0x12f957fd
+0,         54,         54,        1,     5187, 0xf3bcc7c9
+0,         55,         55,        1,     5054, 0xa27684fb
+0,         56,         56,        1,     5148, 0xe76cbad7
+0,         57,         57,        1,     4309, 0x79f7f067
+0,         58,         58,        1,     5087, 0xa2e29f29
+0,         59,         59,        1,     5292, 0xd158e4db
+0,         60,         60,        1,     5434, 0xe0be16f5
+0,         61,         61,        1,     4653, 0x0a3d8a5e
+0,         62,         62,        1,     5271, 0x4412d0a5
+0,         63,         63,        1,     5229, 0x3e06c4f2
+0,         64,         64,        1,     5225, 0x9bc39cfa
+0,         65,         65,        1,     5403, 0x798b009d
+0,         66,         66,        1,     5228, 0x14f2dded
+0,         67,         67,        1,     5712, 0x8724debe
+0,         68,         68,        1,     5644, 0x49d3a383
+0,         69,         69,        1,     5826, 0xde72e0ba
+0,         70,         70,        1,     5771, 0x62efd718
+0,         71,         71,        1,     6124, 0xb2a68c70
+0,         72,         72,        1,     6077, 0xb48b693f
+0,         73,         73,        1,     5804, 0xb700db6c
+0,         74,         74,        1,     6007, 0x02953898
+0,         75,         75,        1,     6228, 0x87a7b197
+0,         76,         76,        1,     6382, 0x49e7e65b
+0,         77,         77,        1,     6473, 0x3b9b6c3d
+0,         78,         78,        1,     7027, 0x2a4e1c17
+0,         79,         79,        1,     7263, 0x2e48c2e7
+0,         80,         80,        1,     8205, 0x013b701a
+0,         81,         81,        1,     8366, 0xcca97b10
+0,         82,         82,        1,     7716, 0x3b088fb3
+0,         83,         83,        1,     7420, 0xefdd1187
+0,         84,         84,        1,     7549, 0x1731227c
+0,         85,         85,        1,     7956, 0x8186ceb3
+0,         86,         86,        1,     8416, 0x23add53c
+0,         87,         87,        1,     8064, 0x09c616c4
+0,         88,         88,        1,     7409, 0x9d98af03
+0,         89,         89,        1,     7502, 0x0b81ebf3
+0,         90,         90,        1,     7814, 0x2f0d75cb
+0,         91,         91,        1,     7776, 0x45d6800f
+0,         92,         92,        1,     7757, 0x777f98b6
+0,         93,         93,        1,     8055, 0x4eea1634
+0,         94,         94,        1,     7626, 0xfb3931fd
+0,         95,         95,        1,     7987, 0x22a1d052
+0,         96,         96,        1,    12070, 0x3aa2924d
+0,         97,         97,        1,    12325, 0xda6cd811
+0,         98,         98,        1,    12225, 0xd478e671
+0,         99,         99,        1,    11235, 0xc6c09240
+0,        100,        100,        1,    11116, 0x95050c25
+0,        101,        101,        1,    11374, 0x14a68e3d
+0,        102,        102,        1,    11904, 0xb14436f2
+0,        103,        103,        1,    11487, 0xa3358311
+0,        104,        104,        1,    13403, 0xccf33a00
+0,        105,        105,        1,    12921, 0xbf7e4759
+0,        106,        106,        1,    13872, 0x7dace890
+0,        107,        107,        1,    13559, 0xb6c868f9
+0,        108,        108,        1,    14049, 0xa5d569b0
+0,        109,        109,        1,    14152, 0x8c9c31fb
+0,        110,        110,        1,    14285, 0x2ffe3bc3
+0,        111,        111,        1,    14432, 0x27abe196
+0,        112,        112,        1,    14697, 0x20d1aedd
+0,        113,        113,        1,    14606, 0xbcbe586d
+0,        114,        114,        1,    15221, 0x515f8224
+0,        115,        115,        1,    15433, 0x68089081
+0,        116,        116,        1,    15603, 0x8ff4e6fd
+0,        117,        117,        1,    15606, 0xc8527e30
+0,        118,        118,        1,    15871, 0x056ddca3
+0,        119,        119,        1,    15725, 0xc1871caf
+0,        120,        120,        1,    16086, 0x063e257b
+0,        121,        121,        1,    16233, 0xf683823b
+0,        122,        122,        1,    16143, 0x576df609
+0,        123,        123,        1,    16669, 0x3d02346b
+0,        124,        124,        1,    16627, 0xe35236cc
+0,        125,        125,        1,    16837, 0x389c996c
+0,        126,        126,        1,    16952, 0xc833af9f
+0,        127,        127,        1,    17127, 0xbf124531
+0,        128,        128,        1,    17158, 0x7abbfe59
+0,        129,        129,        1,    17329, 0x8102cc38
+0,        130,        130,        1,    17403, 0xa9468cad
+0,        131,        131,        1,    17674, 0x46d8038c
+0,        132,        132,        1,    17738, 0x5ee865ce
+0,        133,        133,        1,    17942, 0xc2449873
+0,        134,        134,        1,    17952, 0x3aafedbc
+0,        135,        135,        1,    18246, 0xdd930054
+0,        136,        136,        1,    18399, 0x68a59331
+0,        137,        137,        1,    18551, 0x1301c157
+0,        138,        138,        1,    18947, 0xbed8a9b4
+0,        139,        139,        1,    19153, 0xe338fea2
+0,        140,        140,        1,    19128, 0xbf05820e
+0,        141,        141,        1,    19138, 0x73b5cd49
+0,        142,        142,        1,    19502, 0xd8d68603
+0,        143,        143,        1,    19542, 0x84b47563
+0,        144,        144,        1,    19755, 0x7194b230
+0,        145,        145,        1,    20122, 0x83633f5e
+0,        146,        146,        1,    20265, 0x7365b06b
+0,        147,        147,        1,    20378, 0x1aaf1a98
+0,        148,        148,        1,    20300, 0x1da6d336
+0,        149,        149,        1,    20499, 0x72d54d30
+0,        150,        150,        1,    20655, 0x6996b124
+0,        151,        151,        1,    20674, 0xa883abd2
+0,        152,        152,        1,    21015, 0x96cf4018
+0,        153,        153,        1,    21066, 0x307e4479
+0,        154,        154,        1,    21161, 0xd45a2c38
+0,        155,        155,        1,    21086, 0xcf0e597d
+0,        156,        156,        1,    21466, 0xcc4032fe
+0,        157,        157,        1,    21677, 0x755ccb7b
+0,        158,        158,        1,    21589, 0x5d74fb47
+0,        159,        159,        1,    21662, 0x0c459189
+0,        160,        160,        1,    21995, 0x43d46eb3
+0,        161,        161,        1,    22213, 0x68455c92
+0,        162,        162,        1,    22483, 0xdc83c15a
+0,        163,        163,        1,    22498, 0xfae1251e
+0,        164,        164,        1,    22468, 0x7944b1d4
+0,        165,        165,        1,    22869, 0xff8c10ac
+0,        166,        166,        1,    22754, 0xd8183b84
+0,        167,        167,        1,    23173, 0x6c3c48d5
+0,        168,        168,        1,    23281, 0xc32ca477
+0,        169,        169,        1,    23219, 0x4dc26193
+0,        170,        170,        1,    23656, 0xb85ee15f
+0,        171,        171,        1,    23683, 0x26ba4915
+0,        172,        172,        1,    23882, 0xf57285de
diff --git a/tests/ref/fate/gifenc-gray b/tests/ref/fate/gifenc-gray
index 81cdd1888e..530ad16fb6 100644
--- a/tests/ref/fate/gifenc-gray
+++ b/tests/ref/fate/gifenc-gray
@@ -3,176 +3,176 @@ 
 #codec_id 0: gif
 #dimensions 0: 217x217
 #sar 0: 0/1
-0,          0,          0,        1,      579, 0x0d0e3ab8
-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
-0,          4,          4,        1,      152, 0xaf9a3f2e, S=1,     1024, 0xc2f67c9f
-0,          5,          5,        1,      136, 0x68593d85, S=1,     1024, 0xc2f67c9f
-0,          6,          6,        1,      134, 0x0dcb373f, S=1,     1024, 0xc2f67c9f
-0,          7,          7,        1,      129, 0x3baf3279, S=1,     1024, 0xc2f67c9f
-0,          8,          8,        1,      123, 0x9c963148, S=1,     1024, 0xc2f67c9f
-0,          9,          9,        1,      123, 0x5c272d6b, S=1,     1024, 0xc2f67c9f
-0,         10,         10,        1,      150, 0x5f8d41aa, S=1,     1024, 0xc2f67c9f
-0,         11,         11,        1,      134, 0x6f582fee, S=1,     1024, 0xc2f67c9f
-0,         12,         12,        1,      134, 0x85d53038, S=1,     1024, 0xc2f67c9f
-0,         13,         13,        1,      123, 0x6d2a2cb2, S=1,     1024, 0xc2f67c9f
-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,         19,         19,        1,      123, 0xaa7d313c, S=1,     1024, 0xc2f67c9f
-0,         20,         20,        1,      140, 0x4fd63b34, 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,         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,         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,         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
-0,         39,         39,        1,      123, 0x269b3058, S=1,     1024, 0xc2f67c9f
-0,         40,         40,        1,      119, 0x17052def, S=1,     1024, 0xc2f67c9f
-0,         41,         41,        1,      119, 0x36da2ee2, S=1,     1024, 0xc2f67c9f
-0,         42,         42,        1,      120, 0x984e31be, S=1,     1024, 0xc2f67c9f
-0,         43,         43,        1,      114, 0xfd382c9d, S=1,     1024, 0xc2f67c9f
-0,         44,         44,        1,      125, 0x926a36c6, S=1,     1024, 0xc2f67c9f
-0,         45,         45,        1,      117, 0xbceb3183, S=1,     1024, 0xc2f67c9f
-0,         46,         46,        1,      116, 0xf4c72d82, S=1,     1024, 0xc2f67c9f
-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,         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,         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,         67,         67,        1,      115, 0x4ca92f75, S=1,     1024, 0xc2f67c9f
-0,         68,         68,        1,      131, 0xf4193bc0, 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
-0,         72,         72,        1,      120, 0x22452fd6, S=1,     1024, 0xc2f67c9f
-0,         73,         73,        1,      116, 0xd3c52c26, S=1,     1024, 0xc2f67c9f
-0,         74,         74,        1,      106, 0x95b42c9f, S=1,     1024, 0xc2f67c9f
-0,         75,         75,        1,       96, 0xfdc12639, S=1,     1024, 0xc2f67c9f
-0,         76,         76,        1,       99, 0x210f251b, S=1,     1024, 0xc2f67c9f
-0,         77,         77,        1,      119, 0x173b341c, S=1,     1024, 0xc2f67c9f
-0,         78,         78,        1,      119, 0x3bca2f29, S=1,     1024, 0xc2f67c9f
-0,         79,         79,        1,      213, 0x9e905d4c, S=1,     1024, 0xc2f67c9f
-0,         80,         80,        1,      209, 0xa0015e94, S=1,     1024, 0xc2f67c9f
-0,         81,         81,        1,      120, 0x36762bd4, S=1,     1024, 0xc2f67c9f
-0,         82,         82,        1,      119, 0x019b2edc, S=1,     1024, 0xc2f67c9f
-0,         83,         83,        1,      124, 0x211d30e7, S=1,     1024, 0xc2f67c9f
-0,         84,         84,        1,      125, 0x538732ff, S=1,     1024, 0xc2f67c9f
-0,         85,         85,        1,      123, 0x2887308a, S=1,     1024, 0xc2f67c9f
-0,         86,         86,        1,      119, 0x7ff930f4, S=1,     1024, 0xc2f67c9f
-0,         87,         87,        1,      119, 0xa50c2e16, S=1,     1024, 0xc2f67c9f
-0,         88,         88,        1,      107, 0x9ed02cea, S=1,     1024, 0xc2f67c9f
-0,         89,         89,        1,      119, 0xc234332a, S=1,     1024, 0xc2f67c9f
-0,         90,         90,        1,      115, 0x38353092, S=1,     1024, 0xc2f67c9f
-0,         91,         91,        1,      162, 0x6cda4644, S=1,     1024, 0xc2f67c9f
-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,         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,        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
-0,        103,        103,        1,      190, 0x3e865b77, S=1,     1024, 0xc2f67c9f
-0,        104,        104,        1,      159, 0xdf393fc8, S=1,     1024, 0xc2f67c9f
-0,        105,        105,        1,      188, 0x84be5168, S=1,     1024, 0xc2f67c9f
-0,        106,        106,        1,      163, 0x4c0e41f0, S=1,     1024, 0xc2f67c9f
-0,        107,        107,        1,      144, 0x5fda3792, S=1,     1024, 0xc2f67c9f
-0,        108,        108,        1,      136, 0x028c3800, S=1,     1024, 0xc2f67c9f
-0,        109,        109,        1,      150, 0x75d43a8d, S=1,     1024, 0xc2f67c9f
-0,        110,        110,        1,      134, 0x81123999, S=1,     1024, 0xc2f67c9f
-0,        111,        111,        1,      198, 0x0a875baa, S=1,     1024, 0xc2f67c9f
-0,        112,        112,        1,      169, 0xfdd7458c, S=1,     1024, 0xc2f67c9f
-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,        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,        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,        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,        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
-0,        136,        136,        1,      164, 0x9dc545e5, S=1,     1024, 0xc2f67c9f
-0,        137,        137,        1,      245, 0xc170715a, S=1,     1024, 0xc2f67c9f
-0,        138,        138,        1,      215, 0xc93d5fbe, S=1,     1024, 0xc2f67c9f
-0,        139,        139,        1,      225, 0x14866349, S=1,     1024, 0xc2f67c9f
-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,        144,        144,        1,      224, 0xf548614f, S=1,     1024, 0xc2f67c9f
-0,        145,        145,        1,      239, 0x125c6ade, 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
-0,        149,        149,        1,      126, 0xc1fc3692, S=1,     1024, 0xc2f67c9f
-0,        150,        150,        1,      123, 0xd0bf3170, S=1,     1024, 0xc2f67c9f
-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,        155,        155,        1,      127, 0x352338bc, S=1,     1024, 0xc2f67c9f
-0,        156,        156,        1,      113, 0xf877314e, 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
-0,        160,        160,        1,      237, 0x4e45662e, S=1,     1024, 0xc2f67c9f
-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,        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,        169,        169,        1,      125, 0xc0033320, S=1,     1024, 0xc2f67c9f
-0,        170,        170,        1,      122, 0xe38a2db1, S=1,     1024, 0xc2f67c9f
-0,        171,        171,        1,      145, 0x29d63e83, S=1,     1024, 0xc2f67c9f
-0,        172,        172,        1,      171, 0xc0e44b70, S=1,     1024, 0xc2f67c9f
+0,          0,          0,        1,     1368, 0x6cf0befd
+0,          1,          1,        1,      158, 0xcd173bb4
+0,          2,          2,        1,      163, 0x4f7a451d
+0,          3,          3,        1,      152, 0x17723839
+0,          4,          4,        1,      160, 0x67854056
+0,          5,          5,        1,      144, 0x0dc43ead
+0,          6,          6,        1,      142, 0xb0d73867
+0,          7,          7,        1,      137, 0xd8f333a1
+0,          8,          8,        1,      131, 0x32f93270
+0,          9,          9,        1,      131, 0xf27b2e93
+0,         10,         10,        1,      158, 0x152842d2
+0,         11,         11,        1,      142, 0x12733116
+0,         12,         12,        1,      142, 0x28f03160
+0,         13,         13,        1,      131, 0x038d2dda
+0,         14,         14,        1,      135, 0xb96c33a3
+0,         15,         15,        1,      127, 0x4cbf2d59
+0,         16,         16,        1,      146, 0xff013760
+0,         17,         17,        1,      148, 0xa14d3c03
+0,         18,         18,        1,      130, 0x139430b3
+0,         19,         19,        1,      131, 0x40e03264
+0,         20,         20,        1,      148, 0xf9d23c5c
+0,         21,         21,        1,      131, 0xfdc9328b
+0,         22,         22,        1,      131, 0x986d326f
+0,         23,         23,        1,      132, 0x3fdc3311
+0,         24,         24,        1,      130, 0x84c2330a
+0,         25,         25,        1,      130, 0x9c0033f1
+0,         26,         26,        1,      131, 0x62eb32f5
+0,         27,         27,        1,      126, 0x326e328e
+0,         28,         28,        1,      167, 0x8c8f4674
+0,         29,         29,        1,      148, 0x340d32d5
+0,         30,         30,        1,      171, 0xac2549fa
+0,         31,         31,        1,      150, 0xe77535b1
+0,         32,         32,        1,      178, 0x2c0b4c3a
+0,         33,         33,        1,      154, 0xe99137bb
+0,         34,         34,        1,      140, 0x525535c1
+0,         35,         35,        1,      121, 0xdfdc2d02
+0,         36,         36,        1,      140, 0x4db8345b
+0,         37,         37,        1,      128, 0x32e92f77
+0,         38,         38,        1,      143, 0x06663646
+0,         39,         39,        1,      131, 0xbcef3180
+0,         40,         40,        1,      127, 0xa8b92f17
+0,         41,         41,        1,      127, 0xc88e300a
+0,         42,         42,        1,      128, 0x2b3932e6
+0,         43,         43,        1,      122, 0x89332dc5
+0,         44,         44,        1,      133, 0x2b1d37ee
+0,         45,         45,        1,      125, 0x4c5e32ab
+0,         46,         46,        1,      124, 0x83122eaa
+0,         47,         47,        1,      132, 0xa3953564
+0,         48,         48,        1,      125, 0xae672fd9
+0,         49,         49,        1,      143, 0xd5d8390e
+0,         50,         50,        1,      139, 0xebab3726
+0,         51,         51,        1,      130, 0x4c9b358b
+0,         52,         52,        1,      130, 0x14993609
+0,         53,         53,        1,      132, 0x2ced3637
+0,         54,         54,        1,      134, 0xb27f3881
+0,         55,         55,        1,      125, 0x0402336b
+0,         56,         56,        1,      117, 0xf8a7310f
+0,         57,         57,        1,      128, 0x07752f60
+0,         58,         58,        1,      128, 0xf4d430da
+0,         59,         59,        1,      130, 0xbf9733aa
+0,         60,         60,        1,      124, 0x199f2f0e
+0,         61,         61,        1,      127, 0x84ff32b6
+0,         62,         62,        1,      124, 0x8d63305e
+0,         63,         63,        1,      127, 0x7d6130f4
+0,         64,         64,        1,      126, 0x78c83176
+0,         65,         65,        1,      145, 0x3ec33e58
+0,         66,         66,        1,      157, 0xb5764127
+0,         67,         67,        1,      123, 0xd9bd309d
+0,         68,         68,        1,      139, 0x93bc3ce8
+0,         69,         69,        1,      123, 0x67813058
+0,         70,         70,        1,      108, 0x176e2b80
+0,         71,         71,        1,      117, 0x2ab12db9
+0,         72,         72,        1,      128, 0xb52130fe
+0,         73,         73,        1,      124, 0x62102d4e
+0,         74,         74,        1,      114, 0x186f2dc7
+0,         75,         75,        1,      104, 0x74ec2761
+0,         76,         76,        1,      107, 0x9ba32643
+0,         77,         77,        1,      127, 0xa8ef3544
+0,         78,         78,        1,      127, 0xcd7e3051
+0,         79,         79,        1,      221, 0x9d035e74
+0,         80,         80,        1,      217, 0x99d45fbc
+0,         81,         81,        1,      128, 0xc9522cfc
+0,         82,         82,        1,      127, 0x934f3004
+0,         83,         83,        1,      132, 0xb899320f
+0,         84,         84,        1,      133, 0xec2b3427
+0,         85,         85,        1,      131, 0xbedb31b2
+0,         86,         86,        1,      127, 0x11bc321c
+0,         87,         87,        1,      127, 0x36cf2f3e
+0,         88,         88,        1,      115, 0x22b32e12
+0,         89,         89,        1,      127, 0x53f73452
+0,         90,         90,        1,      123, 0xc54931ba
+0,         91,         91,        1,      170, 0x3055476c
+0,         92,         92,        1,      132, 0xc6e431a9
+0,         93,         93,        1,      124, 0x00e02e2c
+0,         94,         94,        1,       92, 0x838f2429
+0,         95,         95,        1,      184, 0xcee75528
+0,         96,         96,        1,      145, 0xcbb533f9
+0,         97,         97,        1,      187, 0x025b53b3
+0,         98,         98,        1,      158, 0x73dc3de6
+0,         99,         99,        1,      148, 0x489e3a52
+0,        100,        100,        1,      137, 0xf4c23446
+0,        101,        101,        1,      154, 0xc7eb3a4c
+0,        102,        102,        1,      141, 0x175d328b
+0,        103,        103,        1,      198, 0x22615c9f
+0,        104,        104,        1,      167, 0x9f3c40f0
+0,        105,        105,        1,      196, 0x66495290
+0,        106,        106,        1,      171, 0x10b14318
+0,        107,        107,        1,      152, 0x0e8538ba
+0,        108,        108,        1,      144, 0xa7e83928
+0,        109,        109,        1,      158, 0x2b6f3bb5
+0,        110,        110,        1,      142, 0x242d3ac1
+0,        111,        111,        1,      206, 0xf7935cd2
+0,        112,        112,        1,      177, 0xc96a46b4
+0,        113,        113,        1,      218, 0x96145d0c
+0,        114,        114,        1,      182, 0xdb8e4b9e
+0,        115,        115,        1,      145, 0x58483725
+0,        116,        116,        1,      130, 0xe26b33a3
+0,        117,        117,        1,      160, 0x162d3c34
+0,        118,        118,        1,      145, 0x77cd3b1f
+0,        119,        119,        1,      164, 0xfd024449
+0,        120,        120,        1,      148, 0x68293a64
+0,        121,        121,        1,      187, 0x8643475d
+0,        122,        122,        1,      124, 0xe904324b
+0,        123,        123,        1,      126, 0xb3482fed
+0,        124,        124,        1,      131, 0x60183155
+0,        125,        125,        1,      133, 0xf592319f
+0,        126,        126,        1,      202, 0xb53c5af2
+0,        127,        127,        1,      130, 0xe2503351
+0,        128,        128,        1,      132, 0x2c1a3433
+0,        129,        129,        1,      141, 0x772f36f2
+0,        130,        130,        1,      134, 0x5f2f3838
+0,        131,        131,        1,      216, 0x659c5fca
+0,        132,        132,        1,      139, 0x4876362d
+0,        133,        133,        1,      122, 0x96d13129
+0,        134,        134,        1,      137, 0x875238ec
+0,        135,        135,        1,      128, 0x953e3481
+0,        136,        136,        1,      172, 0x6390470d
+0,        137,        137,        1,      253, 0xe4e37282
+0,        138,        138,        1,      223, 0xca0060e6
+0,        139,        139,        1,      233, 0x20d96471
+0,        140,        140,        1,      131, 0x07302c8c
+0,        141,        141,        1,      132, 0x808b30dd
+0,        142,        142,        1,      133, 0xa91231c3
+0,        143,        143,        1,      130, 0x9a3a33d8
+0,        144,        144,        1,      232, 0x00826277
+0,        145,        145,        1,      247, 0x2edf6c06
+0,        146,        146,        1,      135, 0xd47b35de
+0,        147,        147,        1,      134, 0xc9c0330d
+0,        148,        148,        1,      132, 0x2d0e3263
+0,        149,        149,        1,      134, 0x5bd737ba
+0,        150,        150,        1,      131, 0x67223298
+0,        151,        151,        1,      125, 0xf483315a
+0,        152,        152,        1,      127, 0xb83e31a0
+0,        153,        153,        1,      125, 0x2dc033ab
+0,        154,        154,        1,      157, 0x438344e2
+0,        155,        155,        1,      135, 0xd01739e4
+0,        156,        156,        1,      121, 0x834a3276
+0,        157,        157,        1,      136, 0x243b3b8a
+0,        158,        158,        1,      119, 0x47893201
+0,        159,        159,        1,      154, 0xc688461f
+0,        160,        160,        1,      245, 0x68786756
+0,        161,        161,        1,      241, 0xa531647c
+0,        162,        162,        1,      168, 0x5d6a4447
+0,        163,        163,        1,      133, 0x55de34ee
+0,        164,        164,        1,      139, 0xde613ccd
+0,        165,        165,        1,      239, 0xf26b6ede
+0,        166,        166,        1,      161, 0x6fed41b5
+0,        167,        167,        1,      134, 0x011c3786
+0,        168,        168,        1,      121, 0xf0532db8
+0,        169,        169,        1,      133, 0x58b63448
+0,        170,        170,        1,      130, 0x78c52ed9
+0,        171,        171,        1,      153, 0xd99a3fab
+0,        172,        172,        1,      179, 0x8ec74c98
diff --git a/tests/ref/fate/gifenc-pal8 b/tests/ref/fate/gifenc-pal8
index a6d5741992..64fdeded5e 100644
--- a/tests/ref/fate/gifenc-pal8
+++ b/tests/ref/fate/gifenc-pal8
@@ -3,176 +3,176 @@ 
 #codec_id 0: gif
 #dimensions 0: 217x217
 #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,          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,          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
-0,          9,          9,        1,     1157, 0x741c2da1, S=1,     1024, 0xf351799f
-0,         10,         10,        1,      179, 0x3a27517c, S=1,     1024, 0xf351799f
-0,         11,         11,        1,     1333, 0x5ee76f3c, S=1,     1024, 0xf351799f
-0,         12,         12,        1,     1638, 0x5f640e86, S=1,     1024, 0xf351799f
-0,         13,         13,        1,     1531, 0xccb8e437, S=1,     1024, 0xf351799f
-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,         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,         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,         25,         25,        1,     3101, 0xbcc89bec, S=1,     1024, 0xf351799f
-0,         26,         26,        1,     3253, 0xd032f3fa, 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,         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,         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,         38,         38,        1,     3552, 0x23697490, S=1,     1024, 0xf351799f
-0,         39,         39,        1,     3690, 0x62afdbb8, 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,         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,         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,         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,         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,         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,         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
-0,         70,         70,        1,     5763, 0x51d5d5f0, S=1,     1024, 0xf351799f
-0,         71,         71,        1,     6116, 0x09558b48, S=1,     1024, 0xf351799f
-0,         72,         72,        1,     6069, 0x41926817, S=1,     1024, 0xf351799f
-0,         73,         73,        1,     5796, 0x7fbeda44, S=1,     1024, 0xf351799f
-0,         74,         74,        1,     5999, 0xe07d3770, S=1,     1024, 0xf351799f
-0,         75,         75,        1,     6220, 0x6607b06f, S=1,     1024, 0xf351799f
-0,         76,         76,        1,     6374, 0x7628e533, S=1,     1024, 0xf351799f
-0,         77,         77,        1,     6465, 0xfe956b15, S=1,     1024, 0xf351799f
-0,         78,         78,        1,     7019, 0x6c9a1aef, S=1,     1024, 0xf351799f
-0,         79,         79,        1,     7255, 0x5fa5c1bf, S=1,     1024, 0xf351799f
-0,         80,         80,        1,     8197, 0xf11d6ef2, S=1,     1024, 0xf351799f
-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,         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
-0,         88,         88,        1,     7401, 0x2625addb, S=1,     1024, 0xf351799f
-0,         89,         89,        1,     7494, 0x2877eacb, S=1,     1024, 0xf351799f
-0,         90,         90,        1,     7806, 0xe32574a3, S=1,     1024, 0xf351799f
-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,         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,        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
-0,        103,        103,        1,    11479, 0xbf7581e9, S=1,     1024, 0xf351799f
-0,        104,        104,        1,    13395, 0x415b38d8, S=1,     1024, 0xf351799f
-0,        105,        105,        1,    12913, 0x61544631, S=1,     1024, 0xf351799f
-0,        106,        106,        1,    13864, 0xd39fe768, S=1,     1024, 0xf351799f
-0,        107,        107,        1,    13551, 0x76c167d1, S=1,     1024, 0xf351799f
-0,        108,        108,        1,    14041, 0x2f206888, S=1,     1024, 0xf351799f
-0,        109,        109,        1,    14144, 0x9ec030d3, S=1,     1024, 0xf351799f
-0,        110,        110,        1,    14277, 0xa84b3a9b, S=1,     1024, 0xf351799f
-0,        111,        111,        1,    14424, 0xf5f1e06e, S=1,     1024, 0xf351799f
-0,        112,        112,        1,    14689, 0xbca0adb5, S=1,     1024, 0xf351799f
-0,        113,        113,        1,    14598, 0xc1d45745, S=1,     1024, 0xf351799f
-0,        114,        114,        1,    15213, 0x8f3080fc, S=1,     1024, 0xf351799f
-0,        115,        115,        1,    15425, 0xb0aa8f59, S=1,     1024, 0xf351799f
-0,        116,        116,        1,    15595, 0x1406e5d5, S=1,     1024, 0xf351799f
-0,        117,        117,        1,    15598, 0x48ec7d08, S=1,     1024, 0xf351799f
-0,        118,        118,        1,    15863, 0x5381db7b, S=1,     1024, 0xf351799f
-0,        119,        119,        1,    15717, 0xb87a1b87, S=1,     1024, 0xf351799f
-0,        120,        120,        1,    16078, 0x5bab2453, S=1,     1024, 0xf351799f
-0,        121,        121,        1,    16225, 0xa1f88113, S=1,     1024, 0xf351799f
-0,        122,        122,        1,    16135, 0x6af2f4e1, S=1,     1024, 0xf351799f
-0,        123,        123,        1,    16661, 0xf02a3343, S=1,     1024, 0xf351799f
-0,        124,        124,        1,    16619, 0xc71935a4, S=1,     1024, 0xf351799f
-0,        125,        125,        1,    16829, 0x29849844, S=1,     1024, 0xf351799f
-0,        126,        126,        1,    16944, 0x3423ae77, S=1,     1024, 0xf351799f
-0,        127,        127,        1,    17119, 0x609b4409, S=1,     1024, 0xf351799f
-0,        128,        128,        1,    17150, 0xf85dfd31, S=1,     1024, 0xf351799f
-0,        129,        129,        1,    17321, 0x38eccb10, S=1,     1024, 0xf351799f
-0,        130,        130,        1,    17395, 0x0ba08b85, S=1,     1024, 0xf351799f
-0,        131,        131,        1,    17666, 0x6fbc0264, S=1,     1024, 0xf351799f
-0,        132,        132,        1,    17730, 0x3dcc64a6, S=1,     1024, 0xf351799f
-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,        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
-0,        140,        140,        1,    19120, 0x565f80e6, S=1,     1024, 0xf351799f
-0,        141,        141,        1,    19130, 0xff70cc21, S=1,     1024, 0xf351799f
-0,        142,        142,        1,    19494, 0xbfa284db, S=1,     1024, 0xf351799f
-0,        143,        143,        1,    19534, 0x3d40743b, S=1,     1024, 0xf351799f
-0,        144,        144,        1,    19747, 0x33c9b108, S=1,     1024, 0xf351799f
-0,        145,        145,        1,    20114, 0x9d223e36, S=1,     1024, 0xf351799f
-0,        146,        146,        1,    20257, 0xe7bdaf43, S=1,     1024, 0xf351799f
-0,        147,        147,        1,    20370, 0x0c5f1970, S=1,     1024, 0xf351799f
-0,        148,        148,        1,    20292, 0x6986d20e, S=1,     1024, 0xf351799f
-0,        149,        149,        1,    20491, 0xd88e4c08, S=1,     1024, 0xf351799f
-0,        150,        150,        1,    20647, 0x1aefaffc, S=1,     1024, 0xf351799f
-0,        151,        151,        1,    20666, 0x43e4aaaa, S=1,     1024, 0xf351799f
-0,        152,        152,        1,    21007, 0xa7ca3ef0, S=1,     1024, 0xf351799f
-0,        153,        153,        1,    21058, 0x06814351, S=1,     1024, 0xf351799f
-0,        154,        154,        1,    21153, 0x3c852b10, S=1,     1024, 0xf351799f
-0,        155,        155,        1,    21078, 0x8df15855, S=1,     1024, 0xf351799f
-0,        156,        156,        1,    21458, 0xd3a531d6, S=1,     1024, 0xf351799f
-0,        157,        157,        1,    21669, 0x88baca53, S=1,     1024, 0xf351799f
-0,        158,        158,        1,    21581, 0xd692fa1f, S=1,     1024, 0xf351799f
-0,        159,        159,        1,    21654, 0x30fb9061, S=1,     1024, 0xf351799f
-0,        160,        160,        1,    21987, 0xe7646d8b, S=1,     1024, 0xf351799f
-0,        161,        161,        1,    22205, 0x0fc55b6a, S=1,     1024, 0xf351799f
-0,        162,        162,        1,    22475, 0x4bc4c032, S=1,     1024, 0xf351799f
-0,        163,        163,        1,    22490, 0x58ca23f6, S=1,     1024, 0xf351799f
-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,        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
-0,        171,        171,        1,    23675, 0x2a2147ed, S=1,     1024, 0xf351799f
-0,        172,        172,        1,    23874, 0x12c184b6, S=1,     1024, 0xf351799f
+0,          0,          0,        1,     2109, 0x39642b3d
+0,          1,          1,        1,      305, 0xefa98bbd
+0,          2,          2,        1,      446, 0x9499cf43
+0,          3,          3,        1,      458, 0x8cb7d0d5
+0,          4,          4,        1,      555, 0x41f2fe63
+0,          5,          5,        1,      622, 0x3651212e
+0,          6,          6,        1,      650, 0x67542087
+0,          7,          7,        1,      668, 0x392934ca
+0,          8,          8,        1,      829, 0x6cd07a33
+0,          9,          9,        1,     1165, 0xb64b2ec9
+0,         10,         10,        1,      187, 0x114a52a4
+0,         11,         11,        1,     1341, 0x6ca57064
+0,         12,         12,        1,     1646, 0xcdd90fae
+0,         13,         13,        1,     1539, 0xbf75e55f
+0,         14,         14,        1,     1728, 0x96b14714
+0,         15,         15,        1,     1918, 0xffd08446
+0,         16,         16,        1,     2132, 0x3d5ae258
+0,         17,         17,        1,     2256, 0x359526d9
+0,         18,         18,        1,     2319, 0x553c382b
+0,         19,         19,        1,     2416, 0x7ac37066
+0,         20,         20,        1,     2609, 0x552bc27f
+0,         21,         21,        1,     2695, 0xbb0c020e
+0,         22,         22,        1,     2792, 0x46670f7d
+0,         23,         23,        1,     2892, 0x5674481e
+0,         24,         24,        1,     2990, 0x015a7bfd
+0,         25,         25,        1,     3109, 0xc73e9d14
+0,         26,         26,        1,     3261, 0x8a77f522
+0,         27,         27,        1,     3337, 0xf6f92558
+0,         28,         28,        1,     3580, 0x23408bc8
+0,         29,         29,        1,     3815, 0x781dfb1b
+0,         30,         30,        1,     2758, 0xf5cd1d5b
+0,         31,         31,        1,     4039, 0x7909712e
+0,         32,         32,        1,     3033, 0x39089d44
+0,         33,         33,        1,     4303, 0x667b0c60
+0,         34,         34,        1,     2052, 0x9edfba63
+0,         35,         35,        1,     3220, 0x5a56f015
+0,         36,         36,        1,     2300, 0x1719645c
+0,         37,         37,        1,     3641, 0x71c49a57
+0,         38,         38,        1,     3560, 0x377575b8
+0,         39,         39,        1,     3698, 0x165adce0
+0,         40,         40,        1,     1567, 0x6ecbf672
+0,         41,         41,        1,      962, 0x21eccba1
+0,         42,         42,        1,      281, 0x7a5a7ac3
+0,         43,         43,        1,      938, 0x659bb1ec
+0,         44,         44,        1,      279, 0x71e181bc
+0,         45,         45,        1,      204, 0xe0765316
+0,         46,         46,        1,     4307, 0xdbdd0e7d
+0,         47,         47,        1,     4903, 0xd8d24194
+0,         48,         48,        1,     4936, 0x6e9f1aff
+0,         49,         49,        1,     4949, 0xb3115902
+0,         50,         50,        1,     4162, 0xee2cad5b
+0,         51,         51,        1,     4686, 0xd583c178
+0,         52,         52,        1,     4749, 0x8c93b6a9
+0,         53,         53,        1,     4990, 0x12f957fd
+0,         54,         54,        1,     5187, 0xf3bcc7c9
+0,         55,         55,        1,     5054, 0xa27684fb
+0,         56,         56,        1,     5148, 0xe76cbad7
+0,         57,         57,        1,     4309, 0x79f7f067
+0,         58,         58,        1,     5087, 0xa2e29f29
+0,         59,         59,        1,     5292, 0xd158e4db
+0,         60,         60,        1,     5434, 0xe0be16f5
+0,         61,         61,        1,     4653, 0x0a3d8a5e
+0,         62,         62,        1,     5271, 0x4412d0a5
+0,         63,         63,        1,     5229, 0x3e06c4f2
+0,         64,         64,        1,     5225, 0x9bc39cfa
+0,         65,         65,        1,     5403, 0x798b009d
+0,         66,         66,        1,     5228, 0x14f2dded
+0,         67,         67,        1,     5712, 0x8724debe
+0,         68,         68,        1,     5644, 0x49d3a383
+0,         69,         69,        1,     5826, 0xde72e0ba
+0,         70,         70,        1,     5771, 0x62efd718
+0,         71,         71,        1,     6124, 0xb2a68c70
+0,         72,         72,        1,     6077, 0xb48b693f
+0,         73,         73,        1,     5804, 0xb700db6c
+0,         74,         74,        1,     6007, 0x02953898
+0,         75,         75,        1,     6228, 0x87a7b197
+0,         76,         76,        1,     6382, 0x49e7e65b
+0,         77,         77,        1,     6473, 0x3b9b6c3d
+0,         78,         78,        1,     7027, 0x2a4e1c17
+0,         79,         79,        1,     7263, 0x2e48c2e7
+0,         80,         80,        1,     8205, 0x013b701a
+0,         81,         81,        1,     8366, 0xcca97b10
+0,         82,         82,        1,     7716, 0x3b088fb3
+0,         83,         83,        1,     7420, 0xefdd1187
+0,         84,         84,        1,     7549, 0x1731227c
+0,         85,         85,        1,     7956, 0x8186ceb3
+0,         86,         86,        1,     8416, 0x23add53c
+0,         87,         87,        1,     8064, 0x09c616c4
+0,         88,         88,        1,     7409, 0x9d98af03
+0,         89,         89,        1,     7502, 0x0b81ebf3
+0,         90,         90,        1,     7814, 0x2f0d75cb
+0,         91,         91,        1,     7776, 0x45d6800f
+0,         92,         92,        1,     7757, 0x777f98b6
+0,         93,         93,        1,     8055, 0x4eea1634
+0,         94,         94,        1,     7626, 0xfb3931fd
+0,         95,         95,        1,     7987, 0x22a1d052
+0,         96,         96,        1,    12070, 0x3aa2924d
+0,         97,         97,        1,    12325, 0xda6cd811
+0,         98,         98,        1,    12225, 0xd478e671
+0,         99,         99,        1,    11235, 0xc6c09240
+0,        100,        100,        1,    11116, 0x95050c25
+0,        101,        101,        1,    11374, 0x14a68e3d
+0,        102,        102,        1,    11904, 0xb14436f2
+0,        103,        103,        1,    11487, 0xa3358311
+0,        104,        104,        1,    13403, 0xccf33a00
+0,        105,        105,        1,    12921, 0xbf7e4759
+0,        106,        106,        1,    13872, 0x7dace890
+0,        107,        107,        1,    13559, 0xb6c868f9
+0,        108,        108,        1,    14049, 0xa5d569b0
+0,        109,        109,        1,    14152, 0x8c9c31fb
+0,        110,        110,        1,    14285, 0x2ffe3bc3
+0,        111,        111,        1,    14432, 0x27abe196
+0,        112,        112,        1,    14697, 0x20d1aedd
+0,        113,        113,        1,    14606, 0xbcbe586d
+0,        114,        114,        1,    15221, 0x515f8224
+0,        115,        115,        1,    15433, 0x68089081
+0,        116,        116,        1,    15603, 0x8ff4e6fd
+0,        117,        117,        1,    15606, 0xc8527e30
+0,        118,        118,        1,    15871, 0x056ddca3
+0,        119,        119,        1,    15725, 0xc1871caf
+0,        120,        120,        1,    16086, 0x063e257b
+0,        121,        121,        1,    16233, 0xf683823b
+0,        122,        122,        1,    16143, 0x576df609
+0,        123,        123,        1,    16669, 0x3d02346b
+0,        124,        124,        1,    16627, 0xe35236cc
+0,        125,        125,        1,    16837, 0x389c996c
+0,        126,        126,        1,    16952, 0xc833af9f
+0,        127,        127,        1,    17127, 0xbf124531
+0,        128,        128,        1,    17158, 0x7abbfe59
+0,        129,        129,        1,    17329, 0x8102cc38
+0,        130,        130,        1,    17403, 0xa9468cad
+0,        131,        131,        1,    17674, 0x46d8038c
+0,        132,        132,        1,    17738, 0x5ee865ce
+0,        133,        133,        1,    17942, 0xc2449873
+0,        134,        134,        1,    17952, 0x3aafedbc
+0,        135,        135,        1,    18246, 0xdd930054
+0,        136,        136,        1,    18399, 0x68a59331
+0,        137,        137,        1,    18551, 0x1301c157
+0,        138,        138,        1,    18947, 0xbed8a9b4
+0,        139,        139,        1,    19153, 0xe338fea2
+0,        140,        140,        1,    19128, 0xbf05820e
+0,        141,        141,        1,    19138, 0x73b5cd49
+0,        142,        142,        1,    19502, 0xd8d68603
+0,        143,        143,        1,    19542, 0x84b47563
+0,        144,        144,        1,    19755, 0x7194b230
+0,        145,        145,        1,    20122, 0x83633f5e
+0,        146,        146,        1,    20265, 0x7365b06b
+0,        147,        147,        1,    20378, 0x1aaf1a98
+0,        148,        148,        1,    20300, 0x1da6d336
+0,        149,        149,        1,    20499, 0x72d54d30
+0,        150,        150,        1,    20655, 0x6996b124
+0,        151,        151,        1,    20674, 0xa883abd2
+0,        152,        152,        1,    21015, 0x96cf4018
+0,        153,        153,        1,    21066, 0x307e4479
+0,        154,        154,        1,    21161, 0xd45a2c38
+0,        155,        155,        1,    21086, 0xcf0e597d
+0,        156,        156,        1,    21466, 0xcc4032fe
+0,        157,        157,        1,    21677, 0x755ccb7b
+0,        158,        158,        1,    21589, 0x5d74fb47
+0,        159,        159,        1,    21662, 0x0c459189
+0,        160,        160,        1,    21995, 0x43d46eb3
+0,        161,        161,        1,    22213, 0x68455c92
+0,        162,        162,        1,    22483, 0xdc83c15a
+0,        163,        163,        1,    22498, 0xfae1251e
+0,        164,        164,        1,    22468, 0x7944b1d4
+0,        165,        165,        1,    22869, 0xff8c10ac
+0,        166,        166,        1,    22754, 0xd8183b84
+0,        167,        167,        1,    23173, 0x6c3c48d5
+0,        168,        168,        1,    23281, 0xc32ca477
+0,        169,        169,        1,    23219, 0x4dc26193
+0,        170,        170,        1,    23656, 0xb85ee15f
+0,        171,        171,        1,    23683, 0x26ba4915
+0,        172,        172,        1,    23882, 0xf57285de
diff --git a/tests/ref/fate/gifenc-rgb4_byte b/tests/ref/fate/gifenc-rgb4_byte
index 067accd694..50a5d159ca 100644
--- a/tests/ref/fate/gifenc-rgb4_byte
+++ b/tests/ref/fate/gifenc-rgb4_byte
@@ -3,176 +3,176 @@ 
 #codec_id 0: gif
 #dimensions 0: 217x217
 #sar 0: 0/1
-0,          0,          0,        1,      508, 0xf04a113b
-0,          1,          1,        1,      213, 0x23c24d3d, S=1,     1024, 0xf7700427
-0,          2,          2,        1,      131, 0x56d22a39, 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,          7,          7,        1,      535, 0x12cde6b7, S=1,     1024, 0xf3740427
-0,          8,          8,        1,      438, 0xa653b946, 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,         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,         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,         24,         24,        1,     1900, 0xd7737a09, S=1,     1024, 0xecb30526
-0,         25,         25,        1,     1807, 0x4f6c5140, 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,         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,         36,         36,        1,     3814, 0x96a8d57e, S=1,     1024, 0xecb30526
-0,         37,         37,        1,     3627, 0x33a37f8f, 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,         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,         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,         50,         50,        1,     5266, 0xd5ab9630, S=1,     1024, 0xecb30526
-0,         51,         51,        1,     5416, 0x5876e16f, 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
-0,         55,         55,        1,     6233, 0x52a05075, S=1,     1024, 0xecb30526
-0,         56,         56,        1,     5911, 0x04bfc46a, S=1,     1024, 0xecb30526
-0,         57,         57,        1,     5997, 0xf1e6f586, S=1,     1024, 0xecb30526
-0,         58,         58,        1,     5946, 0xe6f3f055, S=1,     1024, 0xecb30526
-0,         59,         59,        1,     6468, 0xc8a3cf61, S=1,     1024, 0xecb30526
-0,         60,         60,        1,     6737, 0xc27b3b79, S=1,     1024, 0xecb30526
-0,         61,         61,        1,     6275, 0x84d88e2b, S=1,     1024, 0xecb30526
-0,         62,         62,        1,     6641, 0xb44b3534, S=1,     1024, 0xecb30526
-0,         63,         63,        1,     6378, 0x3965888b, S=1,     1024, 0xecb30526
-0,         64,         64,        1,     6257, 0x12115750, S=1,     1024, 0xecb30526
-0,         65,         65,        1,     6908, 0x57137217, S=1,     1024, 0xecb30526
-0,         66,         66,        1,     7230, 0xbacc24ee, S=1,     1024, 0xecb30526
-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,         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
-0,         74,         74,        1,     8101, 0xc627adbe, S=1,     1024, 0xecb30526
-0,         75,         75,        1,     7863, 0xe99f3f3b, S=1,     1024, 0xecb30526
-0,         76,         76,        1,     7960, 0x4bc091b8, S=1,     1024, 0xecb30526
-0,         77,         77,        1,     8238, 0x1086ea8a, S=1,     1024, 0xecb30526
-0,         78,         78,        1,     8321, 0x3a404791, S=1,     1024, 0xecb30526
-0,         79,         79,        1,     8562, 0xcbdcc01e, S=1,     1024, 0xecb30526
-0,         80,         80,        1,     8746, 0xec190b22, S=1,     1024, 0xecb30526
-0,         81,         81,        1,     8578, 0x12e7a4e8, S=1,     1024, 0xecb30526
-0,         82,         82,        1,     8878, 0x51c05771, S=1,     1024, 0xecb30526
-0,         83,         83,        1,     9077, 0xe12b589b, S=1,     1024, 0xecb30526
-0,         84,         84,        1,     9310, 0xde3bf881, S=1,     1024, 0xecb30526
-0,         85,         85,        1,     9394, 0x1eba46cc, S=1,     1024, 0xecb30526
-0,         86,         86,        1,     9161, 0x7c359911, S=1,     1024, 0xecb30526
-0,         87,         87,        1,     9462, 0xccda3664, S=1,     1024, 0xecb30526
-0,         88,         88,        1,     9650, 0x6e6292fc, S=1,     1024, 0xecb30526
-0,         89,         89,        1,     9701, 0x08909b95, S=1,     1024, 0xecb30526
-0,         90,         90,        1,     9523, 0xe61b38bb, S=1,     1024, 0xecb30526
-0,         91,         91,        1,     9891, 0x96b90b98, S=1,     1024, 0xecb30526
-0,         92,         92,        1,    10005, 0x2db84c80, S=1,     1024, 0xecb30526
-0,         93,         93,        1,    10038, 0x37e52a72, S=1,     1024, 0xecb30526
-0,         94,         94,        1,    10086, 0x135a43e4, S=1,     1024, 0xecb30526
-0,         95,         95,        1,    10438, 0x472c0372, S=1,     1024, 0xecb30526
-0,         96,         96,        1,    10583, 0xcf4c5862, S=1,     1024, 0xecb30526
-0,         97,         97,        1,    10581, 0xce658137, S=1,     1024, 0xecb30526
-0,         98,         98,        1,    10807, 0x3954dad9, S=1,     1024, 0xecb30526
-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,        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,        107,        107,        1,    11932, 0xecb5bdf7, S=1,     1024, 0xecb30526
-0,        108,        108,        1,    12281, 0x18bb76d5, 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,        113,        113,        1,    12957, 0x3b839f0d, S=1,     1024, 0xecb30526
-0,        114,        114,        1,    13054, 0xb8a5e3db, 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,        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
-0,        121,        121,        1,    13665, 0x8100dbf2, S=1,     1024, 0xecb30526
-0,        122,        122,        1,    13692, 0xddd1eab9, S=1,     1024, 0xecb30526
-0,        123,        123,        1,    13821, 0xc70e2af0, S=1,     1024, 0xecb30526
-0,        124,        124,        1,    13946, 0xe15d9134, S=1,     1024, 0xecb30526
-0,        125,        125,        1,    14063, 0xf652d232, S=1,     1024, 0xecb30526
-0,        126,        126,        1,    14124, 0x756ccc81, S=1,     1024, 0xecb30526
-0,        127,        127,        1,    14331, 0x56d64fe8, S=1,     1024, 0xecb30526
-0,        128,        128,        1,    14469, 0x4c3faa7f, S=1,     1024, 0xecb30526
-0,        129,        129,        1,    14536, 0xad02a19b, S=1,     1024, 0xecb30526
-0,        130,        130,        1,    14608, 0x0971d168, S=1,     1024, 0xecb30526
-0,        131,        131,        1,    14898, 0x1a6827b3, S=1,     1024, 0xecb30526
-0,        132,        132,        1,    14978, 0xf9709fef, S=1,     1024, 0xecb30526
-0,        133,        133,        1,    15142, 0x3598da63, S=1,     1024, 0xecb30526
-0,        134,        134,        1,    15129, 0x062fb976, S=1,     1024, 0xecb30526
-0,        135,        135,        1,    15243, 0x0a6a12f9, S=1,     1024, 0xecb30526
-0,        136,        136,        1,    15337, 0x0f9a65d6, S=1,     1024, 0xecb30526
-0,        137,        137,        1,    15638, 0xf7bc9ef5, S=1,     1024, 0xecb30526
-0,        138,        138,        1,    15912, 0x2d5b26bb, S=1,     1024, 0xecb30526
-0,        139,        139,        1,    16041, 0xbfaf4857, S=1,     1024, 0xecb30526
-0,        140,        140,        1,    16228, 0xdac701f0, S=1,     1024, 0xecb30526
-0,        141,        141,        1,    16262, 0xcd0ae5e4, S=1,     1024, 0xecb30526
-0,        142,        142,        1,    16371, 0x9d4f0e73, S=1,     1024, 0xecb30526
-0,        143,        143,        1,    16661, 0xd37ba990, S=1,     1024, 0xecb30526
-0,        144,        144,        1,    16917, 0xd5b01774, S=1,     1024, 0xecb30526
-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,        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
-0,        153,        153,        1,    17918, 0x84fc9a95, S=1,     1024, 0xecb30526
-0,        154,        154,        1,    17823, 0x788fbada, S=1,     1024, 0xecb30526
-0,        155,        155,        1,    18142, 0x56881e47, S=1,     1024, 0xecb30526
-0,        156,        156,        1,    18257, 0xa35b86cf, S=1,     1024, 0xecb30526
-0,        157,        157,        1,    18337, 0x82ddbc21, S=1,     1024, 0xecb30526
-0,        158,        158,        1,    18293, 0xf0d838d6, S=1,     1024, 0xecb30526
-0,        159,        159,        1,    18418, 0x7ed8bba6, S=1,     1024, 0xecb30526
-0,        160,        160,        1,    18607, 0xccea47f6, S=1,     1024, 0xecb30526
-0,        161,        161,        1,    18916, 0x880ebd63, S=1,     1024, 0xecb30526
-0,        162,        162,        1,    19073, 0x055f02e3, S=1,     1024, 0xecb30526
-0,        163,        163,        1,    19168, 0xcc2c02d7, S=1,     1024, 0xecb30526
-0,        164,        164,        1,    19210, 0xa538ffc1, S=1,     1024, 0xecb30526
-0,        165,        165,        1,    19398, 0x4777644d, S=1,     1024, 0xecb30526
-0,        166,        166,        1,    19480, 0xcb2aa0fa, S=1,     1024, 0xecb30526
-0,        167,        167,        1,    19659, 0xe3c1122d, S=1,     1024, 0xecb30526
-0,        168,        168,        1,    19672, 0x1d1e193f, S=1,     1024, 0xecb30526
-0,        169,        169,        1,    19936, 0xcd036346, S=1,     1024, 0xecb30526
-0,        170,        170,        1,    19975, 0x96529b21, S=1,     1024, 0xecb30526
-0,        171,        171,        1,    20021, 0xcdaf8bb5, S=1,     1024, 0xecb30526
-0,        172,        172,        1,    20060, 0x1cea7784, S=1,     1024, 0xecb30526
+0,          0,          0,        1,     1297, 0x5618fe71
+0,          1,          1,        1,      221, 0x230c4e66
+0,          2,          2,        1,      139, 0xf87a2b65
+0,          3,          3,        1,      392, 0x7794a5e6
+0,          4,          4,        1,      389, 0xf856a3f1
+0,          5,          5,        1,      438, 0x0f95b4fb
+0,          6,          6,        1,      526, 0x7885d860
+0,          7,          7,        1,      543, 0x859fe7df
+0,          8,          8,        1,      446, 0xb34dba74
+0,          9,          9,        1,      931, 0x1c2fa48d
+0,         10,         10,        1,      702, 0x1ce74b4d
+0,         11,         11,        1,     1202, 0x2f232db8
+0,         12,         12,        1,     1299, 0x904e56af
+0,         13,         13,        1,     1253, 0x20803653
+0,         14,         14,        1,     1338, 0x24e052f6
+0,         15,         15,        1,     1284, 0x590a3a42
+0,         16,         16,        1,     1483, 0x93e09883
+0,         17,         17,        1,     1792, 0x70984bdf
+0,         18,         18,        1,     1683, 0x23b9fc30
+0,         19,         19,        1,     1517, 0x0fc1acf6
+0,         20,         20,        1,     1713, 0x6b4c1861
+0,         21,         21,        1,     1753, 0x896b20c1
+0,         22,         22,        1,     1650, 0x2f26027f
+0,         23,         23,        1,     1726, 0x9f731df0
+0,         24,         24,        1,     1908, 0xebd67b41
+0,         25,         25,        1,     1815, 0xf2685278
+0,         26,         26,        1,     1923, 0xbe18821e
+0,         27,         27,        1,     2108, 0x1318d306
+0,         28,         28,        1,     2708, 0x5e28f23c
+0,         29,         29,        1,     2681, 0xb96da855
+0,         30,         30,        1,     2903, 0x61cf4983
+0,         31,         31,        1,     3265, 0x95a1d25d
+0,         32,         32,        1,     3187, 0x6a67c299
+0,         33,         33,        1,     3304, 0x1c5ce63e
+0,         34,         34,        1,     3608, 0x2ed2770f
+0,         35,         35,        1,     3707, 0xa075a17b
+0,         36,         36,        1,     3822, 0xc842d6b6
+0,         37,         37,        1,     3635, 0x814680c7
+0,         38,         38,        1,     2958, 0x64de62cf
+0,         39,         39,        1,     3094, 0x2c338e84
+0,         40,         40,        1,     3102, 0xec5e8757
+0,         41,         41,        1,     3464, 0xea4f2bce
+0,         42,         42,        1,     4116, 0xded05ff3
+0,         43,         43,        1,     4225, 0x21825a2c
+0,         44,         44,        1,     3621, 0xa3125130
+0,         45,         45,        1,     3918, 0x35e0e876
+0,         46,         46,        1,     4469, 0xa408e1f7
+0,         47,         47,        1,     4601, 0x6f7d3081
+0,         48,         48,        1,     4830, 0x023e9cab
+0,         49,         49,        1,     5406, 0xf67ac12c
+0,         50,         50,        1,     5274, 0xf14e9768
+0,         51,         51,        1,     5424, 0x2af8e2a7
+0,         52,         52,        1,     5527, 0x80f70710
+0,         53,         53,        1,     5709, 0x89975c2f
+0,         54,         54,        1,     6168, 0xf5a542af
+0,         55,         55,        1,     6241, 0x091651ad
+0,         56,         56,        1,     5919, 0x32a7c5a2
+0,         57,         57,        1,     6005, 0x88adf6be
+0,         58,         58,        1,     5954, 0x3f92f18d
+0,         59,         59,        1,     6476, 0x9d90d099
+0,         60,         60,        1,     6745, 0xdf4f3cb1
+0,         61,         61,        1,     6283, 0x6e7e8f63
+0,         62,         62,        1,     6649, 0x5c1f366c
+0,         63,         63,        1,     6386, 0xa09389c3
+0,         64,         64,        1,     6265, 0xe5b85888
+0,         65,         65,        1,     6916, 0x445e734f
+0,         66,         66,        1,     7238, 0x30a52626
+0,         67,         67,        1,     7564, 0x1ddaa7cc
+0,         68,         68,        1,     7421, 0x118e7850
+0,         69,         69,        1,     7484, 0x5459acd8
+0,         70,         70,        1,     7604, 0x66f9e6a5
+0,         71,         71,        1,     7764, 0x862c0630
+0,         72,         72,        1,     8023, 0x06e16db8
+0,         73,         73,        1,     8136, 0xce28c084
+0,         74,         74,        1,     8109, 0x61c4aef6
+0,         75,         75,        1,     7871, 0x631d4073
+0,         76,         76,        1,     7968, 0x3b7692f0
+0,         77,         77,        1,     8246, 0x531bebc2
+0,         78,         78,        1,     8329, 0xe1fd48c9
+0,         79,         79,        1,     8570, 0x996fc156
+0,         80,         80,        1,     8754, 0x99fb0c5a
+0,         81,         81,        1,     8586, 0xf3eba620
+0,         82,         82,        1,     8886, 0xa08258a9
+0,         83,         83,        1,     9085, 0x229359d3
+0,         84,         84,        1,     9318, 0x3baaf9b9
+0,         85,         85,        1,     9402, 0xe27a4804
+0,         86,         86,        1,     9169, 0x23fd9a49
+0,         87,         87,        1,     9470, 0xe389379c
+0,         88,         88,        1,     9658, 0x6a409434
+0,         89,         89,        1,     9709, 0x42969ccd
+0,         90,         90,        1,     9531, 0x473139f3
+0,         91,         91,        1,     9899, 0xb85e0cd0
+0,         92,         92,        1,    10013, 0xda4d4db8
+0,         93,         93,        1,    10046, 0x0cc12baa
+0,         94,         94,        1,    10094, 0x22b6451c
+0,         95,         95,        1,    10446, 0x03a604aa
+0,         96,         96,        1,    10591, 0x3c8d599a
+0,         97,         97,        1,    10589, 0x3936826f
+0,         98,         98,        1,    10815, 0xb795dc11
+0,         99,         99,        1,    11119, 0x506c5187
+0,        100,        100,        1,    11202, 0x92856baf
+0,        101,        101,        1,    11248, 0xdf29a1db
+0,        102,        102,        1,    11491, 0x656df632
+0,        103,        103,        1,    11688, 0xeb175aa9
+0,        104,        104,        1,    11793, 0x99ccb713
+0,        105,        105,        1,    11444, 0x602c0c0d
+0,        106,        106,        1,    11936, 0xe89cc9bd
+0,        107,        107,        1,    11940, 0xc668bf2f
+0,        108,        108,        1,    12289, 0x9bd5780d
+0,        109,        109,        1,    12342, 0xd9c680fb
+0,        110,        110,        1,    12460, 0xb539b50f
+0,        111,        111,        1,    12703, 0x07473fac
+0,        112,        112,        1,    12676, 0x743052ae
+0,        113,        113,        1,    12965, 0xf6aaa045
+0,        114,        114,        1,    13062, 0xea13e513
+0,        115,        115,        1,    13155, 0x82312fa0
+0,        116,        116,        1,    13179, 0xd59c1dda
+0,        117,        117,        1,    13206, 0xde825850
+0,        118,        118,        1,    13219, 0x0b375f69
+0,        119,        119,        1,    13218, 0x14036301
+0,        120,        120,        1,    13475, 0x259da599
+0,        121,        121,        1,    13673, 0x9b43dd2a
+0,        122,        122,        1,    13700, 0x190bebf1
+0,        123,        123,        1,    13829, 0x9f802c28
+0,        124,        124,        1,    13954, 0x5236926c
+0,        125,        125,        1,    14071, 0xf5c3d36a
+0,        126,        126,        1,    14132, 0xbf35cdb9
+0,        127,        127,        1,    14339, 0x9cf65120
+0,        128,        128,        1,    14477, 0x3a9eabb7
+0,        129,        129,        1,    14544, 0xed09a2d3
+0,        130,        130,        1,    14616, 0xa138d2a0
+0,        131,        131,        1,    14906, 0x13bd28eb
+0,        132,        132,        1,    14986, 0x5454a127
+0,        133,        133,        1,    15150, 0x585cdb9b
+0,        134,        134,        1,    15137, 0x191bbaae
+0,        135,        135,        1,    15251, 0xa8461431
+0,        136,        136,        1,    15345, 0x2015670e
+0,        137,        137,        1,    15646, 0x772da02d
+0,        138,        138,        1,    15920, 0xfabc27f3
+0,        139,        139,        1,    16049, 0x2a66498f
+0,        140,        140,        1,    16236, 0x29750328
+0,        141,        141,        1,    16270, 0x4528e71c
+0,        142,        142,        1,    16379, 0x9a450fab
+0,        143,        143,        1,    16669, 0x31ffaac8
+0,        144,        144,        1,    16925, 0x6c4318ac
+0,        145,        145,        1,    17157, 0xf4b1cf0c
+0,        146,        146,        1,    17180, 0xd1bab36c
+0,        147,        147,        1,    17323, 0x419eaee3
+0,        148,        148,        1,    17405, 0xdf3f16ee
+0,        149,        149,        1,    17439, 0x7153f9f8
+0,        150,        150,        1,    17584, 0x1612557d
+0,        151,        151,        1,    17772, 0xffa78d73
+0,        152,        152,        1,    17834, 0x3e33866a
+0,        153,        153,        1,    17926, 0xdfc39bcd
+0,        154,        154,        1,    17831, 0x5f8ebc12
+0,        155,        155,        1,    18150, 0xc25e1f7f
+0,        156,        156,        1,    18265, 0x9b688807
+0,        157,        157,        1,    18345, 0xdc6abd59
+0,        158,        158,        1,    18301, 0x14d43a0e
+0,        159,        159,        1,    18426, 0x3b2cbcde
+0,        160,        160,        1,    18615, 0x6fa5492e
+0,        161,        161,        1,    18924, 0xa370be9b
+0,        162,        162,        1,    19081, 0xe019041b
+0,        163,        163,        1,    19176, 0x1acc040f
+0,        164,        164,        1,    19218, 0x27080108
+0,        165,        165,        1,    19406, 0xae676585
+0,        166,        166,        1,    19488, 0x9619a232
+0,        167,        167,        1,    19667, 0x88e71365
+0,        168,        168,        1,    19680, 0xd20d1a77
+0,        169,        169,        1,    19944, 0xc3d0647e
+0,        170,        170,        1,    19983, 0xbca79c59
+0,        171,        171,        1,    20029, 0x2c238ced
+0,        172,        172,        1,    20068, 0xaad778bc
diff --git a/tests/ref/fate/gifenc-rgb8 b/tests/ref/fate/gifenc-rgb8
index 490e4d0b19..25f49e4e1b 100644
--- a/tests/ref/fate/gifenc-rgb8
+++ b/tests/ref/fate/gifenc-rgb8
@@ -3,176 +3,176 @@ 
 #codec_id 0: gif
 #dimensions 0: 217x217
 #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,          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,          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
-0,          9,          9,        1,     1157, 0x4c112ecd, S=1,     1024, 0xcfc8799f
-0,         10,         10,        1,      179, 0x0690541c, S=1,     1024, 0xcfc8799f
-0,         11,         11,        1,     1333, 0x216f70a7, S=1,     1024, 0xcfc8799f
-0,         12,         12,        1,     1638, 0x901c093d, S=1,     1024, 0xcfc8799f
-0,         13,         13,        1,     1531, 0xc9bae5ff, S=1,     1024, 0xcfc8799f
-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,         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,         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,         25,         25,        1,     3101, 0x3e029e0e, S=1,     1024, 0xcfc8799f
-0,         26,         26,        1,     3253, 0x846af678, 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,         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,         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,         38,         38,        1,     3552, 0xed2c75b2, S=1,     1024, 0xcfc8799f
-0,         39,         39,        1,     3690, 0x2020dd0d, 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,         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,         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,         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,         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,         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,         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
-0,         70,         70,        1,     5763, 0xc110c791, S=1,     1024, 0xcfc8799f
-0,         71,         71,        1,     6116, 0xb4ee8e30, S=1,     1024, 0xcfc8799f
-0,         72,         72,        1,     6069, 0x21b263db, S=1,     1024, 0xcfc8799f
-0,         73,         73,        1,     5796, 0x2514df52, S=1,     1024, 0xcfc8799f
-0,         74,         74,        1,     5999, 0x1c3c3701, S=1,     1024, 0xcfc8799f
-0,         75,         75,        1,     6220, 0x8340b150, S=1,     1024, 0xcfc8799f
-0,         76,         76,        1,     6374, 0x00d8eaa5, S=1,     1024, 0xcfc8799f
-0,         77,         77,        1,     6465, 0x74c4778a, S=1,     1024, 0xcfc8799f
-0,         78,         78,        1,     7019, 0xdb1a28a3, S=1,     1024, 0xcfc8799f
-0,         79,         79,        1,     7255, 0x1e19b76e, S=1,     1024, 0xcfc8799f
-0,         80,         80,        1,     8197, 0x26bc6a79, S=1,     1024, 0xcfc8799f
-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,         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
-0,         88,         88,        1,     7401, 0x26ebb649, S=1,     1024, 0xcfc8799f
-0,         89,         89,        1,     7494, 0x35fcf9ae, S=1,     1024, 0xcfc8799f
-0,         90,         90,        1,     7806, 0x4238723d, S=1,     1024, 0xcfc8799f
-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,         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,        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
-0,        103,        103,        1,    11479, 0xeaa38225, S=1,     1024, 0xcfc8799f
-0,        104,        104,        1,    13395, 0xaa9d4c72, S=1,     1024, 0xcfc8799f
-0,        105,        105,        1,    12913, 0x28854353, S=1,     1024, 0xcfc8799f
-0,        106,        106,        1,    13864, 0x663df630, S=1,     1024, 0xcfc8799f
-0,        107,        107,        1,    13551, 0xf7ba7be7, S=1,     1024, 0xcfc8799f
-0,        108,        108,        1,    14041, 0x2dc071b9, S=1,     1024, 0xcfc8799f
-0,        109,        109,        1,    14144, 0x33a03d1d, S=1,     1024, 0xcfc8799f
-0,        110,        110,        1,    14277, 0x6bda5935, S=1,     1024, 0xcfc8799f
-0,        111,        111,        1,    14424, 0xa696efd8, S=1,     1024, 0xcfc8799f
-0,        112,        112,        1,    14689, 0x8e3ad12c, S=1,     1024, 0xcfc8799f
-0,        113,        113,        1,    14598, 0x544668b4, S=1,     1024, 0xcfc8799f
-0,        114,        114,        1,    15213, 0x60009558, S=1,     1024, 0xcfc8799f
-0,        115,        115,        1,    15425, 0x86e5adf4, S=1,     1024, 0xcfc8799f
-0,        116,        116,        1,    15595, 0x878d09b9, S=1,     1024, 0xcfc8799f
-0,        117,        117,        1,    15598, 0x10daabc4, S=1,     1024, 0xcfc8799f
-0,        118,        118,        1,    15863, 0x2462016c, S=1,     1024, 0xcfc8799f
-0,        119,        119,        1,    15717, 0xe05041c4, S=1,     1024, 0xcfc8799f
-0,        120,        120,        1,    16078, 0x7c8f3a8c, S=1,     1024, 0xcfc8799f
-0,        121,        121,        1,    16225, 0x9771a52e, S=1,     1024, 0xcfc8799f
-0,        122,        122,        1,    16135, 0x2dfc1692, S=1,     1024, 0xcfc8799f
-0,        123,        123,        1,    16661, 0x09c96d7e, S=1,     1024, 0xcfc8799f
-0,        124,        124,        1,    16619, 0xc4735b56, S=1,     1024, 0xcfc8799f
-0,        125,        125,        1,    16829, 0x589dc13f, S=1,     1024, 0xcfc8799f
-0,        126,        126,        1,    16944, 0x997cd18f, S=1,     1024, 0xcfc8799f
-0,        127,        127,        1,    17119, 0x6c396b60, S=1,     1024, 0xcfc8799f
-0,        128,        128,        1,    17150, 0x8e603d31, S=1,     1024, 0xcfc8799f
-0,        129,        129,        1,    17321, 0x0bbcee5a, S=1,     1024, 0xcfc8799f
-0,        130,        130,        1,    17395, 0x99f0c974, S=1,     1024, 0xcfc8799f
-0,        131,        131,        1,    17666, 0x37184223, S=1,     1024, 0xcfc8799f
-0,        132,        132,        1,    17730, 0xa0d385b3, S=1,     1024, 0xcfc8799f
-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,        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
-0,        140,        140,        1,    19120, 0xeac6a9c3, S=1,     1024, 0xcfc8799f
-0,        141,        141,        1,    19130, 0x31f3edbc, S=1,     1024, 0xcfc8799f
-0,        142,        142,        1,    19494, 0x3259a2f3, S=1,     1024, 0xcfc8799f
-0,        143,        143,        1,    19534, 0xda22a752, S=1,     1024, 0xcfc8799f
-0,        144,        144,        1,    19747, 0x8805c379, S=1,     1024, 0xcfc8799f
-0,        145,        145,        1,    20114, 0xaaf96864, S=1,     1024, 0xcfc8799f
-0,        146,        146,        1,    20257, 0x7223da26, S=1,     1024, 0xcfc8799f
-0,        147,        147,        1,    20370, 0x08ef382a, S=1,     1024, 0xcfc8799f
-0,        148,        148,        1,    20292, 0x4b47f207, S=1,     1024, 0xcfc8799f
-0,        149,        149,        1,    20491, 0xeedd6d1c, S=1,     1024, 0xcfc8799f
-0,        150,        150,        1,    20647, 0xb0d1dd45, S=1,     1024, 0xcfc8799f
-0,        151,        151,        1,    20666, 0x382cc8a4, S=1,     1024, 0xcfc8799f
-0,        152,        152,        1,    21007, 0x398f4f7d, S=1,     1024, 0xcfc8799f
-0,        153,        153,        1,    21058, 0xd6616a9d, S=1,     1024, 0xcfc8799f
-0,        154,        154,        1,    21153, 0x988749db, S=1,     1024, 0xcfc8799f
-0,        155,        155,        1,    21078, 0x1b328059, S=1,     1024, 0xcfc8799f
-0,        156,        156,        1,    21458, 0x6348529c, S=1,     1024, 0xcfc8799f
-0,        157,        157,        1,    21669, 0xcf63e2de, S=1,     1024, 0xcfc8799f
-0,        158,        158,        1,    21581, 0x1fc021af, S=1,     1024, 0xcfc8799f
-0,        159,        159,        1,    21654, 0x899dab18, S=1,     1024, 0xcfc8799f
-0,        160,        160,        1,    21987, 0x634086fe, S=1,     1024, 0xcfc8799f
-0,        161,        161,        1,    22205, 0x617a7335, S=1,     1024, 0xcfc8799f
-0,        162,        162,        1,    22475, 0x9fa2e01c, S=1,     1024, 0xcfc8799f
-0,        163,        163,        1,    22490, 0x7dc5376c, S=1,     1024, 0xcfc8799f
-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,        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
-0,        171,        171,        1,    23675, 0x760460b9, S=1,     1024, 0xcfc8799f
-0,        172,        172,        1,    23874, 0xacf998c5, S=1,     1024, 0xcfc8799f
+0,          0,          0,        1,     1341, 0xaa85adb1
+0,          1,          1,        1,      305, 0xa970896f
+0,          2,          2,        1,      446, 0x4a20d47a
+0,          3,          3,        1,      458, 0x32ded2af
+0,          4,          4,        1,      555, 0x622205e4
+0,          5,          5,        1,      622, 0xde06214f
+0,          6,          6,        1,      650, 0x8f482007
+0,          7,          7,        1,      668, 0xd3df3a59
+0,          8,          8,        1,      829, 0x812f80d4
+0,          9,          9,        1,     1165, 0x8e402ff5
+0,         10,         10,        1,      187, 0xdda45544
+0,         11,         11,        1,     1341, 0x2f2d71cf
+0,         12,         12,        1,     1646, 0xfe910a65
+0,         13,         13,        1,     1539, 0xbc77e727
+0,         14,         14,        1,     1728, 0x9bd9486b
+0,         15,         15,        1,     1918, 0xcf948795
+0,         16,         16,        1,     2132, 0x4618dbf8
+0,         17,         17,        1,     2256, 0xcdce2bb0
+0,         18,         18,        1,     2319, 0x4f1b36d7
+0,         19,         19,        1,     2416, 0xcba76df1
+0,         20,         20,        1,     2609, 0xb2eec38f
+0,         21,         21,        1,     2695, 0x29d40439
+0,         22,         22,        1,     2792, 0x663f0f16
+0,         23,         23,        1,     2892, 0xd6924cc1
+0,         24,         24,        1,     2990, 0x8bed794d
+0,         25,         25,        1,     3109, 0x48789f36
+0,         26,         26,        1,     3261, 0x3eaff7a0
+0,         27,         27,        1,     3337, 0x3bcd1c99
+0,         28,         28,        1,     3580, 0xcf0c8b7a
+0,         29,         29,        1,     3815, 0x53d40009
+0,         30,         30,        1,     2758, 0x73fd20c6
+0,         31,         31,        1,     4039, 0xab517451
+0,         32,         32,        1,     3033, 0x66d29fbc
+0,         33,         33,        1,     4303, 0x30e50ba8
+0,         34,         34,        1,     2052, 0x4843c19a
+0,         35,         35,        1,     3220, 0x73f7f1b7
+0,         36,         36,        1,     2300, 0xca376466
+0,         37,         37,        1,     3641, 0x1e3a9bcb
+0,         38,         38,        1,     3560, 0x014776da
+0,         39,         39,        1,     3698, 0xd3bcde35
+0,         40,         40,        1,     1567, 0x6c8bf458
+0,         41,         41,        1,      962, 0x0389caed
+0,         42,         42,        1,      281, 0x575f7959
+0,         43,         43,        1,      938, 0x2d7aaf67
+0,         44,         44,        1,      279, 0xd39d81d7
+0,         45,         45,        1,      204, 0x90a9544a
+0,         46,         46,        1,     4307, 0xcf9d0eae
+0,         47,         47,        1,     4903, 0xe9743ace
+0,         48,         48,        1,     4936, 0x3cf21510
+0,         49,         49,        1,     4949, 0xcbff5648
+0,         50,         50,        1,     4162, 0x94a9b9ce
+0,         51,         51,        1,     4686, 0x5098c461
+0,         52,         52,        1,     4749, 0x7304bc6d
+0,         53,         53,        1,     4990, 0x9d025a9f
+0,         54,         54,        1,     5187, 0x0566c4c9
+0,         55,         55,        1,     5054, 0x574f81f5
+0,         56,         56,        1,     5148, 0xe7bac30f
+0,         57,         57,        1,     4309, 0x7844f361
+0,         58,         58,        1,     5087, 0xacf4a406
+0,         59,         59,        1,     5292, 0x9e7be109
+0,         60,         60,        1,     5434, 0x85541f7f
+0,         61,         61,        1,     4653, 0xf5118b09
+0,         62,         62,        1,     5271, 0x54f3d911
+0,         63,         63,        1,     5229, 0xc520cb6b
+0,         64,         64,        1,     5225, 0x2a449e23
+0,         65,         65,        1,     5403, 0x4a2502f3
+0,         66,         66,        1,     5228, 0x8002e47d
+0,         67,         67,        1,     5712, 0x9c9ed686
+0,         68,         68,        1,     5644, 0xfdf5a30d
+0,         69,         69,        1,     5826, 0xb142ece5
+0,         70,         70,        1,     5771, 0xd22ac8b9
+0,         71,         71,        1,     6124, 0x5e4e8f58
+0,         72,         72,        1,     6077, 0x94ab6503
+0,         73,         73,        1,     5804, 0x5c56e07a
+0,         74,         74,        1,     6007, 0x3e453829
+0,         75,         75,        1,     6228, 0xa4e0b278
+0,         76,         76,        1,     6382, 0xd488ebcd
+0,         77,         77,        1,     6473, 0xb1bb78b2
+0,         78,         78,        1,     7027, 0x98ce29cb
+0,         79,         79,        1,     7263, 0xecadb896
+0,         80,         80,        1,     8205, 0x36cb6ba1
+0,         81,         81,        1,     8366, 0xdbbe8308
+0,         82,         82,        1,     7716, 0xd6959765
+0,         83,         83,        1,     7420, 0x60fd1316
+0,         84,         84,        1,     7549, 0x668a1ae9
+0,         85,         85,        1,     7956, 0xe146cb65
+0,         86,         86,        1,     8416, 0x47c3d590
+0,         87,         87,        1,     8064, 0x9a0e249f
+0,         88,         88,        1,     7409, 0x9e5eb771
+0,         89,         89,        1,     7502, 0x1906fad6
+0,         90,         90,        1,     7814, 0x8e117365
+0,         91,         91,        1,     7776, 0xd0077a82
+0,         92,         92,        1,     7757, 0x74a49d3a
+0,         93,         93,        1,     8055, 0x70ef25d2
+0,         94,         94,        1,     7626, 0x4a003537
+0,         95,         95,        1,     7987, 0x1c14c607
+0,         96,         96,        1,    12070, 0x4a729eba
+0,         97,         97,        1,    12325, 0xbff1dd34
+0,         98,         98,        1,    12225, 0xb1ffee58
+0,         99,         99,        1,    11235, 0xea998fe1
+0,        100,        100,        1,    11116, 0x855407b4
+0,        101,        101,        1,    11374, 0xaa019a67
+0,        102,        102,        1,    11904, 0xf8384969
+0,        103,        103,        1,    11487, 0xce63834d
+0,        104,        104,        1,    13403, 0x36444d9a
+0,        105,        105,        1,    12921, 0x86af447b
+0,        106,        106,        1,    13872, 0x104af758
+0,        107,        107,        1,    13559, 0x37d07d0f
+0,        108,        108,        1,    14049, 0xa47572e1
+0,        109,        109,        1,    14152, 0x217c3e45
+0,        110,        110,        1,    14285, 0xf37e5a5d
+0,        111,        111,        1,    14432, 0xd841f100
+0,        112,        112,        1,    14697, 0xf25cd254
+0,        113,        113,        1,    14606, 0x4f3069dc
+0,        114,        114,        1,    15221, 0x222f9680
+0,        115,        115,        1,    15433, 0x3e43af1c
+0,        116,        116,        1,    15603, 0x038a0ae1
+0,        117,        117,        1,    15606, 0x9040acec
+0,        118,        118,        1,    15871, 0xd63f0294
+0,        119,        119,        1,    15725, 0xe95d42ec
+0,        120,        120,        1,    16086, 0x27223bb4
+0,        121,        121,        1,    16233, 0xebfca656
+0,        122,        122,        1,    16143, 0x1a7717ba
+0,        123,        123,        1,    16669, 0x56926ea6
+0,        124,        124,        1,    16627, 0xe0ac5c7e
+0,        125,        125,        1,    16837, 0x67b5c267
+0,        126,        126,        1,    16952, 0x2d9bd2b7
+0,        127,        127,        1,    17127, 0xcab06c88
+0,        128,        128,        1,    17158, 0x10be3e59
+0,        129,        129,        1,    17329, 0x53d2ef82
+0,        130,        130,        1,    17403, 0x37a5ca9c
+0,        131,        131,        1,    17674, 0x0e34434b
+0,        132,        132,        1,    17738, 0xc1ef86db
+0,        133,        133,        1,    17942, 0xbf37caa5
+0,        134,        134,        1,    17952, 0x256e0aee
+0,        135,        135,        1,    18246, 0xd818335f
+0,        136,        136,        1,    18399, 0x6b84c5b2
+0,        137,        137,        1,    18551, 0x5e02f360
+0,        138,        138,        1,    18947, 0x5cdbdb83
+0,        139,        139,        1,    19153, 0x97f52a72
+0,        140,        140,        1,    19128, 0x537baaeb
+0,        141,        141,        1,    19138, 0xa629eee4
+0,        142,        142,        1,    19502, 0x4b8da41b
+0,        143,        143,        1,    19542, 0x21a5a87a
+0,        144,        144,        1,    19755, 0xc5d0c4a1
+0,        145,        145,        1,    20122, 0x913a698c
+0,        146,        146,        1,    20265, 0xfdbcdb4e
+0,        147,        147,        1,    20378, 0x173f3952
+0,        148,        148,        1,    20300, 0xff58f32f
+0,        149,        149,        1,    20499, 0x89246e44
+0,        150,        150,        1,    20655, 0xff78de6d
+0,        151,        151,        1,    20674, 0x9ccbc9cc
+0,        152,        152,        1,    21015, 0x289450a5
+0,        153,        153,        1,    21066, 0x006d6bc5
+0,        154,        154,        1,    21161, 0x306b4b03
+0,        155,        155,        1,    21086, 0x5c4f8181
+0,        156,        156,        1,    21466, 0x5be353c4
+0,        157,        157,        1,    21677, 0xbc05e406
+0,        158,        158,        1,    21589, 0xa69322d7
+0,        159,        159,        1,    21662, 0x64e7ac40
+0,        160,        160,        1,    21995, 0xbfa18826
+0,        161,        161,        1,    22213, 0xb9fa745d
+0,        162,        162,        1,    22483, 0x3070e144
+0,        163,        163,        1,    22498, 0x1feb3894
+0,        164,        164,        1,    22468, 0xb34dbd26
+0,        165,        165,        1,    22869, 0x67c63638
+0,        166,        166,        1,    22754, 0xaa2d573d
+0,        167,        167,        1,    23173, 0x9f7767cb
+0,        168,        168,        1,    23281, 0x3f319c01
+0,        169,        169,        1,    23219, 0xb706632d
+0,        170,        170,        1,    23656, 0x7e2ff143
+0,        171,        171,        1,    23683, 0x729d61e1
+0,        172,        172,        1,    23882, 0x8fb999ed