[xiph-cvs] cvs commit: speex/libspeex lsp.c lsp.h misc.h modes.h nb_celp.c nb_celp.h quant_lsp.c quant_lsp.h sb_celp.c sb_celp.h
Jean-Marc Valin
jm at xiph.org
Wed Oct 8 20:54:38 PDT 2003
jm 03/10/08 23:54:38
Modified: libspeex lsp.c lsp.h misc.h modes.h nb_celp.c nb_celp.h
quant_lsp.c quant_lsp.h sb_celp.c sb_celp.h
Log:
fixed-point: LSPs are now stored quantized
Revision Changes Path
1.33 +14 -14 speex/libspeex/lsp.c
Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- lsp.c 8 Oct 2003 22:31:41 -0000 1.32
+++ lsp.c 9 Oct 2003 03:54:37 -0000 1.33
@@ -57,8 +57,8 @@
#endif
#ifdef FIXED_POINT
-#define ANGLE2X(a) (cos(a))
-#define X2ANGLE(x) (acos(x))
+#define ANGLE2X(a) (cos((a)/LSP_SCALING))
+#define X2ANGLE(x) (acos(x)*LSP_SCALING)
#else
#define ANGLE2X(a) (cos(a))
#define X2ANGLE(x) (acos(x))
@@ -165,7 +165,7 @@
\*---------------------------------------------------------------------------*/
-int lpc_to_lsp (spx_coef_t *a,int lpcrdr,float *freq,int nb,float delta, char *stack)
+int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,float delta, char *stack)
/* float *a lpc coefficients */
/* int lpcrdr order of LPC coefficients (10) */
/* float *freq LSP frequencies in the x domain */
@@ -328,7 +328,7 @@
#ifdef FIXED_POINT
-void lsp_to_lpc(float *freq,spx_coef_t *ak,int lpcrdr, char *stack)
+void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
/* float *freq array of LSP frequencies in the x domain */
/* float *ak array of LPC coefficients */
/* int lpcrdr order of LPC coefficients */
@@ -400,7 +400,7 @@
}
#else
-void lsp_to_lpc(float *freq,spx_coef_t *ak,int lpcrdr, char *stack)
+void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
/* float *freq array of LSP frequencies in the x domain */
/* float *ak array of LPC coefficients */
/* int lpcrdr order of LPC coefficients */
@@ -463,19 +463,19 @@
/*Added by JMV
Makes sure the LSPs are stable*/
-void lsp_enforce_margin(float *lsp, int len, float margin)
+void lsp_enforce_margin(spx_lsp_t *lsp, int len, float margin)
{
int i;
- if (lsp[0]<margin)
- lsp[0]=margin;
- if (lsp[len-1]>M_PI-margin)
- lsp[len-1]=M_PI-margin;
+ if (lsp[0]<LSP_SCALING*margin)
+ lsp[0]=LSP_SCALING*margin;
+ if (lsp[len-1]>LSP_SCALING*(M_PI-margin))
+ lsp[len-1]=LSP_SCALING*(M_PI-margin);
for (i=1;i<len-1;i++)
{
- if (lsp[i]<lsp[i-1]+margin)
- lsp[i]=lsp[i-1]+margin;
+ if (lsp[i]<lsp[i-1]+LSP_SCALING*margin)
+ lsp[i]=lsp[i-1]+LSP_SCALING*margin;
- if (lsp[i]>lsp[i+1]-margin)
- lsp[i]= .5* (lsp[i] + lsp[i+1]-margin);
+ if (lsp[i]>lsp[i+1]-LSP_SCALING*margin)
+ lsp[i]= .5* (lsp[i] + lsp[i+1]-LSP_SCALING*margin);
}
}
<p><p>1.11 +3 -3 speex/libspeex/lsp.h
Index: lsp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- lsp.h 8 Oct 2003 22:31:41 -0000 1.10
+++ lsp.h 9 Oct 2003 03:54:37 -0000 1.11
@@ -49,10 +49,10 @@
#include "misc.h"
-int lpc_to_lsp (spx_coef_t *a, int lpcrdr, float *freq, int nb, float delta, char *stack);
-void lsp_to_lpc(float *freq, spx_coef_t *ak, int lpcrdr, char *stack);
+int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, float delta, char *stack);
+void lsp_to_lpc(spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack);
/*Added by JMV*/
-void lsp_enforce_margin(float *lsp, int len, float margin);
+void lsp_enforce_margin(spx_lsp_t *lsp, int len, float margin);
#endif /* __AK2LSPD__ */
<p><p>1.35 +4 -0 speex/libspeex/misc.h
Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- misc.h 8 Oct 2003 05:11:25 -0000 1.34
+++ misc.h 9 Oct 2003 03:54:37 -0000 1.35
@@ -45,10 +45,12 @@
typedef signed int spx_word32_t;
typedef spx_word32_t spx_mem_t;
typedef spx_word16_t spx_coef_t;
+typedef spx_word16_t spx_lsp_t;
typedef spx_word32_t spx_sig_t;
#define LPC_SCALING 8192.
#define SIG_SCALING 16384
+#define LSP_SCALING 8192.
#define LPC_SHIFT 13
#define SIG_SHIFT 14
@@ -78,12 +80,14 @@
typedef float spx_mem_t;
typedef float spx_coef_t;
+typedef float spx_lsp_t;
typedef float spx_sig_t;
typedef float spx_word16_t;
typedef float spx_word32_t;
#define LPC_SCALING 1.
#define SIG_SCALING 1.
+#define LSP_SCALING 1.
#define LPC_SHIFT 0
#define SIG_SHIFT 0
<p><p>1.47 +2 -2 speex/libspeex/modes.h
Index: modes.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- modes.h 8 Oct 2003 04:40:41 -0000 1.46
+++ modes.h 9 Oct 2003 03:54:37 -0000 1.47
@@ -48,10 +48,10 @@
/** Quantizes LSPs */
-typedef void (*lsp_quant_func)(float *, float *, int, SpeexBits *);
+typedef void (*lsp_quant_func)(spx_lsp_t *, spx_lsp_t *, int, SpeexBits *);
/** Decodes quantized LSPs */
-typedef void (*lsp_unquant_func)(float *, int, SpeexBits *);
+typedef void (*lsp_unquant_func)(spx_lsp_t *, int, SpeexBits *);
/** Long-term predictor quantization */
<p><p>1.139 +12 -10 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -r1.138 -r1.139
--- nb_celp.c 8 Oct 2003 22:31:41 -0000 1.138
+++ nb_celp.c 9 Oct 2003 03:54:37 -0000 1.139
@@ -144,17 +144,17 @@
st->bw_lpc1 = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
st->bw_lpc2 = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
- st->lsp = PUSH(st->stack, st->lpcSize, float);
- st->qlsp = PUSH(st->stack, st->lpcSize, float);
- st->old_lsp = PUSH(st->stack, st->lpcSize, float);
- st->old_qlsp = PUSH(st->stack, st->lpcSize, float);
- st->interp_lsp = PUSH(st->stack, st->lpcSize, float);
- st->interp_qlsp = PUSH(st->stack, st->lpcSize, float);
+ st->lsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->old_lsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->old_qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->interp_lsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->interp_qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
st->first = 1;
for (i=0;i<st->lpcSize;i++)
{
- st->lsp[i]=8192*(M_PI*((float)(i+1)))/(st->lpcSize+1);
+ st->lsp[i]=LSP_SCALING*(M_PI*((float)(i+1)))/(st->lpcSize+1);
}
st->mem_sp = PUSH(st->stack, st->lpcSize, spx_mem_t);
@@ -267,6 +267,7 @@
lsp_dist=0;
for (i=0;i<st->lpcSize;i++)
lsp_dist += (st->old_lsp[i] - st->lsp[i])*(st->old_lsp[i] - st->lsp[i]);
+ lsp_dist /= LSP_SCALING*LSP_SCALING;
/* Whole frame analysis (open-loop estimation of pitch and excitation gain) */
{
@@ -948,9 +949,9 @@
st->innov = PUSH(st->stack, st->frameSize, spx_sig_t);
st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
- st->qlsp = PUSH(st->stack, st->lpcSize, float);
- st->old_qlsp = PUSH(st->stack, st->lpcSize, float);
- st->interp_qlsp = PUSH(st->stack, st->lpcSize, float);
+ st->qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->old_qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->interp_qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
st->mem_sp = PUSH(st->stack, 5*st->lpcSize, spx_mem_t);
st->comb_mem = PUSHS(st->stack, CombFilterMem);
comp_filter_mem_init (st->comb_mem);
@@ -1261,6 +1262,7 @@
float lsp_dist=0, fact;
for (i=0;i<st->lpcSize;i++)
lsp_dist += fabs(st->old_qlsp[i] - st->qlsp[i]);
+ lsp_dist /= LSP_SCALING*LSP_SCALING;
fact = .6*exp(-.2*lsp_dist);
for (i=0;i<2*st->lpcSize;i++)
st->mem_sp[i] = (spx_mem_t)(st->mem_sp[i]*fact);
<p><p>1.58 +9 -9 speex/libspeex/nb_celp.h
Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- nb_celp.h 8 Oct 2003 05:03:47 -0000 1.57
+++ nb_celp.h 9 Oct 2003 03:54:37 -0000 1.58
@@ -84,12 +84,12 @@
spx_word16_t *autocorr; /**< auto-correlation */
float *lagWindow; /**< Window applied to auto-correlation */
spx_coef_t *lpc; /**< LPCs for current frame */
- float *lsp; /**< LSPs for current frame */
- float *qlsp; /**< Quantized LSPs for current frame */
- float *old_lsp; /**< LSPs for previous frame */
- float *old_qlsp; /**< Quantized LSPs for previous frame */
- float *interp_lsp; /**< Interpolated LSPs */
- float *interp_qlsp; /**< Interpolated quantized LSPs */
+ spx_lsp_t *lsp; /**< LSPs for current frame */
+ spx_lsp_t *qlsp; /**< Quantized LSPs for current frame */
+ spx_lsp_t *old_lsp; /**< LSPs for previous frame */
+ spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */
+ spx_lsp_t *interp_lsp; /**< Interpolated LSPs */
+ spx_lsp_t *interp_qlsp; /**< Interpolated quantized LSPs */
spx_coef_t *interp_lpc; /**< Interpolated LPCs */
spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs */
spx_coef_t *bw_lpc1; /**< LPCs after bandwidth expansion by gamma1 for perceptual weighting*/
@@ -149,9 +149,9 @@
spx_sig_t *excBuf; /**< Excitation buffer */
spx_sig_t *exc; /**< Start of excitation frame */
spx_sig_t *innov; /**< Innovation for the frame */
- float *qlsp; /**< Quantized LSPs for current frame */
- float *old_qlsp; /**< Quantized LSPs for previous frame */
- float *interp_qlsp; /**< Interpolated quantized LSPs */
+ spx_lsp_t *qlsp; /**< Quantized LSPs for current frame */
+ spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */
+ spx_lsp_t *interp_qlsp; /**< Interpolated quantized LSPs */
spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs */
spx_mem_t *mem_sp; /**< Filter memory for synthesis signal */
float *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
<p><p>1.26 +65 -78 speex/libspeex/quant_lsp.c
Index: quant_lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/quant_lsp.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- quant_lsp.c 8 Oct 2003 05:11:25 -0000 1.25
+++ quant_lsp.c 9 Oct 2003 03:54:37 -0000 1.26
@@ -32,19 +32,39 @@
#include "quant_lsp.h"
#include <math.h>
+
#include "misc.h"
/* FIXME: Get rid of this kludge quick before someone gets hurt */
-static spx_word16_t quant_weight[MAX_LSP_SIZE];
#ifdef FIXED_POINT
-#define LSP_SCALE 8192
-#define LSP_OVERSCALE 32
+#define LSP_SCALE (8192./LSP_SCALING)
+#define LSP_OVERSCALE (32./LSP_SCALING)
#else
#define LSP_SCALE 256
#define LSP_OVERSCALE 1
#endif
+static void compute_quant_weights(spx_lsp_t *qlsp, spx_word16_t *quant_weight, int order)
+{
+ int i;
+ float tmp1, tmp2;
+ quant_weight[0] = 10/((qlsp[1]-qlsp[0])/LSP_SCALING);
+ quant_weight[order-1] = 10/((qlsp[order-1]-qlsp[order-2])/LSP_SCALING);
+ for (i=1;i<order-1;i++)
+ {
+#if 1
+ tmp1 = 10/((.15+(qlsp[i]-qlsp[i-1])/LSP_SCALING)*(.15+(qlsp[i]-qlsp[i-1])/LSP_SCALING));
+ tmp2 = 10/((.15+(qlsp[i+1]-qlsp[i])/LSP_SCALING)*(.15+(qlsp[i+1]-qlsp[i])/LSP_SCALING));
+#else
+ tmp1 = 10/(qlsp[i]-qlsp[i-1]);
+ tmp2 = 10/(qlsp[i+1]-qlsp[i]);
+#endif
+ quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
+ }
+
+}
+
/* Note: x is modified*/
static int lsp_quant(spx_word16_t *x, signed char *cdbk, int nbVec, int nbDim)
{
@@ -105,32 +125,21 @@
}
-void lsp_quant_nb(float *lsp, float *qlsp, int order, SpeexBits *bits)
+void lsp_quant_nb(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
{
int i;
- float tmp1, tmp2;
int id;
/* FIXME: get rid of that static allocation */
+ spx_word16_t quant_weight[10];
spx_word16_t nlsp[10];
for (i=0;i<order;i++)
qlsp[i]=lsp[i];
- quant_weight[0] = 10/(qlsp[1]-qlsp[0]);
- quant_weight[order-1] = 10/(qlsp[order-1]-qlsp[order-2]);
- for (i=1;i<order-1;i++)
- {
-#if 1
- tmp1 = 10/((.15+qlsp[i]-qlsp[i-1])*(.15+qlsp[i]-qlsp[i-1]));
- tmp2 = 10/((.15+qlsp[i+1]-qlsp[i])*(.15+qlsp[i+1]-qlsp[i]));
-#else
- tmp1 = 10/(qlsp[i]-qlsp[i-1]);
- tmp2 = 10/(qlsp[i+1]-qlsp[i]);
-#endif
- quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
- }
+ compute_quant_weights(qlsp, quant_weight, order);
+
for (i=0;i<order;i++)
- qlsp[i]-=(.25*i+.25);
+ qlsp[i]-=LSP_SCALING*(.25*i+.25);
#ifdef FIXED_POINT
for (i=0;i<order;i++)
@@ -170,71 +179,59 @@
qlsp[i]=lsp[i]-qlsp[i];
}
-void lsp_unquant_nb(float *lsp, int order, SpeexBits *bits)
+void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits)
{
int i, id;
for (i=0;i<order;i++)
- lsp[i]=.25*i+.25;
+ lsp[i]=LSP_SCALING*(.25*i+.25);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<10;i++)
- lsp[i] += 0.0039062*cdbk_nb[id*10+i];
+ lsp[i] += LSP_SCALING*(0.0039062*cdbk_nb[id*10+i]);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
- lsp[i] += 0.0019531 * cdbk_nb_low1[id*5+i];
+ lsp[i] += LSP_SCALING*(0.0019531 * cdbk_nb_low1[id*5+i]);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
- lsp[i] += 0.00097656 * cdbk_nb_low2[id*5+i];
+ lsp[i] += LSP_SCALING*(0.00097656 * cdbk_nb_low2[id*5+i]);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
- lsp[i+5] += 0.0019531 * cdbk_nb_high1[id*5+i];
+ lsp[i+5] += LSP_SCALING*(0.0019531 * cdbk_nb_high1[id*5+i]);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
- lsp[i+5] += 0.00097656 * cdbk_nb_high2[id*5+i];
+ lsp[i+5] += LSP_SCALING*(0.00097656 * cdbk_nb_high2[id*5+i]);
}
-void lsp_quant_lbr(float *lsp, float *qlsp, int order, SpeexBits *bits)
+void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
{
int i;
- float tmp1, tmp2;
int id;
+ spx_word16_t quant_weight[10];
spx_word16_t nlsp[10];
for (i=0;i<order;i++)
qlsp[i]=lsp[i];
- quant_weight[0] = 10/(qlsp[1]-qlsp[0]);
- quant_weight[order-1] = 10/(qlsp[order-1]-qlsp[order-2]);
- for (i=1;i<order-1;i++)
- {
-#if 1
- tmp1 = 10/((.15+qlsp[i]-qlsp[i-1])*(.15+qlsp[i]-qlsp[i-1]));
- tmp2 = 10/((.15+qlsp[i+1]-qlsp[i])*(.15+qlsp[i+1]-qlsp[i]));
-#else
- tmp1 = 10/(qlsp[i]-qlsp[i-1]);
- tmp2 = 10/(qlsp[i+1]-qlsp[i]);
-#endif
- quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
- }
+ compute_quant_weights(qlsp, quant_weight, order);
for (i=0;i<order;i++)
- qlsp[i]-=(.25*i+.25);
+ qlsp[i]-=LSP_SCALING*(.25*i+.25);
#ifdef FIXED_POINT
for (i=0;i<order;i++)
nlsp[i]=floor(.5+qlsp[i]*LSP_SCALE);
#else
for (i=0;i<order;i++)
nlsp[i]=qlsp[i]*LSP_SCALE;
-#endif
+#endif
id = lsp_quant(nlsp, cdbk_nb, NB_CDBK_SIZE, order);
speex_bits_pack(bits, id, 6);
-
+
for (i=0;i<order;i++)
nlsp[i]*=2;
@@ -251,24 +248,24 @@
qlsp[i]=lsp[i]-qlsp[i];
}
-void lsp_unquant_lbr(float *lsp, int order, SpeexBits *bits)
+void lsp_unquant_lbr(spx_lsp_t *lsp, int order, SpeexBits *bits)
{
int i, id;
for (i=0;i<order;i++)
- lsp[i]=.25*i+.25;
+ lsp[i]=LSP_SCALING*(.25*i+.25);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<10;i++)
- lsp[i] += 0.0039062*cdbk_nb[id*10+i];
+ lsp[i] += LSP_SCALING*0.0039062*cdbk_nb[id*10+i];
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
- lsp[i] += 0.0019531*cdbk_nb_low1[id*5+i];
+ lsp[i] += LSP_SCALING*0.0019531*cdbk_nb_low1[id*5+i];
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
- lsp[i+5] += 0.0019531*cdbk_nb_high1[id*5+i];
+ lsp[i+5] += LSP_SCALING*0.0019531*cdbk_nb_high1[id*5+i];
}
@@ -277,27 +274,29 @@
extern signed char high_lsp_cdbk2[];
-void lsp_quant_high(float *lsp, float *qlsp, int order, SpeexBits *bits)
+void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
{
int i;
- float tmp1, tmp2;
int id;
+ spx_word16_t quant_weight[10];
spx_word16_t nlsp[10];
for (i=0;i<order;i++)
qlsp[i]=lsp[i];
- quant_weight[0] = 10/(qlsp[1]-qlsp[0]);
+ compute_quant_weights(qlsp, quant_weight, order);
+
+ /* quant_weight[0] = 10/(qlsp[1]-qlsp[0]);
quant_weight[order-1] = 10/(qlsp[order-1]-qlsp[order-2]);
for (i=1;i<order-1;i++)
{
tmp1 = 10/(qlsp[i]-qlsp[i-1]);
tmp2 = 10/(qlsp[i+1]-qlsp[i]);
quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
- }
+ }*/
for (i=0;i<order;i++)
- qlsp[i]-=(.3125*i+.75);
+ qlsp[i]-=LSP_SCALING*(.3125*i+.75);
#ifdef FIXED_POINT
for (i=0;i<order;i++)
nlsp[i] = floor(.5+qlsp[i]*LSP_SCALE);
@@ -321,22 +320,22 @@
qlsp[i]=lsp[i]-qlsp[i];
}
-void lsp_unquant_high(float *lsp, int order, SpeexBits *bits)
+void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits)
{
int i, id;
for (i=0;i<order;i++)
- lsp[i]=.3125*i+.75;
+ lsp[i]=LSP_SCALING*(.3125*i+.75);
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<order;i++)
- lsp[i] += 0.0039062*high_lsp_cdbk[id*order+i];
+ lsp[i] += LSP_SCALING*0.0039062*high_lsp_cdbk[id*order+i];
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<order;i++)
- lsp[i] += 0.0019531*high_lsp_cdbk2[id*order+i];
+ lsp[i] += LSP_SCALING*0.0019531*high_lsp_cdbk2[id*order+i];
}
@@ -345,32 +344,20 @@
extern signed char cdbk_lsp_vlbr[5120];
extern signed char cdbk_lsp2_vlbr[160];
-void lsp_quant_48k(float *lsp, float *qlsp, int order, SpeexBits *bits)
+void lsp_quant_48k(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
{
int i;
- float tmp1, tmp2;
int id;
+ spx_word16_t quant_weight[10];
spx_word16_t nlsp[10];
for (i=0;i<order;i++)
qlsp[i]=lsp[i];
- quant_weight[0] = 10/(qlsp[1]-qlsp[0]);
- quant_weight[order-1] = 10/(qlsp[order-1]-qlsp[order-2]);
- for (i=1;i<order-1;i++)
- {
-#if 1
- tmp1 = 10/((.15+qlsp[i]-qlsp[i-1])*(.15+qlsp[i]-qlsp[i-1]));
- tmp2 = 10/((.15+qlsp[i+1]-qlsp[i])*(.15+qlsp[i+1]-qlsp[i]));
-#else
- tmp1 = 10/(qlsp[i]-qlsp[i-1]);
- tmp2 = 10/(qlsp[i+1]-qlsp[i]);
-#endif
- quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
- }
+ compute_quant_weights(qlsp, quant_weight, order);
for (i=0;i<order;i++)
- qlsp[i]-=(.25*i+.3125);
+ qlsp[i]-=LSP_SCALING*(.25*i+.3125);
for (i=0;i<order;i++)
nlsp[i]=qlsp[i]*LSP_SCALE;
@@ -390,20 +377,20 @@
qlsp[i]=lsp[i]-qlsp[i];
}
-void lsp_unquant_48k(float *lsp, int order, SpeexBits *bits)
+void lsp_unquant_48k(spx_lsp_t *lsp, int order, SpeexBits *bits)
{
int i, id;
for (i=0;i<order;i++)
- lsp[i]=.25*i+.3125;
+ lsp[i]=LSP_SCALING*(.25*i+.3125);
id=speex_bits_unpack_unsigned(bits, 9);
for (i=0;i<10;i++)
- lsp[i] += 0.0039062*cdbk_lsp_vlbr[id*10+i];
+ lsp[i] += LSP_SCALING*0.0039062*cdbk_lsp_vlbr[id*10+i];
id=speex_bits_unpack_unsigned(bits, 4);
for (i=0;i<10;i++)
- lsp[i] += 0.00097655*cdbk_lsp2_vlbr[id*10+i];
+ lsp[i] += LSP_SCALING*0.00097655*cdbk_lsp2_vlbr[id*10+i];
}
<p><p>1.17 +9 -8 speex/libspeex/quant_lsp.h
Index: quant_lsp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/quant_lsp.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- quant_lsp.h 13 May 2003 20:57:31 -0000 1.16
+++ quant_lsp.h 9 Oct 2003 03:54:37 -0000 1.17
@@ -34,6 +34,7 @@
#define QUANT_LSP_H
#include "speex_bits.h"
+#include "misc.h"
#define MAX_LSP_SIZE 20
@@ -51,29 +52,29 @@
extern signed char cdbk_nb_high2[];
/* Quantizes narrowband LSPs with 30 bits */
-void lsp_quant_nb(float *lsp, float *qlsp, int order, SpeexBits *bits);
+void lsp_quant_nb(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
/* Decodes quantized narrowband LSPs */
-void lsp_unquant_nb(float *lsp, int order, SpeexBits *bits);
+void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits);
/* Quantizes low bit-rate narrowband LSPs with 18 bits */
-void lsp_quant_lbr(float *lsp, float *qlsp, int order, SpeexBits *bits);
+void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
/* Decodes quantized low bit-rate narrowband LSPs */
-void lsp_unquant_lbr(float *lsp, int order, SpeexBits *bits);
+void lsp_unquant_lbr(spx_lsp_t *lsp, int order, SpeexBits *bits);
/* Quantizes high-band LSPs with 12 bits */
-void lsp_quant_high(float *lsp, float *qlsp, int order, SpeexBits *bits);
+void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
/* Decodes high-band LSPs */
-void lsp_unquant_high(float *lsp, int order, SpeexBits *bits);
+void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits);
#ifdef EPIC_48K
/* Quantizes narrowband LSPs with 14 bits */
-void lsp_quant_48k(float *lsp, float *qlsp, int order, SpeexBits *bits);
+void lsp_quant_48k(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
/* Decodes quantized narrowband LSPs (14 bits) */
-void lsp_unquant_48k(float *lsp, int order, SpeexBits *bits);
+void lsp_unquant_48k(spx_lsp_t *lsp, int order, SpeexBits *bits);
#endif
<p><p>1.142 +9 -9 speex/libspeex/sb_celp.c
Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -r1.141 -r1.142
--- sb_celp.c 8 Oct 2003 22:31:42 -0000 1.141
+++ sb_celp.c 9 Oct 2003 03:54:37 -0000 1.142
@@ -205,12 +205,12 @@
st->lpc = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
st->bw_lpc1 = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
st->bw_lpc2 = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
- st->lsp = PUSH(st->stack, st->lpcSize, float);
- st->qlsp = PUSH(st->stack, st->lpcSize, float);
- st->old_lsp = PUSH(st->stack, st->lpcSize, float);
- st->old_qlsp = PUSH(st->stack, st->lpcSize, float);
- st->interp_lsp = PUSH(st->stack, st->lpcSize, float);
- st->interp_qlsp = PUSH(st->stack, st->lpcSize, float);
+ st->lsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->old_lsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->old_qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->interp_lsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->interp_qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
st->interp_lpc = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
st->pi_gain = PUSH(st->stack, st->nbSubframes, float);
@@ -710,9 +710,9 @@
st->exc=PUSH(st->stack, st->frame_size, spx_sig_t);
- st->qlsp = PUSH(st->stack, st->lpcSize, float);
- st->old_qlsp = PUSH(st->stack, st->lpcSize, float);
- st->interp_qlsp = PUSH(st->stack, st->lpcSize, float);
+ st->qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->old_qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
+ st->interp_qlsp = PUSH(st->stack, st->lpcSize, spx_lsp_t);
st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
st->pi_gain = PUSH(st->stack, st->nbSubframes, float);
<p><p>1.47 +9 -9 speex/libspeex/sb_celp.h
Index: sb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- sb_celp.h 8 Oct 2003 22:31:42 -0000 1.46
+++ sb_celp.h 9 Oct 2003 03:54:37 -0000 1.47
@@ -74,12 +74,12 @@
float *lagWindow; /**< Auto-correlation window */
spx_word16_t *autocorr; /**< Auto-correlation (for LPC analysis) */
spx_coef_t *lpc; /**< LPC coefficients */
- float *lsp; /**< LSP coefficients */
- float *qlsp; /**< Quantized LSPs */
- float *old_lsp; /**< LSPs of previous frame */
- float *old_qlsp; /**< Quantized LSPs of previous frame */
- float *interp_lsp; /**< Interpolated LSPs for current sub-frame */
- float *interp_qlsp; /**< Interpolated quantized LSPs for current sub-frame */
+ spx_lsp_t *lsp; /**< LSP coefficients */
+ spx_lsp_t *qlsp; /**< Quantized LSPs */
+ spx_lsp_t *old_lsp; /**< LSPs of previous frame */
+ spx_lsp_t *old_qlsp; /**< Quantized LSPs of previous frame */
+ spx_lsp_t *interp_lsp; /**< Interpolated LSPs for current sub-frame */
+ spx_lsp_t *interp_qlsp; /**< Interpolated quantized LSPs for current sub-frame */
spx_coef_t *interp_lpc; /**< Interpolated LPCs for current sub-frame */
spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs for current sub-frame */
spx_coef_t *bw_lpc1; /**< Bandwidth-expanded version of LPCs (#1) */
@@ -129,9 +129,9 @@
spx_word32_t *g0_mem, *g1_mem;
spx_sig_t *exc;
- float *qlsp;
- float *old_qlsp;
- float *interp_qlsp;
+ spx_lsp_t *qlsp;
+ spx_lsp_t *old_qlsp;
+ spx_lsp_t *interp_qlsp;
spx_coef_t *interp_qlpc;
spx_mem_t *mem_sp;
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list