static void apply_unsharp(      uint8_t *dst, int dst_stride,

                          const uint8_t *src, int src_stride,

                          int width, int height, FilterParam *fp)

{

    uint32_t **sc = fp->sc;

    uint32_t sr[(MAX_SIZE * MAX_SIZE) - 1], tmp1, tmp2;



    int32_t res;

    int x, y, z;

    const uint8_t *src2;



    if (!fp->amount) {

        if (dst_stride == src_stride)

            memcpy(dst, src, src_stride * height);

        else

            for (y = 0; y < height; y++, dst += dst_stride, src += src_stride)

                memcpy(dst, src, width);

        return;

    }



    for (y = 0; y < 2 * fp->steps_y; y++)

        memset(sc[y], 0, sizeof(sc[y][0]) * (width + 2 * fp->steps_x));



    for (y = -fp->steps_y; y < height + fp->steps_y; y++) {

        if (y < height)

            src2 = src;



        memset(sr, 0, sizeof(sr[0]) * (2 * fp->steps_x - 1));

        for (x = -fp->steps_x; x < width + fp->steps_x; x++) {

            tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x];

            for (z = 0; z < fp->steps_x * 2; z += 2) {

                tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1;

                tmp1 = sr[z + 1] + tmp2; sr[z + 1] = tmp2;

            }

            for (z = 0; z < fp->steps_y * 2; z += 2) {

                tmp2 = sc[z + 0][x + fp->steps_x] + tmp1; sc[z + 0][x + fp->steps_x] = tmp1;

                tmp1 = sc[z + 1][x + fp->steps_x] + tmp2; sc[z + 1][x + fp->steps_x] = tmp2;

            }

            if (x >= fp->steps_x && y >= fp->steps_y) {

                const uint8_t *srx = src - fp->steps_y * src_stride + x - fp->steps_x;

                uint8_t       *dsx = dst - fp->steps_y * dst_stride + x - fp->steps_x;



                res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + fp->halfscale) >> fp->scalebits)) * fp->amount) >> 16);

                *dsx = av_clip_uint8(res);

            }

        }

        if (y >= 0) {

            dst += dst_stride;

            src += src_stride;

        }

    }

}

static void apply_unsharp(      uint8_t *dst, int dst_stride,

                          const uint8_t *src, int src_stride,

                          int width, int height, FilterParam *fp)

{

    uint32_t **sc = fp->sc;

    uint32_t sr[(MAX_SIZE * MAX_SIZE) - 1], tmp1, tmp2;



    int32_t res;

    int x, y, z;

    const uint8_t *src2;



    if (!fp->amount) {

        if (dst_stride == src_stride)

            memcpy(dst, src, src_stride * height);

        else

            for (y = 0; y < height; y++, dst += dst_stride, src += src_stride)

                memcpy(dst, src, width);

        return;

    }



    for (y = 0; y < 2 * fp->steps_y; y++)

        memset(sc[y], 0, sizeof(sc[y][0]) * (width + 2 * fp->steps_x));



    for (y = -fp->steps_y; y < height + fp->steps_y; y++) {

        if (y < height)

            src2 = src;



        memset(sr, 0, sizeof(sr[0]) * (2 * fp->steps_x - 1));

        for (x = -fp->steps_x; x < width + fp->steps_x; x++) {

            tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x];

            for (z = 0; z < fp->steps_x * 2; z += 2) {

                tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1;

                tmp1 = sr[z + 1] + tmp2; sr[z + 1] = tmp2;

            }

            for (z = 0; z < fp->steps_y * 2; z += 2) {

                tmp2 = sc[z + 0][x + fp->steps_x] + tmp1; sc[z + 0][x + fp->steps_x] = tmp1;

                tmp1 = sc[z + 1][x + fp->steps_x] + tmp2; sc[z + 1][x + fp->steps_x] = tmp2;

            }

            if (x >= fp->steps_x && y >= fp->steps_y) {

                const uint8_t *srx = src - fp->steps_y * src_stride + x - fp->steps_x;

                uint8_t       *dsx = dst - fp->steps_y * dst_stride + x - fp->steps_x;



                res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + fp->halfscale) >> fp->scalebits)) * fp->amount) >> 16);

                *dsx = av_clip_uint8(res);

            }

        }

        if (y >= 0) {

            dst += dst_stride;

            src += src_stride;

        }

    }

}

    const uint8_t *src2;
static void FUNC_0(      uint8_t *VAR_0, int VAR_1,

                          const uint8_t *VAR_2, int VAR_3,

                          int VAR_4, int VAR_5, FilterParam *VAR_6)

{

    uint32_t **sc = VAR_6->sc;

    uint32_t sr[(MAX_SIZE * MAX_SIZE) - 1], tmp1, tmp2;



    int32_t res;

    int VAR_7, VAR_8, VAR_9;

    const uint8_t *VAR_10;



    if (!VAR_6->amount) {

        if (VAR_1 == VAR_3)

            memcpy(VAR_0, VAR_2, VAR_3 * VAR_5);

        else

            for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++, VAR_0 += VAR_1, VAR_2 += VAR_3)

                memcpy(VAR_0, VAR_2, VAR_4);

        return;

    }



    for (VAR_8 = 0; VAR_8 < 2 * VAR_6->steps_y; VAR_8++)

        memset(sc[VAR_8], 0, sizeof(sc[VAR_8][0]) * (VAR_4 + 2 * VAR_6->steps_x));



    for (VAR_8 = -VAR_6->steps_y; VAR_8 < VAR_5 + VAR_6->steps_y; VAR_8++) {

        if (VAR_8 < VAR_5)

            VAR_10 = VAR_2;



        memset(sr, 0, sizeof(sr[0]) * (2 * VAR_6->steps_x - 1));

        for (VAR_7 = -VAR_6->steps_x; VAR_7 < VAR_4 + VAR_6->steps_x; VAR_7++) {

            tmp1 = VAR_7 <= 0 ? VAR_10[0] : VAR_7 >= VAR_4 ? VAR_10[VAR_4-1] : VAR_10[VAR_7];

            for (VAR_9 = 0; VAR_9 < VAR_6->steps_x * 2; VAR_9 += 2) {

                tmp2 = sr[VAR_9 + 0] + tmp1; sr[VAR_9 + 0] = tmp1;

                tmp1 = sr[VAR_9 + 1] + tmp2; sr[VAR_9 + 1] = tmp2;

            }

            for (VAR_9 = 0; VAR_9 < VAR_6->steps_y * 2; VAR_9 += 2) {

                tmp2 = sc[VAR_9 + 0][VAR_7 + VAR_6->steps_x] + tmp1; sc[VAR_9 + 0][VAR_7 + VAR_6->steps_x] = tmp1;

                tmp1 = sc[VAR_9 + 1][VAR_7 + VAR_6->steps_x] + tmp2; sc[VAR_9 + 1][VAR_7 + VAR_6->steps_x] = tmp2;

            }

            if (VAR_7 >= VAR_6->steps_x && VAR_8 >= VAR_6->steps_y) {

                const uint8_t *srx = VAR_2 - VAR_6->steps_y * VAR_3 + VAR_7 - VAR_6->steps_x;

                uint8_t       *dsx = VAR_0 - VAR_6->steps_y * VAR_1 + VAR_7 - VAR_6->steps_x;



                res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + VAR_6->halfscale) >> VAR_6->scalebits)) * VAR_6->amount) >> 16);

                *dsx = av_clip_uint8(res);

            }

        }

        if (VAR_8 >= 0) {

            VAR_0 += VAR_1;

            VAR_2 += VAR_3;

        }

    }

}

static void FUNC_0(      uint8_t *VAR_0, int VAR_1,
const uint8_t *VAR_2, int VAR_3,
int VAR_4, int VAR_5, FilterParam *VAR_6)
{ uint32_t **sc = VAR_6->sc; uint32_t sr[(MAX_SIZE * MAX_SIZE) - 1], tmp1, tmp2; int32_t res; int VAR_7, VAR_8, VAR_9; const uint8_t *VAR_10; if (!VAR_6->amount) { if (VAR_1 == VAR_3)
memcpy(VAR_0, VAR_2, VAR_3 * VAR_5); else
for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++, VAR_0 += VAR_1, VAR_2 += VAR_3) memcpy(VAR_0, VAR_2, VAR_4); return; } for (VAR_8 = 0; VAR_8 < 2 * VAR_6->steps_y; VAR_8++) memset(sc[VAR_8], 0, sizeof(sc[VAR_8][0]) * (VAR_4 + 2 * VAR_6->steps_x)); for (VAR_8 = -VAR_6->steps_y; VAR_8 < VAR_5 + VAR_6->steps_y; VAR_8++) { if (VAR_8 < VAR_5)
VAR_10 = VAR_2; memset(sr, 0, sizeof(sr[0]) * (2 * VAR_6->steps_x - 1)); for (VAR_7 = -VAR_6->steps_x; VAR_7 < VAR_4 + VAR_6->steps_x; VAR_7++) { tmp1 = VAR_7 <= 0 ? VAR_10[0] : VAR_7 >= VAR_4 ? VAR_10[VAR_4-1] : VAR_10[VAR_7]; for (VAR_9 = 0; VAR_9 < VAR_6->steps_x * 2; VAR_9 += 2) { tmp2 = sr[VAR_9 + 0] + tmp1; sr[VAR_9 + 0] = tmp1; tmp1 = sr[VAR_9 + 1] + tmp2; sr[VAR_9 + 1] = tmp2; } for (VAR_9 = 0; VAR_9 < VAR_6->steps_y * 2; VAR_9 += 2) { tmp2 = sc[VAR_9 + 0][VAR_7 + VAR_6->steps_x] + tmp1; sc[VAR_9 + 0][VAR_7 + VAR_6->steps_x] = tmp1; tmp1 = sc[VAR_9 + 1][VAR_7 + VAR_6->steps_x] + tmp2; sc[VAR_9 + 1][VAR_7 + VAR_6->steps_x] = tmp2; } if (VAR_7 >= VAR_6->steps_x && VAR_8 >= VAR_6->steps_y) { const uint8_t *srx = VAR_2 - VAR_6->steps_y * VAR_3 + VAR_7 - VAR_6->steps_x; uint8_t       *dsx = VAR_0 - VAR_6->steps_y * VAR_1 + VAR_7 - VAR_6->steps_x; res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + VAR_6->halfscale) >> VAR_6->scalebits)) * VAR_6->amount) >> 16); *dsx = av_clip_uint8(res); } } if (VAR_8 >= 0) { VAR_0 += VAR_1; VAR_2 += VAR_3; } } }