summaryrefslogtreecommitdiff
path: root/apps/codecs/libmad/synth.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libmad/synth.c')
-rw-r--r--apps/codecs/libmad/synth.c504
1 files changed, 252 insertions, 252 deletions
diff --git a/apps/codecs/libmad/synth.c b/apps/codecs/libmad/synth.c
index 9b320b594d..9d1bdb7c91 100644
--- a/apps/codecs/libmad/synth.c
+++ b/apps/codecs/libmad/synth.c
@@ -30,7 +30,7 @@
30# include "synth.h" 30# include "synth.h"
31 31
32/* 32/*
33 * NAME: synth->init() 33 * NAME: synth->init()
34 * DESCRIPTION: initialize synth struct 34 * DESCRIPTION: initialize synth struct
35 */ 35 */
36void mad_synth_init(struct mad_synth *synth) 36void mad_synth_init(struct mad_synth *synth)
@@ -50,7 +50,7 @@ void mad_synth_init(struct mad_synth *synth)
50} 50}
51 51
52/* 52/*
53 * NAME: synth->mute() 53 * NAME: synth->mute()
54 * DESCRIPTION: zero all polyphase filterbank values, resetting synthesis 54 * DESCRIPTION: zero all polyphase filterbank values, resetting synthesis
55 */ 55 */
56void mad_synth_mute(struct mad_synth *synth) 56void mad_synth_mute(struct mad_synth *synth)
@@ -60,8 +60,8 @@ void mad_synth_mute(struct mad_synth *synth)
60 for (ch = 0; ch < 2; ++ch) { 60 for (ch = 0; ch < 2; ++ch) {
61 for (s = 0; s < 16; ++s) { 61 for (s = 0; s < 16; ++s) {
62 for (v = 0; v < 8; ++v) { 62 for (v = 0; v < 8; ++v) {
63 synth->filter[ch][0][0][s][v] = synth->filter[ch][0][1][s][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; 64 synth->filter[ch][1][0][s][v] = synth->filter[ch][1][1][s][v] = 0;
65 } 65 }
66 } 66 }
67 } 67 }
@@ -142,12 +142,12 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
142# endif 142# endif
143 143
144/* 144/*
145 * NAME: dct32() 145 * NAME: dct32()
146 * DESCRIPTION: perform fast in[32]->out[32] DCT 146 * DESCRIPTION: perform fast in[32]->out[32] DCT
147 */ 147 */
148static 148static
149void dct32(mad_fixed_t const in[32], unsigned int slot, 149void dct32(mad_fixed_t const in[32], unsigned int slot,
150 mad_fixed_t lo[16][8], mad_fixed_t hi[16][8]) 150 mad_fixed_t lo[16][8], mad_fixed_t hi[16][8])
151{ 151{
152 mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; 152 mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7;
153 mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; 153 mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15;
@@ -176,69 +176,69 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
176 /* costab[i] = cos(PI / (2 * 32) * i) */ 176 /* costab[i] = cos(PI / (2 * 32) * i) */
177 177
178# if defined(OPT_DCTO) 178# if defined(OPT_DCTO)
179# define costab1 MAD_F(0x7fd8878e) 179# define costab1 MAD_F(0x7fd8878e)
180# define costab2 MAD_F(0x7f62368f) 180# define costab2 MAD_F(0x7f62368f)
181# define costab3 MAD_F(0x7e9d55fc) 181# define costab3 MAD_F(0x7e9d55fc)
182# define costab4 MAD_F(0x7d8a5f40) 182# define costab4 MAD_F(0x7d8a5f40)
183# define costab5 MAD_F(0x7c29fbee) 183# define costab5 MAD_F(0x7c29fbee)
184# define costab6 MAD_F(0x7a7d055b) 184# define costab6 MAD_F(0x7a7d055b)
185# define costab7 MAD_F(0x78848414) 185# define costab7 MAD_F(0x78848414)
186# define costab8 MAD_F(0x7641af3d) 186# define costab8 MAD_F(0x7641af3d)
187# define costab9 MAD_F(0x73b5ebd1) 187# define costab9 MAD_F(0x73b5ebd1)
188# define costab10 MAD_F(0x70e2cbc6) 188# define costab10 MAD_F(0x70e2cbc6)
189# define costab11 MAD_F(0x6dca0d14) 189# define costab11 MAD_F(0x6dca0d14)
190# define costab12 MAD_F(0x6a5d98a4) 190# define costab12 MAD_F(0x6a5d98a4)
191# define costab13 MAD_F(0x66cf8120) 191# define costab13 MAD_F(0x66cf8120)
192# define costab14 MAD_F(0x62f201ac) 192# define costab14 MAD_F(0x62f201ac)
193# define costab15 MAD_F(0x5ed77c8a) 193# define costab15 MAD_F(0x5ed77c8a)
194# define costab16 MAD_F(0x5a82799a) 194# define costab16 MAD_F(0x5a82799a)
195# define costab17 MAD_F(0x55f5a4d2) 195# define costab17 MAD_F(0x55f5a4d2)
196# define costab18 MAD_F(0x5133cc94) 196# define costab18 MAD_F(0x5133cc94)
197# define costab19 MAD_F(0x4c3fdff4) 197# define costab19 MAD_F(0x4c3fdff4)
198# define costab20 MAD_F(0x471cece7) 198# define costab20 MAD_F(0x471cece7)
199# define costab21 MAD_F(0x41ce1e65) 199# define costab21 MAD_F(0x41ce1e65)
200# define costab22 MAD_F(0x3c56ba70) 200# define costab22 MAD_F(0x3c56ba70)
201# define costab23 MAD_F(0x36ba2014) 201# define costab23 MAD_F(0x36ba2014)
202# define costab24 MAD_F(0x30fbc54d) 202# define costab24 MAD_F(0x30fbc54d)
203# define costab25 MAD_F(0x2b1f34eb) 203# define costab25 MAD_F(0x2b1f34eb)
204# define costab26 MAD_F(0x25280c5e) 204# define costab26 MAD_F(0x25280c5e)
205# define costab27 MAD_F(0x1f19f97b) 205# define costab27 MAD_F(0x1f19f97b)
206# define costab28 MAD_F(0x18f8b83c) 206# define costab28 MAD_F(0x18f8b83c)
207# define costab29 MAD_F(0x12c8106f) 207# define costab29 MAD_F(0x12c8106f)
208# define costab30 MAD_F(0x0c8bd35e) 208# define costab30 MAD_F(0x0c8bd35e)
209# define costab31 MAD_F(0x0647d97c) 209# define costab31 MAD_F(0x0647d97c)
210# else 210# else
211# define costab1 MAD_F(0x0ffb10f2) /* 0.998795456 */ 211# define costab1 MAD_F(0x0ffb10f2) /* 0.998795456 */
212# define costab2 MAD_F(0x0fec46d2) /* 0.995184727 */ 212# define costab2 MAD_F(0x0fec46d2) /* 0.995184727 */
213# define costab3 MAD_F(0x0fd3aac0) /* 0.989176510 */ 213# define costab3 MAD_F(0x0fd3aac0) /* 0.989176510 */
214# define costab4 MAD_F(0x0fb14be8) /* 0.980785280 */ 214# define costab4 MAD_F(0x0fb14be8) /* 0.980785280 */
215# define costab5 MAD_F(0x0f853f7e) /* 0.970031253 */ 215# define costab5 MAD_F(0x0f853f7e) /* 0.970031253 */
216# define costab6 MAD_F(0x0f4fa0ab) /* 0.956940336 */ 216# define costab6 MAD_F(0x0f4fa0ab) /* 0.956940336 */
217# define costab7 MAD_F(0x0f109082) /* 0.941544065 */ 217# define costab7 MAD_F(0x0f109082) /* 0.941544065 */
218# define costab8 MAD_F(0x0ec835e8) /* 0.923879533 */ 218# define costab8 MAD_F(0x0ec835e8) /* 0.923879533 */
219# define costab9 MAD_F(0x0e76bd7a) /* 0.903989293 */ 219# define costab9 MAD_F(0x0e76bd7a) /* 0.903989293 */
220# define costab10 MAD_F(0x0e1c5979) /* 0.881921264 */ 220# define costab10 MAD_F(0x0e1c5979) /* 0.881921264 */
221# define costab11 MAD_F(0x0db941a3) /* 0.857728610 */ 221# define costab11 MAD_F(0x0db941a3) /* 0.857728610 */
222# define costab12 MAD_F(0x0d4db315) /* 0.831469612 */ 222# define costab12 MAD_F(0x0d4db315) /* 0.831469612 */
223# define costab13 MAD_F(0x0cd9f024) /* 0.803207531 */ 223# define costab13 MAD_F(0x0cd9f024) /* 0.803207531 */
224# define costab14 MAD_F(0x0c5e4036) /* 0.773010453 */ 224# define costab14 MAD_F(0x0c5e4036) /* 0.773010453 */
225# define costab15 MAD_F(0x0bdaef91) /* 0.740951125 */ 225# define costab15 MAD_F(0x0bdaef91) /* 0.740951125 */
226# define costab16 MAD_F(0x0b504f33) /* 0.707106781 */ 226# define costab16 MAD_F(0x0b504f33) /* 0.707106781 */
227# define costab17 MAD_F(0x0abeb49a) /* 0.671558955 */ 227# define costab17 MAD_F(0x0abeb49a) /* 0.671558955 */
228# define costab18 MAD_F(0x0a267993) /* 0.634393284 */ 228# define costab18 MAD_F(0x0a267993) /* 0.634393284 */
229# define costab19 MAD_F(0x0987fbfe) /* 0.595699304 */ 229# define costab19 MAD_F(0x0987fbfe) /* 0.595699304 */
230# define costab20 MAD_F(0x08e39d9d) /* 0.555570233 */ 230# define costab20 MAD_F(0x08e39d9d) /* 0.555570233 */
231# define costab21 MAD_F(0x0839c3cd) /* 0.514102744 */ 231# define costab21 MAD_F(0x0839c3cd) /* 0.514102744 */
232# define costab22 MAD_F(0x078ad74e) /* 0.471396737 */ 232# define costab22 MAD_F(0x078ad74e) /* 0.471396737 */
233# define costab23 MAD_F(0x06d74402) /* 0.427555093 */ 233# define costab23 MAD_F(0x06d74402) /* 0.427555093 */
234# define costab24 MAD_F(0x061f78aa) /* 0.382683432 */ 234# define costab24 MAD_F(0x061f78aa) /* 0.382683432 */
235# define costab25 MAD_F(0x0563e69d) /* 0.336889853 */ 235# define costab25 MAD_F(0x0563e69d) /* 0.336889853 */
236# define costab26 MAD_F(0x04a5018c) /* 0.290284677 */ 236# define costab26 MAD_F(0x04a5018c) /* 0.290284677 */
237# define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */ 237# define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */
238# define costab28 MAD_F(0x031f1708) /* 0.195090322 */ 238# define costab28 MAD_F(0x031f1708) /* 0.195090322 */
239# define costab29 MAD_F(0x0259020e) /* 0.146730474 */ 239# define costab29 MAD_F(0x0259020e) /* 0.146730474 */
240# define costab30 MAD_F(0x01917a5c) /* 0.098017140 */ 240# define costab30 MAD_F(0x01917a5c) /* 0.098017140 */
241# define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */ 241# define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */
242# endif 242# endif
243 243
244 t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1); 244 t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1);
@@ -395,7 +395,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
395 395
396 /* 8 */ hi[ 7][slot] = SHIFT(t143); 396 /* 8 */ hi[ 7][slot] = SHIFT(t143);
397 /* 24 */ lo[ 8][slot] = 397 /* 24 */ lo[ 8][slot] =
398 SHIFT((MUL(t141 - t142, costab16) * 2) - t143); 398 SHIFT((MUL(t141 - t142, costab16) * 2) - t143);
399 399
400 t144 = MUL(t73 - t74, costab8); 400 t144 = MUL(t73 - t74, costab8);
401 t145 = MUL(t75 - t76, costab24); 401 t145 = MUL(t75 - t76, costab24);
@@ -435,7 +435,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
435 435
436 /* 20 */ lo[ 4][slot] = SHIFT(t160); 436 /* 20 */ lo[ 4][slot] = SHIFT(t160);
437 /* 28 */ lo[12][slot] = 437 /* 28 */ lo[12][slot] =
438 SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160); 438 SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160);
439 439
440 t161 = MUL(t94 - t95, costab8); 440 t161 = MUL(t94 - t95, costab8);
441 t162 = MUL(t96 - t97, costab24); 441 t162 = MUL(t96 - t97, costab24);
@@ -473,8 +473,8 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
473 473
474 /* 26 */ lo[10][slot] = SHIFT(t170); 474 /* 26 */ lo[10][slot] = SHIFT(t170);
475 /* 30 */ lo[14][slot] = 475 /* 30 */ lo[14][slot] =
476 SHIFT((((((MUL(t166 - t167, costab16) * 2) - 476 SHIFT((((((MUL(t166 - t167, costab16) * 2) -
477 t168) * 2) - t169) * 2) - t170); 477 t168) * 2) - t169) * 2) - t170);
478 478
479 t171 = MUL(t106 - t107, costab8); 479 t171 = MUL(t106 - t107, costab8);
480 t172 = MUL(t108 - t109, costab24); 480 t172 = MUL(t108 - t109, costab24);
@@ -521,12 +521,12 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
521 /* 27 */ lo[11][slot] = SHIFT(t165); 521 /* 27 */ lo[11][slot] = SHIFT(t165);
522 522
523 t176 = (((((MUL(t161 - t162, costab16) * 2) - 523 t176 = (((((MUL(t161 - t162, costab16) * 2) -
524 t163) * 2) - t164) * 2) - t165; 524 t163) * 2) - t164) * 2) - t165;
525 525
526 /* 29 */ lo[13][slot] = SHIFT(t176); 526 /* 29 */ lo[13][slot] = SHIFT(t176);
527 /* 31 */ lo[15][slot] = 527 /* 31 */ lo[15][slot] =
528 SHIFT((((((((MUL(t171 - t172, costab16) * 2) - 528 SHIFT((((((((MUL(t171 - t172, costab16) * 2) -
529 t173) * 2) - t174) * 2) - t175) * 2) - t176); 529 t173) * 2) - t174) * 2) - t175) * 2) - t176);
530 530
531 /* 531 /*
532 * Totals: 532 * Totals:
@@ -548,24 +548,24 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
548# if MAD_F_FRACBITS != 28 548# if MAD_F_FRACBITS != 28
549# error "MAD_F_FRACBITS must be 28 to use OPT_SSO" 549# error "MAD_F_FRACBITS must be 28 to use OPT_SSO"
550# endif 550# endif
551# define ML0(hi, lo, x, y) ((lo) = (x) * (y)) 551# define ML0(hi, lo, x, y) ((lo) = (x) * (y))
552# define MLA(hi, lo, x, y) ((lo) += (x) * (y)) 552# define MLA(hi, lo, x, y) ((lo) += (x) * (y))
553# define MLN(hi, lo) ((lo) = -(lo)) 553# define MLN(hi, lo) ((lo) = -(lo))
554# define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) 554# define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
555# define SHIFT(x) ((x) >> 2) 555# define SHIFT(x) ((x) >> 2)
556# define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14) 556# define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14)
557# else 557# else
558# define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y)) 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)) 559# define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y))
560# define MLN(hi, lo) MAD_F_MLN((hi), (lo)) 560# define MLN(hi, lo) MAD_F_MLN((hi), (lo))
561# define MLZ(hi, lo) MAD_F_MLZ((hi), (lo)) 561# define MLZ(hi, lo) MAD_F_MLZ((hi), (lo))
562# define SHIFT(x) (x) 562# define SHIFT(x) (x)
563# if defined(MAD_F_SCALEBITS) 563# if defined(MAD_F_SCALEBITS)
564# undef MAD_F_SCALEBITS 564# undef MAD_F_SCALEBITS
565# define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12) 565# define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12)
566# define PRESHIFT(x) (MAD_F(x) >> 12) 566# define PRESHIFT(x) (MAD_F(x) >> 12)
567# else 567# else
568# define PRESHIFT(x) MAD_F(x) 568# define PRESHIFT(x) MAD_F(x)
569# endif 569# endif
570# endif 570# endif
571 571
@@ -576,10 +576,10 @@ mad_fixed_t const D[17][32] ICONST_ATTR = {
576 576
577# if defined(ASO_SYNTH) 577# if defined(ASO_SYNTH)
578void synth_full(struct mad_synth *, struct mad_frame const *, 578void synth_full(struct mad_synth *, struct mad_frame const *,
579 unsigned int, unsigned int); 579 unsigned int, unsigned int);
580# else 580# else
581/* 581/*
582 * NAME: synth->full() 582 * NAME: synth->full()
583 * DESCRIPTION: perform full frequency PCM synthesis 583 * DESCRIPTION: perform full frequency PCM synthesis
584 */ 584 */
585 585
@@ -587,7 +587,7 @@ void synth_full(struct mad_synth *, struct mad_frame const *,
587# ifdef FPM_COLDFIRE_EMAC 587# ifdef FPM_COLDFIRE_EMAC
588static 588static
589void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 589void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
590 unsigned int nch, unsigned int ns) 590 unsigned int nch, unsigned int ns)
591{ 591{
592 int sb; 592 int sb;
593 unsigned int phase, ch, s, p; 593 unsigned int phase, ch, s, p;
@@ -606,7 +606,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
606 606
607 for (s = 0; s < ns; ++s) { 607 for (s = 0; s < ns; ++s) {
608 dct32((*sbsample)[s], phase >> 1, 608 dct32((*sbsample)[s], phase >> 1,
609 (*filter)[0][phase & 1], (*filter)[1][phase & 1]); 609 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
610 610
611 p = (phase - 1) & 0xf; 611 p = (phase - 1) & 0xf;
612 612
@@ -649,11 +649,11 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
649 pcm += 16; 649 pcm += 16;
650 650
651 for (sb = 15; sb; sb--, fo++) { 651 for (sb = 15; sb; sb--, fo++) {
652 ++fe; 652 ++fe;
653 ++D0ptr; 653 ++D0ptr;
654 ++D1ptr; 654 ++D1ptr;
655 655
656 /* D[32 - sb][i] == -D[sb][31 - i] */ 656 /* D[32 - sb][i] == -D[sb][31 - i] */
657 asm volatile ( 657 asm volatile (
658 "movem.l (%0), %%d0-%%d7\n\t" 658 "movem.l (%0), %%d0-%%d7\n\t"
659 "move.l 4(%2), %%a5\n\t" 659 "move.l 4(%2), %%a5\n\t"
@@ -697,8 +697,8 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
697 "movclr.l %%acc0, %0\n\t" 697 "movclr.l %%acc0, %0\n\t"
698 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) ); 698 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) );
699 699
700 pcm[-sb] = hi0 << 3; 700 pcm[-sb] = hi0 << 3;
701 pcm[ sb] = hi1 << 3; 701 pcm[ sb] = hi1 << 3;
702 } 702 }
703 703
704 ++D0ptr; 704 ++D0ptr;
@@ -750,11 +750,11 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
750 pcm += 16; 750 pcm += 16;
751 751
752 for (sb = 15; sb; sb--, fo++) { 752 for (sb = 15; sb; sb--, fo++) {
753 ++fe; 753 ++fe;
754 ++D0ptr; 754 ++D0ptr;
755 ++D1ptr; 755 ++D1ptr;
756 756
757 /* D[32 - sb][i] == -D[sb][31 - i] */ 757 /* D[32 - sb][i] == -D[sb][31 - i] */
758 asm volatile ( 758 asm volatile (
759 "movem.l (%0), %%d0-%%d7\n\t" 759 "movem.l (%0), %%d0-%%d7\n\t"
760 "move.l (%2), %%a5\n\t" 760 "move.l (%2), %%a5\n\t"
@@ -798,8 +798,8 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
798 "movclr.l %%acc0, %0\n\t" 798 "movclr.l %%acc0, %0\n\t"
799 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) ); 799 "movclr.l %%acc1, %1\n\t" : "=d" (hi0), "=d" (hi1) );
800 800
801 pcm[-sb] = hi0 << 3; 801 pcm[-sb] = hi0 << 3;
802 pcm[ sb] = hi1 << 3; 802 pcm[ sb] = hi1 << 3;
803 } 803 }
804 804
805 ++D0ptr; 805 ++D0ptr;
@@ -1045,10 +1045,10 @@ void synth_full2(mad_fixed_t *pcm, mad_fixed_t (*fo)[8], mad_fixed_t (*fe)[8],
1045 1045
1046static 1046static
1047void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 1047void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1048 unsigned int nch, unsigned int ns) ICODE_ATTR_MPA_SYNTH; 1048 unsigned int nch, unsigned int ns) ICODE_ATTR_MPA_SYNTH;
1049static 1049static
1050void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 1050void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1051 unsigned int nch, unsigned int ns) 1051 unsigned int nch, unsigned int ns)
1052{ 1052{
1053 int p; 1053 int p;
1054 unsigned int phase, ch, s; 1054 unsigned int phase, ch, s;
@@ -1068,7 +1068,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1068 1068
1069 for (s = 0; s < ns; ++s) { 1069 for (s = 0; s < ns; ++s) {
1070 dct32((*sbsample)[s], phase >> 1, 1070 dct32((*sbsample)[s], phase >> 1,
1071 (*filter)[0][phase & 1], (*filter)[1][phase & 1]); 1071 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1072 1072
1073 p = (phase - 1) & 0xf; 1073 p = (phase - 1) & 0xf;
1074 1074
@@ -1189,7 +1189,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1189 1189
1190static 1190static
1191void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 1191void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1192 unsigned int nch, unsigned int ns) 1192 unsigned int nch, unsigned int ns)
1193{ 1193{
1194 int p, sb; 1194 int p, sb;
1195 unsigned int phase, ch, s; 1195 unsigned int phase, ch, s;
@@ -1209,7 +1209,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1209 1209
1210 for (s = 0; s < ns; ++s) { 1210 for (s = 0; s < ns; ++s) {
1211 dct32((*sbsample)[s], phase >> 1, 1211 dct32((*sbsample)[s], phase >> 1,
1212 (*filter)[0][phase & 1], (*filter)[1][phase & 1]); 1212 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1213 1213
1214 p = (phase - 1) & 0xf; 1214 p = (phase - 1) & 0xf;
1215 1215
@@ -1246,49 +1246,49 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1246 1246
1247 for (sb = 15; sb; sb--, fo++) 1247 for (sb = 15; sb; sb--, fo++)
1248 { 1248 {
1249 ++fe; 1249 ++fe;
1250 ++D0ptr; 1250 ++D0ptr;
1251 ++D1ptr; 1251 ++D1ptr;
1252 1252
1253 /* D[32 - sb][i] == -D[sb][31 - i] */ 1253 /* D[32 - sb][i] == -D[sb][31 - i] */
1254 ptr = *D0ptr; 1254 ptr = *D0ptr;
1255 ML0(hi, lo, (*fo)[0], ptr[ 1]); 1255 ML0(hi, lo, (*fo)[0], ptr[ 1]);
1256 MLA(hi, lo, (*fo)[1], ptr[15]); 1256 MLA(hi, lo, (*fo)[1], ptr[15]);
1257 MLA(hi, lo, (*fo)[2], ptr[13]); 1257 MLA(hi, lo, (*fo)[2], ptr[13]);
1258 MLA(hi, lo, (*fo)[3], ptr[11]); 1258 MLA(hi, lo, (*fo)[3], ptr[11]);
1259 MLA(hi, lo, (*fo)[4], ptr[ 9]); 1259 MLA(hi, lo, (*fo)[4], ptr[ 9]);
1260 MLA(hi, lo, (*fo)[5], ptr[ 7]); 1260 MLA(hi, lo, (*fo)[5], ptr[ 7]);
1261 MLA(hi, lo, (*fo)[6], ptr[ 5]); 1261 MLA(hi, lo, (*fo)[6], ptr[ 5]);
1262 MLA(hi, lo, (*fo)[7], ptr[ 3]); 1262 MLA(hi, lo, (*fo)[7], ptr[ 3]);
1263 MLN(hi, lo); 1263 MLN(hi, lo);
1264 MLA(hi, lo, (*fe)[7], ptr[ 2]); 1264 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1265 MLA(hi, lo, (*fe)[6], ptr[ 4]); 1265 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1266 MLA(hi, lo, (*fe)[5], ptr[ 6]); 1266 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1267 MLA(hi, lo, (*fe)[4], ptr[ 8]); 1267 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1268 MLA(hi, lo, (*fe)[3], ptr[10]); 1268 MLA(hi, lo, (*fe)[3], ptr[10]);
1269 MLA(hi, lo, (*fe)[2], ptr[12]); 1269 MLA(hi, lo, (*fe)[2], ptr[12]);
1270 MLA(hi, lo, (*fe)[1], ptr[14]); 1270 MLA(hi, lo, (*fe)[1], ptr[14]);
1271 MLA(hi, lo, (*fe)[0], ptr[ 0]); 1271 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1272 pcm[-sb] = SHIFT(MLZ(hi, lo)); 1272 pcm[-sb] = SHIFT(MLZ(hi, lo));
1273 1273
1274 ptr = *D1ptr; 1274 ptr = *D1ptr;
1275 ML0(hi, lo, (*fe)[0], ptr[31 - 16]); 1275 ML0(hi, lo, (*fe)[0], ptr[31 - 16]);
1276 MLA(hi, lo, (*fe)[1], ptr[31 - 14]); 1276 MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
1277 MLA(hi, lo, (*fe)[2], ptr[31 - 12]); 1277 MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
1278 MLA(hi, lo, (*fe)[3], ptr[31 - 10]); 1278 MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
1279 MLA(hi, lo, (*fe)[4], ptr[31 - 8]); 1279 MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
1280 MLA(hi, lo, (*fe)[5], ptr[31 - 6]); 1280 MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
1281 MLA(hi, lo, (*fe)[6], ptr[31 - 4]); 1281 MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
1282 MLA(hi, lo, (*fe)[7], ptr[31 - 2]); 1282 MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
1283 MLA(hi, lo, (*fo)[7], ptr[31 - 3]); 1283 MLA(hi, lo, (*fo)[7], ptr[31 - 3]);
1284 MLA(hi, lo, (*fo)[6], ptr[31 - 5]); 1284 MLA(hi, lo, (*fo)[6], ptr[31 - 5]);
1285 MLA(hi, lo, (*fo)[5], ptr[31 - 7]); 1285 MLA(hi, lo, (*fo)[5], ptr[31 - 7]);
1286 MLA(hi, lo, (*fo)[4], ptr[31 - 9]); 1286 MLA(hi, lo, (*fo)[4], ptr[31 - 9]);
1287 MLA(hi, lo, (*fo)[3], ptr[31 - 11]); 1287 MLA(hi, lo, (*fo)[3], ptr[31 - 11]);
1288 MLA(hi, lo, (*fo)[2], ptr[31 - 13]); 1288 MLA(hi, lo, (*fo)[2], ptr[31 - 13]);
1289 MLA(hi, lo, (*fo)[1], ptr[31 - 15]); 1289 MLA(hi, lo, (*fo)[1], ptr[31 - 15]);
1290 MLA(hi, lo, (*fo)[0], ptr[31 - 1]); 1290 MLA(hi, lo, (*fo)[0], ptr[31 - 1]);
1291 pcm[sb] = SHIFT(MLZ(hi, lo)); 1291 pcm[sb] = SHIFT(MLZ(hi, lo));
1292 } 1292 }
1293 1293
1294 ptr = *(D0ptr + 1); 1294 ptr = *(D0ptr + 1);
@@ -1327,49 +1327,49 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1327 1327
1328 for (sb = 15; sb; sb--, fo++) 1328 for (sb = 15; sb; sb--, fo++)
1329 { 1329 {
1330 ++fe; 1330 ++fe;
1331 ++D0ptr; 1331 ++D0ptr;
1332 ++D1ptr; 1332 ++D1ptr;
1333 1333
1334 /* D[32 - sb][i] == -D[sb][31 - i] */ 1334 /* D[32 - sb][i] == -D[sb][31 - i] */
1335 ptr = *D0ptr; 1335 ptr = *D0ptr;
1336 ML0(hi, lo, (*fo)[0], ptr[ 0]); 1336 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1337 MLA(hi, lo, (*fo)[1], ptr[14]); 1337 MLA(hi, lo, (*fo)[1], ptr[14]);
1338 MLA(hi, lo, (*fo)[2], ptr[12]); 1338 MLA(hi, lo, (*fo)[2], ptr[12]);
1339 MLA(hi, lo, (*fo)[3], ptr[10]); 1339 MLA(hi, lo, (*fo)[3], ptr[10]);
1340 MLA(hi, lo, (*fo)[4], ptr[ 8]); 1340 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1341 MLA(hi, lo, (*fo)[5], ptr[ 6]); 1341 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1342 MLA(hi, lo, (*fo)[6], ptr[ 4]); 1342 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1343 MLA(hi, lo, (*fo)[7], ptr[ 2]); 1343 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1344 MLN(hi, lo); 1344 MLN(hi, lo);
1345 MLA(hi, lo, (*fe)[7], ptr[ 3]); 1345 MLA(hi, lo, (*fe)[7], ptr[ 3]);
1346 MLA(hi, lo, (*fe)[6], ptr[ 5]); 1346 MLA(hi, lo, (*fe)[6], ptr[ 5]);
1347 MLA(hi, lo, (*fe)[5], ptr[ 7]); 1347 MLA(hi, lo, (*fe)[5], ptr[ 7]);
1348 MLA(hi, lo, (*fe)[4], ptr[ 9]); 1348 MLA(hi, lo, (*fe)[4], ptr[ 9]);
1349 MLA(hi, lo, (*fe)[3], ptr[11]); 1349 MLA(hi, lo, (*fe)[3], ptr[11]);
1350 MLA(hi, lo, (*fe)[2], ptr[13]); 1350 MLA(hi, lo, (*fe)[2], ptr[13]);
1351 MLA(hi, lo, (*fe)[1], ptr[15]); 1351 MLA(hi, lo, (*fe)[1], ptr[15]);
1352 MLA(hi, lo, (*fe)[0], ptr[ 1]); 1352 MLA(hi, lo, (*fe)[0], ptr[ 1]);
1353 pcm[-sb] = SHIFT(MLZ(hi, lo)); 1353 pcm[-sb] = SHIFT(MLZ(hi, lo));
1354 1354
1355 ptr = *D1ptr; 1355 ptr = *D1ptr;
1356 ML0(hi, lo, (*fe)[0], ptr[31 - 1]); 1356 ML0(hi, lo, (*fe)[0], ptr[31 - 1]);
1357 MLA(hi, lo, (*fe)[1], ptr[31 - 15]); 1357 MLA(hi, lo, (*fe)[1], ptr[31 - 15]);
1358 MLA(hi, lo, (*fe)[2], ptr[31 - 13]); 1358 MLA(hi, lo, (*fe)[2], ptr[31 - 13]);
1359 MLA(hi, lo, (*fe)[3], ptr[31 - 11]); 1359 MLA(hi, lo, (*fe)[3], ptr[31 - 11]);
1360 MLA(hi, lo, (*fe)[4], ptr[31 - 9]); 1360 MLA(hi, lo, (*fe)[4], ptr[31 - 9]);
1361 MLA(hi, lo, (*fe)[5], ptr[31 - 7]); 1361 MLA(hi, lo, (*fe)[5], ptr[31 - 7]);
1362 MLA(hi, lo, (*fe)[6], ptr[31 - 5]); 1362 MLA(hi, lo, (*fe)[6], ptr[31 - 5]);
1363 MLA(hi, lo, (*fe)[7], ptr[31 - 3]); 1363 MLA(hi, lo, (*fe)[7], ptr[31 - 3]);
1364 MLA(hi, lo, (*fo)[7], ptr[31 - 2]); 1364 MLA(hi, lo, (*fo)[7], ptr[31 - 2]);
1365 MLA(hi, lo, (*fo)[6], ptr[31 - 4]); 1365 MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
1366 MLA(hi, lo, (*fo)[5], ptr[31 - 6]); 1366 MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
1367 MLA(hi, lo, (*fo)[4], ptr[31 - 8]); 1367 MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
1368 MLA(hi, lo, (*fo)[3], ptr[31 - 10]); 1368 MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
1369 MLA(hi, lo, (*fo)[2], ptr[31 - 12]); 1369 MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
1370 MLA(hi, lo, (*fo)[1], ptr[31 - 14]); 1370 MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
1371 MLA(hi, lo, (*fo)[0], ptr[31 - 16]); 1371 MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
1372 pcm[sb] = SHIFT(MLZ(hi, lo)); 1372 pcm[sb] = SHIFT(MLZ(hi, lo));
1373 } 1373 }
1374 1374
1375 ptr = *(D0ptr + 1); 1375 ptr = *(D0ptr + 1);
@@ -1394,12 +1394,12 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
1394# endif 1394# endif
1395 1395
1396/* 1396/*
1397 * NAME: synth->half() 1397 * NAME: synth->half()
1398 * DESCRIPTION: perform half frequency PCM synthesis 1398 * DESCRIPTION: perform half frequency PCM synthesis
1399 */ 1399 */
1400static 1400static
1401void synth_half(struct mad_synth *synth, struct mad_frame const *frame, 1401void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
1402 unsigned int nch, unsigned int ns) 1402 unsigned int nch, unsigned int ns)
1403{ 1403{
1404 unsigned int phase, ch, s, sb, pe, po; 1404 unsigned int phase, ch, s, sb, pe, po;
1405 mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8]; 1405 mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8];
@@ -1417,7 +1417,7 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
1417 1417
1418 for (s = 0; s < ns; ++s) { 1418 for (s = 0; s < ns; ++s) {
1419 dct32((*sbsample)[s], phase >> 1, 1419 dct32((*sbsample)[s], phase >> 1,
1420 (*filter)[0][phase & 1], (*filter)[1][phase & 1]); 1420 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
1421 1421
1422 pe = phase & ~1; 1422 pe = phase & ~1;
1423 po = ((phase - 1) & 0xf) | 1; 1423 po = ((phase - 1) & 0xf) | 1;
@@ -1456,59 +1456,59 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
1456 pcm2 = pcm1 + 14; 1456 pcm2 = pcm1 + 14;
1457 1457
1458 for (sb = 1; sb < 16; ++sb) { 1458 for (sb = 1; sb < 16; ++sb) {
1459 ++fe; 1459 ++fe;
1460 ++Dptr; 1460 ++Dptr;
1461 1461
1462 /* D[32 - sb][i] == -D[sb][31 - i] */ 1462 /* D[32 - sb][i] == -D[sb][31 - i] */
1463 1463
1464 if (!(sb & 1)) { 1464 if (!(sb & 1)) {
1465 ptr = *Dptr + po; 1465 ptr = *Dptr + po;
1466 ML0(hi, lo, (*fo)[0], ptr[ 0]); 1466 ML0(hi, lo, (*fo)[0], ptr[ 0]);
1467 MLA(hi, lo, (*fo)[1], ptr[14]); 1467 MLA(hi, lo, (*fo)[1], ptr[14]);
1468 MLA(hi, lo, (*fo)[2], ptr[12]); 1468 MLA(hi, lo, (*fo)[2], ptr[12]);
1469 MLA(hi, lo, (*fo)[3], ptr[10]); 1469 MLA(hi, lo, (*fo)[3], ptr[10]);
1470 MLA(hi, lo, (*fo)[4], ptr[ 8]); 1470 MLA(hi, lo, (*fo)[4], ptr[ 8]);
1471 MLA(hi, lo, (*fo)[5], ptr[ 6]); 1471 MLA(hi, lo, (*fo)[5], ptr[ 6]);
1472 MLA(hi, lo, (*fo)[6], ptr[ 4]); 1472 MLA(hi, lo, (*fo)[6], ptr[ 4]);
1473 MLA(hi, lo, (*fo)[7], ptr[ 2]); 1473 MLA(hi, lo, (*fo)[7], ptr[ 2]);
1474 MLN(hi, lo); 1474 MLN(hi, lo);
1475 1475
1476 ptr = *Dptr + pe; 1476 ptr = *Dptr + pe;
1477 MLA(hi, lo, (*fe)[7], ptr[ 2]); 1477 MLA(hi, lo, (*fe)[7], ptr[ 2]);
1478 MLA(hi, lo, (*fe)[6], ptr[ 4]); 1478 MLA(hi, lo, (*fe)[6], ptr[ 4]);
1479 MLA(hi, lo, (*fe)[5], ptr[ 6]); 1479 MLA(hi, lo, (*fe)[5], ptr[ 6]);
1480 MLA(hi, lo, (*fe)[4], ptr[ 8]); 1480 MLA(hi, lo, (*fe)[4], ptr[ 8]);
1481 MLA(hi, lo, (*fe)[3], ptr[10]); 1481 MLA(hi, lo, (*fe)[3], ptr[10]);
1482 MLA(hi, lo, (*fe)[2], ptr[12]); 1482 MLA(hi, lo, (*fe)[2], ptr[12]);
1483 MLA(hi, lo, (*fe)[1], ptr[14]); 1483 MLA(hi, lo, (*fe)[1], ptr[14]);
1484 MLA(hi, lo, (*fe)[0], ptr[ 0]); 1484 MLA(hi, lo, (*fe)[0], ptr[ 0]);
1485 1485
1486 *pcm1++ = SHIFT(MLZ(hi, lo)); 1486 *pcm1++ = SHIFT(MLZ(hi, lo));
1487 1487
1488 ptr = *Dptr - po; 1488 ptr = *Dptr - po;
1489 ML0(hi, lo, (*fo)[7], ptr[31 - 2]); 1489 ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
1490 MLA(hi, lo, (*fo)[6], ptr[31 - 4]); 1490 MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
1491 MLA(hi, lo, (*fo)[5], ptr[31 - 6]); 1491 MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
1492 MLA(hi, lo, (*fo)[4], ptr[31 - 8]); 1492 MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
1493 MLA(hi, lo, (*fo)[3], ptr[31 - 10]); 1493 MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
1494 MLA(hi, lo, (*fo)[2], ptr[31 - 12]); 1494 MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
1495 MLA(hi, lo, (*fo)[1], ptr[31 - 14]); 1495 MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
1496 MLA(hi, lo, (*fo)[0], ptr[31 - 16]); 1496 MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
1497 1497
1498 ptr = *Dptr - pe; 1498 ptr = *Dptr - pe;
1499 MLA(hi, lo, (*fe)[0], ptr[31 - 16]); 1499 MLA(hi, lo, (*fe)[0], ptr[31 - 16]);
1500 MLA(hi, lo, (*fe)[1], ptr[31 - 14]); 1500 MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
1501 MLA(hi, lo, (*fe)[2], ptr[31 - 12]); 1501 MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
1502 MLA(hi, lo, (*fe)[3], ptr[31 - 10]); 1502 MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
1503 MLA(hi, lo, (*fe)[4], ptr[31 - 8]); 1503 MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
1504 MLA(hi, lo, (*fe)[5], ptr[31 - 6]); 1504 MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
1505 MLA(hi, lo, (*fe)[6], ptr[31 - 4]); 1505 MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
1506 MLA(hi, lo, (*fe)[7], ptr[31 - 2]); 1506 MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
1507 1507
1508 *pcm2-- = SHIFT(MLZ(hi, lo)); 1508 *pcm2-- = SHIFT(MLZ(hi, lo));
1509 } 1509 }
1510 1510
1511 ++fo; 1511 ++fo;
1512 } 1512 }
1513 1513
1514 ++Dptr; 1514 ++Dptr;
@@ -1532,14 +1532,14 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
1532} 1532}
1533 1533
1534/* 1534/*
1535 * NAME: synth->frame() 1535 * NAME: synth->frame()
1536 * DESCRIPTION: perform PCM synthesis of frame subband samples 1536 * DESCRIPTION: perform PCM synthesis of frame subband samples
1537 */ 1537 */
1538void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame) 1538void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame)
1539{ 1539{
1540 unsigned int nch, ns; 1540 unsigned int nch, ns;
1541 void (*synth_frame)(struct mad_synth *, struct mad_frame const *, 1541 void (*synth_frame)(struct mad_synth *, struct mad_frame const *,
1542 unsigned int, unsigned int); 1542 unsigned int, unsigned int);
1543 1543
1544 nch = MAD_NCHANNELS(&frame->header); 1544 nch = MAD_NCHANNELS(&frame->header);
1545 ns = MAD_NSBSAMPLES(&frame->header); 1545 ns = MAD_NSBSAMPLES(&frame->header);