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.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/apps/codecs/libmad/synth.c b/apps/codecs/libmad/synth.c
index 166e3d9f3a..bdec4258fb 100644
--- a/apps/codecs/libmad/synth.c
+++ b/apps/codecs/libmad/synth.c
@@ -102,7 +102,21 @@ void mad_synth_mute(struct mad_synth *synth)
102 102
103/* possible DCT speed optimization */ 103/* possible DCT speed optimization */
104 104
105# if defined(OPT_SPEED) && defined(MAD_F_MLX) 105/* This is a Coldfire version of the OPT_SPEED optimisation below, but in the
106 case of Coldfire it doesn't lose any more precision than we would ordinarily
107 lose, */
108# ifdef FPM_COLDFIRE_EMAC
109# define OPT_DCTO
110# define MUL(x, y) \
111 ({ \
112 mad_fixed64hi_t hi; \
113 asm volatile("mac.l %[a], %[b], %%acc0\n\t" \
114 "movclr.l %%acc0, %[hi]" \
115 : [hi] "=r" (hi) \
116 : [a] "r" ((x)), [b] "r" ((y))); \
117 hi; \
118 })
119# elif defined(OPT_SPEED) && defined(MAD_F_MLX)
106# define OPT_DCTO 120# define OPT_DCTO
107# define MUL(x, y) \ 121# define MUL(x, y) \
108 ({ mad_fixed64hi_t hi; \ 122 ({ mad_fixed64hi_t hi; \
@@ -555,8 +569,8 @@ void synth_full(struct mad_synth *, struct mad_frame const *,
555 * DESCRIPTION: perform full frequency PCM synthesis 569 * DESCRIPTION: perform full frequency PCM synthesis
556 */ 570 */
557 571
558/* optimised version of synth full, requires OPT_SSO at the moment */ 572/* optimised version of synth_full */
559# if CONFIG_CPU==MCF5249 && defined(OPT_SSO) && !defined(SIMULATOR) 573# ifdef FPM_COLDFIRE_EMAC
560static 574static
561void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 575void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
562 unsigned int nch, unsigned int ns) 576 unsigned int nch, unsigned int ns)
@@ -566,10 +580,9 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
566 mad_fixed_t const (*sbsample)[36][32]; 580 mad_fixed_t const (*sbsample)[36][32];
567 mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; 581 mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
568 mad_fixed_t const (*Dptr)[32]; 582 mad_fixed_t const (*Dptr)[32];
569 mad_fixed64hi_t hi = 0; 583 mad_fixed64hi_t hi;
570 mad_fixed64lo_t lo;
571 584
572 asm volatile("move.l #0, %macsr"); /* need integer mode */ 585 asm volatile("move.l #0x20, %macsr"); /* fractional mode */
573 586
574 for (ch = 0; ch < nch; ++ch) { 587 for (ch = 0; ch < nch; ++ch) {
575 sbsample = &frame->sbsample[ch]; 588 sbsample = &frame->sbsample[ch];
@@ -613,10 +626,12 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
613 "mac.l %%d5, %%a5, 16(%4), %%a5, %%acc0\n\t" 626 "mac.l %%d5, %%a5, 16(%4), %%a5, %%acc0\n\t"
614 "mac.l %%d6, %%a5, 8(%4), %%a5, %%acc0\n\t" 627 "mac.l %%d6, %%a5, 8(%4), %%a5, %%acc0\n\t"
615 "mac.l %%d7, %%a5, %%acc0\n\t" 628 "mac.l %%d7, %%a5, %%acc0\n\t"
616 "movclr.l %%acc0, %0" 629 "movclr.l %%acc0, %0\n\t"
617 : "=ad" (lo) : "a" (*fx), "a" (*Dptr + po), "a" (*fe), "a" (*Dptr + pe) : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5"); 630 : "=r" (hi)
631 : "a" (*fx), "a" (*Dptr + po), "a" (*fe), "a" (*Dptr + pe)
632 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
618 633
619 *pcm1++ = SHIFT(MLZ(hi, lo)); 634 *pcm1++ = hi << 3; /* shift result to libmad's fixed point format */
620 635
621 pcm2 = pcm1 + 30; 636 pcm2 = pcm1 + 30;
622 637
@@ -646,13 +661,13 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
646 "mac.l %%d2, %%a5, 56(%4), %%a5, %%acc0\n\t" 661 "mac.l %%d2, %%a5, 56(%4), %%a5, %%acc0\n\t"
647 "mac.l %%d1, %%a5, (%4), %%a5, %%acc0\n\t" 662 "mac.l %%d1, %%a5, (%4), %%a5, %%acc0\n\t"
648 "mac.l %%d0, %%a5, %%acc0\n\t" 663 "mac.l %%d0, %%a5, %%acc0\n\t"
649 "movclr.l %%acc0, %0" 664 "movclr.l %%acc0, %0\n\t"
650 : "=ad" (lo) 665 : "=r" (hi)
651 : "a" (*fo), "a" (*Dptr + po), "a" (*fe), "a" (*Dptr + pe) 666 : "a" (*fo), "a" (*Dptr + po), "a" (*fe), "a" (*Dptr + pe)
652 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5"); 667 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
653 668
654 *pcm1++ = SHIFT(MLZ(hi, lo)); 669 *pcm1++ = hi << 3;
655 670
656 asm volatile( 671 asm volatile(
657 "movem.l (%1), %%d0-%%d7\n\t" 672 "movem.l (%1), %%d0-%%d7\n\t"
658 "move.l 60(%2), %%a5\n\t" 673 "move.l 60(%2), %%a5\n\t"
@@ -674,12 +689,12 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
674 "mac.l %%d2, %%a5, 68(%4), %%a5, %%acc0\n\t" 689 "mac.l %%d2, %%a5, 68(%4), %%a5, %%acc0\n\t"
675 "mac.l %%d1, %%a5, 60(%4), %%a5, %%acc0\n\t" 690 "mac.l %%d1, %%a5, 60(%4), %%a5, %%acc0\n\t"
676 "mac.l %%d0, %%a5, %%acc0\n\t" 691 "mac.l %%d0, %%a5, %%acc0\n\t"
677 "movclr.l %%acc0, %0" 692 "movclr.l %%acc0, %0\n\t"
678 : "=ad" (lo) 693 : "=r" (hi)
679 : "a" (*fe), "a" (*Dptr - pe), "a" (*fo), "a" (*Dptr - po) 694 : "a" (*fe), "a" (*Dptr - pe), "a" (*fo), "a" (*Dptr - po)
680 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5"); 695 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
681 696
682 *pcm2-- = SHIFT(MLZ(hi, lo)); 697 *pcm2-- = hi << 3;
683 698
684 ++fo; 699 ++fo;
685 } 700 }
@@ -696,11 +711,11 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
696 "mac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t" 711 "mac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
697 "mac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t" 712 "mac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
698 "mac.l %%d7, %%a5, %%acc0\n\t" 713 "mac.l %%d7, %%a5, %%acc0\n\t"
699 "movclr.l %%acc0, %0" 714 "movclr.l %%acc0, %0\n\t"
700 : "=ad" (lo) : "a" (*fo), "a" (*Dptr + po) 715 : "=r" (hi) : "a" (*fo), "a" (*Dptr + po)
701 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5"); 716 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
702 717
703 *pcm1 = SHIFT(-MLZ(hi, lo)); 718 *pcm1 = -(hi << 3);
704 pcm1 += 16; 719 pcm1 += 16;
705 720
706 phase = (phase + 1) % 16; 721 phase = (phase + 1) % 16;