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

jm at svn.xiph.org jm at svn.xiph.org
Thu Oct 26 07:58:28 PDT 2006


Author: jm
Date: 2006-10-26 07:58:26 -0700 (Thu, 26 Oct 2006)
New Revision: 11952

Modified:
   trunk/speex/libspeex/math_approx.c
Log:
debugged spx_ilog2() and added spx_ilog4()


Modified: trunk/speex/libspeex/math_approx.c
===================================================================
--- trunk/speex/libspeex/math_approx.c	2006-10-26 13:15:20 UTC (rev 11951)
+++ trunk/speex/libspeex/math_approx.c	2006-10-26 14:58:26 UTC (rev 11952)
@@ -40,7 +40,7 @@
 spx_int16_t spx_ilog2(spx_uint32_t x)
 {
    int r=0;
-   if (x>=(spx_int32_t)32768)
+   if (x>=(spx_int32_t)65536)
    {
       x >>= 16;
       r += 16;
@@ -60,13 +60,38 @@
       x >>= 2;
       r += 2;
    }
-   if (x>=1)
+   if (x>=2)
    {
       r += 1;
    }
    return r;
 }
 
+spx_int16_t spx_ilog4(spx_uint32_t x)
+{
+   int r=0;
+   if (x>=(spx_int32_t)65536)
+   {
+      x >>= 16;
+      r += 8;
+   }
+   if (x>=256)
+   {
+      x >>= 8;
+      r += 4;
+   }
+   if (x>=16)
+   {
+      x >>= 4;
+      r += 2;
+   }
+   if (x>=4)
+   {
+      r += 1;
+   }
+   return r;
+}
+
 #ifdef FIXED_POINT
 
 /* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */



More information about the commits mailing list