From 9808dfbfff3d0c618698f19ca6c9cbbdae24a380 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 17 May 2016 23:09:15 +0100 Subject: [PATCH] Fix incorrect scaling of S32LE samples; 1<<31 overflows and causes the wrong result. --- src/lib/ffmpeg_decoder.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index e3a425375..068eba80f 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -228,7 +228,7 @@ FFmpegDecoder::deinterleave_audio (shared_ptr stream) const int sample = 0; int channel = 0; for (int i = 0; i < total_samples; ++i) { - audio->data(channel)[sample] = static_cast(*p++) / (1 << 31); + audio->data(channel)[sample] = static_cast(*p++) / 2147483648; ++channel; if (channel == stream->channels()) { @@ -244,7 +244,7 @@ FFmpegDecoder::deinterleave_audio (shared_ptr stream) const int32_t** p = reinterpret_cast (_frame->data); for (int i = 0; i < stream->channels(); ++i) { for (int j = 0; j < frames; ++j) { - audio->data(i)[j] = static_cast(p[i][j]) / (1 << 31); + audio->data(i)[j] = static_cast(p[i][j]) / 2147483648; } } } -- 2.30.2