[FFmpeg-cvslog] vafilter/af_replaygain: fix undefined behaviour

Paul B Mahol git at videolan.org
Wed Oct 16 19:29:06 EEST 2019


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Wed Oct 16 18:24:31 2019 +0200| [98ae6b0a4d6d6909277b664937721e135c0a70ff] | committer: Paul B Mahol

vafilter/af_replaygain: fix undefined behaviour

Fixes #8291

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98ae6b0a4d6d6909277b664937721e135c0a70ff
---

 libavfilter/af_replaygain.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/af_replaygain.c b/libavfilter/af_replaygain.c
index 97617346ed..53fe49d769 100644
--- a/libavfilter/af_replaygain.c
+++ b/libavfilter/af_replaygain.c
@@ -551,7 +551,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     AVFilterContext *ctx = inlink->dst;
     AVFilterLink *outlink = ctx->outputs[0];
     ReplayGainContext *s = ctx->priv;
-    uint32_t level;
+    int64_t level;
     AVFrame *out;
 
     out = ff_get_audio_buffer(outlink, in->nb_samples);
@@ -567,9 +567,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                                                  out->nb_samples);
     butter_filter_stereo_samples(s, (float *)out->data[0],
                                              out->nb_samples);
-    level = (uint32_t)floor(100 * calc_stereo_rms((float *)out->data[0],
-                                                           out->nb_samples));
-    level = av_clip(level, 0, HISTOGRAM_SLOTS - 1);
+    level = lrint(floor(100 * calc_stereo_rms((float *)out->data[0],
+                                                           out->nb_samples)));
+    level = av_clip64(level, 0, HISTOGRAM_SLOTS - 1);
 
     s->histogram[level]++;
 



More information about the ffmpeg-cvslog mailing list