1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

vafilter/af_replaygain: fix undefined behaviour

Fixes #8291
This commit is contained in:
Paul B Mahol 2019-10-16 18:24:31 +02:00
parent 71bceb06e6
commit 98ae6b0a4d

View File

@ -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]++;