From f03ff24bac2c88f1d39cc49aab2e817cc5301a68 Mon Sep 17 00:00:00 2001 From: Sean Bright Date: Tue, 30 Apr 2013 13:46:53 +0000 Subject: [PATCH] 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 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@386930 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/utils.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index f3ae76ba41..6c36eaa22c 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; }