| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 dst_frame->num_channels_ = 1; | 75 dst_frame->num_channels_ = 1; |
| 76 AudioFrameOperations::MonoToStereo(dst_frame); | 76 AudioFrameOperations::MonoToStereo(dst_frame); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 void MixWithSat(int16_t target[], | 80 void MixWithSat(int16_t target[], |
| 81 size_t target_channel, | 81 size_t target_channel, |
| 82 const int16_t source[], | 82 const int16_t source[], |
| 83 size_t source_channel, | 83 size_t source_channel, |
| 84 size_t source_len) { | 84 size_t source_len) { |
| 85 RTC_DCHECK_GE(target_channel, 1u); | 85 RTC_DCHECK_GE(target_channel, 1); |
| 86 RTC_DCHECK_LE(target_channel, 2u); | 86 RTC_DCHECK_LE(target_channel, 2); |
| 87 RTC_DCHECK_GE(source_channel, 1u); | 87 RTC_DCHECK_GE(source_channel, 1); |
| 88 RTC_DCHECK_LE(source_channel, 2u); | 88 RTC_DCHECK_LE(source_channel, 2); |
| 89 | 89 |
| 90 if (target_channel == 2 && source_channel == 1) { | 90 if (target_channel == 2 && source_channel == 1) { |
| 91 // Convert source from mono to stereo. | 91 // Convert source from mono to stereo. |
| 92 int32_t left = 0; | 92 int32_t left = 0; |
| 93 int32_t right = 0; | 93 int32_t right = 0; |
| 94 for (size_t i = 0; i < source_len; ++i) { | 94 for (size_t i = 0; i < source_len; ++i) { |
| 95 left = source[i] + target[i * 2]; | 95 left = source[i] + target[i * 2]; |
| 96 right = source[i] + target[i * 2 + 1]; | 96 right = source[i] + target[i * 2 + 1]; |
| 97 target[i * 2] = WebRtcSpl_SatW32ToW16(left); | 97 target[i * 2] = WebRtcSpl_SatW32ToW16(left); |
| 98 target[i * 2 + 1] = WebRtcSpl_SatW32ToW16(right); | 98 target[i * 2 + 1] = WebRtcSpl_SatW32ToW16(right); |
| 99 } | 99 } |
| 100 } else if (target_channel == 1 && source_channel == 2) { | 100 } else if (target_channel == 1 && source_channel == 2) { |
| 101 // Convert source from stereo to mono. | 101 // Convert source from stereo to mono. |
| 102 int32_t temp = 0; | 102 int32_t temp = 0; |
| 103 for (size_t i = 0; i < source_len / 2; ++i) { | 103 for (size_t i = 0; i < source_len / 2; ++i) { |
| 104 temp = ((source[i * 2] + source[i * 2 + 1]) >> 1) + target[i]; | 104 temp = ((source[i * 2] + source[i * 2 + 1]) >> 1) + target[i]; |
| 105 target[i] = WebRtcSpl_SatW32ToW16(temp); | 105 target[i] = WebRtcSpl_SatW32ToW16(temp); |
| 106 } | 106 } |
| 107 } else { | 107 } else { |
| 108 int32_t temp = 0; | 108 int32_t temp = 0; |
| 109 for (size_t i = 0; i < source_len; ++i) { | 109 for (size_t i = 0; i < source_len; ++i) { |
| 110 temp = source[i] + target[i]; | 110 temp = source[i] + target[i]; |
| 111 target[i] = WebRtcSpl_SatW32ToW16(temp); | 111 target[i] = WebRtcSpl_SatW32ToW16(temp); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace voe | 116 } // namespace voe |
| 117 } // namespace webrtc | 117 } // namespace webrtc |
| OLD | NEW |