aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-10-13 09:37:07 -0700
committerChris Robinson <[email protected]>2019-10-13 09:37:07 -0700
commit33fd1f9efd46c056cd4348e76cd9048b37721c8b (patch)
treec8c3ca61c99a958c75393bf960c895683f0dbbab /alc
parente70f98c95afc61802b26795dbe8aeb20514a211b (diff)
Use better types for some specific sizes
Diffstat (limited to 'alc')
-rw-r--r--alc/alu.cpp30
-rw-r--r--alc/devformat.h17
2 files changed, 24 insertions, 23 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp
index 8c2ee164..5cd8c918 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -1654,11 +1654,11 @@ void ApplyDither(const al::span<FloatBufferLine> Samples, ALuint *dither_seed,
* chokes on that given the inline specializations.
*/
template<typename T>
-inline T SampleConv(ALfloat) noexcept;
+inline T SampleConv(float) noexcept;
-template<> inline ALfloat SampleConv(ALfloat val) noexcept
+template<> inline float SampleConv(float val) noexcept
{ return val; }
-template<> inline ALint SampleConv(ALfloat val) noexcept
+template<> inline int32_t SampleConv(float val) noexcept
{
/* Floats have a 23-bit mantissa, plus an implied 1 bit and a sign bit.
* This means a normalized float has at most 25 bits of signed precision.
@@ -1667,21 +1667,21 @@ template<> inline ALint SampleConv(ALfloat val) noexcept
*/
return fastf2i(clampf(val*2147483648.0f, -2147483648.0f, 2147483520.0f));
}
-template<> inline ALshort SampleConv(ALfloat val) noexcept
-{ return static_cast<ALshort>(fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f))); }
-template<> inline ALbyte SampleConv(ALfloat val) noexcept
-{ return static_cast<ALbyte>(fastf2i(clampf(val*128.0f, -128.0f, 127.0f))); }
+template<> inline int16_t SampleConv(float val) noexcept
+{ return static_cast<int16_t>(fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f))); }
+template<> inline int8_t SampleConv(float val) noexcept
+{ return static_cast<int8_t>(fastf2i(clampf(val*128.0f, -128.0f, 127.0f))); }
/* Define unsigned output variations. */
-template<> inline ALuint SampleConv(ALfloat val) noexcept
-{ return static_cast<ALuint>(SampleConv<ALint>(val)) + 2147483648u; }
-template<> inline ALushort SampleConv(ALfloat val) noexcept
-{ return static_cast<ALushort>(SampleConv<ALshort>(val) + 32768); }
-template<> inline ALubyte SampleConv(ALfloat val) noexcept
-{ return static_cast<ALubyte>(SampleConv<ALbyte>(val) + 128); }
+template<> inline uint32_t SampleConv(float val) noexcept
+{ return static_cast<uint32_t>(SampleConv<int32_t>(val)) + 2147483648u; }
+template<> inline uint16_t SampleConv(float val) noexcept
+{ return static_cast<uint16_t>(SampleConv<int16_t>(val) + 32768); }
+template<> inline uint8_t SampleConv(float val) noexcept
+{ return static_cast<uint8_t>(SampleConv<int8_t>(val) + 128); }
template<DevFmtType T>
-void Write(const al::span<const FloatBufferLine> InBuffer, ALvoid *OutBuffer, const size_t Offset,
+void Write(const al::span<const FloatBufferLine> InBuffer, void *OutBuffer, const size_t Offset,
const ALuint SamplesToDo)
{
using SampleType = typename DevFmtTypeTraits<T>::Type;
@@ -1694,7 +1694,7 @@ void Write(const al::span<const FloatBufferLine> InBuffer, ALvoid *OutBuffer, co
{
ASSUME(SamplesToDo > 0);
SampleType *out{outbase++};
- auto conv_sample = [numchans,&out](const ALfloat s) noexcept -> void
+ auto conv_sample = [numchans,&out](const float s) noexcept -> void
{
*out = SampleConv<SampleType>(s);
out += numchans;
diff --git a/alc/devformat.h b/alc/devformat.h
index e7ff2ec4..402fb8bd 100644
--- a/alc/devformat.h
+++ b/alc/devformat.h
@@ -1,8 +1,9 @@
#ifndef ALC_DEVFORMAT_H
#define ALC_DEVFORMAT_H
+#include <cstdint>
+
#include "AL/al.h"
-#include "AL/alc.h"
#include "AL/alext.h"
#include "inprogext.h"
@@ -82,19 +83,19 @@ template<DevFmtType T>
struct DevFmtTypeTraits { };
template<>
-struct DevFmtTypeTraits<DevFmtByte> { using Type = ALbyte; };
+struct DevFmtTypeTraits<DevFmtByte> { using Type = int8_t; };
template<>
-struct DevFmtTypeTraits<DevFmtUByte> { using Type = ALubyte; };
+struct DevFmtTypeTraits<DevFmtUByte> { using Type = uint8_t; };
template<>
-struct DevFmtTypeTraits<DevFmtShort> { using Type = ALshort; };
+struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; };
template<>
-struct DevFmtTypeTraits<DevFmtUShort> { using Type = ALushort; };
+struct DevFmtTypeTraits<DevFmtUShort> { using Type = uint16_t; };
template<>
-struct DevFmtTypeTraits<DevFmtInt> { using Type = ALint; };
+struct DevFmtTypeTraits<DevFmtInt> { using Type = int32_t; };
template<>
-struct DevFmtTypeTraits<DevFmtUInt> { using Type = ALuint; };
+struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; };
template<>
-struct DevFmtTypeTraits<DevFmtFloat> { using Type = ALfloat; };
+struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; };
ALuint BytesFromDevFmt(DevFmtType type) noexcept;