summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-02-20 23:52:47 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-02-20 23:52:47 +0000
commitd04dbca00b2f288aa02978623cf9f412fb09c56b (patch)
treeb16d80223f32b958cf95991d92df54c1b3d79ab7 /apps
parentefd78238f602bc1d05670b1bc4396ba53e31b804 (diff)
downloadrockbox-d04dbca00b2f288aa02978623cf9f412fb09c56b.tar.gz
rockbox-d04dbca00b2f288aa02978623cf9f412fb09c56b.zip
Speed dsp gain up slightly mostly with better code order
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8758 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/dsp.c68
1 files changed, 40 insertions, 28 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index daecd5c69e..f9d4bf16d5 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -84,17 +84,25 @@
84 * to multiply with into x from s (and increase s); x must contain the 84 * to multiply with into x from s (and increase s); x must contain the
85 * initial value. 85 * initial value.
86 */ 86 */
87#define FRACMUL_8_LOOP(x, y, s) \ 87#define FRACMUL_8_LOOP_PART(x, s, d, y) \
88({ \ 88{ \
89 long t; \
90 long u; \ 89 long u; \
91 asm volatile ("mac.l %[a], %[b], (%[c])+, %[a], %%acc0\n\t" \ 90 asm volatile ("mac.l %[a], %[b], (%[c])+, %[a], %%acc0\n\t" \
92 "move.l %%accext01, %[u]\n\t" \ 91 "move.l %%accext01, %[u]\n\t" \
93 "movclr.l %%acc0, %[t]\n\t" \ 92 "movclr.l %%acc0, %[t]" \
94 : [a] "+r" (x), [c] "+a" (s), [t] "=r" (t), [u] "=r" (u) \ 93 : [a] "+r" (x), [c] "+a" (s), [t] "=r" (d), [u] "=r" (u) \
95 : [b] "r" (y)); \ 94 : [b] "r" (y)); \
96 (t << 8) | (u & 0xff); \ 95 d = (d << 8) | (u & 0xff); \
97}) 96}
97
98#define FRACMUL_8_LOOP(x, y, s, d) \
99{ \
100 long t; \
101 FRACMUL_8_LOOP_PART(x, s, t, y); \
102 asm volatile ("move.l %[t],(%[d])+" \
103 : [d] "+a" (d)\
104 : [t] "r" (t)); \
105}
98 106
99#define ACC(acc, x, y) \ 107#define ACC(acc, x, y) \
100 (void)acc; \ 108 (void)acc; \
@@ -118,11 +126,11 @@
118#define GET_ACC(acc) acc 126#define GET_ACC(acc) acc
119#define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31)) 127#define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31))
120#define FRACMUL_8(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 23)) 128#define FRACMUL_8(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 23))
121#define FRACMUL_8_LOOP(x, y, s) \ 129#define FRACMUL_8_LOOP(x, y, s, d) \
122({ \ 130({ \
123 long t = x; \ 131 long t = x; \
124 x = *(s)++; \ 132 x = *(s)++; \
125 (long) (((((long long) (t)) * ((long long) (y))) >> 23)); \ 133 *(d)++ = (long) (((((long long) (t)) * ((long long) (y))) >> 23)); \
126}) 134})
127 135
128#endif 136#endif
@@ -695,36 +703,40 @@ static void eq_process(long **x, unsigned num)
695 * the src array if gain was applied. 703 * the src array if gain was applied.
696 * Note that this must be called before the resampler. 704 * Note that this must be called before the resampler.
697 */ 705 */
698static void apply_gain(long* src[], int count) 706static void apply_gain(long* _src[], int _count)
699{ 707{
700 if (dsp->replaygain) 708 struct dsp_config *my_dsp = dsp;
709 if (my_dsp->replaygain)
701 { 710 {
711 long** src = _src;
712 int count = _count;
702 long* s0 = src[0]; 713 long* s0 = src[0];
703 long* s1 = src[1]; 714 long* s1 = src[1];
704 long* d0 = &sample_buf[0]; 715 long gain = my_dsp->replaygain;
705 long* d1 = (s0 == s1) ? d0 : &sample_buf[SAMPLE_BUF_SIZE / 2];
706 long gain = dsp->replaygain;
707 long s; 716 long s;
708 long i; 717 int i;
709 718 long *d;
710 src[0] = d0;
711 src[1] = d1;
712 s = *s0++;
713
714 for (i = 0; i < count; i++)
715 {
716 *d0++ = FRACMUL_8_LOOP(s, gain, s0);
717 }
718 719
719 if (src [0] != src [1]) 720 if (s0 != s1)
720 { 721 {
722 d = &sample_buf[SAMPLE_BUF_SIZE / 2];
723 src[1] = d;
721 s = *s1++; 724 s = *s1++;
722 725
723 for (i = 0; i < count; i++) 726 for (i = 0; i < count; i++)
724 { 727 FRACMUL_8_LOOP(s, gain, s1, d);
725 *d1++ = FRACMUL_8_LOOP(s, gain, s1); 728 }
726 } 729 else
730 {
731 src[1] = &sample_buf[0];
727 } 732 }
733
734 d = &sample_buf[0];
735 src[0] = d;
736 s = *s0++;
737
738 for (i = 0; i < count; i++)
739 FRACMUL_8_LOOP(s, gain, s0, d);
728 } 740 }
729} 741}
730 742