[FFmpeg-cvslog] avfilter/af_astats: do not clear previous sample value
Paul B Mahol
git at videolan.org
Fri Feb 26 11:42:08 CET 2016
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Feb 26 10:35:19 2016 +0100| [2a7f056d880774fc7711a4b588af3841cd5a84af] | committer: Paul B Mahol
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 at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2a7f056d880774fc7711a4b588af3841cd5a84af
---
libavfilter/af_astats.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index c8b034a..17b8ad0 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));
More information about the ffmpeg-cvslog
mailing list