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

Jean-Marc Valin jm at xiph.org
Sat Nov 1 23:44:35 PST 2003



jm          03/11/02 02:44:35

  Modified:    libspeex lsp.c misc.c misc.h testenc.c
  Log:
  fixed-point: added code to count MIPS

Revision  Changes    Path
1.38      +8 -8      speex/libspeex/lsp.c

Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- lsp.c	2 Nov 2003 06:38:58 -0000	1.37
+++ lsp.c	2 Nov 2003 07:44:35 -0000	1.38
@@ -68,11 +68,11 @@
    if (x<12868)
    {
       x2 = MULT16_16_Q13(x,x);
-      return C1 + MULT16_16_Q13(x2, C2 + MULT16_16_Q13(C3, x2));
+      return ADD32(C1, MULT16_16_Q13(x2, ADD32(C2, MULT16_16_Q13(C3, x2))));
    } else {
       x = 25736-x;
       x2 = MULT16_16_Q13(x,x);
-      return -C1 - MULT16_16_Q13(x2, C2 + MULT16_16_Q13(C3, x2));
+      return SUB32(-C1, MULT16_16_Q13(x2, ADD32(C2, MULT16_16_Q13(C3, x2))));
    }
 }
 
@@ -137,12 +137,12 @@
 
     /* Evaluate Chebyshev series formulation using iterative approach  */
     /* Evaluate polynomial and return value also free memory space */
-    sum = coefn[m2] + MULT16_16_P14(coefn[m2-1],x);
+    sum = ADD32(coefn[m2], MULT16_16_P14(coefn[m2-1],x));
     /*x *= 2;*/
     for(i=2;i<=m2;i++)
     {
        T[i] = MULT16_16_Q13(x,T[i-1]) - T[i-2];
-       sum += MULT16_16_P14(coefn[m2-i],T[i]);
+       sum = ADD32(sum, MULT16_16_P14(coefn[m2-i],T[i]));
        /*printf ("%f ", sum);*/
     }
     
@@ -385,7 +385,7 @@
     spx_word32_t *Wp;
     spx_word32_t *pw,*n1,*n2,*n3,*n4=NULL;
     spx_word16_t *freqn;
-    int m = lpcrdr/2;
+    int m = lpcrdr>>1;
     
     freqn = PUSH(stack, lpcrdr, spx_word16_t);
     for (i=0;i<lpcrdr;i++)
@@ -418,8 +418,8 @@
             n2 = n1 + 1;
             n3 = n2 + 1;
             n4 = n3 + 1;
-	    xout1 = xin1 - MULT16_32_Q14(freqn[i2],*n1) + *n2;
-            xout2 = xin2 - MULT16_32_Q14(freqn[i2+1],*n3) + *n4;
+	    xout1 = ADD32(SUB32(xin1, MULT16_32_Q14(freqn[i2],*n1)), *n2);
+            xout2 = ADD32(SUB32(xin2, MULT16_32_Q14(freqn[i2+1],*n3)), *n4);
             *n2 = *n1;
             *n4 = *n3;
             *n1 = xin1;
@@ -435,7 +435,7 @@
         else if (xout1 + xout2 < -256*32767)
            ak[j] = -32768;
         else
-           ak[j] = ((128+xout1 + xout2)>>8);
+           ak[j] = PSHR(ADD32(xout1,xout2),8);
         *(n4+1) = xin1;
         *(n4+2) = xin2;
 

<p><p>1.11      +5 -0      speex/libspeex/misc.c

Index: misc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- misc.c	8 Oct 2003 05:03:47 -0000	1.10
+++ misc.c	2 Nov 2003 07:44:35 -0000	1.11
@@ -46,6 +46,11 @@
 }
 #endif
 
+#ifdef COUNT_MIPS
+long long spx_mips=0;
+#endif
+
+
 unsigned int be_int(unsigned int i)
 {
    unsigned int ret=i;

<p><p>1.41      +17 -1     speex/libspeex/misc.h

Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- misc.h	2 Nov 2003 06:59:48 -0000	1.40
+++ misc.h	2 Nov 2003 07:44:35 -0000	1.41
@@ -55,10 +55,25 @@
 #define LPC_SHIFT    13
 #define SIG_SHIFT    14
 
+#ifdef COUNT_MIPS
+extern long long spx_mips;
+#endif
+
 #define PSHR(a,shift) (((a)+(1<<((shift)-1))) >> (shift))
 #define SHR(a,shift) ((a) >> (shift))
 #define SHL(a,shift) ((a) << (shift))
 
+#ifdef COUNT_MIPS
+/*Modified to count operations*/
+#define ADD16(a,b) (spx_mips++,(a)+(b))
+#define SUB16(a,b) (spx_mips++,(a)-(b))
+#define ADD32(a,b) (spx_mips++,(a)+(b))
+#define SUB32(a,b) (spx_mips++,(a)-(b))
+#define MULT16_16_16(a,b)     (spx_mips++,((short)(a))*((short)(b)))
+#define MULT16_16(a,b)     (spx_mips++,((int)(a))*((short)(b)))
+
+#else
+
 #define ADD16(a,b) ((a)+(b))
 #define SUB16(a,b) ((a)-(b))
 #define ADD32(a,b) ((a)+(b))
@@ -66,10 +81,11 @@
 
 /* result fits in 16 bits */
 #define MULT16_16_16(a,b)     (((short)(a))*((short)(b)))
-
 /* Kludge: just making sure results are on 32 bits */
 #define MULT16_16(a,b)     (((int)(a))*((short)(b)))
 
+#endif
+
 #define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),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))

<p><p>1.51      +8 -0      speex/libspeex/testenc.c

Index: testenc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testenc.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- testenc.c	9 Oct 2003 20:53:41 -0000	1.50
+++ testenc.c	2 Nov 2003 07:44:35 -0000	1.51
@@ -3,6 +3,10 @@
 #include <stdlib.h>
 #include "speex_callbacks.h"
 
+#ifdef COUNT_MIPS
+extern long long spx_mips;
+#endif
+
 #define FRAME_SIZE 160
 #include <math.h>
 int main(int argc, char **argv)
@@ -119,6 +123,10 @@
    snr = 10 * log10( sigpow / errpow );
    seg_snr /= snr_frames;
    fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
+
+#ifdef COUNT_MIPS
+   printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
+#endif
    
    return 1;
 }

<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