static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size)

{

    const unsigned char *data_end = data + data_size;

    GetBitContext gb;

    int flags, i, j, x, y, op;

    unsigned char c[3];

    unsigned char *dst;

    uint32_t *palette;



    flags = *data++;



    if (flags & 1) {

        palette = (uint32_t *)seq->frame.data[1];

        if (data_end - data < 256 * 3)

            return AVERROR_INVALIDDATA;

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

            for (j = 0; j < 3; j++, data++)

                c[j] = (*data << 2) | (*data >> 4);

            palette[i] = 0xFF << 24 | AV_RB24(c);

        }

        seq->frame.palette_has_changed = 1;

    }



    if (flags & 2) {

        if (data_end - data < 128)

            return AVERROR_INVALIDDATA;

        init_get_bits(&gb, data, 128 * 8); data += 128;

        for (y = 0; y < 128; y += 8)

            for (x = 0; x < 256; x += 8) {

                dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x];

                op = get_bits(&gb, 2);

                switch (op) {

                case 1:

                    data = seq_decode_op1(seq, data, data_end, dst);

                    break;

                case 2:

                    data = seq_decode_op2(seq, data, data_end, dst);

                    break;

                case 3:

                    data = seq_decode_op3(seq, data, data_end, dst);

                    break;

                }

                if (!data)

                    return AVERROR_INVALIDDATA;

            }

    }

    return 0;

}

static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size)

{

    const unsigned char *data_end = data + data_size;

    GetBitContext gb;

    int flags, i, j, x, y, op;

    unsigned char c[3];

    unsigned char *dst;

    uint32_t *palette;



    flags = *data++;



    if (flags & 1) {

        palette = (uint32_t *)seq->frame.data[1];

        if (data_end - data < 256 * 3)

            return AVERROR_INVALIDDATA;

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

            for (j = 0; j < 3; j++, data++)

                c[j] = (*data << 2) | (*data >> 4);

            palette[i] = 0xFF << 24 | AV_RB24(c);

        }

        seq->frame.palette_has_changed = 1;

    }



    if (flags & 2) {

        if (data_end - data < 128)

            return AVERROR_INVALIDDATA;

        init_get_bits(&gb, data, 128 * 8); data += 128;

        for (y = 0; y < 128; y += 8)

            for (x = 0; x < 256; x += 8) {

                dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x];

                op = get_bits(&gb, 2);

                switch (op) {

                case 1:

                    data = seq_decode_op1(seq, data, data_end, dst);

                    break;

                case 2:

                    data = seq_decode_op2(seq, data, data_end, dst);

                    break;

                case 3:

                    data = seq_decode_op3(seq, data, data_end, dst);

                    break;

                }

                if (!data)

                    return AVERROR_INVALIDDATA;

            }

    }

    return 0;

}

            palette[i] = 0xFF << 24 | AV_RB24(c);
static int FUNC_0(SeqVideoContext *VAR_0, const unsigned char *VAR_1, int VAR_2)

{

    const unsigned char *VAR_3 = VAR_1 + VAR_2;

    GetBitContext gb;

    int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;

    unsigned char VAR_10[3];

    unsigned char *VAR_11;

    uint32_t *palette;



    VAR_4 = *VAR_1++;



    if (VAR_4 & 1) {

        palette = (uint32_t *)VAR_0->frame.VAR_1[1];

        if (VAR_3 - VAR_1 < 256 * 3)

            return AVERROR_INVALIDDATA;

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

            for (VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_1++)

                VAR_10[VAR_6] = (*VAR_1 << 2) | (*VAR_1 >> 4);

            palette[VAR_5] = 0xFF << 24 | AV_RB24(VAR_10);

        }

        VAR_0->frame.palette_has_changed = 1;

    }



    if (VAR_4 & 2) {

        if (VAR_3 - VAR_1 < 128)

            return AVERROR_INVALIDDATA;

        init_get_bits(&gb, VAR_1, 128 * 8); VAR_1 += 128;

        for (VAR_8 = 0; VAR_8 < 128; VAR_8 += 8)

            for (VAR_7 = 0; VAR_7 < 256; VAR_7 += 8) {

                VAR_11 = &VAR_0->frame.VAR_1[0][VAR_8 * VAR_0->frame.linesize[0] + VAR_7];

                VAR_9 = get_bits(&gb, 2);

                switch (VAR_9) {

                case 1:

                    VAR_1 = seq_decode_op1(VAR_0, VAR_1, VAR_3, VAR_11);

                    break;

                case 2:

                    VAR_1 = seq_decode_op2(VAR_0, VAR_1, VAR_3, VAR_11);

                    break;

                case 3:

                    VAR_1 = seq_decode_op3(VAR_0, VAR_1, VAR_3, VAR_11);

                    break;

                }

                if (!VAR_1)

                    return AVERROR_INVALIDDATA;

            }

    }

    return 0;

}

static int FUNC_0(SeqVideoContext *VAR_0, const unsigned char *VAR_1, int VAR_2)
{ const unsigned char *VAR_3 = VAR_1 + VAR_2; GetBitContext gb; int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; unsigned char VAR_10[3]; unsigned char *VAR_11; uint32_t *palette; VAR_4 = *VAR_1++; if (VAR_4 & 1) { palette = (uint32_t *)VAR_0->frame.VAR_1[1]; if (VAR_3 - VAR_1 < 256 * 3)
return AVERROR_INVALIDDATA; for (VAR_5 = 0; VAR_5 < 256; VAR_5++) { for (VAR_6 = 0; VAR_6 < 3; VAR_6++, VAR_1++) VAR_10[VAR_6] = (*VAR_1 << 2) | (*VAR_1 >> 4); palette[VAR_5] = 0xFF << 24 | AV_RB24(VAR_10); } VAR_0->frame.palette_has_changed = 1; } if (VAR_4 & 2) { if (VAR_3 - VAR_1 < 128)
return AVERROR_INVALIDDATA; init_get_bits(&gb, VAR_1, 128 * 8); VAR_1 += 128; for (VAR_8 = 0; VAR_8 < 128; VAR_8 += 8) for (VAR_7 = 0; VAR_7 < 256; VAR_7 += 8) { VAR_11 = &VAR_0->frame.VAR_1[0][VAR_8 * VAR_0->frame.linesize[0] + VAR_7]; VAR_9 = get_bits(&gb, 2); switch (VAR_9) { case 1:
VAR_1 = seq_decode_op1(VAR_0, VAR_1, VAR_3, VAR_11); break; case 2:
VAR_1 = seq_decode_op2(VAR_0, VAR_1, VAR_3, VAR_11); break; case 3:
VAR_1 = seq_decode_op3(VAR_0, VAR_1, VAR_3, VAR_11); break; } if (!VAR_1)
return AVERROR_INVALIDDATA; } } return 0; }