| 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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = 2 * (aec->nlpoutlevel.averagelevel - | 692 suppressedEcho = 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 (2 * aec->nlpoutlevel.averagelevel) + | 696 aec->nlpoutlevel.averagelevel + 1e-10f)); |
| 697 1e-10f)); | |
| 698 dtmp2 = 10 * static_cast<float>(log10(echo / suppressedEcho + 1e-10f)); | 697 dtmp2 = 10 * static_cast<float>(log10(echo / suppressedEcho + 1e-10f)); |
| 699 | 698 |
| 700 dtmp = dtmp2; | 699 dtmp = dtmp2; |
| 701 aec->erle.instant = dtmp; | 700 aec->erle.instant = dtmp; |
| 702 if (dtmp > aec->erle.max) { | 701 if (dtmp > aec->erle.max) { |
| 703 aec->erle.max = dtmp; | 702 aec->erle.max = dtmp; |
| 704 } | 703 } |
| 705 | 704 |
| 706 if (dtmp < aec->erle.min) { | 705 if (dtmp < aec->erle.min) { |
| 707 aec->erle.min = dtmp; | 706 aec->erle.min = dtmp; |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 } | 1131 } |
| 1133 | 1132 |
| 1134 WebRtcAec_OverdriveAndSuppress(aec, hNl, hNlFb, efw); | 1133 WebRtcAec_OverdriveAndSuppress(aec, hNl, hNlFb, efw); |
| 1135 | 1134 |
| 1136 // Add comfort noise. | 1135 // Add comfort noise. |
| 1137 WebRtcAec_ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl); | 1136 WebRtcAec_ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl); |
| 1138 | 1137 |
| 1139 // Inverse error fft. | 1138 // Inverse error fft. |
| 1140 ScaledInverseFft(efw, fft, 2.0f, 1); | 1139 ScaledInverseFft(efw, fft, 2.0f, 1); |
| 1141 | 1140 |
| 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 | |
| 1152 // Overlap and add to obtain output. | 1141 // Overlap and add to obtain output. |
| 1153 for (i = 0; i < PART_LEN; i++) { | 1142 for (i = 0; i < PART_LEN; i++) { |
| 1154 output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] + | 1143 output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] + |
| 1155 aec->outBuf[i] * WebRtcAec_sqrtHanning[PART_LEN - i]); | 1144 aec->outBuf[i] * WebRtcAec_sqrtHanning[PART_LEN - i]); |
| 1156 | 1145 |
| 1157 // Saturate output to keep it in the allowed range. | 1146 // Saturate output to keep it in the allowed range. |
| 1158 output[i] = | 1147 output[i] = |
| 1159 WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, output[i], WEBRTC_SPL_WORD16_MIN); | 1148 WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, output[i], WEBRTC_SPL_WORD16_MIN); |
| 1160 } | 1149 } |
| 1161 memcpy(aec->outBuf, &fft[PART_LEN], PART_LEN * sizeof(aec->outBuf[0])); | 1150 memcpy(aec->outBuf, &fft[PART_LEN], PART_LEN * sizeof(aec->outBuf[0])); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 | 1340 |
| 1352 if (aec->metricsMode == 1) { | 1341 if (aec->metricsMode == 1) { |
| 1353 UpdateLevel(&aec->linoutlevel, | 1342 UpdateLevel(&aec->linoutlevel, |
| 1354 CalculatePower(echo_subtractor_output, PART_LEN)); | 1343 CalculatePower(echo_subtractor_output, PART_LEN)); |
| 1355 } | 1344 } |
| 1356 | 1345 |
| 1357 // Perform echo suppression. | 1346 // Perform echo suppression. |
| 1358 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); | 1347 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); |
| 1359 | 1348 |
| 1360 if (aec->metricsMode == 1) { | 1349 if (aec->metricsMode == 1) { |
| 1350 UpdateLevel(&aec->nlpoutlevel, CalculatePower(output, PART_LEN)); |
| 1361 UpdateMetrics(aec); | 1351 UpdateMetrics(aec); |
| 1362 } | 1352 } |
| 1363 | 1353 |
| 1364 // Store the output block. | 1354 // Store the output block. |
| 1365 WebRtc_WriteBuffer(aec->outFrBuf, output, PART_LEN); | 1355 WebRtc_WriteBuffer(aec->outFrBuf, output, PART_LEN); |
| 1366 // For high bands | 1356 // For high bands |
| 1367 for (i = 0; i < aec->num_bands - 1; ++i) { | 1357 for (i = 0; i < aec->num_bands - 1; ++i) { |
| 1368 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); | 1358 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); |
| 1369 } | 1359 } |
| 1370 | 1360 |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 } | 1894 } |
| 1905 | 1895 |
| 1906 int WebRtcAec_system_delay(AecCore* self) { | 1896 int WebRtcAec_system_delay(AecCore* self) { |
| 1907 return self->system_delay; | 1897 return self->system_delay; |
| 1908 } | 1898 } |
| 1909 | 1899 |
| 1910 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1900 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
| 1911 assert(delay >= 0); | 1901 assert(delay >= 0); |
| 1912 self->system_delay = delay; | 1902 self->system_delay = delay; |
| 1913 } | 1903 } |
| OLD | NEW |