Removing undefined left shifts in AudioProcessing

This CL replaces 5 left shifts where the shifted value may be 
negative. The shifts are replaced with equivalent multiplications.

Bug: chromium:777231, chromium:776719, chromium:776624, chromium:776286
Change-Id: Ifb27d5506eac779e60f238432bdf9e4bc5b2da4c
Reviewed-on: https://webrtc-review.googlesource.com/14800
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20430}
This commit is contained in:
Alex Loiko 2017-10-24 09:58:00 +02:00 committed by Commit Bot
parent a194e58e79
commit b9f536167c
3 changed files with 5 additions and 5 deletions

View File

@ -83,7 +83,7 @@ void WebRtcSpl_DownsampleBy2(const int16_t* in, size_t len,
for (i = (len >> 1); i > 0; i--) {
// lower allpass filter
in32 = (int32_t)(*in++) << 10;
in32 = (int32_t)(*in++) * (1 << 10);
diff = in32 - state1;
tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0);
state0 = in32;
@ -95,7 +95,7 @@ void WebRtcSpl_DownsampleBy2(const int16_t* in, size_t len,
state2 = tmp2;
// upper allpass filter
in32 = (int32_t)(*in++) << 10;
in32 = (int32_t)(*in++) * (1 << 10);
diff = in32 - state5;
tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4);
state4 = in32;

View File

@ -97,8 +97,8 @@ static void AllPassFilter(const int16_t* data_in, size_t data_length,
tmp32 = state32 + filter_coefficient * *data_in;
tmp16 = (int16_t) (tmp32 >> 16); // Q(-1)
*data_out++ = tmp16;
state32 = (*data_in << 14) - filter_coefficient * tmp16; // Q14
state32 <<= 1; // Q15.
state32 = (*data_in * (1 << 14)) - filter_coefficient * tmp16; // Q14
state32 *= 2; // Q15.
data_in += 2;
}

View File

@ -631,7 +631,7 @@ int16_t WebRtcAgc_ProcessVad(AgcVad* state, // (i) VAD state
}
// energy level (range {-32..30}) (Q10)
dB = (15 - zeros) << 11;
dB = (15 - zeros) * (1 << 11);
// Update statistics