]> code.delx.au - pulseaudio/blob - src/modules/echo-cancel/adrian-aec-orc-dist.c
echo-cancel: orc-ify some bits for optimisation
[pulseaudio] / src / modules / echo-cancel / adrian-aec-orc-dist.c
1
2 /* autogenerated from adrian-aec-orc.orc */
3
4 #ifdef HAVE_CONFIG_H
5 #include "config.h"
6 #endif
7 #ifndef DISABLE_ORC
8 #include <orc/orc.h>
9 #endif
10
11 #ifndef _ORC_INTEGER_TYPEDEFS_
12 #define _ORC_INTEGER_TYPEDEFS_
13 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
14 #include <stdint.h>
15 typedef int8_t orc_int8;
16 typedef int16_t orc_int16;
17 typedef int32_t orc_int32;
18 typedef int64_t orc_int64;
19 typedef uint8_t orc_uint8;
20 typedef uint16_t orc_uint16;
21 typedef uint32_t orc_uint32;
22 typedef uint64_t orc_uint64;
23 #elif defined(_MSC_VER)
24 typedef signed __int8 orc_int8;
25 typedef signed __int16 orc_int16;
26 typedef signed __int32 orc_int32;
27 typedef signed __int64 orc_int64;
28 typedef unsigned __int8 orc_uint8;
29 typedef unsigned __int16 orc_uint16;
30 typedef unsigned __int32 orc_uint32;
31 typedef unsigned __int64 orc_uint64;
32 #else
33 #include <limits.h>
34 typedef signed char orc_int8;
35 typedef short orc_int16;
36 typedef int orc_int32;
37 typedef unsigned char orc_uint8;
38 typedef unsigned short orc_uint16;
39 typedef unsigned int orc_uint32;
40 #if INT_MAX == LONG_MAX
41 typedef long long orc_int64;
42 typedef unsigned long long orc_uint64;
43 #else
44 typedef long orc_int64;
45 typedef unsigned long orc_uint64;
46 #endif
47 #endif
48 typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16;
49 typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32;
50 typedef union { orc_int64 i; double f; orc_int32 x2[2]; orc_int16 x4[4]; } orc_union64;
51 #endif
52
53 void update_tap_weights (float * d1, const float * s1, float p1, int n);
54
55
56 /* begin Orc C target preamble */
57 #define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x)))
58 #define ORC_ABS(a) ((a)<0 ? -(a) : (a))
59 #define ORC_MIN(a,b) ((a)<(b) ? (a) : (b))
60 #define ORC_MAX(a,b) ((a)>(b) ? (a) : (b))
61 #define ORC_SB_MAX 127
62 #define ORC_SB_MIN (-1-ORC_SB_MAX)
63 #define ORC_UB_MAX 255
64 #define ORC_UB_MIN 0
65 #define ORC_SW_MAX 32767
66 #define ORC_SW_MIN (-1-ORC_SW_MAX)
67 #define ORC_UW_MAX 65535
68 #define ORC_UW_MIN 0
69 #define ORC_SL_MAX 2147483647
70 #define ORC_SL_MIN (-1-ORC_SL_MAX)
71 #define ORC_UL_MAX 4294967295U
72 #define ORC_UL_MIN 0
73 #define ORC_CLAMP_SB(x) ORC_CLAMP(x,ORC_SB_MIN,ORC_SB_MAX)
74 #define ORC_CLAMP_UB(x) ORC_CLAMP(x,ORC_UB_MIN,ORC_UB_MAX)
75 #define ORC_CLAMP_SW(x) ORC_CLAMP(x,ORC_SW_MIN,ORC_SW_MAX)
76 #define ORC_CLAMP_UW(x) ORC_CLAMP(x,ORC_UW_MIN,ORC_UW_MAX)
77 #define ORC_CLAMP_SL(x) ORC_CLAMP(x,ORC_SL_MIN,ORC_SL_MAX)
78 #define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX)
79 #define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8))
80 #define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24))
81 #define ORC_SWAP_Q(x) ((((x)&0xffULL)<<56) | (((x)&0xff00ULL)<<40) | (((x)&0xff0000ULL)<<24) | (((x)&0xff000000ULL)<<8) | (((x)&0xff00000000ULL)>>8) | (((x)&0xff0000000000ULL)>>24) | (((x)&0xff000000000000ULL)>>40) | (((x)&0xff00000000000000ULL)>>56))
82 #define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset)))
83 #define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff))
84 #define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0))
85 #define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&0x7ff0000000000000ULL) == 0) ? 0xfff0000000000000ULL : 0xffffffffffffffffULL))
86 #define ORC_ISNAN_DOUBLE(x) ((((x)&0x7ff0000000000000ULL) == 0x7ff0000000000000ULL) && (((x)&0x000fffffffffffffULL) != 0))
87 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
88 #define ORC_RESTRICT restrict
89 #elif defined(__GNUC__) && __GNUC__ >= 4
90 #define ORC_RESTRICT __restrict__
91 #else
92 #define ORC_RESTRICT
93 #endif
94 /* end Orc C target preamble */
95
96
97
98 /* update_tap_weights */
99 #ifdef DISABLE_ORC
100 void
101 update_tap_weights (float * d1, const float * s1, float p1, int n){
102 int i;
103 orc_union32 * ORC_RESTRICT ptr0;
104 const orc_union32 * ORC_RESTRICT ptr4;
105 orc_union32 var33;
106 orc_union32 var34;
107 orc_union32 var35;
108 orc_union32 var36;
109 orc_union32 var37;
110
111 ptr0 = (orc_union32 *)d1;
112 ptr4 = (orc_union32 *)s1;
113
114 /* 0: loadpl */
115 var33.i = p1;
116
117 for (i = 0; i < n; i++) {
118 /* 1: loadl */
119 var34 = ptr4[i];
120 /* 2: mulf */
121 {
122 orc_union32 _src1;
123 orc_union32 _src2;
124 orc_union32 _dest1;
125 _src1.i = ORC_DENORMAL(var33.i);
126 _src2.i = ORC_DENORMAL(var34.i);
127 _dest1.f = _src1.f * _src2.f;
128 var37.i = ORC_DENORMAL(_dest1.i);
129 }
130 /* 3: loadl */
131 var35 = ptr0[i];
132 /* 4: addf */
133 {
134 orc_union32 _src1;
135 orc_union32 _src2;
136 orc_union32 _dest1;
137 _src1.i = ORC_DENORMAL(var35.i);
138 _src2.i = ORC_DENORMAL(var37.i);
139 _dest1.f = _src1.f + _src2.f;
140 var36.i = ORC_DENORMAL(_dest1.i);
141 }
142 /* 5: storel */
143 ptr0[i] = var36;
144 }
145
146 }
147
148 #else
149 static void
150 _backup_update_tap_weights (OrcExecutor * ORC_RESTRICT ex)
151 {
152 int i;
153 int n = ex->n;
154 orc_union32 * ORC_RESTRICT ptr0;
155 const orc_union32 * ORC_RESTRICT ptr4;
156 orc_union32 var33;
157 orc_union32 var34;
158 orc_union32 var35;
159 orc_union32 var36;
160 orc_union32 var37;
161
162 ptr0 = (orc_union32 *)ex->arrays[0];
163 ptr4 = (orc_union32 *)ex->arrays[4];
164
165 /* 0: loadpl */
166 var33.i = ex->params[24];
167
168 for (i = 0; i < n; i++) {
169 /* 1: loadl */
170 var34 = ptr4[i];
171 /* 2: mulf */
172 {
173 orc_union32 _src1;
174 orc_union32 _src2;
175 orc_union32 _dest1;
176 _src1.i = ORC_DENORMAL(var33.i);
177 _src2.i = ORC_DENORMAL(var34.i);
178 _dest1.f = _src1.f * _src2.f;
179 var37.i = ORC_DENORMAL(_dest1.i);
180 }
181 /* 3: loadl */
182 var35 = ptr0[i];
183 /* 4: addf */
184 {
185 orc_union32 _src1;
186 orc_union32 _src2;
187 orc_union32 _dest1;
188 _src1.i = ORC_DENORMAL(var35.i);
189 _src2.i = ORC_DENORMAL(var37.i);
190 _dest1.f = _src1.f + _src2.f;
191 var36.i = ORC_DENORMAL(_dest1.i);
192 }
193 /* 5: storel */
194 ptr0[i] = var36;
195 }
196
197 }
198
199 void
200 update_tap_weights (float * d1, const float * s1, float p1, int n)
201 {
202 OrcExecutor _ex, *ex = &_ex;
203 static int p_inited = 0;
204 static OrcProgram *p = 0;
205 void (*func) (OrcExecutor *);
206
207 if (!p_inited) {
208 orc_once_mutex_lock ();
209 if (!p_inited) {
210 OrcCompileResult result;
211
212 p = orc_program_new ();
213 orc_program_set_name (p, "update_tap_weights");
214 orc_program_set_backup_function (p, _backup_update_tap_weights);
215 orc_program_add_destination (p, 4, "d1");
216 orc_program_add_source (p, 4, "s1");
217 orc_program_add_constant (p, 0, 0x00000000, "c1");
218 orc_program_add_constant (p, 0, 0x00000000, "c2");
219 orc_program_add_constant (p, 0, 0x00000000, "c3");
220 orc_program_add_constant (p, 0, 0x00000000, "c4");
221 orc_program_add_constant (p, 0, 0x00000000, "c5");
222 orc_program_add_constant (p, 0, 0x00000000, "c6");
223 orc_program_add_constant (p, 0, 0x00000000, "c7");
224 orc_program_add_constant (p, 0, 0x00000000, "c8");
225 orc_program_add_parameter_float (p, 4, "p1");
226 orc_program_add_temporary (p, 4, "t1");
227
228 orc_program_append_2 (p, "mulf", 0, ORC_VAR_T1, ORC_VAR_P1, ORC_VAR_S1, ORC_VAR_D1);
229 orc_program_append_2 (p, "addf", 0, ORC_VAR_D1, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_D1);
230
231 result = orc_program_compile (p);
232 }
233 p_inited = TRUE;
234 orc_once_mutex_unlock ();
235 }
236 ex->program = p;
237
238 ex->n = n;
239 ex->arrays[ORC_VAR_D1] = d1;
240 ex->arrays[ORC_VAR_S1] = (void *)s1;
241 {
242 orc_union32 tmp;
243 tmp.f = p1;
244 ex->params[ORC_VAR_P1] = tmp.i;
245 }
246
247 func = p->code_exec;
248 func (ex);
249 }
250 #endif