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

Unified Diff: webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.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/entropy_coding.c
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c
index c9ddf935801090e5959df3ee45bf38334011a4be..8e351277c3fd6a9decad2c3d96043598f9d37599 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c
@@ -255,7 +255,7 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12,
}
for (k=0; k<FRAMESAMPLES/8; k++) {
- int32_t diff_q16 = diffQ16[k] << shftVal;
+ int32_t diff_q16 = diffQ16[k] * (1 << shftVal);
CurveQ16[FRAMESAMPLES / 4 - 1 - k] = CurveQ16[k] - diff_q16;
CurveQ16[k] += diff_q16;
}
@@ -864,8 +864,8 @@ void WebRtcIsacfix_MatrixProduct1C(const int16_t matrix0[],
matrix0_index = matrix0_index_factor1 * (*matrix0_index_factor2);
matrix1_index = matrix1_index_factor1 * (*matrix1_index_factor2);
for (n = 0; n < inner_loop_count; n++) {
- sum32 += (WEBRTC_SPL_MUL_16_32_RSFT16(matrix0[matrix0_index],
- matrix1[matrix1_index] << shift));
+ sum32 += WEBRTC_SPL_MUL_16_32_RSFT16(
+ matrix0[matrix0_index], matrix1[matrix1_index] * (1 << shift));
matrix0_index += matrix0_index_step;
matrix1_index += matrix1_index_step;
}
@@ -1042,7 +1042,8 @@ int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec *streamdata,
/* hi band LAR coeffs */
for (n=0; n<ORDERHI; n++, pos++, poss++) {
// ((Q13*Q17)>>16)<<3 = Q17, with 1/0.45 = 2.222222222222 ~= 18204 in Q13
- tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(18204, tmpcoeffs_sQ17[poss]) << 3;
+ tmp32 =
+ WEBRTC_SPL_MUL_16_32_RSFT16(18204, tmpcoeffs_sQ17[poss]) * (1 << 3);
tmp32 = tmp32 + WebRtcIsacfix_kMeansShapeQ17[model][poss]; // Q17+Q17 = Q17
LPCCoefQ17[pos] = tmp32;
}

Powered by Google App Engine
This is Rietveld 408576698