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
This commit is contained in:
kwiberg@webrtc.org 2014-04-17 12:17:39 +00:00
parent 66803489f9
commit d2f366f28c

View File

@ -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<int32_t>(left[i]) +
static_cast<int32_t>(right[i])) >> 1;
out[i] = WebRtcSpl_SatW32ToW16(data32);
}
for (int i = 0; i < samples_per_channel; i++)
out[i] = (static_cast<int32_t>(left[i]) +
static_cast<int32_t>(right[i])) >> 1;
}
} // namespace