static void inline xan_wc3_build_palette(XanContext *s, 

    unsigned int *palette_data)

{

    int i;

    unsigned char r, g, b;

    unsigned short *palette16;

    unsigned int *palette32;

    unsigned int pal_elem;



    /* transform the palette passed through the palette control structure

     * into the necessary internal format depending on colorspace */



    switch (s->avctx->pix_fmt) {



    case PIX_FMT_RGB555:

        palette16 = (unsigned short *)s->palette;

        for (i = 0; i < PALETTE_COUNT; i++) {

            pal_elem = palette_data[i];

            r = (pal_elem >> 16) & 0xff;

            g = (pal_elem >> 8) & 0xff;

            b = pal_elem & 0xff;

            palette16[i] = 

                ((r >> 3) << 10) |

                ((g >> 3) <<  5) |

                ((b >> 3) <<  0);

        }

        break;



    case PIX_FMT_RGB565:

        palette16 = (unsigned short *)s->palette;

        for (i = 0; i < PALETTE_COUNT; i++) {

            pal_elem = palette_data[i];

            r = (pal_elem >> 16) & 0xff;

            g = (pal_elem >> 8) & 0xff;

            b = pal_elem & 0xff;

            palette16[i] = 

                ((r >> 3) << 11) |

                ((g >> 2) <<  5) |

                ((b >> 3) <<  0);

        }

        break;



    case PIX_FMT_RGB24:

        for (i = 0; i < PALETTE_COUNT; i++) {

            pal_elem = palette_data[i];

            r = (pal_elem >> 16) & 0xff;

            g = (pal_elem >> 8) & 0xff;

            b = pal_elem & 0xff;

            s->palette[i * 4 + 0] = r;

            s->palette[i * 4 + 1] = g;

            s->palette[i * 4 + 2] = b;

        }

        break;



    case PIX_FMT_BGR24:

        for (i = 0; i < PALETTE_COUNT; i++) {

            pal_elem = palette_data[i];

            r = (pal_elem >> 16) & 0xff;

            g = (pal_elem >> 8) & 0xff;

            b = pal_elem & 0xff;

            s->palette[i * 4 + 0] = b;

            s->palette[i * 4 + 1] = g;

            s->palette[i * 4 + 2] = r;

        }

        break;



    case PIX_FMT_PAL8:

    case PIX_FMT_RGBA32:

        palette32 = (unsigned int *)s->palette;

        memcpy (palette32, palette_data, PALETTE_COUNT * sizeof(unsigned int));

        break;



    case PIX_FMT_YUV444P:

        for (i = 0; i < PALETTE_COUNT; i++) {

            pal_elem = palette_data[i];

            r = (pal_elem >> 16) & 0xff;

            g = (pal_elem >> 8) & 0xff;

            b = pal_elem & 0xff;

            s->palette[i * 4 + 0] = COMPUTE_Y(r, g, b);

            s->palette[i * 4 + 1] = COMPUTE_U(r, g, b);

            s->palette[i * 4 + 2] = COMPUTE_V(r, g, b);

        }

        break;



    default:

        av_log(s->avctx, AV_LOG_ERROR, " Xan WC3: Unhandled colorspace\n");

        break;

    }

}

static void inline xan_wc3_build_palette(XanContext *s, 

    unsigned int *palette_data)

{

    int i;

    unsigned char r, g, b;

    unsigned short *palette16;

    unsigned int *palette32;

    unsigned int pal_elem;



    





    switch (s->avctx->pix_fmt) {



    case PIX_FMT_RGB555:

        palette16 = (unsigned short *)s->palette;

        for (i = 0; i < PALETTE_COUNT; i++) {

            pal_elem = palette_data[i];

            r = (pal_elem >> 16) & 0xff;

            g = (pal_elem >> 8) & 0xff;

            b = pal_elem & 0xff;

            palette16[i] = 

                ((r >> 3) << 10) |

                ((g >> 3) <<  5) |

                ((b >> 3) <<  0);

        }

        break;



    case PIX_FMT_RGB565:

        palette16 = (unsigned short *)s->palette;

        for (i = 0; i < PALETTE_COUNT; i++) {

            pal_elem = palette_data[i];

            r = (pal_elem >> 16) & 0xff;

            g = (pal_elem >> 8) & 0xff;

            b = pal_elem & 0xff;

            palette16[i] = 

                ((r >> 3) << 11) |

                ((g >> 2) <<  5) |

                ((b >> 3) <<  0);

        }

        break;



    case PIX_FMT_RGB24:

        for (i = 0; i < PALETTE_COUNT; i++) {

            pal_elem = palette_data[i];

            r = (pal_elem >> 16) & 0xff;

            g = (pal_elem >> 8) & 0xff;

            b = pal_elem & 0xff;

            s->palette[i * 4 + 0] = r;

            s->palette[i * 4 + 1] = g;

            s->palette[i * 4 + 2] = b;

        }

        break;



    case PIX_FMT_BGR24:

        for (i = 0; i < PALETTE_COUNT; i++) {

            pal_elem = palette_data[i];

            r = (pal_elem >> 16) & 0xff;

            g = (pal_elem >> 8) & 0xff;

            b = pal_elem & 0xff;

            s->palette[i * 4 + 0] = b;

            s->palette[i * 4 + 1] = g;

            s->palette[i * 4 + 2] = r;

        }

        break;



    case PIX_FMT_PAL8:

    case PIX_FMT_RGBA32:

        palette32 = (unsigned int *)s->palette;

        memcpy (palette32, palette_data, PALETTE_COUNT * sizeof(unsigned int));

        break;



    case PIX_FMT_YUV444P:

        for (i = 0; i < PALETTE_COUNT; i++) {

            pal_elem = palette_data[i];

            r = (pal_elem >> 16) & 0xff;

            g = (pal_elem >> 8) & 0xff;

            b = pal_elem & 0xff;

            s->palette[i * 4 + 0] = COMPUTE_Y(r, g, b);

            s->palette[i * 4 + 1] = COMPUTE_U(r, g, b);

            s->palette[i * 4 + 2] = COMPUTE_V(r, g, b);

        }

        break;



    default:

        av_log(s->avctx, AV_LOG_ERROR, " Xan WC3: Unhandled colorspace\n");

        break;

    }

}

static void inline FUNC_0(XanContext *VAR_0, 

    unsigned int *VAR_1)

{

    int VAR_2;

    unsigned char VAR_3, VAR_4, VAR_5;

    unsigned short *VAR_6;

    unsigned int *VAR_7;

    unsigned int VAR_8;



    





    switch (VAR_0->avctx->pix_fmt) {



    case PIX_FMT_RGB555:

        VAR_6 = (unsigned short *)VAR_0->palette;

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

            VAR_8 = VAR_1[VAR_2];

            VAR_3 = (VAR_8 >> 16) & 0xff;

            VAR_4 = (VAR_8 >> 8) & 0xff;

            VAR_5 = VAR_8 & 0xff;

            VAR_6[VAR_2] = 

                ((VAR_3 >> 3) << 10) |

                ((VAR_4 >> 3) <<  5) |

                ((VAR_5 >> 3) <<  0);

        }

        break;



    case PIX_FMT_RGB565:

        VAR_6 = (unsigned short *)VAR_0->palette;

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

            VAR_8 = VAR_1[VAR_2];

            VAR_3 = (VAR_8 >> 16) & 0xff;

            VAR_4 = (VAR_8 >> 8) & 0xff;

            VAR_5 = VAR_8 & 0xff;

            VAR_6[VAR_2] = 

                ((VAR_3 >> 3) << 11) |

                ((VAR_4 >> 2) <<  5) |

                ((VAR_5 >> 3) <<  0);

        }

        break;



    case PIX_FMT_RGB24:

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

            VAR_8 = VAR_1[VAR_2];

            VAR_3 = (VAR_8 >> 16) & 0xff;

            VAR_4 = (VAR_8 >> 8) & 0xff;

            VAR_5 = VAR_8 & 0xff;

            VAR_0->palette[VAR_2 * 4 + 0] = VAR_3;

            VAR_0->palette[VAR_2 * 4 + 1] = VAR_4;

            VAR_0->palette[VAR_2 * 4 + 2] = VAR_5;

        }

        break;



    case PIX_FMT_BGR24:

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

            VAR_8 = VAR_1[VAR_2];

            VAR_3 = (VAR_8 >> 16) & 0xff;

            VAR_4 = (VAR_8 >> 8) & 0xff;

            VAR_5 = VAR_8 & 0xff;

            VAR_0->palette[VAR_2 * 4 + 0] = VAR_5;

            VAR_0->palette[VAR_2 * 4 + 1] = VAR_4;

            VAR_0->palette[VAR_2 * 4 + 2] = VAR_3;

        }

        break;



    case PIX_FMT_PAL8:

    case PIX_FMT_RGBA32:

        VAR_7 = (unsigned int *)VAR_0->palette;

        memcpy (VAR_7, VAR_1, PALETTE_COUNT * sizeof(unsigned int));

        break;



    case PIX_FMT_YUV444P:

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

            VAR_8 = VAR_1[VAR_2];

            VAR_3 = (VAR_8 >> 16) & 0xff;

            VAR_4 = (VAR_8 >> 8) & 0xff;

            VAR_5 = VAR_8 & 0xff;

            VAR_0->palette[VAR_2 * 4 + 0] = COMPUTE_Y(VAR_3, VAR_4, VAR_5);

            VAR_0->palette[VAR_2 * 4 + 1] = COMPUTE_U(VAR_3, VAR_4, VAR_5);

            VAR_0->palette[VAR_2 * 4 + 2] = COMPUTE_V(VAR_3, VAR_4, VAR_5);

        }

        break;



    default:

        av_log(VAR_0->avctx, AV_LOG_ERROR, " Xan WC3: Unhandled colorspace\n");

        break;

    }

}

static void inline FUNC_0(XanContext *VAR_0,
unsigned int *VAR_1)
{ int VAR_2; unsigned char VAR_3, VAR_4, VAR_5; unsigned short *VAR_6; unsigned int *VAR_7; unsigned int VAR_8; switch (VAR_0->avctx->pix_fmt) { case PIX_FMT_RGB555:
VAR_6 = (unsigned short *)VAR_0->palette; for (VAR_2 = 0; VAR_2 < PALETTE_COUNT; VAR_2++) { VAR_8 = VAR_1[VAR_2]; VAR_3 = (VAR_8 >> 16) & 0xff; VAR_4 = (VAR_8 >> 8) & 0xff; VAR_5 = VAR_8 & 0xff; VAR_6[VAR_2] =
((VAR_3 >> 3) << 10) |
((VAR_4 >> 3) <<  5) |
((VAR_5 >> 3) <<  0); } break; case PIX_FMT_RGB565:
VAR_6 = (unsigned short *)VAR_0->palette; for (VAR_2 = 0; VAR_2 < PALETTE_COUNT; VAR_2++) { VAR_8 = VAR_1[VAR_2]; VAR_3 = (VAR_8 >> 16) & 0xff; VAR_4 = (VAR_8 >> 8) & 0xff; VAR_5 = VAR_8 & 0xff; VAR_6[VAR_2] =
((VAR_3 >> 3) << 11) |
((VAR_4 >> 2) <<  5) |
((VAR_5 >> 3) <<  0); } break; case PIX_FMT_RGB24:
for (VAR_2 = 0; VAR_2 < PALETTE_COUNT; VAR_2++) { VAR_8 = VAR_1[VAR_2]; VAR_3 = (VAR_8 >> 16) & 0xff; VAR_4 = (VAR_8 >> 8) & 0xff; VAR_5 = VAR_8 & 0xff; VAR_0->palette[VAR_2 * 4 + 0] = VAR_3; VAR_0->palette[VAR_2 * 4 + 1] = VAR_4; VAR_0->palette[VAR_2 * 4 + 2] = VAR_5; } break; case PIX_FMT_BGR24:
for (VAR_2 = 0; VAR_2 < PALETTE_COUNT; VAR_2++) { VAR_8 = VAR_1[VAR_2]; VAR_3 = (VAR_8 >> 16) & 0xff; VAR_4 = (VAR_8 >> 8) & 0xff; VAR_5 = VAR_8 & 0xff; VAR_0->palette[VAR_2 * 4 + 0] = VAR_5; VAR_0->palette[VAR_2 * 4 + 1] = VAR_4; VAR_0->palette[VAR_2 * 4 + 2] = VAR_3; } break; case PIX_FMT_PAL8:
case PIX_FMT_RGBA32:
VAR_7 = (unsigned int *)VAR_0->palette; memcpy (VAR_7, VAR_1, PALETTE_COUNT * sizeof(unsigned int)); break; case PIX_FMT_YUV444P:
for (VAR_2 = 0; VAR_2 < PALETTE_COUNT; VAR_2++) { VAR_8 = VAR_1[VAR_2]; VAR_3 = (VAR_8 >> 16) & 0xff; VAR_4 = (VAR_8 >> 8) & 0xff; VAR_5 = VAR_8 & 0xff; VAR_0->palette[VAR_2 * 4 + 0] = COMPUTE_Y(VAR_3, VAR_4, VAR_5); VAR_0->palette[VAR_2 * 4 + 1] = COMPUTE_U(VAR_3, VAR_4, VAR_5); VAR_0->palette[VAR_2 * 4 + 2] = COMPUTE_V(VAR_3, VAR_4, VAR_5); } break; default:
av_log(VAR_0->avctx, AV_LOG_ERROR, " Xan WC3: Unhandled colorspace\n"); break; } }