[xiph-commits] r14122 - in trunk/speex: . libspeex win32

jm at svn.xiph.org jm at svn.xiph.org
Sat Nov 10 02:59:13 PST 2007


Author: jm
Date: 2007-11-10 02:59:13 -0800 (Sat, 10 Nov 2007)
New Revision: 14122

Modified:
   trunk/speex/TODO
   trunk/speex/configure.ac
   trunk/speex/libspeex/arch.h
   trunk/speex/libspeex/modes.c
   trunk/speex/libspeex/modes.h
   trunk/speex/libspeex/modes_wb.c
   trunk/speex/libspeex/nb_celp.c
   trunk/speex/libspeex/nb_celp.h
   trunk/speex/libspeex/sb_celp.c
   trunk/speex/libspeex/sb_celp.h
   trunk/speex/libspeex/window.c
   trunk/speex/win32/config.h
Log:
Lag window now stored as const data instead of computed at init time. Also,
force either FIXED_POINT or FLOATING_POINT to be defined so we can catch
a missing config.h


Modified: trunk/speex/TODO
===================================================================
--- trunk/speex/TODO	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/TODO	2007-11-10 10:59:13 UTC (rev 14122)
@@ -4,6 +4,8 @@
 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:

Modified: trunk/speex/configure.ac
===================================================================
--- trunk/speex/configure.ac	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/configure.ac	2007-11-10 10:59:13 UTC (rev 14122)
@@ -96,12 +96,6 @@
 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 @@
 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

Modified: trunk/speex/libspeex/arch.h
===================================================================
--- trunk/speex/libspeex/arch.h	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/libspeex/arch.h	2007-11-10 10:59:13 UTC (rev 14122)
@@ -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

Modified: trunk/speex/libspeex/modes.c
===================================================================
--- trunk/speex/libspeex/modes.c	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/libspeex/modes.c	2007-11-10 10:59:13 UTC (rev 14122)
@@ -328,7 +328,6 @@
 #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},

Modified: trunk/speex/libspeex/modes.h
===================================================================
--- trunk/speex/libspeex/modes.h	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/libspeex/modes.h	2007-11-10 10:59:13 UTC (rev 14122)
@@ -123,7 +123,6 @@
 
    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 @@
    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;
 

Modified: trunk/speex/libspeex/modes_wb.c
===================================================================
--- trunk/speex/libspeex/modes_wb.c	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/libspeex/modes_wb.c	2007-11-10 10:59:13 UTC (rev 14122)
@@ -187,7 +187,6 @@
 #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 @@
 #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},

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/libspeex/nb_celp.c	2007-11-10 10:59:13 UTC (rev 14122)
@@ -108,6 +108,7 @@
 
 #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 @@
    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 @@
    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 @@
    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);

Modified: trunk/speex/libspeex/nb_celp.h
===================================================================
--- trunk/speex/libspeex/nb_celp.h	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/libspeex/nb_celp.h	2007-11-10 10:59:13 UTC (rev 14122)
@@ -73,7 +73,6 @@
 
    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 @@
    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 */

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/libspeex/sb_celp.c	2007-11-10 10:59:13 UTC (rev 14122)
@@ -183,6 +183,7 @@
 
 #endif
 
+extern const spx_word16_t lag_window[];
 extern const spx_word16_t lpc_window[];
 
 
@@ -224,7 +225,6 @@
    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 @@
 
    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 @@
    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);

Modified: trunk/speex/libspeex/sb_celp.h
===================================================================
--- trunk/speex/libspeex/sb_celp.h	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/libspeex/sb_celp.h	2007-11-10 10:59:13 UTC (rev 14122)
@@ -51,7 +51,6 @@
    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 @@
    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 */

Modified: trunk/speex/libspeex/window.c
===================================================================
--- trunk/speex/libspeex/window.c	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/libspeex/window.c	2007-11-10 10:59:13 UTC (rev 14122)
@@ -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 @@
 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,

Modified: trunk/speex/win32/config.h
===================================================================
--- trunk/speex/win32/config.h	2007-11-10 04:02:00 UTC (rev 14121)
+++ trunk/speex/win32/config.h	2007-11-10 10:59:13 UTC (rev 14122)
@@ -7,3 +7,6 @@
 #ifndef _USE_SSE
 #  define USE_ALLOCA
 #endif
+
+/* Default to floating point */
+#define FLOATING_POINT



More information about the commits mailing list