summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-11-25 19:42:26 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-11-25 19:42:26 +0000
commitfabbeba59ad1de226f5710cf5dfc216850181972 (patch)
tree6b15e0482daab21acbe20dffb2b0950cad4c4ce7
parent65c46e8d777903df6f616db5f3bf0eb9bc179464 (diff)
downloadrockbox-fabbeba59ad1de226f5710cf5dfc216850181972.tar.gz
rockbox-fabbeba59ad1de226f5710cf5dfc216850181972.tar.bz2
rockbox-fabbeba59ad1de226f5710cf5dfc216850181972.zip
Solve FS#12396 through rolling back r26592. This fixes distortions while mpc playback on Coldfire targets with GCC 4.5.2.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31054 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libmusepack/mpcdec_math.h100
1 files changed, 57 insertions, 43 deletions
diff --git a/apps/codecs/libmusepack/mpcdec_math.h b/apps/codecs/libmusepack/mpcdec_math.h
index f4c87324b5..955681f4e5 100644
--- a/apps/codecs/libmusepack/mpcdec_math.h
+++ b/apps/codecs/libmusepack/mpcdec_math.h
@@ -56,50 +56,64 @@
#define MPC_SHR_RND(X, Y) ((X+(1<<(Y-1)))>>Y)
- #if defined(CPU_COLDFIRE)
- /* Calculate: result = (X*Y)>>14 */
- #define MPC_MULTIPLY(X,Y) \
- ({ \
- MPC_SAMPLE_FORMAT t1; \
- MPC_SAMPLE_FORMAT t2; \
- asm volatile ( \
- "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \
- "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \
- "movclr.l %%acc0,%[t1] \n\t" /* get higher half */ \
- "moveq.l #17,%[t2] \n\t" \
- "asl.l %[t2],%[t1] \n\t" /* hi <<= 17, plus one free */ \
- "moveq.l #14,%[t2] \n\t" \
- "lsr.l %[t2],%[x] \n\t" /* (unsigned)lo >>= 14 */ \
- "or.l %[x],%[t1] \n" /* combine result */ \
- : [t1]"=&d"(t1), [t2]"=&d"(t2) \
- : [x]"d"((X)), [y] "d"((Y))); \
- t1; \
- })
+#if defined(CPU_COLDFIRE)
- /* Calculate: result = (X*Y)>>Z */
- #define MPC_MULTIPLY_EX(X,Y,Z) \
- ({ \
- MPC_SAMPLE_FORMAT t1; \
- MPC_SAMPLE_FORMAT t2; \
- asm volatile ( \
- "mac.l %[x],%[y],%%acc0\n\t" /* multiply */ \
- "mulu.l %[y],%[x] \n\t" /* get lower half, avoid emac stall */ \
- "movclr.l %%acc0,%[t1] \n\t" /* get higher half */ \
- "moveq.l #31,%[t2] \n\t" \
- "sub.l %[sh],%[t2] \n\t" /* t2 = 31 - shift */ \
- "ble.s 1f \n\t" \
- "asl.l %[t2],%[t1] \n\t" /* hi <<= 31 - shift */ \
- "lsr.l %[sh],%[x] \n\t" /* (unsigned)lo >>= shift */ \
- "or.l %[x],%[t1] \n\t" /* combine result */ \
- "bra.s 2f \n\t" \
- "1: \n\t" \
- "neg.l %[t2] \n\t" /* t2 = shift - 31 */ \
- "asr.l %[t2],%[t1] \n\t" /* hi >>= t2 */ \
- "2: \n" \
- : [t1]"=&d"(t1), [t2]"=&d"(t2) \
- : [x] "d"((X)), [y] "d"((Y)), [sh]"d"((Z))); \
- t1; \
- })
+ #define MPC_MULTIPLY(X,Y) mpc_multiply((X), (Y))
+ #define MPC_MULTIPLY_EX(X,Y,Z) mpc_multiply_ex((X), (Y), (Z))
+
+ static inline MPC_SAMPLE_FORMAT mpc_multiply(MPC_SAMPLE_FORMAT x,
+ MPC_SAMPLE_FORMAT y)
+ {
+ MPC_SAMPLE_FORMAT t1, t2;
+ asm volatile (
+ "mac.l %[x],%[y],%%acc0\n" /* multiply */
+ "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */
+ "movclr.l %%acc0,%[t1] \n" /* get higher half */
+ "moveq.l #17,%[t2] \n"
+ "asl.l %[t2],%[t1] \n" /* hi <<= 17, plus one free */
+ "moveq.l #14,%[t2] \n"
+ "lsr.l %[t2],%[x] \n" /* (unsigned)lo >>= 14 */
+ "or.l %[x],%[t1] \n" /* combine result */
+ : /* outputs */
+ [t1]"=&d"(t1),
+ [t2]"=&d"(t2),
+ [x] "+d" (x)
+ : /* inputs */
+ [y] "d" (y)
+ );
+ return t1;
+ }
+
+ static inline MPC_SAMPLE_FORMAT mpc_multiply_ex(MPC_SAMPLE_FORMAT x,
+ MPC_SAMPLE_FORMAT y,
+ unsigned shift)
+ {
+ MPC_SAMPLE_FORMAT t1, t2;
+ asm volatile (
+ "mac.l %[x],%[y],%%acc0\n" /* multiply */
+ "mulu.l %[y],%[x] \n" /* get lower half, avoid emac stall */
+ "movclr.l %%acc0,%[t1] \n" /* get higher half */
+ "moveq.l #31,%[t2] \n"
+ "sub.l %[sh],%[t2] \n" /* t2 = 31 - shift */
+ "ble.s 1f \n"
+ "asl.l %[t2],%[t1] \n" /* hi <<= 31 - shift */
+ "lsr.l %[sh],%[x] \n" /* (unsigned)lo >>= shift */
+ "or.l %[x],%[t1] \n" /* combine result */
+ "bra.s 2f \n"
+ "1: \n"
+ "neg.l %[t2] \n" /* t2 = shift - 31 */
+ "asr.l %[t2],%[t1] \n" /* hi >>= t2 */
+ "2: \n"
+ : /* outputs */
+ [t1]"=&d"(t1),
+ [t2]"=&d"(t2),
+ [x] "+d" (x)
+ : /* inputs */
+ [y] "d" (y),
+ [sh]"d" (shift)
+ );
+ return t1;
+ }
#elif defined(CPU_ARM)
/* Calculate: result = (X*Y)>>14 */
#define MPC_MULTIPLY(X,Y) \