shithub: opus

Download patch

ref: e40a19cbe9c121444c28905b217275b21dee1c05
parent: 5d5618340438d0fd0df66279efca71ee25f5ece4
author: Jean-Marc Valin <[email protected]>
date: Wed Feb 27 07:09:50 EST 2008

fixed-point: no float vars left (and nearly no float ops left) in celt.c

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -176,10 +176,10 @@
 }
 
 /** Apply window and compute the MDCT for all sub-frames and all channels in a frame */
-static float compute_mdcts(mdct_lookup *mdct_lookup, celt_word16_t *window, celt_sig_t *in, celt_sig_t *out, int N, int B, int C)
+static celt_word32_t compute_mdcts(mdct_lookup *mdct_lookup, celt_word16_t *window, celt_sig_t *in, celt_sig_t *out, int N, int B, int C)
 {
    int i, c;
-   float E = 1e-15;
+   celt_word32_t E = 0;
    VARDECL(celt_word32_t *x);
    VARDECL(celt_word32_t *tmp);
    ALLOC(x, 2*N, celt_word32_t);
@@ -192,7 +192,7 @@
          for (j=0;j<2*N;j++)
          {
             x[j] = MULT16_32_Q15(window[j],in[C*i*N+C*j+c]);
-            E += SIG_SCALING_1*SIG_SCALING_1*x[j]*x[j];
+            E += MULT16_16(EXTRACT16(SHR32(x[j],SIG_SHIFT+4)),EXTRACT16(SHR32(x[j],SIG_SHIFT+4)));
          }
          mdct_forward(mdct_lookup, x, tmp);
          /* Interleaving the sub-frames */
@@ -238,7 +238,7 @@
    int i, c, N, B, C, N4;
    int has_pitch;
    int pitch_index;
-   float curr_power, pitch_power;
+   celt_word32_t curr_power, pitch_power;
    VARDECL(celt_sig_t *in);
    VARDECL(celt_sig_t *freq);
    VARDECL(celt_norm_t *X);
@@ -328,7 +328,7 @@
    }
 
    /* Check if we can safely use the pitch (i.e. effective gain isn't too high) */
-   if (curr_power + 1e5f < 10.f*pitch_power)
+   if (curr_power + 1e5f*(1.f/SHL16(1,8)) < 10.f*pitch_power)
    {
       /* Normalise the pitch vector as well (discard the energies) */
       VARDECL(celt_ener_t *bandEp);