blob: 5977200c9c59dccd4b014fefa9b413b36bdf95b2 [file] [log] [blame]
Thom Johansena8cc6a72006-01-29 02:10:28 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
Thom Johansena7fabf02007-02-26 00:41:26 +000010 * Copyright (C) 2006-2007 Thom Johansen
Thom Johansena8cc6a72006-01-29 02:10:28 +000011 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Thom Johansena8cc6a72006-01-29 02:10:28 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
Thom Johansenea4ccb52006-03-19 16:31:45 +000022#include <inttypes.h>
Thom Johansena8cc6a72006-01-29 02:10:28 +000023#include "config.h"
Thom Johansen5f48e152007-02-05 01:01:15 +000024#include "dsp.h"
Thom Johansena8cc6a72006-01-29 02:10:28 +000025#include "eq.h"
Thom Johansen5f48e152007-02-05 01:01:15 +000026#include "replaygain.h"
Thom Johansena8cc6a72006-01-29 02:10:28 +000027
Thom Johansene70a50c2006-03-23 15:40:59 +000028/* Inverse gain of circular cordic rotation in s0.31 format. */
29static const long cordic_circular_gain = 0xb2458939; /* 0.607252929 */
30
31/* Table of values of atan(2^-i) in 0.32 format fractions of pi where pi = 0xffffffff / 2 */
32static const unsigned long atan_table[] = {
33 0x1fffffff, /* +0.785398163 (or pi/4) */
34 0x12e4051d, /* +0.463647609 */
35 0x09fb385b, /* +0.244978663 */
36 0x051111d4, /* +0.124354995 */
37 0x028b0d43, /* +0.062418810 */
38 0x0145d7e1, /* +0.031239833 */
39 0x00a2f61e, /* +0.015623729 */
40 0x00517c55, /* +0.007812341 */
41 0x0028be53, /* +0.003906230 */
42 0x00145f2e, /* +0.001953123 */
43 0x000a2f98, /* +0.000976562 */
44 0x000517cc, /* +0.000488281 */
45 0x00028be6, /* +0.000244141 */
46 0x000145f3, /* +0.000122070 */
47 0x0000a2f9, /* +0.000061035 */
48 0x0000517c, /* +0.000030518 */
49 0x000028be, /* +0.000015259 */
50 0x0000145f, /* +0.000007629 */
51 0x00000a2f, /* +0.000003815 */
52 0x00000517, /* +0.000001907 */
53 0x0000028b, /* +0.000000954 */
54 0x00000145, /* +0.000000477 */
55 0x000000a2, /* +0.000000238 */
56 0x00000051, /* +0.000000119 */
57 0x00000028, /* +0.000000060 */
58 0x00000014, /* +0.000000030 */
59 0x0000000a, /* +0.000000015 */
60 0x00000005, /* +0.000000007 */
61 0x00000002, /* +0.000000004 */
62 0x00000001, /* +0.000000002 */
63 0x00000000, /* +0.000000001 */
64 0x00000000, /* +0.000000000 */
Thom Johansena8cc6a72006-01-29 02:10:28 +000065};
66
Thom Johansene70a50c2006-03-23 15:40:59 +000067/**
68 * Implements sin and cos using CORDIC rotation.
69 *
70 * @param phase has range from 0 to 0xffffffff, representing 0 and
71 * 2*pi respectively.
72 * @param cos return address for cos
73 * @return sin of phase, value is a signed value from LONG_MIN to LONG_MAX,
74 * representing -1 and 1 respectively.
Thom Johansena8cc6a72006-01-29 02:10:28 +000075 */
Jens Arnold314f3b52006-12-12 22:22:21 +000076static long fsincos(unsigned long phase, long *cos) {
Thom Johansen5f9bd4f2006-03-23 19:26:21 +000077 int32_t x, x1, y, y1;
Thom Johansene70a50c2006-03-23 15:40:59 +000078 unsigned long z, z1;
79 int i;
Thom Johansena8cc6a72006-01-29 02:10:28 +000080
Thom Johansene70a50c2006-03-23 15:40:59 +000081 /* Setup initial vector */
82 x = cordic_circular_gain;
83 y = 0;
84 z = phase;
85
86 /* The phase has to be somewhere between 0..pi for this to work right */
87 if (z < 0xffffffff / 4) {
88 /* z in first quadrant, z += pi/2 to correct */
89 x = -x;
90 z += 0xffffffff / 4;
91 } else if (z < 3 * (0xffffffff / 4)) {
92 /* z in third quadrant, z -= pi/2 to correct */
93 z -= 0xffffffff / 4;
94 } else {
95 /* z in fourth quadrant, z -= 3pi/2 to correct */
96 x = -x;
97 z -= 3 * (0xffffffff / 4);
98 }
99
100 /* Each iteration adds roughly 1-bit of extra precision */
101 for (i = 0; i < 31; i++) {
102 x1 = x >> i;
103 y1 = y >> i;
104 z1 = atan_table[i];
105
106 /* Decided which direction to rotate vector. Pivot point is pi/2 */
107 if (z >= 0xffffffff / 4) {
108 x -= y1;
109 y += x1;
110 z -= z1;
111 } else {
112 x += y1;
113 y -= x1;
114 z += z1;
115 }
116 }
117
118 *cos = x;
119
120 return y;
Thom Johansena8cc6a72006-01-29 02:10:28 +0000121}
122
Thom Johansen8e6e2902007-03-07 15:06:33 +0000123/**
124 * Calculate first order shelving filter. Filter is not directly usable by the
125 * eq_filter() function.
126 * @param cutoff shelf midpoint frequency. See eq_pk_coefs for format.
127 * @param A decibel value multiplied by ten, describing gain/attenuation of
128 * shelf. Max value is 24 dB.
129 * @param low true for low-shelf filter, false for high-shelf filter.
130 * @param c pointer to coefficient storage. Coefficients are s4.27 format.
Thom Johansen8238b492006-04-11 13:49:05 +0000131 */
Thom Johansen8e6e2902007-03-07 15:06:33 +0000132void filter_shelf_coefs(unsigned long cutoff, long A, bool low, int32_t *c)
Thom Johansen8238b492006-04-11 13:49:05 +0000133{
Thom Johansen8e6e2902007-03-07 15:06:33 +0000134 long sin, cos;
135 int32_t b0, b1, a0, a1; /* s3.28 */
136 const long g = get_replaygain_int(A*5) << 4; /* 10^(db/40), s3.28 */
Thom Johansen8238b492006-04-11 13:49:05 +0000137
Thom Johansen8e6e2902007-03-07 15:06:33 +0000138 sin = fsincos(cutoff/2, &cos);
139 if (low) {
140 const int32_t sin_div_g = DIV64(sin, g, 25);
141 cos >>= 3;
142 b0 = FRACMUL(sin, g) + cos; /* 0.25 .. 4.10 */
143 b1 = FRACMUL(sin, g) - cos; /* -1 .. 3.98 */
144 a0 = sin_div_g + cos; /* 0.25 .. 4.10 */
145 a1 = sin_div_g - cos; /* -1 .. 3.98 */
146 } else {
147 const int32_t cos_div_g = DIV64(cos, g, 25);
148 sin >>= 3;
149 b0 = sin + FRACMUL(cos, g); /* 0.25 .. 4.10 */
150 b1 = sin - FRACMUL(cos, g); /* -3.98 .. 1 */
151 a0 = sin + cos_div_g; /* 0.25 .. 4.10 */
152 a1 = sin - cos_div_g; /* -3.98 .. 1 */
153 }
Thom Johansen8238b492006-04-11 13:49:05 +0000154
Thom Johansen8e6e2902007-03-07 15:06:33 +0000155 const int32_t rcp_a0 = DIV64(1, a0, 57); /* 0.24 .. 3.98, s2.29 */
156 *c++ = FRACMUL_SHL(b0, rcp_a0, 1); /* 0.063 .. 15.85 */
157 *c++ = FRACMUL_SHL(b1, rcp_a0, 1); /* -15.85 .. 15.85 */
158 *c++ = -FRACMUL_SHL(a1, rcp_a0, 1); /* -1 .. 1 */
Thom Johansen8238b492006-04-11 13:49:05 +0000159}
160
Thom Johansendeb69d22007-02-26 00:58:07 +0000161#ifdef HAVE_SW_TONE_CONTROLS
Thom Johansena7fabf02007-02-26 00:41:26 +0000162/**
163 * Calculate second order section filter consisting of one low-shelf and one
164 * high-shelf section.
165 * @param cutoff_low low-shelf midpoint frequency. See eq_pk_coefs for format.
166 * @param cutoff_high high-shelf midpoint frequency.
167 * @param A_low decibel value multiplied by ten, describing gain/attenuation of
168 * low-shelf part. Max value is 24 dB.
169 * @param A_high decibel value multiplied by ten, describing gain/attenuation of
170 * high-shelf part. Max value is 24 dB.
171 * @param A decibel value multiplied by ten, describing additional overall gain.
172 * @param c pointer to coefficient storage. Coefficients are s4.27 format.
173 */
174void filter_bishelf_coefs(unsigned long cutoff_low, unsigned long cutoff_high,
175 long A_low, long A_high, long A, int32_t *c)
176{
Thom Johansena7fabf02007-02-26 00:41:26 +0000177 const long g = get_replaygain_int(A*10) << 7; /* 10^(db/20), s0.31 */
Thom Johansen8e6e2902007-03-07 15:06:33 +0000178 int32_t c_ls[3], c_hs[3];
Thom Johansena7fabf02007-02-26 00:41:26 +0000179
Thom Johansen8e6e2902007-03-07 15:06:33 +0000180 filter_shelf_coefs(cutoff_low, A_low, true, c_ls);
181 filter_shelf_coefs(cutoff_high, A_high, false, c_hs);
182 c_ls[0] = FRACMUL(g, c_ls[0]);
183 c_ls[1] = FRACMUL(g, c_ls[1]);
Thom Johansena7fabf02007-02-26 00:41:26 +0000184
185 /* now we cascade the two first order filters to one second order filter
186 * which can be used by eq_filter(). these resulting coefficients have a
187 * really wide numerical range, so we use a fixed point format which will
188 * work for the selected cutoff frequencies (in dsp.c) only.
189 */
Thom Johansen8e6e2902007-03-07 15:06:33 +0000190 const int32_t b0 = c_ls[0], b1 = c_ls[1], b2 = c_hs[0], b3 = c_hs[1];
191 const int32_t a0 = c_ls[2], a1 = c_hs[2];
192 *c++ = FRACMUL_SHL(b0, b2, 4);
193 *c++ = FRACMUL_SHL(b0, b3, 4) + FRACMUL_SHL(b1, b2, 4);
194 *c++ = FRACMUL_SHL(b1, b3, 4);
195 *c++ = a0 + a1;
196 *c++ = -FRACMUL_SHL(a0, a1, 4);
Thom Johansena7fabf02007-02-26 00:41:26 +0000197}
Thom Johansendeb69d22007-02-26 00:58:07 +0000198#endif
Thom Johansena7fabf02007-02-26 00:41:26 +0000199
Thom Johansen5f48e152007-02-05 01:01:15 +0000200/* Coef calculation taken from Audio-EQ-Cookbook.txt by Robert Bristow-Johnson.
201 * Slightly faster calculation can be done by deriving forms which use tan()
202 * instead of cos() and sin(), but the latter are far easier to use when doing
203 * fixed point math, and performance is not a big point in the calculation part.
204 * All the 'a' filter coefficients are negated so we can use only additions
205 * in the filtering equation.
206 */
207
Thom Johansen48b4ac32006-10-18 22:45:39 +0000208/**
209 * Calculate second order section peaking filter coefficients.
210 * @param cutoff a value from 0 to 0x80000000, where 0 represents 0 Hz and
211 * 0x80000000 represents the Nyquist frequency (samplerate/2).
Thom Johansen5f48e152007-02-05 01:01:15 +0000212 * @param Q Q factor value multiplied by ten. Lower bound is artificially set
213 * at 0.5.
214 * @param db decibel value multiplied by ten, describing gain/attenuation at
Thom Johansena7fabf02007-02-26 00:41:26 +0000215 * peak freq. Max value is 24 dB.
Thom Johansen48b4ac32006-10-18 22:45:39 +0000216 * @param c pointer to coefficient storage. Coefficients are s3.28 format.
Thom Johansena8cc6a72006-01-29 02:10:28 +0000217 */
Thom Johansenc00ec112006-03-21 01:09:53 +0000218void eq_pk_coefs(unsigned long cutoff, unsigned long Q, long db, int32_t *c)
Thom Johansena8cc6a72006-01-29 02:10:28 +0000219{
Thom Johansen5f48e152007-02-05 01:01:15 +0000220 long cs;
Thom Johansena8cc6a72006-01-29 02:10:28 +0000221 const long one = 1 << 28; /* s3.28 */
Thom Johansen5f48e152007-02-05 01:01:15 +0000222 const long A = get_replaygain_int(db*5) << 5; /* 10^(db/40), s2.29 */
223 const long alpha = fsincos(cutoff, &cs)/(2*Q)*10 >> 1; /* s1.30 */
Thom Johansenc00ec112006-03-21 01:09:53 +0000224 int32_t a0, a1, a2; /* these are all s3.28 format */
225 int32_t b0, b1, b2;
Thom Johansen5f48e152007-02-05 01:01:15 +0000226 const long alphadivA = DIV64(alpha, A, 27);
Thom Johansena8cc6a72006-01-29 02:10:28 +0000227
Thom Johansen48b4ac32006-10-18 22:45:39 +0000228 /* possible numerical ranges are in comments by each coef */
229 b0 = one + FRACMUL(alpha, A); /* [1 .. 5] */
Thom Johansen5f48e152007-02-05 01:01:15 +0000230 b1 = a1 = -2*(cs >> 3); /* [-2 .. 2] */
Thom Johansen48b4ac32006-10-18 22:45:39 +0000231 b2 = one - FRACMUL(alpha, A); /* [-3 .. 1] */
Thom Johansen5f48e152007-02-05 01:01:15 +0000232 a0 = one + alphadivA; /* [1 .. 5] */
233 a2 = one - alphadivA; /* [-3 .. 1] */
Thom Johansena8cc6a72006-01-29 02:10:28 +0000234
Thom Johansen5f48e152007-02-05 01:01:15 +0000235 /* range of this is roughly [0.2 .. 1], but we'll never hit 1 completely */
236 const long rcp_a0 = DIV64(1, a0, 59); /* s0.31 */
237 *c++ = FRACMUL(b0, rcp_a0); /* [0.25 .. 4] */
238 *c++ = FRACMUL(b1, rcp_a0); /* [-2 .. 2] */
239 *c++ = FRACMUL(b2, rcp_a0); /* [-2.4 .. 1] */
240 *c++ = FRACMUL(-a1, rcp_a0); /* [-2 .. 2] */
241 *c++ = FRACMUL(-a2, rcp_a0); /* [-0.6 .. 1] */
Thom Johansena8cc6a72006-01-29 02:10:28 +0000242}
243
Thom Johansen48b4ac32006-10-18 22:45:39 +0000244/**
245 * Calculate coefficients for lowshelf filter. Parameters are as for
246 * eq_pk_coefs, but the coefficient format is s5.26 fixed point.
247 */
Thom Johansenc00ec112006-03-21 01:09:53 +0000248void eq_ls_coefs(unsigned long cutoff, unsigned long Q, long db, int32_t *c)
Thom Johansena8cc6a72006-01-29 02:10:28 +0000249{
Thom Johansene70a50c2006-03-23 15:40:59 +0000250 long cs;
Thom Johansen48b4ac32006-10-18 22:45:39 +0000251 const long one = 1 << 25; /* s6.25 */
Thom Johansen5f48e152007-02-05 01:01:15 +0000252 const long sqrtA = get_replaygain_int(db*5/2) << 2; /* 10^(db/80), s5.26 */
253 const long A = FRACMUL_SHL(sqrtA, sqrtA, 8); /* s2.29 */
254 const long alpha = fsincos(cutoff, &cs)/(2*Q)*10 >> 1; /* s1.30 */
Thom Johansen48b4ac32006-10-18 22:45:39 +0000255 const long ap1 = (A >> 4) + one;
256 const long am1 = (A >> 4) - one;
Thom Johansen5f48e152007-02-05 01:01:15 +0000257 const long twosqrtalpha = 2*FRACMUL(sqrtA, alpha);
Thom Johansen48b4ac32006-10-18 22:45:39 +0000258 int32_t a0, a1, a2; /* these are all s6.25 format */
Thom Johansenc00ec112006-03-21 01:09:53 +0000259 int32_t b0, b1, b2;
Thom Johansen48b4ac32006-10-18 22:45:39 +0000260
261 /* [0.1 .. 40] */
Thom Johansen5f48e152007-02-05 01:01:15 +0000262 b0 = FRACMUL_SHL(A, ap1 - FRACMUL(am1, cs) + twosqrtalpha, 2);
Thom Johansen48b4ac32006-10-18 22:45:39 +0000263 /* [-16 .. 63.4] */
Thom Johansen5f48e152007-02-05 01:01:15 +0000264 b1 = FRACMUL_SHL(A, am1 - FRACMUL(ap1, cs), 3);
Thom Johansen48b4ac32006-10-18 22:45:39 +0000265 /* [0 .. 31.7] */
Thom Johansen5f48e152007-02-05 01:01:15 +0000266 b2 = FRACMUL_SHL(A, ap1 - FRACMUL(am1, cs) - twosqrtalpha, 2);
Thom Johansen48b4ac32006-10-18 22:45:39 +0000267 /* [0.5 .. 10] */
268 a0 = ap1 + FRACMUL(am1, cs) + twosqrtalpha;
269 /* [-16 .. 4] */
270 a1 = -2*((am1 + FRACMUL(ap1, cs)));
271 /* [0 .. 8] */
Thom Johansena8cc6a72006-01-29 02:10:28 +0000272 a2 = ap1 + FRACMUL(am1, cs) - twosqrtalpha;
273
Thom Johansen5f48e152007-02-05 01:01:15 +0000274 /* [0.1 .. 1.99] */
Thom Johansen8e6e2902007-03-07 15:06:33 +0000275 const long rcp_a0 = DIV64(1, a0, 55); /* s1.30 */
Thom Johansen5f48e152007-02-05 01:01:15 +0000276 *c++ = FRACMUL_SHL(b0, rcp_a0, 2); /* [0.06 .. 15.9] */
277 *c++ = FRACMUL_SHL(b1, rcp_a0, 2); /* [-2 .. 31.7] */
278 *c++ = FRACMUL_SHL(b2, rcp_a0, 2); /* [0 .. 15.9] */
279 *c++ = FRACMUL_SHL(-a1, rcp_a0, 2); /* [-2 .. 2] */
280 *c++ = FRACMUL_SHL(-a2, rcp_a0, 2); /* [0 .. 1] */
Thom Johansena8cc6a72006-01-29 02:10:28 +0000281}
282
Thom Johansen48b4ac32006-10-18 22:45:39 +0000283/**
284 * Calculate coefficients for highshelf filter. Parameters are as for
285 * eq_pk_coefs, but the coefficient format is s5.26 fixed point.
286 */
Thom Johansenc00ec112006-03-21 01:09:53 +0000287void eq_hs_coefs(unsigned long cutoff, unsigned long Q, long db, int32_t *c)
Thom Johansena8cc6a72006-01-29 02:10:28 +0000288{
Thom Johansene70a50c2006-03-23 15:40:59 +0000289 long cs;
Thom Johansen5f48e152007-02-05 01:01:15 +0000290 const long one = 1 << 25; /* s6.25 */
291 const long sqrtA = get_replaygain_int(db*5/2) << 2; /* 10^(db/80), s5.26 */
292 const long A = FRACMUL_SHL(sqrtA, sqrtA, 8); /* s2.29 */
293 const long alpha = fsincos(cutoff, &cs)/(2*Q)*10 >> 1; /* s1.30 */
294 const long ap1 = (A >> 4) + one;
295 const long am1 = (A >> 4) - one;
296 const long twosqrtalpha = 2*FRACMUL(sqrtA, alpha);
Thom Johansen48b4ac32006-10-18 22:45:39 +0000297 int32_t a0, a1, a2; /* these are all s6.25 format */
Thom Johansenc00ec112006-03-21 01:09:53 +0000298 int32_t b0, b1, b2;
Thom Johansena8cc6a72006-01-29 02:10:28 +0000299
Thom Johansen48b4ac32006-10-18 22:45:39 +0000300 /* [0.1 .. 40] */
Thom Johansen5f48e152007-02-05 01:01:15 +0000301 b0 = FRACMUL_SHL(A, ap1 + FRACMUL(am1, cs) + twosqrtalpha, 2);
Thom Johansen48b4ac32006-10-18 22:45:39 +0000302 /* [-63.5 .. 16] */
Thom Johansen5f48e152007-02-05 01:01:15 +0000303 b1 = -FRACMUL_SHL(A, am1 + FRACMUL(ap1, cs), 3);
Thom Johansen48b4ac32006-10-18 22:45:39 +0000304 /* [0 .. 32] */
Thom Johansen5f48e152007-02-05 01:01:15 +0000305 b2 = FRACMUL_SHL(A, ap1 + FRACMUL(am1, cs) - twosqrtalpha, 2);
Thom Johansen48b4ac32006-10-18 22:45:39 +0000306 /* [0.5 .. 10] */
Thom Johansena8cc6a72006-01-29 02:10:28 +0000307 a0 = ap1 - FRACMUL(am1, cs) + twosqrtalpha;
Thom Johansen48b4ac32006-10-18 22:45:39 +0000308 /* [-4 .. 16] */
Thom Johansena8cc6a72006-01-29 02:10:28 +0000309 a1 = 2*((am1 - FRACMUL(ap1, cs)));
Thom Johansen48b4ac32006-10-18 22:45:39 +0000310 /* [0 .. 8] */
Thom Johansena8cc6a72006-01-29 02:10:28 +0000311 a2 = ap1 - FRACMUL(am1, cs) - twosqrtalpha;
312
Thom Johansen5f48e152007-02-05 01:01:15 +0000313 /* [0.1 .. 1.99] */
Thom Johansen8e6e2902007-03-07 15:06:33 +0000314 const long rcp_a0 = DIV64(1, a0, 55); /* s1.30 */
Thom Johansen5f48e152007-02-05 01:01:15 +0000315 *c++ = FRACMUL_SHL(b0, rcp_a0, 2); /* [0 .. 16] */
316 *c++ = FRACMUL_SHL(b1, rcp_a0, 2); /* [-31.7 .. 2] */
317 *c++ = FRACMUL_SHL(b2, rcp_a0, 2); /* [0 .. 16] */
318 *c++ = FRACMUL_SHL(-a1, rcp_a0, 2); /* [-2 .. 2] */
319 *c++ = FRACMUL_SHL(-a2, rcp_a0, 2); /* [0 .. 1] */
Thom Johansena8cc6a72006-01-29 02:10:28 +0000320}
321
Thom Johansen5f48e152007-02-05 01:01:15 +0000322/* We realise the filters as a second order direct form 1 structure. Direct
323 * form 1 was chosen because of better numerical properties for fixed point
324 * implementations.
325 */
326
Dave Chapmanf02cba82007-05-10 13:16:08 +0000327#if (!defined(CPU_COLDFIRE) && !defined(CPU_ARM))
Thom Johansenea4ccb52006-03-19 16:31:45 +0000328void eq_filter(int32_t **x, struct eqfilter *f, unsigned num,
Thom Johansena8cc6a72006-01-29 02:10:28 +0000329 unsigned channels, unsigned shift)
330{
Dan Everton62441702006-03-09 09:40:03 +0000331 unsigned c, i;
332 long long acc;
333
334 /* Direct form 1 filtering code.
335 y[n] = b0*x[i] + b1*x[i - 1] + b2*x[i - 2] + a1*y[i - 1] + a2*y[i - 2],
336 where y[] is output and x[] is input.
337 */
338
339 for (c = 0; c < channels; c++) {
340 for (i = 0; i < num; i++) {
341 acc = (long long) x[c][i] * f->coefs[0];
342 acc += (long long) f->history[c][0] * f->coefs[1];
343 acc += (long long) f->history[c][1] * f->coefs[2];
344 acc += (long long) f->history[c][2] * f->coefs[3];
345 acc += (long long) f->history[c][3] * f->coefs[4];
346 f->history[c][1] = f->history[c][0];
347 f->history[c][0] = x[c][i];
348 f->history[c][3] = f->history[c][2];
349 x[c][i] = (acc << shift) >> 32;
350 f->history[c][2] = x[c][i];
351 }
352 }
Thom Johansena8cc6a72006-01-29 02:10:28 +0000353}
354#endif
355