Mercurial > libavcodec.hg
comparison iirfilter.c @ 9956:0448219eb490 libavcodec
IIR filter test program.
author | alexc |
---|---|
date | Thu, 16 Jul 2009 22:17:20 +0000 |
parents | 1a345787ba68 |
children | 7dd2a45249a9 |
comparison
equal
deleted
inserted
replaced
9955:4ebcb6c121e4 | 9956:0448219eb490 |
---|---|
175 av_free(coeffs->cy); | 175 av_free(coeffs->cy); |
176 } | 176 } |
177 av_free(coeffs); | 177 av_free(coeffs); |
178 } | 178 } |
179 | 179 |
180 #ifdef TEST | |
181 #define FILT_ORDER 4 | |
182 #define SIZE 1024 | |
183 int main(void) | |
184 { | |
185 struct FFIIRFilterCoeffs *fcoeffs = NULL; | |
186 struct FFIIRFilterState *fstate = NULL; | |
187 float cutoff_coeff = 0.4; | |
188 int16_t x[SIZE], y[SIZE]; | |
189 int i; | |
190 FILE* fd; | |
191 | |
192 fcoeffs = ff_iir_filter_init_coeffs(FF_FILTER_TYPE_BUTTERWORTH, | |
193 FF_FILTER_MODE_LOWPASS, FILT_ORDER, | |
194 cutoff_coeff, 0.0, 0.0); | |
195 fstate = ff_iir_filter_init_state(FILT_ORDER); | |
196 | |
197 for (i = 0; i < SIZE; i++) { | |
198 x[i] = lrint(0.75 * INT16_MAX * sin(0.5*M_PI*i*i/SIZE)); | |
199 } | |
200 | |
201 ff_iir_filter(fcoeffs, fstate, SIZE, x, 1, y, 1); | |
202 | |
203 fd = fopen("in.bin", "w"); | |
204 fwrite(x, sizeof(x[0]), SIZE, fd); | |
205 fclose(fd); | |
206 | |
207 fd = fopen("out.bin", "w"); | |
208 fwrite(y, sizeof(y[0]), SIZE, fd); | |
209 fclose(fd); | |
210 | |
211 ff_iir_filter_free_coeffs(fcoeffs); | |
212 ff_iir_filter_free_state(fstate); | |
213 return 0; | |
214 } | |
215 #endif /* TEST */ |