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

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

Issue 1747883002: Revert "Calculating ERLE in AEC more properly." (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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 | webrtc/modules/audio_processing/test/audio_processing_unittest.cc » ('j') | 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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 // Upper mean 682 // Upper mean
683 if (dtmp > aec->aNlp.average) { 683 if (dtmp > aec->aNlp.average) {
684 aec->aNlp.hicounter++; 684 aec->aNlp.hicounter++;
685 aec->aNlp.hisum += dtmp; 685 aec->aNlp.hisum += dtmp;
686 aec->aNlp.himean = aec->aNlp.hisum / aec->aNlp.hicounter; 686 aec->aNlp.himean = aec->aNlp.hisum / aec->aNlp.hicounter;
687 } 687 }
688 688
689 // ERLE 689 // ERLE
690 690
691 // subtract noise power 691 // subtract noise power
692 suppressedEcho = aec->nlpoutlevel.averagelevel - 692 suppressedEcho = 2 * (aec->nlpoutlevel.averagelevel -
693 safety * aec->nlpoutlevel.minlevel; 693 safety * aec->nlpoutlevel.minlevel);
694 694
695 dtmp = 10 * static_cast<float>(log10(aec->nearlevel.averagelevel / 695 dtmp = 10 * static_cast<float>(log10(aec->nearlevel.averagelevel /
696 aec->nlpoutlevel.averagelevel + 1e-10f)); 696 (2 * aec->nlpoutlevel.averagelevel) +
697 1e-10f));
697 dtmp2 = 10 * static_cast<float>(log10(echo / suppressedEcho + 1e-10f)); 698 dtmp2 = 10 * static_cast<float>(log10(echo / suppressedEcho + 1e-10f));
698 699
699 dtmp = dtmp2; 700 dtmp = dtmp2;
700 aec->erle.instant = dtmp; 701 aec->erle.instant = dtmp;
701 if (dtmp > aec->erle.max) { 702 if (dtmp > aec->erle.max) {
702 aec->erle.max = dtmp; 703 aec->erle.max = dtmp;
703 } 704 }
704 705
705 if (dtmp < aec->erle.min) { 706 if (dtmp < aec->erle.min) {
706 aec->erle.min = dtmp; 707 aec->erle.min = dtmp;
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 } 1132 }
1132 1133
1133 WebRtcAec_OverdriveAndSuppress(aec, hNl, hNlFb, efw); 1134 WebRtcAec_OverdriveAndSuppress(aec, hNl, hNlFb, efw);
1134 1135
1135 // Add comfort noise. 1136 // Add comfort noise.
1136 WebRtcAec_ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl); 1137 WebRtcAec_ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl);
1137 1138
1138 // Inverse error fft. 1139 // Inverse error fft.
1139 ScaledInverseFft(efw, fft, 2.0f, 1); 1140 ScaledInverseFft(efw, fft, 2.0f, 1);
1140 1141
1142 // TODO(bjornv): Investigate how to take the windowing below into account if
1143 // needed.
1144 if (aec->metricsMode == 1) {
1145 // Note that we have a scaling by two in the time domain |eBuf|.
1146 // In addition the time domain signal is windowed before transformation,
1147 // losing half the energy on the average. We take care of the first
1148 // scaling only in UpdateMetrics().
1149 UpdateLevel(&aec->nlpoutlevel, CalculatePower(fft, PART_LEN2));
1150 }
1151
1141 // Overlap and add to obtain output. 1152 // Overlap and add to obtain output.
1142 for (i = 0; i < PART_LEN; i++) { 1153 for (i = 0; i < PART_LEN; i++) {
1143 output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] + 1154 output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] +
1144 aec->outBuf[i] * WebRtcAec_sqrtHanning[PART_LEN - i]); 1155 aec->outBuf[i] * WebRtcAec_sqrtHanning[PART_LEN - i]);
1145 1156
1146 // Saturate output to keep it in the allowed range. 1157 // Saturate output to keep it in the allowed range.
1147 output[i] = 1158 output[i] =
1148 WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, output[i], WEBRTC_SPL_WORD16_MIN); 1159 WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, output[i], WEBRTC_SPL_WORD16_MIN);
1149 } 1160 }
1150 memcpy(aec->outBuf, &fft[PART_LEN], PART_LEN * sizeof(aec->outBuf[0])); 1161 memcpy(aec->outBuf, &fft[PART_LEN], PART_LEN * sizeof(aec->outBuf[0]));
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 1351
1341 if (aec->metricsMode == 1) { 1352 if (aec->metricsMode == 1) {
1342 UpdateLevel(&aec->linoutlevel, 1353 UpdateLevel(&aec->linoutlevel,
1343 CalculatePower(echo_subtractor_output, PART_LEN)); 1354 CalculatePower(echo_subtractor_output, PART_LEN));
1344 } 1355 }
1345 1356
1346 // Perform echo suppression. 1357 // Perform echo suppression.
1347 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); 1358 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr);
1348 1359
1349 if (aec->metricsMode == 1) { 1360 if (aec->metricsMode == 1) {
1350 UpdateLevel(&aec->nlpoutlevel, CalculatePower(output, PART_LEN));
1351 UpdateMetrics(aec); 1361 UpdateMetrics(aec);
1352 } 1362 }
1353 1363
1354 // Store the output block. 1364 // Store the output block.
1355 WebRtc_WriteBuffer(aec->outFrBuf, output, PART_LEN); 1365 WebRtc_WriteBuffer(aec->outFrBuf, output, PART_LEN);
1356 // For high bands 1366 // For high bands
1357 for (i = 0; i < aec->num_bands - 1; ++i) { 1367 for (i = 0; i < aec->num_bands - 1; ++i) {
1358 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); 1368 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN);
1359 } 1369 }
1360 1370
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 } 1904 }
1895 1905
1896 int WebRtcAec_system_delay(AecCore* self) { 1906 int WebRtcAec_system_delay(AecCore* self) {
1897 return self->system_delay; 1907 return self->system_delay;
1898 } 1908 }
1899 1909
1900 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { 1910 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) {
1901 assert(delay >= 0); 1911 assert(delay >= 0);
1902 self->system_delay = delay; 1912 self->system_delay = delay;
1903 } 1913 }
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/test/audio_processing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698