tight_filter_gradient24(VncState *vs, uint8_t *buf, int w, int h)

{

    uint32_t *buf32;

    uint32_t pix32;

    int shift[3];

    int *prev;

    int here[3], upper[3], left[3], upperleft[3];

    int prediction;

    int x, y, c;



    buf32 = (uint32_t *)buf;

    memset(vs->tight_gradient.buffer, 0, w * 3 * sizeof(int));



    if ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) ==

        (vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)) {

        shift[0] = vs->clientds.pf.rshift;

        shift[1] = vs->clientds.pf.gshift;

        shift[2] = vs->clientds.pf.bshift;

    } else {

        shift[0] = 24 - vs->clientds.pf.rshift;

        shift[1] = 24 - vs->clientds.pf.gshift;

        shift[2] = 24 - vs->clientds.pf.bshift;

    }



    for (y = 0; y < h; y++) {

        for (c = 0; c < 3; c++) {

            upper[c] = 0;

            here[c] = 0;

        }

        prev = (int *)vs->tight_gradient.buffer;

        for (x = 0; x < w; x++) {

            pix32 = *buf32++;

            for (c = 0; c < 3; c++) {

                upperleft[c] = upper[c];

                left[c] = here[c];

                upper[c] = *prev;

                here[c] = (int)(pix32 >> shift[c] & 0xFF);

                *prev++ = here[c];



                prediction = left[c] + upper[c] - upperleft[c];

                if (prediction < 0) {

                    prediction = 0;

                } else if (prediction > 0xFF) {

                    prediction = 0xFF;

                }

                *buf++ = (char)(here[c] - prediction);

            }

        }

    }

}

tight_filter_gradient24(VncState *vs, uint8_t *buf, int w, int h)

{

    uint32_t *buf32;

    uint32_t pix32;

    int shift[3];

    int *prev;

    int here[3], upper[3], left[3], upperleft[3];

    int prediction;

    int x, y, c;



    buf32 = (uint32_t *)buf;

    memset(vs->tight_gradient.buffer, 0, w * 3 * sizeof(int));



    if ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) ==

        (vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)) {

        shift[0] = vs->clientds.pf.rshift;

        shift[1] = vs->clientds.pf.gshift;

        shift[2] = vs->clientds.pf.bshift;

    } else {

        shift[0] = 24 - vs->clientds.pf.rshift;

        shift[1] = 24 - vs->clientds.pf.gshift;

        shift[2] = 24 - vs->clientds.pf.bshift;

    }



    for (y = 0; y < h; y++) {

        for (c = 0; c < 3; c++) {

            upper[c] = 0;

            here[c] = 0;

        }

        prev = (int *)vs->tight_gradient.buffer;

        for (x = 0; x < w; x++) {

            pix32 = *buf32++;

            for (c = 0; c < 3; c++) {

                upperleft[c] = upper[c];

                left[c] = here[c];

                upper[c] = *prev;

                here[c] = (int)(pix32 >> shift[c] & 0xFF);

                *prev++ = here[c];



                prediction = left[c] + upper[c] - upperleft[c];

                if (prediction < 0) {

                    prediction = 0;

                } else if (prediction > 0xFF) {

                    prediction = 0xFF;

                }

                *buf++ = (char)(here[c] - prediction);

            }

        }

    }

}

FUNC_0(VncState *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3)

{

    uint32_t *buf32;

    uint32_t pix32;

    int VAR_4[3];

    int *VAR_5;

    int VAR_6[3], VAR_7[3], VAR_8[3], VAR_9[3];

    int VAR_10;

    int VAR_11, VAR_12, VAR_13;



    buf32 = (uint32_t *)VAR_1;

    memset(VAR_0->tight_gradient.buffer, 0, VAR_2 * 3 * sizeof(int));



    if ((VAR_0->clientds.flags & QEMU_BIG_ENDIAN_FLAG) ==

        (VAR_0->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)) {

        VAR_4[0] = VAR_0->clientds.pf.rshift;

        VAR_4[1] = VAR_0->clientds.pf.gshift;

        VAR_4[2] = VAR_0->clientds.pf.bshift;

    } else {

        VAR_4[0] = 24 - VAR_0->clientds.pf.rshift;

        VAR_4[1] = 24 - VAR_0->clientds.pf.gshift;

        VAR_4[2] = 24 - VAR_0->clientds.pf.bshift;

    }



    for (VAR_12 = 0; VAR_12 < VAR_3; VAR_12++) {

        for (VAR_13 = 0; VAR_13 < 3; VAR_13++) {

            VAR_7[VAR_13] = 0;

            VAR_6[VAR_13] = 0;

        }

        VAR_5 = (int *)VAR_0->tight_gradient.buffer;

        for (VAR_11 = 0; VAR_11 < VAR_2; VAR_11++) {

            pix32 = *buf32++;

            for (VAR_13 = 0; VAR_13 < 3; VAR_13++) {

                VAR_9[VAR_13] = VAR_7[VAR_13];

                VAR_8[VAR_13] = VAR_6[VAR_13];

                VAR_7[VAR_13] = *VAR_5;

                VAR_6[VAR_13] = (int)(pix32 >> VAR_4[VAR_13] & 0xFF);

                *VAR_5++ = VAR_6[VAR_13];



                VAR_10 = VAR_8[VAR_13] + VAR_7[VAR_13] - VAR_9[VAR_13];

                if (VAR_10 < 0) {

                    VAR_10 = 0;

                } else if (VAR_10 > 0xFF) {

                    VAR_10 = 0xFF;

                }

                *VAR_1++ = (char)(VAR_6[VAR_13] - VAR_10);

            }

        }

    }

}

FUNC_0(VncState *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3)
{ uint32_t *buf32; uint32_t pix32; int VAR_4[3]; int *VAR_5; int VAR_6[3], VAR_7[3], VAR_8[3], VAR_9[3]; int VAR_10; int VAR_11, VAR_12, VAR_13; buf32 = (uint32_t *)VAR_1; memset(VAR_0->tight_gradient.buffer, 0, VAR_2 * 3 * sizeof(int)); if ((VAR_0->clientds.flags & QEMU_BIG_ENDIAN_FLAG) ==
(VAR_0->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)) { VAR_4[0] = VAR_0->clientds.pf.rshift; VAR_4[1] = VAR_0->clientds.pf.gshift; VAR_4[2] = VAR_0->clientds.pf.bshift; } else { VAR_4[0] = 24 - VAR_0->clientds.pf.rshift; VAR_4[1] = 24 - VAR_0->clientds.pf.gshift; VAR_4[2] = 24 - VAR_0->clientds.pf.bshift; } for (VAR_12 = 0; VAR_12 < VAR_3; VAR_12++) { for (VAR_13 = 0; VAR_13 < 3; VAR_13++) { VAR_7[VAR_13] = 0; VAR_6[VAR_13] = 0; } VAR_5 = (int *)VAR_0->tight_gradient.buffer; for (VAR_11 = 0; VAR_11 < VAR_2; VAR_11++) { pix32 = *buf32++; for (VAR_13 = 0; VAR_13 < 3; VAR_13++) { VAR_9[VAR_13] = VAR_7[VAR_13]; VAR_8[VAR_13] = VAR_6[VAR_13]; VAR_7[VAR_13] = *VAR_5; VAR_6[VAR_13] = (int)(pix32 >> VAR_4[VAR_13] & 0xFF); *VAR_5++ = VAR_6[VAR_13]; VAR_10 = VAR_8[VAR_13] + VAR_7[VAR_13] - VAR_9[VAR_13]; if (VAR_10 < 0) { VAR_10 = 0; } else if (VAR_10 > 0xFF) { VAR_10 = 0xFF; } *VAR_1++ = (char)(VAR_6[VAR_13] - VAR_10); } } } }