diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/buffer_storage.h | 4 | ||||
-rw-r--r-- | core/converter.cpp | 10 | ||||
-rw-r--r-- | core/effects/base.h | 1 | ||||
-rw-r--r-- | core/fmt_traits.h | 20 | ||||
-rw-r--r-- | core/hrtf.cpp | 6 | ||||
-rw-r--r-- | core/voice.cpp | 35 | ||||
-rw-r--r-- | core/voice.h | 5 |
7 files changed, 38 insertions, 43 deletions
diff --git a/core/buffer_storage.h b/core/buffer_storage.h index 282d5b53..d8ab0b67 100644 --- a/core/buffer_storage.h +++ b/core/buffer_storage.h @@ -2,8 +2,8 @@ #define CORE_BUFFER_STORAGE_H #include <atomic> +#include <cstddef> -#include "albyte.h" #include "alnumeric.h" #include "alspan.h" #include "ambidefs.h" @@ -85,7 +85,7 @@ struct BufferStorage { CallbackType mCallback{nullptr}; void *mUserData{nullptr}; - al::span<al::byte> mData; + al::span<std::byte> mData; uint mSampleRate{0u}; FmtChannels mChannels{FmtMono}; diff --git a/core/converter.cpp b/core/converter.cpp index a5141448..b3994d3f 100644 --- a/core/converter.cpp +++ b/core/converter.cpp @@ -6,12 +6,12 @@ #include <algorithm> #include <cassert> #include <cmath> +#include <cstddef> #include <cstdint> #include <iterator> #include <limits.h> #include "albit.h" -#include "albyte.h" #include "alnumeric.h" #include "fpu_ctrl.h" @@ -219,7 +219,7 @@ uint SampleConverter::convert(const void **src, uint *srcframes, void *dst, uint 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); + auto SamplesIn = static_cast<const std::byte*>(*src); uint NumSrcSamples{*srcframes}; FPUCtl mixer_mode{}; @@ -265,8 +265,8 @@ uint SampleConverter::convert(const void **src, uint *srcframes, void *dst, uint for(size_t chan{0u};chan < mChan.size();chan++) { - const al::byte *SrcSamples{SamplesIn + mSrcTypeSize*chan}; - al::byte *DstSamples = static_cast<al::byte*>(dst) + mDstTypeSize*chan; + const std::byte *SrcSamples{SamplesIn + mSrcTypeSize*chan}; + std::byte *DstSamples = static_cast<std::byte*>(dst) + mDstTypeSize*chan; /* Load the previous samples into the source data first, then the * new samples from the input buffer. @@ -299,7 +299,7 @@ uint SampleConverter::convert(const void **src, uint *srcframes, void *dst, uint SamplesIn += SrcFrameSize*srcread; NumSrcSamples -= srcread; - dst = static_cast<al::byte*>(dst) + DstFrameSize*DstSize; + dst = static_cast<std::byte*>(dst) + DstFrameSize*DstSize; pos += DstSize; } diff --git a/core/effects/base.h b/core/effects/base.h index 4ee19f37..b02d33b7 100644 --- a/core/effects/base.h +++ b/core/effects/base.h @@ -3,7 +3,6 @@ #include <stddef.h> -#include "albyte.h" #include "almalloc.h" #include "alspan.h" #include "atomic.h" diff --git a/core/fmt_traits.h b/core/fmt_traits.h index f797f836..1879c81b 100644 --- a/core/fmt_traits.h +++ b/core/fmt_traits.h @@ -1,10 +1,9 @@ #ifndef CORE_FMT_TRAITS_H #define CORE_FMT_TRAITS_H -#include <stddef.h> +#include <cstddef> #include <stdint.h> -#include "albyte.h" #include "buffer_storage.h" @@ -22,36 +21,35 @@ struct FmtTypeTraits<FmtUByte> { using Type = uint8_t; template<typename OutT> - static constexpr inline OutT to(const Type val) noexcept - { return val*OutT{1.0/128.0} - OutT{1.0}; } + static constexpr OutT to(const Type val) noexcept { return val*OutT{1.0/128.0} - OutT{1.0}; } }; template<> struct FmtTypeTraits<FmtShort> { using Type = int16_t; template<typename OutT> - static constexpr inline OutT to(const Type val) noexcept { return val*OutT{1.0/32768.0}; } + static constexpr OutT to(const Type val) noexcept { return val*OutT{1.0/32768.0}; } }; template<> struct FmtTypeTraits<FmtFloat> { using Type = float; template<typename OutT> - static constexpr inline OutT to(const Type val) noexcept { return val; } + static constexpr OutT to(const Type val) noexcept { return val; } }; template<> struct FmtTypeTraits<FmtDouble> { using Type = double; template<typename OutT> - static constexpr inline OutT to(const Type val) noexcept { return static_cast<OutT>(val); } + static constexpr OutT to(const Type val) noexcept { return static_cast<OutT>(val); } }; template<> struct FmtTypeTraits<FmtMulaw> { using Type = uint8_t; template<typename OutT> - static constexpr inline OutT to(const Type val) noexcept + static constexpr OutT to(const Type val) noexcept { return muLawDecompressionTable[val] * OutT{1.0/32768.0}; } }; template<> @@ -59,14 +57,14 @@ struct FmtTypeTraits<FmtAlaw> { using Type = uint8_t; template<typename OutT> - static constexpr inline OutT to(const Type val) noexcept + static constexpr OutT to(const Type val) noexcept { return aLawDecompressionTable[val] * OutT{1.0/32768.0}; } }; template<FmtType SrcType, typename DstT> -inline void LoadSampleArray(DstT *RESTRICT dst, const al::byte *src, const size_t srcstep, - const size_t samples) noexcept +inline void LoadSampleArray(DstT *RESTRICT dst, const std::byte *src, const std::size_t srcstep, + const std::size_t samples) noexcept { using TypeTraits = FmtTypeTraits<SrcType>; using SampleType = typename TypeTraits::Type; diff --git a/core/hrtf.cpp b/core/hrtf.cpp index c54d96d1..1d9bc368 100644 --- a/core/hrtf.cpp +++ b/core/hrtf.cpp @@ -8,6 +8,7 @@ #include <cassert> #include <cctype> #include <cmath> +#include <cstddef> #include <cstdint> #include <cstdio> #include <cstring> @@ -21,7 +22,6 @@ #include <utility> #include "albit.h" -#include "albyte.h" #include "alfstream.h" #include "almalloc.h" #include "alnumbers.h" @@ -492,10 +492,10 @@ T> readle(std::istream &data) static_assert(num_bits <= sizeof(T)*8, "num_bits is too large for the type"); T ret{}; - al::byte b[sizeof(T)]{}; + std::byte b[sizeof(T)]{}; if(!data.read(reinterpret_cast<char*>(b), num_bits/8)) return static_cast<T>(EOF); - std::reverse_copy(std::begin(b), std::end(b), reinterpret_cast<al::byte*>(&ret)); + std::reverse_copy(std::begin(b), std::end(b), reinterpret_cast<std::byte*>(&ret)); return fixsign<num_bits>(ret); } diff --git a/core/voice.cpp b/core/voice.cpp index 090b10a3..cbf84c2a 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -17,7 +17,6 @@ #include <utility> #include <vector> -#include "albyte.h" #include "alnumeric.h" #include "alspan.h" #include "alstring.h" @@ -264,7 +263,7 @@ const float *DoFilters(BiquadFilter &lpfilter, BiquadFilter &hpfilter, float *ds template<FmtType Type> -inline void LoadSamples(float *RESTRICT dstSamples, const al::byte *src, const size_t srcChan, +inline void LoadSamples(float *RESTRICT dstSamples, const std::byte *src, const size_t srcChan, const size_t srcOffset, const size_t srcStep, const size_t /*samplesPerBlock*/, const size_t samplesToLoad) noexcept { @@ -275,7 +274,7 @@ inline void LoadSamples(float *RESTRICT dstSamples, const al::byte *src, const s } template<> -inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src, +inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const std::byte *src, const size_t srcChan, const size_t srcOffset, const size_t srcStep, const size_t samplesPerBlock, const size_t samplesToLoad) noexcept { @@ -293,8 +292,8 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src /* Each IMA4 block starts with a signed 16-bit sample, and a signed * 16-bit table index. The table index needs to be clamped. */ - int sample{src[srcChan*4] | (src[srcChan*4 + 1] << 8)}; - int index{src[srcChan*4 + 2] | (src[srcChan*4 + 3] << 8)}; + int sample{int(src[srcChan*4]) | (int(src[srcChan*4 + 1]) << 8)}; + int index{int(src[srcChan*4 + 2]) | (int(src[srcChan*4 + 3]) << 8)}; sample = (sample^0x8000) - 32768; index = clampi((index^0x8000) - 32768, 0, MaxStepIndex); @@ -326,7 +325,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src * always be less than the block size). They need to be decoded despite * being ignored for proper state on the remaining samples. */ - const al::byte *nibbleData{src + (srcStep+srcChan)*4}; + const std::byte *nibbleData{src + (srcStep+srcChan)*4}; size_t nibbleOffset{0}; const size_t startOffset{skip + 1}; for(;skip;--skip) @@ -336,7 +335,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src const size_t byteOffset{wordOffset*srcStep + ((nibbleOffset>>1)&3u)}; ++nibbleOffset; - std::ignore = decode_sample((nibbleData[byteOffset]>>byteShift) & 15u); + std::ignore = decode_sample(uint(nibbleData[byteOffset]>>byteShift) & 15u); } /* Second, decode the rest of the block and write to the output, until @@ -350,7 +349,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src const size_t byteOffset{wordOffset*srcStep + ((nibbleOffset>>1)&3u)}; ++nibbleOffset; - const int result{decode_sample((nibbleData[byteOffset]>>byteShift) & 15u)}; + const int result{decode_sample(uint(nibbleData[byteOffset]>>byteShift) & 15u)}; dstSamples[wrote++] = static_cast<float>(result) / 32768.0f; } if(wrote == samplesToLoad) @@ -361,7 +360,7 @@ inline void LoadSamples<FmtIMA4>(float *RESTRICT dstSamples, const al::byte *src } template<> -inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte *src, +inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const std::byte *src, const size_t srcChan, const size_t srcOffset, const size_t srcStep, const size_t samplesPerBlock, const size_t samplesToLoad) noexcept { @@ -378,16 +377,16 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte * * nibble sample value. This is followed by the two initial 16-bit * sample history values. */ - const al::byte *input{src}; - const uint8_t blockpred{std::min(input[srcChan], uint8_t{6})}; + const std::byte *input{src}; + const uint8_t blockpred{std::min(uint8_t(input[srcChan]), uint8_t{6})}; input += srcStep; - int delta{input[2*srcChan + 0] | (input[2*srcChan + 1] << 8)}; + int delta{int(input[2*srcChan + 0]) | (int(input[2*srcChan + 1]) << 8)}; input += srcStep*2; int sampleHistory[2]{}; - sampleHistory[0] = input[2*srcChan + 0] | (input[2*srcChan + 1]<<8); + sampleHistory[0] = int(input[2*srcChan + 0]) | (int(input[2*srcChan + 1])<<8); input += srcStep*2; - sampleHistory[1] = input[2*srcChan + 0] | (input[2*srcChan + 1]<<8); + sampleHistory[1] = int(input[2*srcChan + 0]) | (int(input[2*srcChan + 1])<<8); input += srcStep*2; const auto coeffs = al::as_span(MSADPCMAdaptionCoeff[blockpred]); @@ -440,7 +439,7 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte * const size_t byteShift{((nibbleOffset&1)^1) * 4}; nibbleOffset += srcStep; - std::ignore = decode_sample((input[byteOffset]>>byteShift) & 15); + std::ignore = decode_sample(int(input[byteOffset]>>byteShift) & 15); } /* Now decode the rest of the block, until the end of the block or the @@ -453,7 +452,7 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte * const size_t byteShift{((nibbleOffset&1)^1) * 4}; nibbleOffset += srcStep; - const int sample{decode_sample((input[byteOffset]>>byteShift) & 15)}; + const int sample{decode_sample(int(input[byteOffset]>>byteShift) & 15)}; dstSamples[wrote++] = static_cast<float>(sample) / 32768.0f; } if(wrote == samplesToLoad) @@ -463,7 +462,7 @@ inline void LoadSamples<FmtMSADPCM>(float *RESTRICT dstSamples, const al::byte * } while(true); } -void LoadSamples(float *dstSamples, const al::byte *src, const size_t srcChan, +void LoadSamples(float *dstSamples, const std::byte *src, const size_t srcChan, const size_t srcOffset, const FmtType srcType, const size_t srcStep, const size_t samplesPerBlock, const size_t samplesToLoad) noexcept { @@ -1102,7 +1101,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi { const size_t byteOffset{blocksDone*mBytesPerBlock}; const size_t byteEnd{mNumCallbackBlocks*mBytesPerBlock}; - al::byte *data{BufferListItem->mSamples}; + std::byte *data{BufferListItem->mSamples}; std::copy(data+byteOffset, data+byteEnd, data); mNumCallbackBlocks -= blocksDone; mCallbackBlockBase += blocksDone; diff --git a/core/voice.h b/core/voice.h index 9d74ff6b..a599eda8 100644 --- a/core/voice.h +++ b/core/voice.h @@ -5,12 +5,11 @@ #include <atomic> #include <bitset> #include <chrono> +#include <cstddef> #include <memory> #include <optional> -#include <stddef.h> #include <string> -#include "albyte.h" #include "almalloc.h" #include "alspan.h" #include "bufferline.h" @@ -100,7 +99,7 @@ struct VoiceBufferItem { uint mLoopStart{0u}; uint mLoopEnd{0u}; - al::byte *mSamples{nullptr}; + std::byte *mSamples{nullptr}; }; |