ref: 9d5b4a6f56b1bd896025444d571af76668de4f08
parent: 19ae9fc9446067cb119b66a77c13a90e396f5ef1
author: Jean-Marc Valin <[email protected]>
date: Thu Mar 13 07:36:45 EDT 2008
fixed-point: simplification of the gain in mix_pitch_and_residual()
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -196,7 +196,7 @@
void renormalise_bands(const CELTMode *m, celt_norm_t *X)
{
- VARDECL(celt_ener_t *tmpE);
+ VARDECL(celt_ener_t, tmpE);
SAVE_STACK;
ALLOC(tmpE, m->nbEBands*m->nbChannels, celt_ener_t);
compute_band_energies(m, X, tmpE);
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -85,10 +85,14 @@
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;
}