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

Side by Side Diff: webrtc/modules/audio_processing/aec3/echo_canceller3.cc

Issue 2678423005: Finalization of the first version of EchoCanceller 3 (Closed)
Patch Set: Fixed compilation error Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 #include "webrtc/modules/audio_processing/aec3/echo_canceller3.h" 10 #include "webrtc/modules/audio_processing/aec3/echo_canceller3.h"
11 11
12 #include <sstream> 12 #include <sstream>
13 13
14 #include "webrtc/base/atomicops.h" 14 #include "webrtc/base/atomicops.h"
15 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" 15 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
16 16
17 namespace webrtc { 17 namespace webrtc {
18 18
19 namespace { 19 namespace {
20 20
21 bool DetectSaturation(rtc::ArrayView<const float> y) { 21 bool DetectSaturation(rtc::ArrayView<const float> y) {
22 for (auto y_k : y) { 22 for (auto y_k : y) {
23 if (y_k >= 32767.0f || y_k <= -32768.0f) { 23 if (y_k >= 32700.0f || y_k <= -32700.0f) {
24 return true; 24 return true;
25 } 25 }
26 } 26 }
27 return false; 27 return false;
28 } 28 }
29 29
30 void FillSubFrameView(AudioBuffer* frame, 30 void FillSubFrameView(AudioBuffer* frame,
31 size_t sub_frame_index, 31 size_t sub_frame_index,
32 std::vector<rtc::ArrayView<float>>* sub_frame_view) { 32 std::vector<rtc::ArrayView<float>>* sub_frame_view) {
33 RTC_DCHECK_GE(1, sub_frame_index); 33 RTC_DCHECK_GE(1, sub_frame_index);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 bool BufferRemainingRenderFrameContent(FrameBlocker* render_blocker, 100 bool BufferRemainingRenderFrameContent(FrameBlocker* render_blocker,
101 BlockProcessor* block_processor, 101 BlockProcessor* block_processor,
102 std::vector<std::vector<float>>* block) { 102 std::vector<std::vector<float>>* block) {
103 if (!render_blocker->IsBlockAvailable()) { 103 if (!render_blocker->IsBlockAvailable()) {
104 return true; 104 return true;
105 } 105 }
106 render_blocker->ExtractBlock(block); 106 render_blocker->ExtractBlock(block);
107 return block_processor->BufferRender(block); 107 return block_processor->BufferRender(block);
108 } 108 }
109 109
110 void CopyAudioBufferIntoFrame(AudioBuffer* buffer, 110 void CopyLowestBandIntoFrame(AudioBuffer* buffer,
111 size_t num_bands, 111 size_t num_bands,
112 size_t frame_length, 112 size_t frame_length,
113 std::vector<std::vector<float>>* frame) { 113 std::vector<std::vector<float>>* frame) {
114 RTC_DCHECK_EQ(num_bands, frame->size()); 114 RTC_DCHECK_EQ(num_bands, frame->size());
115 for (size_t i = 0; i < num_bands; ++i) { 115 RTC_DCHECK_EQ(frame_length, (*frame)[0].size());
116 rtc::ArrayView<float> buffer_view(&buffer->split_bands_f(0)[i][0], 116 rtc::ArrayView<float> buffer_view(&buffer->channels_f()[0][0], frame_length);
117 frame_length); 117 std::copy(buffer_view.begin(), buffer_view.end(), (*frame)[0].begin());
118 std::copy(buffer_view.begin(), buffer_view.end(), (*frame)[i].begin());
119 }
120 } 118 }
121 119
122 // [B,A] = butter(2,100/4000,'high') 120 // [B,A] = butter(2,100/4000,'high')
123 const CascadedBiQuadFilter::BiQuadCoefficients 121 const CascadedBiQuadFilter::BiQuadCoefficients
124 kHighPassFilterCoefficients_8kHz = {{0.94598f, -1.89195f, 0.94598f}, 122 kHighPassFilterCoefficients_8kHz = {{0.94598f, -1.89195f, 0.94598f},
125 {-1.88903f, 0.89487f}}; 123 {-1.88903f, 0.89487f}};
126 const int kNumberOfHighPassBiQuads_8kHz = 1; 124 const int kNumberOfHighPassBiQuads_8kHz = 1;
127 125
128 // [B,A] = butter(2,100/8000,'high') 126 // [B,A] = butter(2,100/8000,'high')
129 const CascadedBiQuadFilter::BiQuadCoefficients 127 const CascadedBiQuadFilter::BiQuadCoefficients
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 render_queue_input_frame_(num_bands_, 173 render_queue_input_frame_(num_bands_,
176 std::vector<float>(frame_length_, 0.f)), 174 std::vector<float>(frame_length_, 0.f)),
177 render_transfer_queue_(render_transfer_queue) { 175 render_transfer_queue_(render_transfer_queue) {
178 RTC_DCHECK(data_dumper); 176 RTC_DCHECK(data_dumper);
179 } 177 }
180 178
181 EchoCanceller3::RenderWriter::~RenderWriter() = default; 179 EchoCanceller3::RenderWriter::~RenderWriter() = default;
182 180
183 bool EchoCanceller3::RenderWriter::Insert(AudioBuffer* input) { 181 bool EchoCanceller3::RenderWriter::Insert(AudioBuffer* input) {
184 RTC_DCHECK_EQ(1, input->num_channels()); 182 RTC_DCHECK_EQ(1, input->num_channels());
185 RTC_DCHECK_EQ(num_bands_, input->num_bands());
186 RTC_DCHECK_EQ(frame_length_, input->num_frames_per_band()); 183 RTC_DCHECK_EQ(frame_length_, input->num_frames_per_band());
187 data_dumper_->DumpWav("aec3_render_input", frame_length_, 184 data_dumper_->DumpWav("aec3_render_input", frame_length_,
188 &input->split_bands_f(0)[0][0], 185 &input->channels_f()[0][0],
189 LowestBandRate(sample_rate_hz_), 1); 186 LowestBandRate(sample_rate_hz_), 1);
190 187
191 CopyAudioBufferIntoFrame(input, num_bands_, frame_length_, 188 CopyLowestBandIntoFrame(input, num_bands_, frame_length_,
192 &render_queue_input_frame_); 189 &render_queue_input_frame_);
193 190
194 if (render_highpass_filter_) { 191 if (render_highpass_filter_) {
195 render_highpass_filter_->Process(render_queue_input_frame_[0]); 192 render_highpass_filter_->Process(render_queue_input_frame_[0]);
196 } 193 }
197 194
198 return render_transfer_queue_->Insert(&render_queue_input_frame_); 195 return render_transfer_queue_->Insert(&render_queue_input_frame_);
199 } 196 }
200 197
201 int EchoCanceller3::instance_count_ = 0; 198 int EchoCanceller3::instance_count_ = 0;
202 199
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 block_processor_.get(), &block_) && 352 block_processor_.get(), &block_) &&
356 successful_buffering; 353 successful_buffering;
357 354
358 frame_to_buffer = 355 frame_to_buffer =
359 render_transfer_queue_.Remove(&render_queue_output_frame_); 356 render_transfer_queue_.Remove(&render_queue_output_frame_);
360 } 357 }
361 return successful_buffering; 358 return successful_buffering;
362 } 359 }
363 360
364 } // namespace webrtc 361 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698