diff --git a/libcelt/celt.c b/libcelt/celt.c index b04cadedc7e7f24317cc46b579516f9790a2ed71..752c7794a2d1b929fbadf61084e50afeae7f9e58 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -745,7 +745,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c } { - celt_word16 pitch_buf[(MAX_PERIOD+N)>>1]; + celt_word16 pitch_buf[(COMBFILTER_MAXPERIOD+N)>>1]; celt_word32 tmp=0; celt_word32 mem0[2]={0,0}; celt_word16 mem1[2]={0,0}; @@ -756,7 +756,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c COMBFILTER_MAXPERIOD-50, &pitch_index, &tmp, 1<<LM, &gain1); pitch_index = COMBFILTER_MAXPERIOD-pitch_index; - gain1 = remove_doubling(pre, COMBFILTER_MAXPERIOD, N, &pitch_index, + gain1 = remove_doubling(pitch_buf, COMBFILTER_MAXPERIOD, N, &pitch_index, st->prefilter_period, st->prefilter_gain); /*printf("%d %f\n", pitch_index, gain1);*/ if (pitch_index > COMBFILTER_MAXPERIOD) diff --git a/libcelt/pitch.c b/libcelt/pitch.c index c4fc0c18b729010685df36f771c098920c95148b..7cc26e4e87f124e6b4e7d830848dee9e590f05aa 100644 --- a/libcelt/pitch.c +++ b/libcelt/pitch.c @@ -214,17 +214,21 @@ void pitch_search(const CELTMode *m, const celt_word16 * restrict x_lp, celt_wor /*printf ("%d\n", *pitch);*/ } -float remove_doubling(celt_word32 *pre[2], int COMBFILTER_MAXPERIOD, int N, int *_T0, +float remove_doubling(celt_word16 *x, int maxperiod, int N, int *_T0, int prev_period, celt_word16 prev_gain) { int k, i, T, T0, k0; float g, g0; float pg; - float *x; float xy,xx,yy; + maxperiod /= 2; + *_T0 /= 2; + prev_period /= 2; + N /= 2; + x += maxperiod; + T = T0 = *_T0; - x = pre[0]+COMBFILTER_MAXPERIOD; xx=xy=yy=0; for (i=0;i<N;i++) { @@ -241,11 +245,11 @@ float remove_doubling(celt_word32 *pre[2], int COMBFILTER_MAXPERIOD, int N, int float g1; float cont=0; T1 = (2*T0+k)/(2*k); - if (T1 < 50) + if (T1 < 25) break; if (k==2) { - if (T1+T0>COMBFILTER_MAXPERIOD) + if (T1+T0>maxperiod) T1b = T0; else T1b = T0+T1; @@ -269,7 +273,7 @@ float remove_doubling(celt_word32 *pre[2], int COMBFILTER_MAXPERIOD, int N, int cont += 2*prev_gain; if (abs(T1-prev_period)<=4) cont += prev_gain; - if (g1+cont > .75*g0 || g1+cont > .65) + if (g1+cont > .7*g0 || g1+cont > .6) { pg = xy/(1+yy); g = g1; @@ -279,7 +283,7 @@ float remove_doubling(celt_word32 *pre[2], int COMBFILTER_MAXPERIOD, int N, int if (pg > g) pg = g; /*printf ("%d %d ", T0, T);*/ - *_T0 = T; + *_T0 = 2*T; return pg; } diff --git a/libcelt/pitch.h b/libcelt/pitch.h index 0a90ff3b175de7d25bac488a32bfa3f3bbd4123d..676871dac5c2312404cca3e3243e20764b73dcec 100644 --- a/libcelt/pitch.h +++ b/libcelt/pitch.h @@ -46,7 +46,7 @@ void pitch_downsample(celt_sig * restrict x[], celt_word16 * restrict x_lp, int void pitch_search(const CELTMode *m, const celt_word16 * restrict x_lp, celt_word16 * restrict y, int len, int max_pitch, int *pitch, celt_sig *xmem, int M, celt_word16 *gain); -float remove_doubling(celt_word32 *pre[2], int COMBFILTER_MAXPERIOD, int N, int *T0, +float remove_doubling(celt_word16 *x, int COMBFILTER_MAXPERIOD, int N, int *T0, int prev_period, celt_word16 prev_gain); #endif