290
|
1 /*
|
|
2 * filters.h
|
|
3 *
|
|
4 * Description: TTAv1 filter functions
|
|
5 * Developed by: Alexander Djourik <sasha@iszf.irk.ru>
|
|
6 * Pavel Zhilin <pzh@iszf.irk.ru>
|
|
7 *
|
|
8 * Copyright (c) 1999-2004 Alexander Djourik. All rights reserved.
|
|
9 *
|
|
10 */
|
|
11
|
|
12 /*
|
|
13 * This program is free software; you can redistribute it and/or modify
|
|
14 * it under the terms of the GNU General Public License as published by
|
|
15 * the Free Software Foundation; either version 2 of the License, or
|
|
16 * (at your option) any later version.
|
|
17 *
|
|
18 * This program is distributed in the hope that it will be useful,
|
|
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 * GNU General Public License for more details.
|
|
22 *
|
|
23 * You should have received a copy of the GNU General Public License
|
|
24 * aint with this program; if not, write to the Free Software
|
|
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
26 *
|
|
27 * Please see the file COPYING in this directory for full copyright
|
|
28 * information.
|
|
29 */
|
|
30
|
|
31 #ifndef FILTERS_H
|
|
32 #define FILTERS_H
|
|
33
|
|
34 ///////// Filter Settings //////////
|
|
35 static long flt_set[3] = {10, 9, 10};
|
|
36
|
|
37 __inline void
|
|
38 memshl (register long *pA, register long *pB) {
|
|
39 *pA++ = *pB++;
|
|
40 *pA++ = *pB++;
|
|
41 *pA++ = *pB++;
|
|
42 *pA++ = *pB++;
|
|
43 *pA++ = *pB++;
|
|
44 *pA++ = *pB++;
|
|
45 *pA++ = *pB++;
|
|
46 *pA = *pB;
|
|
47 }
|
|
48
|
|
49 __inline void
|
|
50 hybrid_filter (fltst *fs, long *in) {
|
|
51 register long *pA = fs->dl;
|
|
52 register long *pB = fs->qm;
|
|
53 register long *pM = fs->dx;
|
|
54 register long sum = fs->round;
|
|
55
|
|
56 if (!fs->error) {
|
|
57 sum += *pA++ * *pB, pB++;
|
|
58 sum += *pA++ * *pB, pB++;
|
|
59 sum += *pA++ * *pB, pB++;
|
|
60 sum += *pA++ * *pB, pB++;
|
|
61 sum += *pA++ * *pB, pB++;
|
|
62 sum += *pA++ * *pB, pB++;
|
|
63 sum += *pA++ * *pB, pB++;
|
|
64 sum += *pA++ * *pB, pB++; pM += 8;
|
|
65 } else if (fs->error < 0) {
|
|
66 sum += *pA++ * (*pB -= *pM++), pB++;
|
|
67 sum += *pA++ * (*pB -= *pM++), pB++;
|
|
68 sum += *pA++ * (*pB -= *pM++), pB++;
|
|
69 sum += *pA++ * (*pB -= *pM++), pB++;
|
|
70 sum += *pA++ * (*pB -= *pM++), pB++;
|
|
71 sum += *pA++ * (*pB -= *pM++), pB++;
|
|
72 sum += *pA++ * (*pB -= *pM++), pB++;
|
|
73 sum += *pA++ * (*pB -= *pM++), pB++;
|
|
74 } else {
|
|
75 sum += *pA++ * (*pB += *pM++), pB++;
|
|
76 sum += *pA++ * (*pB += *pM++), pB++;
|
|
77 sum += *pA++ * (*pB += *pM++), pB++;
|
|
78 sum += *pA++ * (*pB += *pM++), pB++;
|
|
79 sum += *pA++ * (*pB += *pM++), pB++;
|
|
80 sum += *pA++ * (*pB += *pM++), pB++;
|
|
81 sum += *pA++ * (*pB += *pM++), pB++;
|
|
82 sum += *pA++ * (*pB += *pM++), pB++;
|
|
83 }
|
|
84
|
|
85 *(pM-0) = ((*(pA-1) >> 30) | 1) << 2;
|
|
86 *(pM-1) = ((*(pA-2) >> 30) | 1) << 1;
|
|
87 *(pM-2) = ((*(pA-3) >> 30) | 1) << 1;
|
|
88 *(pM-3) = ((*(pA-4) >> 30) | 1);
|
|
89
|
|
90 fs->error = *in;
|
|
91 *in += (sum >> fs->shift);
|
|
92 *pA = *in;
|
|
93
|
|
94 *(pA-1) = *(pA-0) - *(pA-1);
|
|
95 *(pA-2) = *(pA-1) - *(pA-2);
|
|
96 *(pA-3) = *(pA-2) - *(pA-3);
|
|
97
|
|
98 memshl (fs->dl, fs->dl + 1);
|
|
99 memshl (fs->dx, fs->dx + 1);
|
|
100 }
|
|
101
|
|
102 void
|
|
103 filter_init (fltst *fs, long shift) {
|
|
104 memset (fs, 0, sizeof(fltst));
|
|
105 fs->shift = shift;
|
|
106 fs->round = 1 << (shift - 1);
|
|
107 }
|
|
108
|
|
109 #endif /* FILTERS_H */
|
|
110
|