diff --git a/webrtc/modules/audio_processing/BUILD.gn b/webrtc/modules/audio_processing/BUILD.gn index 22c904d52f..1060ec8871 100644 --- a/webrtc/modules/audio_processing/BUILD.gn +++ b/webrtc/modules/audio_processing/BUILD.gn @@ -32,9 +32,9 @@ source_set("audio_processing") { "aec/echo_cancellation.cc", "aec/echo_cancellation.h", "aec/echo_cancellation_internal.h", - "aecm/aecm_core.c", + "aecm/aecm_core.cc", "aecm/aecm_core.h", - "aecm/echo_control_mobile.c", + "aecm/echo_control_mobile.cc", "aecm/echo_control_mobile.h", "agc/agc.cc", "agc/agc.h", @@ -196,7 +196,7 @@ source_set("audio_processing") { } if (current_cpu == "mipsel") { - sources += [ "aecm/aecm_core_mips.c" ] + sources += [ "aecm/aecm_core_mips.cc" ] if (mips_float_abi == "hard") { sources += [ "aec/aec_core_mips.cc", @@ -204,7 +204,7 @@ source_set("audio_processing") { ] } } else { - sources += [ "aecm/aecm_core_c.c" ] + sources += [ "aecm/aecm_core_c.cc" ] } if (is_win) { @@ -258,7 +258,7 @@ if (rtc_build_with_neon) { sources = [ "aec/aec_core_neon.cc", "aec/aec_rdft_neon.c", - "aecm/aecm_core_neon.c", + "aecm/aecm_core_neon.cc", "ns/nsx_core_neon.c", ] diff --git a/webrtc/modules/audio_processing/aecm/aecm_core.c b/webrtc/modules/audio_processing/aecm/aecm_core.cc similarity index 99% rename from webrtc/modules/audio_processing/aecm/aecm_core.c rename to webrtc/modules/audio_processing/aecm/aecm_core.cc index 6bf1cf7f3e..5c3db1a294 100644 --- a/webrtc/modules/audio_processing/aecm/aecm_core.c +++ b/webrtc/modules/audio_processing/aecm/aecm_core.cc @@ -14,12 +14,13 @@ #include #include +extern "C" { #include "webrtc/common_audio/ring_buffer.h" #include "webrtc/common_audio/signal_processing/include/real_fft.h" #include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" -#include "webrtc/system_wrappers/include/compile_assert_c.h" #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" +} #include "webrtc/typedefs.h" #ifdef AEC_DEBUG @@ -208,7 +209,7 @@ StoreAdaptiveChannel WebRtcAecm_StoreAdaptiveChannel; ResetAdaptiveChannel WebRtcAecm_ResetAdaptiveChannel; AecmCore* WebRtcAecm_CreateCore() { - AecmCore* aecm = malloc(sizeof(AecmCore)); + AecmCore* aecm = static_cast(malloc(sizeof(AecmCore))); aecm->farFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t)); @@ -501,7 +502,7 @@ int WebRtcAecm_InitCore(AecmCore* const aecm, int samplingFreq) { // Assert a preprocessor definition at compile-time. It's an assumption // used in assembly code, so check the assembly files before any change. - COMPILE_ASSERT(PART_LEN % 16 == 0); + static_assert(PART_LEN % 16 == 0, "PART_LEN is not a multiple of 16"); // Initialize function pointers. WebRtcAecm_CalcLinearEnergies = CalcLinearEnergiesC; diff --git a/webrtc/modules/audio_processing/aecm/aecm_core.h b/webrtc/modules/audio_processing/aecm/aecm_core.h index b52bb62d2d..421a8365c2 100644 --- a/webrtc/modules/audio_processing/aecm/aecm_core.h +++ b/webrtc/modules/audio_processing/aecm/aecm_core.h @@ -13,8 +13,10 @@ #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AECM_AECM_CORE_H_ #define WEBRTC_MODULES_AUDIO_PROCESSING_AECM_AECM_CORE_H_ +extern "C" { #include "webrtc/common_audio/ring_buffer.h" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" +} #include "webrtc/modules/audio_processing/aecm/aecm_defines.h" #include "webrtc/typedefs.h" diff --git a/webrtc/modules/audio_processing/aecm/aecm_core_c.c b/webrtc/modules/audio_processing/aecm/aecm_core_c.cc similarity index 99% rename from webrtc/modules/audio_processing/aecm/aecm_core_c.c rename to webrtc/modules/audio_processing/aecm/aecm_core_c.cc index 3a8fafa4ec..3ee053b092 100644 --- a/webrtc/modules/audio_processing/aecm/aecm_core_c.c +++ b/webrtc/modules/audio_processing/aecm/aecm_core_c.cc @@ -14,19 +14,18 @@ #include #include +extern "C" { #include "webrtc/common_audio/ring_buffer.h" #include "webrtc/common_audio/signal_processing/include/real_fft.h" +} #include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" +extern "C" { #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" -#include "webrtc/system_wrappers/include/compile_assert_c.h" #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" +} #include "webrtc/typedefs.h" // Square root of Hanning window in Q14. -#if defined(WEBRTC_DETECT_NEON) || defined(WEBRTC_HAS_NEON) -// Table is defined in an ARM assembly file. -extern const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END; -#else static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = { 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, 3562, 3951, 4337, 4720, 5101, 5478, 5853, 6224, @@ -37,7 +36,6 @@ static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = { 15231, 15373, 15506, 15631, 15746, 15851, 15947, 16034, 16111, 16179, 16237, 16286, 16325, 16354, 16373, 16384 }; -#endif #ifdef AECM_WITH_ABS_APPROX //Q15 alpha = 0.99439986968132 const Factor for magnitude approximation @@ -768,4 +766,3 @@ static void ComfortNoise(AecmCore* aecm, out[i].imag = WebRtcSpl_AddSatW16(out[i].imag, uImag[i]); } } - diff --git a/webrtc/modules/audio_processing/aecm/aecm_core_mips.c b/webrtc/modules/audio_processing/aecm/aecm_core_mips.cc similarity index 99% rename from webrtc/modules/audio_processing/aecm/aecm_core_mips.c rename to webrtc/modules/audio_processing/aecm/aecm_core_mips.cc index 3ca9982ebf..bca32fea1c 100644 --- a/webrtc/modules/audio_processing/aecm/aecm_core_mips.c +++ b/webrtc/modules/audio_processing/aecm/aecm_core_mips.cc @@ -13,7 +13,9 @@ #include #include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" +extern "C" { #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" +} static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = { 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, @@ -1563,4 +1565,3 @@ static void ComfortNoise(AecmCore* aecm, sgn = ((int)tt) >> 31; out[PART_LEN].imag = sgn == (int16_t)(tt >> 15) ? (int16_t)tt : (16384 ^ sgn); } - diff --git a/webrtc/modules/audio_processing/aecm/aecm_core_neon.c b/webrtc/modules/audio_processing/aecm/aecm_core_neon.cc similarity index 93% rename from webrtc/modules/audio_processing/aecm/aecm_core_neon.c rename to webrtc/modules/audio_processing/aecm/aecm_core_neon.cc index 1751fcf7ad..81c7667d98 100644 --- a/webrtc/modules/audio_processing/aecm/aecm_core_neon.c +++ b/webrtc/modules/audio_processing/aecm/aecm_core_neon.cc @@ -18,19 +18,6 @@ // TODO(kma): Re-write the corresponding assembly file, the offset // generating script and makefile, to replace these C functions. -// Square root of Hanning window in Q14. -const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = { - 0, - 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, - 3562, 3951, 4337, 4720, 5101, 5478, 5853, 6224, - 6591, 6954, 7313, 7668, 8019, 8364, 8705, 9040, - 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514, - 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553, - 13773, 13985, 14189, 14384, 14571, 14749, 14918, 15079, - 15231, 15373, 15506, 15631, 15746, 15851, 15947, 16034, - 16111, 16179, 16237, 16286, 16325, 16354, 16373, 16384 -}; - static inline void AddLanes(uint32_t* ptr, uint32x4_t v) { #if defined(WEBRTC_ARCH_ARM64) *(ptr) = vaddvq_u32(v); diff --git a/webrtc/modules/audio_processing/aecm/echo_control_mobile.c b/webrtc/modules/audio_processing/aecm/echo_control_mobile.cc similarity index 96% rename from webrtc/modules/audio_processing/aecm/echo_control_mobile.c rename to webrtc/modules/audio_processing/aecm/echo_control_mobile.cc index 91e6f0e80c..a81466e678 100644 --- a/webrtc/modules/audio_processing/aecm/echo_control_mobile.c +++ b/webrtc/modules/audio_processing/aecm/echo_control_mobile.cc @@ -15,8 +15,10 @@ #endif #include +extern "C" { #include "webrtc/common_audio/ring_buffer.h" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" +} #include "webrtc/modules/audio_processing/aecm/aecm_core.h" #define BUF_SIZE_FRAMES 50 // buffer size (frames) @@ -79,7 +81,7 @@ static int WebRtcAecm_EstBufDelay(AecMobile* aecmInst, short msInSndCardBuf); static int WebRtcAecm_DelayComp(AecMobile* aecmInst); void* WebRtcAecm_Create() { - AecMobile* aecm = malloc(sizeof(AecMobile)); + AecMobile* aecm = static_cast(malloc(sizeof(AecMobile))); WebRtcSpl_Init(); @@ -114,7 +116,7 @@ void* WebRtcAecm_Create() { } void WebRtcAecm_Free(void* aecmInst) { - AecMobile* aecm = aecmInst; + AecMobile* aecm = static_cast(aecmInst); if (aecm == NULL) { return; @@ -138,7 +140,7 @@ void WebRtcAecm_Free(void* aecmInst) { int32_t WebRtcAecm_Init(void *aecmInst, int32_t sampFreq) { - AecMobile* aecm = aecmInst; + AecMobile* aecm = static_cast(aecmInst); AecmConfig aecConfig; if (aecm == NULL) @@ -196,7 +198,7 @@ int32_t WebRtcAecm_Init(void *aecmInst, int32_t sampFreq) // farend signal. int32_t WebRtcAecm_GetBufferFarendError(void *aecmInst, const int16_t *farend, size_t nrOfSamples) { - AecMobile* aecm = aecmInst; + AecMobile* aecm = static_cast(aecmInst); if (aecm == NULL) return -1; @@ -216,7 +218,7 @@ int32_t WebRtcAecm_GetBufferFarendError(void *aecmInst, const int16_t *farend, int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend, size_t nrOfSamples) { - AecMobile* aecm = aecmInst; + AecMobile* aecm = static_cast(aecmInst); const int32_t err = WebRtcAecm_GetBufferFarendError(aecmInst, farend, nrOfSamples); @@ -239,7 +241,7 @@ int32_t WebRtcAecm_Process(void *aecmInst, const int16_t *nearendNoisy, const int16_t *nearendClean, int16_t *out, size_t nrOfSamples, int16_t msInSndCardBuf) { - AecMobile* aecm = aecmInst; + AecMobile* aecm = static_cast(aecmInst); int32_t retVal = 0; size_t i; short nmbrOfFilledBuffers; @@ -435,7 +437,7 @@ int32_t WebRtcAecm_Process(void *aecmInst, const int16_t *nearendNoisy, int32_t WebRtcAecm_set_config(void *aecmInst, AecmConfig config) { - AecMobile* aecm = aecmInst; + AecMobile* aecm = static_cast(aecmInst); if (aecm == NULL) { @@ -516,8 +518,8 @@ int32_t WebRtcAecm_InitEchoPath(void* aecmInst, const void* echo_path, size_t size_bytes) { - AecMobile* aecm = aecmInst; - const int16_t* echo_path_ptr = echo_path; + AecMobile* aecm = static_cast(aecmInst); + const int16_t* echo_path_ptr = static_cast(echo_path); if (aecmInst == NULL) { return -1; @@ -544,8 +546,8 @@ int32_t WebRtcAecm_GetEchoPath(void* aecmInst, void* echo_path, size_t size_bytes) { - AecMobile* aecm = aecmInst; - int16_t* echo_path_ptr = echo_path; + AecMobile* aecm = static_cast(aecmInst); + int16_t* echo_path_ptr = static_cast(echo_path); if (aecmInst == NULL) { return -1; diff --git a/webrtc/modules/audio_processing/audio_processing.gypi b/webrtc/modules/audio_processing/audio_processing.gypi index 264f3e5bef..2b47f7e6b0 100644 --- a/webrtc/modules/audio_processing/audio_processing.gypi +++ b/webrtc/modules/audio_processing/audio_processing.gypi @@ -42,9 +42,9 @@ 'aec/echo_cancellation.cc', 'aec/echo_cancellation_internal.h', 'aec/echo_cancellation.h', - 'aecm/aecm_core.c', + 'aecm/aecm_core.cc', 'aecm/aecm_core.h', - 'aecm/echo_control_mobile.c', + 'aecm/echo_control_mobile.cc', 'aecm/echo_control_mobile.h', 'agc/agc.cc', 'agc/agc.h', @@ -201,7 +201,7 @@ }], ['target_arch=="mipsel" and mips_arch_variant!="r6"', { 'sources': [ - 'aecm/aecm_core_mips.c', + 'aecm/aecm_core_mips.cc', ], 'conditions': [ ['mips_float_abi=="hard"', { @@ -213,7 +213,7 @@ ], }, { 'sources': [ - 'aecm/aecm_core_c.c', + 'aecm/aecm_core_c.cc', ], }], ], @@ -270,7 +270,7 @@ 'sources': [ 'aec/aec_core_neon.cc', 'aec/aec_rdft_neon.c', - 'aecm/aecm_core_neon.c', + 'aecm/aecm_core_neon.cc', 'ns/nsx_core_neon.c', ], }],