diff options
Diffstat (limited to 'thirdparties/common/include/webrtc')
-rw-r--r-- | thirdparties/common/include/webrtc/echo_cancellation.h | 262 | ||||
-rw-r--r-- | thirdparties/common/include/webrtc/echo_control_mobile.h | 233 | ||||
-rw-r--r-- | thirdparties/common/include/webrtc/gain_control.h | 259 | ||||
-rw-r--r-- | thirdparties/common/include/webrtc/noise_suppression.h | 123 | ||||
-rw-r--r-- | thirdparties/common/include/webrtc/noise_suppression_x.h | 109 | ||||
-rw-r--r-- | thirdparties/common/include/webrtc/typedefs.h | 93 |
6 files changed, 1079 insertions, 0 deletions
diff --git a/thirdparties/common/include/webrtc/echo_cancellation.h b/thirdparties/common/include/webrtc/echo_cancellation.h new file mode 100644 index 0000000..a266e84 --- /dev/null +++ b/thirdparties/common/include/webrtc/echo_cancellation.h @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC_INCLUDE_ECHO_CANCELLATION_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_INCLUDE_ECHO_CANCELLATION_H_ + +#include "typedefs.h" + +// Errors +#define AEC_UNSPECIFIED_ERROR 12000 +#define AEC_UNSUPPORTED_FUNCTION_ERROR 12001 +#define AEC_UNINITIALIZED_ERROR 12002 +#define AEC_NULL_POINTER_ERROR 12003 +#define AEC_BAD_PARAMETER_ERROR 12004 + +// Warnings +#define AEC_BAD_PARAMETER_WARNING 12050 + +enum { + kAecNlpConservative = 0, + kAecNlpModerate, + kAecNlpAggressive +}; + +enum { + kAecFalse = 0, + kAecTrue +}; + +typedef struct { + WebRtc_Word16 nlpMode; // default kAecNlpModerate + WebRtc_Word16 skewMode; // default kAecFalse + WebRtc_Word16 metricsMode; // default kAecFalse + int delay_logging; // default kAecFalse + //float realSkew; +} AecConfig; + +typedef struct { + WebRtc_Word16 instant; + WebRtc_Word16 average; + WebRtc_Word16 max; + WebRtc_Word16 min; +} AecLevel; + +typedef struct { + AecLevel rerl; + AecLevel erl; + AecLevel erle; + AecLevel aNlp; +} AecMetrics; + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Allocates the memory needed by the AEC. The memory needs to be initialized + * separately using the WebRtcAec_Init() function. + * + * Inputs Description + * ------------------------------------------------------------------- + * void **aecInst Pointer to the AEC instance to be created + * and initialized + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAec_Create(void **aecInst); + +/* + * This function releases the memory allocated by WebRtcAec_Create(). + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecInst Pointer to the AEC instance + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAec_Free(void *aecInst); + +/* + * Initializes an AEC instance. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecInst Pointer to the AEC instance + * WebRtc_Word32 sampFreq Sampling frequency of data + * WebRtc_Word32 scSampFreq Soundcard sampling frequency + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAec_Init(void *aecInst, + WebRtc_Word32 sampFreq, + WebRtc_Word32 scSampFreq); + +/* + * Inserts an 80 or 160 sample block of data into the farend buffer. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecInst Pointer to the AEC instance + * WebRtc_Word16 *farend In buffer containing one frame of + * farend signal for L band + * WebRtc_Word16 nrOfSamples Number of samples in farend buffer + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAec_BufferFarend(void *aecInst, + const WebRtc_Word16 *farend, + WebRtc_Word16 nrOfSamples); + +/* + * Runs the echo canceller on an 80 or 160 sample blocks of data. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecInst Pointer to the AEC instance + * WebRtc_Word16 *nearend In buffer containing one frame of + * nearend+echo signal for L band + * WebRtc_Word16 *nearendH In buffer containing one frame of + * nearend+echo signal for H band + * WebRtc_Word16 nrOfSamples Number of samples in nearend buffer + * WebRtc_Word16 msInSndCardBuf Delay estimate for sound card and + * system buffers + * WebRtc_Word16 skew Difference between number of samples played + * and recorded at the soundcard (for clock skew + * compensation) + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word16 *out Out buffer, one frame of processed nearend + * for L band + * WebRtc_Word16 *outH Out buffer, one frame of processed nearend + * for H band + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAec_Process(void *aecInst, + const WebRtc_Word16 *nearend, + const WebRtc_Word16 *nearendH, + WebRtc_Word16 *out, + WebRtc_Word16 *outH, + WebRtc_Word16 nrOfSamples, + WebRtc_Word16 msInSndCardBuf, + WebRtc_Word32 skew); + +/* + * This function enables the user to set certain parameters on-the-fly. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecInst Pointer to the AEC instance + * AecConfig config Config instance that contains all + * properties to be set + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAec_set_config(void *aecInst, AecConfig config); + +/* + * Gets the on-the-fly paramters. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecInst Pointer to the AEC instance + * + * Outputs Description + * ------------------------------------------------------------------- + * AecConfig *config Pointer to the config instance that + * all properties will be written to + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAec_get_config(void *aecInst, AecConfig *config); + +/* + * Gets the current echo status of the nearend signal. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecInst Pointer to the AEC instance + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word16 *status 0: Almost certainly nearend single-talk + * 1: Might not be neared single-talk + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAec_get_echo_status(void *aecInst, WebRtc_Word16 *status); + +/* + * Gets the current echo metrics for the session. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecInst Pointer to the AEC instance + * + * Outputs Description + * ------------------------------------------------------------------- + * AecMetrics *metrics Struct which will be filled out with the + * current echo metrics. + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAec_GetMetrics(void *aecInst, AecMetrics *metrics); + +/* + * Gets the current delay metrics for the session. + * + * Inputs Description + * ------------------------------------------------------------------- + * void* handle Pointer to the AEC instance + * + * Outputs Description + * ------------------------------------------------------------------- + * int* median Delay median value. + * int* std Delay standard deviation. + * + * int return 0: OK + * -1: error + */ +int WebRtcAec_GetDelayMetrics(void* handle, int* median, int* std); + +/* + * Gets the last error code. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecInst Pointer to the AEC instance + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 11000-11100: error code + */ +WebRtc_Word32 WebRtcAec_get_error_code(void *aecInst); + +#ifdef __cplusplus +} +#endif +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_INCLUDE_ECHO_CANCELLATION_H_ diff --git a/thirdparties/common/include/webrtc/echo_control_mobile.h b/thirdparties/common/include/webrtc/echo_control_mobile.h new file mode 100644 index 0000000..da0ad86 --- /dev/null +++ b/thirdparties/common/include/webrtc/echo_control_mobile.h @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AECM_INCLUDE_ECHO_CONTROL_MOBILE_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_AECM_INCLUDE_ECHO_CONTROL_MOBILE_H_ + +#include "typedefs.h" + +enum { + AecmFalse = 0, + AecmTrue +}; + +// Errors +#define AECM_UNSPECIFIED_ERROR 12000 +#define AECM_UNSUPPORTED_FUNCTION_ERROR 12001 +#define AECM_UNINITIALIZED_ERROR 12002 +#define AECM_NULL_POINTER_ERROR 12003 +#define AECM_BAD_PARAMETER_ERROR 12004 + +// Warnings +#define AECM_BAD_PARAMETER_WARNING 12100 + +typedef struct { + WebRtc_Word16 cngMode; // AECM_FALSE, AECM_TRUE (default) + WebRtc_Word16 echoMode; // 0, 1, 2, 3 (default), 4 +} AecmConfig; + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Allocates the memory needed by the AECM. The memory needs to be + * initialized separately using the WebRtcAecm_Init() function. + * + * Inputs Description + * ------------------------------------------------------------------- + * void **aecmInst Pointer to the AECM instance to be + * created and initialized + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAecm_Create(void **aecmInst); + +/* + * This function releases the memory allocated by WebRtcAecm_Create() + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecmInst Pointer to the AECM instance + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAecm_Free(void *aecmInst); + +/* + * Initializes an AECM instance. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecmInst Pointer to the AECM instance + * WebRtc_Word32 sampFreq Sampling frequency of data + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAecm_Init(void* aecmInst, + WebRtc_Word32 sampFreq); + +/* + * Inserts an 80 or 160 sample block of data into the farend buffer. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecmInst Pointer to the AECM instance + * WebRtc_Word16 *farend In buffer containing one frame of + * farend signal + * WebRtc_Word16 nrOfSamples Number of samples in farend buffer + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAecm_BufferFarend(void* aecmInst, + const WebRtc_Word16* farend, + WebRtc_Word16 nrOfSamples); + +/* + * Runs the AECM on an 80 or 160 sample blocks of data. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecmInst Pointer to the AECM instance + * WebRtc_Word16 *nearendNoisy In buffer containing one frame of + * reference nearend+echo signal. If + * noise reduction is active, provide + * the noisy signal here. + * WebRtc_Word16 *nearendClean In buffer containing one frame of + * nearend+echo signal. If noise + * reduction is active, provide the + * clean signal here. Otherwise pass a + * NULL pointer. + * WebRtc_Word16 nrOfSamples Number of samples in nearend buffer + * WebRtc_Word16 msInSndCardBuf Delay estimate for sound card and + * system buffers + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word16 *out Out buffer, one frame of processed nearend + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAecm_Process(void* aecmInst, + const WebRtc_Word16* nearendNoisy, + const WebRtc_Word16* nearendClean, + WebRtc_Word16* out, + WebRtc_Word16 nrOfSamples, + WebRtc_Word16 msInSndCardBuf); + +/* + * This function enables the user to set certain parameters on-the-fly + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecmInst Pointer to the AECM instance + * AecmConfig config Config instance that contains all + * properties to be set + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAecm_set_config(void* aecmInst, + AecmConfig config); + +/* + * This function enables the user to set certain parameters on-the-fly + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecmInst Pointer to the AECM instance + * + * Outputs Description + * ------------------------------------------------------------------- + * AecmConfig *config Pointer to the config instance that + * all properties will be written to + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAecm_get_config(void *aecmInst, + AecmConfig *config); + +/* + * This function enables the user to set the echo path on-the-fly. + * + * Inputs Description + * ------------------------------------------------------------------- + * void* aecmInst Pointer to the AECM instance + * void* echo_path Pointer to the echo path to be set + * size_t size_bytes Size in bytes of the echo path + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAecm_InitEchoPath(void* aecmInst, + const void* echo_path, + size_t size_bytes); + +/* + * This function enables the user to get the currently used echo path + * on-the-fly + * + * Inputs Description + * ------------------------------------------------------------------- + * void* aecmInst Pointer to the AECM instance + * void* echo_path Pointer to echo path + * size_t size_bytes Size in bytes of the echo path + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 0: OK + * -1: error + */ +WebRtc_Word32 WebRtcAecm_GetEchoPath(void* aecmInst, + void* echo_path, + size_t size_bytes); + +/* + * This function enables the user to get the echo path size in bytes + * + * Outputs Description + * ------------------------------------------------------------------- + * size_t return : size in bytes + */ +size_t WebRtcAecm_echo_path_size_bytes(); + +/* + * Gets the last error code. + * + * Inputs Description + * ------------------------------------------------------------------- + * void *aecmInst Pointer to the AECM instance + * + * Outputs Description + * ------------------------------------------------------------------- + * WebRtc_Word32 return 11000-11100: error code + */ +WebRtc_Word32 WebRtcAecm_get_error_code(void *aecmInst); + +#ifdef __cplusplus +} +#endif +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AECM_INCLUDE_ECHO_CONTROL_MOBILE_H_ diff --git a/thirdparties/common/include/webrtc/gain_control.h b/thirdparties/common/include/webrtc/gain_control.h new file mode 100644 index 0000000..8af5c71 --- /dev/null +++ b/thirdparties/common/include/webrtc/gain_control.h @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_INCLUDE_GAIN_CONTROL_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_INCLUDE_GAIN_CONTROL_H_ + +#include "typedefs.h" + +// Errors +#define AGC_UNSPECIFIED_ERROR 18000 +#define AGC_UNSUPPORTED_FUNCTION_ERROR 18001 +#define AGC_UNINITIALIZED_ERROR 18002 +#define AGC_NULL_POINTER_ERROR 18003 +#define AGC_BAD_PARAMETER_ERROR 18004 + +// Warnings +#define AGC_BAD_PARAMETER_WARNING 18050 + +enum +{ + kAgcModeUnchanged, + kAgcModeAdaptiveAnalog, + kAgcModeAdaptiveDigital, + kAgcModeFixedDigital +}; + +enum +{ + kAgcFalse = 0, + kAgcTrue +}; + +typedef struct +{ + WebRtc_Word16 targetLevelDbfs; // default 3 (-3 dBOv) + WebRtc_Word16 compressionGaindB; // default 9 dB + WebRtc_UWord8 limiterEnable; // default kAgcTrue (on) +} WebRtcAgc_config_t; + +#if defined(__cplusplus) +extern "C" +{ +#endif + +/* + * This function processes a 10/20ms frame of far-end speech to determine + * if there is active speech. Far-end speech length can be either 10ms or + * 20ms. The length of the input speech vector must be given in samples + * (80/160 when FS=8000, and 160/320 when FS=16000 or FS=32000). + * + * Input: + * - agcInst : AGC instance. + * - inFar : Far-end input speech vector (10 or 20ms) + * - samples : Number of samples in input vector + * + * Return value: + * : 0 - Normal operation. + * : -1 - Error + */ +int WebRtcAgc_AddFarend(void* agcInst, + const WebRtc_Word16* inFar, + WebRtc_Word16 samples); + +/* + * This function processes a 10/20ms frame of microphone speech to determine + * if there is active speech. Microphone speech length can be either 10ms or + * 20ms. The length of the input speech vector must be given in samples + * (80/160 when FS=8000, and 160/320 when FS=16000 or FS=32000). For very low + * input levels, the input signal is increased in level by multiplying and + * overwriting the samples in inMic[]. + * + * This function should be called before any further processing of the + * near-end microphone signal. + * + * Input: + * - agcInst : AGC instance. + * - inMic : Microphone input speech vector (10 or 20 ms) for + * L band + * - inMic_H : Microphone input speech vector (10 or 20 ms) for + * H band + * - samples : Number of samples in input vector + * + * Return value: + * : 0 - Normal operation. + * : -1 - Error + */ +int WebRtcAgc_AddMic(void* agcInst, + WebRtc_Word16* inMic, + WebRtc_Word16* inMic_H, + WebRtc_Word16 samples); + +/* + * This function replaces the analog microphone with a virtual one. + * It is a digital gain applied to the input signal and is used in the + * agcAdaptiveDigital mode where no microphone level is adjustable. + * Microphone speech length can be either 10ms or 20ms. The length of the + * input speech vector must be given in samples (80/160 when FS=8000, and + * 160/320 when FS=16000 or FS=32000). + * + * Input: + * - agcInst : AGC instance. + * - inMic : Microphone input speech vector for (10 or 20 ms) + * L band + * - inMic_H : Microphone input speech vector for (10 or 20 ms) + * H band + * - samples : Number of samples in input vector + * - micLevelIn : Input level of microphone (static) + * + * Output: + * - inMic : Microphone output after processing (L band) + * - inMic_H : Microphone output after processing (H band) + * - micLevelOut : Adjusted microphone level after processing + * + * Return value: + * : 0 - Normal operation. + * : -1 - Error + */ +int WebRtcAgc_VirtualMic(void* agcInst, + WebRtc_Word16* inMic, + WebRtc_Word16* inMic_H, + WebRtc_Word16 samples, + WebRtc_Word32 micLevelIn, + WebRtc_Word32* micLevelOut); + +/* + * This function processes a 10/20ms frame and adjusts (normalizes) the gain + * both analog and digitally. The gain adjustments are done only during + * active periods of speech. The input speech length can be either 10ms or + * 20ms and the output is of the same length. The length of the speech + * vectors must be given in samples (80/160 when FS=8000, and 160/320 when + * FS=16000 or FS=32000). The echo parameter can be used to ensure the AGC will + * not adjust upward in the presence of echo. + * + * This function should be called after processing the near-end microphone + * signal, in any case after any echo cancellation. + * + * Input: + * - agcInst : AGC instance + * - inNear : Near-end input speech vector (10 or 20 ms) for + * L band + * - inNear_H : Near-end input speech vector (10 or 20 ms) for + * H band + * - samples : Number of samples in input/output vector + * - inMicLevel : Current microphone volume level + * - echo : Set to 0 if the signal passed to add_mic is + * almost certainly free of echo; otherwise set + * to 1. If you have no information regarding echo + * set to 0. + * + * Output: + * - outMicLevel : Adjusted microphone volume level + * - out : Gain-adjusted near-end speech vector (L band) + * : May be the same vector as the input. + * - out_H : Gain-adjusted near-end speech vector (H band) + * - saturationWarning : A returned value of 1 indicates a saturation event + * has occurred and the volume cannot be further + * reduced. Otherwise will be set to 0. + * + * Return value: + * : 0 - Normal operation. + * : -1 - Error + */ +int WebRtcAgc_Process(void* agcInst, + const WebRtc_Word16* inNear, + const WebRtc_Word16* inNear_H, + WebRtc_Word16 samples, + WebRtc_Word16* out, + WebRtc_Word16* out_H, + WebRtc_Word32 inMicLevel, + WebRtc_Word32* outMicLevel, + WebRtc_Word16 echo, + WebRtc_UWord8* saturationWarning); + +/* + * This function sets the config parameters (targetLevelDbfs, + * compressionGaindB and limiterEnable). + * + * Input: + * - agcInst : AGC instance + * - config : config struct + * + * Output: + * + * Return value: + * : 0 - Normal operation. + * : -1 - Error + */ +int WebRtcAgc_set_config(void* agcInst, WebRtcAgc_config_t config); + +/* + * This function returns the config parameters (targetLevelDbfs, + * compressionGaindB and limiterEnable). + * + * Input: + * - agcInst : AGC instance + * + * Output: + * - config : config struct + * + * Return value: + * : 0 - Normal operation. + * : -1 - Error + */ +int WebRtcAgc_get_config(void* agcInst, WebRtcAgc_config_t* config); + +/* + * This function creates an AGC instance, which will contain the state + * information for one (duplex) channel. + * + * Return value : AGC instance if successful + * : 0 (i.e., a NULL pointer) if unsuccessful + */ +int WebRtcAgc_Create(void **agcInst); + +/* + * This function frees the AGC instance created at the beginning. + * + * Input: + * - agcInst : AGC instance. + * + * Return value : 0 - Ok + * -1 - Error + */ +int WebRtcAgc_Free(void *agcInst); + +/* + * This function initializes an AGC instance. + * + * Input: + * - agcInst : AGC instance. + * - minLevel : Minimum possible mic level + * - maxLevel : Maximum possible mic level + * - agcMode : 0 - Unchanged + * : 1 - Adaptive Analog Automatic Gain Control -3dBOv + * : 2 - Adaptive Digital Automatic Gain Control -3dBOv + * : 3 - Fixed Digital Gain 0dB + * - fs : Sampling frequency + * + * Return value : 0 - Ok + * -1 - Error + */ +int WebRtcAgc_Init(void *agcInst, + WebRtc_Word32 minLevel, + WebRtc_Word32 maxLevel, + WebRtc_Word16 agcMode, + WebRtc_UWord32 fs); + +#if defined(__cplusplus) +} +#endif + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_INCLUDE_GAIN_CONTROL_H_ diff --git a/thirdparties/common/include/webrtc/noise_suppression.h b/thirdparties/common/include/webrtc/noise_suppression.h new file mode 100644 index 0000000..c9a8e32 --- /dev/null +++ b/thirdparties/common/include/webrtc/noise_suppression.h @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_H_ + +#include "typedefs.h" + +typedef struct NsHandleT NsHandle; + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This function creates an instance to the noise suppression structure + * + * Input: + * - NS_inst : Pointer to noise suppression instance that should be + * created + * + * Output: + * - NS_inst : Pointer to created noise suppression instance + * + * Return value : 0 - Ok + * -1 - Error + */ +int WebRtcNs_Create(NsHandle** NS_inst); + + +/* + * This function frees the dynamic memory of a specified noise suppression + * instance. + * + * Input: + * - NS_inst : Pointer to NS instance that should be freed + * + * Return value : 0 - Ok + * -1 - Error + */ +int WebRtcNs_Free(NsHandle* NS_inst); + + +/* + * This function initializes a NS instance and has to be called before any other + * processing is made. + * + * Input: + * - NS_inst : Instance that should be initialized + * - fs : sampling frequency + * + * Output: + * - NS_inst : Initialized instance + * + * Return value : 0 - Ok + * -1 - Error + */ +int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs); + +/* + * This changes the aggressiveness of the noise suppression method. + * + * Input: + * - NS_inst : Noise suppression instance. + * - mode : 0: Mild, 1: Medium , 2: Aggressive + * + * Output: + * - NS_inst : Updated instance. + * + * Return value : 0 - Ok + * -1 - Error + */ +int WebRtcNs_set_policy(NsHandle* NS_inst, int mode); + + +/* + * This functions does Noise Suppression for the inserted speech frame. The + * input and output signals should always be 10ms (80 or 160 samples). + * + * Input + * - NS_inst : Noise suppression instance. + * - spframe : Pointer to speech frame buffer for L band + * - spframe_H : Pointer to speech frame buffer for H band + * - fs : sampling frequency + * + * Output: + * - NS_inst : Updated NS instance + * - outframe : Pointer to output frame for L band + * - outframe_H : Pointer to output frame for H band + * + * Return value : 0 - OK + * -1 - Error + */ +int WebRtcNs_Process(NsHandle* NS_inst, + short* spframe, + short* spframe_H, + short* outframe, + short* outframe_H); + +/* Returns the internally used prior speech probability of the current frame. + * There is a frequency bin based one as well, with which this should not be + * confused. + * + * Input + * - handle : Noise suppression instance. + * + * Return value : Prior speech probability in interval [0.0, 1.0]. + * -1 - NULL pointer or uninitialized instance. + */ +float WebRtcNs_prior_speech_probability(NsHandle* handle); + +#ifdef __cplusplus +} +#endif + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_H_ diff --git a/thirdparties/common/include/webrtc/noise_suppression_x.h b/thirdparties/common/include/webrtc/noise_suppression_x.h new file mode 100644 index 0000000..b6eef90 --- /dev/null +++ b/thirdparties/common/include/webrtc/noise_suppression_x.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_X_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_X_H_ + +#include "typedefs.h" + +typedef struct NsxHandleT NsxHandle; + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This function creates an instance to the noise reduction structure + * + * Input: + * - nsxInst : Pointer to noise reduction instance that should be + * created + * + * Output: + * - nsxInst : Pointer to created noise reduction instance + * + * Return value : 0 - Ok + * -1 - Error + */ +int WebRtcNsx_Create(NsxHandle** nsxInst); + + +/* + * This function frees the dynamic memory of a specified Noise Suppression + * instance. + * + * Input: + * - nsxInst : Pointer to NS instance that should be freed + * + * Return value : 0 - Ok + * -1 - Error + */ +int WebRtcNsx_Free(NsxHandle* nsxInst); + + +/* + * This function initializes a NS instance + * + * Input: + * - nsxInst : Instance that should be initialized + * - fs : sampling frequency + * + * Output: + * - nsxInst : Initialized instance + * + * Return value : 0 - Ok + * -1 - Error + */ +int WebRtcNsx_Init(NsxHandle* nsxInst, WebRtc_UWord32 fs); + +/* + * This changes the aggressiveness of the noise suppression method. + * + * Input: + * - nsxInst : Instance that should be initialized + * - mode : 0: Mild, 1: Medium , 2: Aggressive + * + * Output: + * - nsxInst : Initialized instance + * + * Return value : 0 - Ok + * -1 - Error + */ +int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode); + +/* + * This functions does noise suppression for the inserted speech frame. The + * input and output signals should always be 10ms (80 or 160 samples). + * + * Input + * - nsxInst : NSx instance. Needs to be initiated before call. + * - speechFrame : Pointer to speech frame buffer for L band + * - speechFrameHB : Pointer to speech frame buffer for H band + * - fs : sampling frequency + * + * Output: + * - nsxInst : Updated NSx instance + * - outFrame : Pointer to output frame for L band + * - outFrameHB : Pointer to output frame for H band + * + * Return value : 0 - OK + * -1 - Error + */ +int WebRtcNsx_Process(NsxHandle* nsxInst, + short* speechFrame, + short* speechFrameHB, + short* outFrame, + short* outFrameHB); + +#ifdef __cplusplus +} +#endif + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_INCLUDE_NOISE_SUPPRESSION_X_H_ diff --git a/thirdparties/common/include/webrtc/typedefs.h b/thirdparties/common/include/webrtc/typedefs.h new file mode 100644 index 0000000..d6d4015 --- /dev/null +++ b/thirdparties/common/include/webrtc/typedefs.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +// This file contains platform-specific typedefs and defines. +// Much of it is derived from Chromium's build/build_config.h. + +#ifndef WEBRTC_TYPEDEFS_H_ +#define WEBRTC_TYPEDEFS_H_ + +// Reserved words definitions +// TODO(andrew): Remove this. +#define G_CONST const + +// For access to standard POSIXish features, use WEBRTC_POSIX instead of a +// more specific macro. +#if defined(WEBRTC_MAC) || defined(WEBRTC_LINUX) || \ + defined(WEBRTC_ANDROID) +#define WEBRTC_POSIX +#endif + +// Processor architecture detection. For more info on what's defined, see: +// http://msdn.microsoft.com/en-us/library/b0084kay.aspx +// http://www.agner.org/optimize/calling_conventions.pdf +// or with gcc, run: "echo | gcc -E -dM -" +// TODO(andrew): replace WEBRTC_LITTLE_ENDIAN with WEBRTC_ARCH_LITTLE_ENDIAN. +#if defined(_M_X64) || defined(__x86_64__) +#define WEBRTC_ARCH_X86_FAMILY +#define WEBRTC_ARCH_X86_64 +#define WEBRTC_ARCH_64_BITS +#define WEBRTC_ARCH_LITTLE_ENDIAN +#define WEBRTC_LITTLE_ENDIAN +#elif defined(_M_IX86) || defined(__i386__) +#define WEBRTC_ARCH_X86_FAMILY +#define WEBRTC_ARCH_X86 +#define WEBRTC_ARCH_32_BITS +#define WEBRTC_ARCH_LITTLE_ENDIAN +#define WEBRTC_LITTLE_ENDIAN +#elif defined(__ARMEL__) +// TODO(andrew): We'd prefer to control platform defines here, but this is +// currently provided by the Android makefiles. Commented to avoid duplicate +// definition warnings. +//#define WEBRTC_ARCH_ARM +// TODO(andrew): Chromium uses the following two defines. Should we switch? +//#define WEBRTC_ARCH_ARM_FAMILY +//#define WEBRTC_ARCH_ARMEL +#define WEBRTC_ARCH_32_BITS +#define WEBRTC_ARCH_LITTLE_ENDIAN +#define WEBRTC_LITTLE_ENDIAN +#elif defined(__MIPSEL__) +#define WEBRTC_ARCH_32_BITS +#define WEBRTC_ARCH_LITTLE_ENDIAN +#define WEBRTC_LITTLE_ENDIAN +#else +#error Please add support for your architecture in typedefs.h +#endif + +#if defined(__SSE2__) || defined(_MSC_VER) +#define WEBRTC_USE_SSE2 +#endif + +#if !defined(_MSC_VER) +#include <stdint.h> +#else +// Define C99 equivalent types, since MSVC doesn't provide stdint.h. +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef __int64 int64_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned __int64 uint64_t; +#endif + +// TODO(andrew): remove WebRtc_ types: +// http://code.google.com/p/webrtc/issues/detail?id=314 +typedef int8_t WebRtc_Word8; +typedef int16_t WebRtc_Word16; +typedef int32_t WebRtc_Word32; +typedef int64_t WebRtc_Word64; +typedef uint8_t WebRtc_UWord8; +typedef uint16_t WebRtc_UWord16; +typedef uint32_t WebRtc_UWord32; +typedef uint64_t WebRtc_UWord64; + +#endif // WEBRTC_TYPEDEFS_H_ |