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

avfilter/af_astats: fix calculations involving last sample

parent 2a4a364f
......@@ -196,6 +196,7 @@ static void reset_stats(AudioStatsContext *s)
p->nb_nans = 0;
p->nb_infs = 0;
p->nb_denormals = 0;
p->last = NAN;
}
}
......@@ -285,10 +286,12 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d,
p->sigma_x += nd;
p->sigma_x2 += nd * nd;
p->avg_sigma_x2 = p->avg_sigma_x2 * s->mult + (1.0 - s->mult) * nd * nd;
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->diff1_sum_x2 += (d - p->last) * (d - p->last);
if (!isnan(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->diff1_sum_x2 += (d - p->last) * (d - p->last);
}
p->last = d;
p->mask |= i;
p->imask &= i;
......
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