diff options
author | Paul B Mahol <onemda@gmail.com> | 2016-02-26 10:35:19 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2016-02-26 11:12:45 +0100 |
commit | 2a7f056d880774fc7711a4b588af3841cd5a84af (patch) | |
tree | 52cb2de655c970531fc9a840b3abec4713f80b2e | |
parent | dedcb3c5a5e6beb2f2977e7cde307c8486078c2e (diff) | |
download | ffmpeg-2a7f056d880774fc7711a4b588af3841cd5a84af.tar.gz |
avfilter/af_astats: do not clear previous sample value
Should help when using reset=1 and metadata=1
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | libavfilter/af_astats.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c index c8b034a65a..17b8ad0aa7 100644 --- a/libavfilter/af_astats.c +++ b/libavfilter/af_astats.c @@ -98,14 +98,27 @@ static void reset_stats(AudioStatsContext *s) { int c; - memset(s->chstats, 0, sizeof(*s->chstats) * s->nb_channels); - for (c = 0; c < s->nb_channels; c++) { ChannelStats *p = &s->chstats[c]; p->min = p->min_sigma_x2 = DBL_MAX; p->max = p->max_sigma_x2 = DBL_MIN; - p->min_diff = p->max_diff = -1; + p->min_diff = DBL_MAX; + p->max_diff = DBL_MIN; + p->sigma_x = 0; + p->sigma_x2 = 0; + p->avg_sigma_x2 = 0; + p->min_sigma_x2 = 0; + p->max_sigma_x2 = 0; + p->min_run = 0; + p->max_run = 0; + p->min_runs = 0; + p->max_runs = 0; + p->diff1_sum = 0; + p->mask = 0; + p->min_count = 0; + p->max_count = 0; + p->nb_samples = 0; } } @@ -164,8 +177,8 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d) p->sigma_x += d; p->sigma_x2 += d * d; p->avg_sigma_x2 = p->avg_sigma_x2 * s->mult + (1.0 - s->mult) * d * d; - p->min_diff = FFMIN(p->min_diff == -1 ? DBL_MAX : p->min_diff, fabs(d - (p->min_diff == -1 ? DBL_MAX : p->last))); - p->max_diff = FFMAX(p->max_diff, fabs(d - (p->max_diff == -1 ? d : p->last))); + p->min_diff = FFMIN(p->min_diff, fabs(d - p->last)); + p->max_diff = FFMAX(p->max_diff, fabs(d - p->last)); p->diff1_sum += fabs(d - p->last); p->last = d; p->mask |= llrint(d * (UINT64_C(1) << 63)); |