mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-06 10:58:01 +00:00
Slight cleanup and commenting of the ADPCM decoder
svn-id: r29682
This commit is contained in:
parent
a77f6157dc
commit
d4831be986
@ -265,10 +265,10 @@ int16 ADPCMInputStream::decodeMS(ADPCMChannelStatus *c, byte code) {
|
|||||||
predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
|
predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
|
||||||
predictor += (signed)((code & 0x08) ? (code - 0x10) : (code)) * c->delta;
|
predictor += (signed)((code & 0x08) ? (code - 0x10) : (code)) * c->delta;
|
||||||
|
|
||||||
if (predictor < -0x8000)
|
if (predictor < -32768)
|
||||||
predictor = -0x8000;
|
predictor = -32768;
|
||||||
else if (predictor > 0x7fff)
|
else if (predictor > 32767)
|
||||||
predictor = 0x7fff;
|
predictor = 32767;
|
||||||
|
|
||||||
c->sample2 = c->sample1;
|
c->sample2 = c->sample1;
|
||||||
c->sample1 = predictor;
|
c->sample1 = predictor;
|
||||||
@ -345,13 +345,12 @@ int16 ADPCMInputStream::decodeMSIMA(byte code) {
|
|||||||
diff = (code & 0x08) ? -E : E;
|
diff = (code & 0x08) ? -E : E;
|
||||||
samp = _status.last + diff;
|
samp = _status.last + diff;
|
||||||
|
|
||||||
if (samp < -0x8000)
|
if (samp < -32768)
|
||||||
samp = -0x8000;
|
samp = -32768;
|
||||||
else if (samp > 0x7fff)
|
else if (samp > 32767)
|
||||||
samp = 0x7fff;
|
samp = 32767;
|
||||||
|
|
||||||
_status.last = samp;
|
_status.last = samp;
|
||||||
|
|
||||||
_status.stepIndex += stepAdjust(code);
|
_status.stepIndex += stepAdjust(code);
|
||||||
if (_status.stepIndex < 0)
|
if (_status.stepIndex < 0)
|
||||||
_status.stepIndex = 0;
|
_status.stepIndex = 0;
|
||||||
|
@ -34,10 +34,15 @@ namespace Audio {
|
|||||||
|
|
||||||
class AudioStream;
|
class AudioStream;
|
||||||
|
|
||||||
|
// There are several types of ADPCM encoding, only some are supported here
|
||||||
|
// For all the different encodings, refer to:
|
||||||
|
// http://wiki.multimedia.cx/index.php?title=Category:ADPCM_Audio_Codecs
|
||||||
|
// Usually, if the audio stream we're trying to play has the FourCC header
|
||||||
|
// string intact, it's easy to discern which encoding is used
|
||||||
enum typesADPCM {
|
enum typesADPCM {
|
||||||
kADPCMOki,
|
kADPCMOki, // Dialogic/Oki ADPCM (aka VOX)
|
||||||
kADPCMMSIma,
|
kADPCMMSIma, // Microsoft IMA ADPCM
|
||||||
kADPCMMS
|
kADPCMMS // Microsoft ADPCM
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user