diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index cb41ccc622..c3d13e5a26 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -404,7 +404,7 @@ OBJS-$(CONFIG_OWDENOISE_FILTER)              += vf_owdenoise.o
 OBJS-$(CONFIG_PAD_FILTER)                    += vf_pad.o
 OBJS-$(CONFIG_PAD_OPENCL_FILTER)             += vf_pad_opencl.o opencl.o opencl/pad.o
 OBJS-$(CONFIG_PALETTEGEN_FILTER)             += vf_palettegen.o
-OBJS-$(CONFIG_PALETTEUSE_FILTER)             += vf_paletteuse.o framesync.o
+OBJS-$(CONFIG_PALETTEUSE_FILTER)             += vf_paletteuse.o framesync.o palette.o
 OBJS-$(CONFIG_PERMS_FILTER)                  += f_perms.o
 OBJS-$(CONFIG_PERSPECTIVE_FILTER)            += vf_perspective.o
 OBJS-$(CONFIG_PHASE_FILTER)                  += vf_phase.o
diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c
index 0861a70a0b..3af121b1eb 100644
--- a/libavfilter/vf_paletteuse.c
+++ b/libavfilter/vf_paletteuse.c
@@ -32,6 +32,7 @@
 #include "filters.h"
 #include "framesync.h"
 #include "internal.h"
+#include "palette.h"
 
 enum dithering_mode {
     DITHERING_NONE,
@@ -56,8 +57,13 @@ enum diff_mode {
     NB_DIFF_MODE
 };
 
+struct color_info {
+    uint32_t srgb;
+    int32_t lab[3];
+};
+
 struct color_node {
-    uint32_t val;
+    struct color_info c;
     uint8_t palette_id;
     int split;
     int left_id, right_id;
@@ -162,25 +168,32 @@ static av_always_inline uint32_t dither_color(uint32_t px, int er, int eg,
          | av_clip_uint8((px       & 0xff) + ((eb * scale) / (1<<shift)));
 }
 
-static av_always_inline int diff(const uint32_t a, const uint32_t b, const int trans_thresh)
+static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
 {
-    // XXX: try L*a*b with CIE76 (dL*dL + da*da + db*db)
-    const uint8_t c1[] = {a >> 24, a >> 16 & 0xff, a >> 8 & 0xff, a & 0xff};
-    const uint8_t c2[] = {b >> 24, b >> 16 & 0xff, b >> 8 & 0xff, b & 0xff};
-    const int dr = c1[1] - c2[1];
-    const int dg = c1[2] - c2[2];
-    const int db = c1[3] - c2[3];
-
-    if (c1[0] < trans_thresh && c2[0] < trans_thresh) {
+    const uint8_t alpha_a = a->srgb >> 24;
+    const uint8_t alpha_b = b->srgb >> 24;
+
+    if (alpha_a < trans_thresh && alpha_b < trans_thresh) {
         return 0;
-    } else if (c1[0] >= trans_thresh && c2[0] >= trans_thresh) {
-        return dr*dr + dg*dg + db*db;
+    } else if (alpha_a >= trans_thresh && alpha_b >= trans_thresh) {
+        const int64_t dL = a->lab[0] - b->lab[0];
+        const int64_t da = a->lab[1] - b->lab[1];
+        const int64_t db = a->lab[2] - b->lab[2];
+        const int64_t ret = dL*dL + da*da + db*db;
+        return FFMIN(ret, INT32_MAX - 1);
     } else {
-        return 255*255 + 255*255 + 255*255;
+        return INT32_MAX - 1;
     }
 }
 
-static av_always_inline uint8_t colormap_nearest_bruteforce(const uint32_t *palette, const uint32_t target, const int trans_thresh)
+static struct color_info get_color_from_srgb(uint32_t srgb)
+{
+    const struct Lab lab = ff_srgb_u8_to_oklab_int(srgb);
+    struct color_info ret = {.srgb=srgb, .lab={lab.L, lab.a, lab.b}};
+    return ret;
+}
+
+static av_always_inline uint8_t colormap_nearest_bruteforce(const uint32_t *palette, const struct color_info *target, const int trans_thresh)
 {
     int i, pal_id = -1, min_dist = INT_MAX;
 
@@ -188,7 +201,8 @@ static av_always_inline uint8_t colormap_nearest_bruteforce(const uint32_t *pale
         const uint32_t c = palette[i];
 
         if (c >> 24 >= trans_thresh) { // ignore transparent entry
-            const int d = diff(palette[i], target, trans_thresh);
+            const struct color_info pal_color = get_color_from_srgb(palette[i]);
+            const int d = diff(&pal_color, target, trans_thresh);
             if (d < min_dist) {
                 pal_id = i;
                 min_dist = d;
@@ -206,14 +220,13 @@ struct nearest_color {
 
 static void colormap_nearest_node(const struct color_node *map,
                                   const int node_pos,
-                                  const uint32_t target,
+                                  const struct color_info *target,
                                   const int trans_thresh,
                                   struct nearest_color *nearest)
 {
     const struct color_node *kd = map + node_pos;
-    const int shift = (2 - kd->split) * 8;
-    int dx, nearer_kd_id, further_kd_id;
-    const uint32_t current = kd->val;
+    int nearer_kd_id, further_kd_id;
+    const struct color_info *current = &kd->c;
     const int current_to_target = diff(target, current, trans_thresh);
 
     if (current_to_target < nearest->dist_sqd) {
@@ -222,7 +235,7 @@ static void colormap_nearest_node(const struct color_node *map,
     }
 
     if (kd->left_id != -1 || kd->right_id != -1) {
-        dx = (int)(target>>shift & 0xff) - (int)(current>>shift & 0xff);
+        const int dx = target->lab[kd->split] - current->lab[kd->split];
 
         if (dx <= 0) nearer_kd_id = kd->left_id,  further_kd_id = kd->right_id;
         else         nearer_kd_id = kd->right_id, further_kd_id = kd->left_id;
@@ -235,9 +248,9 @@ static void colormap_nearest_node(const struct color_node *map,
     }
 }
 
-static av_always_inline uint8_t colormap_nearest_recursive(const struct color_node *node, const uint8_t target, const int trans_thresh)
+static av_always_inline uint8_t colormap_nearest_recursive(const struct color_node *node, const struct color_info *target, const int trans_thresh)
 {
-    struct nearest_color res = {.dist_sqd = INT_MAX, .node_pos = -1};
+    struct nearest_color res = {.dist_sqd = INT32_MAX, .node_pos = -1};
     colormap_nearest_node(node, 0, target, trans_thresh, &res);
     return node[res.node_pos].palette_id;
 }
@@ -247,7 +260,7 @@ struct stack_node {
     int dx2;
 };
 
-static av_always_inline uint8_t colormap_nearest_iterative(const struct color_node *root, const uint32_t target, const int trans_thresh)
+static av_always_inline uint8_t colormap_nearest_iterative(const struct color_node *root, const struct color_info *target, const int trans_thresh)
 {
     int pos = 0, best_node_id = -1, best_dist = INT_MAX, cur_color_id = 0;
     struct stack_node nodes[16];
@@ -256,7 +269,7 @@ static av_always_inline uint8_t colormap_nearest_iterative(const struct color_no
     for (;;) {
 
         const struct color_node *kd = &root[cur_color_id];
-        const uint32_t current = kd->val;
+        const struct color_info *current = &kd->c;
         const int current_to_target = diff(target, current, trans_thresh);
 
         /* Compare current color node to the target and update our best node if
@@ -270,8 +283,7 @@ static av_always_inline uint8_t colormap_nearest_iterative(const struct color_no
 
         /* Check if it's not a leaf */
         if (kd->left_id != -1 || kd->right_id != -1) {
-            const int shift = (2 - kd->split) * 8;
-            const int dx = (target>>shift & 0xff) - (current>>shift & 0xff);
+            const int dx = target->lab[kd->split] - current->lab[kd->split];
             int nearer_kd_id, further_kd_id;
 
             /* Define which side is the most interesting. */
@@ -332,6 +344,7 @@ static av_always_inline int color_get(PaletteUseContext *s, uint32_t color,
                                       const enum color_search_method search_method)
 {
     int i;
+    struct color_info clrinfo;
     const uint8_t rhash = (color>>16) & ((1<<NBITS)-1);
     const uint8_t ghash = (color>> 8) & ((1<<NBITS)-1);
     const uint8_t bhash =  color      & ((1<<NBITS)-1);
@@ -355,7 +368,8 @@ static av_always_inline int color_get(PaletteUseContext *s, uint32_t color,
     if (!e)
         return AVERROR(ENOMEM);
     e->color = color;
-    e->pal_entry = COLORMAP_NEAREST(search_method, s->palette, s->map, color, s->trans_thresh);
+    clrinfo = get_color_from_srgb(color);
+    e->pal_entry = COLORMAP_NEAREST(search_method, s->palette, s->map, &clrinfo, s->trans_thresh);
 
     return e->pal_entry;
 }
@@ -494,20 +508,18 @@ static void disp_node(AVBPrint *buf,
                       int depth)
 {
     const struct color_node *node = &map[node_id];
-    const uint32_t fontcolor = (node->val>>16 & 0xff) > 0x50 &&
-                               (node->val>> 8 & 0xff) > 0x50 &&
-                               (node->val     & 0xff) > 0x50 ? 0 : 0xffffff;
-    const int rgb_comp = node->split;
+    const uint32_t fontcolor = node->c.lab[0] > 0x7fff ? 0 : 0xffffff;
+    const int lab_comp = node->split;
     av_bprintf(buf, "%*cnode%d ["
-               "label=\"%c%02X%c%02X%c%02X%c\" "
+               "label=\"%c%d%c%d%c%d%c\" "
                "fillcolor=\"#%06"PRIX32"\" "
                "fontcolor=\"#%06"PRIX32"\"]\n",
                depth*INDENT, ' ', node->palette_id,
-               "[  "[rgb_comp], node->val>>16 & 0xff,
-               "][ "[rgb_comp], node->val>> 8 & 0xff,
-               " ]["[rgb_comp], node->val     & 0xff,
-               "  ]"[rgb_comp],
-               node->val & 0xffffff,
+               "[  "[lab_comp], node->c.lab[0],
+               "][ "[lab_comp], node->c.lab[1],
+               " ]["[lab_comp], node->c.lab[2],
+               "  ]"[lab_comp],
+               node->c.srgb & 0xffffff,
                fontcolor);
     if (parent_id != -1)
         av_bprintf(buf, "%*cnode%d -> node%d\n", depth*INDENT, ' ',
@@ -550,18 +562,18 @@ static int debug_accuracy(const struct color_node *node, const uint32_t *palette
     for (r = 0; r < 256; r++) {
         for (g = 0; g < 256; g++) {
             for (b = 0; b < 256; b++) {
-                const uint32_t argb = 0xff000000 | r<<16 | g<<8 | b;
-                const int r1 = COLORMAP_NEAREST(search_method, palette, node, argb, trans_thresh);
-                const int r2 = colormap_nearest_bruteforce(palette, argb, trans_thresh);
+                const struct color_info target = get_color_from_srgb(0xff000000 | r<<16 | g<<8 | b);
+                const int r1 = COLORMAP_NEAREST(search_method, palette, node, &target, trans_thresh);
+                const int r2 = colormap_nearest_bruteforce(palette, &target, trans_thresh);
                 if (r1 != r2) {
-                    const uint32_t c1 = palette[r1];
-                    const uint32_t c2 = palette[r2];
-                    const int d1 = diff(0xff000000 | c1, argb, trans_thresh);
-                    const int d2 = diff(0xff000000 | c2, argb, trans_thresh);
+                    const struct color_info pal_c1 = get_color_from_srgb(0xff000000 | palette[r1]);
+                    const struct color_info pal_c2 = get_color_from_srgb(0xff000000 | palette[r2]);
+                    const int d1 = diff(&pal_c1, &target, trans_thresh);
+                    const int d2 = diff(&pal_c2, &target, trans_thresh);
                     if (d1 != d2) {
                         av_log(NULL, AV_LOG_ERROR,
                                "/!\\ %02X%02X%02X: %d ! %d (%06"PRIX32" ! %06"PRIX32") / dist: %d ! %d\n",
-                               r, g, b, r1, r2, c1 & 0xffffff, c2 & 0xffffff, d1, d2);
+                               r, g, b, r1, r2, pal_c1.srgb & 0xffffff, pal_c2.srgb & 0xffffff, d1, d2);
                         ret = 1;
                     }
                 }
@@ -572,66 +584,63 @@ static int debug_accuracy(const struct color_node *node, const uint32_t *palette
 }
 
 struct color {
-    uint32_t value;
+    struct Lab value;
     uint8_t pal_id;
 };
 
 struct color_rect {
-    uint8_t min[3];
-    uint8_t max[3];
+    int min[3];
+    int max[3];
 };
 
 typedef int (*cmp_func)(const void *, const void *);
 
-#define DECLARE_CMP_FUNC(name, pos)                     \
+#define DECLARE_CMP_FUNC(name)                          \
 static int cmp_##name(const void *pa, const void *pb)   \
 {                                                       \
     const struct color *a = pa;                         \
     const struct color *b = pb;                         \
-    return   (int)(a->value >> (8 * (2 - (pos))) & 0xff)     \
-           - (int)(b->value >> (8 * (2 - (pos))) & 0xff);    \
+    return FFDIFFSIGN(a->value.name, b->value.name);    \
 }
 
-DECLARE_CMP_FUNC(r, 0)
-DECLARE_CMP_FUNC(g, 1)
-DECLARE_CMP_FUNC(b, 2)
+DECLARE_CMP_FUNC(L)
+DECLARE_CMP_FUNC(a)
+DECLARE_CMP_FUNC(b)
 
-static const cmp_func cmp_funcs[] = {cmp_r, cmp_g, cmp_b};
+static const cmp_func cmp_funcs[] = {cmp_L, cmp_a, cmp_b};
 
 static int get_next_color(const uint8_t *color_used, const uint32_t *palette,
                           int *component, const struct color_rect *box)
 {
-    int wr, wg, wb;
+    int wL, wa, wb;
     int i, longest = 0;
     unsigned nb_color = 0;
     struct color_rect ranges;
     struct color tmp_pal[256];
     cmp_func cmpf;
 
-    ranges.min[0] = ranges.min[1] = ranges.min[2] = 0xff;
-    ranges.max[0] = ranges.max[1] = ranges.max[2] = 0x00;
+    ranges.min[0] = ranges.min[1] = ranges.min[2] = 0xffff;
+    ranges.max[0] = ranges.max[1] = ranges.max[2] = -0xffff;
 
     for (i = 0; i < AVPALETTE_COUNT; i++) {
         const uint32_t c = palette[i];
         const uint8_t a = c >> 24;
-        const uint8_t r = c >> 16 & 0xff;
-        const uint8_t g = c >>  8 & 0xff;
-        const uint8_t b = c       & 0xff;
+        const struct Lab lab = ff_srgb_u8_to_oklab_int(c);
 
         if (color_used[i] || (a != 0xff) ||
-            r < box->min[0] || g < box->min[1] || b < box->min[2] ||
-            r > box->max[0] || g > box->max[1] || b > box->max[2])
+            lab.L < box->min[0] || lab.a < box->min[1] || lab.b < box->min[2] ||
+            lab.L > box->max[0] || lab.a > box->max[1] || lab.b > box->max[2])
             continue;
 
-        if (r < ranges.min[0]) ranges.min[0] = r;
-        if (g < ranges.min[1]) ranges.min[1] = g;
-        if (b < ranges.min[2]) ranges.min[2] = b;
+        if (lab.L < ranges.min[0]) ranges.min[0] = lab.L;
+        if (lab.a < ranges.min[1]) ranges.min[1] = lab.a;
+        if (lab.b < ranges.min[2]) ranges.min[2] = lab.b;
 
-        if (r > ranges.max[0]) ranges.max[0] = r;
-        if (g > ranges.max[1]) ranges.max[1] = g;
-        if (b > ranges.max[2]) ranges.max[2] = b;
+        if (lab.L > ranges.max[0]) ranges.max[0] = lab.L;
+        if (lab.a > ranges.max[1]) ranges.max[1] = lab.a;
+        if (lab.b > ranges.max[2]) ranges.max[2] = lab.b;
 
-        tmp_pal[nb_color].value  = c;
+        tmp_pal[nb_color].value  = lab;
         tmp_pal[nb_color].pal_id = i;
 
         nb_color++;
@@ -641,12 +650,12 @@ static int get_next_color(const uint8_t *color_used, const uint32_t *palette,
         return -1;
 
     /* define longest axis that will be the split component */
-    wr = ranges.max[0] - ranges.min[0];
-    wg = ranges.max[1] - ranges.min[1];
+    wL = ranges.max[0] - ranges.min[0];
+    wa = ranges.max[1] - ranges.min[1];
     wb = ranges.max[2] - ranges.min[2];
-    if (wr >= wg && wr >= wb) longest = 0;
-    if (wg >= wr && wg >= wb) longest = 1;
-    if (wb >= wr && wb >= wg) longest = 2;
+    if (wb >= wL && wb >= wa) longest = 2;
+    if (wa >= wL && wa >= wb) longest = 1;
+    if (wL >= wa && wL >= wb) longest = 0;
     cmpf = cmp_funcs[longest];
     *component = longest;
 
@@ -663,9 +672,8 @@ static int colormap_insert(struct color_node *map,
                            const int trans_thresh,
                            const struct color_rect *box)
 {
-    uint32_t c;
     int component, cur_id;
-    uint8_t comp_value;
+    int comp_value;
     int node_left_id = -1, node_right_id = -1;
     struct color_node *node;
     struct color_rect box1, box2;
@@ -676,19 +684,18 @@ static int colormap_insert(struct color_node *map,
 
     /* create new node with that color */
     cur_id = (*nb_used)++;
-    c = palette[pal_id];
     node = &map[cur_id];
     node->split = component;
     node->palette_id = pal_id;
-    node->val = c;
+    node->c = get_color_from_srgb(palette[pal_id]);
 
     color_used[pal_id] = 1;
 
     /* get the two boxes this node creates */
     box1 = box2 = *box;
-    comp_value = node->val >> ((2 - component) * 8) & 0xff;
+    comp_value = node->c.lab[component];
     box1.max[component] = comp_value;
-    box2.min[component] = FFMIN(comp_value + 1, 255);
+    box2.min[component] = FFMIN(comp_value + 1, 0xffff);
 
     node_left_id = colormap_insert(map, color_used, nb_used, palette, trans_thresh, &box1);
 
@@ -735,8 +742,8 @@ static void load_colormap(PaletteUseContext *s)
         }
     }
 
-    box.min[0] = box.min[1] = box.min[2] = 0x00;
-    box.max[0] = box.max[1] = box.max[2] = 0xff;
+    box.min[0] = box.min[1] = box.min[2] = -0xffff;
+    box.max[0] = box.max[1] = box.max[2] = 0xffff;
 
     colormap_insert(s->map, color_used, &nb_used, s->palette, s->trans_thresh, &box);
 
@@ -763,11 +770,9 @@ static void debug_mean_error(PaletteUseContext *s, const AVFrame *in1,
 
     for (y = 0; y < in1->height; y++) {
         for (x = 0; x < in1->width; x++) {
-            const uint32_t c1 = src1[x];
-            const uint32_t c2 = palette[src2[x]];
-            const uint32_t argb1 = 0xff000000 | c1;
-            const uint32_t argb2 = 0xff000000 | c2;
-            mean_err += diff(argb1, argb2, s->trans_thresh);
+            const struct color_info c1 = get_color_from_srgb(0xff000000 | src1[x]);
+            const struct color_info c2 = get_color_from_srgb(0xff000000 | palette[src2[x]]);
+            mean_err += diff(&c1, &c2, s->trans_thresh);
         }
         src1 += src1_linesize;
         src2 += src2_linesize;
diff --git a/tests/ref/fate/filter-paletteuse-bayer b/tests/ref/fate/filter-paletteuse-bayer
index 5ca0115053..fa1778a1bb 100644
--- a/tests/ref/fate/filter-paletteuse-bayer
+++ b/tests/ref/fate/filter-paletteuse-bayer
@@ -3,74 +3,74 @@
 #codec_id 0: rawvideo
 #dimensions 0: 320x180
 #sar 0: 1/1
-0,          0,          0,        1,   230400, 0x7b259d08
-0,          1,          1,        1,   230400, 0xf04095e0
-0,          2,          2,        1,   230400, 0x84d49cd5
-0,          3,          3,        1,   230400, 0xd7a29aaf
-0,          4,          4,        1,   230400, 0x9047947c
-0,          5,          5,        1,   230400, 0xfeb990e7
-0,          6,          6,        1,   230400, 0x51ee9295
-0,          7,          7,        1,   230400, 0x66fd4833
-0,          8,          8,        1,   230400, 0x4c0948f0
-0,          9,          9,        1,   230400, 0x632b4776
-0,         10,         10,        1,   230400, 0x7a3c87e2
-0,         11,         11,        1,   230400, 0x4a9286ba
-0,         12,         12,        1,   230400, 0x54dc8649
-0,         13,         13,        1,   230400, 0x92628944
-0,         14,         14,        1,   230400, 0x80f9899f
-0,         15,         15,        1,   230400, 0x5cd78bd8
-0,         16,         16,        1,   230400, 0x4b4ca390
-0,         17,         17,        1,   230400, 0x82cca153
-0,         18,         18,        1,   230400, 0x65f1a2d0
-0,         19,         19,        1,   230400, 0x7df6ae4c
-0,         20,         20,        1,   230400, 0x909baccc
-0,         21,         21,        1,   230400, 0x1892ac65
-0,         22,         22,        1,   230400, 0x3247bb32
-0,         23,         23,        1,   230400, 0x592fbbe5
-0,         24,         24,        1,   230400, 0x189db9d5
-0,         25,         25,        1,   230400, 0x1a38b8da
-0,         26,         26,        1,   230400, 0xccd6bd07
-0,         27,         27,        1,   230400, 0xd4a2bc53
-0,         28,         28,        1,   230400, 0x9ce3bb4e
-0,         29,         29,        1,   230400, 0x5ffdc4db
-0,         30,         30,        1,   230400, 0xc885c7c9
-0,         31,         31,        1,   230400, 0xe27b9d33
-0,         32,         32,        1,   230400, 0xac03a256
-0,         33,         33,        1,   230400, 0xa2c73929
-0,         34,         34,        1,   230400, 0x33793b73
-0,         35,         35,        1,   230400, 0x1e400add
-0,         36,         36,        1,   230400, 0x98e50c6e
-0,         37,         37,        1,   230400, 0x68ed226d
-0,         38,         38,        1,   230400, 0x569e23cb
-0,         39,         39,        1,   230400, 0x82bf3fc0
-0,         40,         40,        1,   230400, 0x2b202e86
-0,         41,         41,        1,   230400, 0x7acd2dee
-0,         42,         42,        1,   230400, 0xfe872e42
-0,         43,         43,        1,   230400, 0x026c12e5
-0,         44,         44,        1,   230400, 0x81561399
-0,         45,         45,        1,   230400, 0xa08c13b6
-0,         46,         46,        1,   230400, 0x89e712f5
-0,         47,         47,        1,   230400, 0x569011ac
-0,         48,         48,        1,   230400, 0xd4691112
-0,         49,         49,        1,   230400, 0x2e50165a
-0,         50,         50,        1,   230400, 0x0a1215b6
-0,         51,         51,        1,   230400, 0x3c5316e3
-0,         52,         52,        1,   230400, 0x079c1393
-0,         53,         53,        1,   230400, 0x39ca1c48
-0,         54,         54,        1,   230400, 0xe27f199c
-0,         55,         55,        1,   230400, 0x10ab1bab
-0,         56,         56,        1,   230400, 0xeab017c3
-0,         57,         57,        1,   230400, 0x5f701f77
-0,         58,         58,        1,   230400, 0x01371d7d
-0,         59,         59,        1,   230400, 0x22751e99
-0,         60,         60,        1,   230400, 0xaee91a97
-0,         61,         61,        1,   230400, 0x27b41f32
-0,         62,         62,        1,   230400, 0x4ff32bb1
-0,         63,         63,        1,   230400, 0x86e02864
-0,         64,         64,        1,   230400, 0x5eb52b3e
-0,         65,         65,        1,   230400, 0xd9252ba8
-0,         66,         66,        1,   230400, 0x72232d9b
-0,         67,         67,        1,   230400, 0x599a206f
-0,         68,         68,        1,   230400, 0x4d2c1ca5
-0,         69,         69,        1,   230400, 0x9166293b
-0,         70,         70,        1,   230400, 0x00992453
+0,          0,          0,        1,   230400, 0x10a99774
+0,          1,          1,        1,   230400, 0xa18b90f8
+0,          2,          2,        1,   230400, 0x837a95f9
+0,          3,          3,        1,   230400, 0xc50d948b
+0,          4,          4,        1,   230400, 0xdefc8eca
+0,          5,          5,        1,   230400, 0x00498bdb
+0,          6,          6,        1,   230400, 0x22458cdc
+0,          7,          7,        1,   230400, 0xfad1418c
+0,          8,          8,        1,   230400, 0xf09341dd
+0,          9,          9,        1,   230400, 0x5ef141ac
+0,         10,         10,        1,   230400, 0x6f2d815f
+0,         11,         11,        1,   230400, 0x960880c2
+0,         12,         12,        1,   230400, 0x4ba37f8f
+0,         13,         13,        1,   230400, 0x3e678082
+0,         14,         14,        1,   230400, 0x4f1c80da
+0,         15,         15,        1,   230400, 0x69be82fd
+0,         16,         16,        1,   230400, 0x81d29b80
+0,         17,         17,        1,   230400, 0x5fdc9af7
+0,         18,         18,        1,   230400, 0xb8969c2b
+0,         19,         19,        1,   230400, 0xdb37a691
+0,         20,         20,        1,   230400, 0xdeb6a645
+0,         21,         21,        1,   230400, 0xf5c6a606
+0,         22,         22,        1,   230400, 0x110ab482
+0,         23,         23,        1,   230400, 0x5bddb45b
+0,         24,         24,        1,   230400, 0xc18ab32a
+0,         25,         25,        1,   230400, 0x22c1b2be
+0,         26,         26,        1,   230400, 0xaa7cb5c3
+0,         27,         27,        1,   230400, 0x5e8fb50f
+0,         28,         28,        1,   230400, 0x20e1b42a
+0,         29,         29,        1,   230400, 0x0c94c158
+0,         30,         30,        1,   230400, 0x41adc2a3
+0,         31,         31,        1,   230400, 0xbc359983
+0,         32,         32,        1,   230400, 0x19bb9eea
+0,         33,         33,        1,   230400, 0xfecd2f06
+0,         34,         34,        1,   230400, 0x26ba3110
+0,         35,         35,        1,   230400, 0xfdbcff0f
+0,         36,         36,        1,   230400, 0x1f030028
+0,         37,         37,        1,   230400, 0xccca1b0b
+0,         38,         38,        1,   230400, 0x66f91b1f
+0,         39,         39,        1,   230400, 0x0ef4366b
+0,         40,         40,        1,   230400, 0x2fac271c
+0,         41,         41,        1,   230400, 0xbef026a9
+0,         42,         42,        1,   230400, 0x775726f5
+0,         43,         43,        1,   230400, 0x35210966
+0,         44,         44,        1,   230400, 0x0c36099a
+0,         45,         45,        1,   230400, 0xc4f00a24
+0,         46,         46,        1,   230400, 0xa7c409b9
+0,         47,         47,        1,   230400, 0xa92d082b
+0,         48,         48,        1,   230400, 0xfc49442e
+0,         49,         49,        1,   230400, 0xb7de4997
+0,         50,         50,        1,   230400, 0x16d24877
+0,         51,         51,        1,   230400, 0xb0954a17
+0,         52,         52,        1,   230400, 0x709f4766
+0,         53,         53,        1,   230400, 0xe0dc4e4f
+0,         54,         54,        1,   230400, 0xfa844b09
+0,         55,         55,        1,   230400, 0xa62a4cf2
+0,         56,         56,        1,   230400, 0x078d4a76
+0,         57,         57,        1,   230400, 0x64c4505c
+0,         58,         58,        1,   230400, 0xe8604f13
+0,         59,         59,        1,   230400, 0x39a3503c
+0,         60,         60,        1,   230400, 0x915a4cf1
+0,         61,         61,        1,   230400, 0x495a5176
+0,         62,         62,        1,   230400, 0xc0a75b2b
+0,         63,         63,        1,   230400, 0x1a385761
+0,         64,         64,        1,   230400, 0x9a245984
+0,         65,         65,        1,   230400, 0xbe475ad9
+0,         66,         66,        1,   230400, 0x8e275c85
+0,         67,         67,        1,   230400, 0x5ba45436
+0,         68,         68,        1,   230400, 0x80285097
+0,         69,         69,        1,   230400, 0xbb1c5bfd
+0,         70,         70,        1,   230400, 0x273a5890
diff --git a/tests/ref/fate/filter-paletteuse-bayer0 b/tests/ref/fate/filter-paletteuse-bayer0
index 85b3832f19..44cd09a6a9 100644
--- a/tests/ref/fate/filter-paletteuse-bayer0
+++ b/tests/ref/fate/filter-paletteuse-bayer0
@@ -3,74 +3,74 @@
 #codec_id 0: rawvideo
 #dimensions 0: 320x180
 #sar 0: 1/1
-0,          0,          0,        1,   230400, 0xfb6042d2
-0,          1,          1,        1,   230400, 0x1c193c09
-0,          2,          2,        1,   230400, 0x183442f8
-0,          3,          3,        1,   230400, 0xa9634084
-0,          4,          4,        1,   230400, 0x90df3d2f
-0,          5,          5,        1,   230400, 0x59d7389f
-0,          6,          6,        1,   230400, 0xb9bd3a30
-0,          7,          7,        1,   230400, 0x9874ee38
-0,          8,          8,        1,   230400, 0xf661f01f
-0,          9,          9,        1,   230400, 0xacbcedbd
-0,         10,         10,        1,   230400, 0x05f02d59
-0,         11,         11,        1,   230400, 0xc54c2cc8
-0,         12,         12,        1,   230400, 0x19c92d61
-0,         13,         13,        1,   230400, 0x14902fb2
-0,         14,         14,        1,   230400, 0x99b62fb6
-0,         15,         15,        1,   230400, 0x3fc63293
-0,         16,         16,        1,   230400, 0x1eed4b38
-0,         17,         17,        1,   230400, 0xe9d747e0
-0,         18,         18,        1,   230400, 0x9825496f
-0,         19,         19,        1,   230400, 0x94625411
-0,         20,         20,        1,   230400, 0xed7052a3
-0,         21,         21,        1,   230400, 0x80d552dc
-0,         22,         22,        1,   230400, 0x89b360bb
-0,         23,         23,        1,   230400, 0xee9a616a
-0,         24,         24,        1,   230400, 0x30bb5f86
-0,         25,         25,        1,   230400, 0x5ec15eae
-0,         26,         26,        1,   230400, 0x0956633e
-0,         27,         27,        1,   230400, 0x72df62fa
-0,         28,         28,        1,   230400, 0xbafd61d0
-0,         29,         29,        1,   230400, 0x393f81f3
-0,         30,         30,        1,   230400, 0xba6a848c
-0,         31,         31,        1,   230400, 0x502ba0d9
-0,         32,         32,        1,   230400, 0xc81ba71d
-0,         33,         33,        1,   230400, 0x54cdf270
-0,         34,         34,        1,   230400, 0xe951f3e2
-0,         35,         35,        1,   230400, 0xbf15baa1
-0,         36,         36,        1,   230400, 0xbf96bb12
-0,         37,         37,        1,   230400, 0xcdd5cafe
-0,         38,         38,        1,   230400, 0x97b1cbb4
-0,         39,         39,        1,   230400, 0x955ae28f
-0,         40,         40,        1,   230400, 0x6a8dd28f
-0,         41,         41,        1,   230400, 0x8f02d268
-0,         42,         42,        1,   230400, 0x3075d269
-0,         43,         43,        1,   230400, 0x29e8b910
-0,         44,         44,        1,   230400, 0xb35ab888
-0,         45,         45,        1,   230400, 0xc3afb942
-0,         46,         46,        1,   230400, 0xeba8b860
-0,         47,         47,        1,   230400, 0x5de8b7ab
-0,         48,         48,        1,   230400, 0x90233679
-0,         49,         49,        1,   230400, 0x5fbc3abb
-0,         50,         50,        1,   230400, 0xeaa73b87
-0,         51,         51,        1,   230400, 0xbd0a3c4b
-0,         52,         52,        1,   230400, 0xeddb39ba
-0,         53,         53,        1,   230400, 0x269d4131
-0,         54,         54,        1,   230400, 0xae3e3e8c
-0,         55,         55,        1,   230400, 0x65f54056
-0,         56,         56,        1,   230400, 0xf2173c5b
-0,         57,         57,        1,   230400, 0xbd714477
-0,         58,         58,        1,   230400, 0xb60c42ed
-0,         59,         59,        1,   230400, 0x8def43a5
-0,         60,         60,        1,   230400, 0xe6a73f05
-0,         61,         61,        1,   230400, 0xedfe4430
-0,         62,         62,        1,   230400, 0x76c5505a
-0,         63,         63,        1,   230400, 0xf48d4d04
-0,         64,         64,        1,   230400, 0xa49950b5
-0,         65,         65,        1,   230400, 0xc64d51d8
-0,         66,         66,        1,   230400, 0xa08253ec
-0,         67,         67,        1,   230400, 0xd6ef4609
-0,         68,         68,        1,   230400, 0x27a241e7
-0,         69,         69,        1,   230400, 0xe5f74b4a
-0,         70,         70,        1,   230400, 0xb0194751
+0,          0,          0,        1,   230400, 0x9f192d87
+0,          1,          1,        1,   230400, 0x49db27f5
+0,          2,          2,        1,   230400, 0x8f8f2cb0
+0,          3,          3,        1,   230400, 0x33a82b14
+0,          4,          4,        1,   230400, 0x6f03275f
+0,          5,          5,        1,   230400, 0x1fce2453
+0,          6,          6,        1,   230400, 0x932925b3
+0,          7,          7,        1,   230400, 0x9987dba9
+0,          8,          8,        1,   230400, 0x9ba2dd04
+0,          9,          9,        1,   230400, 0x37eadc31
+0,         10,         10,        1,   230400, 0xda0518e2
+0,         11,         11,        1,   230400, 0xb96718b5
+0,         12,         12,        1,   230400, 0x0d63191e
+0,         13,         13,        1,   230400, 0xfc561af0
+0,         14,         14,        1,   230400, 0x22fd1b68
+0,         15,         15,        1,   230400, 0xef631dc5
+0,         16,         16,        1,   230400, 0xc0673745
+0,         17,         17,        1,   230400, 0x56c933f6
+0,         18,         18,        1,   230400, 0x3790359a
+0,         19,         19,        1,   230400, 0xd3293d02
+0,         20,         20,        1,   230400, 0xee513caa
+0,         21,         21,        1,   230400, 0x0fc33c17
+0,         22,         22,        1,   230400, 0x00c74991
+0,         23,         23,        1,   230400, 0xa7de49f5
+0,         24,         24,        1,   230400, 0xd99b485a
+0,         25,         25,        1,   230400, 0x6aab47d2
+0,         26,         26,        1,   230400, 0x2e434bf7
+0,         27,         27,        1,   230400, 0x46a04b1d
+0,         28,         28,        1,   230400, 0x135f49f8
+0,         29,         29,        1,   230400, 0x50566b86
+0,         30,         30,        1,   230400, 0xb0416d84
+0,         31,         31,        1,   230400, 0x8f20840c
+0,         32,         32,        1,   230400, 0xedbf8857
+0,         33,         33,        1,   230400, 0x30d6d698
+0,         34,         34,        1,   230400, 0xbc88d7a7
+0,         35,         35,        1,   230400, 0xce869fa3
+0,         36,         36,        1,   230400, 0xa973a0b1
+0,         37,         37,        1,   230400, 0x4c93b3a5
+0,         38,         38,        1,   230400, 0x3574b473
+0,         39,         39,        1,   230400, 0xa96bc936
+0,         40,         40,        1,   230400, 0x4a83b86d
+0,         41,         41,        1,   230400, 0x3b68b7cb
+0,         42,         42,        1,   230400, 0xc0feb869
+0,         43,         43,        1,   230400, 0x1a7d9ed8
+0,         44,         44,        1,   230400, 0xc32e9f12
+0,         45,         45,        1,   230400, 0x30f29fa4
+0,         46,         46,        1,   230400, 0x7b369f80
+0,         47,         47,        1,   230400, 0x28249e03
+0,         48,         48,        1,   230400, 0xf5c67eee
+0,         49,         49,        1,   230400, 0x40728404
+0,         50,         50,        1,   230400, 0xbf7383b0
+0,         51,         51,        1,   230400, 0x446d84c9
+0,         52,         52,        1,   230400, 0x5f678279
+0,         53,         53,        1,   230400, 0x4d1d891d
+0,         54,         54,        1,   230400, 0x173c866c
+0,         55,         55,        1,   230400, 0x045988a6
+0,         56,         56,        1,   230400, 0xf25f848f
+0,         57,         57,        1,   230400, 0xd61c8d71
+0,         58,         58,        1,   230400, 0x86428b1e
+0,         59,         59,        1,   230400, 0xc6268c08
+0,         60,         60,        1,   230400, 0xed9787e3
+0,         61,         61,        1,   230400, 0xe7ef8a27
+0,         62,         62,        1,   230400, 0x5dc09497
+0,         63,         63,        1,   230400, 0x8ec490b6
+0,         64,         64,        1,   230400, 0xc01d92e4
+0,         65,         65,        1,   230400, 0xbf6a941d
+0,         66,         66,        1,   230400, 0x53fd966a
+0,         67,         67,        1,   230400, 0xa2138be9
+0,         68,         68,        1,   230400, 0x2b868967
+0,         69,         69,        1,   230400, 0x4c889564
+0,         70,         70,        1,   230400, 0x6d8491ed
diff --git a/tests/ref/fate/filter-paletteuse-nodither b/tests/ref/fate/filter-paletteuse-nodither
index a2e61c3690..1535777547 100644
--- a/tests/ref/fate/filter-paletteuse-nodither
+++ b/tests/ref/fate/filter-paletteuse-nodither
@@ -3,74 +3,74 @@
 #codec_id 0: rawvideo
 #dimensions 0: 320x180
 #sar 0: 1/1
-0,          0,          0,        1,   230400, 0x690560cb
-0,          1,          1,        1,   230400, 0x197a5a54
-0,          2,          2,        1,   230400, 0x665961db
-0,          3,          3,        1,   230400, 0xce0b5fa8
-0,          4,          4,        1,   230400, 0xa40e5cb0
-0,          5,          5,        1,   230400, 0xa5aa58da
-0,          6,          6,        1,   230400, 0x8e0259bb
-0,          7,          7,        1,   230400, 0x476d0dba
-0,          8,          8,        1,   230400, 0xfb1b0e8c
-0,          9,          9,        1,   230400, 0x50f60d3b
-0,         10,         10,        1,   230400, 0x12cd4bab
-0,         11,         11,        1,   230400, 0x4c274b13
-0,         12,         12,        1,   230400, 0xea494b0a
-0,         13,         13,        1,   230400, 0x118c4cc1
-0,         14,         14,        1,   230400, 0xd4224db7
-0,         15,         15,        1,   230400, 0xc3014f88
-0,         16,         16,        1,   230400, 0xe07a6838
-0,         17,         17,        1,   230400, 0x1b97659a
-0,         18,         18,        1,   230400, 0xf104670c
-0,         19,         19,        1,   230400, 0x7b63733d
-0,         20,         20,        1,   230400, 0x2c237200
-0,         21,         21,        1,   230400, 0x775d7248
-0,         22,         22,        1,   230400, 0xcaee7f9e
-0,         23,         23,        1,   230400, 0x4e4680a1
-0,         24,         24,        1,   230400, 0x21fb7e53
-0,         25,         25,        1,   230400, 0xf0297db6
-0,         26,         26,        1,   230400, 0x79a9829d
-0,         27,         27,        1,   230400, 0x8ccb80f7
-0,         28,         28,        1,   230400, 0xf4dd807f
-0,         29,         29,        1,   230400, 0xb6cc8696
-0,         30,         30,        1,   230400, 0x6c8a8917
-0,         31,         31,        1,   230400, 0x9e08615a
-0,         32,         32,        1,   230400, 0xc098685b
-0,         33,         33,        1,   230400, 0x5c09e710
-0,         34,         34,        1,   230400, 0xe4c4e9be
-0,         35,         35,        1,   230400, 0xac59c150
-0,         36,         36,        1,   230400, 0x6045c272
-0,         37,         37,        1,   230400, 0xf71ee6dc
-0,         38,         38,        1,   230400, 0xc82ce6f6
-0,         39,         39,        1,   230400, 0xb7ed039a
-0,         40,         40,        1,   230400, 0xda93f241
-0,         41,         41,        1,   230400, 0x194bf23b
-0,         42,         42,        1,   230400, 0xe7e6f2e2
-0,         43,         43,        1,   230400, 0xe479d834
-0,         44,         44,        1,   230400, 0xefdfd87e
-0,         45,         45,        1,   230400, 0xec66d8c0
-0,         46,         46,        1,   230400, 0x3a6bd81b
-0,         47,         47,        1,   230400, 0xb5d1d700
-0,         48,         48,        1,   230400, 0x3bc69e8b
-0,         49,         49,        1,   230400, 0x723fa455
-0,         50,         50,        1,   230400, 0x7c49a392
-0,         51,         51,        1,   230400, 0x272ea4b7
-0,         52,         52,        1,   230400, 0xebdda081
-0,         53,         53,        1,   230400, 0xfd26ab99
-0,         54,         54,        1,   230400, 0xfa02a891
-0,         55,         55,        1,   230400, 0xda2caa7f
-0,         56,         56,        1,   230400, 0x2360a611
-0,         57,         57,        1,   230400, 0xaa3baefd
-0,         58,         58,        1,   230400, 0x0961ad5c
-0,         59,         59,        1,   230400, 0x48d2ae47
-0,         60,         60,        1,   230400, 0x20eda81b
-0,         61,         61,        1,   230400, 0x8821adbb
-0,         62,         62,        1,   230400, 0x1150b810
-0,         63,         63,        1,   230400, 0x08dab596
-0,         64,         64,        1,   230400, 0x4731b7a5
-0,         65,         65,        1,   230400, 0xf382b87e
-0,         66,         66,        1,   230400, 0xdba7bac2
-0,         67,         67,        1,   230400, 0xf569acf9
-0,         68,         68,        1,   230400, 0x22d8a95d
-0,         69,         69,        1,   230400, 0xed0bb4fb
-0,         70,         70,        1,   230400, 0x2dccb218
+0,          0,          0,        1,   230400, 0xf7976830
+0,          1,          1,        1,   230400, 0xfb756340
+0,          2,          2,        1,   230400, 0x2199687e
+0,          3,          3,        1,   230400, 0xd8186657
+0,          4,          4,        1,   230400, 0xd33a6319
+0,          5,          5,        1,   230400, 0x704c603b
+0,          6,          6,        1,   230400, 0x9e6c6146
+0,          7,          7,        1,   230400, 0x63ee15f1
+0,          8,          8,        1,   230400, 0x8b201716
+0,          9,          9,        1,   230400, 0xac8e1602
+0,         10,         10,        1,   230400, 0xd97e53b6
+0,         11,         11,        1,   230400, 0x8ecc5304
+0,         12,         12,        1,   230400, 0x0ea25368
+0,         13,         13,        1,   230400, 0x78c7555e
+0,         14,         14,        1,   230400, 0x96e3562d
+0,         15,         15,        1,   230400, 0xecc75867
+0,         16,         16,        1,   230400, 0x56e26feb
+0,         17,         17,        1,   230400, 0xf65d6fac
+0,         18,         18,        1,   230400, 0x5597709e
+0,         19,         19,        1,   230400, 0xeb077c34
+0,         20,         20,        1,   230400, 0xce997afa
+0,         21,         21,        1,   230400, 0xbec37abd
+0,         22,         22,        1,   230400, 0xb01688c4
+0,         23,         23,        1,   230400, 0x0c828927
+0,         24,         24,        1,   230400, 0xa6308757
+0,         25,         25,        1,   230400, 0x90e68727
+0,         26,         26,        1,   230400, 0xe3258ae5
+0,         27,         27,        1,   230400, 0x988e8993
+0,         28,         28,        1,   230400, 0xc13688b0
+0,         29,         29,        1,   230400, 0xcc528fa1
+0,         30,         30,        1,   230400, 0x28c691a9
+0,         31,         31,        1,   230400, 0x7de96ae9
+0,         32,         32,        1,   230400, 0x47946fa5
+0,         33,         33,        1,   230400, 0x1c3efa7c
+0,         34,         34,        1,   230400, 0x7fc6fc80
+0,         35,         35,        1,   230400, 0x0509c853
+0,         36,         36,        1,   230400, 0x691bca43
+0,         37,         37,        1,   230400, 0xadb5eafd
+0,         38,         38,        1,   230400, 0x559feafa
+0,         39,         39,        1,   230400, 0xa17906da
+0,         40,         40,        1,   230400, 0x6091f838
+0,         41,         41,        1,   230400, 0x9640f6fa
+0,         42,         42,        1,   230400, 0xa73af817
+0,         43,         43,        1,   230400, 0x255fde90
+0,         44,         44,        1,   230400, 0x7284deac
+0,         45,         45,        1,   230400, 0xf603df3f
+0,         46,         46,        1,   230400, 0x435cde3a
+0,         47,         47,        1,   230400, 0x825add61
+0,         48,         48,        1,   230400, 0x13b6bc0e
+0,         49,         49,        1,   230400, 0x72e7c13d
+0,         50,         50,        1,   230400, 0x2bcdc061
+0,         51,         51,        1,   230400, 0xb2e7c189
+0,         52,         52,        1,   230400, 0xb4eabe46
+0,         53,         53,        1,   230400, 0x0108c777
+0,         54,         54,        1,   230400, 0xae5cc3b3
+0,         55,         55,        1,   230400, 0xdd8ec4da
+0,         56,         56,        1,   230400, 0x0ec5c1d0
+0,         57,         57,        1,   230400, 0x3ad7cab8
+0,         58,         58,        1,   230400, 0xa9b0c95b
+0,         59,         59,        1,   230400, 0xe98ec9a0
+0,         60,         60,        1,   230400, 0x07d9c42e
+0,         61,         61,        1,   230400, 0x23b8c94e
+0,         62,         62,        1,   230400, 0xd3a9d25d
+0,         63,         63,        1,   230400, 0x3154cf78
+0,         64,         64,        1,   230400, 0x163ad234
+0,         65,         65,        1,   230400, 0x3ce2d276
+0,         66,         66,        1,   230400, 0x6f0bd556
+0,         67,         67,        1,   230400, 0xd982cb24
+0,         68,         68,        1,   230400, 0xd04ac7ab
+0,         69,         69,        1,   230400, 0x5302d29a
+0,         70,         70,        1,   230400, 0xd989d0dc
diff --git a/tests/ref/fate/filter-paletteuse-sierra2_4a b/tests/ref/fate/filter-paletteuse-sierra2_4a
index d257820a32..75115066e1 100644
--- a/tests/ref/fate/filter-paletteuse-sierra2_4a
+++ b/tests/ref/fate/filter-paletteuse-sierra2_4a
@@ -3,74 +3,74 @@
 #codec_id 0: rawvideo
 #dimensions 0: 320x180
 #sar 0: 1/1
-0,          0,          0,        1,   230400, 0xa4f85758
-0,          1,          1,        1,   230400, 0xbe83505c
-0,          2,          2,        1,   230400, 0x0a09584e
-0,          3,          3,        1,   230400, 0xd2065629
-0,          4,          4,        1,   230400, 0x11eb5319
-0,          5,          5,        1,   230400, 0x61024f4c
-0,          6,          6,        1,   230400, 0xd5384faa
-0,          7,          7,        1,   230400, 0xdeae0343
-0,          8,          8,        1,   230400, 0xcb640541
-0,          9,          9,        1,   230400, 0xea2602c3
-0,         10,         10,        1,   230400, 0xa7974293
-0,         11,         11,        1,   230400, 0x67cd4287
-0,         12,         12,        1,   230400, 0x83fa437a
-0,         13,         13,        1,   230400, 0x852b42bf
-0,         14,         14,        1,   230400, 0x6d2d434c
-0,         15,         15,        1,   230400, 0x20c44629
-0,         16,         16,        1,   230400, 0xf2a35f57
-0,         17,         17,        1,   230400, 0x232959ec
-0,         18,         18,        1,   230400, 0x1f8e5c48
-0,         19,         19,        1,   230400, 0x88dc69bd
-0,         20,         20,        1,   230400, 0x4b6866f3
-0,         21,         21,        1,   230400, 0xe8f966dc
-0,         22,         22,        1,   230400, 0xe0877466
-0,         23,         23,        1,   230400, 0x8799748c
-0,         24,         24,        1,   230400, 0xcab871bc
-0,         25,         25,        1,   230400, 0x2e0372b4
-0,         26,         26,        1,   230400, 0x15fb77d5
-0,         27,         27,        1,   230400, 0xbadf75fc
-0,         28,         28,        1,   230400, 0xa4977626
-0,         29,         29,        1,   230400, 0x5b987943
-0,         30,         30,        1,   230400, 0x9ed57c09
-0,         31,         31,        1,   230400, 0x565d5105
-0,         32,         32,        1,   230400, 0x901b5a07
-0,         33,         33,        1,   230400, 0x8dc4e9a8
-0,         34,         34,        1,   230400, 0x0b9cee1c
-0,         35,         35,        1,   230400, 0x2bcdbe37
-0,         36,         36,        1,   230400, 0xf3e2bf71
-0,         37,         37,        1,   230400, 0xb718da67
-0,         38,         38,        1,   230400, 0x8f59da64
-0,         39,         39,        1,   230400, 0x8812f9aa
-0,         40,         40,        1,   230400, 0xe0dae6a3
-0,         41,         41,        1,   230400, 0xd2c7e5b7
-0,         42,         42,        1,   230400, 0xea2ae5d2
-0,         43,         43,        1,   230400, 0x2d66ca25
-0,         44,         44,        1,   230400, 0xf0d3cac6
-0,         45,         45,        1,   230400, 0xb9acccac
-0,         46,         46,        1,   230400, 0x8523ca4a
-0,         47,         47,        1,   230400, 0x92b9c9ef
-0,         48,         48,        1,   230400, 0x0a88946e
-0,         49,         49,        1,   230400, 0xe33699b8
-0,         50,         50,        1,   230400, 0x5e7b9917
-0,         51,         51,        1,   230400, 0xdac99998
-0,         52,         52,        1,   230400, 0xb5c995fc
-0,         53,         53,        1,   230400, 0x908b9f50
-0,         54,         54,        1,   230400, 0x60d59ced
-0,         55,         55,        1,   230400, 0x212e9f55
-0,         56,         56,        1,   230400, 0x95e69b2a
-0,         57,         57,        1,   230400, 0x6c38a34a
-0,         58,         58,        1,   230400, 0xeb32a103
-0,         59,         59,        1,   230400, 0x0131a1b7
-0,         60,         60,        1,   230400, 0xd59b9c4e
-0,         61,         61,        1,   230400, 0x2fc0a13f
-0,         62,         62,        1,   230400, 0x7a40adf9
-0,         63,         63,        1,   230400, 0x5cdbab2f
-0,         64,         64,        1,   230400, 0xcdc0ada8
-0,         65,         65,        1,   230400, 0x2f5faf32
-0,         66,         66,        1,   230400, 0xd463b224
-0,         67,         67,        1,   230400, 0xe337a2d5
-0,         68,         68,        1,   230400, 0xe775a0c1
-0,         69,         69,        1,   230400, 0x726aab49
-0,         70,         70,        1,   230400, 0x74dda81e
+0,          0,          0,        1,   230400, 0xa40645e7
+0,          1,          1,        1,   230400, 0x72b63e5e
+0,          2,          2,        1,   230400, 0x030344b2
+0,          3,          3,        1,   230400, 0xab8c42b8
+0,          4,          4,        1,   230400, 0x1fcd3f00
+0,          5,          5,        1,   230400, 0x371f3c27
+0,          6,          6,        1,   230400, 0x0cfe3dff
+0,          7,          7,        1,   230400, 0x0c64f102
+0,          8,          8,        1,   230400, 0xbca2f2f7
+0,          9,          9,        1,   230400, 0x5198f134
+0,         10,         10,        1,   230400, 0xee02305e
+0,         11,         11,        1,   230400, 0x22592ff1
+0,         12,         12,        1,   230400, 0xa230311d
+0,         13,         13,        1,   230400, 0x66453278
+0,         14,         14,        1,   230400, 0x68c63165
+0,         15,         15,        1,   230400, 0xded434ae
+0,         16,         16,        1,   230400, 0xff1a4e51
+0,         17,         17,        1,   230400, 0x31064c7b
+0,         18,         18,        1,   230400, 0x3d374e74
+0,         19,         19,        1,   230400, 0x58ec59d5
+0,         20,         20,        1,   230400, 0x8c02570f
+0,         21,         21,        1,   230400, 0x5f6b56ac
+0,         22,         22,        1,   230400, 0x781f6408
+0,         23,         23,        1,   230400, 0x1c0165d2
+0,         24,         24,        1,   230400, 0xc6e66311
+0,         25,         25,        1,   230400, 0x0375635d
+0,         26,         26,        1,   230400, 0x00756822
+0,         27,         27,        1,   230400, 0xb4276753
+0,         28,         28,        1,   230400, 0x8b826638
+0,         29,         29,        1,   230400, 0x201066e2
+0,         30,         30,        1,   230400, 0x4acc6ab8
+0,         31,         31,        1,   230400, 0xa78741fe
+0,         32,         32,        1,   230400, 0xfe85481e
+0,         33,         33,        1,   230400, 0x7153dae0
+0,         34,         34,        1,   230400, 0x9b7ede62
+0,         35,         35,        1,   230400, 0x785cad21
+0,         36,         36,        1,   230400, 0x4c81ac20
+0,         37,         37,        1,   230400, 0x2e9cc57c
+0,         38,         38,        1,   230400, 0x0043c629
+0,         39,         39,        1,   230400, 0xccb1e72d
+0,         40,         40,        1,   230400, 0xf800d4d9
+0,         41,         41,        1,   230400, 0xb40ad374
+0,         42,         42,        1,   230400, 0xa94bd3eb
+0,         43,         43,        1,   230400, 0xefa8b85f
+0,         44,         44,        1,   230400, 0xa32ab85d
+0,         45,         45,        1,   230400, 0xbb89b941
+0,         46,         46,        1,   230400, 0x6556b8f0
+0,         47,         47,        1,   230400, 0x3d5ab7ab
+0,         48,         48,        1,   230400, 0x7b68afd9
+0,         49,         49,        1,   230400, 0x7518b560
+0,         50,         50,        1,   230400, 0x4d6bb43f
+0,         51,         51,        1,   230400, 0xafe7b5a0
+0,         52,         52,        1,   230400, 0x5211b1c0
+0,         53,         53,        1,   230400, 0x4ababa33
+0,         54,         54,        1,   230400, 0x90f7b7fc
+0,         55,         55,        1,   230400, 0x0b0dba13
+0,         56,         56,        1,   230400, 0xc9b6b5b4
+0,         57,         57,        1,   230400, 0xa1c5bfcd
+0,         58,         58,        1,   230400, 0xde30bdaf
+0,         59,         59,        1,   230400, 0x6ae5bc07
+0,         60,         60,        1,   230400, 0x9845b936
+0,         61,         61,        1,   230400, 0xcad4bf41
+0,         62,         62,        1,   230400, 0x90abca33
+0,         63,         63,        1,   230400, 0x2c12c614
+0,         64,         64,        1,   230400, 0x2d65c7ea
+0,         65,         65,        1,   230400, 0x1949c8f3
+0,         66,         66,        1,   230400, 0xe5adcb22
+0,         67,         67,        1,   230400, 0xa87bc06c
+0,         68,         68,        1,   230400, 0x4c43baeb
+0,         69,         69,        1,   230400, 0xbf66c7f9
+0,         70,         70,        1,   230400, 0x9883c62d
