[Scummvm-cvs-logs] SF.net SVN: scummvm:[35209] scummvm/trunk/sound/adpcm.cpp
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Tue Dec 2 22:58:48 CET 2008
Revision: 35209
http://scummvm.svn.sourceforge.net/scummvm/?rev=35209&view=rev
Author: drmccoy
Date: 2008-12-02 21:58:48 +0000 (Tue, 02 Dec 2008)
Log Message:
-----------
Apparently, constraining the number of mixing samples to be divisible by 4 is too strict, so I'm changing readBufferTinsel6() around a bit to allow for any number of samples (at the cost of adding 2 variables and a bit complexity ;))
Modified Paths:
--------------
scummvm/trunk/sound/adpcm.cpp
Modified: scummvm/trunk/sound/adpcm.cpp
===================================================================
--- scummvm/trunk/sound/adpcm.cpp 2008-12-02 21:26:41 UTC (rev 35208)
+++ scummvm/trunk/sound/adpcm.cpp 2008-12-02 21:58:48 UTC (rev 35209)
@@ -43,6 +43,8 @@
typesADPCM _type;
uint32 _blockAlign;
uint32 _blockPos;
+ uint8 _chunkPos;
+ uint16 _chunkData;
int _blockLen;
int _rate;
@@ -111,6 +113,8 @@
_endpos = stream->pos() + size;
_blockLen = 0;
_blockPos = _blockAlign; // To make sure first header is read
+ _chunkPos = 0;
+ _chunkData = 0;
if (type == kADPCMMSIma && blockAlign == 0)
error("ADPCMInputStream(): blockAlign isn't specifiled for MS IMA ADPCM");
@@ -332,30 +336,43 @@
int ADPCMInputStream::readBufferTinsel6(int channels, int16 *buffer, const int numSamples) {
int samples;
- uint16 data;
const double eVal = 1.032226562;
samples = 0;
- assert(numSamples % 4 == 0);
-
while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) {
if (_blockPos == _blockAlign) {
readBufferTinselHeader();
_blockPos = 0;
+ _chunkPos = 0;
}
- for (; samples < numSamples && _blockPos < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 4, _blockPos += 3) {
- // Read 3 bytes = 24 bits = four 6 bit blocks
- data = _stream->readByte();
- buffer[samples] = TO_LE_16(decodeTinsel((data << 8) & 0xFC00, eVal));
- data = (data << 8) | (_stream->readByte());
- buffer[samples+1] = TO_LE_16(decodeTinsel((data << 6) & 0xFC00, eVal));
- data = (data << 8) | (_stream->readByte());
- buffer[samples+2] = TO_LE_16(decodeTinsel((data << 4) & 0xFC00, eVal));
- data = (data << 8);
- buffer[samples+3] = TO_LE_16(decodeTinsel((data << 2) & 0xFC00, eVal));
+ for (; samples < numSamples && _blockPos < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples++, _chunkPos = (_chunkPos + 1) % 4) {
+
+ switch (_chunkPos) {
+ case 0:
+ _chunkData = _stream->readByte();
+ buffer[samples] = TO_LE_16(decodeTinsel((_chunkData << 8) & 0xFC00, eVal));
+ break;
+ case 1:
+ _chunkData = (_chunkData << 8) | (_stream->readByte());
+ buffer[samples] = TO_LE_16(decodeTinsel((_chunkData << 6) & 0xFC00, eVal));
+ _blockPos++;
+ break;
+ case 2:
+ _chunkData = (_chunkData << 8) | (_stream->readByte());
+ buffer[samples] = TO_LE_16(decodeTinsel((_chunkData << 4) & 0xFC00, eVal));
+ _blockPos++;
+ break;
+ case 3:
+ _chunkData = (_chunkData << 8);
+ buffer[samples] = TO_LE_16(decodeTinsel((_chunkData << 2) & 0xFC00, eVal));
+ _blockPos++;
+ break;
+ }
+
}
+
}
return samples;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list