static int read_uncompressed_sgi(const SGIInfo *si, 

        AVPicture *pict, ByteIOContext *f)

{

    int x, y, z, chan_offset, ret = 0;

    uint8_t *dest_row, *tmp_row = NULL;



    tmp_row = av_malloc(si->xsize);



    /* skip header */ 

    url_fseek(f, SGI_HEADER_SIZE, SEEK_SET);



    pict->linesize[0] = si->xsize;



    for (z = 0; z < si->zsize; z++) {



#ifndef WORDS_BIGENDIAN

        /* rgba -> bgra for rgba32 on little endian cpus */

        if (si->zsize == 4 && z != 3) 

            chan_offset = 2 - z;

        else

#endif

            chan_offset = z;

            

        for (y = si->ysize - 1; y >= 0; y--) {

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



            if (!get_buffer(f, tmp_row, si->xsize)) {

                ret = -1;

                goto cleanup;

            }

            for (x = 0; x < si->xsize; x++) {

                dest_row[chan_offset] = tmp_row[x]; 

                dest_row += si->zsize;

            }

        }

    }



cleanup:

    av_free(tmp_row);

    return ret;

}

static int read_uncompressed_sgi(const SGIInfo *si, 

        AVPicture *pict, ByteIOContext *f)

{

    int x, y, z, chan_offset, ret = 0;

    uint8_t *dest_row, *tmp_row = NULL;



    tmp_row = av_malloc(si->xsize);



     

    url_fseek(f, SGI_HEADER_SIZE, SEEK_SET);



    pict->linesize[0] = si->xsize;



    for (z = 0; z < si->zsize; z++) {



#ifndef WORDS_BIGENDIAN

        

        if (si->zsize == 4 && z != 3) 

            chan_offset = 2 - z;

        else

#endif

            chan_offset = z;

            

        for (y = si->ysize - 1; y >= 0; y--) {

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



            if (!get_buffer(f, tmp_row, si->xsize)) {

                ret = -1;

                goto cleanup;

            }

            for (x = 0; x < si->xsize; x++) {

                dest_row[chan_offset] = tmp_row[x]; 

                dest_row += si->zsize;

            }

        }

    }



cleanup:

    av_free(tmp_row);

    return ret;

}

    uint8_t *dest_row, *tmp_row = NULL;     tmp_row = av_malloc(si->xsize);             if (!get_buffer(f, tmp_row, si->xsize)) {                 ret = -1;                 goto cleanup;                 dest_row[chan_offset] = tmp_row[x];  cleanup:     av_free(tmp_row);
static int FUNC_0(const SGIInfo *VAR_0, 

        AVPicture *VAR_1, ByteIOContext *VAR_2)

{

    int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7 = 0;

    uint8_t *dest_row, *tmp_row = NULL;



    tmp_row = av_malloc(VAR_0->xsize);



     

    url_fseek(VAR_2, SGI_HEADER_SIZE, SEEK_SET);



    VAR_1->linesize[0] = VAR_0->xsize;



    for (VAR_5 = 0; VAR_5 < VAR_0->zsize; VAR_5++) {



#ifndef WORDS_BIGENDIAN

        

        if (VAR_0->zsize == 4 && VAR_5 != 3) 

            VAR_6 = 2 - VAR_5;

        else

#endif

            VAR_6 = VAR_5;

            

        for (VAR_4 = VAR_0->ysize - 1; VAR_4 >= 0; VAR_4--) {

            dest_row = VAR_1->data[0] + (VAR_4 * VAR_0->xsize * VAR_0->zsize);



            if (!get_buffer(VAR_2, tmp_row, VAR_0->xsize)) {

                VAR_7 = -1;

                goto cleanup;

            }

            for (VAR_3 = 0; VAR_3 < VAR_0->xsize; VAR_3++) {

                dest_row[VAR_6] = tmp_row[VAR_3]; 

                dest_row += VAR_0->zsize;

            }

        }

    }



cleanup:

    av_free(tmp_row);

    return VAR_7;

}

static int FUNC_0(const SGIInfo *VAR_0,
AVPicture *VAR_1, ByteIOContext *VAR_2)
{ int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7 = 0; uint8_t *dest_row, *tmp_row = NULL; tmp_row = av_malloc(VAR_0->xsize); url_fseek(VAR_2, SGI_HEADER_SIZE, SEEK_SET); VAR_1->linesize[0] = VAR_0->xsize; for (VAR_5 = 0; VAR_5 < VAR_0->zsize; VAR_5++) { #ifndef WORDS_BIGENDIAN
if (VAR_0->zsize == 4 && VAR_5 != 3)
VAR_6 = 2 - VAR_5; else
#endif
VAR_6 = VAR_5; for (VAR_4 = VAR_0->ysize - 1; VAR_4 >= 0; VAR_4--) { dest_row = VAR_1->data[0] + (VAR_4 * VAR_0->xsize * VAR_0->zsize); if (!get_buffer(VAR_2, tmp_row, VAR_0->xsize)) { VAR_7 = -1; goto cleanup; } for (VAR_3 = 0; VAR_3 < VAR_0->xsize; VAR_3++) { dest_row[VAR_6] = tmp_row[VAR_3]; dest_row += VAR_0->zsize; } } } cleanup:
av_free(tmp_row); return VAR_7; }