2 * this code comes under GPL
3 * This code was taken from http://www.mpg123.org
4 * See ChangeLog of mpg123-0.59s-pre.1 for detail
5 * Applied to mplayer by Nick Kurshev <nickols_k@mail.ru>
8 * - Partial loops unrolling and removing MOVW insn from loops
10 #include "../mangle.h"
11 #define real float /* ugly - but only way */
13 static unsigned long long __attribute__((aligned(8))) null_one
= 0x0000ffff0000ffffULL
;
14 static unsigned long long __attribute__((aligned(8))) one_null
= 0xffff0000ffff0000ULL
;
15 unsigned long __attribute__((aligned(8))) costab_mmx
[] =
50 static int temp
; // buggy gcc 3.x fails if this is moved into the function :(
51 void synth_1to1_MMX_s(real
*bandPtr
, int channel
, short *samples
,
52 short *buffs
, int *bo
)
60 "leal (%%edi,%%ecx,2),%%edi\n\t"
63 "movl (%%edx),%%eax\n\t"
66 "andl %%ebx,%%eax\n\t"
67 "leal 1088(%%esi),%%esi\n\t"
68 "movl %%eax,(%%edx)\n\t"
70 "leal (%%esi,%%eax,2),%%edx\n\t"
73 "andl %%ebx,%%eax\n\t"
74 "leal 544(%%esi,%%eax,2),%%ecx\n\t"
78 "xchgl %%edx,%%ecx\n\t"
80 "leal 544(%%esi),%%esi\n\t"
86 "call *"MANGLE(dct64_MMX_func
)"\n\t"
88 "leal 1(%%ebx), %%ecx\n\t"
91 "leal "MANGLE(mp3lib_decwins
)"(%%ebx,%%ebx,1), %%edx\n\t"
95 "movq (%%edx),%%mm0\n\t"
96 "movq 64(%%edx),%%mm4\n\t"
97 "pmaddwd (%%esi),%%mm0\n\t"
98 "pmaddwd 32(%%esi),%%mm4\n\t"
99 "movq 8(%%edx),%%mm1\n\t"
100 "movq 72(%%edx),%%mm5\n\t"
101 "pmaddwd 8(%%esi),%%mm1\n\t"
102 "pmaddwd 40(%%esi),%%mm5\n\t"
103 "movq 16(%%edx),%%mm2\n\t"
104 "movq 80(%%edx),%%mm6\n\t"
105 "pmaddwd 16(%%esi),%%mm2\n\t"
106 "pmaddwd 48(%%esi),%%mm6\n\t"
107 "movq 24(%%edx),%%mm3\n\t"
108 "movq 88(%%edx),%%mm7\n\t"
109 "pmaddwd 24(%%esi),%%mm3\n\t"
110 "pmaddwd 56(%%esi),%%mm7\n\t"
111 "paddd %%mm1,%%mm0\n\t"
112 "paddd %%mm5,%%mm4\n\t"
113 "paddd %%mm2,%%mm0\n\t"
114 "paddd %%mm6,%%mm4\n\t"
115 "paddd %%mm3,%%mm0\n\t"
116 "paddd %%mm7,%%mm4\n\t"
117 "movq %%mm0,%%mm1\n\t"
118 "movq %%mm4,%%mm5\n\t"
119 "psrlq $32,%%mm1\n\t"
120 "psrlq $32,%%mm5\n\t"
121 "paddd %%mm1,%%mm0\n\t"
122 "paddd %%mm5,%%mm4\n\t"
123 "psrad $13,%%mm0\n\t"
124 "psrad $13,%%mm4\n\t"
125 "packssdw %%mm0,%%mm0\n\t"
126 "packssdw %%mm4,%%mm4\n\t"
128 "movq (%%edi), %%mm1\n\t"
129 "punpckldq %%mm4, %%mm0\n\t"
130 "pand "MANGLE(one_null
)", %%mm1\n\t"
131 "pand "MANGLE(null_one
)", %%mm0\n\t"
132 "por %%mm0, %%mm1\n\t"
133 "movq %%mm1,(%%edi)\n\t"
135 "leal 64(%%esi),%%esi\n\t"
136 "leal 128(%%edx),%%edx\n\t"
137 "leal 8(%%edi),%%edi\n\t"
144 "jecxz .next_loop\n\t"
146 "movq (%%edx),%%mm0\n\t"
147 "pmaddwd (%%esi),%%mm0\n\t"
148 "movq 8(%%edx),%%mm1\n\t"
149 "pmaddwd 8(%%esi),%%mm1\n\t"
150 "movq 16(%%edx),%%mm2\n\t"
151 "pmaddwd 16(%%esi),%%mm2\n\t"
152 "movq 24(%%edx),%%mm3\n\t"
153 "pmaddwd 24(%%esi),%%mm3\n\t"
154 "paddd %%mm1,%%mm0\n\t"
155 "paddd %%mm2,%%mm0\n\t"
156 "paddd %%mm3,%%mm0\n\t"
157 "movq %%mm0,%%mm1\n\t"
158 "psrlq $32,%%mm1\n\t"
159 "paddd %%mm1,%%mm0\n\t"
160 "psrad $13,%%mm0\n\t"
161 "packssdw %%mm0,%%mm0\n\t"
162 "movd %%mm0,%%eax\n\t"
163 "movw %%ax, (%%edi)\n\t"
164 "leal 32(%%esi),%%esi\n\t"
165 "leal 64(%%edx),%%edx\n\t"
166 "leal 4(%%edi),%%edi\n\t"
173 "movq (%%edx),%%mm0\n\t"
174 "movq 64(%%edx),%%mm4\n\t"
175 "pmaddwd (%%esi),%%mm0\n\t"
176 "pmaddwd -32(%%esi),%%mm4\n\t"
177 "movq 8(%%edx),%%mm1\n\t"
178 "movq 72(%%edx),%%mm5\n\t"
179 "pmaddwd 8(%%esi),%%mm1\n\t"
180 "pmaddwd -24(%%esi),%%mm5\n\t"
181 "movq 16(%%edx),%%mm2\n\t"
182 "movq 80(%%edx),%%mm6\n\t"
183 "pmaddwd 16(%%esi),%%mm2\n\t"
184 "pmaddwd -16(%%esi),%%mm6\n\t"
185 "movq 24(%%edx),%%mm3\n\t"
186 "movq 88(%%edx),%%mm7\n\t"
187 "pmaddwd 24(%%esi),%%mm3\n\t"
188 "pmaddwd -8(%%esi),%%mm7\n\t"
189 "paddd %%mm1,%%mm0\n\t"
190 "paddd %%mm5,%%mm4\n\t"
191 "paddd %%mm2,%%mm0\n\t"
192 "paddd %%mm6,%%mm4\n\t"
193 "paddd %%mm3,%%mm0\n\t"
194 "paddd %%mm7,%%mm4\n\t"
195 "movq %%mm0,%%mm1\n\t"
196 "movq %%mm4,%%mm5\n\t"
197 "psrlq $32,%%mm1\n\t"
198 "psrlq $32,%%mm5\n\t"
199 "paddd %%mm0,%%mm1\n\t"
200 "paddd %%mm4,%%mm5\n\t"
201 "psrad $13,%%mm1\n\t"
202 "psrad $13,%%mm5\n\t"
203 "packssdw %%mm1,%%mm1\n\t"
204 "packssdw %%mm5,%%mm5\n\t"
205 "psubd %%mm0,%%mm0\n\t"
206 "psubd %%mm4,%%mm4\n\t"
207 "psubsw %%mm1,%%mm0\n\t"
208 "psubsw %%mm5,%%mm4\n\t"
210 "movq (%%edi), %%mm1\n\t"
211 "punpckldq %%mm4, %%mm0\n\t"
212 "pand "MANGLE(one_null
)", %%mm1\n\t"
213 "pand "MANGLE(null_one
)", %%mm0\n\t"
214 "por %%mm0, %%mm1\n\t"
215 "movq %%mm1,(%%edi)\n\t"
218 "addl $128,%%edx\n\t"
219 "leal 8(%%edi),%%edi\n\t"
223 "movq (%%edx),%%mm0\n\t"
224 "pmaddwd (%%esi),%%mm0\n\t"
225 "movq 8(%%edx),%%mm1\n\t"
226 "pmaddwd 8(%%esi),%%mm1\n\t"
227 "movq 16(%%edx),%%mm2\n\t"
228 "pmaddwd 16(%%esi),%%mm2\n\t"
229 "movq 24(%%edx),%%mm3\n\t"
230 "pmaddwd 24(%%esi),%%mm3\n\t"
231 "paddd %%mm1,%%mm0\n\t"
232 "paddd %%mm2,%%mm0\n\t"
233 "paddd %%mm3,%%mm0\n\t"
234 "movq %%mm0,%%mm1\n\t"
235 "psrlq $32,%%mm1\n\t"
236 "paddd %%mm0,%%mm1\n\t"
237 "psrad $13,%%mm1\n\t"
238 "packssdw %%mm1,%%mm1\n\t"
239 "psubd %%mm0,%%mm0\n\t"
240 "psubsw %%mm1,%%mm0\n\t"
241 "movd %%mm0,%%eax\n\t"
242 "movw %%ax,(%%edi)\n\t"
245 :"m"(bandPtr
),"m"(channel
),"m"(samples
),"m"(buffs
),"m"(bo
), "m"(temp
)
246 :"memory","%edi","%esi","%ebx","%esp");