Chromium Code Reviews| Index: webrtc/common_audio/signal_processing/spl_sqrt.c |
| diff --git a/webrtc/common_audio/signal_processing/spl_sqrt.c b/webrtc/common_audio/signal_processing/spl_sqrt.c |
| index 24db4f822ca153ceebd85d436135970a651ac559..3e01dcbd7ddade860dd4d252e625e2bf0dc0a4c0 100644 |
| --- a/webrtc/common_audio/signal_processing/spl_sqrt.c |
| +++ b/webrtc/common_audio/signal_processing/spl_sqrt.c |
| @@ -139,6 +139,16 @@ int32_t WebRtcSpl_Sqrt(int32_t value) |
| A = value; |
| + // The convention in this function is to calculate sqrt(abs(A)). Negate the |
| + // input if it is negative. |
| + if (A == WEBRTC_SPL_WORD32_MIN) { |
| + // This number cannot be held in an int32_t after negating. |
| + // Map it to the maximum positive value. |
| + A = WEBRTC_SPL_WORD32_MAX; |
| + } else if (A < 0) { |
| + A = -A; |
| + } |
|
kwiberg-webrtc
2016/02/11 09:28:10
The optimizer may already be doing this for you, b
hlundin-webrtc
2016/02/11 22:02:29
Much better. Done.
|
| + |
| if (A == 0) |
| return (int32_t)0; // sqrt(0) = 0 |