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

Unified Diff: webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c

Issue 1734883003: iSAC entropy coder: Avoid signed integer overflow (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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/main/source/entropy_coding.c
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c b/webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c
index dd1d64af7b86958496fcc28b42a1d63beb484841..c1204ad03adcbcae5175824818ee92f2c24e6928 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c
+++ b/webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c
@@ -182,13 +182,13 @@ static void GenerateDitherQ7Lb(int16_t* bufQ7, uint32_t seed,
/* Fixed-point dither sample between -64 and 64 (Q7). */
/* dither = seed * 128 / 4294967295 */
- dither1_Q7 = (int16_t)(((int)seed + 16777216) >> 25);
+ dither1_Q7 = (int16_t)(((int32_t)(seed + 16777216)) >> 25);
/* New random unsigned int. */
seed = (seed * 196314165) + 907633515;
/* Fixed-point dither sample between -64 and 64. */
- dither2_Q7 = (int16_t)(((int)seed + 16777216) >> 25);
+ dither2_Q7 = (int16_t)(((int32_t)(seed + 16777216)) >> 25);
shft = (seed >> 25) & 15;
if (shft < 5) {
@@ -214,7 +214,7 @@ static void GenerateDitherQ7Lb(int16_t* bufQ7, uint32_t seed,
seed = (seed * 196314165) + 907633515;
/* Fixed-point dither sample between -64 and 64. */
- dither1_Q7 = (int16_t)(((int)seed + 16777216) >> 25);
+ dither1_Q7 = (int16_t)(((int32_t)(seed + 16777216)) >> 25);
/* Dither sample is placed in either even or odd index. */
shft = (seed >> 25) & 1; /* Either 0 or 1 */
@@ -254,7 +254,7 @@ static void GenerateDitherQ7LbUB(
/* Fixed-point dither sample between -64 and 64 (Q7). */
/* bufQ7 = seed * 128 / 4294967295 */
- bufQ7[k] = (int16_t)(((int)seed + 16777216) >> 25);
+ bufQ7[k] = (int16_t)(((int32_t)(seed + 16777216)) >> 25);
/* Scale by 0.35. */
bufQ7[k] = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(bufQ7[k], 2048, 13);

Powered by Google App Engine
This is Rietveld 408576698