Mercurial > hg > beaglert
comparison include/ne10/NE10_types.h @ 379:24c3a0663d54 prerelease
Added Ne10 headers within include directory
author | andrewm |
---|---|
date | Sun, 12 Jun 2016 18:16:20 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
378:8db03611ee76 | 379:24c3a0663d54 |
---|---|
1 /* | |
2 * Copyright 2011-15 ARM Limited and Contributors. | |
3 * All rights reserved. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions are met: | |
7 * * Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * * Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * * Neither the name of ARM Limited nor the | |
13 * names of its contributors may be used to endorse or promote products | |
14 * derived from this software without specific prior written permission. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY ARM LIMITED AND CONTRIBUTORS "AS IS" AND | |
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
19 * DISCLAIMED. IN NO EVENT SHALL ARM LIMITED AND CONTRIBUTORS BE LIABLE FOR ANY | |
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 | |
28 /* | |
29 * NE10 Library : inc/NE10_types.h | |
30 */ | |
31 | |
32 /** NE10 defines a number of types for use in its function signatures. | |
33 * The types are defined within this header file. | |
34 */ | |
35 | |
36 #ifndef NE10_TYPES_H | |
37 #define NE10_TYPES_H | |
38 | |
39 #include <stdio.h> | |
40 #include <stdlib.h> | |
41 #include <stdint.h> | |
42 #include <math.h> | |
43 #include <string.h> | |
44 #include <assert.h> | |
45 | |
46 /** | |
47 * @TODO Move the definition of NE10_UNROLL_LEVEL to cmake configuration files. | |
48 * Macro NE10_UNROLL_LEVEL controls algorithm of FFT funtions. | |
49 * When NE10_UNROLL_LEVEL == 0, complex FFT performs radix-4 x2 per loop. | |
50 * When NE10_UNROLL_LEVEL == 1, complex FFT performs radix-4 x4 per loop. | |
51 */ | |
52 #if !defined(NE10_UNROLL_LEVEL) | |
53 #if defined(__arm__) | |
54 #define NE10_UNROLL_LEVEL 0 | |
55 #elif defined(__aarch64__) | |
56 #define NE10_UNROLL_LEVEL 1 | |
57 #else | |
58 #define NE10_UNROLL_LEVEL 0 | |
59 #endif | |
60 #endif | |
61 | |
62 ///////////////////////////////////////////////////////// | |
63 // constant values that are used across the library | |
64 ///////////////////////////////////////////////////////// | |
65 #define NE10_OK 0 | |
66 #define NE10_ERR -1 | |
67 | |
68 ///////////////////////////////////////////////////////// | |
69 // some external definitions to be exposed to the users | |
70 ///////////////////////////////////////////////////////// | |
71 | |
72 typedef signed char ne10_int8_t; | |
73 typedef unsigned char ne10_uint8_t; | |
74 typedef signed short ne10_int16_t; | |
75 typedef unsigned short ne10_uint16_t; | |
76 typedef signed int ne10_int32_t; | |
77 typedef unsigned int ne10_uint32_t; | |
78 typedef signed long long int ne10_int64_t; | |
79 typedef unsigned long long int ne10_uint64_t; | |
80 typedef float ne10_float32_t; | |
81 typedef double ne10_float64_t; | |
82 typedef int ne10_result_t; // resulting [error-]code | |
83 | |
84 /** | |
85 * @brief a 2-tuple of ne10_float32_t values. | |
86 */ | |
87 typedef struct | |
88 { | |
89 ne10_float32_t x; | |
90 ne10_float32_t y; | |
91 } ne10_vec2f_t; | |
92 | |
93 /** | |
94 * @brief a 3-tuple of ne10_float32_t values. | |
95 */ | |
96 typedef struct | |
97 { | |
98 ne10_float32_t x; | |
99 ne10_float32_t y; | |
100 ne10_float32_t z; | |
101 } ne10_vec3f_t; | |
102 | |
103 /** | |
104 * @brief a 4-tuple of ne10_float32_t values. | |
105 */ | |
106 typedef struct | |
107 { | |
108 ne10_float32_t x; | |
109 ne10_float32_t y; | |
110 ne10_float32_t z; | |
111 ne10_float32_t w; | |
112 } ne10_vec4f_t; | |
113 | |
114 ///////////////////////////////////////////////////////// | |
115 // definitions for matrix | |
116 ///////////////////////////////////////////////////////// | |
117 | |
118 typedef struct | |
119 { | |
120 ne10_float32_t r1; | |
121 ne10_float32_t r2; | |
122 } __attribute__ ( (packed)) ne10_mat_row2f; | |
123 | |
124 typedef struct | |
125 { | |
126 ne10_mat_row2f c1; | |
127 ne10_mat_row2f c2; | |
128 | |
129 } __attribute__ ( (packed)) ne10_mat2x2f_t; // a 2x2 matrix | |
130 | |
131 static inline void createColumnMajorMatrix2x2 (ne10_mat2x2f_t * outMat, ne10_float32_t m11, ne10_float32_t m21, ne10_float32_t m12, ne10_float32_t m22) | |
132 { | |
133 assert (NULL != outMat); | |
134 | |
135 outMat->c1.r1 = m11; | |
136 outMat->c1.r2 = m21; | |
137 outMat->c2.r1 = m12; | |
138 outMat->c2.r2 = m22; | |
139 } | |
140 | |
141 | |
142 typedef struct | |
143 { | |
144 ne10_float32_t r1; | |
145 ne10_float32_t r2; | |
146 ne10_float32_t r3; | |
147 } __attribute__ ( (packed)) ne10_mat_row3f; | |
148 | |
149 typedef struct | |
150 { | |
151 ne10_mat_row3f c1; | |
152 ne10_mat_row3f c2; | |
153 ne10_mat_row3f c3; | |
154 | |
155 } __attribute__ ( (packed)) ne10_mat3x3f_t; // a 3x3 matrix | |
156 | |
157 static inline void createColumnMajorMatrix3x3 (ne10_mat3x3f_t * outMat, ne10_float32_t m11, ne10_float32_t m21, ne10_float32_t m31, | |
158 ne10_float32_t m12, ne10_float32_t m22, ne10_float32_t m32, | |
159 ne10_float32_t m13, ne10_float32_t m23, ne10_float32_t m33) | |
160 { | |
161 assert (NULL != outMat); | |
162 | |
163 outMat->c1.r1 = m11; | |
164 outMat->c1.r2 = m21; | |
165 outMat->c1.r3 = m31; | |
166 | |
167 outMat->c2.r1 = m12; | |
168 outMat->c2.r2 = m22; | |
169 outMat->c2.r3 = m32; | |
170 | |
171 outMat->c3.r1 = m13; | |
172 outMat->c3.r2 = m23; | |
173 outMat->c3.r3 = m33; | |
174 } | |
175 | |
176 | |
177 typedef struct | |
178 { | |
179 ne10_float32_t r1; | |
180 ne10_float32_t r2; | |
181 ne10_float32_t r3; | |
182 ne10_float32_t r4; | |
183 } __attribute__ ( (packed)) ne10_mat_row4f; | |
184 | |
185 typedef struct | |
186 { | |
187 ne10_mat_row4f c1; | |
188 ne10_mat_row4f c2; | |
189 ne10_mat_row4f c3; | |
190 ne10_mat_row4f c4; | |
191 | |
192 } __attribute__ ( (packed)) ne10_mat4x4f_t; // a 4x4 matrix | |
193 | |
194 static inline void createColumnMajorMatrix4x4 (ne10_mat4x4f_t * outMat, ne10_float32_t m11, ne10_float32_t m21, ne10_float32_t m31, ne10_float32_t m41, | |
195 ne10_float32_t m12, ne10_float32_t m22, ne10_float32_t m32, ne10_float32_t m42, | |
196 ne10_float32_t m13, ne10_float32_t m23, ne10_float32_t m33, ne10_float32_t m43, | |
197 ne10_float32_t m14, ne10_float32_t m24, ne10_float32_t m34, ne10_float32_t m44) | |
198 { | |
199 assert (NULL != outMat); | |
200 | |
201 outMat->c1.r1 = m11; | |
202 outMat->c1.r2 = m21; | |
203 outMat->c1.r3 = m31; | |
204 outMat->c1.r4 = m41; | |
205 | |
206 outMat->c2.r1 = m12; | |
207 outMat->c2.r2 = m22; | |
208 outMat->c2.r3 = m32; | |
209 outMat->c2.r4 = m42; | |
210 | |
211 outMat->c3.r1 = m13; | |
212 outMat->c3.r2 = m23; | |
213 outMat->c3.r3 = m33; | |
214 outMat->c3.r4 = m43; | |
215 | |
216 outMat->c4.r1 = m14; | |
217 outMat->c4.r2 = m24; | |
218 outMat->c4.r3 = m34; | |
219 outMat->c4.r4 = m44; | |
220 } | |
221 | |
222 ///////////////////////////////////////////////////////// | |
223 // definitions for fft | |
224 ///////////////////////////////////////////////////////// | |
225 | |
226 /** | |
227 * @brief structure for the floating point FFT function. | |
228 */ | |
229 #define NE10_MAXFACTORS 32 | |
230 typedef struct | |
231 { | |
232 ne10_float32_t r; | |
233 ne10_float32_t i; | |
234 } ne10_fft_cpx_float32_t; | |
235 | |
236 /** | |
237 * @brief structure for the floating point FFT state | |
238 * | |
239 */ | |
240 typedef struct | |
241 { | |
242 ne10_int32_t nfft; | |
243 ne10_int32_t *factors; | |
244 ne10_fft_cpx_float32_t *twiddles; | |
245 ne10_fft_cpx_float32_t *buffer; | |
246 ne10_fft_cpx_float32_t *last_twiddles; | |
247 /** | |
248 * @biref Flag to control scaling behaviour in forward floating point complex FFT. | |
249 * @note If is_forward_scaled is set 0, Ne10 will not scale output of forward floating | |
250 * point complex FFT. Otherwise, Ne10 will scale output of forward floating | |
251 * point complex FFT. | |
252 * @warning | |
253 * Only non-power-of-2 FFT is affected by this flag. | |
254 */ | |
255 ne10_int32_t is_forward_scaled; | |
256 /** | |
257 * @biref Flag to control scaling behaviour in backward floating point complex FFT. | |
258 * @note If is_backward_scaled is set 0, Ne10 will not scale output of backward floating | |
259 * point complex FFT. Otherwise, Ne10 will scale output of backward floating | |
260 * point complex FFT. | |
261 * @warning | |
262 * Only non-power-of-2 FFT is affected by this flag. | |
263 */ | |
264 ne10_int32_t is_backward_scaled; | |
265 } ne10_fft_state_float32_t; | |
266 | |
267 /** | |
268 * @brief Configure for floating point FFT. | |
269 */ | |
270 typedef ne10_fft_state_float32_t* ne10_fft_cfg_float32_t; | |
271 | |
272 typedef struct | |
273 { | |
274 ne10_fft_cpx_float32_t *buffer; | |
275 #if (NE10_UNROLL_LEVEL == 0) | |
276 ne10_int32_t ncfft; | |
277 ne10_int32_t *factors; | |
278 ne10_fft_cpx_float32_t *twiddles; | |
279 ne10_fft_cpx_float32_t *super_twiddles; | |
280 #elif (NE10_UNROLL_LEVEL > 0) | |
281 ne10_int32_t nfft; | |
282 ne10_fft_cpx_float32_t *r_twiddles; | |
283 ne10_int32_t *r_factors; | |
284 ne10_fft_cpx_float32_t *r_twiddles_backward; | |
285 ne10_fft_cpx_float32_t *r_twiddles_neon; | |
286 ne10_fft_cpx_float32_t *r_twiddles_neon_backward; | |
287 ne10_int32_t *r_factors_neon; | |
288 ne10_fft_cpx_float32_t *r_super_twiddles_neon; | |
289 #endif | |
290 } ne10_fft_r2c_state_float32_t; | |
291 | |
292 typedef ne10_fft_r2c_state_float32_t* ne10_fft_r2c_cfg_float32_t; | |
293 | |
294 /** | |
295 * @brief structure for the 16 bits fixed point FFT function. | |
296 */ | |
297 typedef struct | |
298 { | |
299 ne10_int16_t r; | |
300 ne10_int16_t i; | |
301 } ne10_fft_cpx_int16_t; | |
302 | |
303 typedef struct | |
304 { | |
305 ne10_int32_t nfft; | |
306 ne10_int32_t *factors; | |
307 ne10_fft_cpx_int16_t *twiddles; | |
308 ne10_fft_cpx_int16_t *buffer; | |
309 } ne10_fft_state_int16_t; | |
310 | |
311 typedef ne10_fft_state_int16_t* ne10_fft_cfg_int16_t; | |
312 | |
313 typedef struct | |
314 { | |
315 ne10_int32_t nfft; | |
316 ne10_int32_t ncfft; | |
317 ne10_int32_t *factors; | |
318 ne10_fft_cpx_int16_t *twiddles; | |
319 ne10_fft_cpx_int16_t *super_twiddles; | |
320 ne10_fft_cpx_int16_t *buffer; | |
321 } ne10_fft_r2c_state_int16_t; | |
322 | |
323 typedef ne10_fft_r2c_state_int16_t* ne10_fft_r2c_cfg_int16_t; | |
324 | |
325 /** | |
326 * @brief structure for the 32 bits fixed point FFT function. | |
327 */ | |
328 typedef struct | |
329 { | |
330 ne10_int32_t r; | |
331 ne10_int32_t i; | |
332 } ne10_fft_cpx_int32_t; | |
333 | |
334 typedef struct | |
335 { | |
336 ne10_int32_t nfft; | |
337 ne10_int32_t *factors; | |
338 ne10_fft_cpx_int32_t *twiddles; | |
339 ne10_fft_cpx_int32_t *buffer; | |
340 ne10_fft_cpx_int32_t *last_twiddles; | |
341 } ne10_fft_state_int32_t; | |
342 | |
343 typedef ne10_fft_state_int32_t* ne10_fft_cfg_int32_t; | |
344 | |
345 typedef struct | |
346 { | |
347 ne10_int32_t nfft; | |
348 ne10_int32_t ncfft; | |
349 ne10_int32_t *factors; | |
350 ne10_fft_cpx_int32_t *twiddles; | |
351 ne10_fft_cpx_int32_t *super_twiddles; | |
352 ne10_fft_cpx_int32_t *buffer; | |
353 } ne10_fft_r2c_state_int32_t; | |
354 | |
355 typedef ne10_fft_r2c_state_int32_t* ne10_fft_r2c_cfg_int32_t; | |
356 | |
357 ///////////////////////////////////////////////////////// | |
358 // definitions for fir | |
359 ///////////////////////////////////////////////////////// | |
360 | |
361 /** | |
362 * @brief Instance structure for the floating-point FIR filter. | |
363 */ | |
364 typedef struct | |
365 { | |
366 ne10_uint16_t numTaps; /**< Length of the filter. */ | |
367 ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */ | |
368 ne10_float32_t *pCoeffs; /**< Points to the coefficient array. The array is of length numTaps. */ | |
369 } ne10_fir_instance_f32_t; | |
370 | |
371 /** | |
372 * @brief Instance structure for the floating point FIR Lattice filter. | |
373 */ | |
374 typedef struct | |
375 { | |
376 ne10_uint16_t numStages; /**< numStages of the of lattice filter. */ | |
377 ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numStages. */ | |
378 ne10_float32_t *pCoeffs; /**< Points to the coefficient array. The array is of length numStages. */ | |
379 } ne10_fir_lattice_instance_f32_t; | |
380 | |
381 /** | |
382 * @brief Instance structure for the floating-point FIR Decimation. | |
383 */ | |
384 typedef struct | |
385 { | |
386 ne10_uint8_t M; /**< Decimation Factor. */ | |
387 ne10_uint16_t numTaps; /**< Length of the filter. */ | |
388 ne10_float32_t *pCoeffs; /**< Points to the coefficient array. The array is of length numTaps.*/ | |
389 ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */ | |
390 } ne10_fir_decimate_instance_f32_t; | |
391 | |
392 /** | |
393 * @brief Instance structure for the floating-point FIR Interpolation. | |
394 */ | |
395 typedef struct | |
396 { | |
397 ne10_uint8_t L; /**< Interpolation Factor. */ | |
398 ne10_uint16_t phaseLength; /**< Length of each polyphase filter component. */ | |
399 ne10_float32_t *pCoeffs; /**< Points to the coefficient array. The array is of length numTaps.*/ | |
400 ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */ | |
401 } ne10_fir_interpolate_instance_f32_t; | |
402 | |
403 /** | |
404 * @brief Instance structure for the floating-point FIR Sparse filter. | |
405 */ | |
406 typedef struct | |
407 { | |
408 ne10_uint16_t numTaps; /**< Length of the filter. */ | |
409 ne10_uint16_t stateIndex; /**< Index pointer for the state buffer .*/ | |
410 ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */ | |
411 ne10_float32_t *pCoeffs; /**< Points to the coefficient array. The array is of length numTaps.*/ | |
412 ne10_uint16_t maxDelay; /**< the largest number of delay line values .*/ | |
413 ne10_int32_t *pTapDelay; /**< Pointer to the array containing positions of the non-zero tap values. */ | |
414 } ne10_fir_sparse_instance_f32_t; | |
415 | |
416 /** | |
417 * @brief Instance structure for the floating point IIR Lattice filter. | |
418 */ | |
419 typedef struct | |
420 { | |
421 ne10_uint16_t numStages; /**< numStages of the of lattice filter. */ | |
422 ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numStages + blockSize -1. */ | |
423 ne10_float32_t *pkCoeffs; /**< Points to the reflection coefficient array. The array is of length numStages. */ | |
424 ne10_float32_t *pvCoeffs; /**< Points to the ladder coefficient array. The array is of length numStages+1. */ | |
425 } ne10_iir_lattice_instance_f32_t; | |
426 | |
427 ///////////////////////////////////////////////////////// | |
428 // definitions for imgproc module | |
429 ///////////////////////////////////////////////////////// | |
430 | |
431 /** | |
432 * @brief Structure for point in image | |
433 */ | |
434 typedef struct | |
435 { | |
436 ne10_uint32_t x; | |
437 ne10_uint32_t y; | |
438 } ne10_point_t; | |
439 | |
440 typedef struct | |
441 { | |
442 ne10_uint32_t x; | |
443 ne10_uint32_t y; | |
444 } ne10_size_t; | |
445 | |
446 typedef enum | |
447 { | |
448 UBUNTU_COMMAND_LINE, | |
449 ANDROID_DEMO, | |
450 IOS_DEMO | |
451 } ne10_print_target_t; | |
452 | |
453 #endif |