Changed the name of the variable overdriveSm and removed the

state as an input to OverdriveAndSuppress in the AEC.

This CL is step towards simplifying the AEC code, making it more
modifiable and modular.

The changes should be bitexact.

BUG=webrtc:5201, webrtc:5298

Review-Url: https://codereview.webrtc.org/1939723002
Cr-Commit-Position: refs/heads/master@{#12616}
This commit is contained in:
peah 2016-05-03 14:08:11 -07:00 committed by Commit bot
parent 55dd70842c
commit 7dd7ab5c51
5 changed files with 22 additions and 19 deletions

View File

@ -307,7 +307,7 @@ static void FilterAdaptation(
}
}
static void OverdriveAndSuppress(AecCore* aec,
static void OverdriveAndSuppress(float overdrive_scaling,
float hNl[PART_LEN1],
const float hNlFb,
float efw[2][PART_LEN1]) {
@ -318,7 +318,7 @@ static void OverdriveAndSuppress(AecCore* aec,
hNl[i] = WebRtcAec_weightCurve[i] * hNlFb +
(1 - WebRtcAec_weightCurve[i]) * hNl[i];
}
hNl[i] = powf(hNl[i], aec->overDriveSm * WebRtcAec_overDriveCurve[i]);
hNl[i] = powf(hNl[i], overdrive_scaling * WebRtcAec_overDriveCurve[i]);
// Suppress error signal
efw[0][i] *= hNl[i];
@ -1145,13 +1145,15 @@ static void EchoSuppression(AecCore* aec,
}
// Smooth the overdrive.
if (aec->overDrive < aec->overDriveSm) {
aec->overDriveSm = 0.99f * aec->overDriveSm + 0.01f * aec->overDrive;
if (aec->overDrive < aec->overdrive_scaling) {
aec->overdrive_scaling =
0.99f * aec->overdrive_scaling + 0.01f * aec->overDrive;
} else {
aec->overDriveSm = 0.9f * aec->overDriveSm + 0.1f * aec->overDrive;
aec->overdrive_scaling =
0.9f * aec->overdrive_scaling + 0.1f * aec->overDrive;
}
WebRtcAec_OverdriveAndSuppress(aec, hNl, hNlFb, efw);
WebRtcAec_OverdriveAndSuppress(aec->overdrive_scaling, hNl, hNlFb, efw);
// Add comfort noise.
WebRtcAec_ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl);
@ -1687,7 +1689,7 @@ int WebRtcAec_InitAec(AecCore* aec, int sampFreq) {
aec->hNlNewMin = 0;
aec->hNlMinCtr = 0;
aec->overDrive = 2;
aec->overDriveSm = 2;
aec->overdrive_scaling = 2;
aec->delayIdx = 0;
aec->stNearState = 0;
aec->echoState = 0;

View File

@ -113,7 +113,8 @@ struct AecCore {
float hNlFbMin, hNlFbLocalMin;
float hNlXdAvgMin;
int hNlNewMin, hNlMinCtr;
float overDrive, overDriveSm;
float overDrive;
float overdrive_scaling;
int nlp_mode;
float outBuf[PART_LEN];
int delayIdx;
@ -209,7 +210,7 @@ typedef void (*WebRtcAecFilterAdaptation)(
float e_fft[2][PART_LEN1],
float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1]);
extern WebRtcAecFilterAdaptation WebRtcAec_FilterAdaptation;
typedef void (*WebRtcAecOverdriveAndSuppress)(AecCore* aec,
typedef void (*WebRtcAecOverdriveAndSuppress)(float overdrive_scaling,
float hNl[PART_LEN1],
const float hNlFb,
float efw[2][PART_LEN1]);

View File

@ -642,7 +642,7 @@ void WebRtcAec_FilterAdaptation_mips(
}
}
void WebRtcAec_OverdriveAndSuppress_mips(AecCore* aec,
void WebRtcAec_OverdriveAndSuppress_mips(float overdrive_scaling,
float hNl[PART_LEN1],
const float hNlFb,
float efw[2][PART_LEN1]) {
@ -685,7 +685,7 @@ void WebRtcAec_OverdriveAndSuppress_mips(AecCore* aec,
: [hNlFb] "f" (hNlFb), [one] "f" (one), [p_hNl] "r" (p_hNl)
: "memory");
hNl[i] = powf(hNl[i], aec->overDriveSm * WebRtcAec_overDriveCurve[i]);
hNl[i] = powf(hNl[i], overdrive_scaling * WebRtcAec_overDriveCurve[i]);
__asm __volatile(
"lwc1 %[temp1], 0(%[p_hNl]) \n\t"

View File

@ -374,7 +374,7 @@ static float32x4_t vpowq_f32(float32x4_t a, float32x4_t b) {
return a_exp_b;
}
static void OverdriveAndSuppressNEON(AecCore* aec,
static void OverdriveAndSuppressNEON(float overdrive_scaling,
float hNl[PART_LEN1],
const float hNlFb,
float efw[2][PART_LEN1]) {
@ -382,7 +382,7 @@ static void OverdriveAndSuppressNEON(AecCore* aec,
const float32x4_t vec_hNlFb = vmovq_n_f32(hNlFb);
const float32x4_t vec_one = vdupq_n_f32(1.0f);
const float32x4_t vec_minus_one = vdupq_n_f32(-1.0f);
const float32x4_t vec_overDriveSm = vmovq_n_f32(aec->overDriveSm);
const float32x4_t vec_overdrive_scaling = vmovq_n_f32(overdrive_scaling);
// vectorized code (four at once)
for (i = 0; i + 3 < PART_LEN1; i += 4) {
@ -408,7 +408,7 @@ static void OverdriveAndSuppressNEON(AecCore* aec,
const float32x4_t vec_overDriveCurve =
vld1q_f32(&WebRtcAec_overDriveCurve[i]);
const float32x4_t vec_overDriveSm_overDriveCurve =
vmulq_f32(vec_overDriveSm, vec_overDriveCurve);
vmulq_f32(vec_overdrive_scaling, vec_overDriveCurve);
vec_hNl = vpowq_f32(vec_hNl, vec_overDriveSm_overDriveCurve);
vst1q_f32(&hNl[i], vec_hNl);
}
@ -436,7 +436,7 @@ static void OverdriveAndSuppressNEON(AecCore* aec,
(1 - WebRtcAec_weightCurve[i]) * hNl[i];
}
hNl[i] = powf(hNl[i], aec->overDriveSm * WebRtcAec_overDriveCurve[i]);
hNl[i] = powf(hNl[i], overdrive_scaling * WebRtcAec_overDriveCurve[i]);
// Suppress error signal
efw[0][i] *= hNl[i];

View File

@ -375,7 +375,7 @@ static __m128 mm_pow_ps(__m128 a, __m128 b) {
return a_exp_b;
}
static void OverdriveAndSuppressSSE2(AecCore* aec,
static void OverdriveAndSuppressSSE2(float overdrive_scaling,
float hNl[PART_LEN1],
const float hNlFb,
float efw[2][PART_LEN1]) {
@ -383,7 +383,7 @@ static void OverdriveAndSuppressSSE2(AecCore* aec,
const __m128 vec_hNlFb = _mm_set1_ps(hNlFb);
const __m128 vec_one = _mm_set1_ps(1.0f);
const __m128 vec_minus_one = _mm_set1_ps(-1.0f);
const __m128 vec_overDriveSm = _mm_set1_ps(aec->overDriveSm);
const __m128 vec_overdrive_scaling = _mm_set1_ps(overdrive_scaling);
// vectorized code (four at once)
for (i = 0; i + 3 < PART_LEN1; i += 4) {
// Weight subbands
@ -403,7 +403,7 @@ static void OverdriveAndSuppressSSE2(AecCore* aec,
const __m128 vec_overDriveCurve =
_mm_loadu_ps(&WebRtcAec_overDriveCurve[i]);
const __m128 vec_overDriveSm_overDriveCurve =
_mm_mul_ps(vec_overDriveSm, vec_overDriveCurve);
_mm_mul_ps(vec_overdrive_scaling, vec_overDriveCurve);
vec_hNl = mm_pow_ps(vec_hNl, vec_overDriveSm_overDriveCurve);
_mm_storeu_ps(&hNl[i], vec_hNl);
}
@ -429,7 +429,7 @@ static void OverdriveAndSuppressSSE2(AecCore* aec,
hNl[i] = WebRtcAec_weightCurve[i] * hNlFb +
(1 - WebRtcAec_weightCurve[i]) * hNl[i];
}
hNl[i] = powf(hNl[i], aec->overDriveSm * WebRtcAec_overDriveCurve[i]);
hNl[i] = powf(hNl[i], overdrive_scaling * WebRtcAec_overDriveCurve[i]);
// Suppress error signal
efw[0][i] *= hNl[i];