Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Unified Diff: webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c

Issue 1989803002: Fix UBSan errors (left shift of negative value) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c
index b5d91d421984e4d674f6c70421cc72b714a66c3b..2e92578cf7f2d97b6186fc6ec5d738e30978bd13 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c
@@ -50,33 +50,37 @@ void WebRtcIsacfix_AllpassFilter2FixDec16C(
// Process channel 1:
in_out = data_ch1[n];
a = factor_ch1[0] * in_out; // Q15 * Q0 = Q15
- a <<= 1; // Q15 -> Q16
+ a *= 1 << 1; // Q15 -> Q16
b = WebRtcSpl_AddSatW32(a, state0_ch1);
a = -factor_ch1[0] * (int16_t)(b >> 16); // Q15
- state0_ch1 = WebRtcSpl_AddSatW32(a << 1, (uint32_t)in_out << 16); // Q16
+ state0_ch1 =
+ WebRtcSpl_AddSatW32(a * (1 << 1), (int32_t)in_out * (1 << 16)); // Q16
in_out = (int16_t) (b >> 16); // Save as Q0
a = factor_ch1[1] * in_out; // Q15 * Q0 = Q15
- a <<= 1; // Q15 -> Q16
+ a *= 1 << 1; // Q15 -> Q16
b = WebRtcSpl_AddSatW32(a, state1_ch1); // Q16
a = -factor_ch1[1] * (int16_t)(b >> 16); // Q15
- state1_ch1 = WebRtcSpl_AddSatW32(a << 1, (uint32_t)in_out << 16); // Q16
+ state1_ch1 =
+ WebRtcSpl_AddSatW32(a * (1 << 1), (int32_t)in_out * (1 << 16)); // Q16
data_ch1[n] = (int16_t) (b >> 16); // Save as Q0
// Process channel 2:
in_out = data_ch2[n];
a = factor_ch2[0] * in_out; // Q15 * Q0 = Q15
- a <<= 1; // Q15 -> Q16
+ a *= 1 << 1; // Q15 -> Q16
b = WebRtcSpl_AddSatW32(a, state0_ch2); // Q16
a = -factor_ch2[0] * (int16_t)(b >> 16); // Q15
- state0_ch2 = WebRtcSpl_AddSatW32(a << 1, (uint32_t)in_out << 16); // Q16
+ state0_ch2 =
+ WebRtcSpl_AddSatW32(a * (1 << 1), (int32_t)in_out * (1 << 16)); // Q16
in_out = (int16_t) (b >> 16); // Save as Q0
a = factor_ch2[1] * in_out; // Q15 * Q0 = Q15
- a <<= 1; // Q15 -> Q16
+ a *= (1 << 1); // Q15 -> Q16
b = WebRtcSpl_AddSatW32(a, state1_ch2); // Q16
a = -factor_ch2[1] * (int16_t)(b >> 16); // Q15
- state1_ch2 = WebRtcSpl_AddSatW32(a << 1, (uint32_t)in_out << 16); // Q16
+ state1_ch2 =
+ WebRtcSpl_AddSatW32(a * (1 << 1), (int32_t)in_out * (1 << 16)); // Q16
data_ch2[n] = (int16_t) (b >> 16); // Save as Q0
}
@@ -144,11 +148,11 @@ void WebRtcIsacfix_HighpassFilterFixDec32C(int16_t *io,
c = in + ((a1 + b1) >> 7); // Q0.
io[k] = (int16_t)WebRtcSpl_SatW32ToW16(c); // Write output as Q0.
- c = (in << 2) - a2 - b2; // In Q2.
+ c = in * (1 << 2) - a2 - b2; // In Q2.
c = (int32_t)WEBRTC_SPL_SAT(536870911, c, -536870912);
state1 = state0;
- state0 = c << 2; // Write state as Q4
+ state0 = c * (1 << 2); // Write state as Q4
}
state[0] = state0;
state[1] = state1;

Powered by Google App Engine
This is Rietveld 408576698