Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@amazon.com>2023-11-25 02:28:08 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-11-25 02:28:08 +0300
commit984f35b313d57280e3e1b108ba3418e7e6232e22 (patch)
tree45151023f2c249a2a7ee8da273101493eaf48f0d
parentd65b7de3c559b5f38119ac96838e2716236cd572 (diff)
Speed up cross-correlation normalization
-rw-r--r--dnn/lpcnet_enc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/dnn/lpcnet_enc.c b/dnn/lpcnet_enc.c
index f2c2238f..e720c958 100644
--- a/dnn/lpcnet_enc.c
+++ b/dnn/lpcnet_enc.c
@@ -120,6 +120,7 @@ void compute_frame_features(LPCNetEncState *st, const float *in, int arch) {
float frame_corr;
float xy, xx, yy;
int pitch;
+ float ener_norm[PITCH_MAX_PERIOD - PITCH_MIN_PERIOD];
/* [b,a]=ellip(2, 2, 20, 1200/8000); */
static const float lp_b[2] = {-0.84946f, 1.f};
static const float lp_a[2] = {-1.54220f, 0.70781f};
@@ -168,15 +169,19 @@ void compute_frame_features(LPCNetEncState *st, const float *in, int arch) {
float *buf = st->exc_buf;
celt_pitch_xcorr(&buf[PITCH_MAX_PERIOD], buf, xcorr, FRAME_SIZE, PITCH_MAX_PERIOD-PITCH_MIN_PERIOD, arch);
ener0 = celt_inner_prod(&buf[PITCH_MAX_PERIOD], &buf[PITCH_MAX_PERIOD], FRAME_SIZE, arch);
- ener1 = celt_inner_prod(&buf[0], &buf[0], FRAME_SIZE-1, arch);
+ ener1 = celt_inner_prod(&buf[0], &buf[0], FRAME_SIZE, arch);
/*printf("%f\n", st->frame_weight[sub]);*/
for (i=0;i<PITCH_MAX_PERIOD-PITCH_MIN_PERIOD;i++) {
- ener1 += buf[i+FRAME_SIZE-1]*buf[i+FRAME_SIZE-1];
ener = 1 + ener0 + ener1;
- st->xcorr_features[i] = 2*xcorr[i] / ener;
- ener1 -= buf[i]*buf[i];
+ st->xcorr_features[i] = 2*xcorr[i];
+ ener_norm[i] = ener;
+ ener1 += buf[i+FRAME_SIZE]*(double)buf[i+FRAME_SIZE] - buf[i]*(double)buf[i];
/*printf("%f ", st->xcorr_features[i]);*/
}
+ /* Split in a separate loop so the compiler can vectorize it */
+ for (i=0;i<PITCH_MAX_PERIOD-PITCH_MIN_PERIOD;i++) {
+ st->xcorr_features[i] /= ener_norm[i];
+ }
/*printf("\n");*/
}
st->dnn_pitch = compute_pitchdnn(&st->pitchdnn, st->if_features, st->xcorr_features, arch);