129 float input[64]; |
129 float input[64]; |
130 float input_test[64]; |
130 float input_test[64]; |
131 float input_dct[64]; |
131 float input_dct[64]; |
132 float output_dct[64]; |
132 float output_dct[64]; |
133 float output[64]; |
133 float output[64]; |
|
134 float quantize[64] = { |
|
135 20, 14, 13, 20, 30, 50, 64, 76, |
|
136 15, 15, 18, 24, 33, 73, 75, 69, |
|
137 18, 16, 20, 30, 50, 71, 86, 70, |
|
138 18, 21, 28, 36, 64, 109, 100, 78, |
|
139 23, 28, 46, 70, 85, 136, 129, 96, |
|
140 30, 44, 69, 80, 101, 130, 141, 115, |
|
141 61, 80, 98, 109, 129, 151, 150, 126, |
|
142 90, 115, 119, 123, 140, 125, 129, 124 }; |
|
143 |
|
144 |
134 struct bitmap obmap; |
145 struct bitmap obmap; |
135 int i,j,k; |
146 int i,j,k; |
136 |
147 |
137 bitmap_pam_init(&argn, argv); |
148 bitmap_pam_init(&argn, argv); |
138 |
149 |
151 gsl_matrix *mat = bmap.m[0]; |
162 gsl_matrix *mat = bmap.m[0]; |
152 input[k++] = mat->data[j*mat->tda + i]; |
163 input[k++] = mat->data[j*mat->tda + i]; |
153 } |
164 } |
154 |
165 |
155 mydct(input, input_dct); |
166 mydct(input, input_dct); |
|
167 |
|
168 { |
|
169 FILE *odct, *ifile, *qtable, *qfile; |
|
170 odct = fopen("dct.txt", "wt"); |
|
171 ifile = fopen("ifile.txt", "wt"); |
|
172 qtable = fopen("qtable.txt", "wt"); |
|
173 qfile = fopen("qfile.txt", "wt"); |
|
174 for(j=0;j < 8; ++j) |
|
175 { |
|
176 fprintf(odct, "<tr>\n"); |
|
177 fprintf(ifile, "<tr>\n"); |
|
178 fprintf(qtable, "<tr>\n"); |
|
179 fprintf(qfile, "<tr>\n"); |
|
180 for(i=0;i < 8; ++i) |
|
181 { |
|
182 fprintf(odct, "<td>%.2f\n", input_dct[j*8+i]); |
|
183 fprintf(ifile, "<td>%.0f\n", input[j*8+i]); |
|
184 fprintf(qtable, "<td>%.0f\n", quantize[j*8+i]); |
|
185 fprintf(qfile, "<td>%i\n", lrint(input_dct[j*8+i]/quantize[j*8+i])); |
|
186 } |
|
187 } |
|
188 fclose(odct); |
|
189 fclose(ifile); |
|
190 fclose(qtable); |
|
191 fclose(qfile); |
|
192 } |
|
193 |
156 myidct(input_dct, input_test); |
194 myidct(input_dct, input_test); |
157 |
195 |
158 obmap = bitmap_alloc(1, 64+7, 64+7); |
196 obmap = bitmap_alloc(1, 64+7, 64+7); |
159 |
197 |
160 for(j=0;j < 8; ++j) |
198 for(j=0;j < 8; ++j) |