| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 void BlockBuffer::ReInit() { | 195 void BlockBuffer::ReInit() { |
| 196 WebRtc_InitBuffer(buffer_); | 196 WebRtc_InitBuffer(buffer_); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void BlockBuffer::Insert(const float block[PART_LEN]) { | 199 void BlockBuffer::Insert(const float block[PART_LEN]) { |
| 200 WebRtc_WriteBuffer(buffer_, block, 1); | 200 WebRtc_WriteBuffer(buffer_, block, 1); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void BlockBuffer::ExtractExtendedBlock(float extended_block[PART_LEN2]) { | 203 void BlockBuffer::ExtractExtendedBlock(float extended_block[PART_LEN2]) { |
| 204 float* block_ptr = NULL; | 204 float* block_ptr = nullptr; |
| 205 RTC_DCHECK_LT(0, AvaliableSpace()); | 205 RTC_DCHECK_LT(0, AvaliableSpace()); |
| 206 | 206 |
| 207 // Extract the previous block. | 207 // Extract the previous block. |
| 208 WebRtc_MoveReadPtr(buffer_, -1); | 208 WebRtc_MoveReadPtr(buffer_, -1); |
| 209 WebRtc_ReadBuffer(buffer_, reinterpret_cast<void**>(&block_ptr), | 209 WebRtc_ReadBuffer(buffer_, reinterpret_cast<void**>(&block_ptr), |
| 210 &extended_block[0], 1); | 210 &extended_block[0], 1); |
| 211 if (block_ptr != &extended_block[0]) { | 211 if (block_ptr != &extended_block[0]) { |
| 212 memcpy(&extended_block[0], block_ptr, PART_LEN * sizeof(float)); | 212 memcpy(&extended_block[0], block_ptr, PART_LEN * sizeof(float)); |
| 213 } | 213 } |
| 214 | 214 |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 int i; | 1171 int i; |
| 1172 size_t j; | 1172 size_t j; |
| 1173 | 1173 |
| 1174 // Coherence and non-linear filter | 1174 // Coherence and non-linear filter |
| 1175 float cohde[PART_LEN1], cohxd[PART_LEN1]; | 1175 float cohde[PART_LEN1], cohxd[PART_LEN1]; |
| 1176 float hNl[PART_LEN1]; | 1176 float hNl[PART_LEN1]; |
| 1177 | 1177 |
| 1178 // Filter energy | 1178 // Filter energy |
| 1179 const int delayEstInterval = 10 * aec->mult; | 1179 const int delayEstInterval = 10 * aec->mult; |
| 1180 | 1180 |
| 1181 float* xfw_ptr = NULL; | 1181 float* xfw_ptr = nullptr; |
| 1182 | 1182 |
| 1183 // Update eBuf with echo subtractor output. | 1183 // Update eBuf with echo subtractor output. |
| 1184 memcpy(aec->eBuf + PART_LEN, echo_subtractor_output, | 1184 memcpy(aec->eBuf + PART_LEN, echo_subtractor_output, |
| 1185 sizeof(float) * PART_LEN); | 1185 sizeof(float) * PART_LEN); |
| 1186 | 1186 |
| 1187 // Analysis filter banks for the echo suppressor. | 1187 // Analysis filter banks for the echo suppressor. |
| 1188 // Windowed near-end ffts. | 1188 // Windowed near-end ffts. |
| 1189 WindowData(fft, nearend_extended_block_lowest_band); | 1189 WindowData(fft, nearend_extended_block_lowest_band); |
| 1190 ooura_fft.Fft(fft); | 1190 ooura_fft.Fft(fft); |
| 1191 StoreAsComplex(fft, dfw); | 1191 StoreAsComplex(fft, dfw); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 aec->data_dumper->DumpWav("aec_out", PART_LEN, &output_block[0][0], | 1462 aec->data_dumper->DumpWav("aec_out", PART_LEN, &output_block[0][0], |
| 1463 std::min(aec->sampFreq, 16000), 1); | 1463 std::min(aec->sampFreq, 16000), 1); |
| 1464 } | 1464 } |
| 1465 | 1465 |
| 1466 AecCore* WebRtcAec_CreateAec(int instance_count) { | 1466 AecCore* WebRtcAec_CreateAec(int instance_count) { |
| 1467 AecCore* aec = new AecCore(instance_count); | 1467 AecCore* aec = new AecCore(instance_count); |
| 1468 | 1468 |
| 1469 if (!aec) { | 1469 if (!aec) { |
| 1470 return NULL; | 1470 return nullptr; |
| 1471 } | 1471 } |
| 1472 aec->nearend_buffer_size = 0; | 1472 aec->nearend_buffer_size = 0; |
| 1473 memset(&aec->nearend_buffer[0], 0, sizeof(aec->nearend_buffer)); | 1473 memset(&aec->nearend_buffer[0], 0, sizeof(aec->nearend_buffer)); |
| 1474 // Start the output buffer with zeros to be able to produce | 1474 // Start the output buffer with zeros to be able to produce |
| 1475 // a full output frame in the first frame. | 1475 // a full output frame in the first frame. |
| 1476 aec->output_buffer_size = PART_LEN - (FRAME_LEN - PART_LEN); | 1476 aec->output_buffer_size = PART_LEN - (FRAME_LEN - PART_LEN); |
| 1477 memset(&aec->output_buffer[0], 0, sizeof(aec->output_buffer)); | 1477 memset(&aec->output_buffer[0], 0, sizeof(aec->output_buffer)); |
| 1478 | 1478 |
| 1479 aec->delay_estimator_farend = | 1479 aec->delay_estimator_farend = |
| 1480 WebRtc_CreateDelayEstimatorFarend(PART_LEN1, kHistorySizeBlocks); | 1480 WebRtc_CreateDelayEstimatorFarend(PART_LEN1, kHistorySizeBlocks); |
| 1481 if (aec->delay_estimator_farend == NULL) { | 1481 if (aec->delay_estimator_farend == nullptr) { |
| 1482 WebRtcAec_FreeAec(aec); | 1482 WebRtcAec_FreeAec(aec); |
| 1483 return NULL; | 1483 return nullptr; |
| 1484 } | 1484 } |
| 1485 // We create the delay_estimator with the same amount of maximum lookahead as | 1485 // We create the delay_estimator with the same amount of maximum lookahead as |
| 1486 // the delay history size (kHistorySizeBlocks) for symmetry reasons. | 1486 // the delay history size (kHistorySizeBlocks) for symmetry reasons. |
| 1487 aec->delay_estimator = WebRtc_CreateDelayEstimator( | 1487 aec->delay_estimator = WebRtc_CreateDelayEstimator( |
| 1488 aec->delay_estimator_farend, kHistorySizeBlocks); | 1488 aec->delay_estimator_farend, kHistorySizeBlocks); |
| 1489 if (aec->delay_estimator == NULL) { | 1489 if (aec->delay_estimator == nullptr) { |
| 1490 WebRtcAec_FreeAec(aec); | 1490 WebRtcAec_FreeAec(aec); |
| 1491 return NULL; | 1491 return nullptr; |
| 1492 } | 1492 } |
| 1493 #ifdef WEBRTC_ANDROID | 1493 #ifdef WEBRTC_ANDROID |
| 1494 aec->delay_agnostic_enabled = 1; // DA-AEC enabled by default. | 1494 aec->delay_agnostic_enabled = 1; // DA-AEC enabled by default. |
| 1495 // DA-AEC assumes the system is causal from the beginning and will self adjust | 1495 // DA-AEC assumes the system is causal from the beginning and will self adjust |
| 1496 // the lookahead when shifting is required. | 1496 // the lookahead when shifting is required. |
| 1497 WebRtc_set_lookahead(aec->delay_estimator, 0); | 1497 WebRtc_set_lookahead(aec->delay_estimator, 0); |
| 1498 #else | 1498 #else |
| 1499 aec->delay_agnostic_enabled = 0; | 1499 aec->delay_agnostic_enabled = 0; |
| 1500 WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks); | 1500 WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks); |
| 1501 #endif | 1501 #endif |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1525 #endif | 1525 #endif |
| 1526 | 1526 |
| 1527 #if defined(WEBRTC_HAS_NEON) | 1527 #if defined(WEBRTC_HAS_NEON) |
| 1528 WebRtcAec_InitAec_neon(); | 1528 WebRtcAec_InitAec_neon(); |
| 1529 #endif | 1529 #endif |
| 1530 | 1530 |
| 1531 return aec; | 1531 return aec; |
| 1532 } | 1532 } |
| 1533 | 1533 |
| 1534 void WebRtcAec_FreeAec(AecCore* aec) { | 1534 void WebRtcAec_FreeAec(AecCore* aec) { |
| 1535 if (aec == NULL) { | 1535 if (aec == nullptr) { |
| 1536 return; | 1536 return; |
| 1537 } | 1537 } |
| 1538 | 1538 |
| 1539 WebRtc_FreeDelayEstimator(aec->delay_estimator); | 1539 WebRtc_FreeDelayEstimator(aec->delay_estimator); |
| 1540 WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend); | 1540 WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend); |
| 1541 | 1541 |
| 1542 delete aec; | 1542 delete aec; |
| 1543 } | 1543 } |
| 1544 | 1544 |
| 1545 static void SetAdaptiveFilterStepSize(AecCore* aec) { | 1545 static void SetAdaptiveFilterStepSize(AecCore* aec) { |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 | 2038 |
| 2039 int WebRtcAec_system_delay(AecCore* self) { | 2039 int WebRtcAec_system_delay(AecCore* self) { |
| 2040 return self->system_delay; | 2040 return self->system_delay; |
| 2041 } | 2041 } |
| 2042 | 2042 |
| 2043 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 2043 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
| 2044 RTC_DCHECK_GE(delay, 0); | 2044 RTC_DCHECK_GE(delay, 0); |
| 2045 self->system_delay = delay; | 2045 self->system_delay = delay; |
| 2046 } | 2046 } |
| 2047 } // namespace webrtc | 2047 } // namespace webrtc |
| OLD | NEW |