[xiph-cvs] cvs commit: speex/libspeex cb_search.c cb_search.h filters.c filters.h lsp.c lsp.h ltp.c ltp.h modes.h nb_celp.c nb_celp.h sb_celp.c stack_alloc.h
Jean-Marc Valin
jm at xiph.org
Sun Jan 5 21:56:57 PST 2003
jm 03/01/06 00:56:57
Modified: libspeex cb_search.c cb_search.h filters.c filters.h lsp.c
lsp.h ltp.c ltp.h modes.h nb_celp.c nb_celp.h
sb_celp.c stack_alloc.h
Log:
Think I made the stack operations more portable in case sizeof(int) !=
sizeof(void*)
Revision Changes Path
1.82 +4 -4 speex/libspeex/cb_search.c
Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- cb_search.c 6 Jan 2003 04:18:11 -0000 1.81
+++ cb_search.c 6 Jan 2003 05:56:56 -0000 1.82
@@ -47,7 +47,7 @@
float *exc,
float *r,
SpeexBits *bits,
-void *stack,
+char *stack,
int complexity
)
{
@@ -308,7 +308,7 @@
void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
-void *stack
+char *stack
)
{
int i,j;
@@ -359,7 +359,7 @@
float *exc,
float *r,
SpeexBits *bits,
-void *stack,
+char *stack,
int complexity
)
{
@@ -380,7 +380,7 @@
void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
-void *stack
+char *stack
)
{
speex_rand_vec(1, exc, nsf);
<p><p>1.27 +4 -4 speex/libspeex/cb_search.h
Index: cb_search.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- cb_search.h 27 Oct 2002 02:59:00 -0000 1.26
+++ cb_search.h 6 Jan 2003 05:56:56 -0000 1.27
@@ -55,7 +55,7 @@
float *exc,
float *r,
SpeexBits *bits,
-void *stack,
+char *stack,
int complexity
);
@@ -64,7 +64,7 @@
void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
-void *stack
+char *stack
);
@@ -79,7 +79,7 @@
float *exc,
float *r,
SpeexBits *bits,
-void *stack,
+char *stack,
int complexity
);
@@ -89,7 +89,7 @@
void *par, /* non-overlapping codebook */
int nsf, /* number of samples in subframe */
SpeexBits *bits,
-void *stack
+char *stack
);
#endif
<p><p>1.32 +4 -4 speex/libspeex/filters.c
Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- filters.c 20 Dec 2002 07:16:10 -0000 1.31
+++ filters.c 6 Jan 2003 05:56:56 -0000 1.32
@@ -98,7 +98,7 @@
}
}
-void syn_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, void *stack)
+void syn_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack)
{
int i;
float *mem = PUSH(stack,ord, float);
@@ -110,7 +110,7 @@
iir_mem2(y, awk2, y, N, ord, mem);
}
-void residue_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, void *stack)
+void residue_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack)
{
int i;
float *mem = PUSH(stack,ord, float);
@@ -123,7 +123,7 @@
}
-void qmf_decomp(float *xx, float *aa, float *y1, float *y2, int N, int M, float *mem, void *stack)
+void qmf_decomp(float *xx, float *aa, float *y1, float *y2, int N, int M, float *mem, char *stack)
{
int i,j,k,M2;
float *a;
@@ -158,7 +158,7 @@
}
/* By segher */
-void fir_mem_up(float *x, float *a, float *y, int N, int M, float *mem, void *stack)
+void fir_mem_up(float *x, float *a, float *y, int N, int M, float *mem, char *stack)
/* assumptions:
all odd x[i] are zero -- well, actually they are left out of the array now
N and M are multiples of 4 */
<p><p>1.23 +4 -4 speex/libspeex/filters.h
Index: filters.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- filters.h 20 Dec 2002 07:16:10 -0000 1.22
+++ filters.h 6 Jan 2003 05:56:56 -0000 1.23
@@ -41,8 +41,8 @@
} CombFilterMem;
-void qmf_decomp(float *xx, float *aa, float *y1, float *y2, int N, int M, float *mem, void *stack);
-void fir_mem_up(float *x, float *a, float *y, int N, int M, float *mem, void *stack);
+void qmf_decomp(float *xx, float *aa, float *y1, float *y2, int N, int M, float *mem, char *stack);
+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);
@@ -57,9 +57,9 @@
/* 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, void *stack);
+void syn_percep_zero(float *x, float *ak, float *awk1, float *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, void *stack);
+void residue_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack);
void comp_filter_mem_init (CombFilterMem *mem);
<p><p>1.22 +3 -3 speex/libspeex/lsp.c
Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- lsp.c 6 Jan 2003 04:18:11 -0000 1.21
+++ lsp.c 6 Jan 2003 05:56:56 -0000 1.22
@@ -69,7 +69,7 @@
-static float cheb_poly_eva(float *coef,float x,int m,void *stack)
+static float cheb_poly_eva(float *coef,float x,int m,char *stack)
/* float coef[] coefficients of the polynomial to be evaluated */
/* float x the point where polynomial is to be evaluated */
/* int m order of the polynomial */
@@ -112,7 +112,7 @@
\*---------------------------------------------------------------------------*/
-int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta, void *stack)
+int lpc_to_lsp (float *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 */
@@ -248,7 +248,7 @@
\*---------------------------------------------------------------------------*/
-void lsp_to_lpc(float *freq,float *ak,int lpcrdr, void *stack)
+void lsp_to_lpc(float *freq,float *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 */
<p><p>1.8 +2 -2 speex/libspeex/lsp.h
Index: lsp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- lsp.h 27 Oct 2002 02:59:00 -0000 1.7
+++ lsp.h 6 Jan 2003 05:56:56 -0000 1.8
@@ -47,8 +47,8 @@
#ifndef __AK2LSPD__
#define __AK2LSPD__
-int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta, void *stack);
-void lsp_to_lpc(float *freq, float *ak, int lpcrdr, void *stack);
+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);
/*Added by JMV*/
void lsp_enforce_margin(float *lsp, int len, float margin);
<p><p>1.68 +6 -6 speex/libspeex/ltp.c
Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- ltp.c 6 Jan 2003 04:18:11 -0000 1.67
+++ ltp.c 6 Jan 2003 05:56:56 -0000 1.68
@@ -67,7 +67,7 @@
*/
-void open_loop_nbest_pitch(float *sw, int start, int end, int len, int *pitch, float *gain, int N, void *stack)
+void open_loop_nbest_pitch(float *sw, int start, int end, int len, int *pitch, float *gain, int N, char *stack)
{
int i,j,k;
/*float corr=0;*/
@@ -151,7 +151,7 @@
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
-void *stack,
+char *stack,
float *exc2,
float *r,
int *cdbk_index
@@ -346,7 +346,7 @@
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
-void *stack,
+char *stack,
float *exc2,
float *r,
int complexity
@@ -421,7 +421,7 @@
int *pitch_val,
float *gain_val,
SpeexBits *bits,
-void *stack,
+char *stack,
int count_lost,
int subframe_offset,
float last_pitch_gain)
@@ -553,7 +553,7 @@
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
-void *stack,
+char *stack,
float *exc2,
float *r,
int complexity
@@ -580,7 +580,7 @@
int *pitch_val,
float *gain_val,
SpeexBits *bits,
-void *stack,
+char *stack,
int count_lost,
int subframe_offset,
float last_pitch_gain)
<p><p>1.31 +6 -6 speex/libspeex/ltp.h
Index: ltp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ltp.h 28 Nov 2002 06:32:50 -0000 1.30
+++ ltp.h 6 Jan 2003 05:56:56 -0000 1.31
@@ -40,7 +40,7 @@
} ltp_params;
-void open_loop_nbest_pitch(float *sw, int start, int end, int len, int *pitch, float *gain, int N, void *stack);
+void open_loop_nbest_pitch(float *sw, int start, int end, int len, int *pitch, float *gain, int N, char *stack);
/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
@@ -58,7 +58,7 @@
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
-void *stack,
+char *stack,
float *exc2,
float *r,
int complexity
@@ -75,7 +75,7 @@
int *pitch_val,
float *gain_val,
SpeexBits *bits,
-void *stack,
+char *stack,
int lost,
int subframe_offset,
float last_pitch_gain
@@ -92,7 +92,7 @@
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
-void *stack,
+char *stack,
float *exc2,
float *r,
int *cdbk_index
@@ -114,7 +114,7 @@
int p, /* Number of LPC coeffs */
int nsf, /* Number of samples in subframe */
SpeexBits *bits,
-void *stack,
+char *stack,
float *exc2,
float *r,
int complexity
@@ -131,7 +131,7 @@
int *pitch_val,
float *gain_val,
SpeexBits *bits,
-void *stack,
+char *stack,
int lost,
int subframe_offset,
float last_pitch_gain
<p><p>1.41 +4 -4 speex/libspeex/modes.h
Index: modes.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- modes.h 30 Nov 2002 05:24:41 -0000 1.40
+++ modes.h 6 Jan 2003 05:56:56 -0000 1.41
@@ -57,19 +57,19 @@
/** Long-term predictor quantization */
typedef int (*ltp_quant_func)(float *, float *, float *, float *,
float *, float *, void *, int, int, float,
- int, int, SpeexBits*, void *, float *, float *, int);
+ int, int, SpeexBits*, char *, float *, float *, int);
/** Long-term un-quantize */
typedef void (*ltp_unquant_func)(float *, int, int, float, void *, int, int *,
- float *, SpeexBits*, void*, int, int, float);
+ float *, SpeexBits*, char*, int, int, float);
/** Innovation quantization function */
typedef void (*innovation_quant_func)(float *, float *, float *, float *, void *, int, int,
- float *, float *, SpeexBits *, void *, int);
+ float *, float *, SpeexBits *, char *, int);
/** Innovation unquantization function */
-typedef void (*innovation_unquant_func)(float *, void *, int, SpeexBits*, void *);
+typedef void (*innovation_unquant_func)(float *, void *, int, SpeexBits*, char *);
/** Description of a Speex sub-mode (wither narrowband or wideband */
typedef struct SpeexSubmode {
<p><p>1.105 +8 -8 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- nb_celp.c 6 Jan 2003 04:18:11 -0000 1.104
+++ nb_celp.c 6 Jan 2003 05:56:56 -0000 1.105
@@ -129,7 +129,7 @@
st->autocorr = (float*)speex_alloc((st->lpcSize+1)*sizeof(float));
- st->stack = (float*)speex_alloc(4000*sizeof(float));
+ st->stack = (char*)speex_alloc(4000*sizeof(float));
st->buf2 = (float*)speex_alloc(st->windowSize*sizeof(float));
@@ -186,7 +186,7 @@
speex_free(st->swBuf);
speex_free(st->exc2Buf);
speex_free(st->innov);
- speex_free((float*)st->stack);
+ speex_free(st->stack);
speex_free(st->window);
speex_free(st->buf2);
@@ -228,7 +228,7 @@
float ol_pitch_coef;
float ol_gain;
float *res, *target, *mem;
- void *stack;
+ char *stack;
float *syn_resp;
float lsp_dist=0;
float *orig;
@@ -775,7 +775,7 @@
/* In some (rare) modes, we do a second search (more bits) to reduce noise even more */
if (SUBMODE(double_codebook)) {
- void *tmp_stack=stack;
+ char *tmp_stack=stack;
float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
for (i=0;i<st->subframeSize;i++)
innov2[i]=0;
@@ -876,7 +876,7 @@
st->pre_mem=0;
st->lpc_enh_enabled=0;
- st->stack = speex_alloc(2000*sizeof(float));
+ st->stack = (char*)speex_alloc(2000*sizeof(float));
st->inBuf = (float*)speex_alloc(st->bufSize*sizeof(float));
st->frame = st->inBuf + st->bufSize - st->windowSize;
@@ -937,7 +937,7 @@
#define median3(a, b, c) ((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a))))
-static void nb_decode_lost(DecState *st, float *out, void *stack)
+static void nb_decode_lost(DecState *st, float *out, char *stack)
{
int i, sub;
float *awk1, *awk2, *awk3;
@@ -1063,7 +1063,7 @@
float best_pitch_gain=0;
int wideband;
int m;
- void *stack;
+ char *stack;
float *awk1, *awk2, *awk3;
float pitch_average=0;
@@ -1420,7 +1420,7 @@
/* Decode second codebook (only for some modes) */
if (SUBMODE(double_codebook))
{
- void *tmp_stack=stack;
+ char *tmp_stack=stack;
float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
for (i=0;i<st->subframeSize;i++)
innov2[i]=0;
<p><p>1.45 +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.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- nb_celp.h 20 Dec 2002 08:24:46 -0000 1.44
+++ nb_celp.h 6 Jan 2003 05:56:56 -0000 1.45
@@ -67,7 +67,7 @@
float preemph; /**< Pre-emphasis: P(z) = 1 - a*z^-1*/
float pre_mem; /**< 1-element memory for pre-emphasis */
float pre_mem2; /**< 1-element memory for pre-emphasis */
- void *stack; /**< Pseudo-stack allocation for temporary memory */
+ char *stack; /**< Pseudo-stack allocation for temporary memory */
float *inBuf; /**< Input buffer (original signal) */
float *frame; /**< Start of original frame */
float *excBuf; /**< Excitation buffer */
@@ -139,7 +139,7 @@
float gamma2; /**< Perceptual filter: A(z/gamma2) */
float preemph; /**< Pre-emphasis: P(z) = 1 - a*z^-1*/
float pre_mem; /**< 1-element memory for pre-emphasis */
- void *stack; /**< Pseudo-stack allocation for temporary memory */
+ char *stack; /**< Pseudo-stack allocation for temporary memory */
float *inBuf; /**< Input buffer (original signal) */
float *frame; /**< Start of original frame */
float *excBuf; /**< Excitation buffer */
<p><p>1.109 +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.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- sb_celp.c 6 Jan 2003 04:18:12 -0000 1.108
+++ sb_celp.c 6 Jan 2003 05:56:56 -0000 1.109
@@ -152,7 +152,7 @@
st->gamma1=mode->gamma1;
st->gamma2=mode->gamma2;
st->first=1;
- st->stack = speex_alloc(4000*sizeof(float));
+ st->stack = (char*)speex_alloc(4000*sizeof(float));
st->x0d=(float*)speex_alloc(st->frame_size*sizeof(float));
st->x1d=(float*)speex_alloc(st->frame_size*sizeof(float));
@@ -261,7 +261,7 @@
speex_free(st->mem_sw);
speex_free(st->pi_gain);
- speex_free(st->stack);
+ speex_free((float*)st->stack);
speex_free(st);
}
@@ -271,7 +271,7 @@
{
SBEncState *st;
int i, roots, sub;
- void *stack;
+ char *stack;
float *mem, *innov, *syn_resp;
float *low_pi_gain, *low_exc, *low_innov;
SpeexSBMode *mode;
@@ -660,7 +660,7 @@
exc[i] += innov[i]*scale;
if (SUBMODE(double_codebook)) {
- void *tmp_stack=stack;
+ char *tmp_stack=stack;
float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
for (i=0;i<st->subframeSize;i++)
innov2[i]=0;
@@ -743,7 +743,7 @@
st->submodeID=mode->defaultSubmode;
st->first=1;
- st->stack = speex_alloc(2000*sizeof(float));
+ st->stack = (char*)speex_alloc(2000*sizeof(float));
st->x0d=(float*)speex_alloc(st->frame_size*sizeof(float));
st->x1d=(float*)speex_alloc(st->frame_size*sizeof(float));
@@ -795,12 +795,12 @@
speex_free(st->mem_sp);
- speex_free(st->stack);
+ speex_free((float*)st->stack);
speex_free(state);
}
-static void sb_decode_lost(SBDecState *st, float *out, int dtx, void *stack)
+static void sb_decode_lost(SBDecState *st, float *out, int dtx, char *stack)
{
int i;
float *awk1, *awk2, *awk3;
@@ -887,7 +887,7 @@
SBDecState *st;
int wideband;
int ret;
- void *stack;
+ char *stack;
float *low_pi_gain, *low_exc, *low_innov;
float *awk1, *awk2, *awk3;
float dtx;
@@ -1080,7 +1080,7 @@
exc[i]*=scale;
if (SUBMODE(double_codebook)) {
- void *tmp_stack=stack;
+ char *tmp_stack=stack;
float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
for (i=0;i<st->subframeSize;i++)
innov2[i]=0;
<p><p>1.10 +13 -0 speex/libspeex/stack_alloc.h
Index: stack_alloc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/stack_alloc.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- stack_alloc.h 27 Oct 2002 02:59:00 -0000 1.9
+++ stack_alloc.h 6 Jan 2003 05:56:56 -0000 1.10
@@ -34,6 +34,8 @@
#ifndef STACK_ALLOC_H
#define STACK_ALLOC_H
+#if 0
+
/*Aligns the stack to a 'size' boundary */
#define ALIGN(stack, size) (stack=(void*)((((int)stack)+((size)-1)) & (-(size))))
/*Aligns the stack to a 'size' boundary minus k */
@@ -42,5 +44,16 @@
/* Allocates 'size' elements of type 'type' on the stack */
#define PUSH(stack, size, type) (ALIGN(stack,sizeof(type)),stack=(void*)(((int)stack)+((size)*sizeof(type))),(type*)(((int)stack)-((size)*sizeof(type))))
+
+#else
+
+/*Aligns the stack to a 'size' boundary */
+#define ALIGN(stack, size) (stack += (size - (int)stack) & (size - 1))
+
+/* Allocates 'size' elements of type 'type' on the stack */
+#define PUSH(stack, size, type) (ALIGN(stack,sizeof(type)),stack+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))
+
+
+#endif
#endif
<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