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 | |
18 #include <stdio.h> | |
19 #endif | |
20 | |
21 #include <algorithm> | 17 #include <algorithm> |
22 #include <assert.h> | 18 #include <assert.h> |
23 #include <math.h> | 19 #include <math.h> |
24 #include <stddef.h> // size_t | 20 #include <stddef.h> // size_t |
25 #include <stdlib.h> | 21 #include <stdlib.h> |
26 #include <string.h> | 22 #include <string.h> |
27 | 23 |
28 extern "C" { | 24 extern "C" { |
29 #include "webrtc/common_audio/ring_buffer.h" | 25 #include "webrtc/common_audio/ring_buffer.h" |
30 } | 26 } |
31 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 27 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
32 #include "webrtc/modules/audio_processing/aec/aec_common.h" | 28 #include "webrtc/modules/audio_processing/aec/aec_common.h" |
33 #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" | 29 #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" |
34 extern "C" { | 30 extern "C" { |
35 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" | 31 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" |
36 } | 32 } |
37 #include "webrtc/modules/audio_processing/logging/aec_logging.h" | |
38 extern "C" { | 33 extern "C" { |
39 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" | 34 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" |
40 } | 35 } |
41 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" | 36 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" |
42 #include "webrtc/typedefs.h" | 37 #include "webrtc/typedefs.h" |
43 | 38 |
44 namespace webrtc { | 39 namespace webrtc { |
45 | 40 |
46 // Buffer size (samples) | 41 // Buffer size (samples) |
47 static const size_t kBufSizePartitions = 250; // 1 second of audio in 16 kHz. | 42 static const size_t kBufSizePartitions = 250; // 1 second of audio in 16 kHz. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 const float WebRtcAec_kExtendedSmoothingCoefficients[2][2] = {{0.9f, 0.1f}, | 125 const float WebRtcAec_kExtendedSmoothingCoefficients[2][2] = {{0.9f, 0.1f}, |
131 {0.92f, 0.08f}}; | 126 {0.92f, 0.08f}}; |
132 const float WebRtcAec_kNormalSmoothingCoefficients[2][2] = {{0.9f, 0.1f}, | 127 const float WebRtcAec_kNormalSmoothingCoefficients[2][2] = {{0.9f, 0.1f}, |
133 {0.93f, 0.07f}}; | 128 {0.93f, 0.07f}}; |
134 | 129 |
135 // Number of partitions forming the NLP's "preferred" bands. | 130 // Number of partitions forming the NLP's "preferred" bands. |
136 enum { kPrefBandSize = 24 }; | 131 enum { kPrefBandSize = 24 }; |
137 | 132 |
138 #ifdef WEBRTC_AEC_DEBUG_DUMP | 133 #ifdef WEBRTC_AEC_DEBUG_DUMP |
139 extern int webrtc_aec_instance_count; | 134 extern int webrtc_aec_instance_count; |
| 135 #else |
| 136 const int webrtc_aec_instance_count = 0; |
140 #endif | 137 #endif |
141 | 138 |
142 WebRtcAecFilterFar WebRtcAec_FilterFar; | 139 WebRtcAecFilterFar WebRtcAec_FilterFar; |
143 WebRtcAecScaleErrorSignal WebRtcAec_ScaleErrorSignal; | 140 WebRtcAecScaleErrorSignal WebRtcAec_ScaleErrorSignal; |
144 WebRtcAecFilterAdaptation WebRtcAec_FilterAdaptation; | 141 WebRtcAecFilterAdaptation WebRtcAec_FilterAdaptation; |
145 WebRtcAecOverdriveAndSuppress WebRtcAec_OverdriveAndSuppress; | 142 WebRtcAecOverdriveAndSuppress WebRtcAec_OverdriveAndSuppress; |
146 WebRtcAecComfortNoise WebRtcAec_ComfortNoise; | 143 WebRtcAecComfortNoise WebRtcAec_ComfortNoise; |
147 WebRtcAecSubBandCoherence WebRtcAec_SubbandCoherence; | 144 WebRtcAecSubBandCoherence WebRtcAec_SubbandCoherence; |
148 WebRtcAecStoreAsComplex WebRtcAec_StoreAsComplex; | 145 WebRtcAecStoreAsComplex WebRtcAec_StoreAsComplex; |
149 WebRtcAecPartitionDelay WebRtcAec_PartitionDelay; | 146 WebRtcAecPartitionDelay WebRtcAec_PartitionDelay; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 float DivergentFilterFraction::GetLatestFraction() const { | 199 float DivergentFilterFraction::GetLatestFraction() const { |
203 return fraction_; | 200 return fraction_; |
204 } | 201 } |
205 | 202 |
206 void DivergentFilterFraction::Clear() { | 203 void DivergentFilterFraction::Clear() { |
207 count_ = 0; | 204 count_ = 0; |
208 occurrence_ = 0; | 205 occurrence_ = 0; |
209 } | 206 } |
210 | 207 |
211 // TODO(minyue): Moving some initialization from WebRtcAec_CreateAec() to ctor. | 208 // TODO(minyue): Moving some initialization from WebRtcAec_CreateAec() to ctor. |
212 AecCore::AecCore() = default; | 209 AecCore::AecCore(int instance_index) : data_dumper(instance_index) {} |
213 | 210 |
214 static int CmpFloat(const void* a, const void* b) { | 211 static int CmpFloat(const void* a, const void* b) { |
215 const float* da = (const float*)a; | 212 const float* da = (const float*)a; |
216 const float* db = (const float*)b; | 213 const float* db = (const float*)b; |
217 | 214 |
218 return (*da > *db) - (*da < *db); | 215 return (*da > *db) - (*da < *db); |
219 } | 216 } |
220 | 217 |
221 static void FilterFar(int num_partitions, | 218 static void FilterFar(int num_partitions, |
222 int x_fft_buf_block_pos, | 219 int x_fft_buf_block_pos, |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 // Compute the time-domain echo prediction error. | 991 // Compute the time-domain echo prediction error. |
995 for (i = 0; i < PART_LEN; ++i) { | 992 for (i = 0; i < PART_LEN; ++i) { |
996 e[i] = y[i] - s[i]; | 993 e[i] = y[i] - s[i]; |
997 } | 994 } |
998 | 995 |
999 // Compute the frequency domain echo prediction error. | 996 // Compute the frequency domain echo prediction error. |
1000 memset(e_extended, 0, sizeof(float) * PART_LEN); | 997 memset(e_extended, 0, sizeof(float) * PART_LEN); |
1001 memcpy(e_extended + PART_LEN, e, sizeof(float) * PART_LEN); | 998 memcpy(e_extended + PART_LEN, e, sizeof(float) * PART_LEN); |
1002 Fft(e_extended, e_fft); | 999 Fft(e_extended, e_fft); |
1003 | 1000 |
1004 RTC_AEC_DEBUG_RAW_WRITE(aec->e_fft_file, &e_fft[0][0], | 1001 aec->data_dumper.DumpRaw("aec_e_fft", PART_LEN1 * 2, &e_fft[0][0]); |
1005 sizeof(e_fft[0][0]) * PART_LEN1 * 2); | |
1006 | 1002 |
1007 // Scale error signal inversely with far power. | 1003 // Scale error signal inversely with far power. |
1008 WebRtcAec_ScaleErrorSignal(extended_filter_enabled, normal_mu, | 1004 WebRtcAec_ScaleErrorSignal(extended_filter_enabled, normal_mu, |
1009 normal_error_threshold, x_pow, e_fft); | 1005 normal_error_threshold, x_pow, e_fft); |
1010 WebRtcAec_FilterAdaptation(num_partitions, *x_fft_buf_block_pos, x_fft_buf, | 1006 WebRtcAec_FilterAdaptation(num_partitions, *x_fft_buf_block_pos, x_fft_buf, |
1011 e_fft, h_fft_buf); | 1007 e_fft, h_fft_buf); |
1012 memcpy(echo_subtractor_output, e, sizeof(float) * PART_LEN); | 1008 memcpy(echo_subtractor_output, e, sizeof(float) * PART_LEN); |
1013 } | 1009 } |
1014 | 1010 |
1015 static void EchoSuppression(AecCore* aec, | 1011 static void EchoSuppression(AecCore* aec, |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 } | 1282 } |
1287 WebRtc_ReadBuffer(aec->nearFrBuf, reinterpret_cast<void**>(&nearend_ptr), | 1283 WebRtc_ReadBuffer(aec->nearFrBuf, reinterpret_cast<void**>(&nearend_ptr), |
1288 nearend, PART_LEN); | 1284 nearend, PART_LEN); |
1289 memcpy(aec->dBuf + PART_LEN, nearend_ptr, sizeof(nearend)); | 1285 memcpy(aec->dBuf + PART_LEN, nearend_ptr, sizeof(nearend)); |
1290 | 1286 |
1291 // We should always have at least one element stored in |far_buf|. | 1287 // We should always have at least one element stored in |far_buf|. |
1292 assert(WebRtc_available_read(aec->far_time_buf) > 0); | 1288 assert(WebRtc_available_read(aec->far_time_buf) > 0); |
1293 WebRtc_ReadBuffer(aec->far_time_buf, reinterpret_cast<void**>(&farend_ptr), | 1289 WebRtc_ReadBuffer(aec->far_time_buf, reinterpret_cast<void**>(&farend_ptr), |
1294 farend, 1); | 1290 farend, 1); |
1295 | 1291 |
1296 #ifdef WEBRTC_AEC_DEBUG_DUMP | 1292 aec->data_dumper.DumpWav("aec_far", PART_LEN, &farend_ptr[PART_LEN], |
1297 { | 1293 aec->sampFreq > 16000 ? 16000 : aec->sampFreq); |
1298 // TODO(minyue): |farend_ptr| starts from buffered samples. This will be | 1294 aec->data_dumper.DumpWav("aec_near", PART_LEN, nearend_ptr, |
1299 // modified when |aec->far_time_buf| is revised. | 1295 aec->sampFreq > 16000 ? 16000 : aec->sampFreq); |
1300 RTC_AEC_DEBUG_WAV_WRITE(aec->farFile, &farend_ptr[PART_LEN], PART_LEN); | |
1301 | |
1302 RTC_AEC_DEBUG_WAV_WRITE(aec->nearFile, nearend_ptr, PART_LEN); | |
1303 } | |
1304 #endif | |
1305 | 1296 |
1306 if (aec->metricsMode == 1) { | 1297 if (aec->metricsMode == 1) { |
1307 // Update power levels | 1298 // Update power levels |
1308 UpdateLevel(&aec->farlevel, | 1299 UpdateLevel(&aec->farlevel, |
1309 CalculatePower(&farend_ptr[PART_LEN], PART_LEN)); | 1300 CalculatePower(&farend_ptr[PART_LEN], PART_LEN)); |
1310 UpdateLevel(&aec->nearlevel, CalculatePower(nearend_ptr, PART_LEN)); | 1301 UpdateLevel(&aec->nearlevel, CalculatePower(nearend_ptr, PART_LEN)); |
1311 } | 1302 } |
1312 | 1303 |
1313 // Convert far-end signal to the frequency domain. | 1304 // Convert far-end signal to the frequency domain. |
1314 memcpy(fft, farend_ptr, sizeof(float) * PART_LEN2); | 1305 memcpy(fft, farend_ptr, sizeof(float) * PART_LEN2); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 } | 1371 } |
1381 } | 1372 } |
1382 } | 1373 } |
1383 | 1374 |
1384 // Perform echo subtraction. | 1375 // Perform echo subtraction. |
1385 EchoSubtraction(aec, aec->num_partitions, aec->extended_filter_enabled, | 1376 EchoSubtraction(aec, aec->num_partitions, aec->extended_filter_enabled, |
1386 aec->normal_mu, aec->normal_error_threshold, &x_fft[0][0], | 1377 aec->normal_mu, aec->normal_error_threshold, &x_fft[0][0], |
1387 &aec->xfBufBlockPos, aec->xfBuf, nearend_ptr, aec->xPow, | 1378 &aec->xfBufBlockPos, aec->xfBuf, nearend_ptr, aec->xPow, |
1388 aec->wfBuf, echo_subtractor_output); | 1379 aec->wfBuf, echo_subtractor_output); |
1389 | 1380 |
1390 RTC_AEC_DEBUG_WAV_WRITE(aec->outLinearFile, echo_subtractor_output, PART_LEN); | 1381 aec->data_dumper.DumpWav("aec_out_linear", PART_LEN, echo_subtractor_output, |
| 1382 aec->sampFreq > 16000 ? 16000 : aec->sampFreq); |
1391 | 1383 |
1392 if (aec->metricsMode == 1) { | 1384 if (aec->metricsMode == 1) { |
1393 UpdateLevel(&aec->linoutlevel, | 1385 UpdateLevel(&aec->linoutlevel, |
1394 CalculatePower(echo_subtractor_output, PART_LEN)); | 1386 CalculatePower(echo_subtractor_output, PART_LEN)); |
1395 } | 1387 } |
1396 | 1388 |
1397 // Perform echo suppression. | 1389 // Perform echo suppression. |
1398 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); | 1390 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); |
1399 | 1391 |
1400 if (aec->metricsMode == 1) { | 1392 if (aec->metricsMode == 1) { |
1401 UpdateLevel(&aec->nlpoutlevel, CalculatePower(output, PART_LEN)); | 1393 UpdateLevel(&aec->nlpoutlevel, CalculatePower(output, PART_LEN)); |
1402 UpdateMetrics(aec); | 1394 UpdateMetrics(aec); |
1403 } | 1395 } |
1404 | 1396 |
1405 // Store the output block. | 1397 // Store the output block. |
1406 WebRtc_WriteBuffer(aec->outFrBuf, output, PART_LEN); | 1398 WebRtc_WriteBuffer(aec->outFrBuf, output, PART_LEN); |
1407 // For high bands | 1399 // For high bands |
1408 for (i = 0; i < aec->num_bands - 1; ++i) { | 1400 for (i = 0; i < aec->num_bands - 1; ++i) { |
1409 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); | 1401 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); |
1410 } | 1402 } |
1411 | 1403 |
1412 RTC_AEC_DEBUG_WAV_WRITE(aec->outFile, output, PART_LEN); | 1404 aec->data_dumper.DumpWav("aec_out", PART_LEN, output, |
| 1405 aec->sampFreq > 16000 ? 16000 : aec->sampFreq); |
1413 } | 1406 } |
1414 | 1407 |
1415 AecCore* WebRtcAec_CreateAec() { | 1408 AecCore* WebRtcAec_CreateAec() { |
1416 int i; | 1409 int i; |
1417 AecCore* aec = new AecCore; | 1410 AecCore* aec = new AecCore(webrtc_aec_instance_count); |
| 1411 |
1418 if (!aec) { | 1412 if (!aec) { |
1419 return NULL; | 1413 return NULL; |
1420 } | 1414 } |
1421 | 1415 |
1422 aec->nearFrBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(float)); | 1416 aec->nearFrBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(float)); |
1423 if (!aec->nearFrBuf) { | 1417 if (!aec->nearFrBuf) { |
1424 WebRtcAec_FreeAec(aec); | 1418 WebRtcAec_FreeAec(aec); |
1425 return NULL; | 1419 return NULL; |
1426 } | 1420 } |
1427 | 1421 |
(...skipping 23 matching lines...) Expand all Loading... |
1451 // supposed to contain |PART_LEN2| samples with an overlap of |PART_LEN| | 1445 // supposed to contain |PART_LEN2| samples with an overlap of |PART_LEN| |
1452 // samples from the last frame. | 1446 // samples from the last frame. |
1453 // TODO(minyue): reduce |far_time_buf| to non-overlapped |PART_LEN| samples. | 1447 // TODO(minyue): reduce |far_time_buf| to non-overlapped |PART_LEN| samples. |
1454 aec->far_time_buf = | 1448 aec->far_time_buf = |
1455 WebRtc_CreateBuffer(kBufSizePartitions, sizeof(float) * PART_LEN2); | 1449 WebRtc_CreateBuffer(kBufSizePartitions, sizeof(float) * PART_LEN2); |
1456 if (!aec->far_time_buf) { | 1450 if (!aec->far_time_buf) { |
1457 WebRtcAec_FreeAec(aec); | 1451 WebRtcAec_FreeAec(aec); |
1458 return NULL; | 1452 return NULL; |
1459 } | 1453 } |
1460 | 1454 |
1461 #ifdef WEBRTC_AEC_DEBUG_DUMP | |
1462 aec->instance_index = webrtc_aec_instance_count; | |
1463 | |
1464 aec->farFile = aec->nearFile = aec->outFile = aec->outLinearFile = NULL; | |
1465 aec->debug_dump_count = 0; | |
1466 #endif | |
1467 aec->delay_estimator_farend = | 1455 aec->delay_estimator_farend = |
1468 WebRtc_CreateDelayEstimatorFarend(PART_LEN1, kHistorySizeBlocks); | 1456 WebRtc_CreateDelayEstimatorFarend(PART_LEN1, kHistorySizeBlocks); |
1469 if (aec->delay_estimator_farend == NULL) { | 1457 if (aec->delay_estimator_farend == NULL) { |
1470 WebRtcAec_FreeAec(aec); | 1458 WebRtcAec_FreeAec(aec); |
1471 return NULL; | 1459 return NULL; |
1472 } | 1460 } |
1473 // We create the delay_estimator with the same amount of maximum lookahead as | 1461 // We create the delay_estimator with the same amount of maximum lookahead as |
1474 // the delay history size (kHistorySizeBlocks) for symmetry reasons. | 1462 // the delay history size (kHistorySizeBlocks) for symmetry reasons. |
1475 aec->delay_estimator = WebRtc_CreateDelayEstimator( | 1463 aec->delay_estimator = WebRtc_CreateDelayEstimator( |
1476 aec->delay_estimator_farend, kHistorySizeBlocks); | 1464 aec->delay_estimator_farend, kHistorySizeBlocks); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 WebRtc_FreeBuffer(aec->nearFrBuf); | 1521 WebRtc_FreeBuffer(aec->nearFrBuf); |
1534 WebRtc_FreeBuffer(aec->outFrBuf); | 1522 WebRtc_FreeBuffer(aec->outFrBuf); |
1535 | 1523 |
1536 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { | 1524 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { |
1537 WebRtc_FreeBuffer(aec->nearFrBufH[i]); | 1525 WebRtc_FreeBuffer(aec->nearFrBufH[i]); |
1538 WebRtc_FreeBuffer(aec->outFrBufH[i]); | 1526 WebRtc_FreeBuffer(aec->outFrBufH[i]); |
1539 } | 1527 } |
1540 | 1528 |
1541 WebRtc_FreeBuffer(aec->far_time_buf); | 1529 WebRtc_FreeBuffer(aec->far_time_buf); |
1542 | 1530 |
1543 RTC_AEC_DEBUG_WAV_CLOSE(aec->farFile); | |
1544 RTC_AEC_DEBUG_WAV_CLOSE(aec->nearFile); | |
1545 RTC_AEC_DEBUG_WAV_CLOSE(aec->outFile); | |
1546 RTC_AEC_DEBUG_WAV_CLOSE(aec->outLinearFile); | |
1547 RTC_AEC_DEBUG_RAW_CLOSE(aec->e_fft_file); | |
1548 | |
1549 WebRtc_FreeDelayEstimator(aec->delay_estimator); | 1531 WebRtc_FreeDelayEstimator(aec->delay_estimator); |
1550 WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend); | 1532 WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend); |
1551 | 1533 |
1552 delete aec; | 1534 delete aec; |
1553 } | 1535 } |
1554 | 1536 |
1555 int WebRtcAec_InitAec(AecCore* aec, int sampFreq) { | 1537 int WebRtcAec_InitAec(AecCore* aec, int sampFreq) { |
1556 int i; | 1538 int i; |
| 1539 aec->data_dumper.Initialize(); |
1557 | 1540 |
1558 aec->sampFreq = sampFreq; | 1541 aec->sampFreq = sampFreq; |
1559 | 1542 |
1560 if (sampFreq == 8000) { | 1543 if (sampFreq == 8000) { |
1561 aec->normal_mu = 0.6f; | 1544 aec->normal_mu = 0.6f; |
1562 aec->normal_error_threshold = 2e-6f; | 1545 aec->normal_error_threshold = 2e-6f; |
1563 aec->num_bands = 1; | 1546 aec->num_bands = 1; |
1564 } else { | 1547 } else { |
1565 aec->normal_mu = 0.5f; | 1548 aec->normal_mu = 0.5f; |
1566 aec->normal_error_threshold = 1.5e-6f; | 1549 aec->normal_error_threshold = 1.5e-6f; |
1567 aec->num_bands = (size_t)(sampFreq / 16000); | 1550 aec->num_bands = (size_t)(sampFreq / 16000); |
1568 } | 1551 } |
1569 | 1552 |
1570 WebRtc_InitBuffer(aec->nearFrBuf); | 1553 WebRtc_InitBuffer(aec->nearFrBuf); |
1571 WebRtc_InitBuffer(aec->outFrBuf); | 1554 WebRtc_InitBuffer(aec->outFrBuf); |
1572 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { | 1555 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { |
1573 WebRtc_InitBuffer(aec->nearFrBufH[i]); | 1556 WebRtc_InitBuffer(aec->nearFrBufH[i]); |
1574 WebRtc_InitBuffer(aec->outFrBufH[i]); | 1557 WebRtc_InitBuffer(aec->outFrBufH[i]); |
1575 } | 1558 } |
1576 | 1559 |
1577 // Initialize far-end buffers. | 1560 // Initialize far-end buffers. |
1578 WebRtc_InitBuffer(aec->far_time_buf); | 1561 WebRtc_InitBuffer(aec->far_time_buf); |
1579 | 1562 |
1580 #ifdef WEBRTC_AEC_DEBUG_DUMP | |
1581 { | |
1582 int process_rate = sampFreq > 16000 ? 16000 : sampFreq; | |
1583 RTC_AEC_DEBUG_WAV_REOPEN("aec_far", aec->instance_index, | |
1584 aec->debug_dump_count, process_rate, | |
1585 &aec->farFile); | |
1586 RTC_AEC_DEBUG_WAV_REOPEN("aec_near", aec->instance_index, | |
1587 aec->debug_dump_count, process_rate, | |
1588 &aec->nearFile); | |
1589 RTC_AEC_DEBUG_WAV_REOPEN("aec_out", aec->instance_index, | |
1590 aec->debug_dump_count, process_rate, | |
1591 &aec->outFile); | |
1592 RTC_AEC_DEBUG_WAV_REOPEN("aec_out_linear", aec->instance_index, | |
1593 aec->debug_dump_count, process_rate, | |
1594 &aec->outLinearFile); | |
1595 } | |
1596 | |
1597 RTC_AEC_DEBUG_RAW_OPEN("aec_e_fft", aec->debug_dump_count, &aec->e_fft_file); | |
1598 | |
1599 ++aec->debug_dump_count; | |
1600 #endif | |
1601 aec->system_delay = 0; | 1563 aec->system_delay = 0; |
1602 | 1564 |
1603 if (WebRtc_InitDelayEstimatorFarend(aec->delay_estimator_farend) != 0) { | 1565 if (WebRtc_InitDelayEstimatorFarend(aec->delay_estimator_farend) != 0) { |
1604 return -1; | 1566 return -1; |
1605 } | 1567 } |
1606 if (WebRtc_InitDelayEstimator(aec->delay_estimator) != 0) { | 1568 if (WebRtc_InitDelayEstimator(aec->delay_estimator) != 0) { |
1607 return -1; | 1569 return -1; |
1608 } | 1570 } |
1609 aec->delay_logging_enabled = 0; | 1571 aec->delay_logging_enabled = 0; |
1610 aec->delay_metrics_delivered = 0; | 1572 aec->delay_metrics_delivered = 0; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 | 1907 |
1946 int WebRtcAec_system_delay(AecCore* self) { | 1908 int WebRtcAec_system_delay(AecCore* self) { |
1947 return self->system_delay; | 1909 return self->system_delay; |
1948 } | 1910 } |
1949 | 1911 |
1950 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1912 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
1951 assert(delay >= 0); | 1913 assert(delay >= 0); |
1952 self->system_delay = delay; | 1914 self->system_delay = delay; |
1953 } | 1915 } |
1954 } // namespace webrtc | 1916 } // namespace webrtc |
OLD | NEW |