ffmpeg / libavcodec / iirfilter.h @ d42dc217
History | View | Annotate | Download (3.89 KB)
1 |
/*
|
---|---|
2 |
* IIR filter
|
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 |
/**
|
23 |
* @file
|
24 |
* IIR filter interface
|
25 |
*/
|
26 |
|
27 |
#ifndef AVCODEC_IIRFILTER_H
|
28 |
#define AVCODEC_IIRFILTER_H
|
29 |
|
30 |
#include "avcodec.h" |
31 |
|
32 |
struct FFIIRFilterCoeffs;
|
33 |
struct FFIIRFilterState;
|
34 |
|
35 |
enum IIRFilterType{
|
36 |
FF_FILTER_TYPE_BESSEL, |
37 |
FF_FILTER_TYPE_BUTTERWORTH, |
38 |
FF_FILTER_TYPE_CHEBYSHEV, |
39 |
FF_FILTER_TYPE_ELLIPTIC, |
40 |
}; |
41 |
|
42 |
enum IIRFilterMode{
|
43 |
FF_FILTER_MODE_LOWPASS, |
44 |
FF_FILTER_MODE_HIGHPASS, |
45 |
FF_FILTER_MODE_BANDPASS, |
46 |
FF_FILTER_MODE_BANDSTOP, |
47 |
}; |
48 |
|
49 |
/**
|
50 |
* Initialize filter coefficients.
|
51 |
*
|
52 |
* @param avc a pointer to an arbitrary struct of which the first
|
53 |
* field is a pointer to an AVClass struct
|
54 |
* @param filt_type filter type (e.g. Butterworth)
|
55 |
* @param filt_mode filter mode (e.g. lowpass)
|
56 |
* @param order filter order
|
57 |
* @param cutoff_ratio cutoff to input frequency ratio
|
58 |
* @param stopband stopband to input frequency ratio (used by bandpass and bandstop filter modes)
|
59 |
* @param ripple ripple factor (used only in Chebyshev filters)
|
60 |
*
|
61 |
* @return pointer to filter coefficients structure or NULL if filter cannot be created
|
62 |
*/
|
63 |
struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc, |
64 |
enum IIRFilterType filt_type,
|
65 |
enum IIRFilterMode filt_mode,
|
66 |
int order, float cutoff_ratio, |
67 |
float stopband, float ripple); |
68 |
|
69 |
/**
|
70 |
* Create new filter state.
|
71 |
*
|
72 |
* @param order filter order
|
73 |
*
|
74 |
* @return pointer to new filter state or NULL if state creation fails
|
75 |
*/
|
76 |
struct FFIIRFilterState* ff_iir_filter_init_state(int order); |
77 |
|
78 |
/**
|
79 |
* Free filter coefficients.
|
80 |
*
|
81 |
* @param coeffs pointer allocated with ff_iir_filter_init_coeffs()
|
82 |
*/
|
83 |
void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs); |
84 |
|
85 |
/**
|
86 |
* Free filter state.
|
87 |
*
|
88 |
* @param state pointer allocated with ff_iir_filter_init_state()
|
89 |
*/
|
90 |
void ff_iir_filter_free_state(struct FFIIRFilterState *state); |
91 |
|
92 |
/**
|
93 |
* Perform IIR filtering on signed 16-bit input samples.
|
94 |
*
|
95 |
* @param coeffs pointer to filter coefficients
|
96 |
* @param state pointer to filter state
|
97 |
* @param size input length
|
98 |
* @param src source samples
|
99 |
* @param sstep source stride
|
100 |
* @param dst filtered samples (destination may be the same as input)
|
101 |
* @param dstep destination stride
|
102 |
*/
|
103 |
void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state, |
104 |
int size, const int16_t *src, int sstep, int16_t *dst, int dstep); |
105 |
|
106 |
/**
|
107 |
* Perform IIR filtering on floating-point input samples.
|
108 |
*
|
109 |
* @param coeffs pointer to filter coefficients
|
110 |
* @param state pointer to filter state
|
111 |
* @param size input length
|
112 |
* @param src source samples
|
113 |
* @param sstep source stride
|
114 |
* @param dst filtered samples (destination may be the same as input)
|
115 |
* @param dstep destination stride
|
116 |
*/
|
117 |
void ff_iir_filter_flt(const struct FFIIRFilterCoeffs *coeffs, |
118 |
struct FFIIRFilterState *state, int size, |
119 |
const float *src, int sstep, void *dst, int dstep); |
120 |
|
121 |
#endif /* AVCODEC_IIRFILTER_H */ |