static int read_rle_sgi(uint8_t *out_buf, SgiState *s)

{

    uint8_t *dest_row;

    unsigned int len = s->height * s->depth * 4;

    GetByteContext g_table = s->g;

    unsigned int y, z;

    unsigned int start_offset;



    /* size of  RLE offset and length tables */

    if (len * 2  > bytestream2_get_bytes_left(&s->g)) {

        return AVERROR_INVALIDDATA;

    }



    for (z = 0; z < s->depth; z++) {

        dest_row = out_buf;

        for (y = 0; y < s->height; y++) {

            dest_row -= s->linesize;

            start_offset = bytestream2_get_be32(&g_table);

            bytestream2_seek(&s->g, start_offset, SEEK_SET);

            if (expand_rle_row(s, dest_row + z, dest_row + FFABS(s->linesize),

                               s->depth) != s->width) {

                return AVERROR_INVALIDDATA;

            }

        }

    }

    return 0;

}

static int read_rle_sgi(uint8_t *out_buf, SgiState *s)

{

    uint8_t *dest_row;

    unsigned int len = s->height * s->depth * 4;

    GetByteContext g_table = s->g;

    unsigned int y, z;

    unsigned int start_offset;



    

    if (len * 2  > bytestream2_get_bytes_left(&s->g)) {

        return AVERROR_INVALIDDATA;

    }



    for (z = 0; z < s->depth; z++) {

        dest_row = out_buf;

        for (y = 0; y < s->height; y++) {

            dest_row -= s->linesize;

            start_offset = bytestream2_get_be32(&g_table);

            bytestream2_seek(&s->g, start_offset, SEEK_SET);

            if (expand_rle_row(s, dest_row + z, dest_row + FFABS(s->linesize),

                               s->depth) != s->width) {

                return AVERROR_INVALIDDATA;

            }

        }

    }

    return 0;

}

            if (expand_rle_row(s, dest_row + z, dest_row + FFABS(s->linesize),
static int FUNC_0(uint8_t *VAR_0, SgiState *VAR_1)

{

    uint8_t *dest_row;

    unsigned int VAR_2 = VAR_1->height * VAR_1->depth * 4;

    GetByteContext g_table = VAR_1->g;

    unsigned int VAR_3, VAR_4;

    unsigned int VAR_5;



    

    if (VAR_2 * 2  > bytestream2_get_bytes_left(&VAR_1->g)) {

        return AVERROR_INVALIDDATA;

    }



    for (VAR_4 = 0; VAR_4 < VAR_1->depth; VAR_4++) {

        dest_row = VAR_0;

        for (VAR_3 = 0; VAR_3 < VAR_1->height; VAR_3++) {

            dest_row -= VAR_1->linesize;

            VAR_5 = bytestream2_get_be32(&g_table);

            bytestream2_seek(&VAR_1->g, VAR_5, SEEK_SET);

            if (expand_rle_row(VAR_1, dest_row + VAR_4, dest_row + FFABS(VAR_1->linesize),

                               VAR_1->depth) != VAR_1->width) {

                return AVERROR_INVALIDDATA;

            }

        }

    }

    return 0;

}

static int FUNC_0(uint8_t *VAR_0, SgiState *VAR_1)
{ uint8_t *dest_row; unsigned int VAR_2 = VAR_1->height * VAR_1->depth * 4; GetByteContext g_table = VAR_1->g; unsigned int VAR_3, VAR_4; unsigned int VAR_5; if (VAR_2 * 2  > bytestream2_get_bytes_left(&VAR_1->g)) { return AVERROR_INVALIDDATA; } for (VAR_4 = 0; VAR_4 < VAR_1->depth; VAR_4++) { dest_row = VAR_0; for (VAR_3 = 0; VAR_3 < VAR_1->height; VAR_3++) { dest_row -= VAR_1->linesize; VAR_5 = bytestream2_get_be32(&g_table); bytestream2_seek(&VAR_1->g, VAR_5, SEEK_SET); if (expand_rle_row(VAR_1, dest_row + VAR_4, dest_row + FFABS(VAR_1->linesize),
VAR_1->depth) != VAR_1->width) { return AVERROR_INVALIDDATA; } } } return 0; }