mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Cleaned up a couple of parameter types in byte order conversion.
This commit is contained in:
parent
7e35b73df6
commit
e3d7ec1827
2 changed files with 38 additions and 38 deletions
|
|
@ -25,7 +25,7 @@
|
||||||
void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
||||||
{
|
{
|
||||||
const double maxVal = (double) 0x7fff;
|
const double maxVal = (double) 0x7fff;
|
||||||
char* intData = static_cast <char*> (dest);
|
char* intData = static_cast<char*> (dest);
|
||||||
|
|
||||||
if (dest != (void*) source || destBytesPerSample <= 4)
|
if (dest != (void*) source || destBytesPerSample <= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -50,7 +50,7 @@ void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest
|
||||||
void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
||||||
{
|
{
|
||||||
const double maxVal = (double) 0x7fff;
|
const double maxVal = (double) 0x7fff;
|
||||||
char* intData = static_cast <char*> (dest);
|
char* intData = static_cast<char*> (dest);
|
||||||
|
|
||||||
if (dest != (void*) source || destBytesPerSample <= 4)
|
if (dest != (void*) source || destBytesPerSample <= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -75,7 +75,7 @@ void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest
|
||||||
void AudioDataConverters::convertFloatToInt24LE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
void AudioDataConverters::convertFloatToInt24LE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
||||||
{
|
{
|
||||||
const double maxVal = (double) 0x7fffff;
|
const double maxVal = (double) 0x7fffff;
|
||||||
char* intData = static_cast <char*> (dest);
|
char* intData = static_cast<char*> (dest);
|
||||||
|
|
||||||
if (dest != (void*) source || destBytesPerSample <= 4)
|
if (dest != (void*) source || destBytesPerSample <= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -100,7 +100,7 @@ void AudioDataConverters::convertFloatToInt24LE (const float* source, void* dest
|
||||||
void AudioDataConverters::convertFloatToInt24BE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
void AudioDataConverters::convertFloatToInt24BE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
||||||
{
|
{
|
||||||
const double maxVal = (double) 0x7fffff;
|
const double maxVal = (double) 0x7fffff;
|
||||||
char* intData = static_cast <char*> (dest);
|
char* intData = static_cast<char*> (dest);
|
||||||
|
|
||||||
if (dest != (void*) source || destBytesPerSample <= 4)
|
if (dest != (void*) source || destBytesPerSample <= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -125,7 +125,7 @@ void AudioDataConverters::convertFloatToInt24BE (const float* source, void* dest
|
||||||
void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
||||||
{
|
{
|
||||||
const double maxVal = (double) 0x7fffffff;
|
const double maxVal = (double) 0x7fffffff;
|
||||||
char* intData = static_cast <char*> (dest);
|
char* intData = static_cast<char*> (dest);
|
||||||
|
|
||||||
if (dest != (void*) source || destBytesPerSample <= 4)
|
if (dest != (void*) source || destBytesPerSample <= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -150,7 +150,7 @@ void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest
|
||||||
void AudioDataConverters::convertFloatToInt32BE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
void AudioDataConverters::convertFloatToInt32BE (const float* source, void* dest, int numSamples, const int destBytesPerSample)
|
||||||
{
|
{
|
||||||
const double maxVal = (double) 0x7fffffff;
|
const double maxVal = (double) 0x7fffffff;
|
||||||
char* intData = static_cast <char*> (dest);
|
char* intData = static_cast<char*> (dest);
|
||||||
|
|
||||||
if (dest != (void*) source || destBytesPerSample <= 4)
|
if (dest != (void*) source || destBytesPerSample <= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -176,7 +176,7 @@ void AudioDataConverters::convertFloatToFloat32LE (const float* source, void* de
|
||||||
{
|
{
|
||||||
jassert (dest != (void*) source || destBytesPerSample <= 4); // This op can't be performed on in-place data!
|
jassert (dest != (void*) source || destBytesPerSample <= 4); // This op can't be performed on in-place data!
|
||||||
|
|
||||||
char* d = static_cast <char*> (dest);
|
char* d = static_cast<char*> (dest);
|
||||||
|
|
||||||
for (int i = 0; i < numSamples; ++i)
|
for (int i = 0; i < numSamples; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -194,7 +194,7 @@ void AudioDataConverters::convertFloatToFloat32BE (const float* source, void* de
|
||||||
{
|
{
|
||||||
jassert (dest != (void*) source || destBytesPerSample <= 4); // This op can't be performed on in-place data!
|
jassert (dest != (void*) source || destBytesPerSample <= 4); // This op can't be performed on in-place data!
|
||||||
|
|
||||||
char* d = static_cast <char*> (dest);
|
char* d = static_cast<char*> (dest);
|
||||||
|
|
||||||
for (int i = 0; i < numSamples; ++i)
|
for (int i = 0; i < numSamples; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -212,7 +212,7 @@ void AudioDataConverters::convertFloatToFloat32BE (const float* source, void* de
|
||||||
void AudioDataConverters::convertInt16LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
void AudioDataConverters::convertInt16LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
||||||
{
|
{
|
||||||
const float scale = 1.0f / 0x7fff;
|
const float scale = 1.0f / 0x7fff;
|
||||||
const char* intData = static_cast <const char*> (source);
|
const char* intData = static_cast<const char*> (source);
|
||||||
|
|
||||||
if (source != (void*) dest || srcBytesPerSample >= 4)
|
if (source != (void*) dest || srcBytesPerSample >= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -237,7 +237,7 @@ void AudioDataConverters::convertInt16LEToFloat (const void* const source, float
|
||||||
void AudioDataConverters::convertInt16BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
void AudioDataConverters::convertInt16BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
||||||
{
|
{
|
||||||
const float scale = 1.0f / 0x7fff;
|
const float scale = 1.0f / 0x7fff;
|
||||||
const char* intData = static_cast <const char*> (source);
|
const char* intData = static_cast<const char*> (source);
|
||||||
|
|
||||||
if (source != (void*) dest || srcBytesPerSample >= 4)
|
if (source != (void*) dest || srcBytesPerSample >= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -262,7 +262,7 @@ void AudioDataConverters::convertInt16BEToFloat (const void* const source, float
|
||||||
void AudioDataConverters::convertInt24LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
void AudioDataConverters::convertInt24LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
||||||
{
|
{
|
||||||
const float scale = 1.0f / 0x7fffff;
|
const float scale = 1.0f / 0x7fffff;
|
||||||
const char* intData = static_cast <const char*> (source);
|
const char* intData = static_cast<const char*> (source);
|
||||||
|
|
||||||
if (source != (void*) dest || srcBytesPerSample >= 4)
|
if (source != (void*) dest || srcBytesPerSample >= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -287,7 +287,7 @@ void AudioDataConverters::convertInt24LEToFloat (const void* const source, float
|
||||||
void AudioDataConverters::convertInt24BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
void AudioDataConverters::convertInt24BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
||||||
{
|
{
|
||||||
const float scale = 1.0f / 0x7fffff;
|
const float scale = 1.0f / 0x7fffff;
|
||||||
const char* intData = static_cast <const char*> (source);
|
const char* intData = static_cast<const char*> (source);
|
||||||
|
|
||||||
if (source != (void*) dest || srcBytesPerSample >= 4)
|
if (source != (void*) dest || srcBytesPerSample >= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -312,7 +312,7 @@ void AudioDataConverters::convertInt24BEToFloat (const void* const source, float
|
||||||
void AudioDataConverters::convertInt32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
void AudioDataConverters::convertInt32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
||||||
{
|
{
|
||||||
const float scale = 1.0f / 0x7fffffff;
|
const float scale = 1.0f / 0x7fffffff;
|
||||||
const char* intData = static_cast <const char*> (source);
|
const char* intData = static_cast<const char*> (source);
|
||||||
|
|
||||||
if (source != (void*) dest || srcBytesPerSample >= 4)
|
if (source != (void*) dest || srcBytesPerSample >= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -337,7 +337,7 @@ void AudioDataConverters::convertInt32LEToFloat (const void* const source, float
|
||||||
void AudioDataConverters::convertInt32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
void AudioDataConverters::convertInt32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
||||||
{
|
{
|
||||||
const float scale = 1.0f / 0x7fffffff;
|
const float scale = 1.0f / 0x7fffffff;
|
||||||
const char* intData = static_cast <const char*> (source);
|
const char* intData = static_cast<const char*> (source);
|
||||||
|
|
||||||
if (source != (void*) dest || srcBytesPerSample >= 4)
|
if (source != (void*) dest || srcBytesPerSample >= 4)
|
||||||
{
|
{
|
||||||
|
|
@ -361,7 +361,7 @@ void AudioDataConverters::convertInt32BEToFloat (const void* const source, float
|
||||||
|
|
||||||
void AudioDataConverters::convertFloat32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
void AudioDataConverters::convertFloat32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
||||||
{
|
{
|
||||||
const char* s = static_cast <const char*> (source);
|
const char* s = static_cast<const char*> (source);
|
||||||
|
|
||||||
for (int i = 0; i < numSamples; ++i)
|
for (int i = 0; i < numSamples; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -378,7 +378,7 @@ void AudioDataConverters::convertFloat32LEToFloat (const void* const source, flo
|
||||||
|
|
||||||
void AudioDataConverters::convertFloat32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
void AudioDataConverters::convertFloat32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
|
||||||
{
|
{
|
||||||
const char* s = static_cast <const char*> (source);
|
const char* s = static_cast<const char*> (source);
|
||||||
|
|
||||||
for (int i = 0; i < numSamples; ++i)
|
for (int i = 0; i < numSamples; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -87,16 +87,16 @@ public:
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/** Converts 3 little-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */
|
/** Converts 3 little-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */
|
||||||
static int littleEndian24Bit (const char* bytes) noexcept;
|
static int littleEndian24Bit (const void* bytes) noexcept;
|
||||||
|
|
||||||
/** Converts 3 big-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */
|
/** Converts 3 big-endian bytes into a signed 24-bit value (which is sign-extended to 32 bits). */
|
||||||
static int bigEndian24Bit (const char* bytes) noexcept;
|
static int bigEndian24Bit (const void* bytes) noexcept;
|
||||||
|
|
||||||
/** Copies a 24-bit number to 3 little-endian bytes. */
|
/** Copies a 24-bit number to 3 little-endian bytes. */
|
||||||
static void littleEndian24BitToChars (int value, char* destBytes) noexcept;
|
static void littleEndian24BitToChars (int value, void* destBytes) noexcept;
|
||||||
|
|
||||||
/** Copies a 24-bit number to 3 big-endian bytes. */
|
/** Copies a 24-bit number to 3 big-endian bytes. */
|
||||||
static void bigEndian24BitToChars (int value, char* destBytes) noexcept;
|
static void bigEndian24BitToChars (int value, void* destBytes) noexcept;
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/** Returns true if the current CPU is big-endian. */
|
/** Returns true if the current CPU is big-endian. */
|
||||||
|
|
@ -117,9 +117,9 @@ private:
|
||||||
inline uint16 ByteOrder::swap (uint16 n) noexcept
|
inline uint16 ByteOrder::swap (uint16 n) noexcept
|
||||||
{
|
{
|
||||||
#if JUCE_USE_INTRINSICSxxx // agh - the MS compiler has an internal error when you try to use this intrinsic!
|
#if JUCE_USE_INTRINSICSxxx // agh - the MS compiler has an internal error when you try to use this intrinsic!
|
||||||
return static_cast <uint16> (_byteswap_ushort (n));
|
return static_cast<uint16> (_byteswap_ushort (n));
|
||||||
#else
|
#else
|
||||||
return static_cast <uint16> ((n << 8) | (n >> 8));
|
return static_cast<uint16> ((n << 8) | (n >> 8));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,12 +164,12 @@ inline uint64 ByteOrder::swap (uint64 value) noexcept
|
||||||
inline uint16 ByteOrder::swapIfLittleEndian (const uint16 v) noexcept { return swap (v); }
|
inline uint16 ByteOrder::swapIfLittleEndian (const uint16 v) noexcept { return swap (v); }
|
||||||
inline uint32 ByteOrder::swapIfLittleEndian (const uint32 v) noexcept { return swap (v); }
|
inline uint32 ByteOrder::swapIfLittleEndian (const uint32 v) noexcept { return swap (v); }
|
||||||
inline uint64 ByteOrder::swapIfLittleEndian (const uint64 v) noexcept { return swap (v); }
|
inline uint64 ByteOrder::swapIfLittleEndian (const uint64 v) noexcept { return swap (v); }
|
||||||
inline uint32 ByteOrder::littleEndianInt (const void* const bytes) noexcept { return *static_cast <const uint32*> (bytes); }
|
inline uint32 ByteOrder::littleEndianInt (const void* const bytes) noexcept { return *static_cast<const uint32*> (bytes); }
|
||||||
inline uint64 ByteOrder::littleEndianInt64 (const void* const bytes) noexcept { return *static_cast <const uint64*> (bytes); }
|
inline uint64 ByteOrder::littleEndianInt64 (const void* const bytes) noexcept { return *static_cast<const uint64*> (bytes); }
|
||||||
inline uint16 ByteOrder::littleEndianShort (const void* const bytes) noexcept { return *static_cast <const uint16*> (bytes); }
|
inline uint16 ByteOrder::littleEndianShort (const void* const bytes) noexcept { return *static_cast<const uint16*> (bytes); }
|
||||||
inline uint32 ByteOrder::bigEndianInt (const void* const bytes) noexcept { return swap (*static_cast <const uint32*> (bytes)); }
|
inline uint32 ByteOrder::bigEndianInt (const void* const bytes) noexcept { return swap (*static_cast<const uint32*> (bytes)); }
|
||||||
inline uint64 ByteOrder::bigEndianInt64 (const void* const bytes) noexcept { return swap (*static_cast <const uint64*> (bytes)); }
|
inline uint64 ByteOrder::bigEndianInt64 (const void* const bytes) noexcept { return swap (*static_cast<const uint64*> (bytes)); }
|
||||||
inline uint16 ByteOrder::bigEndianShort (const void* const bytes) noexcept { return swap (*static_cast <const uint16*> (bytes)); }
|
inline uint16 ByteOrder::bigEndianShort (const void* const bytes) noexcept { return swap (*static_cast<const uint16*> (bytes)); }
|
||||||
inline bool ByteOrder::isBigEndian() noexcept { return false; }
|
inline bool ByteOrder::isBigEndian() noexcept { return false; }
|
||||||
#else
|
#else
|
||||||
inline uint16 ByteOrder::swapIfBigEndian (const uint16 v) noexcept { return swap (v); }
|
inline uint16 ByteOrder::swapIfBigEndian (const uint16 v) noexcept { return swap (v); }
|
||||||
|
|
@ -178,19 +178,19 @@ inline uint64 ByteOrder::swap (uint64 value) noexcept
|
||||||
inline uint16 ByteOrder::swapIfLittleEndian (const uint16 v) noexcept { return v; }
|
inline uint16 ByteOrder::swapIfLittleEndian (const uint16 v) noexcept { return v; }
|
||||||
inline uint32 ByteOrder::swapIfLittleEndian (const uint32 v) noexcept { return v; }
|
inline uint32 ByteOrder::swapIfLittleEndian (const uint32 v) noexcept { return v; }
|
||||||
inline uint64 ByteOrder::swapIfLittleEndian (const uint64 v) noexcept { return v; }
|
inline uint64 ByteOrder::swapIfLittleEndian (const uint64 v) noexcept { return v; }
|
||||||
inline uint32 ByteOrder::littleEndianInt (const void* const bytes) noexcept { return swap (*static_cast <const uint32*> (bytes)); }
|
inline uint32 ByteOrder::littleEndianInt (const void* const bytes) noexcept { return swap (*static_cast<const uint32*> (bytes)); }
|
||||||
inline uint64 ByteOrder::littleEndianInt64 (const void* const bytes) noexcept { return swap (*static_cast <const uint64*> (bytes)); }
|
inline uint64 ByteOrder::littleEndianInt64 (const void* const bytes) noexcept { return swap (*static_cast<const uint64*> (bytes)); }
|
||||||
inline uint16 ByteOrder::littleEndianShort (const void* const bytes) noexcept { return swap (*static_cast <const uint16*> (bytes)); }
|
inline uint16 ByteOrder::littleEndianShort (const void* const bytes) noexcept { return swap (*static_cast<const uint16*> (bytes)); }
|
||||||
inline uint32 ByteOrder::bigEndianInt (const void* const bytes) noexcept { return *static_cast <const uint32*> (bytes); }
|
inline uint32 ByteOrder::bigEndianInt (const void* const bytes) noexcept { return *static_cast<const uint32*> (bytes); }
|
||||||
inline uint64 ByteOrder::bigEndianInt64 (const void* const bytes) noexcept { return *static_cast <const uint64*> (bytes); }
|
inline uint64 ByteOrder::bigEndianInt64 (const void* const bytes) noexcept { return *static_cast<const uint64*> (bytes); }
|
||||||
inline uint16 ByteOrder::bigEndianShort (const void* const bytes) noexcept { return *static_cast <const uint16*> (bytes); }
|
inline uint16 ByteOrder::bigEndianShort (const void* const bytes) noexcept { return *static_cast<const uint16*> (bytes); }
|
||||||
inline bool ByteOrder::isBigEndian() noexcept { return true; }
|
inline bool ByteOrder::isBigEndian() noexcept { return true; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline int ByteOrder::littleEndian24Bit (const char* const bytes) noexcept { return (((int) bytes[2]) << 16) | (((int) (uint8) bytes[1]) << 8) | ((int) (uint8) bytes[0]); }
|
inline int ByteOrder::littleEndian24Bit (const void* const bytes) noexcept { return (((int) static_cast<const int8*> (bytes)[2]) << 16) | (((int) static_cast<const uint8*> (bytes)[1]) << 8) | ((int) static_cast<const uint8*> (bytes)[0]); }
|
||||||
inline int ByteOrder::bigEndian24Bit (const char* const bytes) noexcept { return (((int) bytes[0]) << 16) | (((int) (uint8) bytes[1]) << 8) | ((int) (uint8) bytes[2]); }
|
inline int ByteOrder::bigEndian24Bit (const void* const bytes) noexcept { return (((int) static_cast<const int8*> (bytes)[0]) << 16) | (((int) static_cast<const uint8*> (bytes)[1]) << 8) | ((int) static_cast<const uint8*> (bytes)[2]); }
|
||||||
inline void ByteOrder::littleEndian24BitToChars (const int value, char* const destBytes) noexcept { destBytes[0] = (char)(value & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)((value >> 16) & 0xff); }
|
inline void ByteOrder::littleEndian24BitToChars (const int value, void* const destBytes) noexcept { static_cast<uint8*> (destBytes)[0] = (uint8) value; static_cast<uint8*> (destBytes)[1] = (uint8) (value >> 8); static_cast<uint8*> (destBytes)[2] = (uint8) (value >> 16); }
|
||||||
inline void ByteOrder::bigEndian24BitToChars (const int value, char* const destBytes) noexcept { destBytes[0] = (char)((value >> 16) & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)(value & 0xff); }
|
inline void ByteOrder::bigEndian24BitToChars (const int value, void* const destBytes) noexcept { static_cast<uint8*> (destBytes)[0] = (uint8) (value >> 16); static_cast<uint8*> (destBytes)[1] = (uint8) (value >> 8); static_cast<uint8*> (destBytes)[2] = (uint8) value; }
|
||||||
|
|
||||||
|
|
||||||
#endif // JUCE_BYTEORDER_H_INCLUDED
|
#endif // JUCE_BYTEORDER_H_INCLUDED
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue