Commit b4dfce46 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

fixed-point: Using a NORM_SCALING of 16384, sig_norm_t is still a float though.

parent 5c032a4c
......@@ -59,6 +59,8 @@ typedef float celt_norm_t;
#define LPC_SCALING 8192
#define SIG_SCALING 16384.f
#define SIG_SCALING_1 0.000061035
#define NORM_SCALING 16384.f
#define NORM_SCALING_1 0.000061035
#define LSP_SCALING 8192.
#define GAMMA_SCALING 32768.
......@@ -105,6 +107,9 @@ typedef float celt_norm_t;
#define LPC_SCALING 1.f
#define SIG_SCALING 1.f
#define SIG_SCALING_1 1.f
#define NORM_SCALING 1.f
#define NORM_SCALING_1 1.f
#define LSP_SCALING 1.f
#define GAMMA_SCALING 1.f
#define GAIN_SCALING 1.f
......
......@@ -105,7 +105,7 @@ void normalise_bands(const CELTMode *m, celt_sig_t *freq, celt_norm_t *X, float
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] = SIG_SCALING_1*freq[j*C+c]*g;
X[j*C+c] = NORM_SCALING*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 @@ void denormalise_bands(const CELTMode *m, celt_norm_t *X, celt_sig_t *freq, floa
int j;
float g = bank[i*C+c];
for (j=B*eBands[i];j<B*eBands[i+1];j++)
freq[j*C+c] = SIG_SCALING*X[j*C+c] * g;
freq[j*C+c] = NORM_SCALING_1*SIG_SCALING*X[j*C+c] * g;
}
}
for (i=B*C*eBands[m->nbEBands];i<B*C*eBands[m->nbEBands+1];i++)
......@@ -168,10 +168,10 @@ void compute_pitch_gain(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float
float gain;
for (j=B*pBands[i];j<B*pBands[i+1];j++)
{
Sxy += X[j]*P[j]*w[j];
Sxx += X[j]*X[j]*w[j];
Sxy += 1.f*X[j]*P[j]*w[j];
Sxx += 1.f*X[j]*X[j]*w[j];
}
gain = Sxy/(1e-10+Sxx);
gain = Sxy/(1e-10*NORM_SCALING*NORM_SCALING+Sxx);
if (gain > 1.f)
gain = 1.f;
if (gain < 0.0f)
......
......@@ -64,7 +64,7 @@ void mdct_init(mdct_lookup *l,int N)
N2 = N/2;
N4 = N/4;
l->kfft = kiss_fft_alloc(N4, NULL, NULL);
l->trig = celt_alloc(N2*sizeof(float));
l->trig = (kiss_twiddle_scalar*)celt_alloc(N2*sizeof(kiss_twiddle_scalar));
/* We have enough points that sine isn't necessary */
#if defined(FIXED_POINT)
#if defined(DOUBLE_PRECISION) & !defined(MIXED_PRECISION)
......
......@@ -106,6 +106,12 @@ void alg_quant(celt_norm_t *x, float *W, int N, int K, celt_norm_t *p, float alp
ALLOC(_nbest, L, struct NBest);
ALLOC(nbest, L, struct NBest *);
for (j=0;j<N;j++)
{
x[j] *= NORM_SCALING_1;
p[j] *= NORM_SCALING_1;
}
for (m=0;m<L;m++)
nbest[m] = &_nbest[m];
......@@ -301,6 +307,11 @@ void alg_quant(celt_norm_t *x, float *W, int N, int K, celt_norm_t *p, float alp
x[i] = p[i] + g*y[0][i];
}
for (j=0;j<N;j++)
{
x[j] *= NORM_SCALING;
p[j] *= NORM_SCALING;
}
}
......@@ -318,6 +329,11 @@ void alg_unquant(celt_norm_t *x, int N, int K, celt_norm_t *p, float alpha, ec_d
ALLOC(y, N, float);
decode_pulses(iy, N, K, dec);
for (i=0;i<N;i++)
{
x[i] *= NORM_SCALING_1;
p[i] *= NORM_SCALING_1;
}
/*for (i=0;i<N;i++)
printf ("%d ", iy[i]);*/
......@@ -342,6 +358,12 @@ void alg_unquant(celt_norm_t *x, int N, int K, celt_norm_t *p, float alpha, ec_d
for (i=0;i<N;i++)
x[i] = p[i] + g*y[i];
for (i=0;i<N;i++)
{
x[i] *= NORM_SCALING;
p[i] *= NORM_SCALING;
}
}
......@@ -367,8 +389,8 @@ void intra_prediction(celt_norm_t *x, float *W, int N, int K, celt_norm_t *Y, ce
float score;
for (j=0;j<N;j++)
{
xy += x[j]*Y[i+N-j-1];
yy += Y[i+N-j-1]*Y[i+N-j-1];
xy += 1.f*x[j]*Y[i+N-j-1];
yy += 1.f*Y[i+N-j-1]*Y[i+N-j-1];
}
score = xy*xy/(.001+yy);
if (score > best_score)
......@@ -398,7 +420,7 @@ void intra_prediction(celt_norm_t *x, float *W, int N, int K, celt_norm_t *Y, ce
for (j=0;j<N;j++)
{
P[j] = s*Y[best+N-j-1];
E += P[j]*P[j];
E += NORM_SCALING_1*NORM_SCALING_1*P[j]*P[j];
}
E = pred_gain/sqrt(E);
for (j=0;j<N;j++)
......@@ -445,7 +467,7 @@ void intra_unquant(celt_norm_t *x, int N, int K, celt_norm_t *Y, celt_norm_t *P,
for (j=0;j<N;j++)
{
P[j] = s*Y[best+N-j-1];
E += P[j]*P[j];
E += NORM_SCALING_1*NORM_SCALING_1*P[j]*P[j];
}
E = pred_gain/sqrt(E);
for (j=0;j<N;j++)
......@@ -470,14 +492,14 @@ void intra_fold(celt_norm_t *x, int N, celt_norm_t *Y, celt_norm_t *P, int B, in
for (j=0;j<N/B;j++)
{
P[j*B+i] = Y[(Nmax-N0-j-1)*B+i];
E += P[j*B+i]*P[j*B+i];
E += NORM_SCALING_1*NORM_SCALING_1*P[j*B+i]*P[j*B+i];
}
}
} else {
for (j=0;j<N;j++)
{
P[j] = Y[j];
E += P[j]*P[j];
E += NORM_SCALING_1*NORM_SCALING_1*P[j]*P[j];
}
}
E = 1.f/sqrt(E);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment