| 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..579e714a1104b965ebdb5065324a08a24637c4f8 100644
|
| --- a/webrtc/common_audio/signal_processing/spl_sqrt.c
|
| +++ b/webrtc/common_audio/signal_processing/spl_sqrt.c
|
| @@ -139,8 +139,19 @@ int32_t WebRtcSpl_Sqrt(int32_t value)
|
|
|
| A = value;
|
|
|
| - if (A == 0)
|
| - return (int32_t)0; // sqrt(0) = 0
|
| + // The convention in this function is to calculate sqrt(abs(A)). Negate the
|
| + // input if it is negative.
|
| + if (A < 0) {
|
| + 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 {
|
| + A = -A;
|
| + }
|
| + } else if (A == 0) {
|
| + return 0; // sqrt(0) = 0
|
| + }
|
|
|
| sh = WebRtcSpl_NormW32(A); // # shifts to normalize A
|
| A = WEBRTC_SPL_LSHIFT_W32(A, sh); // Normalize A
|
|
|