+ DSP primitives: fix a rather stupid bug in clamping functions

(cherry picked from commit d55bbe5f163d3e32f3428c0a1f2643d4fe999a1b)
This commit is contained in:
Krzysztof Foltman
2009-10-12 23:06:37 +01:00
committed by Tobias Doerffel
parent f8c6833e9f
commit b60527e699

View File

@@ -224,14 +224,14 @@ inline T clip(T value, T min, T max) {
inline double clip11(double value) {
double a = fabs(value);
if (a<=1) return value;
return (a<0) ? -1.0 : 1.0;
return (value<0) ? -1.0 : 1.0;
}
/// Clip a float to [-1.0f, +1.0f]
inline float clip11(float value) {
float a = fabsf(value);
if (a<=1) return value;
return (a<0) ? -1.0f : 1.0f;
return (value<0) ? -1.0f : 1.0f;
}
/// Clip a double to [0.0, +1.0]
@@ -245,7 +245,7 @@ inline double clip01(double value) {
inline float clip01(float value) {
float a = fabsf(value-0.5f);
if (a<=0.5f) return value;
return (a<0) ? -0.0f : 1.0f;
return (value < 0) ? -0.0f : 1.0f;
}
// Linear interpolation (mix-way between v1 and v2).