Mercurial > libavcodec.hg
annotate iirfilter.c @ 8991:ca768cb2bfb6 libavcodec
Use last decoded SPS as current SPS in order to parse picture timing SEI
correctly. This works around an apparent H.264 standard deficiency.
Patch by Ivan Schreter, schreter gmx net
author | cehoyos |
---|---|
date | Fri, 20 Feb 2009 16:20:01 +0000 |
parents | e9d9d946f213 |
children | 2cd0d1447bd3 |
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:
7713
diff
changeset
|
23 * @file libavcodec/iirfilter.c |
7713
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
24 * different IIR filters implementation |
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 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
27 #include "iirfilter.h" |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
28 #include <complex.h> |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
29 #include <math.h> |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
30 |
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 * IIR filter global parameters |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
33 */ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
34 typedef struct FFIIRFilterCoeffs{ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
35 int order; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
36 float gain; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
37 int *cx; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
38 float *cy; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
39 }FFIIRFilterCoeffs; |
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 * IIR filter state |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
43 */ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
44 typedef struct FFIIRFilterState{ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
45 float x[1]; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
46 }FFIIRFilterState; |
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 /// maximum supported filter order |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
49 #define MAXORDER 30 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
50 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
51 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
|
52 enum IIRFilterMode filt_mode, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
53 int order, float cutoff_ratio, |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
54 float stopband, float ripple) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
55 { |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
56 int i, j, size; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
57 FFIIRFilterCoeffs *c; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
58 double wa; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
59 complex p[MAXORDER + 1]; |
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 if(filt_type != FF_FILTER_TYPE_BUTTERWORTH || filt_mode != FF_FILTER_MODE_LOWPASS) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
62 return NULL; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
63 if(order <= 1 || (order & 1) || order > MAXORDER || cutoff_ratio >= 1.0) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
64 return NULL; |
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 c = av_malloc(sizeof(FFIIRFilterCoeffs)); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
67 c->cx = av_malloc(sizeof(c->cx[0]) * ((order >> 1) + 1)); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
68 c->cy = av_malloc(sizeof(c->cy[0]) * order); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
69 c->order = 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 wa = 2 * tan(M_PI * 0.5 * cutoff_ratio); |
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 c->cx[0] = 1; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
74 for(i = 1; i < (order >> 1) + 1; i++) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
75 c->cx[i] = c->cx[i - 1] * (order - i + 1LL) / i; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
76 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
77 p[0] = 1.0; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
78 for(i = 1; i <= order; i++) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
79 p[i] = 0.0; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
80 for(i = 0; i < order; i++){ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
81 complex zp; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
82 double th = (i + (order >> 1) + 0.5) * M_PI / order; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
83 zp = cexp(I*th) * wa; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
84 zp = (zp + 2.0) / (zp - 2.0); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
85 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
86 for(j = order; j >= 1; j--) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
87 p[j] = zp*p[j] + p[j - 1]; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
88 p[0] *= zp; |
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 c->gain = creal(p[order]); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
91 for(i = 0; i < order; i++){ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
92 c->gain += creal(p[i]); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
93 c->cy[i] = creal(-p[i] / p[order]); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
94 } |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
95 c->gain /= 1 << order; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
96 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
97 return c; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
98 } |
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 struct FFIIRFilterState* ff_iir_filter_init_state(int order) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
101 { |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
102 FFIIRFilterState* s = av_mallocz(sizeof(FFIIRFilterState) + sizeof(s->x[0]) * (order - 1)); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
103 return s; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
104 } |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
105 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
106 #define FILTER(i0, i1, i2, i3) \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
107 in = *src * c->gain \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
108 + c->cy[0]*s->x[i0] + c->cy[1]*s->x[i1] \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
109 + c->cy[2]*s->x[i2] + c->cy[3]*s->x[i3]; \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
110 res = (s->x[i0] + in )*1 \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
111 + (s->x[i1] + s->x[i3])*4 \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
112 + s->x[i2] *6; \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
113 *dst = av_clip_int16(lrintf(res)); \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
114 s->x[i0] = in; \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
115 src += sstep; \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
116 dst += dstep; \ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
117 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
118 void ff_iir_filter(const struct FFIIRFilterCoeffs *c, struct FFIIRFilterState *s, 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
|
119 { |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
120 int i; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
121 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
122 if(c->order == 4){ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
123 for(i = 0; i < size; i += 4){ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
124 float in, res; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
125 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
126 FILTER(0, 1, 2, 3); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
127 FILTER(1, 2, 3, 0); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
128 FILTER(2, 3, 0, 1); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
129 FILTER(3, 0, 1, 2); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
130 } |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
131 }else{ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
132 for(i = 0; i < size; i++){ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
133 int j; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
134 float in, res; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
135 in = *src * c->gain; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
136 for(j = 0; j < c->order; j++) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
137 in += c->cy[j] * s->x[j]; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
138 res = s->x[0] + in + s->x[c->order >> 1] * c->cx[c->order >> 1]; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
139 for(j = 1; j < c->order >> 1; j++) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
140 res += (s->x[j] + s->x[c->order - j]) * c->cx[j]; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
141 for(j = 0; j < c->order - 1; j++) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
142 s->x[j] = s->x[j + 1]; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
143 *dst = av_clip_int16(lrintf(res)); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
144 s->x[c->order - 1] = in; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
145 src += sstep; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
146 dst += sstep; |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
147 } |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
148 } |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
149 } |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
150 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
151 void ff_iir_filter_free_state(struct FFIIRFilterState *state) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
152 { |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
153 av_free(state); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
154 } |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
155 |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
156 void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs) |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
157 { |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
158 if(coeffs){ |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
159 av_free(coeffs->cx); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
160 av_free(coeffs->cy); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
161 } |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
162 av_free(coeffs); |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
163 } |
f1e68b2dc389
Add generic IIR filter interface with Butterworth lowpass filter implementation
kostya
parents:
diff
changeset
|
164 |