annotate sconv_neon.c @ 3:e889fd0e7769

stuff
author Peter Meerwald <p.meerwald@bct-electronic.com>
date Thu, 05 Jul 2012 17:31:56 +0200
parents b829afbea564
children 07763f536182
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
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
13 typedef short int16_t;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
14 typedef void (*pa_convert_func_t)(unsigned n, const void *a, void *b);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
15 typedef long long unsigned int pa_usec_t;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
16
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
17 #define pa_assert(x) assert(x)
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
18
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
19 #define PA_CLAMP_UNLIKELY(x, low, high) \
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
20 (((x) < (low)) ? (low) : (((x) > (high)) ? (high) : (x)))
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
21
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
22 static void pa_log_info(const char *format, ...) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
23 va_list ap;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
24 char buf[1024];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
25 va_start(ap, format);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
26 vsprintf(buf, format, ap);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
27 printf("%s\n", buf);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
28 va_end(ap);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
29 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
30
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
31 #define pa_log_debug pa_log_info
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
32
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
33 static pa_usec_t pa_rtclock_now() {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
34 struct timeval tv;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
35 gettimeofday(&tv, NULL);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
36
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
37 return tv.tv_sec * 1000000ULL + tv.tv_usec;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
38 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
39
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
40 #if defined(__arm__)
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
41
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
42 #include "arm_neon.h"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
43
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
44 void pa_sconv_s16le_from_float32ne(unsigned n, const float *src, int16_t *dst) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
45 pa_assert(src);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
46 pa_assert(dst);
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
47
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
48 for (; n > 0; n--) {
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
49 float v = *(src++);
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
50
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
51 v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
52 *(dst++) = (int16_t) lrintf(v * 0x7FFF);
0
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
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
56 void pa_sconv_s16le_from_f32ne_neon(unsigned n, const float *src, int16_t *dst) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
57 unsigned i = n & 3;
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
58
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
59 asm volatile (
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
60 "mov %[n], %[n], lsr #2\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
61 "vdup.f32 q2, %[plusone]\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
62 "vneg.f32 q3, q2\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
63 "vdup.f32 q4, %[scale]\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
64 "vdup.u32 q5, %[mask]\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
65 "vdup.f32 q6, %[half]\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
66 "1:\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
67 "vld1.32 {q0}, [%[src]]!\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
68 "vmin.f32 q0, q0, q2\n\t" /* clamp */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
69 "vmax.f32 q0, q0, q3\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
70 "vmul.f32 q0, q0, q4\n\t" /* scale */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
71 "vand.u32 q1, q0, q5\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
72 "vorr.u32 q1, q1, q6\n\t" /* round */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
73 "vadd.f32 q0, q0, q1\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
74 "vcvt.s32.f32 q0, q0\n\t" /* narrow */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
75 "vmovn.i32 d0, q0\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
76 "subs %[n], %[n], #1\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
77 "vst1.16 {d0}, [%[dst]]!\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
78 "bgt 1b\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
79 /* output operands (or input operands that get modified) */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
80 : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n)
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
81 : [plusone] "r" (1.0f), [scale] "r" (32767.0f),
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
82 [half] "r" (0.5f), [mask] "r" (0x80000000) /* input operands */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
83 : "memory", "cc", "q0", "q1", "q2", "q3", "q4", "q5", "q6" /* clobber list */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
84 );
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
85
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
86 // leftovers
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
87 while (i--) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
88 *dst++ = (int16_t) lrintf(PA_CLAMP_UNLIKELY(*src, -1.0f, 1.0f) * 0x7FFF);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
89 src++;
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
90 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
91 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
92
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
93 void pa_sconv_s16le_to_float32ne(unsigned n, const int16_t *src, float *dst) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
94 pa_assert(src);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
95 pa_assert(dst);
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
96
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
97 for (; n > 0; n--)
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
98 *(dst++) = ((float) (*(src++)))/(float) 0x7FFF;
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
99 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
100
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
101 void pa_sconv_s16le_to_f32ne_neon(unsigned n, const int16_t *src, float *dst) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
102 unsigned i = n & 3;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
103
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
104 const float invscale = 1.0f / 0x7FFF;
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
105
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
106 asm volatile (
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
107 "mov %[n], %[n], lsr #2\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
108 "vdup.f32 q1, %[invscale]\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
109 "1:\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
110 "vld1.16 {d0}, [%[src]]!\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
111 "vmovl.s16 q0, d0\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
112
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
113 "vcvt.f32.s32 q0, q0\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
114 "vmul.f32 q0, q0, q1\n\t"
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
115
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
116 "subs %[n], %[n], #1\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
117 "vst1.32 {q0}, [%[dst]]!\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
118 "bgt 1b\n\t"
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
119 /* output operands (or input operands that get modified) */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
120 : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n)
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
121 : [invscale] "r" (invscale) /* input operands */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
122 : "memory", "cc", "q0", "q1" /* clobber list */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
123 );
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
124
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
125 // leftovers
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
126 while (i--) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
127 *dst++ = *src++ * invscale;
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
128 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
129 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
130
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
131 #define SAMPLES 1019
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
132 #define TIMES 100000
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
133
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
134 static void run_test_from(void) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
135 int16_t samples[SAMPLES];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
136 int16_t samples_ref[SAMPLES];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
137 float floats[SAMPLES];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
138 int i;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
139 pa_usec_t start, stop;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
140
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
141 pa_log_debug("checking NEON sconv_s16le_from_float(%d)", SAMPLES);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
142
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
143 memset(samples_ref, 0, sizeof(samples_ref));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
144 memset(samples, 0, sizeof(samples));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
145
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
146 for (i = 0; i < SAMPLES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
147 floats[i] = 2.1f * (rand()/(float) RAND_MAX - 0.5f);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
148 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
149
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
150 pa_sconv_s16le_from_float32ne(SAMPLES, floats, samples_ref);
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
151 pa_sconv_s16le_from_f32ne_neon(SAMPLES, floats, samples);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
152
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
153 for (i = 0; i < SAMPLES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
154 if (abs(samples[i] - samples_ref[i]) > 0) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
155 pa_log_debug("%d: %d != %d (%f)", i, samples[i], samples_ref[i],
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
156 floats[i]);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
157 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
158 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
159
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
160 start = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
161 for (i = 0; i < TIMES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
162 pa_sconv_s16le_from_f32ne_neon(SAMPLES, floats, samples);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
163 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
164 stop = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
165 pa_log_info("NEON: %llu usec.", (long long unsigned int)(stop - start));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
166
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
167 start = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
168 for (i = 0; i < TIMES; i++) {
3
Peter Meerwald <p.meerwald@bct-electronic.com>
parents: 1
diff changeset
169 pa_sconv_s16le_from_float32ne(SAMPLES, floats, samples_ref);
0
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
170 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
171 stop = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
172 pa_log_info("ref: %llu usec.", (long long unsigned int)(stop - start));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
173 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
174
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
175 static void run_test_to(void) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
176 int16_t samples[SAMPLES];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
177 float floats[SAMPLES];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
178 float floats_ref[SAMPLES];
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
179 int i;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
180 pa_usec_t start, stop;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
181 pa_convert_func_t func;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
182
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
183 pa_log_debug("checking NEON sconv_s16le_to_float(%d)", SAMPLES);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
184
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
185 memset(floats_ref, 0, sizeof(floats_ref));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
186 memset(floats, 0, sizeof(float));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
187
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
188 for (i = 0; i < SAMPLES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
189 samples[i] = rand() - RAND_MAX/2;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
190 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
191
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
192 func = (pa_convert_func_t) pa_sconv_s16le_to_float32ne;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
193 func(SAMPLES, samples, floats_ref);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
194 pa_sconv_s16le_to_f32ne_neon(SAMPLES, samples, floats);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
195
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
196 for (i = 0; i < SAMPLES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
197 if (fabsf(floats[i] - floats_ref[i]) > 0.00001) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
198 pa_log_debug("%d: %.8f != %.8f (%d)", i, floats[i], floats_ref[i],
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
199 samples[i]);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
200 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
201 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
202
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
203 start = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
204 for (i = 0; i < TIMES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
205 pa_sconv_s16le_to_f32ne_neon(SAMPLES, samples, floats);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
206 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
207 stop = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
208 pa_log_info("NEON: %llu usec.", (long long unsigned int)(stop - start));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
209
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
210 start = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
211 for (i = 0; i < TIMES; i++) {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
212 func(SAMPLES, samples, floats_ref);
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
213 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
214 stop = pa_rtclock_now();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
215 pa_log_info("ref: %llu usec.", (long long unsigned int)(stop - start));
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
216 }
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
217
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
218 #endif /* defined(__arm__) */
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
219
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
220 int main() {
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
221
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
222 run_test_from();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
223 run_test_to();
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
224
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
225 return EXIT_SUCCESS;
Peter Meerwald <p.meerwald@bct-electronic.com>
parents:
diff changeset
226 }

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