History

IIR filter test program.

Originally committed as revision 19443 to svn://svn.ffmpeg.org/ffmpeg/trunk

Alex Converse committed 17 years ago

Commit ca0f1e51 parent 359a9971 file · +36 −0Browse files

Unified · Split

libavcodec/iirfilter.c+36−0
@@ -177,3 +177,39 @@ av_cold void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs) · 176 unmodified lines
177 av_free(coeffs);177 av_free(coeffs);
178}178}
179 179
180#ifdef TEST
181#define FILT_ORDER 4
182#define SIZE 1024
183int 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 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t