Always write full buffers in ao_win32, except for the last block.
[mplayer/glamo.git] / mp3lib / dct64.c
blob54ac3c3d6a37f50deccf402c5bbfe6a4e88557d5
1 /*
2 * Modified for use with MPlayer, for details see the changelog at
3 * http://svn.mplayerhq.hu/mplayer/trunk/
4 * $Id$
5 */
7 /*
8 * Discrete Cosine Tansform (DCT) for subband synthesis
9 * optimized for machines with no auto-increment.
10 * The performance is highly compiler dependend. Maybe
11 * the dct64.c version for 'normal' processor may be faster
12 * even for Intel processors.
15 static void dct64_1(real *out0,real *out1,real *b1,real *b2,real *samples)
19 register real *costab = mp3lib_pnts[0];
21 b1[0x00] = samples[0x00] + samples[0x1F];
22 b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
24 b1[0x01] = samples[0x01] + samples[0x1E];
25 b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
27 b1[0x02] = samples[0x02] + samples[0x1D];
28 b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
30 b1[0x03] = samples[0x03] + samples[0x1C];
31 b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
33 b1[0x04] = samples[0x04] + samples[0x1B];
34 b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
36 b1[0x05] = samples[0x05] + samples[0x1A];
37 b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
39 b1[0x06] = samples[0x06] + samples[0x19];
40 b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
42 b1[0x07] = samples[0x07] + samples[0x18];
43 b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
45 b1[0x08] = samples[0x08] + samples[0x17];
46 b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
48 b1[0x09] = samples[0x09] + samples[0x16];
49 b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
51 b1[0x0A] = samples[0x0A] + samples[0x15];
52 b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
54 b1[0x0B] = samples[0x0B] + samples[0x14];
55 b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
57 b1[0x0C] = samples[0x0C] + samples[0x13];
58 b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
60 b1[0x0D] = samples[0x0D] + samples[0x12];
61 b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
63 b1[0x0E] = samples[0x0E] + samples[0x11];
64 b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
66 b1[0x0F] = samples[0x0F] + samples[0x10];
67 b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
72 register real *costab = mp3lib_pnts[1];
74 b2[0x00] = b1[0x00] + b1[0x0F];
75 b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
76 b2[0x01] = b1[0x01] + b1[0x0E];
77 b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
78 b2[0x02] = b1[0x02] + b1[0x0D];
79 b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
80 b2[0x03] = b1[0x03] + b1[0x0C];
81 b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
82 b2[0x04] = b1[0x04] + b1[0x0B];
83 b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
84 b2[0x05] = b1[0x05] + b1[0x0A];
85 b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
86 b2[0x06] = b1[0x06] + b1[0x09];
87 b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
88 b2[0x07] = b1[0x07] + b1[0x08];
89 b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
91 b2[0x10] = b1[0x10] + b1[0x1F];
92 b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
93 b2[0x11] = b1[0x11] + b1[0x1E];
94 b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
95 b2[0x12] = b1[0x12] + b1[0x1D];
96 b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
97 b2[0x13] = b1[0x13] + b1[0x1C];
98 b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
99 b2[0x14] = b1[0x14] + b1[0x1B];
100 b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
101 b2[0x15] = b1[0x15] + b1[0x1A];
102 b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
103 b2[0x16] = b1[0x16] + b1[0x19];
104 b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
105 b2[0x17] = b1[0x17] + b1[0x18];
106 b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
110 register real *costab = mp3lib_pnts[2];
112 b1[0x00] = b2[0x00] + b2[0x07];
113 b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
114 b1[0x01] = b2[0x01] + b2[0x06];
115 b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
116 b1[0x02] = b2[0x02] + b2[0x05];
117 b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
118 b1[0x03] = b2[0x03] + b2[0x04];
119 b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
121 b1[0x08] = b2[0x08] + b2[0x0F];
122 b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
123 b1[0x09] = b2[0x09] + b2[0x0E];
124 b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
125 b1[0x0A] = b2[0x0A] + b2[0x0D];
126 b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
127 b1[0x0B] = b2[0x0B] + b2[0x0C];
128 b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
130 b1[0x10] = b2[0x10] + b2[0x17];
131 b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
132 b1[0x11] = b2[0x11] + b2[0x16];
133 b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
134 b1[0x12] = b2[0x12] + b2[0x15];
135 b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
136 b1[0x13] = b2[0x13] + b2[0x14];
137 b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
139 b1[0x18] = b2[0x18] + b2[0x1F];
140 b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
141 b1[0x19] = b2[0x19] + b2[0x1E];
142 b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
143 b1[0x1A] = b2[0x1A] + b2[0x1D];
144 b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
145 b1[0x1B] = b2[0x1B] + b2[0x1C];
146 b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
150 register real const cos0 = mp3lib_pnts[3][0];
151 register real const cos1 = mp3lib_pnts[3][1];
153 b2[0x00] = b1[0x00] + b1[0x03];
154 b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
155 b2[0x01] = b1[0x01] + b1[0x02];
156 b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
158 b2[0x04] = b1[0x04] + b1[0x07];
159 b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
160 b2[0x05] = b1[0x05] + b1[0x06];
161 b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
163 b2[0x08] = b1[0x08] + b1[0x0B];
164 b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
165 b2[0x09] = b1[0x09] + b1[0x0A];
166 b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
168 b2[0x0C] = b1[0x0C] + b1[0x0F];
169 b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
170 b2[0x0D] = b1[0x0D] + b1[0x0E];
171 b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
173 b2[0x10] = b1[0x10] + b1[0x13];
174 b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
175 b2[0x11] = b1[0x11] + b1[0x12];
176 b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
178 b2[0x14] = b1[0x14] + b1[0x17];
179 b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
180 b2[0x15] = b1[0x15] + b1[0x16];
181 b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
183 b2[0x18] = b1[0x18] + b1[0x1B];
184 b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
185 b2[0x19] = b1[0x19] + b1[0x1A];
186 b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
188 b2[0x1C] = b1[0x1C] + b1[0x1F];
189 b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
190 b2[0x1D] = b1[0x1D] + b1[0x1E];
191 b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
195 register real const cos0 = mp3lib_pnts[4][0];
197 b1[0x00] = b2[0x00] + b2[0x01];
198 b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
199 b1[0x02] = b2[0x02] + b2[0x03];
200 b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
201 b1[0x02] += b1[0x03];
203 b1[0x04] = b2[0x04] + b2[0x05];
204 b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
205 b1[0x06] = b2[0x06] + b2[0x07];
206 b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
207 b1[0x06] += b1[0x07];
208 b1[0x04] += b1[0x06];
209 b1[0x06] += b1[0x05];
210 b1[0x05] += b1[0x07];
212 b1[0x08] = b2[0x08] + b2[0x09];
213 b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
214 b1[0x0A] = b2[0x0A] + b2[0x0B];
215 b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
216 b1[0x0A] += b1[0x0B];
218 b1[0x0C] = b2[0x0C] + b2[0x0D];
219 b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
220 b1[0x0E] = b2[0x0E] + b2[0x0F];
221 b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
222 b1[0x0E] += b1[0x0F];
223 b1[0x0C] += b1[0x0E];
224 b1[0x0E] += b1[0x0D];
225 b1[0x0D] += b1[0x0F];
227 b1[0x10] = b2[0x10] + b2[0x11];
228 b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
229 b1[0x12] = b2[0x12] + b2[0x13];
230 b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
231 b1[0x12] += b1[0x13];
233 b1[0x14] = b2[0x14] + b2[0x15];
234 b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
235 b1[0x16] = b2[0x16] + b2[0x17];
236 b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
237 b1[0x16] += b1[0x17];
238 b1[0x14] += b1[0x16];
239 b1[0x16] += b1[0x15];
240 b1[0x15] += b1[0x17];
242 b1[0x18] = b2[0x18] + b2[0x19];
243 b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
244 b1[0x1A] = b2[0x1A] + b2[0x1B];
245 b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
246 b1[0x1A] += b1[0x1B];
248 b1[0x1C] = b2[0x1C] + b2[0x1D];
249 b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
250 b1[0x1E] = b2[0x1E] + b2[0x1F];
251 b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
252 b1[0x1E] += b1[0x1F];
253 b1[0x1C] += b1[0x1E];
254 b1[0x1E] += b1[0x1D];
255 b1[0x1D] += b1[0x1F];
258 out0[0x10*16] = b1[0x00];
259 out0[0x10*12] = b1[0x04];
260 out0[0x10* 8] = b1[0x02];
261 out0[0x10* 4] = b1[0x06];
262 out0[0x10* 0] = b1[0x01];
263 out1[0x10* 0] = b1[0x01];
264 out1[0x10* 4] = b1[0x05];
265 out1[0x10* 8] = b1[0x03];
266 out1[0x10*12] = b1[0x07];
268 b1[0x08] += b1[0x0C];
269 out0[0x10*14] = b1[0x08];
270 b1[0x0C] += b1[0x0a];
271 out0[0x10*10] = b1[0x0C];
272 b1[0x0A] += b1[0x0E];
273 out0[0x10* 6] = b1[0x0A];
274 b1[0x0E] += b1[0x09];
275 out0[0x10* 2] = b1[0x0E];
276 b1[0x09] += b1[0x0D];
277 out1[0x10* 2] = b1[0x09];
278 b1[0x0D] += b1[0x0B];
279 out1[0x10* 6] = b1[0x0D];
280 b1[0x0B] += b1[0x0F];
281 out1[0x10*10] = b1[0x0B];
282 out1[0x10*14] = b1[0x0F];
284 b1[0x18] += b1[0x1C];
285 out0[0x10*15] = b1[0x10] + b1[0x18];
286 out0[0x10*13] = b1[0x18] + b1[0x14];
287 b1[0x1C] += b1[0x1a];
288 out0[0x10*11] = b1[0x14] + b1[0x1C];
289 out0[0x10* 9] = b1[0x1C] + b1[0x12];
290 b1[0x1A] += b1[0x1E];
291 out0[0x10* 7] = b1[0x12] + b1[0x1A];
292 out0[0x10* 5] = b1[0x1A] + b1[0x16];
293 b1[0x1E] += b1[0x19];
294 out0[0x10* 3] = b1[0x16] + b1[0x1E];
295 out0[0x10* 1] = b1[0x1E] + b1[0x11];
296 b1[0x19] += b1[0x1D];
297 out1[0x10* 1] = b1[0x11] + b1[0x19];
298 out1[0x10* 3] = b1[0x19] + b1[0x15];
299 b1[0x1D] += b1[0x1B];
300 out1[0x10* 5] = b1[0x15] + b1[0x1D];
301 out1[0x10* 7] = b1[0x1D] + b1[0x13];
302 b1[0x1B] += b1[0x1F];
303 out1[0x10* 9] = b1[0x13] + b1[0x1B];
304 out1[0x10*11] = b1[0x1B] + b1[0x17];
305 out1[0x10*13] = b1[0x17] + b1[0x1F];
306 out1[0x10*15] = b1[0x1F];
310 * the call via dct64 is a trick to force GCC to use
311 * (new) registers for the b1,b2 pointer to the bufs[xx] field
313 static void dct64(real *a,real *b,real *c)
315 real bufs[0x40];
316 dct64_1(a,b,bufs,bufs+0x20,c);
319 void mp3lib_dct64(real *a,real *b,real *c)
321 real bufs[0x40];
322 dct64_1(a,b,bufs,bufs+0x20,c);