+ s->filter = s->depth > 8 ? inflate16 : inflate;
+
+ return 0;
+}
+
+static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
+{
+ NContext *s = ctx->priv;
+ ThreadData *td = arg;
+ AVFrame *out = td->out;
+ AVFrame *in = td->in;
+ int plane, y;
+
+ for (plane = 0; plane < s->nb_planes; plane++) {
+ const int bpc = s->bpc;
+ const int threshold = s->threshold[plane];
+ const int stride = in->linesize[plane];
+ const int dstride = out->linesize[plane];
+ const int height = s->planeheight[plane];
+ const int width = s->planewidth[plane];
+ const int slice_start = (height * jobnr) / nb_jobs;
+ const int slice_end = (height * (jobnr+1)) / nb_jobs;
+ const uint8_t *src = (const uint8_t *)in->data[plane] + slice_start * stride;
+ uint8_t *dst = out->data[plane] + slice_start * dstride;
+
+ if (!threshold) {
+ av_image_copy_plane(dst, dstride, src, stride, width * bpc, slice_end - slice_start);
+ continue;
+ }
+
+ for (y = slice_start; y < slice_end; y++) {
+ const int nh = y > 0;
+ const int ph = y < height - 1;
+ const uint8_t *coordinates[] = { src - nh * stride, src + 1 * bpc - nh * stride, src + 2 * bpc - nh * stride,
+ src, src + 2 * bpc,
+ src + ph * stride, src + 1 * bpc + ph * stride, src + 2 * bpc + ph * stride};
+
+ const uint8_t *coordinateslb[] = { src + 1 * bpc - nh * stride, src - nh * stride, src + 1 * bpc - nh * stride,
+ src + 1 * bpc, src + 1 * bpc,
+ src + 1 * bpc + ph * stride, src + ph * stride, src + 1 * bpc + ph * stride};
+
+ const uint8_t *coordinatesrb[] = { src + (width - 2) * bpc - nh * stride, src + (width - 1) * bpc - nh * stride, src + (width - 2) * bpc - nh * stride,
+ src + (width - 2) * bpc, src + (width - 2) * bpc,
+ src + (width - 2) * bpc + ph * stride, src + (width - 1) * bpc + ph * stride, src + (width - 2) * bpc + ph * stride};
+
+ s->filter(dst, src, 1, threshold, coordinateslb, s->coordinates);
+ s->filter(dst + 1 * bpc, src + 1 * bpc, width - 2, threshold, coordinates, s->coordinates);
+ s->filter(dst + (width - 1) * bpc, src + (width - 1) * bpc, 1, threshold, coordinatesrb, s->coordinates);
+
+ src += stride;
+ dst += dstride;
+ }
+ }