diff options
author | Chris Robinson <[email protected]> | 2010-12-01 14:07:21 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-12-01 14:07:21 -0800 |
commit | 7f5814c4d8c9c520833f84fe86ecca38d3900171 (patch) | |
tree | a1e8c9063e1e9dab8bf48b54738eec3d54de0dd8 /OpenAL32 | |
parent | e3afc3587e204a089e460bb5f95a808895ba0256 (diff) |
Use min/max to clamp the IMA4 sample and index values
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alBuffer.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index e85d2626..d34aa3b1 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -870,8 +870,8 @@ static void DecodeIMA4Block(ALshort *dst, const ALubyte *IMAData, ALint numchans Index[c] |= *(IMAData++) << 8; Index[c] = (Index[c]^0x8000) - 32768; - Index[c] = ((Index[c]<0) ? 0 : Index[c]); - Index[c] = ((Index[c]>88) ? 88 : Index[c]); + Index[c] = max(0, Index[c]); + Index[c] = min(Index[c], 88); dst[c] = Sample[c]; } @@ -895,11 +895,11 @@ static void DecodeIMA4Block(ALshort *dst, const ALubyte *IMAData, ALint numchans g_IMACodeword_4[IMACode[c]&15] / 8; Index[c] += g_IMAIndex_adjust_4[IMACode[c]&15]; - if(Sample[c] < -32768) Sample[c] = -32768; - else if(Sample[c] > 32767) Sample[c] = 32767; + Sample[c] = max(-32768, Sample[c]); + Sample[c] = min(Sample[c], 32767); - if(Index[c] < 0) Index[c] = 0; - else if(Index[c] > 88) Index[c] = 88; + Index[c] = max(0, Index[c]); + Index[c] = min(Index[c], 88); dst[j*numchans + c] = Sample[c]; IMACode[c] >>= 4; |