static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){

    int x, y;

    const int width= f->avctx->width;

    const int height= f->avctx->height;

    uint16_t *dst= (uint16_t*)f->current_picture.data[0];

    const int stride= f->current_picture.linesize[0]>>1;

    const unsigned int bitstream_size= AV_RL32(buf);

    const int token_count av_unused = AV_RL32(buf + bitstream_size + 8);

    unsigned int prestream_size= 4*AV_RL32(buf + bitstream_size + 4);

    const uint8_t *prestream= buf + bitstream_size + 12;



    if(prestream_size + bitstream_size + 12 != length

       || bitstream_size > (1<<26)

       || prestream_size > (1<<26)){

        av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n", prestream_size, bitstream_size, length);

        return -1;

    }



    prestream= read_huffman_tables(f, prestream);



    init_get_bits(&f->gb, buf + 4, 8*bitstream_size);



    prestream_size= length + buf - prestream;



    av_fast_malloc(&f->bitstream_buffer, &f->bitstream_buffer_size, prestream_size + FF_INPUT_BUFFER_PADDING_SIZE);

    if (!f->bitstream_buffer)

        return AVERROR(ENOMEM);

    f->dsp.bswap_buf(f->bitstream_buffer, (const uint32_t*)prestream, prestream_size/4);

    memset((uint8_t*)f->bitstream_buffer + prestream_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);

    init_get_bits(&f->pre_gb, f->bitstream_buffer, 8*prestream_size);



    f->last_dc= 0*128*8*8;



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

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

            if(decode_i_mb(f) < 0)

                return -1;



            idct_put(f, x, y);

        }

        dst += 16*stride;

    }



    if(get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3) != 256)

        av_log(f->avctx, AV_LOG_ERROR, "end mismatch\n");



    return 0;

}

static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){

    int x, y;

    const int width= f->avctx->width;

    const int height= f->avctx->height;

    uint16_t *dst= (uint16_t*)f->current_picture.data[0];

    const int stride= f->current_picture.linesize[0]>>1;

    const unsigned int bitstream_size= AV_RL32(buf);

    const int token_count av_unused = AV_RL32(buf + bitstream_size + 8);

    unsigned int prestream_size= 4*AV_RL32(buf + bitstream_size + 4);

    const uint8_t *prestream= buf + bitstream_size + 12;



    if(prestream_size + bitstream_size + 12 != length

       || bitstream_size > (1<<26)

       || prestream_size > (1<<26)){

        av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n", prestream_size, bitstream_size, length);

        return -1;

    }



    prestream= read_huffman_tables(f, prestream);



    init_get_bits(&f->gb, buf + 4, 8*bitstream_size);



    prestream_size= length + buf - prestream;



    av_fast_malloc(&f->bitstream_buffer, &f->bitstream_buffer_size, prestream_size + FF_INPUT_BUFFER_PADDING_SIZE);

    if (!f->bitstream_buffer)

        return AVERROR(ENOMEM);

    f->dsp.bswap_buf(f->bitstream_buffer, (const uint32_t*)prestream, prestream_size/4);

    memset((uint8_t*)f->bitstream_buffer + prestream_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);

    init_get_bits(&f->pre_gb, f->bitstream_buffer, 8*prestream_size);



    f->last_dc= 0*128*8*8;



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

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

            if(decode_i_mb(f) < 0)

                return -1;



            idct_put(f, x, y);

        }

        dst += 16*stride;

    }



    if(get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3) != 256)

        av_log(f->avctx, AV_LOG_ERROR, "end mismatch\n");



    return 0;

}

    const int token_count av_unused = AV_RL32(buf + bitstream_size + 8);     unsigned int prestream_size= 4*AV_RL32(buf + bitstream_size + 4);     const uint8_t *prestream= buf + bitstream_size + 12;     if(prestream_size + bitstream_size + 12 != length        || bitstream_size > (1<<26)        || prestream_size > (1<<26)){     prestream= read_huffman_tables(f, prestream);
static int FUNC_0(FourXContext *VAR_0, const uint8_t *VAR_1, int VAR_2){

    int VAR_3, VAR_4;

    const int VAR_5= VAR_0->avctx->VAR_5;

    const int VAR_6= VAR_0->avctx->VAR_6;

    uint16_t *dst= (uint16_t*)VAR_0->current_picture.data[0];

    const int VAR_7= VAR_0->current_picture.linesize[0]>>1;

    const unsigned int VAR_8= AV_RL32(VAR_1);

    const int VAR_9 av_unused = AV_RL32(VAR_1 + VAR_8 + 8);

    unsigned int VAR_10= 4*AV_RL32(VAR_1 + VAR_8 + 4);

    const uint8_t *VAR_11= VAR_1 + VAR_8 + 12;



    if(VAR_10 + VAR_8 + 12 != VAR_2

       || VAR_8 > (1<<26)

       || VAR_10 > (1<<26)){

        av_log(VAR_0->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n", VAR_10, VAR_8, VAR_2);

        return -1;

    }



    VAR_11= read_huffman_tables(VAR_0, VAR_11);



    init_get_bits(&VAR_0->gb, VAR_1 + 4, 8*VAR_8);



    VAR_10= VAR_2 + VAR_1 - VAR_11;



    av_fast_malloc(&VAR_0->bitstream_buffer, &VAR_0->bitstream_buffer_size, VAR_10 + FF_INPUT_BUFFER_PADDING_SIZE);

    if (!VAR_0->bitstream_buffer)

        return AVERROR(ENOMEM);

    VAR_0->dsp.bswap_buf(VAR_0->bitstream_buffer, (const uint32_t*)VAR_11, VAR_10/4);

    memset((uint8_t*)VAR_0->bitstream_buffer + VAR_10, 0, FF_INPUT_BUFFER_PADDING_SIZE);

    init_get_bits(&VAR_0->pre_gb, VAR_0->bitstream_buffer, 8*VAR_10);



    VAR_0->last_dc= 0*128*8*8;



    for(VAR_4=0; VAR_4<VAR_6; VAR_4+=16){

        for(VAR_3=0; VAR_3<VAR_5; VAR_3+=16){

            if(decode_i_mb(VAR_0) < 0)

                return -1;



            idct_put(VAR_0, VAR_3, VAR_4);

        }

        dst += 16*VAR_7;

    }



    if(get_vlc2(&VAR_0->pre_gb, VAR_0->pre_vlc.table, ACDC_VLC_BITS, 3) != 256)

        av_log(VAR_0->avctx, AV_LOG_ERROR, "end mismatch\n");



    return 0;

}

static int FUNC_0(FourXContext *VAR_0, const uint8_t *VAR_1, int VAR_2){ int VAR_3, VAR_4; const int VAR_5= VAR_0->avctx->VAR_5; const int VAR_6= VAR_0->avctx->VAR_6; uint16_t *dst= (uint16_t*)VAR_0->current_picture.data[0]; const int VAR_7= VAR_0->current_picture.linesize[0]>>1; const unsigned int VAR_8= AV_RL32(VAR_1); const int VAR_9 av_unused = AV_RL32(VAR_1 + VAR_8 + 8); unsigned int VAR_10= 4*AV_RL32(VAR_1 + VAR_8 + 4); const uint8_t *VAR_11= VAR_1 + VAR_8 + 12; if(VAR_10 + VAR_8 + 12 != VAR_2
|| VAR_8 > (1<<26)
|| VAR_10 > (1<<26)){ av_log(VAR_0->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n", VAR_10, VAR_8, VAR_2); return -1; } VAR_11= read_huffman_tables(VAR_0, VAR_11); init_get_bits(&VAR_0->gb, VAR_1 + 4, 8*VAR_8); VAR_10= VAR_2 + VAR_1 - VAR_11; av_fast_malloc(&VAR_0->bitstream_buffer, &VAR_0->bitstream_buffer_size, VAR_10 + FF_INPUT_BUFFER_PADDING_SIZE); if (!VAR_0->bitstream_buffer)
return AVERROR(ENOMEM); VAR_0->dsp.bswap_buf(VAR_0->bitstream_buffer, (const uint32_t*)VAR_11, VAR_10/4); memset((uint8_t*)VAR_0->bitstream_buffer + VAR_10, 0, FF_INPUT_BUFFER_PADDING_SIZE); init_get_bits(&VAR_0->pre_gb, VAR_0->bitstream_buffer, 8*VAR_10); VAR_0->last_dc= 0*128*8*8; for(VAR_4=0; VAR_4<VAR_6; VAR_4+=16){ for(VAR_3=0; VAR_3<VAR_5; VAR_3+=16){ if(decode_i_mb(VAR_0) < 0)
return -1; idct_put(VAR_0, VAR_3, VAR_4); } dst += 16*VAR_7; } if(get_vlc2(&VAR_0->pre_gb, VAR_0->pre_vlc.table, ACDC_VLC_BITS, 3) != 256)
av_log(VAR_0->avctx, AV_LOG_ERROR, "end mismatch\n"); return 0; }