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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 if (input_num_frames_ != proc_num_frames_) { | 396 if (input_num_frames_ != proc_num_frames_) { |
397 for (int i = 0; i < num_proc_channels_; ++i) { | 397 for (int i = 0; i < num_proc_channels_; ++i) { |
398 input_resamplers_[i]->Resample(input_buffer_->fbuf_const()->channels()[i], | 398 input_resamplers_[i]->Resample(input_buffer_->fbuf_const()->channels()[i], |
399 input_num_frames_, | 399 input_num_frames_, |
400 data_->fbuf()->channels()[i], | 400 data_->fbuf()->channels()[i], |
401 proc_num_frames_); | 401 proc_num_frames_); |
402 } | 402 } |
403 } | 403 } |
404 } | 404 } |
405 | 405 |
406 void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) const { | 406 void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) { |
407 assert(proc_num_frames_ == output_num_frames_); | |
408 assert(num_channels_ == num_input_channels_); | |
409 assert(frame->num_channels_ == num_channels_); | |
410 assert(frame->samples_per_channel_ == proc_num_frames_); | |
411 frame->vad_activity_ = activity_; | 407 frame->vad_activity_ = activity_; |
412 | |
413 if (!data_changed) { | 408 if (!data_changed) { |
414 return; | 409 return; |
415 } | 410 } |
416 | 411 |
417 Interleave(data_->ibuf()->channels(), | 412 assert(frame->num_channels_ == num_channels_ || num_channels_ == 1); |
418 proc_num_frames_, | 413 assert(frame->samples_per_channel_ == output_num_frames_); |
419 num_channels_, | 414 |
420 frame->data_); | 415 // Resample if necessary. |
| 416 IFChannelBuffer* data_ptr = data_.get(); |
| 417 if (proc_num_frames_ != output_num_frames_) { |
| 418 if (!output_buffer_) { |
| 419 output_buffer_.reset( |
| 420 new IFChannelBuffer(output_num_frames_, num_channels_)); |
| 421 } |
| 422 for (int i = 0; i < num_channels_; ++i) { |
| 423 output_resamplers_[i]->Resample( |
| 424 data_->fbuf()->channels()[i], proc_num_frames_, |
| 425 output_buffer_->fbuf()->channels()[i], output_num_frames_); |
| 426 } |
| 427 data_ptr = output_buffer_.get(); |
| 428 } |
| 429 |
| 430 if (frame->num_channels_ == num_channels_) { |
| 431 Interleave(data_ptr->ibuf()->channels(), proc_num_frames_, num_channels_, |
| 432 frame->data_); |
| 433 } else { |
| 434 UpmixMonoToInterleaved(data_ptr->ibuf()->channels()[0], proc_num_frames_, |
| 435 frame->num_channels_, frame->data_); |
| 436 } |
421 } | 437 } |
422 | 438 |
423 void AudioBuffer::CopyLowPassToReference() { | 439 void AudioBuffer::CopyLowPassToReference() { |
424 reference_copied_ = true; | 440 reference_copied_ = true; |
425 if (!low_pass_reference_channels_.get() || | 441 if (!low_pass_reference_channels_.get() || |
426 low_pass_reference_channels_->num_channels() != num_channels_) { | 442 low_pass_reference_channels_->num_channels() != num_channels_) { |
427 low_pass_reference_channels_.reset( | 443 low_pass_reference_channels_.reset( |
428 new ChannelBuffer<int16_t>(num_split_frames_, | 444 new ChannelBuffer<int16_t>(num_split_frames_, |
429 num_proc_channels_)); | 445 num_proc_channels_)); |
430 } | 446 } |
431 for (int i = 0; i < num_proc_channels_; i++) { | 447 for (int i = 0; i < num_proc_channels_; i++) { |
432 memcpy(low_pass_reference_channels_->channels()[i], | 448 memcpy(low_pass_reference_channels_->channels()[i], |
433 split_bands_const(i)[kBand0To8kHz], | 449 split_bands_const(i)[kBand0To8kHz], |
434 low_pass_reference_channels_->num_frames_per_band() * | 450 low_pass_reference_channels_->num_frames_per_band() * |
435 sizeof(split_bands_const(i)[kBand0To8kHz][0])); | 451 sizeof(split_bands_const(i)[kBand0To8kHz][0])); |
436 } | 452 } |
437 } | 453 } |
438 | 454 |
439 void AudioBuffer::SplitIntoFrequencyBands() { | 455 void AudioBuffer::SplitIntoFrequencyBands() { |
440 splitting_filter_->Analysis(data_.get(), split_data_.get()); | 456 splitting_filter_->Analysis(data_.get(), split_data_.get()); |
441 } | 457 } |
442 | 458 |
443 void AudioBuffer::MergeFrequencyBands() { | 459 void AudioBuffer::MergeFrequencyBands() { |
444 splitting_filter_->Synthesis(split_data_.get(), data_.get()); | 460 splitting_filter_->Synthesis(split_data_.get(), data_.get()); |
445 } | 461 } |
446 | 462 |
447 } // namespace webrtc | 463 } // namespace webrtc |
OLD | NEW |