Originally committed as revision 19443 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -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 | ||
| 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 */ | ||