summaryrefslogtreecommitdiff
path: root/silk/Inlines.h
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2011-10-11 16:47:00 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2011-10-11 16:47:00 -0400
commit4541bbcc22c6289f3a2a70fda88a9aa372535b58 (patch)
treedb4b21988e8db63302f6d74e44902ed2668fa294 /silk/Inlines.h
parent37378626205c46690629dd6291ec528703b4ae60 (diff)
downloadopus-4541bbcc22c6289f3a2a70fda88a9aa372535b58.tar.gz
Gets rid of a "safe" signed overflow in silk_DIV32_varQ()
Diffstat (limited to 'silk/Inlines.h')
-rw-r--r--silk/Inlines.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/silk/Inlines.h b/silk/Inlines.h
index 50060e63..765e7708 100644
--- a/silk/Inlines.h
+++ b/silk/Inlines.h
@@ -117,7 +117,8 @@ static inline opus_int32 silk_DIV32_varQ( /* O returns a good approximatio
result = silk_SMULWB(a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */
/* Compute residual by subtracting product of denominator and first approximation */
- a32_nrm -= silk_LSHIFT( silk_SMMUL(b32_nrm, result), 3 ); /* Q: a_headrm */
+ /* It's OK to overflow because the final value of a32_nrm should always be small */
+ a32_nrm = silk_SUB32_ovflw(a32_nrm, silk_LSHIFT_ovflw( silk_SMMUL(b32_nrm, result), 3 )); /* Q: a_headrm */
/* Refinement */
result = silk_SMLAWB(result, a32_nrm, b32_inv); /* Q: 29 + a_headrm - b_headrm */