static int read_rle_sgi(const SGIInfo *sgi_info, 

        AVPicture *pict, ByteIOContext *f)

{

    uint8_t *dest_row, *rle_data = NULL;

    unsigned long *start_table, *length_table;

    int y, z, xsize, ysize, zsize, tablen; 

    long start_offset, run_length;

    int ret = 0;



    xsize = sgi_info->xsize;

    ysize = sgi_info->ysize;

    zsize = sgi_info->zsize;



    rle_data = av_malloc(xsize);



    /* skip header */ 

    url_fseek(f, SGI_HEADER_SIZE, SEEK_SET);



    /* size of rle offset and length tables */

    tablen = ysize * zsize * sizeof(long);



    start_table = (unsigned long *)av_malloc(tablen);

    length_table = (unsigned long *)av_malloc(tablen);



    if (!get_buffer(f, (uint8_t *)start_table, tablen)) {

        ret = -1;

        goto fail;

    }



    if (!get_buffer(f, (uint8_t *)length_table, tablen)) {

        ret = -1;

        goto fail;

    }



    for (z = 0; z < zsize; z++) {

        for (y = 0; y < ysize; y++) {

            dest_row = pict->data[0] + (ysize - 1 - y) * (xsize * zsize);



            start_offset = BE_32(&start_table[y + z * ysize]);

            run_length = BE_32(&length_table[y + z * ysize]);



            /* don't seek if already in the correct spot */

            if (url_ftell(f) != start_offset) {

                url_fseek(f, start_offset, SEEK_SET);

            }



            get_buffer(f, rle_data, run_length);

            

            expand_rle_row(dest_row, rle_data, z, zsize);

        }

    }



fail:

    av_free(start_table);

    av_free(length_table);

    av_free(rle_data);



    return ret;

}

static int read_rle_sgi(const SGIInfo *sgi_info, 

        AVPicture *pict, ByteIOContext *f)

{

    uint8_t *dest_row, *rle_data = NULL;

    unsigned long *start_table, *length_table;

    int y, z, xsize, ysize, zsize, tablen; 

    long start_offset, run_length;

    int ret = 0;



    xsize = sgi_info->xsize;

    ysize = sgi_info->ysize;

    zsize = sgi_info->zsize;



    rle_data = av_malloc(xsize);



     

    url_fseek(f, SGI_HEADER_SIZE, SEEK_SET);



    

    tablen = ysize * zsize * sizeof(long);



    start_table = (unsigned long *)av_malloc(tablen);

    length_table = (unsigned long *)av_malloc(tablen);



    if (!get_buffer(f, (uint8_t *)start_table, tablen)) {

        ret = -1;

        goto fail;

    }



    if (!get_buffer(f, (uint8_t *)length_table, tablen)) {

        ret = -1;

        goto fail;

    }



    for (z = 0; z < zsize; z++) {

        for (y = 0; y < ysize; y++) {

            dest_row = pict->data[0] + (ysize - 1 - y) * (xsize * zsize);



            start_offset = BE_32(&start_table[y + z * ysize]);

            run_length = BE_32(&length_table[y + z * ysize]);



            

            if (url_ftell(f) != start_offset) {

                url_fseek(f, start_offset, SEEK_SET);

            }



            get_buffer(f, rle_data, run_length);

            

            expand_rle_row(dest_row, rle_data, z, zsize);

        }

    }



fail:

    av_free(start_table);

    av_free(length_table);

    av_free(rle_data);



    return ret;

}

    uint8_t *dest_row, *rle_data = NULL;     unsigned long *start_table, *length_table;     long start_offset, run_length;     rle_data = av_malloc(xsize);     length_table = (unsigned long *)av_malloc(tablen);         ret = -1;     if (!get_buffer(f, (uint8_t *)length_table, tablen)) {         ret = -1;         goto fail;             run_length = BE_32(&length_table[y + z * ysize]);             get_buffer(f, rle_data, run_length);             expand_rle_row(dest_row, rle_data, z, zsize);     av_free(length_table);     av_free(rle_data);
static int FUNC_0(const SGIInfo *VAR_0, 

        AVPicture *VAR_1, ByteIOContext *VAR_2)

{

    uint8_t *dest_row, *rle_data = NULL;

    unsigned long *VAR_3, *VAR_4;

    int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; 

    long VAR_11, VAR_12;

    int VAR_13 = 0;



    VAR_7 = VAR_0->VAR_7;

    VAR_8 = VAR_0->VAR_8;

    VAR_9 = VAR_0->VAR_9;



    rle_data = av_malloc(VAR_7);



     

    url_fseek(VAR_2, SGI_HEADER_SIZE, SEEK_SET);



    

    VAR_10 = VAR_8 * VAR_9 * sizeof(long);



    VAR_3 = (unsigned long *)av_malloc(VAR_10);

    VAR_4 = (unsigned long *)av_malloc(VAR_10);



    if (!get_buffer(VAR_2, (uint8_t *)VAR_3, VAR_10)) {

        VAR_13 = -1;

        goto fail;

    }



    if (!get_buffer(VAR_2, (uint8_t *)VAR_4, VAR_10)) {

        VAR_13 = -1;

        goto fail;

    }



    for (VAR_6 = 0; VAR_6 < VAR_9; VAR_6++) {

        for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5++) {

            dest_row = VAR_1->data[0] + (VAR_8 - 1 - VAR_5) * (VAR_7 * VAR_9);



            VAR_11 = BE_32(&VAR_3[VAR_5 + VAR_6 * VAR_8]);

            VAR_12 = BE_32(&VAR_4[VAR_5 + VAR_6 * VAR_8]);



            

            if (url_ftell(VAR_2) != VAR_11) {

                url_fseek(VAR_2, VAR_11, SEEK_SET);

            }



            get_buffer(VAR_2, rle_data, VAR_12);

            

            expand_rle_row(dest_row, rle_data, VAR_6, VAR_9);

        }

    }



fail:

    av_free(VAR_3);

    av_free(VAR_4);

    av_free(rle_data);



    return VAR_13;

}

static int FUNC_0(const SGIInfo *VAR_0,
AVPicture *VAR_1, ByteIOContext *VAR_2)
{ uint8_t *dest_row, *rle_data = NULL; unsigned long *VAR_3, *VAR_4; int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; long VAR_11, VAR_12; int VAR_13 = 0; VAR_7 = VAR_0->VAR_7; VAR_8 = VAR_0->VAR_8; VAR_9 = VAR_0->VAR_9; rle_data = av_malloc(VAR_7); url_fseek(VAR_2, SGI_HEADER_SIZE, SEEK_SET); VAR_10 = VAR_8 * VAR_9 * sizeof(long); VAR_3 = (unsigned long *)av_malloc(VAR_10); VAR_4 = (unsigned long *)av_malloc(VAR_10); if (!get_buffer(VAR_2, (uint8_t *)VAR_3, VAR_10)) { VAR_13 = -1; goto fail; } if (!get_buffer(VAR_2, (uint8_t *)VAR_4, VAR_10)) { VAR_13 = -1; goto fail; } for (VAR_6 = 0; VAR_6 < VAR_9; VAR_6++) { for (VAR_5 = 0; VAR_5 < VAR_8; VAR_5++) { dest_row = VAR_1->data[0] + (VAR_8 - 1 - VAR_5) * (VAR_7 * VAR_9); VAR_11 = BE_32(&VAR_3[VAR_5 + VAR_6 * VAR_8]); VAR_12 = BE_32(&VAR_4[VAR_5 + VAR_6 * VAR_8]); if (url_ftell(VAR_2) != VAR_11) { url_fseek(VAR_2, VAR_11, SEEK_SET); } get_buffer(VAR_2, rle_data, VAR_12); expand_rle_row(dest_row, rle_data, VAR_6, VAR_9); } } fail:
av_free(VAR_3); av_free(VAR_4); av_free(rle_data); return VAR_13; }