diff options
author | Chris Robinson <[email protected]> | 2014-03-06 19:14:19 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-03-06 19:14:19 -0800 |
commit | 7657fbb2966549d23154fd37abfae578703a28f4 (patch) | |
tree | 85b0dbd45f8cd074012923fa2ba4f412a3d3c68a /OpenAL32/sample_cvt.c | |
parent | 143f786d1ae7415c0389d4b1cb04fbbd8472b14f (diff) |
Only sign-expand the nibble when needed
Diffstat (limited to 'OpenAL32/sample_cvt.c')
-rw-r--r-- | OpenAL32/sample_cvt.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/OpenAL32/sample_cvt.c b/OpenAL32/sample_cvt.c index a4dfabca..0c0ba6dd 100644 --- a/OpenAL32/sample_cvt.c +++ b/OpenAL32/sample_cvt.c @@ -396,22 +396,21 @@ static void DecodeMSADPCMBlock(ALshort *dst, const ALmsadpcm *src, ALint numchan const ALint num = (j*numchans) + i; ALint nibble, pred; - /* Read the nibble and sign-expand it. */ + /* Read the nibble (first is in the upper bits). */ if(!(num&1)) nibble = (*src>>4)&0x0f; else nibble = (*(src++))&0x0f; - nibble = (nibble^0x08) - 0x08; pred = (samples[i][0]*MSADPCMAdaptionCoeff[blockpred[i]][0] + samples[i][1]*MSADPCMAdaptionCoeff[blockpred[i]][1]) / 256; - pred += nibble * delta[i]; + pred += ((nibble^0x08) - 0x08) * delta[i]; pred = clampi(pred, -32768, 32767); samples[i][1] = samples[i][0]; samples[i][0] = pred; - delta[i] = (MSADPCMAdaption[nibble&0x0f] * delta[i]) / 256; + delta[i] = (MSADPCMAdaption[nibble] * delta[i]) / 256; delta[i] = maxi(16, delta[i]); *(dst++) = pred; |