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) {}
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));
224 MS_ADPCMStream(
Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size,
int rate,
int channels, uint32 blockAlign)
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();
Definition: adpcm_intern.h:42
static const int16 _stepAdjustTable[16]
Definition: adpcm_intern.h:81
Timestamp getLength() const override
Definition: adpcm_intern.h:72
bool seek(const Timestamp &where) override
Definition: adpcm_intern.h:71
int getRate() const override
Definition: adpcm_intern.h:68
bool endOfData() const override
Definition: adpcm_intern.h:66
bool isStereo() const override
Definition: adpcm_intern.h:67
Definition: adpcm_intern.h:147
int readBuffer(int16 *buffer, const int numSamples) override
Definition: adpcm_intern.h:249
int readBuffer(int16 *buffer, const int numSamples) override
Definition: adpcm_intern.h:133
int readBuffer(int16 *buffer, const int numSamples) override
bool endOfData() const override
Definition: adpcm_intern.h:138
Definition: adpcm_intern.h:265
int readBuffer(int16 *buffer, const int numSamples) override
bool endOfData() const override
Definition: adpcm_intern.h:273
Definition: adpcm_intern.h:119
static const int16 _imaTable[89]
Definition: adpcm_intern.h:130
Definition: adpcm_intern.h:202
int readBuffer(int16 *buffer, const int numSamples) override
bool endOfData() const override
Definition: adpcm_intern.h:233
Definition: adpcm_intern.h:174
int readBuffer(int16 *buffer, const int numSamples) override
Definition: adpcm_intern.h:84
int readBuffer(int16 *buffer, const int numSamples) override
bool endOfData() const override
Definition: adpcm_intern.h:89
Definition: audiostream.h:212
Definition: timestamp.h:83
Definition: adpcm_intern.h:101
bool endOfData() const override
Definition: adpcm_intern.h:106
int readBuffer(int16 *buffer, const int numSamples) override
size_type size() const
Definition: array.h:316
void clear()
Definition: array.h:321
bool empty() const
Definition: array.h:352
virtual bool eos() const =0
virtual int64 pos() const =0
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: adpcm_intern.h:52
Definition: adpcm_intern.h:204