diff options
author | Chris Robinson <[email protected]> | 2018-01-21 18:15:25 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-21 18:16:27 -0800 |
commit | efd11f32a20c8fa06161a42facc5b97180c0c1a5 (patch) | |
tree | 135d2d11a61ed7db8897448c7d0e2bad8842a716 | |
parent | 6489fb586b7f7776ade4adb48910599fc8528802 (diff) |
Remove support for (signed) byte and ushort sample storage
Also not used without buffer_samples
-rw-r--r-- | OpenAL32/Include/alBuffer.h | 2 | ||||
-rw-r--r-- | OpenAL32/alBuffer.c | 8 | ||||
-rw-r--r-- | OpenAL32/sample_cvt.c | 103 |
3 files changed, 24 insertions, 89 deletions
diff --git a/OpenAL32/Include/alBuffer.h b/OpenAL32/Include/alBuffer.h index 3e4268e0..35c880c9 100644 --- a/OpenAL32/Include/alBuffer.h +++ b/OpenAL32/Include/alBuffer.h @@ -9,10 +9,8 @@ extern "C" { /* User formats */ enum UserFmtType { - UserFmtByte, UserFmtUByte, UserFmtShort, - UserFmtUShort, UserFmtFloat, UserFmtDouble, UserFmtMulaw, diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 37266570..e0f2160d 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -144,7 +144,7 @@ AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer) AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq) { enum UserFmtChannels srcchannels = UserFmtMono; - enum UserFmtType srctype = UserFmtByte; + enum UserFmtType srctype = UserFmtUByte; ALCdevice *device; ALCcontext *context; ALbuffer *albuf; @@ -170,10 +170,8 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoi switch(srctype) { - case UserFmtByte: case UserFmtUByte: case UserFmtShort: - case UserFmtUShort: case UserFmtFloat: case UserFmtMulaw: case UserFmtAlaw: @@ -339,7 +337,7 @@ done: AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, const ALvoid *data, ALsizei offset, ALsizei length) { enum UserFmtChannels srcchannels = UserFmtMono; - enum UserFmtType srctype = UserFmtByte; + enum UserFmtType srctype = UserFmtUByte; ALCdevice *device; ALCcontext *context; ALbuffer *albuf; @@ -1030,10 +1028,8 @@ ALsizei BytesFromUserFmt(enum UserFmtType type) { switch(type) { - case UserFmtByte: return sizeof(ALbyte); case UserFmtUByte: return sizeof(ALubyte); case UserFmtShort: return sizeof(ALshort); - case UserFmtUShort: return sizeof(ALushort); case UserFmtFloat: return sizeof(ALfloat); case UserFmtDouble: return sizeof(ALdouble); case UserFmtMulaw: return sizeof(ALubyte); diff --git a/OpenAL32/sample_cvt.c b/OpenAL32/sample_cvt.c index 8f67548b..0bbfb86c 100644 --- a/OpenAL32/sample_cvt.c +++ b/OpenAL32/sample_cvt.c @@ -502,10 +502,8 @@ static void EncodeMSADPCMBlock(ALmsadpcm *dst, const ALshort *src, ALint *sample #define DECL_TEMPLATE(T) \ static inline T Conv_##T##_##T(T val) { return val; } -DECL_TEMPLATE(ALbyte); DECL_TEMPLATE(ALubyte); DECL_TEMPLATE(ALshort); -DECL_TEMPLATE(ALushort); DECL_TEMPLATE(ALalaw); DECL_TEMPLATE(ALmulaw); @@ -523,62 +521,33 @@ static inline ALdouble Conv_ALdouble_ALdouble(ALdouble val) #undef DECL_TEMPLATE -/* Define alternate-sign functions. */ -#define DECL_TEMPLATE(T1, T2, O) \ -static inline T1 Conv_##T1##_##T2(T2 val) { return (T1)val - O; } \ -static inline T2 Conv_##T2##_##T1(T1 val) { return (T2)val + O; } - -DECL_TEMPLATE(ALbyte, ALubyte, 128); -DECL_TEMPLATE(ALshort, ALushort, 32768); - -#undef DECL_TEMPLATE - /* Define int-type to int-type functions */ -#define DECL_TEMPLATE(T, T1, T2, SH) \ -static inline T Conv_##T##_##T1(T1 val){ return val >> SH; } \ -static inline T Conv_##T##_##T2(T2 val){ return Conv_##T1##_##T2(val) >> SH; }\ -static inline T1 Conv_##T1##_##T(T val){ return val << SH; } \ -static inline T2 Conv_##T2##_##T(T val){ return Conv_##T2##_##T1(val << SH); } - -DECL_TEMPLATE(ALbyte, ALshort, ALushort, 8) -DECL_TEMPLATE(ALubyte, ALushort, ALshort, 8) - -#undef DECL_TEMPLATE +static inline ALubyte Conv_ALubyte_ALshort(ALshort val) { return (val>>8) + 128; } +static inline ALshort Conv_ALshort_ALubyte(ALubyte val) { return (val-128) << 8; } /* Define int-type to fp functions */ -#define DECL_TEMPLATE(T, ST, UT, OP) \ -static inline T Conv_##T##_##ST(ST val) { return (T)val * OP; } \ -static inline T Conv_##T##_##UT(UT val) { return (T)Conv_##ST##_##UT(val) * OP; } - -#define DECL_TEMPLATE2(T1, T2, OP) \ -DECL_TEMPLATE(T1, AL##T2, ALu##T2, OP) - -DECL_TEMPLATE2(ALfloat, byte, (1.0f/128.0f)) -DECL_TEMPLATE2(ALdouble, byte, (1.0/128.0)) -DECL_TEMPLATE2(ALfloat, short, (1.0f/32768.0f)) -DECL_TEMPLATE2(ALdouble, short, (1.0/32768.0)) - -#undef DECL_TEMPLATE2 -#undef DECL_TEMPLATE +static inline ALfloat Conv_ALfloat_ALubyte(ALubyte val) { return (val-128) * (1.0f/128.0f); } +static inline ALdouble Conv_ALdouble_ALubyte(ALubyte val) { return (val-128) * (1.0/128.0); } +static inline ALfloat Conv_ALfloat_ALshort(ALshort val) { return val * (1.0f/32768.0f); } +static inline ALdouble Conv_ALdouble_ALshort(ALshort val) { return val * (1.0/32768.0); } /* Define fp to int-type functions */ -#define DECL_TEMPLATE(FT, T, smin, smax) \ -static inline AL##T Conv_AL##T##_##FT(FT val) \ -{ \ - val *= (FT)smax + 1; \ - if(val >= (FT)smax) return smax; \ - if(val <= (FT)smin) return smin; \ - return (AL##T)val; \ -} \ -static inline ALu##T Conv_ALu##T##_##FT(FT val) \ -{ return Conv_ALu##T##_AL##T(Conv_AL##T##_##FT(val)); } - -DECL_TEMPLATE(ALfloat, byte, -128, 127) -DECL_TEMPLATE(ALdouble, byte, -128, 127) -DECL_TEMPLATE(ALfloat, short, -32768, 32767) -DECL_TEMPLATE(ALdouble, short, -32768, 32767) - -#undef DECL_TEMPLATE +static inline ALubyte Conv_ALubyte_ALfloat(ALfloat val) +{ + val *= 128.0f; + if(val >= 127.0f) return 255; + if(val <= -128.0f) return 0; + return (ALbyte)val + 128; +} +static inline ALubyte Conv_ALubyte_ALdouble(ALdouble val) { return Conv_ALubyte_ALfloat(val); } +static inline ALshort Conv_ALshort_ALfloat(ALfloat val) +{ + val *= 32768.0f; + if(val >= 32767.0f) return 32767; + if(val <= -32768.0f) return -32768; + return (ALshort)val; +} +static inline ALshort Conv_ALshort_ALdouble(ALdouble val) { return Conv_ALshort_ALfloat(val); } /* Define muLaw and aLaw functions (goes through short functions). */ #define DECL_TEMPLATE(T) \ @@ -592,10 +561,8 @@ static inline ALalaw Conv_ALalaw_##T(T val) \ static inline T Conv_##T##_ALalaw(ALalaw val) \ { return Conv_##T##_ALshort(DecodeALaw(val)); } -DECL_TEMPLATE(ALbyte) DECL_TEMPLATE(ALubyte) DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) DECL_TEMPLATE(ALfloat) DECL_TEMPLATE(ALdouble) @@ -619,19 +586,15 @@ static void Convert_##T1##_##T2(T1 *dst, const T2 *src, ALsizei numchans, \ } #define DECL_TEMPLATE2(T) \ -DECL_TEMPLATE(T, ALbyte) \ DECL_TEMPLATE(T, ALubyte) \ DECL_TEMPLATE(T, ALshort) \ -DECL_TEMPLATE(T, ALushort) \ DECL_TEMPLATE(T, ALfloat) \ DECL_TEMPLATE(T, ALdouble) \ DECL_TEMPLATE(T, ALmulaw) \ DECL_TEMPLATE(T, ALalaw) -DECL_TEMPLATE2(ALbyte) DECL_TEMPLATE2(ALubyte) DECL_TEMPLATE2(ALshort) -DECL_TEMPLATE2(ALushort) DECL_TEMPLATE2(ALfloat) DECL_TEMPLATE2(ALdouble) DECL_TEMPLATE2(ALmulaw) @@ -662,7 +625,6 @@ static void Convert_##T##_ALima4(T *dst, const ALima4 *src, ALsizei numchans, \ } \ } -DECL_TEMPLATE(ALbyte) DECL_TEMPLATE(ALubyte) static void Convert_ALshort_ALima4(ALshort *dst, const ALima4 *src, ALsizei numchans, ALsizei len, ALsizei align) @@ -678,7 +640,6 @@ static void Convert_ALshort_ALima4(ALshort *dst, const ALima4 *src, ALsizei numc dst += align*numchans; } } -DECL_TEMPLATE(ALushort) DECL_TEMPLATE(ALfloat) DECL_TEMPLATE(ALdouble) DECL_TEMPLATE(ALmulaw) @@ -709,7 +670,6 @@ static void Convert_ALima4_##T(ALima4 *dst, const T *src, ALsizei numchans, \ } \ } -DECL_TEMPLATE(ALbyte) DECL_TEMPLATE(ALubyte) static void Convert_ALima4_ALshort(ALima4 *dst, const ALshort *src, ALsizei numchans, ALsizei len, ALsizei align) @@ -727,7 +687,6 @@ static void Convert_ALima4_ALshort(ALima4 *dst, const ALshort *src, dst += byte_align; } } -DECL_TEMPLATE(ALushort) DECL_TEMPLATE(ALfloat) DECL_TEMPLATE(ALdouble) DECL_TEMPLATE(ALmulaw) @@ -759,7 +718,6 @@ static void Convert_##T##_ALmsadpcm(T *dst, const ALmsadpcm *src, \ } \ } -DECL_TEMPLATE(ALbyte) DECL_TEMPLATE(ALubyte) static void Convert_ALshort_ALmsadpcm(ALshort *dst, const ALmsadpcm *src, ALsizei numchans, ALsizei len, @@ -776,7 +734,6 @@ static void Convert_ALshort_ALmsadpcm(ALshort *dst, const ALmsadpcm *src, dst += align*numchans; } } -DECL_TEMPLATE(ALushort) DECL_TEMPLATE(ALfloat) DECL_TEMPLATE(ALdouble) DECL_TEMPLATE(ALmulaw) @@ -807,7 +764,6 @@ static void Convert_ALmsadpcm_##T(ALmsadpcm *dst, const T *src, \ } \ } -DECL_TEMPLATE(ALbyte) DECL_TEMPLATE(ALubyte) static void Convert_ALmsadpcm_ALshort(ALmsadpcm *dst, const ALshort *src, ALsizei numchans, ALsizei len, ALsizei align) @@ -824,7 +780,6 @@ static void Convert_ALmsadpcm_ALshort(ALmsadpcm *dst, const ALshort *src, dst += byte_align; } } -DECL_TEMPLATE(ALushort) DECL_TEMPLATE(ALfloat) DECL_TEMPLATE(ALdouble) DECL_TEMPLATE(ALmulaw) @@ -869,18 +824,12 @@ static void Convert_##T(T *dst, const ALvoid *src, enum UserFmtType srcType, \ { \ switch(srcType) \ { \ - case UserFmtByte: \ - Convert_##T##_ALbyte(dst, src, numchans, len, align); \ - break; \ case UserFmtUByte: \ Convert_##T##_ALubyte(dst, src, numchans, len, align); \ break; \ case UserFmtShort: \ Convert_##T##_ALshort(dst, src, numchans, len, align); \ break; \ - case UserFmtUShort: \ - Convert_##T##_ALushort(dst, src, numchans, len, align); \ - break; \ case UserFmtFloat: \ Convert_##T##_ALfloat(dst, src, numchans, len, align); \ break; \ @@ -902,10 +851,8 @@ static void Convert_##T(T *dst, const ALvoid *src, enum UserFmtType srcType, \ } \ } -DECL_TEMPLATE(ALbyte) DECL_TEMPLATE(ALubyte) DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) DECL_TEMPLATE(ALfloat) DECL_TEMPLATE(ALdouble) DECL_TEMPLATE(ALmulaw) @@ -921,18 +868,12 @@ void ConvertData(ALvoid *dst, enum UserFmtType dstType, const ALvoid *src, { switch(dstType) { - case UserFmtByte: - Convert_ALbyte(dst, src, srcType, numchans, len, align); - break; case UserFmtUByte: Convert_ALubyte(dst, src, srcType, numchans, len, align); break; case UserFmtShort: Convert_ALshort(dst, src, srcType, numchans, len, align); break; - case UserFmtUShort: - Convert_ALushort(dst, src, srcType, numchans, len, align); - break; case UserFmtFloat: Convert_ALfloat(dst, src, srcType, numchans, len, align); break; |