annotate liba52/resample_mmx.c @ 6593:a2937bae0651

Expanded RTC section. It now explains how to allow RTC via /proc on newer kernels or how to patch older ones. Removed some <I> tags since it makes text hard to read on the screen and ugly when combined with <B>. 1001 typos
author diego
date Sat, 29 Jun 2002 02:43:27 +0000
parents 2dbd637ffe05
children 9fc45fe0d444
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
1
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
2 // MMX optimizations from Michael Niedermayer (michaelni@gmx.at) (under GPL)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
3
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
4 /* optimization TODO / NOTES
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
5 movntq is slightly faster (0.5% with the current test.c benchmark)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
6 (but thats just test.c so that needs to be testd in reallity)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
7 and it would mean (C / MMX2 / MMX / 3DNOW) versions
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
8 */
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
9
3574
8600f40003de mmx opt
michael
parents: 3569
diff changeset
10 static uint64_t __attribute__((aligned(8))) magicF2W= 0x43c0000043c00000LL;
8600f40003de mmx opt
michael
parents: 3569
diff changeset
11 static uint64_t __attribute__((aligned(8))) wm1010= 0xFFFF0000FFFF0000LL;
8600f40003de mmx opt
michael
parents: 3569
diff changeset
12 static uint64_t __attribute__((aligned(8))) wm0101= 0x0000FFFF0000FFFFLL;
8600f40003de mmx opt
michael
parents: 3569
diff changeset
13 static uint64_t __attribute__((aligned(8))) wm1100= 0xFFFFFFFF00000000LL;
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
14
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
15 static int a52_resample_MONO_to_5_MMX(float * _f, int16_t * s16){
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
16 int i;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
17 int32_t * f = (int32_t *) _f;
3574
8600f40003de mmx opt
michael
parents: 3569
diff changeset
18 asm volatile(
8600f40003de mmx opt
michael
parents: 3569
diff changeset
19 "movl $-512, %%esi \n\t"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
20 "movq "MANGLE(magicF2W)", %%mm7 \n\t"
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
21 "movq "MANGLE(wm1100)", %%mm3 \n\t"
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
22 "movq "MANGLE(wm0101)", %%mm4 \n\t"
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
23 "movq "MANGLE(wm1010)", %%mm5 \n\t"
3574
8600f40003de mmx opt
michael
parents: 3569
diff changeset
24 "pxor %%mm6, %%mm6 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
25 "1: \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
26 "movq (%1, %%esi, 2), %%mm0 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
27 "movq 8(%1, %%esi, 2), %%mm1 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
28 "leal (%%esi, %%esi, 4), %%edi \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
29 "psubd %%mm7, %%mm0 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
30 "psubd %%mm7, %%mm1 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
31 "packssdw %%mm1, %%mm0 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
32 "movq %%mm0, %%mm1 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
33 "pand %%mm4, %%mm0 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
34 "pand %%mm5, %%mm1 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
35 "movq %%mm6, (%0, %%edi) \n\t" // 0 0 0 0
8600f40003de mmx opt
michael
parents: 3569
diff changeset
36 "movd %%mm0, 8(%0, %%edi) \n\t" // A 0
8600f40003de mmx opt
michael
parents: 3569
diff changeset
37 "pand %%mm3, %%mm0 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
38 "movd %%mm6, 12(%0, %%edi) \n\t" // 0 0
8600f40003de mmx opt
michael
parents: 3569
diff changeset
39 "movd %%mm1, 16(%0, %%edi) \n\t" // 0 B
8600f40003de mmx opt
michael
parents: 3569
diff changeset
40 "pand %%mm3, %%mm1 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
41 "movd %%mm6, 20(%0, %%edi) \n\t" // 0 0
8600f40003de mmx opt
michael
parents: 3569
diff changeset
42 "movq %%mm0, 24(%0, %%edi) \n\t" // 0 0 C 0
8600f40003de mmx opt
michael
parents: 3569
diff changeset
43 "movq %%mm1, 32(%0, %%edi) \n\t" // 0 0 0 B
8600f40003de mmx opt
michael
parents: 3569
diff changeset
44 "addl $8, %%esi \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
45 " jnz 1b \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
46 "emms \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
47 :: "r" (s16+1280), "r" (f+256)
8600f40003de mmx opt
michael
parents: 3569
diff changeset
48 :"%esi", "%edi", "memory"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
49 );
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
50 return 5*256;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
51 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
52
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
53 static int a52_resample_STEREO_to_2_MMX(float * _f, int16_t * s16){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
54 int i;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
55 int32_t * f = (int32_t *) _f;
3567
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
56 /* benchmark scores are 0.3% better with SSE but we would need to set bias=0 and premultiply it
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
57 #ifdef HAVE_SSE
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
58 asm volatile(
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
59 "movl $-1024, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
60 "1: \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
61 "cvtps2pi (%1, %%esi), %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
62 "cvtps2pi 1024(%1, %%esi), %%mm2\n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
63 "movq %%mm0, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
64 "punpcklwd %%mm2, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
65 "punpckhwd %%mm2, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
66 "movq %%mm0, (%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
67 "movq %%mm1, 8(%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
68 "addl $16, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
69 " jnz 1b \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
70 "emms \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
71 :: "r" (s16+512), "r" (f+256)
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
72 :"%esi", "memory"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
73 );*/
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
74 asm volatile(
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
75 "movl $-1024, %%esi \n\t"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
76 "movq "MANGLE(magicF2W)", %%mm7 \n\t"
3567
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
77 "1: \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
78 "movq (%1, %%esi), %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
79 "movq 8(%1, %%esi), %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
80 "movq 1024(%1, %%esi), %%mm2 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
81 "movq 1032(%1, %%esi), %%mm3 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
82 "psubd %%mm7, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
83 "psubd %%mm7, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
84 "psubd %%mm7, %%mm2 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
85 "psubd %%mm7, %%mm3 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
86 "packssdw %%mm1, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
87 "packssdw %%mm3, %%mm2 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
88 "movq %%mm0, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
89 "punpcklwd %%mm2, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
90 "punpckhwd %%mm2, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
91 "movq %%mm0, (%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
92 "movq %%mm1, 8(%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
93 "addl $16, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
94 " jnz 1b \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
95 "emms \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
96 :: "r" (s16+512), "r" (f+256)
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
97 :"%esi", "memory"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
98 );
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
99 return 2*256;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
100 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
101
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
102 static int a52_resample_3F_to_5_MMX(float * _f, int16_t * s16){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
103 int i;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
104 int32_t * f = (int32_t *) _f;
3654
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
105 asm volatile(
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
106 "movl $-1024, %%esi \n\t"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
107 "movq "MANGLE(magicF2W)", %%mm7 \n\t"
3654
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
108 "pxor %%mm6, %%mm6 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
109 "movq %%mm7, %%mm5 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
110 "punpckldq %%mm6, %%mm5 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
111 "1: \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
112 "movd (%1, %%esi), %%mm0 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
113 "punpckldq 2048(%1, %%esi), %%mm0\n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
114 "movd 1024(%1, %%esi), %%mm1 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
115 "punpckldq 4(%1, %%esi), %%mm1 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
116 "movd 2052(%1, %%esi), %%mm2 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
117 "movq %%mm7, %%mm3 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
118 "punpckldq 1028(%1, %%esi), %%mm3\n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
119 "movd 8(%1, %%esi), %%mm4 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
120 "punpckldq 2056(%1, %%esi), %%mm4\n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
121 "leal (%%esi, %%esi, 4), %%edi \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
122 "sarl $1, %%edi \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
123 "psubd %%mm7, %%mm0 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
124 "psubd %%mm7, %%mm1 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
125 "psubd %%mm5, %%mm2 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
126 "psubd %%mm7, %%mm3 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
127 "psubd %%mm7, %%mm4 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
128 "packssdw %%mm6, %%mm0 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
129 "packssdw %%mm2, %%mm1 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
130 "packssdw %%mm4, %%mm3 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
131 "movq %%mm0, (%0, %%edi) \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
132 "movq %%mm1, 8(%0, %%edi) \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
133 "movq %%mm3, 16(%0, %%edi) \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
134
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
135 "movd 1032(%1, %%esi), %%mm1 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
136 "punpckldq 12(%1, %%esi), %%mm1\n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
137 "movd 2060(%1, %%esi), %%mm2 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
138 "movq %%mm7, %%mm3 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
139 "punpckldq 1036(%1, %%esi), %%mm3\n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
140 "pxor %%mm0, %%mm0 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
141 "psubd %%mm7, %%mm1 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
142 "psubd %%mm5, %%mm2 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
143 "psubd %%mm7, %%mm3 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
144 "packssdw %%mm1, %%mm0 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
145 "packssdw %%mm3, %%mm2 \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
146 "movq %%mm0, 24(%0, %%edi) \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
147 "movq %%mm2, 32(%0, %%edi) \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
148
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
149 "addl $16, %%esi \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
150 " jnz 1b \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
151 "emms \n\t"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
152 :: "r" (s16+1280), "r" (f+256)
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
153 :"%esi", "%edi", "memory"
33c3cff374a1 sse optimize of 3F
michael
parents: 3653
diff changeset
154 );
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
155 return 5*256;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
156 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
157
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
158 static int a52_resample_2F_2R_to_4_MMX(float * _f, int16_t * s16){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
159 int i;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
160 int32_t * f = (int32_t *) _f;
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
161 asm volatile(
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
162 "movl $-1024, %%esi \n\t"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
163 "movq "MANGLE(magicF2W)", %%mm7 \n\t"
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
164 "1: \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
165 "movq (%1, %%esi), %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
166 "movq 8(%1, %%esi), %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
167 "movq 1024(%1, %%esi), %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
168 "movq 1032(%1, %%esi), %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
169 "psubd %%mm7, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
170 "psubd %%mm7, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
171 "psubd %%mm7, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
172 "psubd %%mm7, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
173 "packssdw %%mm1, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
174 "packssdw %%mm3, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
175 "movq 2048(%1, %%esi), %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
176 "movq 2056(%1, %%esi), %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
177 "movq 3072(%1, %%esi), %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
178 "movq 3080(%1, %%esi), %%mm6 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
179 "psubd %%mm7, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
180 "psubd %%mm7, %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
181 "psubd %%mm7, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
182 "psubd %%mm7, %%mm6 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
183 "packssdw %%mm4, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
184 "packssdw %%mm6, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
185 "movq %%mm0, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
186 "movq %%mm3, %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
187 "punpcklwd %%mm2, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
188 "punpckhwd %%mm2, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
189 "punpcklwd %%mm5, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
190 "punpckhwd %%mm5, %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
191 "movq %%mm0, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
192 "movq %%mm1, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
193 "punpckldq %%mm3, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
194 "punpckhdq %%mm3, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
195 "punpckldq %%mm4, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
196 "punpckhdq %%mm4, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
197 "movq %%mm0, (%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
198 "movq %%mm2, 8(%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
199 "movq %%mm1, 16(%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
200 "movq %%mm5, 24(%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
201 "addl $16, %%esi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
202 " jnz 1b \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
203 "emms \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
204 :: "r" (s16+1024), "r" (f+256)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
205 :"%esi", "memory"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
206 );
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
207 return 4*256;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
208 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
209
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
210 static int a52_resample_3F_2R_to_5_MMX(float * _f, int16_t * s16){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
211 int i;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
212 int32_t * f = (int32_t *) _f;
3653
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
213 asm volatile(
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
214 "movl $-1024, %%esi \n\t"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
215 "movq "MANGLE(magicF2W)", %%mm7 \n\t"
3653
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
216 "1: \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
217 "movd (%1, %%esi), %%mm0 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
218 "punpckldq 2048(%1, %%esi), %%mm0\n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
219 "movd 3072(%1, %%esi), %%mm1 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
220 "punpckldq 4096(%1, %%esi), %%mm1\n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
221 "movd 1024(%1, %%esi), %%mm2 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
222 "punpckldq 4(%1, %%esi), %%mm2 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
223 "movd 2052(%1, %%esi), %%mm3 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
224 "punpckldq 3076(%1, %%esi), %%mm3\n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
225 "movd 4100(%1, %%esi), %%mm4 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
226 "punpckldq 1028(%1, %%esi), %%mm4\n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
227 "movd 8(%1, %%esi), %%mm5 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
228 "punpckldq 2056(%1, %%esi), %%mm5\n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
229 "leal (%%esi, %%esi, 4), %%edi \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
230 "sarl $1, %%edi \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
231 "psubd %%mm7, %%mm0 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
232 "psubd %%mm7, %%mm1 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
233 "psubd %%mm7, %%mm2 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
234 "psubd %%mm7, %%mm3 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
235 "psubd %%mm7, %%mm4 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
236 "psubd %%mm7, %%mm5 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
237 "packssdw %%mm1, %%mm0 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
238 "packssdw %%mm3, %%mm2 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
239 "packssdw %%mm5, %%mm4 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
240 "movq %%mm0, (%0, %%edi) \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
241 "movq %%mm2, 8(%0, %%edi) \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
242 "movq %%mm4, 16(%0, %%edi) \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
243
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
244 "movd 3080(%1, %%esi), %%mm0 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
245 "punpckldq 4104(%1, %%esi), %%mm0\n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
246 "movd 1032(%1, %%esi), %%mm1 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
247 "punpckldq 12(%1, %%esi), %%mm1\n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
248 "movd 2060(%1, %%esi), %%mm2 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
249 "punpckldq 3084(%1, %%esi), %%mm2\n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
250 "movd 4108(%1, %%esi), %%mm3 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
251 "punpckldq 1036(%1, %%esi), %%mm3\n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
252 "psubd %%mm7, %%mm0 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
253 "psubd %%mm7, %%mm1 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
254 "psubd %%mm7, %%mm2 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
255 "psubd %%mm7, %%mm3 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
256 "packssdw %%mm1, %%mm0 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
257 "packssdw %%mm3, %%mm2 \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
258 "movq %%mm0, 24(%0, %%edi) \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
259 "movq %%mm2, 32(%0, %%edi) \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
260
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
261 "addl $16, %%esi \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
262 " jnz 1b \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
263 "emms \n\t"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
264 :: "r" (s16+1280), "r" (f+256)
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
265 :"%esi", "%edi", "memory"
b11b15df02ed 3F2R sse optimized
michael
parents: 3626
diff changeset
266 );
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
267 return 5*256;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
268 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
269
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
270 static int a52_resample_MONO_LFE_to_6_MMX(float * _f, int16_t * s16){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
271 int i;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
272 int32_t * f = (int32_t *) _f;
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
273 asm volatile(
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
274 "movl $-1024, %%esi \n\t"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
275 "movq "MANGLE(magicF2W)", %%mm7 \n\t"
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
276 "pxor %%mm6, %%mm6 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
277 "1: \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
278 "movq 1024(%1, %%esi), %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
279 "movq 1032(%1, %%esi), %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
280 "movq (%1, %%esi), %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
281 "movq 8(%1, %%esi), %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
282 "psubd %%mm7, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
283 "psubd %%mm7, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
284 "psubd %%mm7, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
285 "psubd %%mm7, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
286 "packssdw %%mm1, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
287 "packssdw %%mm3, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
288 "movq %%mm0, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
289 "punpcklwd %%mm2, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
290 "punpckhwd %%mm2, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
291 "leal (%%esi, %%esi, 2), %%edi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
292 "movq %%mm6, (%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
293 "movd %%mm0, 8(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
294 "punpckhdq %%mm0, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
295 "movq %%mm6, 12(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
296 "movd %%mm0, 20(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
297 "movq %%mm6, 24(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
298 "movd %%mm1, 32(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
299 "punpckhdq %%mm1, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
300 "movq %%mm6, 36(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
301 "movd %%mm1, 44(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
302 "addl $16, %%esi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
303 " jnz 1b \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
304 "emms \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
305 :: "r" (s16+1536), "r" (f+256)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
306 :"%esi", "%edi", "memory"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
307 );
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
308 return 6*256;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
309 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
310
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
311 static int a52_resample_STEREO_LFE_to_6_MMX(float * _f, int16_t * s16){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
312 int i;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
313 int32_t * f = (int32_t *) _f;
3576
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
314 asm volatile(
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
315 "movl $-1024, %%esi \n\t"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
316 "movq "MANGLE(magicF2W)", %%mm7 \n\t"
3576
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
317 "pxor %%mm6, %%mm6 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
318 "1: \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
319 "movq 1024(%1, %%esi), %%mm0 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
320 "movq 2048(%1, %%esi), %%mm1 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
321 "movq (%1, %%esi), %%mm5 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
322 "psubd %%mm7, %%mm0 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
323 "psubd %%mm7, %%mm1 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
324 "psubd %%mm7, %%mm5 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
325 "leal (%%esi, %%esi, 2), %%edi \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
326
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
327 "pxor %%mm4, %%mm4 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
328 "packssdw %%mm5, %%mm0 \n\t" // FfAa
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
329 "packssdw %%mm4, %%mm1 \n\t" // 00Bb
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
330 "punpckhwd %%mm0, %%mm4 \n\t" // F0f0
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
331 "punpcklwd %%mm1, %%mm0 \n\t" // BAba
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
332 "movq %%mm0, %%mm1 \n\t" // BAba
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
333 "punpckldq %%mm4, %%mm3 \n\t" // f0XX
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
334 "punpckldq %%mm6, %%mm0 \n\t" // 00ba
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
335 "punpckhdq %%mm1, %%mm3 \n\t" // BAf0
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
336
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
337 "movq %%mm0, (%0, %%edi) \n\t" // 00ba
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
338 "punpckhdq %%mm4, %%mm0 \n\t" // F000
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
339 "movq %%mm3, 8(%0, %%edi) \n\t" // BAf0
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
340 "movq %%mm0, 16(%0, %%edi) \n\t" // F000
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
341 "addl $8, %%esi \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
342 " jnz 1b \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
343 "emms \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
344 :: "r" (s16+1536), "r" (f+256)
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
345 :"%esi", "%edi", "memory"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
346 );
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
347 return 6*256;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
348 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
349
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
350 static int a52_resample_3F_LFE_to_6_MMX(float * _f, int16_t * s16){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
351 int i;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
352 int32_t * f = (int32_t *) _f;
3578
79759c05911e mmx opt
michael
parents: 3577
diff changeset
353 asm volatile(
79759c05911e mmx opt
michael
parents: 3577
diff changeset
354 "movl $-1024, %%esi \n\t"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
355 "movq "MANGLE(magicF2W)", %%mm7 \n\t"
3578
79759c05911e mmx opt
michael
parents: 3577
diff changeset
356 "pxor %%mm6, %%mm6 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
357 "1: \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
358 "movq 1024(%1, %%esi), %%mm0 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
359 "movq 3072(%1, %%esi), %%mm1 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
360 "movq 2048(%1, %%esi), %%mm4 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
361 "movq (%1, %%esi), %%mm5 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
362 "psubd %%mm7, %%mm0 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
363 "psubd %%mm7, %%mm1 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
364 "psubd %%mm7, %%mm4 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
365 "psubd %%mm7, %%mm5 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
366 "leal (%%esi, %%esi, 2), %%edi \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
367
79759c05911e mmx opt
michael
parents: 3577
diff changeset
368 "packssdw %%mm4, %%mm0 \n\t" // EeAa
79759c05911e mmx opt
michael
parents: 3577
diff changeset
369 "packssdw %%mm5, %%mm1 \n\t" // FfBb
79759c05911e mmx opt
michael
parents: 3577
diff changeset
370 "movq %%mm0, %%mm2 \n\t" // EeAa
79759c05911e mmx opt
michael
parents: 3577
diff changeset
371 "punpcklwd %%mm1, %%mm0 \n\t" // BAba
79759c05911e mmx opt
michael
parents: 3577
diff changeset
372 "punpckhwd %%mm1, %%mm2 \n\t" // FEfe
79759c05911e mmx opt
michael
parents: 3577
diff changeset
373 "movq %%mm0, %%mm1 \n\t" // BAba
79759c05911e mmx opt
michael
parents: 3577
diff changeset
374 "punpckldq %%mm6, %%mm0 \n\t" // 00ba
79759c05911e mmx opt
michael
parents: 3577
diff changeset
375 "punpckhdq %%mm1, %%mm1 \n\t" // BABA
79759c05911e mmx opt
michael
parents: 3577
diff changeset
376
79759c05911e mmx opt
michael
parents: 3577
diff changeset
377 "movq %%mm0, (%0, %%edi) \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
378 "punpckhdq %%mm2, %%mm0 \n\t" // FE00
79759c05911e mmx opt
michael
parents: 3577
diff changeset
379 "punpckldq %%mm1, %%mm2 \n\t" // BAfe
79759c05911e mmx opt
michael
parents: 3577
diff changeset
380 "movq %%mm2, 8(%0, %%edi) \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
381 "movq %%mm0, 16(%0, %%edi) \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
382 "addl $8, %%esi \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
383 " jnz 1b \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
384 "emms \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
385 :: "r" (s16+1536), "r" (f+256)
79759c05911e mmx opt
michael
parents: 3577
diff changeset
386 :"%esi", "%edi", "memory"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
387 );
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
388 return 6*256;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
389 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
390
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
391 static int a52_resample_2F_2R_LFE_to_6_MMX(float * _f, int16_t * s16){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
392 int i;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
393 int32_t * f = (int32_t *) _f;
3577
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
394 asm volatile(
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
395 "movl $-1024, %%esi \n\t"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
396 "movq "MANGLE(magicF2W)", %%mm7 \n\t"
3577
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
397 // "pxor %%mm6, %%mm6 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
398 "1: \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
399 "movq 1024(%1, %%esi), %%mm0 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
400 "movq 2048(%1, %%esi), %%mm1 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
401 "movq 3072(%1, %%esi), %%mm2 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
402 "movq 4096(%1, %%esi), %%mm3 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
403 "movq (%1, %%esi), %%mm5 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
404 "psubd %%mm7, %%mm0 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
405 "psubd %%mm7, %%mm1 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
406 "psubd %%mm7, %%mm2 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
407 "psubd %%mm7, %%mm3 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
408 "psubd %%mm7, %%mm5 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
409 "leal (%%esi, %%esi, 2), %%edi \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
410
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
411 "packssdw %%mm2, %%mm0 \n\t" // CcAa
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
412 "packssdw %%mm3, %%mm1 \n\t" // DdBb
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
413 "packssdw %%mm5, %%mm5 \n\t" // FfFf
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
414 "movq %%mm0, %%mm2 \n\t" // CcAa
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
415 "punpcklwd %%mm1, %%mm0 \n\t" // BAba
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
416 "punpckhwd %%mm1, %%mm2 \n\t" // DCdc
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
417 "pxor %%mm4, %%mm4 \n\t" // 0000
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
418 "punpcklwd %%mm5, %%mm4 \n\t" // F0f0
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
419 "movq %%mm0, %%mm1 \n\t" // BAba
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
420 "movq %%mm4, %%mm3 \n\t" // F0f0
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
421 "punpckldq %%mm2, %%mm0 \n\t" // dcba
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
422 "punpckhdq %%mm1, %%mm1 \n\t" // BABA
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
423 "punpckldq %%mm1, %%mm4 \n\t" // BAf0
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
424 "punpckhdq %%mm3, %%mm2 \n\t" // F0DC
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
425
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
426 "movq %%mm0, (%0, %%edi) \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
427 "movq %%mm4, 8(%0, %%edi) \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
428 "movq %%mm2, 16(%0, %%edi) \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
429 "addl $8, %%esi \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
430 " jnz 1b \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
431 "emms \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
432 :: "r" (s16+1536), "r" (f+256)
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
433 :"%esi", "%edi", "memory"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
434 );
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
435 return 6*256;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
436 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
437
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
438 static int a52_resample_3F_2R_LFE_to_6_MMX(float * _f, int16_t * s16){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
439 int i;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
440 int32_t * f = (int32_t *) _f;
3575
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
441 asm volatile(
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
442 "movl $-1024, %%esi \n\t"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
443 "movq "MANGLE(magicF2W)", %%mm7 \n\t"
3575
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
444 // "pxor %%mm6, %%mm6 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
445 "1: \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
446 "movq 1024(%1, %%esi), %%mm0 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
447 "movq 3072(%1, %%esi), %%mm1 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
448 "movq 4096(%1, %%esi), %%mm2 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
449 "movq 5120(%1, %%esi), %%mm3 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
450 "movq 2048(%1, %%esi), %%mm4 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
451 "movq (%1, %%esi), %%mm5 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
452 "psubd %%mm7, %%mm0 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
453 "psubd %%mm7, %%mm1 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
454 "psubd %%mm7, %%mm2 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
455 "psubd %%mm7, %%mm3 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
456 "psubd %%mm7, %%mm4 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
457 "psubd %%mm7, %%mm5 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
458 "leal (%%esi, %%esi, 2), %%edi \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
459
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
460 "packssdw %%mm2, %%mm0 \n\t" // CcAa
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
461 "packssdw %%mm3, %%mm1 \n\t" // DdBb
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
462 "packssdw %%mm4, %%mm4 \n\t" // EeEe
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
463 "packssdw %%mm5, %%mm5 \n\t" // FfFf
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
464 "movq %%mm0, %%mm2 \n\t" // CcAa
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
465 "punpcklwd %%mm1, %%mm0 \n\t" // BAba
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
466 "punpckhwd %%mm1, %%mm2 \n\t" // DCdc
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
467 "punpcklwd %%mm5, %%mm4 \n\t" // FEfe
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
468 "movq %%mm0, %%mm1 \n\t" // BAba
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
469 "movq %%mm4, %%mm3 \n\t" // FEfe
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
470 "punpckldq %%mm2, %%mm0 \n\t" // dcba
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
471 "punpckhdq %%mm1, %%mm1 \n\t" // BABA
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
472 "punpckldq %%mm1, %%mm4 \n\t" // BAfe
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
473 "punpckhdq %%mm3, %%mm2 \n\t" // FEDC
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
474
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
475 "movq %%mm0, (%0, %%edi) \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
476 "movq %%mm4, 8(%0, %%edi) \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
477 "movq %%mm2, 16(%0, %%edi) \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
478 "addl $8, %%esi \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
479 " jnz 1b \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
480 "emms \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
481 :: "r" (s16+1536), "r" (f+256)
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
482 :"%esi", "%edi", "memory"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
483 );
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
484 return 6*256;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
485 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
486
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
487
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
488 static void* a52_resample_MMX(int flags, int ch){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
489 switch (flags) {
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
490 case A52_MONO:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
491 if(ch==5) return a52_resample_MONO_to_5_MMX;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
492 break;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
493 case A52_CHANNEL:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
494 case A52_STEREO:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
495 case A52_DOLBY:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
496 if(ch==2) return a52_resample_STEREO_to_2_MMX;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
497 break;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
498 case A52_3F:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
499 if(ch==5) return a52_resample_3F_to_5_MMX;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
500 break;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
501 case A52_2F2R:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
502 if(ch==4) return a52_resample_2F_2R_to_4_MMX;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
503 break;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
504 case A52_3F2R:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
505 if(ch==5) return a52_resample_3F_2R_to_5_MMX;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
506 break;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
507 case A52_MONO | A52_LFE:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
508 if(ch==6) return a52_resample_MONO_LFE_to_6_MMX;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
509 break;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
510 case A52_CHANNEL | A52_LFE:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
511 case A52_STEREO | A52_LFE:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
512 case A52_DOLBY | A52_LFE:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
513 if(ch==6) return a52_resample_STEREO_LFE_to_6_MMX;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
514 break;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
515 case A52_3F | A52_LFE:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
516 if(ch==6) return a52_resample_3F_LFE_to_6_MMX;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
517 break;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
518 case A52_2F2R | A52_LFE:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
519 if(ch==6) return a52_resample_2F_2R_LFE_to_6_MMX;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
520 break;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
521 case A52_3F2R | A52_LFE:
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
522 if(ch==6) return a52_resample_3F_2R_LFE_to_6_MMX;
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
523 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
524 }
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
525 return NULL;
3626
e22ff7ebdc05 runtime cpu detection for the resample stuff
michael
parents: 3578
diff changeset
526 }
e22ff7ebdc05 runtime cpu detection for the resample stuff
michael
parents: 3578
diff changeset
527
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
528