[xiph-commits] r12374 - in trunk/speex: include/speex libspeex

jm at svn.xiph.org jm at svn.xiph.org
Mon Jan 22 06:33:26 PST 2007


Author: jm
Date: 2007-01-22 06:33:23 -0800 (Mon, 22 Jan 2007)
New Revision: 12374

Modified:
   trunk/speex/include/speex/speex_resampler.h
   trunk/speex/libspeex/resample.c
Log:
starting fixed-point version of resampler.


Modified: trunk/speex/include/speex/speex_resampler.h
===================================================================
--- trunk/speex/include/speex/speex_resampler.h	2007-01-22 13:53:52 UTC (rev 12373)
+++ trunk/speex/include/speex/speex_resampler.h	2007-01-22 14:33:23 UTC (rev 12374)
@@ -40,8 +40,20 @@
 #define SPEEX_RESAMPLER_H
 
 #ifdef OUTSIDE_SPEEX
+
+#define spx_int16_t short
+#ifdef FIXED_POINT
+#define spx_word16_t short
+#define spx_word32_t int
 #else
+#define spx_word16_t float
+#define spx_word32_t float
+#endif
+
+#else
+
 #include "speex/speex_types.h"
+
 #endif
 
 #ifdef __cplusplus

Modified: trunk/speex/libspeex/resample.c
===================================================================
--- trunk/speex/libspeex/resample.c	2007-01-22 13:53:52 UTC (rev 12373)
+++ trunk/speex/libspeex/resample.c	2007-01-22 14:33:23 UTC (rev 12374)
@@ -125,7 +125,7 @@
    speex_free(st);
 }
 
-void speex_resampler_process_float(SpeexResamplerState *st, int channel_index, const float *in, int *in_len, float *out, int *out_len)
+static void speex_resampler_process_native(SpeexResamplerState *st, int channel_index, const float *in, int *in_len, float *out, int *out_len)
 {
    int j=0;
    int N = st->filt_len;
@@ -218,6 +218,41 @@
    
 }
 
+#ifdef FIXED_POINT
+void speex_resampler_process_float(SpeexResamplerState *st, int channel_index, const float *in, int *in_len, float *out, int *out_len)
+{
+   int i;
+   spx_word16_t x[*in_len];
+   spx_word16_t y[*out_len];
+   for (i=0;i<*in_len;i++)
+      x[i] = floor(.5+in[i]);
+   speex_resampler_process_native(st, channel_index, x, in_len, y, out_len);
+   for (i=0;i<*out_len;i++)
+      out[i] = y[i];
+
+}
+void speex_resampler_process_int(SpeexResamplerState *st, int channel_index, const spx_int16_t *in, int *in_len, spx_int16_t *out, int *out_len)
+{
+   speex_resampler_process_native(st, channel_index, in, in_len, out, out_len);
+}
+#else
+void speex_resampler_process_float(SpeexResamplerState *st, int channel_index, const float *in, int *in_len, float *out, int *out_len)
+{
+   speex_resampler_process_native(st, channel_index, in, in_len, out, out_len);
+}
+void speex_resampler_process_int(SpeexResamplerState *st, int channel_index, const spx_int16_t *in, int *in_len, spx_int16_t *out, int *out_len)
+{
+   int i;
+   spx_word16_t x[*in_len];
+   spx_word16_t y[*out_len];
+   for (i=0;i<*out_len;i++)
+      x[i] = in[i];
+   speex_resampler_process_native(st, channel_index, x, in_len, y, out_len);
+   for (i=0;i<*in_len;i++)
+      out[i] = floor(.5+y[i]);
+}
+#endif
+
 void speex_resampler_process_interleaved_float(SpeexResamplerState *st, const float *in, int *in_len, float *out, int *out_len)
 {
    int i;



More information about the commits mailing list