Forgot to remove wps_data.remove_wps in checkwps too.
[kugel-rb.git] / apps / codecs / libmad / synth.c
blobbc7ac742fe302306906327e19ed8cea9dfed7cf0
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 int sb;
593 unsigned int phase, ch, s, p;
594 mad_fixed_t *pcm, (*filter)[2][2][16][8];
595 mad_fixed_t (*sbsample)[36][32];
596 mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
597 mad_fixed_t const (*D0ptr)[32];
598 mad_fixed_t const (*D1ptr)[32];
599 mad_fixed64hi_t hi0, hi1;
601 for (ch = 0; ch < nch; ++ch) {
602 sbsample = &(*frame->sbsample_prev)[ch];
603 filter = &synth->filter[ch];
604 phase = synth->phase;
605 pcm = synth->pcm.samples[ch];
607 for (s = 0; s < ns; ++s) {
608 dct32((*sbsample)[s], phase >> 1,
609 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
611 p = (phase - 1) & 0xf;
613 /* calculate 32 samples */
614 fe = &(*filter)[0][ phase & 1][0];
615 fx = &(*filter)[0][~phase & 1][0];
616 fo = &(*filter)[1][~phase & 1][0];
618 D0ptr = (void*)&D[0][ p];
619 D1ptr = (void*)&D[0][-p];
621 if(s & 1)
623 asm volatile(
624 "movem.l (%1), %%d0-%%d7\n\t"
625 "move.l 4(%2), %%a5\n\t"
626 "msac.l %%d0, %%a5, 60(%2), %%a5, %%acc0\n\t"
627 "msac.l %%d1, %%a5, 52(%2), %%a5, %%acc0\n\t"
628 "msac.l %%d2, %%a5, 44(%2), %%a5, %%acc0\n\t"
629 "msac.l %%d3, %%a5, 36(%2), %%a5, %%acc0\n\t"
630 "msac.l %%d4, %%a5, 28(%2), %%a5, %%acc0\n\t"
631 "msac.l %%d5, %%a5, 20(%2), %%a5, %%acc0\n\t"
632 "msac.l %%d6, %%a5, 12(%2), %%a5, %%acc0\n\t"
633 "msac.l %%d7, %%a5, (%2), %%a5, %%acc0\n\t"
635 "movem.l (%3), %%d0-%%d7\n\t"
636 "mac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
637 "mac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
638 "mac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
639 "mac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
640 "mac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
641 "mac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
642 "mac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
643 "mac.l %%d7, %%a5, %%acc0\n\t"
644 "movclr.l %%acc0, %0\n\t"
645 : "=r" (hi0) : "a" (*fx), "a" (*D0ptr), "a" (*fe)
646 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
648 pcm[0] = hi0 << 3; /* shift result to libmad's fixed point format */
649 pcm += 16;
651 for (sb = 15; sb; sb--, fo++) {
652 ++fe;
653 ++D0ptr;
654 ++D1ptr;
656 /* D[32 - sb][i] == -D[sb][31 - i] */
657 asm volatile (
658 "movem.l (%0), %%d0-%%d7\n\t"
659 "move.l 4(%2), %%a5\n\t"
660 "msac.l %%d0, %%a5, 60(%2), %%a5, %%acc0\n\t"
661 "msac.l %%d1, %%a5, 52(%2), %%a5, %%acc0\n\t"
662 "msac.l %%d2, %%a5, 44(%2), %%a5, %%acc0\n\t"
663 "msac.l %%d3, %%a5, 36(%2), %%a5, %%acc0\n\t"
664 "msac.l %%d4, %%a5, 28(%2), %%a5, %%acc0\n\t"
665 "msac.l %%d5, %%a5, 20(%2), %%a5, %%acc0\n\t"
666 "msac.l %%d6, %%a5, 12(%2), %%a5, %%acc0\n\t"
667 "msac.l %%d7, %%a5, 112(%3), %%a5, %%acc0\n\t"
668 "mac.l %%d7, %%a5, 104(%3), %%a5, %%acc1\n\t"
669 "mac.l %%d6, %%a5, 96(%3), %%a5, %%acc1\n\t"
670 "mac.l %%d5, %%a5, 88(%3), %%a5, %%acc1\n\t"
671 "mac.l %%d4, %%a5, 80(%3), %%a5, %%acc1\n\t"
672 "mac.l %%d3, %%a5, 72(%3), %%a5, %%acc1\n\t"
673 "mac.l %%d2, %%a5, 64(%3), %%a5, %%acc1\n\t"
674 "mac.l %%d1, %%a5, 120(%3), %%a5, %%acc1\n\t"
675 "mac.l %%d0, %%a5, 8(%2), %%a5, %%acc1\n\t"
676 "movem.l (%1), %%d0-%%d7\n\t"
677 "mac.l %%d7, %%a5, 16(%2), %%a5, %%acc0\n\t"
678 "mac.l %%d6, %%a5, 24(%2), %%a5, %%acc0\n\t"
679 "mac.l %%d5, %%a5, 32(%2), %%a5, %%acc0\n\t"
680 "mac.l %%d4, %%a5, 40(%2), %%a5, %%acc0\n\t"
681 "mac.l %%d3, %%a5, 48(%2), %%a5, %%acc0\n\t"
682 "mac.l %%d2, %%a5, 56(%2), %%a5, %%acc0\n\t"
683 "mac.l %%d1, %%a5, (%2), %%a5, %%acc0\n\t"
684 "mac.l %%d0, %%a5, 60(%3), %%a5, %%acc0\n\t"
685 "mac.l %%d0, %%a5, 68(%3), %%a5, %%acc1\n\t"
686 "mac.l %%d1, %%a5, 76(%3), %%a5, %%acc1\n\t"
687 "mac.l %%d2, %%a5, 84(%3), %%a5, %%acc1\n\t"
688 "mac.l %%d3, %%a5, 92(%3), %%a5, %%acc1\n\t"
689 "mac.l %%d4, %%a5, 100(%3), %%a5, %%acc1\n\t"
690 "mac.l %%d5, %%a5, 108(%3), %%a5, %%acc1\n\t"
691 "mac.l %%d6, %%a5, 116(%3), %%a5, %%acc1\n\t"
692 "mac.l %%d7, %%a5, %%acc1\n\t"
693 : : "a" (*fo), "a" (*fe), "a" (*D0ptr), "a" (*D1ptr)
694 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
696 asm volatile(
697 "movclr.l %%acc0, %0\n\t"
698 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) );
700 pcm[-sb] = hi0 << 3;
701 pcm[ sb] = hi1 << 3;
704 ++D0ptr;
705 asm volatile(
706 "movem.l (%1), %%d0-%%d7\n\t"
707 "move.l 4(%2), %%a5\n\t"
708 "mac.l %%d0, %%a5, 60(%2), %%a5, %%acc0\n\t"
709 "mac.l %%d1, %%a5, 52(%2), %%a5, %%acc0\n\t"
710 "mac.l %%d2, %%a5, 44(%2), %%a5, %%acc0\n\t"
711 "mac.l %%d3, %%a5, 36(%2), %%a5, %%acc0\n\t"
712 "mac.l %%d4, %%a5, 28(%2), %%a5, %%acc0\n\t"
713 "mac.l %%d5, %%a5, 20(%2), %%a5, %%acc0\n\t"
714 "mac.l %%d6, %%a5, 12(%2), %%a5, %%acc0\n\t"
715 "mac.l %%d7, %%a5, %%acc0\n\t"
716 "movclr.l %%acc0, %0\n\t"
717 : "=r" (hi0) : "a" (*fo), "a" (*D0ptr)
718 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
720 pcm[0] = -(hi0 << 3);
722 else
724 asm volatile(
725 "movem.l (%1), %%d0-%%d7\n\t"
726 "move.l (%2), %%a5\n\t"
727 "msac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
728 "msac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
729 "msac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
730 "msac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
731 "msac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
732 "msac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
733 "msac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
734 "msac.l %%d7, %%a5, 4(%2), %%a5, %%acc0\n\t"
736 "movem.l (%3), %%d0-%%d7\n\t"
737 "mac.l %%d0, %%a5, 60(%2), %%a5, %%acc0\n\t"
738 "mac.l %%d1, %%a5, 52(%2), %%a5, %%acc0\n\t"
739 "mac.l %%d2, %%a5, 44(%2), %%a5, %%acc0\n\t"
740 "mac.l %%d3, %%a5, 36(%2), %%a5, %%acc0\n\t"
741 "mac.l %%d4, %%a5, 28(%2), %%a5, %%acc0\n\t"
742 "mac.l %%d5, %%a5, 20(%2), %%a5, %%acc0\n\t"
743 "mac.l %%d6, %%a5, 12(%2), %%a5, %%acc0\n\t"
744 "mac.l %%d7, %%a5, %%acc0\n\t"
745 "movclr.l %%acc0, %0\n\t"
746 : "=r" (hi0) : "a" (*fx), "a" (*D0ptr), "a" (*fe)
747 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
749 pcm[0] = hi0 << 3; /* shift result to libmad's fixed point format */
750 pcm += 16;
752 for (sb = 15; sb; sb--, fo++) {
753 ++fe;
754 ++D0ptr;
755 ++D1ptr;
757 /* D[32 - sb][i] == -D[sb][31 - i] */
758 asm volatile (
759 "movem.l (%0), %%d0-%%d7\n\t"
760 "move.l (%2), %%a5\n\t"
761 "msac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
762 "msac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
763 "msac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
764 "msac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
765 "msac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
766 "msac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
767 "msac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
768 "msac.l %%d7, %%a5, 116(%3), %%a5, %%acc0\n\t"
769 "mac.l %%d7, %%a5, 108(%3), %%a5, %%acc1\n\t"
770 "mac.l %%d6, %%a5, 100(%3), %%a5, %%acc1\n\t"
771 "mac.l %%d5, %%a5, 92(%3), %%a5, %%acc1\n\t"
772 "mac.l %%d4, %%a5, 84(%3), %%a5, %%acc1\n\t"
773 "mac.l %%d3, %%a5, 76(%3), %%a5, %%acc1\n\t"
774 "mac.l %%d2, %%a5, 68(%3), %%a5, %%acc1\n\t"
775 "mac.l %%d1, %%a5, 60(%3), %%a5, %%acc1\n\t"
776 "mac.l %%d0, %%a5, 12(%2), %%a5, %%acc1\n\t"
777 "movem.l (%1), %%d0-%%d7\n\t"
778 "mac.l %%d7, %%a5, 20(%2), %%a5, %%acc0\n\t"
779 "mac.l %%d6, %%a5, 28(%2), %%a5, %%acc0\n\t"
780 "mac.l %%d5, %%a5, 36(%2), %%a5, %%acc0\n\t"
781 "mac.l %%d4, %%a5, 44(%2), %%a5, %%acc0\n\t"
782 "mac.l %%d3, %%a5, 52(%2), %%a5, %%acc0\n\t"
783 "mac.l %%d2, %%a5, 60(%2), %%a5, %%acc0\n\t"
784 "mac.l %%d1, %%a5, 4(%2), %%a5, %%acc0\n\t"
785 "mac.l %%d0, %%a5, 120(%3), %%a5, %%acc0\n\t"
786 "mac.l %%d0, %%a5, 64(%3), %%a5, %%acc1\n\t"
787 "mac.l %%d1, %%a5, 72(%3), %%a5, %%acc1\n\t"
788 "mac.l %%d2, %%a5, 80(%3), %%a5, %%acc1\n\t"
789 "mac.l %%d3, %%a5, 88(%3), %%a5, %%acc1\n\t"
790 "mac.l %%d4, %%a5, 96(%3), %%a5, %%acc1\n\t"
791 "mac.l %%d5, %%a5, 104(%3), %%a5, %%acc1\n\t"
792 "mac.l %%d6, %%a5, 112(%3), %%a5, %%acc1\n\t"
793 "mac.l %%d7, %%a5, %%acc1\n\t"
794 : : "a" (*fo), "a" (*fe), "a" (*D0ptr), "a" (*D1ptr)
795 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
797 asm volatile(
798 "movclr.l %%acc0, %0\n\t"
799 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) );
801 pcm[-sb] = hi0 << 3;
802 pcm[ sb] = hi1 << 3;
805 ++D0ptr;
806 asm volatile(
807 "movem.l (%1), %%d0-%%d7\n\t"
808 "move.l (%2), %%a5\n\t"
809 "mac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
810 "mac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
811 "mac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
812 "mac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
813 "mac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
814 "mac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
815 "mac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
816 "mac.l %%d7, %%a5, %%acc0\n\t"
817 "movclr.l %%acc0, %0\n\t"
818 : "=r" (hi0) : "a" (*fo), "a" (*D0ptr)
819 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
821 pcm[0] = -(hi0 << 3);
823 pcm += 16;
824 phase = (phase + 1) % 16;
829 #elif defined(FPM_ARM)
831 #define PROD_ODD_0(hi, lo, f, ptr) \
832 do { \
833 mad_fixed_t *__p = (f); \
834 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
835 "ldr r4, [%3, #4]\n\t" \
836 "smull %0, %1, r0, r4\n\t" \
837 "ldr r4, [%3, #60]\n\t" \
838 "smlal %0, %1, r1, r4\n\t" \
839 "ldr r4, [%3, #52]\n\t" \
840 "smlal %0, %1, r2, r4\n\t" \
841 "ldr r4, [%3, #44]\n\t" \
842 "smlal %0, %1, r3, r4\n\t" \
843 "ldmia %2, {r0, r1, r2, r3}\n\t" \
844 "ldr r4, [%3, #36]\n\t" \
845 "smlal %0, %1, r0, r4\n\t" \
846 "ldr r4, [%3, #28]\n\t" \
847 "smlal %0, %1, r1, r4\n\t" \
848 "ldr r4, [%3, #20]\n\t" \
849 "smlal %0, %1, r2, r4\n\t" \
850 "ldr r4, [%3, #12]\n\t" \
851 "smlal %0, %1, r3, r4\n\t" \
852 : "=&r" (lo), "=&r" (hi), "+r" (__p) \
853 : "r" (ptr) \
854 : "r0", "r1", "r2", "r3", "r4"); \
855 } while (0)
857 #define PROD_ODD_A(hi, lo, f, ptr) \
858 do { \
859 mad_fixed_t *__p = (f); \
860 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
861 "ldr r4, [%3, #4]\n\t" \
862 "smlal %0, %1, r0, r4\n\t" \
863 "ldr r4, [%3, #60]\n\t" \
864 "smlal %0, %1, r1, r4\n\t" \
865 "ldr r4, [%3, #52]\n\t" \
866 "smlal %0, %1, r2, r4\n\t" \
867 "ldr r4, [%3, #44]\n\t" \
868 "smlal %0, %1, r3, r4\n\t" \
869 "ldmia %2, {r0, r1, r2, r3}\n\t" \
870 "ldr r4, [%3, #36]\n\t" \
871 "smlal %0, %1, r0, r4\n\t" \
872 "ldr r4, [%3, #28]\n\t" \
873 "smlal %0, %1, r1, r4\n\t" \
874 "ldr r4, [%3, #20]\n\t" \
875 "smlal %0, %1, r2, r4\n\t" \
876 "ldr r4, [%3, #12]\n\t" \
877 "smlal %0, %1, r3, r4\n\t" \
878 : "+r" (lo), "+r" (hi), "+r" (__p) \
879 : "r" (ptr) \
880 : "r0", "r1", "r2", "r3", "r4"); \
881 } while (0)
883 #define PROD_EVEN_0(hi, lo, f, ptr) \
884 do { \
885 mad_fixed_t *__p = (f); \
886 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
887 "ldr r4, [%3, #0]\n\t" \
888 "smull %0, %1, r0, r4\n\t" \
889 "ldr r4, [%3, #56]\n\t" \
890 "smlal %0, %1, r1, r4\n\t" \
891 "ldr r4, [%3, #48]\n\t" \
892 "smlal %0, %1, r2, r4\n\t" \
893 "ldr r4, [%3, #40]\n\t" \
894 "smlal %0, %1, r3, r4\n\t" \
895 "ldmia %2, {r0, r1, r2, r3}\n\t" \
896 "ldr r4, [%3, #32]\n\t" \
897 "smlal %0, %1, r0, r4\n\t" \
898 "ldr r4, [%3, #24]\n\t" \
899 "smlal %0, %1, r1, r4\n\t" \
900 "ldr r4, [%3, #16]\n\t" \
901 "smlal %0, %1, r2, r4\n\t" \
902 "ldr r4, [%3, #8]\n\t" \
903 "smlal %0, %1, r3, r4\n\t" \
904 : "=&r" (lo), "=&r" (hi), "+r" (__p) \
905 : "r" (ptr) \
906 : "r0", "r1", "r2", "r3", "r4"); \
907 } while (0)
909 #define PROD_EVEN_A(hi, lo, f, ptr) \
910 do { \
911 mad_fixed_t *__p = (f); \
912 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
913 "ldr r4, [%3, #0]\n\t" \
914 "smlal %0, %1, r0, r4\n\t" \
915 "ldr r4, [%3, #56]\n\t" \
916 "smlal %0, %1, r1, r4\n\t" \
917 "ldr r4, [%3, #48]\n\t" \
918 "smlal %0, %1, r2, r4\n\t" \
919 "ldr r4, [%3, #40]\n\t" \
920 "smlal %0, %1, r3, r4\n\t" \
921 "ldmia %2, {r0, r1, r2, r3}\n\t" \
922 "ldr r4, [%3, #32]\n\t" \
923 "smlal %0, %1, r0, r4\n\t" \
924 "ldr r4, [%3, #24]\n\t" \
925 "smlal %0, %1, r1, r4\n\t" \
926 "ldr r4, [%3, #16]\n\t" \
927 "smlal %0, %1, r2, r4\n\t" \
928 "ldr r4, [%3, #8]\n\t" \
929 "smlal %0, %1, r3, r4\n\t" \
930 : "+r" (lo), "+r" (hi), "+r" (__p) \
931 : "r" (ptr) \
932 : "r0", "r1", "r2", "r3", "r4"); \
933 } while (0)
935 #define PROD_EVENBACK_0(hi, lo, f, ptr) \
936 do { \
937 mad_fixed_t *__p = (f); \
938 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
939 "ldr r4, [%3, #60]\n\t" \
940 "smull %0, %1, r0, r4\n\t" \
941 "ldr r4, [%3, #68]\n\t" \
942 "smlal %0, %1, r1, r4\n\t" \
943 "ldr r4, [%3, #76]\n\t" \
944 "smlal %0, %1, r2, r4\n\t" \
945 "ldr r4, [%3, #84]\n\t" \
946 "smlal %0, %1, r3, r4\n\t" \
947 "ldmia %2, {r0, r1, r2, r3}\n\t" \
948 "ldr r4, [%3, #92]\n\t" \
949 "smlal %0, %1, r0, r4\n\t" \
950 "ldr r4, [%3, #100]\n\t" \
951 "smlal %0, %1, r1, r4\n\t" \
952 "ldr r4, [%3, #108]\n\t" \
953 "smlal %0, %1, r2, r4\n\t" \
954 "ldr r4, [%3, #116]\n\t" \
955 "smlal %0, %1, r3, r4\n\t" \
956 : "=&r" (lo), "=&r" (hi), "+r" (__p) \
957 : "r" (ptr) \
958 : "r0", "r1", "r2", "r3", "r4"); \
959 } while (0)
961 #define PROD_EVENBACK_A(hi, lo, f, ptr) \
962 do { \
963 mad_fixed_t *__p = (f); \
964 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
965 "ldr r4, [%3, #60]\n\t" \
966 "smlal %0, %1, r0, r4\n\t" \
967 "ldr r4, [%3, #68]\n\t" \
968 "smlal %0, %1, r1, r4\n\t" \
969 "ldr r4, [%3, #76]\n\t" \
970 "smlal %0, %1, r2, r4\n\t" \
971 "ldr r4, [%3, #84]\n\t" \
972 "smlal %0, %1, r3, r4\n\t" \
973 "ldmia %2, {r0, r1, r2, r3}\n\t" \
974 "ldr r4, [%3, #92]\n\t" \
975 "smlal %0, %1, r0, r4\n\t" \
976 "ldr r4, [%3, #100]\n\t" \
977 "smlal %0, %1, r1, r4\n\t" \
978 "ldr r4, [%3, #108]\n\t" \
979 "smlal %0, %1, r2, r4\n\t" \
980 "ldr r4, [%3, #116]\n\t" \
981 "smlal %0, %1, r3, r4\n\t" \
982 : "+r" (lo), "+r" (hi), "+r" (__p) \
983 : "r" (ptr) \
984 : "r0", "r1", "r2", "r3", "r4"); \
985 } while (0)
987 #define PROD_ODDBACK_0(hi, lo, f, ptr) \
988 do { \
989 mad_fixed_t *__p = (f); \
990 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
991 "ldr r4, [%3, #120]\n\t" \
992 "smull %0, %1, r0, r4\n\t" \
993 "ldr r4, [%3, #64]\n\t" \
994 "smlal %0, %1, r1, r4\n\t" \
995 "ldr r4, [%3, #72]\n\t" \
996 "smlal %0, %1, r2, r4\n\t" \
997 "ldr r4, [%3, #80]\n\t" \
998 "smlal %0, %1, r3, r4\n\t" \
999 "ldmia %2, {r0, r1, r2, r3}\n\t" \
1000 "ldr r4, [%3, #88]\n\t" \
1001 "smlal %0, %1, r0, r4\n\t" \
1002 "ldr r4, [%3, #96]\n\t" \
1003 "smlal %0, %1, r1, r4\n\t" \
1004 "ldr r4, [%3, #104]\n\t" \
1005 "smlal %0, %1, r2, r4\n\t" \
1006 "ldr r4, [%3, #112]\n\t" \
1007 "smlal %0, %1, r3, r4\n\t" \
1008 : "=&r" (lo), "=&r" (hi), "+r" (__p) \
1009 : "r" (ptr) \
1010 : "r0", "r1", "r2", "r3", "r4"); \
1011 } while (0)
1013 #define PROD_ODDBACK_A(hi, lo, f, ptr) \
1014 do { \
1015 mad_fixed_t *__p = (f); \
1016 asm("ldmia %2!, {r0, r1, r2, r3}\n\t" \
1017 "ldr r4, [%3, #120]\n\t" \
1018 "smlal %0, %1, r0, r4\n\t" \
1019 "ldr r4, [%3, #64]\n\t" \
1020 "smlal %0, %1, r1, r4\n\t" \
1021 "ldr r4, [%3, #72]\n\t" \
1022 "smlal %0, %1, r2, r4\n\t" \
1023 "ldr r4, [%3, #80]\n\t" \
1024 "smlal %0, %1, r3, r4\n\t" \
1025 "ldmia %2, {r0, r1, r2, r3}\n\t" \
1026 "ldr r4, [%3, #88]\n\t" \
1027 "smlal %0, %1, r0, r4\n\t" \
1028 "ldr r4, [%3, #96]\n\t" \
1029 "smlal %0, %1, r1, r4\n\t" \
1030 "ldr r4, [%3, #104]\n\t" \
1031 "smlal %0, %1, r2, r4\n\t" \
1032 "ldr r4, [%3, #112]\n\t" \
1033 "smlal %0, %1, r3, r4\n\t" \
1034 : "+r" (lo), "+r" (hi), "+r" (__p) \
1035 : "r" (ptr) \
1036 : "r0", "r1", "r2", "r3", "r4"); \
1037 } while (0)
1039 void synth_full1(mad_fixed_t *pcm, mad_fixed_t (*fo)[8], mad_fixed_t (*fe)[8],
1040 mad_fixed_t const (*D0ptr)[32],
1041 mad_fixed_t const (*D1ptr)[32]);
1042 void synth_full2(mad_fixed_t *pcm, mad_fixed_t (*fo)[8], mad_fixed_t (*fe)[8],
1043 mad_fixed_t const (*D0ptr)[32],
1044 mad_fixed_t const (*D1ptr)[32]);
1046 static
1047 void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1048 unsigned int nch, unsigned int ns) ICODE_ATTR_MPA_SYNTH;
1049 static
1050 void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1051 unsigned int nch, unsigned int ns)
1053 int p;
1054 unsigned int phase, ch, s;
1055 mad_fixed_t *pcm, (*filter)[2][2][16][8];
1056 mad_fixed_t (*sbsample)[36][32];
1057 mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
1058 mad_fixed_t const (*D0ptr)[32], *ptr;
1059 mad_fixed_t const (*D1ptr)[32];
1060 mad_fixed64hi_t hi;
1061 mad_fixed64lo_t lo;
1063 for (ch = 0; ch < nch; ++ch) {
1064 sbsample = &(*frame->sbsample_prev)[ch];
1065 filter = &synth->filter[ch];
1066 phase = synth->phase;
1067 pcm = synth->pcm.samples[ch];
1069 for (s = 0; s < ns; ++s) {
1070 dct32((*sbsample)[s], phase >> 1,
1071 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1073 p = (phase - 1) & 0xf;
1075 /* calculate 32 samples */
1076 fe = &(*filter)[0][ phase & 1][0];
1077 fx = &(*filter)[0][~phase & 1][0];
1078 fo = &(*filter)[1][~phase & 1][0];
1080 D0ptr = (void*)&D[0][ p];
1081 D1ptr = (void*)&D[0][-p];
1083 if(s & 1)
1085 ptr = *D0ptr;
1087 ML0(hi, lo, (*fx)[0], ptr[ 1]);
1088 MLA(hi, lo, (*fx)[1], ptr[15]);
1089 MLA(hi, lo, (*fx)[2], ptr[13]);
1090 MLA(hi, lo, (*fx)[3], ptr[11]);
1091 MLA(hi, lo, (*fx)[4], ptr[ 9]);
1092 MLA(hi, lo, (*fx)[5], ptr[ 7]);
1093 MLA(hi, lo, (*fx)[6], ptr[ 5]);
1094 MLA(hi, lo, (*fx)[7], ptr[ 3]);
1096 PROD_ODD_0(hi, lo, *fx, ptr);
1097 MLN(hi, lo);
1099 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1100 MLA(hi, lo, (*fe)[1], ptr[14]);
1101 MLA(hi, lo, (*fe)[2], ptr[12]);
1102 MLA(hi, lo, (*fe)[3], ptr[10]);
1103 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1104 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1105 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1106 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1108 PROD_EVEN_A(hi, lo, *fe, ptr);
1109 pcm[0] = SHIFT(MLZ(hi, lo));
1110 pcm += 16;
1112 synth_full1(pcm, fo, fe, D0ptr, D1ptr);
1113 D0ptr += 15;
1114 D1ptr += 15;
1115 fo += 15;
1116 fe += 15;
1118 ptr = *(D0ptr + 1);
1119 PROD_ODD_0(hi, lo, *fo, ptr);
1121 ML0(hi, lo, (*fo)[0], ptr[ 1]);
1122 MLA(hi, lo, (*fo)[1], ptr[15]);
1123 MLA(hi, lo, (*fo)[2], ptr[13]);
1124 MLA(hi, lo, (*fo)[3], ptr[11]);
1125 MLA(hi, lo, (*fo)[4], ptr[ 9]);
1126 MLA(hi, lo, (*fo)[5], ptr[ 7]);
1127 MLA(hi, lo, (*fo)[6], ptr[ 5]);
1128 MLA(hi, lo, (*fo)[7], ptr[ 3]);
1130 pcm[0] = SHIFT(-MLZ(hi, lo));
1132 else
1134 ptr = *D0ptr;
1136 ML0(hi, lo, (*fx)[0], ptr[ 0]);
1137 MLA(hi, lo, (*fx)[1], ptr[14]);
1138 MLA(hi, lo, (*fx)[2], ptr[12]);
1139 MLA(hi, lo, (*fx)[3], ptr[10]);
1140 MLA(hi, lo, (*fx)[4], ptr[ 8]);
1141 MLA(hi, lo, (*fx)[5], ptr[ 6]);
1142 MLA(hi, lo, (*fx)[6], ptr[ 4]);
1143 MLA(hi, lo, (*fx)[7], ptr[ 2]);
1145 PROD_EVEN_0(hi, lo, *fx, ptr);
1146 MLN(hi, lo);
1148 MLA(hi, lo, (*fe)[0], ptr[ 1]);
1149 MLA(hi, lo, (*fe)[1], ptr[15]);
1150 MLA(hi, lo, (*fe)[2], ptr[13]);
1151 MLA(hi, lo, (*fe)[3], ptr[11]);
1152 MLA(hi, lo, (*fe)[4], ptr[ 9]);
1153 MLA(hi, lo, (*fe)[5], ptr[ 7]);
1154 MLA(hi, lo, (*fe)[6], ptr[ 5]);
1155 MLA(hi, lo, (*fe)[7], ptr[ 3]);
1157 PROD_ODD_A(hi, lo, *fe, ptr);
1158 pcm[0] = SHIFT(MLZ(hi, lo));
1159 pcm += 16;
1161 synth_full2(pcm, fo, fe, D0ptr, D1ptr);
1162 D0ptr += 15;
1163 D1ptr += 15;
1164 fo += 15;
1165 fe += 15;
1167 ptr = *(D0ptr + 1);
1169 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1170 MLA(hi, lo, (*fo)[1], ptr[14]);
1171 MLA(hi, lo, (*fo)[2], ptr[12]);
1172 MLA(hi, lo, (*fo)[3], ptr[10]);
1173 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1174 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1175 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1176 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1178 PROD_EVEN_0(hi, lo, *fo, ptr);
1179 pcm[0] = SHIFT(-MLZ(hi, lo));
1182 pcm += 16;
1183 phase = (phase + 1) % 16;
1188 # else
1190 static
1191 void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1192 unsigned int nch, unsigned int ns)
1194 int p, sb;
1195 unsigned int phase, ch, s;
1196 mad_fixed_t *pcm, (*filter)[2][2][16][8];
1197 mad_fixed_t (*sbsample)[36][32];
1198 mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
1199 mad_fixed_t const (*D0ptr)[32], *ptr;
1200 mad_fixed_t const (*D1ptr)[32];
1201 mad_fixed64hi_t hi;
1202 mad_fixed64lo_t lo;
1204 for (ch = 0; ch < nch; ++ch) {
1205 sbsample = &(*frame->sbsample_prev)[ch];
1206 filter = &synth->filter[ch];
1207 phase = synth->phase;
1208 pcm = synth->pcm.samples[ch];
1210 for (s = 0; s < ns; ++s) {
1211 dct32((*sbsample)[s], phase >> 1,
1212 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1214 p = (phase - 1) & 0xf;
1216 /* calculate 32 samples */
1217 fe = &(*filter)[0][ phase & 1][0];
1218 fx = &(*filter)[0][~phase & 1][0];
1219 fo = &(*filter)[1][~phase & 1][0];
1221 D0ptr = (void*)&D[0][ p];
1222 D1ptr = (void*)&D[0][-p];
1224 if(s & 1)
1226 ptr = *D0ptr;
1227 ML0(hi, lo, (*fx)[0], ptr[ 1]);
1228 MLA(hi, lo, (*fx)[1], ptr[15]);
1229 MLA(hi, lo, (*fx)[2], ptr[13]);
1230 MLA(hi, lo, (*fx)[3], ptr[11]);
1231 MLA(hi, lo, (*fx)[4], ptr[ 9]);
1232 MLA(hi, lo, (*fx)[5], ptr[ 7]);
1233 MLA(hi, lo, (*fx)[6], ptr[ 5]);
1234 MLA(hi, lo, (*fx)[7], ptr[ 3]);
1235 MLN(hi, lo);
1236 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1237 MLA(hi, lo, (*fe)[1], ptr[14]);
1238 MLA(hi, lo, (*fe)[2], ptr[12]);
1239 MLA(hi, lo, (*fe)[3], ptr[10]);
1240 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1241 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1242 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1243 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1244 pcm[0] = SHIFT(MLZ(hi, lo));
1245 pcm += 16;
1247 for (sb = 15; sb; sb--, fo++)
1249 ++fe;
1250 ++D0ptr;
1251 ++D1ptr;
1253 /* D[32 - sb][i] == -D[sb][31 - i] */
1254 ptr = *D0ptr;
1255 ML0(hi, lo, (*fo)[0], ptr[ 1]);
1256 MLA(hi, lo, (*fo)[1], ptr[15]);
1257 MLA(hi, lo, (*fo)[2], ptr[13]);
1258 MLA(hi, lo, (*fo)[3], ptr[11]);
1259 MLA(hi, lo, (*fo)[4], ptr[ 9]);
1260 MLA(hi, lo, (*fo)[5], ptr[ 7]);
1261 MLA(hi, lo, (*fo)[6], ptr[ 5]);
1262 MLA(hi, lo, (*fo)[7], ptr[ 3]);
1263 MLN(hi, lo);
1264 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1265 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1266 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1267 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1268 MLA(hi, lo, (*fe)[3], ptr[10]);
1269 MLA(hi, lo, (*fe)[2], ptr[12]);
1270 MLA(hi, lo, (*fe)[1], ptr[14]);
1271 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1272 pcm[-sb] = SHIFT(MLZ(hi, lo));
1274 ptr = *D1ptr;
1275 ML0(hi, lo, (*fe)[0], ptr[31 - 16]);
1276 MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
1277 MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
1278 MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
1279 MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
1280 MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
1281 MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
1282 MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
1283 MLA(hi, lo, (*fo)[7], ptr[31 - 3]);
1284 MLA(hi, lo, (*fo)[6], ptr[31 - 5]);
1285 MLA(hi, lo, (*fo)[5], ptr[31 - 7]);
1286 MLA(hi, lo, (*fo)[4], ptr[31 - 9]);
1287 MLA(hi, lo, (*fo)[3], ptr[31 - 11]);
1288 MLA(hi, lo, (*fo)[2], ptr[31 - 13]);
1289 MLA(hi, lo, (*fo)[1], ptr[31 - 15]);
1290 MLA(hi, lo, (*fo)[0], ptr[31 - 1]);
1291 pcm[sb] = SHIFT(MLZ(hi, lo));
1294 ptr = *(D0ptr + 1);
1295 ML0(hi, lo, (*fo)[0], ptr[ 1]);
1296 MLA(hi, lo, (*fo)[1], ptr[15]);
1297 MLA(hi, lo, (*fo)[2], ptr[13]);
1298 MLA(hi, lo, (*fo)[3], ptr[11]);
1299 MLA(hi, lo, (*fo)[4], ptr[ 9]);
1300 MLA(hi, lo, (*fo)[5], ptr[ 7]);
1301 MLA(hi, lo, (*fo)[6], ptr[ 5]);
1302 MLA(hi, lo, (*fo)[7], ptr[ 3]);
1303 pcm[0] = SHIFT(-MLZ(hi, lo));
1305 else
1307 ptr = *D0ptr;
1308 ML0(hi, lo, (*fx)[0], ptr[ 0]);
1309 MLA(hi, lo, (*fx)[1], ptr[14]);
1310 MLA(hi, lo, (*fx)[2], ptr[12]);
1311 MLA(hi, lo, (*fx)[3], ptr[10]);
1312 MLA(hi, lo, (*fx)[4], ptr[ 8]);
1313 MLA(hi, lo, (*fx)[5], ptr[ 6]);
1314 MLA(hi, lo, (*fx)[6], ptr[ 4]);
1315 MLA(hi, lo, (*fx)[7], ptr[ 2]);
1316 MLN(hi, lo);
1317 MLA(hi, lo, (*fe)[0], ptr[ 1]);
1318 MLA(hi, lo, (*fe)[1], ptr[15]);
1319 MLA(hi, lo, (*fe)[2], ptr[13]);
1320 MLA(hi, lo, (*fe)[3], ptr[11]);
1321 MLA(hi, lo, (*fe)[4], ptr[ 9]);
1322 MLA(hi, lo, (*fe)[5], ptr[ 7]);
1323 MLA(hi, lo, (*fe)[6], ptr[ 5]);
1324 MLA(hi, lo, (*fe)[7], ptr[ 3]);
1325 pcm[0] = SHIFT(MLZ(hi, lo));
1326 pcm += 16;
1328 for (sb = 15; sb; sb--, fo++)
1330 ++fe;
1331 ++D0ptr;
1332 ++D1ptr;
1334 /* D[32 - sb][i] == -D[sb][31 - i] */
1335 ptr = *D0ptr;
1336 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1337 MLA(hi, lo, (*fo)[1], ptr[14]);
1338 MLA(hi, lo, (*fo)[2], ptr[12]);
1339 MLA(hi, lo, (*fo)[3], ptr[10]);
1340 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1341 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1342 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1343 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1344 MLN(hi, lo);
1345 MLA(hi, lo, (*fe)[7], ptr[ 3]);
1346 MLA(hi, lo, (*fe)[6], ptr[ 5]);
1347 MLA(hi, lo, (*fe)[5], ptr[ 7]);
1348 MLA(hi, lo, (*fe)[4], ptr[ 9]);
1349 MLA(hi, lo, (*fe)[3], ptr[11]);
1350 MLA(hi, lo, (*fe)[2], ptr[13]);
1351 MLA(hi, lo, (*fe)[1], ptr[15]);
1352 MLA(hi, lo, (*fe)[0], ptr[ 1]);
1353 pcm[-sb] = SHIFT(MLZ(hi, lo));
1355 ptr = *D1ptr;
1356 ML0(hi, lo, (*fe)[0], ptr[31 - 1]);
1357 MLA(hi, lo, (*fe)[1], ptr[31 - 15]);
1358 MLA(hi, lo, (*fe)[2], ptr[31 - 13]);
1359 MLA(hi, lo, (*fe)[3], ptr[31 - 11]);
1360 MLA(hi, lo, (*fe)[4], ptr[31 - 9]);
1361 MLA(hi, lo, (*fe)[5], ptr[31 - 7]);
1362 MLA(hi, lo, (*fe)[6], ptr[31 - 5]);
1363 MLA(hi, lo, (*fe)[7], ptr[31 - 3]);
1364 MLA(hi, lo, (*fo)[7], ptr[31 - 2]);
1365 MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
1366 MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
1367 MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
1368 MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
1369 MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
1370 MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
1371 MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
1372 pcm[sb] = SHIFT(MLZ(hi, lo));
1375 ptr = *(D0ptr + 1);
1376 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1377 MLA(hi, lo, (*fo)[1], ptr[14]);
1378 MLA(hi, lo, (*fo)[2], ptr[12]);
1379 MLA(hi, lo, (*fo)[3], ptr[10]);
1380 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1381 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1382 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1383 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1384 pcm[0] = SHIFT(-MLZ(hi, lo));
1387 pcm += 16;
1388 phase = (phase + 1) % 16;
1393 # endif
1394 # endif
1397 * NAME: synth->half()
1398 * DESCRIPTION: perform half frequency PCM synthesis
1400 static
1401 void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
1402 unsigned int nch, unsigned int ns)
1404 unsigned int phase, ch, s, sb, pe, po;
1405 mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8];
1406 mad_fixed_t (*sbsample)[36][32];
1407 register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
1408 register mad_fixed_t const (*Dptr)[32], *ptr;
1409 register mad_fixed64hi_t hi;
1410 register mad_fixed64lo_t lo;
1412 for (ch = 0; ch < nch; ++ch) {
1413 sbsample = &(*frame->sbsample_prev)[ch];
1414 filter = &synth->filter[ch];
1415 phase = synth->phase;
1416 pcm1 = synth->pcm.samples[ch];
1418 for (s = 0; s < ns; ++s) {
1419 dct32((*sbsample)[s], phase >> 1,
1420 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1422 pe = phase & ~1;
1423 po = ((phase - 1) & 0xf) | 1;
1425 /* calculate 16 samples */
1427 fe = &(*filter)[0][ phase & 1][0];
1428 fx = &(*filter)[0][~phase & 1][0];
1429 fo = &(*filter)[1][~phase & 1][0];
1431 Dptr = &D[0];
1433 ptr = *Dptr + po;
1434 ML0(hi, lo, (*fx)[0], ptr[ 0]);
1435 MLA(hi, lo, (*fx)[1], ptr[14]);
1436 MLA(hi, lo, (*fx)[2], ptr[12]);
1437 MLA(hi, lo, (*fx)[3], ptr[10]);
1438 MLA(hi, lo, (*fx)[4], ptr[ 8]);
1439 MLA(hi, lo, (*fx)[5], ptr[ 6]);
1440 MLA(hi, lo, (*fx)[6], ptr[ 4]);
1441 MLA(hi, lo, (*fx)[7], ptr[ 2]);
1442 MLN(hi, lo);
1444 ptr = *Dptr + pe;
1445 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1446 MLA(hi, lo, (*fe)[1], ptr[14]);
1447 MLA(hi, lo, (*fe)[2], ptr[12]);
1448 MLA(hi, lo, (*fe)[3], ptr[10]);
1449 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1450 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1451 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1452 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1454 *pcm1++ = SHIFT(MLZ(hi, lo));
1456 pcm2 = pcm1 + 14;
1458 for (sb = 1; sb < 16; ++sb) {
1459 ++fe;
1460 ++Dptr;
1462 /* D[32 - sb][i] == -D[sb][31 - i] */
1464 if (!(sb & 1)) {
1465 ptr = *Dptr + po;
1466 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1467 MLA(hi, lo, (*fo)[1], ptr[14]);
1468 MLA(hi, lo, (*fo)[2], ptr[12]);
1469 MLA(hi, lo, (*fo)[3], ptr[10]);
1470 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1471 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1472 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1473 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1474 MLN(hi, lo);
1476 ptr = *Dptr + pe;
1477 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1478 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1479 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1480 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1481 MLA(hi, lo, (*fe)[3], ptr[10]);
1482 MLA(hi, lo, (*fe)[2], ptr[12]);
1483 MLA(hi, lo, (*fe)[1], ptr[14]);
1484 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1486 *pcm1++ = SHIFT(MLZ(hi, lo));
1488 ptr = *Dptr - po;
1489 ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
1490 MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
1491 MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
1492 MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
1493 MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
1494 MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
1495 MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
1496 MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
1498 ptr = *Dptr - pe;
1499 MLA(hi, lo, (*fe)[0], ptr[31 - 16]);
1500 MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
1501 MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
1502 MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
1503 MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
1504 MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
1505 MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
1506 MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
1508 *pcm2-- = SHIFT(MLZ(hi, lo));
1511 ++fo;
1514 ++Dptr;
1516 ptr = *Dptr + po;
1517 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1518 MLA(hi, lo, (*fo)[1], ptr[14]);
1519 MLA(hi, lo, (*fo)[2], ptr[12]);
1520 MLA(hi, lo, (*fo)[3], ptr[10]);
1521 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1522 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1523 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1524 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1526 *pcm1 = SHIFT(-MLZ(hi, lo));
1527 pcm1 += 8;
1529 phase = (phase + 1) % 16;
1535 * NAME: synth->frame()
1536 * DESCRIPTION: perform PCM synthesis of frame subband samples
1538 void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame)
1540 unsigned int nch, ns;
1541 void (*synth_frame)(struct mad_synth *, struct mad_frame const *,
1542 unsigned int, unsigned int);
1544 nch = MAD_NCHANNELS(&frame->header);
1545 ns = MAD_NSBSAMPLES(&frame->header);
1547 synth->pcm.samplerate = frame->header.samplerate;
1548 synth->pcm.channels = nch;
1549 synth->pcm.length = 32 * ns;
1551 synth_frame = synth_full;
1553 if (frame->options & MAD_OPTION_HALFSAMPLERATE) {
1554 synth->pcm.samplerate /= 2;
1555 synth->pcm.length /= 2;
1557 synth_frame = synth_half;
1560 synth_frame(synth, frame, nch, ns);
1562 synth->phase = (synth->phase + ns) % 16;