aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/scumm/imuse_digi/dimuse.cpp60
-rw-r--r--engines/scumm/imuse_digi/dimuse_bndmgr.cpp58
-rw-r--r--engines/scumm/imuse_digi/dimuse_bndmgr.h10
-rw-r--r--engines/scumm/imuse_digi/dimuse_codecs.cpp150
4 files changed, 139 insertions, 139 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp
index 31c97dac19..0221657966 100644
--- a/engines/scumm/imuse_digi/dimuse.cpp
+++ b/engines/scumm/imuse_digi/dimuse.cpp
@@ -275,8 +275,8 @@ void IMuseDigital::callback() {
type = Audio::Mixer::kMusicSoundType;
if (track->stream) {
- byte *data = NULL;
- int32 result = 0;
+ byte *tmpSndBufferPtr = NULL;
+ int32 curFeedSize = 0;
if (track->curRegion == -1) {
switchToNextRegion(track);
@@ -287,73 +287,73 @@ void IMuseDigital::callback() {
int bits = _sound->getBits(track->soundHandle);
int channels = _sound->getChannels(track->soundHandle);
- int32 mixer_size = track->feedSize / _callbackFps;
+ int32 feedSize = track->feedSize / _callbackFps;
if (track->stream->endOfData()) {
- mixer_size *= 2;
+ feedSize *= 2;
}
if ((bits == 12) || (bits == 16)) {
if (channels == 1)
- mixer_size &= ~1;
+ feedSize &= ~1;
if (channels == 2)
- mixer_size &= ~3;
+ feedSize &= ~3;
} else {
if (channels == 2)
- mixer_size &= ~1;
+ feedSize &= ~1;
}
- if (mixer_size == 0)
+ if (feedSize == 0)
continue;
do {
if (bits == 12) {
- byte *ptr = NULL;
+ byte *tmpPtr = NULL;
- mixer_size += track->dataMod12Bit;
- int mixer_size_12 = (mixer_size * 3) / 4;
- int length = (mixer_size_12 / 3) * 4;
- track->dataMod12Bit = mixer_size - length;
+ feedSize += track->dataMod12Bit;
+ int tmpFeedSize12Bits = (feedSize * 3) / 4;
+ int tmpLength12Bits = (tmpFeedSize12Bits / 3) * 4;
+ track->dataMod12Bit = feedSize - tmpLength12Bits;
- int32 offset = (track->regionOffset * 3) / 4;
- int result2 = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &ptr, offset, mixer_size_12);
- result = BundleCodecs::decode12BitsSample(ptr, &data, result2);
+ int32 tmpOffset = (track->regionOffset * 3) / 4;
+ int tmpFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpPtr, tmpOffset, tmpFeedSize12Bits);
+ curFeedSize = BundleCodecs::decode12BitsSample(tmpPtr, &tmpSndBufferPtr, tmpFeedSize);
- free(ptr);
+ free(tmpPtr);
} else if (bits == 16) {
- result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size);
+ curFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize);
if (channels == 1) {
- result &= ~1;
+ curFeedSize &= ~1;
}
if (channels == 2) {
- result &= ~3;
+ curFeedSize &= ~3;
}
} else if (bits == 8) {
- result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size);
+ curFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize);
if (channels == 2) {
- result &= ~1;
+ curFeedSize &= ~1;
}
}
- if (result > mixer_size)
- result = mixer_size;
+ if (curFeedSize > feedSize)
+ curFeedSize = feedSize;
if (_mixer->isReady()) {
_mixer->setChannelVolume(track->mixChanHandle, vol);
_mixer->setChannelBalance(track->mixChanHandle, pan);
- track->stream->queueBuffer(data, result);
- track->regionOffset += result;
+ track->stream->queueBuffer(tmpSndBufferPtr, curFeedSize);
+ track->regionOffset += curFeedSize;
} else
- delete[] data;
+ delete[] tmpSndBufferPtr;
if (_sound->isEndOfRegion(track->soundHandle, track->curRegion)) {
switchToNextRegion(track);
if (track->toBeRemoved)
break;
}
- mixer_size -= result;
- assert(mixer_size >= 0);
- } while (mixer_size != 0);
+ feedSize -= curFeedSize;
+ assert(feedSize >= 0);
+ } while (feedSize != 0);
} else if (track->streamSou) {
if (_mixer->isReady()) {
if (!track->mixerStreamRunning) {
diff --git a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
index 389ed6897c..03b3e4e74a 100644
--- a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
+++ b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
@@ -247,13 +247,13 @@ bool BundleMgr::loadCompTable(int32 index) {
return true;
}
-int32 BundleMgr::decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside) {
- return decompressSampleByIndex(_curSampleId, offset, size, comp_final, header_size, header_outside);
+int32 BundleMgr::decompressSampleByCurIndex(int32 offset, int32 size, byte **compFinal, int headerSize, bool headerOutside) {
+ return decompressSampleByIndex(_curSampleId, offset, size, compFinal, headerSize, headerOutside);
}
-int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside) {
- int32 i, final_size, output_size;
- int skip, first_block, last_block;
+int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **compFinal, int headerSize, bool headerOutside) {
+ int32 i, finalSize, outputSize;
+ int skip, firstBlock, lastBlock;
assert(0 <= index && index < _numFiles);
@@ -273,21 +273,21 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size,
return 0;
}
- first_block = (offset + header_size) / 0x2000;
- last_block = (offset + header_size + size - 1) / 0x2000;
+ firstBlock = (offset + headerSize) / 0x2000;
+ lastBlock = (offset + headerSize + size - 1) / 0x2000;
// Clip last_block by the total number of blocks (= "comp items")
- if ((last_block >= _numCompItems) && (_numCompItems > 0))
- last_block = _numCompItems - 1;
+ if ((lastBlock >= _numCompItems) && (_numCompItems > 0))
+ lastBlock = _numCompItems - 1;
- int32 blocks_final_size = 0x2000 * (1 + last_block - first_block);
- *comp_final = (byte *)malloc(blocks_final_size);
- assert(*comp_final);
- final_size = 0;
+ int32 blocksFinalSize = 0x2000 * (1 + lastBlock - firstBlock);
+ *compFinal = (byte *)malloc(blocksFinalSize);
+ assert(*compFinal);
+ finalSize = 0;
- skip = (offset + header_size) % 0x2000;
+ skip = (offset + headerSize) % 0x2000;
- for (i = first_block; i <= last_block; i++) {
+ for (i = firstBlock; i <= lastBlock; i++) {
if (_lastBlock != i) {
// CMI hack: one more zero byte at the end of input buffer
_compInputBuff[_compTable[i].size] = 0;
@@ -300,27 +300,27 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size,
_lastBlock = i;
}
- output_size = _outputSize;
+ outputSize = _outputSize;
- if (header_outside) {
- output_size -= skip;
+ if (headerOutside) {
+ outputSize -= skip;
} else {
- if ((header_size != 0) && (skip >= header_size))
- output_size -= skip;
+ if ((headerSize != 0) && (skip >= headerSize))
+ outputSize -= skip;
}
- if ((output_size + skip) > 0x2000) // workaround
- output_size -= (output_size + skip) - 0x2000;
+ if ((outputSize + skip) > 0x2000) // workaround
+ outputSize -= (outputSize + skip) - 0x2000;
- if (output_size > size)
- output_size = size;
+ if (outputSize > size)
+ outputSize = size;
- assert(final_size + output_size <= blocks_final_size);
+ assert(finalSize + outputSize <= blocksFinalSize);
- memcpy(*comp_final + final_size, _compOutputBuff + skip, output_size);
- final_size += output_size;
+ memcpy(*compFinal + finalSize, _compOutputBuff + skip, outputSize);
+ finalSize += outputSize;
- size -= output_size;
+ size -= outputSize;
assert(size >= 0);
if (size == 0)
break;
@@ -328,7 +328,7 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size,
skip = 0;
}
- return final_size;
+ return finalSize;
}
int32 BundleMgr::decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final, bool header_outside) {
diff --git a/engines/scumm/imuse_digi/dimuse_bndmgr.h b/engines/scumm/imuse_digi/dimuse_bndmgr.h
index a23bb462d4..65360d8ba4 100644
--- a/engines/scumm/imuse_digi/dimuse_bndmgr.h
+++ b/engines/scumm/imuse_digi/dimuse_bndmgr.h
@@ -99,19 +99,19 @@ public:
BundleMgr(BundleDirCache *_cache);
~BundleMgr();
- bool open(const char *filename, bool &compressed, bool errorFlag=false);
+ bool open(const char *filename, bool &compressed, bool errorFlag = false);
void close();
Common::File *getFile(const char *filename, int32 &offset, int32 &size);
- int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final, bool header_outside);
- int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside);
- int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside);
+ int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **compFinal, bool headerOutside);
+ int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **compFinal, int header_size, bool headerOutside);
+ int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **compFinal, int headerSize, bool headerOutside);
};
namespace BundleCodecs {
uint32 decode12BitsSample(const byte *src, byte **dst, uint32 size);
void initializeImcTables();
-int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 input_size);
+int32 decompressCodec(int32 codec, byte *compInput, byte *compOutput, int32 inputSize);
} // End of namespace BundleCodecs
diff --git a/engines/scumm/imuse_digi/dimuse_codecs.cpp b/engines/scumm/imuse_digi/dimuse_codecs.cpp
index 601bfddbe9..17082f5256 100644
--- a/engines/scumm/imuse_digi/dimuse_codecs.cpp
+++ b/engines/scumm/imuse_digi/dimuse_codecs.cpp
@@ -188,51 +188,51 @@ static int32 compDecode(byte *src, byte *dst) {
}
#undef NextBit
-int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 input_size) {
- int32 output_size, channels;
+int32 decompressCodec(int32 codec, byte *compInput, byte *compOutput, int32 inputSize) {
+ int32 outputSize, channels;
int32 offset1, offset2, offset3, length, k, c, s, j, r, t, z;
byte *src, *t_table, *p, *ptr;
byte t_tmp1, t_tmp2;
switch (codec) {
case 0:
- memcpy(comp_output, comp_input, input_size);
- output_size = input_size;
+ memcpy(compOutput, compInput, inputSize);
+ outputSize = inputSize;
break;
case 1:
- output_size = compDecode(comp_input, comp_output);
+ outputSize = compDecode(compInput, compOutput);
break;
case 2:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 1; z < output_size; z++)
+ outputSize = compDecode(compInput, compOutput);
+ p = compOutput;
+ for (z = 1; z < outputSize; z++)
p[z] += p[z - 1];
break;
case 3:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
+ outputSize = compDecode(compInput, compOutput);
+ p = compOutput;
+ for (z = 2; z < outputSize; z++)
p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
+ for (z = 1; z < outputSize; z++)
p[z] += p[z - 1];
break;
case 4:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
+ outputSize = compDecode(compInput, compOutput);
+ p = compOutput;
+ for (z = 2; z < outputSize; z++)
p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
+ for (z = 1; z < outputSize; z++)
p[z] += p[z - 1];
- t_table = (byte *)malloc(output_size);
+ t_table = (byte *)malloc(outputSize);
assert(t_table);
- src = comp_output;
- length = (output_size << 3) / 12;
+ src = compOutput;
+ length = (outputSize << 3) / 12;
k = 0;
if (length > 0) {
c = -12;
@@ -258,23 +258,23 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in
}
offset1 = ((length - 1) * 3) >> 1;
t_table[offset1 + 1] = (t_table[offset1 + 1]) | (src[length - 1] & 0xf0);
- memcpy(src, t_table, output_size);
+ memcpy(src, t_table, outputSize);
free(t_table);
break;
case 5:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
+ outputSize = compDecode(compInput, compOutput);
+ p = compOutput;
+ for (z = 2; z < outputSize; z++)
p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
+ for (z = 1; z < outputSize; z++)
p[z] += p[z - 1];
- t_table = (byte *)malloc(output_size);
+ t_table = (byte *)malloc(outputSize);
assert(t_table);
- src = comp_output;
- length = (output_size << 3) / 12;
+ src = compOutput;
+ length = (outputSize << 3) / 12;
k = 1;
c = 0;
s = 12;
@@ -300,29 +300,29 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in
j++;
} while (k < t);
}
- memcpy(src, t_table, output_size);
+ memcpy(src, t_table, outputSize);
free(t_table);
break;
case 6:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
+ outputSize = compDecode(compInput, compOutput);
+ p = compOutput;
+ for (z = 2; z < outputSize; z++)
p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
+ for (z = 1; z < outputSize; z++)
p[z] += p[z - 1];
- t_table = (byte *)malloc(output_size);
+ t_table = (byte *)malloc(outputSize);
assert(t_table);
- src = comp_output;
- length = (output_size << 3) / 12;
+ src = compOutput;
+ length = (outputSize << 3) / 12;
k = 0;
c = 0;
j = 0;
s = -12;
- t_table[0] = src[output_size - 1];
- t_table[output_size - 1] = src[length - 1];
+ t_table[0] = src[outputSize - 1];
+ t_table[outputSize - 1] = src[length - 1];
t = length - 1;
if (t > 0) {
do {
@@ -343,26 +343,26 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in
j++;
} while (k < t);
}
- memcpy(src, t_table, output_size);
+ memcpy(src, t_table, outputSize);
free(t_table);
break;
case 10:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
+ outputSize = compDecode(compInput, compOutput);
+ p = compOutput;
+ for (z = 2; z < outputSize; z++)
p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
+ for (z = 1; z < outputSize; z++)
p[z] += p[z - 1];
- t_table = (byte *)malloc(output_size);
+ t_table = (byte *)malloc(outputSize);
assert(t_table);
- memcpy(t_table, p, output_size);
+ memcpy(t_table, p, outputSize);
- offset1 = output_size / 3;
+ offset1 = outputSize / 3;
offset2 = offset1 << 1;
offset3 = offset2;
- src = comp_output;
+ src = compOutput;
while (offset1--) {
offset2 -= 2;
@@ -371,8 +371,8 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in
t_table[offset2 + 1] = src[offset3];
}
- src = comp_output;
- length = (output_size << 3) / 12;
+ src = compOutput;
+ length = (outputSize << 3) / 12;
k = 0;
if (length > 0) {
c = -12;
@@ -402,21 +402,21 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in
break;
case 11:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
+ outputSize = compDecode(compInput, compOutput);
+ p = compOutput;
+ for (z = 2; z < outputSize; z++)
p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
+ for (z = 1; z < outputSize; z++)
p[z] += p[z - 1];
- t_table = (byte *)malloc(output_size);
+ t_table = (byte *)malloc(outputSize);
assert(t_table);
- memcpy(t_table, p, output_size);
+ memcpy(t_table, p, outputSize);
- offset1 = output_size / 3;
+ offset1 = outputSize / 3;
offset2 = offset1 << 1;
offset3 = offset2;
- src = comp_output;
+ src = compOutput;
while (offset1--) {
offset2 -= 2;
@@ -425,8 +425,8 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in
t_table[offset2 + 1] = src[offset3];
}
- src = comp_output;
- length = (output_size << 3) / 12;
+ src = compOutput;
+ length = (outputSize << 3) / 12;
k = 1;
c = 0;
s = 12;
@@ -456,21 +456,21 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in
break;
case 12:
- output_size = compDecode(comp_input, comp_output);
- p = comp_output;
- for (z = 2; z < output_size; z++)
+ outputSize = compDecode(compInput, compOutput);
+ p = compOutput;
+ for (z = 2; z < outputSize; z++)
p[z] += p[z - 1];
- for (z = 1; z < output_size; z++)
+ for (z = 1; z < outputSize; z++)
p[z] += p[z - 1];
- t_table = (byte *)malloc(output_size);
+ t_table = (byte *)malloc(outputSize);
assert(t_table);
- memcpy(t_table, p, output_size);
+ memcpy(t_table, p, outputSize);
- offset1 = output_size / 3;
+ offset1 = outputSize / 3;
offset2 = offset1 << 1;
offset3 = offset2;
- src = comp_output;
+ src = compOutput;
while (offset1--) {
offset2 -= 2;
@@ -479,13 +479,13 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in
t_table[offset2 + 1] = src[offset3];
}
- src = comp_output;
- length = (output_size << 3) / 12;
+ src = compOutput;
+ length = (outputSize << 3) / 12;
k = 0;
c = 0;
s = -12;
- src[0] = t_table[output_size - 1];
- src[output_size - 1] = t_table[length - 1];
+ src[0] = t_table[outputSize - 1];
+ src[outputSize - 1] = t_table[length - 1];
t = length - 1;
if (t > 0) {
do {
@@ -536,9 +536,9 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in
// We only support mono and stereo
assert(channels == 1 || channels == 2);
- src = comp_input;
- dst = comp_output;
- output_size = 0x2000;
+ src = compInput;
+ dst = compOutput;
+ outputSize = 0x2000;
outputSamplesLeft = 0x1000;
// Every data packet contains 0x2000 bytes of audio data
@@ -641,11 +641,11 @@ int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 in
default:
error("BundleCodecs::decompressCodec() Unknown codec %d!", (int)codec);
- output_size = 0;
+ outputSize = 0;
break;
}
- return output_size;
+ return outputSize;
}
} // End of namespace BundleCodecs