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
4d363ae305/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}
This commit is contained in:
henrik.lundin
2016-02-10 02:47:52 -08:00
committed by Commit bot
parent 15583c19d7
commit 6608d9a1aa
3 changed files with 23 additions and 22 deletions

View File

@ -99,7 +99,8 @@ int Normal::Process(const int16_t* input,
// 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 {