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

Unified Diff: webrtc/modules/audio_coding/neteq/time_stretch.cc

Issue 2718943004: Avoid overflow in NetEq's TimeStretch::SpeechDetection (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/neteq/time_stretch.cc
diff --git a/webrtc/modules/audio_coding/neteq/time_stretch.cc b/webrtc/modules/audio_coding/neteq/time_stretch.cc
index 880b1f82ea595271ee0f92795f8a39542e5039f4..c96d165e743cc9ffec8ed013598299ef40a8c9c6 100644
--- a/webrtc/modules/audio_coding/neteq/time_stretch.cc
+++ b/webrtc/modules/audio_coding/neteq/time_stretch.cc
@@ -182,7 +182,8 @@ bool TimeStretch::SpeechDetection(int32_t vec1_energy, int32_t vec2_energy,
// (vec1_energy + vec2_energy) / 16 <= peak_index * background_noise_energy.
// The two sides of the inequality will be denoted |left_side| and
// |right_side|.
- int32_t left_side = (vec1_energy + vec2_energy) / 16;
+ int32_t left_side = rtc::saturated_cast<int32_t>(
+ (static_cast<int64_t>(vec1_energy) + vec2_energy) / 16);
int32_t right_side;
if (background_noise_.initialized()) {
right_side = background_noise_.Energy(master_channel_);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698