[xiph-cvs] cvs commit: speex/src speexdec.c
Jean-Marc Valin
jm at xiph.org
Tue Oct 7 21:27:52 PDT 2003
jm 03/10/08 00:27:52
Modified: libspeex cb_search.c cb_search.h filters.c filters.h lpc.c
lpc.h lsp.c lsp.h ltp.c ltp.h misc.h modes.h
nb_celp.c nb_celp.h preprocess.c sb_celp.c
sb_celp.h testenc.c
src speexdec.c
Log:
first step in fixed-point port, converted the LPC filters
Revision Changes Path
1.87 +7 -8 speex/libspeex/cb_search.c
Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- cb_search.c 30 Sep 2003 00:44:08 -0000 1.86
+++ cb_search.c 8 Oct 2003 04:27:51 -0000 1.87
@@ -38,9 +38,9 @@
void split_cb_search_shape_sign(
float target[], /* target vector */
-float ak[], /* LPCs for this subframe */
-float awk1[], /* Weighted LPCs for this subframe */
-float awk2[], /* Weighted LPCs for this subframe */
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs for this subframe */
void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */
@@ -136,8 +136,7 @@
{
res[j]=0;
for (k=0;k<=j;k++)
- res[j] += shape[k]*r[j-k];
- res[j] *= 0.03125;
+ res[j] += 0.03125*shape[k]*r[j-k];
}
/* Compute codeword energy */
@@ -351,9 +350,9 @@
void noise_codebook_quant(
float target[], /* target vector */
-float ak[], /* LPCs for this subframe */
-float awk1[], /* Weighted LPCs for this subframe */
-float awk2[], /* Weighted LPCs for this subframe */
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs for this subframe */
void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */
<p><p>1.29 +7 -6 speex/libspeex/cb_search.h
Index: cb_search.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- cb_search.h 27 Jan 2003 08:31:45 -0000 1.28
+++ cb_search.h 8 Oct 2003 04:27:51 -0000 1.29
@@ -34,6 +34,7 @@
#define CB_SEARCH_H
#include "speex_bits.h"
+#include "misc.h"
typedef struct split_cb_params {
int subvect_size;
@@ -46,9 +47,9 @@
void split_cb_search_shape_sign(
float target[], /* target vector */
-float ak[], /* LPCs for this subframe */
-float awk1[], /* Weighted LPCs for this subframe */
-float awk2[], /* Weighted LPCs for this subframe */
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs for this subframe */
void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */
@@ -70,9 +71,9 @@
void noise_codebook_quant(
float target[], /* target vector */
-float ak[], /* LPCs for this subframe */
-float awk1[], /* Weighted LPCs for this subframe */
-float awk2[], /* Weighted LPCs for this subframe */
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs for this subframe */
void *par, /* Codebook/search parameters*/
int p, /* number of LPC coeffs */
int nsf, /* number of samples in subframe */
<p><p>1.33 +114 -14 speex/libspeex/filters.c
Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- filters.c 6 Jan 2003 05:56:56 -0000 1.32
+++ filters.c 8 Oct 2003 04:27:51 -0000 1.33
@@ -33,9 +33,9 @@
#include "filters.h"
#include "stack_alloc.h"
#include <math.h>
+#include "misc.h"
-
-void bw_lpc(float gamma, float *lpc_in, float *lpc_out, int order)
+void bw_lpc(float gamma, spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order)
{
int i;
float tmp=1;
@@ -46,10 +46,104 @@
}
}
+
+#ifdef FIXED_POINT
+
+
+#define MUL_16_32_R15(a,bh,bl) ((a)*(bh) + ((a)*(bl)>>15))
+
+
+void filter_mem2(float *x, spx_coef_t *num, spx_coef_t *den, float *y, int N, int ord, spx_mem_t *mem)
+{
+ int i,j;
+ int xi,yi;
+ short nums[11], dens[11];
+
+ for (i=0;i<ord+1;i++)
+ {
+ nums[i] = (int)floor(.5+8192*num[i]);
+ dens[i] = (int)floor(.5+8192*den[i]);
+ }
+
+ for (i=0;i<N;i++)
+ {
+ int xh,xl,yh,yl;
+ xi=floor(.5+16384*x[i]);
+ yi = xi + (mem[0]<<2);
+ xh = xi>>15; xl=xi&0x00007fff; yh = yi>>15; yl=yi&0x00007fff;
+ for (j=0;j<ord-1;j++)
+ {
+ mem[j] = mem[j+1] + MUL_16_32_R15(nums[j+1],xh,xl) - MUL_16_32_R15(dens[j+1],yh,yl);
+ }
+ mem[ord-1] = MUL_16_32_R15(nums[ord],xh,xl) - MUL_16_32_R15(dens[ord],yh,yl);
+ y[i] = yi*(1.f/16384.f);
+ }
+}
+
+void iir_mem2(float *x, spx_coef_t *den, float *y, int N, int ord, spx_mem_t *mem)
+{
+ int i,j;
+ int xi,yi;
+ short dens[11];
+
+ for (i=0;i<11;i++)
+ {
+ dens[i] = (int)floor(.5+8192*den[i]);
+ }
+
+ for (i=0;i<N;i++)
+ {
+ int yh,yl;
+ xi=floor(.5+16384*x[i]);
+ yi = xi + (mem[0]<<2);
+ yh = yi>>15; yl=yi&0x00007fff;
+ for (j=0;j<ord-1;j++)
+ {
+ mem[j] = mem[j+1] - MUL_16_32_R15(dens[j+1],yh,yl);
+ }
+ mem[ord-1] = - MUL_16_32_R15(dens[ord],yh,yl);
+ y[i] = yi*(1.f/16384.f);
+ }
+}
+
+
+void fir_mem2(float *x, spx_coef_t *num, float *y, int N, int ord, spx_mem_t *mem)
+{
+ int i,j;
+ int xi,yi;
+ short nums[11];
+
+ for (i=0;i<11;i++)
+ {
+ nums[i] = (int)floor(.5+8192*num[i]);
+ }
+
+ for (i=0;i<N;i++)
+ {
+ int xh,xl;
+ xi=floor(.5+16384*x[i]);
+ yi = xi + (mem[0]<<2);
+ xh = xi>>15; xl=xi&0x00007fff;
+ for (j=0;j<ord-1;j++)
+ {
+ mem[j] = mem[j+1] + MUL_16_32_R15(nums[j+1],xh,xl);
+ }
+ mem[ord-1] = MUL_16_32_R15(nums[ord],xh,xl);
+ y[i] = yi*(1.f/16384.f);
+ }
+
+}
+
+#else
+
+
+
#ifdef _USE_SSE
#include "filters_sse.h"
#else
-void filter_mem2(float *x, float *num, float *den, float *y, int N, int ord, float *mem)
+
+
+void filter_mem2(float *x, spx_coef_t *num, spx_coef_t *den, float *y, int N, int ord, spx_mem_t *mem)
{
int i,j;
float xi,yi;
@@ -67,7 +161,7 @@
}
-void iir_mem2(float *x, float *den, float *y, int N, int ord, float *mem)
+void iir_mem2(float *x, spx_coef_t *den, float *y, int N, int ord, spx_mem_t *mem)
{
int i,j;
for (i=0;i<N;i++)
@@ -80,9 +174,11 @@
mem[ord-1] = - den[ord]*y[i];
}
}
+
+
#endif
-void fir_mem2(float *x, float *num, float *y, int N, int ord, float *mem)
+void fir_mem2(float *x, spx_coef_t *num, float *y, int N, int ord, spx_mem_t *mem)
{
int i,j;
float xi;
@@ -98,22 +194,26 @@
}
}
-void syn_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack)
+
+#endif
+
+
+void syn_percep_zero(float *xx, spx_coef_t *ak, spx_coef_t *awk1, spx_coef_t *awk2, float *y, int N, int ord, char *stack)
{
int i;
- float *mem = PUSH(stack,ord, float);
- for (i=0;i<ord;i++)
- mem[i]=0;
- filter_mem2(xx, awk1, ak, y, N, ord, mem);
+ spx_mem_t *mem = PUSH(stack,ord, spx_mem_t);
for (i=0;i<ord;i++)
mem[i]=0;
- iir_mem2(y, awk2, y, N, ord, mem);
+ iir_mem2(xx, ak, y, N, ord, mem);
+ for (i=0;i<ord;i++)
+ mem[i]=0;
+ filter_mem2(y, awk1, awk2, y, N, ord, mem);
}
-void residue_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack)
+void residue_percep_zero(float *xx, spx_coef_t *ak, spx_coef_t *awk1, spx_coef_t *awk2, float *y, int N, int ord, char *stack)
{
int i;
- float *mem = PUSH(stack,ord, float);
+ spx_mem_t *mem = PUSH(stack,ord, spx_mem_t);
for (i=0;i<ord;i++)
mem[i]=0;
filter_mem2(xx, ak, awk1, y, N, ord, mem);
@@ -221,7 +321,7 @@
void comb_filter(
float *exc, /*decoded excitation*/
float *new_exc, /*enhanced excitation*/
-float *ak, /*LPC filter coefs*/
+spx_coef_t *ak, /*LPC filter coefs*/
int p, /*LPC order*/
int nsf, /*sub-frame size*/
int pitch, /*pitch period*/
<p><p>1.24 +8 -7 speex/libspeex/filters.h
Index: filters.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- filters.h 6 Jan 2003 05:56:56 -0000 1.23
+++ filters.h 8 Oct 2003 04:27:51 -0000 1.24
@@ -33,6 +33,7 @@
#ifndef FILTERS_H
#define FILTERS_H
+#include "misc.h"
typedef struct CombFilterMem {
int last_pitch;
@@ -45,28 +46,28 @@
void fir_mem_up(float *x, float *a, float *y, int N, int M, float *mem, char *stack);
-void filter_mem2(float *x, float *num, float *den, float *y, int N, int ord, float *mem);
-void fir_mem2(float *x, float *num, float *y, int N, int ord, float *mem);
-void iir_mem2(float *x, float *den, float *y, int N, int ord, float *mem);
+void filter_mem2(float *x, spx_coef_t *num, spx_coef_t *den, float *y, int N, int ord, spx_mem_t *mem);
+void fir_mem2(float *x, spx_coef_t *num, float *y, int N, int ord, spx_mem_t *mem);
+void iir_mem2(float *x, spx_coef_t *den, float *y, int N, int ord, spx_mem_t *mem);
/* Apply bandwidth expansion on LPC coef */
-void bw_lpc(float gamma, float *lpc_in, float *lpc_out, int order);
+void bw_lpc(float gamma, spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order);
/* FIR filter */
void fir_decim_mem(float *x, float *a, float *y, int N, int M, float *mem);
-void syn_percep_zero(float *x, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack);
+void syn_percep_zero(float *x, spx_coef_t *ak, spx_coef_t *awk1, spx_coef_t *awk2, float *y, int N, int ord, char *stack);
-void residue_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack);
+void residue_percep_zero(float *xx, spx_coef_t *ak, spx_coef_t *awk1, spx_coef_t *awk2, float *y, int N, int ord, char *stack);
void comp_filter_mem_init (CombFilterMem *mem);
void comb_filter(
float *exc, /*decoded excitation*/
float *new_exc, /*enhanced excitation*/
-float *ak, /*LPC filter coefs*/
+spx_coef_t *ak, /*LPC filter coefs*/
int p, /*LPC order*/
int nsf, /*sub-frame size*/
int pitch, /*pitch period*/
<p><p>1.11 +2 -2 speex/libspeex/lpc.c
Index: lpc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lpc.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- lpc.c 1 Oct 2003 22:17:25 -0000 1.10
+++ lpc.c 8 Oct 2003 04:27:51 -0000 1.11
@@ -65,7 +65,7 @@
/* returns minimum mean square error */
float _spx_lpc(
-float *lpc, /* out: [0...p-1] LPC coefficients */
+spx_coef_t *lpc, /* out: [0...p-1] LPC coefficients */
const float *ac, /* in: [0...p] autocorrelation values */
int p
)
@@ -85,7 +85,7 @@
r = -ac[i + 1];
for (j = 0; j < i; j++)
r -= lpc[j] * ac[i - j];
- r /= error+.004*ac[0];
+ r /= error;
/* Update LPC coefficients and total error */
lpc[i] = r;
<p><p>1.6 +3 -1 speex/libspeex/lpc.h
Index: lpc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lpc.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- lpc.h 16 May 2003 20:41:49 -0000 1.5
+++ lpc.h 8 Oct 2003 04:27:51 -0000 1.6
@@ -33,6 +33,8 @@
#ifndef LPC_H
#define LPC_H
+#include "misc.h"
+
void _spx_autocorr(
const float * x, /* in: [0...n-1] samples x */
float *ac, /* out: [0...lag-1] ac values */
@@ -40,7 +42,7 @@
float /* returns minimum mean square error */
_spx_lpc(
- float * lpc, /* [0...p-1] LPC coefficients */
+ spx_coef_t * lpc, /* [0...p-1] LPC coefficients */
const float * ac, /* in: [0...p] autocorrelation values */
int p
);
<p><p>1.24 +74 -3 speex/libspeex/lsp.c
Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- lsp.c 23 Jan 2003 07:29:39 -0000 1.23
+++ lsp.c 8 Oct 2003 04:27:51 -0000 1.24
@@ -112,7 +112,7 @@
\*---------------------------------------------------------------------------*/
-int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta, char *stack)
+int lpc_to_lsp (spx_coef_t *a,int lpcrdr,float *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 */
@@ -247,8 +247,8 @@
\*---------------------------------------------------------------------------*/
-
-void lsp_to_lpc(float *freq,float *ak,int lpcrdr, char *stack)
+#if 0
+void lsp_to_lpc(float *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 */
@@ -307,6 +307,77 @@
}
}
+#else
+
+#define MULT16_32_Q14(a,b) (((a)*((b)>>14)) + ((a)*((signed int)((b)&0x00003fff))>>14))
+#define MULT16_32_Q15(a,b) (((a)*((b)>>15)) + ((a)*((signed int)((b)&0x00007fff))>>15))
+
+void lsp_to_lpc(float *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 */
+
+
+{
+ int i,j;
+ spx_word32_t xout1,xout2,xin1,xin2;
+ spx_word32_t *Wp;
+ spx_word32_t *pw,*n1,*n2,*n3,*n4=NULL;
+ spx_word16_t *freqn;
+ int m = lpcrdr/2;
+
+ freqn = PUSH(stack, lpcrdr, spx_word16_t);
+ for (i=0;i<lpcrdr;i++)
+ freqn[i] = freq[i]*32768.;
+
+ Wp = PUSH(stack, 4*m+2, spx_word32_t);
+ pw = Wp;
+
+
+ /* initialise contents of array */
+
+ for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */
+ *pw++ = 0.0;
+ }
+
+ /* Set pointers up */
+
+ pw = Wp;
+ xin1 = 1048576;
+ xin2 = 1048576;
+
+ /* reconstruct P(z) and Q(z) by cascading second order
+ polynomials in form 1 - 2xz(-1) +z(-2), where x is the
+ LSP coefficient */
+
+ for(j=0;j<=lpcrdr;j++){
+ int i2=0;
+ for(i=0;i<m;i++,i2+=2){
+ n1 = pw+(i*4);
+ n2 = n1 + 1;
+ n3 = n2 + 1;
+ n4 = n3 + 1;
+ xout1 = xin1 - MULT16_32_Q14(freqn[i2],*n1) + *n2;
+ xout2 = xin2 - MULT16_32_Q14(freqn[i2+1],*n3) + *n4;
+ *n2 = floor(.5+*n1);
+ *n4 = floor(.5+*n3);
+ *n1 = floor(.5+xin1);
+ *n3 = floor(.5+xin2);
+ xin1 = xout1;
+ xin2 = xout2;
+ }
+ xout1 = xin1 + *(n4+1);
+ xout2 = xin2 - *(n4+2);
+ ak[j] = ((128+xout1 + xout2)>>8)/8192.;
+ *(n4+1) = xin1;
+ *(n4+2) = xin2;
+
+ xin1 = 0.0;
+ xin2 = 0.0;
+ }
+
+}
+#endif
/*Added by JMV
Makes sure the LSPs are stable*/
<p><p>1.9 +4 -2 speex/libspeex/lsp.h
Index: lsp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- lsp.h 6 Jan 2003 05:56:56 -0000 1.8
+++ lsp.h 8 Oct 2003 04:27:51 -0000 1.9
@@ -47,8 +47,10 @@
#ifndef __AK2LSPD__
#define __AK2LSPD__
-int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta, char *stack);
-void lsp_to_lpc(float *freq, float *ak, int lpcrdr, char *stack);
+#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);
/*Added by JMV*/
void lsp_enforce_margin(float *lsp, int len, float margin);
<p><p>1.77 +9 -9 speex/libspeex/ltp.c
Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- ltp.c 13 May 2003 20:57:31 -0000 1.76
+++ ltp.c 8 Oct 2003 04:27:51 -0000 1.77
@@ -142,9 +142,9 @@
/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
static float pitch_gain_search_3tap(
float target[], /* Target vector */
-float ak[], /* LPCs for this subframe */
-float awk1[], /* Weighted LPCs #1 for this subframe */
-float awk2[], /* Weighted LPCs #2 for this subframe */
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Excitation */
void *par,
int pitch, /* Pitch value */
@@ -292,9 +292,9 @@
int pitch_search_3tap(
float target[], /* Target vector */
float *sw,
-float ak[], /* LPCs for this subframe */
-float awk1[], /* Weighted LPCs #1 for this subframe */
-float awk2[], /* Weighted LPCs #2 for this subframe */
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Excitation */
void *par,
int start, /* Smallest pitch value allowed */
@@ -497,9 +497,9 @@
int forced_pitch_quant(
float target[], /* Target vector */
float *sw,
-float ak[], /* LPCs for this subframe */
-float awk1[], /* Weighted LPCs #1 for this subframe */
-float awk2[], /* Weighted LPCs #2 for this subframe */
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Excitation */
void *par,
int start, /* Smallest pitch value allowed */
<p><p>1.35 +7 -7 speex/libspeex/ltp.h
Index: ltp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- ltp.h 13 May 2003 20:57:31 -0000 1.34
+++ ltp.h 8 Oct 2003 04:27:51 -0000 1.35
@@ -31,7 +31,7 @@
*/
#include "speex_bits.h"
-
+#include "misc.h"
typedef struct ltp_params {
signed char *gain_cdbk;
@@ -47,9 +47,9 @@
int pitch_search_3tap(
float target[], /* Target vector */
float *sw,
-float ak[], /* LPCs for this subframe */
-float awk1[], /* Weighted LPCs #1 for this subframe */
-float awk2[], /* Weighted LPCs #2 for this subframe */
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Overlapping codebook */
void *par,
int start, /* Smallest pitch value allowed */
@@ -87,9 +87,9 @@
int forced_pitch_quant(
float target[], /* Target vector */
float *sw,
-float ak[], /* LPCs for this subframe */
-float awk1[], /* Weighted LPCs #1 for this subframe */
-float awk2[], /* Weighted LPCs #2 for this subframe */
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
float exc[], /* Excitation */
void *par,
int start, /* Smallest pitch value allowed */
<p><p>1.21 +22 -0 speex/libspeex/misc.h
Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- misc.h 22 Mar 2003 19:19:48 -0000 1.20
+++ misc.h 8 Oct 2003 04:27:51 -0000 1.21
@@ -45,6 +45,28 @@
#pragma warning(disable : 4305)
#endif
+
+#ifdef FIXED_POINT
+
+typedef int spx_mem_t;
+typedef float spx_coef_t;
+typedef float spx_sig_t;
+typedef short spx_word16_t;
+typedef int spx_word32_t;
+
+#define MULT16_32_Q14(a,b) (((a)*((b)>>14)) + ((a)*((signed int)((b)&0x00003fff))>>14))
+#define MULT16_32_Q15(a,b) (((a)*((b)>>15)) + ((a)*((signed int)((b)&0x00007fff))>>15))
+
+#else
+
+typedef float spx_mem_t;
+typedef float spx_coef_t;
+typedef float spx_sig_t;
+typedef float spx_word16_t;
+typedef float spx_word32_t;
+
+#endif
+
#ifndef RELEASE
void print_vec(float *vec, int len, char *name);
#endif
<p><p>1.44 +4 -4 speex/libspeex/modes.h
Index: modes.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- modes.h 13 May 2003 20:57:31 -0000 1.43
+++ modes.h 8 Oct 2003 04:27:51 -0000 1.44
@@ -38,7 +38,7 @@
#include "speex.h"
#include "speex_bits.h"
-
+#include "misc.h"
#define NB_SUBMODES 16
#define NB_SUBMODE_BITS 4
@@ -55,8 +55,8 @@
/** Long-term predictor quantization */
-typedef int (*ltp_quant_func)(float *, float *, float *, float *,
- float *, float *, void *, int, int, float,
+typedef int (*ltp_quant_func)(float *, float *, spx_coef_t *, spx_coef_t *,
+ spx_coef_t *, float *, void *, int, int, float,
int, int, SpeexBits*, char *, float *, float *, int, int);
/** Long-term un-quantize */
@@ -65,7 +65,7 @@
/** Innovation quantization function */
-typedef void (*innovation_quant_func)(float *, float *, float *, float *, void *, int, int,
+typedef void (*innovation_quant_func)(float *, spx_coef_t *, spx_coef_t *, spx_coef_t *, void *, int, int,
float *, float *, SpeexBits *, char *, int);
/** Innovation unquantization function */
<p><p>1.122 +24 -23 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -r1.121 -r1.122
--- nb_celp.c 24 Aug 2003 04:28:11 -0000 1.121
+++ nb_celp.c 8 Oct 2003 04:27:51 -0000 1.122
@@ -139,11 +139,11 @@
st->buf2 = PUSH(st->stack, st->windowSize, float);
- st->lpc = PUSH(st->stack, st->lpcSize+1, float);
- st->interp_lpc = PUSH(st->stack, st->lpcSize+1, float);
- st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, float);
- st->bw_lpc1 = PUSH(st->stack, st->lpcSize+1, float);
- st->bw_lpc2 = PUSH(st->stack, st->lpcSize+1, float);
+ st->lpc = PUSH(st->stack, st->lpcSize+1, spx_coef_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->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);
@@ -158,10 +158,10 @@
st->lsp[i]=(M_PI*((float)(i+1)))/(st->lpcSize+1);
}
- st->mem_sp = PUSH(st->stack, st->lpcSize, float);
- st->mem_sw = PUSH(st->stack, st->lpcSize, float);
- st->mem_sw_whole = PUSH(st->stack, st->lpcSize, float);
- st->mem_exc = PUSH(st->stack, st->lpcSize, float);
+ st->mem_sp = PUSH(st->stack, st->lpcSize, spx_mem_t);
+ st->mem_sw = PUSH(st->stack, st->lpcSize, spx_mem_t);
+ st->mem_sw_whole = PUSH(st->stack, st->lpcSize, spx_mem_t);
+ st->mem_exc = PUSH(st->stack, st->lpcSize, spx_mem_t);
st->pi_gain = PUSH(st->stack, st->nbSubframes, float);
@@ -201,7 +201,8 @@
int ol_pitch;
float ol_pitch_coef;
float ol_gain;
- float *res, *target, *mem;
+ float *res, *target;
+ spx_mem_t *mem;
char *stack;
float *syn_resp;
float lsp_dist=0;
@@ -605,7 +606,7 @@
/* Target signal */
target = PUSH(stack, st->subframeSize, float);
syn_resp = PUSH(stack, st->subframeSize, float);
- mem = PUSH(stack, st->lpcSize, float);
+ mem = PUSH(stack, st->lpcSize, spx_mem_t);
orig = PUSH(stack, st->frameSize, float);
for (i=0;i<st->frameSize;i++)
orig[i]=st->frame[i];
@@ -969,11 +970,11 @@
st->excBuf[i]=0;
st->innov = PUSH(st->stack, st->frameSize, float);
- st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, float);
+ 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->mem_sp = PUSH(st->stack, 5*st->lpcSize, float);
+ 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);
@@ -1010,7 +1011,7 @@
static void nb_decode_lost(DecState *st, float *out, char *stack)
{
int i, sub;
- float *awk1, *awk2, *awk3;
+ spx_coef_t *awk1, *awk2, *awk3;
float pitch_gain, fact, gain_med;
fact = exp(-.04*st->count_lost*st->count_lost);
@@ -1028,9 +1029,9 @@
speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
- awk1=PUSH(stack, (st->lpcSize+1), float);
- awk2=PUSH(stack, (st->lpcSize+1), float);
- awk3=PUSH(stack, (st->lpcSize+1), float);
+ awk1=PUSH(stack, (st->lpcSize+1), spx_coef_t);
+ awk2=PUSH(stack, (st->lpcSize+1), spx_coef_t);
+ awk3=PUSH(stack, (st->lpcSize+1), spx_coef_t);
for (sub=0;sub<st->nbSubframes;sub++)
{
@@ -1134,7 +1135,7 @@
int wideband;
int m;
char *stack;
- float *awk1, *awk2, *awk3;
+ spx_coef_t *awk1, *awk2, *awk3;
float pitch_average=0;
#ifdef EPIC_48K
int pitch_half[2];
@@ -1246,8 +1247,8 @@
/* If null mode (no transmission), just set a couple things to zero*/
if (st->submodes[st->submodeID] == NULL)
{
- float *lpc;
- lpc = PUSH(stack,11, float);
+ spx_coef_t *lpc;
+ lpc = PUSH(stack,11, spx_coef_t);
bw_lpc(.93, st->interp_qlpc, lpc, 10);
/*for (i=0;i<st->frameSize;i++)
st->exc[i]=0;*/
@@ -1340,9 +1341,9 @@
}
#endif
- awk1=PUSH(stack, st->lpcSize+1, float);
- awk2=PUSH(stack, st->lpcSize+1, float);
- awk3=PUSH(stack, st->lpcSize+1, float);
+ awk1=PUSH(stack, st->lpcSize+1, spx_coef_t);
+ awk2=PUSH(stack, st->lpcSize+1, spx_coef_t);
+ awk3=PUSH(stack, st->lpcSize+1, spx_coef_t);
if (st->submodeID==1)
{
<p><p>1.52 +11 -11 speex/libspeex/nb_celp.h
Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- nb_celp.h 22 Aug 2003 22:01:48 -0000 1.51
+++ nb_celp.h 8 Oct 2003 04:27:51 -0000 1.52
@@ -86,21 +86,21 @@
float *buf2; /**< 2nd temporary buffer */
float *autocorr; /**< auto-correlation */
float *lagWindow; /**< Window applied to auto-correlation */
- float *lpc; /**< LPCs for current frame */
+ 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 */
- float *interp_lpc; /**< Interpolated LPCs */
- float *interp_qlpc; /**< Interpolated quantized LPCs */
- float *bw_lpc1; /**< LPCs after bandwidth expansion by gamma1 for perceptual weighting*/
- float *bw_lpc2; /**< LPCs after bandwidth expansion by gamma2 for perceptual weighting*/
- float *mem_sp; /**< Filter memory for signal synthesis */
- float *mem_sw; /**< Filter memory for perceptually-weighted signal */
- float *mem_sw_whole; /**< Filter memory for perceptually-weighted signal (whole frame)*/
- float *mem_exc; /**< Filter memory for excitation (whole frame) */
+ 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*/
+ spx_coef_t *bw_lpc2; /**< LPCs after bandwidth expansion by gamma2 for perceptual weighting*/
+ spx_mem_t *mem_sp; /**< Filter memory for signal synthesis */
+ spx_mem_t *mem_sw; /**< Filter memory for perceptually-weighted signal */
+ spx_mem_t *mem_sw_whole; /**< Filter memory for perceptually-weighted signal (whole frame)*/
+ spx_mem_t *mem_exc; /**< Filter memory for excitation (whole frame) */
float *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
VBRState *vbr; /**< State of the VBR data */
@@ -157,8 +157,8 @@
float *qlsp; /**< Quantized LSPs for current frame */
float *old_qlsp; /**< Quantized LSPs for previous frame */
float *interp_qlsp; /**< Interpolated quantized LSPs */
- float *interp_qlpc; /**< Interpolated quantized LPCs */
- float *mem_sp; /**< Filter memory for synthesis signal */
+ 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) */
int last_pitch; /**< Pitch of last correctly decoded frame */
float last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
<p><p>1.14 +7 -8 speex/libspeex/preprocess.c
Index: preprocess.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/preprocess.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- preprocess.c 30 Sep 2003 00:44:08 -0000 1.13
+++ preprocess.c 8 Oct 2003 04:27:51 -0000 1.14
@@ -582,7 +582,7 @@
st->Smin[i] = st->Stmp[i] = st->S[i]+100;
}
- if (st->nb_preprocess%100==0)
+ if (st->nb_preprocess%80==0)
{
for (i=1;i<N-1;i++)
{
@@ -670,15 +670,14 @@
else
min_gamma *= 4.;
#else
- min_gamma = .1*fabs(mean_prior - mean_post)*fabs(mean_prior - mean_post);
- if (min_gamma>.15)
- min_gamma = .15;
- if (min_gamma<.02)
- min_gamma = .02;
+ min_gamma = .2*fabs(mean_prior - mean_post)*fabs(mean_prior - mean_post);
+ if (min_gamma>.6)
+ min_gamma = .6;
+ if (min_gamma<.01)
+ min_gamma = .01;
#endif
- /*min_gamma = .08;*/
- /*if (gamma<min_gamma)*/
+ if (gamma<min_gamma)
gamma=min_gamma;
for (i=1;i<N;i++)
<p><p>1.126 +21 -20 speex/libspeex/sb_celp.c
Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -r1.125 -r1.126
--- sb_celp.c 24 Aug 2003 04:28:11 -0000 1.125
+++ sb_celp.c 8 Oct 2003 04:27:51 -0000 1.126
@@ -191,22 +191,22 @@
st->lagWindow[i]=exp(-.5*sqr(2*M_PI*st->lag_factor*i));
st->autocorr = PUSH(st->stack, st->lpcSize+1, float);
- st->lpc = PUSH(st->stack, st->lpcSize+1, float);
- st->bw_lpc1 = PUSH(st->stack, st->lpcSize+1, float);
- st->bw_lpc2 = PUSH(st->stack, st->lpcSize+1, float);
+ 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->interp_lpc = PUSH(st->stack, st->lpcSize+1, float);
- st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, float);
+ 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);
- st->mem_sp = PUSH(st->stack, st->lpcSize, float);
- st->mem_sp2 = PUSH(st->stack, st->lpcSize, float);
- st->mem_sw = PUSH(st->stack, st->lpcSize, float);
+ st->mem_sp = PUSH(st->stack, st->lpcSize, spx_mem_t);
+ st->mem_sp2 = PUSH(st->stack, st->lpcSize, spx_mem_t);
+ st->mem_sw = PUSH(st->stack, st->lpcSize, spx_mem_t);
st->vbr_quality = 8;
st->vbr_enabled = 0;
@@ -236,7 +236,8 @@
SBEncState *st;
int i, roots, sub;
char *stack;
- float *mem, *innov, *syn_resp;
+ spx_mem_t *mem;
+ float *innov, *syn_resp;
float *low_pi_gain, *low_exc, *low_innov;
SpeexSBMode *mode;
int dtx;
@@ -441,7 +442,7 @@
st->old_qlsp[i] = st->qlsp[i];
}
- mem=PUSH(stack, st->lpcSize, float);
+ mem=PUSH(stack, st->lpcSize, spx_mem_t);
syn_resp=PUSH(stack, st->subframeSize, float);
innov = PUSH(stack, st->subframeSize, float);
@@ -700,10 +701,10 @@
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->interp_qlpc = PUSH(st->stack, st->lpcSize+1, float);
+ st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
st->pi_gain = PUSH(st->stack, st->nbSubframes, float);
- st->mem_sp = PUSH(st->stack, 2*st->lpcSize, float);
+ st->mem_sp = PUSH(st->stack, 2*st->lpcSize, spx_mem_t);
st->lpc_enh_enabled=0;
@@ -722,7 +723,7 @@
static void sb_decode_lost(SBDecState *st, float *out, int dtx, char *stack)
{
int i;
- float *awk1, *awk2, *awk3;
+ spx_coef_t *awk1, *awk2, *awk3;
int saved_modeid=0;
if (dtx)
@@ -735,9 +736,9 @@
st->first=1;
- awk1=PUSH(stack, st->lpcSize+1, float);
- awk2=PUSH(stack, st->lpcSize+1, float);
- awk3=PUSH(stack, st->lpcSize+1, float);
+ awk1=PUSH(stack, st->lpcSize+1, spx_coef_t);
+ awk2=PUSH(stack, st->lpcSize+1, spx_coef_t);
+ awk3=PUSH(stack, st->lpcSize+1, spx_coef_t);
if (st->lpc_enh_enabled)
{
@@ -815,7 +816,7 @@
int ret;
char *stack;
float *low_pi_gain, *low_exc, *low_innov;
- float *awk1, *awk2, *awk3;
+ spx_coef_t *awk1, *awk2, *awk3;
int dtx;
SpeexSBMode *mode;
@@ -910,9 +911,9 @@
st->old_qlsp[i] = st->qlsp[i];
}
- awk1=PUSH(stack, st->lpcSize+1, float);
- awk2=PUSH(stack, st->lpcSize+1, float);
- awk3=PUSH(stack, st->lpcSize+1, float);
+ awk1=PUSH(stack, st->lpcSize+1, spx_coef_t);
+ awk2=PUSH(stack, st->lpcSize+1, spx_coef_t);
+ awk3=PUSH(stack, st->lpcSize+1, spx_coef_t);
for (sub=0;sub<st->nbSubframes;sub++)
{
<p><p>1.41 +11 -11 speex/libspeex/sb_celp.h
Index: sb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- sb_celp.h 22 Aug 2003 22:01:48 -0000 1.40
+++ sb_celp.h 8 Oct 2003 04:27:51 -0000 1.41
@@ -72,21 +72,21 @@
float *window; /**< LPC analysis window */
float *lagWindow; /**< Auto-correlation window */
float *autocorr; /**< Auto-correlation (for LPC analysis) */
- float *lpc; /**< LPC coefficients */
+ 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 */
- float *interp_lpc; /**< Interpolated LPCs for current sub-frame */
- float *interp_qlpc; /**< Interpolated quantized LPCs for current sub-frame */
- float *bw_lpc1; /**< Bandwidth-expanded version of LPCs (#1) */
- float *bw_lpc2; /**< Bandwidth-expanded version of LPCs (#2) */
-
- float *mem_sp; /**< Synthesis signal memory */
- float *mem_sp2;
- float *mem_sw; /**< Perceptual signal memory */
+ 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) */
+ spx_coef_t *bw_lpc2; /**< Bandwidth-expanded version of LPCs (#2) */
+
+ spx_mem_t *mem_sp; /**< Synthesis signal memory */
+ spx_mem_t *mem_sp2;
+ spx_mem_t *mem_sw; /**< Perceptual signal memory */
float *pi_gain;
float vbr_quality; /**< Quality setting for VBR encoding */
@@ -131,9 +131,9 @@
float *qlsp;
float *old_qlsp;
float *interp_qlsp;
- float *interp_qlpc;
+ spx_coef_t *interp_qlpc;
- float *mem_sp;
+ spx_mem_t *mem_sp;
float *pi_gain;
int encode_submode;
<p><p>1.46 +2 -2 speex/libspeex/testenc.c
Index: testenc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testenc.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- testenc.c 18 Sep 2003 03:46:30 -0000 1.45
+++ testenc.c 8 Oct 2003 04:27:51 -0000 1.46
@@ -46,9 +46,9 @@
speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
tmp=0;
speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
- tmp=8;
+ tmp=4;
speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
- tmp=3;
+ tmp=5;
speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
speex_mode_query(&speex_nb_mode, SPEEX_MODE_FRAME_SIZE, &tmp);
<p><p>1.81 +0 -1 speex/src/speexdec.c
Index: speexdec.c
===================================================================
RCS file: /usr/local/cvsroot/speex/src/speexdec.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- speexdec.c 30 Sep 2003 00:44:08 -0000 1.80
+++ speexdec.c 8 Oct 2003 04:27:52 -0000 1.81
@@ -194,7 +194,6 @@
#endif
info.play.encoding = AUDIO_ENCODING_SLINEAR;
info.play.precision = 16;
- info.play.sample_rate = rate;
info.play.channels = *channels;
if (ioctl(audio_fd, AUDIO_SETINFO, &info) < 0)
<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