ref: 2fa8affdc5134327592c473ce9f429f94cd403f5
parent: 9a5f3d2e6d6f9ca7278697180d18efdfd685913d
author: Jean-Marc Valin <[email protected]>
date: Tue Feb 26 06:38:00 EST 2008
fixed-point: celt_norm_t now a 16-bit value.
--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -52,7 +52,7 @@
typedef celt_int32_t celt_word32_t;
typedef celt_word32_t celt_sig_t;
-typedef float celt_norm_t;
+typedef celt_word16_t celt_norm_t;
#define Q15ONE 32767
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -241,7 +241,9 @@
int q;
float theta, n;
q = pulses[i];
- n = sqrt(B*(eBands[i+1]-eBands[i]));
+ /*Scale factor of .0625f is just there to prevent overflows in fixed-point
+ (has no effect on float)*/
+ n = .0625f*sqrt(B*(eBands[i+1]-eBands[i]));
theta = .007*(B*(eBands[i+1]-eBands[i]))/(.1f+q);
/* If pitch isn't available, use intra-frame prediction */
@@ -298,7 +300,9 @@
int q;
float theta, n;
q = pulses[i];
- n = sqrt(B*(eBands[i+1]-eBands[i]));
+ /*Scale factor of .0625f is just there to prevent overflows in fixed-point
+ (has no effect on float)*/
+ n = .0625f*sqrt(B*(eBands[i+1]-eBands[i]));
theta = .007*(B*(eBands[i+1]-eBands[i]))/(.1f+q);
/* If pitch isn't available, use intra-frame prediction */
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -70,9 +70,11 @@
float yp;
};
-void alg_quant(celt_norm_t *x, float *W, int N, int K, celt_norm_t *p, float alpha, ec_enc *enc)
+void alg_quant(celt_norm_t *X, float *W, int N, int K, celt_norm_t *P, float alpha, ec_enc *enc)
{
int L = 3;
+ VARDECL(float *x);
+ VARDECL(float *p);
VARDECL(float *_y);
VARDECL(float *_ny);
VARDECL(int *_iy);
@@ -91,6 +93,8 @@
float Rpp=0, Rxp=0;
int maxL = 1;
+ ALLOC(x, N, float);
+ ALLOC(p, N, float);
ALLOC(_y, L*N, float);
ALLOC(_ny, L*N, float);
ALLOC(_iy, L*N, int);
@@ -108,8 +112,8 @@
for (j=0;j<N;j++)
{
- x[j] *= NORM_SCALING_1;
- p[j] *= NORM_SCALING_1;
+ x[j] = X[j]*NORM_SCALING_1;
+ p[j] = P[j]*NORM_SCALING_1;
}
for (m=0;m<L;m++)
@@ -309,8 +313,8 @@
}
for (j=0;j<N;j++)
{
- x[j] *= NORM_SCALING;
- p[j] *= NORM_SCALING;
+ X[j] = x[j] * NORM_SCALING;
+ P[j] = p[j] * NORM_SCALING;
}
}
@@ -317,7 +321,7 @@
/** Decode pulse vector and combine the result with the pitch vector to produce
the final normalised signal in the current band. */
-void alg_unquant(celt_norm_t *x, int N, int K, celt_norm_t *p, float alpha, ec_dec *dec)
+void alg_unquant(celt_norm_t *X, int N, int K, celt_norm_t *P, float alpha, ec_dec *dec)
{
int i;
float Rpp=0, Ryp=0, Ryy=0;
@@ -324,15 +328,19 @@
float g;
VARDECL(int *iy);
VARDECL(float *y);
+ VARDECL(float *x);
+ VARDECL(float *p);
ALLOC(iy, N, int);
ALLOC(y, N, float);
+ ALLOC(x, N, float);
+ ALLOC(p, N, float);
decode_pulses(iy, N, K, dec);
for (i=0;i<N;i++)
{
- x[i] *= NORM_SCALING_1;
- p[i] *= NORM_SCALING_1;
+ x[i] = X[i]*NORM_SCALING_1;
+ p[i] = P[i]*NORM_SCALING_1;
}
/*for (i=0;i<N;i++)
@@ -360,8 +368,8 @@
x[i] = p[i] + g*y[i];
for (i=0;i<N;i++)
{
- x[i] *= NORM_SCALING;
- p[i] *= NORM_SCALING;
+ X[i] = x[i] * NORM_SCALING;
+ P[i] = p[i] * NORM_SCALING;
}
}
--- a/libcelt/vq.h
+++ b/libcelt/vq.h
@@ -51,7 +51,7 @@
* @param alpha compression factor to apply in the pitch direction (magic!)
* @param enc Entropy encoder state
*/
-void alg_quant(celt_norm_t *x, float *W, int N, int K, celt_norm_t *p, float alpha, ec_enc *enc);
+void alg_quant(celt_norm_t *X, float *W, int N, int K, celt_norm_t *P, float alpha, ec_enc *enc);
/** Algebraic pulse decoder
* @param x Decoded normalised spectrum (returned)
@@ -61,7 +61,7 @@
* @param alpha compression factor in the pitch direction (magic!)
* @param dec Entropy decoder state
*/
-void alg_unquant(celt_norm_t *x, int N, int K, celt_norm_t *p, float alpha, ec_dec *dec);
+void alg_unquant(celt_norm_t *X, int N, int K, celt_norm_t *P, float alpha, ec_dec *dec);
/** Intra-frame predictor that matches a section of the current frame (at lower
* frequencies) to encode the current band.