Fix mp3 playback on the gigabeat by not putting code in IRAM. Someone actually famila...
[kugel-rb.git] / apps / codecs / libmad / synth.c
blob00e00ad5ffb9357d3c73a7897346ad0d0dd62011
1 /*
2 * libmad - MPEG audio decoder library
3 * Copyright (C) 2000-2004 Underbit Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * $Id$
22 # ifdef HAVE_CONFIG_H
23 # include "config.h"
24 # endif
26 # include "global.h"
28 # include "fixed.h"
29 # include "frame.h"
30 # include "synth.h"
33 * NAME: synth->init()
34 * DESCRIPTION: initialize synth struct
36 void mad_synth_init(struct mad_synth *synth)
38 mad_synth_mute(synth);
40 synth->phase = 0;
42 synth->pcm.samplerate = 0;
43 synth->pcm.channels = 0;
44 synth->pcm.length = 0;
45 #if defined(CPU_COLDFIRE)
46 /* init the emac unit here, since this function should always be called
47 before using libmad */
48 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND);
49 #endif
53 * NAME: synth->mute()
54 * DESCRIPTION: zero all polyphase filterbank values, resetting synthesis
56 void mad_synth_mute(struct mad_synth *synth)
58 unsigned int ch, s, v;
60 for (ch = 0; ch < 2; ++ch) {
61 for (s = 0; s < 16; ++s) {
62 for (v = 0; v < 8; ++v) {
63 synth->filter[ch][0][0][s][v] = synth->filter[ch][0][1][s][v] =
64 synth->filter[ch][1][0][s][v] = synth->filter[ch][1][1][s][v] = 0;
70 #ifdef FPM_ARM
72 void dct32(mad_fixed_t const in[32], unsigned int slot,
73 mad_fixed_t lo[16][8], mad_fixed_t hi[16][8]);
75 #else
78 * An optional optimization called here the Subband Synthesis Optimization
79 * (SSO) improves the performance of subband synthesis at the expense of
80 * accuracy.
82 * The idea is to simplify 32x32->64-bit multiplication to 32x32->32 such
83 * that extra scaling and rounding are not necessary. This often allows the
84 * compiler to use faster 32-bit multiply-accumulate instructions instead of
85 * explicit 64-bit multiply, shift, and add instructions.
87 * SSO works like this: a full 32x32->64-bit multiply of two mad_fixed_t
88 * values requires the result to be right-shifted 28 bits to be properly
89 * scaled to the same fixed-point format. Right shifts can be applied at any
90 * time to either operand or to the result, so the optimization involves
91 * careful placement of these shifts to minimize the loss of accuracy.
93 * First, a 14-bit shift is applied with rounding at compile-time to the D[]
94 * table of coefficients for the subband synthesis window. This only loses 2
95 * bits of accuracy because the lower 12 bits are always zero. A second
96 * 12-bit shift occurs after the DCT calculation. This loses 12 bits of
97 * accuracy. Finally, a third 2-bit shift occurs just before the sample is
98 * saved in the PCM buffer. 14 + 12 + 2 == 28 bits.
101 /* FPM_DEFAULT without OPT_SSO will actually lose accuracy and performance */
103 # if defined(FPM_DEFAULT) && !defined(OPT_SSO)
104 # define OPT_SSO
105 # endif
107 /* second SSO shift, with rounding */
109 # if defined(OPT_SSO)
110 # define SHIFT(x) (((x) + (1L << 11)) >> 12)
111 # else
112 # define SHIFT(x) (x)
113 # endif
115 /* possible DCT speed optimization */
117 /* This is a Coldfire version of the OPT_SPEED optimisation below, but in the
118 case of Coldfire it doesn't lose any more precision than we would ordinarily
119 lose, */
120 # ifdef FPM_COLDFIRE_EMAC
121 # define OPT_DCTO
122 # define MUL(x, y) \
123 ({ \
124 mad_fixed64hi_t hi; \
125 asm volatile("mac.l %[a], %[b], %%acc0\n\t" \
126 "movclr.l %%acc0, %[hi]" \
127 : [hi] "=r" (hi) \
128 : [a] "r" ((x)), [b] "r" ((y))); \
129 hi; \
131 # elif defined(OPT_SPEED) && defined(MAD_F_MLX)
132 # define OPT_DCTO
133 # define MUL(x, y) \
134 ({ mad_fixed64hi_t hi; \
135 mad_fixed64lo_t lo; \
136 MAD_F_MLX(hi, lo, (x), (y)); \
137 hi << (32 - MAD_F_SCALEBITS - 3); \
139 # else
140 # undef OPT_DCTO
141 # define MUL(x, y) mad_f_mul((x), (y))
142 # endif
145 * NAME: dct32()
146 * DESCRIPTION: perform fast in[32]->out[32] DCT
148 static
149 void dct32(mad_fixed_t const in[32], unsigned int slot,
150 mad_fixed_t lo[16][8], mad_fixed_t hi[16][8])
152 mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7;
153 mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15;
154 mad_fixed_t t16, t17, t18, t19, t20, t21, t22, t23;
155 mad_fixed_t t24, t25, t26, t27, t28, t29, t30, t31;
156 mad_fixed_t t32, t33, t34, t35, t36, t37, t38, t39;
157 mad_fixed_t t40, t41, t42, t43, t44, t45, t46, t47;
158 mad_fixed_t t48, t49, t50, t51, t52, t53, t54, t55;
159 mad_fixed_t t56, t57, t58, t59, t60, t61, t62, t63;
160 mad_fixed_t t64, t65, t66, t67, t68, t69, t70, t71;
161 mad_fixed_t t72, t73, t74, t75, t76, t77, t78, t79;
162 mad_fixed_t t80, t81, t82, t83, t84, t85, t86, t87;
163 mad_fixed_t t88, t89, t90, t91, t92, t93, t94, t95;
164 mad_fixed_t t96, t97, t98, t99, t100, t101, t102, t103;
165 mad_fixed_t t104, t105, t106, t107, t108, t109, t110, t111;
166 mad_fixed_t t112, t113, t114, t115, t116, t117, t118, t119;
167 mad_fixed_t t120, t121, t122, t123, t124, t125, t126, t127;
168 mad_fixed_t t128, t129, t130, t131, t132, t133, t134, t135;
169 mad_fixed_t t136, t137, t138, t139, t140, t141, t142, t143;
170 mad_fixed_t t144, t145, t146, t147, t148, t149, t150, t151;
171 mad_fixed_t t152, t153, t154, t155, t156, t157, t158, t159;
172 mad_fixed_t t160, t161, t162, t163, t164, t165, t166, t167;
173 mad_fixed_t t168, t169, t170, t171, t172, t173, t174, t175;
174 mad_fixed_t t176;
176 /* costab[i] = cos(PI / (2 * 32) * i) */
178 # if defined(OPT_DCTO)
179 # define costab1 MAD_F(0x7fd8878e)
180 # define costab2 MAD_F(0x7f62368f)
181 # define costab3 MAD_F(0x7e9d55fc)
182 # define costab4 MAD_F(0x7d8a5f40)
183 # define costab5 MAD_F(0x7c29fbee)
184 # define costab6 MAD_F(0x7a7d055b)
185 # define costab7 MAD_F(0x78848414)
186 # define costab8 MAD_F(0x7641af3d)
187 # define costab9 MAD_F(0x73b5ebd1)
188 # define costab10 MAD_F(0x70e2cbc6)
189 # define costab11 MAD_F(0x6dca0d14)
190 # define costab12 MAD_F(0x6a5d98a4)
191 # define costab13 MAD_F(0x66cf8120)
192 # define costab14 MAD_F(0x62f201ac)
193 # define costab15 MAD_F(0x5ed77c8a)
194 # define costab16 MAD_F(0x5a82799a)
195 # define costab17 MAD_F(0x55f5a4d2)
196 # define costab18 MAD_F(0x5133cc94)
197 # define costab19 MAD_F(0x4c3fdff4)
198 # define costab20 MAD_F(0x471cece7)
199 # define costab21 MAD_F(0x41ce1e65)
200 # define costab22 MAD_F(0x3c56ba70)
201 # define costab23 MAD_F(0x36ba2014)
202 # define costab24 MAD_F(0x30fbc54d)
203 # define costab25 MAD_F(0x2b1f34eb)
204 # define costab26 MAD_F(0x25280c5e)
205 # define costab27 MAD_F(0x1f19f97b)
206 # define costab28 MAD_F(0x18f8b83c)
207 # define costab29 MAD_F(0x12c8106f)
208 # define costab30 MAD_F(0x0c8bd35e)
209 # define costab31 MAD_F(0x0647d97c)
210 # else
211 # define costab1 MAD_F(0x0ffb10f2) /* 0.998795456 */
212 # define costab2 MAD_F(0x0fec46d2) /* 0.995184727 */
213 # define costab3 MAD_F(0x0fd3aac0) /* 0.989176510 */
214 # define costab4 MAD_F(0x0fb14be8) /* 0.980785280 */
215 # define costab5 MAD_F(0x0f853f7e) /* 0.970031253 */
216 # define costab6 MAD_F(0x0f4fa0ab) /* 0.956940336 */
217 # define costab7 MAD_F(0x0f109082) /* 0.941544065 */
218 # define costab8 MAD_F(0x0ec835e8) /* 0.923879533 */
219 # define costab9 MAD_F(0x0e76bd7a) /* 0.903989293 */
220 # define costab10 MAD_F(0x0e1c5979) /* 0.881921264 */
221 # define costab11 MAD_F(0x0db941a3) /* 0.857728610 */
222 # define costab12 MAD_F(0x0d4db315) /* 0.831469612 */
223 # define costab13 MAD_F(0x0cd9f024) /* 0.803207531 */
224 # define costab14 MAD_F(0x0c5e4036) /* 0.773010453 */
225 # define costab15 MAD_F(0x0bdaef91) /* 0.740951125 */
226 # define costab16 MAD_F(0x0b504f33) /* 0.707106781 */
227 # define costab17 MAD_F(0x0abeb49a) /* 0.671558955 */
228 # define costab18 MAD_F(0x0a267993) /* 0.634393284 */
229 # define costab19 MAD_F(0x0987fbfe) /* 0.595699304 */
230 # define costab20 MAD_F(0x08e39d9d) /* 0.555570233 */
231 # define costab21 MAD_F(0x0839c3cd) /* 0.514102744 */
232 # define costab22 MAD_F(0x078ad74e) /* 0.471396737 */
233 # define costab23 MAD_F(0x06d74402) /* 0.427555093 */
234 # define costab24 MAD_F(0x061f78aa) /* 0.382683432 */
235 # define costab25 MAD_F(0x0563e69d) /* 0.336889853 */
236 # define costab26 MAD_F(0x04a5018c) /* 0.290284677 */
237 # define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */
238 # define costab28 MAD_F(0x031f1708) /* 0.195090322 */
239 # define costab29 MAD_F(0x0259020e) /* 0.146730474 */
240 # define costab30 MAD_F(0x01917a5c) /* 0.098017140 */
241 # define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */
242 # endif
244 t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1);
245 t1 = in[15] + in[16]; t17 = MUL(in[15] - in[16], costab31);
247 t41 = t16 + t17;
248 t59 = MUL(t16 - t17, costab2);
249 t33 = t0 + t1;
250 t50 = MUL(t0 - t1, costab2);
252 t2 = in[7] + in[24]; t18 = MUL(in[7] - in[24], costab15);
253 t3 = in[8] + in[23]; t19 = MUL(in[8] - in[23], costab17);
255 t42 = t18 + t19;
256 t60 = MUL(t18 - t19, costab30);
257 t34 = t2 + t3;
258 t51 = MUL(t2 - t3, costab30);
260 t4 = in[3] + in[28]; t20 = MUL(in[3] - in[28], costab7);
261 t5 = in[12] + in[19]; t21 = MUL(in[12] - in[19], costab25);
263 t43 = t20 + t21;
264 t61 = MUL(t20 - t21, costab14);
265 t35 = t4 + t5;
266 t52 = MUL(t4 - t5, costab14);
268 t6 = in[4] + in[27]; t22 = MUL(in[4] - in[27], costab9);
269 t7 = in[11] + in[20]; t23 = MUL(in[11] - in[20], costab23);
271 t44 = t22 + t23;
272 t62 = MUL(t22 - t23, costab18);
273 t36 = t6 + t7;
274 t53 = MUL(t6 - t7, costab18);
276 t8 = in[1] + in[30]; t24 = MUL(in[1] - in[30], costab3);
277 t9 = in[14] + in[17]; t25 = MUL(in[14] - in[17], costab29);
279 t45 = t24 + t25;
280 t63 = MUL(t24 - t25, costab6);
281 t37 = t8 + t9;
282 t54 = MUL(t8 - t9, costab6);
284 t10 = in[6] + in[25]; t26 = MUL(in[6] - in[25], costab13);
285 t11 = in[9] + in[22]; t27 = MUL(in[9] - in[22], costab19);
287 t46 = t26 + t27;
288 t64 = MUL(t26 - t27, costab26);
289 t38 = t10 + t11;
290 t55 = MUL(t10 - t11, costab26);
292 t12 = in[2] + in[29]; t28 = MUL(in[2] - in[29], costab5);
293 t13 = in[13] + in[18]; t29 = MUL(in[13] - in[18], costab27);
295 t47 = t28 + t29;
296 t65 = MUL(t28 - t29, costab10);
297 t39 = t12 + t13;
298 t56 = MUL(t12 - t13, costab10);
300 t14 = in[5] + in[26]; t30 = MUL(in[5] - in[26], costab11);
301 t15 = in[10] + in[21]; t31 = MUL(in[10] - in[21], costab21);
303 t48 = t30 + t31;
304 t66 = MUL(t30 - t31, costab22);
305 t40 = t14 + t15;
306 t57 = MUL(t14 - t15, costab22);
308 t69 = t33 + t34; t89 = MUL(t33 - t34, costab4);
309 t70 = t35 + t36; t90 = MUL(t35 - t36, costab28);
310 t71 = t37 + t38; t91 = MUL(t37 - t38, costab12);
311 t72 = t39 + t40; t92 = MUL(t39 - t40, costab20);
312 t73 = t41 + t42; t94 = MUL(t41 - t42, costab4);
313 t74 = t43 + t44; t95 = MUL(t43 - t44, costab28);
314 t75 = t45 + t46; t96 = MUL(t45 - t46, costab12);
315 t76 = t47 + t48; t97 = MUL(t47 - t48, costab20);
317 t78 = t50 + t51; t100 = MUL(t50 - t51, costab4);
318 t79 = t52 + t53; t101 = MUL(t52 - t53, costab28);
319 t80 = t54 + t55; t102 = MUL(t54 - t55, costab12);
320 t81 = t56 + t57; t103 = MUL(t56 - t57, costab20);
322 t83 = t59 + t60; t106 = MUL(t59 - t60, costab4);
323 t84 = t61 + t62; t107 = MUL(t61 - t62, costab28);
324 t85 = t63 + t64; t108 = MUL(t63 - t64, costab12);
325 t86 = t65 + t66; t109 = MUL(t65 - t66, costab20);
327 t113 = t69 + t70;
328 t114 = t71 + t72;
330 /* 0 */ hi[15][slot] = SHIFT(t113 + t114);
331 /* 16 */ lo[ 0][slot] = SHIFT(MUL(t113 - t114, costab16));
333 t115 = t73 + t74;
334 t116 = t75 + t76;
336 t32 = t115 + t116;
338 /* 1 */ hi[14][slot] = SHIFT(t32);
340 t118 = t78 + t79;
341 t119 = t80 + t81;
343 t58 = t118 + t119;
345 /* 2 */ hi[13][slot] = SHIFT(t58);
347 t121 = t83 + t84;
348 t122 = t85 + t86;
350 t67 = t121 + t122;
352 t49 = (t67 * 2) - t32;
354 /* 3 */ hi[12][slot] = SHIFT(t49);
356 t125 = t89 + t90;
357 t126 = t91 + t92;
359 t93 = t125 + t126;
361 /* 4 */ hi[11][slot] = SHIFT(t93);
363 t128 = t94 + t95;
364 t129 = t96 + t97;
366 t98 = t128 + t129;
368 t68 = (t98 * 2) - t49;
370 /* 5 */ hi[10][slot] = SHIFT(t68);
372 t132 = t100 + t101;
373 t133 = t102 + t103;
375 t104 = t132 + t133;
377 t82 = (t104 * 2) - t58;
379 /* 6 */ hi[ 9][slot] = SHIFT(t82);
381 t136 = t106 + t107;
382 t137 = t108 + t109;
384 t110 = t136 + t137;
386 t87 = (t110 * 2) - t67;
388 t77 = (t87 * 2) - t68;
390 /* 7 */ hi[ 8][slot] = SHIFT(t77);
392 t141 = MUL(t69 - t70, costab8);
393 t142 = MUL(t71 - t72, costab24);
394 t143 = t141 + t142;
396 /* 8 */ hi[ 7][slot] = SHIFT(t143);
397 /* 24 */ lo[ 8][slot] =
398 SHIFT((MUL(t141 - t142, costab16) * 2) - t143);
400 t144 = MUL(t73 - t74, costab8);
401 t145 = MUL(t75 - t76, costab24);
402 t146 = t144 + t145;
404 t88 = (t146 * 2) - t77;
406 /* 9 */ hi[ 6][slot] = SHIFT(t88);
408 t148 = MUL(t78 - t79, costab8);
409 t149 = MUL(t80 - t81, costab24);
410 t150 = t148 + t149;
412 t105 = (t150 * 2) - t82;
414 /* 10 */ hi[ 5][slot] = SHIFT(t105);
416 t152 = MUL(t83 - t84, costab8);
417 t153 = MUL(t85 - t86, costab24);
418 t154 = t152 + t153;
420 t111 = (t154 * 2) - t87;
422 t99 = (t111 * 2) - t88;
424 /* 11 */ hi[ 4][slot] = SHIFT(t99);
426 t157 = MUL(t89 - t90, costab8);
427 t158 = MUL(t91 - t92, costab24);
428 t159 = t157 + t158;
430 t127 = (t159 * 2) - t93;
432 /* 12 */ hi[ 3][slot] = SHIFT(t127);
434 t160 = (MUL(t125 - t126, costab16) * 2) - t127;
436 /* 20 */ lo[ 4][slot] = SHIFT(t160);
437 /* 28 */ lo[12][slot] =
438 SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160);
440 t161 = MUL(t94 - t95, costab8);
441 t162 = MUL(t96 - t97, costab24);
442 t163 = t161 + t162;
444 t130 = (t163 * 2) - t98;
446 t112 = (t130 * 2) - t99;
448 /* 13 */ hi[ 2][slot] = SHIFT(t112);
450 t164 = (MUL(t128 - t129, costab16) * 2) - t130;
452 t166 = MUL(t100 - t101, costab8);
453 t167 = MUL(t102 - t103, costab24);
454 t168 = t166 + t167;
456 t134 = (t168 * 2) - t104;
458 t120 = (t134 * 2) - t105;
460 /* 14 */ hi[ 1][slot] = SHIFT(t120);
462 t135 = (MUL(t118 - t119, costab16) * 2) - t120;
464 /* 18 */ lo[ 2][slot] = SHIFT(t135);
466 t169 = (MUL(t132 - t133, costab16) * 2) - t134;
468 t151 = (t169 * 2) - t135;
470 /* 22 */ lo[ 6][slot] = SHIFT(t151);
472 t170 = (((MUL(t148 - t149, costab16) * 2) - t150) * 2) - t151;
474 /* 26 */ lo[10][slot] = SHIFT(t170);
475 /* 30 */ lo[14][slot] =
476 SHIFT((((((MUL(t166 - t167, costab16) * 2) -
477 t168) * 2) - t169) * 2) - t170);
479 t171 = MUL(t106 - t107, costab8);
480 t172 = MUL(t108 - t109, costab24);
481 t173 = t171 + t172;
483 t138 = (t173 * 2) - t110;
485 t123 = (t138 * 2) - t111;
487 t139 = (MUL(t121 - t122, costab16) * 2) - t123;
489 t117 = (t123 * 2) - t112;
491 /* 15 */ hi[ 0][slot] = SHIFT(t117);
493 t124 = (MUL(t115 - t116, costab16) * 2) - t117;
495 /* 17 */ lo[ 1][slot] = SHIFT(t124);
497 t131 = (t139 * 2) - t124;
499 /* 19 */ lo[ 3][slot] = SHIFT(t131);
501 t140 = (t164 * 2) - t131;
503 /* 21 */ lo[ 5][slot] = SHIFT(t140);
505 t174 = (MUL(t136 - t137, costab16) * 2) - t138;
507 t155 = (t174 * 2) - t139;
509 t147 = (t155 * 2) - t140;
511 /* 23 */ lo[ 7][slot] = SHIFT(t147);
513 t156 = (((MUL(t144 - t145, costab16) * 2) - t146) * 2) - t147;
515 /* 25 */ lo[ 9][slot] = SHIFT(t156);
517 t175 = (((MUL(t152 - t153, costab16) * 2) - t154) * 2) - t155;
519 t165 = (t175 * 2) - t156;
521 /* 27 */ lo[11][slot] = SHIFT(t165);
523 t176 = (((((MUL(t161 - t162, costab16) * 2) -
524 t163) * 2) - t164) * 2) - t165;
526 /* 29 */ lo[13][slot] = SHIFT(t176);
527 /* 31 */ lo[15][slot] =
528 SHIFT((((((((MUL(t171 - t172, costab16) * 2) -
529 t173) * 2) - t174) * 2) - t175) * 2) - t176);
532 * Totals:
533 * 80 multiplies
534 * 80 additions
535 * 119 subtractions
536 * 49 shifts (not counting SSO)
540 # undef MUL
541 # undef SHIFT
543 #endif
545 /* third SSO shift and/or D[] optimization preshift */
547 # if defined(OPT_SSO)
548 # if MAD_F_FRACBITS != 28
549 # error "MAD_F_FRACBITS must be 28 to use OPT_SSO"
550 # endif
551 # define ML0(hi, lo, x, y) ((lo) = (x) * (y))
552 # define MLA(hi, lo, x, y) ((lo) += (x) * (y))
553 # define MLN(hi, lo) ((lo) = -(lo))
554 # define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
555 # define SHIFT(x) ((x) >> 2)
556 # define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14)
557 # else
558 # define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y))
559 # define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y))
560 # define MLN(hi, lo) MAD_F_MLN((hi), (lo))
561 # define MLZ(hi, lo) MAD_F_MLZ((hi), (lo))
562 # define SHIFT(x) (x)
563 # if defined(MAD_F_SCALEBITS)
564 # undef MAD_F_SCALEBITS
565 # define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12)
566 # define PRESHIFT(x) (MAD_F(x) >> 12)
567 # else
568 # define PRESHIFT(x) MAD_F(x)
569 # endif
570 # endif
572 static
573 mad_fixed_t const D[17][32] ICONST_ATTR = {
574 # include "D.dat"
577 # if defined(ASO_SYNTH)
578 void synth_full(struct mad_synth *, struct mad_frame const *,
579 unsigned int, unsigned int);
580 # else
582 * NAME: synth->full()
583 * DESCRIPTION: perform full frequency PCM synthesis
586 /* optimised version of synth_full */
587 # ifdef FPM_COLDFIRE_EMAC
588 static
589 void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
590 unsigned int nch, unsigned int ns)
592 unsigned int phase, ch, s, sb, p;
593 mad_fixed_t *pcm, (*filter)[2][2][16][8];
594 mad_fixed_t const (*sbsample)[36][32];
595 mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
596 mad_fixed_t const (*D0ptr)[32];
597 mad_fixed_t const (*D1ptr)[32];
598 mad_fixed64hi_t hi0, hi1;
600 for (ch = 0; ch < nch; ++ch) {
601 sbsample = &frame->sbsample[ch];
602 filter = &synth->filter[ch];
603 phase = synth->phase;
604 pcm = synth->pcm.samples[ch];
606 for (s = 0; s < ns; ++s) {
607 dct32((*sbsample)[s], phase >> 1,
608 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
610 p = (phase - 1) & 0xf;
612 /* calculate 32 samples */
613 fe = &(*filter)[0][ phase & 1][0];
614 fx = &(*filter)[0][~phase & 1][0];
615 fo = &(*filter)[1][~phase & 1][0];
617 D0ptr = (void*)&D[0][ p];
618 D1ptr = (void*)&D[0][-p];
620 if(s & 1)
622 asm volatile(
623 "movem.l (%1), %%d0-%%d7\n\t"
624 "move.l 4(%2), %%a5\n\t"
625 "msac.l %%d0, %%a5, 60(%2), %%a5, %%acc0\n\t"
626 "msac.l %%d1, %%a5, 52(%2), %%a5, %%acc0\n\t"
627 "msac.l %%d2, %%a5, 44(%2), %%a5, %%acc0\n\t"
628 "msac.l %%d3, %%a5, 36(%2), %%a5, %%acc0\n\t"
629 "msac.l %%d4, %%a5, 28(%2), %%a5, %%acc0\n\t"
630 "msac.l %%d5, %%a5, 20(%2), %%a5, %%acc0\n\t"
631 "msac.l %%d6, %%a5, 12(%2), %%a5, %%acc0\n\t"
632 "msac.l %%d7, %%a5, (%2), %%a5, %%acc0\n\t"
634 "movem.l (%3), %%d0-%%d7\n\t"
635 "mac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
636 "mac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
637 "mac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
638 "mac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
639 "mac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
640 "mac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
641 "mac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
642 "mac.l %%d7, %%a5, %%acc0\n\t"
643 "movclr.l %%acc0, %0\n\t"
644 : "=r" (hi0) : "a" (*fx), "a" (*D0ptr), "a" (*fe)
645 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
647 pcm[0] = hi0 << 3; /* shift result to libmad's fixed point format */
648 pcm += 16;
650 for (sb = 15; sb; sb--, fo++) {
651 ++fe;
652 ++D0ptr;
653 ++D1ptr;
655 /* D[32 - sb][i] == -D[sb][31 - i] */
656 asm volatile (
657 "movem.l (%0), %%d0-%%d7\n\t"
658 "move.l 4(%2), %%a5\n\t"
659 "msac.l %%d0, %%a5, 60(%2), %%a5, %%acc0\n\t"
660 "msac.l %%d1, %%a5, 52(%2), %%a5, %%acc0\n\t"
661 "msac.l %%d2, %%a5, 44(%2), %%a5, %%acc0\n\t"
662 "msac.l %%d3, %%a5, 36(%2), %%a5, %%acc0\n\t"
663 "msac.l %%d4, %%a5, 28(%2), %%a5, %%acc0\n\t"
664 "msac.l %%d5, %%a5, 20(%2), %%a5, %%acc0\n\t"
665 "msac.l %%d6, %%a5, 12(%2), %%a5, %%acc0\n\t"
666 "msac.l %%d7, %%a5, 112(%3), %%a5, %%acc0\n\t"
667 "mac.l %%d7, %%a5, 104(%3), %%a5, %%acc1\n\t"
668 "mac.l %%d6, %%a5, 96(%3), %%a5, %%acc1\n\t"
669 "mac.l %%d5, %%a5, 88(%3), %%a5, %%acc1\n\t"
670 "mac.l %%d4, %%a5, 80(%3), %%a5, %%acc1\n\t"
671 "mac.l %%d3, %%a5, 72(%3), %%a5, %%acc1\n\t"
672 "mac.l %%d2, %%a5, 64(%3), %%a5, %%acc1\n\t"
673 "mac.l %%d1, %%a5, 120(%3), %%a5, %%acc1\n\t"
674 "mac.l %%d0, %%a5, 8(%2), %%a5, %%acc1\n\t"
675 "movem.l (%1), %%d0-%%d7\n\t"
676 "mac.l %%d7, %%a5, 16(%2), %%a5, %%acc0\n\t"
677 "mac.l %%d6, %%a5, 24(%2), %%a5, %%acc0\n\t"
678 "mac.l %%d5, %%a5, 32(%2), %%a5, %%acc0\n\t"
679 "mac.l %%d4, %%a5, 40(%2), %%a5, %%acc0\n\t"
680 "mac.l %%d3, %%a5, 48(%2), %%a5, %%acc0\n\t"
681 "mac.l %%d2, %%a5, 56(%2), %%a5, %%acc0\n\t"
682 "mac.l %%d1, %%a5, (%2), %%a5, %%acc0\n\t"
683 "mac.l %%d0, %%a5, 60(%3), %%a5, %%acc0\n\t"
684 "mac.l %%d0, %%a5, 68(%3), %%a5, %%acc1\n\t"
685 "mac.l %%d1, %%a5, 76(%3), %%a5, %%acc1\n\t"
686 "mac.l %%d2, %%a5, 84(%3), %%a5, %%acc1\n\t"
687 "mac.l %%d3, %%a5, 92(%3), %%a5, %%acc1\n\t"
688 "mac.l %%d4, %%a5, 100(%3), %%a5, %%acc1\n\t"
689 "mac.l %%d5, %%a5, 108(%3), %%a5, %%acc1\n\t"
690 "mac.l %%d6, %%a5, 116(%3), %%a5, %%acc1\n\t"
691 "mac.l %%d7, %%a5, %%acc1\n\t"
692 : : "a" (*fo), "a" (*fe), "a" (*D0ptr), "a" (*D1ptr)
693 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
695 asm volatile(
696 "movclr.l %%acc0, %0\n\t"
697 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) );
699 pcm[-sb] = hi0 << 3;
700 pcm[ sb] = hi1 << 3;
703 ++D0ptr;
704 asm volatile(
705 "movem.l (%1), %%d0-%%d7\n\t"
706 "move.l 4(%2), %%a5\n\t"
707 "mac.l %%d0, %%a5, 60(%2), %%a5, %%acc0\n\t"
708 "mac.l %%d1, %%a5, 52(%2), %%a5, %%acc0\n\t"
709 "mac.l %%d2, %%a5, 44(%2), %%a5, %%acc0\n\t"
710 "mac.l %%d3, %%a5, 36(%2), %%a5, %%acc0\n\t"
711 "mac.l %%d4, %%a5, 28(%2), %%a5, %%acc0\n\t"
712 "mac.l %%d5, %%a5, 20(%2), %%a5, %%acc0\n\t"
713 "mac.l %%d6, %%a5, 12(%2), %%a5, %%acc0\n\t"
714 "mac.l %%d7, %%a5, %%acc0\n\t"
715 "movclr.l %%acc0, %0\n\t"
716 : "=r" (hi0) : "a" (*fo), "a" (*D0ptr)
717 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
719 pcm[0] = -(hi0 << 3);
721 else
723 asm volatile(
724 "movem.l (%1), %%d0-%%d7\n\t"
725 "move.l (%2), %%a5\n\t"
726 "msac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
727 "msac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
728 "msac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
729 "msac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
730 "msac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
731 "msac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
732 "msac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
733 "msac.l %%d7, %%a5, 4(%2), %%a5, %%acc0\n\t"
735 "movem.l (%3), %%d0-%%d7\n\t"
736 "mac.l %%d0, %%a5, 60(%2), %%a5, %%acc0\n\t"
737 "mac.l %%d1, %%a5, 52(%2), %%a5, %%acc0\n\t"
738 "mac.l %%d2, %%a5, 44(%2), %%a5, %%acc0\n\t"
739 "mac.l %%d3, %%a5, 36(%2), %%a5, %%acc0\n\t"
740 "mac.l %%d4, %%a5, 28(%2), %%a5, %%acc0\n\t"
741 "mac.l %%d5, %%a5, 20(%2), %%a5, %%acc0\n\t"
742 "mac.l %%d6, %%a5, 12(%2), %%a5, %%acc0\n\t"
743 "mac.l %%d7, %%a5, %%acc0\n\t"
744 "movclr.l %%acc0, %0\n\t"
745 : "=r" (hi0) : "a" (*fx), "a" (*D0ptr), "a" (*fe)
746 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
748 pcm[0] = hi0 << 3; /* shift result to libmad's fixed point format */
749 pcm += 16;
751 for (sb = 15; sb; sb--, fo++) {
752 ++fe;
753 ++D0ptr;
754 ++D1ptr;
756 /* D[32 - sb][i] == -D[sb][31 - i] */
757 asm volatile (
758 "movem.l (%0), %%d0-%%d7\n\t"
759 "move.l (%2), %%a5\n\t"
760 "msac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
761 "msac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
762 "msac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
763 "msac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
764 "msac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
765 "msac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
766 "msac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
767 "msac.l %%d7, %%a5, 116(%3), %%a5, %%acc0\n\t"
768 "mac.l %%d7, %%a5, 108(%3), %%a5, %%acc1\n\t"
769 "mac.l %%d6, %%a5, 100(%3), %%a5, %%acc1\n\t"
770 "mac.l %%d5, %%a5, 92(%3), %%a5, %%acc1\n\t"
771 "mac.l %%d4, %%a5, 84(%3), %%a5, %%acc1\n\t"
772 "mac.l %%d3, %%a5, 76(%3), %%a5, %%acc1\n\t"
773 "mac.l %%d2, %%a5, 68(%3), %%a5, %%acc1\n\t"
774 "mac.l %%d1, %%a5, 60(%3), %%a5, %%acc1\n\t"
775 "mac.l %%d0, %%a5, 12(%2), %%a5, %%acc1\n\t"
776 "movem.l (%1), %%d0-%%d7\n\t"
777 "mac.l %%d7, %%a5, 20(%2), %%a5, %%acc0\n\t"
778 "mac.l %%d6, %%a5, 28(%2), %%a5, %%acc0\n\t"
779 "mac.l %%d5, %%a5, 36(%2), %%a5, %%acc0\n\t"
780 "mac.l %%d4, %%a5, 44(%2), %%a5, %%acc0\n\t"
781 "mac.l %%d3, %%a5, 52(%2), %%a5, %%acc0\n\t"
782 "mac.l %%d2, %%a5, 60(%2), %%a5, %%acc0\n\t"
783 "mac.l %%d1, %%a5, 4(%2), %%a5, %%acc0\n\t"
784 "mac.l %%d0, %%a5, 120(%3), %%a5, %%acc0\n\t"
785 "mac.l %%d0, %%a5, 64(%3), %%a5, %%acc1\n\t"
786 "mac.l %%d1, %%a5, 72(%3), %%a5, %%acc1\n\t"
787 "mac.l %%d2, %%a5, 80(%3), %%a5, %%acc1\n\t"
788 "mac.l %%d3, %%a5, 88(%3), %%a5, %%acc1\n\t"
789 "mac.l %%d4, %%a5, 96(%3), %%a5, %%acc1\n\t"
790 "mac.l %%d5, %%a5, 104(%3), %%a5, %%acc1\n\t"
791 "mac.l %%d6, %%a5, 112(%3), %%a5, %%acc1\n\t"
792 "mac.l %%d7, %%a5, %%acc1\n\t"
793 : : "a" (*fo), "a" (*fe), "a" (*D0ptr), "a" (*D1ptr)
794 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
796 asm volatile(
797 "movclr.l %%acc0, %0\n\t"
798 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) );
800 pcm[-sb] = hi0 << 3;
801 pcm[ sb] = hi1 << 3;
804 ++D0ptr;
805 asm volatile(
806 "movem.l (%1), %%d0-%%d7\n\t"
807 "move.l (%2), %%a5\n\t"
808 "mac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
809 "mac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
810 "mac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
811 "mac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
812 "mac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
813 "mac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
814 "mac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
815 "mac.l %%d7, %%a5, %%acc0\n\t"
816 "movclr.l %%acc0, %0\n\t"
817 : "=r" (hi0) : "a" (*fo), "a" (*D0ptr)
818 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
820 pcm[0] = -(hi0 << 3);
822 pcm += 16;
823 phase = (phase + 1) % 16;
828 #elif defined(FPM_ARM)
830 #define PROD_ODD_0(hi, lo, f, ptr) \
831 do { \
832 mad_fixed_t *__p = (f); \
833 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
834 "ldr r4, [%3, #4]\n\t" \
835 "smull %0, %1, r0, r4\n\t" \
836 "ldr r4, [%3, #60]\n\t" \
837 "smlal %0, %1, r1, r4\n\t" \
838 "ldr r4, [%3, #52]\n\t" \
839 "smlal %0, %1, r2, r4\n\t" \
840 "ldr r4, [%3, #44]\n\t" \
841 "smlal %0, %1, r3, r4\n\t" \
842 "ldmia %2, {r0, r1, r2, r3}\n\t" \
843 "ldr r4, [%3, #36]\n\t" \
844 "smlal %0, %1, r0, r4\n\t" \
845 "ldr r4, [%3, #28]\n\t" \
846 "smlal %0, %1, r1, r4\n\t" \
847 "ldr r4, [%3, #20]\n\t" \
848 "smlal %0, %1, r2, r4\n\t" \
849 "ldr r4, [%3, #12]\n\t" \
850 "smlal %0, %1, r3, r4\n\t" \
851 : "=&r" (lo), "=&r" (hi), "+r" (__p) \
852 : "r" (ptr) \
853 : "r0", "r1", "r2", "r3", "r4"); \
854 } while (0)
856 #define PROD_ODD_A(hi, lo, f, ptr) \
857 do { \
858 mad_fixed_t *__p = (f); \
859 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
860 "ldr r4, [%3, #4]\n\t" \
861 "smlal %0, %1, r0, r4\n\t" \
862 "ldr r4, [%3, #60]\n\t" \
863 "smlal %0, %1, r1, r4\n\t" \
864 "ldr r4, [%3, #52]\n\t" \
865 "smlal %0, %1, r2, r4\n\t" \
866 "ldr r4, [%3, #44]\n\t" \
867 "smlal %0, %1, r3, r4\n\t" \
868 "ldmia %2, {r0, r1, r2, r3}\n\t" \
869 "ldr r4, [%3, #36]\n\t" \
870 "smlal %0, %1, r0, r4\n\t" \
871 "ldr r4, [%3, #28]\n\t" \
872 "smlal %0, %1, r1, r4\n\t" \
873 "ldr r4, [%3, #20]\n\t" \
874 "smlal %0, %1, r2, r4\n\t" \
875 "ldr r4, [%3, #12]\n\t" \
876 "smlal %0, %1, r3, r4\n\t" \
877 : "+r" (lo), "+r" (hi), "+r" (__p) \
878 : "r" (ptr) \
879 : "r0", "r1", "r2", "r3", "r4"); \
880 } while (0)
882 #define PROD_EVEN_0(hi, lo, f, ptr) \
883 do { \
884 mad_fixed_t *__p = (f); \
885 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
886 "ldr r4, [%3, #0]\n\t" \
887 "smull %0, %1, r0, r4\n\t" \
888 "ldr r4, [%3, #56]\n\t" \
889 "smlal %0, %1, r1, r4\n\t" \
890 "ldr r4, [%3, #48]\n\t" \
891 "smlal %0, %1, r2, r4\n\t" \
892 "ldr r4, [%3, #40]\n\t" \
893 "smlal %0, %1, r3, r4\n\t" \
894 "ldmia %2, {r0, r1, r2, r3}\n\t" \
895 "ldr r4, [%3, #32]\n\t" \
896 "smlal %0, %1, r0, r4\n\t" \
897 "ldr r4, [%3, #24]\n\t" \
898 "smlal %0, %1, r1, r4\n\t" \
899 "ldr r4, [%3, #16]\n\t" \
900 "smlal %0, %1, r2, r4\n\t" \
901 "ldr r4, [%3, #8]\n\t" \
902 "smlal %0, %1, r3, r4\n\t" \
903 : "=&r" (lo), "=&r" (hi), "+r" (__p) \
904 : "r" (ptr) \
905 : "r0", "r1", "r2", "r3", "r4"); \
906 } while (0)
908 #define PROD_EVEN_A(hi, lo, f, ptr) \
909 do { \
910 mad_fixed_t *__p = (f); \
911 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
912 "ldr r4, [%3, #0]\n\t" \
913 "smlal %0, %1, r0, r4\n\t" \
914 "ldr r4, [%3, #56]\n\t" \
915 "smlal %0, %1, r1, r4\n\t" \
916 "ldr r4, [%3, #48]\n\t" \
917 "smlal %0, %1, r2, r4\n\t" \
918 "ldr r4, [%3, #40]\n\t" \
919 "smlal %0, %1, r3, r4\n\t" \
920 "ldmia %2, {r0, r1, r2, r3}\n\t" \
921 "ldr r4, [%3, #32]\n\t" \
922 "smlal %0, %1, r0, r4\n\t" \
923 "ldr r4, [%3, #24]\n\t" \
924 "smlal %0, %1, r1, r4\n\t" \
925 "ldr r4, [%3, #16]\n\t" \
926 "smlal %0, %1, r2, r4\n\t" \
927 "ldr r4, [%3, #8]\n\t" \
928 "smlal %0, %1, r3, r4\n\t" \
929 : "+r" (lo), "+r" (hi), "+r" (__p) \
930 : "r" (ptr) \
931 : "r0", "r1", "r2", "r3", "r4"); \
932 } while (0)
934 #define PROD_EVENBACK_0(hi, lo, f, ptr) \
935 do { \
936 mad_fixed_t *__p = (f); \
937 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
938 "ldr r4, [%3, #60]\n\t" \
939 "smull %0, %1, r0, r4\n\t" \
940 "ldr r4, [%3, #68]\n\t" \
941 "smlal %0, %1, r1, r4\n\t" \
942 "ldr r4, [%3, #76]\n\t" \
943 "smlal %0, %1, r2, r4\n\t" \
944 "ldr r4, [%3, #84]\n\t" \
945 "smlal %0, %1, r3, r4\n\t" \
946 "ldmia %2, {r0, r1, r2, r3}\n\t" \
947 "ldr r4, [%3, #92]\n\t" \
948 "smlal %0, %1, r0, r4\n\t" \
949 "ldr r4, [%3, #100]\n\t" \
950 "smlal %0, %1, r1, r4\n\t" \
951 "ldr r4, [%3, #108]\n\t" \
952 "smlal %0, %1, r2, r4\n\t" \
953 "ldr r4, [%3, #116]\n\t" \
954 "smlal %0, %1, r3, r4\n\t" \
955 : "=&r" (lo), "=&r" (hi), "+r" (__p) \
956 : "r" (ptr) \
957 : "r0", "r1", "r2", "r3", "r4"); \
958 } while (0)
960 #define PROD_EVENBACK_A(hi, lo, f, ptr) \
961 do { \
962 mad_fixed_t *__p = (f); \
963 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
964 "ldr r4, [%3, #60]\n\t" \
965 "smlal %0, %1, r0, r4\n\t" \
966 "ldr r4, [%3, #68]\n\t" \
967 "smlal %0, %1, r1, r4\n\t" \
968 "ldr r4, [%3, #76]\n\t" \
969 "smlal %0, %1, r2, r4\n\t" \
970 "ldr r4, [%3, #84]\n\t" \
971 "smlal %0, %1, r3, r4\n\t" \
972 "ldmia %2, {r0, r1, r2, r3}\n\t" \
973 "ldr r4, [%3, #92]\n\t" \
974 "smlal %0, %1, r0, r4\n\t" \
975 "ldr r4, [%3, #100]\n\t" \
976 "smlal %0, %1, r1, r4\n\t" \
977 "ldr r4, [%3, #108]\n\t" \
978 "smlal %0, %1, r2, r4\n\t" \
979 "ldr r4, [%3, #116]\n\t" \
980 "smlal %0, %1, r3, r4\n\t" \
981 : "+r" (lo), "+r" (hi), "+r" (__p) \
982 : "r" (ptr) \
983 : "r0", "r1", "r2", "r3", "r4"); \
984 } while (0)
986 #define PROD_ODDBACK_0(hi, lo, f, ptr) \
987 do { \
988 mad_fixed_t *__p = (f); \
989 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
990 "ldr r4, [%3, #120]\n\t" \
991 "smull %0, %1, r0, r4\n\t" \
992 "ldr r4, [%3, #64]\n\t" \
993 "smlal %0, %1, r1, r4\n\t" \
994 "ldr r4, [%3, #72]\n\t" \
995 "smlal %0, %1, r2, r4\n\t" \
996 "ldr r4, [%3, #80]\n\t" \
997 "smlal %0, %1, r3, r4\n\t" \
998 "ldmia %2, {r0, r1, r2, r3}\n\t" \
999 "ldr r4, [%3, #88]\n\t" \
1000 "smlal %0, %1, r0, r4\n\t" \
1001 "ldr r4, [%3, #96]\n\t" \
1002 "smlal %0, %1, r1, r4\n\t" \
1003 "ldr r4, [%3, #104]\n\t" \
1004 "smlal %0, %1, r2, r4\n\t" \
1005 "ldr r4, [%3, #112]\n\t" \
1006 "smlal %0, %1, r3, r4\n\t" \
1007 : "=&r" (lo), "=&r" (hi), "+r" (__p) \
1008 : "r" (ptr) \
1009 : "r0", "r1", "r2", "r3", "r4"); \
1010 } while (0)
1012 #define PROD_ODDBACK_A(hi, lo, f, ptr) \
1013 do { \
1014 mad_fixed_t *__p = (f); \
1015 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
1016 "ldr r4, [%3, #120]\n\t" \
1017 "smlal %0, %1, r0, r4\n\t" \
1018 "ldr r4, [%3, #64]\n\t" \
1019 "smlal %0, %1, r1, r4\n\t" \
1020 "ldr r4, [%3, #72]\n\t" \
1021 "smlal %0, %1, r2, r4\n\t" \
1022 "ldr r4, [%3, #80]\n\t" \
1023 "smlal %0, %1, r3, r4\n\t" \
1024 "ldmia %2, {r0, r1, r2, r3}\n\t" \
1025 "ldr r4, [%3, #88]\n\t" \
1026 "smlal %0, %1, r0, r4\n\t" \
1027 "ldr r4, [%3, #96]\n\t" \
1028 "smlal %0, %1, r1, r4\n\t" \
1029 "ldr r4, [%3, #104]\n\t" \
1030 "smlal %0, %1, r2, r4\n\t" \
1031 "ldr r4, [%3, #112]\n\t" \
1032 "smlal %0, %1, r3, r4\n\t" \
1033 : "+r" (lo), "+r" (hi), "+r" (__p) \
1034 : "r" (ptr) \
1035 : "r0", "r1", "r2", "r3", "r4"); \
1036 } while (0)
1038 void synth_full1(mad_fixed_t *pcm, mad_fixed_t (*fo)[8], mad_fixed_t (*fe)[8],
1039 mad_fixed_t const (*D0ptr)[32],
1040 mad_fixed_t const (*D1ptr)[32]);
1041 void synth_full2(mad_fixed_t *pcm, mad_fixed_t (*fo)[8], mad_fixed_t (*fe)[8],
1042 mad_fixed_t const (*D0ptr)[32],
1043 mad_fixed_t const (*D1ptr)[32]);
1045 /* This performs slower in IRAM on PP502x and there is no space in
1046 mpegplayer on the PP5002 */
1047 #if !defined(CPU_PP502x) && !(CONFIG_CPU == PP5002 && defined(MPEGPLAYER)) && !defined(TOSHIBA_GIGABEAT_F)
1048 static
1049 void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1050 unsigned int nch, unsigned int ns) ICODE_ATTR;
1051 #endif
1052 static
1053 void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1054 unsigned int nch, unsigned int ns)
1056 int p;
1057 unsigned int phase, ch, s;
1058 mad_fixed_t *pcm, (*filter)[2][2][16][8];
1059 mad_fixed_t const (*sbsample)[36][32];
1060 mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
1061 mad_fixed_t const (*D0ptr)[32], *ptr;
1062 mad_fixed_t const (*D1ptr)[32];
1063 mad_fixed64hi_t hi;
1064 mad_fixed64lo_t lo;
1066 for (ch = 0; ch < nch; ++ch) {
1067 sbsample = &frame->sbsample[ch];
1068 filter = &synth->filter[ch];
1069 phase = synth->phase;
1070 pcm = synth->pcm.samples[ch];
1072 for (s = 0; s < ns; ++s) {
1073 dct32((*sbsample)[s], phase >> 1,
1074 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1076 p = (phase - 1) & 0xf;
1078 /* calculate 32 samples */
1079 fe = &(*filter)[0][ phase & 1][0];
1080 fx = &(*filter)[0][~phase & 1][0];
1081 fo = &(*filter)[1][~phase & 1][0];
1083 D0ptr = (void*)&D[0][ p];
1084 D1ptr = (void*)&D[0][-p];
1086 if(s & 1)
1088 ptr = *D0ptr;
1090 ML0(hi, lo, (*fx)[0], ptr[ 1]);
1091 MLA(hi, lo, (*fx)[1], ptr[15]);
1092 MLA(hi, lo, (*fx)[2], ptr[13]);
1093 MLA(hi, lo, (*fx)[3], ptr[11]);
1094 MLA(hi, lo, (*fx)[4], ptr[ 9]);
1095 MLA(hi, lo, (*fx)[5], ptr[ 7]);
1096 MLA(hi, lo, (*fx)[6], ptr[ 5]);
1097 MLA(hi, lo, (*fx)[7], ptr[ 3]);
1099 PROD_ODD_0(hi, lo, *fx, ptr);
1100 MLN(hi, lo);
1102 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1103 MLA(hi, lo, (*fe)[1], ptr[14]);
1104 MLA(hi, lo, (*fe)[2], ptr[12]);
1105 MLA(hi, lo, (*fe)[3], ptr[10]);
1106 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1107 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1108 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1109 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1111 PROD_EVEN_A(hi, lo, *fe, ptr);
1112 pcm[0] = SHIFT(MLZ(hi, lo));
1113 pcm += 16;
1115 synth_full1(pcm, fo, fe, D0ptr, D1ptr);
1116 D0ptr += 15;
1117 D1ptr += 15;
1118 fo += 15;
1119 fe += 15;
1121 ptr = *(D0ptr + 1);
1122 PROD_ODD_0(hi, lo, *fo, ptr);
1124 ML0(hi, lo, (*fo)[0], ptr[ 1]);
1125 MLA(hi, lo, (*fo)[1], ptr[15]);
1126 MLA(hi, lo, (*fo)[2], ptr[13]);
1127 MLA(hi, lo, (*fo)[3], ptr[11]);
1128 MLA(hi, lo, (*fo)[4], ptr[ 9]);
1129 MLA(hi, lo, (*fo)[5], ptr[ 7]);
1130 MLA(hi, lo, (*fo)[6], ptr[ 5]);
1131 MLA(hi, lo, (*fo)[7], ptr[ 3]);
1133 pcm[0] = SHIFT(-MLZ(hi, lo));
1135 else
1137 ptr = *D0ptr;
1139 ML0(hi, lo, (*fx)[0], ptr[ 0]);
1140 MLA(hi, lo, (*fx)[1], ptr[14]);
1141 MLA(hi, lo, (*fx)[2], ptr[12]);
1142 MLA(hi, lo, (*fx)[3], ptr[10]);
1143 MLA(hi, lo, (*fx)[4], ptr[ 8]);
1144 MLA(hi, lo, (*fx)[5], ptr[ 6]);
1145 MLA(hi, lo, (*fx)[6], ptr[ 4]);
1146 MLA(hi, lo, (*fx)[7], ptr[ 2]);
1148 PROD_EVEN_0(hi, lo, *fx, ptr);
1149 MLN(hi, lo);
1151 MLA(hi, lo, (*fe)[0], ptr[ 1]);
1152 MLA(hi, lo, (*fe)[1], ptr[15]);
1153 MLA(hi, lo, (*fe)[2], ptr[13]);
1154 MLA(hi, lo, (*fe)[3], ptr[11]);
1155 MLA(hi, lo, (*fe)[4], ptr[ 9]);
1156 MLA(hi, lo, (*fe)[5], ptr[ 7]);
1157 MLA(hi, lo, (*fe)[6], ptr[ 5]);
1158 MLA(hi, lo, (*fe)[7], ptr[ 3]);
1160 PROD_ODD_A(hi, lo, *fe, ptr);
1161 pcm[0] = SHIFT(MLZ(hi, lo));
1162 pcm += 16;
1164 synth_full2(pcm, fo, fe, D0ptr, D1ptr);
1165 D0ptr += 15;
1166 D1ptr += 15;
1167 fo += 15;
1168 fe += 15;
1170 ptr = *(D0ptr + 1);
1172 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1173 MLA(hi, lo, (*fo)[1], ptr[14]);
1174 MLA(hi, lo, (*fo)[2], ptr[12]);
1175 MLA(hi, lo, (*fo)[3], ptr[10]);
1176 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1177 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1178 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1179 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1181 PROD_EVEN_0(hi, lo, *fo, ptr);
1182 pcm[0] = SHIFT(-MLZ(hi, lo));
1185 pcm += 16;
1186 phase = (phase + 1) % 16;
1191 # else
1193 static
1194 void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1195 unsigned int nch, unsigned int ns)
1197 int p;
1198 unsigned int phase, ch, s, sb;
1199 mad_fixed_t *pcm, (*filter)[2][2][16][8];
1200 mad_fixed_t const (*sbsample)[36][32];
1201 mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
1202 mad_fixed_t const (*D0ptr)[32], *ptr;
1203 mad_fixed_t const (*D1ptr)[32];
1204 mad_fixed64hi_t hi;
1205 mad_fixed64lo_t lo;
1207 for (ch = 0; ch < nch; ++ch) {
1208 sbsample = &frame->sbsample[ch];
1209 filter = &synth->filter[ch];
1210 phase = synth->phase;
1211 pcm = synth->pcm.samples[ch];
1213 for (s = 0; s < ns; ++s) {
1214 dct32((*sbsample)[s], phase >> 1,
1215 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1217 p = (phase - 1) & 0xf;
1219 /* calculate 32 samples */
1220 fe = &(*filter)[0][ phase & 1][0];
1221 fx = &(*filter)[0][~phase & 1][0];
1222 fo = &(*filter)[1][~phase & 1][0];
1224 D0ptr = (void*)&D[0][ p];
1225 D1ptr = (void*)&D[0][-p];
1227 if(s & 1)
1229 ptr = *D0ptr;
1230 ML0(hi, lo, (*fx)[0], ptr[ 1]);
1231 MLA(hi, lo, (*fx)[1], ptr[15]);
1232 MLA(hi, lo, (*fx)[2], ptr[13]);
1233 MLA(hi, lo, (*fx)[3], ptr[11]);
1234 MLA(hi, lo, (*fx)[4], ptr[ 9]);
1235 MLA(hi, lo, (*fx)[5], ptr[ 7]);
1236 MLA(hi, lo, (*fx)[6], ptr[ 5]);
1237 MLA(hi, lo, (*fx)[7], ptr[ 3]);
1238 MLN(hi, lo);
1239 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1240 MLA(hi, lo, (*fe)[1], ptr[14]);
1241 MLA(hi, lo, (*fe)[2], ptr[12]);
1242 MLA(hi, lo, (*fe)[3], ptr[10]);
1243 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1244 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1245 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1246 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1247 pcm[0] = SHIFT(MLZ(hi, lo));
1248 pcm += 16;
1250 for (sb = 15; sb; sb--, fo++)
1252 ++fe;
1253 ++D0ptr;
1254 ++D1ptr;
1256 /* D[32 - sb][i] == -D[sb][31 - i] */
1257 ptr = *D0ptr;
1258 ML0(hi, lo, (*fo)[0], ptr[ 1]);
1259 MLA(hi, lo, (*fo)[1], ptr[15]);
1260 MLA(hi, lo, (*fo)[2], ptr[13]);
1261 MLA(hi, lo, (*fo)[3], ptr[11]);
1262 MLA(hi, lo, (*fo)[4], ptr[ 9]);
1263 MLA(hi, lo, (*fo)[5], ptr[ 7]);
1264 MLA(hi, lo, (*fo)[6], ptr[ 5]);
1265 MLA(hi, lo, (*fo)[7], ptr[ 3]);
1266 MLN(hi, lo);
1267 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1268 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1269 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1270 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1271 MLA(hi, lo, (*fe)[3], ptr[10]);
1272 MLA(hi, lo, (*fe)[2], ptr[12]);
1273 MLA(hi, lo, (*fe)[1], ptr[14]);
1274 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1275 pcm[-sb] = SHIFT(MLZ(hi, lo));
1277 ptr = *D1ptr;
1278 ML0(hi, lo, (*fe)[0], ptr[31 - 16]);
1279 MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
1280 MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
1281 MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
1282 MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
1283 MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
1284 MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
1285 MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
1286 MLA(hi, lo, (*fo)[7], ptr[31 - 3]);
1287 MLA(hi, lo, (*fo)[6], ptr[31 - 5]);
1288 MLA(hi, lo, (*fo)[5], ptr[31 - 7]);
1289 MLA(hi, lo, (*fo)[4], ptr[31 - 9]);
1290 MLA(hi, lo, (*fo)[3], ptr[31 - 11]);
1291 MLA(hi, lo, (*fo)[2], ptr[31 - 13]);
1292 MLA(hi, lo, (*fo)[1], ptr[31 - 15]);
1293 MLA(hi, lo, (*fo)[0], ptr[31 - 1]);
1294 pcm[sb] = SHIFT(MLZ(hi, lo));
1297 ptr = *(D0ptr + 1);
1298 ML0(hi, lo, (*fo)[0], ptr[ 1]);
1299 MLA(hi, lo, (*fo)[1], ptr[15]);
1300 MLA(hi, lo, (*fo)[2], ptr[13]);
1301 MLA(hi, lo, (*fo)[3], ptr[11]);
1302 MLA(hi, lo, (*fo)[4], ptr[ 9]);
1303 MLA(hi, lo, (*fo)[5], ptr[ 7]);
1304 MLA(hi, lo, (*fo)[6], ptr[ 5]);
1305 MLA(hi, lo, (*fo)[7], ptr[ 3]);
1306 pcm[0] = SHIFT(-MLZ(hi, lo));
1308 else
1310 ptr = *D0ptr;
1311 ML0(hi, lo, (*fx)[0], ptr[ 0]);
1312 MLA(hi, lo, (*fx)[1], ptr[14]);
1313 MLA(hi, lo, (*fx)[2], ptr[12]);
1314 MLA(hi, lo, (*fx)[3], ptr[10]);
1315 MLA(hi, lo, (*fx)[4], ptr[ 8]);
1316 MLA(hi, lo, (*fx)[5], ptr[ 6]);
1317 MLA(hi, lo, (*fx)[6], ptr[ 4]);
1318 MLA(hi, lo, (*fx)[7], ptr[ 2]);
1319 MLN(hi, lo);
1320 MLA(hi, lo, (*fe)[0], ptr[ 1]);
1321 MLA(hi, lo, (*fe)[1], ptr[15]);
1322 MLA(hi, lo, (*fe)[2], ptr[13]);
1323 MLA(hi, lo, (*fe)[3], ptr[11]);
1324 MLA(hi, lo, (*fe)[4], ptr[ 9]);
1325 MLA(hi, lo, (*fe)[5], ptr[ 7]);
1326 MLA(hi, lo, (*fe)[6], ptr[ 5]);
1327 MLA(hi, lo, (*fe)[7], ptr[ 3]);
1328 pcm[0] = SHIFT(MLZ(hi, lo));
1329 pcm += 16;
1331 for (sb = 15; sb; sb--, fo++)
1333 ++fe;
1334 ++D0ptr;
1335 ++D1ptr;
1337 /* D[32 - sb][i] == -D[sb][31 - i] */
1338 ptr = *D0ptr;
1339 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1340 MLA(hi, lo, (*fo)[1], ptr[14]);
1341 MLA(hi, lo, (*fo)[2], ptr[12]);
1342 MLA(hi, lo, (*fo)[3], ptr[10]);
1343 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1344 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1345 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1346 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1347 MLN(hi, lo);
1348 MLA(hi, lo, (*fe)[7], ptr[ 3]);
1349 MLA(hi, lo, (*fe)[6], ptr[ 5]);
1350 MLA(hi, lo, (*fe)[5], ptr[ 7]);
1351 MLA(hi, lo, (*fe)[4], ptr[ 9]);
1352 MLA(hi, lo, (*fe)[3], ptr[11]);
1353 MLA(hi, lo, (*fe)[2], ptr[13]);
1354 MLA(hi, lo, (*fe)[1], ptr[15]);
1355 MLA(hi, lo, (*fe)[0], ptr[ 1]);
1356 pcm[-sb] = SHIFT(MLZ(hi, lo));
1358 ptr = *D1ptr;
1359 ML0(hi, lo, (*fe)[0], ptr[31 - 1]);
1360 MLA(hi, lo, (*fe)[1], ptr[31 - 15]);
1361 MLA(hi, lo, (*fe)[2], ptr[31 - 13]);
1362 MLA(hi, lo, (*fe)[3], ptr[31 - 11]);
1363 MLA(hi, lo, (*fe)[4], ptr[31 - 9]);
1364 MLA(hi, lo, (*fe)[5], ptr[31 - 7]);
1365 MLA(hi, lo, (*fe)[6], ptr[31 - 5]);
1366 MLA(hi, lo, (*fe)[7], ptr[31 - 3]);
1367 MLA(hi, lo, (*fo)[7], ptr[31 - 2]);
1368 MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
1369 MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
1370 MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
1371 MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
1372 MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
1373 MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
1374 MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
1375 pcm[sb] = SHIFT(MLZ(hi, lo));
1378 ptr = *(D0ptr + 1);
1379 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1380 MLA(hi, lo, (*fo)[1], ptr[14]);
1381 MLA(hi, lo, (*fo)[2], ptr[12]);
1382 MLA(hi, lo, (*fo)[3], ptr[10]);
1383 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1384 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1385 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1386 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1387 pcm[0] = SHIFT(-MLZ(hi, lo));
1390 pcm += 16;
1391 phase = (phase + 1) % 16;
1396 # endif
1397 # endif
1400 * NAME: synth->half()
1401 * DESCRIPTION: perform half frequency PCM synthesis
1403 static
1404 void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
1405 unsigned int nch, unsigned int ns)
1407 unsigned int phase, ch, s, sb, pe, po;
1408 mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8];
1409 mad_fixed_t const (*sbsample)[36][32];
1410 register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
1411 register mad_fixed_t const (*Dptr)[32], *ptr;
1412 register mad_fixed64hi_t hi;
1413 register mad_fixed64lo_t lo;
1415 for (ch = 0; ch < nch; ++ch) {
1416 sbsample = &frame->sbsample[ch];
1417 filter = &synth->filter[ch];
1418 phase = synth->phase;
1419 pcm1 = synth->pcm.samples[ch];
1421 for (s = 0; s < ns; ++s) {
1422 dct32((*sbsample)[s], phase >> 1,
1423 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1425 pe = phase & ~1;
1426 po = ((phase - 1) & 0xf) | 1;
1428 /* calculate 16 samples */
1430 fe = &(*filter)[0][ phase & 1][0];
1431 fx = &(*filter)[0][~phase & 1][0];
1432 fo = &(*filter)[1][~phase & 1][0];
1434 Dptr = &D[0];
1436 ptr = *Dptr + po;
1437 ML0(hi, lo, (*fx)[0], ptr[ 0]);
1438 MLA(hi, lo, (*fx)[1], ptr[14]);
1439 MLA(hi, lo, (*fx)[2], ptr[12]);
1440 MLA(hi, lo, (*fx)[3], ptr[10]);
1441 MLA(hi, lo, (*fx)[4], ptr[ 8]);
1442 MLA(hi, lo, (*fx)[5], ptr[ 6]);
1443 MLA(hi, lo, (*fx)[6], ptr[ 4]);
1444 MLA(hi, lo, (*fx)[7], ptr[ 2]);
1445 MLN(hi, lo);
1447 ptr = *Dptr + pe;
1448 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1449 MLA(hi, lo, (*fe)[1], ptr[14]);
1450 MLA(hi, lo, (*fe)[2], ptr[12]);
1451 MLA(hi, lo, (*fe)[3], ptr[10]);
1452 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1453 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1454 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1455 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1457 *pcm1++ = SHIFT(MLZ(hi, lo));
1459 pcm2 = pcm1 + 14;
1461 for (sb = 1; sb < 16; ++sb) {
1462 ++fe;
1463 ++Dptr;
1465 /* D[32 - sb][i] == -D[sb][31 - i] */
1467 if (!(sb & 1)) {
1468 ptr = *Dptr + po;
1469 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1470 MLA(hi, lo, (*fo)[1], ptr[14]);
1471 MLA(hi, lo, (*fo)[2], ptr[12]);
1472 MLA(hi, lo, (*fo)[3], ptr[10]);
1473 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1474 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1475 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1476 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1477 MLN(hi, lo);
1479 ptr = *Dptr + pe;
1480 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1481 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1482 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1483 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1484 MLA(hi, lo, (*fe)[3], ptr[10]);
1485 MLA(hi, lo, (*fe)[2], ptr[12]);
1486 MLA(hi, lo, (*fe)[1], ptr[14]);
1487 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1489 *pcm1++ = SHIFT(MLZ(hi, lo));
1491 ptr = *Dptr - po;
1492 ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
1493 MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
1494 MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
1495 MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
1496 MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
1497 MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
1498 MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
1499 MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
1501 ptr = *Dptr - pe;
1502 MLA(hi, lo, (*fe)[0], ptr[31 - 16]);
1503 MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
1504 MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
1505 MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
1506 MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
1507 MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
1508 MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
1509 MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
1511 *pcm2-- = SHIFT(MLZ(hi, lo));
1514 ++fo;
1517 ++Dptr;
1519 ptr = *Dptr + po;
1520 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1521 MLA(hi, lo, (*fo)[1], ptr[14]);
1522 MLA(hi, lo, (*fo)[2], ptr[12]);
1523 MLA(hi, lo, (*fo)[3], ptr[10]);
1524 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1525 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1526 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1527 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1529 *pcm1 = SHIFT(-MLZ(hi, lo));
1530 pcm1 += 8;
1532 phase = (phase + 1) % 16;
1538 * NAME: synth->frame()
1539 * DESCRIPTION: perform PCM synthesis of frame subband samples
1541 void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame)
1543 unsigned int nch, ns;
1544 void (*synth_frame)(struct mad_synth *, struct mad_frame const *,
1545 unsigned int, unsigned int);
1547 nch = MAD_NCHANNELS(&frame->header);
1548 ns = MAD_NSBSAMPLES(&frame->header);
1550 synth->pcm.samplerate = frame->header.samplerate;
1551 synth->pcm.channels = nch;
1552 synth->pcm.length = 32 * ns;
1554 synth_frame = synth_full;
1556 if (frame->options & MAD_OPTION_HALFSAMPLERATE) {
1557 synth->pcm.samplerate /= 2;
1558 synth->pcm.length /= 2;
1560 synth_frame = synth_half;
1563 synth_frame(synth, frame, nch, ns);
1565 synth->phase = (synth->phase + ns) % 16;