static int mm_decode_intra(MmContext * s, int half_horiz, int half_vert)

{

    int x = 0, y = 0;



    while (bytestream2_get_bytes_left(&s->gb) > 0) {

        int run_length, color;



        if (y >= s->avctx->height)

            return 0;



        color = bytestream2_get_byte(&s->gb);

        if (color & 0x80) {

            run_length = 1;

        }else{

            run_length = (color & 0x7f) + 2;

            color = bytestream2_get_byte(&s->gb);

        }



        if (half_horiz)

            run_length *=2;



        if (run_length > s->avctx->width - x)

            return AVERROR_INVALIDDATA;



        if (color) {

            memset(s->frame->data[0] + y*s->frame->linesize[0] + x, color, run_length);

            if (half_vert)

                memset(s->frame->data[0] + (y+1)*s->frame->linesize[0] + x, color, run_length);

        }

        x+= run_length;



        if (x >= s->avctx->width) {

            x=0;

            y += 1 + half_vert;

        }

    }



    return 0;

}

static int mm_decode_intra(MmContext * s, int half_horiz, int half_vert)

{

    int x = 0, y = 0;



    while (bytestream2_get_bytes_left(&s->gb) > 0) {

        int run_length, color;



        if (y >= s->avctx->height)

            return 0;



        color = bytestream2_get_byte(&s->gb);

        if (color & 0x80) {

            run_length = 1;

        }else{

            run_length = (color & 0x7f) + 2;

            color = bytestream2_get_byte(&s->gb);

        }



        if (half_horiz)

            run_length *=2;



        if (run_length > s->avctx->width - x)

            return AVERROR_INVALIDDATA;



        if (color) {

            memset(s->frame->data[0] + y*s->frame->linesize[0] + x, color, run_length);

            if (half_vert)

                memset(s->frame->data[0] + (y+1)*s->frame->linesize[0] + x, color, run_length);

        }

        x+= run_length;



        if (x >= s->avctx->width) {

            x=0;

            y += 1 + half_vert;

        }

    }



    return 0;

}

static int FUNC_0(MmContext * VAR_0, int VAR_1, int VAR_2)

{

    int VAR_3 = 0, VAR_4 = 0;



    while (bytestream2_get_bytes_left(&VAR_0->gb) > 0) {

        int VAR_5, VAR_6;



        if (VAR_4 >= VAR_0->avctx->height)

            return 0;



        VAR_6 = bytestream2_get_byte(&VAR_0->gb);

        if (VAR_6 & 0x80) {

            VAR_5 = 1;

        }else{

            VAR_5 = (VAR_6 & 0x7f) + 2;

            VAR_6 = bytestream2_get_byte(&VAR_0->gb);

        }



        if (VAR_1)

            VAR_5 *=2;



        if (VAR_5 > VAR_0->avctx->width - VAR_3)

            return AVERROR_INVALIDDATA;



        if (VAR_6) {

            memset(VAR_0->frame->data[0] + VAR_4*VAR_0->frame->linesize[0] + VAR_3, VAR_6, VAR_5);

            if (VAR_2)

                memset(VAR_0->frame->data[0] + (VAR_4+1)*VAR_0->frame->linesize[0] + VAR_3, VAR_6, VAR_5);

        }

        VAR_3+= VAR_5;



        if (VAR_3 >= VAR_0->avctx->width) {

            VAR_3=0;

            VAR_4 += 1 + VAR_2;

        }

    }



    return 0;

}

static int FUNC_0(MmContext * VAR_0, int VAR_1, int VAR_2)
{ int VAR_3 = 0, VAR_4 = 0; while (bytestream2_get_bytes_left(&VAR_0->gb) > 0) { int VAR_5, VAR_6; if (VAR_4 >= VAR_0->avctx->height)
return 0; VAR_6 = bytestream2_get_byte(&VAR_0->gb); if (VAR_6 & 0x80) { VAR_5 = 1; }else{ VAR_5 = (VAR_6 & 0x7f) + 2; VAR_6 = bytestream2_get_byte(&VAR_0->gb); } if (VAR_1)
VAR_5 *=2; if (VAR_5 > VAR_0->avctx->width - VAR_3)
return AVERROR_INVALIDDATA; if (VAR_6) { memset(VAR_0->frame->data[0] + VAR_4*VAR_0->frame->linesize[0] + VAR_3, VAR_6, VAR_5); if (VAR_2)
memset(VAR_0->frame->data[0] + (VAR_4+1)*VAR_0->frame->linesize[0] + VAR_3, VAR_6, VAR_5); } VAR_3+= VAR_5; if (VAR_3 >= VAR_0->avctx->width) { VAR_3=0; VAR_4 += 1 + VAR_2; } } return 0; }