static int deband_16_coupling_c(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)

{

    DebandContext *s = ctx->priv;

    ThreadData *td = arg;

    AVFrame *in = td->in;

    AVFrame *out = td->out;

    const int start = (s->planeheight[0] *  jobnr   ) / nb_jobs;

    const int end   = (s->planeheight[0] * (jobnr+1)) / nb_jobs;

    int x, y, p, z;



    for (y = start; y < end; y++) {

        const int pos = y * s->planewidth[0];



        for (x = 0; x < s->planewidth[p]; x++) {

            const int x_pos = s->x_pos[pos + x];

            const int y_pos = s->y_pos[pos + x];

            int avg[4], cmp[4] = { 0 }, src[4];



            for (p = 0; p < s->nb_components; p++) {

                const uint16_t *src_ptr = (const uint16_t *)in->data[p];

                const int src_linesize = in->linesize[p] / 2;

                const int thr = s->thr[p];

                const int w = s->planewidth[p] - 1;

                const int h = s->planeheight[p] - 1;

                const int ref0 = src_ptr[av_clip(y +  y_pos, 0, h) * src_linesize + av_clip(x +  x_pos, 0, w)];

                const int ref1 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x +  x_pos, 0, w)];

                const int ref2 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)];

                const int ref3 = src_ptr[av_clip(y +  y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)];

                const int src0 = src_ptr[y * src_linesize + x];



                src[p] = src0;

                avg[p] = get_avg(ref0, ref1, ref2, ref3);



                if (s->blur) {

                    cmp[p] = FFABS(src0 - avg[p]) < thr;

                } else {

                    cmp[p] = (FFABS(src0 - ref0) < thr) &&

                             (FFABS(src0 - ref1) < thr) &&

                             (FFABS(src0 - ref2) < thr) &&

                             (FFABS(src0 - ref3) < thr);

                }

            }



            for (z = 0; z < s->nb_components; z++)

                if (!cmp[z])

                    break;

            if (z == s->nb_components) {

                for (p = 0; p < s->nb_components; p++) {

                    const int dst_linesize = out->linesize[p] / 2;

                    uint16_t *dst = (uint16_t *)out->data[p] + y * dst_linesize + x;



                    dst[0] = avg[p];

                }

            } else {

                for (p = 0; p < s->nb_components; p++) {

                    const int dst_linesize = out->linesize[p] / 2;

                    uint16_t *dst = (uint16_t *)out->data[p] + y * dst_linesize + x;



                    dst[0] = src[p];

                }

            }

        }

    }



    return 0;

}

static int deband_16_coupling_c(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)

{

    DebandContext *s = ctx->priv;

    ThreadData *td = arg;

    AVFrame *in = td->in;

    AVFrame *out = td->out;

    const int start = (s->planeheight[0] *  jobnr   ) / nb_jobs;

    const int end   = (s->planeheight[0] * (jobnr+1)) / nb_jobs;

    int x, y, p, z;



    for (y = start; y < end; y++) {

        const int pos = y * s->planewidth[0];



        for (x = 0; x < s->planewidth[p]; x++) {

            const int x_pos = s->x_pos[pos + x];

            const int y_pos = s->y_pos[pos + x];

            int avg[4], cmp[4] = { 0 }, src[4];



            for (p = 0; p < s->nb_components; p++) {

                const uint16_t *src_ptr = (const uint16_t *)in->data[p];

                const int src_linesize = in->linesize[p] / 2;

                const int thr = s->thr[p];

                const int w = s->planewidth[p] - 1;

                const int h = s->planeheight[p] - 1;

                const int ref0 = src_ptr[av_clip(y +  y_pos, 0, h) * src_linesize + av_clip(x +  x_pos, 0, w)];

                const int ref1 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x +  x_pos, 0, w)];

                const int ref2 = src_ptr[av_clip(y + -y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)];

                const int ref3 = src_ptr[av_clip(y +  y_pos, 0, h) * src_linesize + av_clip(x + -x_pos, 0, w)];

                const int src0 = src_ptr[y * src_linesize + x];



                src[p] = src0;

                avg[p] = get_avg(ref0, ref1, ref2, ref3);



                if (s->blur) {

                    cmp[p] = FFABS(src0 - avg[p]) < thr;

                } else {

                    cmp[p] = (FFABS(src0 - ref0) < thr) &&

                             (FFABS(src0 - ref1) < thr) &&

                             (FFABS(src0 - ref2) < thr) &&

                             (FFABS(src0 - ref3) < thr);

                }

            }



            for (z = 0; z < s->nb_components; z++)

                if (!cmp[z])

                    break;

            if (z == s->nb_components) {

                for (p = 0; p < s->nb_components; p++) {

                    const int dst_linesize = out->linesize[p] / 2;

                    uint16_t *dst = (uint16_t *)out->data[p] + y * dst_linesize + x;



                    dst[0] = avg[p];

                }

            } else {

                for (p = 0; p < s->nb_components; p++) {

                    const int dst_linesize = out->linesize[p] / 2;

                    uint16_t *dst = (uint16_t *)out->data[p] + y * dst_linesize + x;



                    dst[0] = src[p];

                }

            }

        }

    }



    return 0;

}

        for (x = 0; x < s->planewidth[p]; x++) {         for (x = 0; x < s->planewidth[p]; x++) {
static int FUNC_0(AVFilterContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)

{

    DebandContext *s = VAR_0->priv;

    ThreadData *td = VAR_1;

    AVFrame *in = td->in;

    AVFrame *out = td->out;

    const int VAR_4 = (s->planeheight[0] *  VAR_2   ) / VAR_3;

    const int VAR_5   = (s->planeheight[0] * (VAR_2+1)) / VAR_3;

    int VAR_6, VAR_7, VAR_8, VAR_9;



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

        const int VAR_10 = VAR_7 * s->planewidth[0];



        for (VAR_6 = 0; VAR_6 < s->planewidth[VAR_8]; VAR_6++) {

            const int x_pos = s->x_pos[VAR_10 + VAR_6];

            const int y_pos = s->y_pos[VAR_10 + VAR_6];

            int avg[4], cmp[4] = { 0 }, src[4];



            for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) {

                const uint16_t *src_ptr = (const uint16_t *)in->data[VAR_8];

                const int src_linesize = in->linesize[VAR_8] / 2;

                const int thr = s->thr[VAR_8];

                const int w = s->planewidth[VAR_8] - 1;

                const int h = s->planeheight[VAR_8] - 1;

                const int ref0 = src_ptr[av_clip(VAR_7 +  y_pos, 0, h) * src_linesize + av_clip(VAR_6 +  x_pos, 0, w)];

                const int ref1 = src_ptr[av_clip(VAR_7 + -y_pos, 0, h) * src_linesize + av_clip(VAR_6 +  x_pos, 0, w)];

                const int ref2 = src_ptr[av_clip(VAR_7 + -y_pos, 0, h) * src_linesize + av_clip(VAR_6 + -x_pos, 0, w)];

                const int ref3 = src_ptr[av_clip(VAR_7 +  y_pos, 0, h) * src_linesize + av_clip(VAR_6 + -x_pos, 0, w)];

                const int src0 = src_ptr[VAR_7 * src_linesize + VAR_6];



                src[VAR_8] = src0;

                avg[VAR_8] = get_avg(ref0, ref1, ref2, ref3);



                if (s->blur) {

                    cmp[VAR_8] = FFABS(src0 - avg[VAR_8]) < thr;

                } else {

                    cmp[VAR_8] = (FFABS(src0 - ref0) < thr) &&

                             (FFABS(src0 - ref1) < thr) &&

                             (FFABS(src0 - ref2) < thr) &&

                             (FFABS(src0 - ref3) < thr);

                }

            }



            for (VAR_9 = 0; VAR_9 < s->nb_components; VAR_9++)

                if (!cmp[VAR_9])

                    break;

            if (VAR_9 == s->nb_components) {

                for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) {

                    const int dst_linesize = out->linesize[VAR_8] / 2;

                    uint16_t *dst = (uint16_t *)out->data[VAR_8] + VAR_7 * dst_linesize + VAR_6;



                    dst[0] = avg[VAR_8];

                }

            } else {

                for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) {

                    const int dst_linesize = out->linesize[VAR_8] / 2;

                    uint16_t *dst = (uint16_t *)out->data[VAR_8] + VAR_7 * dst_linesize + VAR_6;



                    dst[0] = src[VAR_8];

                }

            }

        }

    }



    return 0;

}

static int FUNC_0(AVFilterContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)
{ DebandContext *s = VAR_0->priv; ThreadData *td = VAR_1; AVFrame *in = td->in; AVFrame *out = td->out; const int VAR_4 = (s->planeheight[0] *  VAR_2   ) / VAR_3; const int VAR_5   = (s->planeheight[0] * (VAR_2+1)) / VAR_3; int VAR_6, VAR_7, VAR_8, VAR_9; for (VAR_7 = VAR_4; VAR_7 < VAR_5; VAR_7++) { const int VAR_10 = VAR_7 * s->planewidth[0]; for (VAR_6 = 0; VAR_6 < s->planewidth[VAR_8]; VAR_6++) { const int x_pos = s->x_pos[VAR_10 + VAR_6]; const int y_pos = s->y_pos[VAR_10 + VAR_6]; int avg[4], cmp[4] = { 0 }, src[4]; for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) { const uint16_t *src_ptr = (const uint16_t *)in->data[VAR_8]; const int src_linesize = in->linesize[VAR_8] / 2; const int thr = s->thr[VAR_8]; const int w = s->planewidth[VAR_8] - 1; const int h = s->planeheight[VAR_8] - 1; const int ref0 = src_ptr[av_clip(VAR_7 +  y_pos, 0, h) * src_linesize + av_clip(VAR_6 +  x_pos, 0, w)]; const int ref1 = src_ptr[av_clip(VAR_7 + -y_pos, 0, h) * src_linesize + av_clip(VAR_6 +  x_pos, 0, w)]; const int ref2 = src_ptr[av_clip(VAR_7 + -y_pos, 0, h) * src_linesize + av_clip(VAR_6 + -x_pos, 0, w)]; const int ref3 = src_ptr[av_clip(VAR_7 +  y_pos, 0, h) * src_linesize + av_clip(VAR_6 + -x_pos, 0, w)]; const int src0 = src_ptr[VAR_7 * src_linesize + VAR_6]; src[VAR_8] = src0; avg[VAR_8] = get_avg(ref0, ref1, ref2, ref3); if (s->blur) { cmp[VAR_8] = FFABS(src0 - avg[VAR_8]) < thr; } else { cmp[VAR_8] = (FFABS(src0 - ref0) < thr) &&
(FFABS(src0 - ref1) < thr) &&
(FFABS(src0 - ref2) < thr) &&
(FFABS(src0 - ref3) < thr); } } for (VAR_9 = 0; VAR_9 < s->nb_components; VAR_9++) if (!cmp[VAR_9])
break; if (VAR_9 == s->nb_components) { for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) { const int dst_linesize = out->linesize[VAR_8] / 2; uint16_t *dst = (uint16_t *)out->data[VAR_8] + VAR_7 * dst_linesize + VAR_6; dst[0] = avg[VAR_8]; } } else { for (VAR_8 = 0; VAR_8 < s->nb_components; VAR_8++) { const int dst_linesize = out->linesize[VAR_8] / 2; uint16_t *dst = (uint16_t *)out->data[VAR_8] + VAR_7 * dst_linesize + VAR_6; dst[0] = src[VAR_8]; } } } } return 0; }