File: NE10_types.h

package info (click to toggle)
ne10 1.2.1-4
  • links: PTS
  • area: main
  • in suites: buster
  • size: 7,676 kB
  • sloc: ansic: 26,841; asm: 8,546; cpp: 2,428; python: 342; sh: 135; objc: 105; xml: 63; java: 35; makefile: 12
file content (453 lines) | stat: -rw-r--r-- 13,761 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
/*
 *  Copyright 2011-15 ARM Limited and Contributors.
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *    * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *    * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *    * Neither the name of ARM Limited nor the
 *      names of its contributors may be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY ARM LIMITED AND CONTRIBUTORS "AS IS" AND
 *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *  DISCLAIMED. IN NO EVENT SHALL ARM LIMITED AND CONTRIBUTORS BE LIABLE FOR ANY
 *  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * NE10 Library : inc/NE10_types.h
 */

/** NE10 defines a number of types for use in its function signatures.
 *  The types are defined within this header file.
 */

#ifndef NE10_TYPES_H
#define NE10_TYPES_H

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
#include <assert.h>

/**
 * @TODO Move the definition of NE10_UNROLL_LEVEL to cmake configuration files.
 * Macro NE10_UNROLL_LEVEL controls algorithm of FFT funtions.
 * When NE10_UNROLL_LEVEL == 0, complex FFT performs radix-4 x2 per loop.
 * When NE10_UNROLL_LEVEL == 1, complex FFT performs radix-4 x4 per loop.
 */
#if !defined(NE10_UNROLL_LEVEL)
#if defined(__arm__)
#define NE10_UNROLL_LEVEL 0
#elif defined(__aarch64__)
#define NE10_UNROLL_LEVEL 1
#else
#define NE10_UNROLL_LEVEL 0
#endif
#endif

/////////////////////////////////////////////////////////
// constant values that are used across the library
/////////////////////////////////////////////////////////
#define NE10_OK 0
#define NE10_ERR -1

/////////////////////////////////////////////////////////
// some external definitions to be exposed to the users
/////////////////////////////////////////////////////////

typedef signed char             ne10_int8_t;
typedef unsigned char           ne10_uint8_t;
typedef signed short            ne10_int16_t;
typedef unsigned short          ne10_uint16_t;
typedef signed int              ne10_int32_t;
typedef unsigned int            ne10_uint32_t;
typedef signed long long int    ne10_int64_t;
typedef unsigned long long int  ne10_uint64_t;
typedef float                   ne10_float32_t;
typedef double                  ne10_float64_t;
typedef int                     ne10_result_t;     // resulting [error-]code

/**
 * @brief a 2-tuple of ne10_float32_t values.
 */
typedef struct
{
    ne10_float32_t x;
    ne10_float32_t y;
} ne10_vec2f_t;

/**
 * @brief a 3-tuple of ne10_float32_t values.
 */
typedef struct
{
    ne10_float32_t x;
    ne10_float32_t y;
    ne10_float32_t z;
} ne10_vec3f_t;

/**
 * @brief a 4-tuple of ne10_float32_t values.
 */
typedef struct
{
    ne10_float32_t x;
    ne10_float32_t y;
    ne10_float32_t z;
    ne10_float32_t w;
} ne10_vec4f_t;

/////////////////////////////////////////////////////////
// definitions for matrix
/////////////////////////////////////////////////////////

typedef struct
{
    ne10_float32_t r1;
    ne10_float32_t r2;
} __attribute__ ( (packed)) ne10_mat_row2f;

typedef struct
{
    ne10_mat_row2f c1;
    ne10_mat_row2f c2;

} __attribute__ ( (packed)) ne10_mat2x2f_t;   // a 2x2 matrix

static inline void createColumnMajorMatrix2x2 (ne10_mat2x2f_t * outMat, ne10_float32_t m11, ne10_float32_t m21, ne10_float32_t m12, ne10_float32_t m22)
{
    assert (NULL != outMat);

    outMat->c1.r1 = m11;
    outMat->c1.r2 = m21;
    outMat->c2.r1 = m12;
    outMat->c2.r2 = m22;
}


typedef struct
{
    ne10_float32_t r1;
    ne10_float32_t r2;
    ne10_float32_t r3;
} __attribute__ ( (packed)) ne10_mat_row3f;

typedef struct
{
    ne10_mat_row3f c1;
    ne10_mat_row3f c2;
    ne10_mat_row3f c3;

} __attribute__ ( (packed)) ne10_mat3x3f_t;   // a 3x3 matrix

static inline void createColumnMajorMatrix3x3 (ne10_mat3x3f_t * outMat, ne10_float32_t m11, ne10_float32_t m21, ne10_float32_t m31,
        ne10_float32_t m12, ne10_float32_t m22, ne10_float32_t m32,
        ne10_float32_t m13, ne10_float32_t m23, ne10_float32_t m33)
{
    assert (NULL != outMat);

    outMat->c1.r1 = m11;
    outMat->c1.r2 = m21;
    outMat->c1.r3 = m31;

    outMat->c2.r1 = m12;
    outMat->c2.r2 = m22;
    outMat->c2.r3 = m32;

    outMat->c3.r1 = m13;
    outMat->c3.r2 = m23;
    outMat->c3.r3 = m33;
}


typedef struct
{
    ne10_float32_t r1;
    ne10_float32_t r2;
    ne10_float32_t r3;
    ne10_float32_t r4;
} __attribute__ ( (packed)) ne10_mat_row4f;

typedef struct
{
    ne10_mat_row4f c1;
    ne10_mat_row4f c2;
    ne10_mat_row4f c3;
    ne10_mat_row4f c4;

} __attribute__ ( (packed)) ne10_mat4x4f_t;   // a 4x4 matrix

static inline void createColumnMajorMatrix4x4 (ne10_mat4x4f_t * outMat, ne10_float32_t m11, ne10_float32_t m21, ne10_float32_t m31, ne10_float32_t m41,
        ne10_float32_t m12, ne10_float32_t m22, ne10_float32_t m32, ne10_float32_t m42,
        ne10_float32_t m13, ne10_float32_t m23, ne10_float32_t m33, ne10_float32_t m43,
        ne10_float32_t m14, ne10_float32_t m24, ne10_float32_t m34, ne10_float32_t m44)
{
    assert (NULL != outMat);

    outMat->c1.r1 = m11;
    outMat->c1.r2 = m21;
    outMat->c1.r3 = m31;
    outMat->c1.r4 = m41;

    outMat->c2.r1 = m12;
    outMat->c2.r2 = m22;
    outMat->c2.r3 = m32;
    outMat->c2.r4 = m42;

    outMat->c3.r1 = m13;
    outMat->c3.r2 = m23;
    outMat->c3.r3 = m33;
    outMat->c3.r4 = m43;

    outMat->c4.r1 = m14;
    outMat->c4.r2 = m24;
    outMat->c4.r3 = m34;
    outMat->c4.r4 = m44;
}

/////////////////////////////////////////////////////////
// definitions for fft
/////////////////////////////////////////////////////////

/**
 * @brief structure for the floating point FFT function.
 */
#define NE10_MAXFACTORS             32
typedef struct
{
    ne10_float32_t r;
    ne10_float32_t i;
} ne10_fft_cpx_float32_t;

/**
 * @brief structure for the floating point FFT state
 *
 */
typedef struct
{
    ne10_int32_t nfft;
    ne10_int32_t *factors;
    ne10_fft_cpx_float32_t *twiddles;
    ne10_fft_cpx_float32_t *buffer;
    ne10_fft_cpx_float32_t *last_twiddles;
    /**
     *  @biref Flag to control scaling behaviour in forward floating point complex FFT.
     *  @note If is_forward_scaled is set 0, Ne10 will not scale output of forward floating
     *  point complex FFT. Otherwise, Ne10 will scale output of forward floating
     *  point complex FFT.
     *  @warning
     *  Only non-power-of-2 FFT is affected by this flag.
     */
    ne10_int32_t is_forward_scaled;
    /**
     *  @biref Flag to control scaling behaviour in backward floating point complex FFT.
     *  @note If is_backward_scaled is set 0, Ne10 will not scale output of backward floating
     *  point complex FFT. Otherwise, Ne10 will scale output of backward floating
     *  point complex FFT.
     *  @warning
     *  Only non-power-of-2 FFT is affected by this flag.
     */
    ne10_int32_t is_backward_scaled;
} ne10_fft_state_float32_t;

/**
 * @brief Configure for floating point FFT.
 */
typedef ne10_fft_state_float32_t* ne10_fft_cfg_float32_t;

typedef struct
{
    ne10_fft_cpx_float32_t *buffer;
#if (NE10_UNROLL_LEVEL == 0)
    ne10_int32_t ncfft;
    ne10_int32_t *factors;
    ne10_fft_cpx_float32_t *twiddles;
    ne10_fft_cpx_float32_t *super_twiddles;
#elif (NE10_UNROLL_LEVEL > 0)
    ne10_int32_t nfft;
    ne10_fft_cpx_float32_t *r_twiddles;
    ne10_int32_t *r_factors;
    ne10_fft_cpx_float32_t *r_twiddles_backward;
    ne10_fft_cpx_float32_t *r_twiddles_neon;
    ne10_fft_cpx_float32_t *r_twiddles_neon_backward;
    ne10_int32_t *r_factors_neon;
    ne10_fft_cpx_float32_t *r_super_twiddles_neon;
#endif
} ne10_fft_r2c_state_float32_t;

typedef ne10_fft_r2c_state_float32_t* ne10_fft_r2c_cfg_float32_t;

/**
 * @brief structure for the 16 bits fixed point FFT function.
 */
typedef struct
{
    ne10_int16_t r;
    ne10_int16_t i;
} ne10_fft_cpx_int16_t;

typedef struct
{
    ne10_int32_t nfft;
    ne10_int32_t *factors;
    ne10_fft_cpx_int16_t *twiddles;
    ne10_fft_cpx_int16_t *buffer;
} ne10_fft_state_int16_t;

typedef ne10_fft_state_int16_t* ne10_fft_cfg_int16_t;

typedef struct
{
    ne10_int32_t nfft;
    ne10_int32_t ncfft;
    ne10_int32_t *factors;
    ne10_fft_cpx_int16_t *twiddles;
    ne10_fft_cpx_int16_t *super_twiddles;
    ne10_fft_cpx_int16_t *buffer;
} ne10_fft_r2c_state_int16_t;

typedef ne10_fft_r2c_state_int16_t* ne10_fft_r2c_cfg_int16_t;

/**
 * @brief structure for the 32 bits fixed point FFT function.
 */
typedef struct
{
    ne10_int32_t r;
    ne10_int32_t i;
} ne10_fft_cpx_int32_t;

typedef struct
{
    ne10_int32_t nfft;
    ne10_int32_t *factors;
    ne10_fft_cpx_int32_t *twiddles;
    ne10_fft_cpx_int32_t *buffer;
    ne10_fft_cpx_int32_t *last_twiddles;
} ne10_fft_state_int32_t;

typedef ne10_fft_state_int32_t* ne10_fft_cfg_int32_t;

typedef struct
{
    ne10_int32_t nfft;
    ne10_int32_t ncfft;
    ne10_int32_t *factors;
    ne10_fft_cpx_int32_t *twiddles;
    ne10_fft_cpx_int32_t *super_twiddles;
    ne10_fft_cpx_int32_t *buffer;
} ne10_fft_r2c_state_int32_t;

typedef ne10_fft_r2c_state_int32_t* ne10_fft_r2c_cfg_int32_t;

/////////////////////////////////////////////////////////
// definitions for fir
/////////////////////////////////////////////////////////

/**
 * @brief Instance structure for the floating-point FIR filter.
 */
typedef struct
{
    ne10_uint16_t numTaps;    /**< Length of the filter. */
    ne10_float32_t *pState;    /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */
    ne10_float32_t *pCoeffs;   /**< Points to the coefficient array. The array is of length numTaps. */
} ne10_fir_instance_f32_t;

/**
 * @brief Instance structure for the floating point FIR Lattice filter.
 */
typedef struct
{
    ne10_uint16_t numStages;    /**< numStages of the of lattice filter. */
    ne10_float32_t *pState;      /**< Points to the state variable array. The array is of length numStages. */
    ne10_float32_t *pCoeffs;     /**< Points to the coefficient array. The array is of length numStages. */
} ne10_fir_lattice_instance_f32_t;

/**
 * @brief Instance structure for the floating-point FIR Decimation.
 */
typedef struct
{
    ne10_uint8_t  M;            /**< Decimation Factor. */
    ne10_uint16_t numTaps;      /**< Length of the filter. */
    ne10_float32_t    *pCoeffs;      /**< Points to the coefficient array. The array is of length numTaps.*/
    ne10_float32_t    *pState;       /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */
} ne10_fir_decimate_instance_f32_t;

/**
 * @brief Instance structure for the floating-point FIR Interpolation.
 */
typedef struct
{
    ne10_uint8_t L;             /**< Interpolation Factor. */
    ne10_uint16_t phaseLength;  /**< Length of each polyphase filter component. */
    ne10_float32_t *pCoeffs;         /**< Points to the coefficient array. The array is of length numTaps.*/
    ne10_float32_t *pState;          /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */
} ne10_fir_interpolate_instance_f32_t;

/**
 * @brief Instance structure for the floating-point FIR Sparse filter.
 */
typedef struct
{
    ne10_uint16_t numTaps;      /**< Length of the filter. */
    ne10_uint16_t stateIndex;   /**< Index pointer for the state buffer .*/
    ne10_float32_t *pState;          /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */
    ne10_float32_t *pCoeffs;         /**< Points to the coefficient array. The array is of length numTaps.*/
    ne10_uint16_t  maxDelay;    /**< the largest number of delay line values .*/
    ne10_int32_t  *pTapDelay;    /**< Pointer to the array containing positions of the non-zero tap values. */
} ne10_fir_sparse_instance_f32_t;

/**
   * @brief Instance structure for the floating point IIR Lattice filter.
   */
typedef struct
{
    ne10_uint16_t numStages;    /**< numStages of the of lattice filter. */
    ne10_float32_t *pState;      /**< Points to the state variable array. The array is of length numStages + blockSize -1. */
    ne10_float32_t *pkCoeffs;    /**< Points to the reflection coefficient array. The array is of length numStages. */
    ne10_float32_t *pvCoeffs;    /**< Points to the ladder coefficient array. The array is of length numStages+1. */
} ne10_iir_lattice_instance_f32_t;

/////////////////////////////////////////////////////////
// definitions for imgproc module
/////////////////////////////////////////////////////////

/**
 * @brief Structure for point in image
 */
typedef struct
{
    ne10_uint32_t x;
    ne10_uint32_t y;
} ne10_point_t;

typedef struct
{
    ne10_uint32_t x;
    ne10_uint32_t y;
} ne10_size_t;

typedef enum
{
    UBUNTU_COMMAND_LINE,
    ANDROID_DEMO,
    IOS_DEMO
} ne10_print_target_t;

#endif