ref: 34da05b30d4947b54c1aafb2dbca8e91f58afaf0
parent: 33f18a20dc1eb401e51369e97674f09f79943631
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Tue Apr 19 12:21:08 EDT 2016
Fixes signed integer overlof in silk_ADD_POS_SAT32() Removes unused 64-bit version
--- a/silk/MacroCount.h
+++ b/silk/MacroCount.h
@@ -319,14 +319,6 @@
return(tmp);
}
-#undef silk_ADD_POS_SAT64
-static OPUS_INLINE opus_int64 silk_ADD_POS_SAT64(opus_int64 a, opus_int64 b){
- opus_int64 tmp;
- ops_count += 1;
- tmp = ((((a)+(b)) & 0x8000000000000000LL) ? silk_int64_MAX : ((a)+(b)));
- return(tmp);
-}
-
#undef silk_LSHIFT8
static OPUS_INLINE opus_int8 silk_LSHIFT8(opus_int8 a, opus_int32 shift){
opus_int8 ret;
--- a/silk/MacroDebug.h
+++ b/silk/MacroDebug.h
@@ -539,8 +539,7 @@
no checking needed for silk_POS_SAT32
no checking needed for silk_ADD_POS_SAT8
no checking needed for silk_ADD_POS_SAT16
- no checking needed for silk_ADD_POS_SAT32
- no checking needed for silk_ADD_POS_SAT64 */
+ no checking needed for silk_ADD_POS_SAT32 */
#undef silk_LSHIFT8
#define silk_LSHIFT8(a,b) silk_LSHIFT8_((a), (b), __FILE__, __LINE__)
--- a/silk/SigProc_FIX.h
+++ b/silk/SigProc_FIX.h
@@ -471,8 +471,7 @@
/* Add with saturation for positive input values */
#define silk_ADD_POS_SAT8(a, b) ((((a)+(b)) & 0x80) ? silk_int8_MAX : ((a)+(b)))
#define silk_ADD_POS_SAT16(a, b) ((((a)+(b)) & 0x8000) ? silk_int16_MAX : ((a)+(b)))
-#define silk_ADD_POS_SAT32(a, b) ((((a)+(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b)))
-#define silk_ADD_POS_SAT64(a, b) ((((a)+(b)) & 0x8000000000000000LL) ? silk_int64_MAX : ((a)+(b)))
+#define silk_ADD_POS_SAT32(a, b) ((((opus_uint32)(a)+(opus_uint32)(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b)))
#define silk_LSHIFT8(a, shift) ((opus_int8)((opus_uint8)(a)<<(shift))) /* shift >= 0, shift < 8 */
#define silk_LSHIFT16(a, shift) ((opus_int16)((opus_uint16)(a)<<(shift))) /* shift >= 0, shift < 16 */