Skip to content

Commit

Permalink
Replace left shift with equivalent multiplication.
Browse files Browse the repository at this point in the history
We have done changes to the Audio Processing fuzzer here
https://webrtc-review.googlesource.com/c/src/+/36500/6.

We ran the new version of the fuzzer locally. The UBSAN
detector found these (minor) issues.

We have used the Godbolt compiler explorer to check that similar
changes produce identical compiled code.

Bug: webrtc:7820
Change-Id: I9cc3b81e4be7cf691f878c37010ce105bc2f3e38
Reviewed-on: https://webrtc-review.googlesource.com/39264
Reviewed-by: Karl Wiberg <[email protected]>
Commit-Queue: Alex Loiko <[email protected]>
Cr-Commit-Position: refs/heads/master@{#21605}
  • Loading branch information
Alex Loiko authored and Commit Bot committed Jan 12, 2018
1 parent d84b3d1 commit ee67ca3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions common_audio/signal_processing/complex_fft.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ int WebRtcSpl_ComplexFFT(int16_t frfi[], int stages, int mode)
tr32 >>= 15 - CFFTSFT;
ti32 >>= 15 - CFFTSFT;

qr32 = ((int32_t)frfi[2 * i]) << CFFTSFT;
qi32 = ((int32_t)frfi[2 * i + 1]) << CFFTSFT;
qr32 = ((int32_t)frfi[2 * i]) * (1 << CFFTSFT);
qi32 = ((int32_t)frfi[2 * i + 1]) * (1 << CFFTSFT);

frfi[2 * j] = (int16_t)(
(qr32 - tr32 + CFFTRND2) >> (1 + CFFTSFT));
Expand Down Expand Up @@ -276,8 +276,8 @@ int WebRtcSpl_ComplexIFFT(int16_t frfi[], int stages, int mode)
tr32 >>= 15 - CIFFTSFT;
ti32 >>= 15 - CIFFTSFT;

qr32 = ((int32_t)frfi[2 * i]) << CIFFTSFT;
qi32 = ((int32_t)frfi[2 * i + 1]) << CIFFTSFT;
qr32 = ((int32_t)frfi[2 * i]) * (1 << CIFFTSFT);
qi32 = ((int32_t)frfi[2 * i + 1]) * (1 << CIFFTSFT);

frfi[2 * j] = (int16_t)(
(qr32 - tr32 + round2) >> (shift + CIFFTSFT));
Expand Down
4 changes: 2 additions & 2 deletions modules/audio_processing/aecm/aecm_core_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ static void WindowAndFFT(AecmCore* aecm,
for (i = 0; i < PART_LEN; i++) {
// Window time domain signal and insert into real part of
// transformation array |fft|
int16_t scaled_time_signal = time_signal[i] << time_signal_scaling;
int16_t scaled_time_signal = time_signal[i] * (1 << time_signal_scaling);
fft[i] = (int16_t)((scaled_time_signal * WebRtcAecm_kSqrtHanning[i]) >> 14);
scaled_time_signal = time_signal[i + PART_LEN] << time_signal_scaling;
scaled_time_signal = time_signal[i + PART_LEN] * (1 << time_signal_scaling);
fft[PART_LEN + i] = (int16_t)((
scaled_time_signal * WebRtcAecm_kSqrtHanning[PART_LEN - i]) >> 14);
}
Expand Down

0 comments on commit ee67ca3

Please sign in to comment.