diff options
author | Chris Robinson <[email protected]> | 2018-01-17 08:49:49 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-17 08:49:49 -0800 |
commit | 884fe40fd1262fe642a86d29f27e157e2b562212 (patch) | |
tree | bc41817b5349d69f0fd825a753d41204a52257d7 /Alc | |
parent | 3baf9d0e81c16555fc417697a5445b7cd674db02 (diff) |
Store mulaw and alaw samples directly in the buffer
They're now decompressed on the fly in the mixer. This is not a significant
performance issue given that it only needs a 512-byte lookup table, and the
buffer stores half as much data (it may actually be faster, requiring less
overall memory).
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/mixer.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c index 8f946f6d..d1796da8 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -33,6 +33,7 @@ #include "alBuffer.h" #include "alListener.h" #include "alAuxEffectSlot.h" +#include "sample_cvt.h" #include "alu.h" #include "alconfig.h" @@ -201,6 +202,14 @@ static inline ALfloat Sample_ALshort(ALshort val) static inline ALfloat Sample_ALfloat(ALfloat val) { return val; } +typedef ALubyte ALmulaw; +static inline ALfloat Sample_ALmulaw(ALmulaw val) +{ return muLawDecompressionTable[val] * (1.0f/32768.0f); } + +typedef ALubyte ALalaw; +static inline ALfloat Sample_ALalaw(ALalaw val) +{ return aLawDecompressionTable[val] * (1.0f/32768.0f); } + #define DECL_TEMPLATE(T) \ static inline void Load_##T(ALfloat *restrict dst, const T *restrict src, \ ALint srcstep, ALsizei samples) \ @@ -213,24 +222,24 @@ static inline void Load_##T(ALfloat *restrict dst, const T *restrict src, \ DECL_TEMPLATE(ALbyte) DECL_TEMPLATE(ALshort) DECL_TEMPLATE(ALfloat) +DECL_TEMPLATE(ALmulaw) +DECL_TEMPLATE(ALalaw) #undef DECL_TEMPLATE static void LoadSamples(ALfloat *restrict dst, const ALvoid *restrict src, ALint srcstep, enum FmtType srctype, ALsizei samples) { +#define HANDLE_FMT(ET, ST) case ET: Load_##ST(dst, src, srcstep, samples); break switch(srctype) { - case FmtByte: - Load_ALbyte(dst, src, srcstep, samples); - break; - case FmtShort: - Load_ALshort(dst, src, srcstep, samples); - break; - case FmtFloat: - Load_ALfloat(dst, src, srcstep, samples); - break; + HANDLE_FMT(FmtByte, ALbyte); + HANDLE_FMT(FmtShort, ALshort); + HANDLE_FMT(FmtFloat, ALfloat); + HANDLE_FMT(FmtMulaw, ALmulaw); + HANDLE_FMT(FmtAlaw, ALalaw); } +#undef HANDLE_FMT } |