[xiph-commits] r9166 - trunk/speex/libspeex
jm at motherfish-iii.xiph.org
jm at motherfish-iii.xiph.org
Fri Apr 22 00:39:33 PDT 2005
Author: jm
Date: 2005-04-22 00:39:29 -0700 (Fri, 22 Apr 2005)
New Revision: 9166
Modified:
trunk/speex/libspeex/arch.h
trunk/speex/libspeex/cb_search.c
trunk/speex/libspeex/filters.c
trunk/speex/libspeex/fixed_arm4.h
trunk/speex/libspeex/fixed_arm5e.h
trunk/speex/libspeex/fixed_debug.h
trunk/speex/libspeex/fixed_generic.h
trunk/speex/libspeex/lpc.c
trunk/speex/libspeex/lsp.c
trunk/speex/libspeex/ltp.c
trunk/speex/libspeex/ltp.h
trunk/speex/libspeex/math_approx.c
trunk/speex/libspeex/nb_celp.c
trunk/speex/libspeex/quant_lsp.c
trunk/speex/libspeex/vq.c
Log:
More work on fixed-point operators
Modified: trunk/speex/libspeex/arch.h
===================================================================
--- trunk/speex/libspeex/arch.h 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/arch.h 2005-04-22 07:39:29 UTC (rev 9166)
@@ -139,7 +139,7 @@
#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b))
#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b))
-#define MULT16_16_Q11(a,b) ((a)*(b))
+#define MULT16_16_Q11_32(a,b) ((a)*(b))
#define MULT16_16_Q13(a,b) ((a)*(b))
#define MULT16_16_Q14(a,b) ((a)*(b))
#define MULT16_16_Q15(a,b) ((a)*(b))
Modified: trunk/speex/libspeex/cb_search.c
===================================================================
--- trunk/speex/libspeex/cb_search.c 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/cb_search.c 2005-04-22 07:39:29 UTC (rev 9166)
@@ -64,12 +64,12 @@
for (k=0;k<=j;k++)
resj = MAC16_16(resj,shape[k],r[j-k]);
#ifdef FIXED_POINT
- resj = SHR(resj, 11);
+ resj = SHR32(resj, 11);
#else
resj *= 0.03125;
#endif
/* Compute codeword energy */
- E[i]=ADD32(E[i],MULT16_16(resj,resj));
+ E[i]=ADD32(E[i],MULT16_16(EXTRACT16(resj),EXTRACT16(resj)));
res[j] = resj;
/*printf ("%d\n", (int)res[j]);*/
}
@@ -140,7 +140,7 @@
/* FIXME: make that adaptive? */
for (i=0;i<nsf;i++)
- t[i]=SHR(target[i],6);
+ t[i]=EXTRACT16(PSHR32(target[i],6));
compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
@@ -177,10 +177,10 @@
if (sign)
{
for (j=0;j<subvect_size;j++)
- e[subvect_size*i+j]=SHL(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5);
+ 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(SHL(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5));
+ 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++)
@@ -205,7 +205,7 @@
#ifdef FIXED_POINT
g=sign*shape_cb[rind*subvect_size+m];
for (n=subvect_size*(i+1);n<nsf;n++,q++)
- t[n] = SUB32(t[n],MULT16_16_Q11(g,r[q]));
+ t[n] = SUB32(t[n],MULT16_16_Q11_32(g,r[q]));
#else
g=sign*0.03125*shape_cb[rind*subvect_size+m];
for (n=subvect_size*(i+1);n<nsf;n++,q++)
@@ -336,7 +336,7 @@
/* FIXME: make that adaptive? */
for (i=0;i<nsf;i++)
- t[i]=SHR(target[i],6);
+ t[i]=EXTRACT16(PSHR32(target[i],6));
for (j=0;j<N;j++)
for (i=0;i<nsf;i++)
@@ -427,7 +427,7 @@
#ifdef FIXED_POINT
g=sign*shape_cb[rind*subvect_size+m];
for (n=subvect_size*(i+1);n<nsf;n++,q++)
- t[n] = SUB32(t[n],MULT16_16_Q11(g,r[q]));
+ t[n] = SUB32(t[n],MULT16_16_Q11_32(g,r[q]));
#else
g=sign*0.03125*shape_cb[rind*subvect_size+m];
for (n=subvect_size*(i+1);n<nsf;n++,q++)
@@ -500,10 +500,10 @@
if (sign==1)
{
for (j=0;j<subvect_size;j++)
- e[subvect_size*i+j]=SHL(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5);
+ 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(SHL(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5));
+ 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++)
@@ -569,10 +569,10 @@
if (s==1)
{
for (j=0;j<subvect_size;j++)
- exc[subvect_size*i+j]=SHL((spx_word32_t)shape_cb[ind[i]*subvect_size+j],SIG_SHIFT-5);
+ exc[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[ind[i]*subvect_size+j]),SIG_SHIFT-5);
} else {
for (j=0;j<subvect_size;j++)
- exc[subvect_size*i+j]=NEG32(SHL(EXTEND32(shape_cb[ind[i]*subvect_size+j]),SIG_SHIFT-5));
+ exc[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[ind[i]*subvect_size+j]),SIG_SHIFT-5));
}
#else
for (j=0;j<subvect_size;j++)
Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/filters.c 2005-04-22 07:39:29 UTC (rev 9166)
@@ -62,7 +62,7 @@
int i;
for (i=0;i<len;i++)
{
- y[i] = SHL(MULT16_32_Q14(SHR(x[i],7),scale),7);
+ y[i] = SHL32(MULT16_32_Q14(EXTRACT16(SHR32(x[i],7)),scale),7);
}
}
@@ -71,11 +71,11 @@
int i;
spx_word16_t scale_1;
- scale = PSHR(scale, SIG_SHIFT);
+ scale = PSHR32(scale, SIG_SHIFT);
if (scale<2)
scale_1 = 32767;
else
- scale_1 = 32767/scale;
+ scale_1 = EXTRACT16(DIV32(32767,scale));
for (i=0;i<len;i++)
{
y[i] = MULT16_32_Q15(scale_1,x[i]);
@@ -133,18 +133,18 @@
{
spx_word32_t sum2=0;
spx_word16_t tmp;
- tmp = SHR(x[i],sig_shift);
+ tmp = EXTRACT16(SHR32(x[i],sig_shift));
sum2 = MAC16_16(sum2,tmp,tmp);
- tmp = SHR(x[i+1],sig_shift);
+ tmp = EXTRACT16(SHR32(x[i+1],sig_shift));
sum2 = MAC16_16(sum2,tmp,tmp);
- tmp = SHR(x[i+2],sig_shift);
+ tmp = EXTRACT16(SHR32(x[i+2],sig_shift));
sum2 = MAC16_16(sum2,tmp,tmp);
- tmp = SHR(x[i+3],sig_shift);
+ tmp = EXTRACT16(SHR32(x[i+3],sig_shift));
sum2 = MAC16_16(sum2,tmp,tmp);
- sum = ADD32(sum,SHR(sum2,6));
+ sum = ADD32(sum,SHR32(sum2,6));
}
- return SHR(SHL((spx_word32_t)spx_sqrt(1+DIV32(sum,len)),(sig_shift+3)),SIG_SHIFT);
+ return EXTRACT16(SHR32(SHL32(EXTEND32(spx_sqrt(1+DIV32(sum,len))),(sig_shift+3)),SIG_SHIFT));
}
#if defined(ARM4_ASM) || defined(ARM5E_ASM)
@@ -162,7 +162,7 @@
{
spx_sig_t tmp = x[i];
if (tmp<0)
- tmp = -tmp;
+ tmp = NEG32(tmp);
if (tmp >= max_val)
max_val = tmp;
}
@@ -175,7 +175,7 @@
}
for (i=0;i<len;i++)
- y[i] = SHR(x[i], sig_shift);
+ y[i] = EXTRACT16(SHR32(x[i], sig_shift));
return sig_shift;
}
@@ -418,9 +418,9 @@
mem1[i] = mem2[i] = 0;
for (i=0;i<N;i++)
{
- y1 = ADD16(y[i], PSHR(mem1[0],LPC_SHIFT));
+ y1 = ADD16(y[i], EXTRACT16(PSHR32(mem1[0],LPC_SHIFT)));
ny1i = NEG16(y1);
- y[i] = ADD16(SHL(y1,1), PSHR(mem2[0],LPC_SHIFT));
+ y[i] = ADD16(SHL16(y1,1), EXTRACT16(PSHR32(mem2[0],LPC_SHIFT)));
ny2i = NEG16(y[i]);
for (j=0;j<ord-1;j++)
{
Modified: trunk/speex/libspeex/fixed_arm4.h
===================================================================
--- trunk/speex/libspeex/fixed_arm4.h 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/fixed_arm4.h 2005-04-22 07:39:29 UTC (rev 9166)
@@ -106,7 +106,7 @@
#define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11)))
#define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13)))
-#define MULT16_16_Q11(a,b) (SHR(MULT16_16((a),(b)),11))
+#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11))
#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
Modified: trunk/speex/libspeex/fixed_arm5e.h
===================================================================
--- trunk/speex/libspeex/fixed_arm5e.h 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/fixed_arm5e.h 2005-04-22 07:39:29 UTC (rev 9166)
@@ -116,7 +116,7 @@
#define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11)))
#define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13)))
-#define MULT16_16_Q11(a,b) (SHR(MULT16_16((a),(b)),11))
+#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11))
#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
Modified: trunk/speex/libspeex/fixed_debug.h
===================================================================
--- trunk/speex/libspeex/fixed_debug.h 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/fixed_debug.h 2005-04-22 07:39:29 UTC (rev 9166)
@@ -244,7 +244,6 @@
spx_mips++;
return res;
}
-#define MULT16_16B(a,b) (((short)(a))*((short)(b)))
#define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b))))
#define MAC16_16_Q11(c,a,b) (ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),11))))
@@ -254,11 +253,11 @@
#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR32((b),13)), SHR32(MULT16_16((a),((b)&0x00001fff)),13))
#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR32((b),14)), SHR32(MULT16_16((a),((b)&0x00003fff)),14))
-#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))
-#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)))
+#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR32((b),11)), SHR32(MULT16_16((a),((b)&0x000007ff)),11))
+#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR32((b),11)), SHR32(MULT16_16((a),((b)&0x000007ff)),11)))
-#define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
-#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))
+#define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR32((b),15)), SHR32(MULT16_16((a),((b)&0x00007fff)),15))
+#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR32((b),15)), SHR32(MULT16_16((a),((b)&0x00007fff)),15)))
static inline int SATURATE(int a, int b)
{
@@ -269,7 +268,7 @@
return a;
}
-static inline short MULT16_16_Q11(int a, int b)
+static inline int MULT16_16_Q11_32(int a, int b)
{
long long res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
@@ -278,9 +277,9 @@
}
res = ((long long)a)*b;
res >>= 11;
- if (!VERIFY_SHORT(res))
+ if (!VERIFY_INT(res))
fprintf (stderr, "MULT16_16_Q11: output is not short: %d*%d=%d\n", (int)a, (int)b, (int)res);
- spx_mips++;
+ spx_mips+=3;
return res;
}
static inline short MULT16_16_Q13(int a, int b)
@@ -294,7 +293,7 @@
res >>= 13;
if (!VERIFY_SHORT(res))
fprintf (stderr, "MULT16_16_Q13: output is not short: %d*%d=%d\n", a, b, (int)res);
- spx_mips++;
+ spx_mips+=3;
return res;
}
static inline short MULT16_16_Q14(int a, int b)
@@ -308,7 +307,7 @@
res >>= 14;
if (!VERIFY_SHORT(res))
fprintf (stderr, "MULT16_16_Q14: output is not short: %d\n", (int)res);
- spx_mips++;
+ spx_mips+=3;
return res;
}
static inline short MULT16_16_Q15(int a, int b)
@@ -322,7 +321,7 @@
res >>= 15;
if (!VERIFY_SHORT(res))
fprintf (stderr, "MULT16_16_Q15: output is not short: %d\n", (int)res);
- spx_mips++;
+ spx_mips+=3;
return res;
}
@@ -340,7 +339,7 @@
res >>= 13;
if (!VERIFY_SHORT(res))
fprintf (stderr, "MULT16_16_P13: output is not short: %d*%d=%d\n", a, b, (int)res);
- spx_mips++;
+ spx_mips+=4;
return res;
}
static inline short MULT16_16_P14(int a, int b)
@@ -357,7 +356,7 @@
res >>= 14;
if (!VERIFY_SHORT(res))
fprintf (stderr, "MULT16_16_P14: output is not short: %d*%d=%d\n", a, b, (int)res);
- spx_mips++;
+ spx_mips+=4;
return res;
}
static inline short MULT16_16_P15(int a, int b)
@@ -374,7 +373,7 @@
res >>= 15;
if (!VERIFY_SHORT(res))
fprintf (stderr, "MULT16_16_P15: output is not short: %d*%d=%d\n", a, b, (int)res);
- spx_mips++;
+ spx_mips+=4;
return res;
}
Modified: trunk/speex/libspeex/fixed_generic.h
===================================================================
--- trunk/speex/libspeex/fixed_generic.h 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/fixed_generic.h 2005-04-22 07:39:29 UTC (rev 9166)
@@ -86,7 +86,7 @@
#define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11)))
#define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13)))
-#define MULT16_16_Q11(a,b) (SHR(MULT16_16((a),(b)),11))
+#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11))
#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
Modified: trunk/speex/libspeex/lpc.c
===================================================================
--- trunk/speex/libspeex/lpc.c 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/lpc.c 2005-04-22 07:39:29 UTC (rev 9166)
@@ -135,7 +135,7 @@
int shift, ac_shift;
for (j=0;j<n;j++)
- ac0 = ADD32(ac0,SHR(MULT16_16(x[j],x[j]),8));
+ ac0 = ADD32(ac0,SHR32(MULT16_16(x[j],x[j]),8));
ac0 = ADD32(ac0,n);
shift = 8;
while (shift && ac0<0x40000000)
@@ -156,10 +156,10 @@
d=0;
for (j=i;j<n;j++)
{
- d = ADD32(d,SHR(MULT16_16(x[j],x[j-i]), shift));
+ d = ADD32(d,SHR32(MULT16_16(x[j],x[j-i]), shift));
}
- ac[i] = SHR(d, ac_shift);
+ ac[i] = SHR32(d, ac_shift);
}
}
Modified: trunk/speex/libspeex/lsp.c
===================================================================
--- trunk/speex/libspeex/lsp.c 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/lsp.c 2005-04-22 07:39:29 UTC (rev 9166)
@@ -88,7 +88,7 @@
#define FREQ_SCALE 16384
/*#define ANGLE2X(a) (32768*cos(((a)/8192.)))*/
-#define ANGLE2X(a) (SHL(spx_cos(a),2))
+#define ANGLE2X(a) (SHL16(spx_cos(a),2))
/*#define X2ANGLE(x) (acos(.00006103515625*(x))*LSP_SCALING)*/
#define X2ANGLE(x) (spx_acos(x))
@@ -292,8 +292,8 @@
px++;
qx++;
}
- P[m] = PSHR(P[m],3);
- Q[m] = PSHR(Q[m],3);
+ P[m] = PSHR32(P[m],3);
+ Q[m] = PSHR32(Q[m],3);
#else
*px++ = LPC_SCALING;
*qx++ = LPC_SCALING;
@@ -335,7 +335,7 @@
#ifdef FIXED_POINT
dd = MULT16_16_Q15(delta,SUB16(FREQ_SCALE, MULT16_16_Q14(MULT16_16_Q14(xl,xl),14000)));
if (psuml<512 && psuml>-512)
- dd = PSHR(dd,1);
+ dd = PSHR16(dd,1);
#else
dd=delta*(1-.9*xl*xl);
if (fabs(psuml)<.2)
@@ -362,7 +362,7 @@
psumm=psuml;
for(k=0;k<=nb;k++){
#ifdef FIXED_POINT
- xm = ADD16(PSHR(xl,1),PSHR(xr,1)); /* bisect the interval */
+ xm = ADD16(PSHR16(xl,1),PSHR16(xr,1)); /* bisect the interval */
#else
xm = .5*(xl+xr); /* bisect the interval */
#endif
@@ -472,7 +472,7 @@
else if (xout1 + xout2 < -SHL(32766,8))
ak[j] = -32767;
else
- ak[j] = PSHR(ADD32(xout1,xout2),8);
+ ak[j] = EXTRACT16(PSHR32(ADD32(xout1,xout2),8));
*(n4+1) = xin1;
*(n4+2) = xin2;
@@ -568,7 +568,7 @@
lsp[i]=lsp[i-1]+m;
if (lsp[i]>lsp[i+1]-m)
- lsp[i]= SHR(lsp[i],1) + SHR(lsp[i+1]-m,1);
+ lsp[i]= SHR16(lsp[i],1) + SHR16(lsp[i+1]-m,1);
}
}
@@ -576,7 +576,7 @@
void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes)
{
int i;
- spx_word16_t tmp = DIV32_16(SHL(1 + subframe,14),nb_subframes);
+ spx_word16_t tmp = DIV32_16(SHL32(1 + subframe,14),nb_subframes);
spx_word16_t tmp2 = 16384-tmp;
for (i=0;i<len;i++)
{
Modified: trunk/speex/libspeex/ltp.c
===================================================================
--- trunk/speex/libspeex/ltp.c 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/ltp.c 2005-04-22 07:39:29 UTC (rev 9166)
@@ -63,7 +63,7 @@
part = MAC16_16(part,x[i+1],y[i+1]);
part = MAC16_16(part,x[i+2],y[i+2]);
part = MAC16_16(part,x[i+3],y[i+3]);
- sum = ADD32(sum,SHR(part,6));
+ sum = ADD32(sum,SHR32(part,6));
}
return sum;
}
@@ -119,10 +119,10 @@
x++;
y3=*y++;
- sum1 = ADD32(sum1,SHR(part1,6));
- sum2 = ADD32(sum2,SHR(part2,6));
- sum3 = ADD32(sum3,SHR(part3,6));
- sum4 = ADD32(sum4,SHR(part4,6));
+ sum1 = ADD32(sum1,SHR32(part1,6));
+ sum2 = ADD32(sum2,SHR32(part2,6));
+ sum3 = ADD32(sum3,SHR32(part3,6));
+ sum4 = ADD32(sum4,SHR32(part4,6));
}
corr[nb_pitch-1-i]=sum1;
corr[nb_pitch-2-i]=sum2;
@@ -184,7 +184,7 @@
for (i=start;i<=end;i++)
{
/* Update energy for next pitch*/
- energy[i-start+1] = energy[i-start] + SHR(MULT16_16(swn[-i-1],swn[-i-1]),6) - SHR(MULT16_16(swn[-i+len-1],swn[-i+len-1]),6);
+ energy[i-start+1] = SUB32(ADD32(energy[i-start],SHR32(MULT16_16(swn[-i-1],swn[-i-1]),6)), SHR32(MULT16_16(swn[-i+len-1],swn[-i+len-1]),6));
}
pitch_xcorr(swn, swn-end, corr, len, end-start+1, stack);
@@ -205,12 +205,12 @@
tmp = corr16[i-start];
if (tmp>0)
{
- if (SHR(corr16[i-start],4)>ener16[i-start])
- tmp = SHL((spx_word32_t)ener16[i-start],14);
- else if (-SHR(corr16[i-start],4)>ener16[i-start])
- tmp = -SHL((spx_word32_t)ener16[i-start],14);
+ if (SHR16(corr16[i-start],4)>ener16[i-start])
+ tmp = SHL32(EXTEND32(ener16[i-start]),14);
+ else if (-SHR16(corr16[i-start],4)>ener16[i-start])
+ tmp = -SHL32(EXTEND32(ener16[i-start]),14);
else
- tmp = SHL(tmp,10);
+ tmp = SHL32(tmp,10);
g = DIV32_16(tmp, 8+ener16[i-start]);
score[i-start] = MULT16_16(corr16[i-start],g);
} else
@@ -260,7 +260,7 @@
{
spx_word16_t g;
i=pitch[j];
- g = DIV32(corr[i-start], 10+SHR(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),6));
+ g = DIV32(corr[i-start], 10+SHR32(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),6));
/* FIXME: g = max(g,corr/energy) */
if (g<0)
g = 0;
@@ -337,7 +337,7 @@
x[i][0]=0;
for (j=0;j<nsf;j++)
{
- x[i][j]=ADD32(x[i][j],SHL(MULT16_32_Q15(r[j], e[i][0]),1));
+ x[i][j]=ADD32(x[i][j],SHL32(MULT16_32_Q15(r[j], e[i][0]),1));
}
}
}
@@ -394,12 +394,12 @@
{
for (i=0;i<nsf;i++)
{
- y[j][i] = SHR(x[j][i],sig_shift);
+ y[j][i] = EXTRACT16(SHR32(x[j][i],sig_shift));
}
- }
+ }
for (i=0;i<nsf;i++)
{
- t[i] = SHR(target[i],sig_shift);
+ t[i] = EXTRACT16(SHR32(target[i],sig_shift));
}
for (i=0;i<3;i++)
@@ -467,9 +467,9 @@
}
}
#ifdef FIXED_POINT
- gain[0] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3];
- gain[1] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3+1];
- gain[2] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3+2];
+ gain[0] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*3]);
+ gain[1] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*3+1]);
+ gain[2] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*3+2]);
#else
gain[0] = 0.015625*gain_cdbk[best_cdbk*3] + .5;
gain[1] = 0.015625*gain_cdbk[best_cdbk*3+1]+ .5;
@@ -480,16 +480,18 @@
#ifdef FIXED_POINT
for (i=0;i<nsf;i++)
- exc[i]=SHL(MULT16_32_Q15(SHL(gain[0],7),e[2][i])+MULT16_32_Q15(SHL(gain[1],7),e[1][i])+MULT16_32_Q15(SHL(gain[2],7),e[0][i]),2);
+ exc[i]=SHL32(ADD32(ADD32(MULT16_32_Q15(SHL16(gain[0],7),e[2][i]), MULT16_32_Q15(SHL16(gain[1],7),e[1][i])),
+ MULT16_32_Q15(SHL16(gain[2],7),e[0][i])), 2);
err=0;
for (i=0;i<nsf;i++)
{
spx_word16_t perr2;
- spx_sig_t tmp = SHL((MULT16_32_Q15(SHL(gain[0],7),x[2][i])+MULT16_32_Q15(SHL(gain[1],7),x[1][i])+MULT16_32_Q15(SHL(gain[2],7),x[0][i])),2);
+ spx_sig_t tmp = SHL32(ADD32(ADD32(MULT16_32_Q15(SHL16(gain[0],7),x[2][i]),MULT16_32_Q15(SHL16(gain[1],7),x[1][i])),
+ MULT16_32_Q15(SHL16(gain[2],7),x[0][i])),2);
spx_sig_t perr=SUB32(target[i],tmp);
new_target[i] = SUB32(target[i], tmp);
- perr2 = PSHR(perr,15);
+ perr2 = EXTRACT16(PSHR32(perr,15));
err = ADD64(err,MULT16_16(perr2,perr2));
}
@@ -711,7 +713,8 @@
#ifdef FIXED_POINT
{
for (i=0;i<nsf;i++)
- exc[i]=SHL(MULT16_32_Q15(SHL(gain[0],7),e[2][i])+MULT16_32_Q15(SHL(gain[1],7),e[1][i])+MULT16_32_Q15(SHL(gain[2],7),e[0][i]),2);
+ exc[i]=SHL32(ADD32(ADD32(MULT16_32_Q15(SHL16(gain[0],7),e[2][i]), MULT16_32_Q15(SHL16(gain[1],7),e[1][i])),
+ MULT16_32_Q15(SHL16(gain[2],7),e[0][i])), 2);
}
#else
for (i=0;i<nsf;i++)
Modified: trunk/speex/libspeex/ltp.h
===================================================================
--- trunk/speex/libspeex/ltp.h 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/ltp.h 2005-04-22 07:39:29 UTC (rev 9166)
@@ -40,7 +40,7 @@
} ltp_params;
#ifdef FIXED_POINT
-#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -SHR(g[0],1)) + (g[2]>0 ? g[2] : -SHR(g[2],1)))
+#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -SHR16(g[0],1)) + (g[2]>0 ? g[2] : -SHR16(g[2],1)))
#else
#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -.5*g[0]) + (g[2]>0 ? g[2] : -.5*g[2]))
#endif
Modified: trunk/speex/libspeex/math_approx.c
===================================================================
--- trunk/speex/libspeex/math_approx.c 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/math_approx.c 2005-04-22 07:39:29 UTC (rev 9166)
@@ -110,21 +110,21 @@
{
int s=0;
spx_word16_t ret;
- spx_word32_t sq;
+ spx_word16_t sq;
if (x<0)
{
s=1;
- x = -x;
+ x = NEG16(x);
}
- x = 16384-x;
+ x = SUB16(16384,x);
x = x >> 1;
sq = MULT16_16_Q13(x, ADD16(A1, MULT16_16_Q13(x, ADD16(A2, MULT16_16_Q13(x, (A3))))));
- ret = spx_sqrt(SHL(sq,13));
+ ret = spx_sqrt(SHL32(EXTEND32(sq),13));
/*ret = spx_sqrt(67108864*(-1.6129e-04 + 2.0104e+00*f + 2.7373e-01*f*f + 1.8136e-01*f*f*f));*/
if (s)
- ret = 25736-ret;
+ ret = SUB16(25736,ret);
return ret;
}
Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/nb_celp.c 2005-04-22 07:39:29 UTC (rev 9166)
@@ -803,14 +803,14 @@
/*FIXME: Should use DIV32_16 and make sure result fits in 16 bits */
#ifdef FIXED_POINT
{
- spx_word32_t f = DIV32(ener,PSHR(ol_gain,SIG_SHIFT));
+ spx_word32_t f = DIV32(ener,PSHR32(ol_gain,SIG_SHIFT));
if (f<32768)
fine_gain = f;
else
fine_gain = 32767;
}
#else
- fine_gain = DIV32_16(ener,PSHR(ol_gain,SIG_SHIFT));
+ fine_gain = DIV32_16(ener,PSHR32(ol_gain,SIG_SHIFT));
#endif
/* Calculate gain correction for the sub-frame (if any) */
if (SUBMODE(have_subframe_gain))
@@ -904,7 +904,7 @@
/* Replace input by synthesized speech */
for (i=0;i<st->frameSize;i++)
{
- spx_word32_t sig = PSHR(st->frame[i],SIG_SHIFT);
+ spx_word32_t sig = PSHR32(st->frame[i],SIG_SHIFT);
if (sig>32767)
sig = 32767;
if (sig<-32767)
@@ -1102,7 +1102,7 @@
for (i=0;i<st->frameSize;i++)
{
- spx_word32_t sig = PSHR(st->frame[i],SIG_SHIFT);
+ spx_word32_t sig = PSHR32(st->frame[i],SIG_SHIFT);
if (sig>32767)
sig = 32767;
if (sig<-32767)
@@ -1267,7 +1267,7 @@
for (i=0;i<st->frameSize;i++)
{
- spx_word32_t sig = PSHR(st->frame[i],SIG_SHIFT);
+ spx_word32_t sig = PSHR32(st->frame[i],SIG_SHIFT);
if (sig>32767)
sig = 32767;
if (sig<-32767)
@@ -1609,7 +1609,7 @@
/*Copy output signal*/
for (i=0;i<st->frameSize;i++)
{
- spx_word32_t sig = PSHR(st->frame[i],SIG_SHIFT);
+ spx_word32_t sig = PSHR32(st->frame[i],SIG_SHIFT);
if (sig>32767)
sig = 32767;
if (sig<-32767)
@@ -1629,7 +1629,7 @@
st->count_lost=0;
st->last_pitch = best_pitch;
#ifdef FIXED_POINT
- st->last_pitch_gain = PSHR(pitch_average,2);
+ st->last_pitch_gain = PSHR16(pitch_average,2);
#else
st->last_pitch_gain = .25*pitch_average;
#endif
Modified: trunk/speex/libspeex/quant_lsp.c
===================================================================
--- trunk/speex/libspeex/quant_lsp.c 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/quant_lsp.c 2005-04-22 07:39:29 UTC (rev 9166)
@@ -45,11 +45,11 @@
#ifdef FIXED_POINT
-#define LSP_LINEAR(i) (SHL(i+1,11))
+#define LSP_LINEAR(i) (SHL16(i+1,11))
#define LSP_LINEAR_HIGH(i) (ADD16(MULT16_16_16(i,2560),6144))
-#define LSP_DIV_256(x) (SHL((spx_word16_t)x, 5))
-#define LSP_DIV_512(x) (SHL((spx_word16_t)x, 4))
-#define LSP_DIV_1024(x) (SHL((spx_word16_t)x, 3))
+#define LSP_DIV_256(x) (SHL16((spx_word16_t)x, 5))
+#define LSP_DIV_512(x) (SHL16((spx_word16_t)x, 4))
+#define LSP_DIV_1024(x) (SHL16((spx_word16_t)x, 3))
#define LSP_PI 25736
#else
@@ -103,7 +103,7 @@
dist=0;
for (j=0;j<nbDim;j++)
{
- tmp=SUB16(x[j],SHL((spx_word16_t)*ptr++,5));
+ tmp=SUB16(x[j],SHL16((spx_word16_t)*ptr++,5));
dist=MAC16_16(dist,tmp,tmp);
}
if (dist<best_dist || i==0)
@@ -114,7 +114,7 @@
}
for (j=0;j<nbDim;j++)
- x[j] = SUB16(x[j],SHL((spx_word16_t)cdbk[best_id*nbDim+j],5));
+ x[j] = SUB16(x[j],SHL16((spx_word16_t)cdbk[best_id*nbDim+j],5));
return best_id;
}
@@ -133,7 +133,7 @@
dist=0;
for (j=0;j<nbDim;j++)
{
- tmp=SUB16(x[j],SHL((spx_word16_t)*ptr++,5));
+ tmp=SUB16(x[j],SHL16((spx_word16_t)*ptr++,5));
dist=MAC16_32_Q15(dist,weight[j],MULT16_16(tmp,tmp));
}
if (dist<best_dist || i==0)
@@ -144,7 +144,7 @@
}
for (j=0;j<nbDim;j++)
- x[j] = SUB16(x[j],SHL((spx_word16_t)cdbk[best_id*nbDim+j],5));
+ x[j] = SUB16(x[j],SHL16((spx_word16_t)cdbk[best_id*nbDim+j],5));
return best_id;
}
@@ -193,7 +193,7 @@
#ifdef FIXED_POINT
for (i=0;i<order;i++)
- qlsp[i]=PSHR(qlsp[i],2);
+ qlsp[i]=PSHR16(qlsp[i],2);
#else
for (i=0;i<order;i++)
qlsp[i]=qlsp[i] * .00097656;
@@ -212,23 +212,23 @@
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<10;i++)
- lsp[i] += LSP_DIV_256(cdbk_nb[id*10+i]);
+ lsp[i] = ADD32(lsp[i], LSP_DIV_256(cdbk_nb[id*10+i]));
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
- lsp[i] += LSP_DIV_512(cdbk_nb_low1[id*5+i]);
+ lsp[i] = ADD16(lsp[i], LSP_DIV_512(cdbk_nb_low1[id*5+i]));
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
- lsp[i] += LSP_DIV_1024(cdbk_nb_low2[id*5+i]);
+ lsp[i] = ADD32(lsp[i], LSP_DIV_1024(cdbk_nb_low2[id*5+i]));
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
- lsp[i+5] += LSP_DIV_512(cdbk_nb_high1[id*5+i]);
+ lsp[i+5] = ADD32(lsp[i+5], LSP_DIV_512(cdbk_nb_high1[id*5+i]));
id=speex_bits_unpack_unsigned(bits, 6);
for (i=0;i<5;i++)
- lsp[i+5] += LSP_DIV_1024(cdbk_nb_high2[id*5+i]);
+ lsp[i+5] = ADD32(lsp[i+5], LSP_DIV_1024(cdbk_nb_high2[id*5+i]));
}
@@ -263,7 +263,7 @@
#ifdef FIXED_POINT
for (i=0;i<order;i++)
- qlsp[i] = PSHR(qlsp[i],1);
+ qlsp[i] = PSHR16(qlsp[i],1);
#else
for (i=0;i<order;i++)
qlsp[i] = qlsp[i]*0.0019531;
@@ -346,7 +346,7 @@
#ifdef FIXED_POINT
for (i=0;i<order;i++)
- qlsp[i] = PSHR(qlsp[i],1);
+ qlsp[i] = PSHR16(qlsp[i],1);
#else
for (i=0;i<order;i++)
qlsp[i] = qlsp[i]*0.0019531;
Modified: trunk/speex/libspeex/vq.c
===================================================================
--- trunk/speex/libspeex/vq.c 2005-04-22 06:23:27 UTC (rev 9165)
+++ trunk/speex/libspeex/vq.c 2005-04-22 07:39:29 UTC (rev 9166)
@@ -138,7 +138,7 @@
for (j=0;j<len;j++)
dist = MAC16_16(dist,in[j],*codebook++);
#ifdef FIXED_POINT
- dist=SUB32(SHR(E[i],1),dist);
+ dist=SUB32(SHR32(E[i],1),dist);
#else
dist=.5f*E[i]-dist;
#endif
@@ -231,7 +231,7 @@
sign=1;
}
#ifdef FIXED_POINT
- dist = ADD32(dist,SHR(E[i],1));
+ dist = ADD32(dist,SHR32(E[i],1));
#else
dist = ADD32(dist,.5f*E[i]);
#endif
More information about the commits
mailing list