summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2005-03-04 10:37:15 +0000
committerThom Johansen <thomj@rockbox.org>2005-03-04 10:37:15 +0000
commitee811a34433e88c965090fc9e936dc46db48f737 (patch)
tree3c6c60ae6434d760435985f3f4731c3a02840618 /apps
parentd787c836bcaa0193ea1cfd5ac4a7918a52291e52 (diff)
downloadrockbox-ee811a34433e88c965090fc9e936dc46db48f737.tar.gz
rockbox-ee811a34433e88c965090fc9e936dc46db48f737.zip
Inserted optimized synth_full and put some vital data in IRAM.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6131 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/libmad/synth.c168
-rw-r--r--apps/plugins/mpa2wav.c6
2 files changed, 165 insertions, 9 deletions
diff --git a/apps/codecs/libmad/synth.c b/apps/codecs/libmad/synth.c
index aa9862c3e4..530f33cdf6 100644
--- a/apps/codecs/libmad/synth.c
+++ b/apps/codecs/libmad/synth.c
@@ -24,7 +24,6 @@
24# endif 24# endif
25 25
26# include "global.h" 26# include "global.h"
27
28# include "fixed.h" 27# include "fixed.h"
29# include "frame.h" 28# include "frame.h"
30# include "synth.h" 29# include "synth.h"
@@ -101,7 +100,6 @@ void mad_synth_mute(struct mad_synth *synth)
101# endif 100# endif
102 101
103/* possible DCT speed optimization */ 102/* possible DCT speed optimization */
104
105# if defined(OPT_SPEED) && defined(MAD_F_MLX) 103# if defined(OPT_SPEED) && defined(MAD_F_MLX)
106# define OPT_DCTO 104# define OPT_DCTO
107# define MUL(x, y) \ 105# define MUL(x, y) \
@@ -114,7 +112,6 @@ void mad_synth_mute(struct mad_synth *synth)
114# undef OPT_DCTO 112# undef OPT_DCTO
115# define MUL(x, y) mad_f_mul((x), (y)) 113# define MUL(x, y) mad_f_mul((x), (y))
116# endif 114# endif
117
118/* 115/*
119 * NAME: dct32() 116 * NAME: dct32()
120 * DESCRIPTION: perform fast in[32]->out[32] DCT 117 * DESCRIPTION: perform fast in[32]->out[32] DCT
@@ -161,7 +158,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
161# define costab9 MAD_F(0x73b5ebd1) 158# define costab9 MAD_F(0x73b5ebd1)
162# define costab10 MAD_F(0x70e2cbc6) 159# define costab10 MAD_F(0x70e2cbc6)
163# define costab11 MAD_F(0x6dca0d14) 160# define costab11 MAD_F(0x6dca0d14)
164# define costab12 MAD_F(0x6a6d98a4) 161# define costab12 MAD_F(0x6a5d98a4)
165# define costab13 MAD_F(0x66cf8120) 162# define costab13 MAD_F(0x66cf8120)
166# define costab14 MAD_F(0x62f201ac) 163# define costab14 MAD_F(0x62f201ac)
167# define costab15 MAD_F(0x5ed77c8a) 164# define costab15 MAD_F(0x5ed77c8a)
@@ -211,7 +208,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
211# define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */ 208# define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */
212# define costab28 MAD_F(0x031f1708) /* 0.195090322 */ 209# define costab28 MAD_F(0x031f1708) /* 0.195090322 */
213# define costab29 MAD_F(0x0259020e) /* 0.146730474 */ 210# define costab29 MAD_F(0x0259020e) /* 0.146730474 */
214# define costab30 MAD_F(0x01917a6c) /* 0.098017140 */ 211# define costab30 MAD_F(0x01917a5c) /* 0.098017140 */
215# define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */ 212# define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */
216# endif 213# endif
217 214
@@ -542,7 +539,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
542# endif 539# endif
543 540
544static 541static
545mad_fixed_t const D[17][32] = { 542mad_fixed_t const D[17][32] __attribute__ ((section(".idata"))) = {
546# include "D.dat" 543# include "D.dat"
547}; 544};
548 545
@@ -550,10 +547,167 @@ mad_fixed_t const D[17][32] = {
550void synth_full(struct mad_synth *, struct mad_frame const *, 547void synth_full(struct mad_synth *, struct mad_frame const *,
551 unsigned int, unsigned int); 548 unsigned int, unsigned int);
552# else 549# else
550
553/* 551/*
554 * NAME: synth->full() 552 * NAME: synth->full()
555 * DESCRIPTION: perform full frequency PCM synthesis 553 * DESCRIPTION: perform full frequency PCM synthesis
556 */ 554 */
555
556/* optimised version of synth full, requires OPT_SSO at the moment */
557# if CONFIG_CPU==MCF5249 && defined(OPT_SSO) && !defined(SIMULATOR)
558static
559void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
560 unsigned int nch, unsigned int ns)
561{
562 unsigned int phase, ch, s, sb, pe, po;
563 mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8];
564 mad_fixed_t const (*sbsample)[36][32];
565 mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
566 mad_fixed_t const (*Dptr)[32], *ptr;
567 mad_fixed64hi_t hi = 0;
568 mad_fixed64lo_t lo;
569
570 asm volatile("move.l #0, %macsr"); /* need integer mode */
571
572 for (ch = 0; ch < nch; ++ch) {
573 sbsample = &frame->sbsample[ch];
574 filter = &synth->filter[ch];
575 phase = synth->phase;
576 pcm1 = synth->pcm.samples[ch];
577
578 for (s = 0; s < ns; ++s) {
579 dct32((*sbsample)[s], phase >> 1,
580 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
581
582 pe = phase & ~1;
583 po = ((phase - 1) & 0xf) | 1;
584
585 /* calculate 32 samples */
586
587 fe = &(*filter)[0][ phase & 1][0];
588 fx = &(*filter)[0][~phase & 1][0];
589 fo = &(*filter)[1][~phase & 1][0];
590
591 Dptr = &D[0];
592
593 asm volatile(
594 "movem.l (%1), %%d0-%%d7\n\t"
595 "move.l (%2), %%a5\n\t"
596 "msac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
597 "msac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
598 "msac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
599 "msac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
600 "msac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
601 "msac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
602 "msac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
603 "msac.l %%d7, %%a5, (%4), %%a5, %%acc0\n\t"
604
605 "movem.l (%3), %%d0-%%d7\n\t"
606 "mac.l %%d0, %%a5, 56(%4), %%a5, %%acc0\n\t"
607 "mac.l %%d1, %%a5, 48(%4), %%a5, %%acc0\n\t"
608 "mac.l %%d2, %%a5, 40(%4), %%a5, %%acc0\n\t"
609 "mac.l %%d3, %%a5, 32(%4), %%a5, %%acc0\n\t"
610 "mac.l %%d4, %%a5, 24(%4), %%a5, %%acc0\n\t"
611 "mac.l %%d5, %%a5, 16(%4), %%a5, %%acc0\n\t"
612 "mac.l %%d6, %%a5, 8(%4), %%a5, %%acc0\n\t"
613 "mac.l %%d7, %%a5, %%acc0\n\t"
614 "movclr.l %%acc0, %0"
615 : "=ad" (lo) : "a" (*fx), "a" (*Dptr + po), "a" (*fe), "a" (*Dptr + pe) : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
616
617 *pcm1++ = SHIFT(MLZ(hi, lo));
618
619 pcm2 = pcm1 + 30;
620
621 for (sb = 1; sb < 16; ++sb) {
622 ++fe;
623 ++Dptr;
624
625 /* D[32 - sb][i] == -D[sb][31 - i] */
626 asm volatile (
627 "movem.l (%1), %%d0-%%d7\n\t"
628 "move.l (%2), %%a5\n\t"
629 "msac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
630 "msac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
631 "msac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
632 "msac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
633 "msac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
634 "msac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
635 "msac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
636 "msac.l %%d7, %%a5, 8(%4), %%a5, %%acc0\n\t"
637
638 "movem.l (%3), %%d0-%%d7\n\t"
639 "mac.l %%d7, %%a5, 16(%4), %%a5, %%acc0\n\t"
640 "mac.l %%d6, %%a5, 24(%4), %%a5, %%acc0\n\t"
641 "mac.l %%d5, %%a5, 32(%4), %%a5, %%acc0\n\t"
642 "mac.l %%d4, %%a5, 40(%4), %%a5, %%acc0\n\t"
643 "mac.l %%d3, %%a5, 48(%4), %%a5, %%acc0\n\t"
644 "mac.l %%d2, %%a5, 56(%4), %%a5, %%acc0\n\t"
645 "mac.l %%d1, %%a5, (%4), %%a5, %%acc0\n\t"
646 "mac.l %%d0, %%a5, %%acc0\n\t"
647 "movclr.l %%acc0, %0"
648 : "=ad" (lo)
649 : "a" (*fo), "a" (*Dptr + po), "a" (*fe), "a" (*Dptr + pe)
650 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
651
652 *pcm1++ = SHIFT(MLZ(hi, lo));
653
654 asm volatile(
655 "movem.l (%1), %%d0-%%d7\n\t"
656 "move.l 60(%2), %%a5\n\t"
657 "mac.l %%d0, %%a5, 68(%2), %%a5, %%acc0\n\t"
658 "mac.l %%d1, %%a5, 76(%2), %%a5, %%acc0\n\t"
659 "mac.l %%d2, %%a5, 84(%2), %%a5, %%acc0\n\t"
660 "mac.l %%d3, %%a5, 92(%2), %%a5, %%acc0\n\t"
661 "mac.l %%d4, %%a5, 100(%2), %%a5, %%acc0\n\t"
662 "mac.l %%d5, %%a5, 108(%2), %%a5, %%acc0\n\t"
663 "mac.l %%d6, %%a5, 116(%2), %%a5, %%acc0\n\t"
664 "mac.l %%d7, %%a5, 116(%4), %%a5, %%acc0\n\t"
665
666 "movem.l (%3), %%d0-%%d7\n\t"
667 "mac.l %%d7, %%a5, 108(%4), %%a5, %%acc0\n\t"
668 "mac.l %%d6, %%a5, 100(%4), %%a5, %%acc0\n\t"
669 "mac.l %%d5, %%a5, 92(%4), %%a5, %%acc0\n\t"
670 "mac.l %%d4, %%a5, 84(%4), %%a5, %%acc0\n\t"
671 "mac.l %%d3, %%a5, 76(%4), %%a5, %%acc0\n\t"
672 "mac.l %%d2, %%a5, 68(%4), %%a5, %%acc0\n\t"
673 "mac.l %%d1, %%a5, 60(%4), %%a5, %%acc0\n\t"
674 "mac.l %%d0, %%a5, %%acc0\n\t"
675 "movclr.l %%acc0, %0"
676 : "=ad" (lo)
677 : "a" (*fe), "a" (*Dptr - pe), "a" (*fo), "a" (*Dptr - po)
678 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
679
680 *pcm2-- = SHIFT(MLZ(hi, lo));
681
682 ++fo;
683 }
684
685 ++Dptr;
686 asm volatile(
687 "movem.l (%1), %%d0-%%d7\n\t"
688 "move.l (%2), %%a5\n\t"
689 "mac.l %%d0, %%a5, 56(%2), %%a5, %%acc0\n\t"
690 "mac.l %%d1, %%a5, 48(%2), %%a5, %%acc0\n\t"
691 "mac.l %%d2, %%a5, 40(%2), %%a5, %%acc0\n\t"
692 "mac.l %%d3, %%a5, 32(%2), %%a5, %%acc0\n\t"
693 "mac.l %%d4, %%a5, 24(%2), %%a5, %%acc0\n\t"
694 "mac.l %%d5, %%a5, 16(%2), %%a5, %%acc0\n\t"
695 "mac.l %%d6, %%a5, 8(%2), %%a5, %%acc0\n\t"
696 "mac.l %%d7, %%a5, %%acc0\n\t"
697 "movclr.l %%acc0, %0"
698 : "=ad" (lo) : "a" (*fo), "a" (*Dptr + po)
699 : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a5");
700
701 *pcm1 = SHIFT(-MLZ(hi, lo));
702 pcm1 += 16;
703
704 phase = (phase + 1) % 16;
705 }
706 }
707}
708
709#else
710
557static 711static
558void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 712void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
559 unsigned int nch, unsigned int ns) 713 unsigned int nch, unsigned int ns)
@@ -686,6 +840,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
686 } 840 }
687} 841}
688# endif 842# endif
843# endif
689 844
690/* 845/*
691 * NAME: synth->half() 846 * NAME: synth->half()
@@ -855,3 +1010,4 @@ void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame)
855 1010
856 synth->phase = (synth->phase + ns) % 16; 1011 synth->phase = (synth->phase + ns) % 16;
857} 1012}
1013
diff --git a/apps/plugins/mpa2wav.c b/apps/plugins/mpa2wav.c
index 2a87801999..6c28100800 100644
--- a/apps/plugins/mpa2wav.c
+++ b/apps/plugins/mpa2wav.c
@@ -28,9 +28,9 @@
28 28
29static struct plugin_api* rb; 29static struct plugin_api* rb;
30 30
31struct mad_stream Stream; 31struct mad_stream Stream __attribute__ ((section(".idata")));
32struct mad_frame Frame; 32struct mad_frame Frame __attribute__ ((section(".idata")));
33struct mad_synth Synth; 33struct mad_synth Synth __attribute__ ((section(".idata")));
34mad_timer_t Timer; 34mad_timer_t Timer;
35struct dither d0, d1; 35struct dither d0, d1;
36 36