10 are taken from http://git.xiph.org/speex.git/ as of 2008-10-28.
14 --- arch.h 2008-11-28 09:57:15.000000000 +0100
15 +++ arch.h 2008-11-28 09:57:37.000000000 +0100
17 #include "../include/speex/speex_types.h"
21 #define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
24 #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
25 #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */
26 #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */
31 +#ifdef DOUBLE_PRECISION
32 +typedef double spx_mem_t;
33 +typedef double spx_coef_t;
34 +typedef double spx_lsp_t;
35 +typedef double spx_sig_t;
36 +typedef double spx_word16_t;
37 +typedef double spx_word32_t;
40 +#define LPC_SCALING 1.
41 +#define SIG_SCALING 1.
42 +#define LSP_SCALING 1.
43 +#define GAMMA_SCALING 1.
44 +#define GAIN_SCALING 1.
45 +#define GAIN_SCALING_1 1.
48 +#define VERY_SMALL 1e-20
49 +#define VERY_LARGE32 1e20
50 +#define VERY_LARGE16 1e20
51 +#define Q15_ONE ((spx_word16_t)1.)
52 +#else /* !DOUBLE_PRECISION */
53 typedef float spx_mem_t;
54 typedef float spx_coef_t;
55 typedef float spx_lsp_t;
57 #define VERY_LARGE32 1e15f
58 #define VERY_LARGE16 1e15f
59 #define Q15_ONE ((spx_word16_t)1.f)
60 +#endif /* DOUBLE_PRECISION */
62 #define QCONST16(x,bits) (x)
63 #define QCONST32(x,bits) (x)
64 --- resample.c 2008-11-28 09:56:42.000000000 +0100
65 +++ resample.c 2008-11-01 20:38:35.000000000 +0100
74 +#define EXPORT G_GNUC_INTERNAL
77 speex_alloc (int size)
79 - return calloc (size, 1);
80 + return g_malloc0 (size);
85 speex_realloc (void *ptr, int size)
87 - return realloc (ptr, size);
88 + return g_realloc (ptr, size);
93 speex_free (void *ptr)
99 #include "speex_resampler.h"
101 #include "os_support.h"
102 #endif /* OUTSIDE_SPEEX */
104 -#include "stack_alloc.h"
108 @@ -263,10 +267,17 @@
111 /*8,24,40,56,80,104,128,160,200,256,320*/
112 +#ifdef DOUBLE_PRECISION
114 +compute_func (double x, struct FuncDef *func)
119 compute_func (float x, struct FuncDef *func)
125 y = x * func->oversample;
126 @@ -317,11 +328,19 @@
129 /* The slow way of computing a sinc for the table. Should improve that some day */
130 +#ifdef DOUBLE_PRECISION
132 +sinc (double cutoff, double x, int N, struct FuncDef *window_func)
134 + /*fprintf (stderr, "%f ", x); */
135 + double xx = x * cutoff;
138 sinc (float cutoff, float x, int N, struct FuncDef *window_func)
140 /*fprintf (stderr, "%f ", x); */
141 float xx = x * cutoff;
145 else if (fabs (x) > .5 * N)
150 +#ifndef DOUBLE_PRECISION
152 resampler_basic_direct_single (SpeexResamplerState * st,
153 spx_uint32_t channel_index, const spx_word16_t * in, spx_uint32_t * in_len,
155 st->samp_frac_num[channel_index] = samp_frac_num;
166 +#ifndef DOUBLE_PRECISION
168 resampler_basic_interpolate_single (SpeexResamplerState * st,
169 spx_uint32_t channel_index, const spx_word16_t * in, spx_uint32_t * in_len,
171 st->samp_frac_num[channel_index] = samp_frac_num;
178 @@ -584,10 +607,16 @@
179 PDIV32 (SHL32 ((samp_frac_num * st->oversample) % st->den_rate, 15),
182 +#ifdef DOUBLE_PRECISION
183 + const spx_word16_t frac =
184 + ((double) ((samp_frac_num * st->oversample) % st->den_rate)) /
187 const spx_word16_t frac =
188 ((float) ((samp_frac_num * st->oversample) % st->den_rate)) /
192 spx_word16_t interp[4];
195 @@ -688,20 +717,27 @@
197 for (j = 0; j < st->filt_len; j++) {
198 st->sinc_table[i * st->filt_len + j] =
200 - ((j - (spx_int32_t) st->filt_len / 2 + 1) -
201 + sinc (st->cutoff, ((j - (spx_int32_t) st->filt_len / 2 + 1) -
202 +#ifdef DOUBLE_PRECISION
203 + ((double) i) / st->den_rate), st->filt_len,
205 ((float) i) / st->den_rate), st->filt_len,
207 quality_map[st->quality].window_func);
211 st->resampler_ptr = resampler_basic_direct_single;
213 +#ifdef DOUBLE_PRECISION
214 + st->resampler_ptr = resampler_basic_direct_double;
217 st->resampler_ptr = resampler_basic_direct_double;
219 st->resampler_ptr = resampler_basic_direct_single;
222 /*fprintf (stderr, "resampler uses direct sinc table and normalised cutoff %f\n", cutoff); */
225 @@ -717,16 +753,24 @@
227 for (i = -4; i < (spx_int32_t) (st->oversample * st->filt_len + 4); i++)
228 st->sinc_table[i + 4] =
229 +#ifdef DOUBLE_PRECISION
230 + sinc (st->cutoff, (i / (double) st->oversample - st->filt_len / 2),
232 sinc (st->cutoff, (i / (float) st->oversample - st->filt_len / 2),
234 st->filt_len, quality_map[st->quality].window_func);
236 st->resampler_ptr = resampler_basic_interpolate_single;
238 +#ifdef DOUBLE_PRECISION
239 + st->resampler_ptr = resampler_basic_interpolate_double;
242 st->resampler_ptr = resampler_basic_interpolate_double;
244 st->resampler_ptr = resampler_basic_interpolate_single;
247 /*fprintf (stderr, "resampler uses interpolated sinc table and normalised cutoff %f\n", cutoff); */
249 st->int_advance = st->num_rate / st->den_rate;
250 @@ -956,11 +1000,18 @@
251 spx_uint32_t channel_index, const spx_int16_t * in, spx_uint32_t * in_len,
252 spx_int16_t * out, spx_uint32_t * out_len)
254 +#ifdef DOUBLE_PRECISION
256 +speex_resampler_process_float (SpeexResamplerState * st,
257 + spx_uint32_t channel_index, const double *in, spx_uint32_t * in_len,
258 + double *out, spx_uint32_t * out_len)
261 speex_resampler_process_float (SpeexResamplerState * st,
262 spx_uint32_t channel_index, const float *in, spx_uint32_t * in_len,
263 float *out, spx_uint32_t * out_len)
268 spx_uint32_t ilen = *in_len;
269 @@ -1078,9 +1129,16 @@
270 return RESAMPLER_ERR_SUCCESS;
273 +#ifdef DOUBLE_PRECISION
275 +speex_resampler_process_interleaved_float (SpeexResamplerState * st,
276 + const double *in, spx_uint32_t * in_len, double *out,
277 + spx_uint32_t * out_len)
280 speex_resampler_process_interleaved_float (SpeexResamplerState * st,
281 const float *in, spx_uint32_t * in_len, float *out, spx_uint32_t * out_len)
285 int istride_save, ostride_save;
286 --- speex_resampler.h 2008-11-28 09:57:15.000000000 +0100
287 +++ speex_resampler.h 2008-11-28 09:57:37.000000000 +0100
289 #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
290 #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
292 -#define spx_int16_t short
293 -#define spx_int32_t int
294 -#define spx_uint16_t unsigned short
295 -#define spx_uint32_t unsigned int
296 +#define spx_int16_t gint16
297 +#define spx_int32_t gint32
298 +#define spx_uint16_t guint16
299 +#define spx_uint32_t guint32
301 #else /* OUTSIDE_SPEEX */
303 @@ -162,10 +162,17 @@
304 * @param out Output buffer
305 * @param out_len Size of the output buffer. Returns the number of samples written
307 +#ifdef DOUBLE_PRECISION
308 + int speex_resampler_process_float (SpeexResamplerState * st,
309 + spx_uint32_t channel_index,
311 + spx_uint32_t * in_len, double *out, spx_uint32_t * out_len);
313 int speex_resampler_process_float (SpeexResamplerState * st,
314 spx_uint32_t channel_index,
316 spx_uint32_t * in_len, float *out, spx_uint32_t * out_len);
319 /** Resample an int array. The input and output buffers must *not* overlap.
320 * @param st Resampler state
322 * @param out_len Size of the output buffer. Returns the number of samples written.
323 * This is all per-channel.
325 +#ifdef DOUBLE_PRECISION
326 + int speex_resampler_process_interleaved_float (SpeexResamplerState * st,
328 + spx_uint32_t * in_len, double *out, spx_uint32_t * out_len);
330 int speex_resampler_process_interleaved_float (SpeexResamplerState * st,
332 spx_uint32_t * in_len, float *out, spx_uint32_t * out_len);
335 /** Resample an interleaved int array. The input and output buffers must *not* overlap.
336 * @param st Resampler state