mirror of
https://github.com/jorio/Pomme.git
synced 2024-11-26 13:49:22 +00:00
Preprocess sound resource: Convert big-endian raw PCM to little-endian
This commit is contained in:
parent
010d57bf8d
commit
801d7e8d1e
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user