commit | 6608d9a1aa2b67d320aba0193b37271605aa7786 | [log] [tgz] |
---|---|---|
author | henrik.lundin <henrik.lundin@webrtc.org> | Wed Feb 10 02:47:52 2016 -0800 |
committer | Commit bot <commit-bot@chromium.org> | Wed Feb 10 10:47:56 2016 +0000 |
tree | e7fa039e998717507343a6c0443edf1ed6e60c9a | |
parent | 15583c19d7d491d53f9bf9c0f6d15a734b0a473d [diff] [blame] |
NetEq: Fix a negative shift value In some rare occations (very low energy signal), a shift value happened to be negative. This is now fixed by using the WEBRTC_SPL_SHIFT_W32, which in essence checks the sign of the number of shifts and performs a right or left shift accordingly. The fix reverts to how the code was written in old NetEq; see https://chromium.googlesource.com/external/webrtc/+/4d363ae305fa975e7f3ad2a5ca5dbe5e3f101f82/webrtc/modules/audio_coding/neteq/normal.c#165. BUG=webrtc:5490 Review URL: https://codereview.webrtc.org/1675293002 Cr-Commit-Position: refs/heads/master@{#11546}
diff --git a/webrtc/modules/audio_coding/neteq/normal.cc b/webrtc/modules/audio_coding/neteq/normal.cc index 1b888f7..9bddfe7 100644 --- a/webrtc/modules/audio_coding/neteq/normal.cc +++ b/webrtc/modules/audio_coding/neteq/normal.cc
@@ -99,7 +99,8 @@ // We want background_noise_.energy() / energy in Q14. int32_t bgn_energy = background_noise_.Energy(channel_ix) << (scaling+14); - int16_t energy_scaled = static_cast<int16_t>(energy << scaling); + int16_t energy_scaled = + static_cast<int16_t>(WEBRTC_SPL_SHIFT_W32(energy, scaling)); int32_t ratio = WebRtcSpl_DivW32W16(bgn_energy, energy_scaled); mute_factor = WebRtcSpl_SqrtFloor(ratio << 14); } else {