diff options
author | Chris Robinson <[email protected]> | 2020-12-05 02:44:19 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-12-05 02:44:19 -0800 |
commit | 2b919eac78cd6ebe07d6ca7cd01450e6f1aea75b (patch) | |
tree | 48fb8a5c4076ceaaff095cdbcee78e229179274a | |
parent | 16ec07275f68919cc0e4264f917e4fcebcdca039 (diff) |
Use an alias for the DevFmtType type
-rw-r--r-- | alc/alu.cpp | 8 | ||||
-rw-r--r-- | alc/converter.cpp | 34 | ||||
-rw-r--r-- | core/devformat.h | 3 |
3 files changed, 19 insertions, 26 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp index fe42b14b..1824a5a9 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -1888,18 +1888,16 @@ template<DevFmtType T> void Write(const al::span<const FloatBufferLine> InBuffer, void *OutBuffer, const size_t Offset, const size_t SamplesToDo, const size_t FrameStep) { - using SampleType = typename DevFmtTypeTraits<T>::Type; - ASSUME(FrameStep > 0); ASSUME(SamplesToDo > 0); - SampleType *outbase = static_cast<SampleType*>(OutBuffer) + Offset*FrameStep; + DevFmtType_t<T> *outbase = static_cast<DevFmtType_t<T>*>(OutBuffer) + Offset*FrameStep; for(const FloatBufferLine &inbuf : InBuffer) { - SampleType *out{outbase++}; + DevFmtType_t<T> *out{outbase++}; auto conv_sample = [FrameStep,&out](const float s) noexcept -> void { - *out = SampleConv<SampleType>(s); + *out = SampleConv<DevFmtType_t<T>>(s); out += FrameStep; }; std::for_each(inbuf.begin(), inbuf.begin()+SamplesToDo, conv_sample); diff --git a/alc/converter.cpp b/alc/converter.cpp index de6f4587..9a3fa2f2 100644 --- a/alc/converter.cpp +++ b/alc/converter.cpp @@ -30,22 +30,22 @@ static_assert((INT_MAX>>MixerFracBits)/MaxPitch > BufferLineSize, * chokes on that given the inline specializations. */ template<DevFmtType T> -inline float LoadSample(typename DevFmtTypeTraits<T>::Type val) noexcept; +inline float LoadSample(DevFmtType_t<T> val) noexcept; -template<> inline float LoadSample<DevFmtByte>(DevFmtTypeTraits<DevFmtByte>::Type val) noexcept +template<> inline float LoadSample<DevFmtByte>(DevFmtType_t<DevFmtByte> val) noexcept { return val * (1.0f/128.0f); } -template<> inline float LoadSample<DevFmtShort>(DevFmtTypeTraits<DevFmtShort>::Type val) noexcept +template<> inline float LoadSample<DevFmtShort>(DevFmtType_t<DevFmtShort> val) noexcept { return val * (1.0f/32768.0f); } -template<> inline float LoadSample<DevFmtInt>(DevFmtTypeTraits<DevFmtInt>::Type val) noexcept +template<> inline float LoadSample<DevFmtInt>(DevFmtType_t<DevFmtInt> val) noexcept { return static_cast<float>(val) * (1.0f/2147483648.0f); } -template<> inline float LoadSample<DevFmtFloat>(DevFmtTypeTraits<DevFmtFloat>::Type val) noexcept +template<> inline float LoadSample<DevFmtFloat>(DevFmtType_t<DevFmtFloat> val) noexcept { return val; } -template<> inline float LoadSample<DevFmtUByte>(DevFmtTypeTraits<DevFmtUByte>::Type val) noexcept +template<> inline float LoadSample<DevFmtUByte>(DevFmtType_t<DevFmtUByte> val) noexcept { return LoadSample<DevFmtByte>(static_cast<int8_t>(val - 128)); } -template<> inline float LoadSample<DevFmtUShort>(DevFmtTypeTraits<DevFmtUShort>::Type val) noexcept +template<> inline float LoadSample<DevFmtUShort>(DevFmtType_t<DevFmtUShort> val) noexcept { return LoadSample<DevFmtShort>(static_cast<int16_t>(val - 32768)); } -template<> inline float LoadSample<DevFmtUInt>(DevFmtTypeTraits<DevFmtUInt>::Type val) noexcept +template<> inline float LoadSample<DevFmtUInt>(DevFmtType_t<DevFmtUInt> val) noexcept { return LoadSample<DevFmtInt>(static_cast<int32_t>(val - 2147483648u)); } @@ -53,9 +53,7 @@ template<DevFmtType T> inline void LoadSampleArray(float *RESTRICT dst, const void *src, const size_t srcstep, const size_t samples) noexcept { - using SampleType = typename DevFmtTypeTraits<T>::Type; - - const SampleType *ssrc = static_cast<const SampleType*>(src); + const DevFmtType_t<T> *ssrc = static_cast<const DevFmtType_t<T>*>(src); for(size_t i{0u};i < samples;i++) dst[i] = LoadSample<T>(ssrc[i*srcstep]); } @@ -80,7 +78,7 @@ void LoadSamples(float *dst, const void *src, const size_t srcstep, const DevFmt template<DevFmtType T> -inline typename DevFmtTypeTraits<T>::Type StoreSample(float) noexcept; +inline DevFmtType_t<T> StoreSample(float) noexcept; template<> inline float StoreSample<DevFmtFloat>(float val) noexcept { return val; } @@ -103,9 +101,7 @@ template<DevFmtType T> inline void StoreSampleArray(void *dst, const float *RESTRICT src, const size_t dststep, const size_t samples) noexcept { - using SampleType = typename DevFmtTypeTraits<T>::Type; - - SampleType *sdst = static_cast<SampleType*>(dst); + DevFmtType_t<T> *sdst = static_cast<DevFmtType_t<T>*>(dst); for(size_t i{0u};i < samples;i++) sdst[i*dststep] = StoreSample<T>(src[i]); } @@ -133,9 +129,7 @@ void StoreSamples(void *dst, const float *src, const size_t dststep, const DevFm template<DevFmtType T> void Mono2Stereo(float *RESTRICT dst, const void *src, const size_t frames) noexcept { - using SampleType = typename DevFmtTypeTraits<T>::Type; - - const SampleType *ssrc = static_cast<const SampleType*>(src); + const DevFmtType_t<T> *ssrc = static_cast<const DevFmtType_t<T>*>(src); for(size_t i{0u};i < frames;i++) dst[i*2 + 1] = dst[i*2 + 0] = LoadSample<T>(ssrc[i]) * 0.707106781187f; } @@ -144,9 +138,7 @@ template<DevFmtType T> 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; - - const SampleType *ssrc = static_cast<const SampleType*>(src); + const DevFmtType_t<T> *ssrc = static_cast<const DevFmtType_t<T>*>(src); std::fill_n(dst, frames, 0.0f); for(size_t c{0};chanmask;++c) { diff --git a/core/devformat.h b/core/devformat.h index bcd42539..9577c4b7 100644 --- a/core/devformat.h +++ b/core/devformat.h @@ -76,6 +76,9 @@ struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; }; template<> struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; }; +template<DevFmtType T> +using DevFmtType_t = typename DevFmtTypeTraits<T>::Type; + uint BytesFromDevFmt(DevFmtType type) noexcept; uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept; |