Avoid overflow in NetEq's TimeStretch::SpeechDetection
BUG=chromium:675193 R=kwiberg@webrtc.org Review-Url: https://codereview.webrtc.org/2718943004 . Cr-Commit-Position: refs/heads/master@{#16902}
This commit is contained in:
@ -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_);
|
||||
|
||||
Reference in New Issue
Block a user