aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-10-26 15:31:14 -0700
committerChris Robinson <[email protected]>2012-10-26 15:31:14 -0700
commitf02a9935c65efbad9a0387b288df008a7f1ebf91 (patch)
treee0a4b17d0568a34383b397cdeb98ab6f911c8e17 /Alc/ALu.c
parent3711735ed95e1627ca6da0ab794b145fb4f661ea (diff)
Avoid branching when clamping and converting float samples to integer
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 1ab58de6..4dd4c7dc 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -908,8 +908,8 @@ static __inline ALfloat aluF2F(ALfloat val)
{ return val; }
static __inline ALint aluF2I(ALfloat val)
{
- if(val > 1.0f) return 2147483647;
- if(val < -1.0f) return -2147483647-1;
+ val = val+1.0f - fabsf(val-1.0f);
+ val = (val-2.0f + fabsf(val+2.0f)) * 0.25;
return fastf2i((ALfloat)(val*2147483647.0));
}
static __inline ALuint aluF2UI(ALfloat val)