static void blur(uint8_t       *dst, const int dst_linesize,

                 const uint8_t *src, const int src_linesize,

                 const int w, const int h, FilterParam *fp)

{

    int x, y;

    FilterParam f = *fp;

    const int radius = f.dist_width/2;



    const uint8_t * const src2[NB_PLANES] = { src };

    int          src2_linesize[NB_PLANES] = { src_linesize };

    uint8_t     *dst2[NB_PLANES] = { f.pre_filter_buf };

    int dst2_linesize[NB_PLANES] = { f.pre_filter_linesize };



    sws_scale(f.pre_filter_context, src2, src2_linesize, 0, h, dst2, dst2_linesize);



#define UPDATE_FACTOR do {                                              \

        int factor;                                                     \

        factor = f.color_diff_coeff[COLOR_DIFF_COEFF_SIZE/2 + pre_val - \

                 f.pre_filter_buf[ix + iy*f.pre_filter_linesize]] * f.dist_coeff[dx + dy*f.dist_linesize]; \

        sum += src[ix + iy*src_linesize] * factor;                      \

        div += factor;                                                  \

    } while (0)



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

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

            int sum = 0;

            int div = 0;

            int dy;

            const int pre_val = f.pre_filter_buf[x + y*f.pre_filter_linesize];

            if (x >= radius && x < w - radius) {

                for (dy = 0; dy < radius*2 + 1; dy++) {

                    int dx;

                    int iy = y+dy - radius;

                    if      (iy < 0)  iy = -iy;

                    else if (iy >= h) iy = h+h-iy-1;



                    for (dx = 0; dx < radius*2 + 1; dx++) {

                        const int ix = x+dx - radius;

                        UPDATE_FACTOR;

                    }

                }

            } else {

                for (dy = 0; dy < radius*2+1; dy++) {

                    int dx;

                    int iy = y+dy - radius;

                    if      (iy <  0) iy = -iy;

                    else if (iy >= h) iy = h+h-iy-1;



                    for (dx = 0; dx < radius*2 + 1; dx++) {

                        int ix = x+dx - radius;

                        if      (ix < 0)  ix = -ix;

                        else if (ix >= w) ix = w+w-ix-1;

                        UPDATE_FACTOR;

                    }

                }

            }

            dst[x + y*dst_linesize] = (sum + div/2) / div;

        }

    }

}

static void blur(uint8_t       *dst, const int dst_linesize,

                 const uint8_t *src, const int src_linesize,

                 const int w, const int h, FilterParam *fp)

{

    int x, y;

    FilterParam f = *fp;

    const int radius = f.dist_width/2;



    const uint8_t * const src2[NB_PLANES] = { src };

    int          src2_linesize[NB_PLANES] = { src_linesize };

    uint8_t     *dst2[NB_PLANES] = { f.pre_filter_buf };

    int dst2_linesize[NB_PLANES] = { f.pre_filter_linesize };



    sws_scale(f.pre_filter_context, src2, src2_linesize, 0, h, dst2, dst2_linesize);



#define UPDATE_FACTOR do {                                              \

        int factor;                                                     \

        factor = f.color_diff_coeff[COLOR_DIFF_COEFF_SIZE/2 + pre_val - \

                 f.pre_filter_buf[ix + iy*f.pre_filter_linesize]] * f.dist_coeff[dx + dy*f.dist_linesize]; \

        sum += src[ix + iy*src_linesize] * factor;                      \

        div += factor;                                                  \

    } while (0)



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

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

            int sum = 0;

            int div = 0;

            int dy;

            const int pre_val = f.pre_filter_buf[x + y*f.pre_filter_linesize];

            if (x >= radius && x < w - radius) {

                for (dy = 0; dy < radius*2 + 1; dy++) {

                    int dx;

                    int iy = y+dy - radius;

                    if      (iy < 0)  iy = -iy;

                    else if (iy >= h) iy = h+h-iy-1;



                    for (dx = 0; dx < radius*2 + 1; dx++) {

                        const int ix = x+dx - radius;

                        UPDATE_FACTOR;

                    }

                }

            } else {

                for (dy = 0; dy < radius*2+1; dy++) {

                    int dx;

                    int iy = y+dy - radius;

                    if      (iy <  0) iy = -iy;

                    else if (iy >= h) iy = h+h-iy-1;



                    for (dx = 0; dx < radius*2 + 1; dx++) {

                        int ix = x+dx - radius;

                        if      (ix < 0)  ix = -ix;

                        else if (ix >= w) ix = w+w-ix-1;

                        UPDATE_FACTOR;

                    }

                }

            }

            dst[x + y*dst_linesize] = (sum + div/2) / div;

        }

    }

}

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

                 const uint8_t *VAR_2, const int VAR_3,

                 const int VAR_4, const int VAR_5, FilterParam *VAR_6)

{

    int VAR_7, VAR_8;

    FilterParam f = *VAR_6;

    const int VAR_9 = f.dist_width/2;



    const uint8_t * const VAR_10[NB_PLANES] = { VAR_2 };

    int          VAR_11[NB_PLANES] = { VAR_3 };

    uint8_t     *dst2[NB_PLANES] = { f.pre_filter_buf };

    int VAR_12[NB_PLANES] = { f.pre_filter_linesize };



    sws_scale(f.pre_filter_context, VAR_10, VAR_11, 0, VAR_5, dst2, VAR_12);



#define UPDATE_FACTOR do {                                              \

        int VAR_13;                                                     \

        VAR_13 = f.color_diff_coeff[COLOR_DIFF_COEFF_SIZE/2 + pre_val - \

                 f.pre_filter_buf[ix + iy*f.pre_filter_linesize]] * f.dist_coeff[dx + dy*f.dist_linesize]; \

        sum += VAR_2[ix + iy*VAR_3] * VAR_13;                      \

        div += VAR_13;                                                  \

    } while (0)



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

        for (VAR_7 = 0; VAR_7 < VAR_4; VAR_7++) {

            int sum = 0;

            int div = 0;

            int dy;

            const int pre_val = f.pre_filter_buf[VAR_7 + VAR_8*f.pre_filter_linesize];

            if (VAR_7 >= VAR_9 && VAR_7 < VAR_4 - VAR_9) {

                for (dy = 0; dy < VAR_9*2 + 1; dy++) {

                    int dx;

                    int iy = VAR_8+dy - VAR_9;

                    if      (iy < 0)  iy = -iy;

                    else if (iy >= VAR_5) iy = VAR_5+VAR_5-iy-1;



                    for (dx = 0; dx < VAR_9*2 + 1; dx++) {

                        const int ix = VAR_7+dx - VAR_9;

                        UPDATE_FACTOR;

                    }

                }

            } else {

                for (dy = 0; dy < VAR_9*2+1; dy++) {

                    int dx;

                    int iy = VAR_8+dy - VAR_9;

                    if      (iy <  0) iy = -iy;

                    else if (iy >= VAR_5) iy = VAR_5+VAR_5-iy-1;



                    for (dx = 0; dx < VAR_9*2 + 1; dx++) {

                        int ix = VAR_7+dx - VAR_9;

                        if      (ix < 0)  ix = -ix;

                        else if (ix >= VAR_4) ix = VAR_4+VAR_4-ix-1;

                        UPDATE_FACTOR;

                    }

                }

            }

            VAR_0[VAR_7 + VAR_8*VAR_1] = (sum + div/2) / div;

        }

    }

}

static void FUNC_0(uint8_t       *VAR_0, const int VAR_1,
const uint8_t *VAR_2, const int VAR_3,
const int VAR_4, const int VAR_5, FilterParam *VAR_6)
{ int VAR_7, VAR_8; FilterParam f = *VAR_6; const int VAR_9 = f.dist_width/2; const uint8_t * const VAR_10[NB_PLANES] = { VAR_2 }; int          VAR_11[NB_PLANES] = { VAR_3 }; uint8_t     *dst2[NB_PLANES] = { f.pre_filter_buf }; int VAR_12[NB_PLANES] = { f.pre_filter_linesize }; sws_scale(f.pre_filter_context, VAR_10, VAR_11, 0, VAR_5, dst2, VAR_12); #define UPDATE_FACTOR do {                                              \ int VAR_13;                                                     \ VAR_13 = f.color_diff_coeff[COLOR_DIFF_COEFF_SIZE/2 + pre_val - \
f.pre_filter_buf[ix + iy*f.pre_filter_linesize]] * f.dist_coeff[dx + dy*f.dist_linesize]; \ sum += VAR_2[ix + iy*VAR_3] * VAR_13;                      \ div += VAR_13;                                                  \ } while (0) for (VAR_8 = 0; VAR_8 < VAR_5; VAR_8++) { for (VAR_7 = 0; VAR_7 < VAR_4; VAR_7++) { int sum = 0; int div = 0; int dy; const int pre_val = f.pre_filter_buf[VAR_7 + VAR_8*f.pre_filter_linesize]; if (VAR_7 >= VAR_9 && VAR_7 < VAR_4 - VAR_9) { for (dy = 0; dy < VAR_9*2 + 1; dy++) { int dx; int iy = VAR_8+dy - VAR_9; if      (iy < 0)  iy = -iy; else if (iy >= VAR_5) iy = VAR_5+VAR_5-iy-1; for (dx = 0; dx < VAR_9*2 + 1; dx++) { const int ix = VAR_7+dx - VAR_9; UPDATE_FACTOR; } } } else { for (dy = 0; dy < VAR_9*2+1; dy++) { int dx; int iy = VAR_8+dy - VAR_9; if      (iy <  0) iy = -iy; else if (iy >= VAR_5) iy = VAR_5+VAR_5-iy-1; for (dx = 0; dx < VAR_9*2 + 1; dx++) { int ix = VAR_7+dx - VAR_9; if      (ix < 0)  ix = -ix; else if (ix >= VAR_4) ix = VAR_4+VAR_4-ix-1; UPDATE_FACTOR; } } } VAR_0[VAR_7 + VAR_8*VAR_1] = (sum + div/2) / div; } } }