Mercurial > libavcodec.hg
annotate iirfilter.h @ 9675:2e84b386a8b6 libavcodec
Fix for a problem with inverted sign of output data from ffvorbis decoder.
Now the sign of audio samples in ffvorbis output is the same as in original
uncompressed audio file and this also allows the use of tiny_psnr to compare
ffvorbis with libvorbis/tremor.
author | serge |
---|---|
date | Wed, 20 May 2009 07:24:38 +0000 |
parents | e9d9d946f213 |
children | 7dd2a45249a9 |
rev | line source |
---|---|
7713
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
1 /* |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
2 * IIR filter |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
3 * Copyright (c) 2008 Konstantin Shishkov |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
4 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
5 * This file is part of FFmpeg. |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
6 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
11 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
16 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
20 */ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
21 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
22 /** |
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
7760
diff
changeset
|
23 * @file libavcodec/iirfilter.h |
7713
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
24 * IIR filter interface |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
25 */ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
26 |
7760 | 27 #ifndef AVCODEC_IIRFILTER_H |
28 #define AVCODEC_IIRFILTER_H | |
7713
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
29 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
30 #include "avcodec.h" |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
31 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
32 struct FFIIRFilterCoeffs; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
33 struct FFIIRFilterState; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
34 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
35 enum IIRFilterType{ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
36 FF_FILTER_TYPE_BESSEL, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
37 FF_FILTER_TYPE_BUTTERWORTH, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
38 FF_FILTER_TYPE_CHEBYSHEV, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
39 FF_FILTER_TYPE_ELLIPTIC, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
40 }; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
41 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
42 enum IIRFilterMode{ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
43 FF_FILTER_MODE_LOWPASS, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
44 FF_FILTER_MODE_HIGHPASS, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
45 FF_FILTER_MODE_BANDPASS, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
46 FF_FILTER_MODE_BANDSTOP, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
47 }; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
48 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
49 /** |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
50 * Initialize filter coefficients. |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
51 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
52 * @param filt_type filter type (e.g. Butterworth) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
53 * @param filt_mode filter mode (e.g. lowpass) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
54 * @param order filter order |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
55 * @param cutoff_ratio cutoff to input frequency ratio |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
56 * @param stopband stopband to input frequency ratio (used by bandpass and bandstop filter modes) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
57 * @param ripple ripple factor (used only in Chebyshev filters) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
58 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
59 * @return pointer to filter coefficients structure or NULL if filter cannot be created |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
60 */ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
61 struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType filt_type, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
62 enum IIRFilterMode filt_mode, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
63 int order, float cutoff_ratio, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
64 float stopband, float ripple); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
65 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
66 /** |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
67 * Create new filter state. |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
68 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
69 * @param order filter order |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
70 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
71 * @return pointer to new filter state or NULL if state creation fails |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
72 */ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
73 struct FFIIRFilterState* ff_iir_filter_init_state(int order); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
74 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
75 /** |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
76 * Free filter coefficients. |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
77 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
78 * @param coeffs pointer allocated with ff_iir_filter_init_coeffs() |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
79 */ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
80 void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
81 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
82 /** |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
83 * Free filter state. |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
84 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
85 * @param state pointer allocated with ff_iir_filter_init_state() |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
86 */ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
87 void ff_iir_filter_free_state(struct FFIIRFilterState *state); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
88 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
89 /** |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
90 * Perform lowpass filtering on input samples. |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
91 * |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
92 * @param coeffs pointer to filter coefficients |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
93 * @param state pointer to filter state |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
94 * @param size input length |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
95 * @param src source samples |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
96 * @param sstep source stride |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
97 * @param dst filtered samples (destination may be the same as input) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
98 * @param dstep destination stride |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
99 */ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
100 void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
101 int size, const int16_t *src, int sstep, int16_t *dst, int dstep); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
102 |
7760 | 103 #endif /* AVCODEC_IIRFILTER_H */ |