fixed-point: simplification of the gain in mix_pitch_and_residual()
authorJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Thu, 13 Mar 2008 00:36:45 +0000 (11:36 +1100)
committerJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Thu, 13 Mar 2008 00:36:45 +0000 (11:36 +1100)
libcelt/bands.c
libcelt/vq.c

index c578a84..f52a7aa 100644 (file)
@@ -196,7 +196,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t *freq, celt_norm_t *X,
 
 void renormalise_bands(const CELTMode *m, celt_norm_t *X)
 {
-   VARDECL(celt_ener_t *tmpE);
+   VARDECL(celt_ener_ttmpE);
    SAVE_STACK;
    ALLOC(tmpE, m->nbEBands*m->nbChannels, celt_ener_t);
    compute_band_energies(m, X, tmpE);
index 7c89d02..7718bd8 100644 (file)
@@ -85,10 +85,14 @@ static void mix_pitch_and_residual(int *iy, celt_norm_t *X, int N, int K, const
       Ryy = MAC16_16(Ryy, y[i],y[i]);
 
    /* g = (sqrt(Ryp^2 + Ryy - Rpp*Ryy)-Ryp)/Ryy */
-   g = DIV32(SHL32(celt_sqrt(MULT16_16(ROUND(Ryp,14),ROUND(Ryp,14)) + Ryy - MULT16_16(ROUND(Ryy,14),ROUND(Rpp,14))) - ROUND(Ryp,14),14),ROUND(Ryy,14));
+   g = MULT16_32_Q15(
+            celt_sqrt(MULT16_16(ROUND(Ryp,14),ROUND(Ryp,14)) + Ryy -
+                      MULT16_16(ROUND(Ryy,14),ROUND(Rpp,14)))
+            - ROUND(Ryp,14),
+       celt_rcp(SHR32(Ryy,9)));
 
    for (i=0;i<N;i++)
-      X[i] = P[i] + MULT16_32_Q14(y[i], g);
+      X[i] = P[i] + ROUND(MULT16_16(y[i], g),11);
    RESTORE_STACK;
 }