aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorColin Snover2017-02-21 15:11:12 -0600
committerColin Snover2017-04-22 19:38:12 -0500
commit5231541e7ca5fa74da01d6c60f46f51ff10b3d78 (patch)
tree7d99a8a49346e0328bf58d6c19f55a9dd4fa7c90 /engines
parentf6c4e0c7c7278d643cd723cebae812d2894e27c1 (diff)
downloadscummvm-rg350-5231541e7ca5fa74da01d6c60f46f51ff10b3d78.tar.gz
scummvm-rg350-5231541e7ca5fa74da01d6c60f46f51ff10b3d78.tar.bz2
scummvm-rg350-5231541e7ca5fa74da01d6c60f46f51ff10b3d78.zip
SCI32: Add and divide instead of performing two divisions
This should make things trivially faster, and matches more accurately how the original engine worked.
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/video/robot_decoder.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/engines/sci/video/robot_decoder.cpp b/engines/sci/video/robot_decoder.cpp
index 0cb4831159..d052929eeb 100644
--- a/engines/sci/video/robot_decoder.cpp
+++ b/engines/sci/video/robot_decoder.cpp
@@ -134,7 +134,7 @@ bool RobotAudioStream::addPacket(const RobotAudioPacket &packet) {
return true;
}
- const int32 packetEndByte = packet.position + (packet.dataSize * sizeof(int16) * kEOSExpansion);
+ const int32 packetEndByte = packet.position + (packet.dataSize * (sizeof(int16) + kEOSExpansion));
// Already read all the way past this packet (or already wrote valid samples
// to this channel all the way past this packet), so discard it
@@ -228,12 +228,12 @@ void RobotAudioStream::fillRobotBuffer(const RobotAudioPacket &packet, const int
targetBytePosition = _jointMin[bufferIndex] % _loopBufferSize;
if (targetBytePosition >= packetEndByte) {
numBytesToEnd = _loopBufferSize - targetBytePosition;
- interpolateChannel((int16 *)(_loopBuffer + targetBytePosition), numBytesToEnd / sizeof(int16) / kEOSExpansion, 0);
+ interpolateChannel((int16 *)(_loopBuffer + targetBytePosition), numBytesToEnd / (sizeof(int16) + kEOSExpansion), 0);
targetBytePosition = bufferIndex ? 2 : 0;
}
numBytesToEnd = packetEndByte - targetBytePosition;
if (numBytesToEnd > 0) {
- interpolateChannel((int16 *)(_loopBuffer + targetBytePosition), numBytesToEnd / sizeof(int16) / kEOSExpansion, 0);
+ interpolateChannel((int16 *)(_loopBuffer + targetBytePosition), numBytesToEnd / (sizeof(int16) + kEOSExpansion), 0);
}
}
@@ -246,13 +246,13 @@ void RobotAudioStream::fillRobotBuffer(const RobotAudioPacket &packet, const int
copyEveryOtherSample((int16 *)(_loopBuffer + targetBytePosition), (int16 *)(_decompressionBuffer + sourceByte), numBytesToEnd / kEOSExpansion);
targetBytePosition = bufferIndex ? 2 : 0;
}
- copyEveryOtherSample((int16 *)(_loopBuffer + targetBytePosition), (int16 *)(_decompressionBuffer + sourceByte + numBytesToEnd), (packetEndByte - targetBytePosition) / sizeof(int16) / kEOSExpansion);
+ copyEveryOtherSample((int16 *)(_loopBuffer + targetBytePosition), (int16 *)(_decompressionBuffer + sourceByte + numBytesToEnd), (packetEndByte - targetBytePosition) / (sizeof(int16) + kEOSExpansion));
}
_jointMin[bufferIndex] = endByte;
}
void RobotAudioStream::interpolateMissingSamples(int32 numSamples) {
- int32 numBytes = numSamples * sizeof(int16) * kEOSExpansion;
+ int32 numBytes = numSamples * (sizeof(int16) + kEOSExpansion);
int32 targetPosition = _readHead;
if (_readHeadAbs > _jointMin[1]) {
@@ -268,7 +268,7 @@ void RobotAudioStream::interpolateMissingSamples(int32 numSamples) {
_jointMin[1] += numBytes;
} else {
if (targetPosition + numBytes >= _loopBufferSize) {
- const int32 numSamplesToEdge = (_loopBufferSize - targetPosition) / sizeof(int16) / kEOSExpansion;
+ const int32 numSamplesToEdge = (_loopBufferSize - targetPosition) / (sizeof(int16) + kEOSExpansion);
interpolateChannel((int16 *)(_loopBuffer + targetPosition), numSamplesToEdge, 1);
numSamples -= numSamplesToEdge;
targetPosition = 0;
@@ -278,7 +278,7 @@ void RobotAudioStream::interpolateMissingSamples(int32 numSamples) {
}
} else if (_readHeadAbs > _jointMin[0]) {
if (targetPosition + numBytes >= _loopBufferSize) {
- const int32 numSamplesToEdge = (_loopBufferSize - targetPosition) / sizeof(int16) / kEOSExpansion;
+ const int32 numSamplesToEdge = (_loopBufferSize - targetPosition) / (sizeof(int16) + kEOSExpansion);
interpolateChannel((int16 *)(_loopBuffer + targetPosition), numSamplesToEdge, 0);
numSamples -= numSamplesToEdge;
targetPosition = 2;