OLD | NEW |
---|---|
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 CopyAudioBufferIntoFrame(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()); |
aleloi
2017/02/23 10:56:45
Suggest renaming into 'CopyLowestBandIntoFrame' or
peah-webrtc
2017/02/23 11:18:33
Done.
| |
115 for (size_t i = 0; i < num_bands; ++i) { | 115 rtc::ArrayView<float> buffer_view(&buffer->channels_f()[0][0], frame_length); |
116 rtc::ArrayView<float> buffer_view(&buffer->split_bands_f(0)[i][0], | 116 std::copy(buffer_view.begin(), buffer_view.end(), (*frame)[0].begin()); |
117 frame_length); | |
118 std::copy(buffer_view.begin(), buffer_view.end(), (*frame)[i].begin()); | |
119 } | |
120 } | 117 } |
121 | 118 |
122 // [B,A] = butter(2,100/4000,'high') | 119 // [B,A] = butter(2,100/4000,'high') |
123 const CascadedBiQuadFilter::BiQuadCoefficients | 120 const CascadedBiQuadFilter::BiQuadCoefficients |
124 kHighPassFilterCoefficients_8kHz = {{0.94598f, -1.89195f, 0.94598f}, | 121 kHighPassFilterCoefficients_8kHz = {{0.94598f, -1.89195f, 0.94598f}, |
125 {-1.88903f, 0.89487f}}; | 122 {-1.88903f, 0.89487f}}; |
126 const int kNumberOfHighPassBiQuads_8kHz = 1; | 123 const int kNumberOfHighPassBiQuads_8kHz = 1; |
127 | 124 |
128 // [B,A] = butter(2,100/8000,'high') | 125 // [B,A] = butter(2,100/8000,'high') |
129 const CascadedBiQuadFilter::BiQuadCoefficients | 126 const CascadedBiQuadFilter::BiQuadCoefficients |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 render_queue_input_frame_(num_bands_, | 172 render_queue_input_frame_(num_bands_, |
176 std::vector<float>(frame_length_, 0.f)), | 173 std::vector<float>(frame_length_, 0.f)), |
177 render_transfer_queue_(render_transfer_queue) { | 174 render_transfer_queue_(render_transfer_queue) { |
178 RTC_DCHECK(data_dumper); | 175 RTC_DCHECK(data_dumper); |
179 } | 176 } |
180 | 177 |
181 EchoCanceller3::RenderWriter::~RenderWriter() = default; | 178 EchoCanceller3::RenderWriter::~RenderWriter() = default; |
182 | 179 |
183 bool EchoCanceller3::RenderWriter::Insert(AudioBuffer* input) { | 180 bool EchoCanceller3::RenderWriter::Insert(AudioBuffer* input) { |
184 RTC_DCHECK_EQ(1, input->num_channels()); | 181 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()); | 182 RTC_DCHECK_EQ(frame_length_, input->num_frames_per_band()); |
187 data_dumper_->DumpWav("aec3_render_input", frame_length_, | 183 data_dumper_->DumpWav("aec3_render_input", frame_length_, |
188 &input->split_bands_f(0)[0][0], | 184 &input->channels_f()[0][0], |
189 LowestBandRate(sample_rate_hz_), 1); | 185 LowestBandRate(sample_rate_hz_), 1); |
190 | 186 |
191 CopyAudioBufferIntoFrame(input, num_bands_, frame_length_, | 187 CopyAudioBufferIntoFrame(input, num_bands_, frame_length_, |
192 &render_queue_input_frame_); | 188 &render_queue_input_frame_); |
193 | 189 |
194 if (render_highpass_filter_) { | 190 if (render_highpass_filter_) { |
195 render_highpass_filter_->Process(render_queue_input_frame_[0]); | 191 render_highpass_filter_->Process(render_queue_input_frame_[0]); |
196 } | 192 } |
197 | 193 |
198 return render_transfer_queue_->Insert(&render_queue_input_frame_); | 194 return render_transfer_queue_->Insert(&render_queue_input_frame_); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 block_processor_.get(), &block_) && | 351 block_processor_.get(), &block_) && |
356 successful_buffering; | 352 successful_buffering; |
357 | 353 |
358 frame_to_buffer = | 354 frame_to_buffer = |
359 render_transfer_queue_.Remove(&render_queue_output_frame_); | 355 render_transfer_queue_.Remove(&render_queue_output_frame_); |
360 } | 356 } |
361 return successful_buffering; | 357 return successful_buffering; |
362 } | 358 } |
363 | 359 |
364 } // namespace webrtc | 360 } // namespace webrtc |
OLD | NEW |