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

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: Added resampling support to InterleaveTo; removed VAD logic Created 5 years, 5 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 04dcaea799d60af6bbc48d899e9ded8134d6ce03..f25309407da32c1c26065c6652365839e9ba123c 100644
--- a/webrtc/modules/audio_processing/audio_buffer.cc
+++ b/webrtc/modules/audio_processing/audio_buffer.cc
@@ -435,21 +435,40 @@ 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;
+ 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();
+ } else {
+ data_ptr = data_.get();
Andrew MacDonald 2015/07/29 03:52:27 Initialize data_ptr to data_.get() when you declar
ekm 2015/07/29 23:35:06 Done.
+ }
+
+ 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_,
aluebs-webrtc 2015/07/29 22:17:10 Should this method be in a anonymous namespace in
ekm 2015/07/29 23:35:06 Hmm.... it seems cleaner and clearer as is for now
aluebs-webrtc 2015/07/30 15:28:07 As I said, I don't have a strong opinion and I agr
ekm 2015/07/30 21:23:50 Acknowledged.
+ frame->num_channels_, frame->data_);
+ }
}
void AudioBuffer::CopyLowPassToReference() {

Powered by Google App Engine
This is Rietveld 408576698