summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmad/fixed.h
Side-by-side diff
Diffstat (limited to 'core/multimedia/opieplayer/libmad/fixed.h') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/fixed.h111
1 files changed, 67 insertions, 44 deletions
diff --git a/core/multimedia/opieplayer/libmad/fixed.h b/core/multimedia/opieplayer/libmad/fixed.h
index c9b98ca..baa7dc5 100644
--- a/core/multimedia/opieplayer/libmad/fixed.h
+++ b/core/multimedia/opieplayer/libmad/fixed.h
@@ -2,3 +2,3 @@
* libmad - MPEG audio decoder library
- * Copyright (C) 2000-2001 Robert Leslie
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
*
@@ -210,2 +210,17 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
})
+# elif defined(OPT_INTEL)
+/*
+ * Alternate Intel scaling that may or may not perform better.
+ */
+# define mad_f_scale64(hi, lo) \
+ ({ mad_fixed_t __result; \
+ asm ("shrl %3,%1\n\t" \
+ "shll %4,%2\n\t" \
+ "orl %2,%1" \
+ : "=rm" (__result) \
+ : "0" (lo), "r" (hi), \
+ "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS) \
+ : "cc"); \
+ __result; \
+ })
# else
@@ -234,8 +249,4 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
/*
- * There's a bug somewhere, possibly in the compiler, that sometimes makes
- * this necessary instead of the default implementation via MAD_F_MLX and
- * mad_f_scale64. It may be related to the use (or lack) of
- * -finline-functions and/or -fstrength-reduce.
- *
- * This is also apparently faster than MAD_F_MLX/mad_f_scale64.
+ * This is faster than the default implementation via MAD_F_MLX() and
+ * mad_f_scale64().
*/
@@ -277,3 +288,3 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
"adc %0, %0, %2, lsl %4" \
- : "=r" (__result) \
+ : "=&r" (__result) \
: "r" (lo), "r" (hi), \
@@ -345,14 +356,21 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
/*
- * This PowerPC version is tuned for the 4xx embedded processors. It is
- * effectively a tuned version of FPM_64BIT. It is a little faster and just
- * as accurate. The disposition of the least significant bit depends on
- * OPT_ACCURACY via mad_f_scale64().
+ * This PowerPC version is fast and accurate; the disposition of the least
+ * significant bit depends on OPT_ACCURACY via mad_f_scale64().
*/
# define MAD_F_MLX(hi, lo, x, y) \
- asm ("mulhw %1, %2, %3\n\t" \
- "mullw %0, %2, %3" \
- : "=&r" (lo), "=&r" (hi) \
- : "%r" (x), "r" (y))
+ do { \
+ asm ("mullw %0,%1,%2" \
+ : "=r" (lo) \
+ : "%r" (x), "r" (y)); \
+ asm ("mulhw %0,%1,%2" \
+ : "=r" (hi) \
+ : "%r" (x), "r" (y)); \
+ } \
+ while (0)
-# define MAD_F_MLA(hi, lo, x, y) \
+# if defined(OPT_ACCURACY)
+/*
+ * This gives best accuracy but is not very fast.
+ */
+# define MAD_F_MLA(hi, lo, x, y) \
({ mad_fixed64hi_t __hi; \
@@ -360,7 +378,10 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
MAD_F_MLX(__hi, __lo, (x), (y)); \
- asm ("addc %0, %2, %3\n\t" \
- "adde %1, %4, %5" \
+ asm ("addc %0,%2,%3\n\t" \
+ "adde %1,%4,%5" \
: "=r" (lo), "=r" (hi) \
- : "%r" (__lo), "0" (lo), "%r" (__hi), "1" (hi)); \
+ : "%r" (lo), "r" (__lo), \
+ "%r" (hi), "r" (__hi) \
+ : "xer"); \
})
+# endif
@@ -368,20 +389,19 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
/*
- * This is accurate and ~2 - 2.5 times slower than the unrounded version.
- *
- * The __volatile__ improves the generated code by another 5% (fewer spills
- * to memory); eventually they should be removed.
+ * This is slower than the truncating version below it.
*/
# define mad_f_scale64(hi, lo) \
- ({ mad_fixed_t __result; \
- mad_fixed64hi_t __hi_; \
- mad_fixed64lo_t __lo_; \
- asm __volatile__ ("addc %0, %2, %4\n\t" \
- "addze %1, %3" \
- : "=r" (__lo_), "=r" (__hi_) \
- : "r" (lo), "r" (hi), "r" (1 << (MAD_F_SCALEBITS - 1))); \
- asm __volatile__ ("rlwinm %0, %2,32-%3,0,%3-1\n\t" \
- "rlwimi %0, %1,32-%3,%3,31" \
- : "=&r" (__result) \
- : "r" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS)); \
- __result; \
+ ({ mad_fixed_t __result, __round; \
+ asm ("rotrwi %0,%1,%2" \
+ : "=r" (__result) \
+ : "r" (lo), "i" (MAD_F_SCALEBITS)); \
+ asm ("extrwi %0,%1,1,0" \
+ : "=r" (__round) \
+ : "r" (__result)); \
+ asm ("insrwi %0,%1,%2,0" \
+ : "+r" (__result) \
+ : "r" (hi), "i" (MAD_F_SCALEBITS)); \
+ asm ("add %0,%1,%2" \
+ : "=r" (__result) \
+ : "%r" (__result), "r" (__round)); \
+ __result; \
})
@@ -390,9 +410,11 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
({ mad_fixed_t __result; \
- asm ("rlwinm %0, %2,32-%3,0,%3-1\n\t" \
- "rlwimi %0, %1,32-%3,%3,31" \
+ asm ("rotrwi %0,%1,%2" \
: "=r" (__result) \
- : "r" (lo), "r" (hi), "I" (MAD_F_SCALEBITS)); \
- __result; \
+ : "r" (lo), "i" (MAD_F_SCALEBITS)); \
+ asm ("insrwi %0,%1,%2,0" \
+ : "+r" (__result) \
+ : "r" (hi), "i" (MAD_F_SCALEBITS)); \
+ __result; \
})
-# endif /* OPT_ACCURACY */
+# endif
@@ -430,4 +452,4 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
# define mad_f_mul(x, y) \
- ({ mad_fixed64hi_t __hi; \
- mad_fixed64lo_t __lo; \
+ ({ register mad_fixed64hi_t __hi; \
+ register mad_fixed64lo_t __lo; \
MAD_F_MLX(__hi, __lo, (x), (y)); \
@@ -471,5 +493,6 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
-/* miscellaneous C routines */
+/* C routines */
mad_fixed_t mad_f_abs(mad_fixed_t);
+mad_fixed_t mad_f_div(mad_fixed_t, mad_fixed_t);