summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2007-07-03 19:36:26 +0000
committerThom Johansen <thomj@rockbox.org>2007-07-03 19:36:26 +0000
commit4aeab55f67be12010250db884ef455340d0da341 (patch)
treefe1d432833a23d483fa67e51664092d5ade4a366
parent9337efdb7a157d5788b4ef45c8f2732024b3b3f4 (diff)
downloadrockbox-4aeab55f67be12010250db884ef455340d0da341.tar.gz
rockbox-4aeab55f67be12010250db884ef455340d0da341.zip
Replace some 64 bit multiplies with assembly on Coldfire targets. Codec lots closer to realtime on those targets now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13779 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libwma/wmadeci.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c
index 95e35c0d86..ee06033d85 100644
--- a/apps/codecs/libwma/wmadeci.c
+++ b/apps/codecs/libwma/wmadeci.c
@@ -96,6 +96,28 @@ static fixed64 Fixed32To64(fixed32 x)
96 : "cc"); \ 96 : "cc"); \
97 __result; \ 97 __result; \
98 }) 98 })
99#elif defined(CPU_COLDFIRE)
100 static inline int32_t fixmul32(int32_t x, int32_t y)
101 {
102 int32_t t1, t2;
103 asm volatile (
104 "mac.l %[x],%[y],%%acc0\n" /* multiply */
105 "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */
106 "movclr.l %%acc0,%[t1] \n" /* get higher half */
107 "moveq.l #15,%[t2] \n"
108 "asl.l %[t2],%[t1] \n" /* hi <<= 15, plus one free */
109 "moveq.l #16,%[t2] \n"
110 "lsr.l %[t2],%[x] \n" /* (unsigned)lo >>= 16 */
111 "or.l %[x],%[t1] \n" /* combine result */
112 : /* outputs */
113 [t1]"=&d"(t1),
114 [t2]"=&d"(t2),
115 [x] "+d" (x)
116 : /* inputs */
117 [y] "d" (y)
118 );
119 return t1;
120 }
99#else 121#else
100fixed32 fixmul32(fixed32 x, fixed32 y) 122fixed32 fixmul32(fixed32 x, fixed32 y)
101{ 123{
@@ -136,7 +158,7 @@ fixed32 fixmul32(fixed32 x, fixed32 y)
136 : "cc"); \ 158 : "cc"); \
137 __result; \ 159 __result; \
138 }) 160 })
139#else 161#elif !defined(CPU_COLDFIRE)
140static fixed32 fixmul32b(fixed32 x, fixed32 y) 162static fixed32 fixmul32b(fixed32 x, fixed32 y)
141{ 163{
142 fixed64 temp; 164 fixed64 temp;
@@ -428,6 +450,26 @@ uint32_t bswap_32(uint32_t x)
428 return (b1 >> 24) | (b2 >> 8) | (b3 << 8) | (b4 << 24); 450 return (b1 >> 24) | (b2 >> 8) | (b3 << 8) | (b4 << 24);
429} 451}
430 452
453#ifdef CPU_COLDFIRE
454static inline
455void CMUL(fixed32 *x, fixed32 *y,
456 fixed32 a, fixed32 b,
457 fixed32 t, fixed32 v)
458{
459 asm volatile ("mac.l %[a], %[t], %%acc0;"
460 "msac.l %[b], %[v], %%acc0;"
461 "mac.l %[b], %[t], %%acc1;"
462 "mac.l %[a], %[v], %%acc1;"
463 "movclr.l %%acc0, %[a];"
464 "move.l %[a], (%[x]);"
465 "movclr.l %%acc1, %[a];"
466 "move.l %[a], (%[y]);"
467 : [a] "+&r" (a)
468 : [x] "a" (x), [y] "a" (y),
469 [b] "r" (b), [t] "r" (t), [v] "r" (v)
470 : "cc", "memory");
471}
472#else
431// PJJ : reinstate macro 473// PJJ : reinstate macro
432void CMUL(fixed32 *pre, 474void CMUL(fixed32 *pre,
433 fixed32 *pim, 475 fixed32 *pim,
@@ -449,7 +491,7 @@ void CMUL(fixed32 *pre,
449 *pim = _r3 + _r4; 491 *pim = _r3 + _r4;
450 492
451} 493}
452 494#endif
453 495
454typedef struct CoefVLCTable 496typedef struct CoefVLCTable
455{ 497{
@@ -1191,6 +1233,9 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx)
1191 int sample_rate1; 1233 int sample_rate1;
1192 int coef_vlc_table; 1234 int coef_vlc_table;
1193 // int filehandle; 1235 // int filehandle;
1236 #ifdef CPU_COLDFIRE
1237 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
1238 #endif
1194 1239
1195 s->sample_rate = wfx->rate; 1240 s->sample_rate = wfx->rate;
1196 s->nb_channels = wfx->channels; 1241 s->nb_channels = wfx->channels;