annotate liba52/resample_mmx.c @ 3599:2141db140d84

nop_steraming fixed
author arpi
date Wed, 19 Dec 2001 01:59:25 +0000
parents 79759c05911e
children e22ff7ebdc05
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 // this code come from a52dec/libao/audio_out_oss.c
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
2
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
3 // FIXME FIXME FIXME
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
4
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
5 // a52_resample_init should find the requested converter (from type flags ->
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
6 // given number of channels) and set up some function pointers...
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
7
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
8 // a52_resample() should do the conversion.
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
9
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
10 // MMX optimizations from Michael Niedermayer (michaelni@gmx.at) (under GPL)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
11
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
12 /* optimization TODO / NOTES
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
13 movntq is slightly faster (0.5% with the current test.c benchmark)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
14 (but thats just test.c so that needs to be testd in reallity)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
15 and it would mean (C / MMX2 / MMX / 3DNOW) versions
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
16 */
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
17
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
18 #include <inttypes.h>
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
19 #include "a52.h"
3567
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
20 #include "../config.h"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
21
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
22 #ifdef HAVE_MMX
3574
8600f40003de mmx opt
michael
parents: 3569
diff changeset
23 static uint64_t __attribute__((aligned(8))) magicF2W= 0x43c0000043c00000LL;
8600f40003de mmx opt
michael
parents: 3569
diff changeset
24 static uint64_t __attribute__((aligned(8))) wm1010= 0xFFFF0000FFFF0000LL;
8600f40003de mmx opt
michael
parents: 3569
diff changeset
25 static uint64_t __attribute__((aligned(8))) wm0101= 0x0000FFFF0000FFFFLL;
8600f40003de mmx opt
michael
parents: 3569
diff changeset
26 static uint64_t __attribute__((aligned(8))) wm1100= 0xFFFFFFFF00000000LL;
3567
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
27 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
28
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
29 static inline int16_t convert (int32_t i)
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
30 {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
31 if (i > 0x43c07fff)
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
32 return 32767;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
33 else if (i < 0x43bf8000)
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
34 return -32768;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
35 else
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
36 return i - 0x43c00000;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
37 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
38
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
39 static int chans=2;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
40 static int flags=0;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
41
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
42 void a52_resample_init(int _flags,int _chans){
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
43 chans=_chans;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
44 flags=_flags;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
45 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
46
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
47 int a52_resample(float * _f, int16_t * s16)
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
48 {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
49 int i;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
50 int32_t * f = (int32_t *) _f;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
51
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
52 switch (flags) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
53 case A52_MONO:
3574
8600f40003de mmx opt
michael
parents: 3569
diff changeset
54 #ifdef HAVE_MMX
8600f40003de mmx opt
michael
parents: 3569
diff changeset
55 asm volatile(
8600f40003de mmx opt
michael
parents: 3569
diff changeset
56 "movl $-512, %%esi \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
57 "movq magicF2W, %%mm7 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
58 "movq wm1100, %%mm3 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
59 "movq wm0101, %%mm4 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
60 "movq wm1010, %%mm5 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
61 "pxor %%mm6, %%mm6 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
62 "1: \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
63 "movq (%1, %%esi, 2), %%mm0 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
64 "movq 8(%1, %%esi, 2), %%mm1 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
65 "leal (%%esi, %%esi, 4), %%edi \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
66 "psubd %%mm7, %%mm0 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
67 "psubd %%mm7, %%mm1 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
68 "packssdw %%mm1, %%mm0 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
69 "movq %%mm0, %%mm1 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
70 "pand %%mm4, %%mm0 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
71 "pand %%mm5, %%mm1 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
72 "movq %%mm6, (%0, %%edi) \n\t" // 0 0 0 0
8600f40003de mmx opt
michael
parents: 3569
diff changeset
73 "movd %%mm0, 8(%0, %%edi) \n\t" // A 0
8600f40003de mmx opt
michael
parents: 3569
diff changeset
74 "pand %%mm3, %%mm0 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
75 "movd %%mm6, 12(%0, %%edi) \n\t" // 0 0
8600f40003de mmx opt
michael
parents: 3569
diff changeset
76 "movd %%mm1, 16(%0, %%edi) \n\t" // 0 B
8600f40003de mmx opt
michael
parents: 3569
diff changeset
77 "pand %%mm3, %%mm1 \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
78 "movd %%mm6, 20(%0, %%edi) \n\t" // 0 0
8600f40003de mmx opt
michael
parents: 3569
diff changeset
79 "movq %%mm0, 24(%0, %%edi) \n\t" // 0 0 C 0
8600f40003de mmx opt
michael
parents: 3569
diff changeset
80 "movq %%mm1, 32(%0, %%edi) \n\t" // 0 0 0 B
8600f40003de mmx opt
michael
parents: 3569
diff changeset
81 "addl $8, %%esi \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
82 " jnz 1b \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
83 "emms \n\t"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
84 :: "r" (s16+1280), "r" (f+256)
8600f40003de mmx opt
michael
parents: 3569
diff changeset
85 :"%esi", "%edi", "memory"
8600f40003de mmx opt
michael
parents: 3569
diff changeset
86 );
8600f40003de mmx opt
michael
parents: 3569
diff changeset
87 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
88 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
89 s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
90 s16[5*i+4] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
91 }
3574
8600f40003de mmx opt
michael
parents: 3569
diff changeset
92 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
93 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
94 case A52_CHANNEL:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
95 case A52_STEREO:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
96 case A52_DOLBY:
3567
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
97 /* 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
98 #ifdef HAVE_SSE
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
99 asm volatile(
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
100 "movl $-1024, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
101 "1: \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
102 "cvtps2pi (%1, %%esi), %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
103 "cvtps2pi 1024(%1, %%esi), %%mm2\n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
104 "movq %%mm0, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
105 "punpcklwd %%mm2, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
106 "punpckhwd %%mm2, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
107 "movq %%mm0, (%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
108 "movq %%mm1, 8(%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
109 "addl $16, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
110 " jnz 1b \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
111 "emms \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
112 :: "r" (s16+512), "r" (f+256)
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
113 :"%esi", "memory"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
114 );*/
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
115 #ifdef HAVE_MMX
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
116 asm volatile(
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
117 "movl $-1024, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
118 "movq magicF2W, %%mm7 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
119 "1: \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
120 "movq (%1, %%esi), %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
121 "movq 8(%1, %%esi), %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
122 "movq 1024(%1, %%esi), %%mm2 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
123 "movq 1032(%1, %%esi), %%mm3 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
124 "psubd %%mm7, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
125 "psubd %%mm7, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
126 "psubd %%mm7, %%mm2 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
127 "psubd %%mm7, %%mm3 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
128 "packssdw %%mm1, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
129 "packssdw %%mm3, %%mm2 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
130 "movq %%mm0, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
131 "punpcklwd %%mm2, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
132 "punpckhwd %%mm2, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
133 "movq %%mm0, (%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
134 "movq %%mm1, 8(%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
135 "addl $16, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
136 " jnz 1b \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
137 "emms \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
138 :: "r" (s16+512), "r" (f+256)
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
139 :"%esi", "memory"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
140 );
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
141 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
142 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
143 s16[2*i] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
144 s16[2*i+1] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
145 }
3567
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
146 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
147 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
148 case A52_3F:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
149 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
150 s16[5*i] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
151 s16[5*i+1] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
152 s16[5*i+2] = s16[5*i+3] = 0;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
153 s16[5*i+4] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
154 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
155 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
156 case A52_2F2R:
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
157 #ifdef HAVE_MMX
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
158 asm volatile(
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
159 "movl $-1024, %%esi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
160 "movq magicF2W, %%mm7 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
161 "1: \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
162 "movq (%1, %%esi), %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
163 "movq 8(%1, %%esi), %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
164 "movq 1024(%1, %%esi), %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
165 "movq 1032(%1, %%esi), %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
166 "psubd %%mm7, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
167 "psubd %%mm7, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
168 "psubd %%mm7, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
169 "psubd %%mm7, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
170 "packssdw %%mm1, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
171 "packssdw %%mm3, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
172 "movq 2048(%1, %%esi), %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
173 "movq 2056(%1, %%esi), %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
174 "movq 3072(%1, %%esi), %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
175 "movq 3080(%1, %%esi), %%mm6 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
176 "psubd %%mm7, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
177 "psubd %%mm7, %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
178 "psubd %%mm7, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
179 "psubd %%mm7, %%mm6 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
180 "packssdw %%mm4, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
181 "packssdw %%mm6, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
182 "movq %%mm0, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
183 "movq %%mm3, %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
184 "punpcklwd %%mm2, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
185 "punpckhwd %%mm2, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
186 "punpcklwd %%mm5, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
187 "punpckhwd %%mm5, %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
188 "movq %%mm0, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
189 "movq %%mm1, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
190 "punpckldq %%mm3, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
191 "punpckhdq %%mm3, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
192 "punpckldq %%mm4, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
193 "punpckhdq %%mm4, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
194 "movq %%mm0, (%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
195 "movq %%mm2, 8(%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
196 "movq %%mm1, 16(%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
197 "movq %%mm5, 24(%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
198 "addl $16, %%esi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
199 " jnz 1b \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
200 "emms \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
201 :: "r" (s16+1024), "r" (f+256)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
202 :"%esi", "memory"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
203 );
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
204 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
205 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
206 s16[4*i] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
207 s16[4*i+1] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
208 s16[4*i+2] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
209 s16[4*i+3] = convert (f[i+768]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
210 }
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
211 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
212 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
213 case A52_3F2R:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
214 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
215 s16[5*i] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
216 s16[5*i+1] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
217 s16[5*i+2] = convert (f[i+768]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
218 s16[5*i+3] = convert (f[i+1024]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
219 s16[5*i+4] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
220 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
221 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
222 case A52_MONO | A52_LFE:
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
223 #ifdef HAVE_MMX
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
224 asm volatile(
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
225 "movl $-1024, %%esi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
226 "movq magicF2W, %%mm7 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
227 "pxor %%mm6, %%mm6 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
228 "1: \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
229 "movq 1024(%1, %%esi), %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
230 "movq 1032(%1, %%esi), %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
231 "movq (%1, %%esi), %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
232 "movq 8(%1, %%esi), %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
233 "psubd %%mm7, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
234 "psubd %%mm7, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
235 "psubd %%mm7, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
236 "psubd %%mm7, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
237 "packssdw %%mm1, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
238 "packssdw %%mm3, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
239 "movq %%mm0, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
240 "punpcklwd %%mm2, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
241 "punpckhwd %%mm2, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
242 "leal (%%esi, %%esi, 2), %%edi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
243 "movq %%mm6, (%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
244 "movd %%mm0, 8(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
245 "punpckhdq %%mm0, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
246 "movq %%mm6, 12(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
247 "movd %%mm0, 20(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
248 "movq %%mm6, 24(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
249 "movd %%mm1, 32(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
250 "punpckhdq %%mm1, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
251 "movq %%mm6, 36(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
252 "movd %%mm1, 44(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
253 "addl $16, %%esi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
254 " jnz 1b \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
255 "emms \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
256 :: "r" (s16+1536), "r" (f+256)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
257 :"%esi", "%edi", "memory"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
258 );
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
259 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
260 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
261 s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
262 s16[6*i+4] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
263 s16[6*i+5] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
264 }
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
265 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
266 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
267 case A52_CHANNEL | A52_LFE:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
268 case A52_STEREO | A52_LFE:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
269 case A52_DOLBY | A52_LFE:
3576
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
270 #ifdef HAVE_MMX
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
271 asm volatile(
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
272 "movl $-1024, %%esi \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
273 "movq magicF2W, %%mm7 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
274 "pxor %%mm6, %%mm6 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
275 "1: \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
276 "movq 1024(%1, %%esi), %%mm0 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
277 "movq 2048(%1, %%esi), %%mm1 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
278 "movq (%1, %%esi), %%mm5 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
279 "psubd %%mm7, %%mm0 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
280 "psubd %%mm7, %%mm1 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
281 "psubd %%mm7, %%mm5 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
282 "leal (%%esi, %%esi, 2), %%edi \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
283
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
284 "pxor %%mm4, %%mm4 \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
285 "packssdw %%mm5, %%mm0 \n\t" // FfAa
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
286 "packssdw %%mm4, %%mm1 \n\t" // 00Bb
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
287 "punpckhwd %%mm0, %%mm4 \n\t" // F0f0
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
288 "punpcklwd %%mm1, %%mm0 \n\t" // BAba
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
289 "movq %%mm0, %%mm1 \n\t" // BAba
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
290 "punpckldq %%mm4, %%mm3 \n\t" // f0XX
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
291 "punpckldq %%mm6, %%mm0 \n\t" // 00ba
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
292 "punpckhdq %%mm1, %%mm3 \n\t" // BAf0
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
293
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
294 "movq %%mm0, (%0, %%edi) \n\t" // 00ba
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
295 "punpckhdq %%mm4, %%mm0 \n\t" // F000
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
296 "movq %%mm3, 8(%0, %%edi) \n\t" // BAf0
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
297 "movq %%mm0, 16(%0, %%edi) \n\t" // F000
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
298 "addl $8, %%esi \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
299 " jnz 1b \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
300 "emms \n\t"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
301 :: "r" (s16+1536), "r" (f+256)
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
302 :"%esi", "%edi", "memory"
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
303 );
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
304 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
305 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
306 s16[6*i] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
307 s16[6*i+1] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
308 s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
309 s16[6*i+5] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
310 }
3576
c282fd9e8534 mmx opt
michael
parents: 3575
diff changeset
311 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
312 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
313 case A52_3F | A52_LFE:
3578
79759c05911e mmx opt
michael
parents: 3577
diff changeset
314 #ifdef HAVE_MMX
79759c05911e mmx opt
michael
parents: 3577
diff changeset
315 asm volatile(
79759c05911e mmx opt
michael
parents: 3577
diff changeset
316 "movl $-1024, %%esi \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
317 "movq magicF2W, %%mm7 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
318 "pxor %%mm6, %%mm6 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
319 "1: \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
320 "movq 1024(%1, %%esi), %%mm0 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
321 "movq 3072(%1, %%esi), %%mm1 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
322 "movq 2048(%1, %%esi), %%mm4 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
323 "movq (%1, %%esi), %%mm5 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
324 "psubd %%mm7, %%mm0 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
325 "psubd %%mm7, %%mm1 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
326 "psubd %%mm7, %%mm4 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
327 "psubd %%mm7, %%mm5 \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
328 "leal (%%esi, %%esi, 2), %%edi \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
329
79759c05911e mmx opt
michael
parents: 3577
diff changeset
330 "packssdw %%mm4, %%mm0 \n\t" // EeAa
79759c05911e mmx opt
michael
parents: 3577
diff changeset
331 "packssdw %%mm5, %%mm1 \n\t" // FfBb
79759c05911e mmx opt
michael
parents: 3577
diff changeset
332 "movq %%mm0, %%mm2 \n\t" // EeAa
79759c05911e mmx opt
michael
parents: 3577
diff changeset
333 "punpcklwd %%mm1, %%mm0 \n\t" // BAba
79759c05911e mmx opt
michael
parents: 3577
diff changeset
334 "punpckhwd %%mm1, %%mm2 \n\t" // FEfe
79759c05911e mmx opt
michael
parents: 3577
diff changeset
335 "movq %%mm0, %%mm1 \n\t" // BAba
79759c05911e mmx opt
michael
parents: 3577
diff changeset
336 "punpckldq %%mm6, %%mm0 \n\t" // 00ba
79759c05911e mmx opt
michael
parents: 3577
diff changeset
337 "punpckhdq %%mm1, %%mm1 \n\t" // BABA
79759c05911e mmx opt
michael
parents: 3577
diff changeset
338
79759c05911e mmx opt
michael
parents: 3577
diff changeset
339 "movq %%mm0, (%0, %%edi) \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
340 "punpckhdq %%mm2, %%mm0 \n\t" // FE00
79759c05911e mmx opt
michael
parents: 3577
diff changeset
341 "punpckldq %%mm1, %%mm2 \n\t" // BAfe
79759c05911e mmx opt
michael
parents: 3577
diff changeset
342 "movq %%mm2, 8(%0, %%edi) \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
343 "movq %%mm0, 16(%0, %%edi) \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
344 "addl $8, %%esi \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
345 " jnz 1b \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
346 "emms \n\t"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
347 :: "r" (s16+1536), "r" (f+256)
79759c05911e mmx opt
michael
parents: 3577
diff changeset
348 :"%esi", "%edi", "memory"
79759c05911e mmx opt
michael
parents: 3577
diff changeset
349 );
79759c05911e mmx opt
michael
parents: 3577
diff changeset
350 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
351 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
352 s16[6*i] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
353 s16[6*i+1] = convert (f[i+768]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
354 s16[6*i+2] = s16[6*i+3] = 0;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
355 s16[6*i+4] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
356 s16[6*i+5] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
357 }
3578
79759c05911e mmx opt
michael
parents: 3577
diff changeset
358 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
359 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
360 case A52_2F2R | A52_LFE:
3577
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
361 #ifdef HAVE_MMX
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
362 asm volatile(
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
363 "movl $-1024, %%esi \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
364 "movq magicF2W, %%mm7 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
365 // "pxor %%mm6, %%mm6 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
366 "1: \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
367 "movq 1024(%1, %%esi), %%mm0 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
368 "movq 2048(%1, %%esi), %%mm1 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
369 "movq 3072(%1, %%esi), %%mm2 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
370 "movq 4096(%1, %%esi), %%mm3 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
371 "movq (%1, %%esi), %%mm5 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
372 "psubd %%mm7, %%mm0 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
373 "psubd %%mm7, %%mm1 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
374 "psubd %%mm7, %%mm2 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
375 "psubd %%mm7, %%mm3 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
376 "psubd %%mm7, %%mm5 \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
377 "leal (%%esi, %%esi, 2), %%edi \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
378
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
379 "packssdw %%mm2, %%mm0 \n\t" // CcAa
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
380 "packssdw %%mm3, %%mm1 \n\t" // DdBb
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
381 "packssdw %%mm5, %%mm5 \n\t" // FfFf
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
382 "movq %%mm0, %%mm2 \n\t" // CcAa
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
383 "punpcklwd %%mm1, %%mm0 \n\t" // BAba
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
384 "punpckhwd %%mm1, %%mm2 \n\t" // DCdc
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
385 "pxor %%mm4, %%mm4 \n\t" // 0000
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
386 "punpcklwd %%mm5, %%mm4 \n\t" // F0f0
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
387 "movq %%mm0, %%mm1 \n\t" // BAba
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
388 "movq %%mm4, %%mm3 \n\t" // F0f0
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
389 "punpckldq %%mm2, %%mm0 \n\t" // dcba
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
390 "punpckhdq %%mm1, %%mm1 \n\t" // BABA
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
391 "punpckldq %%mm1, %%mm4 \n\t" // BAf0
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
392 "punpckhdq %%mm3, %%mm2 \n\t" // F0DC
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
393
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
394 "movq %%mm0, (%0, %%edi) \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
395 "movq %%mm4, 8(%0, %%edi) \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
396 "movq %%mm2, 16(%0, %%edi) \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
397 "addl $8, %%esi \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
398 " jnz 1b \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
399 "emms \n\t"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
400 :: "r" (s16+1536), "r" (f+256)
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
401 :"%esi", "%edi", "memory"
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
402 );
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
403 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
404 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
405 s16[6*i] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
406 s16[6*i+1] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
407 s16[6*i+2] = convert (f[i+768]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
408 s16[6*i+3] = convert (f[i+1024]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
409 s16[6*i+4] = 0;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
410 s16[6*i+5] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
411 }
3577
6bf4dbfb941c mmx opt
michael
parents: 3576
diff changeset
412 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
413 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
414 case A52_3F2R | A52_LFE:
3575
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
415 #ifdef HAVE_MMX
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
416 asm volatile(
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
417 "movl $-1024, %%esi \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
418 "movq magicF2W, %%mm7 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
419 // "pxor %%mm6, %%mm6 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
420 "1: \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
421 "movq 1024(%1, %%esi), %%mm0 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
422 "movq 3072(%1, %%esi), %%mm1 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
423 "movq 4096(%1, %%esi), %%mm2 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
424 "movq 5120(%1, %%esi), %%mm3 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
425 "movq 2048(%1, %%esi), %%mm4 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
426 "movq (%1, %%esi), %%mm5 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
427 "psubd %%mm7, %%mm0 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
428 "psubd %%mm7, %%mm1 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
429 "psubd %%mm7, %%mm2 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
430 "psubd %%mm7, %%mm3 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
431 "psubd %%mm7, %%mm4 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
432 "psubd %%mm7, %%mm5 \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
433 "leal (%%esi, %%esi, 2), %%edi \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
434
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
435 "packssdw %%mm2, %%mm0 \n\t" // CcAa
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
436 "packssdw %%mm3, %%mm1 \n\t" // DdBb
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
437 "packssdw %%mm4, %%mm4 \n\t" // EeEe
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
438 "packssdw %%mm5, %%mm5 \n\t" // FfFf
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
439 "movq %%mm0, %%mm2 \n\t" // CcAa
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
440 "punpcklwd %%mm1, %%mm0 \n\t" // BAba
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
441 "punpckhwd %%mm1, %%mm2 \n\t" // DCdc
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
442 "punpcklwd %%mm5, %%mm4 \n\t" // FEfe
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
443 "movq %%mm0, %%mm1 \n\t" // BAba
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
444 "movq %%mm4, %%mm3 \n\t" // FEfe
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
445 "punpckldq %%mm2, %%mm0 \n\t" // dcba
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
446 "punpckhdq %%mm1, %%mm1 \n\t" // BABA
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
447 "punpckldq %%mm1, %%mm4 \n\t" // BAfe
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
448 "punpckhdq %%mm3, %%mm2 \n\t" // FEDC
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
449
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
450 "movq %%mm0, (%0, %%edi) \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
451 "movq %%mm4, 8(%0, %%edi) \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
452 "movq %%mm2, 16(%0, %%edi) \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
453 "addl $8, %%esi \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
454 " jnz 1b \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
455 "emms \n\t"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
456 :: "r" (s16+1536), "r" (f+256)
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
457 :"%esi", "%edi", "memory"
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
458 );
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
459 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
460 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
461 s16[6*i] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
462 s16[6*i+1] = convert (f[i+768]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
463 s16[6*i+2] = convert (f[i+1024]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
464 s16[6*i+3] = convert (f[i+1280]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
465 s16[6*i+4] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
466 s16[6*i+5] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
467 }
3575
01a2466e035e mmx opt
michael
parents: 3574
diff changeset
468 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
469 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
470 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
471 return chans*256;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
472 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
473