From d2f366f28ceb738a9f193a5ce1868b50b3697197 Mon Sep 17 00:00:00 2001 From: "kwiberg@webrtc.org" Date: Thu, 17 Apr 2014 12:17:39 +0000 Subject: [PATCH] StereoToMono: Remove useless call to WebRtcSpl_SatW32ToW16 The max value is ((2**15 - 1) + (2**15 - 1)) >> 1 == (2**16 - 2) >> 1 == 2**15 - 1 which doesn't overflow. The min value is (-2**15 + -2**15) >> 1 == -2**16 >> 1 == -2**15 which doesn't overflow. Since those two bracket all possible results, the call to WebRtcSpl_SatW32ToW16 is redundant. BUG= R=andrew@webrtc.org, bjornv@webrtc.org Review URL: https://webrtc-codereview.appspot.com/12019004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5929 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/audio_processing/audio_buffer.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/webrtc/modules/audio_processing/audio_buffer.cc b/webrtc/modules/audio_processing/audio_buffer.cc index 90824770b7..8d26f52495 100644 --- a/webrtc/modules/audio_processing/audio_buffer.cc +++ b/webrtc/modules/audio_processing/audio_buffer.cc @@ -25,12 +25,9 @@ enum { void StereoToMono(const int16_t* left, const int16_t* right, int16_t* out, int samples_per_channel) { assert(left != NULL && right != NULL && out != NULL); - for (int i = 0; i < samples_per_channel; i++) { - int32_t data32 = (static_cast(left[i]) + - static_cast(right[i])) >> 1; - - out[i] = WebRtcSpl_SatW32ToW16(data32); - } + for (int i = 0; i < samples_per_channel; i++) + out[i] = (static_cast(left[i]) + + static_cast(right[i])) >> 1; } } // namespace