static av_cold int vqa_decode_init(AVCodecContext *avctx)

{

    VqaContext *s = avctx->priv_data;

    unsigned char *vqa_header;

    int i, j, codebook_index;



    s->avctx = avctx;

    avctx->pix_fmt = PIX_FMT_PAL8;



    /* make sure the extradata made it */

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

        av_log(s->avctx, AV_LOG_ERROR, "  VQA video: expected extradata size of %d\n", VQA_HEADER_SIZE);

        return -1;

    }



    /* load up the VQA parameters from the header */

    vqa_header = (unsigned char *)s->avctx->extradata;

    s->vqa_version = vqa_header[0];

    s->width = AV_RL16(&vqa_header[6]);

    s->height = AV_RL16(&vqa_header[8]);

    if(av_image_check_size(s->width, s->height, 0, avctx)){

        s->width= s->height= 0;

        return -1;

    }

    s->vector_width = vqa_header[10];

    s->vector_height = vqa_header[11];

    s->partial_count = s->partial_countdown = vqa_header[13];



    /* the vector dimensions have to meet very stringent requirements */

    if ((s->vector_width != 4) ||

        ((s->vector_height != 2) && (s->vector_height != 4))) {

        /* return without further initialization */

        return -1;

    }



    /* allocate codebooks */

    s->codebook_size = MAX_CODEBOOK_SIZE;

    s->codebook = av_malloc(s->codebook_size);

    s->next_codebook_buffer = av_malloc(s->codebook_size);



    /* initialize the solid-color vectors */

    if (s->vector_height == 4) {

        codebook_index = 0xFF00 * 16;

        for (i = 0; i < 256; i++)

            for (j = 0; j < 16; j++)

                s->codebook[codebook_index++] = i;

    } else {

        codebook_index = 0xF00 * 8;

        for (i = 0; i < 256; i++)

            for (j = 0; j < 8; j++)

                s->codebook[codebook_index++] = i;

    }

    s->next_codebook_buffer_index = 0;



    /* allocate decode buffer */

    s->decode_buffer_size = (s->width / s->vector_width) *

        (s->height / s->vector_height) * 2;

    s->decode_buffer = av_malloc(s->decode_buffer_size);



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



    return 0;

}

static av_cold int vqa_decode_init(AVCodecContext *avctx)

{

    VqaContext *s = avctx->priv_data;

    unsigned char *vqa_header;

    int i, j, codebook_index;



    s->avctx = avctx;

    avctx->pix_fmt = PIX_FMT_PAL8;



    

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

        av_log(s->avctx, AV_LOG_ERROR, "  VQA video: expected extradata size of %d\n", VQA_HEADER_SIZE);

        return -1;

    }



    

    vqa_header = (unsigned char *)s->avctx->extradata;

    s->vqa_version = vqa_header[0];

    s->width = AV_RL16(&vqa_header[6]);

    s->height = AV_RL16(&vqa_header[8]);

    if(av_image_check_size(s->width, s->height, 0, avctx)){

        s->width= s->height= 0;

        return -1;

    }

    s->vector_width = vqa_header[10];

    s->vector_height = vqa_header[11];

    s->partial_count = s->partial_countdown = vqa_header[13];



    

    if ((s->vector_width != 4) ||

        ((s->vector_height != 2) && (s->vector_height != 4))) {

        

        return -1;

    }



    

    s->codebook_size = MAX_CODEBOOK_SIZE;

    s->codebook = av_malloc(s->codebook_size);

    s->next_codebook_buffer = av_malloc(s->codebook_size);



    

    if (s->vector_height == 4) {

        codebook_index = 0xFF00 * 16;

        for (i = 0; i < 256; i++)

            for (j = 0; j < 16; j++)

                s->codebook[codebook_index++] = i;

    } else {

        codebook_index = 0xF00 * 8;

        for (i = 0; i < 256; i++)

            for (j = 0; j < 8; j++)

                s->codebook[codebook_index++] = i;

    }

    s->next_codebook_buffer_index = 0;



    

    s->decode_buffer_size = (s->width / s->vector_width) *

        (s->height / s->vector_height) * 2;

    s->decode_buffer = av_malloc(s->decode_buffer_size);



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



    return 0;

}

static av_cold int FUNC_0(AVCodecContext *avctx)

{

    VqaContext *s = avctx->priv_data;

    unsigned char *VAR_0;

    int VAR_1, VAR_2, VAR_3;



    s->avctx = avctx;

    avctx->pix_fmt = PIX_FMT_PAL8;



    

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

        av_log(s->avctx, AV_LOG_ERROR, "  VQA video: expected extradata size of %d\n", VQA_HEADER_SIZE);

        return -1;

    }



    

    VAR_0 = (unsigned char *)s->avctx->extradata;

    s->vqa_version = VAR_0[0];

    s->width = AV_RL16(&VAR_0[6]);

    s->height = AV_RL16(&VAR_0[8]);

    if(av_image_check_size(s->width, s->height, 0, avctx)){

        s->width= s->height= 0;

        return -1;

    }

    s->vector_width = VAR_0[10];

    s->vector_height = VAR_0[11];

    s->partial_count = s->partial_countdown = VAR_0[13];



    

    if ((s->vector_width != 4) ||

        ((s->vector_height != 2) && (s->vector_height != 4))) {

        

        return -1;

    }



    

    s->codebook_size = MAX_CODEBOOK_SIZE;

    s->codebook = av_malloc(s->codebook_size);

    s->next_codebook_buffer = av_malloc(s->codebook_size);



    

    if (s->vector_height == 4) {

        VAR_3 = 0xFF00 * 16;

        for (VAR_1 = 0; VAR_1 < 256; VAR_1++)

            for (VAR_2 = 0; VAR_2 < 16; VAR_2++)

                s->codebook[VAR_3++] = VAR_1;

    } else {

        VAR_3 = 0xF00 * 8;

        for (VAR_1 = 0; VAR_1 < 256; VAR_1++)

            for (VAR_2 = 0; VAR_2 < 8; VAR_2++)

                s->codebook[VAR_3++] = VAR_1;

    }

    s->next_codebook_buffer_index = 0;



    

    s->decode_buffer_size = (s->width / s->vector_width) *

        (s->height / s->vector_height) * 2;

    s->decode_buffer = av_malloc(s->decode_buffer_size);



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



    return 0;

}

static av_cold int FUNC_0(AVCodecContext *avctx)
{ VqaContext *s = avctx->priv_data; unsigned char *VAR_0; int VAR_1, VAR_2, VAR_3; s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; if (s->avctx->extradata_size != VQA_HEADER_SIZE) { av_log(s->avctx, AV_LOG_ERROR, "  VQA video: expected extradata size of %d\n", VQA_HEADER_SIZE); return -1; } VAR_0 = (unsigned char *)s->avctx->extradata; s->vqa_version = VAR_0[0]; s->width = AV_RL16(&VAR_0[6]); s->height = AV_RL16(&VAR_0[8]); if(av_image_check_size(s->width, s->height, 0, avctx)){ s->width= s->height= 0; return -1; } s->vector_width = VAR_0[10]; s->vector_height = VAR_0[11]; s->partial_count = s->partial_countdown = VAR_0[13]; if ((s->vector_width != 4) ||
((s->vector_height != 2) && (s->vector_height != 4))) { return -1; } s->codebook_size = MAX_CODEBOOK_SIZE; s->codebook = av_malloc(s->codebook_size); s->next_codebook_buffer = av_malloc(s->codebook_size); if (s->vector_height == 4) { VAR_3 = 0xFF00 * 16; for (VAR_1 = 0; VAR_1 < 256; VAR_1++) for (VAR_2 = 0; VAR_2 < 16; VAR_2++) s->codebook[VAR_3++] = VAR_1; } else { VAR_3 = 0xF00 * 8; for (VAR_1 = 0; VAR_1 < 256; VAR_1++) for (VAR_2 = 0; VAR_2 < 8; VAR_2++) s->codebook[VAR_3++] = VAR_1; } s->next_codebook_buffer_index = 0; s->decode_buffer_size = (s->width / s->vector_width) *
(s->height / s->vector_height) * 2; s->decode_buffer = av_malloc(s->decode_buffer_size); s->frame.data[0] = NULL; return 0; }