diff -Nru rockboxO/apps/codecs/libspeex/cb_search.c rockbox/apps/codecs/libspeex/cb_search.c
--- rockboxO/apps/codecs/libspeex/cb_search.c	2006-07-22 18:33:40.000000000 +0200
+++ rockbox/apps/codecs/libspeex/cb_search.c	2006-07-22 18:34:09.000000000 +0200
@@ -42,6 +42,7 @@
 #ifdef _USE_SSE
 #include "cb_search_sse.h"
 #elif defined(ARM4_ASM) || defined(ARM5E_ASM)
+//|| defined(CPU_ARM)
 #include "cb_search_arm4.h"
 #elif defined(BFIN_ASM)
 #include "cb_search_bfin.h"
@@ -50,36 +51,6 @@
 #ifndef OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
 static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
 {
-   int i, j, k;
-   VARDECL(spx_word16_t *shape);
-   ALLOC(shape, subvect_size, spx_word16_t);
-   for (i=0;i<shape_cb_size;i++)
-   {
-      spx_word16_t *res;
-      
-      res = resp+i*subvect_size;
-      for (k=0;k<subvect_size;k++)
-         shape[k] = (spx_word16_t)shape_cb[i*subvect_size+k];
-      E[i]=0;
-
-      /* Compute codeword response using convolution with impulse response */
-      for(j=0;j<subvect_size;j++)
-      {
-         spx_word32_t resj=0;
-         spx_word16_t res16;
-         for (k=0;k<=j;k++)
-            resj = MAC16_16(resj,shape[k],r[j-k]);
-#ifdef FIXED_POINT
-         res16 = EXTRACT16(SHR32(resj, 13));
-#else
-         res16 = 0.03125f*resj;
-#endif
-         /* Compute codeword energy */
-         E[i]=MAC16_16(E[i],res16,res16);
-         res[j] = res16;
-         /*printf ("%d\n", (int)res[j]);*/
-      }
-   }
 
 }
 #endif
@@ -87,9 +58,6 @@
 #ifndef OVERRIDE_TARGET_UPDATE
 static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len)
 {
-   int n;
-   for (n=0;n<len;n++)
-      t[n] = SUB16(t[n],PSHR32(MULT16_16(g,r[n]),13));
 }
 #endif
 
@@ -111,134 +79,6 @@
 int   update_target
 )
 {
-   int i,j,m,q;
-   VARDECL(spx_word16_t *resp);
-#ifdef _USE_SSE
-   VARDECL(__m128 *resp2);
-   VARDECL(__m128 *E);
-#else
-   spx_word16_t *resp2;
-   VARDECL(spx_word32_t *E);
-#endif
-   VARDECL(spx_word16_t *t);
-   VARDECL(spx_sig_t *e);
-   const signed char *shape_cb;
-   int shape_cb_size, subvect_size, nb_subvect;
-   const split_cb_params *params;
-   int N=2;
-   int best_index;
-   spx_word32_t best_dist;
-   int have_sign;
-   N=complexity;
-   if (N>10)
-      N=10;
-   if (N<1)
-      N=1;
-   
-   params = (const split_cb_params *) par;
-   subvect_size = params->subvect_size;
-   nb_subvect = params->nb_subvect;
-   shape_cb_size = 1<<params->shape_bits;
-   shape_cb = params->shape_cb;
-   have_sign = params->have_sign;
-   ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t);
-#ifdef _USE_SSE
-   ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128);
-   ALLOC(E, shape_cb_size>>2, __m128);
-#else
-   resp2 = resp;
-   ALLOC(E, shape_cb_size, spx_word32_t);
-#endif
-   ALLOC(t, nsf, spx_word16_t);
-   ALLOC(e, nsf, spx_sig_t);
-   
-   /* FIXME: make that adaptive? */
-   for (i=0;i<nsf;i++)
-      t[i]=target[i];
-
-   compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
-
-   for (i=0;i<nb_subvect;i++)
-   {
-      spx_word16_t *x=t+subvect_size*i;
-      /*Find new n-best based on previous n-best j*/
-      if (have_sign)
-         vq_nbest_sign(x, resp2, subvect_size, shape_cb_size, E, 1, &best_index, &best_dist, stack);
-      else
-         vq_nbest(x, resp2, subvect_size, shape_cb_size, E, 1, &best_index, &best_dist, stack);
-      
-      speex_bits_pack(bits,best_index,params->shape_bits+have_sign);
-      
-      {
-         int rind;
-         spx_word16_t *res;
-         spx_word16_t sign=1;
-         rind = best_index;
-         if (rind>=shape_cb_size)
-         {
-            sign=-1;
-            rind-=shape_cb_size;
-         }
-         res = resp+rind*subvect_size;
-         if (sign>0)
-            for (m=0;m<subvect_size;m++)
-               t[subvect_size*i+m] = SUB16(t[subvect_size*i+m], res[m]);
-         else
-            for (m=0;m<subvect_size;m++)
-               t[subvect_size*i+m] = ADD16(t[subvect_size*i+m], res[m]);
-
-#ifdef FIXED_POINT
-         if (sign)
-         {
-            for (j=0;j<subvect_size;j++)
-               e[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5);
-         } else {
-            for (j=0;j<subvect_size;j++)
-               e[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5));
-         }
-#else
-         for (j=0;j<subvect_size;j++)
-            e[subvect_size*i+j]=sign*0.03125*shape_cb[rind*subvect_size+j];
-#endif
-      
-      }
-            
-      for (m=0;m<subvect_size;m++)
-      {
-         spx_word16_t g;
-         int rind;
-         spx_word16_t sign=1;
-         rind = best_index;
-         if (rind>=shape_cb_size)
-         {
-            sign=-1;
-            rind-=shape_cb_size;
-         }
-         
-         q=subvect_size-m;
-#ifdef FIXED_POINT
-         g=sign*shape_cb[rind*subvect_size+m];
-#else
-         g=sign*0.03125*shape_cb[rind*subvect_size+m];
-#endif
-         target_update(t+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1));
-      }
-   }
-
-   /* Update excitation */
-   /* FIXME: We could update the excitation directly above */
-   for (j=0;j<nsf;j++)
-      exc[j]=ADD32(exc[j],e[j]);
-   
-   /* Update target: only update target if necessary */
-   if (update_target)
-   {
-      VARDECL(spx_sig_t *r2);
-      ALLOC(r2, nsf, spx_sig_t);
-      syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack);
-      for (j=0;j<nsf;j++)
-         target[j]=SUB16(target[j],EXTRACT16(PSHR32(r2[j],8)));
-   }
 }
 
 
@@ -259,253 +99,7 @@
 int   update_target
 )
 {
-   int i,j,k,m,n,q;
-   VARDECL(spx_word16_t *resp);
-#ifdef _USE_SSE
-   VARDECL(__m128 *resp2);
-   VARDECL(__m128 *E);
-#else
-   spx_word16_t *resp2;
-   VARDECL(spx_word32_t *E);
-#endif
-   VARDECL(spx_word16_t *t);
-   VARDECL(spx_sig_t *e);
-   VARDECL(spx_sig_t *r2);
-   VARDECL(spx_word16_t *tmp);
-   VARDECL(spx_word32_t *ndist);
-   VARDECL(spx_word32_t *odist);
-   VARDECL(int *itmp);
-   VARDECL(spx_word16_t **ot2);
-   VARDECL(spx_word16_t **nt2);
-   spx_word16_t **ot, **nt;
-   VARDECL(int **nind);
-   VARDECL(int **oind);
-   VARDECL(int *ind);
-   const signed char *shape_cb;
-   int shape_cb_size, subvect_size, nb_subvect;
-   const split_cb_params *params;
-   int N=2;
-   VARDECL(int *best_index);
-   VARDECL(spx_word32_t *best_dist);
-   VARDECL(int *best_nind);
-   VARDECL(int *best_ntarget);
-   int have_sign;
-   N=complexity;
-   if (N>10)
-      N=10;
-   if (N<1)
-      N=1;
-   
-   if (N==1)
-   {
-      split_cb_search_shape_sign_N1(target,ak,awk1,awk2,par,p,nsf,exc,r,bits,stack,complexity,update_target);
-      return;
-   }
-   ALLOC(ot2, N, spx_word16_t*);
-   ALLOC(nt2, N, spx_word16_t*);
-   ALLOC(oind, N, int*);
-   ALLOC(nind, N, int*);
-
-   params = (const split_cb_params *) par;
-   subvect_size = params->subvect_size;
-   nb_subvect = params->nb_subvect;
-   shape_cb_size = 1<<params->shape_bits;
-   shape_cb = params->shape_cb;
-   have_sign = params->have_sign;
-   ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t);
-#ifdef _USE_SSE
-   ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128);
-   ALLOC(E, shape_cb_size>>2, __m128);
-#else
-   resp2 = resp;
-   ALLOC(E, shape_cb_size, spx_word32_t);
-#endif
-   ALLOC(t, nsf, spx_word16_t);
-   ALLOC(e, nsf, spx_sig_t);
-   ALLOC(r2, nsf, spx_sig_t);
-   ALLOC(ind, nb_subvect, int);
-
-   ALLOC(tmp, 2*N*nsf, spx_word16_t);
-   for (i=0;i<N;i++)
-   {
-      ot2[i]=tmp+2*i*nsf;
-      nt2[i]=tmp+(2*i+1)*nsf;
-   }
-   ot=ot2;
-   nt=nt2;
-   ALLOC(best_index, N, int);
-   ALLOC(best_dist, N, spx_word32_t);
-   ALLOC(best_nind, N, int);
-   ALLOC(best_ntarget, N, int);
-   ALLOC(ndist, N, spx_word32_t);
-   ALLOC(odist, N, spx_word32_t);
-   
-   ALLOC(itmp, 2*N*nb_subvect, int);
-   for (i=0;i<N;i++)
-   {
-      nind[i]=itmp+2*i*nb_subvect;
-      oind[i]=itmp+(2*i+1)*nb_subvect;
-   }
-   
-   /* FIXME: make that adaptive? */
-   for (i=0;i<nsf;i++)
-      t[i]=target[i];
-
-   for (j=0;j<N;j++)
-      speex_move(&ot[j][0], t, nsf*sizeof(spx_word16_t));
-
-   /* Pre-compute codewords response and energy */
-   compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
-
-   for (j=0;j<N;j++)
-      odist[j]=0;
-   
-   /*For all subvectors*/
-   for (i=0;i<nb_subvect;i++)
-   {
-      /*"erase" nbest list*/
-      for (j=0;j<N;j++)
-         ndist[j]=VERY_LARGE32;
-
-      /*For all n-bests of previous subvector*/
-      for (j=0;j<N;j++)
-      {
-         spx_word16_t *x=ot[j]+subvect_size*i;
-         spx_word32_t tener = 0;
-         for (m=0;m<subvect_size;m++)
-            tener = MAC16_16(tener, x[m],x[m]);
-#ifdef FIXED_POINT
-         tener = SHR32(tener,1);
-#else
-         tener *= .5;
-#endif
-         /*Find new n-best based on previous n-best j*/
-         if (have_sign)
-            vq_nbest_sign(x, resp2, subvect_size, shape_cb_size, E, N, best_index, best_dist, stack);
-         else
-            vq_nbest(x, resp2, subvect_size, shape_cb_size, E, N, best_index, best_dist, stack);
-
-         /*For all new n-bests*/
-         for (k=0;k<N;k++)
-         {
-            /* Compute total distance (including previous sub-vectors */
-            spx_word32_t err = ADD32(ADD32(odist[j],best_dist[k]),tener);
-            
-            /*update n-best list*/
-            if (err<ndist[N-1])
-            {
-               for (m=0;m<N;m++)
-               {
-                  if (err < ndist[m])
-                  {
-                     for (n=N-1;n>m;n--)
-                     {
-                        ndist[n] = ndist[n-1];
-                        best_nind[n] = best_nind[n-1];
-                        best_ntarget[n] = best_ntarget[n-1];
-                     }
-                     ndist[m] = err;
-                     best_nind[n] = best_index[k];
-                     best_ntarget[n] = j;
-                     break;
-                  }
-               }
-            }
-         }
-         if (i==0)
-            break;
-      }
-      for (j=0;j<N;j++)
-      {
-         /*previous target (we don't care what happened before*/
-         for (m=(i+1)*subvect_size;m<nsf;m++)
-            nt[j][m]=ot[best_ntarget[j]][m];
-         
-         /* New code: update the rest of the target only if it's worth it */
-         for (m=0;m<subvect_size;m++)
-         {
-            spx_word16_t g;
-            int rind;
-            spx_word16_t sign=1;
-            rind = best_nind[j];
-            if (rind>=shape_cb_size)
-            {
-               sign=-1;
-               rind-=shape_cb_size;
-            }
-
-            q=subvect_size-m;
-#ifdef FIXED_POINT
-            g=sign*shape_cb[rind*subvect_size+m];
-#else
-            g=sign*0.03125*shape_cb[rind*subvect_size+m];
-#endif
-            target_update(nt[j]+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1));
-         }
-
-         for (q=0;q<nb_subvect;q++)
-            nind[j][q]=oind[best_ntarget[j]][q];
-         nind[j][i]=best_nind[j];
-      }
-
-      /*update old-new data*/
-      /* just swap pointers instead of a long copy */
-      {
-         spx_word16_t **tmp2;
-         tmp2=ot;
-         ot=nt;
-         nt=tmp2;
-      }
-      for (j=0;j<N;j++)
-         for (m=0;m<nb_subvect;m++)
-            oind[j][m]=nind[j][m];
-      for (j=0;j<N;j++)
-         odist[j]=ndist[j];
-   }
-
-   /*save indices*/
-   for (i=0;i<nb_subvect;i++)
-   {
-      ind[i]=nind[0][i];
-      speex_bits_pack(bits,ind[i],params->shape_bits+have_sign);
-   }
-   
-   /* Put everything back together */
-   for (i=0;i<nb_subvect;i++)
-   {
-      int rind;
-      spx_word16_t sign=1;
-      rind = ind[i];
-      if (rind>=shape_cb_size)
-      {
-         sign=-1;
-         rind-=shape_cb_size;
-      }
-#ifdef FIXED_POINT
-      if (sign==1)
-      {
-         for (j=0;j<subvect_size;j++)
-            e[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5);
-      } else {
-         for (j=0;j<subvect_size;j++)
-            e[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5));
-      }
-#else
-      for (j=0;j<subvect_size;j++)
-         e[subvect_size*i+j]=sign*0.03125*shape_cb[rind*subvect_size+j];
-#endif
-   }   
-   /* Update excitation */
-   for (j=0;j<nsf;j++)
-      exc[j]=ADD32(exc[j],e[j]);
-   
-   /* Update target: only update target if necessary */
-   if (update_target)
-   {
-      syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack);
-      for (j=0;j<nsf;j++)
-         target[j]=SUB16(target[j],EXTRACT16(PSHR32(r2[j],8)));
-   }
+   return;
 }
 
 
@@ -582,17 +176,6 @@
 int   update_target
 )
 {
-   int i;
-   VARDECL(spx_sig_t *tmp);
-   ALLOC(tmp, nsf, spx_sig_t);
-   for (i=0;i<nsf;i++)
-      tmp[i]=PSHR32(EXTEND32(target[i]),SIG_SHIFT);
-   residue_percep_zero(tmp, ak, awk1, awk2, tmp, nsf, p, stack);
-
-   for (i=0;i<nsf;i++)
-      exc[i]+=tmp[i];
-   for (i=0;i<nsf;i++)
-      target[i]=0;
 }
 
 
@@ -604,9 +187,4 @@
 char *stack
 )
 {
-   int i;
-   /* FIXME: This is bad, but I don't think the function ever gets called anyway */
-   spx_int32_t seed = 0;
-   for (i=0;i<nsf;i++)
-      exc[i]=SHL32(EXTEND32(speex_rand(1, &seed)),SIG_SHIFT);
 }
diff -Nru rockboxO/apps/codecs/libspeex/fixed_arm4.h rockbox/apps/codecs/libspeex/fixed_arm4.h
--- rockboxO/apps/codecs/libspeex/fixed_arm4.h	2006-07-22 18:33:40.000000000 +0200
+++ rockbox/apps/codecs/libspeex/fixed_arm4.h	2006-07-22 18:34:12.000000000 +0200
@@ -37,6 +37,8 @@
 
 //#warning "----------------Error arm4 enabled----------------"
 
+//# MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b))))
+
 #undef MULT16_32_Q14
 static inline spx_word32_t MULT16_32_Q14(spx_word16_t x, spx_word32_t y) {
   int res;
diff -Nru rockboxO/apps/codecs/libspeex/lsp.c rockbox/apps/codecs/libspeex/lsp.c
--- rockboxO/apps/codecs/libspeex/lsp.c	2006-07-22 18:33:40.000000000 +0200
+++ rockbox/apps/codecs/libspeex/lsp.c	2006-07-22 18:34:09.000000000 +0200
@@ -106,8 +106,11 @@
 /*#define X2ANGLE(x) (acos(.00006103515625*(x))*LSP_SCALING)*/
 #define X2ANGLE(x) (spx_acos(x))
 
+
 #ifdef BFIN_ASM
 #include "lsp_bfin.h"
+/*#elif defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(CPU_ARM)
+#include "lsp_arm4.h"*/
 #endif
 
 #else
@@ -144,31 +147,7 @@
   char         *stack
 )
 {
-    int i;
-    spx_word16_t b0, b1;
-    spx_word32_t sum;
-
-    /*Prevents overflows*/
-    if (x>16383)
-       x = 16383;
-    if (x<-16383)
-       x = -16383;
-
-    /* Initialise values */
-    b1=16384;
-    b0=x;
-
-    /* Evaluate Chebyshev series formulation usin g iterative approach  */
-    sum = ADD32(EXTEND32(coef[m]), EXTEND32(MULT16_16_P14(coef[m-1],x)));
-    for(i=2;i<=m;i++)
-    {
-       spx_word16_t tmp=b0;
-       b0 = SUB16(MULT16_16_Q13(x,b0), b1);
-       b1 = tmp;
-       sum = ADD32(sum, EXTEND32(MULT16_16_P14(coef[m-i],b0)));
-    }
-    
-    return sum;
+
 }
 #endif
 
@@ -176,24 +155,6 @@
 
 static float cheb_poly_eva(spx_word32_t *coef, spx_word16_t x, int m, char *stack)
 {
-   int k;
-   float b0, b1, tmp;
-
-   /* Initial conditions */
-   b0=0; /* b_(m+1) */
-   b1=0; /* b_(m+2) */
-
-   x*=2;
-
-   /* Calculate the b_(k) */
-   for(k=m;k>0;k--)
-   {
-      tmp=b0;                           /* tmp holds the previous value of b0 */
-      b0=x*b0-b1+coef[m-k];    /* b0 holds its new value based on b0 and b1 */
-      b1=tmp;                           /* b1 holds the previous value of b0 */
-   }
-
-   return(-b1+.5*x*b0+coef[m]);
 }
 #endif
 
@@ -246,6 +207,7 @@
 /*  float *ak 		array of LPC coefficients 			*/
 /*  int lpcrdr  	order of LPC coefficients 			*/
 {
+
     int i,j;
     spx_word32_t xout1,xout2,xin;
     spx_word32_t mult, a;
@@ -433,22 +395,6 @@
 /*Makes sure the LSPs are stable*/
 void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin)
 {
-   int i;
-   spx_word16_t m = margin;
-   spx_word16_t m2 = 25736-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]+m)
-         lsp[i]=lsp[i-1]+m;
-
-      if (lsp[i]>lsp[i+1]-m)
-         lsp[i]= SHR16(lsp[i],1) + SHR16(lsp[i+1]-m,1);
-   }
 }
 
 
@@ -468,19 +414,6 @@
 /*Makes sure the LSPs are stable*/
 void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t 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]= .5f* (lsp[i] + lsp[i+1]-LSP_SCALING*margin);
-   }
 }
 
 
diff -Nru rockboxO/apps/codecs/libspeex/ltp_arm4.h rockbox/apps/codecs/libspeex/ltp_arm4.h
--- rockboxO/apps/codecs/libspeex/ltp_arm4.h	2006-07-22 18:33:40.000000000 +0200
+++ rockbox/apps/codecs/libspeex/ltp_arm4.h	2006-07-22 18:34:12.000000000 +0200
@@ -35,6 +35,7 @@
 #define OVERRIDE_INNER_PROD
 spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
 {
+
    spx_word32_t sum1=0,sum2=0;
    spx_word16_t *deadx, *deady;
    int deadlen, dead1, dead2, dead3, dead4, dead5, dead6;
diff -Nru rockboxO/apps/codecs/libspeex/ltp.c rockbox/apps/codecs/libspeex/ltp.c
--- rockboxO/apps/codecs/libspeex/ltp.c	2006-07-22 18:33:40.000000000 +0200
+++ rockbox/apps/codecs/libspeex/ltp.c	2006-07-22 18:34:09.000000000 +0200
@@ -47,7 +47,7 @@
 
 #ifdef _USE_SSE
 #include "ltp_sse.h"
-#elif defined (ARM4_ASM) || defined(ARM5E_ASM)
+#elif defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(CPU_ARM)
 #include "ltp_arm4.h"
 #elif defined (BFIN_ASM)
 #include "ltp_bfin.h"
diff -Nru rockboxO/apps/codecs/libspeex/math_approx.c rockbox/apps/codecs/libspeex/math_approx.c
--- rockboxO/apps/codecs/libspeex/math_approx.c	2006-07-22 18:33:40.000000000 +0200
+++ rockbox/apps/codecs/libspeex/math_approx.c	2006-07-22 18:34:09.000000000 +0200
@@ -104,7 +104,8 @@
    return rt;
 }
 
-  int fastSqrt(int x) {
+  static int intSqrt(int x) {
+    int xn;
    static int sqrt_table[256] = {
      0,    16,  22,  27,  32,  35,  39,  42,  45,  48,  50,  53,  55,  57,
      59,   61,  64,  65,  67,  69,  71,  73,  75,  76,  78,  80,  81,  83,
@@ -130,58 +131,82 @@
       if (x >= 0x1000000) {
         if (x >= 0x10000000) {
           if (x >= 0x40000000) {
-            return (sqrt_table[x >> 24] << 8);
+            xn = sqrt_table[x >> 24] << 8;
           } else {
-            return (sqrt_table[x >> 22] << 7);
+            xn = sqrt_table[x >> 22] << 7;
           }
-        } else if (x >= 0x4000000) {
-          return (sqrt_table[x >> 20] << 6);
         } else {
-          return (sqrt_table[x >> 18] << 5);
+          if (x >= 0x4000000) {
+            xn = sqrt_table[x >> 20] << 6;
+          } else {
+            xn = sqrt_table[x >> 18] << 5;
+          }
         }
-      } else if (x >= 0x100000) {
-        if (x >= 0x400000) {
-          return (sqrt_table[x >> 16] << 4);
+
+        xn = (xn + 1 + (x / xn)) >> 1;
+        xn = (xn + 1 + (x / xn)) >> 1;
+        return ((xn * xn) > x) ? --xn : xn;
+      } else {
+        if (x >= 0x100000) {
+          if (x >= 0x400000) {
+            xn = sqrt_table[x >> 16] << 4;
+          } else {
+            xn = sqrt_table[x >> 14] << 3;
+          }
         } else {
-          return (sqrt_table[x >> 14] << 3);
+          if (x >= 0x40000) {
+            xn = sqrt_table[x >> 12] << 2;
+          } else {
+            xn = sqrt_table[x >> 10] << 1;
+          }
         }
-      } else if (x >= 0x40000) {
-        return (sqrt_table[x >> 12] << 2);
-      } else {
-        return (sqrt_table[x >> 10] << 1);
+
+        xn = (xn + 1 + (x / xn)) >> 1;
+
+        return ((xn * xn) > x) ? --xn : xn;
       }
-    } else if (x >= 0x100) {
-      if (x >= 0x1000) {
-        if (x >= 0x4000) {
-          return (sqrt_table[x >> 8]);
+    } else {
+      if (x >= 0x100) {
+        if (x >= 0x1000) {
+          if (x >= 0x4000) {
+            xn = (sqrt_table[x >> 8]) + 1;
+          } else {
+            xn = (sqrt_table[x >> 6] >> 1) + 1;
+          }
         } else {
-          return (sqrt_table[x >> 6] >> 1);
+          if (x >= 0x400) {
+            xn = (sqrt_table[x >> 4] >> 2) + 1;
+          } else {
+            xn = (sqrt_table[x >> 2] >> 3) + 1;
+          }
         }
-      } else if (x >= 0x400) {
-        return (sqrt_table[x >> 4] >> 2);
+
+        return ((xn * xn) > x) ? --xn : xn;
       } else {
-        return (sqrt_table[x >> 2] >> 3);
+        if (x >= 0) {
+          return sqrt_table[x] >> 4;
+        }
       }
-    } else if (x >= 0) {
-      return sqrt_table[x] >> 4;
     }
+    
     return -1;
   }
 
 float spx_sqrtf(float arg)
 {
-	if((int)arg==0)
+	if(arg==0.0)
 		return 0.0;
-	else if((int)arg==1)
+	else if(arg==1.0)
 		return 1.0;
-	else if((int)arg==2)
+	else if(arg==2.0)
 		return 1.414;
 	else if(arg==3.27)
 		return 1.8083;
-	//printf("Sqrt:%d:%d:%d\n",arg,(fastSqrt((int)(arg*2500)))/50,(float)spx_sqrt((spx_word32_t)arg));
+	//printf("Sqrt:%f:%f:%f\n",arg,(((float)intSqrt((int)(arg*10000)))/100)+0.0055,(float)spx_sqrt((spx_word32_t)arg));
 	//return ((float)fastSqrt((int)(arg*2500)))/50;
-	
-	return (float)spx_sqrt((spx_word32_t)arg);
+	//LOGF("Sqrt:%d:%d\n",arg,(intSqrt((int)(arg*2500)))/50);
+	return (((float)intSqrt((int)(arg*10000)))/100)+0.0055;//(float)spx_sqrt((spx_word32_t)arg);
+	//return 1;
 }
 
 
diff -Nru rockboxO/apps/codecs/libspeex/sb_celp.c rockbox/apps/codecs/libspeex/sb_celp.c
--- rockboxO/apps/codecs/libspeex/sb_celp.c	2006-07-22 18:33:40.000000000 +0200
+++ rockbox/apps/codecs/libspeex/sb_celp.c	2006-07-22 18:34:09.000000000 +0200
@@ -545,7 +545,7 @@
          exc[i]=0;
       if (!SUBMODE(innovation_unquant))
       {
-         float g;
+         spx_word16_t g;
          int quant;
 
          quant = speex_bits_unpack_unsigned(bits, 5);
@@ -563,20 +563,21 @@
             exc[i]=mode->folding_gain*g*st->low_innov[offset+i];
 #else
          {
-            float tmp=1;
+//             float tmp=1;
             /*static tmp1=0,tmp2=0;
             static int seed=1;
             el = compute_rms(low_innov+offset, st->subframeSize);*/
             for (i=0;i<st->subframeSize;i++)
-            {
-               float e=tmp*g*mode->folding_gain*st->low_innov[offset+i];
-               tmp *= -1;
-               exc[i] = e;
+		exc[i] = g*(spx_word16_t)mode->folding_gain*st->low_innov[offset+i];
+//             {
+//                float e=tmp*g*mode->folding_gain*st->low_innov[offset+i];
+//                tmp *= -1;
+//                exc[i] = e;
                /*float r = speex_rand(g*el,&seed);
                exc[i] = .5*(r+tmp2 + e-tmp1);
                tmp1 = e;
                tmp2 = r;*/               
-            }
+//             }
             
          }
          
diff -Nru rockboxO/apps/codecs/libspeex/vq.c rockbox/apps/codecs/libspeex/vq.c
--- rockboxO/apps/codecs/libspeex/vq.c	2006-07-22 18:33:40.000000000 +0200
+++ rockbox/apps/codecs/libspeex/vq.c	2006-07-22 18:34:09.000000000 +0200
@@ -42,7 +42,7 @@
 #include <xmmintrin.h>
 #include "vq_sse.h"
 #elif defined (CPU_ARM) || defined(SHORTCUTS) && (defined(ARM4_ASM) || defined(ARM5E_ASM))
-//#include "vq_arm4.h"
+#include "vq_arm4.h"
 #elif defined(BFIN_ASM)
 #include "vq_bfin.h"
 #endif
