static void rgb24_to_pal8(AVPicture *dst, AVPicture *src,

                          int width, int height)

{

    const unsigned char *p;

    unsigned char *q;

    int r, g, b, dst_wrap, src_wrap;

    int x, y, i;

    static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };

    uint32_t *pal;



    p = src->data[0];

    src_wrap = src->linesize[0] - 3 * width;



    q = dst->data[0];

    dst_wrap = dst->linesize[0] - width;



    for(y=0;y<height;y++) {

        for(x=0;x<width;x++) {

            r = p[0];

            g = p[1];

            b = p[2];



            q[0] = gif_clut_index(r, g, b);

            q++;

            p += 3;

        }

        p += src_wrap;

        q += dst_wrap;

    }



    /* build palette */

    pal = (uint32_t *)dst->data[1];

    i = 0;

    for(r = 0; r < 6; r++) {

        for(g = 0; g < 6; g++) {

            for(b = 0; b < 6; b++) {

                pal[i++] = (0xff << 24) | (pal_value[r] << 16) | 

                    (pal_value[g] << 8) | pal_value[b];

            }

        }

    }

    while (i < 256)

        pal[i++] = 0;

}

static void rgb24_to_pal8(AVPicture *dst, AVPicture *src,

                          int width, int height)

{

    const unsigned char *p;

    unsigned char *q;

    int r, g, b, dst_wrap, src_wrap;

    int x, y, i;

    static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };

    uint32_t *pal;



    p = src->data[0];

    src_wrap = src->linesize[0] - 3 * width;



    q = dst->data[0];

    dst_wrap = dst->linesize[0] - width;



    for(y=0;y<height;y++) {

        for(x=0;x<width;x++) {

            r = p[0];

            g = p[1];

            b = p[2];



            q[0] = gif_clut_index(r, g, b);

            q++;

            p += 3;

        }

        p += src_wrap;

        q += dst_wrap;

    }



    

    pal = (uint32_t *)dst->data[1];

    i = 0;

    for(r = 0; r < 6; r++) {

        for(g = 0; g < 6; g++) {

            for(b = 0; b < 6; b++) {

                pal[i++] = (0xff << 24) | (pal_value[r] << 16) | 

                    (pal_value[g] << 8) | pal_value[b];

            }

        }

    }

    while (i < 256)

        pal[i++] = 0;

}

static void FUNC_0(AVPicture *VAR_0, AVPicture *VAR_1,

                          int VAR_2, int VAR_3)

{

    const unsigned char *VAR_4;

    unsigned char *VAR_5;

    int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;

    int VAR_11, VAR_12, VAR_13;

    static const uint8_t VAR_14[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };

    uint32_t *pal;



    VAR_4 = VAR_1->data[0];

    VAR_10 = VAR_1->linesize[0] - 3 * VAR_2;



    VAR_5 = VAR_0->data[0];

    VAR_9 = VAR_0->linesize[0] - VAR_2;



    for(VAR_12=0;VAR_12<VAR_3;VAR_12++) {

        for(VAR_11=0;VAR_11<VAR_2;VAR_11++) {

            VAR_6 = VAR_4[0];

            VAR_7 = VAR_4[1];

            VAR_8 = VAR_4[2];



            VAR_5[0] = gif_clut_index(VAR_6, VAR_7, VAR_8);

            VAR_5++;

            VAR_4 += 3;

        }

        VAR_4 += VAR_10;

        VAR_5 += VAR_9;

    }



    

    pal = (uint32_t *)VAR_0->data[1];

    VAR_13 = 0;

    for(VAR_6 = 0; VAR_6 < 6; VAR_6++) {

        for(VAR_7 = 0; VAR_7 < 6; VAR_7++) {

            for(VAR_8 = 0; VAR_8 < 6; VAR_8++) {

                pal[VAR_13++] = (0xff << 24) | (VAR_14[VAR_6] << 16) | 

                    (VAR_14[VAR_7] << 8) | VAR_14[VAR_8];

            }

        }

    }

    while (VAR_13 < 256)

        pal[VAR_13++] = 0;

}

static void FUNC_0(AVPicture *VAR_0, AVPicture *VAR_1,
int VAR_2, int VAR_3)
{ const unsigned char *VAR_4; unsigned char *VAR_5; int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; int VAR_11, VAR_12, VAR_13; static const uint8_t VAR_14[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff }; uint32_t *pal; VAR_4 = VAR_1->data[0]; VAR_10 = VAR_1->linesize[0] - 3 * VAR_2; VAR_5 = VAR_0->data[0]; VAR_9 = VAR_0->linesize[0] - VAR_2; for(VAR_12=0;VAR_12<VAR_3;VAR_12++) { for(VAR_11=0;VAR_11<VAR_2;VAR_11++) { VAR_6 = VAR_4[0]; VAR_7 = VAR_4[1]; VAR_8 = VAR_4[2]; VAR_5[0] = gif_clut_index(VAR_6, VAR_7, VAR_8); VAR_5++; VAR_4 += 3; } VAR_4 += VAR_10; VAR_5 += VAR_9; } pal = (uint32_t *)VAR_0->data[1]; VAR_13 = 0; for(VAR_6 = 0; VAR_6 < 6; VAR_6++) { for(VAR_7 = 0; VAR_7 < 6; VAR_7++) { for(VAR_8 = 0; VAR_8 < 6; VAR_8++) { pal[VAR_13++] = (0xff << 24) | (VAR_14[VAR_6] << 16) |
(VAR_14[VAR_7] << 8) | VAR_14[VAR_8]; } } } while (VAR_13 < 256)
pal[VAR_13++] = 0; }