Chromium Code Reviews| 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 |
| 11 /* | 11 /* |
| 12 * The core AEC algorithm, which is presented with time-aligned signals. | 12 * The core AEC algorithm, which is presented with time-aligned signals. |
| 13 */ | 13 */ |
| 14 | 14 |
| 15 #include "webrtc/modules/audio_processing/aec/aec_core.h" | 15 #include "webrtc/modules/audio_processing/aec/aec_core.h" |
| 16 | 16 |
| 17 #ifdef WEBRTC_AEC_DEBUG_DUMP | 17 #ifdef WEBRTC_AEC_DEBUG_DUMP |
| 18 #include <stdio.h> | 18 #include <stdio.h> |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 #include <algorithm> | 21 #include <algorithm> |
| 22 #include <assert.h> | 22 #include <assert.h> |
| 23 #include <math.h> | 23 #include <math.h> |
| 24 #include <stddef.h> // size_t | 24 #include <stddef.h> // size_t |
| 25 #include <stdlib.h> | 25 #include <stdlib.h> |
| 26 #include <string.h> | 26 #include <string.h> |
| 27 | 27 |
| 28 #include "webrtc/base/checks.h" | |
| 28 extern "C" { | 29 extern "C" { |
| 29 #include "webrtc/common_audio/ring_buffer.h" | 30 #include "webrtc/common_audio/ring_buffer.h" |
| 30 } | 31 } |
| 31 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" | 32 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" |
| 32 #include "webrtc/modules/audio_processing/aec/aec_common.h" | 33 #include "webrtc/modules/audio_processing/aec/aec_common.h" |
| 33 #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" | 34 #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" |
| 34 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" | 35 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" |
| 35 #include "webrtc/modules/audio_processing/logging/aec_logging.h" | 36 #include "webrtc/modules/audio_processing/logging/aec_logging.h" |
| 36 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" | 37 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" |
| 37 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" | 38 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 | 232 |
| 232 for (j = 0; j < PART_LEN1; j++) { | 233 for (j = 0; j < PART_LEN1; j++) { |
| 233 y_fft[0][j] += MulRe(x_fft_buf[0][xPos + j], x_fft_buf[1][xPos + j], | 234 y_fft[0][j] += MulRe(x_fft_buf[0][xPos + j], x_fft_buf[1][xPos + j], |
| 234 h_fft_buf[0][pos + j], h_fft_buf[1][pos + j]); | 235 h_fft_buf[0][pos + j], h_fft_buf[1][pos + j]); |
| 235 y_fft[1][j] += MulIm(x_fft_buf[0][xPos + j], x_fft_buf[1][xPos + j], | 236 y_fft[1][j] += MulIm(x_fft_buf[0][xPos + j], x_fft_buf[1][xPos + j], |
| 236 h_fft_buf[0][pos + j], h_fft_buf[1][pos + j]); | 237 h_fft_buf[0][pos + j], h_fft_buf[1][pos + j]); |
| 237 } | 238 } |
| 238 } | 239 } |
| 239 } | 240 } |
| 240 | 241 |
| 241 static void ScaleErrorSignal(int extended_filter_enabled, | 242 static void ScaleErrorSignal(int extended_filter_enabled, |
|
tlegrand-webrtc
2016/04/14 14:32:42
This function don't really need the first paramete
peah-webrtc
2016/04/14 22:12:41
That is definitely a good change. I did not want t
tlegrand-webrtc
2016/04/15 09:07:04
Great! I think it's fine, since the CL isn't that
| |
| 242 float normal_mu, | 243 float mu, |
|
tlegrand-webrtc
2016/04/14 14:32:42
With removal of mu = kExtendedMu if extended filte
hlundin-webrtc
2016/04/14 14:47:46
It is now called (through EchoSubtraction) with ae
peah-webrtc
2016/04/14 22:12:41
Fully true.
peah-webrtc
2016/04/14 22:12:41
It is now called in a different way but with a mu
tlegrand-webrtc
2016/04/15 09:07:04
Acknowledged.
| |
| 243 float normal_error_threshold, | 244 float normal_error_threshold, |
| 244 float x_pow[PART_LEN1], | 245 float x_pow[PART_LEN1], |
| 245 float ef[2][PART_LEN1]) { | 246 float ef[2][PART_LEN1]) { |
| 246 const float mu = extended_filter_enabled ? kExtendedMu : normal_mu; | |
| 247 const float error_threshold = extended_filter_enabled | 247 const float error_threshold = extended_filter_enabled |
| 248 ? kExtendedErrorThreshold | 248 ? kExtendedErrorThreshold |
| 249 : normal_error_threshold; | 249 : normal_error_threshold; |
| 250 int i; | 250 int i; |
| 251 float abs_ef; | 251 float abs_ef; |
| 252 for (i = 0; i < (PART_LEN1); i++) { | 252 for (i = 0; i < (PART_LEN1); i++) { |
| 253 ef[0][i] /= (x_pow[i] + 1e-10f); | 253 ef[0][i] /= (x_pow[i] + 1e-10f); |
| 254 ef[1][i] /= (x_pow[i] + 1e-10f); | 254 ef[1][i] /= (x_pow[i] + 1e-10f); |
| 255 abs_ef = sqrtf(ef[0][i] * ef[0][i] + ef[1][i] * ef[1][i]); | 255 abs_ef = sqrtf(ef[0][i] * ef[0][i] + ef[1][i] * ef[1][i]); |
| 256 | 256 |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 929 (delay_quality > kDelayQualityThresholdMax ? kDelayQualityThresholdMax | 929 (delay_quality > kDelayQualityThresholdMax ? kDelayQualityThresholdMax |
| 930 : delay_quality); | 930 : delay_quality); |
| 931 self->delay_quality_threshold = | 931 self->delay_quality_threshold = |
| 932 (delay_quality > self->delay_quality_threshold | 932 (delay_quality > self->delay_quality_threshold |
| 933 ? delay_quality | 933 ? delay_quality |
| 934 : self->delay_quality_threshold); | 934 : self->delay_quality_threshold); |
| 935 } | 935 } |
| 936 return delay_correction; | 936 return delay_correction; |
| 937 } | 937 } |
| 938 | 938 |
| 939 static void RegressorPower(int num_partitions, | |
| 940 int latest_added_partition, | |
| 941 float x_fft_buf[2] | |
| 942 [kExtendedNumPartitions * PART_LEN1], | |
| 943 float x_pow[PART_LEN1]) { | |
| 944 RTC_DCHECK_LT(latest_added_partition, num_partitions); | |
| 945 memset(x_pow, 0, PART_LEN1 * sizeof(x_pow[0])); | |
| 946 | |
| 947 int partition = latest_added_partition; | |
| 948 int x_fft_buf_position = partition * PART_LEN1; | |
| 949 for (int i = 0; i < num_partitions; ++i) { | |
| 950 for (int bin = 0; bin < PART_LEN1; ++bin) { | |
| 951 float re = x_fft_buf[0][x_fft_buf_position]; | |
| 952 float im = x_fft_buf[1][x_fft_buf_position]; | |
| 953 x_pow[bin] += re * re + im * im; | |
| 954 ++x_fft_buf_position; | |
| 955 } | |
| 956 | |
| 957 ++partition; | |
| 958 if (partition == num_partitions) { | |
| 959 partition = 0; | |
| 960 x_fft_buf_position = 0; | |
|
hlundin-webrtc
2016/04/14 14:02:26
Can you DCHECK what you expect x_fft_buf_position
peah-webrtc
2016/04/14 22:12:41
Good point!
Done.
| |
| 961 } | |
| 962 } | |
| 963 } | |
| 964 | |
| 939 static void EchoSubtraction(AecCore* aec, | 965 static void EchoSubtraction(AecCore* aec, |
| 940 int num_partitions, | 966 int num_partitions, |
| 941 int extended_filter_enabled, | 967 int extended_filter_enabled, |
| 942 float normal_mu, | 968 float filter_step_size, |
| 943 float normal_error_threshold, | 969 float normal_error_threshold, |
| 944 float* x_fft, | 970 float* x_fft, |
| 945 int* x_fft_buf_block_pos, | 971 int* x_fft_buf_block_pos, |
| 946 float x_fft_buf[2] | 972 float x_fft_buf[2] |
| 947 [kExtendedNumPartitions * PART_LEN1], | 973 [kExtendedNumPartitions * PART_LEN1], |
| 948 float* const y, | 974 float* const y, |
| 949 float x_pow[PART_LEN1], | 975 float x_pow[PART_LEN1], |
| 950 float h_fft_buf[2] | 976 float h_fft_buf[2] |
| 951 [kExtendedNumPartitions * PART_LEN1], | 977 [kExtendedNumPartitions * PART_LEN1], |
| 952 float echo_subtractor_output[PART_LEN]) { | 978 float echo_subtractor_output[PART_LEN]) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 994 | 1020 |
| 995 // Compute the frequency domain echo prediction error. | 1021 // Compute the frequency domain echo prediction error. |
| 996 memset(e_extended, 0, sizeof(float) * PART_LEN); | 1022 memset(e_extended, 0, sizeof(float) * PART_LEN); |
| 997 memcpy(e_extended + PART_LEN, e, sizeof(float) * PART_LEN); | 1023 memcpy(e_extended + PART_LEN, e, sizeof(float) * PART_LEN); |
| 998 Fft(e_extended, e_fft); | 1024 Fft(e_extended, e_fft); |
| 999 | 1025 |
| 1000 RTC_AEC_DEBUG_RAW_WRITE(aec->e_fft_file, &e_fft[0][0], | 1026 RTC_AEC_DEBUG_RAW_WRITE(aec->e_fft_file, &e_fft[0][0], |
| 1001 sizeof(e_fft[0][0]) * PART_LEN1 * 2); | 1027 sizeof(e_fft[0][0]) * PART_LEN1 * 2); |
| 1002 | 1028 |
| 1003 // Scale error signal inversely with far power. | 1029 // Scale error signal inversely with far power. |
| 1004 WebRtcAec_ScaleErrorSignal(extended_filter_enabled, normal_mu, | 1030 WebRtcAec_ScaleErrorSignal(extended_filter_enabled, filter_step_size, |
| 1005 normal_error_threshold, x_pow, e_fft); | 1031 normal_error_threshold, x_pow, e_fft); |
| 1006 WebRtcAec_FilterAdaptation(num_partitions, *x_fft_buf_block_pos, x_fft_buf, | 1032 WebRtcAec_FilterAdaptation(num_partitions, *x_fft_buf_block_pos, x_fft_buf, |
| 1007 e_fft, h_fft_buf); | 1033 e_fft, h_fft_buf); |
| 1008 memcpy(echo_subtractor_output, e, sizeof(float) * PART_LEN); | 1034 memcpy(echo_subtractor_output, e, sizeof(float) * PART_LEN); |
| 1009 } | 1035 } |
| 1010 | 1036 |
| 1011 static void EchoSuppression(AecCore* aec, | 1037 static void EchoSuppression(AecCore* aec, |
| 1012 float farend[PART_LEN2], | 1038 float farend[PART_LEN2], |
| 1013 float* echo_subtractor_output, | 1039 float* echo_subtractor_output, |
| 1014 float* output, | 1040 float* output, |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1309 // Convert far-end signal to the frequency domain. | 1335 // Convert far-end signal to the frequency domain. |
| 1310 memcpy(fft, farend_ptr, sizeof(float) * PART_LEN2); | 1336 memcpy(fft, farend_ptr, sizeof(float) * PART_LEN2); |
| 1311 Fft(fft, x_fft); | 1337 Fft(fft, x_fft); |
| 1312 x_fft_ptr = &x_fft[0][0]; | 1338 x_fft_ptr = &x_fft[0][0]; |
| 1313 | 1339 |
| 1314 // Near fft | 1340 // Near fft |
| 1315 memcpy(fft, aec->dBuf, sizeof(float) * PART_LEN2); | 1341 memcpy(fft, aec->dBuf, sizeof(float) * PART_LEN2); |
| 1316 Fft(fft, df); | 1342 Fft(fft, df); |
| 1317 | 1343 |
| 1318 // Power smoothing | 1344 // Power smoothing |
| 1319 for (i = 0; i < PART_LEN1; i++) { | 1345 if (aec->refined_adaptive_filter_enabled) { |
| 1320 far_spectrum = (x_fft_ptr[i] * x_fft_ptr[i]) + | 1346 for (i = 0; i < PART_LEN1; ++i) { |
| 1321 (x_fft_ptr[PART_LEN1 + i] * x_fft_ptr[PART_LEN1 + i]); | 1347 far_spectrum = (x_fft_ptr[i] * x_fft_ptr[i]) + |
| 1322 aec->xPow[i] = | 1348 (x_fft_ptr[PART_LEN1 + i] * x_fft_ptr[PART_LEN1 + i]); |
| 1323 gPow[0] * aec->xPow[i] + gPow[1] * aec->num_partitions * far_spectrum; | 1349 // Calculate absolute spectra |
| 1324 // Calculate absolute spectra | 1350 abs_far_spectrum[i] = sqrtf(far_spectrum); |
| 1325 abs_far_spectrum[i] = sqrtf(far_spectrum); | 1351 } |
| 1352 RegressorPower(aec->num_partitions, aec->xfBufBlockPos, aec->xfBuf, | |
| 1353 aec->xPow); | |
| 1354 } else { | |
| 1355 for (i = 0; i < PART_LEN1; ++i) { | |
| 1356 far_spectrum = (x_fft_ptr[i] * x_fft_ptr[i]) + | |
| 1357 (x_fft_ptr[PART_LEN1 + i] * x_fft_ptr[PART_LEN1 + i]); | |
| 1358 aec->xPow[i] = | |
| 1359 gPow[0] * aec->xPow[i] + gPow[1] * aec->num_partitions * far_spectrum; | |
| 1360 // Calculate absolute spectra | |
| 1361 abs_far_spectrum[i] = sqrtf(far_spectrum); | |
| 1362 } | |
| 1363 } | |
| 1326 | 1364 |
| 1365 for (i = 0; i < PART_LEN1; ++i) { | |
| 1327 near_spectrum = df[0][i] * df[0][i] + df[1][i] * df[1][i]; | 1366 near_spectrum = df[0][i] * df[0][i] + df[1][i] * df[1][i]; |
| 1328 aec->dPow[i] = gPow[0] * aec->dPow[i] + gPow[1] * near_spectrum; | 1367 aec->dPow[i] = gPow[0] * aec->dPow[i] + gPow[1] * near_spectrum; |
| 1329 // Calculate absolute spectra | 1368 // Calculate absolute spectra |
| 1330 abs_near_spectrum[i] = sqrtf(near_spectrum); | 1369 abs_near_spectrum[i] = sqrtf(near_spectrum); |
| 1331 } | 1370 } |
| 1332 | 1371 |
| 1333 // Estimate noise power. Wait until dPow is more stable. | 1372 // Estimate noise power. Wait until dPow is more stable. |
| 1334 if (aec->noiseEstCtr > 50) { | 1373 if (aec->noiseEstCtr > 50) { |
| 1335 for (i = 0; i < PART_LEN1; i++) { | 1374 for (i = 0; i < PART_LEN1; i++) { |
| 1336 if (aec->dPow[i] < aec->dMinPow[i]) { | 1375 if (aec->dPow[i] < aec->dMinPow[i]) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1372 } | 1411 } |
| 1373 if (aec->delay_metrics_delivered == 1 && | 1412 if (aec->delay_metrics_delivered == 1 && |
| 1374 aec->num_delay_values >= kDelayMetricsAggregationWindow) { | 1413 aec->num_delay_values >= kDelayMetricsAggregationWindow) { |
| 1375 UpdateDelayMetrics(aec); | 1414 UpdateDelayMetrics(aec); |
| 1376 } | 1415 } |
| 1377 } | 1416 } |
| 1378 } | 1417 } |
| 1379 | 1418 |
| 1380 // Perform echo subtraction. | 1419 // Perform echo subtraction. |
| 1381 EchoSubtraction(aec, aec->num_partitions, aec->extended_filter_enabled, | 1420 EchoSubtraction(aec, aec->num_partitions, aec->extended_filter_enabled, |
| 1382 aec->normal_mu, aec->normal_error_threshold, &x_fft[0][0], | 1421 aec->filter_step_size, aec->normal_error_threshold, |
| 1383 &aec->xfBufBlockPos, aec->xfBuf, nearend_ptr, aec->xPow, | 1422 &x_fft[0][0], &aec->xfBufBlockPos, aec->xfBuf, nearend_ptr, |
| 1384 aec->wfBuf, echo_subtractor_output); | 1423 aec->xPow, aec->wfBuf, echo_subtractor_output); |
| 1385 | 1424 |
| 1386 RTC_AEC_DEBUG_WAV_WRITE(aec->outLinearFile, echo_subtractor_output, PART_LEN); | 1425 RTC_AEC_DEBUG_WAV_WRITE(aec->outLinearFile, echo_subtractor_output, PART_LEN); |
| 1387 | 1426 |
| 1388 if (aec->metricsMode == 1) { | 1427 if (aec->metricsMode == 1) { |
| 1389 UpdateLevel(&aec->linoutlevel, | 1428 UpdateLevel(&aec->linoutlevel, |
| 1390 CalculatePower(echo_subtractor_output, PART_LEN)); | 1429 CalculatePower(echo_subtractor_output, PART_LEN)); |
| 1391 } | 1430 } |
| 1392 | 1431 |
| 1393 // Perform echo suppression. | 1432 // Perform echo suppression. |
| 1394 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); | 1433 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1478 aec->delay_agnostic_enabled = 1; // DA-AEC enabled by default. | 1517 aec->delay_agnostic_enabled = 1; // DA-AEC enabled by default. |
| 1479 // DA-AEC assumes the system is causal from the beginning and will self adjust | 1518 // DA-AEC assumes the system is causal from the beginning and will self adjust |
| 1480 // the lookahead when shifting is required. | 1519 // the lookahead when shifting is required. |
| 1481 WebRtc_set_lookahead(aec->delay_estimator, 0); | 1520 WebRtc_set_lookahead(aec->delay_estimator, 0); |
| 1482 #else | 1521 #else |
| 1483 aec->delay_agnostic_enabled = 0; | 1522 aec->delay_agnostic_enabled = 0; |
| 1484 WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks); | 1523 WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks); |
| 1485 #endif | 1524 #endif |
| 1486 aec->extended_filter_enabled = 0; | 1525 aec->extended_filter_enabled = 0; |
| 1487 aec->aec3_enabled = 0; | 1526 aec->aec3_enabled = 0; |
| 1527 aec->refined_adaptive_filter_enabled = false; | |
| 1488 | 1528 |
| 1489 // Assembly optimization | 1529 // Assembly optimization |
| 1490 WebRtcAec_FilterFar = FilterFar; | 1530 WebRtcAec_FilterFar = FilterFar; |
| 1491 WebRtcAec_ScaleErrorSignal = ScaleErrorSignal; | 1531 WebRtcAec_ScaleErrorSignal = ScaleErrorSignal; |
| 1492 WebRtcAec_FilterAdaptation = FilterAdaptation; | 1532 WebRtcAec_FilterAdaptation = FilterAdaptation; |
| 1493 WebRtcAec_OverdriveAndSuppress = OverdriveAndSuppress; | 1533 WebRtcAec_OverdriveAndSuppress = OverdriveAndSuppress; |
| 1494 WebRtcAec_ComfortNoise = ComfortNoise; | 1534 WebRtcAec_ComfortNoise = ComfortNoise; |
| 1495 WebRtcAec_SubbandCoherence = SubbandCoherence; | 1535 WebRtcAec_SubbandCoherence = SubbandCoherence; |
| 1496 WebRtcAec_StoreAsComplex = StoreAsComplex; | 1536 WebRtcAec_StoreAsComplex = StoreAsComplex; |
| 1497 WebRtcAec_PartitionDelay = PartitionDelay; | 1537 WebRtcAec_PartitionDelay = PartitionDelay; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1541 RTC_AEC_DEBUG_WAV_CLOSE(aec->outFile); | 1581 RTC_AEC_DEBUG_WAV_CLOSE(aec->outFile); |
| 1542 RTC_AEC_DEBUG_WAV_CLOSE(aec->outLinearFile); | 1582 RTC_AEC_DEBUG_WAV_CLOSE(aec->outLinearFile); |
| 1543 RTC_AEC_DEBUG_RAW_CLOSE(aec->e_fft_file); | 1583 RTC_AEC_DEBUG_RAW_CLOSE(aec->e_fft_file); |
| 1544 | 1584 |
| 1545 WebRtc_FreeDelayEstimator(aec->delay_estimator); | 1585 WebRtc_FreeDelayEstimator(aec->delay_estimator); |
| 1546 WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend); | 1586 WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend); |
| 1547 | 1587 |
| 1548 delete aec; | 1588 delete aec; |
| 1549 } | 1589 } |
| 1550 | 1590 |
| 1591 static void SetAdaptiveFilterStepSize(AecCore* aec) { | |
| 1592 // Extended filter adaptation parameter. | |
| 1593 // TODO(ajm): No narrowband tuning yet. | |
| 1594 const float kExtendedMu = 0.4f; | |
| 1595 | |
| 1596 if (aec->refined_adaptive_filter_enabled) { | |
| 1597 aec->filter_step_size = 0.05f; | |
|
hlundin-webrtc
2016/04/14 14:02:26
The old code seems to vary the step size depending
peah-webrtc
2016/04/14 22:12:41
Maybe,
The only way the sample rate affects the a
| |
| 1598 } else { | |
| 1599 if (aec->extended_filter_enabled) { | |
| 1600 aec->filter_step_size = kExtendedMu; | |
| 1601 } else { | |
| 1602 if (aec->sampFreq == 8000) { | |
| 1603 aec->filter_step_size = 0.6f; | |
| 1604 } else { | |
| 1605 aec->filter_step_size = 0.5f; | |
| 1606 } | |
| 1607 } | |
| 1608 } | |
| 1609 } | |
| 1610 | |
| 1551 int WebRtcAec_InitAec(AecCore* aec, int sampFreq) { | 1611 int WebRtcAec_InitAec(AecCore* aec, int sampFreq) { |
| 1552 int i; | 1612 int i; |
| 1553 | 1613 |
| 1554 aec->sampFreq = sampFreq; | 1614 aec->sampFreq = sampFreq; |
| 1555 | 1615 |
| 1616 SetAdaptiveFilterStepSize(aec); | |
| 1617 | |
| 1556 if (sampFreq == 8000) { | 1618 if (sampFreq == 8000) { |
| 1557 aec->normal_mu = 0.6f; | |
| 1558 aec->normal_error_threshold = 2e-6f; | 1619 aec->normal_error_threshold = 2e-6f; |
| 1559 aec->num_bands = 1; | 1620 aec->num_bands = 1; |
| 1560 } else { | 1621 } else { |
| 1561 aec->normal_mu = 0.5f; | |
| 1562 aec->normal_error_threshold = 1.5e-6f; | 1622 aec->normal_error_threshold = 1.5e-6f; |
| 1563 aec->num_bands = (size_t)(sampFreq / 16000); | 1623 aec->num_bands = (size_t)(sampFreq / 16000); |
| 1564 } | 1624 } |
| 1565 | 1625 |
| 1566 WebRtc_InitBuffer(aec->nearFrBuf); | 1626 WebRtc_InitBuffer(aec->nearFrBuf); |
| 1567 WebRtc_InitBuffer(aec->outFrBuf); | 1627 WebRtc_InitBuffer(aec->outFrBuf); |
| 1568 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { | 1628 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { |
| 1569 WebRtc_InitBuffer(aec->nearFrBufH[i]); | 1629 WebRtc_InitBuffer(aec->nearFrBufH[i]); |
| 1570 WebRtc_InitBuffer(aec->outFrBufH[i]); | 1630 WebRtc_InitBuffer(aec->outFrBufH[i]); |
| 1571 } | 1631 } |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1923 | 1983 |
| 1924 void WebRtcAec_enable_aec3(AecCore* self, int enable) { | 1984 void WebRtcAec_enable_aec3(AecCore* self, int enable) { |
| 1925 self->aec3_enabled = (enable != 0); | 1985 self->aec3_enabled = (enable != 0); |
| 1926 } | 1986 } |
| 1927 | 1987 |
| 1928 int WebRtcAec_aec3_enabled(AecCore* self) { | 1988 int WebRtcAec_aec3_enabled(AecCore* self) { |
| 1929 assert(self->aec3_enabled == 0 || self->aec3_enabled == 1); | 1989 assert(self->aec3_enabled == 0 || self->aec3_enabled == 1); |
| 1930 return self->aec3_enabled; | 1990 return self->aec3_enabled; |
| 1931 } | 1991 } |
| 1932 | 1992 |
| 1993 void WebRtcAec_enable_refined_adaptive_filter(AecCore* self, bool enable) { | |
| 1994 self->refined_adaptive_filter_enabled = enable; | |
| 1995 SetAdaptiveFilterStepSize(self); | |
| 1996 } | |
| 1997 | |
| 1998 bool WebRtcAec_refined_adaptive_filter_enabled(AecCore* self) { | |
|
hlundin-webrtc
2016/04/14 14:02:27
const AecCore*
peah-webrtc
2016/04/14 22:12:41
Done.
| |
| 1999 return self->refined_adaptive_filter_enabled; | |
| 2000 } | |
| 1933 | 2001 |
| 1934 void WebRtcAec_enable_extended_filter(AecCore* self, int enable) { | 2002 void WebRtcAec_enable_extended_filter(AecCore* self, int enable) { |
| 1935 self->extended_filter_enabled = enable; | 2003 self->extended_filter_enabled = enable; |
| 1936 self->num_partitions = enable ? kExtendedNumPartitions : kNormalNumPartitions; | 2004 self->num_partitions = enable ? kExtendedNumPartitions : kNormalNumPartitions; |
| 1937 // Update the delay estimator with filter length. See InitAEC() for details. | 2005 // Update the delay estimator with filter length. See InitAEC() for details. |
| 1938 WebRtc_set_allowed_offset(self->delay_estimator, self->num_partitions / 2); | 2006 WebRtc_set_allowed_offset(self->delay_estimator, self->num_partitions / 2); |
| 1939 } | 2007 } |
|
hlundin-webrtc
2016/04/14 14:47:46
You must call SetAdaptiveFilterStepSize here too.
peah-webrtc
2016/04/14 22:12:41
Great find!
Done.
| |
| 1940 | 2008 |
| 1941 int WebRtcAec_extended_filter_enabled(AecCore* self) { | 2009 int WebRtcAec_extended_filter_enabled(AecCore* self) { |
| 1942 return self->extended_filter_enabled; | 2010 return self->extended_filter_enabled; |
| 1943 } | 2011 } |
| 1944 | 2012 |
| 1945 int WebRtcAec_system_delay(AecCore* self) { | 2013 int WebRtcAec_system_delay(AecCore* self) { |
| 1946 return self->system_delay; | 2014 return self->system_delay; |
| 1947 } | 2015 } |
| 1948 | 2016 |
| 1949 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 2017 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
| 1950 assert(delay >= 0); | 2018 assert(delay >= 0); |
| 1951 self->system_delay = delay; | 2019 self->system_delay = delay; |
| 1952 } | 2020 } |
| 1953 } // namespace webrtc | 2021 } // namespace webrtc |
| OLD | NEW |