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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 for (int i = 0; i < num_proc_channels_; ++i) { | 143 for (int i = 0; i < num_proc_channels_; ++i) { |
144 FloatToFloatS16(data_ptr[i], | 144 FloatToFloatS16(data_ptr[i], |
145 proc_num_frames_, | 145 proc_num_frames_, |
146 data_->fbuf()->channels()[i]); | 146 data_->fbuf()->channels()[i]); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 void AudioBuffer::CopyTo(const StreamConfig& stream_config, | 150 void AudioBuffer::CopyTo(const StreamConfig& stream_config, |
151 float* const* data) { | 151 float* const* data) { |
152 assert(stream_config.num_frames() == output_num_frames_); | 152 assert(stream_config.num_frames() == output_num_frames_); |
153 assert(stream_config.num_channels() == num_channels_); | 153 assert(stream_config.num_channels() == num_channels_ || num_channels_ == 1); |
154 | 154 |
155 // Convert to the float range. | 155 // Convert to the float range. |
156 float* const* data_ptr = data; | 156 float* const* data_ptr = data; |
157 if (output_num_frames_ != proc_num_frames_) { | 157 if (output_num_frames_ != proc_num_frames_) { |
158 // Convert to an intermediate buffer for subsequent resampling. | 158 // Convert to an intermediate buffer for subsequent resampling. |
159 data_ptr = process_buffer_->channels(); | 159 data_ptr = process_buffer_->channels(); |
160 } | 160 } |
161 for (int i = 0; i < num_channels_; ++i) { | 161 for (int i = 0; i < num_channels_; ++i) { |
162 FloatS16ToFloat(data_->fbuf()->channels()[i], | 162 FloatS16ToFloat(data_->fbuf()->channels()[i], |
163 proc_num_frames_, | 163 proc_num_frames_, |
164 data_ptr[i]); | 164 data_ptr[i]); |
165 } | 165 } |
166 | 166 |
167 // Resample. | 167 // Resample. |
168 if (output_num_frames_ != proc_num_frames_) { | 168 if (output_num_frames_ != proc_num_frames_) { |
169 for (int i = 0; i < num_channels_; ++i) { | 169 for (int i = 0; i < num_channels_; ++i) { |
170 output_resamplers_[i]->Resample(data_ptr[i], | 170 output_resamplers_[i]->Resample(data_ptr[i], |
171 proc_num_frames_, | 171 proc_num_frames_, |
172 data[i], | 172 data[i], |
173 output_num_frames_); | 173 output_num_frames_); |
174 } | 174 } |
175 } | 175 } |
| 176 |
| 177 // Upmix. |
| 178 for (int i = num_channels_; i < stream_config.num_channels(); ++i) { |
| 179 memcpy(data[i], data[0], output_num_frames_ * sizeof(**data)); |
| 180 } |
176 } | 181 } |
177 | 182 |
178 void AudioBuffer::InitForNewData() { | 183 void AudioBuffer::InitForNewData() { |
179 keyboard_data_ = NULL; | 184 keyboard_data_ = NULL; |
180 mixed_low_pass_valid_ = false; | 185 mixed_low_pass_valid_ = false; |
181 reference_copied_ = false; | 186 reference_copied_ = false; |
182 activity_ = AudioFrame::kVadUnknown; | 187 activity_ = AudioFrame::kVadUnknown; |
183 num_channels_ = num_proc_channels_; | 188 num_channels_ = num_proc_channels_; |
184 } | 189 } |
185 | 190 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 458 |
454 void AudioBuffer::SplitIntoFrequencyBands() { | 459 void AudioBuffer::SplitIntoFrequencyBands() { |
455 splitting_filter_->Analysis(data_.get(), split_data_.get()); | 460 splitting_filter_->Analysis(data_.get(), split_data_.get()); |
456 } | 461 } |
457 | 462 |
458 void AudioBuffer::MergeFrequencyBands() { | 463 void AudioBuffer::MergeFrequencyBands() { |
459 splitting_filter_->Synthesis(split_data_.get(), data_.get()); | 464 splitting_filter_->Synthesis(split_data_.get(), data_.get()); |
460 } | 465 } |
461 | 466 |
462 } // namespace webrtc | 467 } // namespace webrtc |
OLD | NEW |