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/array.h" 37 #include "common/stream.h" 38 #include "common/textconsole.h" 48 const uint32 _blockAlign;
66 bool endOfData()
const override {
return (_stream->
eos() || _stream->
pos() >= _endpos); }
67 bool isStereo()
const override {
return _channels == 2; }
68 int getRate()
const override {
return _rate; }
87 :
ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { _decodedSampleCount = 0; }
89 bool endOfData()
const override {
return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); }
91 int readBuffer(int16 *buffer,
const int numSamples)
override;
94 int16 decodeOKI(byte);
97 uint8 _decodedSampleCount;
98 int16 _decodedSamples[2];
104 :
ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { _decodedSampleCount = 0; }
106 bool endOfData()
const override {
return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); }
108 int readBuffer(int16 *buffer,
const int numSamples)
override;
111 void decodeXA(
const byte *src);
114 uint8 _decodedSampleCount;
115 uint8 _decodedSampleIndex;
116 int16 _decodedSamples[28 * 2 * 4];
121 int16 decodeIMA(byte code,
int channel = 0,
int shift = 3);
125 :
ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {}
130 static const int16 _imaTable[89];
136 :
Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { _decodedSampleCount = 0; }
138 bool endOfData()
const override {
return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); }
140 int readBuffer(int16 *buffer,
const int numSamples)
override;
143 uint8 _decodedSampleCount;
144 int16 _decodedSamples[2];
154 void reset()
override {
155 Ima_ADPCMStream::reset();
159 _streamPos[1] = _blockAlign;
164 :
Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {
168 _streamPos[1] = _blockAlign;
171 int readBuffer(int16 *buffer,
const int numSamples)
override;
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 int readBuffer(int16 *buffer,
const int numSamples)
override;
191 void reset()
override {
192 Ima_ADPCMStream::reset();
218 void reset()
override {
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 bool endOfData()
const override {
return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); }
235 int readBuffer(int16 *buffer,
const int numSamples)
override;
241 uint8 _decodedSampleCount;
242 uint8 _decodedSampleIndex;
243 int16 _decodedSamples[4];
252 :
Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {
255 assert(channels == 2);
258 int readBuffer(int16 *buffer,
const int numSamples)
override;
261 byte _nibble, _lastByte;
272 int readBuffer(int16 *buffer,
const int numSamples)
override;
274 return !_planes.empty() && _samplePos >= _planes[0].size();
277 void reset()
override {
278 Ima_ADPCMStream::reset();
virtual int64 pos() const =0
virtual int readBuffer(int16 *buffer, const int numSamples)=0
bool endOfData() const override
Definition: adpcm_intern.h:106
bool endOfData() const override
Definition: adpcm_intern.h:89
virtual bool eos() const =0
Definition: adpcm_intern.h:52
Definition: timestamp.h:83
bool endOfData() const override
Definition: adpcm_intern.h:66
int getRate() const override
Definition: adpcm_intern.h:68
Definition: audiostream.h:212
Definition: adpcm_intern.h:174
Definition: adpcm_intern.h:204
Definition: adpcm_intern.h:84
bool endOfData() const override
Definition: adpcm_intern.h:233
Definition: adpcm_intern.h:147
Definition: adpcm_intern.h:202
Definition: adpcm_intern.h:265
static const int16 _stepAdjustTable[16]
Definition: adpcm_intern.h:81
Definition: adpcm_intern.h:101
Definition: adpcm_intern.h:249
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
bool seek(const Timestamp &where) override
Definition: adpcm_intern.h:71
Timestamp getLength() const override
Definition: adpcm_intern.h:72
Definition: adpcm_intern.h:42
Definition: adpcm_intern.h:119
Definition: adpcm_intern.h:133
bool endOfData() const override
Definition: adpcm_intern.h:138
bool endOfData() const override
Definition: adpcm_intern.h:273
bool isStereo() const override
Definition: adpcm_intern.h:67