aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorSven Hesse2008-12-19 01:01:07 +0000
committerSven Hesse2008-12-19 01:01:07 +0000
commit55edaf0945ba4c9962197a5fbbda76f3a4b8bcee (patch)
tree15daad13b16cc1b6e87bdb881d6d0c532305cab1 /graphics
parent6d19ee6e64c9c6bf5ba5efa58028a300ffd4ce69 (diff)
downloadscummvm-rg350-55edaf0945ba4c9962197a5fbbda76f3a4b8bcee.tar.gz
scummvm-rg350-55edaf0945ba4c9962197a5fbbda76f3a4b8bcee.tar.bz2
scummvm-rg350-55edaf0945ba4c9962197a5fbbda76f3a4b8bcee.zip
Fixing 16bit audio
svn-id: r35432
Diffstat (limited to 'graphics')
-rw-r--r--graphics/smk_player.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/graphics/smk_player.cpp b/graphics/smk_player.cpp
index 41e118fc9e..3a5d6e8fe5 100644
--- a/graphics/smk_player.cpp
+++ b/graphics/smk_player.cpp
@@ -775,10 +775,10 @@ void SMKPlayer::queueCompressedBuffer(byte *buffer, int bufferSize,
if (isStereo)
bases[1] = (!is16Bits) ? audioBS.getBits8() :
- ((audioBS.getBits8() << 8) || audioBS.getBits8());
+ ((int16) (((audioBS.getBits8() << 8) | audioBS.getBits8())));
bases[0] = (!is16Bits) ? audioBS.getBits8() :
- ((audioBS.getBits8() << 8) || audioBS.getBits8());
+ ((int16) (((audioBS.getBits8() << 8) | audioBS.getBits8())));
// The bases are the first samples, too
@@ -797,6 +797,7 @@ void SMKPlayer::queueCompressedBuffer(byte *buffer, int bufferSize,
// If the sample is stereo, the data is stored for the left and right channel, respectively
// (the exact opposite to the base values)
if (!is16Bits) {
+
for (int k = 0; k < (isStereo ? 2 : 1); k++) {
int8 v = (int8) ((int16) audioTrees[k]->getCode(audioBS));
@@ -807,19 +808,24 @@ void SMKPlayer::queueCompressedBuffer(byte *buffer, int bufferSize,
*curPointer++ = data ^ 0x80;
curPos++;
}
+
} else {
+
for (int k = 0; k < (isStereo ? 2 : 1); k++) {
- uint16 cur = bases[k];
- // adding takes care of possible overflows
- cur += audioTrees[k * 2]->getCode(audioBS); // low byte
- cur += (audioTrees[k * 2 + 1]->getCode(audioBS) << 8); // high byte
- *curPointer++ = (cur >> 8) & 0xFF; // high byte
- curPos++;
- *curPointer++ = cur & 0xFF; // low byte
- curPos++;
- }
+ int16 v = (int16) (audioTrees[k * 2]->getCode(audioBS) |
+ (audioTrees[k * 2 + 1]->getCode(audioBS) << 8));
+ bases[k] += v;
+
+ int16 data = CLIP<int32>(bases[k], -32768, 32767);
+
+ WRITE_BE_UINT16(curPointer, data);
+
+ curPointer += 2;
+ curPos += 2;
+ }
}
+
}
for (int k = 0; k < numBytes; k++)