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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 // 1) The valley is distinct enough (|valley_depth| > |kProbabilityOffset|) | 611 // 1) The valley is distinct enough (|valley_depth| > |kProbabilityOffset|) |
| 612 // and | 612 // and |
| 613 // 2) The depth of the valley is deep enough | 613 // 2) The depth of the valley is deep enough |
| 614 // (|value_best_candidate| < |minimum_probability|) | 614 // (|value_best_candidate| < |minimum_probability|) |
| 615 // and deeper than the best estimate so far | 615 // and deeper than the best estimate so far |
| 616 // (|value_best_candidate| < |last_delay_probability|) | 616 // (|value_best_candidate| < |last_delay_probability|) |
| 617 valid_candidate = ((valley_depth > kProbabilityOffset) && | 617 valid_candidate = ((valley_depth > kProbabilityOffset) && |
| 618 ((value_best_candidate < self->minimum_probability) || | 618 ((value_best_candidate < self->minimum_probability) || |
| 619 (value_best_candidate < self->last_delay_probability))); | 619 (value_best_candidate < self->last_delay_probability))); |
| 620 | 620 |
| 621 UpdateRobustValidationStatistics(self, candidate_delay, valley_depth, | 621 // Check for nonstationary farend signal. |
| 622 value_best_candidate); | 622 bool non_stationary_farend = false; |
|
hlundin-webrtc
2016/05/11 12:39:48
You are traversing the array from end to beginning
peah-webrtc
2016/05/11 12:53:33
Wow! That was great!! And works splendidly. Thanks
| |
| 623 for (i = self->history_size - 1; i >= 0; --i) { | |
| 624 if (self->farend->far_bit_counts[i] > 0) { | |
| 625 non_stationary_farend = true; | |
| 626 break; | |
| 627 } | |
| 628 } | |
| 629 | |
| 630 if (non_stationary_farend) { | |
| 631 // Only update the validation statistics when the farend is nonstationary | |
| 632 // as the underlying estimates are otherwise freezed. | |
|
hlundin-webrtc
2016/05/11 12:39:48
frozen
peah-webrtc
2016/05/11 12:53:33
Done.
| |
| 633 UpdateRobustValidationStatistics(self, candidate_delay, valley_depth, | |
| 634 value_best_candidate); | |
| 635 } | |
| 636 | |
| 623 if (self->robust_validation_enabled) { | 637 if (self->robust_validation_enabled) { |
| 624 int is_histogram_valid = HistogramBasedValidation(self, candidate_delay); | 638 int is_histogram_valid = HistogramBasedValidation(self, candidate_delay); |
| 625 valid_candidate = RobustValidation(self, candidate_delay, valid_candidate, | 639 valid_candidate = RobustValidation(self, candidate_delay, valid_candidate, |
| 626 is_histogram_valid); | 640 is_histogram_valid); |
| 627 | 641 |
| 628 } | 642 } |
| 629 if (valid_candidate) { | 643 |
| 644 // Only update the delay estimate when the farend is nonstationary and when | |
| 645 // a valid delay candidate is available. | |
| 646 if (non_stationary_farend && valid_candidate) { | |
| 630 if (candidate_delay != self->last_delay) { | 647 if (candidate_delay != self->last_delay) { |
| 631 self->last_delay_histogram = | 648 self->last_delay_histogram = |
| 632 (self->histogram[candidate_delay] > kLastHistogramMax ? | 649 (self->histogram[candidate_delay] > kLastHistogramMax ? |
| 633 kLastHistogramMax : self->histogram[candidate_delay]); | 650 kLastHistogramMax : self->histogram[candidate_delay]); |
| 634 // Adjust the histogram if we made a change to |last_delay|, though it was | 651 // Adjust the histogram if we made a change to |last_delay|, though it was |
| 635 // not the most likely one according to the histogram. | 652 // not the most likely one according to the histogram. |
| 636 if (self->histogram[candidate_delay] < | 653 if (self->histogram[candidate_delay] < |
| 637 self->histogram[self->compare_delay]) { | 654 self->histogram[self->compare_delay]) { |
| 638 self->histogram[self->compare_delay] = self->histogram[candidate_delay]; | 655 self->histogram[self->compare_delay] = self->histogram[candidate_delay]; |
| 639 } | 656 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 int32_t diff = new_value - *mean_value; | 695 int32_t diff = new_value - *mean_value; |
| 679 | 696 |
| 680 // mean_new = mean_value + ((new_value - mean_value) >> factor); | 697 // mean_new = mean_value + ((new_value - mean_value) >> factor); |
| 681 if (diff < 0) { | 698 if (diff < 0) { |
| 682 diff = -((-diff) >> factor); | 699 diff = -((-diff) >> factor); |
| 683 } else { | 700 } else { |
| 684 diff = (diff >> factor); | 701 diff = (diff >> factor); |
| 685 } | 702 } |
| 686 *mean_value += diff; | 703 *mean_value += diff; |
| 687 } | 704 } |
| OLD | NEW |