diff --git a/lib/Adecode.h b/lib/Adecode.h index 870c4d52..b62b21e1 100644 --- a/lib/Adecode.h +++ b/lib/Adecode.h @@ -21,7 +21,7 @@ namespace AudioDecoder { typedef uint32_t uint32_t; -typedef int32_t sint32; +typedef int32_t int32_t; typedef unsigned short uint16; typedef signed short sint16; typedef uint8_t uint8; @@ -46,7 +46,7 @@ public: // and also returns the number of channels (1 or 2), the sample rate // (e.g. 22050), and the number of samples contained in the compressed file // (in case you want to pre-allocate a buffer to load them all into memory). -typedef sint32 (*ReadDataFunction)(void *pData, void *pBuffer, uint32_t amount); +typedef int32_t (*ReadDataFunction)(void *pData, void *pBuffer, uint32_t amount); IAudioDecoder *CreateDecoder(ReadDataFunction reader, void *pData, uint32_t &numChannels, uint32_t &sampleRate, uint32_t &sampleCount); diff --git a/libacm/aencode.cpp b/libacm/aencode.cpp index 7f0d0bdd..5f430f08 100644 --- a/libacm/aencode.cpp +++ b/libacm/aencode.cpp @@ -24,7 +24,7 @@ #include "Aencode.h" typedef uint32_t uint32_t; -typedef int32_t sint32; +typedef int32_t int32_t; typedef unsigned short uint16; typedef signed short sint16; typedef uint8_t uint8; @@ -35,7 +35,7 @@ struct BitsEncoder { uint32_t m_bitData; // var4C | offset 0x14 uint32_t m_bitCount; // var48 | offset 0x18 - void WriteBits(sint32 val, uint32_t numBits) { + void WriteBits(int32_t val, uint32_t numBits) { assert((numBits + m_bitCount) <= 32); m_bitData |= static_cast(val << m_bitCount); m_bitCount += numBits; @@ -75,38 +75,38 @@ struct Encoder { BitsEncoder m_bits; // var50 - var48 | offset 0x10 - 0x18 sint8 m_levels; // var44* | offset 0x1C sint8 m_pad[3]; // 43, 42, 41 - sint32 m_numColumns; // var40 | offset 0x20 - sint32 m_samples_per_subband; // var3C | offset 0x24 - sint32 m_samplesPerBlock; // var38 | offset 0x28 - sint32 m_adjustedSamplesTimeNumColumns; // var34 | offset 0x2C + int32_t m_numColumns; // var40 | offset 0x20 + int32_t m_samples_per_subband; // var3C | offset 0x24 + int32_t m_samplesPerBlock; // var38 | offset 0x28 + int32_t m_adjustedSamplesTimeNumColumns; // var34 | offset 0x2C float **m_levelSlots; // var30 | offset 0x30 float *m_pCurrBlockData; // var2C | offset 0x34 - sint32 m_blockSamplesRemaining; // var28 | offset 0x38 - sint32 m_bandWriteEnabled; // var24 | offset 0x3C - sint32 m_finishedReading; // var20 | offset 0x40 - sint32 m_someVal; // var1C | offset 0x44 + int32_t m_blockSamplesRemaining; // var28 | offset 0x38 + int32_t m_bandWriteEnabled; // var24 | offset 0x3C + int32_t m_finishedReading; // var20 | offset 0x40 + int32_t m_someVal; // var1C | offset 0x44 float *m_lo_filter; // var18 | offset 0x48 float *m_hi_filter; // var14 | offset 0x4C uint32_t *m_pFormatIdPerColumn; // var10 | offset 0x50 - sint32 m_currBlockBitPower; // var0C | offset 0x54 - sint32 m_currBlockBitValue; // var08 | offset 0x58 - sint32 m_threshold; // var04 | offset 0x5C + int32_t m_currBlockBitPower; // var0C | offset 0x54 + int32_t m_currBlockBitValue; // var08 | offset 0x58 + int32_t m_threshold; // var04 | offset 0x5C }; -typedef void (*WriteBandFunc)(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt0(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt3_16(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt17(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt18(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt19(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt20(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt21(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt22(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt23(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt24(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt26(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt27(Encoder &enc, sint32 colIndex, uint32_t packerId); -void WriteBand_Fmt29(Encoder &enc, sint32 colIndex, uint32_t packerId); +typedef void (*WriteBandFunc)(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt0(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt3_16(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt17(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt18(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt19(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt20(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt21(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt22(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt23(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt24(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt26(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt27(Encoder &enc, int32_t colIndex, uint32_t packerId); +void WriteBand_Fmt29(Encoder &enc, int32_t colIndex, uint32_t packerId); WriteBandFunc WriteBand_tbl[] = {WriteBand_Fmt0, NULL, @@ -153,17 +153,17 @@ const float T911 = -32767.0f; const float T913 = 32767.0f; const float T1266 = 0.0f; -void WriteBand_Fmt0(Encoder &enc, sint32 colIndex, uint32_t formatId) {} +void WriteBand_Fmt0(Encoder &enc, int32_t colIndex, uint32_t formatId) {} -void WriteBand_Fmt3_16(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt3_16(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBlockValue = float(enc.m_currBlockBitValue); const float halfCurrBlockValue = currBlockValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBlockValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBlockValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockValue); float *pColumnData = &enc.m_levelSlots[enc.m_levels][colIndex]; - for (sint32 i = 0; i < enc.m_samples_per_subband; ++i) { - sint32 val = (sint32)floorf((*pColumnData + halfCurrBlockValue) / currBlockValue); + for (int32_t i = 0; i < enc.m_samples_per_subband; ++i) { + int32_t val = (int32_t)floorf((*pColumnData + halfCurrBlockValue) / currBlockValue); if (minValue > val) { val = minValue; } else if (val > maxValue) { @@ -175,17 +175,17 @@ void WriteBand_Fmt3_16(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt17(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt17(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBitValue = static_cast(enc.m_currBlockBitValue); const float halfCurrBitValue = currBitValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBitValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBitValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBitValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBitValue); const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIndex = enc.m_samples_per_subband; + int32_t currSampleIndex = enc.m_samples_per_subband; while (currSampleIndex) { --currSampleIndex; - sint32 val = (sint32)floorf((*pCurrSample + halfCurrBitValue) / currBitValue); + int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBitValue) / currBitValue); if (minValue > val) { val = minValue; } else if (maxValue < val) { @@ -213,17 +213,17 @@ void WriteBand_Fmt17(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt18(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt18(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBlockBitValue = static_cast(enc.m_currBlockBitValue); const float halfCurrBlockBitValue = enc.m_currBlockBitValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBlockBitValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBlockBitValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockBitValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockBitValue); const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIndex = enc.m_samples_per_subband; + int32_t currSampleIndex = enc.m_samples_per_subband; while (currSampleIndex) { --currSampleIndex; - sint32 val = (sint32)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue); + int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue); if (minValue > val) { val = minValue; } else if (val > maxValue) { @@ -242,27 +242,27 @@ void WriteBand_Fmt18(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt19(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt19(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBlockBitValue = static_cast(enc.m_currBlockBitValue); const float halfCurrBlockBitValue = currBlockBitValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBlockBitValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBlockBitValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockBitValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockBitValue); const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIndex = enc.m_samples_per_subband; + int32_t currSampleIndex = enc.m_samples_per_subband; while (currSampleIndex) { --currSampleIndex; - sint32 workingVal = (sint32)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue); + int32_t workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue); if (minValue > workingVal) { workingVal = minValue; } else if (maxValue < workingVal) { workingVal = maxValue; } pCurrSample += enc.m_numColumns; - sint32 baseValue = workingVal + 1; + int32_t baseValue = workingVal + 1; if (currSampleIndex) { --currSampleIndex; - workingVal = (sint32)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue); + workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue); if (minValue > workingVal) { workingVal = minValue; } else if (maxValue < workingVal) { @@ -276,7 +276,7 @@ void WriteBand_Fmt19(Encoder &enc, sint32 colIndex, uint32_t formatId) { baseValue += workingVal * 3 + 3; if (currSampleIndex) { --currSampleIndex; - workingVal = (sint32)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue); + workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue); if (minValue > workingVal) { workingVal = minValue; } else if (maxValue < workingVal) { @@ -291,17 +291,17 @@ void WriteBand_Fmt19(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt20(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt20(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBlockValue = static_cast(enc.m_currBlockBitValue); const float halfCurrBlockValue = currBlockValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBlockValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBlockValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockValue); const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIndex = enc.m_samples_per_subband; + int32_t currSampleIndex = enc.m_samples_per_subband; while (currSampleIndex) { --currSampleIndex; - sint32 val = (sint32)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); + int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); if (minValue > val) { val = minValue; } else if (maxValue < val) { @@ -310,7 +310,7 @@ void WriteBand_Fmt20(Encoder &enc, sint32 colIndex, uint32_t formatId) { pCurrSample += enc.m_numColumns; if (val == 0) { - if (currSampleIndex != 0 && !(sint32)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue)) { + if (currSampleIndex != 0 && !(int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue)) { enc.m_bits.WriteBits(0, 1); if (currSampleIndex == 0) @@ -333,17 +333,17 @@ void WriteBand_Fmt20(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt21(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt21(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBlockValue = static_cast(enc.m_currBlockBitValue); const float halfCurrBlockValue = currBlockValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBlockValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBlockValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockValue); const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIndex = enc.m_samples_per_subband; + int32_t currSampleIndex = enc.m_samples_per_subband; while (currSampleIndex) { --currSampleIndex; - sint32 val = (sint32)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); + int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); if (minValue > val) { val = minValue; } else if (maxValue < val) { @@ -367,29 +367,29 @@ void WriteBand_Fmt21(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt22(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt22(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBlockValue = static_cast(enc.m_currBlockBitValue); const float halfCurrBlockValue = currBlockValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBlockValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBlockValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockValue); const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIndex = enc.m_samples_per_subband; + int32_t currSampleIndex = enc.m_samples_per_subband; while (currSampleIndex) { --currSampleIndex; - sint32 workingVal = (sint32)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); + int32_t workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); if (minValue > workingVal) { workingVal = minValue; } else if (maxValue < workingVal) { workingVal = maxValue; } - sint32 baseValue = workingVal + 2; + int32_t baseValue = workingVal + 2; pCurrSample += enc.m_numColumns; if (currSampleIndex) { --currSampleIndex; - workingVal = (sint32)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); + workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); if (minValue > workingVal) { workingVal = minValue; } else if (maxValue < workingVal) { @@ -403,7 +403,7 @@ void WriteBand_Fmt22(Encoder &enc, sint32 colIndex, uint32_t formatId) { baseValue += workingVal * 5 + 10; if (currSampleIndex) { --currSampleIndex; - workingVal = (sint32)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); + workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); if (minValue > workingVal) { workingVal = minValue; } else if (maxValue < workingVal) { @@ -418,18 +418,18 @@ void WriteBand_Fmt22(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt23(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt23(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBlockValue = static_cast(enc.m_currBlockBitValue); const float halfCurrBlockValue = currBlockValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBlockValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBlockValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockValue); const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIndex = enc.m_samples_per_subband; + int32_t currSampleIndex = enc.m_samples_per_subband; while (currSampleIndex) { --currSampleIndex; - sint32 val = (sint32)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); + int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); if (minValue > val) { val = minValue; } else if (maxValue < val) { @@ -439,7 +439,7 @@ void WriteBand_Fmt23(Encoder &enc, sint32 colIndex, uint32_t formatId) { pCurrSample += enc.m_numColumns; if (!val) { if (currSampleIndex != 0) { - if (!(sint32)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue)) { + if (!(int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue)) { enc.m_bits.WriteBits(0, 1); if (currSampleIndex == 0) @@ -473,17 +473,17 @@ void WriteBand_Fmt23(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt24(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt24(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBlockBitValue = static_cast(enc.m_currBlockBitValue); const float halfCurrBlockBitValue = currBlockBitValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBlockBitValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBlockBitValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockBitValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockBitValue); const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIndex = enc.m_samples_per_subband; + int32_t currSampleIndex = enc.m_samples_per_subband; while (currSampleIndex) { --currSampleIndex; - sint32 val = (sint32)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue); + int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue); if (minValue > val) { val = minValue; } else if (maxValue < val) { @@ -513,18 +513,18 @@ void WriteBand_Fmt24(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt26(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt26(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBlockValue = static_cast(enc.m_currBlockBitValue); const float halfCurrBlockValue = currBlockValue * 0.5f; - const sint32 minValue = static_cast(ceilf(-32767.0f / currBlockValue)); - const sint32 maxValue = static_cast(floorf(32767.0f / currBlockValue)); + const int32_t minValue = static_cast(ceilf(-32767.0f / currBlockValue)); + const int32_t maxValue = static_cast(floorf(32767.0f / currBlockValue)); const float *pColumnData = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIdx = enc.m_samples_per_subband; + int32_t currSampleIdx = enc.m_samples_per_subband; while (currSampleIdx) { --currSampleIdx; - sint32 val = (sint32)floorf((*pColumnData + halfCurrBlockValue) / currBlockValue); + int32_t val = (int32_t)floorf((*pColumnData + halfCurrBlockValue) / currBlockValue); if (minValue > val) { val = minValue; } else if (maxValue < val) { @@ -534,7 +534,7 @@ void WriteBand_Fmt26(Encoder &enc, sint32 colIndex, uint32_t formatId) { pColumnData += enc.m_numColumns; if (!val) { if (currSampleIdx) { - sint32 testVal = (sint32)floorf((*pColumnData + halfCurrBlockValue) / currBlockValue); + int32_t testVal = (int32_t)floorf((*pColumnData + halfCurrBlockValue) / currBlockValue); if (!testVal) { enc.m_bits.WriteBits(0, 1); @@ -563,17 +563,17 @@ void WriteBand_Fmt26(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt27(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt27(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBlockValue = static_cast(enc.m_currBlockBitValue); const float halfCurrBlockValue = currBlockValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBlockValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBlockValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockValue); const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIndex = enc.m_samples_per_subband; + int32_t currSampleIndex = enc.m_samples_per_subband; while (currSampleIndex) { --currSampleIndex; - sint32 val = (sint32)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); + int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); if (val < minValue) { val = minValue; } else if (maxValue < val) { @@ -598,30 +598,30 @@ void WriteBand_Fmt27(Encoder &enc, sint32 colIndex, uint32_t formatId) { } } -void WriteBand_Fmt29(Encoder &enc, sint32 colIndex, uint32_t formatId) { +void WriteBand_Fmt29(Encoder &enc, int32_t colIndex, uint32_t formatId) { const float currBitValue = (float)enc.m_currBlockBitValue; const float halfCurrBitValue = currBitValue * 0.5f; - const sint32 minValue = (sint32)ceilf(-32767.0f / currBitValue); - const sint32 maxValue = (sint32)floorf(32767.0f / currBitValue); + const int32_t minValue = (int32_t)ceilf(-32767.0f / currBitValue); + const int32_t maxValue = (int32_t)floorf(32767.0f / currBitValue); const float *pColumnData = &enc.m_levelSlots[enc.m_levels][colIndex]; - sint32 currSampleIndex = enc.m_samples_per_subband; + int32_t currSampleIndex = enc.m_samples_per_subband; while (currSampleIndex) { --currSampleIndex; - sint32 val = (sint32)floorf((*pColumnData + halfCurrBitValue) / currBitValue); + int32_t val = (int32_t)floorf((*pColumnData + halfCurrBitValue) / currBitValue); if (minValue > val) { val = minValue; } else if (maxValue < val) { val = maxValue; } - sint32 baseValue = val + 5; + int32_t baseValue = val + 5; pColumnData += enc.m_numColumns; if (currSampleIndex != 0) { --currSampleIndex; - val = (sint32)floorf((*pColumnData + halfCurrBitValue) / currBitValue); + val = (int32_t)floorf((*pColumnData + halfCurrBitValue) / currBitValue); if (minValue > val) { val = minValue; } else if (maxValue < val) { @@ -689,7 +689,7 @@ int SetupEncoder(Encoder &enc, int someVal, float std_lo_filter[], float std_hi_ enc.m_sampleCount = 0; - sint32 edxOffset = + int32_t edxOffset = ((enc.m_samplesPerBlock * sizeof(float) * 25) - enc.m_adjustedSamplesTimeNumColumns) % enc.m_samplesPerBlock; enc.m_pCurrBlockData = enc.m_levelSlots[0] + edxOffset; enc.m_blockSamplesRemaining = enc.m_samplesPerBlock - edxOffset; @@ -719,12 +719,12 @@ void DestroyEncoder(Encoder &enc) { } } -void transform_subband(Encoder &enc, float *pD0, float *pD1, sint32 subBandCount, sint32 sampleCount) { +void transform_subband(Encoder &enc, float *pD0, float *pD1, int32_t subBandCount, int32_t sampleCount) { if (sampleCount <= 0) return; - const sint32 var_8 = (enc.m_someVal - 1) >> 1; - const sint32 edx = var_8 * subBandCount; + const int32_t var_8 = (enc.m_someVal - 1) >> 1; + const int32_t edx = var_8 * subBandCount; pD0 -= edx; for (int i = 0; i < sampleCount; ++i) { @@ -734,7 +734,7 @@ void transform_subband(Encoder &enc, float *pD0, float *pD1, sint32 subBandCount float var_4 = 0.0f; if (var_8 > 0) { - for (sint32 ebp = var_8; ebp != 0; --ebp) { + for (int32_t ebp = var_8; ebp != 0; --ebp) { var_4 += (*eax + *ebx) * *pFilter++; ebx += subBandCount; eax -= subBandCount; @@ -751,8 +751,8 @@ void transform_all(Encoder &enc) { if (enc.m_levels <= 0) return; - sint32 subBandCount = 1; - sint32 sampleCount = enc.m_samplesPerBlock; + int32_t subBandCount = 1; + int32_t sampleCount = enc.m_samplesPerBlock; for (int i = 0; i < enc.m_levels; ++i) { float *levelDataEBX = enc.m_levelSlots[i]; float *levelDataEBP = enc.m_levelSlots[i + 1]; @@ -766,23 +766,23 @@ void transform_all(Encoder &enc) { } } -sint32 calc_bits(Encoder &enc, sint32 val) { +int32_t calc_bits(Encoder &enc, int32_t val) { static uint32_t calc_bits_data[] = {0x00, 0x13, 0x16, 0x03, 0x1D, 0x00}; - sint32 bitPower = 3; - sint32 result = enc.m_numColumns * 5 + 20; + int32_t bitPower = 3; + int32_t result = enc.m_numColumns * 5 + 20; float halfVal = float(val) * 0.5f; float *var_18 = enc.m_levelSlots[enc.m_levels]; float *var_8 = enc.m_levelSlots[enc.m_levels]; - for (sint32 var_1C = 0; var_1C < enc.m_numColumns; ++var_1C) { - sint32 minValue = 0x10000; - sint32 maxValue = -0x10000; + for (int32_t var_1C = 0; var_1C < enc.m_numColumns; ++var_1C) { + int32_t minValue = 0x10000; + int32_t maxValue = -0x10000; if (enc.m_samples_per_subband > 0) { float *pSlotData = var_8; for (int ebp = enc.m_samples_per_subband; ebp != 0; --ebp) { - sint32 testVal = (sint32)floor((*pSlotData + halfVal) / float(val)); + int32_t testVal = (int32_t)floor((*pSlotData + halfVal) / float(val)); if (minValue > testVal) { minValue = testVal; } @@ -795,7 +795,7 @@ sint32 calc_bits(Encoder &enc, sint32 val) { } } - sint32 absMaxVal = abs(minValue); + int32_t absMaxVal = abs(minValue); if (absMaxVal < maxValue) { absMaxVal = maxValue; } else if (absMaxVal < -maxValue) { @@ -806,8 +806,8 @@ sint32 calc_bits(Encoder &enc, sint32 val) { minValue = 0; enc.m_pFormatIdPerColumn[var_1C] = 0; } else if (absMaxVal <= 4) { - sint32 ebx = 1; - sint32 var_28 = absMaxVal * 3 + 14; + int32_t ebx = 1; + int32_t var_28 = absMaxVal * 3 + 14; if (absMaxVal != 1) { ebx = ((absMaxVal - 2) < 1) ? 2 : 3; } @@ -815,7 +815,7 @@ sint32 calc_bits(Encoder &enc, sint32 val) { minValue = 0; maxValue = 0; for (int ebp = 0; ebp < enc.m_samples_per_subband; ++ebp) { - sint32 v = (int)floor((var_18[(ebp * enc.m_numColumns) + var_1C] + halfVal) / float(val)); + int32_t v = (int)floor((var_18[(ebp * enc.m_numColumns) + var_1C] + halfVal) / float(val)); if (v) { if (ebx != 1) { if (v == -1 || v == 1) { @@ -833,7 +833,7 @@ sint32 calc_bits(Encoder &enc, sint32 val) { minValue += 2; ++maxValue; } else { - sint32 v = (int)floor((var_18[((ebp + 1) * enc.m_numColumns) + var_1C] + halfVal) / float(val)); + int32_t v = (int)floor((var_18[((ebp + 1) * enc.m_numColumns) + var_1C] + halfVal) / float(val)); if (v) { minValue += 2; ++maxValue; @@ -850,7 +850,7 @@ sint32 calc_bits(Encoder &enc, sint32 val) { ++var_28; } - sint32 ecx; + int32_t ecx; if (absMaxVal != 4) { ecx = ((enc.m_samples_per_subband + 2) / 3) * ((absMaxVal * 2) + 3); } else { @@ -872,7 +872,7 @@ sint32 calc_bits(Encoder &enc, sint32 val) { 7; enc.m_pFormatIdPerColumn[var_1C] = 0x1D; } else { - sint32 eax = 0; + int32_t eax = 0; if (minValue < 0) { eax = ~minValue; } @@ -904,12 +904,12 @@ sint32 calc_bits(Encoder &enc, sint32 val) { } void DetermineStep(Encoder &enc) { - sint32 lo = 1; - sint32 hi = 0x7FFF; + int32_t lo = 1; + int32_t hi = 0x7FFF; do { - const sint32 midPoint = (lo + hi) >> 1; - sint32 errorAmt = calc_bits(enc, midPoint); + const int32_t midPoint = (lo + hi) >> 1; + int32_t errorAmt = calc_bits(enc, midPoint); if (enc.m_threshold < errorAmt) { lo = midPoint + 1; } else { @@ -935,7 +935,7 @@ void WriteBands(Encoder &enc) { } void shift_transform_levels(Encoder &enc) { - sint32 levelCount = enc.m_someVal - 1; + int32_t levelCount = enc.m_someVal - 1; for (int i = 0; i < enc.m_levels; ++i, levelCount += levelCount) { float *pDst = enc.m_levelSlots[i] - levelCount; float *pSrc = pDst + enc.m_samplesPerBlock; @@ -959,7 +959,7 @@ void ProcessBlock(Encoder &enc) { } void EncodeSample(Encoder &enc) { - sint32 sample = 0; + int32_t sample = 0; if (enc.m_finishedReading == 0) { sample = (*enc.m_reader)(enc.m_pReaderData); if (sample == ReadSampleEof) { @@ -1014,7 +1014,7 @@ int32_t AudioEncode(ReadSampleFunction *read, void *data, unsigned channels, uns return 0; } - enc.m_threshold = (sint32)(float(enc.m_samplesPerBlock) * comp_ratio * 16.0f); + enc.m_threshold = (int32_t)(float(enc.m_samplesPerBlock) * comp_ratio * 16.0f); int32_t originalPosVAR64 = ftell(out); @@ -1046,7 +1046,7 @@ int32_t AudioEncode(ReadSampleFunction *read, void *data, unsigned channels, uns enc.m_bandWriteEnabled = 0; - sint32 esi = enc.m_adjustedSamplesTimeNumColumns; + int32_t esi = enc.m_adjustedSamplesTimeNumColumns; while (esi) { EncodeSample(enc); --esi;