diff options
author | Paul B Mahol <onemda@gmail.com> | 2018-12-30 17:40:31 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2018-12-30 17:50:44 +0100 |
commit | ba3d983c95b2054d046c9b9b79088634c54a24f0 (patch) | |
tree | b2ff09098b1e51777960086ae7c26653bc88923c /libavfilter/af_afir.c | |
parent | 72270d5bd071684944fa0a09d390e818aa76a975 (diff) | |
download | ffmpeg-ba3d983c95b2054d046c9b9b79088634c54a24f0.tar.gz |
avfilter/af_afir: stop using as much threads as stream have it
Diffstat (limited to 'libavfilter/af_afir.c')
-rw-r--r-- | libavfilter/af_afir.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index 3e13edf96a..35fa66bad5 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -56,7 +56,7 @@ static void fcmul_add_c(float *sum, const float *t, const float *c, ptrdiff_t le sum[2 * n] += t[2 * n] * c[2 * n]; } -static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) +static int fir_channel(AVFilterContext *ctx, void *arg, int ch) { AudioFIRContext *s = ctx->priv; const float *in = (const float *)s->in[0]->extended_data[ch]; @@ -138,6 +138,19 @@ static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) return 0; } +static int fir_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) +{ + AVFrame *out = arg; + const int start = (out->channels * jobnr) / nb_jobs; + const int end = (out->channels * (jobnr+1)) / nb_jobs; + + for (int ch = start; ch < end; ch++) { + fir_channel(ctx, out, ch); + } + + return 0; +} + static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; @@ -152,7 +165,8 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink) if (s->pts == AV_NOPTS_VALUE) s->pts = in->pts; s->in[0] = in; - ctx->internal->execute(ctx, fir_channel, out, NULL, outlink->channels); + ctx->internal->execute(ctx, fir_channels, out, NULL, FFMIN(outlink->channels, + ff_filter_get_nb_threads(ctx))); out->pts = s->pts; if (s->pts != AV_NOPTS_VALUE) |