aboutsummaryrefslogtreecommitdiffstats
path: root/libFDK/include/scale.h
diff options
context:
space:
mode:
Diffstat (limited to 'libFDK/include/scale.h')
-rw-r--r--libFDK/include/scale.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/libFDK/include/scale.h b/libFDK/include/scale.h
index fcb6c48..d60ed2c 100644
--- a/libFDK/include/scale.h
+++ b/libFDK/include/scale.h
@@ -148,12 +148,20 @@ FIXP_DBL scaleValueSaturate(
{
if(scalefactor > 0) {
if (fNorm(value) < scalefactor && value != (FIXP_DBL)0) {
- return (FIXP_DBL)MAXVAL_DBL;
+ if (value > (FIXP_DBL)0) {
+ return (FIXP_DBL)MAXVAL_DBL;
+ } else {
+ return (FIXP_DBL)MINVAL_DBL;
+ }
} else {
return (value<<scalefactor);
}
} else {
+ if (-(DFRACT_BITS-1) > scalefactor) {
+ return (FIXP_DBL)0;
+ } else {
return (value>>(-scalefactor));
+ }
}
}
#endif