Mercurial > mplayer.hg
annotate libaf/af.h @ 20911:5ab1e8c8f749
bump date of NUT spec for previous commit
author | ods15 |
---|---|
date | Tue, 14 Nov 2006 17:05:20 +0000 |
parents | 584bd8980d57 |
children | 1e188b06ce98 |
rev | line source |
---|---|
12676 | 1 #ifndef __aop_h__ |
2 #define __aop_h__ | |
3 | |
8167 | 4 #include <stdio.h> |
5 | |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
6 #include "af_mp.h" |
8167 | 7 #include "config.h" |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
8 #include "control.h" |
8167 | 9 #include "af_format.h" |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
10 |
7568 | 11 struct af_instance_s; |
12 | |
13 // Audio data chunk | |
14 typedef struct af_data_s | |
15 { | |
16 void* audio; // data buffer | |
17 int len; // buffer length | |
18 int rate; // sample rate | |
19 int nch; // number of channels | |
20 int format; // format | |
21 int bps; // bytes per sample | |
22 } af_data_t; | |
23 | |
24 // Fraction, used to calculate buffer lengths | |
25 typedef struct frac_s | |
26 { | |
27 int n; // Numerator | |
28 int d; // Denominator | |
29 } frac_t; | |
30 | |
14433
95bb94a930a3
always cancel down fractions (frac_t) to avoid overflows and playback
reimar
parents:
14292
diff
changeset
|
31 int af_gcd(register int a, register int b); |
95bb94a930a3
always cancel down fractions (frac_t) to avoid overflows and playback
reimar
parents:
14292
diff
changeset
|
32 void af_frac_cancel(frac_t *f); |
95bb94a930a3
always cancel down fractions (frac_t) to avoid overflows and playback
reimar
parents:
14292
diff
changeset
|
33 void af_frac_mul(frac_t *out, const frac_t *in); |
95bb94a930a3
always cancel down fractions (frac_t) to avoid overflows and playback
reimar
parents:
14292
diff
changeset
|
34 |
8167 | 35 // Flags used for defining the behavior of an audio filter |
7615 | 36 #define AF_FLAGS_REENTRANT 0x00000000 |
37 #define AF_FLAGS_NOT_REENTRANT 0x00000001 | |
38 | |
7568 | 39 /* Audio filter information not specific for current instance, but for |
40 a specific filter */ | |
41 typedef struct af_info_s | |
42 { | |
43 const char *info; | |
44 const char *name; | |
45 const char *author; | |
46 const char *comment; | |
7615 | 47 const int flags; |
7568 | 48 int (*open)(struct af_instance_s* vf); |
49 } af_info_t; | |
50 | |
51 // Linked list of audio filters | |
52 typedef struct af_instance_s | |
53 { | |
54 af_info_t* info; | |
55 int (*control)(struct af_instance_s* af, int cmd, void* arg); | |
56 void (*uninit)(struct af_instance_s* af); | |
57 af_data_t* (*play)(struct af_instance_s* af, af_data_t* data); | |
58 void* setup; // setup data for this specific instance and filter | |
59 af_data_t* data; // configuration for outgoing data stream | |
60 struct af_instance_s* next; | |
61 struct af_instance_s* prev; | |
7665
fbd5445cc853
Adding function for calculating the delay caused by the filters
anders
parents:
7649
diff
changeset
|
62 double delay; // Delay caused by the filter [ms] |
7568 | 63 frac_t mul; /* length multiplier: how much does this instance change |
64 the length of the buffer. */ | |
65 }af_instance_t; | |
66 | |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
67 // Initialization flags |
8167 | 68 extern int* af_cpu_speed; |
69 | |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
70 #define AF_INIT_AUTO 0x00000000 |
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
71 #define AF_INIT_SLOW 0x00000001 |
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
72 #define AF_INIT_FAST 0x00000002 |
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
73 #define AF_INIT_FORCE 0x00000003 |
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
74 #define AF_INIT_TYPE_MASK 0x00000003 |
7571
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
75 |
8867
558f0b1f45ee
New auto config for volume and resample and added support for float flag in configuration
anders
parents:
8674
diff
changeset
|
76 #define AF_INIT_INT 0x00000000 |
8868
398e3fb7c103
10l bug for float conversion control + feature fix in volume control
anders
parents:
8867
diff
changeset
|
77 #define AF_INIT_FLOAT 0x00000004 |
398e3fb7c103
10l bug for float conversion control + feature fix in volume control
anders
parents:
8867
diff
changeset
|
78 #define AF_INIT_FORMAT_MASK 0x00000004 |
8867
558f0b1f45ee
New auto config for volume and resample and added support for float flag in configuration
anders
parents:
8674
diff
changeset
|
79 |
8167 | 80 // Default init type |
81 #ifndef AF_INIT_TYPE | |
82 #if defined(HAVE_SSE) || defined(HAVE_3DNOW) | |
83 #define AF_INIT_TYPE (af_cpu_speed?*af_cpu_speed:AF_INIT_FAST) | |
84 #else | |
85 #define AF_INIT_TYPE (af_cpu_speed?*af_cpu_speed:AF_INIT_SLOW) | |
86 #endif | |
87 #endif | |
88 | |
7571
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
89 // Configuration switches |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
90 typedef struct af_cfg_s{ |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
91 int force; // Initialization type |
8167 | 92 char** list; /* list of names of filters that are added to filter |
7571
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
93 list during first initialization of stream */ |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
94 }af_cfg_t; |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
95 |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
96 // Current audio stream |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
97 typedef struct af_stream_s |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
98 { |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
99 // The first and last filter in the list |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
100 af_instance_t* first; |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
101 af_instance_t* last; |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
102 // Storage for input and output data formats |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
103 af_data_t input; |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
104 af_data_t output; |
8167 | 105 // Configuration for this stream |
7571
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
106 af_cfg_t cfg; |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
107 }af_stream_t; |
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
108 |
7568 | 109 /********************************************* |
110 // Return values | |
111 */ | |
112 | |
113 #define AF_DETACH 2 | |
114 #define AF_OK 1 | |
115 #define AF_TRUE 1 | |
116 #define AF_FALSE 0 | |
117 #define AF_UNKNOWN -1 | |
118 #define AF_ERROR -2 | |
8167 | 119 #define AF_FATAL -3 |
7568 | 120 |
121 | |
122 | |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
123 /********************************************* |
7568 | 124 // Export functions |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
125 */ |
7568 | 126 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
127 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
128 * \defgroup af_chain Audio filter chain functions |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
129 * \{ |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
130 * \param s filter chain |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
131 */ |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
132 |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
133 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
134 * \brief Initialize the stream "s". |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
135 * \return 0 on success, -1 on failure |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
136 * |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
137 * This function creates a new filter list if necessary, according |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
138 * to the values set in input and output. Input and output should contain |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
139 * the format of the current movie and the format of the preferred output |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
140 * respectively. |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
141 * Filters to convert to the preferred output format are inserted |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
142 * automatically, except when they are set to 0. |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
143 * The function is reentrant i.e. if called with an already initialized |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
144 * stream the stream will be reinitialized. |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
145 */ |
15811
9b4bbb6098f6
make -srate work again, unify audio filter init and preinit.
reimar
parents:
14883
diff
changeset
|
146 int af_init(af_stream_t* s); |
7649
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
147 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
148 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
149 * \brief Uninit and remove all filters from audio filter chain |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
150 */ |
7571
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
151 void af_uninit(af_stream_t* s); |
7649
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
152 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
153 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
154 * \brief This function adds the filter "name" to the stream s. |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
155 * \param name name of filter to add |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
156 * \return pointer to the new filter, NULL if insert failed |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
157 * |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
158 * The filter will be inserted somewhere nice in the |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
159 * list of filters (i.e. at the beginning unless the |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
160 * first filter is the format filter (why??). |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
161 */ |
7649
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
162 af_instance_t* af_add(af_stream_t* s, char* name); |
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
163 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
164 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
165 * \brief Uninit and remove the filter "af" |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
166 * \param af filter to remove |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
167 */ |
7649
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
168 void af_remove(af_stream_t* s, af_instance_t* af); |
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
169 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
170 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
171 * \brief find filter in chain by name |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
172 * \param name name of the filter to find |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
173 * \return first filter with right name or NULL if not found |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
174 * |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
175 * This function is used for finding already initialized filters |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
176 */ |
7649
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
177 af_instance_t* af_get(af_stream_t* s, char* name); |
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
178 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
179 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
180 * \brief filter data chunk through the filters in the list |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
181 * \param data data to play |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
182 * \return resulting data |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
183 * \ingroup af_chain |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
184 */ |
7571
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
185 af_data_t* af_play(af_stream_t* s, af_data_t* data); |
7649
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
186 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
187 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
188 * \brief send control to all filters, starting with the last until |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
189 * one accepts the command with AF_OK. |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
190 * \param cmd filter control command |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
191 * \param arg argument for filter command |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
192 * \return the accepting filter or NULL if none was found |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
193 */ |
14292
12239a0d5408
Make af_control_any_rev return the matching filter
reimar
parents:
13269
diff
changeset
|
194 af_instance_t *af_control_any_rev (af_stream_t* s, int cmd, void* arg); |
12668
ce6ab8cb8597
Send a command throught the filter chain until some item returns AF_OK. Patch by Reimar Doeffinger
alex
parents:
8969
diff
changeset
|
195 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
196 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
197 * \brief Calculate how long the output from the filters will be for a given |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
198 * input length. |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
199 * \param len input lenght for which to calculate output length |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
200 * \return calculated output length, will always be >= the resulting |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
201 * length when actually calling af_play. |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
202 */ |
7571
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
203 int af_outputlen(af_stream_t* s, int len); |
7649
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
204 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
205 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
206 * \brief Calculate how long the input to the filters should be to produce a |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
207 * certain output length |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
208 * \param len wanted output length |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
209 * \return input length required to produce the output length "len". Possibly |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
210 * smaller to avoid overflow of output buffer |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
211 */ |
7571
8819fdf88b5d
Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents:
7568
diff
changeset
|
212 int af_inputlen(af_stream_t* s, int len); |
7649
90e16aa8ae5f
Adding functionality for adding filters during execution
anders
parents:
7615
diff
changeset
|
213 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
214 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
215 * \brief calculate required input length for desired output size |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
216 * \param len desired minimum output length |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
217 * \param max_outsize maximum output length |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
218 * \param max_insize maximum input length |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
219 * \return input length or -1 on error |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
220 * |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
221 Calculate how long the input IN to the filters should be to produce |
7598
48f8c731efb5
Adding function for estimating required buffer length
anders
parents:
7591
diff
changeset
|
222 a certain output length OUT but with the following three constraints: |
48f8c731efb5
Adding function for estimating required buffer length
anders
parents:
7591
diff
changeset
|
223 1. IN <= max_insize, where max_insize is the maximum possible input |
48f8c731efb5
Adding function for estimating required buffer length
anders
parents:
7591
diff
changeset
|
224 block length |
48f8c731efb5
Adding function for estimating required buffer length
anders
parents:
7591
diff
changeset
|
225 2. OUT <= max_outsize, where max_outsize is the maximum possible |
48f8c731efb5
Adding function for estimating required buffer length
anders
parents:
7591
diff
changeset
|
226 output block length |
48f8c731efb5
Adding function for estimating required buffer length
anders
parents:
7591
diff
changeset
|
227 3. If possible OUT >= len. |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
228 */ |
7598
48f8c731efb5
Adding function for estimating required buffer length
anders
parents:
7591
diff
changeset
|
229 int af_calc_insize_constrained(af_stream_t* s, int len, |
48f8c731efb5
Adding function for estimating required buffer length
anders
parents:
7591
diff
changeset
|
230 int max_outsize,int max_insize); |
7568 | 231 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
232 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
233 * \brief Calculate the total delay caused by the filters |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
234 * \return delay in seconds |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
235 */ |
7665
fbd5445cc853
Adding function for calculating the delay caused by the filters
anders
parents:
7649
diff
changeset
|
236 double af_calc_delay(af_stream_t* s); |
7568 | 237 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
238 /** \} */ // end of af_chain group |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
239 |
7568 | 240 // Helper functions and macros used inside the audio filters |
241 | |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
242 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
243 * \defgroup af_filter Audio filter helper functions |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
244 * \{ |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
245 */ |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
246 |
7568 | 247 /* Helper function called by the macro with the same name only to be |
248 called from inside filters */ | |
249 int af_resize_local_buffer(af_instance_t* af, af_data_t* data); | |
250 | |
251 /* Helper function used to calculate the exact buffer length needed | |
7589 | 252 when buffers are resized. The returned length is >= than what is |
253 needed */ | |
254 int af_lencalc(frac_t mul, af_data_t* data); | |
7568 | 255 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
256 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
257 * \brief convert dB to gain value |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
258 * \param n number of values to convert |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
259 * \param in [in] values in dB, <= -200 will become 0 gain |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
260 * \param out [out] gain values |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
261 * \param k input values are divided by this |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
262 * \param mi minimum dB value, input will be clamped to this |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
263 * \param ma maximum dB value, input will be clamped to this |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
264 * \return AF_ERROR on error, AF_OK otherwise |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
265 */ |
8607 | 266 int af_from_dB(int n, float* in, float* out, float k, float mi, float ma); |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
267 |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
268 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
269 * \brief convert gain value to dB |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
270 * \param n number of values to convert |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
271 * \param in [in] gain values, 0 wil become -200 dB |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
272 * \param out [out] values in dB |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
273 * \param k output values will be multiplied by this |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
274 * \return AF_ERROR on error, AF_OK otherwise |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
275 */ |
8607 | 276 int af_to_dB(int n, float* in, float* out, float k); |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
277 |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
278 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
279 * \brief convert milliseconds to sample time |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
280 * \param n number of values to convert |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
281 * \param in [in] values in milliseconds |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
282 * \param out [out] sample time values |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
283 * \param rate sample rate |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
284 * \param mi minimum ms value, input will be clamped to this |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
285 * \param ma maximum ms value, input will be clamped to this |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
286 * \return AF_ERROR on error, AF_OK otherwise |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
287 */ |
8674
93212da0032e
10l memory leak + bug fixes in ms to sample time conversion
anders
parents:
8607
diff
changeset
|
288 int af_from_ms(int n, float* in, int* out, int rate, float mi, float ma); |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
289 |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
290 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
291 * \brief convert sample time to milliseconds |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
292 * \param n number of values to convert |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
293 * \param in [in] sample time values |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
294 * \param out [out] values in milliseconds |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
295 * \param rate sample rate |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
296 * \return AF_ERROR on error, AF_OK otherwise |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
297 */ |
8674
93212da0032e
10l memory leak + bug fixes in ms to sample time conversion
anders
parents:
8607
diff
changeset
|
298 int af_to_ms(int n, int* in, float* out, int rate); |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
299 |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
300 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
301 * \brief test if output format matches |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
302 * \param af audio filter |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
303 * \param out needed format, will be overwritten by available |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
304 * format if they do not match |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
305 * \return AF_FALSE if formats do not match, AF_OK if they match |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
306 * |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
307 * compares the format, bps, rate and nch values of af->data with out |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
308 */ |
8607 | 309 int af_test_output(struct af_instance_s* af, af_data_t* out); |
310 | |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
311 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
312 * \brief soft clipping function using sin() |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
313 * \param a input value |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
314 * \return clipped value |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
315 */ |
14622 | 316 float af_softclip(float a); |
317 | |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
318 /** \} */ // end of af_filter group, but more functions of this group below |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
319 |
13269
aa13937da8a0
mplayer -af help now lists all available audio filters.
ivo
parents:
12676
diff
changeset
|
320 /** Print a list of all available audio filters */ |
aa13937da8a0
mplayer -af help now lists all available audio filters.
ivo
parents:
12676
diff
changeset
|
321 void af_help(void); |
aa13937da8a0
mplayer -af help now lists all available audio filters.
ivo
parents:
12676
diff
changeset
|
322 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
323 /** |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
324 * \brief fill the missing parameters in the af_data_t structure |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
325 * \param data structure to fill |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
326 * \ingroup af_filter |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
327 * |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
328 * Currently only sets bps based on format |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
329 */ |
14883 | 330 void af_fix_parameters(af_data_t *data); |
14818
663c1ea5f595
finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents:
14622
diff
changeset
|
331 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
332 /** Memory reallocation macro: if a local buffer is used (i.e. if the |
7568 | 333 filter doesn't operate on the incoming buffer this macro must be |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
334 called to ensure the buffer is big enough. |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
335 * \ingroup af_filter |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
336 */ |
7568 | 337 #define RESIZE_LOCAL_BUFFER(a,d)\ |
7591 | 338 ((a->data->len < af_lencalc(a->mul,d))?af_resize_local_buffer(a,d):AF_OK) |
7568 | 339 |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
340 /* Some other useful macro definitions*/ |
7568 | 341 #ifndef min |
342 #define min(a,b)(((a)>(b))?(b):(a)) | |
343 #endif | |
344 | |
345 #ifndef max | |
346 #define max(a,b)(((a)>(b))?(a):(b)) | |
347 #endif | |
348 | |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
349 #ifndef clamp |
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
350 #define clamp(a,min,max) (((a)>(max))?(max):(((a)<(min))?(min):(a))) |
7568 | 351 #endif |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
352 |
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
353 #ifndef sign |
8073 | 354 #define sign(a) (((a)>0)?(1):(-1)) |
355 #endif | |
356 | |
8167 | 357 #ifndef lrnd |
358 #define lrnd(a,b) ((b)((a)>=0.0?(a)+0.5:(a)-0.5)) | |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
359 #endif |
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
360 |
8167 | 361 /* Error messages */ |
362 | |
363 typedef struct af_msg_cfg_s | |
364 { | |
365 int level; /* Message level for debug and error messages max = 2 | |
366 min = -2 default = 0 */ | |
367 FILE* err; // Stream to print error messages to | |
368 FILE* msg; // Stream to print information messages to | |
369 }af_msg_cfg_t; | |
370 | |
371 extern af_msg_cfg_t af_msg_cfg; // Message | |
372 | |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
373 //! \addtogroup af_filter |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
374 //! \{ |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
375 #define AF_MSG_FATAL -3 ///< Fatal error exit immediately |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
376 #define AF_MSG_ERROR -2 ///< Error return gracefully |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
377 #define AF_MSG_WARN -1 ///< Print warning but do not exit (can be suppressed) |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
378 #define AF_MSG_INFO 0 ///< Important information |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
379 #define AF_MSG_VERBOSE 1 ///< Print this if verbose is enabled |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
380 #define AF_MSG_DEBUG0 2 ///< Print if very verbose |
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
381 #define AF_MSG_DEBUG1 3 ///< Print if very very verbose |
8167 | 382 |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
383 //! Macro for printing error messages |
8167 | 384 #ifndef af_msg |
385 #define af_msg(lev, args... ) \ | |
8957
36a5cdca733b
bunkus: Encapsulated arguments to #define in ( ... ) so that the #defines can be safely used like functions: mydef(flag ? val1 : val2)
mosu
parents:
8868
diff
changeset
|
386 (((lev)<AF_MSG_WARN)?(fprintf(af_msg_cfg.err?af_msg_cfg.err:stderr, ## args )): \ |
36a5cdca733b
bunkus: Encapsulated arguments to #define in ( ... ) so that the #defines can be safely used like functions: mydef(flag ? val1 : val2)
mosu
parents:
8868
diff
changeset
|
387 (((lev)<=af_msg_cfg.level)?(fprintf(af_msg_cfg.msg?af_msg_cfg.msg:stdout, ## args )):0)) |
7745
1d3a3dc1f488
Adding volume control and moving control() call parameters to a seperate file
anders
parents:
7665
diff
changeset
|
388 #endif |
16627
584bd8980d57
documentation-only patch: make doxygen compatible and create
reimar
parents:
15811
diff
changeset
|
389 //! \} |
8167 | 390 |
391 #endif /* __aop_h__ */ |