summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-05-17 23:09:15 +0100
committerCarl Hetherington <cth@carlh.net>2016-05-18 11:50:29 +0100
commit9808dfbfff3d0c618698f19ca6c9cbbdae24a380 (patch)
tree3c2e7d6785cb423f72315aef2ba77379018fb744 /src/lib/ffmpeg_decoder.cc
parentfb019eb087ffc38668dcd3bef455457ad4ebf161 (diff)
Fix incorrect scaling of S32LE samples; 1<<31 overflows and causes the wrong result.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
-rw-r--r--src/lib/ffmpeg_decoder.cc4
1 files 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<FFmpegAudioStream> stream) const
int sample = 0;
int channel = 0;
for (int i = 0; i < total_samples; ++i) {
- audio->data(channel)[sample] = static_cast<float>(*p++) / (1 << 31);
+ audio->data(channel)[sample] = static_cast<float>(*p++) / 2147483648;
++channel;
if (channel == stream->channels()) {
@@ -244,7 +244,7 @@ FFmpegDecoder::deinterleave_audio (shared_ptr<FFmpegAudioStream> stream) const
int32_t** p = reinterpret_cast<int32_t **> (_frame->data);
for (int i = 0; i < stream->channels(); ++i) {
for (int j = 0; j < frames; ++j) {
- audio->data(i)[j] = static_cast<float>(p[i][j]) / (1 << 31);
+ audio->data(i)[j] = static_cast<float>(p[i][j]) / 2147483648;
}
}
}