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

jm at svn.xiph.org jm at svn.xiph.org
Wed Jan 3 05:38:04 PST 2007


Author: jm
Date: 2007-01-03 05:37:59 -0800 (Wed, 03 Jan 2007)
New Revision: 12294

Modified:
   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:
Only the RMS of the excitation is saved in the encoder -- 320 bytes off the 
wideband encoder state.


Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2007-01-03 05:16:04 UTC (rev 12293)
+++ trunk/speex/libspeex/nb_celp.c	2007-01-03 13:37:59 UTC (rev 12294)
@@ -187,7 +187,7 @@
    st->mem_exc2 = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
 
    st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
-   st->innov_save = NULL;
+   st->innov_rms_save = NULL;
    
    st->pitch = (int*)speex_alloc((st->nbSubframes)*sizeof(int));
 
@@ -722,7 +722,6 @@
       int   offset;
       spx_word16_t *sw;
       spx_word16_t *exc;
-      spx_word16_t *innov_save = NULL;
       int pitch;
       int response_bound = st->subframeSize;
 #ifdef EPIC_48K
@@ -741,9 +740,6 @@
       exc=st->exc+offset;
       /* Weighted signal */
       sw=st->sw+offset;
-      /* Pointer for saving innovation */
-      if (st->innov_save)
-         innov_save = st->innov_save+offset;
       
       /* LSP interpolation (quantized and unquantized) */
       lsp_interpolate(st->old_lsp, lsp, interp_lsp, st->lpcSize, sub, st->nbSubframes);
@@ -980,10 +976,9 @@
          }
          for (i=0;i<st->subframeSize;i++)
             exc[i] = EXTRACT16(SATURATE32(PSHR32(ADD32(SHL32(exc32[i],1),innov[i]),SIG_SHIFT),32767));
-         if (innov_save)
+         if (st->innov_rms_save)
          {
-            for (i=0;i<st->subframeSize;i++)
-               innov_save[i] = EXTRACT16(PSHR32(innov[i],SIG_SHIFT));
+            st->innov_rms_save[sub] = compute_rms(innov, st->subframeSize);
          }
       } else {
          speex_error("No fixed codebook");
@@ -1924,7 +1919,7 @@
       (*(float*)ptr)=st->relative_quality;
       break;
    case SPEEX_SET_INNOVATION_SAVE:
-      st->innov_save = (spx_word16_t*)ptr;
+      st->innov_rms_save = (spx_word16_t*)ptr;
       break;
    case SPEEX_SET_WIDEBAND:
       st->isWideband = *((spx_int32_t*)ptr);

Modified: trunk/speex/libspeex/nb_celp.h
===================================================================
--- trunk/speex/libspeex/nb_celp.h	2007-01-03 05:16:04 UTC (rev 12293)
+++ trunk/speex/libspeex/nb_celp.h	2007-01-03 13:37:59 UTC (rev 12294)
@@ -96,7 +96,7 @@
    spx_mem_t *mem_exc2;          /**< Filter memory for excitation (whole frame) */
    spx_mem_t mem_hp[2];          /**< High-pass filter memory */
    spx_word32_t *pi_gain;        /**< Gain of LPC filter at theta=pi (fe/2) */
-   spx_word16_t *innov_save;        /**< If non-NULL, innovation is copied here */
+   spx_word16_t *innov_rms_save; /**< If non-NULL, innovation RMS is copied here */
          
    VBRState *vbr;                /**< State of the VBR data */
    float  vbr_quality;           /**< Quality setting for VBR encoding */

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2007-01-03 05:16:04 UTC (rev 12293)
+++ trunk/speex/libspeex/sb_celp.c	2007-01-03 13:37:59 UTC (rev 12294)
@@ -250,9 +250,7 @@
    st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
    st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
    st->exc_rms = (spx_word16_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word16_t));
-   st->low_innov = (spx_word16_t*)speex_alloc((st->frame_size)*sizeof(spx_word16_t));
-   speex_encoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, st->low_innov);
-   st->innov_save = NULL;
+   st->innov_rms_save = NULL;
    
    st->mem_sp = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
    st->mem_sp2 = (spx_mem_t*)speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
@@ -310,7 +308,6 @@
    speex_free(st->interp_qlpc);
    speex_free(st->pi_gain);
    speex_free(st->exc_rms);
-   speex_free(st->low_innov);
 
    speex_free(st->mem_sp);
    speex_free(st->mem_sp2);
@@ -334,6 +331,7 @@
    spx_word16_t *low;
    spx_word16_t *high;
    VARDECL(spx_word16_t *low_exc_rms);
+   VARDECL(spx_word16_t *low_innov_rms);
    const SpeexSBMode *mode;
    spx_int32_t dtx;
    spx_word16_t *in = (spx_word16_t*)vin;
@@ -356,6 +354,8 @@
       e_low = compute_rms16(low, st->frame_size);
       e_high = compute_rms16(high, st->frame_size);
    }
+   ALLOC(low_innov_rms, st->nbSubframes, spx_word16_t);
+   speex_encoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, low_innov_rms);
    /* Encode the narrowband part*/
    speex_encode_native(st->st_low, low, bits);
 
@@ -545,7 +545,6 @@
       VARDECL(spx_word16_t *res);
       VARDECL(spx_word16_t *sw);
       spx_word16_t *sp;
-      spx_word16_t *innov_save=NULL;
       spx_word16_t filter_ratio;     /*Q7*/
       int offset;
       spx_word32_t rl, rh;           /*Q13*/
@@ -556,13 +555,6 @@
       ALLOC(exc, st->subframeSize, spx_word16_t);
       ALLOC(res, st->subframeSize, spx_word16_t);
       ALLOC(sw, st->subframeSize, spx_word16_t);
-      /* Pointer for saving innovation */
-      if (st->innov_save)
-      {
-         innov_save = st->innov_save+2*offset;
-         for (i=0;i<2*st->subframeSize;i++)
-            innov_save[i]=0;
-      }
       
       /* LSP interpolation (quantized and unquantized) */
       lsp_interpolate(st->old_lsp, st->lsp, st->interp_lsp, st->lpcSize, sub, st->nbSubframes);
@@ -603,7 +595,7 @@
       if (!SUBMODE(innovation_quant)) {/* 1 for spectral folding excitation, 0 for stochastic */
          spx_word32_t g;   /*Q7*/
          spx_word16_t el;  /*Q0*/
-         el = compute_rms16(st->low_innov+offset, st->subframeSize);
+         el = low_innov_rms[sub];
 
          /* Gain to use if we want to use the low-band excitation for high-band */
          g=PDIV32(MULT16_16(filter_ratio,eh),EXTEND32(ADD16(1,el)));
@@ -718,10 +710,9 @@
          for (i=0;i<st->subframeSize;i++)
             exc[i] = PSHR32(innov[i],SIG_SHIFT);
 
-         if (st->innov_save)
+         if (st->innov_rms_save)
          {
-            for (i=0;i<st->subframeSize;i++)
-               innov_save[2*i]=EXTRACT16(SHR32(innov[i],SIG_SHIFT));
+            st->innov_rms_save[sub] = MULT16_16_Q15(QCONST16(.70711f, 15), compute_rms(innov, st->subframeSize));
          }
          
 
@@ -1337,7 +1328,7 @@
       (*(float*)ptr)=st->relative_quality;
       break;
    case SPEEX_SET_INNOVATION_SAVE:
-      st->innov_save = (spx_word16_t*)ptr;
+      st->innov_rms_save = (spx_word16_t*)ptr;
       break;
    case SPEEX_SET_WIDEBAND:
       speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);

Modified: trunk/speex/libspeex/sb_celp.h
===================================================================
--- trunk/speex/libspeex/sb_celp.h	2007-01-03 05:16:04 UTC (rev 12293)
+++ trunk/speex/libspeex/sb_celp.h	2007-01-03 13:37:59 UTC (rev 12294)
@@ -81,8 +81,7 @@
    spx_mem_t *mem_sw;             /**< Perceptual signal memory */
    spx_word32_t *pi_gain;
    spx_word16_t *exc_rms;
-   spx_word16_t *innov_save;         /**< If non-NULL, innovation is copied here */
-   spx_word16_t *low_innov;          /**< Lower-band innovation is copied here magically */
+   spx_word16_t *innov_rms_save;         /**< If non-NULL, innovation is copied here */
 
    float  vbr_quality;            /**< Quality setting for VBR encoding */
    int    vbr_enabled;            /**< 1 for enabling VBR, 0 otherwise */



More information about the commits mailing list