Unified · Split
| @@ -219,11 +219,34 @@ static int config_output(AVFilterLink *outlink) · 218 unmodified lines | |||
| 219 | return 0; | 219 | return 0; |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 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 | |||
| 222 | static int filter_frame(AVFilterLink *inlink, AVFrame *in) | 244 | static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
| 223 | { | 245 | { |
| 224 | AVFilterContext *ctx = inlink->dst; | 246 | AVFilterContext *ctx = inlink->dst; |
| 225 | ADenormContext *s = ctx->priv; | 247 | ADenormContext *s = ctx->priv; |
| 226 | AVFilterLink *outlink = ctx->outputs[0]; | 248 | AVFilterLink *outlink = ctx->outputs[0]; |
| 249 | ThreadData td; | ||
| 227 | AVFrame *out; | 250 | AVFrame *out; |
| 228 | 251 | ||
| 229 | if (av_frame_is_writable(in)) { | 252 | if (av_frame_is_writable(in)) { |
| @@ -238,11 +261,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 8 unmodified lines | |||
| 238 | } | 261 | } |
| 239 | 262 | ||
| 240 | s->level = exp(s->level_db / 20. * M_LN10); | 263 | s->level = exp(s->level_db / 20. * M_LN10); |
| 241 | for (int ch = 0; ch < inlink->channels; ch++) { | 264 | td.in = in; td.out = out; |
| 242 | s->filter(ctx, out->extended_data[ch], | 265 | ctx->internal->execute(ctx, filter_channels, &td, NULL, FFMIN(inlink->channels, |
| 243 | in->extended_data[ch], | 266 | ff_filter_get_nb_threads(ctx))); |
| 244 | in->nb_samples); | 267 | |
| 245 | } | ||
| 246 | s->in_samples += in->nb_samples; | 268 | s->in_samples += in->nb_samples; |
| 247 | 269 | ||
| 248 | if (out != in) | 270 | if (out != in) |
| @@ -305,4 +327,6 @@ AVFilter ff_af_adenorm = { · 56 unmodified lines | |||
| 305 | .outputs = adenorm_outputs, | 327 | .outputs = adenorm_outputs, |
| 306 | .priv_class = &adenorm_class, | 328 | .priv_class = &adenorm_class, |
| 307 | .process_command = process_command, | 329 | .process_command = process_command, |
| 330 | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | | ||
| 331 | AVFILTER_FLAG_SLICE_THREADS, | ||
| 308 | }; | 332 | }; |