lcd-m6sp.c: remove \r
[kugel-rb.git] / apps / codecs / lib / mdct.h
blob48d1c25a5531fc905fb29135e7f999844ee62090
1 /*
2 * WMA compatible decoder
3 * Copyright (c) 2002 The FFmpeg Project.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef CODECLIB_MDCT_H_INCLUDED
21 #define CODECLIB_MDCT_H_INCLUDED
23 //#include "types.h"
24 #include "fft.h"
26 void ff_imdct_calc(unsigned int nbits, fixed32 *output, const fixed32 *input);
27 void ff_imdct_half(unsigned int nbits, fixed32 *output, const fixed32 *input);
29 #ifdef CPU_ARM
31 /*Sign-15.16 format */
32 #define fixmul32b(x, y) \
33 ({ int32_t __hi; \
34 uint32_t __lo; \
35 int32_t __result; \
36 asm ("smull %0, %1, %3, %4\n\t" \
37 "mov %2, %1, lsl #1" \
38 : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
39 : "%r" (x), "r" (y) \
40 : "cc" ); \
41 __result; \
44 #elif defined(CPU_COLDFIRE)
46 static inline int32_t fixmul32b(int32_t x, int32_t y)
48 asm (
49 "mac.l %[x], %[y], %%acc0 \n" /* multiply */
50 "movclr.l %%acc0, %[x] \n" /* get higher half */
51 : [x] "+d" (x)
52 : [y] "d" (y)
54 return x;
57 #else
59 static inline fixed32 fixmul32b(fixed32 x, fixed32 y)
61 fixed64 temp;
63 temp = x;
64 temp *= y;
66 temp >>= 31; //16+31-16 = 31 bits
68 return (fixed32)temp;
70 #endif
73 #ifdef CPU_ARM
74 static inline
75 void CMUL(fixed32 *x, fixed32 *y,
76 fixed32 a, fixed32 b,
77 fixed32 t, fixed32 v)
79 /* This version loses one bit of precision. Could be solved at the cost
80 * of 2 extra cycles if it becomes an issue. */
81 int x1, y1, l;
82 asm(
83 "smull %[l], %[y1], %[b], %[t] \n"
84 "smlal %[l], %[y1], %[a], %[v] \n"
85 "rsb %[b], %[b], #0 \n"
86 "smull %[l], %[x1], %[a], %[t] \n"
87 "smlal %[l], %[x1], %[b], %[v] \n"
88 : [l] "=&r" (l), [x1]"=&r" (x1), [y1]"=&r" (y1), [b] "+r" (b)
89 : [a] "r" (a), [t] "r" (t), [v] "r" (v)
90 : "cc"
92 *x = x1 << 1;
93 *y = y1 << 1;
95 #elif defined CPU_COLDFIRE
96 static inline
97 void CMUL(fixed32 *x, fixed32 *y,
98 fixed32 a, fixed32 b,
99 fixed32 t, fixed32 v)
101 asm volatile ("mac.l %[a], %[t], %%acc0;"
102 "msac.l %[b], %[v], %%acc0;"
103 "mac.l %[b], %[t], %%acc1;"
104 "mac.l %[a], %[v], %%acc1;"
105 "movclr.l %%acc0, %[a];"
106 "move.l %[a], (%[x]);"
107 "movclr.l %%acc1, %[a];"
108 "move.l %[a], (%[y]);"
109 : [a] "+&r" (a)
110 : [x] "a" (x), [y] "a" (y),
111 [b] "r" (b), [t] "r" (t), [v] "r" (v)
112 : "cc", "memory");
114 #else
115 static inline
116 void CMUL(fixed32 *pre,
117 fixed32 *pim,
118 fixed32 are,
119 fixed32 aim,
120 fixed32 bre,
121 fixed32 bim)
123 //int64_t x,y;
124 fixed32 _aref = are;
125 fixed32 _aimf = aim;
126 fixed32 _bref = bre;
127 fixed32 _bimf = bim;
128 fixed32 _r1 = fixmul32b(_bref, _aref);
129 fixed32 _r2 = fixmul32b(_bimf, _aimf);
130 fixed32 _r3 = fixmul32b(_bref, _aimf);
131 fixed32 _r4 = fixmul32b(_bimf, _aref);
132 *pre = _r1 - _r2;
133 *pim = _r3 + _r4;
136 #endif
139 #endif // CODECLIB_MDCT_H_INCLUDED