[xiph-commits] r10649 - in trunk/speex: include/speex libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Mon Dec 19 02:29:03 PST 2005
Author: jm
Date: 2005-12-19 02:28:57 -0800 (Mon, 19 Dec 2005)
New Revision: 10649
Modified:
trunk/speex/include/speex/speex_echo.h
trunk/speex/include/speex/speex_preprocess.h
trunk/speex/libspeex/mdf.c
trunk/speex/libspeex/preprocess.c
trunk/speex/libspeex/pseudofloat.h
Log:
Converted leak spectral estimation array to int32.
Modified: trunk/speex/include/speex/speex_echo.h
===================================================================
--- trunk/speex/include/speex/speex_echo.h 2005-12-18 21:56:40 UTC (rev 10648)
+++ trunk/speex/include/speex/speex_echo.h 2005-12-19 10:28:57 UTC (rev 10649)
@@ -34,6 +34,8 @@
#ifndef SPEEX_ECHO_H
#define SPEEX_ECHO_H
+#include "misc.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -50,7 +52,7 @@
void speex_echo_state_destroy(SpeexEchoState *st);
/** Performs echo cancellation a frame */
-void speex_echo_cancel(SpeexEchoState *st, short *ref, short *echo, short *out, float *Y);
+void speex_echo_cancel(SpeexEchoState *st, short *ref, short *echo, short *out, spx_int32_t *Y);
/** Reset the echo canceller state */
void speex_echo_state_reset(SpeexEchoState *st);
Modified: trunk/speex/include/speex/speex_preprocess.h
===================================================================
--- trunk/speex/include/speex/speex_preprocess.h 2005-12-18 21:56:40 UTC (rev 10648)
+++ trunk/speex/include/speex/speex_preprocess.h 2005-12-19 10:28:57 UTC (rev 10649)
@@ -113,10 +113,10 @@
void speex_preprocess_state_destroy(SpeexPreprocessState *st);
/** Preprocess a frame */
-int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, float *echo);
+int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo);
/** Preprocess a frame */
-void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, float *echo);
+void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo);
/** Used like the ioctl function to control the preprocessor parameters */
int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr);
Modified: trunk/speex/libspeex/mdf.c
===================================================================
--- trunk/speex/libspeex/mdf.c 2005-12-18 21:56:40 UTC (rev 10648)
+++ trunk/speex/libspeex/mdf.c 2005-12-19 10:28:57 UTC (rev 10649)
@@ -312,7 +312,7 @@
extern int fixed_point;
/** Performs echo cancellation on a frame */
-void speex_echo_cancel(SpeexEchoState *st, short *ref, short *echo, short *out, float *Yout)
+void speex_echo_cancel(SpeexEchoState *st, short *ref, short *echo, short *out, spx_int32_t *Yout)
{
int i,j;
int N,M;
@@ -573,6 +573,7 @@
/* Compute spectrum of estimated echo for use in an echo post-filter (if necessary)*/
if (Yout)
{
+ spx_word16_t leak2;
if (st->adapted)
{
/* If the filter is adapted, take the filtered echo */
@@ -594,9 +595,20 @@
spx_fft(st->fft_table, st->y, st->Y);
power_spectrum(st->Y, st->Yps, N);
+#ifdef FIXED_POINT
+ if (leak_estimate > 16383)
+ leak2 = 32767;
+ else
+ leak2 = SHL16(leak_estimate, 1);
+#else
+ if (leak_estimate>.5)
+ leak2 = 1;
+ else
+ leak2 = 2*leak_estimate;
+#endif
/* Estimate residual echo */
for (i=0;i<=st->frame_size;i++)
- Yout[i] = N*N*max(.2,3.f*leak_estimate)*st->Yps[i];
+ Yout[i] = MULT16_32_Q15(leak2,st->Yps[i]);
}
}
Modified: trunk/speex/libspeex/preprocess.c
===================================================================
--- trunk/speex/libspeex/preprocess.c 2005-12-18 21:56:40 UTC (rev 10648)
+++ trunk/speex/libspeex/preprocess.c 2005-12-19 10:28:57 UTC (rev 10649)
@@ -280,7 +280,7 @@
speex_free(st);
}
-static void update_noise(SpeexPreprocessState *st, float *ps, float *echo)
+static void update_noise(SpeexPreprocessState *st, float *ps, spx_int32_t *echo)
{
int i;
float beta;
@@ -295,7 +295,7 @@
st->noise[i] = (1.f-beta)*st->noise[i] + beta*ps[i];
} else {
for (i=0;i<st->ps_size;i++)
- st->noise[i] = (1.f-beta)*st->noise[i] + beta*max(1.f,ps[i]-echo[i]);
+ st->noise[i] = (1.f-beta)*st->noise[i] + beta*max(1.f,ps[i]-st->frame_size*st->frame_size*4.0*echo[i]);
#if 0
for (i=0;i<st->ps_size;i++)
st->noise[i] = 0;
@@ -632,7 +632,7 @@
#define NOISE_OVERCOMPENS 1.4
-int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, float *echo)
+int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo)
{
int i;
int is_speech=1;
@@ -660,7 +660,7 @@
/* Deal with residual echo if provided */
if (echo)
for (i=1;i<N;i++)
- st->echo_noise[i] = (.3f*st->echo_noise[i] + echo[i]);
+ st->echo_noise[i] = (.3f*st->echo_noise[i] + st->frame_size*st->frame_size*4.0*echo[i]);
/* Compute a posteriori SNR */
for (i=1;i<N;i++)
@@ -747,7 +747,7 @@
if (st->update_prob[i]<.5f/* || st->ps[i] < st->noise[i]*/)
{
if (echo)
- st->noise[i] = .95f*st->noise[i] + .05f*max(1.0f,st->ps[i]-echo[i]);
+ st->noise[i] = .95f*st->noise[i] + .05f*max(1.0f,st->ps[i]-st->frame_size*st->frame_size*4.0*echo[i]);
else
st->noise[i] = .95f*st->noise[i] + .05f*st->ps[i];
}
@@ -901,7 +901,7 @@
return is_speech;
}
-void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, float *echo)
+void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo)
{
int i;
int N = st->ps_size;
@@ -920,7 +920,7 @@
if (st->update_prob[i]<.5f || st->ps[i] < st->noise[i])
{
if (echo)
- st->noise[i] = .95f*st->noise[i] + .1f*max(1.0f,st->ps[i]-echo[i]);
+ st->noise[i] = .95f*st->noise[i] + .1f*max(1.0f,st->ps[i]-st->frame_size*st->frame_size*4.0*echo[i]);
else
st->noise[i] = .95f*st->noise[i] + .1f*st->ps[i];
}
Modified: trunk/speex/libspeex/pseudofloat.h
===================================================================
--- trunk/speex/libspeex/pseudofloat.h 2005-12-18 21:56:40 UTC (rev 10648)
+++ trunk/speex/libspeex/pseudofloat.h 2005-12-19 10:28:57 UTC (rev 10649)
@@ -50,7 +50,7 @@
#define FLOAT_HALF ((spx_float_t){16384,-15})
#define MIN(a,b) ((a)<(b)?(a):(b))
-static inline spx_float_t PSEUDOFLOAT(float x)
+static inline spx_float_t PSEUDOFLOAT(spx_int32_t x)
{
int e=0;
int sign=0;
@@ -63,14 +63,14 @@
return (spx_float_t) {0,0};
while (x>32767)
{
- /*x >>= 1;*/
- x *= .5;
+ x >>= 1;
+ /*x *= .5;*/
e++;
}
while (x<16383)
{
- /*x <<= 1;*/
- x *= 2;
+ x <<= 1;
+ /*x *= 2;*/
e--;
}
if (sign)
More information about the commits
mailing list