2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
12 * Specifies the interface for the AEC core.
15 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_CORE_H_
16 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_CORE_H_
18 #include "webrtc/typedefs.h"
21 #define PART_LEN 64 // Length of partition
22 #define PART_LEN1 (PART_LEN + 1) // Unique fft coefficients
23 #define PART_LEN2 (PART_LEN * 2) // Length of partition * 2
25 typedef float complex_t[2];
26 // For performance reasons, some arrays of complex numbers are replaced by twice
27 // as long arrays of float, all the real parts followed by all the imaginary
28 // ones (complex_t[SIZE] -> float[2][SIZE]). This allows SIMD optimizations and
29 // is better than two arrays (one for the real parts and one for the imaginary
30 // parts) as this other way would require two pointers instead of one and cause
31 // extra register spilling. This also allows the offsets to be calculated at
39 typedef struct Stats {
51 typedef struct AecCore AecCore;
53 int WebRtcAec_CreateAec(AecCore** aec);
54 int WebRtcAec_FreeAec(AecCore* aec);
55 int WebRtcAec_InitAec(AecCore* aec, int sampFreq);
56 void WebRtcAec_InitAec_SSE2(void);
57 #if defined(MIPS_FPU_LE)
58 void WebRtcAec_InitAec_mips(void);
61 void WebRtcAec_BufferFarendPartition(AecCore* aec, const float* farend);
62 void WebRtcAec_ProcessFrame(AecCore* aec,
64 const short* nearendH,
69 // A helper function to call WebRtc_MoveReadPtr() for all far-end buffers.
70 // Returns the number of elements moved, and adjusts |system_delay| by the
71 // corresponding amount in ms.
72 int WebRtcAec_MoveFarReadPtr(AecCore* aec, int elements);
74 // Calculates the median and standard deviation among the delay estimates
75 // collected since the last call to this function.
76 int WebRtcAec_GetDelayMetricsCore(AecCore* self, int* median, int* std);
78 // Returns the echo state (1: echo, 0: no echo).
79 int WebRtcAec_echo_state(AecCore* self);
81 // Gets statistics of the echo metrics ERL, ERLE, A_NLP.
82 void WebRtcAec_GetEchoStats(AecCore* self,
86 #ifdef WEBRTC_AEC_DEBUG_DUMP
87 void* WebRtcAec_far_time_buf(AecCore* self);
90 // Sets local configuration modes.
91 void WebRtcAec_SetConfigCore(AecCore* self,
96 // Non-zero enables, zero disables.
97 void WebRtcAec_enable_reported_delay(AecCore* self, int enable);
99 // Returns non-zero if reported delay is enabled and zero if disabled.
100 int WebRtcAec_reported_delay_enabled(AecCore* self);
102 // We now interpret delay correction to mean an extended filter length feature.
103 // We reuse the delay correction infrastructure to avoid changes through to
104 // libjingle. See details along with |DelayCorrection| in
105 // echo_cancellation_impl.h. Non-zero enables, zero disables.
106 void WebRtcAec_enable_delay_correction(AecCore* self, int enable);
108 // Returns non-zero if delay correction is enabled and zero if disabled.
109 int WebRtcAec_delay_correction_enabled(AecCore* self);
111 // Returns the current |system_delay|, i.e., the buffered difference between
112 // far-end and near-end.
113 int WebRtcAec_system_delay(AecCore* self);
115 // Sets the |system_delay| to |value|. Note that if the value is changed
116 // improperly, there can be a performance regression. So it should be used with
118 void WebRtcAec_SetSystemDelay(AecCore* self, int delay);
120 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_CORE_H_