[FFmpeg-cvslog] avfilter/af_astats: fix calculations involving last sample
Paul B Mahol
git at videolan.org
Sun May 12 18:26:06 EEST 2019
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun May 12 17:10:40 2019 +0200| [bd6942b4c031fabcc82e9487f0af41f278da429a] | committer: Paul B Mahol
avfilter/af_astats: fix calculations involving last sample
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bd6942b4c031fabcc82e9487f0af41f278da429a
---
libavfilter/af_astats.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index 9c673b2392..7707f3158d 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -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;
More information about the ffmpeg-cvslog
mailing list