diff --git a/lib/Adecode.h b/lib/Adecode.h index cbb02eae..870c4d52 100644 --- a/lib/Adecode.h +++ b/lib/Adecode.h @@ -20,7 +20,7 @@ #define AUDIODECODE_H_ namespace AudioDecoder { -typedef uint32_t uint32; +typedef uint32_t uint32_t; typedef int32_t sint32; typedef unsigned short uint16; typedef signed short sint16; @@ -35,7 +35,7 @@ public: // pBuffer: The buffer to receive the data from // amount: How much data to read // Returns the number of bytes read - zero when we're at the end of the file - virtual uint32 Read(void *pBuffer, uint32 amount) = 0; + virtual uint32_t Read(void *pBuffer, uint32_t amount) = 0; }; // Create an audio decoder @@ -47,8 +47,8 @@ public: // (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); -IAudioDecoder *CreateDecoder(ReadDataFunction reader, void *pData, uint32 &numChannels, uint32 &sampleRate, - uint32 &sampleCount); +IAudioDecoder *CreateDecoder(ReadDataFunction reader, void *pData, uint32_t &numChannels, uint32_t &sampleRate, + uint32_t &sampleCount); } // namespace AudioDecoder diff --git a/libacm/adecode.cpp b/libacm/adecode.cpp index fa344fa7..1651fec6 100644 --- a/libacm/adecode.cpp +++ b/libacm/adecode.cpp @@ -36,7 +36,7 @@ public: // pBuffer: The buffer to receive the data into // amount: How much data to read // Returns the number of bytes read - zero when we're at the end of the file - uint32 Read(void *pBuffer, uint32 amount); + uint32_t Read(void *pBuffer, uint32_t amount); ACMStream *m_acm = nullptr; ReadDataFunction m_readerFunction; @@ -94,11 +94,11 @@ InternalAudioDecoder::~InternalAudioDecoder() { // pBuffer: The buffer to receive the data into // amount: How much data to read // Returns the number of bytes read - zero when we're at the end of the file -uint32 InternalAudioDecoder::Read(void *pBuffer, uint32 amount) { +uint32_t InternalAudioDecoder::Read(void *pBuffer, uint32_t amount) { const int bigendianp = 0; // we want little endian samples - TODO: or only on little endian platforms? const int wordlen = 2; // the only supported value const int sgned = 1; // we want signed samples - uint32 totalBytesRead = 0; + uint32_t totalBytesRead = 0; uint8 *pBuf = reinterpret_cast(pBuffer); while (totalBytesRead < amount) { @@ -129,9 +129,9 @@ uint32 InternalAudioDecoder::Read(void *pBuffer, uint32 amount) { // (in case you want to pre-allocate a buffer to load them all into memory). IAudioDecoder *AudioDecoder::CreateDecoder(ReadDataFunction readerFunction, void *pReaderData, - uint32 &numChannels, - uint32 &sampleRate, - uint32 &sampleCount) { + uint32_t &numChannels, + uint32_t &sampleRate, + uint32_t &sampleCount) { // allocate our decoder InternalAudioDecoder *pDecoder = new InternalAudioDecoder(readerFunction, pReaderData); diff --git a/libacm/aencode.cpp b/libacm/aencode.cpp index ac010939..7f0d0bdd 100644 --- a/libacm/aencode.cpp +++ b/libacm/aencode.cpp @@ -23,7 +23,7 @@ #include #include "Aencode.h" -typedef uint32_t uint32; +typedef uint32_t uint32_t; typedef int32_t sint32; typedef unsigned short uint16; typedef signed short sint16; @@ -32,12 +32,12 @@ typedef int8_t sint8; struct BitsEncoder { FILE *m_outFile; // var50 | offset 0x10 - uint32 m_bitData; // var4C | offset 0x14 - uint32 m_bitCount; // var48 | offset 0x18 + uint32_t m_bitData; // var4C | offset 0x14 + uint32_t m_bitCount; // var48 | offset 0x18 - void WriteBits(sint32 val, uint32 numBits) { + void WriteBits(sint32 val, uint32_t numBits) { assert((numBits + m_bitCount) <= 32); - m_bitData |= static_cast(val << m_bitCount); + m_bitData |= static_cast(val << m_bitCount); m_bitCount += numBits; while (m_bitCount >= 8) { @@ -70,7 +70,7 @@ struct BitsEncoder { struct Encoder { ReadSampleFunction *m_reader; // var60 | offset 0x00 void *m_pReaderData; // var5C | offset 0x04 - uint32 m_sampleCount; // var58 | offset 0x08 + uint32_t m_sampleCount; // var58 | offset 0x08 float m_volume; // var54 | offset 0x0C BitsEncoder m_bits; // var50 - var48 | offset 0x10 - 0x18 sint8 m_levels; // var44* | offset 0x1C @@ -87,26 +87,26 @@ struct Encoder { sint32 m_someVal; // var1C | offset 0x44 float *m_lo_filter; // var18 | offset 0x48 float *m_hi_filter; // var14 | offset 0x4C - uint32 *m_pFormatIdPerColumn; // var10 | offset 0x50 + 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 }; -typedef void (*WriteBandFunc)(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt0(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt3_16(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt17(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt18(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt19(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt20(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt21(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt22(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt23(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt24(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt26(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt27(Encoder &enc, sint32 colIndex, uint32 packerId); -void WriteBand_Fmt29(Encoder &enc, sint32 colIndex, uint32 packerId); +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); WriteBandFunc WriteBand_tbl[] = {WriteBand_Fmt0, NULL, @@ -153,9 +153,9 @@ const float T911 = -32767.0f; const float T913 = 32767.0f; const float T1266 = 0.0f; -void WriteBand_Fmt0(Encoder &enc, sint32 colIndex, uint32 formatId) {} +void WriteBand_Fmt0(Encoder &enc, sint32 colIndex, uint32_t formatId) {} -void WriteBand_Fmt3_16(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt3_16(Encoder &enc, sint32 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); @@ -175,7 +175,7 @@ void WriteBand_Fmt3_16(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt17(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt17(Encoder &enc, sint32 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); @@ -213,7 +213,7 @@ void WriteBand_Fmt17(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt18(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt18(Encoder &enc, sint32 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); @@ -242,7 +242,7 @@ void WriteBand_Fmt18(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt19(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt19(Encoder &enc, sint32 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); @@ -291,7 +291,7 @@ void WriteBand_Fmt19(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt20(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt20(Encoder &enc, sint32 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); @@ -333,7 +333,7 @@ void WriteBand_Fmt20(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt21(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt21(Encoder &enc, sint32 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); @@ -367,7 +367,7 @@ void WriteBand_Fmt21(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt22(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt22(Encoder &enc, sint32 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); @@ -418,7 +418,7 @@ void WriteBand_Fmt22(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt23(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt23(Encoder &enc, sint32 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); @@ -473,7 +473,7 @@ void WriteBand_Fmt23(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt24(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt24(Encoder &enc, sint32 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); @@ -513,7 +513,7 @@ void WriteBand_Fmt24(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt26(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt26(Encoder &enc, sint32 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)); @@ -563,7 +563,7 @@ void WriteBand_Fmt26(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt27(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt27(Encoder &enc, sint32 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); @@ -598,7 +598,7 @@ void WriteBand_Fmt27(Encoder &enc, sint32 colIndex, uint32 formatId) { } } -void WriteBand_Fmt29(Encoder &enc, sint32 colIndex, uint32 formatId) { +void WriteBand_Fmt29(Encoder &enc, sint32 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); @@ -683,7 +683,7 @@ int SetupEncoder(Encoder &enc, int someVal, float std_lo_filter[], float std_hi_ } } - enc.m_pFormatIdPerColumn = reinterpret_cast(malloc(enc.m_numColumns * sizeof(uint32))); + enc.m_pFormatIdPerColumn = reinterpret_cast(malloc(enc.m_numColumns * sizeof(uint32_t))); if (enc.m_pFormatIdPerColumn == NULL) return 0; @@ -767,7 +767,7 @@ void transform_all(Encoder &enc) { } sint32 calc_bits(Encoder &enc, sint32 val) { - static uint32 calc_bits_data[] = {0x00, 0x13, 0x16, 0x03, 0x1D, 0x00}; + static uint32_t calc_bits_data[] = {0x00, 0x13, 0x16, 0x03, 0x1D, 0x00}; sint32 bitPower = 3; sint32 result = enc.m_numColumns * 5 + 20; @@ -927,7 +927,7 @@ void WriteBands(Encoder &enc) { enc.m_bits.WriteBits(enc.m_currBlockBitValue, 16); for (int i = 0; i < enc.m_numColumns; ++i) { - const uint32 formatId = enc.m_pFormatIdPerColumn[i]; + const uint32_t formatId = enc.m_pFormatIdPerColumn[i]; enc.m_bits.WriteBits(formatId, 5); // int32_t currPos = ftell(enc.m_bits.m_outFile); WriteBand_tbl[formatId](enc, i, formatId);