diff options
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | configure.ac | 11 | ||||
-rw-r--r-- | libspeex/arch.h | 6 | ||||
-rw-r--r-- | libspeex/modes.c | 1 | ||||
-rw-r--r-- | libspeex/modes.h | 2 | ||||
-rw-r--r-- | libspeex/modes_wb.c | 2 | ||||
-rw-r--r-- | libspeex/nb_celp.c | 8 | ||||
-rw-r--r-- | libspeex/nb_celp.h | 3 | ||||
-rw-r--r-- | libspeex/sb_celp.c | 8 | ||||
-rw-r--r-- | libspeex/sb_celp.h | 3 | ||||
-rw-r--r-- | libspeex/window.c | 8 | ||||
-rw-r--r-- | win32/config.h | 3 |
12 files changed, 29 insertions, 28 deletions
@@ -4,6 +4,8 @@ Implement speex_header_free() better error reporting get rid of floats in initialisation (make the lag window a const array) split encoder and decoder? +improve float<->int conversion +NaN checks? Eventually: diff --git a/configure.ac b/configure.ac index bd52a32..dd86817 100644 --- a/configure.ac +++ b/configure.ac @@ -96,12 +96,6 @@ AC_DEFINE_UNQUOTED(SPEEX_MINOR_VERSION, ${SPEEX_MINOR_VERSION}, [Version minor]) AC_DEFINE_UNQUOTED(SPEEX_MICRO_VERSION, ${SPEEX_MICRO_VERSION}, [Version micro]) AC_DEFINE_UNQUOTED(SPEEX_EXTRA_VERSION, "${SPEEX_EXTRA_VERSION}", [Version extra]) -AC_ARG_ENABLE(floating-point, [ --enable-floating-point Compile as floating-point (default)], -[if test "$enableval" = yes; then - AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]) -fi], -AC_DEFINE([FLOATING_POINT], , [Compile as floating-point])) - AC_ARG_ENABLE(valgrind, [ --enable-valgrind Enable valgrind extra checks], [if test "$enableval" = yes; then AC_DEFINE([ENABLE_VALGRIND], , [Enable valgrind extra checks]) @@ -116,7 +110,10 @@ fi AC_ARG_ENABLE(fixed-point, [ --enable-fixed-point Compile as fixed-point], [if test "$enableval" = yes; then AC_DEFINE([FIXED_POINT], , [Compile as fixed-point]) -fi]) +else + AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]) +fi], +AC_DEFINE([FLOATING_POINT], , [Compile as floating-point])) AC_ARG_ENABLE(arm4-asm, [ --enable-arm4-asm Make use of ARM4 assembly optimizations], [if test "$enableval" = yes; then diff --git a/libspeex/arch.h b/libspeex/arch.h index 219c90e..7679aea 100644 --- a/libspeex/arch.h +++ b/libspeex/arch.h @@ -46,6 +46,9 @@ /* A couple test to catch stupid option combinations */ #ifdef FIXED_POINT +#ifdef FLOATING_POINT +#error You cannot compile as floating point and fixed point at the same time +#endif #ifdef _USE_SSE #error SSE is only for floating-point #endif @@ -58,6 +61,9 @@ #else +#ifndef FLOATING_POINT +#error You now need to define either FIXED_POINT or FLOATING_POINT +#endif #if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM) #error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions? #endif diff --git a/libspeex/modes.c b/libspeex/modes.c index 18c12a3..33e031e 100644 --- a/libspeex/modes.c +++ b/libspeex/modes.c @@ -328,7 +328,6 @@ static const SpeexNBMode nb_mode = { #else 0.9, 0.6, /* gamma1, gamma2 */ #endif - .012, /*lag_factor*/ QCONST16(.0002,15), /*lpc_floor*/ {NULL, &nb_submode1, &nb_submode2, &nb_submode3, &nb_submode4, &nb_submode5, &nb_submode6, &nb_submode7, &nb_submode8, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, diff --git a/libspeex/modes.h b/libspeex/modes.h index 3ef95e9..d0ff842 100644 --- a/libspeex/modes.h +++ b/libspeex/modes.h @@ -123,7 +123,6 @@ typedef struct SpeexNBMode { spx_word16_t gamma1; /**< Perceptual filter parameter #1 */ spx_word16_t gamma2; /**< Perceptual filter parameter #2 */ - float lag_factor; /**< Lag-windowing parameter */ spx_word16_t lpc_floor; /**< Noise floor for LPC analysis */ const SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */ @@ -140,7 +139,6 @@ typedef struct SpeexSBMode { int lpcSize; /**< Order of LPC filter */ spx_word16_t gamma1; /**< Perceptual filter parameter #1 */ spx_word16_t gamma2; /**< Perceptual filter parameter #1 */ - float lag_factor; /**< Lag-windowing parameter */ spx_word16_t lpc_floor; /**< Noise floor for LPC analysis */ spx_word16_t folding_gain; diff --git a/libspeex/modes_wb.c b/libspeex/modes_wb.c index 253f07a..64c9373 100644 --- a/libspeex/modes_wb.c +++ b/libspeex/modes_wb.c @@ -187,7 +187,6 @@ static const SpeexSBMode sb_wb_mode = { #else 0.9, 0.6, /* gamma1, gamma2 */ #endif - .012, /*lag_factor*/ QCONST16(.0002,15), /*lpc_floor*/ QCONST16(0.9f,15), {NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL}, @@ -232,7 +231,6 @@ static const SpeexSBMode sb_uwb_mode = { #else 0.9, 0.6, /* gamma1, gamma2 */ #endif - .012, /*lag_factor*/ QCONST16(.0002,15), /*lpc_floor*/ QCONST16(0.7f,15), {NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL}, diff --git a/libspeex/nb_celp.c b/libspeex/nb_celp.c index 8c8630d..4b2903d 100644 --- a/libspeex/nb_celp.c +++ b/libspeex/nb_celp.c @@ -108,6 +108,7 @@ const float exc_gain_quant_scal1[2]={0.70469f, 1.05127f}; #define sqr(x) ((x)*(x)) +extern const spx_word16_t lag_window[]; extern const spx_word16_t lpc_window[]; void *nb_encoder_init(const SpeexMode *m) @@ -137,7 +138,6 @@ void *nb_encoder_init(const SpeexMode *m) st->gamma2=mode->gamma2; st->min_pitch=mode->pitchStart; st->max_pitch=mode->pitchEnd; - st->lag_factor=mode->lag_factor; st->lpc_floor = mode->lpc_floor; st->submodes=mode->submodes; @@ -166,9 +166,7 @@ void *nb_encoder_init(const SpeexMode *m) st->window= lpc_window; /* Create the window for autocorrelation (lag-windowing) */ - st->lagWindow = (spx_word16_t*)speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t)); - for (i=0;i<st->lpcSize+1;i++) - st->lagWindow[i]=16384*exp(-.5*sqr(2*M_PI*st->lag_factor*i)); + st->lagWindow = lag_window; st->old_lsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); st->old_qlsp = (spx_lsp_t*)speex_alloc((st->lpcSize)*sizeof(spx_lsp_t)); @@ -225,8 +223,6 @@ void nb_encoder_destroy(void *state) speex_free (st->old_qlsp); speex_free (st->swBuf); - speex_free (st->lagWindow); - speex_free (st->old_lsp); speex_free (st->mem_sp); speex_free (st->mem_sw); diff --git a/libspeex/nb_celp.h b/libspeex/nb_celp.h index 259bead..eac1261 100644 --- a/libspeex/nb_celp.h +++ b/libspeex/nb_celp.h @@ -73,7 +73,6 @@ typedef struct EncState { 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 */ spx_word16_t lpc_floor; /**< Noise floor multiplier for A[0] in LPC analysis*/ char *stack; /**< Pseudo-stack allocation for temporary memory */ spx_word16_t *winBuf; /**< Input buffer (original signal) */ @@ -82,7 +81,7 @@ typedef struct EncState { spx_word16_t *swBuf; /**< Weighted signal buffer */ spx_word16_t *sw; /**< Start of weighted signal frame */ const spx_word16_t *window; /**< Temporary (Hanning) window */ - spx_word16_t *lagWindow; /**< Window applied to auto-correlation */ + const spx_word16_t *lagWindow; /**< Window applied to auto-correlation */ spx_lsp_t *old_lsp; /**< LSPs for previous frame */ spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */ spx_mem_t *mem_sp; /**< Filter memory for signal synthesis */ diff --git a/libspeex/sb_celp.c b/libspeex/sb_celp.c index a328ec4..e254d1a 100644 --- a/libspeex/sb_celp.c +++ b/libspeex/sb_celp.c @@ -183,6 +183,7 @@ static const float h0[64] = { #endif +extern const spx_word16_t lag_window[]; extern const spx_word16_t lpc_window[]; @@ -224,7 +225,6 @@ void *sb_encoder_init(const SpeexMode *m) tmp=1; speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, &tmp); - st->lag_factor = mode->lag_factor; st->lpc_floor = mode->lpc_floor; st->gamma1=mode->gamma1; st->gamma2=mode->gamma2; @@ -237,9 +237,7 @@ void *sb_encoder_init(const SpeexMode *m) st->window= lpc_window; - st->lagWindow = (spx_word16_t*)speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t)); - for (i=0;i<st->lpcSize+1;i++) - st->lagWindow[i]=16384*exp(-.5*sqr(2*M_PI*st->lag_factor*i)); + st->lagWindow = lag_window; st->old_lsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); @@ -288,8 +286,6 @@ void sb_encoder_destroy(void *state) speex_free(st->h0_mem); speex_free(st->h1_mem); - speex_free(st->lagWindow); - speex_free(st->old_lsp); speex_free(st->old_qlsp); speex_free(st->interp_qlpc); diff --git a/libspeex/sb_celp.h b/libspeex/sb_celp.h index ce0709e..c2e28bf 100644 --- a/libspeex/sb_celp.h +++ b/libspeex/sb_celp.h @@ -51,7 +51,6 @@ typedef struct SBEncState { int windowSize; /**< Length of high-band LPC window*/ int lpcSize; /**< Order of high-band LPC analysis */ int first; /**< First frame? */ - float lag_factor; /**< Lag-windowing control parameter */ spx_word16_t lpc_floor; /**< Controls LPC analysis noise floor */ spx_word16_t gamma1; /**< Perceptual weighting coef 1 */ spx_word16_t gamma2; /**< Perceptual weighting coef 2 */ @@ -61,7 +60,7 @@ typedef struct SBEncState { spx_word16_t *h0_mem, *h1_mem; const spx_word16_t *window; /**< LPC analysis window */ - spx_word16_t *lagWindow; /**< Auto-correlation window */ + const spx_word16_t *lagWindow; /**< Auto-correlation window */ spx_lsp_t *old_lsp; /**< LSPs of previous frame */ spx_lsp_t *old_qlsp; /**< Quantized LSPs of previous frame */ spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs for current sub-frame */ diff --git a/libspeex/window.c b/libspeex/window.c index 35dac3b..ac042d4 100644 --- a/libspeex/window.c +++ b/libspeex/window.c @@ -36,6 +36,10 @@ #include "arch.h" #ifdef FIXED_POINT +const spx_word16_t lag_window[11] = { + 16384, 16337, 16199, 15970, 15656, 15260, 14790, 14254, 13659, 13015, 12330 +}; + const spx_word16_t lpc_window[200] = { 1310, 1313, 1321, 1333, 1352, 1375, 1403, 1436, 1475, 1518, 1567, 1621, 1679, 1743, 1811, 1884, @@ -64,6 +68,10 @@ const spx_word16_t lpc_window[200] = { 6797, 6028, 5251, 4470, 3695, 2943, 2248, 1696 }; #else +const spx_word16_t lag_window[11] = { + 1.00000, 0.99716, 0.98869, 0.97474, 0.95554, 0.93140, 0.90273, 0.86998, 0.83367, 0.79434, 0.75258 +}; + const spx_word16_t lpc_window[200] = { 0.080000f, 0.080158f, 0.080630f, 0.081418f, 0.082520f, 0.083935f, 0.085663f, 0.087703f, 0.090052f, 0.092710f, 0.095674f, 0.098943f, 0.102514f, 0.106385f, 0.110553f, 0.115015f, diff --git a/win32/config.h b/win32/config.h index 2819e58..bdfbbc8 100644 --- a/win32/config.h +++ b/win32/config.h @@ -7,3 +7,6 @@ #ifndef _USE_SSE
# define USE_ALLOCA
#endif
+
+/* Default to floating point */
+#define FLOATING_POINT
|