aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/af_astats.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2016-02-24 22:10:32 +0100
committerPaul B Mahol <onemda@gmail.com>2016-02-24 22:32:26 +0100
commitc09248aecd0d3f03064387734094ec75a23e1078 (patch)
tree21eb552cac9ce00214c34b9a2c844cb68edd389b /libavfilter/af_astats.c
parent5870f2a1dc46d439669087951656c8dfec2cecbe (diff)
downloadffmpeg-c09248aecd0d3f03064387734094ec75a23e1078.tar.gz
avfilter/af_astats: reset stats prior not after filtering
This way stats printed at uninit are also useful. Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/af_astats.c')
-rw-r--r--libavfilter/af_astats.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index b3b8f2818c..70ec28a50f 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -119,6 +119,7 @@ static int config_output(AVFilterLink *outlink)
s->nb_channels = outlink->channels;
s->mult = exp((-1 / s->time_constant / outlink->sample_rate));
s->tc_samples = 5 * s->time_constant * outlink->sample_rate + .5;
+ s->nb_frames = 0;
reset_stats(s);
@@ -269,6 +270,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
const double *src;
int i, c;
+ if (s->reset_count > 0) {
+ if (s->nb_frames >= s->reset_count) {
+ reset_stats(s);
+ s->nb_frames = 0;
+ }
+ s->nb_frames++;
+ }
+
switch (inlink->format) {
case AV_SAMPLE_FMT_DBLP:
for (c = 0; c < channels; c++) {
@@ -292,14 +301,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
if (s->metadata)
set_metadata(s, metadata);
- if (s->reset_count > 0) {
- s->nb_frames++;
- if (s->nb_frames >= s->reset_count) {
- reset_stats(s);
- s->nb_frames = 0;
- }
- }
-
return ff_filter_frame(inlink->dst->outputs[0], buf);
}