Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(748)

Unified Diff: webrtc/modules/audio_processing/audio_buffer.cc

Issue 1234463003: Integrate Intelligibility with APM (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix Mac Error (3) Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/audio_buffer.cc
diff --git a/webrtc/modules/audio_processing/audio_buffer.cc b/webrtc/modules/audio_processing/audio_buffer.cc
index 9073ad7569732a8e9c204b93689c30be86275709..6f732624930fb5d04e8ed860dd442d71a9fc91a3 100644
--- a/webrtc/modules/audio_processing/audio_buffer.cc
+++ b/webrtc/modules/audio_processing/audio_buffer.cc
@@ -403,21 +403,37 @@ void AudioBuffer::DeinterleaveFrom(AudioFrame* frame) {
}
}
-void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) const {
- assert(proc_num_frames_ == output_num_frames_);
- assert(num_channels_ == num_input_channels_);
- assert(frame->num_channels_ == num_channels_);
- assert(frame->samples_per_channel_ == proc_num_frames_);
+void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) {
frame->vad_activity_ = activity_;
-
if (!data_changed) {
return;
}
- Interleave(data_->ibuf()->channels(),
- proc_num_frames_,
- num_channels_,
- frame->data_);
+ assert(frame->num_channels_ == num_channels_ || num_channels_ == 1);
+ assert(frame->samples_per_channel_ == output_num_frames_);
+
+ // Resample if necessary.
+ IFChannelBuffer* data_ptr = data_.get();
+ if (proc_num_frames_ != output_num_frames_) {
+ if (!output_buffer_) {
+ output_buffer_.reset(
+ new IFChannelBuffer(output_num_frames_, num_channels_));
+ }
+ for (int i = 0; i < num_channels_; ++i) {
+ output_resamplers_[i]->Resample(
+ data_->fbuf()->channels()[i], proc_num_frames_,
+ output_buffer_->fbuf()->channels()[i], output_num_frames_);
+ }
+ data_ptr = output_buffer_.get();
+ }
+
+ if (frame->num_channels_ == num_channels_) {
+ Interleave(data_ptr->ibuf()->channels(), proc_num_frames_, num_channels_,
+ frame->data_);
+ } else {
+ UpmixMonoToInterleaved(data_ptr->ibuf()->channels()[0], proc_num_frames_,
+ frame->num_channels_, frame->data_);
+ }
}
void AudioBuffer::CopyLowPassToReference() {
« no previous file with comments | « webrtc/modules/audio_processing/audio_buffer.h ('k') | webrtc/modules/audio_processing/audio_processing_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698