annotate liba52/resample_c.c @ 3569:d14494d84c29

MMX opt
author michael
date Mon, 17 Dec 2001 21:19:57 +0000
parents 9e1e88b3ca18
children 8600f40003de
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
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
23 static uint64_t __attribute__((aligned(16))) magicF2W= 0x43c0000043c00000LL;
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
24 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
25
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
26 static inline int16_t convert (int32_t i)
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
27 {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
28 if (i > 0x43c07fff)
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
29 return 32767;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
30 else if (i < 0x43bf8000)
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
31 return -32768;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
32 else
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
33 return i - 0x43c00000;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
34 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
35
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
36 static int chans=2;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
37 static int flags=0;
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 void a52_resample_init(int _flags,int _chans){
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
40 chans=_chans;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
41 flags=_flags;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
42 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
43
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
44 int a52_resample(float * _f, int16_t * s16)
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 int i;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
47 int32_t * f = (int32_t *) _f;
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 switch (flags) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
50 case A52_MONO:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
51 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
52 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
53 s16[5*i+4] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
54 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
55 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
56 case A52_CHANNEL:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
57 case A52_STEREO:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
58 case A52_DOLBY:
3567
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
59 /* 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
60 #ifdef HAVE_SSE
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
61 asm volatile(
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
62 "movl $-1024, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
63 "1: \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
64 "cvtps2pi (%1, %%esi), %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
65 "cvtps2pi 1024(%1, %%esi), %%mm2\n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
66 "movq %%mm0, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
67 "punpcklwd %%mm2, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
68 "punpckhwd %%mm2, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
69 "movq %%mm0, (%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
70 "movq %%mm1, 8(%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
71 "addl $16, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
72 " jnz 1b \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
73 "emms \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
74 :: "r" (s16+512), "r" (f+256)
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
75 :"%esi", "memory"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
76 );*/
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
77 #ifdef HAVE_MMX
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
78 asm volatile(
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
79 "movl $-1024, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
80 "movq magicF2W, %%mm7 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
81 "1: \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
82 "movq (%1, %%esi), %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
83 "movq 8(%1, %%esi), %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
84 "movq 1024(%1, %%esi), %%mm2 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
85 "movq 1032(%1, %%esi), %%mm3 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
86 "psubd %%mm7, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
87 "psubd %%mm7, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
88 "psubd %%mm7, %%mm2 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
89 "psubd %%mm7, %%mm3 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
90 "packssdw %%mm1, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
91 "packssdw %%mm3, %%mm2 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
92 "movq %%mm0, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
93 "punpcklwd %%mm2, %%mm0 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
94 "punpckhwd %%mm2, %%mm1 \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
95 "movq %%mm0, (%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
96 "movq %%mm1, 8(%0, %%esi) \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
97 "addl $16, %%esi \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
98 " jnz 1b \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
99 "emms \n\t"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
100 :: "r" (s16+512), "r" (f+256)
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
101 :"%esi", "memory"
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
102 );
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
103 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
104 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
105 s16[2*i] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
106 s16[2*i+1] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
107 }
3567
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
108 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
109 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
110 case A52_3F:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
111 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
112 s16[5*i] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
113 s16[5*i+1] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
114 s16[5*i+2] = s16[5*i+3] = 0;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
115 s16[5*i+4] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
116 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
117 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
118 case A52_2F2R:
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
119 #ifdef HAVE_MMX
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
120 asm volatile(
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
121 "movl $-1024, %%esi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
122 "movq magicF2W, %%mm7 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
123 "1: \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
124 "movq (%1, %%esi), %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
125 "movq 8(%1, %%esi), %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
126 "movq 1024(%1, %%esi), %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
127 "movq 1032(%1, %%esi), %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
128 "psubd %%mm7, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
129 "psubd %%mm7, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
130 "psubd %%mm7, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
131 "psubd %%mm7, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
132 "packssdw %%mm1, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
133 "packssdw %%mm3, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
134 "movq 2048(%1, %%esi), %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
135 "movq 2056(%1, %%esi), %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
136 "movq 3072(%1, %%esi), %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
137 "movq 3080(%1, %%esi), %%mm6 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
138 "psubd %%mm7, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
139 "psubd %%mm7, %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
140 "psubd %%mm7, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
141 "psubd %%mm7, %%mm6 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
142 "packssdw %%mm4, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
143 "packssdw %%mm6, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
144 "movq %%mm0, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
145 "movq %%mm3, %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
146 "punpcklwd %%mm2, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
147 "punpckhwd %%mm2, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
148 "punpcklwd %%mm5, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
149 "punpckhwd %%mm5, %%mm4 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
150 "movq %%mm0, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
151 "movq %%mm1, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
152 "punpckldq %%mm3, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
153 "punpckhdq %%mm3, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
154 "punpckldq %%mm4, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
155 "punpckhdq %%mm4, %%mm5 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
156 "movq %%mm0, (%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
157 "movq %%mm2, 8(%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
158 "movq %%mm1, 16(%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
159 "movq %%mm5, 24(%0, %%esi,2) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
160 "addl $16, %%esi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
161 " jnz 1b \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
162 "emms \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
163 :: "r" (s16+1024), "r" (f+256)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
164 :"%esi", "memory"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
165 );
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
166 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
167 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
168 s16[4*i] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
169 s16[4*i+1] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
170 s16[4*i+2] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
171 s16[4*i+3] = convert (f[i+768]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
172 }
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
173 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
174 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
175 case A52_3F2R:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
176 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
177 s16[5*i] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
178 s16[5*i+1] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
179 s16[5*i+2] = convert (f[i+768]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
180 s16[5*i+3] = convert (f[i+1024]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
181 s16[5*i+4] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
182 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
183 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
184 case A52_MONO | A52_LFE:
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
185 #ifdef HAVE_MMX
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
186 asm volatile(
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
187 "movl $-1024, %%esi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
188 "movq magicF2W, %%mm7 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
189 "pxor %%mm6, %%mm6 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
190 "1: \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
191 "movq 1024(%1, %%esi), %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
192 "movq 1032(%1, %%esi), %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
193 "movq (%1, %%esi), %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
194 "movq 8(%1, %%esi), %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
195 "psubd %%mm7, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
196 "psubd %%mm7, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
197 "psubd %%mm7, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
198 "psubd %%mm7, %%mm3 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
199 "packssdw %%mm1, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
200 "packssdw %%mm3, %%mm2 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
201 "movq %%mm0, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
202 "punpcklwd %%mm2, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
203 "punpckhwd %%mm2, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
204 "leal (%%esi, %%esi, 2), %%edi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
205 "movq %%mm6, (%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
206 "movd %%mm0, 8(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
207 "punpckhdq %%mm0, %%mm0 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
208 "movq %%mm6, 12(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
209 "movd %%mm0, 20(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
210 "movq %%mm6, 24(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
211 "movd %%mm1, 32(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
212 "punpckhdq %%mm1, %%mm1 \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
213 "movq %%mm6, 36(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
214 "movd %%mm1, 44(%0, %%edi) \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
215 "addl $16, %%esi \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
216 " jnz 1b \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
217 "emms \n\t"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
218 :: "r" (s16+1536), "r" (f+256)
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
219 :"%esi", "%edi", "memory"
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
220 );
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
221 #else
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
222 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
223 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
224 s16[6*i+4] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
225 s16[6*i+5] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
226 }
3569
d14494d84c29 MMX opt
michael
parents: 3567
diff changeset
227 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
228 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
229 case A52_CHANNEL | A52_LFE:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
230 case A52_STEREO | A52_LFE:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
231 case A52_DOLBY | A52_LFE:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
232 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
233 s16[6*i] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
234 s16[6*i+1] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
235 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
236 s16[6*i+5] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
237 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
238 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
239 case A52_3F | A52_LFE:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
240 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
241 s16[6*i] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
242 s16[6*i+1] = convert (f[i+768]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
243 s16[6*i+2] = s16[6*i+3] = 0;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
244 s16[6*i+4] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
245 s16[6*i+5] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
246 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
247 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
248 case A52_2F2R | A52_LFE:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
249 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
250 s16[6*i] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
251 s16[6*i+1] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
252 s16[6*i+2] = convert (f[i+768]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
253 s16[6*i+3] = convert (f[i+1024]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
254 s16[6*i+4] = 0;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
255 s16[6*i+5] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
256 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
257 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
258 case A52_3F2R | A52_LFE:
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
259 for (i = 0; i < 256; i++) {
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
260 s16[6*i] = convert (f[i+256]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
261 s16[6*i+1] = convert (f[i+768]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
262 s16[6*i+2] = convert (f[i+1024]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
263 s16[6*i+3] = convert (f[i+1280]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
264 s16[6*i+4] = convert (f[i+512]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
265 s16[6*i+5] = convert (f[i]);
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
266 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
267 break;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
268 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
269 return chans*256;
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
270 }
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
271