source: golgotha/src/i4/loaders/mp3/dct64_i386.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 10.0 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9
10/*
11 * Discrete Cosine Tansform (DCT) for subband synthesis
12 * optimized for machines with no auto-increment.
13 * The performance is highly compiler dependend. Maybe
14 * the dct64.c version for 'normal' processor may be faster
15 * even for Intel processors.
16 */
17
18#include "mpg123.h"
19
20dct64_1(real *out0,real *out1,real *b1,real *b2,real *samples)
21{
22
23 {
24  register real *costab = pnts[0];
25
26  b1[0x00] = samples[0x00] + samples[0x1F];
27  b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
28
29  b1[0x01] = samples[0x01] + samples[0x1E];
30  b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
31
32  b1[0x02] = samples[0x02] + samples[0x1D];
33  b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
34
35  b1[0x03] = samples[0x03] + samples[0x1C];
36  b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
37
38  b1[0x04] = samples[0x04] + samples[0x1B];
39  b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
40
41  b1[0x05] = samples[0x05] + samples[0x1A];
42  b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
43
44  b1[0x06] = samples[0x06] + samples[0x19];
45  b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
46
47  b1[0x07] = samples[0x07] + samples[0x18];
48  b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
49
50  b1[0x08] = samples[0x08] + samples[0x17];
51  b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
52
53  b1[0x09] = samples[0x09] + samples[0x16];
54  b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
55
56  b1[0x0A] = samples[0x0A] + samples[0x15];
57  b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
58
59  b1[0x0B] = samples[0x0B] + samples[0x14];
60  b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
61
62  b1[0x0C] = samples[0x0C] + samples[0x13];
63  b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
64
65  b1[0x0D] = samples[0x0D] + samples[0x12];
66  b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
67
68  b1[0x0E] = samples[0x0E] + samples[0x11];
69  b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
70
71  b1[0x0F] = samples[0x0F] + samples[0x10];
72  b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
73 }
74
75
76 {
77  register real *costab = pnts[1];
78
79  b2[0x00] = b1[0x00] + b1[0x0F];
80  b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
81  b2[0x01] = b1[0x01] + b1[0x0E];
82  b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
83  b2[0x02] = b1[0x02] + b1[0x0D];
84  b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
85  b2[0x03] = b1[0x03] + b1[0x0C];
86  b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
87  b2[0x04] = b1[0x04] + b1[0x0B];
88  b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
89  b2[0x05] = b1[0x05] + b1[0x0A];
90  b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
91  b2[0x06] = b1[0x06] + b1[0x09];
92  b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
93  b2[0x07] = b1[0x07] + b1[0x08];
94  b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
95
96  b2[0x10] = b1[0x10] + b1[0x1F];
97  b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
98  b2[0x11] = b1[0x11] + b1[0x1E];
99  b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
100  b2[0x12] = b1[0x12] + b1[0x1D];
101  b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
102  b2[0x13] = b1[0x13] + b1[0x1C];
103  b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
104  b2[0x14] = b1[0x14] + b1[0x1B];
105  b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
106  b2[0x15] = b1[0x15] + b1[0x1A];
107  b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
108  b2[0x16] = b1[0x16] + b1[0x19];
109  b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
110  b2[0x17] = b1[0x17] + b1[0x18];
111  b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
112 }
113
114 {
115  register real *costab = pnts[2];
116
117  b1[0x00] = b2[0x00] + b2[0x07];
118  b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
119  b1[0x01] = b2[0x01] + b2[0x06];
120  b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
121  b1[0x02] = b2[0x02] + b2[0x05];
122  b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
123  b1[0x03] = b2[0x03] + b2[0x04];
124  b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
125
126  b1[0x08] = b2[0x08] + b2[0x0F];
127  b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
128  b1[0x09] = b2[0x09] + b2[0x0E];
129  b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
130  b1[0x0A] = b2[0x0A] + b2[0x0D];
131  b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
132  b1[0x0B] = b2[0x0B] + b2[0x0C];
133  b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
134
135  b1[0x10] = b2[0x10] + b2[0x17];
136  b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
137  b1[0x11] = b2[0x11] + b2[0x16];
138  b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
139  b1[0x12] = b2[0x12] + b2[0x15];
140  b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
141  b1[0x13] = b2[0x13] + b2[0x14];
142  b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
143
144  b1[0x18] = b2[0x18] + b2[0x1F];
145  b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
146  b1[0x19] = b2[0x19] + b2[0x1E];
147  b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
148  b1[0x1A] = b2[0x1A] + b2[0x1D];
149  b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
150  b1[0x1B] = b2[0x1B] + b2[0x1C];
151  b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
152 }
153
154 {
155  register real const cos0 = pnts[3][0];
156  register real const cos1 = pnts[3][1];
157
158  b2[0x00] = b1[0x00] + b1[0x03];
159  b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
160  b2[0x01] = b1[0x01] + b1[0x02];
161  b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
162
163  b2[0x04] = b1[0x04] + b1[0x07];
164  b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
165  b2[0x05] = b1[0x05] + b1[0x06];
166  b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
167
168  b2[0x08] = b1[0x08] + b1[0x0B];
169  b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
170  b2[0x09] = b1[0x09] + b1[0x0A];
171  b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
172 
173  b2[0x0C] = b1[0x0C] + b1[0x0F];
174  b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
175  b2[0x0D] = b1[0x0D] + b1[0x0E];
176  b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
177
178  b2[0x10] = b1[0x10] + b1[0x13];
179  b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
180  b2[0x11] = b1[0x11] + b1[0x12];
181  b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
182
183  b2[0x14] = b1[0x14] + b1[0x17];
184  b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
185  b2[0x15] = b1[0x15] + b1[0x16];
186  b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
187
188  b2[0x18] = b1[0x18] + b1[0x1B];
189  b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
190  b2[0x19] = b1[0x19] + b1[0x1A];
191  b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
192
193  b2[0x1C] = b1[0x1C] + b1[0x1F];
194  b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
195  b2[0x1D] = b1[0x1D] + b1[0x1E];
196  b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
197 }
198
199 {
200  register real const cos0 = pnts[4][0];
201
202  b1[0x00] = b2[0x00] + b2[0x01];
203  b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
204  b1[0x02] = b2[0x02] + b2[0x03];
205  b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
206  b1[0x02] += b1[0x03];
207
208  b1[0x04] = b2[0x04] + b2[0x05];
209  b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
210  b1[0x06] = b2[0x06] + b2[0x07];
211  b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
212  b1[0x06] += b1[0x07];
213  b1[0x04] += b1[0x06];
214  b1[0x06] += b1[0x05];
215  b1[0x05] += b1[0x07];
216
217  b1[0x08] = b2[0x08] + b2[0x09];
218  b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
219  b1[0x0A] = b2[0x0A] + b2[0x0B];
220  b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
221  b1[0x0A] += b1[0x0B];
222
223  b1[0x0C] = b2[0x0C] + b2[0x0D];
224  b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
225  b1[0x0E] = b2[0x0E] + b2[0x0F];
226  b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
227  b1[0x0E] += b1[0x0F];
228  b1[0x0C] += b1[0x0E];
229  b1[0x0E] += b1[0x0D];
230  b1[0x0D] += b1[0x0F];
231
232  b1[0x10] = b2[0x10] + b2[0x11];
233  b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
234  b1[0x12] = b2[0x12] + b2[0x13];
235  b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
236  b1[0x12] += b1[0x13];
237
238  b1[0x14] = b2[0x14] + b2[0x15];
239  b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
240  b1[0x16] = b2[0x16] + b2[0x17];
241  b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
242  b1[0x16] += b1[0x17];
243  b1[0x14] += b1[0x16];
244  b1[0x16] += b1[0x15];
245  b1[0x15] += b1[0x17];
246
247  b1[0x18] = b2[0x18] + b2[0x19];
248  b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
249  b1[0x1A] = b2[0x1A] + b2[0x1B];
250  b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
251  b1[0x1A] += b1[0x1B];
252
253  b1[0x1C] = b2[0x1C] + b2[0x1D];
254  b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
255  b1[0x1E] = b2[0x1E] + b2[0x1F];
256  b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
257  b1[0x1E] += b1[0x1F];
258  b1[0x1C] += b1[0x1E];
259  b1[0x1E] += b1[0x1D];
260  b1[0x1D] += b1[0x1F];
261 }
262
263 out0[0x10*16] = b1[0x00];
264 out0[0x10*12] = b1[0x04];
265 out0[0x10* 8] = b1[0x02];
266 out0[0x10* 4] = b1[0x06];
267 out0[0x10* 0] = b1[0x01];
268 out1[0x10* 0] = b1[0x01];
269 out1[0x10* 4] = b1[0x05];
270 out1[0x10* 8] = b1[0x03];
271 out1[0x10*12] = b1[0x07];
272
273 b1[0x08] += b1[0x0C];
274 out0[0x10*14] = b1[0x08];
275 b1[0x0C] += b1[0x0a];
276 out0[0x10*10] = b1[0x0C];
277 b1[0x0A] += b1[0x0E];
278 out0[0x10* 6] = b1[0x0A];
279 b1[0x0E] += b1[0x09];
280 out0[0x10* 2] = b1[0x0E];
281 b1[0x09] += b1[0x0D];
282 out1[0x10* 2] = b1[0x09];
283 b1[0x0D] += b1[0x0B];
284 out1[0x10* 6] = b1[0x0D];
285 b1[0x0B] += b1[0x0F];
286 out1[0x10*10] = b1[0x0B];
287 out1[0x10*14] = b1[0x0F];
288
289 b1[0x18] += b1[0x1C];
290 out0[0x10*15] = b1[0x10] + b1[0x18];
291 out0[0x10*13] = b1[0x18] + b1[0x14];
292 b1[0x1C] += b1[0x1a];
293 out0[0x10*11] = b1[0x14] + b1[0x1C];
294 out0[0x10* 9] = b1[0x1C] + b1[0x12];
295 b1[0x1A] += b1[0x1E];
296 out0[0x10* 7] = b1[0x12] + b1[0x1A];
297 out0[0x10* 5] = b1[0x1A] + b1[0x16];
298 b1[0x1E] += b1[0x19];
299 out0[0x10* 3] = b1[0x16] + b1[0x1E];
300 out0[0x10* 1] = b1[0x1E] + b1[0x11];
301 b1[0x19] += b1[0x1D];
302 out1[0x10* 1] = b1[0x11] + b1[0x19];
303 out1[0x10* 3] = b1[0x19] + b1[0x15];
304 b1[0x1D] += b1[0x1B];
305 out1[0x10* 5] = b1[0x15] + b1[0x1D];
306 out1[0x10* 7] = b1[0x1D] + b1[0x13];
307 b1[0x1B] += b1[0x1F];
308 out1[0x10* 9] = b1[0x13] + b1[0x1B];
309 out1[0x10*11] = b1[0x1B] + b1[0x17];
310 out1[0x10*13] = b1[0x17] + b1[0x1F];
311 out1[0x10*15] = b1[0x1F];
312}
313
314/*
315 * the call via dct64 is a trick to force GCC to use
316 * (new) registers for the b1,b2 pointer to the bufs[xx] field
317 */
318void dct64(real *a,real *b,real *c)
319{
320  real bufs[0x40];
321  dct64_1(a,b,bufs,bufs+0x20,c);
322}
323
Note: See TracBrowser for help on using the repository browser.