static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,

                               int h, const uint8_t *src, int size, int Uoff,

                               const int step)

{

    int i, j;

    GetBitContext gb;

    VLC vlc;

    Node nodes[512];



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

        nodes[i].count = bytestream_get_le32(&src);

    size -= 1024;

    if (ff_huff_build_tree(s->avctx, &vlc, 256, nodes, huff_cmp,

                           FF_HUFFMAN_FLAG_ZERO_COUNT) < 0)

        return -1;

    /* we have built Huffman table and are ready to decode plane */



    /* convert bits so they may be used by standard bitreader */

    s->dsp.bswap_buf((uint32_t *)s->tmpbuf, (const uint32_t *)src, size >> 2);



    init_get_bits(&gb, s->tmpbuf, size * 8);

    for(j = 0; j < h; j++){

        for(i = 0; i < w*step; i += step){

            dst[i] = get_vlc2(&gb, vlc.table, 9, 3);

            /* lines are stored as deltas between previous lines

             * and we need to add 0x80 to the first lines of chroma planes

             */

            if(j) dst[i] += dst[i - stride];

            else if(Uoff) dst[i] += 0x80;

        }

        dst += stride;

        if(get_bits_left(&gb) < 0){

            free_vlc(&vlc);

            return -1;

        }

    }

    free_vlc(&vlc);

    return 0;

}

static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,

                               int h, const uint8_t *src, int size, int Uoff,

                               const int step)

{

    int i, j;

    GetBitContext gb;

    VLC vlc;

    Node nodes[512];



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

        nodes[i].count = bytestream_get_le32(&src);

    size -= 1024;

    if (ff_huff_build_tree(s->avctx, &vlc, 256, nodes, huff_cmp,

                           FF_HUFFMAN_FLAG_ZERO_COUNT) < 0)

        return -1;

    



    

    s->dsp.bswap_buf((uint32_t *)s->tmpbuf, (const uint32_t *)src, size >> 2);



    init_get_bits(&gb, s->tmpbuf, size * 8);

    for(j = 0; j < h; j++){

        for(i = 0; i < w*step; i += step){

            dst[i] = get_vlc2(&gb, vlc.table, 9, 3);

            





            if(j) dst[i] += dst[i - stride];

            else if(Uoff) dst[i] += 0x80;

        }

        dst += stride;

        if(get_bits_left(&gb) < 0){

            free_vlc(&vlc);

            return -1;

        }

    }

    free_vlc(&vlc);

    return 0;

}

        if(get_bits_left(&gb) < 0){             free_vlc(&vlc);             return -1;
static int FUNC_0(FrapsContext *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3,

                               int VAR_4, const uint8_t *VAR_5, int VAR_6, int VAR_7,

                               const int VAR_8)

{

    int VAR_9, VAR_10;

    GetBitContext gb;

    VLC vlc;

    Node nodes[512];



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

        nodes[VAR_9].count = bytestream_get_le32(&VAR_5);

    VAR_6 -= 1024;

    if (ff_huff_build_tree(VAR_0->avctx, &vlc, 256, nodes, huff_cmp,

                           FF_HUFFMAN_FLAG_ZERO_COUNT) < 0)

        return -1;

    



    

    VAR_0->dsp.bswap_buf((uint32_t *)VAR_0->tmpbuf, (const uint32_t *)VAR_5, VAR_6 >> 2);



    init_get_bits(&gb, VAR_0->tmpbuf, VAR_6 * 8);

    for(VAR_10 = 0; VAR_10 < VAR_4; VAR_10++){

        for(VAR_9 = 0; VAR_9 < VAR_3*VAR_8; VAR_9 += VAR_8){

            VAR_1[VAR_9] = get_vlc2(&gb, vlc.table, 9, 3);

            





            if(VAR_10) VAR_1[VAR_9] += VAR_1[VAR_9 - VAR_2];

            else if(VAR_7) VAR_1[VAR_9] += 0x80;

        }

        VAR_1 += VAR_2;

        if(get_bits_left(&gb) < 0){

            free_vlc(&vlc);

            return -1;

        }

    }

    free_vlc(&vlc);

    return 0;

}

static int FUNC_0(FrapsContext *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3,
int VAR_4, const uint8_t *VAR_5, int VAR_6, int VAR_7,
const int VAR_8)
{ int VAR_9, VAR_10; GetBitContext gb; VLC vlc; Node nodes[512]; for(VAR_9 = 0; VAR_9 < 256; VAR_9++) nodes[VAR_9].count = bytestream_get_le32(&VAR_5); VAR_6 -= 1024; if (ff_huff_build_tree(VAR_0->avctx, &vlc, 256, nodes, huff_cmp,
FF_HUFFMAN_FLAG_ZERO_COUNT) < 0)
return -1; VAR_0->dsp.bswap_buf((uint32_t *)VAR_0->tmpbuf, (const uint32_t *)VAR_5, VAR_6 >> 2); init_get_bits(&gb, VAR_0->tmpbuf, VAR_6 * 8); for(VAR_10 = 0; VAR_10 < VAR_4; VAR_10++){ for(VAR_9 = 0; VAR_9 < VAR_3*VAR_8; VAR_9 += VAR_8){ VAR_1[VAR_9] = get_vlc2(&gb, vlc.table, 9, 3); if(VAR_10) VAR_1[VAR_9] += VAR_1[VAR_9 - VAR_2]; else if(VAR_7) VAR_1[VAR_9] += 0x80; } VAR_1 += VAR_2; if(get_bits_left(&gb) < 0){ free_vlc(&vlc); return -1; } } free_vlc(&vlc); return 0; }