diff options
author | Matthew Hoops | 2011-05-11 00:30:02 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-05-11 00:30:28 -0400 |
commit | a1d41da096c0bcf502a85919cb1cb1ee471719c5 (patch) | |
tree | 8c51419daa486f1d4833757db4715dadab6c3497 /audio/decoders | |
parent | accb0c2a5d0c9e7b353cda4b74f511a498ed8073 (diff) | |
parent | 33c3e19cea2a08fbf26ecbe940763e8ee1c37d28 (diff) | |
download | scummvm-rg350-a1d41da096c0bcf502a85919cb1cb1ee471719c5.tar.gz scummvm-rg350-a1d41da096c0bcf502a85919cb1cb1ee471719c5.tar.bz2 scummvm-rg350-a1d41da096c0bcf502a85919cb1cb1ee471719c5.zip |
Merge remote branch 'upstream/master' into t7g-ios
Conflicts:
audio/decoders/qdm2.h
common/util.cpp
engines/groovie/music.cpp
engines/groovie/resource.h
video/qt_decoder.cpp
video/qt_decoder.h
Diffstat (limited to 'audio/decoders')
-rw-r--r-- | audio/decoders/aac.cpp | 1 | ||||
-rw-r--r-- | audio/decoders/adpcm.cpp | 76 | ||||
-rw-r--r-- | audio/decoders/adpcm.h | 6 | ||||
-rw-r--r-- | audio/decoders/adpcm_intern.h | 35 | ||||
-rw-r--r-- | audio/decoders/aiff.cpp | 4 | ||||
-rw-r--r-- | audio/decoders/aiff.h | 4 | ||||
-rw-r--r-- | audio/decoders/flac.cpp | 1 | ||||
-rw-r--r-- | audio/decoders/flac.h | 3 | ||||
-rw-r--r-- | audio/decoders/iff_sound.cpp | 1 | ||||
-rw-r--r-- | audio/decoders/iff_sound.h | 2 | ||||
-rw-r--r-- | audio/decoders/mac_snd.cpp | 3 | ||||
-rw-r--r-- | audio/decoders/mac_snd.h | 4 | ||||
-rw-r--r-- | audio/decoders/mp3.cpp | 1 | ||||
-rw-r--r-- | audio/decoders/mp3.h | 3 | ||||
-rw-r--r-- | audio/decoders/qdm2.cpp | 3 | ||||
-rw-r--r-- | audio/decoders/qdm2.h | 2 | ||||
-rw-r--r-- | audio/decoders/quicktime.cpp | 1 | ||||
-rw-r--r-- | audio/decoders/raw.cpp | 3 | ||||
-rw-r--r-- | audio/decoders/raw.h | 6 | ||||
-rw-r--r-- | audio/decoders/vag.h | 3 | ||||
-rw-r--r-- | audio/decoders/voc.cpp | 2 | ||||
-rw-r--r-- | audio/decoders/voc.h | 6 | ||||
-rw-r--r-- | audio/decoders/vorbis.cpp | 6 | ||||
-rw-r--r-- | audio/decoders/vorbis.h | 3 | ||||
-rw-r--r-- | audio/decoders/wave.cpp | 3 | ||||
-rw-r--r-- | audio/decoders/wave.h | 4 |
26 files changed, 93 insertions, 93 deletions
diff --git a/audio/decoders/aac.cpp b/audio/decoders/aac.cpp index fd9c4a075c..7949b5b561 100644 --- a/audio/decoders/aac.cpp +++ b/audio/decoders/aac.cpp @@ -29,6 +29,7 @@ #include "common/debug.h" #include "common/stream.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/audiostream.h" diff --git a/audio/decoders/adpcm.cpp b/audio/decoders/adpcm.cpp index ac18b244c5..a9284973d5 100644 --- a/audio/decoders/adpcm.cpp +++ b/audio/decoders/adpcm.cpp @@ -23,11 +23,12 @@ * */ -#include "common/endian.h" +#include "common/stream.h" +#include "common/textconsole.h" +#include "common/util.h" #include "audio/decoders/adpcm.h" #include "audio/decoders/adpcm_intern.h" -#include "audio/audiostream.h" namespace Audio { @@ -201,60 +202,49 @@ int Apple_ADPCMStream::readBuffer(int16 *buffer, const int numSamples) { return samples[0] + samples[1]; } + #pragma mark - -int MSIma_ADPCMStream::readBufferMSIMA1(int16 *buffer, const int numSamples) { - int samples = 0; - byte data; +int MSIma_ADPCMStream::readBuffer(int16 *buffer, const int numSamples) { + // Need to write at least one sample per channel + assert((numSamples % _channels) == 0); - assert(numSamples % 2 == 0); + int samples = 0; while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) { if (_blockPos[0] == _blockAlign) { - // read block header - _status.ima_ch[0].last = _stream->readSint16LE(); - _status.ima_ch[0].stepIndex = _stream->readSint16LE(); - _blockPos[0] = 4; - } + for (int i = 0; i < _channels; i++) { + // read block header + _status.ima_ch[i].last = _stream->readSint16LE(); + _status.ima_ch[i].stepIndex = _stream->readSint16LE(); + } - for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2) { - data = _stream->readByte(); - _blockPos[0]++; - buffer[samples] = decodeIMA(_invertSamples ? (data >> 4) & 0x0f : data & 0x0f); - buffer[samples + 1] = decodeIMA(_invertSamples ? data & 0x0f : (data >> 4) & 0x0f); + _blockPos[0] = _channels * 4; } - } - return samples; -} + // Decode a set of samples + for (int i = 0; i < _channels; i++) { + // The stream encodes four bytes per channel at a time + for (int j = 0; j < 4; j++) { + byte data = _stream->readByte(); + _blockPos[0]++; + _buffer[i][j * 2] = decodeIMA(data & 0x0f, i); + _buffer[i][j * 2 + 1] = decodeIMA((data >> 4) & 0x0f, i); + _samplesLeft[i] += 2; + } + } -// Microsoft as usual tries to implement it differently. This method -// is used for stereo data. -int MSIma_ADPCMStream::readBufferMSIMA2(int16 *buffer, const int numSamples) { - int samples; - uint32 data; - int nibble; - byte k; - - // TODO: Currently this implementation only supports - // reading a multiple of 16 samples at once. We might - // consider changing that so it could read an arbitrary - // sample pair count. - assert(numSamples % 16 == 0); - - 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++) { - k = ((data & 0xf0000000) >> 28); - buffer[samples + channel + nibble * 2] = decodeIMA(k); - data <<= 4; + while (samples < numSamples && _samplesLeft[0] != 0) { + for (int i = 0; i < _channels; i++) { + buffer[samples] = _buffer[i][8 - _samplesLeft[i]]; + _samplesLeft[i]--; } + + samples += _channels; } - samples += 16; } + return samples; } @@ -449,8 +439,6 @@ RewindableAudioStream *makeADPCMStream(Common::SeekableReadStream *stream, Dispo return new Oki_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign); case kADPCMMSIma: return new MSIma_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign); - case kADPCMMSImaLastExpress: - return new MSIma_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign, true); case kADPCMMS: return new MS_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign); case kADPCMDVI: diff --git a/audio/decoders/adpcm.h b/audio/decoders/adpcm.h index 7202d6bc9c..10344101e2 100644 --- a/audio/decoders/adpcm.h +++ b/audio/decoders/adpcm.h @@ -40,12 +40,13 @@ #include "common/scummsys.h" #include "common/types.h" -namespace Common { class SeekableReadStream; } +namespace Common { +class SeekableReadStream; +} namespace Audio { -class AudioStream; class RewindableAudioStream; // There are several types of ADPCM encoding, only some are supported here @@ -56,7 +57,6 @@ class RewindableAudioStream; enum typesADPCM { kADPCMOki, // Dialogic/Oki ADPCM (aka VOX) kADPCMMSIma, // Microsoft IMA ADPCM - kADPCMMSImaLastExpress, // Microsoft IMA ADPCM (with inverted samples) kADPCMMS, // Microsoft ADPCM kADPCMDVI, // Intel DVI IMA ADPCM kADPCMApple, // Apple QuickTime IMA ADPCM diff --git a/audio/decoders/adpcm_intern.h b/audio/decoders/adpcm_intern.h index 2d56c9d468..f875bd88c7 100644 --- a/audio/decoders/adpcm_intern.h +++ b/audio/decoders/adpcm_intern.h @@ -24,7 +24,7 @@ */ /** - * Internal interfaces to the ADPCM encoders. + * Internal interfaces to the ADPCM decoders. * * These can be used to make custom ADPCM decoder subclasses, * or to at least share some common data tables between various @@ -37,6 +37,7 @@ #include "audio/audiostream.h" #include "common/endian.h" #include "common/stream.h" +#include "common/textconsole.h" namespace Audio { @@ -52,7 +53,7 @@ protected: uint32 _blockPos[2]; const int _rate; - struct { + struct ADPCMStatus { // OKI/IMA struct { int32 last; @@ -148,24 +149,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"); + + if (blockAlign % (_channels * 4)) + error("MSIma_ADPCMStream(): invalid blockAlign"); - virtual int readBuffer(int16 *buffer, const int numSamples) { - if (_channels == 1) - return readBufferMSIMA1(buffer, numSamples); - else - return readBufferMSIMA2(buffer, numSamples); + _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 { diff --git a/audio/decoders/aiff.cpp b/audio/decoders/aiff.cpp index 0f947752f6..957fb13638 100644 --- a/audio/decoders/aiff.cpp +++ b/audio/decoders/aiff.cpp @@ -32,12 +32,10 @@ */ #include "common/endian.h" -#include "common/util.h" #include "common/stream.h" +#include "common/textconsole.h" #include "audio/decoders/aiff.h" -#include "audio/audiostream.h" -#include "audio/mixer.h" #include "audio/decoders/raw.h" namespace Audio { diff --git a/audio/decoders/aiff.h b/audio/decoders/aiff.h index 06c56ecd38..dddbffb520 100644 --- a/audio/decoders/aiff.h +++ b/audio/decoders/aiff.h @@ -37,7 +37,9 @@ #include "common/scummsys.h" #include "common/types.h" -namespace Common { class SeekableReadStream; } +namespace Common { +class SeekableReadStream; +} namespace Audio { diff --git a/audio/decoders/flac.cpp b/audio/decoders/flac.cpp index 76b6d35419..fe15877ac6 100644 --- a/audio/decoders/flac.cpp +++ b/audio/decoders/flac.cpp @@ -32,6 +32,7 @@ #include "common/debug.h" #include "common/stream.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/audiostream.h" diff --git a/audio/decoders/flac.h b/audio/decoders/flac.h index 17f95ec1fb..69222f22a1 100644 --- a/audio/decoders/flac.h +++ b/audio/decoders/flac.h @@ -49,12 +49,11 @@ #ifdef USE_FLAC namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace Audio { -class AudioStream; class SeekableAudioStream; /** diff --git a/audio/decoders/iff_sound.cpp b/audio/decoders/iff_sound.cpp index 2ec189c586..8efe017e75 100644 --- a/audio/decoders/iff_sound.cpp +++ b/audio/decoders/iff_sound.cpp @@ -25,7 +25,6 @@ #include "audio/decoders/iff_sound.h" #include "audio/audiostream.h" -#include "audio/mixer.h" #include "audio/decoders/raw.h" #include "common/iff_container.h" #include "common/func.h" diff --git a/audio/decoders/iff_sound.h b/audio/decoders/iff_sound.h index 4e53059380..4d26b32e71 100644 --- a/audio/decoders/iff_sound.h +++ b/audio/decoders/iff_sound.h @@ -33,7 +33,7 @@ #define SOUND_IFF_H namespace Common { - class ReadStream; +class ReadStream; } namespace Audio { diff --git a/audio/decoders/mac_snd.cpp b/audio/decoders/mac_snd.cpp index 7c1a2f75f0..fc69988860 100644 --- a/audio/decoders/mac_snd.cpp +++ b/audio/decoders/mac_snd.cpp @@ -30,11 +30,10 @@ * We implement both type 1 and type 2 snd resources, but only those that are sampled */ -#include "common/util.h" +#include "common/textconsole.h" #include "common/stream.h" #include "audio/decoders/mac_snd.h" -#include "audio/audiostream.h" #include "audio/decoders/raw.h" namespace Audio { diff --git a/audio/decoders/mac_snd.h b/audio/decoders/mac_snd.h index 198a61333e..bf6331a265 100644 --- a/audio/decoders/mac_snd.h +++ b/audio/decoders/mac_snd.h @@ -35,7 +35,9 @@ #include "common/scummsys.h" #include "common/types.h" -namespace Common { class SeekableReadStream; } +namespace Common { +class SeekableReadStream; +} namespace Audio { diff --git a/audio/decoders/mp3.cpp b/audio/decoders/mp3.cpp index 53d68fa9db..91bd49873a 100644 --- a/audio/decoders/mp3.cpp +++ b/audio/decoders/mp3.cpp @@ -29,6 +29,7 @@ #include "common/debug.h" #include "common/stream.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/audiostream.h" diff --git a/audio/decoders/mp3.h b/audio/decoders/mp3.h index 72bc6e1b3e..d3a5b70d45 100644 --- a/audio/decoders/mp3.h +++ b/audio/decoders/mp3.h @@ -50,12 +50,11 @@ #ifdef USE_MAD namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace Audio { -class AudioStream; class SeekableAudioStream; /** diff --git a/audio/decoders/qdm2.cpp b/audio/decoders/qdm2.cpp index d4f3b2f101..dbce8d2447 100644 --- a/audio/decoders/qdm2.cpp +++ b/audio/decoders/qdm2.cpp @@ -34,8 +34,9 @@ #include "audio/decoders/qdm2data.h" #include "common/array.h" +#include "common/debug.h" #include "common/stream.h" -#include "common/system.h" +#include "common/textconsole.h" namespace Audio { diff --git a/audio/decoders/qdm2.h b/audio/decoders/qdm2.h index 3d4b542de1..6988623dcb 100644 --- a/audio/decoders/qdm2.h +++ b/audio/decoders/qdm2.h @@ -30,7 +30,7 @@ #define AUDIO_QDM2_H namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace Audio { diff --git a/audio/decoders/quicktime.cpp b/audio/decoders/quicktime.cpp index 5115a20218..f82dc05b7c 100644 --- a/audio/decoders/quicktime.cpp +++ b/audio/decoders/quicktime.cpp @@ -27,6 +27,7 @@ #include "common/util.h" #include "common/memstream.h" #include "common/stream.h" +#include "common/textconsole.h" #include "audio/audiostream.h" #include "audio/decoders/quicktime.h" diff --git a/audio/decoders/raw.cpp b/audio/decoders/raw.cpp index 8b833c7838..cf787f9b12 100644 --- a/audio/decoders/raw.cpp +++ b/audio/decoders/raw.cpp @@ -25,9 +25,10 @@ #include "common/endian.h" #include "common/memstream.h" +#include "common/textconsole.h" +#include "common/util.h" #include "audio/audiostream.h" -#include "audio/mixer.h" #include "audio/decoders/raw.h" namespace Audio { diff --git a/audio/decoders/raw.h b/audio/decoders/raw.h index 3e9426012c..23ed02182d 100644 --- a/audio/decoders/raw.h +++ b/audio/decoders/raw.h @@ -32,12 +32,12 @@ #include "common/list.h" -namespace Common { class SeekableReadStream; } - +namespace Common { +class SeekableReadStream; +} namespace Audio { -class AudioStream; class SeekableAudioStream; /** diff --git a/audio/decoders/vag.h b/audio/decoders/vag.h index cdf91a8ea1..4adc1d3dde 100644 --- a/audio/decoders/vag.h +++ b/audio/decoders/vag.h @@ -35,12 +35,11 @@ #define SOUND_VAG_H namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace Audio { -class AudioStream; class RewindableAudioStream; /** diff --git a/audio/decoders/voc.cpp b/audio/decoders/voc.cpp index b811a640ec..9c2dc4f337 100644 --- a/audio/decoders/voc.cpp +++ b/audio/decoders/voc.cpp @@ -27,9 +27,9 @@ #include "common/endian.h" #include "common/util.h" #include "common/stream.h" +#include "common/textconsole.h" #include "audio/audiostream.h" -#include "audio/mixer.h" #include "audio/decoders/raw.h" #include "audio/decoders/voc.h" diff --git a/audio/decoders/voc.h b/audio/decoders/voc.h index 82cc261f2c..38250dcf7a 100644 --- a/audio/decoders/voc.h +++ b/audio/decoders/voc.h @@ -41,8 +41,10 @@ #include "common/scummsys.h" #include "common/types.h" -namespace Common { class ReadStream; } -namespace Common { class SeekableReadStream; } +namespace Common { +class ReadStream; +class SeekableReadStream; +} namespace Audio { diff --git a/audio/decoders/vorbis.cpp b/audio/decoders/vorbis.cpp index dc37e852d3..63f7ba8207 100644 --- a/audio/decoders/vorbis.cpp +++ b/audio/decoders/vorbis.cpp @@ -32,15 +32,15 @@ #ifdef USE_VORBIS -#include "common/debug.h" #include "common/stream.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/audiostream.h" #ifdef USE_TREMOR -#if defined(__GP32__) // custom libtremor locations -#include <ivorbisfile.h> +#ifdef USE_TREMOLO +#include <tremolo/ivorbisfile.h> #else #include <tremor/ivorbisfile.h> #endif diff --git a/audio/decoders/vorbis.h b/audio/decoders/vorbis.h index 7cc395cccb..51d0b82d5f 100644 --- a/audio/decoders/vorbis.h +++ b/audio/decoders/vorbis.h @@ -49,12 +49,11 @@ #ifdef USE_VORBIS namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace Audio { -class AudioStream; class SeekableAudioStream; /** diff --git a/audio/decoders/wave.cpp b/audio/decoders/wave.cpp index 1f0ddd8ceb..a64874887a 100644 --- a/audio/decoders/wave.cpp +++ b/audio/decoders/wave.cpp @@ -24,11 +24,10 @@ */ #include "common/debug.h" -#include "common/util.h" +#include "common/textconsole.h" #include "common/stream.h" #include "audio/audiostream.h" -#include "audio/mixer.h" #include "audio/decoders/wave.h" #include "audio/decoders/adpcm.h" #include "audio/decoders/raw.h" diff --git a/audio/decoders/wave.h b/audio/decoders/wave.h index 2bdbe8f0b6..33c3e798a0 100644 --- a/audio/decoders/wave.h +++ b/audio/decoders/wave.h @@ -43,7 +43,9 @@ #include "common/scummsys.h" #include "common/types.h" -namespace Common { class SeekableReadStream; } +namespace Common { +class SeekableReadStream; +} namespace Audio { |