aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/imuse_digi.cpp16
-rw-r--r--scumm/smush/imuse_channel.cpp18
2 files changed, 16 insertions, 18 deletions
diff --git a/scumm/imuse_digi.cpp b/scumm/imuse_digi.cpp
index f0a78e232b..ca1aa0eca1 100644
--- a/scumm/imuse_digi.cpp
+++ b/scumm/imuse_digi.cpp
@@ -687,8 +687,8 @@ static byte *readCreativeVocFile(byte *ptr, int32 &size, int &rate) {
}
static uint32 decode12BitsSample(byte *src, byte **dst, uint32 size, bool stereo) {
- uint32 s_size = (size / 3) * 4;
- uint32 loop_size = s_size / 4;
+ uint32 loop_size = size / 3;
+ uint32 s_size = loop_size * 4;
if (stereo) {
s_size *= 2;
}
@@ -700,18 +700,14 @@ static uint32 decode12BitsSample(byte *src, byte **dst, uint32 size, bool stereo
byte v2 = *src++;
byte v3 = *src++;
tmp = ((((v2 & 0x0f) << 8) | v1) << 4) - 0x8000;
- *ptr++ = (byte)((tmp >> 8) & 0xff);
- *ptr++ = (byte)(tmp & 0xff);
+ WRITE_BE_UINT16(ptr, tmp); ptr += 2;
if (stereo) {
- *ptr++ = (byte)((tmp >> 8) & 0xff);
- *ptr++ = (byte)(tmp & 0xff);
+ WRITE_BE_UINT16(ptr, tmp); ptr += 2;
}
tmp = ((((v2 & 0xf0) << 4) | v3) << 4) - 0x8000;
- *ptr++ = (byte)((tmp >> 8) & 0xff);
- *ptr++ = (byte)(tmp & 0xff);
+ WRITE_BE_UINT16(ptr, tmp); ptr += 2;
if (stereo) {
- *ptr++ = (byte)((tmp >> 8) & 0xff);
- *ptr++ = (byte)(tmp & 0xff);
+ WRITE_BE_UINT16(ptr, tmp); ptr += 2;
}
}
return s_size;
diff --git a/scumm/smush/imuse_channel.cpp b/scumm/smush/imuse_channel.cpp
index 2c6762008c..3a6ccc843d 100644
--- a/scumm/smush/imuse_channel.cpp
+++ b/scumm/smush/imuse_channel.cpp
@@ -185,27 +185,29 @@ void ImuseChannel::decode() {
_tbufferSize += remaining_size;
}
}
+
+ // FIXME: Code duplication! See decode12BitsSample() in scumm/imuse_digi.cpp
+
int loop_size = _sbufferSize / 3;
- int new_size = loop_size * 2;
+ int new_size = loop_size * 4;
byte *keep, *decoded;
uint32 value;
- keep = decoded = new byte[new_size * 2];
+ keep = decoded = new byte[new_size];
assert(keep);
unsigned char * source = _sbuffer;
- while (loop_size--) {
+
+ while (loop_size--) {
byte v1 = *source++;
byte v2 = *source++;
byte v3 = *source++;
value = ((((v2 & 0x0f) << 8) | v1) << 4) - 0x8000;
- *decoded++ = (byte)((value >> 8) & 0xff);
- *decoded++ = (byte)(value & 0xff);
+ WRITE_BE_UINT16(decoded, value); decoded += 2;
value = ((((v2 & 0xf0) << 4) | v3) << 4) - 0x8000;
- *decoded++ = (byte)((value >> 8) & 0xff);
- *decoded++ = (byte)(value & 0xff);
+ WRITE_BE_UINT16(decoded, value); decoded += 2;
}
delete []_sbuffer;
_sbuffer = (byte *)keep;
- _sbufferSize = new_size * sizeof(int16);
+ _sbufferSize = new_size;
}
bool ImuseChannel::handleSubTags(int32 &offset) {