| 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 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1610 return -1; | 1610 return -1; |
| 1611 } | 1611 } |
| 1612 aec->delay_logging_enabled = 0; | 1612 aec->delay_logging_enabled = 0; |
| 1613 aec->delay_metrics_delivered = 0; | 1613 aec->delay_metrics_delivered = 0; |
| 1614 memset(aec->delay_histogram, 0, sizeof(aec->delay_histogram)); | 1614 memset(aec->delay_histogram, 0, sizeof(aec->delay_histogram)); |
| 1615 aec->num_delay_values = 0; | 1615 aec->num_delay_values = 0; |
| 1616 aec->delay_median = -1; | 1616 aec->delay_median = -1; |
| 1617 aec->delay_std = -1; | 1617 aec->delay_std = -1; |
| 1618 aec->fraction_poor_delays = -1.0f; | 1618 aec->fraction_poor_delays = -1.0f; |
| 1619 | 1619 |
| 1620 aec->signal_delay_correction = 0; | |
| 1621 aec->previous_delay = -2; // (-2): Uninitialized. | 1620 aec->previous_delay = -2; // (-2): Uninitialized. |
| 1622 aec->delay_correction_count = 0; | 1621 aec->delay_correction_count = 0; |
| 1623 aec->shift_offset = kInitialShiftOffset; | 1622 aec->shift_offset = kInitialShiftOffset; |
| 1624 aec->delay_quality_threshold = kDelayQualityThresholdMin; | 1623 aec->delay_quality_threshold = kDelayQualityThresholdMin; |
| 1625 | 1624 |
| 1626 aec->num_partitions = kNormalNumPartitions; | 1625 aec->num_partitions = kNormalNumPartitions; |
| 1627 | 1626 |
| 1628 // Update the delay estimator with filter length. We use half the | 1627 // Update the delay estimator with filter length. We use half the |
| 1629 // |num_partitions| to take the echo path into account. In practice we say | 1628 // |num_partitions| to take the echo path into account. In practice we say |
| 1630 // that the echo has a duration of maximum half |num_partitions|, which is not | 1629 // that the echo has a duration of maximum half |num_partitions|, which is not |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 int move_elements = SignalBasedDelayCorrection(aec); | 1875 int move_elements = SignalBasedDelayCorrection(aec); |
| 1877 int moved_elements = aec->farend_block_buffer_.AdjustSize(move_elements); | 1876 int moved_elements = aec->farend_block_buffer_.AdjustSize(move_elements); |
| 1878 MaybeLogDelayAdjustment(moved_elements * (aec->sampFreq == 8000 ? 8 : 4), | 1877 MaybeLogDelayAdjustment(moved_elements * (aec->sampFreq == 8000 ? 8 : 4), |
| 1879 DelaySource::kDelayAgnostic); | 1878 DelaySource::kDelayAgnostic); |
| 1880 int far_near_buffer_diff = | 1879 int far_near_buffer_diff = |
| 1881 aec->farend_block_buffer_.Size() - | 1880 aec->farend_block_buffer_.Size() - |
| 1882 (aec->nearend_buffer_size + FRAME_LEN) / PART_LEN; | 1881 (aec->nearend_buffer_size + FRAME_LEN) / PART_LEN; |
| 1883 WebRtc_SoftResetDelayEstimator(aec->delay_estimator, moved_elements); | 1882 WebRtc_SoftResetDelayEstimator(aec->delay_estimator, moved_elements); |
| 1884 WebRtc_SoftResetDelayEstimatorFarend(aec->delay_estimator_farend, | 1883 WebRtc_SoftResetDelayEstimatorFarend(aec->delay_estimator_farend, |
| 1885 moved_elements); | 1884 moved_elements); |
| 1886 aec->signal_delay_correction += moved_elements; | |
| 1887 // If we rely on reported system delay values only, a buffer underrun here | 1885 // If we rely on reported system delay values only, a buffer underrun here |
| 1888 // can never occur since we've taken care of that in 1) above. Here, we | 1886 // can never occur since we've taken care of that in 1) above. Here, we |
| 1889 // apply signal based delay correction and can therefore end up with | 1887 // apply signal based delay correction and can therefore end up with |
| 1890 // buffer underruns since the delay estimation can be wrong. We therefore | 1888 // buffer underruns since the delay estimation can be wrong. We therefore |
| 1891 // stuff the buffer with enough elements if needed. | 1889 // stuff the buffer with enough elements if needed. |
| 1892 if (far_near_buffer_diff < 0) { | 1890 if (far_near_buffer_diff < 0) { |
| 1893 WebRtcAec_AdjustFarendBufferSizeAndSystemDelay(aec, | 1891 WebRtcAec_AdjustFarendBufferSizeAndSystemDelay(aec, |
| 1894 far_near_buffer_diff); | 1892 far_near_buffer_diff); |
| 1895 } | 1893 } |
| 1896 } | 1894 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2048 | 2046 |
| 2049 int WebRtcAec_system_delay(AecCore* self) { | 2047 int WebRtcAec_system_delay(AecCore* self) { |
| 2050 return self->system_delay; | 2048 return self->system_delay; |
| 2051 } | 2049 } |
| 2052 | 2050 |
| 2053 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 2051 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
| 2054 RTC_DCHECK_GE(delay, 0); | 2052 RTC_DCHECK_GE(delay, 0); |
| 2055 self->system_delay = delay; | 2053 self->system_delay = delay; |
| 2056 } | 2054 } |
| 2057 } // namespace webrtc | 2055 } // namespace webrtc |
| OLD | NEW |