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

jm at svn.xiph.org jm at svn.xiph.org
Thu Aug 3 02:44:27 PDT 2006


Author: jm
Date: 2006-08-03 02:44:22 -0700 (Thu, 03 Aug 2006)
New Revision: 11730

Modified:
   trunk/speex/libspeex/cb_search.c
   trunk/speex/libspeex/cb_search.h
   trunk/speex/libspeex/modes.h
   trunk/speex/libspeex/nb_celp.c
   trunk/speex/libspeex/sb_celp.c
   trunk/speex/libspeex/testenc.c
Log:
fixed random numbers (were reset on each subframe) in noise codebook unquant.


Modified: trunk/speex/libspeex/cb_search.c
===================================================================
--- trunk/speex/libspeex/cb_search.c	2006-08-03 00:55:52 UTC (rev 11729)
+++ trunk/speex/libspeex/cb_search.c	2006-08-03 09:44:22 UTC (rev 11730)
@@ -514,7 +514,8 @@
 const void *par,                      /* non-overlapping codebook */
 int   nsf,                      /* number of samples in subframe */
 SpeexBits *bits,
-char *stack
+char *stack,
+spx_int32_t *seed
 )
 {
    int i,j;
@@ -601,12 +602,12 @@
 const void *par,                      /* non-overlapping codebook */
 int   nsf,                      /* number of samples in subframe */
 SpeexBits *bits,
-char *stack
+char *stack,
+spx_int32_t *seed
 )
 {
    int i;
    /* FIXME: This is bad, but I don't think the function ever gets called anyway */
-   static spx_int32_t seed = 0;
    for (i=0;i<nsf;i++)
-      exc[i]=SHL32(EXTEND32(speex_rand(1, &seed)),SIG_SHIFT);
+      exc[i]=SHL32(EXTEND32(speex_rand(1, seed)),SIG_SHIFT);
 }

Modified: trunk/speex/libspeex/cb_search.h
===================================================================
--- trunk/speex/libspeex/cb_search.h	2006-08-03 00:55:52 UTC (rev 11729)
+++ trunk/speex/libspeex/cb_search.h	2006-08-03 09:44:22 UTC (rev 11730)
@@ -69,7 +69,8 @@
 const void *par,                /* non-overlapping codebook */
 int   nsf,                      /* number of samples in subframe */
 SpeexBits *bits,
-char *stack
+char *stack,
+spx_int32_t *seed
 );
 
 
@@ -95,7 +96,8 @@
 const void *par,                /* non-overlapping codebook */
 int   nsf,                      /* number of samples in subframe */
 SpeexBits *bits,
-char *stack
+char *stack,
+spx_int32_t *seed
 );
 
 #endif

Modified: trunk/speex/libspeex/modes.h
===================================================================
--- trunk/speex/libspeex/modes.h	2006-08-03 00:55:52 UTC (rev 11729)
+++ trunk/speex/libspeex/modes.h	2006-08-03 09:44:22 UTC (rev 11730)
@@ -69,7 +69,7 @@
                                       spx_sig_t *, spx_word16_t *, SpeexBits *, char *, int, int);
 
 /** Innovation unquantization function */
-typedef void (*innovation_unquant_func)(spx_sig_t *, const void *, int, SpeexBits*, char *);
+typedef void (*innovation_unquant_func)(spx_sig_t *, const void *, int, SpeexBits*, char *, spx_int32_t *);
 
 /** Description of a Speex sub-mode (wither narrowband or wideband */
 typedef struct SpeexSubmode {

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2006-08-03 00:55:52 UTC (rev 11729)
+++ trunk/speex/libspeex/nb_celp.c	2006-08-03 09:44:22 UTC (rev 11730)
@@ -1593,7 +1593,7 @@
          if (SUBMODE(innovation_unquant))
          {
             /*Fixed codebook contribution*/
-            SUBMODE(innovation_unquant)(innov, SUBMODE(innovation_params), st->subframeSize, bits, stack);
+            SUBMODE(innovation_unquant)(innov, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed);
          } else {
             speex_error("No fixed codebook");
          }
@@ -1653,7 +1653,7 @@
             ALLOC(innov2, st->subframeSize, spx_sig_t);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]=0;
-            SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, stack);
+            SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed);
             signal_mul(innov2, innov2, MULT16_32_Q15(QCONST16(0.454545,15),ener), st->subframeSize);
             for (i=0;i<st->subframeSize;i++)
                exc[i] = ADD16(exc[i],PSHR32(innov2[i],SIG_SHIFT));

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2006-08-03 00:55:52 UTC (rev 11729)
+++ trunk/speex/libspeex/sb_celp.c	2006-08-03 09:44:22 UTC (rev 11730)
@@ -1195,7 +1195,7 @@
          scale = SHL(MULT16_16(PDIV32_16(SHL(gc,SIG_SHIFT-6),filter_ratio),(1+el)),6);
 
          SUBMODE(innovation_unquant)(exc, SUBMODE(innovation_params), st->subframeSize, 
-                                bits, stack);
+                                     bits, stack, &st->seed);
 
          signal_mul(exc,exc,scale,st->subframeSize);
 
@@ -1206,7 +1206,7 @@
             for (i=0;i<st->subframeSize;i++)
                innov2[i]=0;
             SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, 
-                                bits, stack);
+                                        bits, stack, &st->seed);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]*=scale/(float)SIG_SCALING*(1/2.5);
             for (i=0;i<st->subframeSize;i++)

Modified: trunk/speex/libspeex/testenc.c
===================================================================
--- trunk/speex/libspeex/testenc.c	2006-08-03 00:55:52 UTC (rev 11729)
+++ trunk/speex/libspeex/testenc.c	2006-08-03 09:44:22 UTC (rev 11730)
@@ -38,6 +38,7 @@
    st = speex_encoder_init(&speex_nb_mode);
    dec = speex_decoder_init(&speex_nb_mode);
 
+   /* BEGIN: You probably don't need the following in a real application */
    callback.callback_id = SPEEX_INBAND_CHAR;
    callback.func = speex_std_char_handler;
    callback.data = stderr;
@@ -47,6 +48,7 @@
    callback.func = speex_std_mode_request_handler;
    callback.data = st;
    speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
+   /* END of unnecessary stuff */
 
    tmp=1;
    speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
@@ -57,6 +59,11 @@
    tmp=1;
    speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
 
+   /* Turn this off if you want to measure SNR (on by default) */
+   tmp=1;
+   speex_encoder_ctl(st, SPEEX_SET_HIGHPASS, &tmp);
+   speex_decoder_ctl(dec, SPEEX_SET_HIGHPASS, &tmp);
+
    speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &skip_group_delay);
    speex_decoder_ctl(dec, SPEEX_GET_LOOKAHEAD, &tmp);
    skip_group_delay += tmp;
@@ -102,6 +109,7 @@
    speex_decoder_destroy(dec);
    speex_bits_destroy(&bits);
 
+   /* This code just computes SNR, so you don't need it either */
    rewind(fin);
    rewind(fout);
 



More information about the commits mailing list