mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avfilter: make use of ff_filter_get_nb_threads
This commit is contained in:
parent
5b1907142d
commit
a0a57072c9
@ -23,6 +23,7 @@ version <next>:
|
||||
- lut2 filter
|
||||
- yuvtestsrc filter
|
||||
- vaguedenoiser filter
|
||||
- added threads option per filter instance
|
||||
|
||||
|
||||
version 3.1:
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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++) {
|
||||
|
@ -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);
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user