[xiph-commits] r9303 - trunk/speex/libspeex
jm at motherfish-iii.xiph.org
jm at motherfish-iii.xiph.org
Sun May 22 17:58:33 PDT 2005
Author: jm
Date: 2005-05-22 17:58:30 -0700 (Sun, 22 May 2005)
New Revision: 9303
Modified:
trunk/speex/libspeex/filters.c
trunk/speex/libspeex/filters_arm4.h
trunk/speex/libspeex/filters_sse.h
trunk/speex/libspeex/lsp.c
trunk/speex/libspeex/nb_celp.c
trunk/speex/libspeex/sb_celp.c
Log:
Changed storage of lpc coefficients so that it no longer contains a0 (= 1).
Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c 2005-05-22 23:20:27 UTC (rev 9302)
+++ trunk/speex/libspeex/filters.c 2005-05-23 00:58:30 UTC (rev 9303)
@@ -45,8 +45,7 @@
{
int i;
spx_word16_t tmp=gamma;
- lpc_out[0] = lpc_in[0];
- for (i=1;i<order+1;i++)
+ for (i=0;i<order;i++)
{
lpc_out[i] = MULT16_16_P15(tmp,lpc_in[i]);
tmp = MULT16_16_P15(tmp, gamma);
@@ -193,9 +192,9 @@
nyi = NEG16(yi);
for (j=0;j<ord-1;j++)
{
- mem[j] = MAC16_16(MAC16_16(mem[j+1], num[j+1],xi), den[j+1],nyi);
+ mem[j] = MAC16_16(MAC16_16(mem[j+1], num[j],xi), den[j],nyi);
}
- mem[ord-1] = ADD32(MULT16_16(num[ord],xi), MULT16_16(den[ord],nyi));
+ mem[ord-1] = ADD32(MULT16_16(num[ord-1],xi), MULT16_16(den[ord-1],nyi));
y[i] = SHL32(EXTEND32(yi),SIG_SHIFT);
}
}
@@ -212,9 +211,9 @@
nyi = NEG32(yi);
for (j=0;j<ord-1;j++)
{
- mem[j] = MAC16_32_Q15(MAC16_32_Q15(mem[j+1], num[j+1],xi), den[j+1],nyi);
+ mem[j] = MAC16_32_Q15(MAC16_32_Q15(mem[j+1], num[j],xi), den[j],nyi);
}
- mem[ord-1] = SUB32(MULT16_32_Q15(num[ord],xi), MULT16_32_Q15(den[ord],yi));
+ mem[ord-1] = SUB32(MULT16_32_Q15(num[ord-1],xi), MULT16_32_Q15(den[ord-1],yi));
y[i] = yi;
}
}
@@ -232,9 +231,9 @@
nyi = NEG16(yi);
for (j=0;j<ord-1;j++)
{
- mem[j] = MAC16_16(mem[j+1],den[j+1],nyi);
+ mem[j] = MAC16_16(mem[j+1],den[j],nyi);
}
- mem[ord-1] = MULT16_16(den[ord],nyi);
+ mem[ord-1] = MULT16_16(den[ord-1],nyi);
y[i] = SHL32(EXTEND32(yi),SIG_SHIFT);
}
}
@@ -251,9 +250,9 @@
nyi = NEG32(yi);
for (j=0;j<ord-1;j++)
{
- mem[j] = MAC16_32_Q15(mem[j+1],den[j+1],nyi);
+ mem[j] = MAC16_32_Q15(mem[j+1],den[j],nyi);
}
- mem[ord-1] = MULT16_32_Q15(den[ord],nyi);
+ mem[ord-1] = MULT16_32_Q15(den[ord-1],nyi);
y[i] = yi;
}
}
@@ -274,9 +273,9 @@
yi = EXTRACT16(PSHR32(SATURATE(x[i] + SHL32(mem[0],1),536870911),SIG_SHIFT));
for (j=0;j<ord-1;j++)
{
- mem[j] = MAC16_16(mem[j+1], num[j+1],xi);
+ mem[j] = MAC16_16(mem[j+1], num[j],xi);
}
- mem[ord-1] = MULT16_16(num[ord],xi);
+ mem[ord-1] = MULT16_16(num[ord-1],xi);
y[i] = SHL32(EXTEND32(yi),SIG_SHIFT);
}
}
@@ -292,9 +291,9 @@
yi = xi + SHL32(mem[0],2);
for (j=0;j<ord-1;j++)
{
- mem[j] = MAC16_32_Q15(mem[j+1], num[j+1],xi);
+ mem[j] = MAC16_32_Q15(mem[j+1], num[j],xi);
}
- mem[ord-1] = MULT16_32_Q15(num[ord],xi);
+ mem[ord-1] = MULT16_32_Q15(num[ord-1],xi);
y[i] = SATURATE(yi,805306368);
}
}
@@ -327,13 +326,13 @@
for (i=0;i<N;i++)
{
xi=x[i];
- y[i] = num[0]*xi + mem[0];
+ y[i] = xi + mem[0];
yi=y[i];
for (j=0;j<ord-1;j++)
{
- mem[j] = mem[j+1] + num[j+1]*xi - den[j+1]*yi;
+ mem[j] = mem[j+1] + num[j]*xi - den[j]*yi;
}
- mem[ord-1] = num[ord]*xi - den[ord]*yi;
+ mem[ord-1] = num[ord-1]*xi - den[ord-1]*yi;
}
}
@@ -346,9 +345,9 @@
y[i] = x[i] + mem[0];
for (j=0;j<ord-1;j++)
{
- mem[j] = mem[j+1] - den[j+1]*y[i];
+ mem[j] = mem[j+1] - den[j]*y[i];
}
- mem[ord-1] = - den[ord]*y[i];
+ mem[ord-1] = - den[ord-1]*y[i];
}
}
@@ -360,12 +359,12 @@
for (i=0;i<N;i++)
{
xi=x[i];
- y[i] = num[0]*xi + mem[0];
+ y[i] = xi + mem[0];
for (j=0;j<ord-1;j++)
{
- mem[j] = mem[j+1] + num[j+1]*xi;
+ mem[j] = mem[j+1] + num[j]*xi;
}
- mem[ord-1] = num[ord]*xi;
+ mem[ord-1] = num[ord-1]*xi;
}
}
#endif
@@ -408,8 +407,10 @@
ALLOC(mem1, ord, spx_mem_t);
ALLOC(mem2, ord, spx_mem_t);
- for (i=0;i<ord+1;i++)
- y[i] = awk1[i];
+ y[0] = LPC_SCALING;
+ for (i=0;i<ord;i++)
+ y[i+1] = awk1[i];
+ i++;
for (;i<N;i++)
y[i] = VERY_SMALL;
@@ -423,11 +424,11 @@
ny2i = NEG16(y[i]);
for (j=0;j<ord-1;j++)
{
- mem1[j] = MAC16_16(mem1[j+1], awk2[j+1],ny1i);
- mem2[j] = MAC16_16(mem2[j+1], ak[j+1],ny2i);
+ mem1[j] = MAC16_16(mem1[j+1], awk2[j],ny1i);
+ mem2[j] = MAC16_16(mem2[j+1], ak[j],ny2i);
}
- mem1[ord-1] = MULT16_16(awk2[ord],ny1i);
- mem2[ord-1] = MULT16_16(ak[ord],ny2i);
+ mem1[ord-1] = MULT16_16(awk2[ord-1],ny1i);
+ mem2[ord-1] = MULT16_16(ak[ord-1],ny2i);
}
}
Modified: trunk/speex/libspeex/filters_arm4.h
===================================================================
--- trunk/speex/libspeex/filters_arm4.h 2005-05-22 23:20:27 UTC (rev 9302)
+++ trunk/speex/libspeex/filters_arm4.h 2005-05-23 00:58:30 UTC (rev 9303)
@@ -245,7 +245,7 @@
: "=r" (deadm), "=r" (deadn), "=r" (deadd), "=r" (deadidx),
"=r" (xi), "=r" (nyi), "=r" (dead1), "=r" (dead2),
"=r" (dead3), "=r" (dead4), "=r" (dead5), "=r" (dead6)
- : "0" (mem), "1" (num+1), "2" (den+1), "3" (ord-1), "4" (xi), "5" (nyi)
+ : "0" (mem), "1" (num), "2" (den), "3" (ord-1), "4" (xi), "5" (nyi)
: "cc", "memory");
}
@@ -368,7 +368,7 @@
: "=r" (deadm), "=r" (deadd), "=r" (deadidx), "=r" (nyi),
"=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
"=r" (dead5), "=r" (dead6)
- : "0" (mem), "1" (den+1), "2" (ord-1), "3" (nyi)
+ : "0" (mem), "1" (den), "2" (ord-1), "3" (nyi)
: "cc", "memory");
}
Modified: trunk/speex/libspeex/filters_sse.h
===================================================================
--- trunk/speex/libspeex/filters_sse.h 2005-05-22 23:20:27 UTC (rev 9302)
+++ trunk/speex/libspeex/filters_sse.h 2005-05-23 00:58:30 UTC (rev 9303)
@@ -42,8 +42,8 @@
for (i=0;i<2;i++)
{
mem[i] = _mm_loadu_ps(_mem+4*i);
- num[i] = _mm_loadu_ps(_num+4*i+1);
- den[i] = _mm_loadu_ps(_den+4*i+1);
+ num[i] = _mm_loadu_ps(_num+4*i);
+ den[i] = _mm_loadu_ps(_den+4*i);
}
mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0);
num[2] = _mm_setr_ps(_num[9], _num[10], 0, 0);
@@ -95,8 +95,8 @@
for (i=0;i<2;i++)
{
mem[i] = _mm_loadu_ps(_mem+4*i);
- num[i] = _mm_loadu_ps(_num+4*i+1);
- den[i] = _mm_loadu_ps(_den+4*i+1);
+ num[i] = _mm_loadu_ps(_num+4*i);
+ den[i] = _mm_loadu_ps(_den+4*i);
}
for (i=0;i<N;i++)
@@ -149,7 +149,7 @@
for (i=0;i<2;i++)
{
mem[i] = _mm_loadu_ps(_mem+4*i);
- den[i] = _mm_loadu_ps(_den+4*i+1);
+ den[i] = _mm_loadu_ps(_den+4*i);
}
mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0);
den[2] = _mm_setr_ps(_den[9], _den[10], 0, 0);
@@ -198,7 +198,7 @@
for (i=0;i<2;i++)
{
mem[i] = _mm_loadu_ps(_mem+4*i);
- den[i] = _mm_loadu_ps(_den+4*i+1);
+ den[i] = _mm_loadu_ps(_den+4*i);
}
for (i=0;i<N;i++)
@@ -246,7 +246,7 @@
for (i=0;i<2;i++)
{
mem[i] = _mm_loadu_ps(_mem+4*i);
- num[i] = _mm_loadu_ps(_num+4*i+1);
+ num[i] = _mm_loadu_ps(_num+4*i);
}
mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0);
num[2] = _mm_setr_ps(_num[9], _num[10], 0, 0);
@@ -294,7 +294,7 @@
for (i=0;i<2;i++)
{
mem[i] = _mm_loadu_ps(_mem+4*i);
- num[i] = _mm_loadu_ps(_num+4*i+1);
+ num[i] = _mm_loadu_ps(_num+4*i);
}
for (i=0;i<N;i++)
Modified: trunk/speex/libspeex/lsp.c
===================================================================
--- trunk/speex/libspeex/lsp.c 2005-05-22 23:20:27 UTC (rev 9302)
+++ trunk/speex/libspeex/lsp.c 2005-05-23 00:58:30 UTC (rev 9303)
@@ -275,9 +275,9 @@
#ifdef FIXED_POINT
*px++ = LPC_SCALING;
*qx++ = LPC_SCALING;
- for(i=1;i<=m;i++){
- *px++ = SUB32(ADD32(EXTEND32(a[i]),EXTEND32(a[lpcrdr+1-i])), *p++);
- *qx++ = ADD32(SUB32(EXTEND32(a[i]),EXTEND32(a[lpcrdr+1-i])), *q++);
+ for(i=0;i<m;i++){
+ *px++ = SUB32(ADD32(EXTEND32(a[i]),EXTEND32(a[lpcrdr-i-1])), *p++);
+ *qx++ = ADD32(SUB32(EXTEND32(a[i]),EXTEND32(a[lpcrdr-i-1])), *q++);
}
px = P;
qx = Q;
@@ -298,9 +298,9 @@
#else
*px++ = LPC_SCALING;
*qx++ = LPC_SCALING;
- for(i=1;i<=m;i++){
- *px++ = (a[i]+a[lpcrdr+1-i]) - *p++;
- *qx++ = (a[i]-a[lpcrdr+1-i]) + *q++;
+ for(i=0;i<m;i++){
+ *px++ = (a[i]+a[lpcrdr-1-i]) - *p++;
+ *qx++ = (a[i]-a[lpcrdr-1-i]) + *q++;
}
px = P;
qx = Q;
@@ -467,13 +467,15 @@
xout1 = xin1 + *(n4+1);
xout2 = xin2 - *(n4+2);
/* FIXME: perhaps apply bandwidth expansion in case of overflow? */
- /*FIXME: Is it OK to have a long constant? */
+ if (j>0)
+ {
if (xout1 + xout2>SHL(32766,8))
- ak[j] = 32767;
+ ak[j-1] = 32767;
else if (xout1 + xout2 < -SHL(32766,8))
- ak[j] = -32767;
+ ak[j-1] = -32767;
else
- ak[j] = EXTRACT16(PSHR32(ADD32(xout1,xout2),8));
+ ak[j-1] = EXTRACT16(PSHR32(ADD32(xout1,xout2),8));
+ } else {/*speex_warning_int("ak[0] = ", EXTRACT16(PSHR32(ADD32(xout1,xout2),8)));*/}
*(n4+1) = xin1;
*(n4+2) = xin2;
@@ -538,7 +540,8 @@
}
xout1 = xin1 + *(n4+1);
xout2 = xin2 - *(n4+2);
- ak[j] = (xout1 + xout2)*0.5f;
+ if (j>0)
+ ak[j-1] = (xout1 + xout2)*0.5f;
*(n4+1) = xin1;
*(n4+2) = xin2;
Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c 2005-05-22 23:20:27 UTC (rev 9302)
+++ trunk/speex/libspeex/nb_celp.c 2005-05-23 00:58:30 UTC (rev 9303)
@@ -157,11 +157,11 @@
st->autocorr = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
- st->lpc = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
- st->interp_lpc = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
- st->interp_qlpc = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
- st->bw_lpc1 = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
- st->bw_lpc2 = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
+ st->lpc = speex_alloc((st->lpcSize)*sizeof(spx_coef_t));
+ st->interp_lpc = speex_alloc((st->lpcSize)*sizeof(spx_coef_t));
+ st->interp_qlpc = speex_alloc((st->lpcSize)*sizeof(spx_coef_t));
+ st->bw_lpc1 = speex_alloc((st->lpcSize)*sizeof(spx_coef_t));
+ st->bw_lpc2 = speex_alloc((st->lpcSize)*sizeof(spx_coef_t));
st->lsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
st->qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
@@ -264,8 +264,7 @@
st->autocorr[i] = MULT16_16_Q14(st->autocorr[i],st->lagWindow[i]);
/* Levinson-Durbin */
- _spx_lpc(st->lpc+1, st->autocorr, st->lpcSize);
- st->lpc[0]=(spx_coef_t)LPC_SCALING;
+ _spx_lpc(st->lpc, st->autocorr, st->lpcSize);
/* LPC to LSPs (x-domain) transform */
roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, LSP_DELTA1, stack);
@@ -670,8 +669,8 @@
/* Compute analysis filter gain at w=pi (for use in SB-CELP) */
{
- spx_word32_t pi_g=st->interp_qlpc[0];
- for (i=1;i<=st->lpcSize;i+=2)
+ spx_word32_t pi_g=LPC_SCALING;
+ for (i=0;i<st->lpcSize;i+=2)
{
/*pi_g += -st->interp_qlpc[i] + st->interp_qlpc[i+1];*/
pi_g = ADD32(pi_g, SUB32(st->interp_qlpc[i+1],st->interp_qlpc[i]));
@@ -979,10 +978,10 @@
st->excBuf[i]=0;
st->innov = speex_alloc((st->frameSize)*sizeof(spx_sig_t));
- st->interp_qlpc = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
- st->qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
- st->old_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
- st->interp_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+ st->interp_qlpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+ st->qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+ st->old_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+ st->interp_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
st->mem_sp = speex_alloc((5*st->lpcSize)*sizeof(spx_mem_t));
st->comb_mem = speex_alloc(sizeof(CombFilterMem));
comb_filter_mem_init (st->comb_mem);
@@ -1424,8 +1423,8 @@
/* Compute analysis filter at w=pi */
{
- spx_word32_t pi_g=st->interp_qlpc[0];
- for (i=1;i<=st->lpcSize;i+=2)
+ spx_word32_t pi_g=LPC_SCALING;
+ for (i=0;i<st->lpcSize;i+=2)
{
/*pi_g += -st->interp_qlpc[i] + st->interp_qlpc[i+1];*/
pi_g = ADD32(pi_g, SUB32(st->interp_qlpc[i+1],st->interp_qlpc[i]));
Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c 2005-05-22 23:20:27 UTC (rev 9302)
+++ trunk/speex/libspeex/sb_celp.c 2005-05-23 00:58:30 UTC (rev 9303)
@@ -286,17 +286,17 @@
st->lagWindow[i]=16384*exp(-.5*sqr(2*M_PI*st->lag_factor*i));
st->autocorr = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
- st->lpc = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
- st->bw_lpc1 = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
- st->bw_lpc2 = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
- st->lsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
- st->qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
- st->old_lsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
- st->old_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
- st->interp_lsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
- st->interp_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
- st->interp_lpc = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
- st->interp_qlpc = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
+ st->lpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+ st->bw_lpc1 = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+ st->bw_lpc2 = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+ st->lsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+ st->qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+ st->old_lsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+ st->old_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+ st->interp_lsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+ st->interp_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+ st->interp_lpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+ st->interp_qlpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
st->mem_sp = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
@@ -405,8 +405,7 @@
st->autocorr[i] = MULT16_16_Q14(st->autocorr[i],st->lagWindow[i]);
/* Levinson-Durbin */
- _spx_lpc(st->lpc+1, st->autocorr, st->lpcSize);
- st->lpc[0] = (spx_coef_t)LPC_SCALING;
+ _spx_lpc(st->lpc, st->autocorr, st->lpcSize);
/* LPC to LSPs (x-domain) transform */
roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, LSP_DELTA1, stack);
@@ -588,7 +587,7 @@
filters */
st->pi_gain[sub]=LPC_SCALING;
rh = LPC_SCALING;
- for (i=1;i<=st->lpcSize;i+=2)
+ for (i=0;i<st->lpcSize;i+=2)
{
rh += st->interp_qlpc[i+1] - st->interp_qlpc[i];
st->pi_gain[sub] += st->interp_qlpc[i] + st->interp_qlpc[i+1];
@@ -829,8 +828,8 @@
st->qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
st->old_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
- st->interp_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
- st->interp_qlpc = speex_alloc((st->lpcSize+1)*sizeof(spx_coef_t));
+ st->interp_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+ st->interp_qlpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
st->mem_sp = speex_alloc((2*st->lpcSize)*sizeof(spx_mem_t));
@@ -1092,7 +1091,7 @@
st->pi_gain[sub]=LPC_SCALING;
rh = LPC_SCALING;
- for (i=1;i<=st->lpcSize;i+=2)
+ for (i=0;i<st->lpcSize;i+=2)
{
rh += st->interp_qlpc[i+1] - st->interp_qlpc[i];
st->pi_gain[sub] += st->interp_qlpc[i] + st->interp_qlpc[i+1];
More information about the commits
mailing list