diff options
author | Marton Balint <cus@passwd.hu> | 2021-01-11 00:12:39 +0100 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2021-01-23 19:54:14 +0100 |
commit | c8e1e56509c3f176803cdf40b4019263125fa43f (patch) | |
tree | 42c2a1f8d9c1786d2219bfc5219ceac2c8a75bf6 /libavfilter/af_astats.c | |
parent | 16766bf8a8e477da09337801b96f732740a0b279 (diff) |
avfilter/af_astats: fix possible crash because of undefined float to integer rounding
Fixes ticket #9049.
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavfilter/af_astats.c')
-rw-r--r-- | libavfilter/af_astats.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c index ebaae29f44..f50cbe199c 100644 --- a/libavfilter/af_astats.c +++ b/libavfilter/af_astats.c @@ -329,11 +329,11 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d, drop = p->win_samples[p->win_pos]; p->win_samples[p->win_pos] = nd; - index = av_clip(FFABS(av_clipd(nd, -1.0, 1.0)) * HISTOGRAM_MAX, 0, HISTOGRAM_MAX); + index = av_clip(lrint(av_clipd(FFABS(nd), 0.0, 1.0) * HISTOGRAM_MAX), 0, HISTOGRAM_MAX); p->max_index = FFMAX(p->max_index, index); p->histogram[index]++; if (!isnan(p->noise_floor)) - p->histogram[av_clip(FFABS(drop) * HISTOGRAM_MAX, 0, HISTOGRAM_MAX)]--; + p->histogram[av_clip(lrint(av_clipd(FFABS(drop), 0.0, 1.0) * HISTOGRAM_MAX), 0, HISTOGRAM_MAX)]--; p->win_pos++; while (p->histogram[p->max_index] == 0) |