summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-05-22 15:37:32 -0700
committerChris Robinson <[email protected]>2010-05-22 15:37:32 -0700
commit9ac6b4c2c84ddbe89ec1db42f92c6e13dadfcc6e (patch)
tree832acb232e6116f1053899137d9cbb72d9a41261
parent861a933b7b518392920a5723e1a2df71ead4f7e9 (diff)
Be big endian safe with the IMA4 decoder
-rw-r--r--OpenAL32/alBuffer.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index b19ac5d9..4a92ba2d 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -1230,7 +1230,7 @@ static void ConvertDataRear(ALfloat *dst, const ALvoid *src, ALint origBytes, AL
static void ConvertDataIMA4(ALfloat *dst, const ALvoid *src, ALint origChans, ALsizei len)
{
- const ALuint *IMAData;
+ const ALubyte *IMAData;
ALint Sample[2],Index[2];
ALuint IMACode[2];
ALsizei i,j,k,c;
@@ -1243,21 +1243,30 @@ static void ConvertDataIMA4(ALfloat *dst, const ALvoid *src, ALint origChans, AL
{
for(c = 0;c < origChans;c++)
{
- Sample[c] = ((ALshort*)IMAData)[0];
- Index[c] = ((ALshort*)IMAData)[1];
+ Sample[c] = IMAData[0];
+ Sample[c] |= IMAData[1] << 8;
+ Sample[c] = (Sample[c]^0x8000) - 32768;
+ Index[c] = IMAData[2];
+ Index[c] |= IMAData[3] << 8;
+ Index[c] = (Index[c]^0x8000) - 32768;
Index[c] = ((Index[c]<0) ? 0 : Index[c]);
Index[c] = ((Index[c]>88) ? 88 : Index[c]);
dst[i*65*origChans + c] = ((Sample[c] < 0) ? (Sample[c]/32768.0f) : (Sample[c]/32767.0f));
- IMAData++;
+ IMAData += 4;
}
for(j = 1;j < 65;j += 8)
{
for(c = 0;c < origChans;c++)
- IMACode[c] = *(IMAData++);
+ {
+ IMACode[c] = *(IMAData++);
+ IMACode[c] |= *(IMAData++) << 8;
+ IMACode[c] |= *(IMAData++) << 16;
+ IMACode[c] |= *(IMAData++) << 24;
+ }
for(k = 0;k < 8;k++)
{