History

avfilter/af_adenorm: add timeline and slice threading support

Paul B Mahol committed 5 years ago

Commit 68429b91 parent ee8ecc21 file · +29 −5Browse files

Unified · Split

libavfilter/af_adenorm.c+29−5
@@ -219,11 +219,34 @@ static int config_output(AVFilterLink *outlink) · 218 unmodified lines
219219 return 0;
220220 }
221221
222+typedef struct ThreadData {
223+ AVFrame *in, *out;
224+} ThreadData;
225+
226+static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
227+{
228+ ADenormContext *s = ctx->priv;
229+ ThreadData *td = arg;
230+ AVFrame *out = td->out;
231+ AVFrame *in = td->in;
232+ const int start = (in->channels * jobnr) / nb_jobs;
233+ const int end = (in->channels * (jobnr+1)) / nb_jobs;
234+
235+ for (int ch = start; ch < end; ch++) {
236+ s->filter(ctx, out->extended_data[ch],
237+ in->extended_data[ch],
238+ in->nb_samples);
239+ }
240+
241+ return 0;
242+}
243+
222244 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
223245 {
224246 AVFilterContext *ctx = inlink->dst;
225247 ADenormContext *s = ctx->priv;
226248 AVFilterLink *outlink = ctx->outputs[0];
249+ ThreadData td;
227250 AVFrame *out;
228251
229252 if (av_frame_is_writable(in)) {
@@ -238,11 +261,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 8 unmodified lines
238261 }
239262
240263 s->level = exp(s->level_db / 20. * M_LN10);
241− for (int ch = 0; ch < inlink->channels; ch++) {
242− s->filter(ctx, out->extended_data[ch],
243− in->extended_data[ch],
244− in->nb_samples);
245− }
264+ td.in = in; td.out = out;
265+ ctx->internal->execute(ctx, filter_channels, &td, NULL, FFMIN(inlink->channels,
266+ ff_filter_get_nb_threads(ctx)));
267+
246268 s->in_samples += in->nb_samples;
247269
248270 if (out != in)
@@ -305,4 +327,6 @@ AVFilter ff_af_adenorm = { · 56 unmodified lines
305327 .outputs = adenorm_outputs,
306328 .priv_class = &adenorm_class,
307329 .process_command = process_command,
330+ .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC |
331+ AVFILTER_FLAG_SLICE_THREADS,
308332 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t