ogg_int64_t len;
char *buff;
ogg_int64_t done;
- int bs;
+ int bs, bigendian;
long ret;
sfxcache_t *sc;
buff = Mem_Alloc (tempmempool, (int)len);
done = 0;
bs = 0;
- while ((ret = qov_read (&vf, &buff[done], (int)(len - done), 0, 2, 1, &bs)) > 0)
+#if BYTE_ORDER == LITTLE_ENDIAN
+ bigendian = 0;
+#else
+ bigendian = 1;
+#endif
+ while ((ret = qov_read (&vf, &buff[done], (int)(len - done), bigendian, 2, 1, &bs)) > 0)
done += ret;
// Calculate resampled length
((signed char *)sc->data)[i] = ((unsigned char *)data)[i] - 128;
else //if (sc->width == 2) // 16bit
for (i = 0;i < srclength;i++)
- ((short *)sc->data)[i] = LittleShort (((short *)data)[i]);
+ ((short *)sc->data)[i] = ((short *)data)[i];
}
else
{
fracstep <<= 1;
for (i=0 ; i<outcount ; i++)
{
- *out++ = LittleShort (in[srcsample ]);
- *out++ = LittleShort (in[srcsample+1]);
+ *out++ = in[srcsample ];
+ *out++ = in[srcsample+1];
srcsample += fracstep;
}
}
{
for (i=0 ; i<outcount ; i++)
{
- *out++ = LittleShort (in[srcsample ]);
+ *out++ = in[srcsample];
srcsample += fracstep;
}
}
sc->width = info.width;
sc->stereo = info.channels == 2;
+#if BYTE_ORDER != LITTLE_ENDIAN
+ // We must convert the WAV data from little endian
+ // to the machine endianess before resampling it
+ if (info.width == 2)
+ {
+ int i;
+ short* ptr;
+
+ len = info.samples * info.channels;
+ ptr = (short*)(data + info.dataofs);
+ for (i = 0; i < len; i++)
+ ptr[i] = LittleShort (ptr[i]);
+ }
+#endif
+
ResampleSfx(sc, data + info.dataofs, s->name);
Mem_Free(data);