diff options
-rw-r--r-- | AUTHORS | 3 | ||||
-rw-r--r-- | libspeex/filters.c | 19 | ||||
-rw-r--r-- | libspeex/filters.h | 4 | ||||
-rw-r--r-- | libspeex/lsp.c | 17 | ||||
-rw-r--r-- | libspeex/lsp.h | 1 | ||||
-rw-r--r-- | libspeex/nb_celp.c | 2 | ||||
-rw-r--r-- | libspeex/sb_celp.c | 25 | ||||
-rw-r--r-- | libspeex/sb_celp.h | 5 |
8 files changed, 41 insertions, 35 deletions
@@ -8,6 +8,9 @@ David Rowe <david@voicetronix.com.au> via VoiceTronix John Francis Edwards: wave_out.[ch], some #ifdefs for windows port and MSVC project files +Segher Boessenkool + Misc. optimizations (for QMF in particular) + Atsuhiko Yamanaka <ymnk@jcraft.com>: Patch to speexenc.c to add Vorbis comment format diff --git a/libspeex/filters.c b/libspeex/filters.c index a2d39ca..1a8972c 100644 --- a/libspeex/filters.c +++ b/libspeex/filters.c @@ -282,7 +282,7 @@ void residue_percep_zero(spx_sig_t *xx, spx_coef_t *ak, spx_coef_t *awk1, spx_co fir_mem2(y, awk2, y, N, ord, mem); } -void qmf_decomp(short *xx, float *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, float *mem, char *stack) +void qmf_decomp(short *xx, spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack) { int i,j,k,M2; spx_word16_t *a; @@ -293,13 +293,9 @@ void qmf_decomp(short *xx, float *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M x = PUSH(stack, N+M-1, spx_word16_t); x2=x+M-1; M2=M>>1; -#ifdef FIXED_POINT - for (i=0;i<M;i++) - a[M-i-1]=floor(.5+65536*aa[i]); -#else for (i=0;i<M;i++) a[M-i-1]= aa[i]; -#endif + for (i=0;i<M-1;i++) x[i]=mem[M-i-2]; for (i=0;i<N;i++) @@ -323,13 +319,12 @@ void qmf_decomp(short *xx, float *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M /* By segher */ -void fir_mem_up(spx_sig_t *x, float *aa, spx_sig_t *y, int N, int M, float *mem, char *stack) +void fir_mem_up(spx_sig_t *x, spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *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 */ { int i, j; - spx_word16_t *a; spx_word16_t *xx; xx= PUSH(stack, M+N-1, spx_word16_t); @@ -339,14 +334,6 @@ void fir_mem_up(spx_sig_t *x, float *aa, spx_sig_t *y, int N, int M, float *mem, for (i = 0; i < M - 1; i += 2) xx[N+i] = mem[i+1]; -#ifdef FIXED_POINT - a = PUSH(stack, M, spx_word16_t); - for (i=0;i<M;i++) - a[i] = floor(.5+65536*aa[i]); -#else - a = aa; -#endif - for (i = 0; i < N; i += 4) { spx_sig_t y0, y1, y2, y3; spx_word16_t x0; diff --git a/libspeex/filters.h b/libspeex/filters.h index f608cf4..c8967fd 100644 --- a/libspeex/filters.h +++ b/libspeex/filters.h @@ -47,8 +47,8 @@ typedef struct CombFilterMem { } CombFilterMem; -void qmf_decomp(short *xx, float *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, float *mem, char *stack); -void fir_mem_up(spx_sig_t *x, float *a, spx_sig_t *y, int N, int M, float *mem, char *stack); +void qmf_decomp(short *xx, spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack); +void fir_mem_up(spx_sig_t *x, spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack); void filter_mem2(spx_sig_t *x, spx_coef_t *num, spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem); diff --git a/libspeex/lsp.c b/libspeex/lsp.c index 1814701..12fc20f 100644 --- a/libspeex/lsp.c +++ b/libspeex/lsp.c @@ -56,6 +56,15 @@ Modified by Jean-Marc Valin #define NULL 0 #endif +#ifdef FIXED_POINT +#define ANGLE2X(a) (cos(a)) +#define X2ANGLE(x) (acos(x)) +#else +#define ANGLE2X(a) (cos(a)) +#define X2ANGLE(x) (acos(x)) +#endif + + /*---------------------------------------------------------------------------*\ FUNCTION....: cheb_poly_eva() @@ -291,7 +300,7 @@ int lpc_to_lsp (spx_coef_t *a,int lpcrdr,float *freq,int nb,float delta, char *s } /* once zero is found, reset initial interval to xr */ - freq[j] = acos(xm); + freq[j] = X2ANGLE(xm); xl = xm; flag = 0; /* reset flag for next search */ } @@ -335,7 +344,7 @@ void lsp_to_lpc(float *freq,spx_coef_t *ak,int lpcrdr, char *stack) freqn = PUSH(stack, lpcrdr, spx_word16_t); for (i=0;i<lpcrdr;i++) - freqn[i] = cos(freq[i])*32768.; + freqn[i] = ANGLE2X(freq[i])*32768.; Wp = PUSH(stack, 4*m+2, spx_word32_t); pw = Wp; @@ -430,8 +439,8 @@ void lsp_to_lpc(float *freq,spx_coef_t *ak,int lpcrdr, char *stack) n2 = n1 + 1; n3 = n2 + 1; n4 = n3 + 1; - xout1 = xin1 - 2*(cos(freq[i2])) * *n1 + *n2; - xout2 = xin2 - 2*(cos(freq[i2+1])) * *n3 + *n4; + xout1 = xin1 - 2*(ANGLE2X(freq[i2])) * *n1 + *n2; + xout2 = xin2 - 2*(ANGLE2X(freq[i2+1])) * *n3 + *n4; *n2 = *n1; *n4 = *n3; *n1 = xin1; diff --git a/libspeex/lsp.h b/libspeex/lsp.h index 656f9f8..a0ecac0 100644 --- a/libspeex/lsp.h +++ b/libspeex/lsp.h @@ -55,5 +55,4 @@ 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);
-
#endif /* __AK2LSPD__ */
diff --git a/libspeex/nb_celp.c b/libspeex/nb_celp.c index 82c5e15..8bedaa3 100644 --- a/libspeex/nb_celp.c +++ b/libspeex/nb_celp.c @@ -154,7 +154,7 @@ void *nb_encoder_init(SpeexMode *m) st->first = 1; for (i=0;i<st->lpcSize;i++) { - st->lsp[i]=(M_PI*((float)(i+1)))/(st->lpcSize+1); + st->lsp[i]=8192*(M_PI*((float)(i+1)))/(st->lpcSize+1); } st->mem_sp = PUSH(st->stack, st->lpcSize, spx_mem_t); diff --git a/libspeex/sb_celp.c b/libspeex/sb_celp.c index a98771e..20cbd48 100644 --- a/libspeex/sb_celp.c +++ b/libspeex/sb_celp.c @@ -54,6 +54,14 @@ #define SUBMODE(x) st->submodes[st->submodeID]->x #define QMF_ORDER 64 + +#ifdef FIXED_POINT +static spx_word16_t h0[64] = {2, -7, -7, 18, 15, -39, -25, 75, 35, -130, -41, 212, 38, -327, -17, 483, -32, -689, 124, 956, -283, -1307, 543, 1780, -973, -2467, 1733, 3633, -3339, -6409, 9059, 30153, 30153, 9059, -6409, -3339, 3633, 1733, -2467, -973, 1780, 543, -1307, -283, 956, 124, -689, -32, 483, -17, -327, 38, 212, -41, -130, 35, 75, -25, -39, 15, 18, -7, -7, 2}; + +static spx_word16_t h1[64] = {2, 7, -7, -18, 15, 39, -25, -75, 35, 130, -41, -212, 38, 327, -17, -483, -32, 689, 124, -956, -283, 1307, 543, -1780, -973, 2467, 1733, -3633, -3339, 6409, 9059, -30153, 30153, -9059, -6409, 3339, 3633, -1733, -2467, 973, 1780, -543, -1307, 283, 956, -124, -689, 32, 483, 17, -327, -38, 212, 41, -130, -35, 75, 25, -39, -15, 18, 7, -7, -2}; + + +#else static float h0[64] = { 3.596189e-05, -0.0001123515, -0.0001104587, 0.0002790277, @@ -123,6 +131,7 @@ static float h1[64] = { 0.0002790277, 0.0001104587, -0.0001123515, -3.596189e-05 }; +#endif void *sb_encoder_init(SpeexMode *m) { @@ -164,10 +173,10 @@ void *sb_encoder_init(SpeexMode *m) st->y0=PUSH(st->stack, st->full_frame_size, spx_sig_t); st->y1=PUSH(st->stack, st->full_frame_size, spx_sig_t); - st->h0_mem=PUSH(st->stack, QMF_ORDER, float); - st->h1_mem=PUSH(st->stack, QMF_ORDER, float); - st->g0_mem=PUSH(st->stack, QMF_ORDER, float); - st->g1_mem=PUSH(st->stack, QMF_ORDER, float); + st->h0_mem=PUSH(st->stack, QMF_ORDER, spx_word16_t); + st->h1_mem=PUSH(st->stack, QMF_ORDER, spx_word16_t); + st->g0_mem=PUSH(st->stack, QMF_ORDER, spx_word32_t); + st->g1_mem=PUSH(st->stack, QMF_ORDER, spx_word32_t); st->buf=PUSH(st->stack, st->windowSize, spx_sig_t); st->excBuf=PUSH(st->stack, st->bufSize, spx_sig_t); @@ -696,10 +705,8 @@ void *sb_decoder_init(SpeexMode *m) st->y0=PUSH(st->stack, st->full_frame_size, spx_sig_t); st->y1=PUSH(st->stack, st->full_frame_size, spx_sig_t); - st->h0_mem=PUSH(st->stack, QMF_ORDER, float); - st->h1_mem=PUSH(st->stack, QMF_ORDER, float); - st->g0_mem=PUSH(st->stack, QMF_ORDER, float); - st->g1_mem=PUSH(st->stack, QMF_ORDER, float); + st->g0_mem=PUSH(st->stack, QMF_ORDER, spx_word32_t); + st->g1_mem=PUSH(st->stack, QMF_ORDER, spx_word32_t); st->exc=PUSH(st->stack, st->frame_size, spx_sig_t); @@ -1354,7 +1361,7 @@ int sb_decoder_ctl(void *state, int request, void *ptr) for (i=0;i<2*st->lpcSize;i++) st->mem_sp[i]=0; for (i=0;i<QMF_ORDER;i++) - st->h0_mem[i]=st->h1_mem[i]=st->g0_mem[i]=st->g1_mem[i]=0; + st->g0_mem[i]=st->g1_mem[i]=0; } break; case SPEEX_SET_SUBMODE_ENCODING: diff --git a/libspeex/sb_celp.h b/libspeex/sb_celp.h index 4fb55a0..0b08352 100644 --- a/libspeex/sb_celp.h +++ b/libspeex/sb_celp.h @@ -61,7 +61,8 @@ typedef struct SBEncState { spx_sig_t *x0d, *x1d; /**< QMF filter signals*/ spx_sig_t *high; /**< High-band signal (buffer) */ spx_sig_t *y0, *y1; /**< QMF synthesis signals */ - float *h0_mem, *h1_mem, *g0_mem, *g1_mem; /**< QMF memories */ + spx_word16_t *h0_mem, *h1_mem; + spx_word32_t *g0_mem, *g1_mem; /**< QMF memories */ spx_sig_t *excBuf; /**< High-band excitation */ spx_sig_t *exc; /**< High-band excitation (for QMF only)*/ @@ -125,7 +126,7 @@ typedef struct SBDecState { spx_sig_t *x0d, *x1d; spx_sig_t *high; spx_sig_t *y0, *y1; - float *h0_mem, *h1_mem, *g0_mem, *g1_mem; + spx_word32_t *g0_mem, *g1_mem; spx_sig_t *exc; float *qlsp; |