Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "webrtc/common_audio/ring_buffer.h" | 26 #include "webrtc/common_audio/ring_buffer.h" |
| 27 } | 27 } |
| 28 #include "webrtc/base/checks.h" | 28 #include "webrtc/base/checks.h" |
| 29 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" | 29 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" |
| 30 #include "webrtc/modules/audio_processing/aec/aec_common.h" | 30 #include "webrtc/modules/audio_processing/aec/aec_common.h" |
| 31 #include "webrtc/modules/audio_processing/aec/aec_core_optimized_methods.h" | 31 #include "webrtc/modules/audio_processing/aec/aec_core_optimized_methods.h" |
| 32 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" | 32 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" |
| 33 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" | 33 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" |
| 34 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" | 34 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" |
| 35 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" | 35 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" |
| 36 #include "webrtc/system_wrappers/include/metrics.h" | |
| 36 #include "webrtc/typedefs.h" | 37 #include "webrtc/typedefs.h" |
| 37 | 38 |
| 38 namespace webrtc { | 39 namespace webrtc { |
| 40 namespace { | |
| 41 enum class DelaySource { | |
| 42 kSystemDelay, // The delay values come from the OS. | |
| 43 kDelayAgnostic, // The delay values come from the DA-AEC. | |
| 44 }; | |
| 45 | |
| 46 constexpr int kMinDelayLogValue = -200; | |
| 47 constexpr int kMaxDelayLogValue = 200; | |
| 48 constexpr int kNumDelayLogBuckets = 100; | |
| 49 | |
| 50 void MaybeLogDelayAdjustment(int moved_ms, DelaySource source) { | |
| 51 if (moved_ms == 0) | |
|
peah-webrtc
2016/05/18 10:54:19
I'd rather put this check when calling the method.
| |
| 52 return; | |
| 53 switch (source) { | |
| 54 case DelaySource::kSystemDelay: | |
| 55 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.AecDelayAdjustmentMsSystemValue", | |
| 56 moved_ms, kMinDelayLogValue, kMaxDelayLogValue, | |
| 57 kNumDelayLogBuckets); | |
| 58 return; | |
| 59 case DelaySource::kDelayAgnostic: | |
| 60 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.AecDelayAdjustmentMsAgnosticValue", | |
| 61 moved_ms, kMinDelayLogValue, kMaxDelayLogValue, | |
| 62 kNumDelayLogBuckets); | |
| 63 return; | |
| 64 } | |
| 65 } | |
| 66 } // namespace | |
| 39 | 67 |
| 40 // Buffer size (samples) | 68 // Buffer size (samples) |
| 41 static const size_t kBufSizePartitions = 250; // 1 second of audio in 16 kHz. | 69 static const size_t kBufSizePartitions = 250; // 1 second of audio in 16 kHz. |
| 42 | 70 |
| 43 // Metrics | 71 // Metrics |
| 44 static const size_t kSubCountLen = 4; | 72 static const size_t kSubCountLen = 4; |
| 45 static const size_t kCountLen = 50; | 73 static const size_t kCountLen = 50; |
| 46 static const int kDelayMetricsAggregationWindow = 1250; // 5 seconds at 16 kHz. | 74 static const int kDelayMetricsAggregationWindow = 1250; // 5 seconds at 16 kHz. |
| 47 | 75 |
| 48 // Divergence metric is based on audio level, which gets updated every | 76 // Divergence metric is based on audio level, which gets updated every |
| (...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1778 | 1806 |
| 1779 // TODO(bjornv): Investigate how we should round the delay difference; | 1807 // TODO(bjornv): Investigate how we should round the delay difference; |
| 1780 // right now we know that incoming |knownDelay| is underestimated when | 1808 // right now we know that incoming |knownDelay| is underestimated when |
| 1781 // it's less than |aec->knownDelay|. We therefore, round (-32) in that | 1809 // it's less than |aec->knownDelay|. We therefore, round (-32) in that |
| 1782 // direction. In the other direction, we don't have this situation, but | 1810 // direction. In the other direction, we don't have this situation, but |
| 1783 // might flush one partition too little. This can cause non-causality, | 1811 // might flush one partition too little. This can cause non-causality, |
| 1784 // which should be investigated. Maybe, allow for a non-symmetric | 1812 // which should be investigated. Maybe, allow for a non-symmetric |
| 1785 // rounding, like -16. | 1813 // rounding, like -16. |
| 1786 int move_elements = (aec->knownDelay - knownDelay - 32) / PART_LEN; | 1814 int move_elements = (aec->knownDelay - knownDelay - 32) / PART_LEN; |
| 1787 int moved_elements = WebRtc_MoveReadPtr(aec->far_time_buf, move_elements); | 1815 int moved_elements = WebRtc_MoveReadPtr(aec->far_time_buf, move_elements); |
| 1816 MaybeLogDelayAdjustment(moved_elements * (aec->sampFreq == 8000 ? 8 : 4), | |
|
peah-webrtc
2016/05/18 10:54:19
I'd rather put the if-statement contained inside t
| |
| 1817 DelaySource::kSystemDelay); | |
| 1788 aec->knownDelay -= moved_elements * PART_LEN; | 1818 aec->knownDelay -= moved_elements * PART_LEN; |
| 1789 } else { | 1819 } else { |
| 1790 // 2 b) Apply signal based delay correction. | 1820 // 2 b) Apply signal based delay correction. |
| 1791 int move_elements = SignalBasedDelayCorrection(aec); | 1821 int move_elements = SignalBasedDelayCorrection(aec); |
| 1792 int moved_elements = WebRtc_MoveReadPtr(aec->far_time_buf, move_elements); | 1822 int moved_elements = WebRtc_MoveReadPtr(aec->far_time_buf, move_elements); |
| 1823 MaybeLogDelayAdjustment(moved_elements * (aec->sampFreq == 8000 ? 8 : 4), | |
| 1824 DelaySource::kDelayAgnostic); | |
| 1793 int far_near_buffer_diff = | 1825 int far_near_buffer_diff = |
| 1794 WebRtc_available_read(aec->far_time_buf) - | 1826 WebRtc_available_read(aec->far_time_buf) - |
| 1795 WebRtc_available_read(aec->nearFrBuf) / PART_LEN; | 1827 WebRtc_available_read(aec->nearFrBuf) / PART_LEN; |
| 1796 WebRtc_SoftResetDelayEstimator(aec->delay_estimator, moved_elements); | 1828 WebRtc_SoftResetDelayEstimator(aec->delay_estimator, moved_elements); |
| 1797 WebRtc_SoftResetDelayEstimatorFarend(aec->delay_estimator_farend, | 1829 WebRtc_SoftResetDelayEstimatorFarend(aec->delay_estimator_farend, |
| 1798 moved_elements); | 1830 moved_elements); |
| 1799 aec->signal_delay_correction += moved_elements; | 1831 aec->signal_delay_correction += moved_elements; |
| 1800 // If we rely on reported system delay values only, a buffer underrun here | 1832 // If we rely on reported system delay values only, a buffer underrun here |
| 1801 // can never occur since we've taken care of that in 1) above. Here, we | 1833 // can never occur since we've taken care of that in 1) above. Here, we |
| 1802 // apply signal based delay correction and can therefore end up with | 1834 // apply signal based delay correction and can therefore end up with |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1937 | 1969 |
| 1938 int WebRtcAec_system_delay(AecCore* self) { | 1970 int WebRtcAec_system_delay(AecCore* self) { |
| 1939 return self->system_delay; | 1971 return self->system_delay; |
| 1940 } | 1972 } |
| 1941 | 1973 |
| 1942 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1974 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
| 1943 assert(delay >= 0); | 1975 assert(delay >= 0); |
| 1944 self->system_delay = delay; | 1976 self->system_delay = delay; |
| 1945 } | 1977 } |
| 1946 } // namespace webrtc | 1978 } // namespace webrtc |
| OLD | NEW |