[xiph-cvs] cvs commit: speex/libspeex cb_search.c filters.c misc.h nb_celp.c

Jean-Marc Valin jm at xiph.org
Tue Oct 7 21:35:49 PDT 2003



jm          03/10/08 00:35:48

  Modified:    libspeex cb_search.c filters.c misc.h nb_celp.c
  Log:
  fixed-point: signals scaling

Revision  Changes    Path
1.89      +6 -1      speex/libspeex/cb_search.c

Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- cb_search.c	8 Oct 2003 04:35:01 -0000	1.88
+++ cb_search.c	8 Oct 2003 04:35:48 -0000	1.89
@@ -344,8 +344,13 @@
       float s=1;
       if (signs[i])
          s=-1;
+#ifdef FIXED_POINT
       for (j=0;j<subvect_size;j++)
-         exc[subvect_size*i+j]+=s*0.03125*shape_cb[ind[i]*subvect_size+j];
+         exc[subvect_size*i+j]+=s*0.03125*SIG_SCALING*shape_cb[ind[i]*subvect_size+j];
+#else
+      for (j=0;j<subvect_size;j++)
+         exc[subvect_size*i+j]+=s*0.03125*shape_cb[ind[i]*subvect_size+j];      
+#endif
    }
 }
 

<p><p>1.37      +20 -6     speex/libspeex/filters.c

Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- filters.c	8 Oct 2003 04:33:36 -0000	1.36
+++ filters.c	8 Oct 2003 04:35:48 -0000	1.37
@@ -50,6 +50,8 @@
 #ifdef FIXED_POINT
 
 
+int fixed_point_on = 0;
+
 #define MUL_16_32_R15(a,bh,bl) ((a)*(bh) + ((a)*(bl)>>15))
 
 
@@ -58,10 +60,14 @@
    int i,j;
    int xi,yi;
 
+   float local_scale = 1;
+   if (!fixed_point_on)
+      local_scale = 16384.;
+
    for (i=0;i<N;i++)
    {
       int xh,xl,yh,yl;
-      xi=floor(.5+16384*x[i]);
+      xi=floor(.5+local_scale*x[i]);
       yi = xi + (mem[0]<<2);
       xh = xi>>15; xl=xi&0x00007fff; yh = yi>>15; yl=yi&0x00007fff; 
       for (j=0;j<ord-1;j++)
@@ -69,7 +75,7 @@
          mem[j] = mem[j+1] +  MUL_16_32_R15(num[j+1],xh,xl) - MUL_16_32_R15(den[j+1],yh,yl);
       }
       mem[ord-1] = MUL_16_32_R15(num[ord],xh,xl) - MUL_16_32_R15(den[ord],yh,yl);
-      y[i] = yi*(1.f/16384.f);
+      y[i] = yi*(1.f/local_scale);
    }
 }
 
@@ -77,11 +83,15 @@
 {
    int i,j;
    int xi,yi;
+
+   float local_scale = 1;
+   if (!fixed_point_on)
+      local_scale = 16384.;
    
    for (i=0;i<N;i++)
    {
       int yh,yl;
-      xi=floor(.5+16384*x[i]);
+      xi=floor(.5+local_scale*x[i]);
       yi = xi + (mem[0]<<2);
       yh = yi>>15; yl=yi&0x00007fff; 
       for (j=0;j<ord-1;j++)
@@ -89,7 +99,7 @@
          mem[j] = mem[j+1] - MUL_16_32_R15(den[j+1],yh,yl);
       }
       mem[ord-1] = - MUL_16_32_R15(den[ord],yh,yl);
-      y[i] = yi*(1.f/16384.f);
+      y[i] = yi*(1.f/local_scale);
    }
 }
 
@@ -99,10 +109,14 @@
    int i,j;
    int xi,yi;
 
+   float local_scale = 1;
+   if (!fixed_point_on)
+      local_scale = 16384.;
+
    for (i=0;i<N;i++)
    {
       int xh,xl;
-      xi=floor(.5+16384*x[i]);
+      xi=floor(.5+local_scale*x[i]);
       yi = xi + (mem[0]<<2);
       xh = xi>>15; xl=xi&0x00007fff;
       for (j=0;j<ord-1;j++)
@@ -110,7 +124,7 @@
          mem[j] = mem[j+1] +  MUL_16_32_R15(num[j+1],xh,xl);
       }
       mem[ord-1] = MUL_16_32_R15(num[ord],xh,xl);
-      y[i] = yi*(1.f/16384.f);
+      y[i] = yi*(1.f/local_scale);
    }
 
 }

<p><p>1.27      +9 -1      speex/libspeex/misc.h

Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- misc.h	8 Oct 2003 04:35:01 -0000	1.26
+++ misc.h	8 Oct 2003 04:35:48 -0000	1.27
@@ -41,6 +41,10 @@
 
 #ifdef FIXED_POINT
 
+extern int fixed_point_on;
+#define FIXED_SIGNAL fixed_point_on=1;
+#define FLOAT_SIGNAL fixed_point_on=0;
+
 typedef short        spx_word16_t;
 typedef int          spx_word32_t;
 typedef spx_word32_t spx_mem_t;
@@ -48,6 +52,7 @@
 typedef float   spx_sig_t;
 
 #define LPC_SCALING  8192.
+#define SIG_SCALING  16384.
 
 #define MULT16_32_Q14(a,b) (((a)*((b)>>14)) + ((a)*((signed int)((b)&0x00003fff))>>14))
 #define MULT16_32_Q15(a,b) (((a)*((b)>>15)) + ((a)*((signed int)((b)&0x00007fff))>>15))
@@ -63,6 +68,9 @@
 
 #else
 
+#define FIXED_SIGNAL
+#define FLOAT_SIGNAL
+
 typedef float spx_mem_t;
 typedef float spx_coef_t;
 typedef float spx_sig_t;
@@ -70,7 +78,7 @@
 typedef float spx_word32_t;
 
 #define LPC_SCALING  1.
-
+#define SIG_SCALING  1.
 #endif
 
 #ifndef RELEASE

<p><p>1.128     +6 -2      speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- nb_celp.c	8 Oct 2003 04:35:01 -0000	1.127
+++ nb_celp.c	8 Oct 2003 04:35:48 -0000	1.128
@@ -1545,7 +1545,7 @@
             while (st->voc_offset<st->subframeSize)
             {
                if (st->voc_offset>=0)
-                  exc[st->voc_offset]=sqrt(1.0*ol_pitch);
+                  exc[st->voc_offset]=SIG_SCALING*sqrt(1.0*ol_pitch);
                st->voc_offset+=ol_pitch;
             }
             st->voc_offset -= st->subframeSize;
@@ -1591,6 +1591,8 @@
       if (st->lpc_enh_enabled && SUBMODE(comb_gain)>0)
          comb_filter(exc, sp, st->interp_qlpc, st->lpcSize, st->subframeSize,
                               pitch, pitch_gain, SUBMODE(comb_gain), st->comb_mem);
+      FIXED_SIGNAL;
+
       if (st->lpc_enh_enabled)
       {
          /* Use enhanced LPC filter */
@@ -1605,11 +1607,13 @@
          iir_mem2(sp, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, 
                      st->mem_sp);
       }
+
+      FLOAT_SIGNAL;
    }
    
    /*Copy output signal*/
    for (i=0;i<st->frameSize;i++)
-     out[i]=st->frame[i];
+     out[i]=st->frame[i]/SIG_SCALING;
 
    /* Store the LSPs for interpolation in the next frame */
    for (i=0;i<st->lpcSize;i++)

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list