aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alBuffer.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-12-01 14:07:21 -0800
committerChris Robinson <[email protected]>2010-12-01 14:07:21 -0800
commit7f5814c4d8c9c520833f84fe86ecca38d3900171 (patch)
treea1e8c9063e1e9dab8bf48b54738eec3d54de0dd8 /OpenAL32/alBuffer.c
parente3afc3587e204a089e460bb5f95a808895ba0256 (diff)
Use min/max to clamp the IMA4 sample and index values
Diffstat (limited to 'OpenAL32/alBuffer.c')
-rw-r--r--OpenAL32/alBuffer.c12
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;