Chromium Code Reviews| 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/block_processor.h" | 10 #include "webrtc/modules/audio_processing/aec3/block_processor.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 data_dumper_->DumpWav("aec3_processblock_capture_input2", kBlockSize, | 94 data_dumper_->DumpWav("aec3_processblock_capture_input2", kBlockSize, |
| 95 &(*capture_block)[0][0], | 95 &(*capture_block)[0][0], |
| 96 LowestBandRate(sample_rate_hz_), 1); | 96 LowestBandRate(sample_rate_hz_), 1); |
| 97 | 97 |
| 98 bool render_buffer_underrun = false; | 98 bool render_buffer_underrun = false; |
| 99 if (render_buffer_overrun_occurred_) { | 99 if (render_buffer_overrun_occurred_) { |
| 100 // Reset the render buffers and the alignment functionality when there has | 100 // Reset the render buffers and the alignment functionality when there has |
| 101 // been a render buffer overrun as the buffer alignment may be noncausal. | 101 // been a render buffer overrun as the buffer alignment may be noncausal. |
| 102 delay_controller_->Reset(); | 102 delay_controller_->Reset(); |
| 103 render_buffer_->Reset(); | 103 render_buffer_->Reset(); |
| 104 } else { | 104 } |
|
peah-webrtc
2017/04/06 13:39:08
Before this change, the AEC leaked echo for one bl
| |
| 105 // Update the render buffers with new render data, filling the buffers with | |
| 106 // empty blocks when there is no render data available. | |
| 107 render_buffer_underrun = !render_buffer_->UpdateBuffers(); | |
| 108 | 105 |
| 109 // Compute and and apply the render delay required to achieve proper signal | 106 // Update the render buffers with new render data, filling the buffers with |
| 110 // alignment. | 107 // empty blocks when there is no render data available. |
| 111 const size_t old_delay = render_buffer_->Delay(); | 108 render_buffer_underrun = !render_buffer_->UpdateBuffers(); |
| 112 const size_t new_delay = delay_controller_->GetDelay( | |
| 113 render_buffer_->GetDownsampledRenderBuffer(), (*capture_block)[0]); | |
| 114 render_buffer_->SetDelay(new_delay); | |
| 115 const size_t achieved_delay = render_buffer_->Delay(); | |
| 116 | 109 |
| 117 // Inform the delay controller of the actually set delay to allow it to | 110 // Compute and and apply the render delay required to achieve proper signal |
| 118 // properly react to a non-feasible delay. | 111 // alignment. |
| 119 delay_controller_->SetDelay(achieved_delay); | 112 const size_t old_delay = render_buffer_->Delay(); |
| 113 const size_t new_delay = delay_controller_->GetDelay( | |
| 114 render_buffer_->GetDownsampledRenderBuffer(), (*capture_block)[0]); | |
| 115 render_buffer_->SetDelay(new_delay); | |
| 116 const size_t achieved_delay = render_buffer_->Delay(); | |
| 120 | 117 |
| 121 // Remove the echo from the capture signal. | 118 // Inform the delay controller of the actually set delay to allow it to |
| 122 echo_remover_->ProcessCapture( | 119 // properly react to a non-feasible delay. |
| 123 delay_controller_->AlignmentHeadroomSamples(), | 120 delay_controller_->SetDelay(achieved_delay); |
| 124 EchoPathVariability(echo_path_gain_change, | 121 |
| 125 old_delay != achieved_delay || | 122 // Remove the echo from the capture signal. |
| 126 old_delay != new_delay || | 123 echo_remover_->ProcessCapture( |
| 127 render_buffer_overrun_occurred_), | 124 delay_controller_->AlignmentHeadroomSamples(), |
| 128 capture_signal_saturation, render_buffer_->GetRenderBuffer(), | 125 EchoPathVariability(echo_path_gain_change, |
| 129 capture_block); | 126 old_delay != achieved_delay || |
| 130 } | 127 old_delay != new_delay || |
| 128 render_buffer_overrun_occurred_), | |
| 129 capture_signal_saturation, render_buffer_->GetRenderBuffer(), | |
| 130 capture_block); | |
| 131 | 131 |
| 132 // Update the metrics. | 132 // Update the metrics. |
| 133 metrics_.UpdateCapture(render_buffer_underrun); | 133 metrics_.UpdateCapture(render_buffer_underrun); |
| 134 | 134 |
| 135 render_buffer_overrun_occurred_ = false; | 135 render_buffer_overrun_occurred_ = false; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void BlockProcessorImpl::BufferRender(std::vector<std::vector<float>>* block) { | 138 void BlockProcessorImpl::BufferRender(std::vector<std::vector<float>>* block) { |
| 139 RTC_DCHECK(block); | 139 RTC_DCHECK(block); |
| 140 RTC_DCHECK_EQ(NumBandsForRate(sample_rate_hz_), block->size()); | 140 RTC_DCHECK_EQ(NumBandsForRate(sample_rate_hz_), block->size()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 int sample_rate_hz, | 194 int sample_rate_hz, |
| 195 std::unique_ptr<RenderDelayBuffer> render_buffer, | 195 std::unique_ptr<RenderDelayBuffer> render_buffer, |
| 196 std::unique_ptr<RenderDelayController> delay_controller, | 196 std::unique_ptr<RenderDelayController> delay_controller, |
| 197 std::unique_ptr<EchoRemover> echo_remover) { | 197 std::unique_ptr<EchoRemover> echo_remover) { |
| 198 return new BlockProcessorImpl(sample_rate_hz, std::move(render_buffer), | 198 return new BlockProcessorImpl(sample_rate_hz, std::move(render_buffer), |
| 199 std::move(delay_controller), | 199 std::move(delay_controller), |
| 200 std::move(echo_remover)); | 200 std::move(echo_remover)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace webrtc | 203 } // namespace webrtc |
| OLD | NEW |