Refactoring AEC: Added a SetConfigCore function
* Configuraion parameters now passed down the AEC Core struct. * Tested with audioproc_unittest and on trybots. TEST=none BUG=none Review URL: https://webrtc-codereview.appspot.com/1098014 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3548 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
716fd90ff2
commit
47b274de44
@ -126,8 +126,9 @@ static void ComfortNoise(aec_t *aec, float efw[2][PART_LEN1],
|
||||
complex_t *comfortNoiseHband,
|
||||
const float *noisePow, const float *lambda);
|
||||
|
||||
static void WebRtcAec_InitLevel(power_level_t *level);
|
||||
static void InitLevel(power_level_t *level);
|
||||
static void InitStats(Stats* stats);
|
||||
static void InitMetrics(aec_t *aec);
|
||||
static void UpdateLevel(power_level_t* level, float in[2][PART_LEN1]);
|
||||
static void UpdateMetrics(aec_t *aec);
|
||||
// Convert from time domain to frequency domain. Note that |time_data| are
|
||||
@ -544,7 +545,7 @@ int WebRtcAec_InitAec(aec_t *aec, int sampFreq)
|
||||
|
||||
// Metrics disabled by default
|
||||
aec->metricsMode = 0;
|
||||
WebRtcAec_InitMetrics(aec);
|
||||
InitMetrics(aec);
|
||||
|
||||
// Assembly optimization
|
||||
WebRtcAec_FilterFar = FilterFar;
|
||||
@ -563,20 +564,6 @@ int WebRtcAec_InitAec(aec_t *aec, int sampFreq)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WebRtcAec_InitMetrics(aec_t *aec)
|
||||
{
|
||||
aec->stateCounter = 0;
|
||||
WebRtcAec_InitLevel(&aec->farlevel);
|
||||
WebRtcAec_InitLevel(&aec->nearlevel);
|
||||
WebRtcAec_InitLevel(&aec->linoutlevel);
|
||||
WebRtcAec_InitLevel(&aec->nlpoutlevel);
|
||||
|
||||
InitStats(&aec->erl);
|
||||
InitStats(&aec->erle);
|
||||
InitStats(&aec->aNlp);
|
||||
InitStats(&aec->rerl);
|
||||
}
|
||||
|
||||
void WebRtcAec_BufferFarendPartition(aec_t *aec, const float* farend) {
|
||||
float fft[PART_LEN2];
|
||||
float xf[2][PART_LEN1];
|
||||
@ -768,6 +755,21 @@ void* WebRtcAec_far_time_buf(aec_t* self) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void WebRtcAec_SetConfigCore(aec_t* self, int nlp_mode, int metrics_mode,
|
||||
int delay_logging) {
|
||||
assert(self != NULL);
|
||||
assert(nlp_mode >= 0 && nlp_mode < 3);
|
||||
self->nlp_mode = nlp_mode;
|
||||
self->metricsMode = metrics_mode;
|
||||
if (self->metricsMode) {
|
||||
InitMetrics(self);
|
||||
}
|
||||
self->delay_logging_enabled = delay_logging;
|
||||
if (self->delay_logging_enabled) {
|
||||
memset(self->delay_histogram, 0, sizeof(self->delay_histogram));
|
||||
}
|
||||
}
|
||||
|
||||
static void ProcessBlock(aec_t* aec) {
|
||||
int i;
|
||||
float d[PART_LEN], y[PART_LEN], e[PART_LEN], dH[PART_LEN];
|
||||
@ -1426,7 +1428,7 @@ static void ComfortNoise(aec_t *aec, float efw[2][PART_LEN1],
|
||||
}
|
||||
}
|
||||
|
||||
static void WebRtcAec_InitLevel(power_level_t *level)
|
||||
static void InitLevel(power_level_t *level)
|
||||
{
|
||||
const float bigFloat = 1E17f;
|
||||
|
||||
@ -1451,6 +1453,20 @@ static void InitStats(Stats* stats) {
|
||||
stats->hicounter = 0;
|
||||
}
|
||||
|
||||
static void InitMetrics(aec_t* self) {
|
||||
assert(self != NULL);
|
||||
self->stateCounter = 0;
|
||||
InitLevel(&self->farlevel);
|
||||
InitLevel(&self->nearlevel);
|
||||
InitLevel(&self->linoutlevel);
|
||||
InitLevel(&self->nlpoutlevel);
|
||||
|
||||
InitStats(&self->erl);
|
||||
InitStats(&self->erle);
|
||||
InitStats(&self->aNlp);
|
||||
InitStats(&self->rerl);
|
||||
}
|
||||
|
||||
static void UpdateLevel(power_level_t* level, float in[2][PART_LEN1]) {
|
||||
// Do the energy calculation in the frequency domain. The FFT is performed on
|
||||
// a segment of PART_LEN2 samples due to overlap, but we only want the energy
|
||||
|
@ -171,7 +171,6 @@ int WebRtcAec_FreeAec(aec_t *aec);
|
||||
int WebRtcAec_InitAec(aec_t *aec, int sampFreq);
|
||||
void WebRtcAec_InitAec_SSE2(void);
|
||||
|
||||
void WebRtcAec_InitMetrics(aec_t *aec);
|
||||
void WebRtcAec_BufferFarendPartition(aec_t *aec, const float* farend);
|
||||
void WebRtcAec_ProcessFrame(aec_t* aec,
|
||||
const short* nearend,
|
||||
@ -194,5 +193,8 @@ void WebRtcAec_GetEchoStats(aec_t* self, Stats* erl, Stats* erle, Stats* a_nlp);
|
||||
#ifdef WEBRTC_AEC_DEBUG_DUMP
|
||||
void* WebRtcAec_far_time_buf(aec_t* self);
|
||||
#endif
|
||||
// Sets local configuration modes.
|
||||
void WebRtcAec_SetConfigCore(aec_t* self, int nlp_mode, int metrics_mode,
|
||||
int delay_logging);
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_AEC_CORE_H_
|
||||
|
@ -504,51 +504,43 @@ WebRtc_Word32 WebRtcAec_Process(void *aecInst, const WebRtc_Word16 *nearend,
|
||||
return retVal;
|
||||
}
|
||||
|
||||
WebRtc_Word32 WebRtcAec_set_config(void *aecInst, AecConfig config)
|
||||
{
|
||||
aecpc_t *aecpc = aecInst;
|
||||
int WebRtcAec_set_config(void* handle, AecConfig config) {
|
||||
aecpc_t* self = (aecpc_t*)handle;
|
||||
|
||||
if (aecpc == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (aecpc->initFlag != initCheck) {
|
||||
aecpc->lastError = AEC_UNINITIALIZED_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (config.skewMode != kAecFalse && config.skewMode != kAecTrue) {
|
||||
aecpc->lastError = AEC_BAD_PARAMETER_ERROR;
|
||||
return -1;
|
||||
}
|
||||
aecpc->skewMode = config.skewMode;
|
||||
|
||||
if (config.nlpMode != kAecNlpConservative && config.nlpMode !=
|
||||
kAecNlpModerate && config.nlpMode != kAecNlpAggressive) {
|
||||
aecpc->lastError = AEC_BAD_PARAMETER_ERROR;
|
||||
return -1;
|
||||
}
|
||||
aecpc->aec->nlp_mode = config.nlpMode;
|
||||
|
||||
if (config.metricsMode != kAecFalse && config.metricsMode != kAecTrue) {
|
||||
aecpc->lastError = AEC_BAD_PARAMETER_ERROR;
|
||||
return -1;
|
||||
}
|
||||
aecpc->aec->metricsMode = config.metricsMode;
|
||||
if (aecpc->aec->metricsMode == kAecTrue) {
|
||||
WebRtcAec_InitMetrics(aecpc->aec);
|
||||
}
|
||||
|
||||
if (config.delay_logging != kAecFalse && config.delay_logging != kAecTrue) {
|
||||
aecpc->lastError = AEC_BAD_PARAMETER_ERROR;
|
||||
if (handle == NULL ) {
|
||||
return -1;
|
||||
}
|
||||
aecpc->aec->delay_logging_enabled = config.delay_logging;
|
||||
if (aecpc->aec->delay_logging_enabled == kAecTrue) {
|
||||
memset(aecpc->aec->delay_histogram, 0, sizeof(aecpc->aec->delay_histogram));
|
||||
|
||||
if (self->initFlag != initCheck) {
|
||||
self->lastError = AEC_UNINITIALIZED_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (config.skewMode != kAecFalse && config.skewMode != kAecTrue) {
|
||||
self->lastError = AEC_BAD_PARAMETER_ERROR;
|
||||
return -1;
|
||||
}
|
||||
self->skewMode = config.skewMode;
|
||||
|
||||
if (config.nlpMode != kAecNlpConservative && config.nlpMode != kAecNlpModerate
|
||||
&& config.nlpMode != kAecNlpAggressive) {
|
||||
self->lastError = AEC_BAD_PARAMETER_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (config.metricsMode != kAecFalse && config.metricsMode != kAecTrue) {
|
||||
self->lastError = AEC_BAD_PARAMETER_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (config.delay_logging != kAecFalse && config.delay_logging != kAecTrue) {
|
||||
self->lastError = AEC_BAD_PARAMETER_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtcAec_SetConfigCore(self->aec, config.nlpMode, config.metricsMode,
|
||||
config.delay_logging);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WebRtcAec_get_echo_status(void* handle, int* status) {
|
||||
|
@ -167,16 +167,16 @@ WebRtc_Word32 WebRtcAec_Process(void *aecInst,
|
||||
*
|
||||
* Inputs Description
|
||||
* -------------------------------------------------------------------
|
||||
* void *aecInst Pointer to the AEC instance
|
||||
* void *handle Pointer to the AEC instance
|
||||
* AecConfig config Config instance that contains all
|
||||
* properties to be set
|
||||
*
|
||||
* Outputs Description
|
||||
* -------------------------------------------------------------------
|
||||
* WebRtc_Word32 return 0: OK
|
||||
* int return 0: OK
|
||||
* -1: error
|
||||
*/
|
||||
WebRtc_Word32 WebRtcAec_set_config(void *aecInst, AecConfig config);
|
||||
int WebRtcAec_set_config(void* handle, AecConfig config);
|
||||
|
||||
/*
|
||||
* Gets the current echo status of the nearend signal.
|
||||
|
Loading…
x
Reference in New Issue
Block a user