comparison libaf/af.h @ 7589:443b440798a5

Redesign of buffer length calculation
author anders
date Thu, 03 Oct 2002 12:02:46 +0000
parents 8819fdf88b5d
children 5ef4d009f950
comparison
equal deleted inserted replaced
7588:8ee95f554262 7589:443b440798a5
136 // Uninit and remove all filters 136 // Uninit and remove all filters
137 void af_uninit(af_stream_t* s); 137 void af_uninit(af_stream_t* s);
138 // Filter data chunk through the filters in the list 138 // Filter data chunk through the filters in the list
139 af_data_t* af_play(af_stream_t* s, af_data_t* data); 139 af_data_t* af_play(af_stream_t* s, af_data_t* data);
140 /* Calculate how long the output from the filters will be given the 140 /* Calculate how long the output from the filters will be given the
141 input length "len" */ 141 input length "len". The calculated length is >= the actual
142 length */
142 int af_outputlen(af_stream_t* s, int len); 143 int af_outputlen(af_stream_t* s, int len);
143 /* Calculate how long the input to the filters should be to produce a 144 /* Calculate how long the input to the filters should be to produce a
144 certain output length, i.e. the return value of this function is 145 certain output length, i.e. the return value of this function is
145 the input length required to produce the output length "len". */ 146 the input length required to produce the output length "len". The
147 calculated length is <= the actual length */
146 int af_inputlen(af_stream_t* s, int len); 148 int af_inputlen(af_stream_t* s, int len);
147 149
148 150
149 151
150 // Helper functions and macros used inside the audio filters 152 // Helper functions and macros used inside the audio filters
152 /* Helper function called by the macro with the same name only to be 154 /* Helper function called by the macro with the same name only to be
153 called from inside filters */ 155 called from inside filters */
154 int af_resize_local_buffer(af_instance_t* af, af_data_t* data); 156 int af_resize_local_buffer(af_instance_t* af, af_data_t* data);
155 157
156 /* Helper function used to calculate the exact buffer length needed 158 /* Helper function used to calculate the exact buffer length needed
157 when buffers are resized */ 159 when buffers are resized. The returned length is >= than what is
158 int af_lencalc(frac_t mul, int len); 160 needed */
161 int af_lencalc(frac_t mul, af_data_t* data);
159 162
160 /* Memory reallocation macro: if a local buffer is used (i.e. if the 163 /* Memory reallocation macro: if a local buffer is used (i.e. if the
161 filter doesn't operate on the incoming buffer this macro must be 164 filter doesn't operate on the incoming buffer this macro must be
162 called to ensure the buffer is big enough. */ 165 called to ensure the buffer is big enough. */
163 #define RESIZE_LOCAL_BUFFER(a,d)\ 166 #define RESIZE_LOCAL_BUFFER(a,d)\
164 ((af->data->len < af_lencalc(af->mul,data->len))?af_resize_local_buffer(af,data):AF_OK) 167 ((af->data->len < af_lencalc(af->mul,data))?af_resize_local_buffer(af,data):AF_OK)
165 168
166 #ifndef min 169 #ifndef min
167 #define min(a,b)(((a)>(b))?(b):(a)) 170 #define min(a,b)(((a)>(b))?(b):(a))
168 #endif 171 #endif
169 172