summaryrefslogtreecommitdiff
path: root/apps/codecs/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/lib')
-rw-r--r--apps/codecs/lib/asm_arm.h11
-rw-r--r--apps/codecs/lib/asm_mcf5249.h15
-rw-r--r--apps/codecs/lib/codeclib_misc.h7
3 files changed, 33 insertions, 0 deletions
diff --git a/apps/codecs/lib/asm_arm.h b/apps/codecs/lib/asm_arm.h
index c0f9440450..629e47b3bd 100644
--- a/apps/codecs/lib/asm_arm.h
+++ b/apps/codecs/lib/asm_arm.h
@@ -52,6 +52,17 @@ static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
52 return(hi); 52 return(hi);
53} 53}
54 54
55static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) {
56 int32_t lo,hi;
57 asm volatile("smull %0, %1, %2, %3\n\t"
58 "movs %0, %0, lsr #16\n\t"
59 "adc %1, %0, %1, lsl #16\n\t"
60 : "=&r"(lo),"=&r"(hi)
61 : "r"(x),"r"(y)
62 : "cc" );
63 return(hi);
64}
65
55#define XPROD32(a, b, t, v, x, y) \ 66#define XPROD32(a, b, t, v, x, y) \
56{ \ 67{ \
57 int32_t l; \ 68 int32_t l; \
diff --git a/apps/codecs/lib/asm_mcf5249.h b/apps/codecs/lib/asm_mcf5249.h
index 49d2ddf7cb..5fb3cff94a 100644
--- a/apps/codecs/lib/asm_mcf5249.h
+++ b/apps/codecs/lib/asm_mcf5249.h
@@ -61,6 +61,21 @@ static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
61 return r; 61 return r;
62} 62}
63 63
64static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) {
65 int32_t r;
66
67 asm volatile ("mac.l %[x], %[y], %%acc0;" /* multiply */
68 "mulu.l %[y], %[x];" /* get lower half, avoid emac stall */
69 "movclr.l %%acc0, %[r];" /* get higher half */
70 "lsr.l #1, %[r];" /* hi >> 1, to compensate emac shift */
71 "move.w %[r], %[x];" /* x = x & 0xffff0000 | r & 0xffff */
72 "swap %[x];" /* x = (unsigned)x << 16 | (unsigned)x >> 16 */
73 : [r] "=&d" (r), [x] "+d" (x)
74 : [y] "d" (y)
75 : "cc");
76 return x;
77}
78
64static inline 79static inline
65void XPROD31(int32_t a, int32_t b, 80void XPROD31(int32_t a, int32_t b,
66 int32_t t, int32_t v, 81 int32_t t, int32_t v,
diff --git a/apps/codecs/lib/codeclib_misc.h b/apps/codecs/lib/codeclib_misc.h
index f3ec209e78..f3b1805e26 100644
--- a/apps/codecs/lib/codeclib_misc.h
+++ b/apps/codecs/lib/codeclib_misc.h
@@ -65,6 +65,7 @@ static inline int32_t MULT32(int32_t x, int32_t y) {
65 magic.whole = (int64_t)x * y; 65 magic.whole = (int64_t)x * y;
66 return magic.halves.hi; 66 return magic.halves.hi;
67} 67}
68
68static inline int32_t MULT31(int32_t x, int32_t y) { 69static inline int32_t MULT31(int32_t x, int32_t y) {
69 return MULT32(x,y)<<1; 70 return MULT32(x,y)<<1;
70} 71}
@@ -75,6 +76,12 @@ static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
75 return ((uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17); 76 return ((uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17);
76} 77}
77 78
79static inline int32_t MULT31_SHIFT16(int32_t x, int32_t y) {
80 union magic magic;
81 magic.whole = (int64_t)x * y;
82 return ((uint32_t)(magic.halves.lo)>>16) | ((magic.halves.hi)<<16);
83}
84
78#else 85#else
79/* 32 bit multiply, more portable but less accurate */ 86/* 32 bit multiply, more portable but less accurate */
80 87