30 #ifndef AUDIO_ADPCM_INTERN_H 31 #define AUDIO_ADPCM_INTERN_H 33 #include "audio/audiostream.h" 34 #include "common/endian.h" 35 #include "common/ptr.h" 36 #include "common/stream.h" 37 #include "common/textconsole.h" 47 const uint32 _blockAlign;
65 virtual bool endOfData()
const {
return (_stream->
eos() || _stream->
pos() >= _endpos); }
66 virtual bool isStereo()
const {
return _channels == 2; }
67 virtual int getRate()
const {
return _rate; }
86 :
ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { _decodedSampleCount = 0; }
88 virtual bool endOfData()
const {
return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); }
90 virtual int readBuffer(int16 *buffer,
const int numSamples);
93 int16 decodeOKI(byte);
96 uint8 _decodedSampleCount;
97 int16 _decodedSamples[2];
103 :
ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { _decodedSampleCount = 0; }
105 virtual bool endOfData()
const {
return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); }
107 virtual int readBuffer(int16 *buffer,
const int numSamples);
110 void decodeXA(
const byte *src);
113 uint8 _decodedSampleCount;
114 uint8 _decodedSampleIndex;
115 int16 _decodedSamples[28 * 2 * 4];
120 int16 decodeIMA(byte code,
int channel = 0);
124 :
ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {}
129 static const int16 _imaTable[89];
135 :
Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { _decodedSampleCount = 0; }
137 virtual bool endOfData()
const {
return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); }
139 virtual int readBuffer(int16 *buffer,
const int numSamples);
142 uint8 _decodedSampleCount;
143 int16 _decodedSamples[2];
154 Ima_ADPCMStream::reset();
158 _streamPos[1] = _blockAlign;
163 :
Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {
167 _streamPos[1] = _blockAlign;
170 virtual int readBuffer(int16 *buffer,
const int numSamples);
177 :
Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {
180 error(
"MSIma_ADPCMStream(): blockAlign isn't specified");
182 if (blockAlign % (_channels * 4))
183 error(
"MSIma_ADPCMStream(): invalid blockAlign");
189 virtual int readBuffer(int16 *buffer,
const int numSamples);
192 Ima_ADPCMStream::reset();
219 ADPCMStream::reset();
220 memset(&_status, 0,
sizeof(_status));
225 :
ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {
227 error(
"MS_ADPCMStream(): blockAlign isn't specified for MS ADPCM");
228 memset(&_status, 0,
sizeof(_status));
229 _decodedSampleCount = 0;
230 _decodedSampleIndex = 0;
233 virtual bool endOfData()
const {
return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); }
235 virtual int readBuffer(int16 *buffer,
const int numSamples);
241 uint8 _decodedSampleCount;
242 uint8 _decodedSampleIndex;
243 int16 _decodedSamples[4];
252 :
Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {
255 assert(channels == 2);
258 virtual int readBuffer(int16 *buffer,
const int numSamples);
261 byte _nibble, _lastByte;
virtual bool endOfData() const
Definition: adpcm_intern.h:137
virtual int64 pos() const =0
virtual int readBuffer(int16 *buffer, const int numSamples)=0
virtual bool endOfData() const
Definition: adpcm_intern.h:88
virtual bool eos() const =0
virtual Timestamp getLength() const
Definition: adpcm_intern.h:71
virtual bool endOfData() const
Definition: adpcm_intern.h:233
Definition: adpcm_intern.h:51
Definition: timestamp.h:83
virtual int getRate() const
Definition: adpcm_intern.h:67
Definition: audiostream.h:212
Definition: adpcm_intern.h:174
Definition: adpcm_intern.h:204
Definition: adpcm_intern.h:83
Definition: adpcm_intern.h:146
Definition: adpcm_intern.h:202
static const int16 _stepAdjustTable[16]
Definition: adpcm_intern.h:80
virtual bool seek(const Timestamp &where)
Definition: adpcm_intern.h:70
Definition: adpcm_intern.h:100
virtual bool isStereo() const
Definition: adpcm_intern.h:66
virtual bool endOfData() const
Definition: adpcm_intern.h:65
Definition: adpcm_intern.h:249
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: adpcm_intern.h:41
Definition: adpcm_intern.h:118
virtual bool endOfData() const
Definition: adpcm_intern.h:105
Definition: adpcm_intern.h:132