static int decode_frame_byterun1(AVCodecContext *avctx,

                            void *data, int *data_size,

                            AVPacket *avpkt)

{

    IffContext *s = avctx->priv_data;

    const uint8_t *buf = avpkt->data;

    unsigned buf_size = avpkt->size;

    const uint8_t *buf_end = buf+buf_size;

    unsigned y, plane, x;



    if (avctx->reget_buffer(avctx, &s->frame) < 0){

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return -1;

    }



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

        uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];

        if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved

            memset(row, 0, avctx->pix_fmt == PIX_FMT_PAL8 ? avctx->width : (avctx->width * 4));

            for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) {

                for(x = 0; x < s->planesize && buf < buf_end; ) {

                    int8_t value = *buf++;

                    unsigned length;

                    if (value >= 0) {

                        length = value + 1;

                        memcpy(s->planebuf + x, buf, FFMIN3(length, s->planesize - x, buf_end - buf));

                        buf += length;

                    } else if (value > -128) {

                        length = -value + 1;

                        memset(s->planebuf + x, *buf++, FFMIN(length, s->planesize - x));

                    } else { //noop

                        continue;

                    }

                    x += length;

                }

                if (avctx->pix_fmt == PIX_FMT_PAL8) {

                    decodeplane8(row, s->planebuf, s->planesize, avctx->bits_per_coded_sample, plane);

                } else { //PIX_FMT_BGR32

                    decodeplane32((uint32_t *) row, s->planebuf, s->planesize, avctx->bits_per_coded_sample, plane);

                }

            }

        } else {

            for(x = 0; x < avctx->width && buf < buf_end; ) {

                int8_t value = *buf++;

                unsigned length;

                if (value >= 0) {

                    length = value + 1;

                    memcpy(row + x, buf, FFMIN3(length, buf_end - buf, avctx->width - x));

                    buf += length;

                } else if (value > -128) {

                    length = -value + 1;

                    memset(row + x, *buf++, FFMIN(length, avctx->width - x));

                } else { //noop

                    continue;

                }

                x += length;

            }

        }

    }



    *data_size = sizeof(AVFrame);

    *(AVFrame*)data = s->frame;

    return buf_size;

}

static int decode_frame_byterun1(AVCodecContext *avctx,

                            void *data, int *data_size,

                            AVPacket *avpkt)

{

    IffContext *s = avctx->priv_data;

    const uint8_t *buf = avpkt->data;

    unsigned buf_size = avpkt->size;

    const uint8_t *buf_end = buf+buf_size;

    unsigned y, plane, x;



    if (avctx->reget_buffer(avctx, &s->frame) < 0){

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return -1;

    }



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

        uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];

        if (avctx->codec_tag == MKTAG('I','L','B','M')) { 

            memset(row, 0, avctx->pix_fmt == PIX_FMT_PAL8 ? avctx->width : (avctx->width * 4));

            for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) {

                for(x = 0; x < s->planesize && buf < buf_end; ) {

                    int8_t value = *buf++;

                    unsigned length;

                    if (value >= 0) {

                        length = value + 1;

                        memcpy(s->planebuf + x, buf, FFMIN3(length, s->planesize - x, buf_end - buf));

                        buf += length;

                    } else if (value > -128) {

                        length = -value + 1;

                        memset(s->planebuf + x, *buf++, FFMIN(length, s->planesize - x));

                    } else { 

                        continue;

                    }

                    x += length;

                }

                if (avctx->pix_fmt == PIX_FMT_PAL8) {

                    decodeplane8(row, s->planebuf, s->planesize, avctx->bits_per_coded_sample, plane);

                } else { 

                    decodeplane32((uint32_t *) row, s->planebuf, s->planesize, avctx->bits_per_coded_sample, plane);

                }

            }

        } else {

            for(x = 0; x < avctx->width && buf < buf_end; ) {

                int8_t value = *buf++;

                unsigned length;

                if (value >= 0) {

                    length = value + 1;

                    memcpy(row + x, buf, FFMIN3(length, buf_end - buf, avctx->width - x));

                    buf += length;

                } else if (value > -128) {

                    length = -value + 1;

                    memset(row + x, *buf++, FFMIN(length, avctx->width - x));

                } else { 

                    continue;

                }

                x += length;

            }

        }

    }



    *data_size = sizeof(AVFrame);

    *(AVFrame*)data = s->frame;

    return buf_size;

}

static int FUNC_0(AVCodecContext *VAR_0,

                            void *VAR_1, int *VAR_2,

                            AVPacket *VAR_3)

{

    IffContext *s = VAR_0->priv_data;

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    unsigned VAR_5 = VAR_3->size;

    const uint8_t *VAR_6 = VAR_4+VAR_5;

    unsigned VAR_7, VAR_8, VAR_9;



    if (VAR_0->reget_buffer(VAR_0, &s->frame) < 0){

        av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");

        return -1;

    }



    for(VAR_7 = 0; VAR_7 < VAR_0->height ; VAR_7++ ) {

        uint8_t *row = &s->frame.VAR_1[0][ VAR_7*s->frame.linesize[0] ];

        if (VAR_0->codec_tag == MKTAG('I','L','B','M')) { 

            memset(row, 0, VAR_0->pix_fmt == PIX_FMT_PAL8 ? VAR_0->width : (VAR_0->width * 4));

            for (VAR_8 = 0; VAR_8 < VAR_0->bits_per_coded_sample; VAR_8++) {

                for(VAR_9 = 0; VAR_9 < s->planesize && VAR_4 < VAR_6; ) {

                    int8_t value = *VAR_4++;

                    unsigned length;

                    if (value >= 0) {

                        length = value + 1;

                        memcpy(s->planebuf + VAR_9, VAR_4, FFMIN3(length, s->planesize - VAR_9, VAR_6 - VAR_4));

                        VAR_4 += length;

                    } else if (value > -128) {

                        length = -value + 1;

                        memset(s->planebuf + VAR_9, *VAR_4++, FFMIN(length, s->planesize - VAR_9));

                    } else { 

                        continue;

                    }

                    VAR_9 += length;

                }

                if (VAR_0->pix_fmt == PIX_FMT_PAL8) {

                    decodeplane8(row, s->planebuf, s->planesize, VAR_0->bits_per_coded_sample, VAR_8);

                } else { 

                    decodeplane32((uint32_t *) row, s->planebuf, s->planesize, VAR_0->bits_per_coded_sample, VAR_8);

                }

            }

        } else {

            for(VAR_9 = 0; VAR_9 < VAR_0->width && VAR_4 < VAR_6; ) {

                int8_t value = *VAR_4++;

                unsigned length;

                if (value >= 0) {

                    length = value + 1;

                    memcpy(row + VAR_9, VAR_4, FFMIN3(length, VAR_6 - VAR_4, VAR_0->width - VAR_9));

                    VAR_4 += length;

                } else if (value > -128) {

                    length = -value + 1;

                    memset(row + VAR_9, *VAR_4++, FFMIN(length, VAR_0->width - VAR_9));

                } else { 

                    continue;

                }

                VAR_9 += length;

            }

        }

    }



    *VAR_2 = sizeof(AVFrame);

    *(AVFrame*)VAR_1 = s->frame;

    return VAR_5;

}

static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{ IffContext *s = VAR_0->priv_data; const uint8_t *VAR_4 = VAR_3->VAR_1; unsigned VAR_5 = VAR_3->size; const uint8_t *VAR_6 = VAR_4+VAR_5; unsigned VAR_7, VAR_8, VAR_9; if (VAR_0->reget_buffer(VAR_0, &s->frame) < 0){ av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } for(VAR_7 = 0; VAR_7 < VAR_0->height ; VAR_7++ ) { uint8_t *row = &s->frame.VAR_1[0][ VAR_7*s->frame.linesize[0] ]; if (VAR_0->codec_tag == MKTAG('I','L','B','M')) { memset(row, 0, VAR_0->pix_fmt == PIX_FMT_PAL8 ? VAR_0->width : (VAR_0->width * 4)); for (VAR_8 = 0; VAR_8 < VAR_0->bits_per_coded_sample; VAR_8++) { for(VAR_9 = 0; VAR_9 < s->planesize && VAR_4 < VAR_6; ) { int8_t value = *VAR_4++; unsigned length; if (value >= 0) { length = value + 1; memcpy(s->planebuf + VAR_9, VAR_4, FFMIN3(length, s->planesize - VAR_9, VAR_6 - VAR_4)); VAR_4 += length; } else if (value > -128) { length = -value + 1; memset(s->planebuf + VAR_9, *VAR_4++, FFMIN(length, s->planesize - VAR_9)); } else { continue; } VAR_9 += length; } if (VAR_0->pix_fmt == PIX_FMT_PAL8) { decodeplane8(row, s->planebuf, s->planesize, VAR_0->bits_per_coded_sample, VAR_8); } else { decodeplane32((uint32_t *) row, s->planebuf, s->planesize, VAR_0->bits_per_coded_sample, VAR_8); } } } else { for(VAR_9 = 0; VAR_9 < VAR_0->width && VAR_4 < VAR_6; ) { int8_t value = *VAR_4++; unsigned length; if (value >= 0) { length = value + 1; memcpy(row + VAR_9, VAR_4, FFMIN3(length, VAR_6 - VAR_4, VAR_0->width - VAR_9)); VAR_4 += length; } else if (value > -128) { length = -value + 1; memset(row + VAR_9, *VAR_4++, FFMIN(length, VAR_0->width - VAR_9)); } else { continue; } VAR_9 += length; } } } *VAR_2 = sizeof(AVFrame); *(AVFrame*)VAR_1 = s->frame; return VAR_5; }