mirror of
https://github.com/jorio/Pomme.git
synced 2025-02-18 13:30:25 +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)
|
if (!inInfo.isCompressed)
|
||||||
{
|
{
|
||||||
// Raw big-endian PCM
|
// Raw PCM
|
||||||
if (inInfo.decompressedLength != inInfo.compressedLength)
|
if (inInfo.decompressedLength != inInfo.compressedLength)
|
||||||
throw std::runtime_error("decompressedLength != compressedLength???");
|
throw std::runtime_error("decompressedLength != compressedLength???");
|
||||||
|
|
||||||
memcpy(outDataStart, inDataStart, inInfo.decompressedLength);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user