aboutsummaryrefslogtreecommitdiff
path: root/video/bink_decoder.cpp
diff options
context:
space:
mode:
authorSven Hesse2011-07-24 23:56:56 +0200
committerSven Hesse2011-07-24 23:56:56 +0200
commit62862ecb239c23ccd9b41d4e95392f72aacadf0f (patch)
treea84f35ea93f422a48d11ff9de9b6c89a1afad47c /video/bink_decoder.cpp
parentcf2060a4168236da1a81cf45078bc7bd2f1ee25d (diff)
downloadscummvm-rg350-62862ecb239c23ccd9b41d4e95392f72aacadf0f.tar.gz
scummvm-rg350-62862ecb239c23ccd9b41d4e95392f72aacadf0f.tar.bz2
scummvm-rg350-62862ecb239c23ccd9b41d4e95392f72aacadf0f.zip
VIDEO: Don't depend on IEEE floats for Bink audio
Diffstat (limited to 'video/bink_decoder.cpp')
-rw-r--r--video/bink_decoder.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp
index de716269c9..c60dbc29be 100644
--- a/video/bink_decoder.cpp
+++ b/video/bink_decoder.cpp
@@ -1418,10 +1418,6 @@ void BinkDecoder::audioBlock(AudioTrack &audio, int16 *out) {
else if (audio.codec == kAudioCodecRDFT)
audioBlockRDFT(audio);
- for (uint32 i = 0; i < audio.channels; i++)
- for (uint32 j = 0; j < audio.frameLen; j++)
- audio.coeffsPtr[i][j] = 385.0 + audio.coeffsPtr[i][j] * (1.0 / 32767.0);
-
floatToInt16Interleave(out, const_cast<const float **>(audio.coeffsPtr), audio.frameLen, audio.channels);
if (!audio.first) {
@@ -1535,25 +1531,20 @@ void BinkDecoder::readAudioCoeffs(AudioTrack &audio, float *coeffs) {
}
-static inline int floatToInt16One(const float *src) {
- int32 tmp = *(const int32 *) src;
-
- if (tmp & 0xF0000)
- tmp = (0x43C0FFFF - tmp) >> 31;
-
- return tmp - 0x8000;
+static inline int floatToInt16One(float src) {
+ return (int16) CLIP<int>((int) floor(src + 0.5), -32768, 32767);
}
void BinkDecoder::floatToInt16Interleave(int16 *dst, const float **src, uint32 length, uint8 channels) {
if (channels == 2) {
for (uint32 i = 0; i < length; i++) {
- dst[2 * i ] = TO_LE_16(floatToInt16One(src[0] + i));
- dst[2 * i + 1] = TO_LE_16(floatToInt16One(src[1] + i));
+ dst[2 * i ] = TO_LE_16(floatToInt16One(src[0][i]));
+ dst[2 * i + 1] = TO_LE_16(floatToInt16One(src[1][i]));
}
} else {
for(uint8 c = 0; c < channels; c++)
for(uint32 i = 0, j = c; i < length; i++, j += channels)
- dst[j] = TO_LE_16(floatToInt16One(src[c] + i));
+ dst[j] = TO_LE_16(floatToInt16One(src[c][i]));
}
}