annotate libaf/af.h @ 14839:6e8905b4410c

reversed, as this breaks vorbis decoding! 1000l! someone figure out why this is the case and fix it before re-committing
author rfelker
date Sun, 27 Feb 2005 06:18:00 +0000
parents 663c1ea5f595
children 0c0ef2177115
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12676
alex
parents: 12668
diff changeset
1 #ifndef __aop_h__
alex
parents: 12668
diff changeset
2 #define __aop_h__
alex
parents: 12668
diff changeset
3
8167
e8832e66babd New features:
anders
parents: 8073
diff changeset
4 #include <stdio.h>
e8832e66babd New features:
anders
parents: 8073
diff changeset
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
e8832e66babd New features:
anders
parents: 8073
diff changeset
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
e8832e66babd New features:
anders
parents: 8073
diff changeset
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
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
11 struct af_instance_s;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
12
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
13 // Audio data chunk
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
14 typedef struct af_data_s
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
15 {
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
16 void* audio; // data buffer
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
17 int len; // buffer length
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
18 int rate; // sample rate
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
19 int nch; // number of channels
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
20 int format; // format
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
21 int bps; // bytes per sample
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
22 } af_data_t;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
23
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
24 // Fraction, used to calculate buffer lengths
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
25 typedef struct frac_s
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
26 {
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
27 int n; // Numerator
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
28 int d; // Denominator
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
29 } frac_t;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
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
e8832e66babd New features:
anders
parents: 8073
diff changeset
35 // Flags used for defining the behavior of an audio filter
7615
c67328dd459a Adding Support for non-reentrant audio filters
anders
parents: 7598
diff changeset
36 #define AF_FLAGS_REENTRANT 0x00000000
c67328dd459a Adding Support for non-reentrant audio filters
anders
parents: 7598
diff changeset
37 #define AF_FLAGS_NOT_REENTRANT 0x00000001
c67328dd459a Adding Support for non-reentrant audio filters
anders
parents: 7598
diff changeset
38
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
39 /* Audio filter information not specific for current instance, but for
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
40 a specific filter */
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
41 typedef struct af_info_s
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
42 {
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
43 const char *info;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
44 const char *name;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
45 const char *author;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
46 const char *comment;
7615
c67328dd459a Adding Support for non-reentrant audio filters
anders
parents: 7598
diff changeset
47 const int flags;
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
48 int (*open)(struct af_instance_s* vf);
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
49 } af_info_t;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
50
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
51 // Linked list of audio filters
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
52 typedef struct af_instance_s
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
53 {
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
54 af_info_t* info;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
55 int (*control)(struct af_instance_s* af, int cmd, void* arg);
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
56 void (*uninit)(struct af_instance_s* af);
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
57 af_data_t* (*play)(struct af_instance_s* af, af_data_t* data);
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
58 void* setup; // setup data for this specific instance and filter
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
59 af_data_t* data; // configuration for outgoing data stream
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
60 struct af_instance_s* next;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
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
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
63 frac_t mul; /* length multiplier: how much does this instance change
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
64 the length of the buffer. */
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
65 }af_instance_t;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
66
7745
1d3a3dc1f488 Adding volume control and moving control() call parameters to a seperate file
anders
parents: 7665
diff changeset
67 // Initialization flags
8167
e8832e66babd New features:
anders
parents: 8073
diff changeset
68 extern int* af_cpu_speed;
e8832e66babd New features:
anders
parents: 8073
diff changeset
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
e8832e66babd New features:
anders
parents: 8073
diff changeset
80 // Default init type
e8832e66babd New features:
anders
parents: 8073
diff changeset
81 #ifndef AF_INIT_TYPE
e8832e66babd New features:
anders
parents: 8073
diff changeset
82 #if defined(HAVE_SSE) || defined(HAVE_3DNOW)
e8832e66babd New features:
anders
parents: 8073
diff changeset
83 #define AF_INIT_TYPE (af_cpu_speed?*af_cpu_speed:AF_INIT_FAST)
e8832e66babd New features:
anders
parents: 8073
diff changeset
84 #else
e8832e66babd New features:
anders
parents: 8073
diff changeset
85 #define AF_INIT_TYPE (af_cpu_speed?*af_cpu_speed:AF_INIT_SLOW)
e8832e66babd New features:
anders
parents: 8073
diff changeset
86 #endif
e8832e66babd New features:
anders
parents: 8073
diff changeset
87 #endif
e8832e66babd New features:
anders
parents: 8073
diff changeset
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
e8832e66babd New features:
anders
parents: 8073
diff changeset
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
e8832e66babd New features:
anders
parents: 8073
diff changeset
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
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
109 /*********************************************
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
110 // Return values
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
111 */
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
112
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
113 #define AF_DETACH 2
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
114 #define AF_OK 1
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
115 #define AF_TRUE 1
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
116 #define AF_FALSE 0
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
117 #define AF_UNKNOWN -1
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
118 #define AF_ERROR -2
8167
e8832e66babd New features:
anders
parents: 8073
diff changeset
119 #define AF_FATAL -3
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
120
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
121
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
122
7745
1d3a3dc1f488 Adding volume control and moving control() call parameters to a seperate file
anders
parents: 7665
diff changeset
123 /*********************************************
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
124 // Export functions
7745
1d3a3dc1f488 Adding volume control and moving control() call parameters to a seperate file
anders
parents: 7665
diff changeset
125 */
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
126
8167
e8832e66babd New features:
anders
parents: 8073
diff changeset
127 /* Initialize the stream "s". This function creates a new filter list
e8832e66babd New features:
anders
parents: 8073
diff changeset
128 if necessary according to the values set in input and output. Input
7571
8819fdf88b5d Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents: 7568
diff changeset
129 and output should contain the format of the current movie and the
8819fdf88b5d Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents: 7568
diff changeset
130 formate of the preferred output respectively. The function is
8969
a892e5f051e1 Adding support for more logical libaf configuration
anders
parents: 8957
diff changeset
131 reentrant i.e. if called with an already initialized stream the
a892e5f051e1 Adding support for more logical libaf configuration
anders
parents: 8957
diff changeset
132 stream will be reinitialized. If the binary parameter
a892e5f051e1 Adding support for more logical libaf configuration
anders
parents: 8957
diff changeset
133 "force_output" is set, the output format will be converted to the
a892e5f051e1 Adding support for more logical libaf configuration
anders
parents: 8957
diff changeset
134 format given in "s", otherwise the output fromat in the last filter
a892e5f051e1 Adding support for more logical libaf configuration
anders
parents: 8957
diff changeset
135 will be copied "s". The return value is 0 if success and -1 if
a892e5f051e1 Adding support for more logical libaf configuration
anders
parents: 8957
diff changeset
136 failure */
a892e5f051e1 Adding support for more logical libaf configuration
anders
parents: 8957
diff changeset
137 int af_init(af_stream_t* s, int force_output);
7649
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
138
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
139 // Uninit and remove all filters
7571
8819fdf88b5d Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents: 7568
diff changeset
140 void af_uninit(af_stream_t* s);
7649
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
141
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
142 /* Add filter during execution. This function adds the filter "name"
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
143 to the stream s. The filter will be inserted somewhere nice in the
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
144 list of filters. The return value is a pointer to the new filter,
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
145 If the filter couldn't be added the return value is NULL. */
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
146 af_instance_t* af_add(af_stream_t* s, char* name);
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
147
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
148 // Uninit and remove the filter "af"
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
149 void af_remove(af_stream_t* s, af_instance_t* af);
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
150
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
151 /* Find filter in the dynamic filter list using it's name This
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
152 function is used for finding already initialized filters */
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
153 af_instance_t* af_get(af_stream_t* s, char* name);
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
154
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
155 // Filter data chunk through the filters in the list
7571
8819fdf88b5d Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents: 7568
diff changeset
156 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
157
12668
ce6ab8cb8597 Send a command throught the filter chain until some item returns AF_OK. Patch by Reimar Doeffinger
alex
parents: 8969
diff changeset
158 // send control to all filters, starting with the last until
ce6ab8cb8597 Send a command throught the filter chain until some item returns AF_OK. Patch by Reimar Doeffinger
alex
parents: 8969
diff changeset
159 // one accepts the command with AF_OK.
14292
12239a0d5408 Make af_control_any_rev return the matching filter
reimar
parents: 13269
diff changeset
160 // Returns the accepting filter or NULL if none was found.
12239a0d5408 Make af_control_any_rev return the matching filter
reimar
parents: 13269
diff changeset
161 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
162
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
163 /* Calculate how long the output from the filters will be given the
7589
443b440798a5 Redesign of buffer length calculation
anders
parents: 7571
diff changeset
164 input length "len". The calculated length is >= the actual
443b440798a5 Redesign of buffer length calculation
anders
parents: 7571
diff changeset
165 length */
7571
8819fdf88b5d Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents: 7568
diff changeset
166 int af_outputlen(af_stream_t* s, int len);
7649
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
167
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
168 /* Calculate how long the input to the filters should be to produce a
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
169 certain output length, i.e. the return value of this function is
7589
443b440798a5 Redesign of buffer length calculation
anders
parents: 7571
diff changeset
170 the input length required to produce the output length "len". The
443b440798a5 Redesign of buffer length calculation
anders
parents: 7571
diff changeset
171 calculated length is <= the actual length */
7571
8819fdf88b5d Adding support for multiple audio streams and removing annoying message from resample and format
anders
parents: 7568
diff changeset
172 int af_inputlen(af_stream_t* s, int len);
7649
90e16aa8ae5f Adding functionality for adding filters during execution
anders
parents: 7615
diff changeset
173
7598
48f8c731efb5 Adding function for estimating required buffer length
anders
parents: 7591
diff changeset
174 /* Calculate how long the input IN to the filters should be to produce
48f8c731efb5 Adding function for estimating required buffer length
anders
parents: 7591
diff changeset
175 a certain output length OUT but with the following three constraints:
48f8c731efb5 Adding function for estimating required buffer length
anders
parents: 7591
diff changeset
176 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
177 block length
48f8c731efb5 Adding function for estimating required buffer length
anders
parents: 7591
diff changeset
178 2. OUT <= max_outsize, where max_outsize is the maximum possible
48f8c731efb5 Adding function for estimating required buffer length
anders
parents: 7591
diff changeset
179 output block length
48f8c731efb5 Adding function for estimating required buffer length
anders
parents: 7591
diff changeset
180 3. If possible OUT >= len.
48f8c731efb5 Adding function for estimating required buffer length
anders
parents: 7591
diff changeset
181 Return -1 in case of error */
48f8c731efb5 Adding function for estimating required buffer length
anders
parents: 7591
diff changeset
182 int af_calc_insize_constrained(af_stream_t* s, int len,
48f8c731efb5 Adding function for estimating required buffer length
anders
parents: 7591
diff changeset
183 int max_outsize,int max_insize);
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
184
7665
fbd5445cc853 Adding function for calculating the delay caused by the filters
anders
parents: 7649
diff changeset
185 /* Calculate the total delay caused by the filters */
fbd5445cc853 Adding function for calculating the delay caused by the filters
anders
parents: 7649
diff changeset
186 double af_calc_delay(af_stream_t* s);
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
187
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
188 // Helper functions and macros used inside the audio filters
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
189
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
190 /* Helper function called by the macro with the same name only to be
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
191 called from inside filters */
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
192 int af_resize_local_buffer(af_instance_t* af, af_data_t* data);
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
193
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
194 /* Helper function used to calculate the exact buffer length needed
7589
443b440798a5 Redesign of buffer length calculation
anders
parents: 7571
diff changeset
195 when buffers are resized. The returned length is >= than what is
443b440798a5 Redesign of buffer length calculation
anders
parents: 7571
diff changeset
196 needed */
443b440798a5 Redesign of buffer length calculation
anders
parents: 7571
diff changeset
197 int af_lencalc(frac_t mul, af_data_t* data);
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
198
8607
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
199 /* Helper function used to convert to gain value from dB. Returns
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
200 AF_OK if of and AF_ERROR if fail */
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
201 int af_from_dB(int n, float* in, float* out, float k, float mi, float ma);
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
202 /* Helper function used to convert from gain value to dB. Returns
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
203 AF_OK if of and AF_ERROR if fail */
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
204 int af_to_dB(int n, float* in, float* out, float k);
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
205 /* Helper function used to convert from ms to sample time*/
8674
93212da0032e 10l memory leak + bug fixes in ms to sample time conversion
anders
parents: 8607
diff changeset
206 int af_from_ms(int n, float* in, int* out, int rate, float mi, float ma);
8607
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
207 /* Helper function used to convert from sample time to ms */
8674
93212da0032e 10l memory leak + bug fixes in ms to sample time conversion
anders
parents: 8607
diff changeset
208 int af_to_ms(int n, int* in, float* out, int rate);
8607
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
209 /* Helper function for testing the output format */
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
210 int af_test_output(struct af_instance_s* af, af_data_t* out);
d6f40a06867b Changes includes:
anders
parents: 8180
diff changeset
211
14622
637fbaa8f56c af_softclip
alex
parents: 14433
diff changeset
212 float af_softclip(float a);
637fbaa8f56c af_softclip
alex
parents: 14433
diff changeset
213
13269
aa13937da8a0 mplayer -af help now lists all available audio filters.
ivo
parents: 12676
diff changeset
214 /** Print a list of all available audio filters */
aa13937da8a0 mplayer -af help now lists all available audio filters.
ivo
parents: 12676
diff changeset
215 void af_help(void);
aa13937da8a0 mplayer -af help now lists all available audio filters.
ivo
parents: 12676
diff changeset
216
14818
663c1ea5f595 finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents: 14622
diff changeset
217 /* Fill the missing parameters in the af_data_t structure.
663c1ea5f595 finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents: 14622
diff changeset
218 Used for stuffing bps with a value based on format. */
663c1ea5f595 finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents: 14622
diff changeset
219 void af_fix_paramaters(af_data_t *data);
663c1ea5f595 finally remove the refences to bps outside libaf. also simplification of some messages and removed redundants
alex
parents: 14622
diff changeset
220
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
221 /* Memory reallocation macro: if a local buffer is used (i.e. if the
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
222 filter doesn't operate on the incoming buffer this macro must be
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
223 called to ensure the buffer is big enough. */
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
224 #define RESIZE_LOCAL_BUFFER(a,d)\
7591
5ef4d009f950 Correcting error in macro
anders
parents: 7589
diff changeset
225 ((a->data->len < af_lencalc(a->mul,d))?af_resize_local_buffer(a,d):AF_OK)
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
226
7745
1d3a3dc1f488 Adding volume control and moving control() call parameters to a seperate file
anders
parents: 7665
diff changeset
227 /* Some other useful macro definitions*/
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
228 #ifndef min
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
229 #define min(a,b)(((a)>(b))?(b):(a))
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
230 #endif
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
231
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
232 #ifndef max
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
233 #define max(a,b)(((a)>(b))?(a):(b))
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
234 #endif
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
235
7745
1d3a3dc1f488 Adding volume control and moving control() call parameters to a seperate file
anders
parents: 7665
diff changeset
236 #ifndef clamp
1d3a3dc1f488 Adding volume control and moving control() call parameters to a seperate file
anders
parents: 7665
diff changeset
237 #define clamp(a,min,max) (((a)>(max))?(max):(((a)<(min))?(min):(a)))
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
238 #endif
7745
1d3a3dc1f488 Adding volume control and moving control() call parameters to a seperate file
anders
parents: 7665
diff changeset
239
1d3a3dc1f488 Adding volume control and moving control() call parameters to a seperate file
anders
parents: 7665
diff changeset
240 #ifndef sign
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents: 7745
diff changeset
241 #define sign(a) (((a)>0)?(1):(-1))
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents: 7745
diff changeset
242 #endif
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents: 7745
diff changeset
243
8167
e8832e66babd New features:
anders
parents: 8073
diff changeset
244 #ifndef lrnd
e8832e66babd New features:
anders
parents: 8073
diff changeset
245 #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
246 #endif
1d3a3dc1f488 Adding volume control and moving control() call parameters to a seperate file
anders
parents: 7665
diff changeset
247
8167
e8832e66babd New features:
anders
parents: 8073
diff changeset
248 /* Error messages */
e8832e66babd New features:
anders
parents: 8073
diff changeset
249
e8832e66babd New features:
anders
parents: 8073
diff changeset
250 typedef struct af_msg_cfg_s
e8832e66babd New features:
anders
parents: 8073
diff changeset
251 {
e8832e66babd New features:
anders
parents: 8073
diff changeset
252 int level; /* Message level for debug and error messages max = 2
e8832e66babd New features:
anders
parents: 8073
diff changeset
253 min = -2 default = 0 */
e8832e66babd New features:
anders
parents: 8073
diff changeset
254 FILE* err; // Stream to print error messages to
e8832e66babd New features:
anders
parents: 8073
diff changeset
255 FILE* msg; // Stream to print information messages to
e8832e66babd New features:
anders
parents: 8073
diff changeset
256 }af_msg_cfg_t;
e8832e66babd New features:
anders
parents: 8073
diff changeset
257
e8832e66babd New features:
anders
parents: 8073
diff changeset
258 extern af_msg_cfg_t af_msg_cfg; // Message
e8832e66babd New features:
anders
parents: 8073
diff changeset
259
e8832e66babd New features:
anders
parents: 8073
diff changeset
260 #define AF_MSG_FATAL -3 // Fatal error exit immediately
e8832e66babd New features:
anders
parents: 8073
diff changeset
261 #define AF_MSG_ERROR -2 // Error return gracefully
e8832e66babd New features:
anders
parents: 8073
diff changeset
262 #define AF_MSG_WARN -1 // Print warning but do not exit (can be suppressed)
e8832e66babd New features:
anders
parents: 8073
diff changeset
263 #define AF_MSG_INFO 0 // Important information
e8832e66babd New features:
anders
parents: 8073
diff changeset
264 #define AF_MSG_VERBOSE 1 // Print this if verbose is enabled
e8832e66babd New features:
anders
parents: 8073
diff changeset
265 #define AF_MSG_DEBUG0 2 // Print if very verbose
e8832e66babd New features:
anders
parents: 8073
diff changeset
266 #define AF_MSG_DEBUG1 3 // Print if very very verbose
e8832e66babd New features:
anders
parents: 8073
diff changeset
267
e8832e66babd New features:
anders
parents: 8073
diff changeset
268 /* Macro for printing error messages */
e8832e66babd New features:
anders
parents: 8073
diff changeset
269 #ifndef af_msg
e8832e66babd New features:
anders
parents: 8073
diff changeset
270 #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
271 (((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
272 (((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
273 #endif
8167
e8832e66babd New features:
anders
parents: 8073
diff changeset
274
e8832e66babd New features:
anders
parents: 8073
diff changeset
275 #endif /* __aop_h__ */