static void decode_delta_l(uint8_t *dst,

                           const uint8_t *buf, const uint8_t *buf_end,

                           int w, int flag, int bpp, int dst_size)

{

    GetByteContext off0, off1, dgb, ogb;

    PutByteContext pb;

    unsigned poff0, poff1;

    int i, k, dstpitch;

    int planepitch_byte = (w + 7) / 8;

    int planepitch = ((w + 15) / 16) * 2;

    int pitch = planepitch * bpp;



    if (buf_end - buf <= 64)

        return;



    bytestream2_init(&off0, buf, buf_end - buf);

    bytestream2_init(&off1, buf + 32, buf_end - (buf + 32));

    bytestream2_init_writer(&pb, dst, dst_size);



    dstpitch = flag ? (((w + 7) / 8) * bpp): 2;



    for (k = 0; k < bpp; k++) {

        poff0 = bytestream2_get_be32(&off0);

        poff1 = bytestream2_get_be32(&off1);



        if (!poff0)

            continue;



        if (2LL * poff0 >= buf_end - buf)

            return;



        if (2LL * poff1 >= buf_end - buf)

            return;



        bytestream2_init(&dgb, buf + 2 * poff0, buf_end - (buf + 2 * poff0));

        bytestream2_init(&ogb, buf + 2 * poff1, buf_end - (buf + 2 * poff1));



        while ((bytestream2_peek_be16(&ogb)) != 0xFFFF) {

            uint32_t offset = bytestream2_get_be16(&ogb);

            int16_t cnt = bytestream2_get_be16(&ogb);

            uint16_t data;



            offset = ((2 * offset) / planepitch_byte) * pitch + ((2 * offset) % planepitch_byte) + k * planepitch;

            if (cnt < 0) {

                bytestream2_seek_p(&pb, offset, SEEK_SET);

                cnt = -cnt;

                data = bytestream2_get_be16(&dgb);

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

                    bytestream2_put_be16(&pb, data);

                    bytestream2_skip_p(&pb, dstpitch - 2);

                }

            } else {

                bytestream2_seek_p(&pb, offset, SEEK_SET);

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

                    data = bytestream2_get_be16(&dgb);

                    bytestream2_put_be16(&pb, data);

                    bytestream2_skip_p(&pb, dstpitch - 2);

                }

            }

        }

    }

}

static void decode_delta_l(uint8_t *dst,

                           const uint8_t *buf, const uint8_t *buf_end,

                           int w, int flag, int bpp, int dst_size)

{

    GetByteContext off0, off1, dgb, ogb;

    PutByteContext pb;

    unsigned poff0, poff1;

    int i, k, dstpitch;

    int planepitch_byte = (w + 7) / 8;

    int planepitch = ((w + 15) / 16) * 2;

    int pitch = planepitch * bpp;



    if (buf_end - buf <= 64)

        return;



    bytestream2_init(&off0, buf, buf_end - buf);

    bytestream2_init(&off1, buf + 32, buf_end - (buf + 32));

    bytestream2_init_writer(&pb, dst, dst_size);



    dstpitch = flag ? (((w + 7) / 8) * bpp): 2;



    for (k = 0; k < bpp; k++) {

        poff0 = bytestream2_get_be32(&off0);

        poff1 = bytestream2_get_be32(&off1);



        if (!poff0)

            continue;



        if (2LL * poff0 >= buf_end - buf)

            return;



        if (2LL * poff1 >= buf_end - buf)

            return;



        bytestream2_init(&dgb, buf + 2 * poff0, buf_end - (buf + 2 * poff0));

        bytestream2_init(&ogb, buf + 2 * poff1, buf_end - (buf + 2 * poff1));



        while ((bytestream2_peek_be16(&ogb)) != 0xFFFF) {

            uint32_t offset = bytestream2_get_be16(&ogb);

            int16_t cnt = bytestream2_get_be16(&ogb);

            uint16_t data;



            offset = ((2 * offset) / planepitch_byte) * pitch + ((2 * offset) % planepitch_byte) + k * planepitch;

            if (cnt < 0) {

                bytestream2_seek_p(&pb, offset, SEEK_SET);

                cnt = -cnt;

                data = bytestream2_get_be16(&dgb);

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

                    bytestream2_put_be16(&pb, data);

                    bytestream2_skip_p(&pb, dstpitch - 2);

                }

            } else {

                bytestream2_seek_p(&pb, offset, SEEK_SET);

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

                    data = bytestream2_get_be16(&dgb);

                    bytestream2_put_be16(&pb, data);

                    bytestream2_skip_p(&pb, dstpitch - 2);

                }

            }

        }

    }

}

static void FUNC_0(uint8_t *VAR_0,

                           const uint8_t *VAR_1, const uint8_t *VAR_2,

                           int VAR_3, int VAR_4, int VAR_5, int VAR_6)

{

    GetByteContext off0, off1, dgb, ogb;

    PutByteContext pb;

    unsigned VAR_7, VAR_8;

    int VAR_9, VAR_10, VAR_11;

    int VAR_12 = (VAR_3 + 7) / 8;

    int VAR_13 = ((VAR_3 + 15) / 16) * 2;

    int VAR_14 = VAR_13 * VAR_5;



    if (VAR_2 - VAR_1 <= 64)

        return;



    bytestream2_init(&off0, VAR_1, VAR_2 - VAR_1);

    bytestream2_init(&off1, VAR_1 + 32, VAR_2 - (VAR_1 + 32));

    bytestream2_init_writer(&pb, VAR_0, VAR_6);



    VAR_11 = VAR_4 ? (((VAR_3 + 7) / 8) * VAR_5): 2;



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

        VAR_7 = bytestream2_get_be32(&off0);

        VAR_8 = bytestream2_get_be32(&off1);



        if (!VAR_7)

            continue;



        if (2LL * VAR_7 >= VAR_2 - VAR_1)

            return;



        if (2LL * VAR_8 >= VAR_2 - VAR_1)

            return;



        bytestream2_init(&dgb, VAR_1 + 2 * VAR_7, VAR_2 - (VAR_1 + 2 * VAR_7));

        bytestream2_init(&ogb, VAR_1 + 2 * VAR_8, VAR_2 - (VAR_1 + 2 * VAR_8));



        while ((bytestream2_peek_be16(&ogb)) != 0xFFFF) {

            uint32_t offset = bytestream2_get_be16(&ogb);

            int16_t cnt = bytestream2_get_be16(&ogb);

            uint16_t data;



            offset = ((2 * offset) / VAR_12) * VAR_14 + ((2 * offset) % VAR_12) + VAR_10 * VAR_13;

            if (cnt < 0) {

                bytestream2_seek_p(&pb, offset, SEEK_SET);

                cnt = -cnt;

                data = bytestream2_get_be16(&dgb);

                for (VAR_9 = 0; VAR_9 < cnt; VAR_9++) {

                    bytestream2_put_be16(&pb, data);

                    bytestream2_skip_p(&pb, VAR_11 - 2);

                }

            } else {

                bytestream2_seek_p(&pb, offset, SEEK_SET);

                for (VAR_9 = 0; VAR_9 < cnt; VAR_9++) {

                    data = bytestream2_get_be16(&dgb);

                    bytestream2_put_be16(&pb, data);

                    bytestream2_skip_p(&pb, VAR_11 - 2);

                }

            }

        }

    }

}

static void FUNC_0(uint8_t *VAR_0,
const uint8_t *VAR_1, const uint8_t *VAR_2,
int VAR_3, int VAR_4, int VAR_5, int VAR_6)
{ GetByteContext off0, off1, dgb, ogb; PutByteContext pb; unsigned VAR_7, VAR_8; int VAR_9, VAR_10, VAR_11; int VAR_12 = (VAR_3 + 7) / 8; int VAR_13 = ((VAR_3 + 15) / 16) * 2; int VAR_14 = VAR_13 * VAR_5; if (VAR_2 - VAR_1 <= 64)
return; bytestream2_init(&off0, VAR_1, VAR_2 - VAR_1); bytestream2_init(&off1, VAR_1 + 32, VAR_2 - (VAR_1 + 32)); bytestream2_init_writer(&pb, VAR_0, VAR_6); VAR_11 = VAR_4 ? (((VAR_3 + 7) / 8) * VAR_5): 2; for (VAR_10 = 0; VAR_10 < VAR_5; VAR_10++) { VAR_7 = bytestream2_get_be32(&off0); VAR_8 = bytestream2_get_be32(&off1); if (!VAR_7)
continue; if (2LL * VAR_7 >= VAR_2 - VAR_1)
return; if (2LL * VAR_8 >= VAR_2 - VAR_1)
return; bytestream2_init(&dgb, VAR_1 + 2 * VAR_7, VAR_2 - (VAR_1 + 2 * VAR_7)); bytestream2_init(&ogb, VAR_1 + 2 * VAR_8, VAR_2 - (VAR_1 + 2 * VAR_8)); while ((bytestream2_peek_be16(&ogb)) != 0xFFFF) { uint32_t offset = bytestream2_get_be16(&ogb); int16_t cnt = bytestream2_get_be16(&ogb); uint16_t data; offset = ((2 * offset) / VAR_12) * VAR_14 + ((2 * offset) % VAR_12) + VAR_10 * VAR_13; if (cnt < 0) { bytestream2_seek_p(&pb, offset, SEEK_SET); cnt = -cnt; data = bytestream2_get_be16(&dgb); for (VAR_9 = 0; VAR_9 < cnt; VAR_9++) { bytestream2_put_be16(&pb, data); bytestream2_skip_p(&pb, VAR_11 - 2); } } else { bytestream2_seek_p(&pb, offset, SEEK_SET); for (VAR_9 = 0; VAR_9 < cnt; VAR_9++) { data = bytestream2_get_be16(&dgb); bytestream2_put_be16(&pb, data); bytestream2_skip_p(&pb, VAR_11 - 2); } } } } }