[xiph-cvs] cvs commit: speex/libspeex ltp.c
Jean-Marc Valin
jm at xiph.org
Mon Oct 27 14:53:15 PST 2003
jm 03/10/27 17:53:15
Modified: libspeex ltp.c
Log:
fixed-point: excitation and error computation for closed-loop search
mostly converted
Revision Changes Path
1.89 +24 -8 speex/libspeex/ltp.c
Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- ltp.c 27 Oct 2003 21:43:33 -0000 1.88
+++ ltp.c 27 Oct 2003 22:53:15 -0000 1.89
@@ -62,7 +62,7 @@
{
int i,j,k;
spx_word32_t *best_score;
- float e0;
+ spx_word32_t e0;
spx_word32_t *corr, *energy;
spx_word32_t *score;
spx_word16_t *swn;
@@ -204,7 +204,8 @@
float gain[3];
int gain_cdbk_size;
signed char *gain_cdbk;
- float err1,err2;
+ spx_word16_t sgain[3];
+ float err;
ltp_params *params;
params = (ltp_params*) par;
@@ -380,21 +381,36 @@
gain[1] = 0.015625*gain_cdbk[best_cdbk*3+1]+ .5;
gain[2] = 0.015625*gain_cdbk[best_cdbk*3+2]+ .5;
+ sgain[0] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3];
+ sgain[1] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3+1];
+ sgain[2] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3+2];
+
*cdbk_index=best_cdbk;
}
+#ifdef FIXED_POINT
for (i=0;i<nsf;i++)
- exc[i]=gain[0]*e[2][i]+gain[1]*e[1][i]+gain[2]*e[0][i];
+ exc[i]=MULT16_16(sgain[0],SHR(e[2][i],6))+MULT16_16(sgain[1],SHR(e[1][i],6))+MULT16_16(sgain[2],SHR(e[0][i],6));
- err1=0;
- err2=0;
+ err=0;
for (i=0;i<nsf;i++)
- err1+=target[i]*target[i];
+ {
+ spx_sig_t perr=target[i]-(MULT16_16(sgain[0],SHR(x[2][i],6))+MULT16_16(sgain[1],SHR(x[1][i],6))+MULT16_16(sgain[2],SHR(x[0][i],6)));
+ spx_word16_t perr2 = SHR(perr,15);
+ err += MULT16_16(perr2,perr2);
+
+ }
+#else
for (i=0;i<nsf;i++)
- err2+=(target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i])
+ exc[i]=gain[0]*e[2][i]+gain[1]*e[1][i]+gain[2]*e[0][i];
+
+ err=0;
+ for (i=0;i<nsf;i++)
+ err+=(target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i])
* (target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i]);
+#endif
- return err2;
+ return err;
}
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list