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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 // Upper mean | 691 // Upper mean |
692 if (dtmp > aec->aNlp.average) { | 692 if (dtmp > aec->aNlp.average) { |
693 aec->aNlp.hicounter++; | 693 aec->aNlp.hicounter++; |
694 aec->aNlp.hisum += dtmp; | 694 aec->aNlp.hisum += dtmp; |
695 aec->aNlp.himean = aec->aNlp.hisum / aec->aNlp.hicounter; | 695 aec->aNlp.himean = aec->aNlp.hisum / aec->aNlp.hicounter; |
696 } | 696 } |
697 | 697 |
698 // ERLE | 698 // ERLE |
699 | 699 |
700 // subtract noise power | 700 // subtract noise power |
701 suppressedEcho = 2 * (aec->nlpoutlevel.averagelevel - | 701 suppressedEcho = aec->nlpoutlevel.averagelevel - |
702 safety * aec->nlpoutlevel.minlevel); | 702 safety * aec->nlpoutlevel.minlevel; |
703 | 703 |
704 dtmp = 10 * (float)log10(aec->nearlevel.averagelevel / | 704 dtmp = 10 * (float)log10(aec->nearlevel.averagelevel / |
705 (2 * aec->nlpoutlevel.averagelevel) + | 705 aec->nlpoutlevel.averagelevel + 1e-10f); |
706 1e-10f); | |
707 dtmp2 = 10 * (float)log10(echo / suppressedEcho + 1e-10f); | 706 dtmp2 = 10 * (float)log10(echo / suppressedEcho + 1e-10f); |
708 | 707 |
709 dtmp = dtmp2; | 708 dtmp = dtmp2; |
710 aec->erle.instant = dtmp; | 709 aec->erle.instant = dtmp; |
711 if (dtmp > aec->erle.max) { | 710 if (dtmp > aec->erle.max) { |
712 aec->erle.max = dtmp; | 711 aec->erle.max = dtmp; |
713 } | 712 } |
714 | 713 |
715 if (dtmp < aec->erle.min) { | 714 if (dtmp < aec->erle.min) { |
716 aec->erle.min = dtmp; | 715 aec->erle.min = dtmp; |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 } | 1135 } |
1137 | 1136 |
1138 WebRtcAec_OverdriveAndSuppress(aec, hNl, hNlFb, efw); | 1137 WebRtcAec_OverdriveAndSuppress(aec, hNl, hNlFb, efw); |
1139 | 1138 |
1140 // Add comfort noise. | 1139 // Add comfort noise. |
1141 WebRtcAec_ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl); | 1140 WebRtcAec_ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl); |
1142 | 1141 |
1143 // Inverse error fft. | 1142 // Inverse error fft. |
1144 ScaledInverseFft(efw, fft, 2.0f, 1); | 1143 ScaledInverseFft(efw, fft, 2.0f, 1); |
1145 | 1144 |
1146 // TODO(bjornv): Investigate how to take the windowing below into account if | |
1147 // needed. | |
1148 if (aec->metricsMode == 1) { | |
1149 // Note that we have a scaling by two in the time domain |eBuf|. | |
1150 // In addition the time domain signal is windowed before transformation, | |
1151 // losing half the energy on the average. We take care of the first | |
1152 // scaling only in UpdateMetrics(). | |
1153 UpdateLevel(&aec->nlpoutlevel, CalculatePower(fft, PART_LEN2)); | |
1154 } | |
1155 | |
1156 // Overlap and add to obtain output. | 1145 // Overlap and add to obtain output. |
1157 for (i = 0; i < PART_LEN; i++) { | 1146 for (i = 0; i < PART_LEN; i++) { |
1158 output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] + | 1147 output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] + |
1159 aec->outBuf[i] * WebRtcAec_sqrtHanning[PART_LEN - i]); | 1148 aec->outBuf[i] * WebRtcAec_sqrtHanning[PART_LEN - i]); |
1160 | 1149 |
1161 // Saturate output to keep it in the allowed range. | 1150 // Saturate output to keep it in the allowed range. |
1162 output[i] = WEBRTC_SPL_SAT( | 1151 output[i] = WEBRTC_SPL_SAT( |
1163 WEBRTC_SPL_WORD16_MAX, output[i], WEBRTC_SPL_WORD16_MIN); | 1152 WEBRTC_SPL_WORD16_MAX, output[i], WEBRTC_SPL_WORD16_MIN); |
1164 } | 1153 } |
1165 memcpy(aec->outBuf, &fft[PART_LEN], PART_LEN * sizeof(aec->outBuf[0])); | 1154 memcpy(aec->outBuf, &fft[PART_LEN], PART_LEN * sizeof(aec->outBuf[0])); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 | 1366 |
1378 if (aec->metricsMode == 1) { | 1367 if (aec->metricsMode == 1) { |
1379 UpdateLevel(&aec->linoutlevel, | 1368 UpdateLevel(&aec->linoutlevel, |
1380 CalculatePower(echo_subtractor_output, PART_LEN)); | 1369 CalculatePower(echo_subtractor_output, PART_LEN)); |
1381 } | 1370 } |
1382 | 1371 |
1383 // Perform echo suppression. | 1372 // Perform echo suppression. |
1384 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); | 1373 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); |
1385 | 1374 |
1386 if (aec->metricsMode == 1) { | 1375 if (aec->metricsMode == 1) { |
| 1376 UpdateLevel(&aec->nlpoutlevel, CalculatePower(output, PART_LEN)); |
1387 UpdateMetrics(aec); | 1377 UpdateMetrics(aec); |
1388 } | 1378 } |
1389 | 1379 |
1390 // Store the output block. | 1380 // Store the output block. |
1391 WebRtc_WriteBuffer(aec->outFrBuf, output, PART_LEN); | 1381 WebRtc_WriteBuffer(aec->outFrBuf, output, PART_LEN); |
1392 // For high bands | 1382 // For high bands |
1393 for (i = 0; i < aec->num_bands - 1; ++i) { | 1383 for (i = 0; i < aec->num_bands - 1; ++i) { |
1394 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); | 1384 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); |
1395 } | 1385 } |
1396 | 1386 |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 int WebRtcAec_extended_filter_enabled(AecCore* self) { | 1906 int WebRtcAec_extended_filter_enabled(AecCore* self) { |
1917 return self->extended_filter_enabled; | 1907 return self->extended_filter_enabled; |
1918 } | 1908 } |
1919 | 1909 |
1920 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } | 1910 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } |
1921 | 1911 |
1922 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1912 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
1923 assert(delay >= 0); | 1913 assert(delay >= 0); |
1924 self->system_delay = delay; | 1914 self->system_delay = delay; |
1925 } | 1915 } |
OLD | NEW |