ref: 137ec8e9b83c46d1d0491f7e15ba0ec0426246a2
parent: 05080b4b9bce8f63860008483e6c85fc4b5a59b8
author: Jean-Marc Valin <[email protected]>
date: Mon Mar 3 09:44:42 EST 2008
applying the pitch windowing directly in find_spectral_pitch()
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -291,7 +291,7 @@
mask[i] = 1/(.1+mask[i]);
#endif
/* Pitch analysis */
- for (c=0;c<C;c++)
+ /*for (c=0;c<C;c++)
{
for (i=0;i<st->overlap;i++)
{
@@ -298,8 +298,8 @@
in[C*i+c] = MULT16_32_Q15(st->mode->window[i], in[C*i+c]);
in[C*(B*N+N-i-2*N4-1)+c] = MULT16_32_Q15(st->mode->window[i], in[C*(B*N+N-i-2*N4-1)+c]);
}
- }
- find_spectral_pitch(st->fft, &st->psy, in, st->out_mem, MAX_PERIOD, (B+1)*N-2*N4, C, &pitch_index);
+ }*/
+ find_spectral_pitch(st->fft, &st->psy, in, st->out_mem, st->mode->window, st->overlap, MAX_PERIOD, (B+1)*N-2*N4, C, &pitch_index);
/* Deferred allocation after find_spectral_pitch() to reduce the peak memory usage */
ALLOC(X, B*C*N, celt_norm_t); /**< Interleaved normalised MDCTs */
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -46,7 +46,7 @@
#include "_kiss_fft_guts.h"
#include "kiss_fftr.h"
-void find_spectral_pitch(kiss_fftr_cfg fft, struct PsyDecay *decay, celt_sig_t *x, celt_sig_t *y, int lag, int len, int C, int *pitch)
+void find_spectral_pitch(kiss_fftr_cfg fft, struct PsyDecay *decay, celt_sig_t *x, celt_sig_t *y, celt_word16_t *window, int overlap, int lag, int len, int C, int *pitch)
{
int c, i;
float max_corr;
@@ -54,8 +54,10 @@
VARDECL(celt_word32_t *Y);
VARDECL(celt_mask_t *curve);
int n2;
+ int L2;
SAVE_STACK;
n2 = lag/2;
+ L2 = len/2;
ALLOC(X, lag, celt_word32_t);
ALLOC(curve, n2, celt_mask_t);
@@ -63,12 +65,20 @@
X[i] = 0;
for (c=0;c<C;c++)
{
- for (i=0;i<len/2;i++)
+ for (i=0;i<L2;i++)
{
X[2*fft->substate->bitrev[i]] += SHR32(x[C*(2*i)+c],1);
X[2*fft->substate->bitrev[i]+1] += SHR32(x[C*(2*i+1)+c],1);
}
}
+ for (i=0;i<overlap/2;i++)
+ {
+ X[2*fft->substate->bitrev[i]] = MULT16_32_Q15(window[2*i], X[2*fft->substate->bitrev[i]]);
+ X[2*fft->substate->bitrev[i]+1] = MULT16_32_Q15(window[2*i+1], X[2*fft->substate->bitrev[i]+1]);
+ X[2*fft->substate->bitrev[len-i-1]] = MULT16_32_Q15(window[2*i], X[2*fft->substate->bitrev[len-i-1]]);
+ X[2*fft->substate->bitrev[len-i-1]+1] = MULT16_32_Q15(window[2*i+1], X[2*fft->substate->bitrev[len-i-1]+1]);
+ }
+
kf_work((kiss_fft_cpx*)X, NULL, 1,1, fft->substate->factors,fft->substate, 1, 1, 1);
kiss_fftr_twiddles(fft,X);
@@ -80,7 +90,7 @@
Y[i] = 0;
for (c=0;c<C;c++)
{
- for (i=0;i<lag/2;i++)
+ for (i=0;i<n2;i++)
{
Y[2*fft->substate->bitrev[i]] += SHR32(y[C*(2*i)+c],1);
Y[2*fft->substate->bitrev[i]+1] += SHR32(y[C*(2*i+1)+c],1);
--- a/libcelt/pitch.h
+++ b/libcelt/pitch.h
@@ -44,6 +44,6 @@
/** Find the optimal delay for the pitch prediction. Computation is
done in the frequency domain, both to save time and to make it
easier to apply psychoacoustic weighting */
-void find_spectral_pitch(kiss_fftr_cfg fft, struct PsyDecay *decay, celt_sig_t *x, celt_sig_t *y, int lag, int len, int C, int *pitch);
+void find_spectral_pitch(kiss_fftr_cfg fft, struct PsyDecay *decay, celt_sig_t *x, celt_sig_t *y, celt_word16_t *window, int overlap, int lag, int len, int C, int *pitch);
#endif