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

Jean-Marc Valin jm at xiph.org
Mon Nov 10 00:57:29 PST 2003



jm          03/11/10 03:57:28

  Modified:    libspeex filters.c lsp.c misc.h nb_celp.c
  Log:
  fixed-point: converted lsp_enforce_margin, some assembly ARM optimizations

Revision  Changes    Path
1.56      +6 -6      speex/libspeex/filters.c

Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- filters.c	10 Nov 2003 06:27:59 -0000	1.55
+++ filters.c	10 Nov 2003 08:57:27 -0000	1.56
@@ -181,9 +181,9 @@
       xh = xi>>15; xl=xi&0x00007fff; yh = yi>>15; yl=yi&0x00007fff; 
       for (j=0;j<ord-1;j++)
       {
-         mem[j] = SUB32(ADD32(mem[j+1],  MUL_16_32_R15(num[j+1],xh,xl)), MUL_16_32_R15(den[j+1],yh,yl));
+         mem[j] = SUB32(ADD32(mem[j+1],  MULT16_32_Q15(num[j+1],xi)), MULT16_32_Q15(den[j+1],yi));
       }
-      mem[ord-1] = SUB32(MUL_16_32_R15(num[ord],xh,xl), MUL_16_32_R15(den[ord],yh,yl));
+      mem[ord-1] = SUB32(MULT16_32_Q15(num[ord],xi), MULT16_32_Q15(den[ord],yi));
       y[i] = yi;
    }
 }
@@ -201,9 +201,9 @@
       yh = yi>>15; yl=yi&0x00007fff; 
       for (j=0;j<ord-1;j++)
       {
-         mem[j] = SUB32(mem[j+1], MUL_16_32_R15(den[j+1],yh,yl));
+         mem[j] = SUB32(mem[j+1], MULT16_32_Q15(den[j+1],yi));
       }
-      mem[ord-1] = - MUL_16_32_R15(den[ord],yh,yl);
+      mem[ord-1] = - MULT16_32_Q15(den[ord],yi);
       y[i] = yi;
    }
 }
@@ -222,9 +222,9 @@
       xh = xi>>15; xl=xi&0x00007fff;
       for (j=0;j<ord-1;j++)
       {
-         mem[j] = ADD32(mem[j+1], MUL_16_32_R15(num[j+1],xh,xl));
+         mem[j] = ADD32(mem[j+1], MULT16_32_Q15(num[j+1],xi));
       }
-      mem[ord-1] = MUL_16_32_R15(num[ord],xh,xl);
+      mem[ord-1] = MULT16_32_Q15(num[ord],xi);
       y[i] = yi;
    }
 

<p><p>1.42      +34 -12    speex/libspeex/lsp.c

Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- lsp.c	10 Nov 2003 06:56:53 -0000	1.41
+++ lsp.c	10 Nov 2003 08:57:27 -0000	1.42
@@ -506,27 +506,30 @@
 }
 #endif
 
-/*Added by JMV
-  Makes sure the LSPs are stable*/
+
+#ifdef FIXED_POINT
+
+/*Makes sure the LSPs are stable*/
 void lsp_enforce_margin(spx_lsp_t *lsp, int len, float margin)
 {
    int i;
-   if (lsp[0]<LSP_SCALING*margin)
-      lsp[0]=LSP_SCALING*margin;
-   if (lsp[len-1]>LSP_SCALING*(M_PI-margin))
-      lsp[len-1]=LSP_SCALING*(M_PI-margin);
+   spx_word16_t m = LSP_SCALING*margin;
+   spx_word16_t m2 = (LSP_SCALING*M_PI)-LSP_SCALING*margin;
+  
+   if (lsp[0]<m)
+      lsp[0]=m;
+   if (lsp[len-1]>m2)
+      lsp[len-1]=m2;
    for (i=1;i<len-1;i++)
    {
-      if (lsp[i]<lsp[i-1]+LSP_SCALING*margin)
-         lsp[i]=lsp[i-1]+LSP_SCALING*margin;
+      if (lsp[i]<lsp[i-1]+m)
+         lsp[i]=lsp[i-1]+m;
 
-      if (lsp[i]>lsp[i+1]-LSP_SCALING*margin)
-         lsp[i]= .5* (lsp[i] + lsp[i+1]-LSP_SCALING*margin);
+      if (lsp[i]>lsp[i+1]-m)
+         lsp[i]= SHR(lsp[i],1) + SHR(lsp[i+1]-m,1);
    }
 }
 
-#ifdef FIXED_POINT
-
 
 void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes)
 {
@@ -541,6 +544,25 @@
 
 #else
 
+/*Makes sure the LSPs are stable*/
+void lsp_enforce_margin(spx_lsp_t *lsp, int len, float margin)
+{
+   int i;
+   if (lsp[0]<LSP_SCALING*margin)
+      lsp[0]=LSP_SCALING*margin;
+   if (lsp[len-1]>LSP_SCALING*(M_PI-margin))
+      lsp[len-1]=LSP_SCALING*(M_PI-margin);
+   for (i=1;i<len-1;i++)
+   {
+      if (lsp[i]<lsp[i-1]+LSP_SCALING*margin)
+         lsp[i]=lsp[i-1]+LSP_SCALING*margin;
+
+      if (lsp[i]>lsp[i+1]-LSP_SCALING*margin)
+         lsp[i]= .5* (lsp[i] + lsp[i+1]-LSP_SCALING*margin);
+   }
+}
+
+
 void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes)
 {
    int i;

<p><p>1.43      +14 -1     speex/libspeex/misc.h

Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- misc.h	6 Nov 2003 21:35:30 -0000	1.42
+++ misc.h	10 Nov 2003 08:57:27 -0000	1.43
@@ -48,7 +48,7 @@
 typedef spx_word16_t spx_lsp_t;
 typedef spx_word32_t spx_sig_t;
 
-#define LPC_SCALING  8192.
+#define LPC_SCALING  8192
 #define SIG_SCALING  16384
 #define LSP_SCALING  8192.
 
@@ -109,9 +109,22 @@
 #endif
 
 #define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))
+#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),11))
 #define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
 #define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))
+
+#ifdef ARM_ASM
+static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) {
+  int res;
+  asm volatile("smulwb  %0,%1,%2;\n"
+              : "=&r"(res)
+               : "%r"(y<<1),"r"(x));
+  return(res);
+}
+
+#else
 #define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
+#endif
 
 #define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
 #define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))

<p><p>1.145     +2 -3      speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -r1.144 -r1.145
--- nb_celp.c	10 Nov 2003 06:56:53 -0000	1.144
+++ nb_celp.c	10 Nov 2003 08:57:27 -0000	1.145
@@ -194,7 +194,7 @@
    int i, sub, roots;
    int ol_pitch;
    float ol_pitch_coef;
-   float ol_gain;
+   spx_word32_t ol_gain;
    spx_sig_t *res, *target;
    spx_mem_t *mem;
    char *stack;
@@ -270,8 +270,7 @@
          for (i=0;i<st->lpcSize;i++)
             st->interp_lsp[i] = st->lsp[i];
       else
-         for (i=0;i<st->lpcSize;i++)
-            st->interp_lsp[i] = .375*st->old_lsp[i] + .625*st->lsp[i];
+         lsp_interpolate(st->old_lsp, st->lsp, st->interp_lsp, st->lpcSize, st->nbSubframes, st->nbSubframes<<1);
 
       lsp_enforce_margin(st->interp_lsp, st->lpcSize, .002);
 

<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