diff options
author | Matthew Hoops | 2011-04-24 23:14:14 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-04-24 23:14:14 -0400 |
commit | 9d8874c7072709c3739efdad317454cdccf82683 (patch) | |
tree | e961543a8e1988e2145d3d062717e02287cc7ae0 /audio/decoders/adpcm_intern.h | |
parent | de5ec741ffbc491ec33100f7b60d1e4928e8f302 (diff) | |
download | scummvm-rg350-9d8874c7072709c3739efdad317454cdccf82683.tar.gz scummvm-rg350-9d8874c7072709c3739efdad317454cdccf82683.tar.bz2 scummvm-rg350-9d8874c7072709c3739efdad317454cdccf82683.zip |
AUDIO: Cleanup MS IMA handling
- Split The Last Express' ADPCM to the engine. Using the MS IMA routine was really a hack.
- Fixed stereo MS IMA ADPCM, the old routine was completely wrong.
Diffstat (limited to 'audio/decoders/adpcm_intern.h')
-rw-r--r-- | audio/decoders/adpcm_intern.h | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/audio/decoders/adpcm_intern.h b/audio/decoders/adpcm_intern.h index ea20b40338..dd8c14be79 100644 --- a/audio/decoders/adpcm_intern.h +++ b/audio/decoders/adpcm_intern.h @@ -148,24 +148,30 @@ public: class MSIma_ADPCMStream : public Ima_ADPCMStream { public: - MSIma_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign, bool invertSamples = false) - : Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign), _invertSamples(invertSamples) { + MSIma_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) + : Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { + if (blockAlign == 0) - error("ADPCMStream(): blockAlign isn't specified for MS IMA ADPCM"); - } + error("MSIma_ADPCMStream(): blockAlign isn't specified"); - virtual int readBuffer(int16 *buffer, const int numSamples) { - if (_channels == 1) - return readBufferMSIMA1(buffer, numSamples); - else - return readBufferMSIMA2(buffer, numSamples); + if (blockAlign % (_channels * 4)) + error("MSIma_ADPCMStream(): invalid blockAlign"); + + _samplesLeft[0] = 0; + _samplesLeft[1] = 0; } - int readBufferMSIMA1(int16 *buffer, const int numSamples); - int readBufferMSIMA2(int16 *buffer, const int numSamples); + virtual int readBuffer(int16 *buffer, const int numSamples); + + void reset() { + Ima_ADPCMStream::reset(); + _samplesLeft[0] = 0; + _samplesLeft[1] = 0; + } private: - bool _invertSamples; // Some implementations invert the way samples are decoded + int16 _buffer[2][8]; + int _samplesLeft[2]; }; class MS_ADPCMStream : public ADPCMStream { |