aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Converse <alex.converse@gmail.com>2009-07-16 22:17:20 +0000
committerAlex Converse <alex.converse@gmail.com>2009-07-16 22:17:20 +0000
commitca0f1e50928bda4a150d3bafe133e3d593f4aa65 (patch)
tree8da1f4ad9c54f6578b45a60b7beff93b3ad9a28d
parent359a9979adbd6bd4ba31221feb9e4dbdcfc2bba3 (diff)
downloadffmpeg-ca0f1e50928bda4a150d3bafe133e3d593f4aa65.tar.gz
IIR filter test program.
Originally committed as revision 19443 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/iirfilter.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libavcodec/iirfilter.c b/libavcodec/iirfilter.c
index 87206fc5d2..eb6ec90d16 100644
--- a/libavcodec/iirfilter.c
+++ b/libavcodec/iirfilter.c
@@ -177,3 +177,39 @@ av_cold void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs)
av_free(coeffs);
}
+#ifdef TEST
+#define FILT_ORDER 4
+#define SIZE 1024
+int main(void)
+{
+ struct FFIIRFilterCoeffs *fcoeffs = NULL;
+ struct FFIIRFilterState *fstate = NULL;
+ float cutoff_coeff = 0.4;
+ int16_t x[SIZE], y[SIZE];
+ int i;
+ FILE* fd;
+
+ fcoeffs = ff_iir_filter_init_coeffs(FF_FILTER_TYPE_BUTTERWORTH,
+ FF_FILTER_MODE_LOWPASS, FILT_ORDER,
+ cutoff_coeff, 0.0, 0.0);
+ fstate = ff_iir_filter_init_state(FILT_ORDER);
+
+ for (i = 0; i < SIZE; i++) {
+ x[i] = lrint(0.75 * INT16_MAX * sin(0.5*M_PI*i*i/SIZE));
+ }
+
+ ff_iir_filter(fcoeffs, fstate, SIZE, x, 1, y, 1);
+
+ fd = fopen("in.bin", "w");
+ fwrite(x, sizeof(x[0]), SIZE, fd);
+ fclose(fd);
+
+ fd = fopen("out.bin", "w");
+ fwrite(y, sizeof(y[0]), SIZE, fd);
+ fclose(fd);
+
+ ff_iir_filter_free_coeffs(fcoeffs);
+ ff_iir_filter_free_state(fstate);
+ return 0;
+}
+#endif /* TEST */