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_elements, DelaySource source) { | |
51 if (moved_elements == 0) | |
52 return; | |
53 switch (source) { | |
54 case DelaySource::kSystemDelay: | |
55 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.AecDelayAdjustmentSystemValue", | |
56 moved_elements, kMinDelayLogValue, | |
57 kMaxDelayLogValue, kNumDelayLogBuckets); | |
58 return; | |
59 case DelaySource::kDelayAgnostic: | |
60 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.AecDelayAdjustmentAgnosticValue", | |
61 moved_elements, kMinDelayLogValue, | |
62 kMaxDelayLogValue, kNumDelayLogBuckets); | |
63 return; | |
64 } | |
peah-webrtc
2016/05/18 08:22:11
Is a default case needed, or is it fine to use lik
hlundin-webrtc
2016/05/18 10:15:44
I believe it is fine. The compiler complains when
| |
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, DelaySource::kSystemDelay); | |
hlundin-webrtc
2016/05/18 08:04:30
What is the unit for moved_elements? Should probab
peah-webrtc
2016/05/18 08:22:11
For moved_elements below, each element corresponds
hlundin-webrtc
2016/05/18 10:15:44
Done.
| |
1788 aec->knownDelay -= moved_elements * PART_LEN; | 1817 aec->knownDelay -= moved_elements * PART_LEN; |
1789 } else { | 1818 } else { |
1790 // 2 b) Apply signal based delay correction. | 1819 // 2 b) Apply signal based delay correction. |
1791 int move_elements = SignalBasedDelayCorrection(aec); | 1820 int move_elements = SignalBasedDelayCorrection(aec); |
1792 int moved_elements = WebRtc_MoveReadPtr(aec->far_time_buf, move_elements); | 1821 int moved_elements = WebRtc_MoveReadPtr(aec->far_time_buf, move_elements); |
1822 MaybeLogDelayAdjustment(moved_elements, DelaySource::kDelayAgnostic); | |
peah-webrtc
2016/05/18 08:22:11
There is also delay adjustments being applied in e
hlundin-webrtc
2016/05/18 10:15:44
Acknowledged. We'll keep that as a separate exerci
| |
1793 int far_near_buffer_diff = | 1823 int far_near_buffer_diff = |
1794 WebRtc_available_read(aec->far_time_buf) - | 1824 WebRtc_available_read(aec->far_time_buf) - |
1795 WebRtc_available_read(aec->nearFrBuf) / PART_LEN; | 1825 WebRtc_available_read(aec->nearFrBuf) / PART_LEN; |
1796 WebRtc_SoftResetDelayEstimator(aec->delay_estimator, moved_elements); | 1826 WebRtc_SoftResetDelayEstimator(aec->delay_estimator, moved_elements); |
1797 WebRtc_SoftResetDelayEstimatorFarend(aec->delay_estimator_farend, | 1827 WebRtc_SoftResetDelayEstimatorFarend(aec->delay_estimator_farend, |
1798 moved_elements); | 1828 moved_elements); |
1799 aec->signal_delay_correction += moved_elements; | 1829 aec->signal_delay_correction += moved_elements; |
1800 // If we rely on reported system delay values only, a buffer underrun here | 1830 // 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 | 1831 // 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 | 1832 // 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 | 1967 |
1938 int WebRtcAec_system_delay(AecCore* self) { | 1968 int WebRtcAec_system_delay(AecCore* self) { |
1939 return self->system_delay; | 1969 return self->system_delay; |
1940 } | 1970 } |
1941 | 1971 |
1942 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1972 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
1943 assert(delay >= 0); | 1973 assert(delay >= 0); |
1944 self->system_delay = delay; | 1974 self->system_delay = delay; |
1945 } | 1975 } |
1946 } // namespace webrtc | 1976 } // namespace webrtc |
OLD | NEW |