avfilter: make use of ff_filter_get_nb_threads
ffmpeg | branch: master | Paul B Mahol <onemda@gmail.com> | Sat Aug 27 22:44:42 2016 +0200| [a0a57072c93be397afe346d03b907397d6b88396] | committer: Paul B Mahol avfilter: make use of ff_filter_get_nb_threads
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0a57072c93be397af...
Changelog | 1 + libavfilter/vf_atadenoise.c | 2 +- libavfilter/vf_blend.c | 2 +- libavfilter/vf_bwdif.c | 2 +- libavfilter/vf_chromakey.c | 2 +- libavfilter/vf_colorkey.c | 2 +- libavfilter/vf_colormatrix.c | 8 ++++---- libavfilter/vf_colorspace.c | 2 +- libavfilter/vf_curves.c | 2 +- libavfilter/vf_datascope.c | 2 +- libavfilter/vf_dctdnoiz.c | 4 ++-- libavfilter/vf_deband.c | 2 +- libavfilter/vf_fade.c | 8 ++++---- libavfilter/vf_hflip.c | 2 +- libavfilter/vf_hqx.c | 2 +- libavfilter/vf_lenscorrection.c | 2 +- libavfilter/vf_lut3d.c | 2 +- libavfilter/vf_noise.c | 2 +- libavfilter/vf_perspective.c | 2 +- libavfilter/vf_removegrain.c | 2 +- libavfilter/vf_rotate.c | 2 +- libavfilter/vf_selectivecolor.c | 2 +- libavfilter/vf_signalstats.c | 6 +++--- libavfilter/vf_stereo3d.c | 2 +- libavfilter/vf_transpose.c | 2 +- libavfilter/vf_w3fdif.c | 2 +- libavfilter/vf_xbr.c | 2 +- libavfilter/vf_yadif.c | 2 +- 28 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Changelog b/Changelog index 79e0800..7dcec3c 100644 --- 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: diff --git a/libavfilter/vf_atadenoise.c b/libavfilter/vf_atadenoise.c index 07da792..bf75d53 100644 --- a/libavfilter/vf_atadenoise.c +++ b/libavfilter/vf_atadenoise.c @@ -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); diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c index a121267..2731ec8 100644 --- a/libavfilter/vf_blend.c +++ b/libavfilter/vf_blend.c @@ -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) diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c index 595b825..b691983 100644 --- a/libavfilter/vf_bwdif.c +++ b/libavfilter/vf_bwdif.c @@ -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; diff --git a/libavfilter/vf_chromakey.c b/libavfilter/vf_chromakey.c index 3309748..8841478 100644 --- a/libavfilter/vf_chromakey.c +++ b/libavfilter/vf_chromakey.c @@ -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); diff --git a/libavfilter/vf_colorkey.c b/libavfilter/vf_colorkey.c index 2f670d9..3d65e59 100644 --- a/libavfilter/vf_colorkey.c +++ b/libavfilter/vf_colorkey.c @@ -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); diff --git a/libavfilter/vf_colormatrix.c b/libavfilter/vf_colormatrix.c index 15fb680..d237baa 100644 --- a/libavfilter/vf_colormatrix.c +++ b/libavfilter/vf_colormatrix.c @@ -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); diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c index 37e77d1..e4022f8 100644 --- a/libavfilter/vf_colorspace.c +++ b/libavfilter/vf_colorspace.c @@ -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); diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c index fef9a0e..69ec108 100644 --- a/libavfilter/vf_curves.c +++ b/libavfilter/vf_curves.c @@ -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); diff --git a/libavfilter/vf_datascope.c b/libavfilter/vf_datascope.c index 3c82a0e..76134c2 100644 --- a/libavfilter/vf_datascope.c +++ b/libavfilter/vf_datascope.c @@ -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); diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c index 6957f19..62763bf 100644 --- a/libavfilter/vf_dctdnoiz.c +++ b/libavfilter/vf_dctdnoiz.c @@ -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++) { diff --git a/libavfilter/vf_deband.c b/libavfilter/vf_deband.c index 01728b1..3a1cfb8 100644 --- a/libavfilter/vf_deband.c +++ b/libavfilter/vf_deband.c @@ -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); diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c index cf77d87..0496645 100644 --- a/libavfilter/vf_fade.c +++ b/libavfilter/vf_fade.c @@ -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))); } } } diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c index 3e502e3..cf20c19 100644 --- a/libavfilter/vf_hflip.c +++ b/libavfilter/vf_hflip.c @@ -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); diff --git a/libavfilter/vf_hqx.c b/libavfilter/vf_hqx.c index d1e360f..5f63b2a 100644 --- a/libavfilter/vf_hqx.c +++ b/libavfilter/vf_hqx.c @@ -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); diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c index 9db483d..239fe19 100644 --- a/libavfilter/vf_lenscorrection.c +++ b/libavfilter/vf_lenscorrection.c @@ -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); diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c index 2b8e027..b136cda 100644 --- a/libavfilter/vf_lut3d.c +++ b/libavfilter/vf_lut3d.c @@ -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); diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c index fa3863e..abdf047 100644 --- a/libavfilter/vf_noise.c +++ b/libavfilter/vf_noise.c @@ -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) diff --git a/libavfilter/vf_perspective.c b/libavfilter/vf_perspective.c index 2b5afce..287db68 100644 --- a/libavfilter/vf_perspective.c +++ b/libavfilter/vf_perspective.c @@ -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); diff --git a/libavfilter/vf_removegrain.c b/libavfilter/vf_removegrain.c index 8ef0974..bc45076 100644 --- a/libavfilter/vf_removegrain.c +++ b/libavfilter/vf_removegrain.c @@ -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]; diff --git a/libavfilter/vf_rotate.c b/libavfilter/vf_rotate.c index b37685a..42e725a 100644 --- a/libavfilter/vf_rotate.c +++ b/libavfilter/vf_rotate.c @@ -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); diff --git a/libavfilter/vf_selectivecolor.c b/libavfilter/vf_selectivecolor.c index 33716ec..a5cb533 100644 --- a/libavfilter/vf_selectivecolor.c +++ b/libavfilter/vf_selectivecolor.c @@ -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); diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c index 6796af8..22a1db1 100644 --- a/libavfilter/vf_signalstats.c +++ b/libavfilter/vf_signalstats.c @@ -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)); diff --git a/libavfilter/vf_stereo3d.c b/libavfilter/vf_stereo3d.c index 2036c94..3e23890 100644 --- a/libavfilter/vf_stereo3d.c +++ b/libavfilter/vf_stereo3d.c @@ -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; } diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index 9555ff2..28226c3 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -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); } diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c index e6f6628..cde17d2 100644 --- a/libavfilter/vf_w3fdif.c +++ b/libavfilter/vf_w3fdif.c @@ -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); diff --git a/libavfilter/vf_xbr.c b/libavfilter/vf_xbr.c index c92e9a8..9893e0c 100644 --- a/libavfilter/vf_xbr.c +++ b/libavfilter/vf_xbr.c @@ -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; diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 8e6522c..694ac44 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -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();
participants (1)
-
git@videolan.org