summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2020-12-01 18:38:11 +0100
committerPaul B Mahol <onemda@gmail.com>2020-12-01 18:42:28 +0100
commitaa3566a8eea2540da3764ad5f0f2a3356de406d0 (patch)
treeb005af9e67efb0e0fc9916c2f164d99bb457fe05
parentc35cf9fe5349ea6668861a0dcdef1e8fd60a1d3a (diff)
avfilter/af_anequalizer: add timeline and slice support
-rw-r--r--libavfilter/af_anequalizer.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/libavfilter/af_anequalizer.c b/libavfilter/af_anequalizer.c
index f4e02c2923..80e2c690f4 100644
--- a/libavfilter/af_anequalizer.c
+++ b/libavfilter/af_anequalizer.c
@@ -693,22 +693,26 @@ static double process_sample(FoSection *s1, double in)
return p1;
}
-static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
+static int filter_channels(AVFilterContext *ctx, void *arg,
+ int jobnr, int nb_jobs)
{
- AVFilterContext *ctx = inlink->dst;
AudioNEqualizerContext *s = ctx->priv;
- AVFilterLink *outlink = ctx->outputs[0];
- double *bptr;
- int i, n;
+ AVFrame *buf = arg;
+ const int start = (buf->channels * jobnr) / nb_jobs;
+ const int end = (buf->channels * (jobnr+1)) / nb_jobs;
- for (i = 0; i < s->nb_filters; i++) {
+ for (int i = 0; i < s->nb_filters; i++) {
EqualizatorFilter *f = &s->filters[i];
+ double *bptr;
if (f->gain == 0. || f->ignore)
continue;
+ if (f->channel < start ||
+ f->channel >= end)
+ continue;
bptr = (double *)buf->extended_data[f->channel];
- for (n = 0; n < buf->nb_samples; n++) {
+ for (int n = 0; n < buf->nb_samples; n++) {
double sample = bptr[n];
sample = process_sample(f->section, sample);
@@ -716,6 +720,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
}
}
+ return 0;
+}
+
+static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
+{
+ AVFilterContext *ctx = inlink->dst;
+ AudioNEqualizerContext *s = ctx->priv;
+ AVFilterLink *outlink = ctx->outputs[0];
+
+ if (!ctx->is_disabled)
+ ctx->internal->execute(ctx, filter_channels, buf, NULL, FFMIN(inlink->channels,
+ ff_filter_get_nb_threads(ctx)));
+
if (s->draw_curves) {
AVFrame *clone;
@@ -757,6 +774,8 @@ AVFilter ff_af_anequalizer = {
.query_formats = query_formats,
.inputs = inputs,
.outputs = NULL,
- .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS,
.process_command = process_command,
+ .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS |
+ AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
+ AVFILTER_FLAG_SLICE_THREADS,
};