static int decode_rle(AVCodecContext *avctx, AVFrame *p, GetByteContext *gbc,

                      int step)

{

    int i, j;

    int offset = avctx->width * step;

    uint8_t *outdata = p->data[0];



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

        int size, left, code, pix;

        uint8_t *out = outdata;

        int pos = 0;



        /* size of packed line */

        size = left = bytestream2_get_be16(gbc);

        if (bytestream2_get_bytes_left(gbc) < size)




        /* decode line */

        while (left > 0) {

            code = bytestream2_get_byte(gbc);

            if (code & 0x80 ) { /* run */

                pix = bytestream2_get_byte(gbc);

                for (j = 0; j < 257 - code; j++) {

                    out[pos] = pix;

                    pos += step;

                    if (pos >= offset) {

                        pos -= offset;

                        pos++;

                    }



                }

                left  -= 2;

            } else { /* copy */

                for (j = 0; j < code + 1; j++) {

                    out[pos] = bytestream2_get_byte(gbc);

                    pos += step;

                    if (pos >= offset) {

                        pos -= offset;

                        pos++;

                    }



                }

                left  -= 2 + code;

            }

        }

        outdata += p->linesize[0];

    }

    return 0;

}
static int decode_rle(AVCodecContext *avctx, AVFrame *p, GetByteContext *gbc,

                      int step)

{

    int i, j;

    int offset = avctx->width * step;

    uint8_t *outdata = p->data[0];



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

        int size, left, code, pix;

        uint8_t *out = outdata;

        int pos = 0;



        

        size = left = bytestream2_get_be16(gbc);

        if (bytestream2_get_bytes_left(gbc) < size)




        

        while (left > 0) {

            code = bytestream2_get_byte(gbc);

            if (code & 0x80 ) { 

                pix = bytestream2_get_byte(gbc);

                for (j = 0; j < 257 - code; j++) {

                    out[pos] = pix;

                    pos += step;

                    if (pos >= offset) {

                        pos -= offset;

                        pos++;

                    }



                }

                left  -= 2;

            } else { 

                for (j = 0; j < code + 1; j++) {

                    out[pos] = bytestream2_get_byte(gbc);

                    pos += step;

                    if (pos >= offset) {

                        pos -= offset;

                        pos++;

                    }



                }

                left  -= 2 + code;

            }

        }

        outdata += p->linesize[0];

    }

    return 0;

}
static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, GetByteContext *VAR_2,

                      int VAR_3)

{

    int VAR_4, VAR_5;

    int VAR_6 = VAR_0->width * VAR_3;

    uint8_t *outdata = VAR_1->data[0];



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

        int size, left, code, pix;

        uint8_t *out = outdata;

        int pos = 0;



        

        size = left = bytestream2_get_be16(VAR_2);

        if (bytestream2_get_bytes_left(VAR_2) < size)




        

        while (left > 0) {

            code = bytestream2_get_byte(VAR_2);

            if (code & 0x80 ) { 

                pix = bytestream2_get_byte(VAR_2);

                for (VAR_5 = 0; VAR_5 < 257 - code; VAR_5++) {

                    out[pos] = pix;

                    pos += VAR_3;

                    if (pos >= VAR_6) {

                        pos -= VAR_6;

                        pos++;

                    }



                }

                left  -= 2;

            } else { 

                for (VAR_5 = 0; VAR_5 < code + 1; VAR_5++) {

                    out[pos] = bytestream2_get_byte(VAR_2);

                    pos += VAR_3;

                    if (pos >= VAR_6) {

                        pos -= VAR_6;

                        pos++;

                    }



                }

                left  -= 2 + code;

            }

        }

        outdata += VAR_1->linesize[0];

    }

    return 0;

}
static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, GetByteContext *VAR_2,
int VAR_3)
{ int VAR_4, VAR_5; int VAR_6 = VAR_0->width * VAR_3; uint8_t *outdata = VAR_1->data[0]; for (VAR_4 = 0; VAR_4 < VAR_0->height; VAR_4++) { int size, left, code, pix; uint8_t *out = outdata; int pos = 0; size = left = bytestream2_get_be16(VAR_2); if (bytestream2_get_bytes_left(VAR_2) < size)
while (left > 0) { code = bytestream2_get_byte(VAR_2); if (code & 0x80 ) { pix = bytestream2_get_byte(VAR_2); for (VAR_5 = 0; VAR_5 < 257 - code; VAR_5++) { out[pos] = pix; pos += VAR_3; if (pos >= VAR_6) { pos -= VAR_6; pos++; } } left  -= 2; } else { for (VAR_5 = 0; VAR_5 < code + 1; VAR_5++) { out[pos] = bytestream2_get_byte(VAR_2); pos += VAR_3; if (pos >= VAR_6) { pos -= VAR_6; pos++; } } left  -= 2 + code; } } outdata += VAR_1->linesize[0]; } return 0; }