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
14 static const unsigned long long attribute_used
__attribute__((aligned(8))) null_one
= 0x0000ffff0000ffffULL
;
15 static const unsigned long long attribute_used
__attribute__((aligned(8))) one_null
= 0xffff0000ffff0000ULL
;
16 const unsigned int __attribute__((aligned(16))) costab_mmx
[] =
52 This array of magic numbers were calculated by the pure function
53 make_decode_tables_MMX(32768), which had been implemented in (deleted since
54 r23383) tabinit_MMX.c.
56 static const short __attribute__((aligned(8))) mp3lib_decwins
[] =
58 0, 7, 54, 114, 510, 1288, 1644, 9372,
59 18760, -9373, 1644, -1289, 510, -115, 54, -8,
60 0, 7, 54, 114, 510, 1288, 1644, 9372,
61 18760, -9373, 1644, -1289, 510, -115, 54, -8,
62 0, 7, 55, 129, 500, 1379, 1490, 9834,
63 18748, -8910, 1784, -1197, 516, -101, 52, -7,
64 0, 7, 55, 129, 500, 1379, 1490, 9834,
65 18748, -8910, 1784, -1197, 516, -101, 52, -7,
66 0, 8, 56, 145, 488, 1469, 1322, 10294,
67 18714, -8448, 1910, -1107, 520, -87, 51, -6,
68 0, 8, 56, 145, 488, 1469, 1322, 10294,
69 18714, -8448, 1910, -1107, 520, -87, 51, -6,
70 0, 9, 57, 161, 474, 1559, 1141, 10751,
71 18658, -7987, 2023, -1016, 522, -74, 49, -6,
72 0, 9, 57, 161, 474, 1559, 1141, 10751,
73 18658, -7987, 2023, -1016, 522, -74, 49, -6,
74 0, 10, 57, 177, 456, 1647, 944, 11205,
75 18579, -7528, 2123, -927, 522, -61, 48, -5,
76 0, 10, 57, 177, 456, 1647, 944, 11205,
77 18579, -7528, 2123, -927, 522, -61, 48, -5,
78 0, 11, 57, 194, 435, 1733, 734, 11654,
79 18477, -7073, 2210, -838, 519, -50, 46, -5,
80 0, 11, 57, 194, 435, 1733, 734, 11654,
81 18477, -7073, 2210, -838, 519, -50, 46, -5,
82 0, 12, 57, 212, 411, 1817, 510, 12097,
83 18354, -6621, 2285, -751, 515, -39, 44, -4,
84 0, 12, 57, 212, 411, 1817, 510, 12097,
85 18354, -6621, 2285, -751, 515, -39, 44, -4,
86 0, 13, 57, 229, 384, 1899, 271, 12534,
87 18209, -6174, 2348, -666, 508, -28, 43, -4,
88 0, 13, 57, 229, 384, 1899, 271, 12534,
89 18209, -6174, 2348, -666, 508, -28, 43, -4,
90 0, 14, 56, 247, 354, 1977, 18, 12963,
91 18043, -5733, 2398, -583, 501, -18, 41, -4,
92 0, 14, 56, 247, 354, 1977, 18, 12963,
93 18043, -5733, 2398, -583, 501, -18, 41, -4,
94 0, 15, 56, 266, 320, 2052, -249, 13383,
95 17855, -5298, 2438, -502, 491, -9, 39, -3,
96 0, 15, 56, 266, 320, 2052, -249, 13383,
97 17855, -5298, 2438, -502, 491, -9, 39, -3,
98 0, 17, 54, 284, 283, 2122, -530, 13794,
99 17648, -4870, 2466, -423, 480, -1, 37, -3,
100 0, 17, 54, 284, 283, 2122, -530, 13794,
101 17648, -4870, 2466, -423, 480, -1, 37, -3,
102 0, 18, 52, 302, 243, 2188, -825, 14194,
103 17420, -4450, 2484, -347, 468, 7, 35, -3,
104 0, 18, 52, 302, 243, 2188, -825, 14194,
105 17420, -4450, 2484, -347, 468, 7, 35, -3,
106 0, 19, 50, 320, 199, 2249, -1133, 14583,
107 17173, -4039, 2492, -274, 455, 14, 33, -2,
108 0, 19, 50, 320, 199, 2249, -1133, 14583,
109 17173, -4039, 2492, -274, 455, 14, 33, -2,
110 -1, 21, 48, 339, 152, 2304, -1454, 14959,
111 16908, -3637, 2490, -204, 440, 20, 32, -2,
112 -1, 21, 48, 339, 152, 2304, -1454, 14959,
113 16908, -3637, 2490, -204, 440, 20, 32, -2,
114 -1, 22, 45, 357, 101, 2354, -1788, 15322,
115 16624, -3245, 2479, -137, 425, 26, 30, -2,
116 -1, 22, 45, 357, 101, 2354, -1788, 15322,
117 16624, -3245, 2479, -137, 425, 26, 30, -2,
118 -1, 24, 41, 374, 47, 2396, -2135, 15671,
119 16323, -2864, 2460, -72, 409, 31, 28, -2,
120 -1, 24, 41, 374, 47, 2396, -2135, 15671,
121 16323, -2864, 2460, -72, 409, 31, 28, -2,
122 -1, 26, 37, 391, -11, 2431, -2493, 16004,
123 16005, -2494, 2432, -12, 392, 36, 26, -2,
124 -1, 26, 37, 391, -11, 2431, -2493, 16004,
125 16005, -2494, 2432, -12, 392, 36, 26, -2,
126 -2, -28, 31, -409, -72, -2460, -2864, -16323,
127 15671, 2135, 2396, -47, 374, -41, 24, 1,
128 -2, -28, 31, -409, -72, -2460, -2864, -16323,
129 15671, 2135, 2396, -47, 374, -41, 24, 1,
130 -2, -30, 26, -425, -137, -2479, -3245, -16624,
131 15322, 1788, 2354, -101, 357, -45, 22, 1,
132 -2, -30, 26, -425, -137, -2479, -3245, -16624,
133 15322, 1788, 2354, -101, 357, -45, 22, 1,
134 -2, -32, 20, -440, -204, -2490, -3637, -16908,
135 14959, 1454, 2304, -152, 339, -48, 21, 1,
136 -2, -32, 20, -440, -204, -2490, -3637, -16908,
137 14959, 1454, 2304, -152, 339, -48, 21, 1,
138 -2, -33, 14, -455, -274, -2492, -4039, -17173,
139 14583, 1133, 2249, -199, 320, -50, 19, 0,
140 -2, -33, 14, -455, -274, -2492, -4039, -17173,
141 14583, 1133, 2249, -199, 320, -50, 19, 0,
142 -3, -35, 7, -468, -347, -2484, -4450, -17420,
143 14194, 825, 2188, -243, 302, -52, 18, 0,
144 -3, -35, 7, -468, -347, -2484, -4450, -17420,
145 14194, 825, 2188, -243, 302, -52, 18, 0,
146 -3, -37, -1, -480, -423, -2466, -4870, -17648,
147 13794, 530, 2122, -283, 284, -54, 17, 0,
148 -3, -37, -1, -480, -423, -2466, -4870, -17648,
149 13794, 530, 2122, -283, 284, -54, 17, 0,
150 -3, -39, -9, -491, -502, -2438, -5298, -17855,
151 13383, 249, 2052, -320, 266, -56, 15, 0,
152 -3, -39, -9, -491, -502, -2438, -5298, -17855,
153 13383, 249, 2052, -320, 266, -56, 15, 0,
154 -4, -41, -18, -501, -583, -2398, -5733, -18043,
155 12963, -18, 1977, -354, 247, -56, 14, 0,
156 -4, -41, -18, -501, -583, -2398, -5733, -18043,
157 12963, -18, 1977, -354, 247, -56, 14, 0,
158 -4, -43, -28, -508, -666, -2348, -6174, -18209,
159 12534, -271, 1899, -384, 229, -57, 13, 0,
160 -4, -43, -28, -508, -666, -2348, -6174, -18209,
161 12534, -271, 1899, -384, 229, -57, 13, 0,
162 -4, -44, -39, -515, -751, -2285, -6621, -18354,
163 12097, -510, 1817, -411, 212, -57, 12, 0,
164 -4, -44, -39, -515, -751, -2285, -6621, -18354,
165 12097, -510, 1817, -411, 212, -57, 12, 0,
166 -5, -46, -50, -519, -838, -2210, -7073, -18477,
167 11654, -734, 1733, -435, 194, -57, 11, 0,
168 -5, -46, -50, -519, -838, -2210, -7073, -18477,
169 11654, -734, 1733, -435, 194, -57, 11, 0,
170 -5, -48, -61, -522, -927, -2123, -7528, -18579,
171 11205, -944, 1647, -456, 177, -57, 10, 0,
172 -5, -48, -61, -522, -927, -2123, -7528, -18579,
173 11205, -944, 1647, -456, 177, -57, 10, 0,
174 -6, -49, -74, -522, -1016, -2023, -7987, -18658,
175 10751, -1141, 1559, -474, 161, -57, 9, 0,
176 -6, -49, -74, -522, -1016, -2023, -7987, -18658,
177 10751, -1141, 1559, -474, 161, -57, 9, 0,
178 -6, -51, -87, -520, -1107, -1910, -8448, -18714,
179 10294, -1322, 1469, -488, 145, -56, 8, 0,
180 -6, -51, -87, -520, -1107, -1910, -8448, -18714,
181 10294, -1322, 1469, -488, 145, -56, 8, 0,
182 -7, -52, -101, -516, -1197, -1784, -8910, -18748,
183 9834, -1490, 1379, -500, 129, -55, 7, 0,
184 -7, -52, -101, -516, -1197, -1784, -8910, -18748,
185 9834, -1490, 1379, -500, 129, -55, 7, 0,
188 int synth_1to1_MMX(real
*bandPtr
, int channel
, short *samples
)
190 static short buffs
[2][2][0x110] __attribute__((aligned(8)));
192 short *b0
, (*buf
)[0x110], *a
, *b
;
208 b
= buf
[1] + ((bo
+ 1) & 0xf);
213 a
= buf
[1] + ((bo
+ 1) & 0xf);
216 dct64_MMX_func(a
, b
, bandPtr
);
217 window
= mp3lib_decwins
+ 16 - bo1
;
218 //printf("DEBUG: channel %d, bo %d, off %d\n", channel, bo, 16 - bo1);
222 "movq (%1),%%mm0\n\t"
223 "movq 64(%1),%%mm4\n\t"
224 "pmaddwd (%2),%%mm0\n\t"
225 "pmaddwd 32(%2),%%mm4\n\t"
226 "movq 8(%1),%%mm1\n\t"
227 "movq 72(%1),%%mm5\n\t"
228 "pmaddwd 8(%2),%%mm1\n\t"
229 "pmaddwd 40(%2),%%mm5\n\t"
230 "movq 16(%1),%%mm2\n\t"
231 "movq 80(%1),%%mm6\n\t"
232 "pmaddwd 16(%2),%%mm2\n\t"
233 "pmaddwd 48(%2),%%mm6\n\t"
234 "movq 24(%1),%%mm3\n\t"
235 "movq 88(%1),%%mm7\n\t"
236 "pmaddwd 24(%2),%%mm3\n\t"
237 "pmaddwd 56(%2),%%mm7\n\t"
238 "paddd %%mm1,%%mm0\n\t"
239 "paddd %%mm5,%%mm4\n\t"
240 "paddd %%mm2,%%mm0\n\t"
241 "paddd %%mm6,%%mm4\n\t"
242 "paddd %%mm3,%%mm0\n\t"
243 "paddd %%mm7,%%mm4\n\t"
244 "movq %%mm0,%%mm1\n\t"
245 "movq %%mm4,%%mm5\n\t"
246 "psrlq $32,%%mm1\n\t"
247 "psrlq $32,%%mm5\n\t"
248 "paddd %%mm1,%%mm0\n\t"
249 "paddd %%mm5,%%mm4\n\t"
250 "psrad $13,%%mm0\n\t"
251 "psrad $13,%%mm4\n\t"
252 "packssdw %%mm0,%%mm0\n\t"
253 "packssdw %%mm4,%%mm4\n\t"
255 "movq (%3), %%mm1\n\t"
256 "punpckldq %%mm4, %%mm0\n\t"
257 "pand "MANGLE(one_null
)", %%mm1\n\t"
258 "pand "MANGLE(null_one
)", %%mm0\n\t"
259 "por %%mm0, %%mm1\n\t"
260 "movq %%mm1,(%3)\n\t"
269 "movq (%1),%%mm0\n\t"
270 "pmaddwd (%2),%%mm0\n\t"
271 "movq 8(%1),%%mm1\n\t"
272 "pmaddwd 8(%2),%%mm1\n\t"
273 "movq 16(%1),%%mm2\n\t"
274 "pmaddwd 16(%2),%%mm2\n\t"
275 "movq 24(%1),%%mm3\n\t"
276 "pmaddwd 24(%2),%%mm3\n\t"
277 "paddd %%mm1,%%mm0\n\t"
278 "paddd %%mm2,%%mm0\n\t"
279 "paddd %%mm3,%%mm0\n\t"
280 "movq %%mm0,%%mm1\n\t"
281 "psrlq $32,%%mm1\n\t"
282 "paddd %%mm1,%%mm0\n\t"
283 "psrad $13,%%mm0\n\t"
284 "packssdw %%mm0,%%mm0\n\t"
285 "movd %%mm0,%%eax\n\t"
286 "movw %%ax, (%3)\n\t"
294 "movq (%1),%%mm0\n\t"
295 "movq 64(%1),%%mm4\n\t"
296 "pmaddwd (%2),%%mm0\n\t"
297 "pmaddwd -32(%2),%%mm4\n\t"
298 "movq 8(%1),%%mm1\n\t"
299 "movq 72(%1),%%mm5\n\t"
300 "pmaddwd 8(%2),%%mm1\n\t"
301 "pmaddwd -24(%2),%%mm5\n\t"
302 "movq 16(%1),%%mm2\n\t"
303 "movq 80(%1),%%mm6\n\t"
304 "pmaddwd 16(%2),%%mm2\n\t"
305 "pmaddwd -16(%2),%%mm6\n\t"
306 "movq 24(%1),%%mm3\n\t"
307 "movq 88(%1),%%mm7\n\t"
308 "pmaddwd 24(%2),%%mm3\n\t"
309 "pmaddwd -8(%2),%%mm7\n\t"
310 "paddd %%mm1,%%mm0\n\t"
311 "paddd %%mm5,%%mm4\n\t"
312 "paddd %%mm2,%%mm0\n\t"
313 "paddd %%mm6,%%mm4\n\t"
314 "paddd %%mm3,%%mm0\n\t"
315 "paddd %%mm7,%%mm4\n\t"
316 "movq %%mm0,%%mm1\n\t"
317 "movq %%mm4,%%mm5\n\t"
318 "psrlq $32,%%mm1\n\t"
319 "psrlq $32,%%mm5\n\t"
320 "paddd %%mm0,%%mm1\n\t"
321 "paddd %%mm4,%%mm5\n\t"
322 "psrad $13,%%mm1\n\t"
323 "psrad $13,%%mm5\n\t"
324 "packssdw %%mm1,%%mm1\n\t"
325 "packssdw %%mm5,%%mm5\n\t"
326 "psubd %%mm0,%%mm0\n\t"
327 "psubd %%mm4,%%mm4\n\t"
328 "psubsw %%mm1,%%mm0\n\t"
329 "psubsw %%mm5,%%mm4\n\t"
331 "movq (%3), %%mm1\n\t"
332 "punpckldq %%mm4, %%mm0\n\t"
333 "pand "MANGLE(one_null
)", %%mm1\n\t"
334 "pand "MANGLE(null_one
)", %%mm0\n\t"
335 "por %%mm0, %%mm1\n\t"
336 "movq %%mm1,(%3)\n\t"
344 "movq (%1),%%mm0\n\t"
345 "pmaddwd (%2),%%mm0\n\t"
346 "movq 8(%1),%%mm1\n\t"
347 "pmaddwd 8(%2),%%mm1\n\t"
348 "movq 16(%1),%%mm2\n\t"
349 "pmaddwd 16(%2),%%mm2\n\t"
350 "movq 24(%1),%%mm3\n\t"
351 "pmaddwd 24(%2),%%mm3\n\t"
352 "paddd %%mm1,%%mm0\n\t"
353 "paddd %%mm2,%%mm0\n\t"
354 "paddd %%mm3,%%mm0\n\t"
355 "movq %%mm0,%%mm1\n\t"
356 "psrlq $32,%%mm1\n\t"
357 "paddd %%mm0,%%mm1\n\t"
358 "psrad $13,%%mm1\n\t"
359 "packssdw %%mm1,%%mm1\n\t"
360 "psubd %%mm0,%%mm0\n\t"
361 "psubsw %%mm1,%%mm0\n\t"
362 "movd %%mm0,%%eax\n\t"
365 :"+r"(i
), "+r"(window
), "+r"(b0
), "+r"(samples
)