port audioresample to basetransform
[platform/upstream/gstreamer.git] / gst / audioresample / resample.h
1 /* Resampling library
2  * Copyright (C) <2001> David Schleef <ds@schleef.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20
21 #ifndef __RESAMPLE_H__
22 #define __RESAMPLE_H__
23
24 #include "functable.h"
25 #include "buffer.h"
26
27 typedef enum {
28         RESAMPLE_FORMAT_S16 = 0,
29         RESAMPLE_FORMAT_S32,
30         RESAMPLE_FORMAT_F32,
31         RESAMPLE_FORMAT_F64
32 } ResampleFormat;
33
34 typedef void (*ResampleCallback) (void *);
35
36 typedef struct _ResampleState ResampleState;
37
38 struct _ResampleState {
39         /* parameters */
40
41         int n_channels;
42         ResampleFormat format;
43
44         int filter_length;
45
46         double i_rate;
47         double o_rate;
48
49         int method;
50
51         /* internal parameters */
52
53         int need_reinit;
54
55         double halftaps;
56
57         /* filter state */
58
59         void *o_buf;
60         int o_size;
61
62         AudioresampleBufferQueue *queue;
63         int eos;
64         int started;
65
66         int sample_size;
67
68         void *buffer;
69         int buffer_len;
70
71         double i_start;
72         double o_start;
73
74         double i_inc;
75         double o_inc;
76
77         double sinc_scale;
78
79         double i_end;
80         double o_end;
81
82         int i_samples;
83         int o_samples;
84
85         //void *i_buf;
86
87         Functable *ft;
88
89         double *out_tmp;
90 };
91
92 void resample_init (void);
93 void resample_cleanup (void);
94
95 ResampleState *resample_new (void);
96 void resample_free (ResampleState *state);
97
98 void resample_add_input_data (ResampleState * r, void *data, int size,
99     ResampleCallback free_func, void *closure);
100 void resample_input_eos (ResampleState *r);
101
102 int resample_get_output_size_for_input (ResampleState * r, int size);
103 int resample_get_output_size (ResampleState *r);
104 int resample_get_output_data (ResampleState *r, void *data, int size);
105
106 void resample_set_filter_length (ResampleState *r, int length);
107 void resample_set_input_rate (ResampleState *r, double rate);
108 void resample_set_output_rate (ResampleState *r, double rate);
109 void resample_set_n_channels (ResampleState *r, int n_channels);
110 void resample_set_format (ResampleState *r, ResampleFormat format);
111 void resample_set_method (ResampleState *r, int method);
112 int resample_format_size (ResampleFormat format);
113
114 #endif /* __RESAMPLE_H__ */
115