Fix handling of -32768 in the muLaw encoder

This commit is contained in:
Chris Robinson 2010-12-01 02:24:39 -08:00
parent 8a52c44d15
commit e3afc3587e

View File

@ -838,7 +838,13 @@ static ALmulaw EncodeMuLaw(ALshort val)
ALint mant, exp, sign;
sign = (val>>8) & 0x80;
if(sign) val = (ALshort)-val;
if(sign)
{
/* -32768 doesn't properly negate on a short; it results in itself.
* So clamp to -32767 */
val = max(val, -32767);
val = -val;
}
val = min(val, muLawClip);
val += muLawBias;