diff options
author | Diego Biurrun <diego@biurrun.de> | 2016-04-20 11:40:40 +0200 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2016-05-13 14:55:56 +0200 |
commit | a6a750c7ef240b72ce01e9653343a0ddf247d196 (patch) | |
tree | 5c472bb92b5264f19b9270b0caf8a8565b071cef /libavcodec/tests/iirfilter.c | |
parent | 257f00ec1ab06a2a161f535036c6512f3fc8e801 (diff) | |
download | ffmpeg-streaming-a6a750c7ef240b72ce01e9653343a0ddf247d196.zip ffmpeg-streaming-a6a750c7ef240b72ce01e9653343a0ddf247d196.tar.gz |
tests: Move all test programs to a subdirectory
Diffstat (limited to 'libavcodec/tests/iirfilter.c')
-rw-r--r-- | libavcodec/tests/iirfilter.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/libavcodec/tests/iirfilter.c b/libavcodec/tests/iirfilter.c new file mode 100644 index 0000000..a6001a3 --- /dev/null +++ b/libavcodec/tests/iirfilter.c @@ -0,0 +1,54 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <math.h> +#include <stdint.h> +#include <stdio.h> + +#include "libavutil/libm.h" + +#include "libavcodec/iirfilter.h" + +#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; + + fcoeffs = ff_iir_filter_init_coeffs(NULL, 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); + + for (i = 0; i < SIZE; i++) + printf("%6d %6d\n", x[i], y[i]); + + ff_iir_filter_free_coeffs(fcoeffs); + ff_iir_filter_free_state(fstate); + return 0; +} |