static int vmdvideo_decode_init(AVCodecContext *avctx)

{

    VmdVideoContext *s = avctx->priv_data;

    int i;

    unsigned int *palette32;

    int palette_index = 0;

    unsigned char r, g, b;

    unsigned char *vmd_header;

    unsigned char *raw_palette;



    s->avctx = avctx;

    avctx->pix_fmt = PIX_FMT_PAL8;

    dsputil_init(&s->dsp, avctx);



    /* make sure the VMD header made it */

    if (s->avctx->extradata_size != VMD_HEADER_SIZE) {

        av_log(s->avctx, AV_LOG_ERROR, "VMD video: expected extradata size of %d\n",

            VMD_HEADER_SIZE);

        return -1;

    }

    vmd_header = (unsigned char *)avctx->extradata;



    s->unpack_buffer_size = AV_RL32(&vmd_header[800]);

    s->unpack_buffer = av_malloc(s->unpack_buffer_size);

    if (!s->unpack_buffer)

        return -1;



    /* load up the initial palette */

    raw_palette = &vmd_header[28];

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

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

        r = raw_palette[palette_index++] * 4;

        g = raw_palette[palette_index++] * 4;

        b = raw_palette[palette_index++] * 4;

        palette32[i] = (r << 16) | (g << 8) | (b);

    }



    s->frame.data[0] = s->prev_frame.data[0] = NULL;



    return 0;

}

static int vmdvideo_decode_init(AVCodecContext *avctx)

{

    VmdVideoContext *s = avctx->priv_data;

    int i;

    unsigned int *palette32;

    int palette_index = 0;

    unsigned char r, g, b;

    unsigned char *vmd_header;

    unsigned char *raw_palette;



    s->avctx = avctx;

    avctx->pix_fmt = PIX_FMT_PAL8;

    dsputil_init(&s->dsp, avctx);



    

    if (s->avctx->extradata_size != VMD_HEADER_SIZE) {

        av_log(s->avctx, AV_LOG_ERROR, "VMD video: expected extradata size of %d\n",

            VMD_HEADER_SIZE);

        return -1;

    }

    vmd_header = (unsigned char *)avctx->extradata;



    s->unpack_buffer_size = AV_RL32(&vmd_header[800]);

    s->unpack_buffer = av_malloc(s->unpack_buffer_size);

    if (!s->unpack_buffer)

        return -1;



    

    raw_palette = &vmd_header[28];

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

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

        r = raw_palette[palette_index++] * 4;

        g = raw_palette[palette_index++] * 4;

        b = raw_palette[palette_index++] * 4;

        palette32[i] = (r << 16) | (g << 8) | (b);

    }



    s->frame.data[0] = s->prev_frame.data[0] = NULL;



    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0)

{

    VmdVideoContext *s = VAR_0->priv_data;

    int VAR_1;

    unsigned int *VAR_2;

    int VAR_3 = 0;

    unsigned char VAR_4, VAR_5, VAR_6;

    unsigned char *VAR_7;

    unsigned char *VAR_8;



    s->VAR_0 = VAR_0;

    VAR_0->pix_fmt = PIX_FMT_PAL8;

    dsputil_init(&s->dsp, VAR_0);



    

    if (s->VAR_0->extradata_size != VMD_HEADER_SIZE) {

        av_log(s->VAR_0, AV_LOG_ERROR, "VMD video: expected extradata size of %d\n",

            VMD_HEADER_SIZE);

        return -1;

    }

    VAR_7 = (unsigned char *)VAR_0->extradata;



    s->unpack_buffer_size = AV_RL32(&VAR_7[800]);

    s->unpack_buffer = av_malloc(s->unpack_buffer_size);

    if (!s->unpack_buffer)

        return -1;



    

    VAR_8 = &VAR_7[28];

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

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

        VAR_4 = VAR_8[VAR_3++] * 4;

        VAR_5 = VAR_8[VAR_3++] * 4;

        VAR_6 = VAR_8[VAR_3++] * 4;

        VAR_2[VAR_1] = (VAR_4 << 16) | (VAR_5 << 8) | (VAR_6);

    }



    s->frame.data[0] = s->prev_frame.data[0] = NULL;



    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0)
{ VmdVideoContext *s = VAR_0->priv_data; int VAR_1; unsigned int *VAR_2; int VAR_3 = 0; unsigned char VAR_4, VAR_5, VAR_6; unsigned char *VAR_7; unsigned char *VAR_8; s->VAR_0 = VAR_0; VAR_0->pix_fmt = PIX_FMT_PAL8; dsputil_init(&s->dsp, VAR_0); if (s->VAR_0->extradata_size != VMD_HEADER_SIZE) { av_log(s->VAR_0, AV_LOG_ERROR, "VMD video: expected extradata size of %d\n",
VMD_HEADER_SIZE); return -1; } VAR_7 = (unsigned char *)VAR_0->extradata; s->unpack_buffer_size = AV_RL32(&VAR_7[800]); s->unpack_buffer = av_malloc(s->unpack_buffer_size); if (!s->unpack_buffer)
return -1; VAR_8 = &VAR_7[28]; VAR_2 = (unsigned int *)s->palette; for (VAR_1 = 0; VAR_1 < PALETTE_COUNT; VAR_1++) { VAR_4 = VAR_8[VAR_3++] * 4; VAR_5 = VAR_8[VAR_3++] * 4; VAR_6 = VAR_8[VAR_3++] * 4; VAR_2[VAR_1] = (VAR_4 << 16) | (VAR_5 << 8) | (VAR_6); } s->frame.data[0] = s->prev_frame.data[0] = NULL; return 0; }