0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
1 /*
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
2 * Copyright 2012 Peter Meerwald <p.meerwald@bct-electronic.com>
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
3 */
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
4
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
5 #include <stdlib.h>
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
6 #include <stdio.h>
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
7 #include <stdarg.h>
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
8 #include <string.h>
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
9 #include <math.h>
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
10 #include <sys/time.h>
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
11 #include <assert.h>
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
12
|
1
|
13 typedef unsigned char uint8_t;
|
|
14 typedef short int16_t;
|
|
15 typedef unsigned int uint32_t;
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
16
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
17 typedef enum pa_sample_format {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
18 PA_SAMPLE_S16LE,
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
19 PA_SAMPLE_FLOAT32LE,
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
20 } pa_sample_format_t;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
21 #define PA_SAMPLE_S16NE PA_SAMPLE_S16LE
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
22 #define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
|
1
|
23
|
|
24 typedef struct pa_sample_spec {
|
|
25 pa_sample_format_t format;
|
|
26 uint32_t rate;
|
|
27 uint8_t channels;
|
|
28 } pa_sample_spec;
|
|
29
|
|
30 #define PA_CHANNELS_MAX 32
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
31 typedef struct {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
32 pa_sample_format_t *format;
|
1
|
33 pa_sample_spec *i_ss, *o_ss;
|
|
34 float map_table_f[PA_CHANNELS_MAX][PA_CHANNELS_MAX];
|
|
35 int32_t map_table_i[PA_CHANNELS_MAX][PA_CHANNELS_MAX];
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
36 } pa_remap_t;
|
1
|
37
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
38 typedef long long unsigned int pa_usec_t;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
39
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
40 #define pa_assert(x) assert(x)
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
41 #define pa_assert_not_reached() assert(0)
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
42
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
43 #define PA_CLAMP_UNLIKELY(x, low, high) \
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
44 (((x) < (low)) ? (low) : (((x) > (high)) ? (high) : (x)))
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
45
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
46 static void pa_log_info(const char *format, ...) {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
47 va_list ap;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
48 char buf[1024];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
49 va_start(ap, format);
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
50 vsprintf(buf, format, ap);
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
51 printf("%s\n", buf);
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
52 va_end(ap);
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
53 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
54
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
55 #define pa_log_debug pa_log_info
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
56
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
57 static pa_usec_t pa_rtclock_now() {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
58 struct timeval tv;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
59 gettimeofday(&tv, NULL);
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
60
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
61 return tv.tv_sec * 1000000ULL + tv.tv_usec;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
62 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
63
|
1
|
64 static void remap_channels_matrix_c(pa_remap_t *m, void *dst, const void *src, unsigned n) {
|
|
65 unsigned oc, ic, i;
|
|
66 unsigned n_ic, n_oc;
|
|
67
|
|
68 n_ic = m->i_ss->channels;
|
|
69 n_oc = m->o_ss->channels;
|
|
70
|
|
71 switch (*m->format) {
|
|
72 case PA_SAMPLE_FLOAT32NE:
|
|
73 {
|
|
74 float *d, *s;
|
|
75
|
|
76 memset(dst, 0, n * sizeof(float) * n_oc);
|
|
77
|
|
78 for (oc = 0; oc < n_oc; oc++) {
|
|
79
|
|
80 for (ic = 0; ic < n_ic; ic++) {
|
|
81 float vol;
|
|
82
|
|
83 vol = m->map_table_f[oc][ic];
|
|
84
|
|
85 if (vol <= 0.0)
|
|
86 continue;
|
|
87
|
|
88 d = (float *)dst + oc;
|
|
89 s = (float *)src + ic;
|
|
90
|
|
91 if (vol >= 1.0) {
|
|
92 for (i = n; i > 0; i--, s += n_ic, d += n_oc)
|
|
93 *d += *s;
|
|
94 } else {
|
|
95 for (i = n; i > 0; i--, s += n_ic, d += n_oc)
|
|
96 *d += *s * vol;
|
|
97 }
|
|
98 }
|
|
99 }
|
|
100
|
|
101 break;
|
|
102 }
|
|
103 case PA_SAMPLE_S16NE:
|
|
104 {
|
|
105 int16_t *d, *s;
|
|
106
|
|
107 memset(dst, 0, n * sizeof(int16_t) * n_oc);
|
|
108
|
|
109 for (oc = 0; oc < n_oc; oc++) {
|
|
110
|
|
111 for (ic = 0; ic < n_ic; ic++) {
|
|
112 int32_t vol;
|
|
113
|
|
114 vol = m->map_table_i[oc][ic];
|
|
115
|
|
116 if (vol <= 0)
|
|
117 continue;
|
|
118
|
|
119 d = (int16_t *)dst + oc;
|
|
120 s = (int16_t *)src + ic;
|
|
121
|
|
122 if (vol >= 0x10000) {
|
|
123 for (i = n; i > 0; i--, s += n_ic, d += n_oc)
|
|
124 *d += *s;
|
|
125 } else {
|
|
126 for (i = n; i > 0; i--, s += n_ic, d += n_oc)
|
|
127 *d += (int16_t) (((int32_t)*s * vol) >> 16);
|
|
128 }
|
|
129 }
|
|
130 }
|
|
131 break;
|
|
132 }
|
|
133 default:
|
|
134 pa_assert_not_reached();
|
|
135 }
|
|
136 }
|
|
137
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
138 static void remap_mono_to_stereo_c(pa_remap_t *m, void *dst, const void *src, unsigned n) {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
139 unsigned i;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
140
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
141 switch (*m->format) {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
142 case PA_SAMPLE_FLOAT32NE:
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
143 {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
144 float *d, *s;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
145
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
146 d = (float *) dst;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
147 s = (float *) src;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
148
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
149 for (i = n >> 2; i; i--) {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
150 d[0] = d[1] = s[0];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
151 d[2] = d[3] = s[1];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
152 d[4] = d[5] = s[2];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
153 d[6] = d[7] = s[3];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
154 s += 4;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
155 d += 8;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
156 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
157 for (i = n & 3; i; i--) {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
158 d[0] = d[1] = s[0];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
159 s++;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
160 d += 2;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
161 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
162 break;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
163 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
164 case PA_SAMPLE_S16NE:
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
165 {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
166 int16_t *d, *s;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
167
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
168 d = (int16_t *) dst;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
169 s = (int16_t *) src;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
170
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
171 for (i = n >> 2; i; i--) {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
172 d[0] = d[1] = s[0];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
173 d[2] = d[3] = s[1];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
174 d[4] = d[5] = s[2];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
175 d[6] = d[7] = s[3];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
176 s += 4;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
177 d += 8;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
178 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
179 for (i = n & 3; i; i--) {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
180 d[0] = d[1] = s[0];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
181 s++;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
182 d += 2;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
183 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
184 break;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
185 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
186 default:
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
187 pa_assert_not_reached();
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
188 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
189 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
190
|
1
|
191 static void remap_stereo_to_mono_c(pa_remap_t *m, void *dst, const void *src, unsigned n) {
|
|
192 unsigned i;
|
|
193
|
|
194 switch (*m->format) {
|
|
195 case PA_SAMPLE_FLOAT32NE:
|
|
196 {
|
|
197 float *d = (float *) dst, *s = (float *) src;
|
|
198
|
|
199 for (i = n >> 2; i > 0; i--) {
|
|
200 d[0] = s[0] + s[1];
|
|
201 d[1] = s[2] + s[3];
|
|
202 d[2] = s[4] + s[5];
|
|
203 d[3] = s[6] + s[7];
|
|
204 s += 8;
|
|
205 d += 4;
|
|
206 }
|
|
207 for (i = n & 3; i; i--) {
|
|
208 d[0] = s[0] + s[1];
|
|
209 s += 2;
|
|
210 d += 1;
|
|
211 }
|
|
212 break;
|
|
213 }
|
|
214 case PA_SAMPLE_S16NE:
|
|
215 {
|
|
216 int16_t *d = (int16_t *) dst, *s = (int16_t *) src;
|
|
217
|
|
218 for (i = n >> 2; i > 0; i--) {
|
|
219 *d++ += s[0] + s[1];
|
|
220 *d++ += s[2] + s[3];
|
|
221 *d++ += s[4] + s[5];
|
|
222 *d++ += s[6] + s[7];
|
|
223 s += 8;
|
|
224 }
|
|
225 for (i = n & 3; i; i--) {
|
|
226 *d++ += s[0] + s[1];
|
|
227 s += 2;
|
|
228 }
|
|
229 break;
|
|
230 }
|
|
231 default:
|
|
232 pa_assert_not_reached();
|
|
233 }
|
|
234 }
|
|
235
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
236 #if defined(__arm__)
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
237
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
238 #include "arm_neon.h"
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
239
|
2
|
240 static void mono_to_stereo_float_neon_a8(float *dst, const float *src, unsigned n) {
|
|
241 int i = n & 3;
|
|
242
|
|
243 asm volatile (
|
|
244 "mov %[n], %[n], lsr #2\n\t"
|
|
245 "1:\n\t"
|
|
246 "vld1.32 {q0}, [%[src]]!\n\t"
|
|
247 "vmov q1, q0\n\t"
|
|
248 "subs %[n], %[n], #1\n\t"
|
|
249 "vst2.32 {q0,q1}, [%[dst]]!\n\t"
|
|
250 "bgt 1b\n\t"
|
|
251 // output operands (or input operands that get modified)
|
|
252 : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n)
|
|
253 : // input operands
|
|
254 : "memory", "cc" // clobber list
|
|
255 );
|
|
256
|
|
257 while (i--) {
|
|
258 dst[0] = dst[1] = src[0];
|
|
259 src++;
|
|
260 dst += 2;
|
|
261 }
|
|
262 }
|
|
263
|
|
264 static void mono_to_stereo_float_neon_a9(float *dst, const float *src, unsigned n) {
|
|
265 int i = n & 1;
|
|
266
|
|
267 asm volatile (
|
|
268 "mov %[n], %[n], lsr #1\n\t"
|
|
269 "1:\n\t"
|
|
270 "ldm %[src]!, {r4,r6}\n\t"
|
|
271 "mov r5, r4\n\t"
|
|
272 "mov r7, r6\n\t"
|
|
273 "subs %[n], %[n], #1\n\t"
|
|
274 "stm %[dst]!, {r4-r7}\n\t"
|
|
275 "bgt 1b\n\t"
|
|
276 // output operands (or input operands that get modified)
|
|
277 : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n)
|
|
278 : // input operands
|
|
279 : "memory", "cc", "r4", "r5", "r6", "r7" // clobber list
|
|
280 );
|
|
281
|
|
282 while (i--) {
|
|
283 dst[0] = dst[1] = src[0];
|
|
284 src++;
|
|
285 dst += 2;
|
|
286 }
|
|
287 }
|
|
288
|
|
289 static void mono_to_stereo_int16_neon(int16_t *dst, const int16_t *src, unsigned n) {
|
|
290 int i = n & 7;
|
|
291
|
|
292 asm volatile (
|
|
293 "mov %[n], %[n], lsr #3\n\t"
|
|
294 "1:\n\t"
|
|
295 "vld1.16 {q0}, [%[src]]!\n\t"
|
|
296 "vmov q1, q0\n\t"
|
|
297 "subs %[n], %[n], #1\n\t"
|
|
298 "vst2.16 {q0,q1}, [%[dst]]!\n\t"
|
|
299 "bgt 1b\n\t"
|
|
300 // output operands (or input operands that get modified)
|
|
301 : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n)
|
|
302 : // input operands
|
|
303 : "memory", "cc" // clobber list
|
|
304 );
|
|
305
|
|
306 while (i--) {
|
|
307 dst[0] = dst[1] = src[0];
|
|
308 src++;
|
|
309 dst += 2;
|
|
310 }
|
|
311 }
|
|
312
|
|
313 static void remap_mono_to_stereo_neon_a9(pa_remap_t *m, void *dst, const void *src, unsigned n) {
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
314 switch (*m->format) {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
315 case PA_SAMPLE_FLOAT32NE:
|
2
|
316 mono_to_stereo_float_neon_a9(dst, src, n);
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
317 break;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
318 case PA_SAMPLE_S16NE:
|
2
|
319 mono_to_stereo_int16_neon(dst, src, n);
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
320 break;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
321 default:
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
322 pa_assert_not_reached();
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
323 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
324 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
325
|
2
|
326 static void remap_mono_to_stereo_neon_a8(pa_remap_t *m, void *dst, const void *src, unsigned n) {
|
|
327 switch (*m->format) {
|
|
328 case PA_SAMPLE_FLOAT32NE:
|
|
329 mono_to_stereo_float_neon_a8(dst, src, n);
|
|
330 break;
|
|
331 case PA_SAMPLE_S16NE:
|
|
332 mono_to_stereo_int16_neon(dst, src, n);
|
|
333 break;
|
|
334 default:
|
|
335 pa_assert_not_reached();
|
1
|
336 }
|
|
337 }
|
|
338
|
2
|
339 static void stereo_to_mono_float_neon(float *dst, const float *src, unsigned n) {
|
|
340 int i = n & 3;
|
|
341
|
|
342 asm volatile (
|
|
343 "mov %[n], %[n], lsr #2\n\t"
|
|
344 "1:\n\t"
|
|
345 "vld2.32 {q0,q1}, [%[src]]!\n\t"
|
|
346 "vadd.f32 q0, q0, q1\n\t"
|
|
347 "subs %[n], %[n], #1\n\t"
|
|
348 "vst1.32 {q0}, [%[dst]]!\n\t"
|
|
349 "bgt 1b\n\t"
|
|
350 // output operands (or input operands that get modified)
|
|
351 : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n)
|
|
352 : // input operands
|
|
353 : "memory", "cc" // clobber list
|
|
354 );
|
1
|
355
|
2
|
356 while (i--) {
|
|
357 dst[0] = src[0] + src[1];
|
|
358 src += 2;
|
|
359 dst++;
|
1
|
360 }
|
2
|
361 }
|
|
362
|
|
363 static void stereo_to_mono_int16_neon(int16_t *dst, const int16_t *src, unsigned n) {
|
|
364 int i = n & 7;
|
|
365
|
|
366 asm volatile (
|
|
367 "mov %[n], %[n], lsr #3\n\t"
|
|
368 "1:\n\t"
|
|
369 "vld2.16 {q0,q1}, [%[src]]!\n\t"
|
|
370 "vadd.s16 q0, q0, q1\n\t"
|
|
371 "subs %[n], %[n], #1\n\t"
|
|
372 "vst1.16 {q0}, [%[dst]]!\n\t"
|
|
373 "bgt 1b\n\t"
|
|
374 // output operands (or input operands that get modified)
|
|
375 : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n)
|
|
376 : // input operands
|
|
377 : "memory", "cc" // clobber list
|
|
378 );
|
|
379
|
|
380 while (i--) {
|
|
381 dst[0] = src[0] + src[1];
|
|
382 src += 2;
|
|
383 dst++;
|
1
|
384 }
|
|
385 }
|
|
386
|
|
387 static void remap_stereo_to_mono_neon(pa_remap_t *m, void *dst, const void *src, unsigned n) {
|
|
388 switch (*m->format) {
|
|
389 case PA_SAMPLE_FLOAT32NE:
|
2
|
390 stereo_to_mono_float_neon(dst, src, n);
|
1
|
391 break;
|
|
392 case PA_SAMPLE_S16NE:
|
2
|
393 stereo_to_mono_int16_neon(dst, src, n);
|
1
|
394 break;
|
|
395 default:
|
|
396 pa_assert_not_reached();
|
|
397 }
|
|
398 }
|
2
|
399
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
400 #define SAMPLES 1019
|
2
|
401 #define TIMES 500000
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
402
|
1
|
403 static void run_test_mono_to_stereo_float(void) {
|
2
|
404 float stereo_a9[2*SAMPLES];
|
|
405 float stereo_a8[2*SAMPLES];
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
406 float stereo_ref[2*SAMPLES];
|
1
|
407 float stereo_gen[2*SAMPLES];
|
2
|
408 float mono[SAMPLES];
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
409 int i;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
410 pa_usec_t start, stop;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
411 pa_sample_format_t sf;
|
1
|
412 pa_sample_spec iss, oss;
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
413 pa_remap_t remap;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
414
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
415 pa_log_debug("checking NEON remap_mono_to_stereo(float, %d)", SAMPLES);
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
416
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
417 memset(stereo_ref, 0, sizeof(stereo_ref));
|
2
|
418 memset(stereo_gen, 0, sizeof(stereo_gen));
|
|
419 memset(stereo_a9, 0, sizeof(stereo_a9));
|
|
420 memset(stereo_a8, 0, sizeof(stereo_a8));
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
421
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
422 for (i = 0; i < SAMPLES; i++) {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
423 mono[i] = rand()/(float) RAND_MAX - 0.5f;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
424 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
425
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
426 sf = PA_SAMPLE_FLOAT32NE;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
427 remap.format = &sf;
|
1
|
428 iss.format = PA_SAMPLE_FLOAT32NE;
|
|
429 iss.channels = 1;
|
|
430 oss.format = PA_SAMPLE_FLOAT32NE;
|
|
431 oss.channels = 2;
|
|
432 remap.i_ss = &iss;
|
|
433 remap.o_ss = &oss;
|
|
434 remap.map_table_f[0][0] = 1.0;
|
|
435 remap.map_table_f[1][0] = 1.0;
|
|
436
|
2
|
437 remap_mono_to_stereo_neon_a9(&remap, stereo_a9, mono, SAMPLES);
|
|
438 remap_mono_to_stereo_neon_a8(&remap, stereo_a8, mono, SAMPLES);
|
1
|
439 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES);
|
|
440 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES);
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
441
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
442 for (i = 0; i < 2*SAMPLES; i++) {
|
2
|
443 if (fabsf(stereo_a9[i] - stereo_ref[i]) > 0.00001) {
|
|
444 pa_log_debug("NEON/A9 %d: %.3f != %.3f (%.3f)", i, stereo_a9[i], stereo_ref[i],
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
445 mono[i/2]);
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
446 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
447 }
|
1
|
448 for (i = 0; i < 2*SAMPLES; i++) {
|
2
|
449 if (fabsf(stereo_a8[i] - stereo_ref[i]) > 0.00001) {
|
|
450 pa_log_debug("NEON/A8 %d: %.3f != %.3f (%.3f)", i, stereo_a8[i], stereo_ref[i],
|
|
451 mono[i/2]);
|
|
452 }
|
|
453 }
|
|
454 for (i = 0; i < 2*SAMPLES; i++) {
|
|
455 if (fabsf(stereo_gen[i] - stereo_ref[i]) > 0.00001) {
|
|
456 pa_log_debug("generic %d: %.3f != %.3f (%.3f)", i, stereo_gen[i], stereo_ref[i],
|
1
|
457 mono[i/2]);
|
|
458 }
|
|
459 }
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
460
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
461 start = pa_rtclock_now();
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
462 for (i = 0; i < TIMES; i++) {
|
2
|
463 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES);
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
464 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
465 stop = pa_rtclock_now();
|
2
|
466 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start));
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
467
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
468 start = pa_rtclock_now();
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
469 for (i = 0; i < TIMES; i++) {
|
2
|
470 remap_mono_to_stereo_neon_a9(&remap, stereo_a9, mono, SAMPLES);
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
471 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
472 stop = pa_rtclock_now();
|
2
|
473 pa_log_info("NEON/A9:\t%llu usec.", (long long unsigned int)(stop - start));
|
|
474
|
|
475 start = pa_rtclock_now();
|
|
476 for (i = 0; i < TIMES; i++) {
|
|
477 remap_mono_to_stereo_neon_a8(&remap, stereo_a8, mono, SAMPLES);
|
|
478 }
|
|
479 stop = pa_rtclock_now();
|
|
480 pa_log_info("NEON/A8:\t%llu usec.", (long long unsigned int)(stop - start));
|
1
|
481
|
|
482 start = pa_rtclock_now();
|
|
483 for (i = 0; i < TIMES; i++) {
|
|
484 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES);
|
|
485 }
|
|
486 stop = pa_rtclock_now();
|
2
|
487 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start));
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
488 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
489
|
1
|
490 static void run_test_stereo_to_mono_float(void) {
|
|
491 float stereo[2*SAMPLES];
|
|
492 float mono_ref[SAMPLES];
|
|
493 float mono_gen[SAMPLES];
|
|
494 float mono[SAMPLES];
|
|
495 int i;
|
|
496 pa_usec_t start, stop;
|
|
497 pa_sample_format_t sf;
|
|
498 pa_sample_spec iss, oss;
|
|
499 pa_remap_t remap;
|
|
500
|
|
501 pa_log_debug("checking NEON remap_stereo_to_mono(float, %d)", SAMPLES);
|
|
502
|
|
503 memset(mono_ref, 0, sizeof(mono_ref));
|
|
504 memset(mono, 0, sizeof(mono));
|
|
505
|
|
506 for (i = 0; i < 2*SAMPLES; i++) {
|
|
507 stereo[i] = rand()/(float) RAND_MAX - 0.5f;
|
|
508 }
|
|
509
|
|
510 sf = PA_SAMPLE_FLOAT32NE;
|
|
511 remap.format = &sf;
|
|
512 iss.format = PA_SAMPLE_FLOAT32NE;
|
|
513 iss.channels = 2;
|
|
514 oss.format = PA_SAMPLE_FLOAT32NE;
|
|
515 oss.channels = 1;
|
|
516 remap.i_ss = &iss;
|
|
517 remap.o_ss = &oss;
|
|
518 remap.map_table_f[0][0] = 1.0;
|
|
519 remap.map_table_f[0][1] = 1.0;
|
|
520
|
|
521 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES);
|
|
522 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES);
|
|
523 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES);
|
|
524
|
|
525 for (i = 0; i < SAMPLES; i++) {
|
|
526 if (fabsf(mono[i] - mono_ref[i]) > 0.00001) {
|
|
527 pa_log_debug("%d: %.3f != %.3f (%.3f %0.3f)", i, mono[i], mono_ref[i],
|
|
528 stereo[2*i+0], stereo[2*i+1]);
|
|
529 }
|
|
530 }
|
|
531
|
|
532 start = pa_rtclock_now();
|
|
533 for (i = 0; i < TIMES; i++) {
|
|
534 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES);
|
|
535 }
|
|
536 stop = pa_rtclock_now();
|
2
|
537 pa_log_info("NEON:\t\t%llu usec.", (long long unsigned int)(stop - start));
|
1
|
538
|
|
539 start = pa_rtclock_now();
|
|
540 for (i = 0; i < TIMES; i++) {
|
|
541 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES);
|
|
542 }
|
|
543 stop = pa_rtclock_now();
|
2
|
544 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start));
|
1
|
545
|
|
546 start = pa_rtclock_now();
|
|
547 for (i = 0; i < TIMES; i++) {
|
|
548 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES);
|
|
549 }
|
|
550 stop = pa_rtclock_now();
|
2
|
551 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start));
|
1
|
552 }
|
|
553
|
|
554 static void run_test_mono_to_stereo_s16(void) {
|
2
|
555 int16_t stereo_a9[2*SAMPLES];
|
|
556 int16_t stereo_a8[2*SAMPLES];
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
557 int16_t stereo_ref[2*SAMPLES];
|
1
|
558 int16_t stereo_gen[2*SAMPLES];
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
559 int16_t mono[SAMPLES];
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
560 int i;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
561 pa_usec_t start, stop;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
562 pa_sample_format_t sf;
|
1
|
563 pa_sample_spec iss, oss;
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
564 pa_remap_t remap;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
565
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
566 pa_log_debug("checking NEON remap_mono_to_stereo(s16, %d)", SAMPLES);
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
567
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
568 memset(stereo_ref, 0, sizeof(stereo_ref));
|
2
|
569 memset(stereo_a9, 0, sizeof(stereo_a9));
|
|
570 memset(stereo_a8, 0, sizeof(stereo_a8));
|
|
571 memset(stereo_gen, 0, sizeof(stereo_gen));
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
572
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
573 for (i = 0; i < SAMPLES; i++) {
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
574 mono[i] = rand() - RAND_MAX/2;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
575 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
576
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
577 sf = PA_SAMPLE_S16NE;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
578 remap.format = &sf;
|
1
|
579 iss.format = PA_SAMPLE_S16NE;
|
|
580 iss.channels = 1;
|
|
581 oss.format = PA_SAMPLE_S16NE;
|
|
582 oss.channels = 2;
|
|
583 remap.i_ss = &iss;
|
|
584 remap.o_ss = &oss;
|
2
|
585 remap.map_table_i[0][0] = 0x10000;
|
|
586 remap.map_table_i[1][0] = 0x10000;
|
1
|
587
|
|
588 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES);
|
|
589 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES);
|
2
|
590 remap_mono_to_stereo_neon_a9(&remap, stereo_a9, mono, SAMPLES);
|
|
591 remap_mono_to_stereo_neon_a8(&remap, stereo_a8, mono, SAMPLES);
|
1
|
592
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
593 for (i = 0; i < 2*SAMPLES; i++) {
|
2
|
594 if (abs(stereo_a9[i] - stereo_ref[i]) > 0) {
|
|
595 pa_log_debug("NEON/A9 %d: %d != %d (%d)", i, stereo_a9[i], stereo_ref[i],
|
|
596 mono[i/2]);
|
|
597 }
|
|
598 }
|
|
599 for (i = 0; i < 2*SAMPLES; i++) {
|
|
600 if (abs(stereo_a8[i] - stereo_ref[i]) > 0) {
|
|
601 pa_log_debug("NEON/A8 %d: %d != %d (%d)", i, stereo_a8[i], stereo_ref[i],
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
602 mono[i/2]);
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
603 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
604 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
605
|
1
|
606 for (i = 0; i < 2*SAMPLES; i++) {
|
2
|
607 if (abs(stereo_gen[i] - stereo_ref[i]) > 0) {
|
|
608 pa_log_debug("generic %d: %d != %d (%d)", i, stereo_gen[i], stereo_ref[i],
|
1
|
609 mono[i/2]);
|
|
610 }
|
|
611 }
|
|
612
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
613 start = pa_rtclock_now();
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
614 for (i = 0; i < TIMES; i++) {
|
2
|
615 remap_mono_to_stereo_neon_a9(&remap, stereo_a9, mono, SAMPLES);
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
616 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
617 stop = pa_rtclock_now();
|
2
|
618 pa_log_info("NEON/A9:\t%llu usec.", (long long unsigned int)(stop - start));
|
|
619
|
|
620 start = pa_rtclock_now();
|
|
621 for (i = 0; i < TIMES; i++) {
|
|
622 remap_mono_to_stereo_neon_a8(&remap, stereo_a8, mono, SAMPLES);
|
|
623 }
|
|
624 stop = pa_rtclock_now();
|
|
625 pa_log_info("NEON/A8:\t%llu usec.", (long long unsigned int)(stop - start));
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
626
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
627 start = pa_rtclock_now();
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
628 for (i = 0; i < TIMES; i++) {
|
1
|
629 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES);
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
630 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
631 stop = pa_rtclock_now();
|
2
|
632 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start));
|
1
|
633
|
|
634 start = pa_rtclock_now();
|
|
635 for (i = 0; i < TIMES; i++) {
|
|
636 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES);
|
|
637 }
|
|
638 stop = pa_rtclock_now();
|
2
|
639 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start));
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
640 }
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
641
|
1
|
642 static void run_test_stereo_to_mono_s16(void) {
|
|
643 int16_t stereo[2*SAMPLES];
|
|
644 int16_t mono_ref[SAMPLES];
|
|
645 int16_t mono_gen[SAMPLES];
|
|
646 int16_t mono[SAMPLES];
|
|
647 int i;
|
|
648 pa_usec_t start, stop;
|
|
649 pa_sample_format_t sf;
|
|
650 pa_sample_spec iss, oss;
|
|
651 pa_remap_t remap;
|
|
652
|
|
653 pa_log_debug("checking NEON remap_stereo_to_mono(s16, %d)", SAMPLES);
|
|
654
|
|
655 memset(mono_ref, 0, sizeof(mono_ref));
|
2
|
656 memset(mono_gen, 0, sizeof(mono_gen));
|
1
|
657 memset(mono, 0, sizeof(mono));
|
|
658
|
|
659 for (i = 0; i < 2*SAMPLES; i++) {
|
|
660 stereo[i] = rand() - RAND_MAX/2;
|
|
661 }
|
|
662
|
|
663 sf = PA_SAMPLE_S16NE;
|
|
664 remap.format = &sf;
|
|
665 iss.format = PA_SAMPLE_S16NE;
|
|
666 iss.channels = 2;
|
|
667 oss.format = PA_SAMPLE_S16NE;
|
|
668 oss.channels = 1;
|
|
669 remap.i_ss = &iss;
|
|
670 remap.o_ss = &oss;
|
2
|
671 remap.map_table_i[0][0] = 0x10000;
|
|
672 remap.map_table_i[0][1] = 0x10000;
|
1
|
673
|
|
674 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES);
|
|
675 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES);
|
|
676 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES);
|
|
677
|
|
678 for (i = 0; i < SAMPLES; i++) {
|
|
679 if (abs(mono[i] - mono_ref[i]) > 0) {
|
|
680 pa_log_debug("%d: %d != %d (%d)", i, mono[i], mono_ref[i],
|
|
681 stereo[2*i+0], stereo[2*i+1]);
|
|
682 }
|
|
683 }
|
|
684 for (i = 0; i < SAMPLES; i++) {
|
|
685 if (abs(mono[i] - mono_gen[i]) > 0) {
|
|
686 pa_log_debug("%d: %d != %d (%d)", i, mono[i], mono_gen[i],
|
|
687 stereo[2*i+0], stereo[2*i+1]);
|
|
688 }
|
|
689 }
|
|
690
|
|
691 start = pa_rtclock_now();
|
|
692 for (i = 0; i < TIMES; i++) {
|
|
693 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES);
|
|
694 }
|
|
695 stop = pa_rtclock_now();
|
2
|
696 pa_log_info("NEON:\t\t%llu usec.", (long long unsigned int)(stop - start));
|
1
|
697
|
|
698 start = pa_rtclock_now();
|
|
699 for (i = 0; i < TIMES; i++) {
|
|
700 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES);
|
|
701 }
|
|
702 stop = pa_rtclock_now();
|
2
|
703 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start));
|
1
|
704
|
|
705 start = pa_rtclock_now();
|
|
706 for (i = 0; i < TIMES; i++) {
|
|
707 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES);
|
|
708 }
|
|
709 stop = pa_rtclock_now();
|
2
|
710 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start));
|
1
|
711 }
|
|
712
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
713 #endif /* defined(__arm__) */
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
714
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
715 int main() {
|
3
|
716
|
|
717 /* not in user space
|
|
718 unsigned cpuid;
|
|
719 asm volatile(
|
|
720 "mrc p15, 0, %[cpuid], c0, c0, 0\n\t"
|
|
721 : [cpuid] "=r" (cpuid)
|
|
722 :
|
|
723 : "cc");
|
|
724
|
|
725 printf("%08x %03x\n", cpuid, (cpuid >> 4) & 0xfff);
|
|
726 */
|
|
727
|
1
|
728 run_test_stereo_to_mono_float();
|
|
729 run_test_stereo_to_mono_s16();
|
|
730
|
|
731 run_test_mono_to_stereo_float();
|
|
732 run_test_mono_to_stereo_s16();
|
|
733
|
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
734 return EXIT_SUCCESS;
|
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff
changeset
|
735 }
|