Avoid using some more AL types

This commit is contained in:
Chris Robinson 2020-04-23 04:57:04 -07:00
parent 2deb5e47d1
commit aff410fa6d
3 changed files with 39 additions and 39 deletions

View File

@ -116,7 +116,7 @@ void DecodeIMA4Block(int16_t *dst, const al::byte *src, size_t numchans, size_t
index[c] = clampi((index[c]^0x8000) - 32768, 0, 88); index[c] = clampi((index[c]^0x8000) - 32768, 0, 88);
src += 2; src += 2;
*(dst++) = static_cast<ALshort>(sample[c]); *(dst++) = static_cast<int16_t>(sample[c]);
} }
for(size_t i{1};i < align;i++) for(size_t i{1};i < align;i++)
@ -142,14 +142,14 @@ void DecodeIMA4Block(int16_t *dst, const al::byte *src, size_t numchans, size_t
index[c] += IMA4Index_adjust[nibble]; index[c] += IMA4Index_adjust[nibble];
index[c] = clampi(index[c], 0, 88); index[c] = clampi(index[c], 0, 88);
*(dst++) = static_cast<ALshort>(sample[c]); *(dst++) = static_cast<int16_t>(sample[c]);
} }
} }
} }
void DecodeMSADPCMBlock(int16_t *dst, const al::byte *src, size_t numchans, size_t align) void DecodeMSADPCMBlock(int16_t *dst, const al::byte *src, size_t numchans, size_t align)
{ {
ALubyte blockpred[MaxAdpcmChannels]{}; uint8_t blockpred[MaxAdpcmChannels]{};
int delta[MaxAdpcmChannels]{}; int delta[MaxAdpcmChannels]{};
int16_t samples[MaxAdpcmChannels][2]{}; int16_t samples[MaxAdpcmChannels][2]{};
@ -211,7 +211,7 @@ void DecodeMSADPCMBlock(int16_t *dst, const al::byte *src, size_t numchans, size
} }
} }
void Convert_ALshort_ALima4(int16_t *dst, const al::byte *src, size_t numchans, size_t len, void Convert_int16_ima4(int16_t *dst, const al::byte *src, size_t numchans, size_t len,
size_t align) size_t align)
{ {
assert(numchans <= MaxAdpcmChannels); assert(numchans <= MaxAdpcmChannels);
@ -226,7 +226,7 @@ void Convert_ALshort_ALima4(int16_t *dst, const al::byte *src, size_t numchans,
} }
} }
void Convert_ALshort_ALmsadpcm(int16_t *dst, const al::byte *src, size_t numchans, size_t len, void Convert_int16_msadpcm(int16_t *dst, const al::byte *src, size_t numchans, size_t len,
size_t align) size_t align)
{ {
assert(numchans <= MaxAdpcmChannels); assert(numchans <= MaxAdpcmChannels);
@ -246,12 +246,12 @@ ALuint BytesFromUserFmt(UserFmtType type) noexcept
{ {
switch(type) switch(type)
{ {
case UserFmtUByte: return sizeof(ALubyte); case UserFmtUByte: return sizeof(uint8_t);
case UserFmtShort: return sizeof(ALshort); case UserFmtShort: return sizeof(int16_t);
case UserFmtFloat: return sizeof(ALfloat); case UserFmtFloat: return sizeof(float);
case UserFmtDouble: return sizeof(ALdouble); case UserFmtDouble: return sizeof(double);
case UserFmtMulaw: return sizeof(ALubyte); case UserFmtMulaw: return sizeof(uint8_t);
case UserFmtAlaw: return sizeof(ALubyte); case UserFmtAlaw: return sizeof(uint8_t);
case UserFmtIMA4: break; /* not handled here */ case UserFmtIMA4: break; /* not handled here */
case UserFmtMSADPCM: break; /* not handled here */ case UserFmtMSADPCM: break; /* not handled here */
} }
@ -523,16 +523,16 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
{ {
assert(DstType == FmtShort); assert(DstType == FmtShort);
if(SrcData != nullptr && !ALBuf->mData.empty()) if(SrcData != nullptr && !ALBuf->mData.empty())
Convert_ALshort_ALima4(reinterpret_cast<int16_t*>(ALBuf->mData.data()), Convert_int16_ima4(reinterpret_cast<int16_t*>(ALBuf->mData.data()), SrcData,
SrcData, NumChannels, frames, align); NumChannels, frames, align);
ALBuf->OriginalAlign = align; ALBuf->OriginalAlign = align;
} }
else if(SrcType == UserFmtMSADPCM) else if(SrcType == UserFmtMSADPCM)
{ {
assert(DstType == FmtShort); assert(DstType == FmtShort);
if(SrcData != nullptr && !ALBuf->mData.empty()) if(SrcData != nullptr && !ALBuf->mData.empty())
Convert_ALshort_ALmsadpcm(reinterpret_cast<int16_t*>(ALBuf->mData.data()), Convert_int16_msadpcm(reinterpret_cast<int16_t*>(ALBuf->mData.data()), SrcData,
SrcData, NumChannels, frames, align); NumChannels, frames, align);
ALBuf->OriginalAlign = align; ALBuf->OriginalAlign = align;
} }
else else
@ -1019,10 +1019,10 @@ START_API_FUNC
void *dst = albuf->mData.data() + byteoff; void *dst = albuf->mData.data() + byteoff;
if(usrfmt->type == UserFmtIMA4 && albuf->mFmtType == FmtShort) if(usrfmt->type == UserFmtIMA4 && albuf->mFmtType == FmtShort)
Convert_ALshort_ALima4(static_cast<ALshort*>(dst), Convert_int16_ima4(static_cast<int16_t*>(dst), static_cast<const al::byte*>(data),
static_cast<const al::byte*>(data), num_chans, samplen, align); num_chans, samplen, align);
else if(usrfmt->type == UserFmtMSADPCM && albuf->mFmtType == FmtShort) else if(usrfmt->type == UserFmtMSADPCM && albuf->mFmtType == FmtShort)
Convert_ALshort_ALmsadpcm(static_cast<ALshort*>(dst), Convert_int16_msadpcm(static_cast<int16_t*>(dst),
static_cast<const al::byte*>(data), num_chans, samplen, align); static_cast<const al::byte*>(data), num_chans, samplen, align);
else else
{ {
@ -1581,12 +1581,12 @@ ALuint BytesFromFmt(FmtType type) noexcept
{ {
switch(type) switch(type)
{ {
case FmtUByte: return sizeof(ALubyte); case FmtUByte: return sizeof(uint8_t);
case FmtShort: return sizeof(ALshort); case FmtShort: return sizeof(int16_t);
case FmtFloat: return sizeof(ALfloat); case FmtFloat: return sizeof(float);
case FmtDouble: return sizeof(ALdouble); case FmtDouble: return sizeof(double);
case FmtMulaw: return sizeof(ALubyte); case FmtMulaw: return sizeof(uint8_t);
case FmtAlaw: return sizeof(ALubyte); case FmtAlaw: return sizeof(uint8_t);
} }
return 0; return 0;
} }

View File

@ -1317,13 +1317,13 @@ ALuint BytesFromDevFmt(DevFmtType type) noexcept
{ {
switch(type) switch(type)
{ {
case DevFmtByte: return sizeof(ALCbyte); case DevFmtByte: return sizeof(int8_t);
case DevFmtUByte: return sizeof(ALCubyte); case DevFmtUByte: return sizeof(uint8_t);
case DevFmtShort: return sizeof(ALCshort); case DevFmtShort: return sizeof(int16_t);
case DevFmtUShort: return sizeof(ALCushort); case DevFmtUShort: return sizeof(uint16_t);
case DevFmtInt: return sizeof(ALCint); case DevFmtInt: return sizeof(int32_t);
case DevFmtUInt: return sizeof(ALCuint); case DevFmtUInt: return sizeof(uint32_t);
case DevFmtFloat: return sizeof(ALCfloat); case DevFmtFloat: return sizeof(float);
} }
return 0; return 0;
} }

View File

@ -184,7 +184,7 @@ namespace {
/* A quick'n'dirty lookup table to decode a muLaw-encoded byte sample into a /* A quick'n'dirty lookup table to decode a muLaw-encoded byte sample into a
* signed 16-bit sample */ * signed 16-bit sample */
constexpr ALshort muLawDecompressionTable[256] = { constexpr int16_t muLawDecompressionTable[256] = {
-32124,-31100,-30076,-29052,-28028,-27004,-25980,-24956, -32124,-31100,-30076,-29052,-28028,-27004,-25980,-24956,
-23932,-22908,-21884,-20860,-19836,-18812,-17788,-16764, -23932,-22908,-21884,-20860,-19836,-18812,-17788,-16764,
-15996,-15484,-14972,-14460,-13948,-13436,-12924,-12412, -15996,-15484,-14972,-14460,-13948,-13436,-12924,-12412,
@ -221,7 +221,7 @@ constexpr ALshort muLawDecompressionTable[256] = {
/* A quick'n'dirty lookup table to decode an aLaw-encoded byte sample into a /* A quick'n'dirty lookup table to decode an aLaw-encoded byte sample into a
* signed 16-bit sample */ * signed 16-bit sample */
constexpr ALshort aLawDecompressionTable[256] = { constexpr int16_t aLawDecompressionTable[256] = {
-5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
-7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
-2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368, -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
@ -261,35 +261,35 @@ struct FmtTypeTraits { };
template<> template<>
struct FmtTypeTraits<FmtUByte> { struct FmtTypeTraits<FmtUByte> {
using Type = ALubyte; using Type = uint8_t;
static constexpr inline float to_float(const Type val) noexcept static constexpr inline float to_float(const Type val) noexcept
{ return val*(1.0f/128.0f) - 1.0f; } { return val*(1.0f/128.0f) - 1.0f; }
}; };
template<> template<>
struct FmtTypeTraits<FmtShort> { struct FmtTypeTraits<FmtShort> {
using Type = ALshort; using Type = int16_t;
static constexpr inline float to_float(const Type val) noexcept { return val*(1.0f/32768.0f); } static constexpr inline float to_float(const Type val) noexcept { return val*(1.0f/32768.0f); }
}; };
template<> template<>
struct FmtTypeTraits<FmtFloat> { struct FmtTypeTraits<FmtFloat> {
using Type = ALfloat; using Type = float;
static constexpr inline float to_float(const Type val) noexcept { return val; } static constexpr inline float to_float(const Type val) noexcept { return val; }
}; };
template<> template<>
struct FmtTypeTraits<FmtDouble> { struct FmtTypeTraits<FmtDouble> {
using Type = ALdouble; using Type = double;
static constexpr inline float to_float(const Type val) noexcept static constexpr inline float to_float(const Type val) noexcept
{ return static_cast<float>(val); } { return static_cast<float>(val); }
}; };
template<> template<>
struct FmtTypeTraits<FmtMulaw> { struct FmtTypeTraits<FmtMulaw> {
using Type = ALubyte; using Type = uint8_t;
static constexpr inline float to_float(const Type val) noexcept static constexpr inline float to_float(const Type val) noexcept
{ return muLawDecompressionTable[val] * (1.0f/32768.0f); } { return muLawDecompressionTable[val] * (1.0f/32768.0f); }
}; };
template<> template<>
struct FmtTypeTraits<FmtAlaw> { struct FmtTypeTraits<FmtAlaw> {
using Type = ALubyte; using Type = uint8_t;
static constexpr inline float to_float(const Type val) noexcept static constexpr inline float to_float(const Type val) noexcept
{ return aLawDecompressionTable[val] * (1.0f/32768.0f); } { return aLawDecompressionTable[val] * (1.0f/32768.0f); }
}; };