ref: b2b2e226c3af2547e769731517c3ff7389e65026
parent: 976729dcd0dcda5826b25ae37d8d2922f57e144f
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Mon Nov 15 10:49:57 EST 2021
Optional code for interpolating the pitch correlation
--- a/dnn/lpcnet_enc.c
+++ b/dnn/lpcnet_enc.c
@@ -544,6 +544,24 @@
ener = (1 + ener0 + celt_inner_prod(&st->exc_buf[i+off], &st->exc_buf[i+off], FRAME_SIZE/2));
st->xc[2+2*st->pcount+sub][i] = 2*xcorr[i] / ener;
}
+ if (0) {+ /* Upsample correlation by 3x and keep the max. */
+ float interpolated[PITCH_MAX_PERIOD]={0};+ /* interp=sinc([-3:3]+1/3).*(.5+.5*cos(pi*[-3:3]/4.5)); interp=interp/sum(interp); */
+ static const float interp[7] = {0.026184, -0.098339, 0.369938, 0.837891, -0.184969, 0.070242, -0.020947};+ for (i=4;i<PITCH_MAX_PERIOD-4;i++) {+ float val1=0, val2=0;
+ int j;
+ for (j=0;j<7;j++) {+ val1 += st->xc[2+2*st->pcount+sub][i-3+j]*interp[j];
+ val2 += st->xc[2+2*st->pcount+sub][i+3-j]*interp[j];
+ interpolated[i] = MAX16(st->xc[2+2*st->pcount+sub][i], MAX16(val1, val2));
+ }
+ }
+ for (i=4;i<PITCH_MAX_PERIOD-4;i++) {+ st->xc[2+2*st->pcount+sub][i] = interpolated[i];
+ }
+ }
#if 0
for (i=0;i<PITCH_MAX_PERIOD;i++)
printf("%f ", st->xc[2*st->pcount+sub][i]);--
⑨