Merge branch 'mirror' into vdpau
[FFMpeg-mirror/ffmpeg-vdpau.git] / libavcodec / iirfilter.h
blobd51f44b8e8344cf2548a9d2a3917473629d1ef42
1 /*
2 * IIR filter
3 * Copyright (c) 2008 Konstantin Shishkov
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 /**
23 * @file iirfilter.h
24 * IIR filter interface
27 #ifndef AVCODEC_IIRFILTER_H
28 #define AVCODEC_IIRFILTER_H
30 #include "avcodec.h"
32 struct FFIIRFilterCoeffs;
33 struct FFIIRFilterState;
35 enum IIRFilterType{
36 FF_FILTER_TYPE_BESSEL,
37 FF_FILTER_TYPE_BUTTERWORTH,
38 FF_FILTER_TYPE_CHEBYSHEV,
39 FF_FILTER_TYPE_ELLIPTIC,
42 enum IIRFilterMode{
43 FF_FILTER_MODE_LOWPASS,
44 FF_FILTER_MODE_HIGHPASS,
45 FF_FILTER_MODE_BANDPASS,
46 FF_FILTER_MODE_BANDSTOP,
49 /**
50 * Initialize filter coefficients.
52 * @param filt_type filter type (e.g. Butterworth)
53 * @param filt_mode filter mode (e.g. lowpass)
54 * @param order filter order
55 * @param cutoff_ratio cutoff to input frequency ratio
56 * @param stopband stopband to input frequency ratio (used by bandpass and bandstop filter modes)
57 * @param ripple ripple factor (used only in Chebyshev filters)
59 * @return pointer to filter coefficients structure or NULL if filter cannot be created
61 struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType filt_type,
62 enum IIRFilterMode filt_mode,
63 int order, float cutoff_ratio,
64 float stopband, float ripple);
66 /**
67 * Create new filter state.
69 * @param order filter order
71 * @return pointer to new filter state or NULL if state creation fails
73 struct FFIIRFilterState* ff_iir_filter_init_state(int order);
75 /**
76 * Free filter coefficients.
78 * @param coeffs pointer allocated with ff_iir_filter_init_coeffs()
80 void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs);
82 /**
83 * Free filter state.
85 * @param state pointer allocated with ff_iir_filter_init_state()
87 void ff_iir_filter_free_state(struct FFIIRFilterState *state);
89 /**
90 * Perform lowpass filtering on input samples.
92 * @param coeffs pointer to filter coefficients
93 * @param state pointer to filter state
94 * @param size input length
95 * @param src source samples
96 * @param sstep source stride
97 * @param dst filtered samples (destination may be the same as input)
98 * @param dstep destination stride
100 void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state,
101 int size, const int16_t *src, int sstep, int16_t *dst, int dstep);
103 #endif /* AVCODEC_IIRFILTER_H */