[FFmpeg-cvslog] avfilter/af_anequalizer: add timeline and slice support

Paul B Mahol git at videolan.org
Tue Dec 1 19:46:20 EET 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Dec  1 18:38:11 2020 +0100| [aa3566a8eea2540da3764ad5f0f2a3356de406d0] | committer: Paul B Mahol

avfilter/af_anequalizer: add timeline and slice support

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa3566a8eea2540da3764ad5f0f2a3356de406d0
---

 libavfilter/af_anequalizer.c | 35 +++++++++++++++++++++++++++--------
 1 file 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,
 };



More information about the ffmpeg-cvslog mailing list