[xiph-cvs] cvs commit: speex/libspeex arch.h filters.c filters.h lsp.c lsp.h nb_celp.c nb_celp.h sb_celp.c sb_celp.h
Jean-Marc Valin
jm at xiph.org
Thu Nov 27 00:42:11 PST 2003
jm 03/11/27 03:42:10
Modified: libspeex arch.h filters.c filters.h lsp.c lsp.h nb_celp.c
nb_celp.h sb_celp.c sb_celp.h
Log:
fixed-point: bw_lpc and lpc_to_lsp are now done.
Revision Changes Path
1.4 +2 -0 speex/libspeex/arch.h
Index: arch.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/arch.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- arch.h 25 Nov 2003 06:58:10 -0000 1.3
+++ arch.h 27 Nov 2003 08:42:06 -0000 1.4
@@ -50,6 +50,7 @@
#define LPC_SCALING 8192
#define SIG_SCALING 16384
#define LSP_SCALING 8192.
+#define GAMMA_SCALING 32768.
#define LPC_SHIFT 13
#define SIG_SHIFT 14
@@ -179,6 +180,7 @@
#define LPC_SCALING 1.
#define SIG_SCALING 1.
#define LSP_SCALING 1.
+#define GAMMA_SCALING 1.
#define LPC_SHIFT 0
#define SIG_SHIFT 0
<p><p>1.64 +3 -4 speex/libspeex/filters.c
Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- filters.c 13 Nov 2003 20:39:06 -0000 1.63
+++ filters.c 27 Nov 2003 08:42:06 -0000 1.64
@@ -38,16 +38,15 @@
#ifdef FIXED_POINT
-void bw_lpc(float gamma, spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order)
+void bw_lpc(spx_word16_t gamma, spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order)
{
int i;
- spx_word16_t g=gamma*32768;
- spx_word16_t tmp=g;
+ spx_word16_t tmp=gamma;
lpc_out[0] = lpc_in[0];
for (i=1;i<order+1;i++)
{
lpc_out[i] = MULT16_16_P15(tmp,lpc_in[i]);
- tmp = MULT16_16_P15(tmp, g);
+ tmp = MULT16_16_P15(tmp, gamma);
}
}
#else
<p><p>1.33 +1 -1 speex/libspeex/filters.h
Index: filters.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- filters.h 13 Nov 2003 20:39:06 -0000 1.32
+++ filters.h 27 Nov 2003 08:42:06 -0000 1.33
@@ -61,7 +61,7 @@
void iir_mem2(spx_sig_t *x, spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem);
/* Apply bandwidth expansion on LPC coef */
-void bw_lpc(float gamma, spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order);
+void bw_lpc(spx_word16_t gamma, spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order);
<p><p>1.47 +2 -4 speex/libspeex/lsp.c
Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- lsp.c 27 Nov 2003 05:00:05 -0000 1.46
+++ lsp.c 27 Nov 2003 08:42:06 -0000 1.47
@@ -204,7 +204,7 @@
#endif
-int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,float delta, char *stack)
+int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t delta, char *stack)
/* float *a lpc coefficients */
/* int lpcrdr order of LPC coefficients (10) */
/* float *freq LSP frequencies in the x domain */
@@ -213,7 +213,6 @@
{
- spx_word16_t ndelta;
spx_word16_t temp_xr,xl,xr,xm=0;
spx_word32_t psuml,psumr,psumm,temp_psumr/*,temp_qsumr*/;
int i,j,m,flag,k;
@@ -229,7 +228,6 @@
flag = 1; /* program is searching for a root when,
1 else has found one */
m = lpcrdr/2; /* order of P'(z) & Q'(z) polynomials */
- ndelta = delta*32768;
/* Allocate memory space for polynomials */
Q = PUSH(stack, (m+1), spx_word32_t);
@@ -304,7 +302,7 @@
spx_word16_t dd;
/* Modified by JMV to provide smaller steps around x=+-1 */
#ifdef FIXED_POINT
- dd = MULT16_16_Q15(ndelta,(FREQ_SCALE - MULT16_16_Q14(MULT16_16_Q14(xl,xl),14000)));
+ dd = MULT16_16_Q15(delta,(FREQ_SCALE - MULT16_16_Q14(MULT16_16_Q14(xl,xl),14000)));
if (psuml<512 && psuml>-512)
dd = PSHR(dd,1);
#else
<p><p>1.14 +1 -1 speex/libspeex/lsp.h
Index: lsp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- lsp.h 27 Nov 2003 05:00:05 -0000 1.13
+++ lsp.h 27 Nov 2003 08:42:06 -0000 1.14
@@ -49,7 +49,7 @@
#include "misc.h"
-int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, float delta, char *stack);
+int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, spx_word16_t delta, char *stack);
void lsp_to_lpc(spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack);
/*Added by JMV*/
<p><p>1.156 +17 -16 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -r1.155 -r1.156
--- nb_celp.c 27 Nov 2003 05:00:05 -0000 1.155
+++ nb_celp.c 27 Nov 2003 08:42:06 -0000 1.156
@@ -65,7 +65,8 @@
spx_word16_t exc_gain_quant_scal1[2]={11546, 17224};
#define LSP_MARGIN 16
-#define LSP_DELTA
+#define LSP_DELTA1 6553
+#define LSP_DELTA2 1638
#else
@@ -75,7 +76,8 @@
float exc_gain_quant_scal1[2]={0.70469, 1.05127};
#define LSP_MARGIN .002
-#define LSP_DELTA
+#define LSP_DELTA1 .2
+#define LSP_DELTA2 .05
#endif
@@ -105,8 +107,8 @@
st->subframeSize=mode->subframeSize;
st->lpcSize = mode->lpcSize;
st->bufSize = mode->bufSize;
- st->gamma1=mode->gamma1;
- st->gamma2=mode->gamma2;
+ st->gamma1=GAMMA_SCALING*mode->gamma1;
+ st->gamma2=GAMMA_SCALING*mode->gamma2;
st->min_pitch=mode->pitchStart;
st->max_pitch=mode->pitchEnd;
st->lag_factor=mode->lag_factor;
@@ -262,13 +264,13 @@
st->lpc[0]=(spx_coef_t)LPC_SCALING;
/* LPC to LSPs (x-domain) transform */
- roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, 0.2, stack);
+ roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, LSP_DELTA1, stack);
/* Check if we found all the roots */
if (roots!=st->lpcSize)
{
/* Search again if we can afford it */
if (st->complexity>1)
- roots = lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 11, 0.05, stack);
+ roots = lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 11, LSP_DELTA2, stack);
if (roots!=st->lpcSize)
{
/*If we can't find all LSP's, do some damage control and use previous filter*/
@@ -1068,9 +1070,9 @@
k1=k2;
k3=0;
}
- bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
- bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
- bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k1, st->interp_qlpc, awk1, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k2, st->interp_qlpc, awk2, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k3, st->interp_qlpc, awk3, st->lpcSize);
}
/* Make up a plausible excitation */
@@ -1258,7 +1260,7 @@
{
spx_coef_t *lpc;
lpc = PUSH(stack,11, spx_coef_t);
- bw_lpc(.93, st->interp_qlpc, lpc, 10);
+ bw_lpc(GAMMA_SCALING*.93, st->interp_qlpc, lpc, 10);
/*for (i=0;i<st->frameSize;i++)
st->exc[i]=0;*/
{
@@ -1427,9 +1429,9 @@
k1=k2;
k3=0;
}
- bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
- bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
- bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k1, st->interp_qlpc, awk1, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k2, st->interp_qlpc, awk2, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k3, st->interp_qlpc, awk3, st->lpcSize);
}
@@ -1507,8 +1509,7 @@
exc[i]*=fact;
}
- tmp = fabs(pitch_gain[0]+pitch_gain[1]+pitch_gain[2]);
- tmp = fabs(pitch_gain[1]);
+ tmp = ABS(pitch_gain[1]);
if (pitch_gain[0]>0)
tmp += pitch_gain[0];
else
@@ -1516,7 +1517,7 @@
if (pitch_gain[2]>0)
tmp += pitch_gain[2];
else
- tmp -= .5*pitch_gain[0];
+ tmp -= .5*pitch_gain[2];
pitch_average += tmp;
<p><p>1.61 +2 -2 speex/libspeex/nb_celp.h
Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- nb_celp.h 14 Nov 2003 19:16:22 -0000 1.60
+++ nb_celp.h 27 Nov 2003 08:42:07 -0000 1.61
@@ -65,8 +65,8 @@
int lbr_48k;
#endif
- float gamma1; /**< Perceptual filter: A(z/gamma1) */
- float gamma2; /**< Perceptual filter: A(z/gamma2) */
+ spx_word16_t gamma1; /**< Perceptual filter: A(z/gamma1) */
+ spx_word16_t gamma2; /**< Perceptual filter: A(z/gamma2) */
float lag_factor; /**< Lag windowing Gaussian width */
float lpc_floor; /**< Noise floor multiplier for A[0] in LPC analysis*/
char *stack; /**< Pseudo-stack allocation for temporary memory */
<p><p>1.159 +15 -11 speex/libspeex/sb_celp.c
Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -r1.158 -r1.159
--- sb_celp.c 27 Nov 2003 05:00:05 -0000 1.158
+++ sb_celp.c 27 Nov 2003 08:42:07 -0000 1.159
@@ -56,10 +56,14 @@
#ifdef FIXED_POINT
spx_word16_t gc_quant_bound[16] = {125, 164, 215, 282, 370, 484, 635, 832, 1090, 1428, 1871, 2452, 3213, 4210, 5516, 7228};
#define LSP_MARGIN 410
+#define LSP_DELTA1 6553
+#define LSP_DELTA2 1638
#else
#define LSP_MARGIN .05
+#define LSP_DELTA1 .2
+#define LSP_DELTA2 .05
#endif
@@ -193,8 +197,8 @@
st->lag_factor = mode->lag_factor;
st->lpc_floor = mode->lpc_floor;
- st->gamma1=mode->gamma1;
- st->gamma2=mode->gamma2;
+ st->gamma1=GAMMA_SCALING*mode->gamma1;
+ st->gamma2=GAMMA_SCALING*mode->gamma2;
st->first=1;
st->x0d=PUSH(st->stack, st->frame_size, spx_sig_t);
@@ -348,10 +352,10 @@
st->lpc[0] = (spx_coef_t)LPC_SCALING;
/* LPC to LSPs (x-domain) transform */
- roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, 0.2, stack);
+ roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, LSP_DELTA1, stack);
if (roots!=st->lpcSize)
{
- roots = lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 11, 0.02, stack);
+ roots = lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 11, LSP_DELTA2, stack);
if (roots!=st->lpcSize) {
/*If we can't find all LSP's, do some damage control and use a flat filter*/
for (i=0;i<st->lpcSize;i++)
@@ -778,7 +782,7 @@
saved_modeid=st->submodeID;
st->submodeID=1;
} else {
- bw_lpc(0.99, st->interp_qlpc, st->interp_qlpc, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*0.99, st->interp_qlpc, st->interp_qlpc, st->lpcSize);
}
st->first=1;
@@ -806,9 +810,9 @@
k1=k2;
k3=0;
}
- bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
- bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
- bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k1, st->interp_qlpc, awk1, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k2, st->interp_qlpc, awk2, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k3, st->interp_qlpc, awk3, st->lpcSize);
/*fprintf (stderr, "%f %f %f\n", k1, k2, k3);*/
}
@@ -1004,9 +1008,9 @@
k1=k2;
k3=0;
}
- bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
- bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
- bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k1, st->interp_qlpc, awk1, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k2, st->interp_qlpc, awk2, st->lpcSize);
+ bw_lpc(GAMMA_SCALING*k3, st->interp_qlpc, awk3, st->lpcSize);
/*fprintf (stderr, "%f %f %f\n", k1, k2, k3);*/
}
<p><p>1.50 +2 -2 speex/libspeex/sb_celp.h
Index: sb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- sb_celp.h 14 Nov 2003 19:16:22 -0000 1.49
+++ sb_celp.h 27 Nov 2003 08:42:07 -0000 1.50
@@ -54,8 +54,8 @@
int first; /**< First frame? */
float lag_factor; /**< Lag-windowing control parameter */
float lpc_floor; /**< Controls LPC analysis noise floor */
- float gamma1; /**< Perceptual weighting coef 1 */
- float gamma2; /**< Perceptual weighting coef 2 */
+ spx_word16_t gamma1; /**< Perceptual weighting coef 1 */
+ spx_word16_t gamma2; /**< Perceptual weighting coef 2 */
char *stack; /**< Temporary allocation stack */
spx_sig_t *x0d, *x1d; /**< QMF filter signals*/
<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