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

jm at svn.xiph.org jm at svn.xiph.org
Wed Apr 19 08:22:22 PDT 2006


Author: jm
Date: 2006-04-19 08:22:17 -0700 (Wed, 19 Apr 2006)
New Revision: 11166

Modified:
   trunk/speex/libspeex/filters.c
Log:
energy scaling is a bit more accurate (especially in fixed-point)


Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c	2006-04-19 13:56:55 UTC (rev 11165)
+++ trunk/speex/libspeex/filters.c	2006-04-19 15:22:17 UTC (rev 11166)
@@ -784,15 +784,20 @@
    }
    for (i=0;i<nsf;i++)
       new_exc[i] = ADD16(exc[i], EXTRACT16(PSHR32(ADD32(MULT16_16(gain0,iexc[i]), MULT16_16(gain1,iexc[i+nsf])),8)));
+   /* FIXME: compute_rms16 is currently not quite accurate enough (but close) */
    new_ener = compute_rms16(new_exc, nsf);
    old_ener = compute_rms16(exc, nsf);
    
+   if (old_ener < 1)
+      old_ener = 1;
+   if (new_ener < 1)
+      new_ener = 1;
    if (old_ener > new_ener)
       old_ener = new_ener;
-   ngain = DIV32_16(SHL32(EXTEND32(old_ener),15),ADD16(1,new_ener));
+   ngain = DIV32_16(SHL32(EXTEND32(old_ener),14),new_ener);
    
    for (i=0;i<nsf;i++)
-      new_exc[i] = MULT16_16_Q15(ngain, new_exc[i]);
+      new_exc[i] = MULT16_16_Q14(ngain, new_exc[i]);
 }
 #endif
 



More information about the commits mailing list