aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alc/converter.cpp82
-rw-r--r--alc/converter.h22
2 files changed, 52 insertions, 52 deletions
diff --git a/alc/converter.cpp b/alc/converter.cpp
index 1eab59bb..2b881645 100644
--- a/alc/converter.cpp
+++ b/alc/converter.cpp
@@ -7,8 +7,6 @@
#include <cstdint>
#include <iterator>
-#include "AL/al.h"
-
#include "albyte.h"
#include "alu.h"
#include "fpu_ctrl.h"
@@ -36,11 +34,11 @@ template<> inline float LoadSample<DevFmtFloat>(DevFmtTypeTraits<DevFmtFloat>::T
{ return val; }
template<> inline float LoadSample<DevFmtUByte>(DevFmtTypeTraits<DevFmtUByte>::Type val) noexcept
-{ return LoadSample<DevFmtByte>(static_cast<ALbyte>(val - 128)); }
+{ return LoadSample<DevFmtByte>(static_cast<int8_t>(val - 128)); }
template<> inline float LoadSample<DevFmtUShort>(DevFmtTypeTraits<DevFmtUShort>::Type val) noexcept
-{ return LoadSample<DevFmtShort>(static_cast<ALshort>(val - 32768)); }
+{ return LoadSample<DevFmtShort>(static_cast<int16_t>(val - 32768)); }
template<> inline float LoadSample<DevFmtUInt>(DevFmtTypeTraits<DevFmtUInt>::Type val) noexcept
-{ return LoadSample<DevFmtInt>(static_cast<ALint>(val - 2147483648u)); }
+{ return LoadSample<DevFmtInt>(static_cast<int32_t>(val - 2147483648u)); }
template<DevFmtType T>
@@ -76,22 +74,22 @@ void LoadSamples(float *dst, const void *src, const size_t srcstep, const DevFmt
template<DevFmtType T>
inline typename DevFmtTypeTraits<T>::Type StoreSample(float) noexcept;
-template<> inline ALfloat StoreSample<DevFmtFloat>(float val) noexcept
+template<> inline float StoreSample<DevFmtFloat>(float val) noexcept
{ return val; }
-template<> inline ALint StoreSample<DevFmtInt>(float val) noexcept
+template<> inline int32_t StoreSample<DevFmtInt>(float val) noexcept
{ return fastf2i(clampf(val*2147483648.0f, -2147483648.0f, 2147483520.0f)); }
-template<> inline ALshort StoreSample<DevFmtShort>(float val) noexcept
-{ return static_cast<ALshort>(fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f))); }
-template<> inline ALbyte StoreSample<DevFmtByte>(float val) noexcept
-{ return static_cast<ALbyte>(fastf2i(clampf(val*128.0f, -128.0f, 127.0f))); }
+template<> inline int16_t StoreSample<DevFmtShort>(float val) noexcept
+{ return static_cast<int16_t>(fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f))); }
+template<> inline int8_t StoreSample<DevFmtByte>(float val) noexcept
+{ return static_cast<int8_t>(fastf2i(clampf(val*128.0f, -128.0f, 127.0f))); }
/* Define unsigned output variations. */
-template<> inline ALuint StoreSample<DevFmtUInt>(float val) noexcept
-{ return static_cast<ALuint>(StoreSample<DevFmtInt>(val)) + 2147483648u; }
-template<> inline ALushort StoreSample<DevFmtUShort>(float val) noexcept
-{ return static_cast<ALushort>(StoreSample<DevFmtShort>(val) + 32768); }
-template<> inline ALubyte StoreSample<DevFmtUByte>(float val) noexcept
-{ return static_cast<ALubyte>(StoreSample<DevFmtByte>(val) + 128); }
+template<> inline uint32_t StoreSample<DevFmtUInt>(float val) noexcept
+{ return static_cast<uint32_t>(StoreSample<DevFmtInt>(val)) + 2147483648u; }
+template<> inline uint16_t StoreSample<DevFmtUShort>(float val) noexcept
+{ return static_cast<uint16_t>(StoreSample<DevFmtShort>(val) + 32768); }
+template<> inline uint8_t StoreSample<DevFmtUByte>(float val) noexcept
+{ return static_cast<uint8_t>(StoreSample<DevFmtByte>(val) + 128); }
template<DevFmtType T>
inline void StoreSampleArray(void *dst, const float *RESTRICT src, const size_t dststep,
@@ -135,7 +133,7 @@ void Mono2Stereo(float *RESTRICT dst, const void *src, const size_t frames) noex
}
template<DevFmtType T>
-void Multi2Mono(ALuint chanmask, const size_t step, const float scale, float *RESTRICT dst,
+void Multi2Mono(uint chanmask, const size_t step, const float scale, float *RESTRICT dst,
const void *src, const size_t frames) noexcept
{
using SampleType = typename DevFmtTypeTraits<T>::Type;
@@ -158,7 +156,7 @@ void Multi2Mono(ALuint chanmask, const size_t step, const float scale, float *RE
} // namespace
SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, size_t numchans,
- ALuint srcRate, ALuint dstRate, Resampler resampler)
+ uint srcRate, uint dstRate, Resampler resampler)
{
if(numchans < 1 || srcRate < 1 || dstRate < 1)
return nullptr;
@@ -174,7 +172,7 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType,
/* Have to set the mixer FPU mode since that's what the resampler code expects. */
FPUCtl mixer_mode{};
- auto step = static_cast<ALuint>(
+ auto step = static_cast<uint>(
mind(srcRate*double{MixerFracOne}/dstRate + 0.5, MAX_PITCH*MixerFracOne));
converter->mIncrement = maxu(step, 1);
if(converter->mIncrement == MixerFracOne)
@@ -186,15 +184,15 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType,
return converter;
}
-ALuint SampleConverter::availableOut(ALuint srcframes) const
+uint SampleConverter::availableOut(uint srcframes) const
{
int prepcount{mSrcPrepCount};
if(prepcount < 0)
{
/* Negative prepcount means we need to skip that many input samples. */
- if(static_cast<ALuint>(-prepcount) >= srcframes)
+ if(static_cast<uint>(-prepcount) >= srcframes)
return 0;
- srcframes -= static_cast<ALuint>(-prepcount);
+ srcframes -= static_cast<uint>(-prepcount);
prepcount = 0;
}
@@ -205,7 +203,7 @@ ALuint SampleConverter::availableOut(ALuint srcframes) const
}
if(prepcount < MAX_RESAMPLER_PADDING
- && static_cast<ALuint>(MAX_RESAMPLER_PADDING - prepcount) >= srcframes)
+ && static_cast<uint>(MAX_RESAMPLER_PADDING - prepcount) >= srcframes)
{
/* Not enough input samples to generate an output sample. */
return 0;
@@ -218,41 +216,41 @@ ALuint SampleConverter::availableOut(ALuint srcframes) const
DataSize64 -= mFracOffset;
/* If we have a full prep, we can generate at least one sample. */
- return static_cast<ALuint>(clampu64((DataSize64 + mIncrement-1)/mIncrement, 1,
+ return static_cast<uint>(clampu64((DataSize64 + mIncrement-1)/mIncrement, 1,
std::numeric_limits<int>::max()));
}
-ALuint SampleConverter::convert(const void **src, ALuint *srcframes, void *dst, ALuint dstframes)
+uint SampleConverter::convert(const void **src, uint *srcframes, void *dst, uint dstframes)
{
- const ALuint SrcFrameSize{static_cast<ALuint>(mChan.size()) * mSrcTypeSize};
- const ALuint DstFrameSize{static_cast<ALuint>(mChan.size()) * mDstTypeSize};
- const ALuint increment{mIncrement};
+ const uint SrcFrameSize{static_cast<uint>(mChan.size()) * mSrcTypeSize};
+ const uint DstFrameSize{static_cast<uint>(mChan.size()) * mDstTypeSize};
+ const uint increment{mIncrement};
auto SamplesIn = static_cast<const al::byte*>(*src);
- ALuint NumSrcSamples{*srcframes};
+ uint NumSrcSamples{*srcframes};
FPUCtl mixer_mode{};
- ALuint pos{0};
+ uint pos{0};
while(pos < dstframes && NumSrcSamples > 0)
{
int prepcount{mSrcPrepCount};
if(prepcount < 0)
{
/* Negative prepcount means we need to skip that many input samples. */
- if(static_cast<ALuint>(-prepcount) >= NumSrcSamples)
+ if(static_cast<uint>(-prepcount) >= NumSrcSamples)
{
mSrcPrepCount = static_cast<int>(NumSrcSamples) + prepcount;
NumSrcSamples = 0;
break;
}
- SamplesIn += SrcFrameSize*static_cast<ALuint>(-prepcount);
- NumSrcSamples -= static_cast<ALuint>(-prepcount);
+ SamplesIn += SrcFrameSize*static_cast<uint>(-prepcount);
+ NumSrcSamples -= static_cast<uint>(-prepcount);
mSrcPrepCount = 0;
continue;
}
- ALuint toread{minu(NumSrcSamples, BUFFERSIZE - MAX_RESAMPLER_PADDING)};
+ uint toread{minu(NumSrcSamples, BUFFERSIZE - MAX_RESAMPLER_PADDING)};
if(prepcount < MAX_RESAMPLER_PADDING
- && static_cast<ALuint>(MAX_RESAMPLER_PADDING - prepcount) >= toread)
+ && static_cast<uint>(MAX_RESAMPLER_PADDING - prepcount) >= toread)
{
/* Not enough input samples to generate an output sample. Store
* what we're given for later.
@@ -268,7 +266,7 @@ ALuint SampleConverter::convert(const void **src, ALuint *srcframes, void *dst,
float *RESTRICT SrcData{mSrcSamples};
float *RESTRICT DstData{mDstSamples};
- ALuint DataPosFrac{mFracOffset};
+ uint DataPosFrac{mFracOffset};
auto DataSize64 = static_cast<uint64_t>(prepcount);
DataSize64 += toread;
DataSize64 -= MAX_RESAMPLER_PADDING;
@@ -276,7 +274,7 @@ ALuint SampleConverter::convert(const void **src, ALuint *srcframes, void *dst,
DataSize64 -= DataPosFrac;
/* If we have a full prep, we can generate at least one sample. */
- auto DstSize = static_cast<ALuint>(
+ auto DstSize = static_cast<uint>(
clampu64((DataSize64 + increment-1)/increment, 1, BUFFERSIZE));
DstSize = minu(DstSize, dstframes-pos);
@@ -294,14 +292,14 @@ ALuint SampleConverter::convert(const void **src, ALuint *srcframes, void *dst,
/* Store as many prep samples for next time as possible, given the
* number of output samples being generated.
*/
- ALuint SrcDataEnd{(DstSize*increment + DataPosFrac)>>MixerFracBits};
- if(SrcDataEnd >= static_cast<ALuint>(prepcount)+toread)
+ uint SrcDataEnd{(DstSize*increment + DataPosFrac)>>MixerFracBits};
+ if(SrcDataEnd >= static_cast<uint>(prepcount)+toread)
std::fill(std::begin(mChan[chan].PrevSamples),
std::end(mChan[chan].PrevSamples), 0.0f);
else
{
const size_t len{minz(al::size(mChan[chan].PrevSamples),
- static_cast<ALuint>(prepcount)+toread-SrcDataEnd)};
+ static_cast<uint>(prepcount)+toread-SrcDataEnd)};
std::copy_n(SrcData+SrcDataEnd, len, mChan[chan].PrevSamples);
std::fill(std::begin(mChan[chan].PrevSamples)+len,
std::end(mChan[chan].PrevSamples), 0.0f);
@@ -337,7 +335,7 @@ ALuint SampleConverter::convert(const void **src, ALuint *srcframes, void *dst,
}
-void ChannelConverter::convert(const void *src, float *dst, ALuint frames) const
+void ChannelConverter::convert(const void *src, float *dst, uint frames) const
{
if(mDstChans == DevFmtMono)
{
diff --git a/alc/converter.h b/alc/converter.h
index a97d1ea5..392c95e5 100644
--- a/alc/converter.h
+++ b/alc/converter.h
@@ -13,17 +13,19 @@
#include "core/devformat.h"
#include "voice.h"
+using uint = unsigned int;
+
struct SampleConverter {
DevFmtType mSrcType{};
DevFmtType mDstType{};
- ALuint mSrcTypeSize{};
- ALuint mDstTypeSize{};
+ uint mSrcTypeSize{};
+ uint mDstTypeSize{};
int mSrcPrepCount{};
- ALuint mFracOffset{};
- ALuint mIncrement{};
+ uint mFracOffset{};
+ uint mIncrement{};
InterpState mState{};
ResamplerFunc mResample{};
@@ -37,26 +39,26 @@ struct SampleConverter {
SampleConverter(size_t numchans) : mChan{numchans} { }
- ALuint convert(const void **src, ALuint *srcframes, void *dst, ALuint dstframes);
- ALuint availableOut(ALuint srcframes) const;
+ uint convert(const void **src, uint *srcframes, void *dst, uint dstframes);
+ uint availableOut(uint srcframes) const;
DEF_FAM_NEWDEL(SampleConverter, mChan)
};
using SampleConverterPtr = std::unique_ptr<SampleConverter>;
SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, size_t numchans,
- ALuint srcRate, ALuint dstRate, Resampler resampler);
+ uint srcRate, uint dstRate, Resampler resampler);
struct ChannelConverter {
DevFmtType mSrcType{};
- ALuint mSrcStep{};
- ALuint mChanMask{};
+ uint mSrcStep{};
+ uint mChanMask{};
DevFmtChannels mDstChans{};
bool is_active() const noexcept { return mChanMask != 0; }
- void convert(const void *src, float *dst, ALuint frames) const;
+ void convert(const void *src, float *dst, uint frames) const;
};
#endif /* CONVERTER_H */