| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 // Upmix after resampling. | 82 // Upmix after resampling. |
| 83 if (num_channels == 1 && dst_frame->num_channels_ == 2) { | 83 if (num_channels == 1 && dst_frame->num_channels_ == 2) { |
| 84 // The audio in dst_frame really is mono at this point; MonoToStereo will | 84 // The audio in dst_frame really is mono at this point; MonoToStereo will |
| 85 // set this back to stereo. | 85 // set this back to stereo. |
| 86 dst_frame->num_channels_ = 1; | 86 dst_frame->num_channels_ = 1; |
| 87 AudioFrameOperations::MonoToStereo(dst_frame); | 87 AudioFrameOperations::MonoToStereo(dst_frame); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 void MixWithSat(int16_t target[], | |
| 92 size_t target_channel, | |
| 93 const int16_t source[], | |
| 94 size_t source_channel, | |
| 95 size_t source_len) { | |
| 96 RTC_DCHECK_GE(target_channel, 1); | |
| 97 RTC_DCHECK_LE(target_channel, 2); | |
| 98 RTC_DCHECK_GE(source_channel, 1); | |
| 99 RTC_DCHECK_LE(source_channel, 2); | |
| 100 | |
| 101 if (target_channel == 2 && source_channel == 1) { | |
| 102 // Convert source from mono to stereo. | |
| 103 int32_t left = 0; | |
| 104 int32_t right = 0; | |
| 105 for (size_t i = 0; i < source_len; ++i) { | |
| 106 left = source[i] + target[i * 2]; | |
| 107 right = source[i] + target[i * 2 + 1]; | |
| 108 target[i * 2] = WebRtcSpl_SatW32ToW16(left); | |
| 109 target[i * 2 + 1] = WebRtcSpl_SatW32ToW16(right); | |
| 110 } | |
| 111 } else if (target_channel == 1 && source_channel == 2) { | |
| 112 // Convert source from stereo to mono. | |
| 113 int32_t temp = 0; | |
| 114 for (size_t i = 0; i < source_len / 2; ++i) { | |
| 115 temp = ((source[i * 2] + source[i * 2 + 1]) >> 1) + target[i]; | |
| 116 target[i] = WebRtcSpl_SatW32ToW16(temp); | |
| 117 } | |
| 118 } else { | |
| 119 int32_t temp = 0; | |
| 120 for (size_t i = 0; i < source_len; ++i) { | |
| 121 temp = source[i] + target[i]; | |
| 122 target[i] = WebRtcSpl_SatW32ToW16(temp); | |
| 123 } | |
| 124 } | |
| 125 } | |
| 126 | |
| 127 } // namespace voe | 91 } // namespace voe |
| 128 } // namespace webrtc | 92 } // namespace webrtc |
| OLD | NEW |