annotate remap_neon.c @ 1:b829afbea564

more testing
author Peter Meerwald <p.meerwald@bct-electronic.com>
date Fri, 20 Apr 2012 14:26:14 +0200
parents e0040ee59c3c
children 09ee6a01a3d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
13 typedef unsigned char uint8_t;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
14 typedef short int16_t;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
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
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
23
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
24 typedef struct pa_sample_spec {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
25 pa_sample_format_t format;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
26 uint32_t rate;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
27 uint8_t channels;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
28 } pa_sample_spec;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
29
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
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
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
33 pa_sample_spec *i_ss, *o_ss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
34 float map_table_f[PA_CHANNELS_MAX][PA_CHANNELS_MAX];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
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
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
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
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
64 static void remap_channels_matrix_c(pa_remap_t *m, void *dst, const void *src, unsigned n) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
65 unsigned oc, ic, i;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
66 unsigned n_ic, n_oc;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
67
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
68 n_ic = m->i_ss->channels;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
69 n_oc = m->o_ss->channels;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
70
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
71 switch (*m->format) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
72 case PA_SAMPLE_FLOAT32NE:
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
73 {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
74 float *d, *s;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
75
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
76 memset(dst, 0, n * sizeof(float) * n_oc);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
77
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
78 for (oc = 0; oc < n_oc; oc++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
79
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
80 for (ic = 0; ic < n_ic; ic++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
81 float vol;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
82
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
83 vol = m->map_table_f[oc][ic];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
84
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
85 if (vol <= 0.0)
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
86 continue;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
87
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
88 d = (float *)dst + oc;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
89 s = (float *)src + ic;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
90
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
91 if (vol >= 1.0) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
92 for (i = n; i > 0; i--, s += n_ic, d += n_oc)
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
93 *d += *s;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
94 } else {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
95 for (i = n; i > 0; i--, s += n_ic, d += n_oc)
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
96 *d += *s * vol;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
97 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
98 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
99 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
100
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
101 break;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
102 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
103 case PA_SAMPLE_S16NE:
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
104 {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
105 int16_t *d, *s;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
106
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
107 memset(dst, 0, n * sizeof(int16_t) * n_oc);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
108
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
109 for (oc = 0; oc < n_oc; oc++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
110
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
111 for (ic = 0; ic < n_ic; ic++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
112 int32_t vol;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
113
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
114 vol = m->map_table_i[oc][ic];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
115
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
116 if (vol <= 0)
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
117 continue;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
118
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
119 d = (int16_t *)dst + oc;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
120 s = (int16_t *)src + ic;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
121
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
122 if (vol >= 0x10000) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
123 for (i = n; i > 0; i--, s += n_ic, d += n_oc)
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
124 *d += *s;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
125 } else {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
126 for (i = n; i > 0; i--, s += n_ic, d += n_oc)
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
127 *d += (int16_t) (((int32_t)*s * vol) >> 16);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
128 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
129 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
130 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
131 break;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
132 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
133 default:
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
134 pa_assert_not_reached();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
135 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
136 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
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
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
191
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
192
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
193 static void remap_stereo_to_mono_c(pa_remap_t *m, void *dst, const void *src, unsigned n) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
194 unsigned i;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
195
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
196 switch (*m->format) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
197 case PA_SAMPLE_FLOAT32NE:
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
198 {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
199 float *d = (float *) dst, *s = (float *) src;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
200
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
201 for (i = n >> 2; i > 0; i--) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
202 d[0] = s[0] + s[1];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
203 d[1] = s[2] + s[3];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
204 d[2] = s[4] + s[5];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
205 d[3] = s[6] + s[7];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
206 s += 8;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
207 d += 4;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
208 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
209 for (i = n & 3; i; i--) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
210 d[0] = s[0] + s[1];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
211 s += 2;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
212 d += 1;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
213 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
214 break;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
215 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
216 case PA_SAMPLE_S16NE:
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
217 {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
218 int16_t *d = (int16_t *) dst, *s = (int16_t *) src;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
219
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
220 for (i = n >> 2; i > 0; i--) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
221 *d++ += s[0] + s[1];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
222 *d++ += s[2] + s[3];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
223 *d++ += s[4] + s[5];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
224 *d++ += s[6] + s[7];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
225 s += 8;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
226 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
227 for (i = n & 3; i; i--) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
228 *d++ += s[0] + s[1];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
229 s += 2;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
230 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
231 break;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
232 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
233 default:
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
234 pa_assert_not_reached();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
235 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
236 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
237
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
238
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
239 #if defined(__arm__)
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
240
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
241 #include "arm_neon.h"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
242
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
243 void remap_mono_to_stereo_neon(pa_remap_t *m, void *dst, const void *src, unsigned n) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
244 unsigned i;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
245 switch (*m->format) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
246 case PA_SAMPLE_FLOAT32NE:
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
247 {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
248 float *d = (float *) dst, *s = (float *) src;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
249
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
250 for (i = 0; i < n/4; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
251 float32x4x2_t stereo;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
252 stereo.val[0] = vld1q_f32(s);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
253 stereo.val[1] = stereo.val[0];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
254 vst2q_f32(d, stereo);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
255 s += 4;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
256 d += 8;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
257 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
258
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
259 for (i = n & ~3; i < n; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
260 d[0] = d[1] = s[0];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
261 s++;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
262 d += 2;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
263 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
264 break;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
265 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
266 case PA_SAMPLE_S16NE:
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
267 {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
268 int16_t *d = (int16_t *) dst, *s = (int16_t *) src;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
269
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
270 for (i = 0; i < n/8; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
271 int16x8x2_t stereo;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
272 stereo.val[0] = vld1q_s16(s);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
273 stereo.val[1] = stereo.val[0];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
274 vst2q_s16(d, stereo);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
275 s += 8;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
276 d += 16;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
277 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
278
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
279 for (i = n & ~7; i < n; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
280 d[0] = d[1] = s[0];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
281 s++;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
282 d += 2;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
283 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
284 break;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
285 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
286 default:
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
287 pa_assert_not_reached();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
288 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
289 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
290
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
291 /* don't inline, causes ICE, see https://bugs.launchpad.net/bugs/936863 */
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
292 static __attribute__ ((noinline)) void stereo_to_mono_float(float *d, const float *s, unsigned n) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
293 unsigned i;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
294
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
295 for (i = 0; i < n/4; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
296 float32x4x2_t stereo = vld2q_f32(s);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
297 float32x4_t mono = vaddq_f32(stereo.val[0], stereo.val[1]);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
298 vst1q_f32(d, mono);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
299 s += 8;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
300 d += 4;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
301 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
302 for (i = n & ~3; i < n; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
303 d[0] = s[0] + s[1];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
304 s += 2;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
305 d++;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
306 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
307 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
308
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
309 /* don't inline, causes ICE, see https://bugs.launchpad.net/bugs/936863 */
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
310 static __attribute__ ((noinline)) void stereo_to_mono_int16(int16_t *d, const int16_t *s, unsigned n) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
311 unsigned int i;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
312
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
313 for (i = 0; i < n/8; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
314 int16x8x2_t stereo = vld2q_s16(s);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
315 int16x8_t mono = vaddq_s16(stereo.val[0], stereo.val[1]);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
316 vst1q_s16(d, mono);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
317 s += 16;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
318 d += 8;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
319 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
320 for (i = n & ~7; i < n; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
321 d[0] = s[0] + s[1];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
322 s += 2;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
323 d++;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
324 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
325 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
326
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
327 static void remap_stereo_to_mono_neon(pa_remap_t *m, void *dst, const void *src, unsigned n) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
328 switch (*m->format) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
329 case PA_SAMPLE_FLOAT32NE:
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
330 stereo_to_mono_float(dst, src, n);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
331 break;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
332 case PA_SAMPLE_S16NE:
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
333 stereo_to_mono_int16(dst, src, n);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
334 break;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
335 default:
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
336 pa_assert_not_reached();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
337 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
338 }
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
339 #define SAMPLES 1019
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
340 #define TIMES 10000
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
341
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
342 static void run_test_mono_to_stereo_float(void) {
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
343 float stereo[2*SAMPLES];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
344 float stereo_ref[2*SAMPLES];
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
345 float stereo_gen[2*SAMPLES];
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
346 float mono[SAMPLES];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
347 int i;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
348 pa_usec_t start, stop;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
349 pa_sample_format_t sf;
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
350 pa_sample_spec iss, oss;
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
351 pa_remap_t remap;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
352
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
353 pa_log_debug("checking NEON remap_mono_to_stereo(float, %d)", SAMPLES);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
354
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
355 memset(stereo_ref, 0, sizeof(stereo_ref));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
356 memset(stereo, 0, sizeof(stereo));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
357
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
358 for (i = 0; i < SAMPLES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
359 mono[i] = rand()/(float) RAND_MAX - 0.5f;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
360 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
361
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
362 sf = PA_SAMPLE_FLOAT32NE;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
363 remap.format = &sf;
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
364 iss.format = PA_SAMPLE_FLOAT32NE;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
365 iss.channels = 1;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
366 oss.format = PA_SAMPLE_FLOAT32NE;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
367 oss.channels = 2;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
368 remap.i_ss = &iss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
369 remap.o_ss = &oss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
370 remap.map_table_f[0][0] = 1.0;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
371 remap.map_table_f[1][0] = 1.0;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
372
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
373 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
374 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES);
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
375 remap_mono_to_stereo_neon(&remap, stereo, mono, SAMPLES);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
376
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
377 for (i = 0; i < 2*SAMPLES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
378 if (fabsf(stereo[i] - stereo_ref[i]) > 0.00001) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
379 pa_log_debug("%d: %.3f != %.3f (%.3f)", i, stereo[i], stereo_ref[i],
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
380 mono[i/2]);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
381 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
382 }
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
383 for (i = 0; i < 2*SAMPLES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
384 if (fabsf(stereo[i] - stereo_gen[i]) > 0.00001) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
385 pa_log_debug("%d: %.3f != %.3f (%.3f)", i, stereo[i], stereo_gen[i],
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
386 mono[i/2]);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
387 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
388 }
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
389
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
390 start = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
391 for (i = 0; i < TIMES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
392 remap_mono_to_stereo_neon(&remap, stereo, mono, SAMPLES);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
393 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
394 stop = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
395 pa_log_info("NEON: %llu usec.", (long long unsigned int)(stop - start));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
396
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
397 start = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
398 for (i = 0; i < TIMES; i++) {
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
399 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES);
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
400 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
401 stop = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
402 pa_log_info("ref: %llu usec.", (long long unsigned int)(stop - start));
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
403
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
404 start = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
405 for (i = 0; i < TIMES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
406 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
407 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
408 stop = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
409 pa_log_info("generic: %llu usec.", (long long unsigned int)(stop - start));
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
410 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
411
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
412 static void run_test_stereo_to_mono_float(void) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
413 float stereo[2*SAMPLES];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
414 float mono_ref[SAMPLES];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
415 float mono_gen[SAMPLES];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
416 float mono[SAMPLES];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
417 int i;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
418 pa_usec_t start, stop;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
419 pa_sample_format_t sf;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
420 pa_sample_spec iss, oss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
421 pa_remap_t remap;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
422
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
423 pa_log_debug("checking NEON remap_stereo_to_mono(float, %d)", SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
424
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
425 memset(mono_ref, 0, sizeof(mono_ref));
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
426 memset(mono, 0, sizeof(mono));
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
427
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
428 for (i = 0; i < 2*SAMPLES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
429 stereo[i] = rand()/(float) RAND_MAX - 0.5f;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
430 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
431
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
432 sf = PA_SAMPLE_FLOAT32NE;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
433 remap.format = &sf;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
434 iss.format = PA_SAMPLE_FLOAT32NE;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
435 iss.channels = 2;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
436 oss.format = PA_SAMPLE_FLOAT32NE;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
437 oss.channels = 1;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
438 remap.i_ss = &iss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
439 remap.o_ss = &oss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
440 remap.map_table_f[0][0] = 1.0;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
441 remap.map_table_f[0][1] = 1.0;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
442
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
443 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
444 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
445 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
446
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
447 for (i = 0; i < SAMPLES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
448 if (fabsf(mono[i] - mono_ref[i]) > 0.00001) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
449 pa_log_debug("%d: %.3f != %.3f (%.3f %0.3f)", i, mono[i], mono_ref[i],
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
450 stereo[2*i+0], stereo[2*i+1]);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
451 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
452 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
453
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
454 start = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
455 for (i = 0; i < TIMES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
456 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
457 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
458 stop = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
459 pa_log_info("NEON: %llu usec.", (long long unsigned int)(stop - start));
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
460
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
461 start = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
462 for (i = 0; i < TIMES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
463 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
464 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
465 stop = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
466 pa_log_info("ref: %llu usec.", (long long unsigned int)(stop - start));
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
467
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
468 start = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
469 for (i = 0; i < TIMES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
470 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
471 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
472 stop = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
473 pa_log_info("generic: %llu usec.", (long long unsigned int)(stop - start));
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
474 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
475
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
476 static void run_test_mono_to_stereo_s16(void) {
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
477 int16_t stereo[2*SAMPLES];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
478 int16_t stereo_ref[2*SAMPLES];
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
479 int16_t stereo_gen[2*SAMPLES];
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
480 int16_t mono[SAMPLES];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
481 int i;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
482 pa_usec_t start, stop;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
483 pa_sample_format_t sf;
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
484 pa_sample_spec iss, oss;
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
485 pa_remap_t remap;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
486
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
487 pa_log_debug("checking NEON remap_mono_to_stereo(s16, %d)", SAMPLES);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
488
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
489 memset(stereo_ref, 0, sizeof(stereo_ref));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
490 memset(stereo, 0, sizeof(stereo));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
491
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
492 for (i = 0; i < SAMPLES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
493 mono[i] = rand() - RAND_MAX/2;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
494 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
495
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
496 sf = PA_SAMPLE_S16NE;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
497 remap.format = &sf;
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
498 iss.format = PA_SAMPLE_S16NE;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
499 iss.channels = 1;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
500 oss.format = PA_SAMPLE_S16NE;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
501 oss.channels = 2;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
502 remap.i_ss = &iss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
503 remap.o_ss = &oss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
504 remap.map_table_f[0][0] = 1.0;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
505 remap.map_table_f[1][0] = 1.0;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
506
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
507 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
508 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES);
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
509 remap_mono_to_stereo_neon(&remap, stereo, mono, SAMPLES);
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
510
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
511 for (i = 0; i < 2*SAMPLES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
512 if (abs(stereo[i] - stereo_ref[i]) > 0) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
513 pa_log_debug("%d: %d != %d (%d)", i, stereo[i], stereo_ref[i],
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
514 mono[i/2]);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
515 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
516 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
517
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
518 for (i = 0; i < 2*SAMPLES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
519 if (abs(stereo[i] - stereo_gen[i]) > 0) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
520 pa_log_debug("%d: %d != %d (%d)", i, stereo[i], stereo_gen[i],
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
521 mono[i/2]);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
522 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
523 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
524
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
525 start = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
526 for (i = 0; i < TIMES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
527 remap_mono_to_stereo_neon(&remap, stereo, mono, SAMPLES);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
528 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
529 stop = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
530 pa_log_info("NEON: %llu usec.", (long long unsigned int)(stop - start));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
531
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
532 start = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
533 for (i = 0; i < TIMES; i++) {
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
534 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES);
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
535 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
536 stop = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
537 pa_log_info("ref: %llu usec.", (long long unsigned int)(stop - start));
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
538
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
539 start = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
540 for (i = 0; i < TIMES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
541 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
542 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
543 stop = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
544 pa_log_info("generic: %llu usec.", (long long unsigned int)(stop - start));
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
545 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
546
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
547 static void run_test_stereo_to_mono_s16(void) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
548 int16_t stereo[2*SAMPLES];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
549 int16_t mono_ref[SAMPLES];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
550 int16_t mono_gen[SAMPLES];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
551 int16_t mono[SAMPLES];
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
552 int i;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
553 pa_usec_t start, stop;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
554 pa_sample_format_t sf;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
555 pa_sample_spec iss, oss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
556 pa_remap_t remap;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
557
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
558 pa_log_debug("checking NEON remap_stereo_to_mono(s16, %d)", SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
559
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
560 memset(mono_ref, 0, sizeof(mono_ref));
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
561 memset(mono, 0, sizeof(mono));
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
562
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
563 for (i = 0; i < 2*SAMPLES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
564 stereo[i] = rand() - RAND_MAX/2;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
565 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
566
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
567 sf = PA_SAMPLE_S16NE;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
568 remap.format = &sf;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
569 iss.format = PA_SAMPLE_S16NE;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
570 iss.channels = 2;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
571 oss.format = PA_SAMPLE_S16NE;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
572 oss.channels = 1;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
573 remap.i_ss = &iss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
574 remap.o_ss = &oss;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
575 remap.map_table_f[0][0] = 1.0;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
576 remap.map_table_f[0][1] = 1.0;
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
577
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
578 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
579 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
580 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
581
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
582 for (i = 0; i < SAMPLES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
583 if (abs(mono[i] - mono_ref[i]) > 0) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
584 pa_log_debug("%d: %d != %d (%d)", i, mono[i], mono_ref[i],
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
585 stereo[2*i+0], stereo[2*i+1]);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
586 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
587 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
588 for (i = 0; i < SAMPLES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
589 if (abs(mono[i] - mono_gen[i]) > 0) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
590 pa_log_debug("%d: %d != %d (%d)", i, mono[i], mono_gen[i],
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
591 stereo[2*i+0], stereo[2*i+1]);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
592 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
593 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
594
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
595 start = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
596 for (i = 0; i < TIMES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
597 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
598 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
599 stop = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
600 pa_log_info("NEON: %llu usec.", (long long unsigned int)(stop - start));
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
601
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
602 start = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
603 for (i = 0; i < TIMES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
604 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
605 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
606 stop = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
607 pa_log_info("ref: %llu usec.", (long long unsigned int)(stop - start));
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
608
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
609 start = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
610 for (i = 0; i < TIMES; i++) {
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
611 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES);
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
612 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
613 stop = pa_rtclock_now();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
614 pa_log_info("generic: %llu usec.", (long long unsigned int)(stop - start));
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
615 }
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
616
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
617
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
618 #endif /* defined(__arm__) */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
619
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
620 int main() {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
621
1
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
622 run_test_stereo_to_mono_float();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
623 run_test_stereo_to_mono_s16();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
624
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
625 run_test_mono_to_stereo_float();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
626 run_test_mono_to_stereo_s16();
b829afbea564 more testing
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 0
diff changeset
627
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
628
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
629 return EXIT_SUCCESS;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
630 }

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.