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

jm at svn.xiph.org jm at svn.xiph.org
Thu Nov 30 04:23:42 PST 2006


Author: jm
Date: 2006-11-30 04:23:37 -0800 (Thu, 30 Nov 2006)
New Revision: 12158

Modified:
   trunk/speex/libspeex/fixed_debug.h
   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:
Saved innovation from nb to wb is now 16-bit precision.


Modified: trunk/speex/libspeex/fixed_debug.h
===================================================================
--- trunk/speex/libspeex/fixed_debug.h	2006-11-30 12:05:59 UTC (rev 12157)
+++ trunk/speex/libspeex/fixed_debug.h	2006-11-30 12:23:37 UTC (rev 12158)
@@ -169,17 +169,18 @@
 //#define SHR(a,shift) ((a) >> (shift))
 //#define SHL(a,shift) ((a) << (shift))
 
-static inline short ADD16(int a, int b) 
+#define ADD16(a, b) _ADD16(a, b, __FILE__, __LINE__)
+static inline short _ADD16(int a, int b, char *file, int line) 
 {
    int res;
    if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
    {
-      fprintf (stderr, "ADD16: inputs are not short: %d %d\n", a, b);
+      fprintf (stderr, "ADD16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line);
    }
    res = a+b;
    if (!VERIFY_SHORT(res))
    {
-     fprintf (stderr, "ADD16: output is not short: %d+%d=%d\n", a,b,res);
+      fprintf (stderr, "ADD16: output is not short: %d+%d=%d in %s: line %d\n", a,b,res, file, line);
    }
    spx_mips++;
    return res;

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2006-11-30 12:05:59 UTC (rev 12157)
+++ trunk/speex/libspeex/nb_celp.c	2006-11-30 12:23:37 UTC (rev 12158)
@@ -720,7 +720,7 @@
       int   offset;
       spx_word16_t *sw;
       spx_word16_t *exc;
-      spx_sig_t *innov_save = NULL;
+      spx_word16_t *innov_save = NULL;
       int pitch;
       int response_bound = st->subframeSize;
 #ifdef EPIC_48K
@@ -969,7 +969,7 @@
          if (innov_save)
          {
             for (i=0;i<st->subframeSize;i++)
-               innov_save[i] = innov[i];
+               innov_save[i] = EXTRACT16(PSHR32(innov[i],SIG_SHIFT));
          }
          /* In some (rare) modes, we do a second search (more bits) to reduce noise even more */
          if (SUBMODE(double_codebook)) {
@@ -989,7 +989,7 @@
             if (innov_save)
             {
                for (i=0;i<st->subframeSize;i++)
-                  innov_save[i] = ADD32(innov_save[i],innov2[i]);
+                  innov_save[i] = ADD16(innov_save[i],EXTRACT16(PSHR32(innov2[i],SIG_SHIFT)));
             }
             stack = tmp_stack;
          }
@@ -1460,7 +1460,7 @@
       int offset;
       spx_word16_t *exc;
       spx_word16_t *sp;
-      spx_sig_t *innov_save = NULL;
+      spx_word16_t *innov_save = NULL;
       spx_word16_t tmp;
 
 #ifdef EPIC_48K
@@ -1627,7 +1627,7 @@
          if (innov_save)
          {
             for (i=0;i<st->subframeSize;i++)
-               innov_save[i] = innov[i];
+               innov_save[i] = EXTRACT16(PSHR32(innov[i], SIG_SHIFT));
          }
          /* Decode second codebook (only for some modes) */
          if (SUBMODE(double_codebook))
@@ -1644,7 +1644,7 @@
             if (innov_save)
             {
                for (i=0;i<st->subframeSize;i++)
-                  innov_save[i] = ADD32(innov_save[i],innov2[i]);
+                  innov_save[i] = ADD16(innov_save[i],EXTRACT16(PSHR32(innov2[i], SIG_SHIFT)));
             }
             stack = tmp_stack;
          }
@@ -1936,7 +1936,7 @@
       (*(float*)ptr)=st->relative_quality;
       break;
    case SPEEX_SET_INNOVATION_SAVE:
-      st->innov_save = (spx_sig_t*)ptr;
+      st->innov_save = (spx_word16_t*)ptr;
       break;
    case SPEEX_SET_WIDEBAND:
       st->isWideband = *((spx_int32_t*)ptr);
@@ -2044,7 +2044,7 @@
       *((spx_int32_t*)ptr) = st->dtx_enabled;
       break;
    case SPEEX_SET_INNOVATION_SAVE:
-      st->innov_save = (spx_sig_t*)ptr;
+      st->innov_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	2006-11-30 12:05:59 UTC (rev 12157)
+++ trunk/speex/libspeex/nb_celp.h	2006-11-30 12:23:37 UTC (rev 12158)
@@ -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_sig_t *innov_save;        /**< If non-NULL, innovation is copied here */
+   spx_word16_t *innov_save;        /**< If non-NULL, innovation is copied here */
          
    VBRState *vbr;                /**< State of the VBR data */
    float  vbr_quality;           /**< Quality setting for VBR encoding */
@@ -148,7 +148,7 @@
    spx_mem_t *mem_sp;           /**< Filter memory for synthesis signal */
    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_sig_t *innov_save;       /** If non-NULL, innovation is copied here */
+   spx_word16_t *innov_save;       /** If non-NULL, innovation is copied here */
    
    /* This is used in packet loss concealment */
    int    last_pitch;           /**< Pitch of last correctly decoded frame */

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2006-11-30 12:05:59 UTC (rev 12157)
+++ trunk/speex/libspeex/sb_celp.c	2006-11-30 12:23:37 UTC (rev 12158)
@@ -243,7 +243,7 @@
    st->interp_lpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t));
    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->low_innov = (spx_word32_t*)speex_alloc((st->frame_size)*sizeof(spx_word32_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;
    
@@ -537,7 +537,8 @@
 
    for (sub=0;sub<st->nbSubframes;sub++)
    {
-      spx_sig_t *exc, *sp, *res, *sw, *innov_save=NULL;
+      spx_sig_t *exc, *sp, *res, *sw;
+      spx_word16_t *innov_save=NULL;
       spx_word16_t filter_ratio;
       int offset;
       spx_word32_t rl, rh;
@@ -595,7 +596,7 @@
       if (!SUBMODE(innovation_quant)) {/* 1 for spectral folding excitation, 0 for stochastic */
          float g;
          spx_word16_t el;
-         el = compute_rms(st->low_innov+offset, st->subframeSize);
+         el = compute_rms16(st->low_innov+offset, st->subframeSize);
 
          /* Gain to use if we want to use the low-band excitation for high-band */
          g=eh/(1.+el);
@@ -818,7 +819,7 @@
    st->pi_gain = (spx_word32_t*)speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
    st->mem_sp = (spx_mem_t*)speex_alloc((2*st->lpcSize)*sizeof(spx_mem_t));
    
-   st->low_innov = (spx_word32_t*)speex_alloc((st->frame_size)*sizeof(spx_word32_t));
+   st->low_innov = (spx_word16_t*)speex_alloc((st->frame_size)*sizeof(spx_word16_t));
    speex_decoder_ctl(st->st_low, SPEEX_SET_INNOVATION_SAVE, st->low_innov);
    st->innov_save = NULL;
 
@@ -1003,7 +1004,8 @@
 
    for (sub=0;sub<st->nbSubframes;sub++)
    {
-      spx_sig_t *exc, *innov_save=NULL;
+      spx_sig_t *exc;
+      spx_word16_t *innov_save=NULL;
       spx_word16_t *sp;
       spx_word16_t filter_ratio;
       spx_word16_t el=0;
@@ -1077,7 +1079,7 @@
             {
                float e=tmp*g*mode->folding_gain*st->low_innov[offset+i];
                tmp *= -1;
-               exc[i] = e;
+               exc[i] = SIG_SCALING*e;
                /*float r = speex_rand(g*el,&seed);
                exc[i] = .5*(r+tmp2 + e-tmp1);
                tmp1 = e;
@@ -1402,7 +1404,7 @@
       (*(float*)ptr)=st->relative_quality;
       break;
    case SPEEX_SET_INNOVATION_SAVE:
-      st->innov_save = (spx_sig_t*)ptr;
+      st->innov_save = (spx_word16_t*)ptr;
       break;
    case SPEEX_SET_WIDEBAND:
       speex_encoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);
@@ -1537,7 +1539,7 @@
       speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, ptr);
       break;
    case SPEEX_SET_INNOVATION_SAVE:
-      st->innov_save = (spx_sig_t*)ptr;
+      st->innov_save = (spx_word16_t*)ptr;
       break;
    case SPEEX_SET_WIDEBAND:
       speex_decoder_ctl(st->st_low, SPEEX_SET_WIDEBAND, ptr);

Modified: trunk/speex/libspeex/sb_celp.h
===================================================================
--- trunk/speex/libspeex/sb_celp.h	2006-11-30 12:05:59 UTC (rev 12157)
+++ trunk/speex/libspeex/sb_celp.h	2006-11-30 12:23:37 UTC (rev 12158)
@@ -86,8 +86,8 @@
    spx_mem_t *mem_sp2;
    spx_mem_t *mem_sw;             /**< Perceptual signal memory */
    spx_word32_t *pi_gain;
-   spx_sig_t *innov_save;         /**< If non-NULL, innovation is copied here */
-   spx_sig_t *low_innov;          /**< Lower-band innovation is copied here magically */
+   spx_word16_t *innov_save;         /**< If non-NULL, innovation is copied here */
+   spx_word16_t *low_innov;          /**< Lower-band innovation is copied here magically */
 
    float  vbr_quality;            /**< Quality setting for VBR encoding */
    int    vbr_enabled;            /**< 1 for enabling VBR, 0 otherwise */
@@ -135,8 +135,8 @@
 
    spx_mem_t *mem_sp;
    spx_word32_t *pi_gain;
-   spx_sig_t *innov_save;      /** If non-NULL, innovation is copied here */
-   spx_sig_t *low_innov;       /** Lower-band innovation is copied here magically */
+   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_int32_t seed;
 



More information about the commits mailing list