[FFmpeg-cvslog] avfilter/af_afir: stop using as much threads as stream have it

Paul B Mahol git at videolan.org
Sun Dec 30 18:51:35 EET 2018


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Dec 30 17:40:31 2018 +0100| [ba3d983c95b2054d046c9b9b79088634c54a24f0] | committer: Paul B Mahol

avfilter/af_afir: stop using as much threads as stream have it

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

 libavfilter/af_afir.c | 18 ++++++++++++++++--
 1 file 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)



More information about the ffmpeg-cvslog mailing list