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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 for (i = 0; i < kHistorySizeBlocks; i++) { | 813 for (i = 0; i < kHistorySizeBlocks; i++) { |
814 l1_norm += abs(i - median) * self->delay_histogram[i]; | 814 l1_norm += abs(i - median) * self->delay_histogram[i]; |
815 } | 815 } |
816 self->delay_std = (int)((l1_norm + self->num_delay_values / 2) / | 816 self->delay_std = (int)((l1_norm + self->num_delay_values / 2) / |
817 self->num_delay_values) * kMsPerBlock; | 817 self->num_delay_values) * kMsPerBlock; |
818 | 818 |
819 // Determine fraction of delays that are out of bounds, that is, either | 819 // Determine fraction of delays that are out of bounds, that is, either |
820 // negative (anti-causal system) or larger than the AEC filter length. | 820 // negative (anti-causal system) or larger than the AEC filter length. |
821 { | 821 { |
822 int num_delays_out_of_bounds = self->num_delay_values; | 822 int num_delays_out_of_bounds = self->num_delay_values; |
| 823 const int histogram_length = sizeof(self->delay_histogram) / |
| 824 sizeof(self->delay_histogram[0]); |
823 for (i = lookahead; i < lookahead + self->num_partitions; ++i) { | 825 for (i = lookahead; i < lookahead + self->num_partitions; ++i) { |
824 num_delays_out_of_bounds -= self->delay_histogram[i]; | 826 if (i < histogram_length) |
| 827 num_delays_out_of_bounds -= self->delay_histogram[i]; |
825 } | 828 } |
826 self->fraction_poor_delays = (float)num_delays_out_of_bounds / | 829 self->fraction_poor_delays = (float)num_delays_out_of_bounds / |
827 self->num_delay_values; | 830 self->num_delay_values; |
828 } | 831 } |
829 | 832 |
830 // Reset histogram. | 833 // Reset histogram. |
831 memset(self->delay_histogram, 0, sizeof(self->delay_histogram)); | 834 memset(self->delay_histogram, 0, sizeof(self->delay_histogram)); |
832 self->num_delay_values = 0; | 835 self->num_delay_values = 0; |
833 | 836 |
834 return; | 837 return; |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 int WebRtcAec_extended_filter_enabled(AecCore* self) { | 1920 int WebRtcAec_extended_filter_enabled(AecCore* self) { |
1918 return self->extended_filter_enabled; | 1921 return self->extended_filter_enabled; |
1919 } | 1922 } |
1920 | 1923 |
1921 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } | 1924 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } |
1922 | 1925 |
1923 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1926 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
1924 assert(delay >= 0); | 1927 assert(delay >= 0); |
1925 self->system_delay = delay; | 1928 self->system_delay = delay; |
1926 } | 1929 } |
OLD | NEW |