summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2011-06-08 10:35:27 +0000
committerNils Wallménius <nils@rockbox.org>2011-06-08 10:35:27 +0000
commitd5ceb4ce2b5ee8f81edfab4fb903c10353d788e5 (patch)
tree1193ac688f8cc2208ea8f2668b92f7cf581bb457 /apps
parent6672766dfe374e26ee20efe010591b64529b2a0f (diff)
downloadrockbox-d5ceb4ce2b5ee8f81edfab4fb903c10353d788e5.tar.gz
rockbox-d5ceb4ce2b5ee8f81edfab4fb903c10353d788e5.tar.bz2
rockbox-d5ceb4ce2b5ee8f81edfab4fb903c10353d788e5.zip
codeclib: make selective inclusion of macros and inline functions from the codeclib_misc.h header easier and clean out some old libtremor stuff.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29985 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/lib/asm_arm.h18
-rw-r--r--apps/codecs/lib/asm_mcf5249.h18
-rw-r--r--apps/codecs/lib/codeclib_misc.h59
3 files changed, 54 insertions, 41 deletions
diff --git a/apps/codecs/lib/asm_arm.h b/apps/codecs/lib/asm_arm.h
index 629e47b3bd..54ce4b0d98 100644
--- a/apps/codecs/lib/asm_arm.h
+++ b/apps/codecs/lib/asm_arm.h
@@ -16,9 +16,7 @@
********************************************************************/
#ifdef CPU_ARM
-#if !defined(_V_WIDE_MATH) && !defined(_LOW_ACCURACY_)
-#define _V_WIDE_MATH
-
+#define INCL_OPTIMIZED_MULT32
#if ARM_ARCH >= 6
static inline int32_t MULT32(int32_t x, int32_t y) {
int32_t hi;
@@ -37,10 +35,12 @@ static inline int32_t MULT32(int32_t x, int32_t y) {
}
#endif
+#define INCL_OPTIMIZED_MULT31
static inline int32_t MULT31(int32_t x, int32_t y) {
return MULT32(x,y)<<1;
}
+#define INCL_OPTIMIZED_MULT31_SHIFT15
static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
int32_t lo,hi;
asm volatile("smull %0, %1, %2, %3\n\t"
@@ -52,6 +52,7 @@ static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
return(hi);
}
+#define INCL_OPTIMIZED_MULT31_SHIFT16
static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) {
int32_t lo,hi;
asm volatile("smull %0, %1, %2, %3\n\t"
@@ -63,6 +64,7 @@ static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) {
return(hi);
}
+#define INCL_OPTIMIZED_XPROD32
#define XPROD32(a, b, t, v, x, y) \
{ \
int32_t l; \
@@ -75,6 +77,8 @@ static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) {
: "r" ((a)), "r" ((b)), "r" ((t)), "r" ((v)) ); \
}
+#define INCL_OPTIMIZED_XPROD31_R
+#define INCL_OPTIMIZED_XNPROD31_R
#if ARM_ARCH >= 6
/* These may yield slightly different result from the macros below
because only the high 32 bits of the multiplications are accumulated while
@@ -134,6 +138,7 @@ static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) {
}
#endif
+#define INCL_OPTIMIZED_XPROD31
static inline void XPROD31(int32_t a, int32_t b,
int32_t t, int32_t v,
int32_t *x, int32_t *y)
@@ -144,6 +149,7 @@ static inline void XPROD31(int32_t a, int32_t b,
*y = _y1;
}
+#define INCL_OPTIMIZED_XNPROD31
static inline void XNPROD31(int32_t a, int32_t b,
int32_t t, int32_t v,
int32_t *x, int32_t *y)
@@ -261,7 +267,6 @@ void vect_mult_bw(int32_t *data, int32_t *window, int n)
#endif
-#endif
/* not used anymore */
/*
#ifndef _V_CLIP_MATH
@@ -282,11 +287,6 @@ static inline int32_t CLIP_TO_15(int32_t x) {
#endif
*/
-#ifndef _V_LSP_MATH_ASM
-#define _V_LSP_MATH_ASM
-
-
-#endif
#endif
diff --git a/apps/codecs/lib/asm_mcf5249.h b/apps/codecs/lib/asm_mcf5249.h
index 5fb3cff94a..88d439631d 100644
--- a/apps/codecs/lib/asm_mcf5249.h
+++ b/apps/codecs/lib/asm_mcf5249.h
@@ -21,9 +21,7 @@
#if defined(CPU_COLDFIRE)
-#ifndef _V_WIDE_MATH
-#define _V_WIDE_MATH
-
+#define INCL_OPTIMIZED_MULT32
static inline int32_t MULT32(int32_t x, int32_t y) {
asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply & shift */
@@ -35,6 +33,7 @@ static inline int32_t MULT32(int32_t x, int32_t y) {
return x;
}
+#define INCL_OPTIMIZED_MULT31
static inline int32_t MULT31(int32_t x, int32_t y) {
asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply */
"movclr.l %%acc0, %[x];" /* move and clear */
@@ -44,6 +43,7 @@ static inline int32_t MULT31(int32_t x, int32_t y) {
return x;
}
+#define INCL_OPTIMIZED_MULT31_SHIFT15
static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
int32_t r;
@@ -61,6 +61,7 @@ static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
return r;
}
+#define INCL_OPTIMIZED_MULT31_SHIFT16
static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) {
int32_t r;
@@ -76,6 +77,7 @@ static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) {
return x;
}
+#define INCL_OPTIMIZED_XPROD31
static inline
void XPROD31(int32_t a, int32_t b,
int32_t t, int32_t v,
@@ -95,6 +97,7 @@ void XPROD31(int32_t a, int32_t b,
: "cc", "memory");
}
+#define INCL_OPTIMIZED_XNPROD31
static inline
void XNPROD31(int32_t a, int32_t b,
int32_t t, int32_t v,
@@ -114,15 +117,11 @@ void XNPROD31(int32_t a, int32_t b,
: "cc", "memory");
}
-#if 0 /* canonical Tremor definition */
-#define XPROD32(_a, _b, _t, _v, _x, _y) \
- { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
- (_y)=MULT32(_b,_t)-MULT32(_a,_v); }
-#endif
/* this could lose the LSB by overflow, but i don't think it'll ever happen.
if anyone think they can hear a bug caused by this, please try the above
version. */
+#define INCL_OPTIMIZED_XPROD32
#define XPROD32(_a, _b, _t, _v, _x, _y) \
asm volatile ("mac.l %[a], %[t], %%acc0;" \
"mac.l %[b], %[v], %%acc0;" \
@@ -137,6 +136,7 @@ void XNPROD31(int32_t a, int32_t b,
[t] "r" (_t), [v] "r" (_v) \
: "cc");
+#define INCL_OPTIMIZED_XPROD31_R
#define XPROD31_R(_a, _b, _t, _v, _x, _y) \
asm volatile ("mac.l %[a], %[t], %%acc0;" \
"mac.l %[b], %[v], %%acc0;" \
@@ -149,6 +149,7 @@ void XNPROD31(int32_t a, int32_t b,
[t] "r" (_t), [v] "r" (_v) \
: "cc");
+#define INCL_OPTIMIZED_XNPROD31_R
#define XNPROD31_R(_a, _b, _t, _v, _x, _y) \
asm volatile ("mac.l %[a], %[t], %%acc0;" \
"msac.l %[b], %[v], %%acc0;" \
@@ -336,7 +337,6 @@ void vect_mult_bw(int32_t *data, int32_t *window, int n)
#endif
-#endif
/* not used anymore */
/*
#ifndef _V_CLIP_MATH
diff --git a/apps/codecs/lib/codeclib_misc.h b/apps/codecs/lib/codeclib_misc.h
index f3b1805e26..08be93716f 100644
--- a/apps/codecs/lib/codeclib_misc.h
+++ b/apps/codecs/lib/codeclib_misc.h
@@ -15,32 +15,15 @@
********************************************************************/
-//#include "config-tremor.h"
-
-#ifndef _V_RANDOM_H_
-#define _V_RANDOM_H_
-//#include "ivorbiscodec.h"
-//#include "os_types.h"
+#ifndef _CODECLIB_MISC_H_
+#define _CODECLIB_MISC_H_
+#include <stdint.h>
#include "asm_arm.h"
#include "asm_mcf5249.h"
-
-/* Some prototypes that were not defined elsewhere */
-//void *_vorbis_block_alloc(vorbis_block *vb,long bytes);
-//void _vorbis_block_ripcord(vorbis_block *vb);
-//extern int _ilog(unsigned int v);
-
-#ifndef _V_WIDE_MATH
-#define _V_WIDE_MATH
-
-#ifndef ROCKBOX
-#include <inttypes.h>
-#endif /* ROCKBOX */
-
#ifndef _LOW_ACCURACY_
/* 64 bit multiply */
-/* #include <sys/types.h> */
#ifdef ROCKBOX_LITTLE_ENDIAN
union magic {
@@ -60,29 +43,43 @@ union magic {
};
#endif
+#ifndef INCL_OPTIMIZED_MULT32
+#define INCL_OPTIMIZED_MULT32
static inline int32_t MULT32(int32_t x, int32_t y) {
union magic magic;
magic.whole = (int64_t)x * y;
return magic.halves.hi;
}
+#endif
+#ifndef INCL_OPTIMIZED_MULT31
+#define INCL_OPTIMIZED_MULT31
static inline int32_t MULT31(int32_t x, int32_t y) {
return MULT32(x,y)<<1;
}
+#endif
+#ifndef INCL_OPTIMIZED_MULT31_SHIFT15
+#define INCL_OPTIMIZED_MULT31_SHIFT15
static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
union magic magic;
magic.whole = (int64_t)x * y;
return ((uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17);
}
+#endif
+#ifndef INCL_OPTIMIZED_MULT31_SHIFT16
+#define INCL_OPTIMIZED_MULT31_SHIFT16
static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) {
union magic magic;
magic.whole = (int64_t)x * y;
return ((uint32_t)(magic.halves.lo)>>16) | ((magic.halves.hi)<<16);
}
+#endif
#else
+/* Rockbox: unused */
+#if 0
/* 32 bit multiply, more portable but less accurate */
/*
@@ -110,6 +107,7 @@ static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
return (x >> 6) * y; /* y preshifted >>9 */
}
#endif
+#endif
/*
* The XPROD functions are meant to optimize the cross products found all
@@ -121,13 +119,17 @@ static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
* macros.
*/
+#ifndef INCL_OPTIMIZED_XPROD32
+#define INCL_OPTIMIZED_XPROD32
/* replaced XPROD32 with a macro to avoid memory reference
_x, _y are the results (must be l-values) */
#define XPROD32(_a, _b, _t, _v, _x, _y) \
{ (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
(_y)=MULT32(_b,_t)-MULT32(_a,_v); }
+#endif
-
+/* Rockbox: Unused */
+/*
#ifdef __i386__
#define XPROD31(_a, _b, _t, _v, _x, _y) \
@@ -138,7 +140,10 @@ static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
*(_y)=MULT31(_b,_t)+MULT31(_a,_v); }
#else
+*/
+#ifndef INCL_OPTIMIZED_XPROD31
+#define INCL_OPTIMIZED_XPROD31
static inline void XPROD31(int32_t a, int32_t b,
int32_t t, int32_t v,
int32_t *x, int32_t *y)
@@ -146,7 +151,10 @@ static inline void XPROD31(int32_t a, int32_t b,
*x = MULT31(a, t) + MULT31(b, v);
*y = MULT31(b, t) - MULT31(a, v);
}
+#endif
+#ifndef INCL_OPTIMIZED_XNPROD31
+#define INCL_OPTIMIZED_XNPROD31
static inline void XNPROD31(int32_t a, int32_t b,
int32_t t, int32_t v,
int32_t *x, int32_t *y)
@@ -155,19 +163,25 @@ static inline void XNPROD31(int32_t a, int32_t b,
*y = MULT31(b, t) + MULT31(a, v);
}
#endif
+/*#endif*/
+#ifndef INCL_OPTIMIZED_XPROD31_R
+#define INCL_OPTIMIZED_XPROD31_R
#define XPROD31_R(_a, _b, _t, _v, _x, _y)\
{\
_x = MULT31(_a, _t) + MULT31(_b, _v);\
_y = MULT31(_b, _t) - MULT31(_a, _v);\
}
+#endif
+#ifndef INCL_OPTIMIZED_XNPROD31_R
+#define INCL_OPTIMIZED_XNPROD31_R
#define XNPROD31_R(_a, _b, _t, _v, _x, _y)\
{\
_x = MULT31(_a, _t) - MULT31(_b, _v);\
_y = MULT31(_b, _t) + MULT31(_a, _v);\
}
-
+#endif
#ifndef _V_VECT_OPS
#define _V_VECT_OPS
@@ -213,7 +227,6 @@ void vect_mult_bw(int32_t *data, int32_t *window, int n)
}
#endif
-#endif
/* not used anymore */
/*
#ifndef _V_CLIP_MATH