FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
iirfilter.h
Go to the documentation of this file.
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 <stddef.h>
31 #include <stdint.h>
32 
33 struct FFIIRFilterCoeffs;
34 struct FFIIRFilterState;
35 
42 };
43 
49 };
50 
51 typedef struct FFIIRFilterContext {
52  /**
53  * Perform IIR filtering on floating-point input samples.
54  *
55  * @param coeffs pointer to filter coefficients
56  * @param state pointer to filter state
57  * @param size input length
58  * @param src source samples
59  * @param sstep source stride
60  * @param dst filtered samples (destination may be the same as input)
61  * @param dstep destination stride
62  */
64  struct FFIIRFilterState *state, int size,
65  const float *src, ptrdiff_t sstep, float *dst, ptrdiff_t dstep);
67 
68 /**
69  * Initialize FFIIRFilterContext
70  */
73 
74 /**
75  * Initialize filter coefficients.
76  *
77  * @param avc a pointer to an arbitrary struct of which the first
78  * field is a pointer to an AVClass struct
79  * @param filt_type filter type (e.g. Butterworth)
80  * @param filt_mode filter mode (e.g. lowpass)
81  * @param order filter order
82  * @param cutoff_ratio cutoff to input frequency ratio
83  * @param stopband stopband to input frequency ratio (used by bandpass and bandstop filter modes)
84  * @param ripple ripple factor (used only in Chebyshev filters)
85  *
86  * @return pointer to filter coefficients structure or NULL if filter cannot be created
87  */
89  enum IIRFilterType filt_type,
90  enum IIRFilterMode filt_mode,
91  int order, float cutoff_ratio,
92  float stopband, float ripple);
93 
94 /**
95  * Create new filter state.
96  *
97  * @param order filter order
98  *
99  * @return pointer to new filter state or NULL if state creation fails
100  */
101 struct FFIIRFilterState* ff_iir_filter_init_state(int order);
102 
103 /**
104  * Free filter coefficients.
105  *
106  * @param coeffs pointer allocated with ff_iir_filter_init_coeffs()
107  */
109 
110 /**
111  * Free and zero filter state.
112  *
113  * @param state pointer to pointer allocated with ff_iir_filter_init_state()
114  */
116 
117 /**
118  * Perform IIR filtering on signed 16-bit input samples.
119  *
120  * @param coeffs pointer to filter coefficients
121  * @param state pointer to filter state
122  * @param size input length
123  * @param src source samples
124  * @param sstep source stride
125  * @param dst filtered samples (destination may be the same as input)
126  * @param dstep destination stride
127  */
128 void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state,
129  int size, const int16_t *src, ptrdiff_t sstep, int16_t *dst, ptrdiff_t dstep);
130 
131 /**
132  * Perform IIR filtering on floating-point input samples.
133  *
134  * @param coeffs pointer to filter coefficients
135  * @param state pointer to filter state
136  * @param size input length
137  * @param src source samples
138  * @param sstep source stride
139  * @param dst filtered samples (destination may be the same as input)
140  * @param dstep destination stride
141  */
142 void ff_iir_filter_flt(const struct FFIIRFilterCoeffs *coeffs,
143  struct FFIIRFilterState *state, int size,
144  const float *src, ptrdiff_t sstep,
145  float *dst, ptrdiff_t dstep);
146 
147 #endif /* AVCODEC_IIRFILTER_H */
struct FFIIRFilterState * ff_iir_filter_init_state(int order)
Create new filter state.
Definition: iirfilter.c:204
IIRFilterMode
Definition: iirfilter.h:44
#define src
Definition: vp8dsp.c:254
void ff_iir_filter_free_statep(struct FFIIRFilterState **state)
Free and zero filter state.
Definition: iirfilter.c:307
void ff_iir_filter_flt(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state, int size, const float *src, ptrdiff_t sstep, float *dst, ptrdiff_t dstep)
Perform IIR filtering on floating-point input samples.
Definition: iirfilter.c:293
ptrdiff_t size
Definition: opengl_enc.c:101
struct FFIIRFilterCoeffs * ff_iir_filter_init_coeffs(void *avc, enum IIRFilterType filt_type, enum IIRFilterMode filt_mode, int order, float cutoff_ratio, float stopband, float ripple)
Initialize filter coefficients.
Definition: iirfilter.c:162
IIR filter state.
Definition: iirfilter.c:47
void ff_iir_filter_free_coeffsp(struct FFIIRFilterCoeffs **coeffs)
Free filter coefficients.
Definition: iirfilter.c:312
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
void(* filter_flt)(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state, int size, const float *src, ptrdiff_t sstep, float *dst, ptrdiff_t dstep)
Perform IIR filtering on floating-point input samples.
Definition: iirfilter.h:63
static struct @271 state
void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state, int size, const int16_t *src, ptrdiff_t sstep, int16_t *dst, ptrdiff_t dstep)
Perform IIR filtering on signed 16-bit input samples.
Definition: iirfilter.c:279
IIRFilterType
Definition: iirfilter.h:36
IIR filter global parameters.
Definition: iirfilter.c:37
void ff_iir_filter_init_mips(FFIIRFilterContext *f)
static const int16_t coeffs[]
void ff_iir_filter_init(FFIIRFilterContext *f)
Initialize FFIIRFilterContext.
Definition: iirfilter.c:322