Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 123 lines (109 sloc) 4.002 kb
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
1 /*
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
2 * IIR filter
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
3 * Copyright (c) 2008 Konstantin Shishkov
4 *
5 * This file is part of FFmpeg.
6 *
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.
11 *
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.
16 *
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
20 */
21
22 /**
ba87f08 @DonDiego Remove explicit filename from Doxygen @file commands.
DonDiego authored
23 * @file
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
24 * IIR filter interface
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
25 */
26
9879038 Globally rename the header inclusion guard names.
Stefano Sabatini authored
27 #ifndef AVCODEC_IIRFILTER_H
28 #define AVCODEC_IIRFILTER_H
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
29
30 #include "avcodec.h"
31
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
32 struct FFIIRFilterCoeffs;
33 struct FFIIRFilterState;
34
35 enum IIRFilterType{
36 FF_FILTER_TYPE_BESSEL,
aa226b2 @justinruggles Add biquad high-pass and low-pass IIR filters.
justinruggles authored
37 FF_FILTER_TYPE_BIQUAD,
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
38 FF_FILTER_TYPE_BUTTERWORTH,
39 FF_FILTER_TYPE_CHEBYSHEV,
40 FF_FILTER_TYPE_ELLIPTIC,
41 };
42
43 enum IIRFilterMode{
44 FF_FILTER_MODE_LOWPASS,
45 FF_FILTER_MODE_HIGHPASS,
46 FF_FILTER_MODE_BANDPASS,
47 FF_FILTER_MODE_BANDSTOP,
48 };
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
49
50 /**
51 * Initialize filter coefficients.
52 *
20d1f6f @justinruggles Add memory allocation failure checks to ff_iir_filter_init_coeffs().
justinruggles authored
53 * @param avc a pointer to an arbitrary struct of which the first
54 * field is a pointer to an AVClass struct
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
55 * @param filt_type filter type (e.g. Butterworth)
56 * @param filt_mode filter mode (e.g. lowpass)
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
57 * @param order filter order
58 * @param cutoff_ratio cutoff to input frequency ratio
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
59 * @param stopband stopband to input frequency ratio (used by bandpass and bandstop filter modes)
60 * @param ripple ripple factor (used only in Chebyshev filters)
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
61 *
62 * @return pointer to filter coefficients structure or NULL if filter cannot be created
63 */
20d1f6f @justinruggles Add memory allocation failure checks to ff_iir_filter_init_coeffs().
justinruggles authored
64 struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
65 enum IIRFilterType filt_type,
99c2111 @justinruggles cosmetics: vertical alignment and line wrap
justinruggles authored
66 enum IIRFilterMode filt_mode,
67 int order, float cutoff_ratio,
68 float stopband, float ripple);
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
69
70 /**
71 * Create new filter state.
72 *
73 * @param order filter order
74 *
75 * @return pointer to new filter state or NULL if state creation fails
76 */
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
77 struct FFIIRFilterState* ff_iir_filter_init_state(int order);
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
78
79 /**
80 * Free filter coefficients.
81 *
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
82 * @param coeffs pointer allocated with ff_iir_filter_init_coeffs()
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
83 */
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
84 void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs);
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
85
86 /**
87 * Free filter state.
88 *
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
89 * @param state pointer allocated with ff_iir_filter_init_state()
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
90 */
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
91 void ff_iir_filter_free_state(struct FFIIRFilterState *state);
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
92
93 /**
b3b8b93 @justinruggles Add function ff_iir_filter_flt() to accept floating-point input and outp...
justinruggles authored
94 * Perform IIR filtering on signed 16-bit input samples.
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
95 *
96 * @param coeffs pointer to filter coefficients
97 * @param state pointer to filter state
98 * @param size input length
99 * @param src source samples
100 * @param sstep source stride
101 * @param dst filtered samples (destination may be the same as input)
102 * @param dstep destination stride
103 */
a169f49 Add generic IIR filter interface with Butterworth lowpass filter impleme...
Kostya Shishkov authored
104 void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state,
105 int size, const int16_t *src, int sstep, int16_t *dst, int dstep);
2e0b635 Simple lowpass filter implementation.
Kostya Shishkov authored
106
b3b8b93 @justinruggles Add function ff_iir_filter_flt() to accept floating-point input and outp...
justinruggles authored
107 /**
108 * Perform IIR filtering on floating-point input samples.
109 *
110 * @param coeffs pointer to filter coefficients
111 * @param state pointer to filter state
112 * @param size input length
113 * @param src source samples
114 * @param sstep source stride
115 * @param dst filtered samples (destination may be the same as input)
116 * @param dstep destination stride
117 */
118 void ff_iir_filter_flt(const struct FFIIRFilterCoeffs *coeffs,
119 struct FFIIRFilterState *state, int size,
17d4f45 @justinruggles iir: Change dst param to float* in ff_iir_filter_flt().
justinruggles authored
120 const float *src, int sstep, float *dst, int dstep);
b3b8b93 @justinruggles Add function ff_iir_filter_flt() to accept floating-point input and outp...
justinruggles authored
121
9879038 Globally rename the header inclusion guard names.
Stefano Sabatini authored
122 #endif /* AVCODEC_IIRFILTER_H */
Something went wrong with that request. Please try again.