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

jm at svn.xiph.org jm at svn.xiph.org
Fri Mar 9 00:07:07 PST 2007


Author: jm
Date: 2007-03-09 00:07:04 -0800 (Fri, 09 Mar 2007)
New Revision: 12697

Modified:
   trunk/speex/libspeex/_kiss_fft_guts.h
   trunk/speex/libspeex/kiss_fft.c
Log:
Improved accuracy in forward fixed-point radix-4 butterfly.


Modified: trunk/speex/libspeex/_kiss_fft_guts.h
===================================================================
--- trunk/speex/libspeex/_kiss_fft_guts.h	2007-03-09 05:57:08 UTC (rev 12696)
+++ trunk/speex/libspeex/_kiss_fft_guts.h	2007-03-09 08:07:04 UTC (rev 12697)
@@ -68,6 +68,10 @@
       do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \
           (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0)
 
+#   define C_MUL4(m,a,b) \
+               do{ (m).r = PSHR32( smul((a).r,(b).r) - smul((a).i,(b).i),17 ); \
+               (m).i = PSHR32( smul((a).r,(b).i) + smul((a).i,(b).r),17 ); }while(0)
+
 #   define DIVSCALAR(x,k) \
 	(x) = sround( smul(  x, SAMP_MAX/k ) )
 

Modified: trunk/speex/libspeex/kiss_fft.c
===================================================================
--- trunk/speex/libspeex/kiss_fft.c	2007-03-09 05:57:08 UTC (rev 12696)
+++ trunk/speex/libspeex/kiss_fft.c	2007-03-09 08:07:04 UTC (rev 12697)
@@ -70,7 +70,7 @@
 
     tw3 = tw2 = tw1 = st->twiddles;
 
-    if (!st->inverse) {
+    /*if (!st->inverse) {
        int i;
        kiss_fft_cpx *x=Fout;
        for (i=0;i<4*m;i++)
@@ -78,7 +78,7 @@
           x[i].r = PSHR16(x[i].r,2);
           x[i].i = PSHR16(x[i].i,2);
        }
-    }
+    }*/
     if (st->inverse)
     {
        do {
@@ -105,14 +105,18 @@
     } else
     {
        do {
-          C_MUL(scratch[0],Fout[m] , *tw1 );
-          C_MUL(scratch[1],Fout[m2] , *tw2 );
-          C_MUL(scratch[2],Fout[m3] , *tw3 );
+          C_MUL4(scratch[0],Fout[m] , *tw1 );
+          C_MUL4(scratch[1],Fout[m2] , *tw2 );
+          C_MUL4(scratch[2],Fout[m3] , *tw3 );
           
+          Fout->r = PSHR16(Fout->r, 2);
+          Fout->i = PSHR16(Fout->i, 2);
           C_SUB( scratch[5] , *Fout, scratch[1] );
           C_ADDTO(*Fout, scratch[1]);
           C_ADD( scratch[3] , scratch[0] , scratch[2] );
           C_SUB( scratch[4] , scratch[0] , scratch[2] );
+          Fout[m2].r = PSHR16(Fout[m2].r, 2);
+          Fout[m2].i = PSHR16(Fout[m2].i, 2);
           C_SUB( Fout[m2], *Fout, scratch[3] );
           tw1 += fstride;
           tw2 += fstride*2;



More information about the commits mailing list