Preprocess sound resource: Convert big-endian raw PCM to little-endian

This commit is contained in:
Iliyas Jorio 2022-05-15 10:47:52 +02:00
parent 010d57bf8d
commit 801d7e8d1e

View File

@ -274,11 +274,23 @@ Boolean Pomme_DecompressSoundResource(SndListHandle* sndHandlePtr, long* offsetT
if (!inInfo.isCompressed)
{
// Raw big-endian PCM
// Raw PCM
if (inInfo.decompressedLength != inInfo.compressedLength)
throw std::runtime_error("decompressedLength != compressedLength???");
memcpy(outDataStart, inDataStart, inInfo.decompressedLength);
// If it's big endian, swap the bytes
int bytesPerSample = inInfo.codecBitDepth / 8;
if (inInfo.bigEndian && bytesPerSample > 1)
{
int nIntegers = inInfo.decompressedLength / bytesPerSample;
if (inInfo.decompressedLength != nIntegers * bytesPerSample)
throw std::runtime_error("unexpected big-endian raw PCM decompressed length");
ByteswapInts(bytesPerSample, nIntegers, outDataStart);
outInfo.bigEndian = false;
}
}
else
{