| |
1 #include "cc_interface.h" |
| |
2 #include "filter.h" |
| |
3 #include "stdio.h" |
| |
4 |
| |
5 #define coef_0 .0022 |
| |
6 #define coef_1 .0174 |
| |
7 #define coef_2 .0737 |
| |
8 #define coef_3 .1662 |
| |
9 #define coef_4 .2405 |
| |
10 |
| |
11 filter_bank* Filter_Initialize (void) |
| |
12 { |
| |
13 filter_bank* new_filter; |
| |
14 new_filter=(filter_bank*)malloc(sizeof(filter_bank)); |
| |
15 memset(new_filter,0,sizeof(filter_bank)); |
| |
16 // fprintf(stderr,"RESETTING FILTER BANK *******************\n"); |
| |
17 return new_filter; |
| |
18 } |
| |
19 |
| |
20 void Filter_Destroy (filter_bank *f) |
| |
21 { |
| |
22 free(f); |
| |
23 } |
| |
24 |
| |
25 void filter(struct cc_features *features, filter_bank *f) |
| |
26 { |
| |
27 |
| |
28 f->head_size[9]=f->head_size[8]; |
| |
29 f->head_size[8]=f->head_size[7]; |
| |
30 f->head_size[7]=f->head_size[6]; |
| |
31 f->head_size[6]=f->head_size[5]; |
| |
32 f->head_size[5]=f->head_size[4]; |
| |
33 f->head_size[4]=f->head_size[3]; |
| |
34 f->head_size[3]=f->head_size[2]; |
| |
35 f->head_size[2]=f->head_size[1]; |
| |
36 f->head_size[1]=f->head_size[0]; |
| |
37 f->head_size[0]=features->head_size; |
| |
38 |
| |
39 features->head_size=(guint8) ( (coef_0*(f->head_size[0]+f->head_size[9]))+(coef_1*(f->head_size[1]+f->head_size[8])) + |
| |
40 (coef_2*(f->head_size[2]+f->head_size[7])) + (coef_3*(f->head_size[3]+f->head_size[6])) |
| |
41 + (coef_4*(f->head_size[4]+f->head_size[5]))); |
| |
42 |
| |
43 |
| |
44 |
| |
45 f->head_z_rot[9]=f->head_z_rot[8]; |
| |
46 f->head_z_rot[8]=f->head_z_rot[7]; |
| |
47 f->head_z_rot[7]=f->head_z_rot[6]; |
| |
48 f->head_z_rot[6]=f->head_z_rot[5]; |
| |
49 f->head_z_rot[5]=f->head_z_rot[4]; |
| |
50 f->head_z_rot[4]=f->head_z_rot[3]; |
| |
51 f->head_z_rot[3]=f->head_z_rot[2]; |
| |
52 f->head_z_rot[2]=f->head_z_rot[1]; |
| |
53 f->head_z_rot[1]=f->head_z_rot[0]; |
| |
54 f->head_z_rot[0]=features->head_z_rot; |
| |
55 |
| |
56 features->head_z_rot=(guint8) ( (coef_0*(f->head_z_rot[0]+f->head_z_rot[9]))+(coef_1*(f->head_z_rot[1]+f->head_z_rot[8])) + |
| |
57 (coef_2*(f->head_z_rot[2]+f->head_z_rot[7])) + (coef_3*(f->head_z_rot[3]+f->head_z_rot[6])) |
| |
58 + (coef_4*(f->head_z_rot[4]+f->head_z_rot[5]))); |
| |
59 |
| |
60 |
| |
61 f->head_y_rot[9]=f->head_y_rot[8]; |
| |
62 f->head_y_rot[8]=f->head_y_rot[7]; |
| |
63 f->head_y_rot[7]=f->head_y_rot[6]; |
| |
64 f->head_y_rot[6]=f->head_y_rot[5]; |
| |
65 f->head_y_rot[5]=f->head_y_rot[4]; |
| |
66 f->head_y_rot[4]=f->head_y_rot[3]; |
| |
67 f->head_y_rot[3]=f->head_y_rot[2]; |
| |
68 f->head_y_rot[2]=f->head_y_rot[1]; |
| |
69 f->head_y_rot[1]=f->head_y_rot[0]; |
| |
70 f->head_y_rot[0]=features->head_y_rot; |
| |
71 |
| |
72 features->head_y_rot=(guint8) ( (coef_0*(f->head_y_rot[0]+f->head_y_rot[9]))+(coef_1*(f->head_y_rot[1]+f->head_y_rot[8])) + |
| |
73 (coef_2*(f->head_y_rot[2]+f->head_y_rot[7])) + (coef_3*(f->head_y_rot[3]+f->head_y_rot[6])) |
| |
74 + (coef_4*(f->head_y_rot[4]+f->head_y_rot[5]))); |
| |
75 |
| |
76 |
| |
77 f->xfilt[9]=f->xfilt[8]; |
| |
78 f->xfilt[8]=f->xfilt[7]; |
| |
79 f->xfilt[7]=f->xfilt[6]; |
| |
80 f->xfilt[6]=f->xfilt[5]; |
| |
81 f->xfilt[5]=f->xfilt[4]; |
| |
82 f->xfilt[4]=f->xfilt[3]; |
| |
83 f->xfilt[3]=f->xfilt[2]; |
| |
84 f->xfilt[2]=f->xfilt[1]; |
| |
85 f->xfilt[1]=f->xfilt[0]; |
| |
86 f->xfilt[0]=features->x; |
| |
87 |
| |
88 features->x=(guint8) ( (coef_0*(f->xfilt[0]+f->xfilt[9]))+(coef_1*(f->xfilt[1]+f->xfilt[8])) + |
| |
89 (coef_2*(f->xfilt[2]+f->xfilt[7])) + (coef_3*(f->xfilt[3]+f->xfilt[6])) |
| |
90 + (coef_4*(f->xfilt[4]+f->xfilt[5]))); |
| |
91 |
| |
92 |
| |
93 f->yfilt[9]=f->yfilt[8]; |
| |
94 f->yfilt[8]=f->yfilt[7]; |
| |
95 f->yfilt[7]=f->yfilt[6]; |
| |
96 f->yfilt[6]=f->yfilt[5]; |
| |
97 f->yfilt[5]=f->yfilt[4]; |
| |
98 f->yfilt[4]=f->yfilt[3]; |
| |
99 f->yfilt[3]=f->yfilt[2]; |
| |
100 f->yfilt[2]=f->yfilt[1]; |
| |
101 f->yfilt[1]=f->yfilt[0]; |
| |
102 f->yfilt[0]=features->y; |
| |
103 |
| |
104 features->y=(guint8) ( (coef_0*(f->yfilt[0]+f->yfilt[9]))+(coef_1*(f->yfilt[1]+f->yfilt[8])) + |
| |
105 (coef_2*(f->yfilt[2]+f->yfilt[7])) + (coef_3*(f->yfilt[3]+f->yfilt[6])) |
| |
106 + (coef_4*(f->yfilt[4]+f->yfilt[5]))); |
| |
107 |
| |
108 |
| |
109 f->mouth_open[9]=f->mouth_open[8]; |
| |
110 f->mouth_open[8]=f->mouth_open[7]; |
| |
111 f->mouth_open[7]=f->mouth_open[6]; |
| |
112 f->mouth_open[6]=f->mouth_open[5]; |
| |
113 f->mouth_open[5]=f->mouth_open[4]; |
| |
114 f->mouth_open[4]=f->mouth_open[3]; |
| |
115 f->mouth_open[3]=f->mouth_open[2]; |
| |
116 f->mouth_open[2]=f->mouth_open[1]; |
| |
117 f->mouth_open[1]=f->mouth_open[0]; |
| |
118 f->mouth_open[0]=features->mouth_open; |
| |
119 |
| |
120 features->mouth_open=(guint8) ( (coef_0*(f->mouth_open[0]+f->mouth_open[9]))+(coef_1*(f->mouth_open[1]+f->mouth_open[8])) + |
| |
121 (coef_2*(f->mouth_open[2]+f->mouth_open[7])) + (coef_3*(f->mouth_open[3]+f->mouth_open[6])) |
| |
122 + (coef_4*(f->mouth_open[4]+f->mouth_open[5]))); |
| |
123 |
| |
124 } |