Project Ne10
An Open Optimized Software Library Project for the ARM Architecture
NE10_types.h
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 
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 
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 
63 // constant values that are used across the library
65 #define NE10_OK 0
66 #define NE10_ERR -1
67 
69 // some external definitions to be exposed to the users
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 
87 typedef struct
88 {
89  ne10_float32_t x;
90  ne10_float32_t y;
91 } ne10_vec2f_t;
92 
96 typedef struct
97 {
98  ne10_float32_t x;
99  ne10_float32_t y;
100  ne10_float32_t z;
101 } ne10_vec3f_t;
102 
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 
115 // definitions for matrix
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 
223 // definitions for fft
225 
229 #define NE10_MAXFACTORS 32
230 typedef struct
231 {
232  ne10_float32_t r;
233  ne10_float32_t i;
235 
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;
255  ne10_int32_t is_forward_scaled;
264  ne10_int32_t is_backward_scaled;
266 
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
291 
293 
297 typedef struct
298 {
299  ne10_int16_t r;
300  ne10_int16_t i;
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;
310 
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;
322 
324 
328 typedef struct
329 {
330  ne10_int32_t r;
331  ne10_int32_t i;
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;
342 
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;
354 
356 
358 // definitions for fir
360 
364 typedef struct
365 {
366  ne10_uint16_t numTaps;
367  ne10_float32_t *pState;
368  ne10_float32_t *pCoeffs;
370 
374 typedef struct
375 {
376  ne10_uint16_t numStages;
377  ne10_float32_t *pState;
378  ne10_float32_t *pCoeffs;
380 
384 typedef struct
385 {
386  ne10_uint8_t M;
387  ne10_uint16_t numTaps;
388  ne10_float32_t *pCoeffs;
389  ne10_float32_t *pState;
391 
395 typedef struct
396 {
397  ne10_uint8_t L;
398  ne10_uint16_t phaseLength;
399  ne10_float32_t *pCoeffs;
400  ne10_float32_t *pState;
402 
406 typedef struct
407 {
408  ne10_uint16_t numTaps;
409  ne10_uint16_t stateIndex;
410  ne10_float32_t *pState;
411  ne10_float32_t *pCoeffs;
412  ne10_uint16_t maxDelay;
413  ne10_int32_t *pTapDelay;
415 
419 typedef struct
420 {
421  ne10_uint16_t numStages;
422  ne10_float32_t *pState;
423  ne10_float32_t *pkCoeffs;
424  ne10_float32_t *pvCoeffs;
426 
428 // definitions for imgproc module
430 
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
structure for the 16 bits fixed point FFT function.
Definition: NE10_types.h:297
ne10_int32_t is_backward_scaled
Flag to control scaling behaviour in backward floating point complex FFT.
Definition: NE10_types.h:264
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition: NE10_types.h:388
Instance structure for the floating-point FIR Sparse filter.
Definition: NE10_types.h:406
ne10_uint16_t numTaps
Length of the filter.
Definition: NE10_types.h:387
a 2-tuple of ne10_float32_t values.
Definition: NE10_types.h:87
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition: NE10_types.h:378
ne10_uint16_t phaseLength
Length of each polyphase filter component.
Definition: NE10_types.h:398
structure for the floating point FFT state
Definition: NE10_types.h:240
ne10_uint16_t numStages
numStages of the of lattice filter.
Definition: NE10_types.h:421
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:410
ne10_float32_t * pkCoeffs
Points to the reflection coefficient array.
Definition: NE10_types.h:423
ne10_uint16_t numTaps
Length of the filter.
Definition: NE10_types.h:366
Instance structure for the floating point IIR Lattice filter.
Definition: NE10_types.h:419
Instance structure for the floating-point FIR Interpolation.
Definition: NE10_types.h:395
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:377
Instance structure for the floating-point FIR filter.
Definition: NE10_types.h:364
ne10_float32_t * pvCoeffs
Points to the ladder coefficient array.
Definition: NE10_types.h:424
ne10_uint8_t L
Interpolation Factor.
Definition: NE10_types.h:397
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:389
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition: NE10_types.h:399
structure for the 32 bits fixed point FFT function.
Definition: NE10_types.h:328
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition: NE10_types.h:368
a 3-tuple of ne10_float32_t values.
Definition: NE10_types.h:96
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:367
Instance structure for the floating point FIR Lattice filter.
Definition: NE10_types.h:374
ne10_float32_t * pCoeffs
Points to the coefficient array.
Definition: NE10_types.h:411
Instance structure for the floating-point FIR Decimation.
Definition: NE10_types.h:384
ne10_uint16_t numTaps
Length of the filter.
Definition: NE10_types.h:408
Structure for point in image.
Definition: NE10_types.h:434
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:422
ne10_uint16_t numStages
numStages of the of lattice filter.
Definition: NE10_types.h:376
ne10_uint16_t maxDelay
the largest number of delay line values .
Definition: NE10_types.h:412
ne10_float32_t * pState
Points to the state variable array.
Definition: NE10_types.h:400
ne10_int32_t * pTapDelay
Pointer to the array containing positions of the non-zero tap values.
Definition: NE10_types.h:413
ne10_uint8_t M
Decimation Factor.
Definition: NE10_types.h:386
ne10_uint16_t stateIndex
Index pointer for the state buffer .
Definition: NE10_types.h:409
ne10_int32_t is_forward_scaled
Flag to control scaling behaviour in forward floating point complex FFT.
Definition: NE10_types.h:255
a 4-tuple of ne10_float32_t values.
Definition: NE10_types.h:106