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