Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -539,7 +539,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata) · 538 unmodified lines | |||
| 539 | } | 539 | } |
| 540 | 540 | ||
| 541 | #define UPDATE_STATS_P(type, update_func, update_float, channel_func) \ | 541 | #define UPDATE_STATS_P(type, update_func, update_float, channel_func) \ |
| 542 | for (int c = 0; c < channels; c++) { \ | 542 | for (int c = start; c < end; c++) { \ |
| 543 | ChannelStats *p = &s->chstats[c]; \ | 543 | ChannelStats *p = &s->chstats[c]; \ |
| 544 | const type *src = (const type *)data[c]; \ | 544 | const type *src = (const type *)data[c]; \ |
| 545 | const type * const srcend = src + samples; \ | 545 | const type * const srcend = src + samples; \ |
| @@ -551,7 +551,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata) · 5 unmodified lines | |||
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | #define UPDATE_STATS_I(type, update_func, update_float, channel_func) \ | 553 | #define UPDATE_STATS_I(type, update_func, update_float, channel_func) \ |
| 554 | for (int c = 0; c < channels; c++) { \ | 554 | for (int c = start; c < end; c++) { \ |
| 555 | ChannelStats *p = &s->chstats[c]; \ | 555 | ChannelStats *p = &s->chstats[c]; \ |
| 556 | const type *src = (const type *)data[0]; \ | 556 | const type *src = (const type *)data[0]; \ |
| 557 | const type * const srcend = src + samples * channels; \ | 557 | const type * const srcend = src + samples * channels; \ |
| @@ -569,21 +569,16 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata) · 11 unmodified lines | |||
| 569 | UPDATE_STATS_##planar(type, update_minmax(s, p, sample), , p->nmin = p->min normalizer_suffix; p->nmax = p->max normalizer_suffix;); \ | 569 | UPDATE_STATS_##planar(type, update_minmax(s, p, sample), , p->nmin = p->min normalizer_suffix; p->nmax = p->max normalizer_suffix;); \ |
| 570 | } | 570 | } |
| 571 | 571 | ||
| 572 | static int filter_frame(AVFilterLink *inlink, AVFrame *buf) | 572 | static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) |
| 573 | { | 573 | { |
| 574 | AudioStatsContext *s = inlink->dst->priv; | 574 | AudioStatsContext *s = ctx->priv; |
| 575 | AVDictionary **metadata = &buf->metadata; | 575 | AVFilterLink *inlink = ctx->inputs[0]; |
| 576 | AVFrame *buf = arg; | ||
| 577 | const uint8_t * const * const data = (const uint8_t * const *)buf->extended_data; | ||
| 576 | const int channels = s->nb_channels; | 578 | const int channels = s->nb_channels; |
| 577 | const int samples = buf->nb_samples; | 579 | const int samples = buf->nb_samples; |
| 578 | const uint8_t * const * const data = (const uint8_t * const *)buf->extended_data; | 580 | const int start = (buf->channels * jobnr) / nb_jobs; |
| 579 | 581 | const int end = (buf->channels * (jobnr+1)) / nb_jobs; | |
| 580 | if (s->reset_count > 0) { | ||
| 581 | if (s->nb_frames >= s->reset_count) { | ||
| 582 | reset_stats(s); | ||
| 583 | s->nb_frames = 0; | ||
| 584 | } | ||
| 585 | s->nb_frames++; | ||
| 586 | } | ||
| 587 | 582 | ||
| 588 | switch (inlink->format) { | 583 | switch (inlink->format) { |
| 589 | case AV_SAMPLE_FMT_DBLP: | 584 | case AV_SAMPLE_FMT_DBLP: |
| @@ -618,6 +613,25 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf) · 28 unmodified lines | |||
| 618 | break; | 613 | break; |
| 619 | } | 614 | } |
| 620 | 615 | ||
| 616 | return 0; | ||
| 617 | } | ||
| 618 | |||
| 619 | static int filter_frame(AVFilterLink *inlink, AVFrame *buf) | ||
| 620 | { | ||
| 621 | AVFilterContext *ctx = inlink->dst; | ||
| 622 | AudioStatsContext *s = ctx->priv; | ||
| 623 | AVDictionary **metadata = &buf->metadata; | ||
| 624 | |||
| 625 | if (s->reset_count > 0) { | ||
| 626 | if (s->nb_frames >= s->reset_count) { | ||
| 627 | reset_stats(s); | ||
| 628 | s->nb_frames = 0; | ||
| 629 | } | ||
| 630 | s->nb_frames++; | ||
| 631 | } | ||
| 632 | |||
| 633 | ctx->internal->execute(ctx, filter_channel, buf, NULL, FFMIN(inlink->channels, ff_filter_get_nb_threads(ctx))); | ||
| 634 | |||
| 621 | if (s->metadata) | 635 | if (s->metadata) |
| 622 | set_metadata(s, metadata); | 636 | set_metadata(s, metadata); |
| 623 | 637 | ||
| @@ -812,4 +826,5 @@ AVFilter ff_af_astats = { · 188 unmodified lines | |||
| 812 | .uninit = uninit, | 826 | .uninit = uninit, |
| 813 | .inputs = astats_inputs, | 827 | .inputs = astats_inputs, |
| 814 | .outputs = astats_outputs, | 828 | .outputs = astats_outputs, |
| 829 | .flags = AVFILTER_FLAG_SLICE_THREADS, | ||
| 815 | }; | 830 | }; |