From b60d1962d8e325e5a3f41fd6130269400e672f0c Mon Sep 17 00:00:00 2001 From: kwiberg Date: Mon, 24 Oct 2016 04:18:46 -0700 Subject: [PATCH] Eliminate left shift of negative value by using multiplication instead BUG=chromium:655917 Review-Url: https://codereview.webrtc.org/2430393003 Cr-Commit-Position: refs/heads/master@{#14741} --- webrtc/modules/audio_coding/neteq/dtmf_tone_generator.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webrtc/modules/audio_coding/neteq/dtmf_tone_generator.cc b/webrtc/modules/audio_coding/neteq/dtmf_tone_generator.cc index 8b4b9d3f4f..9dad2e5efd 100644 --- a/webrtc/modules/audio_coding/neteq/dtmf_tone_generator.cc +++ b/webrtc/modules/audio_coding/neteq/dtmf_tone_generator.cc @@ -195,7 +195,8 @@ int DtmfToneGenerator::Generate(size_t num_samples, sample_history2_[1] = temp_val_high; // Attenuate the low frequency tone 3 dB. - int32_t temp_val = kAmpMultiplier * temp_val_low + (temp_val_high << 15); + int32_t temp_val = + kAmpMultiplier * temp_val_low + temp_val_high * (1 << 15); // Normalize the signal to Q14 with proper rounding. temp_val = (temp_val + 16384) >> 15; // Scale the signal to correct volume.