10 are taken from http://git.xiph.org/speex.git/ as of 2009-11-10.
14 diff -Naur old/arch.h new/arch.h
15 --- old/arch.h 2009-11-10 12:18:29.000000000 +0100
16 +++ new/arch.h 2009-11-10 12:19:09.000000000 +0100
18 #include "../include/speex/speex_types.h"
22 #define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
25 #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
26 #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */
27 #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */
32 +#ifdef DOUBLE_PRECISION
33 +typedef double spx_mem_t;
34 +typedef double spx_coef_t;
35 +typedef double spx_lsp_t;
36 +typedef double spx_sig_t;
37 +typedef double spx_word16_t;
38 +typedef double spx_word32_t;
41 +#define LPC_SCALING 1.
42 +#define SIG_SCALING 1.
43 +#define LSP_SCALING 1.
44 +#define GAMMA_SCALING 1.
45 +#define GAIN_SCALING 1.
46 +#define GAIN_SCALING_1 1.
49 +#define VERY_SMALL 1e-20
50 +#define VERY_LARGE32 1e20
51 +#define VERY_LARGE16 1e20
52 +#define Q15_ONE ((spx_word16_t)1.)
53 +#else /* !DOUBLE_PRECISION */
54 typedef float spx_mem_t;
55 typedef float spx_coef_t;
56 typedef float spx_lsp_t;
58 #define VERY_LARGE32 1e15f
59 #define VERY_LARGE16 1e15f
60 #define Q15_ONE ((spx_word16_t)1.f)
61 +#endif /* DOUBLE_PRECISION */
63 #define QCONST16(x,bits) (x)
64 #define QCONST32(x,bits) (x)
65 diff -Naur old/resample.c new/resample.c
66 --- old/resample.c 2009-11-10 12:18:51.000000000 +0100
67 +++ new/resample.c 2009-11-10 12:19:09.000000000 +0100
76 +#define EXPORT G_GNUC_INTERNAL
79 speex_alloc (int size)
81 - return calloc (size, 1);
82 + return g_malloc0 (size);
87 speex_realloc (void *ptr, int size)
89 - return realloc (ptr, size);
90 + return g_realloc (ptr, size);
95 speex_free (void *ptr)
101 #include "speex_resampler.h"
103 #include "os_support.h"
104 #endif /* OUTSIDE_SPEEX */
106 -#include "stack_alloc.h"
110 @@ -263,10 +267,17 @@
113 /*8,24,40,56,80,104,128,160,200,256,320*/
114 +#ifdef DOUBLE_PRECISION
116 +compute_func (double x, struct FuncDef *func)
121 compute_func (float x, struct FuncDef *func)
127 y = x * func->oversample;
128 @@ -317,11 +328,19 @@
131 /* The slow way of computing a sinc for the table. Should improve that some day */
132 +#ifdef DOUBLE_PRECISION
134 +sinc (double cutoff, double x, int N, struct FuncDef *window_func)
136 + /*fprintf (stderr, "%f ", x); */
137 + double xx = x * cutoff;
140 sinc (float cutoff, float x, int N, struct FuncDef *window_func)
142 /*fprintf (stderr, "%f ", x); */
143 float xx = x * cutoff;
147 else if (fabs (x) > .5 * N)
152 +#ifndef DOUBLE_PRECISION
154 resampler_basic_direct_single (SpeexResamplerState * st,
155 spx_uint32_t channel_index, const spx_word16_t * in, spx_uint32_t * in_len,
157 st->samp_frac_num[channel_index] = samp_frac_num;
168 +#ifndef DOUBLE_PRECISION
170 resampler_basic_interpolate_single (SpeexResamplerState * st,
171 spx_uint32_t channel_index, const spx_word16_t * in, spx_uint32_t * in_len,
173 st->samp_frac_num[channel_index] = samp_frac_num;
180 @@ -592,10 +615,16 @@
181 PDIV32 (SHL32 ((samp_frac_num * st->oversample) % st->den_rate, 15),
184 +#ifdef DOUBLE_PRECISION
185 + const spx_word16_t frac =
186 + ((double) ((samp_frac_num * st->oversample) % st->den_rate)) /
189 const spx_word16_t frac =
190 ((float) ((samp_frac_num * st->oversample) % st->den_rate)) /
194 spx_word16_t interp[4];
197 @@ -696,20 +725,27 @@
199 for (j = 0; j < st->filt_len; j++) {
200 st->sinc_table[i * st->filt_len + j] =
202 - ((j - (spx_int32_t) st->filt_len / 2 + 1) -
203 + sinc (st->cutoff, ((j - (spx_int32_t) st->filt_len / 2 + 1) -
204 +#ifdef DOUBLE_PRECISION
205 + ((double) i) / st->den_rate), st->filt_len,
207 ((float) i) / st->den_rate), st->filt_len,
209 quality_map[st->quality].window_func);
213 st->resampler_ptr = resampler_basic_direct_single;
215 +#ifdef DOUBLE_PRECISION
216 + st->resampler_ptr = resampler_basic_direct_double;
219 st->resampler_ptr = resampler_basic_direct_double;
221 st->resampler_ptr = resampler_basic_direct_single;
224 /*fprintf (stderr, "resampler uses direct sinc table and normalised cutoff %f\n", cutoff); */
227 @@ -725,16 +761,24 @@
229 for (i = -4; i < (spx_int32_t) (st->oversample * st->filt_len + 4); i++)
230 st->sinc_table[i + 4] =
231 +#ifdef DOUBLE_PRECISION
232 + sinc (st->cutoff, (i / (double) st->oversample - st->filt_len / 2),
234 sinc (st->cutoff, (i / (float) st->oversample - st->filt_len / 2),
236 st->filt_len, quality_map[st->quality].window_func);
238 st->resampler_ptr = resampler_basic_interpolate_single;
240 +#ifdef DOUBLE_PRECISION
241 + st->resampler_ptr = resampler_basic_interpolate_double;
244 st->resampler_ptr = resampler_basic_interpolate_double;
246 st->resampler_ptr = resampler_basic_interpolate_single;
249 /*fprintf (stderr, "resampler uses interpolated sinc table and normalised cutoff %f\n", cutoff); */
251 st->int_advance = st->num_rate / st->den_rate;
252 @@ -964,11 +1008,18 @@
253 spx_uint32_t channel_index, const spx_int16_t * in, spx_uint32_t * in_len,
254 spx_int16_t * out, spx_uint32_t * out_len)
256 +#ifdef DOUBLE_PRECISION
258 +speex_resampler_process_float (SpeexResamplerState * st,
259 + spx_uint32_t channel_index, const double *in, spx_uint32_t * in_len,
260 + double *out, spx_uint32_t * out_len)
263 speex_resampler_process_float (SpeexResamplerState * st,
264 spx_uint32_t channel_index, const float *in, spx_uint32_t * in_len,
265 float *out, spx_uint32_t * out_len)
270 spx_uint32_t ilen = *in_len;
271 @@ -1086,9 +1137,16 @@
272 return RESAMPLER_ERR_SUCCESS;
275 +#ifdef DOUBLE_PRECISION
277 +speex_resampler_process_interleaved_float (SpeexResamplerState * st,
278 + const double *in, spx_uint32_t * in_len, double *out,
279 + spx_uint32_t * out_len)
282 speex_resampler_process_interleaved_float (SpeexResamplerState * st,
283 const float *in, spx_uint32_t * in_len, float *out, spx_uint32_t * out_len)
287 int istride_save, ostride_save;
288 diff -Naur old/speex_resampler.h new/speex_resampler.h
289 --- old/speex_resampler.h 2009-11-10 12:18:09.000000000 +0100
290 +++ new/speex_resampler.h 2009-11-10 12:19:09.000000000 +0100
292 #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
293 #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
295 -#define spx_int16_t short
296 -#define spx_int32_t int
297 -#define spx_uint16_t unsigned short
298 -#define spx_uint32_t unsigned int
299 +#define spx_int16_t gint16
300 +#define spx_int32_t gint32
301 +#define spx_uint16_t guint16
302 +#define spx_uint32_t guint32
304 #else /* OUTSIDE_SPEEX */
306 @@ -166,12 +166,21 @@
307 * @param out Output buffer
308 * @param out_len Size of the output buffer. Returns the number of samples written
310 +#ifdef DOUBLE_PRECISION
311 +int speex_resampler_process_float(SpeexResamplerState *st,
312 + spx_uint32_t channel_index,
314 + spx_uint32_t *in_len,
316 + spx_uint32_t *out_len);
318 int speex_resampler_process_float(SpeexResamplerState *st,
319 spx_uint32_t channel_index,
321 spx_uint32_t *in_len,
323 spx_uint32_t *out_len);
326 /** Resample an int array. The input and output buffers must *not* overlap.
327 * @param st Resampler state
328 @@ -199,11 +208,19 @@
329 * @param out_len Size of the output buffer. Returns the number of samples written.
330 * This is all per-channel.
332 +#ifdef DOUBLE_PRECISION
333 +int speex_resampler_process_interleaved_float(SpeexResamplerState *st,
335 + spx_uint32_t *in_len,
337 + spx_uint32_t *out_len);
339 int speex_resampler_process_interleaved_float(SpeexResamplerState *st,
341 spx_uint32_t *in_len,
343 spx_uint32_t *out_len);
346 /** Resample an interleaved int array. The input and output buffers must *not* overlap.
347 * @param st Resampler state