[xiph-commits] r12017 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Sat Nov 4 20:17:00 PST 2006
Author: jm
Date: 2006-11-04 20:16:57 -0800 (Sat, 04 Nov 2006)
New Revision: 12017
Modified:
trunk/speex/libspeex/filterbank.c
trunk/speex/libspeex/filterbank.h
trunk/speex/libspeex/preprocess.c
Log:
converted noise averaging to fixed-point, completed hypergeometric function,
removed normalisation of filterbank for fixed-point
Modified: trunk/speex/libspeex/filterbank.c
===================================================================
--- trunk/speex/libspeex/filterbank.c 2006-11-05 03:09:23 UTC (rev 12016)
+++ trunk/speex/libspeex/filterbank.c 2006-11-05 04:16:57 UTC (rev 12017)
@@ -66,8 +66,10 @@
bank->bank_right = speex_alloc(len*sizeof(int));
bank->filter_left = speex_alloc(len*sizeof(spx_word16_t));
bank->filter_right = speex_alloc(len*sizeof(spx_word16_t));
+ /* Think I can safely disable normalisation that for fixed-point (and probably float as well) */
+#ifndef FIXED_POINT
bank->scaling = speex_alloc(banks*sizeof(float));
-
+#endif
for (i=0;i<len;i++)
{
float curr_freq;
@@ -92,6 +94,8 @@
bank->filter_right[i] = Q15(val);
}
+ /* Think I can safely disable normalisation that for fixed-point (and probably float as well) */
+#ifndef FIXED_POINT
for (i=0;i<bank->nb_banks;i++)
bank->scaling[i] = 0;
for (i=0;i<bank->len;i++)
@@ -103,7 +107,7 @@
}
for (i=0;i<bank->nb_banks;i++)
bank->scaling[i] = Q15_ONE/(bank->scaling[i]);
-
+#endif
return bank;
}
@@ -113,7 +117,9 @@
speex_free(bank->bank_right);
speex_free(bank->filter_left);
speex_free(bank->filter_right);
+#ifndef FIXED_POINT
speex_free(bank->scaling);
+#endif
speex_free(bank);
}
@@ -131,9 +137,12 @@
id = bank->bank_right[i];
mel[id] += MULT16_32_P15(bank->filter_right[i],ps[i]);
}
- for (i=0;i<bank->nb_banks;i++)
+ /* Think I can safely disable normalisation that for fixed-point (and probably float as well) */
+#ifndef FIXED_POINT
+ /*for (i=0;i<bank->nb_banks;i++)
mel[i] = MULT16_32_P15(Q15(bank->scaling[i]),mel[i]);
-
+ */
+#endif
}
void filterbank_compute_bank(FilterBank *bank, float *ps, float *mel)
@@ -149,9 +158,10 @@
id = bank->bank_right[i];
mel[id] += bank->filter_right[i]*ps[i];
}
+#ifndef FIXED_POINT
for (i=0;i<bank->nb_banks;i++)
mel[i] *= bank->scaling[i];
-
+#endif
}
void filterbank_compute_psd(FilterBank *bank, float *mel, float *ps)
Modified: trunk/speex/libspeex/filterbank.h
===================================================================
--- trunk/speex/libspeex/filterbank.h 2006-11-05 03:09:23 UTC (rev 12016)
+++ trunk/speex/libspeex/filterbank.h 2006-11-05 04:16:57 UTC (rev 12017)
@@ -41,7 +41,9 @@
int *bank_right;
spx_word16_t *filter_left;
spx_word16_t *filter_right;
+#ifndef FIXED_POINT
float *scaling;
+#endif
int nb_banks;
int len;
} FilterBank;
Modified: trunk/speex/libspeex/preprocess.c
===================================================================
--- trunk/speex/libspeex/preprocess.c 2006-11-05 03:09:23 UTC (rev 12016)
+++ trunk/speex/libspeex/preprocess.c 2006-11-05 04:16:57 UTC (rev 12017)
@@ -281,18 +281,16 @@
{
int ind;
spx_word16_t frac;
- float x;
/* Q13 table */
static const spx_word16_t table[21] = {
6730, 8357, 9868, 11267, 12563, 13770, 14898,
15959, 16961, 17911, 18816, 19682, 20512, 21311,
22082, 22827, 23549, 24250, 24931, 25594, 26241};
- x = EXPIN_SCALING_1*xx;
ind = SHR32(xx,10);
if (ind<0)
- return FRAC_SCALING;
+ return Q15_ONE;
if (ind>19)
- return FRAC_SCALING*(1+.1296/x);
+ return ADD32(EXTEND32(Q15_ONE),EXTEND32(DIV32_16(QCONST32(.1296,23), SHR32(xx,EXPIN_SHIFT-SNR_SHIFT))));
frac = SHL32(xx-SHL32(ind,10),5);
return SHL32(DIV32_16(PSHR32(MULT16_16(Q15_ONE-frac,table[ind]) + MULT16_16(frac,table[ind+1]),7),(spx_sqrt(SHL32(xx,15)+6711))),7);
}
@@ -678,17 +676,15 @@
spx_word32_t *ps=st->ps;
spx_word32_t Zframe;
spx_word16_t Pframe;
- float beta, beta_1;
+ spx_word16_t beta, beta_1;
float echo_floor;
float noise_floor;
st->nb_adapt++;
st->min_count++;
- beta =1.0f/st->nb_adapt;
- if (beta < .03f)
- beta=.03f;
- beta_1 = 1.0f-beta;
+ beta = MAX16(QCONST16(.03,15),DIV32_16(Q15_ONE,st->nb_adapt));
+ beta_1 = Q15_ONE-beta;
M = st->nbands;
/* Deal with residual echo if provided */
if (st->echo_state)
@@ -717,7 +713,7 @@
for (i=0;i<N;i++)
{
if (!st->update_prob[i] || st->ps[i] < PSHR32(st->noise[i], NOISE_SHIFT))
- st->noise[i] = beta_1*st->noise[i] + beta*NOISE_OVERCOMPENS*SHL32(st->ps[i],NOISE_SHIFT);
+ st->noise[i] = MULT16_32_Q15(beta_1,st->noise[i]) + MULT16_32_Q15(beta,SHL32(st->ps[i],NOISE_SHIFT));
}
filterbank_compute_bank32(st->bank, st->noise, st->noise+N);
More information about the commits
mailing list