ref: 5c032a4cb4620d5a1dad7eadb5e3d90a962a5256
parent: 49ca99efa524928080db0774eed01beba7be45e2
author: Jean-Marc Valin <[email protected]>
date: Mon Feb 25 09:55:09 EST 2008
fixed-point: celt_sig_t now a 32-bit value.
--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -51,7 +51,7 @@
typedef celt_int16_t celt_word16_t;
typedef celt_int32_t celt_word32_t;
-typedef float celt_sig_t;
+typedef celt_word32_t celt_sig_t;
typedef float celt_norm_t;
#define Q15ONE 32767
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -83,7 +83,7 @@
int j;
float sum = 1e-10;
for (j=B*eBands[i];j<B*eBands[i+1];j++)
- sum += X[j*C+c]*X[j*C+c];
+ sum += SIG_SCALING_1*SIG_SCALING_1*X[j*C+c]*X[j*C+c];
bank[i*C+c] = sqrt(C*sum);
/*printf ("%f ", bank[i*C+c]);*/
}
@@ -105,7 +105,7 @@
int j;
float g = 1.f/(1e-10+bank[i*C+c]);
for (j=B*eBands[i];j<B*eBands[i+1];j++)
- X[j*C+c] = freq[j*C+c]*g;
+ X[j*C+c] = SIG_SCALING_1*freq[j*C+c]*g;
}
}
for (i=B*C*eBands[m->nbEBands];i<B*C*eBands[m->nbEBands+1];i++)
@@ -135,7 +135,7 @@
int j;
float g = bank[i*C+c];
for (j=B*eBands[i];j<B*eBands[i+1];j++)
- freq[j*C+c] = X[j*C+c] * g;
+ freq[j*C+c] = SIG_SCALING*X[j*C+c] * g;
}
}
for (i=B*C*eBands[m->nbEBands];i<B*C*eBands[m->nbEBands+1];i++)
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -177,13 +177,13 @@
int j;
for (j=0;j<2*N;j++)
{
- x[j] = SIG_SCALING*window[j]*in[C*i*N+C*j+c];
+ x[j] = 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);
/* Interleaving the sub-frames */
for (j=0;j<N;j++)
- out[C*B*j+C*i+c] = SIG_SCALING_1*tmp[j];
+ out[C*B*j+C*i+c] = tmp[j];
}
}
return E;
@@ -205,16 +205,16 @@
int j;
/* De-interleaving the sub-frames */
for (j=0;j<N;j++)
- tmp[j] = SIG_SCALING*X[C*B*j+C*i+c];
+ 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];
for (j=0;j<overlap;j++)
- out_mem[C*(MAX_PERIOD+(i-B)*N)+C*j+c] = 2*(SIG_SCALING_1*x[N4+j]+mdct_overlap[C*j+c]);
+ 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++)
- out_mem[C*(MAX_PERIOD+(i-B)*N)+C*(j+overlap)+c] = 2*SIG_SCALING_1*x[j+N4+overlap];
+ out_mem[C*(MAX_PERIOD+(i-B)*N)+C*(j+overlap)+c] = 2*x[j+N4+overlap];
for (j=0;j<overlap;j++)
- mdct_overlap[C*j+c] = SIG_SCALING_1*x[N+N4+j];
+ mdct_overlap[C*j+c] = x[N+N4+j];
}
}
}
@@ -257,7 +257,7 @@
in[C*(i+N4)+c] = st->in_mem[C*i+c];
for (i=0;i<B*N;i++)
{
- float tmp = pcm[C*i+c];
+ float tmp = SIG_SCALING*pcm[C*i+c];
in[C*(i+st->overlap+N4)+c] = tmp - st->preemph*st->preemph_memE[c];
st->preemph_memE[c] = tmp;
}
@@ -384,6 +384,7 @@
{
float tmp = st->out_mem[C*(MAX_PERIOD+(i-B)*N)+C*j+c] + st->preemph*st->preemph_memD[c];
st->preemph_memD[c] = tmp;
+ tmp *= SIG_SCALING_1;
if (tmp > 32767) tmp = 32767;
if (tmp < -32767) tmp = -32767;
pcm[C*i*N+C*j+c] = (short)floor(.5+tmp);
@@ -558,6 +559,7 @@
{
float tmp = st->out_mem[C*(MAX_PERIOD+(i-B)*N)+C*j+c] + st->preemph*st->preemph_memD[c];
st->preemph_memD[c] = tmp;
+ tmp *= SIG_SCALING_1;
if (tmp > 32767) tmp = 32767;
if (tmp < -32767) tmp = -32767;
pcm[C*i*N+C*j+c] = (short)floor(.5+tmp);
@@ -660,6 +662,7 @@
{
float tmp = st->out_mem[C*(MAX_PERIOD+(i-B)*N)+C*j+c] + st->preemph*st->preemph_memD[c];
st->preemph_memD[c] = tmp;
+ tmp *= SIG_SCALING_1;
if (tmp > 32767) tmp = 32767;
if (tmp < -32767) tmp = -32767;
pcm[C*i*N+C*j+c] = (short)floor(.5+tmp);
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -65,9 +65,9 @@
for (c=0;c<C;c++)
{
for (i=0;i<len;i++)
- xx[c*lag+i] = SIG_SCALING*x[C*i+c];
+ xx[c*lag+i] = x[C*i+c];
for (i=0;i<lag;i++)
- yy[c*lag+i] = SIG_SCALING*y[C*i+c];
+ yy[c*lag+i] = y[C*i+c];
}