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

fixed-point: celt_norm_t now a 16-bit value.

parent 9a5f3d2e
......@@ -52,7 +52,7 @@ typedef celt_int16_t celt_word16_t;
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
......
......@@ -241,7 +241,9 @@ void quant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, float *W, in
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 @@ void unquant_bands(const CELTMode *m, celt_norm_t *X, celt_norm_t *P, int total_
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 */
......
......@@ -70,9 +70,11 @@ struct NBest {
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 @@ void alg_quant(celt_norm_t *x, float *W, int N, int K, celt_norm_t *p, float alp
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 @@ void alg_quant(celt_norm_t *x, float *W, int N, int K, celt_norm_t *p, float alp
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,30 +313,34 @@ void alg_quant(celt_norm_t *x, float *W, int N, int K, celt_norm_t *p, float alp
}
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;
}
}
/** 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;
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 @@ void alg_unquant(celt_norm_t *x, int N, int K, celt_norm_t *p, float alpha, ec_d
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;
}
}
......
......@@ -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 @@ void alg_quant(celt_norm_t *x, float *W, int N, int K, celt_norm_t *p, float alp
* @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.
......
Markdown is supported
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