summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-12-09 05:06:29 -0800
committerChris Robinson <[email protected]>2010-12-09 05:06:29 -0800
commitbe3f3c4bf03dd5800e25f0d3144f2e122bac2f94 (patch)
tree4c76feee964f98665a0c81f6fcf57485e895a3d1 /Alc
parentd1ca8b44708bedf87002b85a7482aed5486d51cd (diff)
Make better use of the type range when converting from float
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 5b10fb54..e0fd5c9f 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -640,38 +640,30 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
}
-static __inline ALfloat aluF2F(ALfloat Value)
+static __inline ALfloat aluF2F(ALfloat val)
{
- return Value;
+ return val;
}
-static __inline ALshort aluF2US(ALfloat Value)
+static __inline ALushort aluF2US(ALfloat val)
{
- ALint i;
-
- if(Value <= -1.0f) i = 0;
- else if(Value >= 1.0f) i = 65535;
- else i = (ALint)(Value*32767.0f) + 32768;
-
- return ((ALushort)i);
+ if(val > 1.0f) return 65535;
+ if(val < -1.0f) return 0;
+ return (ALint)(val*32767.0f) + 32768;
}
-static __inline ALshort aluF2S(ALfloat Value)
+static __inline ALshort aluF2S(ALfloat val)
{
- ALint i;
-
- if(Value <= -1.0f) i = -32768;
- else if(Value >= 1.0f) i = 32767;
- else i = (ALint)(Value*32767.0f);
-
- return ((ALshort)i);
+ if(val > 1.0f) return 32767;
+ if(val < -1.0f) return -32768;
+ return (ALint)(val*32767.0f);
}
-static __inline ALubyte aluF2UB(ALfloat Value)
+static __inline ALubyte aluF2UB(ALfloat val)
{
- ALshort i = aluF2US(Value);
+ ALushort i = aluF2US(val);
return i>>8;
}
-static __inline ALubyte aluF2B(ALfloat Value)
+static __inline ALbyte aluF2B(ALfloat val)
{
- ALshort i = aluF2S(Value);
+ ALshort i = aluF2S(val);
return i>>8;
}