summaryrefslogtreecommitdiff
path: root/include/asterisk/utils.h
diff options
context:
space:
mode:
authorSean Bright <sean@malleable.com>2013-04-30 13:48:12 +0000
committerSean Bright <sean@malleable.com>2013-04-30 13:48:12 +0000
commitc03b95a3d70f96cac170527512ccc815a47993f1 (patch)
treeee371740c8189a334ec101f266ddc81a61166184 /include/asterisk/utils.h
parente2cd14876fcf0ca1af389112362ee120c60412b2 (diff)
Use the proper lower bound when doing saturation arithmetic.
16 bit signed integers have a range of [-32768, 32768). The existing code was using the interval (-32768, 32768) instead. This patch fixes that. Review: https://reviewboard.asterisk.org/r/2479/ ........ Merged revisions 386929 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 386930 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386931 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/utils.h')
-rw-r--r--include/asterisk/utils.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 9452dd5fb..6f041f953 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -324,8 +324,8 @@ static force_inline void ast_slinear_saturated_add(short *input, short *value)
res = (int) *input + *value;
if (res > 32767)
*input = 32767;
- else if (res < -32767)
- *input = -32767;
+ else if (res < -32768)
+ *input = -32768;
else
*input = (short) res;
}
@@ -337,8 +337,8 @@ static force_inline void ast_slinear_saturated_subtract(short *input, short *val
res = (int) *input - *value;
if (res > 32767)
*input = 32767;
- else if (res < -32767)
- *input = -32767;
+ else if (res < -32768)
+ *input = -32768;
else
*input = (short) res;
}
@@ -350,8 +350,8 @@ static force_inline void ast_slinear_saturated_multiply(short *input, short *val
res = (int) *input * *value;
if (res > 32767)
*input = 32767;
- else if (res < -32767)
- *input = -32767;
+ else if (res < -32768)
+ *input = -32768;
else
*input = (short) res;
}