Commit ba3d983c authored by Paul B Mahol's avatar Paul B Mahol

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

parent 72270d5b
...@@ -56,7 +56,7 @@ static void fcmul_add_c(float *sum, const float *t, const float *c, ptrdiff_t le ...@@ -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]; 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; AudioFIRContext *s = ctx->priv;
const float *in = (const float *)s->in[0]->extended_data[ch]; 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) ...@@ -138,6 +138,19 @@ static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs)
return 0; 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) static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink)
{ {
AVFilterContext *ctx = outlink->src; AVFilterContext *ctx = outlink->src;
...@@ -152,7 +165,8 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink) ...@@ -152,7 +165,8 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink)
if (s->pts == AV_NOPTS_VALUE) if (s->pts == AV_NOPTS_VALUE)
s->pts = in->pts; s->pts = in->pts;
s->in[0] = in; 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; out->pts = s->pts;
if (s->pts != AV_NOPTS_VALUE) if (s->pts != AV_NOPTS_VALUE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment