Another ilbc cross correlation fix

To determine the appropriate amount of shifting to prevent overflow in a
cross correlation, it is necessary to have the max value of both
sequences. However, only one was calculated in the ilbc code. This CL
calculates the max of the other sequence and correctly takes both into
account.

Bug: chromium:1161837
Change-Id: I3ba8eee0814bb5eda3769c0ce6caf2681c7525e1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/202253
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33043}
diff --git a/modules/audio_coding/codecs/ilbc/enhancer_interface.c b/modules/audio_coding/codecs/ilbc/enhancer_interface.c
index fb9740e..71436c2 100644
--- a/modules/audio_coding/codecs/ilbc/enhancer_interface.c
+++ b/modules/audio_coding/codecs/ilbc/enhancer_interface.c
@@ -18,6 +18,7 @@
 
 #include "modules/audio_coding/codecs/ilbc/enhancer_interface.h"
 
+#include <stdlib.h>
 #include <string.h>
 
 #include "modules/audio_coding/codecs/ilbc/constants.h"
@@ -203,11 +204,11 @@
     regressor=in+tlag-1;
 
     /* scaling */
-    // Note that this is not abs-max, but it doesn't matter since we use only
-    // the square of it.
+    // Note that this is not abs-max, so we will take the absolute value below.
     max16 = regressor[WebRtcSpl_MaxAbsIndexW16(regressor, plc_blockl + 3 - 1)];
-
-    const int64_t max_val = plc_blockl * max16 * max16;
+    const int16_t max_target =
+        target[WebRtcSpl_MaxAbsIndexW16(target, plc_blockl + 3 - 1)];
+    const int64_t max_val = plc_blockl * abs(max16 * max_target);
     const int32_t factor = max_val >> 31;
     shifts = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor);