Chromium Code Reviews| 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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 for (int i = 0; i < num_proc_channels_; ++i) { | 429 for (int i = 0; i < num_proc_channels_; ++i) { |
| 430 input_resamplers_[i]->Resample(input_buffer_->fbuf_const()->channels()[i], | 430 input_resamplers_[i]->Resample(input_buffer_->fbuf_const()->channels()[i], |
| 431 input_num_frames_, | 431 input_num_frames_, |
| 432 data_->fbuf()->channels()[i], | 432 data_->fbuf()->channels()[i], |
| 433 proc_num_frames_); | 433 proc_num_frames_); |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 | 437 |
| 438 void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) const { | 438 void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) const { |
| 439 assert(proc_num_frames_ == output_num_frames_); | |
| 440 assert(num_channels_ == num_input_channels_); | |
| 441 assert(frame->num_channels_ == num_channels_); | |
| 442 assert(frame->samples_per_channel_ == proc_num_frames_); | |
| 443 frame->vad_activity_ = activity_; | |
| 444 | |
| 445 if (!data_changed) { | 439 if (!data_changed) { |
| 446 return; | 440 return; |
| 447 } | 441 } |
| 448 | 442 |
| 449 Interleave(data_->ibuf()->channels(), | 443 assert(proc_num_frames_ == output_num_frames_); |
| 450 proc_num_frames_, | 444 assert(frame->num_channels_ == num_channels_ || num_channels_ == 1); |
| 451 num_channels_, | 445 assert(frame->samples_per_channel_ == proc_num_frames_); |
| 452 frame->data_); | 446 frame->vad_activity_ = activity_; |
| 447 | |
| 448 if (frame->num_channels_ == num_channels_) { | |
| 449 Interleave(data_->ibuf()->channels(), proc_num_frames_, num_channels_, | |
| 450 frame->data_); | |
| 451 } else { | |
| 452 // Copy single AudioBuffer channel into all AudioFrame channels | |
| 453 int16_t* const* channel_ptr_copies[frame->num_channels_]; | |
|
aluebs-webrtc
2015/07/20 19:33:43
int16_t* channel_ptr_copies[frame->num_channels_];
ekm
2015/07/21 01:02:43
Done.
| |
| 454 for (int i = 0; i < frame->num_channels_; i++) { | |
|
aluebs-webrtc
2015/07/20 19:33:43
++i
ekm
2015/07/21 01:02:43
Done.
| |
| 455 channel_ptr_copies[i] = data_->ibuf()->channels(); | |
|
aluebs-webrtc
2015/07/20 19:33:43
data->ibuf()->channels()[0];
ekm
2015/07/21 01:02:43
Done.
| |
| 456 } | |
| 457 Interleave(data_->ibuf()->channels(), proc_num_frames_, num_channels_, | |
|
aluebs-webrtc
2015/07/20 19:33:43
channel_ptr_copies
ekm
2015/07/21 01:02:43
Done. Phew, nice catch.
| |
| 458 frame->data_); | |
| 459 } | |
| 453 } | 460 } |
| 454 | 461 |
| 455 void AudioBuffer::CopyLowPassToReference() { | 462 void AudioBuffer::CopyLowPassToReference() { |
| 456 reference_copied_ = true; | 463 reference_copied_ = true; |
| 457 if (!low_pass_reference_channels_.get() || | 464 if (!low_pass_reference_channels_.get() || |
| 458 low_pass_reference_channels_->num_channels() != num_channels_) { | 465 low_pass_reference_channels_->num_channels() != num_channels_) { |
| 459 low_pass_reference_channels_.reset( | 466 low_pass_reference_channels_.reset( |
| 460 new ChannelBuffer<int16_t>(num_split_frames_, | 467 new ChannelBuffer<int16_t>(num_split_frames_, |
| 461 num_proc_channels_)); | 468 num_proc_channels_)); |
| 462 } | 469 } |
| 463 for (int i = 0; i < num_proc_channels_; i++) { | 470 for (int i = 0; i < num_proc_channels_; i++) { |
| 464 memcpy(low_pass_reference_channels_->channels()[i], | 471 memcpy(low_pass_reference_channels_->channels()[i], |
| 465 split_bands_const(i)[kBand0To8kHz], | 472 split_bands_const(i)[kBand0To8kHz], |
| 466 low_pass_reference_channels_->num_frames_per_band() * | 473 low_pass_reference_channels_->num_frames_per_band() * |
| 467 sizeof(split_bands_const(i)[kBand0To8kHz][0])); | 474 sizeof(split_bands_const(i)[kBand0To8kHz][0])); |
| 468 } | 475 } |
| 469 } | 476 } |
| 470 | 477 |
| 471 void AudioBuffer::SplitIntoFrequencyBands() { | 478 void AudioBuffer::SplitIntoFrequencyBands() { |
| 472 splitting_filter_->Analysis(data_.get(), split_data_.get()); | 479 splitting_filter_->Analysis(data_.get(), split_data_.get()); |
| 473 } | 480 } |
| 474 | 481 |
| 475 void AudioBuffer::MergeFrequencyBands() { | 482 void AudioBuffer::MergeFrequencyBands() { |
| 476 splitting_filter_->Synthesis(split_data_.get(), data_.get()); | 483 splitting_filter_->Synthesis(split_data_.get(), data_.get()); |
| 477 } | 484 } |
| 478 | 485 |
| 479 } // namespace webrtc | 486 } // namespace webrtc |
| OLD | NEW |