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 #include "webrtc/modules/audio_processing/aecm/aecm_core.h" | 11 #include "webrtc/modules/audio_processing/aecm/aecm_core.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 #include <stddef.h> | 14 #include <stddef.h> |
15 #include <stdlib.h> | 15 #include <stdlib.h> |
16 | 16 |
| 17 extern "C" { |
17 #include "webrtc/common_audio/ring_buffer.h" | 18 #include "webrtc/common_audio/ring_buffer.h" |
18 #include "webrtc/common_audio/signal_processing/include/real_fft.h" | 19 #include "webrtc/common_audio/signal_processing/include/real_fft.h" |
19 #include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" | 20 #include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" |
20 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" | 21 #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" |
21 #include "webrtc/system_wrappers/include/compile_assert_c.h" | |
22 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" | 22 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" |
| 23 } |
23 #include "webrtc/typedefs.h" | 24 #include "webrtc/typedefs.h" |
24 | 25 |
25 #ifdef AEC_DEBUG | 26 #ifdef AEC_DEBUG |
26 FILE *dfile; | 27 FILE *dfile; |
27 FILE *testfile; | 28 FILE *testfile; |
28 #endif | 29 #endif |
29 | 30 |
30 const int16_t WebRtcAecm_kCosTable[] = { | 31 const int16_t WebRtcAecm_kCosTable[] = { |
31 8192, 8190, 8187, 8180, 8172, 8160, 8147, 8130, 8112, | 32 8192, 8190, 8187, 8180, 8172, 8160, 8147, 8130, 8112, |
32 8091, 8067, 8041, 8012, 7982, 7948, 7912, 7874, 7834, | 33 8091, 8067, 8041, 8012, 7982, 7948, 7912, 7874, 7834, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // Return far end spectrum | 202 // Return far end spectrum |
202 return &(self->far_history[buffer_position * PART_LEN1]); | 203 return &(self->far_history[buffer_position * PART_LEN1]); |
203 } | 204 } |
204 | 205 |
205 // Declare function pointers. | 206 // Declare function pointers. |
206 CalcLinearEnergies WebRtcAecm_CalcLinearEnergies; | 207 CalcLinearEnergies WebRtcAecm_CalcLinearEnergies; |
207 StoreAdaptiveChannel WebRtcAecm_StoreAdaptiveChannel; | 208 StoreAdaptiveChannel WebRtcAecm_StoreAdaptiveChannel; |
208 ResetAdaptiveChannel WebRtcAecm_ResetAdaptiveChannel; | 209 ResetAdaptiveChannel WebRtcAecm_ResetAdaptiveChannel; |
209 | 210 |
210 AecmCore* WebRtcAecm_CreateCore() { | 211 AecmCore* WebRtcAecm_CreateCore() { |
211 AecmCore* aecm = malloc(sizeof(AecmCore)); | 212 AecmCore* aecm = static_cast<AecmCore*>(malloc(sizeof(AecmCore))); |
212 | 213 |
213 aecm->farFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, | 214 aecm->farFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, |
214 sizeof(int16_t)); | 215 sizeof(int16_t)); |
215 if (!aecm->farFrameBuf) | 216 if (!aecm->farFrameBuf) |
216 { | 217 { |
217 WebRtcAecm_FreeCore(aecm); | 218 WebRtcAecm_FreeCore(aecm); |
218 return NULL; | 219 return NULL; |
219 } | 220 } |
220 | 221 |
221 aecm->nearNoisyFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, | 222 aecm->nearNoisyFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 aecm->supGain = SUPGAIN_DEFAULT; | 495 aecm->supGain = SUPGAIN_DEFAULT; |
495 aecm->supGainOld = SUPGAIN_DEFAULT; | 496 aecm->supGainOld = SUPGAIN_DEFAULT; |
496 | 497 |
497 aecm->supGainErrParamA = SUPGAIN_ERROR_PARAM_A; | 498 aecm->supGainErrParamA = SUPGAIN_ERROR_PARAM_A; |
498 aecm->supGainErrParamD = SUPGAIN_ERROR_PARAM_D; | 499 aecm->supGainErrParamD = SUPGAIN_ERROR_PARAM_D; |
499 aecm->supGainErrParamDiffAB = SUPGAIN_ERROR_PARAM_A - SUPGAIN_ERROR_PARAM_B; | 500 aecm->supGainErrParamDiffAB = SUPGAIN_ERROR_PARAM_A - SUPGAIN_ERROR_PARAM_B; |
500 aecm->supGainErrParamDiffBD = SUPGAIN_ERROR_PARAM_B - SUPGAIN_ERROR_PARAM_D; | 501 aecm->supGainErrParamDiffBD = SUPGAIN_ERROR_PARAM_B - SUPGAIN_ERROR_PARAM_D; |
501 | 502 |
502 // Assert a preprocessor definition at compile-time. It's an assumption | 503 // Assert a preprocessor definition at compile-time. It's an assumption |
503 // used in assembly code, so check the assembly files before any change. | 504 // used in assembly code, so check the assembly files before any change. |
504 COMPILE_ASSERT(PART_LEN % 16 == 0); | 505 static_assert(PART_LEN % 16 == 0, "PART_LEN is not a multiple of 16"); |
505 | 506 |
506 // Initialize function pointers. | 507 // Initialize function pointers. |
507 WebRtcAecm_CalcLinearEnergies = CalcLinearEnergiesC; | 508 WebRtcAecm_CalcLinearEnergies = CalcLinearEnergiesC; |
508 WebRtcAecm_StoreAdaptiveChannel = StoreAdaptiveChannelC; | 509 WebRtcAecm_StoreAdaptiveChannel = StoreAdaptiveChannelC; |
509 WebRtcAecm_ResetAdaptiveChannel = ResetAdaptiveChannelC; | 510 WebRtcAecm_ResetAdaptiveChannel = ResetAdaptiveChannelC; |
510 | 511 |
511 #ifdef WEBRTC_DETECT_NEON | 512 #ifdef WEBRTC_DETECT_NEON |
512 uint64_t features = WebRtc_GetCPUFeaturesARM(); | 513 uint64_t features = WebRtc_GetCPUFeaturesARM(); |
513 if ((features & kCPUFeatureNEON) != 0) | 514 if ((features & kCPUFeatureNEON) != 0) |
514 { | 515 { |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 memcpy(farend + readPos, aecm->farBuf + aecm->farBufReadPos, | 1225 memcpy(farend + readPos, aecm->farBuf + aecm->farBufReadPos, |
1225 sizeof(int16_t) * readLen); | 1226 sizeof(int16_t) * readLen); |
1226 aecm->farBufReadPos = 0; | 1227 aecm->farBufReadPos = 0; |
1227 readPos = readLen; | 1228 readPos = readLen; |
1228 readLen = farLen - readLen; | 1229 readLen = farLen - readLen; |
1229 } | 1230 } |
1230 memcpy(farend + readPos, aecm->farBuf + aecm->farBufReadPos, | 1231 memcpy(farend + readPos, aecm->farBuf + aecm->farBufReadPos, |
1231 sizeof(int16_t) * readLen); | 1232 sizeof(int16_t) * readLen); |
1232 aecm->farBufReadPos += readLen; | 1233 aecm->farBufReadPos += readLen; |
1233 } | 1234 } |
OLD | NEW |