From d67cba99bd97d42e7e52c6dfd7a08c288b1539c0 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 8 Apr 2020 10:15:43 -0700 Subject: Clean up some more unnecessary uses of AL types --- alc/converter.cpp | 64 +++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'alc/converter.cpp') 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 -inline ALfloat LoadSample(typename DevFmtTypeTraits::Type val) noexcept; +inline float LoadSample(typename DevFmtTypeTraits::Type val) noexcept; -template<> inline ALfloat LoadSample(DevFmtTypeTraits::Type val) noexcept +template<> inline float LoadSample(DevFmtTypeTraits::Type val) noexcept { return val * (1.0f/128.0f); } -template<> inline ALfloat LoadSample(DevFmtTypeTraits::Type val) noexcept +template<> inline float LoadSample(DevFmtTypeTraits::Type val) noexcept { return val * (1.0f/32768.0f); } -template<> inline ALfloat LoadSample(DevFmtTypeTraits::Type val) noexcept +template<> inline float LoadSample(DevFmtTypeTraits::Type val) noexcept { return static_cast(val) * (1.0f/2147483648.0f); } -template<> inline ALfloat LoadSample(DevFmtTypeTraits::Type val) noexcept +template<> inline float LoadSample(DevFmtTypeTraits::Type val) noexcept { return val; } -template<> inline ALfloat LoadSample(DevFmtTypeTraits::Type val) noexcept +template<> inline float LoadSample(DevFmtTypeTraits::Type val) noexcept { return LoadSample(static_cast(val - 128)); } -template<> inline ALfloat LoadSample(DevFmtTypeTraits::Type val) noexcept +template<> inline float LoadSample(DevFmtTypeTraits::Type val) noexcept { return LoadSample(static_cast(val - 32768)); } -template<> inline ALfloat LoadSample(DevFmtTypeTraits::Type val) noexcept +template<> inline float LoadSample(DevFmtTypeTraits::Type val) noexcept { return LoadSample(static_cast(val - 2147483648u)); } template -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::Type; @@ -54,7 +54,7 @@ inline void LoadSampleArray(ALfloat *RESTRICT dst, const void *src, const size_t dst[i] = LoadSample(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 -inline typename DevFmtTypeTraits::Type StoreSample(ALfloat) noexcept; +inline typename DevFmtTypeTraits::Type StoreSample(float) noexcept; -template<> inline ALfloat StoreSample(ALfloat val) noexcept +template<> inline ALfloat StoreSample(float val) noexcept { return val; } -template<> inline ALint StoreSample(ALfloat val) noexcept +template<> inline ALint StoreSample(float val) noexcept { return fastf2i(clampf(val*2147483648.0f, -2147483648.0f, 2147483520.0f)); } -template<> inline ALshort StoreSample(ALfloat val) noexcept +template<> inline ALshort StoreSample(float val) noexcept { return static_cast(fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f))); } -template<> inline ALbyte StoreSample(ALfloat val) noexcept +template<> inline ALbyte StoreSample(float val) noexcept { return static_cast(fastf2i(clampf(val*128.0f, -128.0f, 127.0f))); } /* Define unsigned output variations. */ -template<> inline ALuint StoreSample(ALfloat val) noexcept +template<> inline ALuint StoreSample(float val) noexcept { return static_cast(StoreSample(val)) + 2147483648u; } -template<> inline ALushort StoreSample(ALfloat val) noexcept +template<> inline ALushort StoreSample(float val) noexcept { return static_cast(StoreSample(val) + 32768); } -template<> inline ALubyte StoreSample(ALfloat val) noexcept +template<> inline ALubyte StoreSample(float val) noexcept { return static_cast(StoreSample(val) + 128); } template -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::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 -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::Type; @@ -135,7 +135,7 @@ void Mono2Stereo(ALfloat *RESTRICT dst, const void *src, const size_t frames) no } template -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::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(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(mChan.size()) * mSrcTypeSize}; const ALuint DstFrameSize{static_cast(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(-prepcount) >= NumSrcSamples) { - mSrcPrepCount = static_cast(NumSrcSamples) + prepcount; + mSrcPrepCount = static_cast(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(toread); + mSrcPrepCount = prepcount + static_cast(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(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(toread - (DataPosFrac>>FRACTIONBITS)), + mSrcPrepCount = mini(prepcount + static_cast(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) { -- cgit v1.2.3