Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: webrtc/modules/audio_processing/aec/aec_core.cc

Issue 1842003003: Removed unused code and simplified the code for the AEC metrics (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 level->minlevel = new_frame_level; // New minimum. 583 level->minlevel = new_frame_level; // New minimum.
584 } else { 584 } else {
585 level->minlevel *= (1 + 0.001f); // Small increase. 585 level->minlevel *= (1 + 0.001f); // Small increase.
586 } 586 }
587 } 587 }
588 level->averagelevel.AddValue(new_frame_level); 588 level->averagelevel.AddValue(new_frame_level);
589 } 589 }
590 } 590 }
591 591
592 static void UpdateMetrics(AecCore* aec) { 592 static void UpdateMetrics(AecCore* aec) {
593 float dtmp, dtmp2; 593 float dtmp;
594 594
595 const float actThresholdNoisy = 8.0f; 595 const float actThresholdNoisy = 8.0f;
596 const float actThresholdClean = 40.0f; 596 const float actThresholdClean = 40.0f;
597 const float safety = 0.99995f; 597 const float safety = 0.99995f;
598 598
599 const float noisyPower = 300000.0f; 599 const float noisyPower = 300000.0f;
600 600
601 float actThreshold; 601 float actThreshold;
602 float echo, suppressedEcho; 602 float echo, suppressedEcho;
603 603
(...skipping 18 matching lines...) Expand all
622 622
623 const float near_average_level = 623 const float near_average_level =
624 aec->nearlevel.averagelevel.GetLatestMean(); 624 aec->nearlevel.averagelevel.GetLatestMean();
625 625
626 // Subtract noise power 626 // Subtract noise power
627 echo = near_average_level - safety * aec->nearlevel.minlevel; 627 echo = near_average_level - safety * aec->nearlevel.minlevel;
628 628
629 // ERL 629 // ERL
630 dtmp = 10 * static_cast<float>(log10(far_average_level / 630 dtmp = 10 * static_cast<float>(log10(far_average_level /
631 near_average_level + 1e-10f)); 631 near_average_level + 1e-10f));
632 dtmp2 = 10 * static_cast<float>(log10(far_average_level / echo + 1e-10f));
633 632
634 aec->erl.instant = dtmp; 633 aec->erl.instant = dtmp;
635 if (dtmp > aec->erl.max) { 634 if (dtmp > aec->erl.max) {
636 aec->erl.max = dtmp; 635 aec->erl.max = dtmp;
637 } 636 }
638 637
639 if (dtmp < aec->erl.min) { 638 if (dtmp < aec->erl.min) {
640 aec->erl.min = dtmp; 639 aec->erl.min = dtmp;
641 } 640 }
642 641
(...skipping 11 matching lines...) Expand all
654 // A_NLP 653 // A_NLP
655 const float linout_average_level = 654 const float linout_average_level =
656 aec->linoutlevel.averagelevel.GetLatestMean(); 655 aec->linoutlevel.averagelevel.GetLatestMean();
657 dtmp = 10 * static_cast<float>(log10(near_average_level / 656 dtmp = 10 * static_cast<float>(log10(near_average_level /
658 linout_average_level + 1e-10f)); 657 linout_average_level + 1e-10f));
659 658
660 // subtract noise power 659 // subtract noise power
661 suppressedEcho = 660 suppressedEcho =
662 linout_average_level - safety * aec->linoutlevel.minlevel; 661 linout_average_level - safety * aec->linoutlevel.minlevel;
663 662
664 dtmp2 = 10 * static_cast<float>(log10(echo / suppressedEcho + 1e-10f)); 663 aec->aNlp.instant =
664 10 * static_cast<float>(log10(echo / suppressedEcho + 1e-10f));
665 665
666 aec->aNlp.instant = dtmp2;
667 if (dtmp > aec->aNlp.max) { 666 if (dtmp > aec->aNlp.max) {
668 aec->aNlp.max = dtmp; 667 aec->aNlp.max = dtmp;
669 } 668 }
670 669
671 if (dtmp < aec->aNlp.min) { 670 if (dtmp < aec->aNlp.min) {
672 aec->aNlp.min = dtmp; 671 aec->aNlp.min = dtmp;
673 } 672 }
674 673
675 aec->aNlp.counter++; 674 aec->aNlp.counter++;
676 aec->aNlp.sum += dtmp; 675 aec->aNlp.sum += dtmp;
677 aec->aNlp.average = aec->aNlp.sum / aec->aNlp.counter; 676 aec->aNlp.average = aec->aNlp.sum / aec->aNlp.counter;
678 677
679 // Upper mean 678 // Upper mean
680 if (dtmp > aec->aNlp.average) { 679 if (dtmp > aec->aNlp.average) {
681 aec->aNlp.hicounter++; 680 aec->aNlp.hicounter++;
682 aec->aNlp.hisum += dtmp; 681 aec->aNlp.hisum += dtmp;
683 aec->aNlp.himean = aec->aNlp.hisum / aec->aNlp.hicounter; 682 aec->aNlp.himean = aec->aNlp.hisum / aec->aNlp.hicounter;
684 } 683 }
685 684
686 // ERLE 685 // ERLE
687 const float nlpout_average_level = 686 const float nlpout_average_level =
688 aec->nlpoutlevel.averagelevel.GetLatestMean(); 687 aec->nlpoutlevel.averagelevel.GetLatestMean();
689 // subtract noise power 688 // subtract noise power
690 suppressedEcho = 689 suppressedEcho =
691 nlpout_average_level - safety * aec->nlpoutlevel.minlevel; 690 nlpout_average_level - safety * aec->nlpoutlevel.minlevel;
691 dtmp = 10 * static_cast<float>(log10(echo / suppressedEcho + 1e-10f));
692 692
693 dtmp = 10 * static_cast<float>(log10(near_average_level /
694 nlpout_average_level + 1e-10f));
695 dtmp2 = 10 * static_cast<float>(log10(echo / suppressedEcho + 1e-10f));
696
697 dtmp = dtmp2;
698 aec->erle.instant = dtmp; 693 aec->erle.instant = dtmp;
699 if (dtmp > aec->erle.max) { 694 if (dtmp > aec->erle.max) {
700 aec->erle.max = dtmp; 695 aec->erle.max = dtmp;
701 } 696 }
702 697
703 if (dtmp < aec->erle.min) { 698 if (dtmp < aec->erle.min) {
704 aec->erle.min = dtmp; 699 aec->erle.min = dtmp;
705 } 700 }
706 701
707 aec->erle.counter++; 702 aec->erle.counter++;
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 1887
1893 int WebRtcAec_system_delay(AecCore* self) { 1888 int WebRtcAec_system_delay(AecCore* self) {
1894 return self->system_delay; 1889 return self->system_delay;
1895 } 1890 }
1896 1891
1897 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { 1892 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) {
1898 assert(delay >= 0); 1893 assert(delay >= 0);
1899 self->system_delay = delay; 1894 self->system_delay = delay;
1900 } 1895 }
1901 } // namespace webrtc 1896 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698