diff options
author | Paul B Mahol <onemda@gmail.com> | 2020-11-24 11:27:14 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2020-11-24 11:32:19 +0100 |
commit | 68429b9465b53bbb64bf8f35ea601f7ec2ead407 (patch) | |
tree | 96b7a04ad761812d2359626e117916f33cd5137f /libavfilter/af_adenorm.c | |
parent | ee8ecc2730dadc8cdcd7be6e470d03a554f03b76 (diff) | |
download | ffmpeg-68429b9465b53bbb64bf8f35ea601f7ec2ead407.tar.gz |
avfilter/af_adenorm: add timeline and slice threading support
Diffstat (limited to 'libavfilter/af_adenorm.c')
-rw-r--r-- | libavfilter/af_adenorm.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/libavfilter/af_adenorm.c b/libavfilter/af_adenorm.c index e689fe556e..992a1fe56a 100644 --- a/libavfilter/af_adenorm.c +++ b/libavfilter/af_adenorm.c @@ -219,11 +219,34 @@ static int config_output(AVFilterLink *outlink) return 0; } +typedef struct ThreadData { + AVFrame *in, *out; +} ThreadData; + +static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) +{ + ADenormContext *s = ctx->priv; + ThreadData *td = arg; + AVFrame *out = td->out; + AVFrame *in = td->in; + const int start = (in->channels * jobnr) / nb_jobs; + const int end = (in->channels * (jobnr+1)) / nb_jobs; + + for (int ch = start; ch < end; ch++) { + s->filter(ctx, out->extended_data[ch], + in->extended_data[ch], + in->nb_samples); + } + + return 0; +} + static int filter_frame(AVFilterLink *inlink, AVFrame *in) { AVFilterContext *ctx = inlink->dst; ADenormContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; + ThreadData td; AVFrame *out; if (av_frame_is_writable(in)) { @@ -238,11 +261,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } s->level = exp(s->level_db / 20. * M_LN10); - for (int ch = 0; ch < inlink->channels; ch++) { - s->filter(ctx, out->extended_data[ch], - in->extended_data[ch], - in->nb_samples); - } + td.in = in; td.out = out; + ctx->internal->execute(ctx, filter_channels, &td, NULL, FFMIN(inlink->channels, + ff_filter_get_nb_threads(ctx))); + s->in_samples += in->nb_samples; if (out != in) @@ -305,4 +327,6 @@ AVFilter ff_af_adenorm = { .outputs = adenorm_outputs, .priv_class = &adenorm_class, .process_command = process_command, + .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | + AVFILTER_FLAG_SLICE_THREADS, }; |