ref: 1d6ad108fb2c6567a96850b2235c3ecad2b17596
parent: 42074389bdd87441e0a9330b23b737db82e94434
author: Jean-Marc Valin <[email protected]>
date: Wed Feb 27 06:25:25 EST 2008
fixed-point: converted window to 16-bit value
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -75,7 +75,7 @@
kiss_fftr_cfg fft;
struct PsyDecay psy;
- float *window;
+ celt_word16_t *window;
celt_sig_t *in_mem;
celt_sig_t *mdct_overlap;
celt_sig_t *out_mem;
@@ -112,7 +112,7 @@
st->fft = kiss_fftr_alloc(MAX_PERIOD*C, 0, 0);
psydecay_init(&st->psy, MAX_PERIOD*C/2, st->mode->Fs);
- st->window = celt_alloc(2*N*sizeof(float));
+ st->window = (celt_word16_t*)celt_alloc(2*N*sizeof(celt_word16_t));
st->in_mem = celt_alloc(N*C*sizeof(celt_sig_t));
st->mdct_overlap = celt_alloc(N*C*sizeof(celt_sig_t));
st->out_mem = celt_alloc(MAX_PERIOD*C*sizeof(celt_sig_t));
@@ -120,9 +120,9 @@
st->window[i] = 0;
for (i=0;i<st->overlap;i++)
st->window[N4+i] = st->window[2*N-N4-i-1]
- = sin(.5*M_PI* sin(.5*M_PI*(i+.5)/st->overlap) * sin(.5*M_PI*(i+.5)/st->overlap));
+ = Q15ONE*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/st->overlap) * sin(.5*M_PI*(i+.5)/st->overlap));
for (i=0;i<2*N4;i++)
- st->window[N-N4+i] = 1;
+ st->window[N-N4+i] = Q15ONE;
st->oldBandE = celt_alloc(C*mode->nbEBands*sizeof(float));
st->preemph = QCONST16(0.8f,15);
@@ -176,7 +176,7 @@
}
/** Apply window and compute the MDCT for all sub-frames and all channels in a frame */
-static float compute_mdcts(mdct_lookup *mdct_lookup, float *window, celt_sig_t *in, celt_sig_t *out, int N, int B, int C)
+static float compute_mdcts(mdct_lookup *mdct_lookup, celt_word16_t *window, celt_sig_t *in, celt_sig_t *out, int N, int B, int C)
{
int i, c;
float E = 1e-15;
@@ -191,7 +191,7 @@
int j;
for (j=0;j<2*N;j++)
{
- x[j] = window[j]*in[C*i*N+C*j+c];
+ x[j] = MULT16_32_Q15(window[j],in[C*i*N+C*j+c]);
E += SIG_SCALING_1*SIG_SCALING_1*x[j]*x[j];
}
mdct_forward(mdct_lookup, x, tmp);
@@ -204,7 +204,7 @@
}
/** Compute the IMDCT and apply window for all sub-frames and all channels in a frame */
-static void compute_inv_mdcts(mdct_lookup *mdct_lookup, float *window, celt_sig_t *X, celt_sig_t *out_mem, celt_sig_t *mdct_overlap, int N, int overlap, int B, int C)
+static void compute_inv_mdcts(mdct_lookup *mdct_lookup, celt_word16_t *window, celt_sig_t *X, celt_sig_t *out_mem, celt_sig_t *mdct_overlap, int N, int overlap, int B, int C)
{
int i, c, N4;
VARDECL(celt_word32_t *x);
@@ -222,7 +222,7 @@
tmp[j] = X[C*B*j+C*i+c];
mdct_backward(mdct_lookup, tmp, x);
for (j=0;j<2*N;j++)
- x[j] = window[j]*x[j];
+ x[j] = MULT16_32_Q15(window[j],x[j]);
for (j=0;j<overlap;j++)
out_mem[C*(MAX_PERIOD+(i-B)*N)+C*j+c] = 2*(x[N4+j]+mdct_overlap[C*j+c]);
for (j=0;j<2*N4;j++)
@@ -296,8 +296,8 @@
{
for (i=0;i<N;i++)
{
- in[C*i+c] *= st->window[i];
- in[C*(B*N+i)+c] *= st->window[N+i];
+ in[C*i+c] = MULT16_32_Q15(st->window[i], in[C*i+c]);
+ in[C*(B*N+i)+c] = MULT16_32_Q15(st->window[N+i], in[C*(B*N+i)+c]);
}
}
find_spectral_pitch(st->fft, &st->psy, in, st->out_mem, MAX_PERIOD, (B+1)*N, C, &pitch_index);
@@ -460,7 +460,7 @@
mdct_lookup mdct_lookup;
- float *window;
+ celt_word16_t *window;
celt_sig_t *mdct_overlap;
celt_sig_t *out_mem;
@@ -492,7 +492,7 @@
mdct_init(&st->mdct_lookup, 2*N);
- st->window = celt_alloc(2*N*sizeof(float));
+ st->window = (celt_word16_t*)celt_alloc(2*N*sizeof(celt_word16_t));
st->mdct_overlap = celt_alloc(N*C*sizeof(celt_sig_t));
st->out_mem = celt_alloc(MAX_PERIOD*C*sizeof(celt_sig_t));
@@ -500,9 +500,9 @@
st->window[i] = 0;
for (i=0;i<st->overlap;i++)
st->window[N4+i] = st->window[2*N-N4-i-1]
- = sin(.5*M_PI* sin(.5*M_PI*(i+.5)/st->overlap) * sin(.5*M_PI*(i+.5)/st->overlap));
+ = Q15ONE*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/st->overlap) * sin(.5*M_PI*(i+.5)/st->overlap));
for (i=0;i<2*N4;i++)
- st->window[N-N4+i] = 1;
+ st->window[N-N4+i] = Q15ONE;
st->oldBandE = celt_alloc(C*mode->nbEBands*sizeof(float));