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 29 matching lines...) Expand all Loading... | |
40 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" | 40 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" |
41 #include "webrtc/typedefs.h" | 41 #include "webrtc/typedefs.h" |
42 | 42 |
43 // Buffer size (samples) | 43 // Buffer size (samples) |
44 static const size_t kBufSizePartitions = 250; // 1 second of audio in 16 kHz. | 44 static const size_t kBufSizePartitions = 250; // 1 second of audio in 16 kHz. |
45 | 45 |
46 // Metrics | 46 // Metrics |
47 static const int subCountLen = 4; | 47 static const int subCountLen = 4; |
48 static const int countLen = 50; | 48 static const int countLen = 50; |
49 static const int kDelayMetricsAggregationWindow = 1250; // 5 seconds at 16 kHz. | 49 static const int kDelayMetricsAggregationWindow = 1250; // 5 seconds at 16 kHz. |
50 | 50 |
tlegrand-webrtc
2016/03/02 15:30:29
I'm wondering if "Diverge" is the right term, or i
kwiberg-webrtc
2016/03/02 18:33:03
I believe "Divergent" is the trendy form.
| |
51 // Diverge metric is based on audio level, which gets updated which every | |
tlegrand-webrtc
2016/03/02 15:30:29
remove "which" in "which every"
| |
52 // |subCountLen + 1| * 10 milliseconds. Diverge metric takes the statistics of | |
53 // |kDivergeMetricAggregationWindow| samples. | |
54 static const int kDivergeMetricAggregationWindow = 50; // 1 seconds at 16 kHz. | |
55 | |
51 // Quantities to control H band scaling for SWB input | 56 // Quantities to control H band scaling for SWB input |
52 static const float cnScaleHband = 0.4f; // scale for comfort noise in H band. | 57 static const float cnScaleHband = 0.4f; // scale for comfort noise in H band. |
53 // Initial bin for averaging nlp gain in low band | 58 // Initial bin for averaging nlp gain in low band |
54 static const int freqAvgIc = PART_LEN / 2; | 59 static const int freqAvgIc = PART_LEN / 2; |
55 | 60 |
56 // Matlab code to produce table: | 61 // Matlab code to produce table: |
57 // win = sqrt(hanning(63)); win = [0 ; win(1:32)]; | 62 // win = sqrt(hanning(63)); win = [0 ; win(1:32)]; |
58 // fprintf(1, '\t%.14f, %.14f, %.14f,\n', win); | 63 // fprintf(1, '\t%.14f, %.14f, %.14f,\n', win); |
59 ALIGN16_BEG const float ALIGN16_END WebRtcAec_sqrtHanning[65] = { | 64 ALIGN16_BEG const float ALIGN16_END WebRtcAec_sqrtHanning[65] = { |
60 0.00000000000000f, 0.02454122852291f, 0.04906767432742f, 0.07356456359967f, | 65 0.00000000000000f, 0.02454122852291f, 0.04906767432742f, 0.07356456359967f, |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 self->stateCounter = 0; | 552 self->stateCounter = 0; |
548 InitLevel(&self->farlevel); | 553 InitLevel(&self->farlevel); |
549 InitLevel(&self->nearlevel); | 554 InitLevel(&self->nearlevel); |
550 InitLevel(&self->linoutlevel); | 555 InitLevel(&self->linoutlevel); |
551 InitLevel(&self->nlpoutlevel); | 556 InitLevel(&self->nlpoutlevel); |
552 | 557 |
553 InitStats(&self->erl); | 558 InitStats(&self->erl); |
554 InitStats(&self->erle); | 559 InitStats(&self->erle); |
555 InitStats(&self->aNlp); | 560 InitStats(&self->aNlp); |
556 InitStats(&self->rerl); | 561 InitStats(&self->rerl); |
562 | |
563 self->num_diverge_values = 0; | |
564 self->num_filter_diverge = 0; | |
565 self->fraction_filter_diverge = 0.0f; | |
557 } | 566 } |
558 | 567 |
559 static float CalculatePower(const float* in, size_t num_samples) { | 568 static float CalculatePower(const float* in, size_t num_samples) { |
560 size_t k; | 569 size_t k; |
561 float energy = 0.0f; | 570 float energy = 0.0f; |
562 | 571 |
563 for (k = 0; k < num_samples; ++k) { | 572 for (k = 0; k < num_samples; ++k) { |
564 energy += in[k] * in[k]; | 573 energy += in[k] * in[k]; |
565 } | 574 } |
566 return energy / num_samples; | 575 return energy / num_samples; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 // a per-sample energy (i.e., power). | 613 // a per-sample energy (i.e., power). |
605 const float noisyPower = 300000.0f * 2.0f / PART_LEN2; | 614 const float noisyPower = 300000.0f * 2.0f / PART_LEN2; |
606 | 615 |
607 float actThreshold; | 616 float actThreshold; |
608 float echo, suppressedEcho; | 617 float echo, suppressedEcho; |
609 | 618 |
610 if (aec->echoState) { // Check if echo is likely present | 619 if (aec->echoState) { // Check if echo is likely present |
611 aec->stateCounter++; | 620 aec->stateCounter++; |
612 } | 621 } |
613 | 622 |
623 if (aec->linoutlevel.sfrcounter == 0) { | |
624 // We count a filter divergence when the audio level of linear filter output | |
625 // is larger than that of near-end signal by -30dB or more. | |
peah-webrtc
2016/02/29 14:05:56
I don't think the usage of "-30dB" is correct. I t
| |
626 if (aec->linoutlevel.framelevel > 1.001 * aec->nearlevel.framelevel) | |
627 aec->num_filter_diverge++; | |
628 aec->num_diverge_values++; | |
629 if (aec->num_diverge_values >= kDivergeMetricAggregationWindow) { | |
630 aec->fraction_filter_diverge = | |
631 static_cast<float>(aec->num_filter_diverge) / aec->num_diverge_values; | |
632 aec->num_diverge_values = 0; | |
633 aec->num_filter_diverge = 0; | |
634 } | |
635 } | |
636 | |
614 if (aec->farlevel.frcounter == 0) { | 637 if (aec->farlevel.frcounter == 0) { |
615 if (aec->farlevel.minlevel < noisyPower) { | 638 if (aec->farlevel.minlevel < noisyPower) { |
616 actThreshold = actThresholdClean; | 639 actThreshold = actThresholdClean; |
617 } else { | 640 } else { |
618 actThreshold = actThresholdNoisy; | 641 actThreshold = actThresholdNoisy; |
619 } | 642 } |
620 | 643 |
621 if ((aec->stateCounter > (0.5f * countLen * subCountLen)) && | 644 if ((aec->stateCounter > (0.5f * countLen * subCountLen)) && |
622 (aec->farlevel.sfrcounter == 0) | 645 (aec->farlevel.sfrcounter == 0) |
623 | 646 |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1904 } | 1927 } |
1905 | 1928 |
1906 int WebRtcAec_system_delay(AecCore* self) { | 1929 int WebRtcAec_system_delay(AecCore* self) { |
1907 return self->system_delay; | 1930 return self->system_delay; |
1908 } | 1931 } |
1909 | 1932 |
1910 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1933 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
1911 assert(delay >= 0); | 1934 assert(delay >= 0); |
1912 self->system_delay = delay; | 1935 self->system_delay = delay; |
1913 } | 1936 } |
OLD | NEW |