diff options
author | Chris Robinson <[email protected]> | 2020-04-08 10:15:43 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-04-08 10:15:43 -0700 |
commit | d67cba99bd97d42e7e52c6dfd7a08c288b1539c0 (patch) | |
tree | 014425832a37173da8d9c3b2377526ce41d58d36 /alc/converter.cpp | |
parent | 8a5153ce0dee072c283b04ff5a61faa764f81743 (diff) |
Clean up some more unnecessary uses of AL types
Diffstat (limited to 'alc/converter.cpp')
-rw-r--r-- | alc/converter.cpp | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/alc/converter.cpp b/alc/converter.cpp index f20a348e..47a3bfce 100644 --- a/alc/converter.cpp +++ b/alc/converter.cpp @@ -24,27 +24,27 @@ namespace { * chokes on that given the inline specializations. */ template<DevFmtType T> -inline ALfloat LoadSample(typename DevFmtTypeTraits<T>::Type val) noexcept; +inline float LoadSample(typename DevFmtTypeTraits<T>::Type val) noexcept; -template<> inline ALfloat LoadSample<DevFmtByte>(DevFmtTypeTraits<DevFmtByte>::Type val) noexcept +template<> inline float LoadSample<DevFmtByte>(DevFmtTypeTraits<DevFmtByte>::Type val) noexcept { return val * (1.0f/128.0f); } -template<> inline ALfloat LoadSample<DevFmtShort>(DevFmtTypeTraits<DevFmtShort>::Type val) noexcept +template<> inline float LoadSample<DevFmtShort>(DevFmtTypeTraits<DevFmtShort>::Type val) noexcept { return val * (1.0f/32768.0f); } -template<> inline ALfloat LoadSample<DevFmtInt>(DevFmtTypeTraits<DevFmtInt>::Type val) noexcept +template<> inline float LoadSample<DevFmtInt>(DevFmtTypeTraits<DevFmtInt>::Type val) noexcept { return static_cast<float>(val) * (1.0f/2147483648.0f); } -template<> inline ALfloat LoadSample<DevFmtFloat>(DevFmtTypeTraits<DevFmtFloat>::Type val) noexcept +template<> inline float LoadSample<DevFmtFloat>(DevFmtTypeTraits<DevFmtFloat>::Type val) noexcept { return val; } -template<> inline ALfloat LoadSample<DevFmtUByte>(DevFmtTypeTraits<DevFmtUByte>::Type val) noexcept +template<> inline float LoadSample<DevFmtUByte>(DevFmtTypeTraits<DevFmtUByte>::Type val) noexcept { return LoadSample<DevFmtByte>(static_cast<ALbyte>(val - 128)); } -template<> inline ALfloat LoadSample<DevFmtUShort>(DevFmtTypeTraits<DevFmtUShort>::Type val) noexcept +template<> inline float LoadSample<DevFmtUShort>(DevFmtTypeTraits<DevFmtUShort>::Type val) noexcept { return LoadSample<DevFmtShort>(static_cast<ALshort>(val - 32768)); } -template<> inline ALfloat LoadSample<DevFmtUInt>(DevFmtTypeTraits<DevFmtUInt>::Type val) noexcept +template<> inline float LoadSample<DevFmtUInt>(DevFmtTypeTraits<DevFmtUInt>::Type val) noexcept { return LoadSample<DevFmtInt>(static_cast<ALint>(val - 2147483648u)); } template<DevFmtType T> -inline void LoadSampleArray(ALfloat *RESTRICT dst, const void *src, const size_t srcstep, +inline void LoadSampleArray(float *RESTRICT dst, const void *src, const size_t srcstep, const size_t samples) noexcept { using SampleType = typename DevFmtTypeTraits<T>::Type; @@ -54,7 +54,7 @@ inline void LoadSampleArray(ALfloat *RESTRICT dst, const void *src, const size_t dst[i] = LoadSample<T>(ssrc[i*srcstep]); } -void LoadSamples(ALfloat *dst, const ALvoid *src, const size_t srcstep, const DevFmtType srctype, +void LoadSamples(float *dst, const void *src, const size_t srcstep, const DevFmtType srctype, const size_t samples) noexcept { #define HANDLE_FMT(T) \ @@ -74,27 +74,27 @@ void LoadSamples(ALfloat *dst, const ALvoid *src, const size_t srcstep, const De template<DevFmtType T> -inline typename DevFmtTypeTraits<T>::Type StoreSample(ALfloat) noexcept; +inline typename DevFmtTypeTraits<T>::Type StoreSample(float) noexcept; -template<> inline ALfloat StoreSample<DevFmtFloat>(ALfloat val) noexcept +template<> inline ALfloat StoreSample<DevFmtFloat>(float val) noexcept { return val; } -template<> inline ALint StoreSample<DevFmtInt>(ALfloat val) noexcept +template<> inline ALint StoreSample<DevFmtInt>(float val) noexcept { return fastf2i(clampf(val*2147483648.0f, -2147483648.0f, 2147483520.0f)); } -template<> inline ALshort StoreSample<DevFmtShort>(ALfloat val) noexcept +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>(ALfloat val) noexcept +template<> inline ALbyte StoreSample<DevFmtByte>(float val) noexcept { return static_cast<ALbyte>(fastf2i(clampf(val*128.0f, -128.0f, 127.0f))); } /* Define unsigned output variations. */ -template<> inline ALuint StoreSample<DevFmtUInt>(ALfloat val) noexcept +template<> inline ALuint StoreSample<DevFmtUInt>(float val) noexcept { return static_cast<ALuint>(StoreSample<DevFmtInt>(val)) + 2147483648u; } -template<> inline ALushort StoreSample<DevFmtUShort>(ALfloat val) noexcept +template<> inline ALushort StoreSample<DevFmtUShort>(float val) noexcept { return static_cast<ALushort>(StoreSample<DevFmtShort>(val) + 32768); } -template<> inline ALubyte StoreSample<DevFmtUByte>(ALfloat val) noexcept +template<> inline ALubyte StoreSample<DevFmtUByte>(float val) noexcept { return static_cast<ALubyte>(StoreSample<DevFmtByte>(val) + 128); } template<DevFmtType T> -inline void StoreSampleArray(void *dst, const ALfloat *RESTRICT src, const size_t dststep, +inline void StoreSampleArray(void *dst, const float *RESTRICT src, const size_t dststep, const size_t samples) noexcept { using SampleType = typename DevFmtTypeTraits<T>::Type; @@ -105,7 +105,7 @@ inline void StoreSampleArray(void *dst, const ALfloat *RESTRICT src, const size_ } -void StoreSamples(ALvoid *dst, const ALfloat *src, const size_t dststep, const DevFmtType dsttype, +void StoreSamples(void *dst, const float *src, const size_t dststep, const DevFmtType dsttype, const size_t samples) noexcept { #define HANDLE_FMT(T) \ @@ -125,7 +125,7 @@ void StoreSamples(ALvoid *dst, const ALfloat *src, const size_t dststep, const D template<DevFmtType T> -void Mono2Stereo(ALfloat *RESTRICT dst, const void *src, const size_t frames) noexcept +void Mono2Stereo(float *RESTRICT dst, const void *src, const size_t frames) noexcept { using SampleType = typename DevFmtTypeTraits<T>::Type; @@ -135,7 +135,7 @@ void Mono2Stereo(ALfloat *RESTRICT dst, const void *src, const size_t frames) no } template<DevFmtType T> -void Stereo2Mono(ALfloat *RESTRICT dst, const void *src, const size_t frames) noexcept +void Stereo2Mono(float *RESTRICT dst, const void *src, const size_t frames) noexcept { using SampleType = typename DevFmtTypeTraits<T>::Type; @@ -178,7 +178,7 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, ALuint SampleConverter::availableOut(ALuint srcframes) const { - ALint prepcount{mSrcPrepCount}; + int prepcount{mSrcPrepCount}; if(prepcount < 0) { /* Negative prepcount means we need to skip that many input samples. */ @@ -211,7 +211,7 @@ ALuint SampleConverter::availableOut(ALuint srcframes) const return static_cast<ALuint>(clampu64((DataSize64 + mIncrement-1)/mIncrement, 1, BUFFERSIZE)); } -ALuint SampleConverter::convert(const ALvoid **src, ALuint *srcframes, ALvoid *dst, ALuint dstframes) +ALuint SampleConverter::convert(const void **src, ALuint *srcframes, void *dst, ALuint dstframes) { const ALuint SrcFrameSize{static_cast<ALuint>(mChan.size()) * mSrcTypeSize}; const ALuint DstFrameSize{static_cast<ALuint>(mChan.size()) * mDstTypeSize}; @@ -223,13 +223,13 @@ ALuint SampleConverter::convert(const ALvoid **src, ALuint *srcframes, ALvoid *d ALuint pos{0}; while(pos < dstframes && NumSrcSamples > 0) { - ALint prepcount{mSrcPrepCount}; + int prepcount{mSrcPrepCount}; if(prepcount < 0) { /* Negative prepcount means we need to skip that many input samples. */ if(static_cast<ALuint>(-prepcount) >= NumSrcSamples) { - mSrcPrepCount = static_cast<ALint>(NumSrcSamples) + prepcount; + mSrcPrepCount = static_cast<int>(NumSrcSamples) + prepcount; NumSrcSamples = 0; break; } @@ -250,13 +250,13 @@ ALuint SampleConverter::convert(const ALvoid **src, ALuint *srcframes, ALvoid *d LoadSamples(&mChan[chan].PrevSamples[prepcount], SamplesIn + mSrcTypeSize*chan, mChan.size(), mSrcType, toread); - mSrcPrepCount = prepcount + static_cast<ALint>(toread); + mSrcPrepCount = prepcount + static_cast<int>(toread); NumSrcSamples = 0; break; } - ALfloat *RESTRICT SrcData{mSrcSamples}; - ALfloat *RESTRICT DstData{mDstSamples}; + float *RESTRICT SrcData{mSrcSamples}; + float *RESTRICT DstData{mDstSamples}; ALuint DataPosFrac{mFracOffset}; auto DataSize64 = static_cast<uint64_t>(prepcount); DataSize64 += toread; @@ -297,7 +297,7 @@ ALuint SampleConverter::convert(const ALvoid **src, ALuint *srcframes, ALvoid *d } /* Now resample, and store the result in the output buffer. */ - const ALfloat *ResampledData{mResample(&mState, SrcData+(MAX_RESAMPLER_PADDING>>1), + const float *ResampledData{mResample(&mState, SrcData+(MAX_RESAMPLER_PADDING>>1), DataPosFrac, increment, {DstData, DstSize})}; StoreSamples(DstSamples, ResampledData, mChan.size(), mDstType, DstSize); @@ -307,7 +307,7 @@ ALuint SampleConverter::convert(const ALvoid **src, ALuint *srcframes, ALvoid *d * fractional offset. */ DataPosFrac += increment*DstSize; - mSrcPrepCount = mini(prepcount + static_cast<ALint>(toread - (DataPosFrac>>FRACTIONBITS)), + mSrcPrepCount = mini(prepcount + static_cast<int>(toread - (DataPosFrac>>FRACTIONBITS)), MAX_RESAMPLER_PADDING); mFracOffset = DataPosFrac & FRACTIONMASK; @@ -326,7 +326,7 @@ ALuint SampleConverter::convert(const ALvoid **src, ALuint *srcframes, ALvoid *d } -void ChannelConverter::convert(const ALvoid *src, ALfloat *dst, ALuint frames) const +void ChannelConverter::convert(const void *src, float *dst, ALuint frames) const { if(mSrcChans == DevFmtStereo && mDstChans == DevFmtMono) { |