Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst / audioresample / README
1  arch.h            
2  fixed_arm4.h      
3  fixed_arm5e.h     
4  fixed_bfin.h      
5  fixed_debug.h     
6  fixed_generic.h   
7  resample.c        
8  speex_resampler.h 
9
10 are taken from http://git.xiph.org/speex.git/ as of 2009-11-10.
11
12 The only changes are:
13
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
17 @@ -78,7 +78,10 @@
18  #include "../include/speex/speex_types.h"
19  #endif
20  
21 +#ifndef ABS
22  #define ABS(x) ((x) < 0 ? (-(x)) : (x))      /**< Absolute integer value. */
23 +#endif
24 +
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.   */
28 @@ -134,6 +137,28 @@
29  
30  #else
31  
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;
39 +
40 +#define Q15ONE 1.0
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.
47 +
48 +
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;
57 @@ -154,6 +179,7 @@
58  #define VERY_LARGE32 1e15f
59  #define VERY_LARGE16 1e15f
60  #define Q15_ONE ((spx_word16_t)1.f)
61 +#endif /* DOUBLE_PRECISION */
62  
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
68 @@ -63,22 +63,27 @@
69  
70  #ifdef OUTSIDE_SPEEX
71  #include <stdlib.h>
72 -static void *
73 +
74 +#include <glib.h>
75 +
76 +#define EXPORT G_GNUC_INTERNAL
77 +
78 +static inline void *
79  speex_alloc (int size)
80  {
81 -  return calloc (size, 1);
82 +  return g_malloc0 (size);
83  }
84  
85 -static void *
86 +static inline void *
87  speex_realloc (void *ptr, int size)
88  {
89 -  return realloc (ptr, size);
90 +  return g_realloc (ptr, size);
91  }
92  
93 -static void
94 +static inline void
95  speex_free (void *ptr)
96  {
97 -  free (ptr);
98 +  g_free (ptr);
99  }
100  
101  #include "speex_resampler.h"
102 @@ -90,7 +95,6 @@
103  #include "os_support.h"
104  #endif /* OUTSIDE_SPEEX */
105  
106 -#include "stack_alloc.h"
107  #include <math.h>
108  
109  #ifndef M_PI
110 @@ -263,10 +267,17 @@
111  };
112  
113  /*8,24,40,56,80,104,128,160,200,256,320*/
114 +#ifdef DOUBLE_PRECISION
115 +static double
116 +compute_func (double x, struct FuncDef *func)
117 +{
118 +  double y, frac;
119 +#else
120  static double
121  compute_func (float x, struct FuncDef *func)
122  {
123    float y, frac;
124 +#endif
125    double interp[4];
126    int ind;
127    y = x * func->oversample;
128 @@ -317,11 +328,19 @@
129  }
130  #else
131  /* The slow way of computing a sinc for the table. Should improve that some day */
132 +#ifdef DOUBLE_PRECISION
133 +static spx_word16_t
134 +sinc (double cutoff, double x, int N, struct FuncDef *window_func)
135 +{
136 +  /*fprintf (stderr, "%f ", x); */
137 +  double xx = x * cutoff;
138 +#else
139  static spx_word16_t
140  sinc (float cutoff, float x, int N, struct FuncDef *window_func)
141  {
142    /*fprintf (stderr, "%f ", x); */
143    float xx = x * cutoff;
144 +#endif
145    if (fabs (x) < 1e-6)
146      return cutoff;
147    else if (fabs (x) > .5 * N)
148 @@ -372,6 +391,7 @@
149  }
150  #endif
151  
152 +#ifndef DOUBLE_PRECISION
153  static int
154  resampler_basic_direct_single (SpeexResamplerState * st,
155      spx_uint32_t channel_index, const spx_word16_t * in, spx_uint32_t * in_len,
156 @@ -428,6 +448,7 @@
157    st->samp_frac_num[channel_index] = samp_frac_num;
158    return out_sample;
159  }
160 +#endif
161  
162  #ifdef FIXED_POINT
163  #else
164 @@ -483,6 +504,7 @@
165  }
166  #endif
167  
168 +#ifndef DOUBLE_PRECISION
169  static int
170  resampler_basic_interpolate_single (SpeexResamplerState * st,
171      spx_uint32_t channel_index, const spx_word16_t * in, spx_uint32_t * in_len,
172 @@ -562,6 +584,7 @@
173    st->samp_frac_num[channel_index] = samp_frac_num;
174    return out_sample;
175  }
176 +#endif
177  
178  #ifdef FIXED_POINT
179  #else
180 @@ -592,10 +615,16 @@
181          PDIV32 (SHL32 ((samp_frac_num * st->oversample) % st->den_rate, 15),
182          st->den_rate);
183  #else
184 +#ifdef DOUBLE_PRECISION
185 +    const spx_word16_t frac =
186 +        ((double) ((samp_frac_num * st->oversample) % st->den_rate)) /
187 +        st->den_rate;
188 +#else
189      const spx_word16_t frac =
190          ((float) ((samp_frac_num * st->oversample) % st->den_rate)) /
191          st->den_rate;
192  #endif
193 +#endif
194      spx_word16_t interp[4];
195  
196  
197 @@ -696,20 +725,27 @@
198        spx_int32_t j;
199        for (j = 0; j < st->filt_len; j++) {
200          st->sinc_table[i * st->filt_len + j] =
201 -            sinc (st->cutoff,
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,
206 +#else
207                  ((float) i) / st->den_rate), st->filt_len,
208 +#endif
209              quality_map[st->quality].window_func);
210        }
211      }
212  #ifdef FIXED_POINT
213      st->resampler_ptr = resampler_basic_direct_single;
214  #else
215 +#ifdef DOUBLE_PRECISION
216 +    st->resampler_ptr = resampler_basic_direct_double;
217 +#else
218      if (st->quality > 8)
219        st->resampler_ptr = resampler_basic_direct_double;
220      else
221        st->resampler_ptr = resampler_basic_direct_single;
222  #endif
223 +#endif
224      /*fprintf (stderr, "resampler uses direct sinc table and normalised cutoff %f\n", cutoff); */
225    } else {
226      spx_int32_t i;
227 @@ -725,16 +761,24 @@
228      }
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),
233 +#else
234            sinc (st->cutoff, (i / (float) st->oversample - st->filt_len / 2),
235 +#endif
236            st->filt_len, quality_map[st->quality].window_func);
237  #ifdef FIXED_POINT
238      st->resampler_ptr = resampler_basic_interpolate_single;
239  #else
240 +#ifdef DOUBLE_PRECISION
241 +    st->resampler_ptr = resampler_basic_interpolate_double;
242 +#else
243      if (st->quality > 8)
244        st->resampler_ptr = resampler_basic_interpolate_double;
245      else
246        st->resampler_ptr = resampler_basic_interpolate_single;
247  #endif
248 +#endif
249      /*fprintf (stderr, "resampler uses interpolated sinc table and normalised cutoff %f\n", cutoff); */
250    }
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)
255  #else
256 +#ifdef DOUBLE_PRECISION
257 +EXPORT int
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)
261 +#else
262  EXPORT int
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)
266  #endif
267 +#endif
268  {
269    int j;
270    spx_uint32_t ilen = *in_len;
271 @@ -1086,9 +1137,16 @@
272    return RESAMPLER_ERR_SUCCESS;
273  }
274  
275 +#ifdef DOUBLE_PRECISION
276 +EXPORT int
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)
280 +#else
281  EXPORT int
282  speex_resampler_process_interleaved_float (SpeexResamplerState * st,
283      const float *in, spx_uint32_t * in_len, float *out, spx_uint32_t * out_len)
284 +#endif
285  {
286    spx_uint32_t i;
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
291 @@ -77,10 +77,10 @@
292  #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
293  #define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
294  
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
303        
304  #else /* OUTSIDE_SPEEX */
305  
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
309   */
310 +#ifdef DOUBLE_PRECISION
311 +int speex_resampler_process_float(SpeexResamplerState *st, 
312 +                                   spx_uint32_t channel_index, 
313 +                                   const double *in, 
314 +                                   spx_uint32_t *in_len, 
315 +                                   double *out, 
316 +                                   spx_uint32_t *out_len);
317 +#else
318  int speex_resampler_process_float(SpeexResamplerState *st, 
319                                     spx_uint32_t channel_index, 
320                                     const float *in, 
321                                     spx_uint32_t *in_len, 
322                                     float *out, 
323                                     spx_uint32_t *out_len);
324 +#endif
325  
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.
331   */
332 +#ifdef DOUBLE_PRECISION
333 +int speex_resampler_process_interleaved_float(SpeexResamplerState *st, 
334 +                                               const double *in, 
335 +                                               spx_uint32_t *in_len, 
336 +                                               double *out, 
337 +                                               spx_uint32_t *out_len);
338 +#else
339  int speex_resampler_process_interleaved_float(SpeexResamplerState *st, 
340                                                 const float *in, 
341                                                 spx_uint32_t *in_len, 
342                                                 float *out, 
343                                                 spx_uint32_t *out_len);
344 +#endif
345  
346  /** Resample an interleaved int array. The input and output buffers must *not* overlap.
347   * @param st Resampler state