[Scummvm-cvs-logs] CVS: scummvm/sound adpcm.cpp,1.9,1.10
Eugene Sandulenko
sev at users.sourceforge.net
Tue Oct 18 20:26:34 CEST 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/kyra screen.cpp,1.13,1.14 screen.h,1.9,1.10 sprites.cpp,1.2,1.3 sprites.h,1.2,1.3
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.480,1.481
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22005
Modified Files:
adpcm.cpp
Log Message:
Simplified common buffer reader. Implemented now unused Microsoft IMA
ADPCM buffer reader. These folks invented ye another incompatible standard
and here it will sit #if 0'ed just for a case.
Index: adpcm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/adpcm.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- adpcm.cpp 18 Oct 2005 01:30:23 -0000 1.9
+++ adpcm.cpp 19 Oct 2005 03:25:00 -0000 1.10
@@ -34,8 +34,6 @@
template <typesADPCM TYPE>
class ADPCMInputStream : public AudioStream {
private:
- bool _evenPos;
- byte _lastByte;
Common::SeekableReadStream *_stream;
uint32 _endpos;
@@ -58,10 +56,14 @@
int getRate() const { return 22050; }
};
+template <>
+int16 ADPCMInputStream<kADPCMOki>::decode(byte code);
+template <>
+int16 ADPCMInputStream<kADPCMIma>::decode(byte code);
template <typesADPCM TYPE>
ADPCMInputStream<TYPE>::ADPCMInputStream(Common::SeekableReadStream *stream, uint32 size)
- : _stream(stream), _evenPos(true) {
+ : _stream(stream) {
_status.last = 0;
_status.stepIndex = 0;
@@ -71,20 +73,44 @@
template <typesADPCM TYPE>
int ADPCMInputStream<TYPE>::readBuffer(int16 *buffer, const int numSamples) {
int samples;
+ byte data;
+
+ assert(numSamples % 2 == 0);
// Since we process high and low nibbles separately never check buffer end
// on low nibble
- for (samples = 0; !_evenPos || samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples++) {
- if (_evenPos) {
- _lastByte = _stream->readByte();
- buffer[samples] = decode((_lastByte >> 4) & 0x0f);
- } else {
- buffer[samples] = decode(_lastByte & 0x0f);
+ for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
+ data = _stream->readByte();
+ buffer[samples] = decode((data >> 4) & 0x0f);
+ buffer[samples + 1] = decode(data & 0x0f);
+ }
+ return samples;
+}
+
+// Microsoft as usual tries to implement it differently. Though we don't
+// use this now
+#if 0
+template <>
+int ADPCMInputStream<kADPCMIma>::readBuffer(int16 *buffer, const int numSamples) {
+ int samples;
+ uint32 data;
+ int nibble;
+
+ for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos;) {
+ for (int channel = 0; channel < 2; channel++) {
+ data = _stream->readUint32LE();
+
+ for (nibble = 0; nibble < 8; nibble++) {
+ byte k = ((data & 0xf0000000) >> 28);
+ buffer[samples + channel + nibble * 2] = decode(k);
+ data <<= 4;
+ }
}
- _evenPos = !_evenPos;
+ samples += 16;
}
return samples;
}
+#endif
// adjust the step for use on the next sample.
template <typesADPCM TYPE>
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/kyra screen.cpp,1.13,1.14 screen.h,1.9,1.10 sprites.cpp,1.2,1.3 sprites.h,1.2,1.3
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.480,1.481
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list