Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/celt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <Jean-Marc.Valin@csiro.au>2008-02-26 03:38:00 +0300
committerJean-Marc Valin <Jean-Marc.Valin@csiro.au>2008-02-26 04:21:58 +0300
commit2fa8affdc5134327592c473ce9f429f94cd403f5 (patch)
treea858d4f4e7b2604b6cc34b302d4d48531ffa2705 /libcelt
parent9a5f3d2e6d6f9ca7278697180d18efdfd685913d (diff)
fixed-point: celt_norm_t now a 16-bit value.
Diffstat (limited to 'libcelt')
-rw-r--r--libcelt/arch.h2
-rw-r--r--libcelt/bands.c8
-rw-r--r--libcelt/vq.c28
-rw-r--r--libcelt/vq.h4
4 files changed, 27 insertions, 15 deletions
diff --git a/libcelt/arch.h b/libcelt/arch.h
index 7214200..e954c70 100644
--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -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
diff --git a/libcelt/bands.c b/libcelt/bands.c
index 299dd38..ab5056c 100644
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -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 */
diff --git a/libcelt/vq.c b/libcelt/vq.c
index 3827d87..91c107e 100644
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -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;
}
}
diff --git a/libcelt/vq.h b/libcelt/vq.h
index 284d74e..493ff8c 100644
--- 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 @@ 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.