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 | |
| 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 #include "webrtc/base/checks.h" | 24 #include "webrtc/base/checks.h" |
| 29 extern "C" { | 25 extern "C" { |
| 30 #include "webrtc/common_audio/ring_buffer.h" | 26 #include "webrtc/common_audio/ring_buffer.h" |
| 31 } | 27 } |
| 32 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" | 28 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" |
| 33 #include "webrtc/modules/audio_processing/aec/aec_common.h" | 29 #include "webrtc/modules/audio_processing/aec/aec_common.h" |
| 34 #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" | 30 #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" |
| 35 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" | 31 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" |
| 36 #include "webrtc/modules/audio_processing/logging/aec_logging.h" | |
| 37 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" | 32 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" |
| 38 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" | 33 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" |
| 39 #include "webrtc/typedefs.h" | 34 #include "webrtc/typedefs.h" |
| 40 | 35 |
| 41 namespace webrtc { | 36 namespace webrtc { |
| 42 | 37 |
| 43 // Buffer size (samples) | 38 // Buffer size (samples) |
| 44 static const size_t kBufSizePartitions = 250; // 1 second of audio in 16 kHz. | 39 static const size_t kBufSizePartitions = 250; // 1 second of audio in 16 kHz. |
| 45 | 40 |
| 46 // Metrics | 41 // Metrics |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 static const float kExtendedMinOverDrive[3] = {3.0f, 6.0f, 15.0f}; | 120 static const float kExtendedMinOverDrive[3] = {3.0f, 6.0f, 15.0f}; |
| 126 static const float kNormalMinOverDrive[3] = {1.0f, 2.0f, 5.0f}; | 121 static const float kNormalMinOverDrive[3] = {1.0f, 2.0f, 5.0f}; |
| 127 const float WebRtcAec_kExtendedSmoothingCoefficients[2][2] = {{0.9f, 0.1f}, | 122 const float WebRtcAec_kExtendedSmoothingCoefficients[2][2] = {{0.9f, 0.1f}, |
| 128 {0.92f, 0.08f}}; | 123 {0.92f, 0.08f}}; |
| 129 const float WebRtcAec_kNormalSmoothingCoefficients[2][2] = {{0.9f, 0.1f}, | 124 const float WebRtcAec_kNormalSmoothingCoefficients[2][2] = {{0.9f, 0.1f}, |
| 130 {0.93f, 0.07f}}; | 125 {0.93f, 0.07f}}; |
| 131 | 126 |
| 132 // Number of partitions forming the NLP's "preferred" bands. | 127 // Number of partitions forming the NLP's "preferred" bands. |
| 133 enum { kPrefBandSize = 24 }; | 128 enum { kPrefBandSize = 24 }; |
| 134 | 129 |
| 135 #ifdef WEBRTC_AEC_DEBUG_DUMP | |
| 136 extern int webrtc_aec_instance_count; | |
| 137 #endif | |
| 138 | |
| 139 WebRtcAecFilterFar WebRtcAec_FilterFar; | 130 WebRtcAecFilterFar WebRtcAec_FilterFar; |
| 140 WebRtcAecScaleErrorSignal WebRtcAec_ScaleErrorSignal; | 131 WebRtcAecScaleErrorSignal WebRtcAec_ScaleErrorSignal; |
| 141 WebRtcAecFilterAdaptation WebRtcAec_FilterAdaptation; | 132 WebRtcAecFilterAdaptation WebRtcAec_FilterAdaptation; |
| 142 WebRtcAecOverdriveAndSuppress WebRtcAec_OverdriveAndSuppress; | 133 WebRtcAecOverdriveAndSuppress WebRtcAec_OverdriveAndSuppress; |
| 143 WebRtcAecComfortNoise WebRtcAec_ComfortNoise; | 134 WebRtcAecComfortNoise WebRtcAec_ComfortNoise; |
| 144 WebRtcAecSubBandCoherence WebRtcAec_SubbandCoherence; | 135 WebRtcAecSubBandCoherence WebRtcAec_SubbandCoherence; |
| 145 WebRtcAecStoreAsComplex WebRtcAec_StoreAsComplex; | 136 WebRtcAecStoreAsComplex WebRtcAec_StoreAsComplex; |
| 146 WebRtcAecPartitionDelay WebRtcAec_PartitionDelay; | 137 WebRtcAecPartitionDelay WebRtcAec_PartitionDelay; |
| 147 WebRtcAecWindowData WebRtcAec_WindowData; | 138 WebRtcAecWindowData WebRtcAec_WindowData; |
| 148 | 139 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 float DivergentFilterFraction::GetLatestFraction() const { | 190 float DivergentFilterFraction::GetLatestFraction() const { |
| 200 return fraction_; | 191 return fraction_; |
| 201 } | 192 } |
| 202 | 193 |
| 203 void DivergentFilterFraction::Clear() { | 194 void DivergentFilterFraction::Clear() { |
| 204 count_ = 0; | 195 count_ = 0; |
| 205 occurrence_ = 0; | 196 occurrence_ = 0; |
| 206 } | 197 } |
| 207 | 198 |
| 208 // TODO(minyue): Moving some initialization from WebRtcAec_CreateAec() to ctor. | 199 // TODO(minyue): Moving some initialization from WebRtcAec_CreateAec() to ctor. |
| 209 AecCore::AecCore() = default; | 200 AecCore::AecCore(int instance_index) |
| 201 : data_dumper(new ApmDataDumper(instance_index)) {} | |
| 202 | |
| 203 AecCore::~AecCore() {} | |
| 210 | 204 |
| 211 static int CmpFloat(const void* a, const void* b) { | 205 static int CmpFloat(const void* a, const void* b) { |
| 212 const float* da = (const float*)a; | 206 const float* da = (const float*)a; |
| 213 const float* db = (const float*)b; | 207 const float* db = (const float*)b; |
| 214 | 208 |
| 215 return (*da > *db) - (*da < *db); | 209 return (*da > *db) - (*da < *db); |
| 216 } | 210 } |
| 217 | 211 |
| 218 static void FilterFar(int num_partitions, | 212 static void FilterFar(int num_partitions, |
| 219 int x_fft_buf_block_pos, | 213 int x_fft_buf_block_pos, |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1302 } | 1296 } |
| 1303 WebRtc_ReadBuffer(aec->nearFrBuf, reinterpret_cast<void**>(&nearend_ptr), | 1297 WebRtc_ReadBuffer(aec->nearFrBuf, reinterpret_cast<void**>(&nearend_ptr), |
| 1304 nearend, PART_LEN); | 1298 nearend, PART_LEN); |
| 1305 memcpy(aec->dBuf + PART_LEN, nearend_ptr, sizeof(nearend)); | 1299 memcpy(aec->dBuf + PART_LEN, nearend_ptr, sizeof(nearend)); |
| 1306 | 1300 |
| 1307 // We should always have at least one element stored in |far_buf|. | 1301 // We should always have at least one element stored in |far_buf|. |
| 1308 assert(WebRtc_available_read(aec->far_time_buf) > 0); | 1302 assert(WebRtc_available_read(aec->far_time_buf) > 0); |
| 1309 WebRtc_ReadBuffer(aec->far_time_buf, reinterpret_cast<void**>(&farend_ptr), | 1303 WebRtc_ReadBuffer(aec->far_time_buf, reinterpret_cast<void**>(&farend_ptr), |
| 1310 farend, 1); | 1304 farend, 1); |
| 1311 | 1305 |
| 1312 #ifdef WEBRTC_AEC_DEBUG_DUMP | 1306 aec->data_dumper->DumpWav("aec_far", PART_LEN, &farend_ptr[PART_LEN], |
|
kwiberg-webrtc
2016/05/03 00:53:00
At each of these call sites, the compiler is conve
peah-webrtc
2016/05/03 06:29:22
Great point!!!
Done.
| |
| 1313 { | 1307 aec->sampFreq > 16000 ? 16000 : aec->sampFreq, 1); |
| 1314 // TODO(minyue): |farend_ptr| starts from buffered samples. This will be | 1308 aec->data_dumper->DumpWav("aec_near", PART_LEN, nearend_ptr, |
| 1315 // modified when |aec->far_time_buf| is revised. | 1309 aec->sampFreq > 16000 ? 16000 : aec->sampFreq, 1); |
|
kwiberg-webrtc
2016/05/03 00:53:01
std::min(aec->sampFreq, 16000)
(Also in several p
peah-webrtc
2016/05/03 06:29:22
Done.
| |
| 1316 RTC_AEC_DEBUG_WAV_WRITE(aec->farFile, &farend_ptr[PART_LEN], PART_LEN); | |
| 1317 | |
| 1318 RTC_AEC_DEBUG_WAV_WRITE(aec->nearFile, nearend_ptr, PART_LEN); | |
| 1319 } | |
| 1320 #endif | |
| 1321 | 1310 |
| 1322 if (aec->metricsMode == 1) { | 1311 if (aec->metricsMode == 1) { |
| 1323 // Update power levels | 1312 // Update power levels |
| 1324 UpdateLevel(&aec->farlevel, | 1313 UpdateLevel(&aec->farlevel, |
| 1325 CalculatePower(&farend_ptr[PART_LEN], PART_LEN)); | 1314 CalculatePower(&farend_ptr[PART_LEN], PART_LEN)); |
| 1326 UpdateLevel(&aec->nearlevel, CalculatePower(nearend_ptr, PART_LEN)); | 1315 UpdateLevel(&aec->nearlevel, CalculatePower(nearend_ptr, PART_LEN)); |
| 1327 } | 1316 } |
| 1328 | 1317 |
| 1329 // Convert far-end signal to the frequency domain. | 1318 // Convert far-end signal to the frequency domain. |
| 1330 memcpy(fft, farend_ptr, sizeof(float) * PART_LEN2); | 1319 memcpy(fft, farend_ptr, sizeof(float) * PART_LEN2); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1410 } | 1399 } |
| 1411 } | 1400 } |
| 1412 | 1401 |
| 1413 // Perform echo subtraction. | 1402 // Perform echo subtraction. |
| 1414 EchoSubtraction(aec->num_partitions, aec->extended_filter_enabled, | 1403 EchoSubtraction(aec->num_partitions, aec->extended_filter_enabled, |
| 1415 &aec->extreme_filter_divergence, aec->filter_step_size, | 1404 &aec->extreme_filter_divergence, aec->filter_step_size, |
| 1416 aec->error_threshold, &x_fft[0][0], &aec->xfBufBlockPos, | 1405 aec->error_threshold, &x_fft[0][0], &aec->xfBufBlockPos, |
| 1417 aec->xfBuf, nearend_ptr, aec->xPow, aec->wfBuf, | 1406 aec->xfBuf, nearend_ptr, aec->xPow, aec->wfBuf, |
| 1418 echo_subtractor_output); | 1407 echo_subtractor_output); |
| 1419 | 1408 |
| 1420 RTC_AEC_DEBUG_WAV_WRITE(aec->outLinearFile, echo_subtractor_output, PART_LEN); | 1409 aec->data_dumper->DumpWav("aec_out_linear", PART_LEN, echo_subtractor_output, |
| 1410 aec->sampFreq > 16000 ? 16000 : aec->sampFreq, 1); | |
| 1421 | 1411 |
| 1422 if (aec->metricsMode == 1) { | 1412 if (aec->metricsMode == 1) { |
| 1423 UpdateLevel(&aec->linoutlevel, | 1413 UpdateLevel(&aec->linoutlevel, |
| 1424 CalculatePower(echo_subtractor_output, PART_LEN)); | 1414 CalculatePower(echo_subtractor_output, PART_LEN)); |
| 1425 } | 1415 } |
| 1426 | 1416 |
| 1427 // Perform echo suppression. | 1417 // Perform echo suppression. |
| 1428 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); | 1418 EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr); |
| 1429 | 1419 |
| 1430 if (aec->metricsMode == 1) { | 1420 if (aec->metricsMode == 1) { |
| 1431 UpdateLevel(&aec->nlpoutlevel, CalculatePower(output, PART_LEN)); | 1421 UpdateLevel(&aec->nlpoutlevel, CalculatePower(output, PART_LEN)); |
| 1432 UpdateMetrics(aec); | 1422 UpdateMetrics(aec); |
| 1433 } | 1423 } |
| 1434 | 1424 |
| 1435 // Store the output block. | 1425 // Store the output block. |
| 1436 WebRtc_WriteBuffer(aec->outFrBuf, output, PART_LEN); | 1426 WebRtc_WriteBuffer(aec->outFrBuf, output, PART_LEN); |
| 1437 // For high bands | 1427 // For high bands |
| 1438 for (i = 0; i < aec->num_bands - 1; ++i) { | 1428 for (i = 0; i < aec->num_bands - 1; ++i) { |
| 1439 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); | 1429 WebRtc_WriteBuffer(aec->outFrBufH[i], outputH[i], PART_LEN); |
| 1440 } | 1430 } |
| 1441 | 1431 |
| 1442 RTC_AEC_DEBUG_WAV_WRITE(aec->outFile, output, PART_LEN); | 1432 aec->data_dumper->DumpWav("aec_out", PART_LEN, output, |
| 1433 aec->sampFreq > 16000 ? 16000 : aec->sampFreq, 1); | |
| 1443 } | 1434 } |
| 1444 | 1435 |
| 1445 AecCore* WebRtcAec_CreateAec() { | 1436 AecCore* WebRtcAec_CreateAec(int instance_count) { |
| 1446 int i; | 1437 int i; |
| 1447 AecCore* aec = new AecCore; | 1438 AecCore* aec = new AecCore(instance_count); |
| 1439 | |
| 1448 if (!aec) { | 1440 if (!aec) { |
| 1449 return NULL; | 1441 return NULL; |
| 1450 } | 1442 } |
| 1451 | 1443 |
| 1452 aec->nearFrBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(float)); | 1444 aec->nearFrBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(float)); |
| 1453 if (!aec->nearFrBuf) { | 1445 if (!aec->nearFrBuf) { |
| 1454 WebRtcAec_FreeAec(aec); | 1446 WebRtcAec_FreeAec(aec); |
| 1455 return NULL; | 1447 return NULL; |
| 1456 } | 1448 } |
| 1457 | 1449 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1481 // supposed to contain |PART_LEN2| samples with an overlap of |PART_LEN| | 1473 // supposed to contain |PART_LEN2| samples with an overlap of |PART_LEN| |
| 1482 // samples from the last frame. | 1474 // samples from the last frame. |
| 1483 // TODO(minyue): reduce |far_time_buf| to non-overlapped |PART_LEN| samples. | 1475 // TODO(minyue): reduce |far_time_buf| to non-overlapped |PART_LEN| samples. |
| 1484 aec->far_time_buf = | 1476 aec->far_time_buf = |
| 1485 WebRtc_CreateBuffer(kBufSizePartitions, sizeof(float) * PART_LEN2); | 1477 WebRtc_CreateBuffer(kBufSizePartitions, sizeof(float) * PART_LEN2); |
| 1486 if (!aec->far_time_buf) { | 1478 if (!aec->far_time_buf) { |
| 1487 WebRtcAec_FreeAec(aec); | 1479 WebRtcAec_FreeAec(aec); |
| 1488 return NULL; | 1480 return NULL; |
| 1489 } | 1481 } |
| 1490 | 1482 |
| 1491 #ifdef WEBRTC_AEC_DEBUG_DUMP | |
| 1492 aec->instance_index = webrtc_aec_instance_count; | |
| 1493 | |
| 1494 aec->farFile = aec->nearFile = aec->outFile = aec->outLinearFile = NULL; | |
| 1495 aec->debug_dump_count = 0; | |
| 1496 #endif | |
| 1497 aec->delay_estimator_farend = | 1483 aec->delay_estimator_farend = |
| 1498 WebRtc_CreateDelayEstimatorFarend(PART_LEN1, kHistorySizeBlocks); | 1484 WebRtc_CreateDelayEstimatorFarend(PART_LEN1, kHistorySizeBlocks); |
| 1499 if (aec->delay_estimator_farend == NULL) { | 1485 if (aec->delay_estimator_farend == NULL) { |
| 1500 WebRtcAec_FreeAec(aec); | 1486 WebRtcAec_FreeAec(aec); |
| 1501 return NULL; | 1487 return NULL; |
| 1502 } | 1488 } |
| 1503 // We create the delay_estimator with the same amount of maximum lookahead as | 1489 // We create the delay_estimator with the same amount of maximum lookahead as |
| 1504 // the delay history size (kHistorySizeBlocks) for symmetry reasons. | 1490 // the delay history size (kHistorySizeBlocks) for symmetry reasons. |
| 1505 aec->delay_estimator = WebRtc_CreateDelayEstimator( | 1491 aec->delay_estimator = WebRtc_CreateDelayEstimator( |
| 1506 aec->delay_estimator_farend, kHistorySizeBlocks); | 1492 aec->delay_estimator_farend, kHistorySizeBlocks); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1564 WebRtc_FreeBuffer(aec->nearFrBuf); | 1550 WebRtc_FreeBuffer(aec->nearFrBuf); |
| 1565 WebRtc_FreeBuffer(aec->outFrBuf); | 1551 WebRtc_FreeBuffer(aec->outFrBuf); |
| 1566 | 1552 |
| 1567 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { | 1553 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { |
| 1568 WebRtc_FreeBuffer(aec->nearFrBufH[i]); | 1554 WebRtc_FreeBuffer(aec->nearFrBufH[i]); |
| 1569 WebRtc_FreeBuffer(aec->outFrBufH[i]); | 1555 WebRtc_FreeBuffer(aec->outFrBufH[i]); |
| 1570 } | 1556 } |
| 1571 | 1557 |
| 1572 WebRtc_FreeBuffer(aec->far_time_buf); | 1558 WebRtc_FreeBuffer(aec->far_time_buf); |
| 1573 | 1559 |
| 1574 RTC_AEC_DEBUG_WAV_CLOSE(aec->farFile); | |
| 1575 RTC_AEC_DEBUG_WAV_CLOSE(aec->nearFile); | |
| 1576 RTC_AEC_DEBUG_WAV_CLOSE(aec->outFile); | |
| 1577 RTC_AEC_DEBUG_WAV_CLOSE(aec->outLinearFile); | |
| 1578 RTC_AEC_DEBUG_RAW_CLOSE(aec->e_fft_file); | |
| 1579 | |
| 1580 WebRtc_FreeDelayEstimator(aec->delay_estimator); | 1560 WebRtc_FreeDelayEstimator(aec->delay_estimator); |
| 1581 WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend); | 1561 WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend); |
| 1582 | 1562 |
| 1583 delete aec; | 1563 delete aec; |
| 1584 } | 1564 } |
| 1585 | 1565 |
| 1586 static void SetAdaptiveFilterStepSize(AecCore* aec) { | 1566 static void SetAdaptiveFilterStepSize(AecCore* aec) { |
| 1587 // Extended filter adaptation parameter. | 1567 // Extended filter adaptation parameter. |
| 1588 // TODO(ajm): No narrowband tuning yet. | 1568 // TODO(ajm): No narrowband tuning yet. |
| 1589 const float kExtendedMu = 0.4f; | 1569 const float kExtendedMu = 0.4f; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1614 if (aec->sampFreq == 8000) { | 1594 if (aec->sampFreq == 8000) { |
| 1615 aec->error_threshold = 2e-6f; | 1595 aec->error_threshold = 2e-6f; |
| 1616 } else { | 1596 } else { |
| 1617 aec->error_threshold = 1.5e-6f; | 1597 aec->error_threshold = 1.5e-6f; |
| 1618 } | 1598 } |
| 1619 } | 1599 } |
| 1620 } | 1600 } |
| 1621 | 1601 |
| 1622 int WebRtcAec_InitAec(AecCore* aec, int sampFreq) { | 1602 int WebRtcAec_InitAec(AecCore* aec, int sampFreq) { |
| 1623 int i; | 1603 int i; |
| 1604 aec->data_dumper->InitiateNewSetOfRecordings(); | |
| 1624 | 1605 |
| 1625 aec->sampFreq = sampFreq; | 1606 aec->sampFreq = sampFreq; |
| 1626 | 1607 |
| 1627 SetAdaptiveFilterStepSize(aec); | 1608 SetAdaptiveFilterStepSize(aec); |
| 1628 SetErrorThreshold(aec); | 1609 SetErrorThreshold(aec); |
| 1629 | 1610 |
| 1630 if (sampFreq == 8000) { | 1611 if (sampFreq == 8000) { |
| 1631 aec->num_bands = 1; | 1612 aec->num_bands = 1; |
| 1632 } else { | 1613 } else { |
| 1633 aec->num_bands = (size_t)(sampFreq / 16000); | 1614 aec->num_bands = (size_t)(sampFreq / 16000); |
| 1634 } | 1615 } |
| 1635 | 1616 |
| 1636 WebRtc_InitBuffer(aec->nearFrBuf); | 1617 WebRtc_InitBuffer(aec->nearFrBuf); |
| 1637 WebRtc_InitBuffer(aec->outFrBuf); | 1618 WebRtc_InitBuffer(aec->outFrBuf); |
| 1638 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { | 1619 for (i = 0; i < NUM_HIGH_BANDS_MAX; ++i) { |
| 1639 WebRtc_InitBuffer(aec->nearFrBufH[i]); | 1620 WebRtc_InitBuffer(aec->nearFrBufH[i]); |
| 1640 WebRtc_InitBuffer(aec->outFrBufH[i]); | 1621 WebRtc_InitBuffer(aec->outFrBufH[i]); |
| 1641 } | 1622 } |
| 1642 | 1623 |
| 1643 // Initialize far-end buffers. | 1624 // Initialize far-end buffers. |
| 1644 WebRtc_InitBuffer(aec->far_time_buf); | 1625 WebRtc_InitBuffer(aec->far_time_buf); |
| 1645 | 1626 |
| 1646 #ifdef WEBRTC_AEC_DEBUG_DUMP | |
| 1647 { | |
| 1648 int process_rate = sampFreq > 16000 ? 16000 : sampFreq; | |
| 1649 RTC_AEC_DEBUG_WAV_REOPEN("aec_far", aec->instance_index, | |
| 1650 aec->debug_dump_count, process_rate, | |
| 1651 &aec->farFile); | |
| 1652 RTC_AEC_DEBUG_WAV_REOPEN("aec_near", aec->instance_index, | |
| 1653 aec->debug_dump_count, process_rate, | |
| 1654 &aec->nearFile); | |
| 1655 RTC_AEC_DEBUG_WAV_REOPEN("aec_out", aec->instance_index, | |
| 1656 aec->debug_dump_count, process_rate, | |
| 1657 &aec->outFile); | |
| 1658 RTC_AEC_DEBUG_WAV_REOPEN("aec_out_linear", aec->instance_index, | |
| 1659 aec->debug_dump_count, process_rate, | |
| 1660 &aec->outLinearFile); | |
| 1661 } | |
| 1662 | |
| 1663 RTC_AEC_DEBUG_RAW_OPEN("aec_e_fft", aec->debug_dump_count, &aec->e_fft_file); | |
| 1664 | |
| 1665 ++aec->debug_dump_count; | |
| 1666 #endif | |
| 1667 aec->system_delay = 0; | 1627 aec->system_delay = 0; |
| 1668 | 1628 |
| 1669 if (WebRtc_InitDelayEstimatorFarend(aec->delay_estimator_farend) != 0) { | 1629 if (WebRtc_InitDelayEstimatorFarend(aec->delay_estimator_farend) != 0) { |
| 1670 return -1; | 1630 return -1; |
| 1671 } | 1631 } |
| 1672 if (WebRtc_InitDelayEstimator(aec->delay_estimator) != 0) { | 1632 if (WebRtc_InitDelayEstimator(aec->delay_estimator) != 0) { |
| 1673 return -1; | 1633 return -1; |
| 1674 } | 1634 } |
| 1675 aec->delay_logging_enabled = 0; | 1635 aec->delay_logging_enabled = 0; |
| 1676 aec->delay_metrics_delivered = 0; | 1636 aec->delay_metrics_delivered = 0; |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2025 | 1985 |
| 2026 int WebRtcAec_system_delay(AecCore* self) { | 1986 int WebRtcAec_system_delay(AecCore* self) { |
| 2027 return self->system_delay; | 1987 return self->system_delay; |
| 2028 } | 1988 } |
| 2029 | 1989 |
| 2030 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1990 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
| 2031 assert(delay >= 0); | 1991 assert(delay >= 0); |
| 2032 self->system_delay = delay; | 1992 self->system_delay = delay; |
| 2033 } | 1993 } |
| 2034 } // namespace webrtc | 1994 } // namespace webrtc |
| OLD | NEW |