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

{

    int data_off = bytestream2_get_le16(&s->gb), y;

    GetByteContext data_ptr;



    if (bytestream2_get_bytes_left(&s->gb) < data_off)

        return AVERROR_INVALIDDATA;



    bytestream2_init(&data_ptr, s->gb.buffer + data_off, bytestream2_get_bytes_left(&s->gb) - data_off);

    while (s->gb.buffer < data_ptr.buffer_start) {

        int i, j;

        int length = bytestream2_get_byte(&s->gb);

        int x = bytestream2_get_byte(&s->gb) + ((length & 0x80) << 1);

        length &= 0x7F;



        if (length==0) {

            y += x;

            continue;

        }



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

            return 0;



        for(i=0; i<length; i++) {

            int replace_array = bytestream2_get_byte(&s->gb);

            for(j=0; j<8; j++) {

                int replace = (replace_array >> (7-j)) & 1;

                if (replace) {

                    int color = bytestream2_get_byte(&data_ptr);

                    s->frame.data[0][y*s->frame.linesize[0] + x] = color;

                    if (half_horiz)

                        s->frame.data[0][y*s->frame.linesize[0] + x + 1] = color;

                    if (half_vert) {

                        s->frame.data[0][(y+1)*s->frame.linesize[0] + x] = color;

                        if (half_horiz)

                            s->frame.data[0][(y+1)*s->frame.linesize[0] + x + 1] = color;

                    }

                }

                x += 1 + half_horiz;

            }

        }



        y += 1 + half_vert;

    }



    return 0;

}

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

{

    int data_off = bytestream2_get_le16(&s->gb), y;

    GetByteContext data_ptr;



    if (bytestream2_get_bytes_left(&s->gb) < data_off)

        return AVERROR_INVALIDDATA;



    bytestream2_init(&data_ptr, s->gb.buffer + data_off, bytestream2_get_bytes_left(&s->gb) - data_off);

    while (s->gb.buffer < data_ptr.buffer_start) {

        int i, j;

        int length = bytestream2_get_byte(&s->gb);

        int x = bytestream2_get_byte(&s->gb) + ((length & 0x80) << 1);

        length &= 0x7F;



        if (length==0) {

            y += x;

            continue;

        }



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

            return 0;



        for(i=0; i<length; i++) {

            int replace_array = bytestream2_get_byte(&s->gb);

            for(j=0; j<8; j++) {

                int replace = (replace_array >> (7-j)) & 1;

                if (replace) {

                    int color = bytestream2_get_byte(&data_ptr);

                    s->frame.data[0][y*s->frame.linesize[0] + x] = color;

                    if (half_horiz)

                        s->frame.data[0][y*s->frame.linesize[0] + x + 1] = color;

                    if (half_vert) {

                        s->frame.data[0][(y+1)*s->frame.linesize[0] + x] = color;

                        if (half_horiz)

                            s->frame.data[0][(y+1)*s->frame.linesize[0] + x + 1] = color;

                    }

                }

                x += 1 + half_horiz;

            }

        }



        y += 1 + half_vert;

    }



    return 0;

}

    int data_off = bytestream2_get_le16(&s->gb), y;
static int FUNC_0(MmContext * VAR_0, int VAR_1, int VAR_2)

{

    int VAR_3 = bytestream2_get_le16(&VAR_0->gb), VAR_4;

    GetByteContext data_ptr;



    if (bytestream2_get_bytes_left(&VAR_0->gb) < VAR_3)

        return AVERROR_INVALIDDATA;



    bytestream2_init(&data_ptr, VAR_0->gb.buffer + VAR_3, bytestream2_get_bytes_left(&VAR_0->gb) - VAR_3);

    while (VAR_0->gb.buffer < data_ptr.buffer_start) {

        int VAR_5, VAR_6;

        int VAR_7 = bytestream2_get_byte(&VAR_0->gb);

        int VAR_8 = bytestream2_get_byte(&VAR_0->gb) + ((VAR_7 & 0x80) << 1);

        VAR_7 &= 0x7F;



        if (VAR_7==0) {

            VAR_4 += VAR_8;

            continue;

        }



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

            return 0;



        for(VAR_5=0; VAR_5<VAR_7; VAR_5++) {

            int VAR_9 = bytestream2_get_byte(&VAR_0->gb);

            for(VAR_6=0; VAR_6<8; VAR_6++) {

                int VAR_10 = (VAR_9 >> (7-VAR_6)) & 1;

                if (VAR_10) {

                    int VAR_11 = bytestream2_get_byte(&data_ptr);

                    VAR_0->frame.data[0][VAR_4*VAR_0->frame.linesize[0] + VAR_8] = VAR_11;

                    if (VAR_1)

                        VAR_0->frame.data[0][VAR_4*VAR_0->frame.linesize[0] + VAR_8 + 1] = VAR_11;

                    if (VAR_2) {

                        VAR_0->frame.data[0][(VAR_4+1)*VAR_0->frame.linesize[0] + VAR_8] = VAR_11;

                        if (VAR_1)

                            VAR_0->frame.data[0][(VAR_4+1)*VAR_0->frame.linesize[0] + VAR_8 + 1] = VAR_11;

                    }

                }

                VAR_8 += 1 + VAR_1;

            }

        }



        VAR_4 += 1 + VAR_2;

    }



    return 0;

}

static int FUNC_0(MmContext * VAR_0, int VAR_1, int VAR_2)
{ int VAR_3 = bytestream2_get_le16(&VAR_0->gb), VAR_4; GetByteContext data_ptr; if (bytestream2_get_bytes_left(&VAR_0->gb) < VAR_3)
return AVERROR_INVALIDDATA; bytestream2_init(&data_ptr, VAR_0->gb.buffer + VAR_3, bytestream2_get_bytes_left(&VAR_0->gb) - VAR_3); while (VAR_0->gb.buffer < data_ptr.buffer_start) { int VAR_5, VAR_6; int VAR_7 = bytestream2_get_byte(&VAR_0->gb); int VAR_8 = bytestream2_get_byte(&VAR_0->gb) + ((VAR_7 & 0x80) << 1); VAR_7 &= 0x7F; if (VAR_7==0) { VAR_4 += VAR_8; continue; } if (VAR_4 + VAR_2 >= VAR_0->avctx->height)
return 0; for(VAR_5=0; VAR_5<VAR_7; VAR_5++) { int VAR_9 = bytestream2_get_byte(&VAR_0->gb); for(VAR_6=0; VAR_6<8; VAR_6++) { int VAR_10 = (VAR_9 >> (7-VAR_6)) & 1; if (VAR_10) { int VAR_11 = bytestream2_get_byte(&data_ptr); VAR_0->frame.data[0][VAR_4*VAR_0->frame.linesize[0] + VAR_8] = VAR_11; if (VAR_1)
VAR_0->frame.data[0][VAR_4*VAR_0->frame.linesize[0] + VAR_8 + 1] = VAR_11; if (VAR_2) { VAR_0->frame.data[0][(VAR_4+1)*VAR_0->frame.linesize[0] + VAR_8] = VAR_11; if (VAR_1)
VAR_0->frame.data[0][(VAR_4+1)*VAR_0->frame.linesize[0] + VAR_8 + 1] = VAR_11; } } VAR_8 += 1 + VAR_1; } } VAR_4 += 1 + VAR_2; } return 0; }