static int decode_555(GetByteContext *gB, uint16_t *dst, int stride,

                      int keyframe, int w, int h)

{

    int last_symbol = 0, repeat = 0, prev_avail = 0;



    if (!keyframe) {

        int x, y, endx, endy, t;



#define READ_PAIR(a, b)                 \

    a  = bytestream2_get_byte(gB) << 4; \

    t  = bytestream2_get_byte(gB);      \

    a |= t >> 4;                        \

    b  = (t & 0xF) << 8;                \

    b |= bytestream2_get_byte(gB);      \



        READ_PAIR(x, endx)

        READ_PAIR(y, endy)



        if (endx >= w || endy >= h || x > endx || y > endy)

            return AVERROR_INVALIDDATA;

        dst += x + stride * y;

        w    = endx - x + 1;

        h    = endy - y + 1;

        if (y)

            prev_avail = 1;

    }



    do {

        uint16_t *p = dst;

        do {

            if (repeat-- < 1) {

                int b = bytestream2_get_byte(gB);

                if (b < 128)

                    last_symbol = b << 8 | bytestream2_get_byte(gB);

                else if (b > 129) {

                    repeat = 0;

                    while (b-- > 130)

                        repeat = (repeat << 8) + bytestream2_get_byte(gB) + 1;

                    if (last_symbol == -2) {

                        int skip = FFMIN((unsigned)repeat, dst + w - p);

                        repeat -= skip;

                        p      += skip;

                    }

                } else

                    last_symbol = 127 - b;

            }

            if (last_symbol >= 0)

                *p = last_symbol;

            else if (last_symbol == -1 && prev_avail)

                *p = *(p - stride);

        } while (++p < dst + w);

        dst       += stride;

        prev_avail = 1;

    } while (--h);



    return 0;

}

static int decode_555(GetByteContext *gB, uint16_t *dst, int stride,

                      int keyframe, int w, int h)

{

    int last_symbol = 0, repeat = 0, prev_avail = 0;



    if (!keyframe) {

        int x, y, endx, endy, t;



#define READ_PAIR(a, b)                 \

    a  = bytestream2_get_byte(gB) << 4; \

    t  = bytestream2_get_byte(gB);      \

    a |= t >> 4;                        \

    b  = (t & 0xF) << 8;                \

    b |= bytestream2_get_byte(gB);      \



        READ_PAIR(x, endx)

        READ_PAIR(y, endy)



        if (endx >= w || endy >= h || x > endx || y > endy)

            return AVERROR_INVALIDDATA;

        dst += x + stride * y;

        w    = endx - x + 1;

        h    = endy - y + 1;

        if (y)

            prev_avail = 1;

    }



    do {

        uint16_t *p = dst;

        do {

            if (repeat-- < 1) {

                int b = bytestream2_get_byte(gB);

                if (b < 128)

                    last_symbol = b << 8 | bytestream2_get_byte(gB);

                else if (b > 129) {

                    repeat = 0;

                    while (b-- > 130)

                        repeat = (repeat << 8) + bytestream2_get_byte(gB) + 1;

                    if (last_symbol == -2) {

                        int skip = FFMIN((unsigned)repeat, dst + w - p);

                        repeat -= skip;

                        p      += skip;

                    }

                } else

                    last_symbol = 127 - b;

            }

            if (last_symbol >= 0)

                *p = last_symbol;

            else if (last_symbol == -1 && prev_avail)

                *p = *(p - stride);

        } while (++p < dst + w);

        dst       += stride;

        prev_avail = 1;

    } while (--h);



    return 0;

}

                    while (b-- > 130)
static int FUNC_0(GetByteContext *VAR_0, uint16_t *VAR_1, int VAR_2,

                      int VAR_3, int VAR_4, int VAR_5)

{

    int VAR_6 = 0, VAR_7 = 0, VAR_8 = 0;



    if (!VAR_3) {

        int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;



#define READ_PAIR(a, VAR_14)                 \

    a  = bytestream2_get_byte(VAR_0) << 4; \

    VAR_13  = bytestream2_get_byte(VAR_0);      \

    a |= VAR_13 >> 4;                        \

    VAR_14  = (VAR_13 & 0xF) << 8;                \

    VAR_14 |= bytestream2_get_byte(VAR_0);      \



        READ_PAIR(VAR_9, VAR_11)

        READ_PAIR(VAR_10, VAR_12)



        if (VAR_11 >= VAR_4 || VAR_12 >= VAR_5 || VAR_9 > VAR_11 || VAR_10 > VAR_12)

            return AVERROR_INVALIDDATA;

        VAR_1 += VAR_9 + VAR_2 * VAR_10;

        VAR_4    = VAR_11 - VAR_9 + 1;

        VAR_5    = VAR_12 - VAR_10 + 1;

        if (VAR_10)

            VAR_8 = 1;

    }



    do {

        uint16_t *p = VAR_1;

        do {

            if (VAR_7-- < 1) {

                int VAR_14 = bytestream2_get_byte(VAR_0);

                if (VAR_14 < 128)

                    VAR_6 = VAR_14 << 8 | bytestream2_get_byte(VAR_0);

                else if (VAR_14 > 129) {

                    VAR_7 = 0;

                    while (VAR_14-- > 130)

                        VAR_7 = (VAR_7 << 8) + bytestream2_get_byte(VAR_0) + 1;

                    if (VAR_6 == -2) {

                        int VAR_15 = FFMIN((unsigned)VAR_7, VAR_1 + VAR_4 - p);

                        VAR_7 -= VAR_15;

                        p      += VAR_15;

                    }

                } else

                    VAR_6 = 127 - VAR_14;

            }

            if (VAR_6 >= 0)

                *p = VAR_6;

            else if (VAR_6 == -1 && VAR_8)

                *p = *(p - VAR_2);

        } while (++p < VAR_1 + VAR_4);

        VAR_1       += VAR_2;

        VAR_8 = 1;

    } while (--VAR_5);



    return 0;

}

static int FUNC_0(GetByteContext *VAR_0, uint16_t *VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5)
{ int VAR_6 = 0, VAR_7 = 0, VAR_8 = 0; if (!VAR_3) { int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13; #define READ_PAIR(a, VAR_14)                 \
a  = bytestream2_get_byte(VAR_0) << 4; \ VAR_13  = bytestream2_get_byte(VAR_0);      \ a |= VAR_13 >> 4;                        \ VAR_14  = (VAR_13 & 0xF) << 8;                \ VAR_14 |= bytestream2_get_byte(VAR_0);      \ READ_PAIR(VAR_9, VAR_11)
READ_PAIR(VAR_10, VAR_12)
if (VAR_11 >= VAR_4 || VAR_12 >= VAR_5 || VAR_9 > VAR_11 || VAR_10 > VAR_12)
return AVERROR_INVALIDDATA; VAR_1 += VAR_9 + VAR_2 * VAR_10; VAR_4    = VAR_11 - VAR_9 + 1; VAR_5    = VAR_12 - VAR_10 + 1; if (VAR_10)
VAR_8 = 1; } do { uint16_t *p = VAR_1; do { if (VAR_7-- < 1) { int VAR_14 = bytestream2_get_byte(VAR_0); if (VAR_14 < 128)
VAR_6 = VAR_14 << 8 | bytestream2_get_byte(VAR_0); else if (VAR_14 > 129) { VAR_7 = 0; while (VAR_14-- > 130)
VAR_7 = (VAR_7 << 8) + bytestream2_get_byte(VAR_0) + 1; if (VAR_6 == -2) { int VAR_15 = FFMIN((unsigned)VAR_7, VAR_1 + VAR_4 - p); VAR_7 -= VAR_15; p      += VAR_15; } } else VAR_6 = 127 - VAR_14; } if (VAR_6 >= 0)
*p = VAR_6; else if (VAR_6 == -1 && VAR_8)
*p = *(p - VAR_2); } while (++p < VAR_1 + VAR_4); VAR_1       += VAR_2; VAR_8 = 1; } while (--VAR_5); return 0; }