[xiph-commits] r11104 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Fri Apr 7 08:08:36 PDT 2006


Author: jm
Date: 2006-04-07 08:08:30 -0700 (Fri, 07 Apr 2006)
New Revision: 11104

Added:
   trunk/speex/libspeex/window.c
Modified:
   trunk/speex/libspeex/Makefile.am
   trunk/speex/libspeex/nb_celp.c
   trunk/speex/libspeex/nb_celp.h
   trunk/speex/libspeex/sb_celp.c
   trunk/speex/libspeex/sb_celp.h
Log:
LPC analysis window now stored as constant in code -> 400 bytes off the
encoder state (800 for wideband).


Modified: trunk/speex/libspeex/Makefile.am
===================================================================
--- trunk/speex/libspeex/Makefile.am	2006-04-07 14:44:04 UTC (rev 11103)
+++ trunk/speex/libspeex/Makefile.am	2006-04-07 15:08:30 UTC (rev 11104)
@@ -16,7 +16,7 @@
 				exc_10_16_table.c 	exc_20_32_table.c 	hexc_10_32_table.c 	misc.c 	speex_header.c \
 				speex_callbacks.c 	math_approx.c 	stereo.c 	preprocess.c 	smallft.c 	lbr_48k_tables.c \
 				jitter.c 	mdf.c vorbis_psy.c fftwrap.c kiss_fft.c _kiss_fft_guts.h kiss_fft.h \
-	kiss_fftr.c kiss_fftr.h pcm_wrapper.c
+	kiss_fftr.c kiss_fftr.h pcm_wrapper.c window.c
 
 noinst_HEADERS = lsp.h 	nb_celp.h 	lpc.h 	lpc_bfin.h 	ltp.h 	quant_lsp.h \
 				cb_search.h 	filters.h 	stack_alloc.h 	vq.h 	vq_sse.h 	vq_arm4.h 	vq_bfin.h \

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2006-04-07 14:44:04 UTC (rev 11103)
+++ trunk/speex/libspeex/nb_celp.c	2006-04-07 15:08:30 UTC (rev 11104)
@@ -106,6 +106,8 @@
 
 #define sqr(x) ((x)*(x))
 
+extern const spx_word16_t lpc_window[];
+
 void *nb_encoder_init(const SpeexMode *m)
 {
    EncState *st;
@@ -161,24 +163,8 @@
 
    st->innov = speex_alloc((st->frameSize)*sizeof(spx_sig_t));
 
-   /* Asymmetric "pseudo-Hamming" window */
-   {
-      int part1, part2, part3;
-      part1=st->frameSize-st->subframeSize;
-      part2=st->subframeSize+10;
-      part3=st->subframeSize-10;
-      st->window = speex_alloc((st->windowSize)*sizeof(spx_word16_t));
-      for (i=0;i<part1;i++)
-         st->window[i]=(spx_word16_t)(SIG_SCALING*(.54-.46*cos(M_PI*i/part1)));
-      for (i=0;i<part2;i++)
-         st->window[part1+i]=(spx_word16_t)(SIG_SCALING);
-      for (i=0;i<part3;i++)
-         st->window[part1+part2+i]=(spx_word16_t)(SIG_SCALING*sqrt(.504+.496*cos(M_PI*i/part3)));
-   }
-   /*for (i=0;i<st->windowSize;i++)
-      printf ("%f ", st->window[i]);
-   printf ("\n");
-   exit(0);*/
+   st->window= lpc_window;
+   
    /* Create the window for autocorrelation (lag-windowing) */
    st->lagWindow = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
    for (i=0;i<st->lpcSize+1;i++)
@@ -252,7 +238,6 @@
    speex_free (st->interp_qlsp);
    speex_free (st->swBuf);
 
-   speex_free (st->window);
    speex_free (st->lagWindow);
    speex_free (st->autocorr);
    speex_free (st->lpc);

Modified: trunk/speex/libspeex/nb_celp.h
===================================================================
--- trunk/speex/libspeex/nb_celp.h	2006-04-07 14:44:04 UTC (rev 11103)
+++ trunk/speex/libspeex/nb_celp.h	2006-04-07 15:08:30 UTC (rev 11104)
@@ -85,7 +85,7 @@
    spx_sig_t *swBuf;          /**< Weighted signal buffer */
    spx_sig_t *sw;             /**< Start of weighted signal frame */
    spx_sig_t *innov;          /**< Innovation for the frame */
-   spx_word16_t *window;         /**< Temporary (Hanning) window */
+   const spx_word16_t *window;         /**< Temporary (Hanning) window */
    spx_word16_t *autocorr;       /**< auto-correlation */
    spx_word16_t *lagWindow;      /**< Window applied to auto-correlation */
    spx_coef_t *lpc;            /**< LPCs for current frame */

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2006-04-07 14:44:04 UTC (rev 11103)
+++ trunk/speex/libspeex/sb_celp.c	2006-04-07 15:08:30 UTC (rev 11104)
@@ -201,6 +201,8 @@
 };
 #endif
 
+extern const spx_word16_t lpc_window[];
+
 static void mix_and_saturate(spx_word32_t *x0, spx_word32_t *x1, spx_word16_t *out, int len)
 {
    int i;
@@ -278,20 +280,7 @@
    st->res=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
    st->sw=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
    st->target=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
-   /*Asymmetric "pseudo-Hamming" window*/
-   {
-      int part1, part2, part3;
-      part1=st->frame_size-st->subframeSize;
-      part2=st->subframeSize+10;
-      part3=st->subframeSize-10;
-      st->window = speex_alloc((st->windowSize)*sizeof(spx_word16_t));
-      for (i=0;i<part1;i++)
-         st->window[i]=(spx_word16_t)(SIG_SCALING*(.54-.46*cos(M_PI*i/part1)));
-      for (i=0;i<part2;i++)
-         st->window[part1+i]=(spx_word16_t)(SIG_SCALING);
-      for (i=0;i<part3;i++)
-         st->window[part1+part2+i]=(spx_word16_t)(SIG_SCALING*sqrt(.504+.496*cos(M_PI*i/part3)));
-   }
+   st->window= lpc_window;
 
    st->lagWindow = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
    for (i=0;i<st->lpcSize+1;i++)
@@ -354,7 +343,6 @@
    speex_free(st->res);
    speex_free(st->sw);
    speex_free(st->target);
-   speex_free(st->window);
    speex_free(st->lagWindow);
 
    speex_free(st->autocorr);

Modified: trunk/speex/libspeex/sb_celp.h
===================================================================
--- trunk/speex/libspeex/sb_celp.h	2006-04-07 14:44:04 UTC (rev 11103)
+++ trunk/speex/libspeex/sb_celp.h	2006-04-07 15:08:30 UTC (rev 11104)
@@ -69,7 +69,7 @@
    spx_sig_t *res;                 /**< Zero-input response (ringing) */
    spx_sig_t *sw;                  /**< Perceptually weighted signal */
    spx_sig_t *target;              /**< Weighted target signal (analysis by synthesis) */
-   spx_word16_t *window;              /**< LPC analysis window */
+   const spx_word16_t *window;              /**< LPC analysis window */
    spx_word16_t *lagWindow;           /**< Auto-correlation window */
    spx_word16_t *autocorr;            /**< Auto-correlation (for LPC analysis) */
    spx_coef_t *lpc;                 /**< LPC coefficients */

Added: trunk/speex/libspeex/window.c
===================================================================
--- trunk/speex/libspeex/window.c	2006-04-07 14:44:04 UTC (rev 11103)
+++ trunk/speex/libspeex/window.c	2006-04-07 15:08:30 UTC (rev 11104)
@@ -0,0 +1,94 @@
+/* Copyright (C) 2006 Jean-Marc Valin 
+   File: window.c
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "misc.h"
+
+#ifdef FIXED_POINT
+const spx_word16_t lpc_window[200] = {
+1310, 1313, 1321, 1333, 1352, 1375, 1403, 1436,
+1475, 1518, 1567, 1621, 1679, 1743, 1811, 1884,
+1962, 2044, 2132, 2224, 2320, 2421, 2526, 2636,
+2750, 2868, 2990, 3116, 3246, 3380, 3518, 3659,
+3804, 3952, 4104, 4259, 4417, 4578, 4742, 4909,
+5079, 5251, 5425, 5602, 5781, 5963, 6146, 6331,
+6518, 6706, 6896, 7087, 7280, 7473, 7668, 7863,
+8059, 8256, 8452, 8650, 8847, 9044, 9241, 9438,
+9635, 9831, 10026, 10220, 10414, 10606, 10797, 10987,
+11176, 11363, 11548, 11731, 11912, 12091, 12268, 12443,
+12615, 12785, 12952, 13116, 13277, 13435, 13590, 13742,
+13890, 14035, 14176, 14314, 14448, 14578, 14704, 14826,
+14944, 15058, 15168, 15273, 15374, 15470, 15562, 15649,
+15732, 15810, 15883, 15951, 16015, 16073, 16127, 16175,
+16219, 16257, 16291, 16319, 16342, 16360, 16373, 16381,
+16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
+16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
+16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
+16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
+16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
+16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
+16384, 16384, 16384, 16361, 16294, 16183, 16028, 15830,
+15588, 15304, 14979, 14613, 14207, 13763, 13282, 12766,
+12215, 11631, 11016, 10373, 9702, 9007, 8289, 7551,
+6797, 6028, 5251, 4470, 3695, 2943, 2248, 1696
+};
+#else
+const spx_word16_t lpc_window[200] = {
+   0.080000, 0.080158, 0.080630, 0.081418, 0.082520, 0.083935, 0.085663, 0.087703,
+   0.090052, 0.092710, 0.095674, 0.098943, 0.102514, 0.106385, 0.110553, 0.115015,
+   0.119769, 0.124811, 0.130137, 0.135744, 0.141628, 0.147786, 0.154212, 0.160902,
+   0.167852, 0.175057, 0.182513, 0.190213, 0.198153, 0.206328, 0.214731, 0.223357,
+   0.232200, 0.241254, 0.250513, 0.259970, 0.269619, 0.279453, 0.289466, 0.299651,
+   0.310000, 0.320507, 0.331164, 0.341965, 0.352901, 0.363966, 0.375151, 0.386449,
+   0.397852, 0.409353, 0.420943, 0.432615, 0.444361, 0.456172, 0.468040, 0.479958,
+   0.491917, 0.503909, 0.515925, 0.527959, 0.540000, 0.552041, 0.564075, 0.576091,
+   0.588083, 0.600042, 0.611960, 0.623828, 0.635639, 0.647385, 0.659057, 0.670647,
+   0.682148, 0.693551, 0.704849, 0.716034, 0.727099, 0.738035, 0.748836, 0.759493,
+   0.770000, 0.780349, 0.790534, 0.800547, 0.810381, 0.820030, 0.829487, 0.838746,
+   0.847800, 0.856643, 0.865269, 0.873672, 0.881847, 0.889787, 0.897487, 0.904943,
+   0.912148, 0.919098, 0.925788, 0.932214, 0.938372, 0.944256, 0.949863, 0.955189,
+   0.960231, 0.964985, 0.969447, 0.973615, 0.977486, 0.981057, 0.984326, 0.987290,
+   0.989948, 0.992297, 0.994337, 0.996065, 0.997480, 0.998582, 0.999370, 0.999842,
+   1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+   1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+   1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+   1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+   1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+   1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
+   1.000000, 1.000000, 1.000000, 0.998640, 0.994566, 0.987787, 0.978324, 0.966203,
+   0.951458, 0.934131, 0.914270, 0.891931, 0.867179, 0.840084, 0.810723, 0.779182,
+   0.745551, 0.709930, 0.672424, 0.633148, 0.592223, 0.549781, 0.505964, 0.460932,
+   0.414863, 0.367968, 0.320511, 0.272858, 0.225569, 0.179655, 0.137254, 0.103524
+};
+#endif



More information about the commits mailing list