2 * Copyright (c) Michael Hipp and other authors of the mpglib project.
4 * Discrete Cosine Transform (DCT) for subband synthesis
5 * optimized for machines with no auto-increment.
6 * The performance is highly compiler dependent. Maybe
7 * the dct64.c version for 'normal' processor may be faster
8 * even for Intel processors.
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 static void dct64_1(real
*out0
,real
*out1
,real
*b1
,real
*b2
,real
*samples
)
31 register real
*costab
= pnts
[0];
33 b1
[0x00] = samples
[0x00] + samples
[0x1F];
34 b1
[0x1F] = (samples
[0x00] - samples
[0x1F]) * costab
[0x0];
36 b1
[0x01] = samples
[0x01] + samples
[0x1E];
37 b1
[0x1E] = (samples
[0x01] - samples
[0x1E]) * costab
[0x1];
39 b1
[0x02] = samples
[0x02] + samples
[0x1D];
40 b1
[0x1D] = (samples
[0x02] - samples
[0x1D]) * costab
[0x2];
42 b1
[0x03] = samples
[0x03] + samples
[0x1C];
43 b1
[0x1C] = (samples
[0x03] - samples
[0x1C]) * costab
[0x3];
45 b1
[0x04] = samples
[0x04] + samples
[0x1B];
46 b1
[0x1B] = (samples
[0x04] - samples
[0x1B]) * costab
[0x4];
48 b1
[0x05] = samples
[0x05] + samples
[0x1A];
49 b1
[0x1A] = (samples
[0x05] - samples
[0x1A]) * costab
[0x5];
51 b1
[0x06] = samples
[0x06] + samples
[0x19];
52 b1
[0x19] = (samples
[0x06] - samples
[0x19]) * costab
[0x6];
54 b1
[0x07] = samples
[0x07] + samples
[0x18];
55 b1
[0x18] = (samples
[0x07] - samples
[0x18]) * costab
[0x7];
57 b1
[0x08] = samples
[0x08] + samples
[0x17];
58 b1
[0x17] = (samples
[0x08] - samples
[0x17]) * costab
[0x8];
60 b1
[0x09] = samples
[0x09] + samples
[0x16];
61 b1
[0x16] = (samples
[0x09] - samples
[0x16]) * costab
[0x9];
63 b1
[0x0A] = samples
[0x0A] + samples
[0x15];
64 b1
[0x15] = (samples
[0x0A] - samples
[0x15]) * costab
[0xA];
66 b1
[0x0B] = samples
[0x0B] + samples
[0x14];
67 b1
[0x14] = (samples
[0x0B] - samples
[0x14]) * costab
[0xB];
69 b1
[0x0C] = samples
[0x0C] + samples
[0x13];
70 b1
[0x13] = (samples
[0x0C] - samples
[0x13]) * costab
[0xC];
72 b1
[0x0D] = samples
[0x0D] + samples
[0x12];
73 b1
[0x12] = (samples
[0x0D] - samples
[0x12]) * costab
[0xD];
75 b1
[0x0E] = samples
[0x0E] + samples
[0x11];
76 b1
[0x11] = (samples
[0x0E] - samples
[0x11]) * costab
[0xE];
78 b1
[0x0F] = samples
[0x0F] + samples
[0x10];
79 b1
[0x10] = (samples
[0x0F] - samples
[0x10]) * costab
[0xF];
84 register real
*costab
= pnts
[1];
86 b2
[0x00] = b1
[0x00] + b1
[0x0F];
87 b2
[0x0F] = (b1
[0x00] - b1
[0x0F]) * costab
[0];
88 b2
[0x01] = b1
[0x01] + b1
[0x0E];
89 b2
[0x0E] = (b1
[0x01] - b1
[0x0E]) * costab
[1];
90 b2
[0x02] = b1
[0x02] + b1
[0x0D];
91 b2
[0x0D] = (b1
[0x02] - b1
[0x0D]) * costab
[2];
92 b2
[0x03] = b1
[0x03] + b1
[0x0C];
93 b2
[0x0C] = (b1
[0x03] - b1
[0x0C]) * costab
[3];
94 b2
[0x04] = b1
[0x04] + b1
[0x0B];
95 b2
[0x0B] = (b1
[0x04] - b1
[0x0B]) * costab
[4];
96 b2
[0x05] = b1
[0x05] + b1
[0x0A];
97 b2
[0x0A] = (b1
[0x05] - b1
[0x0A]) * costab
[5];
98 b2
[0x06] = b1
[0x06] + b1
[0x09];
99 b2
[0x09] = (b1
[0x06] - b1
[0x09]) * costab
[6];
100 b2
[0x07] = b1
[0x07] + b1
[0x08];
101 b2
[0x08] = (b1
[0x07] - b1
[0x08]) * costab
[7];
103 b2
[0x10] = b1
[0x10] + b1
[0x1F];
104 b2
[0x1F] = (b1
[0x1F] - b1
[0x10]) * costab
[0];
105 b2
[0x11] = b1
[0x11] + b1
[0x1E];
106 b2
[0x1E] = (b1
[0x1E] - b1
[0x11]) * costab
[1];
107 b2
[0x12] = b1
[0x12] + b1
[0x1D];
108 b2
[0x1D] = (b1
[0x1D] - b1
[0x12]) * costab
[2];
109 b2
[0x13] = b1
[0x13] + b1
[0x1C];
110 b2
[0x1C] = (b1
[0x1C] - b1
[0x13]) * costab
[3];
111 b2
[0x14] = b1
[0x14] + b1
[0x1B];
112 b2
[0x1B] = (b1
[0x1B] - b1
[0x14]) * costab
[4];
113 b2
[0x15] = b1
[0x15] + b1
[0x1A];
114 b2
[0x1A] = (b1
[0x1A] - b1
[0x15]) * costab
[5];
115 b2
[0x16] = b1
[0x16] + b1
[0x19];
116 b2
[0x19] = (b1
[0x19] - b1
[0x16]) * costab
[6];
117 b2
[0x17] = b1
[0x17] + b1
[0x18];
118 b2
[0x18] = (b1
[0x18] - b1
[0x17]) * costab
[7];
122 register real
*costab
= pnts
[2];
124 b1
[0x00] = b2
[0x00] + b2
[0x07];
125 b1
[0x07] = (b2
[0x00] - b2
[0x07]) * costab
[0];
126 b1
[0x01] = b2
[0x01] + b2
[0x06];
127 b1
[0x06] = (b2
[0x01] - b2
[0x06]) * costab
[1];
128 b1
[0x02] = b2
[0x02] + b2
[0x05];
129 b1
[0x05] = (b2
[0x02] - b2
[0x05]) * costab
[2];
130 b1
[0x03] = b2
[0x03] + b2
[0x04];
131 b1
[0x04] = (b2
[0x03] - b2
[0x04]) * costab
[3];
133 b1
[0x08] = b2
[0x08] + b2
[0x0F];
134 b1
[0x0F] = (b2
[0x0F] - b2
[0x08]) * costab
[0];
135 b1
[0x09] = b2
[0x09] + b2
[0x0E];
136 b1
[0x0E] = (b2
[0x0E] - b2
[0x09]) * costab
[1];
137 b1
[0x0A] = b2
[0x0A] + b2
[0x0D];
138 b1
[0x0D] = (b2
[0x0D] - b2
[0x0A]) * costab
[2];
139 b1
[0x0B] = b2
[0x0B] + b2
[0x0C];
140 b1
[0x0C] = (b2
[0x0C] - b2
[0x0B]) * costab
[3];
142 b1
[0x10] = b2
[0x10] + b2
[0x17];
143 b1
[0x17] = (b2
[0x10] - b2
[0x17]) * costab
[0];
144 b1
[0x11] = b2
[0x11] + b2
[0x16];
145 b1
[0x16] = (b2
[0x11] - b2
[0x16]) * costab
[1];
146 b1
[0x12] = b2
[0x12] + b2
[0x15];
147 b1
[0x15] = (b2
[0x12] - b2
[0x15]) * costab
[2];
148 b1
[0x13] = b2
[0x13] + b2
[0x14];
149 b1
[0x14] = (b2
[0x13] - b2
[0x14]) * costab
[3];
151 b1
[0x18] = b2
[0x18] + b2
[0x1F];
152 b1
[0x1F] = (b2
[0x1F] - b2
[0x18]) * costab
[0];
153 b1
[0x19] = b2
[0x19] + b2
[0x1E];
154 b1
[0x1E] = (b2
[0x1E] - b2
[0x19]) * costab
[1];
155 b1
[0x1A] = b2
[0x1A] + b2
[0x1D];
156 b1
[0x1D] = (b2
[0x1D] - b2
[0x1A]) * costab
[2];
157 b1
[0x1B] = b2
[0x1B] + b2
[0x1C];
158 b1
[0x1C] = (b2
[0x1C] - b2
[0x1B]) * costab
[3];
162 register real
const cos0
= pnts
[3][0];
163 register real
const cos1
= pnts
[3][1];
165 b2
[0x00] = b1
[0x00] + b1
[0x03];
166 b2
[0x03] = (b1
[0x00] - b1
[0x03]) * cos0
;
167 b2
[0x01] = b1
[0x01] + b1
[0x02];
168 b2
[0x02] = (b1
[0x01] - b1
[0x02]) * cos1
;
170 b2
[0x04] = b1
[0x04] + b1
[0x07];
171 b2
[0x07] = (b1
[0x07] - b1
[0x04]) * cos0
;
172 b2
[0x05] = b1
[0x05] + b1
[0x06];
173 b2
[0x06] = (b1
[0x06] - b1
[0x05]) * cos1
;
175 b2
[0x08] = b1
[0x08] + b1
[0x0B];
176 b2
[0x0B] = (b1
[0x08] - b1
[0x0B]) * cos0
;
177 b2
[0x09] = b1
[0x09] + b1
[0x0A];
178 b2
[0x0A] = (b1
[0x09] - b1
[0x0A]) * cos1
;
180 b2
[0x0C] = b1
[0x0C] + b1
[0x0F];
181 b2
[0x0F] = (b1
[0x0F] - b1
[0x0C]) * cos0
;
182 b2
[0x0D] = b1
[0x0D] + b1
[0x0E];
183 b2
[0x0E] = (b1
[0x0E] - b1
[0x0D]) * cos1
;
185 b2
[0x10] = b1
[0x10] + b1
[0x13];
186 b2
[0x13] = (b1
[0x10] - b1
[0x13]) * cos0
;
187 b2
[0x11] = b1
[0x11] + b1
[0x12];
188 b2
[0x12] = (b1
[0x11] - b1
[0x12]) * cos1
;
190 b2
[0x14] = b1
[0x14] + b1
[0x17];
191 b2
[0x17] = (b1
[0x17] - b1
[0x14]) * cos0
;
192 b2
[0x15] = b1
[0x15] + b1
[0x16];
193 b2
[0x16] = (b1
[0x16] - b1
[0x15]) * cos1
;
195 b2
[0x18] = b1
[0x18] + b1
[0x1B];
196 b2
[0x1B] = (b1
[0x18] - b1
[0x1B]) * cos0
;
197 b2
[0x19] = b1
[0x19] + b1
[0x1A];
198 b2
[0x1A] = (b1
[0x19] - b1
[0x1A]) * cos1
;
200 b2
[0x1C] = b1
[0x1C] + b1
[0x1F];
201 b2
[0x1F] = (b1
[0x1F] - b1
[0x1C]) * cos0
;
202 b2
[0x1D] = b1
[0x1D] + b1
[0x1E];
203 b2
[0x1E] = (b1
[0x1E] - b1
[0x1D]) * cos1
;
207 register real
const cos0
= pnts
[4][0];
209 b1
[0x00] = b2
[0x00] + b2
[0x01];
210 b1
[0x01] = (b2
[0x00] - b2
[0x01]) * cos0
;
211 b1
[0x02] = b2
[0x02] + b2
[0x03];
212 b1
[0x03] = (b2
[0x03] - b2
[0x02]) * cos0
;
213 b1
[0x02] += b1
[0x03];
215 b1
[0x04] = b2
[0x04] + b2
[0x05];
216 b1
[0x05] = (b2
[0x04] - b2
[0x05]) * cos0
;
217 b1
[0x06] = b2
[0x06] + b2
[0x07];
218 b1
[0x07] = (b2
[0x07] - b2
[0x06]) * cos0
;
219 b1
[0x06] += b1
[0x07];
220 b1
[0x04] += b1
[0x06];
221 b1
[0x06] += b1
[0x05];
222 b1
[0x05] += b1
[0x07];
224 b1
[0x08] = b2
[0x08] + b2
[0x09];
225 b1
[0x09] = (b2
[0x08] - b2
[0x09]) * cos0
;
226 b1
[0x0A] = b2
[0x0A] + b2
[0x0B];
227 b1
[0x0B] = (b2
[0x0B] - b2
[0x0A]) * cos0
;
228 b1
[0x0A] += b1
[0x0B];
230 b1
[0x0C] = b2
[0x0C] + b2
[0x0D];
231 b1
[0x0D] = (b2
[0x0C] - b2
[0x0D]) * cos0
;
232 b1
[0x0E] = b2
[0x0E] + b2
[0x0F];
233 b1
[0x0F] = (b2
[0x0F] - b2
[0x0E]) * cos0
;
234 b1
[0x0E] += b1
[0x0F];
235 b1
[0x0C] += b1
[0x0E];
236 b1
[0x0E] += b1
[0x0D];
237 b1
[0x0D] += b1
[0x0F];
239 b1
[0x10] = b2
[0x10] + b2
[0x11];
240 b1
[0x11] = (b2
[0x10] - b2
[0x11]) * cos0
;
241 b1
[0x12] = b2
[0x12] + b2
[0x13];
242 b1
[0x13] = (b2
[0x13] - b2
[0x12]) * cos0
;
243 b1
[0x12] += b1
[0x13];
245 b1
[0x14] = b2
[0x14] + b2
[0x15];
246 b1
[0x15] = (b2
[0x14] - b2
[0x15]) * cos0
;
247 b1
[0x16] = b2
[0x16] + b2
[0x17];
248 b1
[0x17] = (b2
[0x17] - b2
[0x16]) * cos0
;
249 b1
[0x16] += b1
[0x17];
250 b1
[0x14] += b1
[0x16];
251 b1
[0x16] += b1
[0x15];
252 b1
[0x15] += b1
[0x17];
254 b1
[0x18] = b2
[0x18] + b2
[0x19];
255 b1
[0x19] = (b2
[0x18] - b2
[0x19]) * cos0
;
256 b1
[0x1A] = b2
[0x1A] + b2
[0x1B];
257 b1
[0x1B] = (b2
[0x1B] - b2
[0x1A]) * cos0
;
258 b1
[0x1A] += b1
[0x1B];
260 b1
[0x1C] = b2
[0x1C] + b2
[0x1D];
261 b1
[0x1D] = (b2
[0x1C] - b2
[0x1D]) * cos0
;
262 b1
[0x1E] = b2
[0x1E] + b2
[0x1F];
263 b1
[0x1F] = (b2
[0x1F] - b2
[0x1E]) * cos0
;
264 b1
[0x1E] += b1
[0x1F];
265 b1
[0x1C] += b1
[0x1E];
266 b1
[0x1E] += b1
[0x1D];
267 b1
[0x1D] += b1
[0x1F];
270 out0
[0x10*16] = b1
[0x00];
271 out0
[0x10*12] = b1
[0x04];
272 out0
[0x10* 8] = b1
[0x02];
273 out0
[0x10* 4] = b1
[0x06];
274 out0
[0x10* 0] = b1
[0x01];
275 out1
[0x10* 0] = b1
[0x01];
276 out1
[0x10* 4] = b1
[0x05];
277 out1
[0x10* 8] = b1
[0x03];
278 out1
[0x10*12] = b1
[0x07];
280 b1
[0x08] += b1
[0x0C];
281 out0
[0x10*14] = b1
[0x08];
282 b1
[0x0C] += b1
[0x0a];
283 out0
[0x10*10] = b1
[0x0C];
284 b1
[0x0A] += b1
[0x0E];
285 out0
[0x10* 6] = b1
[0x0A];
286 b1
[0x0E] += b1
[0x09];
287 out0
[0x10* 2] = b1
[0x0E];
288 b1
[0x09] += b1
[0x0D];
289 out1
[0x10* 2] = b1
[0x09];
290 b1
[0x0D] += b1
[0x0B];
291 out1
[0x10* 6] = b1
[0x0D];
292 b1
[0x0B] += b1
[0x0F];
293 out1
[0x10*10] = b1
[0x0B];
294 out1
[0x10*14] = b1
[0x0F];
296 b1
[0x18] += b1
[0x1C];
297 out0
[0x10*15] = b1
[0x10] + b1
[0x18];
298 out0
[0x10*13] = b1
[0x18] + b1
[0x14];
299 b1
[0x1C] += b1
[0x1a];
300 out0
[0x10*11] = b1
[0x14] + b1
[0x1C];
301 out0
[0x10* 9] = b1
[0x1C] + b1
[0x12];
302 b1
[0x1A] += b1
[0x1E];
303 out0
[0x10* 7] = b1
[0x12] + b1
[0x1A];
304 out0
[0x10* 5] = b1
[0x1A] + b1
[0x16];
305 b1
[0x1E] += b1
[0x19];
306 out0
[0x10* 3] = b1
[0x16] + b1
[0x1E];
307 out0
[0x10* 1] = b1
[0x1E] + b1
[0x11];
308 b1
[0x19] += b1
[0x1D];
309 out1
[0x10* 1] = b1
[0x11] + b1
[0x19];
310 out1
[0x10* 3] = b1
[0x19] + b1
[0x15];
311 b1
[0x1D] += b1
[0x1B];
312 out1
[0x10* 5] = b1
[0x15] + b1
[0x1D];
313 out1
[0x10* 7] = b1
[0x1D] + b1
[0x13];
314 b1
[0x1B] += b1
[0x1F];
315 out1
[0x10* 9] = b1
[0x13] + b1
[0x1B];
316 out1
[0x10*11] = b1
[0x1B] + b1
[0x17];
317 out1
[0x10*13] = b1
[0x17] + b1
[0x1F];
318 out1
[0x10*15] = b1
[0x1F];
322 * the call via dct64 is a trick to force GCC to use
323 * (new) registers for the b1,b2 pointer to the bufs[xx] field
325 void dct64(real
*a
,real
*b
,real
*c
)
328 dct64_1(a
,b
,bufs
,bufs
+0x20,c
);