avfilter: make use of ff_filter_get_nb_threads
authorPaul B Mahol <onemda@gmail.com>
Sat, 27 Aug 2016 20:44:42 +0000 (22:44 +0200)
committerPaul B Mahol <onemda@gmail.com>
Mon, 29 Aug 2016 14:27:09 +0000 (16:27 +0200)
28 files changed:
Changelog
libavfilter/vf_atadenoise.c
libavfilter/vf_blend.c
libavfilter/vf_bwdif.c
libavfilter/vf_chromakey.c
libavfilter/vf_colorkey.c
libavfilter/vf_colormatrix.c
libavfilter/vf_colorspace.c
libavfilter/vf_curves.c
libavfilter/vf_datascope.c
libavfilter/vf_dctdnoiz.c
libavfilter/vf_deband.c
libavfilter/vf_fade.c
libavfilter/vf_hflip.c
libavfilter/vf_hqx.c
libavfilter/vf_lenscorrection.c
libavfilter/vf_lut3d.c
libavfilter/vf_noise.c
libavfilter/vf_perspective.c
libavfilter/vf_removegrain.c
libavfilter/vf_rotate.c
libavfilter/vf_selectivecolor.c
libavfilter/vf_signalstats.c
libavfilter/vf_stereo3d.c
libavfilter/vf_transpose.c
libavfilter/vf_w3fdif.c
libavfilter/vf_xbr.c
libavfilter/vf_yadif.c

index 79e0800..7dcec3c 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -23,6 +23,7 @@ version <next>:
 - lut2 filter
 - yuvtestsrc filter
 - vaguedenoiser filter
+- added threads option per filter instance
 
 
 version 3.1:
index 07da792..bf75d53 100644 (file)
@@ -357,7 +357,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
         ctx->internal->execute(ctx, s->filter_slice, &td, NULL,
                                FFMIN3(s->planeheight[1],
                                       s->planeheight[2],
-                                      ctx->graph->nb_threads));
+                                      ff_filter_get_nb_threads(ctx)));
         av_frame_copy_props(out, in);
     } else {
         out = av_frame_clone(in);
index a121267..2731ec8 100644 (file)
@@ -393,7 +393,7 @@ static AVFrame *blend_frame(AVFilterContext *ctx, AVFrame *top_buf,
                           .w = outw, .h = outh, .param = param, .plane = plane,
                           .inlink = inlink };
 
-        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outh, ctx->graph->nb_threads));
+        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outh, ff_filter_get_nb_threads(ctx)));
     }
 
     if (!s->tblend)
index 595b825..b691983 100644 (file)
@@ -278,7 +278,7 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic,
         td.h     = h;
         td.plane = i;
 
-        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ctx->graph->nb_threads));
+        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ff_filter_get_nb_threads(ctx)));
     }
     if (!bwdif->inter_field) {
         bwdif->inter_field = 1;
index 3309748..8841478 100644 (file)
@@ -108,7 +108,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
     AVFilterContext *avctx = link->dst;
     int res;
 
-    if (res = avctx->internal->execute(avctx, do_chromakey_slice, frame, NULL, FFMIN(frame->height, avctx->graph->nb_threads)))
+    if (res = avctx->internal->execute(avctx, do_chromakey_slice, frame, NULL, FFMIN(frame->height, ff_filter_get_nb_threads(avctx))))
         return res;
 
     return ff_filter_frame(avctx->outputs[0], frame);
index 2f670d9..3d65e59 100644 (file)
@@ -85,7 +85,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
     if (res = av_frame_make_writable(frame))
         return res;
 
-    if (res = avctx->internal->execute(avctx, do_colorkey_slice, frame, NULL, FFMIN(frame->height, avctx->graph->nb_threads)))
+    if (res = avctx->internal->execute(avctx, do_colorkey_slice, frame, NULL, FFMIN(frame->height, ff_filter_get_nb_threads(avctx))))
         return res;
 
     return ff_filter_frame(avctx->outputs[0], frame);
index 15fb680..d237baa 100644 (file)
@@ -474,16 +474,16 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 
     if (in->format == AV_PIX_FMT_YUV444P)
         ctx->internal->execute(ctx, process_slice_yuv444p, &td, NULL,
-                               FFMIN(in->height, ctx->graph->nb_threads));
+                               FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
     else if (in->format == AV_PIX_FMT_YUV422P)
         ctx->internal->execute(ctx, process_slice_yuv422p, &td, NULL,
-                               FFMIN(in->height, ctx->graph->nb_threads));
+                               FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
     else if (in->format == AV_PIX_FMT_YUV420P)
         ctx->internal->execute(ctx, process_slice_yuv420p, &td, NULL,
-                               FFMIN(in->height / 2, ctx->graph->nb_threads));
+                               FFMIN(in->height / 2, ff_filter_get_nb_threads(ctx)));
     else
         ctx->internal->execute(ctx, process_slice_uyvy422, &td, NULL,
-                               FFMIN(in->height, ctx->graph->nb_threads));
+                               FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
index 37e77d1..e4022f8 100644 (file)
@@ -947,7 +947,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
             return res;
     } else {
         ctx->internal->execute(ctx, convert, &td, NULL,
-                               FFMIN((in->height + 1) >> 1, ctx->graph->nb_threads));
+                               FFMIN((in->height + 1) >> 1, ff_filter_get_nb_threads(ctx)));
     }
     av_frame_free(&in);
 
index fef9a0e..69ec108 100644 (file)
@@ -647,7 +647,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
     td.in  = in;
     td.out = out;
-    ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, ctx->graph->nb_threads));
+    ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
         av_frame_free(&in);
index 3c82a0e..76134c2 100644 (file)
@@ -328,7 +328,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     }
 
     td.in = in; td.out = out, td.yoff = xmaxlen, td.xoff = ymaxlen;
-    ctx->internal->execute(ctx, s->filter, &td, NULL, FFMIN(ctx->graph->nb_threads, FFMAX(outlink->w / 20, 1)));
+    ctx->internal->execute(ctx, s->filter, &td, NULL, FFMIN(ff_filter_get_nb_threads(ctx), FFMAX(outlink->w / 20, 1)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
index 6957f19..62763bf 100644 (file)
@@ -507,9 +507,9 @@ static int config_input(AVFilterLink *inlink)
                inlink->h - s->pr_height);
 
     max_slice_h = s->pr_height / ((s->bsize - 1) * 2);
-    s->nb_threads = FFMIN3(MAX_THREADS, ctx->graph->nb_threads, max_slice_h);
+    s->nb_threads = FFMIN3(MAX_THREADS, ff_filter_get_nb_threads(ctx), max_slice_h);
     av_log(ctx, AV_LOG_DEBUG, "threads: [max=%d hmax=%d user=%d] => %d\n",
-           MAX_THREADS, max_slice_h, ctx->graph->nb_threads, s->nb_threads);
+           MAX_THREADS, max_slice_h, ff_filter_get_nb_threads(ctx), s->nb_threads);
 
     s->p_linesize = linesize = FFALIGN(s->pr_width, 32);
     for (i = 0; i < 2; i++) {
index 01728b1..3a1cfb8 100644 (file)
@@ -267,7 +267,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.in = in; td.out = out;
     ctx->internal->execute(ctx, s->deband, &td, NULL, FFMIN3(s->planeheight[1],
                                                              s->planeheight[2],
-                                                             ctx->graph->nb_threads));
+                                                             ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
index cf77d87..0496645 100644 (file)
@@ -347,19 +347,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     if (s->factor < UINT16_MAX) {
         if (s->alpha) {
             ctx->internal->execute(ctx, filter_slice_alpha, frame, NULL,
-                                FFMIN(frame->height, ctx->graph->nb_threads));
+                                FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
         } else if (s->is_packed_rgb && !s->black_fade) {
             ctx->internal->execute(ctx, filter_slice_rgb, frame, NULL,
-                                   FFMIN(frame->height, ctx->graph->nb_threads));
+                                   FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
         } else {
             /* luma, or rgb plane in case of black */
             ctx->internal->execute(ctx, filter_slice_luma, frame, NULL,
-                                FFMIN(frame->height, ctx->graph->nb_threads));
+                                FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
 
             if (frame->data[1] && frame->data[2]) {
                 /* chroma planes */
                 ctx->internal->execute(ctx, filter_slice_chroma, frame, NULL,
-                                    FFMIN(frame->height, ctx->graph->nb_threads));
+                                    FFMIN(frame->height, ff_filter_get_nb_threads(ctx)));
             }
         }
     }
index 3e502e3..cf20c19 100644 (file)
@@ -174,7 +174,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         memcpy(out->data[1], in->data[1], AVPALETTE_SIZE);
 
     td.in = in, td.out = out;
-    ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, ctx->graph->nb_threads));
+    ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
index d1e360f..5f63b2a 100644 (file)
@@ -502,7 +502,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.in = in;
     td.out = out;
     td.rgbtoyuv = hqx->rgbtoyuv;
-    ctx->internal->execute(ctx, hqx->func, &td, NULL, FFMIN(inlink->h, ctx->graph->nb_threads));
+    ctx->internal->execute(ctx, hqx->func, &td, NULL, FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
 
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
index 9db483d..239fe19 100644 (file)
@@ -193,7 +193,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         }
 
         td.correction = rect->correction[plane];
-        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ctx->graph->nb_threads));
+        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ff_filter_get_nb_threads(ctx)));
     }
 
     av_frame_free(&in);
index 2b8e027..b136cda 100644 (file)
@@ -531,7 +531,7 @@ static AVFrame *apply_lut(AVFilterLink *inlink, AVFrame *in)
 
     td.in  = in;
     td.out = out;
-    ctx->internal->execute(ctx, lut3d->interp, &td, NULL, FFMIN(outlink->h, ctx->graph->nb_threads));
+    ctx->internal->execute(ctx, lut3d->interp, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
 
     if (out != in)
         av_frame_free(&in);
index fa3863e..abdf047 100644 (file)
@@ -272,7 +272,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
     }
 
     td.in = inpicref; td.out = out;
-    ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(n->height[0], ctx->graph->nb_threads));
+    ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(n->height[0], ff_filter_get_nb_threads(ctx)));
     emms_c();
 
     if (inpicref != out)
index 2b5afce..287db68 100644 (file)
@@ -478,7 +478,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
                          .h = s->height[plane],
                          .hsub = hsub,
                          .vsub = vsub };
-        ctx->internal->execute(ctx, s->perspective, &td, NULL, FFMIN(td.h, ctx->graph->nb_threads));
+        ctx->internal->execute(ctx, s->perspective, &td, NULL, FFMIN(td.h, ff_filter_get_nb_threads(ctx)));
     }
 
     av_frame_free(&frame);
index 8ef0974..bc45076 100644 (file)
@@ -619,7 +619,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
         td.in = in; td.out = out; td.plane = i;
         ctx->internal->execute(ctx, filter_slice, &td, NULL,
-                               FFMIN(s->planeheight[i], ctx->graph->nb_threads));
+                               FFMIN(s->planeheight[i], ff_filter_get_nb_threads(ctx)));
 
         src = in->data[i] + (s->planeheight[i] - 1) * in->linesize[i];
         dst = out->data[i] + (s->planeheight[i] - 1) * out->linesize[i];
index b37685a..42e725a 100644 (file)
@@ -553,7 +553,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                           .plane = plane, .c = c, .s = s };
 
 
-        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outh, ctx->graph->nb_threads));
+        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outh, ff_filter_get_nb_threads(ctx)));
     }
 
     av_frame_free(&in);
index 33716ec..a5cb533 100644 (file)
@@ -471,7 +471,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.in = in;
     td.out = out;
     ctx->internal->execute(ctx, funcs[s->is_16bit][direct][s->correction_method],
-                           &td, NULL, FFMIN(inlink->h, ctx->graph->nb_threads));
+                           &td, NULL, FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
 
     if (!direct)
         av_frame_free(&in);
index 6796af8..22a1db1 100644 (file)
@@ -185,7 +185,7 @@ static int config_props(AVFilterLink *outlink)
     s->fs = inlink->w * inlink->h;
     s->cfs = s->chromaw * s->chromah;
 
-    s->nb_jobs   = FFMAX(1, FFMIN(inlink->h, ctx->graph->nb_threads));
+    s->nb_jobs   = FFMAX(1, FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
     s->jobs_rets = av_malloc_array(s->nb_jobs, sizeof(*s->jobs_rets));
     if (!s->jobs_rets)
         return AVERROR(ENOMEM);
@@ -602,7 +602,7 @@ static int filter_frame8(AVFilterLink *link, AVFrame *in)
     }
 
     ctx->internal->execute(ctx, compute_sat_hue_metrics8, &td_huesat,
-                           NULL, FFMIN(s->chromah, ctx->graph->nb_threads));
+                           NULL, FFMIN(s->chromah, ff_filter_get_nb_threads(ctx)));
 
     // Calculate luma histogram and difference with previous frame or field.
     for (j = 0; j < link->h; j++) {
@@ -820,7 +820,7 @@ static int filter_frame16(AVFilterLink *link, AVFrame *in)
     }
 
     ctx->internal->execute(ctx, compute_sat_hue_metrics16, &td_huesat,
-                           NULL, FFMIN(s->chromah, ctx->graph->nb_threads));
+                           NULL, FFMIN(s->chromah, ff_filter_get_nb_threads(ctx)));
 
     // Calculate luma histogram and difference with previous frame or field.
     memset(s->histy, 0, (1 << s->depth) * sizeof(*s->histy));
index 2036c94..3e23890 100644 (file)
@@ -935,7 +935,7 @@ copy:
 
             td.ileft = ileft; td.iright = iright; td.out = out;
             ctx->internal->execute(ctx, filter_slice, &td, NULL,
-                                   FFMIN(s->out.height, ctx->graph->nb_threads));
+                                   FFMIN(s->out.height, ff_filter_get_nb_threads(ctx)));
         }
         break;
     }
index 9555ff2..28226c3 100644 (file)
@@ -250,7 +250,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     }
 
     td.in = in, td.out = out;
-    ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, ctx->graph->nb_threads));
+    ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
 }
index e6f6628..cde17d2 100644 (file)
@@ -170,7 +170,7 @@ static int config_input(AVFilterLink *inlink)
     s->planeheight[0] = s->planeheight[3] = inlink->h;
 
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
-    s->nb_threads = ctx->graph->nb_threads;
+    s->nb_threads = ff_filter_get_nb_threads(ctx);
     s->work_line = av_calloc(s->nb_threads, sizeof(*s->work_line));
     if (!s->work_line)
         return AVERROR(ENOMEM);
index c92e9a8..9893e0c 100644 (file)
@@ -367,7 +367,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     td.in = in;
     td.out = out;
     td.rgbtoyuv = s->rgbtoyuv;
-    ctx->internal->execute(ctx, s->func, &td, NULL, FFMIN(inlink->h, ctx->graph->nb_threads));
+    ctx->internal->execute(ctx, s->func, &td, NULL, FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
 
     out->width  = outlink->w;
     out->height = outlink->h;
index 8e6522c..694ac44 100644 (file)
@@ -242,7 +242,7 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic,
         td.h       = h;
         td.plane   = i;
 
-        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ctx->graph->nb_threads));
+        ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(h, ff_filter_get_nb_threads(ctx)));
     }
 
     emms_c();